Commit Graph

32 Commits

Author SHA1 Message Date
Drew DeVault 5493af8c8f Prevent drawing terminal with nil cmd 2019-08-12 09:51:45 +09:00
Drew DeVault 5b2336d0d7 Don't initialize an invalid pty size 2019-07-13 11:13:48 -04:00
Drew DeVault 56b84d3da5 Use forked version of tcell 2019-06-01 11:28:29 -04:00
Kevin Kuehler 3445b80d7a widgets/terminal: Don't segfault on resize
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-06-01 11:09:14 -04:00
Drew DeVault 62cd0b08aa Update terminal color handling per vterm changes 2019-05-26 15:48:29 -04:00
Drew DeVault 855362d813 Update to the latest go-libvterm 2019-05-26 15:13:37 -04:00
Simon Ser 1da3239345 widgets/terminal: fix damage race condition
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-19 11:37:38 -04:00
Drew DeVault 98da4c9509 s/aerc2/aerc/g 2019-05-17 20:57:10 -04:00
Drew DeVault f37508a539 Implement :{next,prev}-field in compose view 2019-05-12 11:21:28 -04:00
Drew DeVault 71c13c9078 "Press any key to close" for completed processes 2019-05-11 14:15:29 -04:00
Simon Ser 5685a17674 lib/ui: introduce Invalidatable
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-27 14:30:28 -04:00
Drew DeVault 2925bdfd6c Re-render terminal on invalidate 2019-04-15 16:07:05 -04:00
Drew DeVault 4bc8ea34bc Clear damage on each terminal.Draw call 2019-04-05 20:11:31 -04:00
Tom Lebreux 399d014bff Fix wrong row due to typo
Signed-off-by: Tom Lebreux <tomlebreux@cock.li>
2019-04-05 20:10:28 -04:00
Drew DeVault fd27a2baf6 Fix crash on command not found 2019-03-30 16:29:52 -04:00
Drew DeVault 700dea23fa Implement :pipe 2019-03-30 11:58:24 -04:00
Drew DeVault e591221509 Expire status errors on input 2019-03-21 21:34:12 -04:00
Drew DeVault a602891768 term: don't mess with cursor when unfocused 2019-03-21 21:28:51 -04:00
Drew DeVault 960d11c4bc Enable alt screen on built-in terminal 2019-03-21 21:24:23 -04:00
Drew DeVault 15b856abcc Make terminal closure thread safe 2019-03-21 21:23:30 -04:00
Drew DeVault be2918a616 Use GetCursorPos instead of stored position 2019-03-21 21:19:34 -04:00
Drew DeVault d97cdde38d Skip writes if term is closed 2019-03-21 21:07:49 -04:00
Drew DeVault 0b26241b42 Improve cursor handling in embedded terminal 2019-03-21 21:00:03 -04:00
Drew DeVault 55ad16bb70 Fix cursor handling in embedded terminal 2019-03-21 19:56:47 -04:00
Drew DeVault 28f393bdbd Forward key events to child terminal 2019-03-21 19:50:54 -04:00
Drew DeVault f3d3e0ed4f moar colors 2019-03-17 18:06:15 -04:00
Drew DeVault 9ff815bb13 s/:term-close/:close/g 2019-03-17 17:45:44 -04:00
Drew DeVault 60b17c473a Wrap Terminal in TermHost 2019-03-17 17:39:49 -04:00
Drew DeVault dee0f8938b Add :term-close 2019-03-17 17:23:53 -04:00
Drew DeVault 16c3f0a893 Handle terminal title, login shell 2019-03-17 17:08:54 -04:00
Drew DeVault bd71787e3f Fix terminal colors; wait until tty size is known 2019-03-17 14:54:25 -04:00
Drew DeVault 1170893e39 Add basic terminal widget 2019-03-17 14:02:33 -04:00