Commit graph

134 commits

Author SHA1 Message Date
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
fcdcd32de7 Remove unimplemented color configuration
Will probably end up doing this differently anyway
2019-05-17 11:52:38 -04:00
Drew DeVault
89ffd8653d Implement ui.empty-message config option
Also removes some options that aren't going to be supported any time
soon.
2019-05-17 11:42:34 -04:00
Drew DeVault
23650ac0c7 Fix date header on outgoing emails 2019-05-17 11:05:21 -04:00
Drew DeVault
5701b6e949 Decode email when reading it for quoting 2019-05-16 14:09:57 -04:00
Drew DeVault
8be59cae6c Implement :reply -q and :reply -a 2019-05-16 12:39:22 -04:00
Drew DeVault
475b697bdf Implement (basic form) of :reply 2019-05-16 12:15:34 -04:00
Drew DeVault
2b3e123cb8 Let caller pass in custom headers to compose 2019-05-16 10:49:50 -04:00
Drew DeVault
b0bf09b98f Copy sent emails to the Sent folder
Or rather, to a user-specified folder
2019-05-15 19:41:21 -04:00
Drew DeVault
07138146a0 Force INBOX to be included in dirlist 2019-05-14 16:53:47 -04:00
Drew DeVault
db213fd0ae Implement :copy (aka :cp) 2019-05-14 16:44:59 -04:00
Drew DeVault
2c486cb7f5 Update tab name as subject changes
Also moves truncation to the tab widget
2019-05-14 16:18:59 -04:00
Drew DeVault
065da5e372 Add $EDITOR, internal config for compose 2019-05-14 15:25:30 -04:00
Drew DeVault
f77d7c2c3d Add distinct keybindings for each compose view 2019-05-14 14:27:28 -04:00
Drew DeVault
29de3297a1 Implement sending emails /o/ 2019-05-14 14:07:27 -04:00
Drew DeVault
6c36e04c1f Add :send-message, prepares & writes email to /tmp 2019-05-14 13:07:48 -04:00
Drew DeVault
3ace4ef732 Handle external message deletions 2019-05-13 20:23:23 -04:00
Drew DeVault
026e8a17ca Handle incoming emails gracefully 2019-05-13 20:16:55 -04:00
Drew DeVault
bb46b2b7e1 Spec out review message screen 2019-05-13 16:53:02 -04:00
Drew DeVault
17bd2dc4db Populate "From" header from config for new emails 2019-05-13 16:04:01 -04:00
Drew DeVault
f37508a539 Implement :{next,prev}-field in compose view 2019-05-12 11:21:28 -04:00
Drew DeVault
2a4dd5cb87 Expand compose focus handling a bit 2019-05-12 00:38:48 -04:00
Drew DeVault
577248f5e1 Add initial compose widget 2019-05-12 00:06:09 -04:00
Drew DeVault
71c13c9078 "Press any key to close" for completed processes 2019-05-11 14:15:29 -04:00
Drew DeVault
72e4b5e2b2 Refactor ctx stashing out of exline 2019-05-11 13:20:29 -04:00
Drew DeVault
8fa4583230 Split ex line text handling into dedicated widget 2019-05-11 13:12:44 -04:00
Simon Ser
a275f65848 lib/msgstore: protect with a mutex
MessageStore has a lot of exported fields that can be read from the outside.
Each read must be protected, because a call from Update could happen at any
time.
2019-04-29 09:49:48 -04:00
Simon Ser
f1698a337e widgets/msglist: fix MessageList.store race
This field could be written to in the middle of a Draw call, which reads it
multiple times. Use an atomic variable instead.
2019-04-29 09:49:39 -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
Simon Ser
2159eb876e widgets/spinner: fix Spinner.frame race
It's accessed by the goroutine which increments it and the goroutine that draws
the widget at the same time. Use atomic instead.

    Write at 0x00c00000ebc0 by goroutine 7:
      git.sr.ht/~sircmpwn/aerc2/widgets.(*Spinner).Start.func1()
          /home/simon/src/aerc2/widgets/spinner.go:50 +0x169

    Previous read at 0x00c00000ebc0 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:44 +0x8b
      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
2019-04-27 11:42:12 -04:00
Drew DeVault
2925bdfd6c Re-render terminal on invalidate 2019-04-15 16:07:05 -04:00
Tom Lebreux
3cd0d5bc28 Fix segfault on :view-message for unloaded message
This also fixes segfault on :view-message on empty directory

Signed-off-by: Tom Lebreux <tomlebreux@cock.li>
2019-04-10 15:40:06 -04:00
Gokberk Yaltirakli
ec09ec8b0e Lowercase MIME types while matching filters 2019-04-07 14:12:19 -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
Tom Lebreux
41212a717e Fix infinite loop on empty DirectoryContents
When changing to an empty directory, ml.selected is 0, and the length
of ml.store.Uids is 0. The loop condition is always true so we have
an infinite loop causing 100% CPU usage and prevents us to change to
other directories.

Signed-off-by: Tom Lebreux <tomlebreux@cock.li>
2019-04-05 15:24:00 -04:00
Drew DeVault
8a42dfc87c Show (no messages) for empty folders 2019-04-04 14:25:51 -04:00
Drew DeVault
315cdf308a Remove extra debug statement 2019-03-31 15:21:33 -04:00
Drew DeVault
36419d85aa Use shell to execute filters, fix non-determinism 2019-03-31 15:21:04 -04:00
Drew DeVault
8e5ed2a161 Implement header-regex-match filters 2019-03-31 14:42:18 -04:00
Drew DeVault
f9262e4b06 Improve error handling in message viewer
Still not great but at least it tells you when something went wrong
2019-03-31 14:32:26 -04:00
Drew DeVault
bbdf9df75e Add basic filter implementation 2019-03-31 14:24:53 -04:00
Drew DeVault
711d22891b Decode messages before rendering them 2019-03-31 13:36:37 -04:00
Drew DeVault
0abafa60e1 Make message viewer real, part two 2019-03-31 12:35:51 -04:00
Drew DeVault
27b25174e2 Make the message viewer real, part one 2019-03-31 12:14:37 -04:00
Drew DeVault
5d0402aeea Add message view commands, :close 2019-03-30 21:45:41 -04:00
Drew DeVault
4bdc0f3715 Minor refactoring to header view 2019-03-30 16:50:14 -04:00
Drew DeVault
fd27a2baf6 Fix crash on command not found 2019-03-30 16:29:52 -04:00
Drew DeVault
78db7ccafa Use bold instead of inverted for header names 2019-03-30 15:59:42 -04:00