Commit Graph

14 Commits (0e3a0c4b7049139994a65c6fe914dd3587c6713e)

Author SHA1 Message Date
Manos Pitsidianakis 0e3a0c4b70
Add safe UI widget area drawing API
Make Screen generic over its display kind: Screen<Tty> and
Screen<Virtual>. The latter is for "cached" renderings we want to keep
and copy to the actual screen when the Component::draw() method is
called. Only Screen<Tty> can write to stdout and it needs an stdout
handle.

Add a generation integer field to Screen, that changes each time it is
resized. This way, we can track if "stale" areas are used and panic on
runtime (in debug mode).

Introduce a new type, Area, that keeps metadata about a subsection of a
Screen, and the generation it came from. New areas can only be created
from a Screen and by operating on an Area to create subsections of it.

This way, it's impossible to make an area refer to (x, y) cells outside
the screen generation of its provenance. If stabilised this API should
eliminate all out of bounds accesses in CellBuffers.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2023-12-02 17:20:37 +02:00
Manos Pitsidianakis 7645ff1b87
terminal/cells: rename write_string{to_grid,}
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2023-11-30 11:04:05 +02:00
Manos Pitsidianakis e0adcdfe15
terminal/cells: move rest of methods under CellBuffer
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2023-11-30 11:04:05 +02:00
Manos Pitsidianakis ab14f81900
terminal/cells: make write_string_to_grid a CellBuffer method
For future reference, refactoring was done with comby:

comby -review ":[w~\s]write_string_to_grid(:[s], &mut :[var],:[rest])" ":[var].write_string_to_grid(:[s],:[rest])" .rs
comby -review ":[w~\s]write_string_to_grid(:[s],:[var],:[rest])" ":[var].write_string_to_grid(:[s],:[rest])" .rs

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2023-11-30 11:04:05 +02:00
Manos Pitsidianakis 7e3e938631
mail/view: fix out-of-bounds draw when terminal is small
Tests / Test on ${{ matrix.build }} (linux-amd64, ubuntu-latest, stable, x86_64-unknown-linux-gnu) (pull_request) Successful in 9m52s Details
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2023-09-07 12:37:24 +03:00
Manos Pitsidianakis f0075b86cf
ui: show descriptive tab names for composer and threads
Instead of showing the nondescript tab names in the tab area,
use Subject or To: data from the draft in the composer and a subject
from the thread entries.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2023-09-03 10:17:24 +03:00
Manos Pitsidianakis 0a9c89b6b3
mail/view/thread: add toggle_layout shortcut
Tests / Test on ${{ matrix.build }} (linux-amd64, ubuntu-latest, stable, x86_64-unknown-linux-gnu) (pull_request) Successful in 14m12s Details
Tests / Test on ${{ matrix.build }} (linux-amd64, ubuntu-latest, stable, x86_64-unknown-linux-gnu) (push) Successful in 7m52s Details
Toggles between horizontal and vertical layout. Previously it was
decided on the terminal width.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2023-09-02 21:47:14 +03:00
Manos Pitsidianakis 49c36009ce
mail/view: don't initialize entire thread at once
For large threads, this would result in a lot of futures being created.
The user just wants to read one entry, not all of them. So prioritize
the open entry and some of the latest ones as an optimistic
pre-fetching.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2023-09-02 21:29:35 +03:00
Manos Pitsidianakis c7825c76c3
mail/view: handle dialog Esc in the parent component
Dialogues handled Esc themselves, which meant the event didn't bubble up
to their parent to let them know they should remove the dialogue. This
commit fixes that.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2023-09-02 21:29:35 +03:00
Manos Pitsidianakis 3344a8dbf6
mail/view: remove unnecessary Clone derives
There's no need to clone MailViews when opening them in new tabs,
just initialize new ones with the same metadata. That saves us the
trouble of implementing Clone for all related types.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2023-09-02 19:36:12 +03:00
Manos Pitsidianakis 1b3bebe304
view/thread: open earliest unread email instead of first in thread
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2023-09-02 19:04:35 +03:00
Manos Pitsidianakis 64982b4cab
mail/view/thread: fix page{up,down} event bubbling up
When pressing PageUp, PageDown, Home, End shortcuts in ThreadView
entries, the event is bubbled up to the mailbox listing because
ThreadView::process_event() didn't return `true`. This commit fixes
this bug.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2023-08-25 18:20:56 +03:00
Manos Pitsidianakis f93adb683a
meli/terminal: replace change_color uses with change_theme
change_color() predated addition of Cell Attributes (Bold, Underline,
etc) so it didn't accept an attribute argument.

This commit adds a change_theme() function that does the same thing as
change_color() but also sets the cell attributes. It also takes a
ThemeAttribute as an argument instead of {fg, bg, attrs} individually.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2023-08-21 12:45:15 +03:00
Manos Pitsidianakis 7c9a4b4b7c
meli: Move components/mail -> mail 2023-08-11 13:01:32 +03:00