summaryrefslogtreecommitdiff
path: root/widgets/terminal.go
AgeCommit message (Collapse)Author
2022-05-25terminal: fix deadlock with finer-grained lockingKoni Marti
Commit 1bac87e80414 ("terminal: fix race when closing a terminal") fixed a race in Terminal.Draw by using a mutex. The current locking of the entire Draw function could create a deadlock, however, since this function itself might call Terminal.Close which is protected by the same mutex. A finer-grained locking solves both the race and deadlock problem. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
2022-05-23fix: "terminal: fix race when closing a terminal"Robin Jarry
I applied the wrong version of this patch. Link: https://lists.sr.ht/~rjarry/aerc-devel/patches/32482 Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-05-23terminal: fix race when closing a terminalKoni Marti
Fix race when closing a terminal. The race appears as a nil pointer dereference panic in pty.StartWithAttrs when trying to access the provided term.cmd variable. Before calling pty.StartwithAttrs in the Terminal.Draw function, term.cmd is checked for nil. Terminal.Close must be called concurrently right after this check and before/while entering pty.StartWithAttrs. This can be avoided with a mutex. Link: https://github.com/creack/pty/issues/146 Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CCJ2I45HMOTGD.2J1QMEJ4T1E3N%40t450.arielp.com%3E#%3CCJ3D069RCTXL.3VEZ7JIGFHOHK@Archetype%3E Fixes: https://todo.sr.ht/~rjarry/aerc/38 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-23logging: added a log on panicMoritz Poldrack
Since panics still regularly "destroy" the terminal, it is hard to get a stack trace for panics you do not anticipate. This commit adds a panic handler that automatically creates a logfile inside the current working directory. It has to be added to every goroutine that is started and will repair the terminal on a panic. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-12all: fix minor issues found by staticcheckMoritz Poldrack
Signed-off-by: Moritz Poldrack <git@moritz.sh>
2022-01-19terminal: fix nil pointer dereference in pty.GetsizeKoni Marti
pty.Getsize() is used in the Draw function of the terminal widget and wraps the pty.GetsizeFull() function. However, pty.Getsize does not check the returned error from pty.GetsizeFull before dereferencing the winsize struct. In case of an error, this will cause a nil pointer deference and panic. This has been reported in the upstream package, but in the meantime, we can directly use pty.GetsizeFull. References: https://todo.sr.ht/~rjarry/aerc/11 Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-01-14fix segfault when copy-pasting into compose editorKoni Marti
fixes the segmentation fault when copy-pasting a large text into the composer editor. The problem is a concurrent read of the vterm field in the Terminal widget in its flushTerminal() method which can be avoided with a mutex. Fixes: https://todo.sr.ht/~rjarry/aerc/12 Signed-off-by: Koni Marti <koni.marti@gmail.com>
2021-11-05go.mod: change base git urlRobin Jarry
I'm not sure what are the implications but it seems required. Link: https://github.com/golang/go/issues/20883 Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-04-13widgets/terminal: Only call vterm.ScreenCell.Attrs once in styleFromCellClayton Craft
This fixes a substantial performance issue when scrolling emails with long/complicated contents, where scrolling down a single line can take something like hundreds of ms before the screen is updated to reflect the scroll. It's really bad if the email has lots of columns, e.g. like if it's an html email that was passed through a filter (w3m, etc) to render it. Using pprof, I found that the multiple calls to vterm.ScreenCell.Attrs() in styleFromCell were really really expensive. This patch replaces them with a single call. Here's a before and after with a simple, but very manual test of opening a large email with contents that went through a w3m filter and continuously scrolling up and down over and over for ~30 seconds: *** Before: ----------------------------------------------------------+------------- flat flat% sum% cum cum% calls calls% + context ----------------------------------------------------------+------------- 28.25s 100% | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.PartSwitcher.Draw 0 0% 99.94% 28.25s 82.31% | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.PartViewer.Draw 28.25s 100% | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.Terminal.Draw ----------------------------------------------------------+------------- 28.25s 100% | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.PartViewer.Draw 0 0% 99.94% 28.25s 82.31% | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.Terminal.Draw 19.23s 68.07% | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.Terminal.styleFromCell 6.04s 21.38% | github.x2ecom..z2fddevault..z2fgo..z2dlibvterm.Screen.GetCellAt 1.38s 4.88% | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2flib..z2fui.Context.Printf 0.62s 2.19% | runtime.mapassign 0.43s 1.52% | runtime.mapaccess2 0.20s 0.71% | runtime.newobject 0.19s 0.67% | runtime.callers (inline) 0.07s 0.25% | runtime.makeslice 0.07s 0.25% | runtime.mallocgc ----------------------------------------------------------+------------- 19.23s 100% | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.Terminal.Draw 0 0% 99.94% 19.23s 56.03% | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.Terminal.styleFromCell 19.21s 99.90% | github.x2ecom..z2fddevault..z2fgo..z2dlibvterm.ScreenCell.Attrs *** After: ----------------------------------------------------------+------------- flat flat% sum% cum cum% calls calls% + context ----------------------------------------------------------+------------- 0.31s 100% | git.x2esr.x2eht/~sircmpwn/aerc/widgets.Terminal.Draw 0 0% 99.87% 0.31s 1.33% | github.x2ecom/ddevault/go-libvterm.NewPos 0.25s 80.65% | runtime.callers (inline) 0.04s 12.90% | runtime.gomcache (inline) ----------------------------------------------------------+------------- 8.40s 100% | github.x2ecom/ddevault/go-libvterm.Screen.GetCellAt 0 0% 99.87% 8.40s 36.11% | github.x2ecom/ddevault/go-libvterm.Screen.GetCell 7.14s 85.00% | github.x2ecom/ddevault/go-libvterm._cgoCheckPointer 0.54s 6.43% | runtime.callers (inline) 0.35s 4.17% | runtime.exitsyscall 0.11s 1.31% | runtime.deferprocStack 0.07s 0.83% | doentersyscall 0.07s 0.83% | runtime.getg 0.05s 0.6% | runtime.casgstatus 0.03s 0.36% | _init 0.03s 0.36% | runtime.gomcache (inline) ----------------------------------------------------------+------------- 8.46s 100% | git.x2esr.x2eht/~sircmpwn/aerc/widgets.Terminal.Draw 0 0% 99.87% 8.46s 36.37% | github.x2ecom/ddevault/go-libvterm.Screen.GetCellAt 8.40s 99.29% | github.x2ecom/ddevault/go-libvterm.Screen.GetCell 0.06s 0.71% | runtime.callers (inline) ----------------------------------------------------------+------------- 0.31s 100% | git.x2esr.x2eht/~sircmpwn/aerc/widgets.Terminal.styleFromCell 0 0% 99.87% 0.31s 1.33% | github.x2ecom/ddevault/go-libvterm.ScreenCell.Attrs )
2021-02-07terminal: Add support for Shift+TabAlexey Yerin
2020-12-24add italics supporty0ast
Fixes: https://todo.sr.ht/~sircmpwn/aerc2/416 Co-authored-by: JD <john1doe@ya.ru>
2020-12-18update tcell to v2 and enable TrueColor supporty0ast
Also update to the tcell v2 PaletteColor api, which should keep the chosen theme of the user intact. Note, that if $TRUECOLOR is defined and a truecolor given, aerc will now stop clipping the value to one of the theme colors. Generally this is desired behaviour though.
2020-05-06Use stdout as controlling terminalGuillaume J. Charmes
Soves an issue with go1.15 not letting ctty be a parent. See https://github.com/creack/pty/pull/97 for more details. Signed-off-by: Guillaume J. Charmes <git+guillaume@charmes.net>
2020-05-06Revert "Dont detach process under vterm"Drew DeVault
This reverts commit d07cf6c667a0d497c67196fca9967db71c1e02f6.
2020-05-06Dont detach process under vtermGuillaume J. Charmes
Signed-off-by: Guillaume J. Charmes <git+guillaume@charmes.net>
2020-03-26fix function keys in terminal widgetJonathan Halmen
off-by-one error
2020-01-16Switch back to upstream pty libraryBen Fiedler
The relevant change was merged upstream, and thus allows us to clean up unneeded forks.
2019-11-21widgets/terminal: Reap more zombiesKevin Kuehler
The editor and pager were not properly being reaped, causing resource leakage whenever a user replies to a message. Signed-off-by: Kevin Kuehler <keur@xcf.berkeley.edu>
2019-09-11Add MouseableJeffas
This adds the Mouseable interface. When this is implemented for a component that item can accept and process mouseevents. At the top level when a mouse event is received it is passed to the grid's handler and then it trickles down until it reaches a component that can actually handle it, such as the tablist, dirlist or msglist. A mouse event is passed so that components can handle other things such as scrolling with the mousewheel. The components themselves then perform the necessary actions. Clicking emails in the messagelist opens them in a new tab. Textinputs can be clicked to position the cursor inside them. Mouseevents are not forwarded to the terminal at the moment. Elements which do not handle mouse events are not required to implement the Mouseable interface.
2019-08-12Prevent drawing terminal with nil cmdDrew DeVault
2019-07-13Don't initialize an invalid pty sizeDrew DeVault
2019-06-01Use forked version of tcellDrew DeVault
2019-06-01widgets/terminal: Don't segfault on resizeKevin Kuehler
vterm.Write and vterm.SetSize race when the window resizes, which causing the underlying library to segfault. Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
2019-05-26Update terminal color handling per vterm changesDrew DeVault
2019-05-26Update to the latest go-libvtermDrew DeVault
2019-05-19widgets/terminal: fix damage race conditionSimon Ser
Terminal.damage is accessed when drawing and when invalidating the widget. For this reason we need to protect it with a mutex. This seems to fix various damage issues I've been experiencing (where some regions of the terminal weren't correctly repainted). Race detector trace: Read at 0x00c0000c6670 by main goroutine: git.sr.ht/~sircmpwn/aerc/widgets.(*Terminal).Draw() /home/simon/src/aerc/widgets/terminal.go:292 +0x191 git.sr.ht/~sircmpwn/aerc/lib/ui.(*Grid).Draw() /home/simon/src/aerc/lib/ui/grid.go:117 +0x575 git.sr.ht/~sircmpwn/aerc/lib/ui.(*Grid).Draw() /home/simon/src/aerc/lib/ui/grid.go:117 +0x575 git.sr.ht/~sircmpwn/aerc/widgets.(*MessageViewer).Draw() /home/simon/src/aerc/widgets/msgviewer.go:231 +0x253 git.sr.ht/~sircmpwn/aerc/lib/ui.(*TabContent).Draw() /home/simon/src/aerc/lib/ui/tab.go:124 +0x12e git.sr.ht/~sircmpwn/aerc/lib/ui.(*Grid).Draw() /home/simon/src/aerc/lib/ui/grid.go:117 +0x575 git.sr.ht/~sircmpwn/aerc/widgets.(*Aerc).Draw() /home/simon/src/aerc/widgets/aerc.go:95 +0x5a git.sr.ht/~sircmpwn/aerc/lib/ui.(*UI).Tick() /home/simon/src/aerc/lib/ui/ui.go:93 +0x1dd main.main() /home/simon/src/aerc/aerc.go:105 +0x539 Previous write at 0x00c0000c6670 by goroutine 37: git.sr.ht/~sircmpwn/aerc/widgets.(*Terminal).onDamage-fm() /home/simon/src/aerc/widgets/terminal.go:429 +0x131 git.sr.ht/~sircmpwn/go-libvterm._go_handle_damage() /home/simon/go/pkg/mod/git.sr.ht/~sircmpwn/go-libvterm@v0.0.0-20190421201021-3184f6f13687/vterm.go:481 +0xf9 git.sr.ht/~sircmpwn/go-libvterm._cgoexpwrap_5e22200b58b7__go_handle_damage() _cgo_gotypes.go:731 +0x58 runtime.call32() /usr/lib/go/src/runtime/asm_amd64.s:519 +0x3a git.sr.ht/~sircmpwn/go-libvterm.(*VTerm).Write.func1() /home/simon/go/pkg/mod/git.sr.ht/~sircmpwn/go-libvterm@v0.0.0-20190421201021-3184f6f13687/vterm.go:329 +0x9d git.sr.ht/~sircmpwn/go-libvterm.(*VTerm).Write() /home/simon/go/pkg/mod/git.sr.ht/~sircmpwn/go-libvterm@v0.0.0-20190421201021-3184f6f13687/vterm.go:329 +0x7f git.sr.ht/~sircmpwn/aerc/widgets.NewTerminal.func1() /home/simon/src/aerc/widgets/terminal.go:131 +0x18c Goroutine 37 (running) created at: git.sr.ht/~sircmpwn/aerc/widgets.NewTerminal() /home/simon/src/aerc/widgets/terminal.go:121 +0x23f git.sr.ht/~sircmpwn/aerc/widgets.NewMessageViewer() /home/simon/src/aerc/widgets/msgviewer.go:147 +0xfbe git.sr.ht/~sircmpwn/aerc/commands/account.ViewMessage() /home/simon/src/aerc/commands/account/view-message.go:26 +0x4a4 git.sr.ht/~sircmpwn/aerc/commands.(*Commands).ExecuteCommand() /home/simon/src/aerc/commands/commands.go:47 +0x1f0 main.main.func1() /home/simon/src/aerc/aerc.go:76 +0x205 git.sr.ht/~sircmpwn/aerc/widgets.(*Aerc).BeginExCommand.func1() /home/simon/src/aerc/widgets/aerc.go:262 +0x89 git.sr.ht/~sircmpwn/aerc/widgets.(*ExLine).Event() /home/simon/src/aerc/widgets/exline.go:47 +0x222 git.sr.ht/~sircmpwn/aerc/widgets.(*Aerc).Event() /home/simon/src/aerc/widgets/aerc.go:133 +0x83c git.sr.ht/~sircmpwn/aerc/widgets.(*Aerc).simulate() /home/simon/src/aerc/widgets/aerc.go:126 +0x12a git.sr.ht/~sircmpwn/aerc/widgets.(*Aerc).Event() /home/simon/src/aerc/widgets/aerc.go:148 +0x766 git.sr.ht/~sircmpwn/aerc/lib/ui.(*UI).Tick() /home/simon/src/aerc/lib/ui/ui.go:86 +0x11b main.main() /home/simon/src/aerc/aerc.go:105 +0x539
2019-05-17s/aerc2/aerc/gDrew DeVault
2019-05-12Implement :{next,prev}-field in compose viewDrew DeVault
2019-05-11"Press any key to close" for completed processesDrew DeVault
2019-04-27lib/ui: introduce InvalidatableSimon Ser
Many Drawable implementations have their own Invalidate and OnInvalidate functions, with an unexported onInvalidate field. However OnInvalidate and Invalidate are usually not called in the same goroutine. This results in a race on this field, e.g.: Read at 0x00c000094748 by goroutine 7: git.sr.ht/~sircmpwn/aerc2/widgets.NewDirectoryList.func1() /home/simon/src/aerc2/widgets/dirlist.go:85 +0x56 git.sr.ht/~sircmpwn/aerc2/widgets.(*Spinner).Start.func1() /home/simon/src/aerc2/widgets/spinner.go:93 +0x1bb Previous write at 0x00c000094748 by main goroutine: [failed to restore the stack] Goroutine 7 (running) created at: git.sr.ht/~sircmpwn/aerc2/widgets.(*Spinner).Start() /home/simon/src/aerc2/widgets/spinner.go:46 +0x8f git.sr.ht/~sircmpwn/aerc2/widgets.NewDirectoryList() /home/simon/src/aerc2/widgets/dirlist.go:37 +0x286 git.sr.ht/~sircmpwn/aerc2/widgets.NewAccountView() /home/simon/src/aerc2/widgets/account.go:50 +0x5ca git.sr.ht/~sircmpwn/aerc2/widgets.NewAerc() /home/simon/src/aerc2/widgets/aerc.go:60 +0x800 main.main() /home/simon/src/aerc2/aerc.go:65 +0x33e To fix this, introduce a new type, Invalidatable, which protects the field. Unfortunately the Drawable must be passed to the callback function in Invalidate, so we still need to re-implement this in each Invalidatable user.
2019-04-15Re-render terminal on invalidateDrew DeVault
2019-04-05Clear damage on each terminal.Draw callDrew DeVault
2019-04-05Fix wrong row due to typoTom Lebreux
Signed-off-by: Tom Lebreux <tomlebreux@cock.li>
2019-03-30Fix crash on command not foundDrew DeVault
2019-03-30Implement :pipeDrew DeVault
2019-03-21Expire status errors on inputDrew DeVault
2019-03-21term: don't mess with cursor when unfocusedDrew DeVault
2019-03-21Enable alt screen on built-in terminalDrew DeVault
2019-03-21Make terminal closure thread safeDrew DeVault
2019-03-21Use GetCursorPos instead of stored positionDrew DeVault
2019-03-21Skip writes if term is closedDrew DeVault
2019-03-21Improve cursor handling in embedded terminalDrew DeVault
2019-03-21Fix cursor handling in embedded terminalDrew DeVault
2019-03-21Forward key events to child terminalDrew DeVault
2019-03-17moar colorsDrew DeVault
2019-03-17s/:term-close/:close/gDrew DeVault
2019-03-17Wrap Terminal in TermHostDrew DeVault
2019-03-17Add :term-closeDrew DeVault
2019-03-17Handle terminal title, login shellDrew DeVault
2019-03-17Fix terminal colors; wait until tty size is knownDrew DeVault