Commit Graph

678 Commits

Author SHA1 Message Date
Christian Muehlhaeuser
39381647f1 docs: new readme footer 2022-10-24 10:13:38 +02:00
Christian Muehlhaeuser
e15bcb7e0e feat: tea.WithContext ProgramOption to supply a context
WithContext lets you specify a context in which to run the Program.
This is useful if you want to cancel the execution from outside.
When a Program gets cancelled it will exit with an error
ErrProgramKilled.
2022-10-23 05:59:10 +02:00
Christian Muehlhaeuser
0f1ce7f2d9 fix: maintain cursor visibility across altscreen state switch
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.
2022-10-23 03:25:11 +02:00
treilik
918d35746b feat: export BatchMsg
There's no good reason to keep it private. Exporting it helps
testability, debugging, and allows for a few special model.Update
implementations.
2022-10-22 22:51:46 +02:00
Christian Muehlhaeuser
80f44c9384 fix: detect terminal size after exec
Based on @knz's work in #499, but slightly supersedes this change.

A little more coupling in the resize handling, but a lot less code
& logic repetition.

Co-authored-by: Raphael 'kena' Poss <knz@thaumogen.net>
2022-10-22 22:02:56 +02:00
Christian Muehlhaeuser
9bcfc026a2 fix: restore Windows console mode on shutdown
The deferred Close call on our input reader caused the console mode
to be reset twice, and the incorrect, inner mode was applied last.
2022-10-20 20:38:33 +02:00
Christian Muehlhaeuser
a7067fbfa2 fix: prevent renderer from overflowing available height
Drops lines from the top when the render buffer is taller than the
available height.

Fixes #297.
2022-10-18 06:33:37 +02:00
Raphael 'kena' Poss
cbe309d624 fix: don't delay messages behind a long command 2022-10-16 17:06:27 +02:00
Christian Muehlhaeuser
3609d87e70 fix: don't block in Send after shutdown
Send should block before a tea.Program has been started, but result
in a no-op when it has already been terminated.

Fixed godocs.
2022-10-15 04:21:44 +02:00
Christian Muehlhaeuser
a520b7f4e1 fix: ensure a final render before a clean shutdown
Fixes #274.
2022-10-13 07:55:48 +02:00
Christian Muehlhaeuser
99ad2eda0d fix: also lock mutex when accessing state read-only 2022-10-13 06:56:45 +02:00
Christian Muehlhaeuser
db664820d4 fix: lock mutex before checking altscreen state
This prevents the odd race condition where Enter- & ExitAltScreen
are called concurrently.
2022-10-13 04:50:50 +02:00
Christian Muehlhaeuser
b8ef6f85ea feat: support ctrl+page up/down keys
Adds support for ctrl+(alt)+page up/down key events.

Tested in konsole, alacritty, foot, urxvt, and a few other
terminals.

