Documentation ¶
Overview ¶
Package ui handles user input, JSON processing output, and sending interactions and commands to the JSON processor.
The basic layout of the UI should include: - One-row input for entering jq programs - The rest of the container for displaying JSON processor output
The data flow should flow through the following loop:
- Initial state
- Actions representing changes or events in the program
- Functions that listen for a given action and call methods on a UI implementation to update the state
- Render the new state into application UI
This should seem familiar to web programmers familiar with the Flux/Redux flow. However, since Go doesn't have union types that carry data, and since we want tighter control over memory, we use internal fields and buffers to manage interim states and reuse memory.
Index ¶
- type Action
- type Termbox
- func (t *Termbox) Events() chan (Action)
- func (t *Termbox) Flush() error
- func (t *Termbox) Quit()
- func (t *Termbox) RenderFilePrompt() error
- func (t *Termbox) RenderInput() error
- func (t *Termbox) RenderResults(data io.Reader) error
- func (t *Termbox) Start(initialProgram string) error
- func (t *Termbox) UpdateInput()
- func (t *Termbox) UpdateInputBackspace()
- func (t *Termbox) UpdateSaveInput()
- func (t *Termbox) UpdateSaveInputBackspace()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action uint8
Action defines the events and interactions possible in the application
type Termbox ¶
type Termbox struct { Debug io.WriteCloser Input string SaveInputMode bool SavePath string // contains filtered or unexported fields }
Termbox draws the jq-live UI via termbox
func (*Termbox) Flush ¶
Flush prints any unprinted UI changes to the screen
termbox-go Flush() is not goroutine safe, so we're protecting access if updates come in very quickly. https://github.com/nsf/termbox-go/issues/113
func (*Termbox) Quit ¶
func (t *Termbox) Quit()
Quit ends the program, gives the display back to the terminal, and performs any required cleanup
func (*Termbox) RenderFilePrompt ¶
RenderFilePrompt switches the UI to the file input
func (*Termbox) RenderInput ¶
RenderInput updates the input display to match the internal buffer
func (*Termbox) RenderResults ¶
RenderResults renders the results of jq output to the screen
func (*Termbox) UpdateInput ¶
func (t *Termbox) UpdateInput()
UpdateInput appends the new input character to the internal input buffer
func (*Termbox) UpdateInputBackspace ¶
func (t *Termbox) UpdateInputBackspace()
UpdateInputBackspace removes the last character from the input
func (*Termbox) UpdateSaveInput ¶
func (t *Termbox) UpdateSaveInput()
UpdateSaveInput appends the new input character to the internal input buffer
func (*Termbox) UpdateSaveInputBackspace ¶
func (t *Termbox) UpdateSaveInputBackspace()
UpdateSaveInputBackspace removes the last character from the input