* feat: bracketed paste
This introduces support for input via bracketed paste, where escape
characters in the pasted input are not interpreted.
Pasted input are marked as a special field in the KeyMsg. This is
useful because pasted input may need sanitation in individual widgets.
* fix(key): support bracketed paste with short reads
Some terminal emulators feed the bracketed paste data in multiple
chunks, which may not be aligned on a 256 byte boundary. So it's
possible for `input.Read` to return less than 256 bytes read
but while there's still more data to be read to complete a bracketed
paste input.
---------
Co-authored-by: Christian Muehlhaeuser <muesli@gmail.com>
From the Go docs:
"If the map is nil, the number of iterations is 0." [1]
Therefore, an additional nil check for before the loop is unnecessary.
[1]: https://go.dev/ref/spec#For_range
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
Based on #462 and #452 by @londek, but fixes maintaining the
current visibility state across altscreen state changes.
This makes the behavior consistent across terminals, some of which
keep separate state for altscreen and regular buffer.
Fixes#190.
* merge Adjective-Object/tea_log_renderer into standard renderer
* rename queuedMessages -> queuedMessageLines & break apart strings during message processing
* delete cursorDownBy
* += 1 -> ++ to make the linter happy
* add skipLines[] tracking back to standard renderer, and add rename skippedLines local to jumpedLines to clarify they are separate comments
* request repaint when a message is recieved
* Convert Println and Printf to commands
* Add package manager example demonstrating tea.Printf
* Use Unix instead of UnixMicro for Go 1.13 support in CI
* fix off by one in std renderer
* add Printf/Println to tea.go
* revert attempt at sequence compression + cursorUpBy
Co-authored-by: Maxwell Huang-Hobbs <mahuangh@microsoft.com>
Co-authored-by: Christian Rocha <christian@rocha.is>
I didn't realise at the time, but the tea.Program and the renderer share
the mutex. This make the code difficult to reason about - it turns out
the program sometimes acquires the lock and then calls the
`setAltScreen` method of the renderer which in turns calls `repaint`.
That causes a deadlock as `repaint` is trying to acquire the lock too.
* add: program.ReleaseTerminal and RestoreTerminal to re-use input & terminal
* chore(examples): add altscreen toggling to exec demo
* chore: put low-level altscreen stuff alongside other screen funcs
* docs: edit GoDocs for ReleaseTerminal and RestoreTerminal
* feat(renderer): add internal Msg renderMsg to immediately repaint
* fix: repaint instantly on RestoreTerminal
* fix: restore the altscreen state when restoring the terminal
* feat: implement Cmd-based API for blocking *exec.Cmds
* feat: allow Exec to return custom messages
* feat: allow Exec to be run without a callback
* fix: separate parameters for exec.Command examples
* fix: error message would get printed over by prompt in exec example
* fix: ignore signals while child process is running
* feat: allow to execute other things besides exec.Commands (#280)
* feat: allow to execute other things besides exec.Commands.
* fix: lint issues
* fix: renames, examples
* fix: callback type should be exported
* docs(exce): tiny ExecCommand doc comment correction
* chore(exec): break out Cmd for clarity's sake in example
* fix(exec): give the terminal a moment to catch up if exiting altscreen
* docs(exec): tidy up doc comments
* chore(exec): disambiguate methods for restoring the terminal state vs input
Co-authored-by: Christian Rocha <christian@rocha.is>
Co-authored-by: Carlos A Becker <caarlos0@gmail.com>
With this change all ANSI output will be piped through an ANSI compressor that
eliminates redundant ANSI sequences. As such the compressor can be considered
"lossless".
This commit also consolidates the exit operations for consistency's
sake, and adds a kill() method to renderers for stopping them without
performing any final rendering.
v0.13.4 introduced a regression where lines weren't always cleared when
resizing the window resulting in the presence of rendering artifacts.
This commit fixes that.
If the number of lines increased there's a chance that the increase in
lines caused the terminal to scroll (even in the altscreen). Because of
this we must repaint everything, as skipping lines will mis-render.
Thanks to @fiws for reporting this bug.
The Nil Renderer essentially disables the Bubble Tea renderer sending
loggings and print statements to stdout. It can be enabled via the
ProgramOption WithoutRenderer.