Fixes #369.
2022-10-12 07:11:20 +02:00
Benjamin DeCoste
aba3cec050 docs: fix code in commands tutorial (#501) 2022-10-12 05:45:51 +02:00
Christian Muehlhaeuser
1ed623fdc0 fix: kill should result in Start returning an error
This fixes Kill resulting in a final nil model being returned.

We can also drop the kill channel and rely on our existing context
channel.
2022-10-12 05:26:39 +02:00
Christian Muehlhaeuser
fd18c149df fix: restoreTerminalState resets mouse handling state
- fixes mouse handling being enabled during sub commands
- fixes shutdown order: restore mouse state before alt screen
2022-10-12 00:36:09 +02:00
Josh Soref
4aa9ce489b docs: fix spelling / various typos (#526) 2022-10-11 14:40:01 +02:00
Christian Muehlhaeuser
8703897aad fix: timeout when waiting for CancelReader
Fixes #524.
2022-10-11 12:42:40 +02:00
Christian Muehlhaeuser
b9bd01b79a fix: lock renderer during stop/kill 2022-10-09 05:57:44 +02:00
Christian Muehlhaeuser
e119cd88b2 fix: prevent double repaint when restoring terminal 2022-10-09 05:57:23 +02:00
Christian Muehlhaeuser
1c3b792596 chore: don't use deprecated methods internally 2022-10-09 05:33:32 +02:00
Christian Muehlhaeuser
a11ff932fa test: complete nil renderer test 2022-10-09 04:23:14 +02:00
Christian Muehlhaeuser
8e79fdd50b test: add screen manipulation tests 2022-10-09 04:14:09 +02:00
Christian Muehlhaeuser
13cdfd2719 test: exec returning an error for invalid and failing commands 2022-10-09 03:46:59 +02:00
Christian Muehlhaeuser
77619d21f5 test: add sequenceMsg test 2022-10-08 19:02:54 +02:00
Christian Muehlhaeuser
9117bbc137 test: add batchMsg test 2022-10-08 18:52:09 +02:00
Christian Muehlhaeuser
6b77c8fc10 chore: rename StartReturningModel to Run
Added aliases for the old functions, but deprecated them.
2022-10-08 01:34:17 +02:00
Christian Muehlhaeuser
22d15efad7 chore: clean up linter errors in examples 2022-10-08 00:56:56 +02:00
Leandro López (inkel)
8b8fd12201 Update Program.Start docs to indicate it's a blocking operation
This addresses one of the concerns in #299.
2022-10-08 00:51:36 +02:00
Christian Muehlhaeuser
9bde73bd4e chore: reorganize Program struct 2022-10-07 23:39:36 +02:00
Christian Muehlhaeuser
fbb00cc71e fix: close input on shutdown whenever possible 2022-10-07 23:38:27 +02:00
Christian Muehlhaeuser
6477a53545 chore: store handlers and simplify teardown 2022-10-07 23:18:35 +02:00
Christian Muehlhaeuser
76ce669474 chore: make CatchPanics an option flag 2022-10-07 22:33:06 +02:00
Christian Muehlhaeuser
0ac6702e11 feat: make signal handler optional
You can now initialize a tea app without a signal handler:

p := NewProgram(model, WithoutSignalHandler())
2022-10-07 21:46:06 +02:00
Christian Muehlhaeuser
2696b2f339 chore: break up Start into several, more maintainable methods 2022-10-07 20:13:57 +02:00
Raphael 'kena' Poss
0e76ba142a fix(key): recover the insert key
We started supporting insert in #418, but then accidentally
removed it during a rebase in #396. Oops.
2022-10-07 14:54:27 +02:00
Christian Muehlhaeuser
f406999cba fix: don't try to set alt screen when already in desired mode 2022-10-06 12:50:51 +02:00
Christian Muehlhaeuser
ca8b21a3e2 fix: force repaint after clearing the screen 2022-10-04 17:34:09 +02:00
Christian Muehlhaeuser
6b6bf6ab6d fix: don't access output from outside renderer 2022-10-04 06:12:17 +02:00
Raphael 'kena' Poss
5d1a7264c5 fix: ensure alt screen switch always clears terminal 2022-10-04 06:01:52 +02:00
Raphael 'kena' Poss
6e1065830a feat: support a Clear command 2022-10-04 06:01:52 +02:00
Christian Muehlhaeuser
37b79f55f1 feat: add tea.ShowCursor, complementing tea.HideCursor 2022-10-04 05:39:38 +02:00
Christian Muehlhaeuser
8d6bdcf2fd chore: reorganize command helpers 2022-10-04 05:29:41 +02:00
Christian Muehlhaeuser
e4ca150210 chore: reorganize screen commands & messages 2022-10-04 05:20:07 +02:00
Christian Muehlhaeuser
ea36e19bee fix: move output handling to renderer 2022-10-04 05:06:42 +02:00
Leandro López
7cf0d54bd4 docs: fix typo in Tick godoc (#477) 2022-10-04 04:14:42 +02:00
Raphael 'kena' Poss
7e7a729b31 fix: remove the now-unused hexes key mapping
This became unnecessary when we fixed the support for the Alt modifier
on control characters.
2022-10-03 22:43:17 +02:00
Raphael 'kena' Poss
b074f6f5a4 fix: properly skip over unrecognized CSI sequences. 2022-10-03 22:43:17 +02:00
Maas Lalani
d20732aaea docs: add examples/gifs locally to repository 2022-10-03 15:07:28 -04:00
Raphael 'kena' Poss
08518987f5 Reorder the function keys in key.go for better troubleshootability
Here the list of keys did not change, I simply re-ordered the lines
in the file.
2022-10-03 19:56:10 +02:00