Commit Graph

788 Commits

Author SHA1 Message Date
Christian Muehlhaeuser 79c76c680b chore: disable dependabot timer 2022-11-18 02:17:42 +01:00
Ayman Bagabas 94d6f5079e
docs: update readme 2022-11-14 13:31:59 -08:00
Christian Muehlhaeuser 9c20a804d7 fix: don't close stdin
This allows programs to re-use stdin after the tea.Program has
finished.

Fixes #595.
2022-11-13 23:55:44 +01:00
Austin Vazquez e079831c31 Remove references to io/ioutil package
Package io/ioutil has been marked deprecated starting in Go 1.16.

Signed-off-by: Austin Vazquez <macedonv@amazon.com>
2022-11-10 13:51:29 +01:00
dependabot[bot] 7ba62d4987 chore(deps): bump github.com/charmbracelet/glamour in /examples
Bumps [github.com/charmbracelet/glamour](https://github.com/charmbracelet/glamour) from 0.5.0 to 0.6.0.
- [Release notes](https://github.com/charmbracelet/glamour/releases)
- [Commits](https://github.com/charmbracelet/glamour/compare/v0.5.0...v0.6.0)

---
updated-dependencies:
- dependency-name: github.com/charmbracelet/glamour
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-10 13:50:14 +01:00
Martin Dosch 2d10416631 [codespell]: Fix typos. 2022-11-03 12:55:31 -04:00
Christian Muehlhaeuser 741f2d37f0 fix: pass actual stdout's fd to command 2022-11-01 00:21:02 +01:00
Christian Muehlhaeuser 4f83c621fb chore: apply ProgramOptions before checking context
We don't need to set the background context if an outside context
was supplied.
2022-10-30 06:17:27 +01:00
Christian Muehlhaeuser 280bc6fc27 docs: clean up readme 2022-10-25 03:49:02 +02:00
Christian Muehlhaeuser bc2befecca docs: picture tag is causing display issues on Firefox 2022-10-25 03:22:49 +02:00
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