Commit graph

32 commits

Author SHA1 Message Date
Drew DeVault
fa5d8d7a00 Advance cursor after :delete and :move
So that you can repeat the action on the next message if appropriate
2019-05-19 18:21:02 -04:00
Drew DeVault
f9251c2344 Reset message list cursor when switching stores 2019-05-19 18:18:48 -04:00
Drew DeVault
13032734cd Advance message list cursor when messages arrive 2019-05-19 18:18:48 -04:00
Simon Ser
a15ea01cfb Update internal state and draw from the same goroutine
This commit introduces a new Aerc.Tick function that should be called to
refresh the internal state. This in turn makes each AccountView process worker
events.

The UI goroutine repeatedly refreshes the internal state before drawing a new
frame. The reason for this is that many worker messages may need to be
processed for a single frame, and drawing the UI is far slower than refreshing
the internal state. This has been confirmed in my testing (calling Aerc.Tick
only once per frame results in a slower display).

Many synchronization code has been removed. We can now write widgets without
having to care so much about races. The remaining sync users are:

- widgets/spinner: the spinner value is updated from inside an internal
  goroutine
- lib/ui/invalidatable: Invalidate may be called from any goroutine
- lib/ui/grid: same
- lib/ui/ui: an internal goroutine needs read access to UI.exit
- worker/types/worker: Worker.callbacks is used for both worker and UI
  callbacks

The exact goroutine requirements for Drawable have been documented.
2019-05-19 11:51:16 -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
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
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
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
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
84965d680c Use tcell.Style.Reverse instead of black on white 2019-03-30 12:59:18 -04:00
Drew DeVault
4465646fed Show deleted emails pending server ack in grey
TODO: Don't let the user select or interact with deleted messages
2019-03-30 10:41:12 -04:00
Drew DeVault
77ede6eb5a Add body fetching support code 2019-03-29 22:36:15 -04:00
Drew DeVault
0b26241b42 Improve cursor handling in embedded terminal 2019-03-21 21:00:03 -04:00
Drew DeVault
312a53e5ff Implement :delete-message 2019-03-20 23:23:38 -04:00
Drew DeVault
c0146efaae Fix scrolling issues on :select-message 2019-03-17 17:51:14 -04:00
Drew DeVault
13ba53c9d0 Implement :select-message 2019-03-15 22:01:20 -04:00
Drew DeVault
52a97c02ae Implement scrolling in message list 2019-03-15 21:49:40 -04:00
Drew DeVault
e780c6ee96 Implement :next-message n% 2019-03-15 21:41:39 -04:00
Drew DeVault
ef6178a12a Move MessageStore into its own file 2019-03-15 21:36:06 -04:00
Drew DeVault
24dfc47126 Rig up key bindings 2019-03-15 01:46:14 -04:00
Drew DeVault
24daef89e0 Implement :{next,prev}-message 2019-03-14 23:41:25 -04:00
Drew DeVault
4c8feb9aa5 Invalidate when UIDs finish downloading 2019-03-14 23:31:56 -04:00
Drew DeVault
de364846cc Display message subjects in message list 2019-03-14 22:19:04 -04:00
Drew DeVault
11f0a7267f Implement message store side of message fetching 2019-03-14 21:51:29 -04:00
Drew DeVault
0f8b7a1203 Lay out message list widget basic design 2019-03-14 21:37:00 -04:00
Drew DeVault
b3896476a0 Fetch valid UIDs from server after opening dir 2019-03-10 23:45:00 -04:00