Skip to content

Latest commit

 

History

History
109 lines (95 loc) · 3.63 KB

README.md

File metadata and controls

109 lines (95 loc) · 3.63 KB

Terminal

Elixir Terminal UIs with Reactish API

image

Uses teletype for native TTY support

Demo

#from bash (no logs)
#Ctrl+c to exit
mix run exs/demo.exs

Development

# socat file:/dev/tty,raw,icanon=0,echo=0,min=0,escape=0x03 tcp-l:8880,reuseaddr
# socat STDIO fails with: Inappropriate ioctl for device
# no resize event is received with this method
# raw required to avoid translating \r to \n
# min=0 required to answer size query immediatelly
# fork useless because term won't answer size query on reconnection
# escape=0x03 required to honor escape sequences (ctrl-c)
# while true; do socat file:/dev/tty,raw,icanon=0,echo=0,min=0 tcp-l:8880,reuseaddr; done
# while true; do socat file:/dev/tty,raw,icanon=0,echo=0,min=0,escape=0x03 tcp-l:8880,reuseaddr; done
# to exit: ctrl-z, then jobs, then kill %1
#
# socat file:/dev/tty,nonblock,raw,icanon=0,echo=0,min=0,escape=0x03 tcp:127.0.0.1:8880
# client socat to test immediate transmission of typed keys on both ends
# escape=0x03 reqired to honor ctrl-c
#
# echo -en "\033[1mThis is bold text.\033[0m" | nc 127.0.0.1 8880
# to test server end honors escapes
mix run exs/demo.exs --socat
#_build/dev/lib/teletype/priv/ptm
mix run exs/demo.exs --ptm

Design

  • Only tested so far on VS Code integrated terminal and Linux legacy TTY.
  • Very minimal escape sequences to ensure Linux TTY works.
  • Control event handlers triggered only from keyboard events
  • Use react state and control events instead of getters (on_change instead of get_value)
    • Corollary: Controls are not focusable if on_handler is nil
  • Function components external children must be ignored
  • No mixing on logic and markup allowed. State and logic to the top, markup to the bottom.
  • Null effects may be executed multiple times in a single user event because of state changes propagation.
  • The reason for use_effect (instead of direct execution from event handlers) is its cleanup mechanism.
  • Effects and cleanups are executed post render in same render process.
  • Mouse wheel may focus but not trigger constrol actions.
  • Select and Radio items can be any datatype implementing String.Chars.
  • Exceptions in timeout/interval handlers should kill the application.
  • Cleanups should be idempotent.
  • Enter should navigate to next control for all controls except buttons.
  • Dialog buttons order should be accept then cancel to take advange of enter navigation.
  • Escape should close dialogs from any current focused control (shortcut).
  • No matter the effort dirty exits are innevitable.

Issues

  • konsole is not consistently responding size queries as vscode term does

Future

  • Ctrl-c cancel
  • Ctrl-c cleanup
  • Ctrl-c handler
  • Resize handler
  • XTerm support
  • Konsole support
  • MacOS terminal support
  • Explicit screen redraw
  • TextArea
  • Drag and drop
  • Selection
  • Clipboard
  • Input scrolling
  • Cursor pos after SIGWINCH/size-query
  • Input validation
  • Mouse
  • Mouse wheel
  • Modals
  • Checkbox
  • Reversed tab
  • Commands
  • Subscriptions
  • Term behaviour
  • Zero index coordinates
  • Tab index testing
  • Tab navigation testing
  • Arror up/down navigation
  • List rendering
  • Nil rendering
  • Keyboard shortcuts
  • Modal accept/cancel
  • Conditional rendering
  • Use effect execution order
  • Use effect cleanups
  • Timer API
  • Test refocus
  • Test reverse nav
  • Test canvas && diffing
  • Test visible propagation
  • Kill app with ctrl+c