Commit Graph

51 Commits

Author SHA1 Message Date
Preston Baxter 14c9ee8b4d adjust bubble tea mod 2024-02-10 22:25:40 -06:00
Raphael 'kena' Poss 2b46020ca0
feat: bracketed paste (#397)
* 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>
2024-02-05 14:49:09 +01:00
Ayman Bagabas a154847611
feat: extended Coordinates mouse reporting & additional buttons support (#594)
* feat(mouse): add extended mouse & shift key support

Support SGR(1006) mouse mode
Support parsing shift key press
Support additional mouse buttons
Report which button was released
Report button motion

* fix: key.go sgr len missing calculation (#841)

* chore(test): add sgr mouse msg detect test

---------

Co-authored-by: robinsamuel <96998379+robin-samuel@users.noreply.github.com>
2023-12-04 11:50:59 -05:00
Raphael 'kena' Poss 6e1065830a feat: support a Clear command 2022-10-04 06:01:52 +02:00
Christian Muehlhaeuser ea36e19bee fix: move output handling to renderer 2022-10-04 05:06:42 +02:00
Christian Muehlhaeuser 3795c036c4
add: Exec, ReleaseTerminal and RestoreTerminal to re-use input and terminal (#237)
* 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>
2022-04-12 10:23:10 -04:00
Christian Muehlhaeuser 3930519979
Fix typos 2021-08-23 23:18:00 +02:00
Christian Rocha 1f773e8f20 Fix a race where artifacts could print when exiting a program
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.
2021-06-02 14:49:54 -04:00
Christian Rocha 3256fae4d4 Force a full repaint when resizing the window
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.
2021-05-31 10:37:32 -04:00
Christian Rocha fb64f34bd0 Only render lines that have changed since the last render 2021-05-10 12:28:49 -04:00
Christian Rocha b3f62af8b5 Add nil renderer and combination TUI-daemon program example
The Nil Renderer essentially disables the Bubble Tea renderer sending
loggings and print statements to stdout. It can be enabled via the
ProgramOption WithoutRenderer.
2021-03-07 13:01:54 -05:00
Christian Rocha 65cb46c475
Remove notes about how we'd auto-truncate lines as we're doing that now 2021-02-25 12:12:52 -05:00
Carl Henrik Lunde 3266c3654b Avoid race on renderer.buf in flush vs. write
Fix race by acquiring the mutex before accessing renderer.buf in flush.

	WARNING: DATA RACE
	Read at 0x00c0000ee0a0 by goroutine 11:
	  bytes.(*Buffer).Len()
	      /home/chlunde/opt/go/src/bytes/buffer.go:73 +0x64
	  github.com/charmbracelet/bubbletea.(*renderer).flush()
	      /home/chlunde/src/bubbletea/renderer.go:91 +0x45
	  github.com/charmbracelet/bubbletea.(*renderer).listen()
	      /home/chlunde/src/bubbletea/renderer.go:76 +0x185

	Previous write at 0x00c0000ee0a0 by main goroutine:
	  bytes.(*Buffer).Reset()
	      /home/chlunde/opt/go/src/bytes/buffer.go:98 +0xf5
	  github.com/charmbracelet/bubbletea.(*renderer).write()
	      /home/chlunde/src/bubbletea/renderer.go:195 +0x13c
	  github.com/charmbracelet/bubbletea.(*Program).Start()
	      /home/chlunde/src/bubbletea/tea.go:330 +0xbbb
	  main.main()
	      /home/chlunde/src/bubbletea/examples/spinner/main.go:27 +0x229

Fixes #54
2021-02-25 10:56:48 -05:00
Carlos Alexandro Becker b2d948b53c Fixed a couple of typos
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2021-01-17 15:58:50 +01:00
Christian Rocha 1f6191c671 Automatically trim lines wider than the window width 2021-01-14 20:14:39 -05:00
Christian Rocha 591fcabdd4
Explicitly ignore io.Writer return values in renderer 2020-09-28 16:28:40 -04:00
Christian Muehlhaeuser d26cfb6b38
Make golint happy 2020-08-22 12:34:03 +02:00
Christian Rocha c0f67a2927
Improve GoDocs 2020-07-29 20:50:00 -04:00
Christian Rocha 2f53eeb54b
Fix a bug in macOS terminal where stuff could get sucked into the scroll area 2020-07-13 11:39:04 -04:00
Christian Rocha 14a06b0896
Improve some comments 2020-07-06 11:54:02 -04:00
Christian Rocha f7ec07de3c
Clear lines before handing them over to the scrolling renderer 2020-06-25 19:22:37 -04:00
Christian Rocha 3a70ecdde1
Use same output for altscreen stuff as everything else 2020-06-22 15:55:52 -04:00
Christian Rocha 05f3028452
Move cursor in a relative fashion in standard render (fixes inline rendering) 2020-06-22 14:35:46 -04:00
Christian Rocha 8bab4bce9a
Actively place the cursor after a normal render 2020-06-22 13:40:44 -04:00
Christian Rocha ebbab2908c
Put cursor back where we found it after scrolling 2020-06-22 13:40:44 -04:00
Christian Rocha eff99294e1
We actually never needed to correct the top boundary 2020-06-22 13:40:44 -04:00
Christian Rocha 6e75920859
Stay in-bounds when clearing lines 2020-06-22 13:40:44 -04:00
Christian Rocha c0ce48dfdd
Fix repaint when syncing and clearing scroll area 2020-06-22 13:40:44 -04:00
Christian Rocha 673752658f
Comments and cleanup 2020-06-22 13:40:32 -04:00
Christian Rocha bbcdb3ac1f
Render scroll area before other stuff when resizing 2020-06-19 13:27:50 -04:00
Christian Rocha 2a297fabad
Also repaint non-scrolling stuff when resizing 2020-06-19 11:51:36 -04:00
Christian Rocha a2897e9dd1
Remove messages and commands we don't need yet 2020-06-18 22:42:29 -04:00
Christian Rocha 00f7f5be93
Remove cursor save/restore as it was wrecking things
Also, um, we didn't need it.
2020-06-18 20:10:20 -04:00
Christian Rocha d4d553c447
Back to a line-based renderer 2020-06-18 19:18:37 -04:00
Christian Rocha da9a1fe2f4
Correct scroll area top positioning 2020-06-18 17:21:48 -04:00
Christian Rocha 6ea16d0b9c
Add command to sync scrollable area with renderer
This is necessary for initial paints, and probably for resizes.
2020-06-18 12:23:42 -04:00
Christian Rocha 83e41c15b1
Create ignoreLines map on demand 2020-06-18 12:20:14 -04:00
Christian Rocha 902225116c
Correct "scroll down" behavior 2020-06-17 20:24:43 -04:00
Christian Rocha 4dc6992767
Cmds for scrolling + handle renderer msgs in a renderer method 2020-06-17 18:46:04 -04:00
Christian Rocha a492302609
Adjust exports of new msgs + add msg to replace ignored lines 2020-06-17 18:19:27 -04:00
Christian Rocha 8539cfcf8c
Fix a bug where left area on the first line was not always cleared 2020-06-17 14:50:39 -04:00
Christian Rocha ae9ea29c0e
Fix line clearing bug 2020-06-17 11:49:33 -04:00
Christian Rocha 830beecffb
Fix render's view clearing loop 2020-06-17 10:48:08 -04:00
Christian Rocha b72009105b
Fix infinte loop + backwards ignore behavior 2020-06-16 22:30:47 -04:00
Christian Rocha 683473c26d
Blind pass at adding high performance scrolling into the renderer 2020-06-16 22:06:46 -04:00
Christian Rocha da86f9ac1a
Renderer comments 2020-06-16 11:05:10 -04:00
Christian Rocha 01032f0579
Set FPS in a more readable fashion (thanks @muesli!) 2020-06-15 20:01:18 -04:00
Christian Rocha 3aba272a10
Fix nonsensical comment 2020-06-11 21:42:40 -04:00
Christian Rocha 55a8d1853e
Comments 2020-06-08 12:48:57 -04:00
Christian Rocha 3647042096
Fix renderer bug where UI could be duplicated in inline-TUIs 2020-06-08 12:48:57 -04:00