fix: Header display, mode toggle, and help screen improvements

- Fix toggle_mode to pass envelope context when reloading (preserves compression)
- Add CSS for header labels: single-line with text-overflow ellipsis
- Add 'full-headers' CSS class for toggling between compressed/full view
- Store full subject in header for proper refresh on toggle
- Update HelpScreen with missing shortcuts (o, b) and better descriptions
- Fix duplicate line in _refresh_display
This commit is contained in:
Bendt
2025-12-29 11:22:26 -05:00
parent 279beeabcc
commit de61795476
3 changed files with 54 additions and 14 deletions

View File

@@ -73,10 +73,25 @@ StatusTitle {
EnvelopeHeader {
dock: top;
width: 100%;
max-height: 2;
height: auto;
max-height: 10;
padding: 0 1;
tint: $primary 10%;
}
/* Header labels should be single line with truncation */
EnvelopeHeader Label {
width: 100%;
height: 1;
text-overflow: ellipsis;
}
/* Full headers mode - allow wrapping */
EnvelopeHeader.full-headers Label {
height: auto;
text-overflow: clip;
}
Markdown {
padding: 1 2;
}

View File

@@ -66,10 +66,12 @@ class HelpScreen(Screen):
yield Static(" j/k - Next/Previous message")
yield Static(" g - Go to oldest message")
yield Static(" G - Go to newest message")
yield Static(" b - Scroll page up")
yield Static(" PageDown/PageUp - Scroll page down/up")
yield Static("")
yield Static("[b green]Message Actions[/b green]")
yield Static(" o - Open message externally")
yield Static(" # - Delete message(s)")
yield Static(" e - Archive message(s)")
yield Static(" u - Toggle read/unread")
@@ -79,8 +81,10 @@ class HelpScreen(Screen):
yield Static("[b green]View Options[/b green]")
yield Static(" w - Toggle message view window")
yield Static(" m - Toggle markdown/html view mode")
yield Static(" h - Toggle envelope header")
yield Static(
" m - Toggle markdown/html view (or compressed/html for notifications)"
)
yield Static(" h - Toggle full/compressed envelope headers")
yield Static("")
yield Static("[b green]Search & Filter[/b green]")

View File

@@ -122,12 +122,13 @@ class EnvelopeHeader(Vertical):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.subject_label = Label("")
self.from_label = Label("")
self.to_label = Label("")
self.date_label = Label("")
self.cc_label = Label("")
self.subject_label = Label("", id="header_subject")
self.from_label = Label("", id="header_from")
self.to_label = Label("", id="header_to")
self.date_label = Label("", id="header_date")
self.cc_label = Label("", id="header_cc")
# Store full values for toggle
self._full_subject = ""
self._full_to = ""
self._full_cc = ""
self._full_from = ""
@@ -212,18 +213,30 @@ class EnvelopeHeader(Vertical):
def toggle_full_headers(self) -> None:
"""Toggle between compressed and full header view."""
self.show_full_headers = not self.show_full_headers
# Update CSS class for styling
if self.show_full_headers:
self.add_class("full-headers")
else:
self.remove_class("full-headers")
self._refresh_display()
def _refresh_display(self) -> None:
"""Refresh the display based on current mode."""
if self.show_full_headers:
# Full view - show complete text
self.subject_label.update(
f"[b bright_white]{self._full_subject}[/b bright_white]"
)
self.from_label.update(f"[b]From:[/b] {self._full_from}")
self.to_label.update(f"[b]To:[/b] {self._full_to}")
if self._full_cc:
self.cc_label.update(f"[b]CC:[/b] {self._full_cc}")
self.cc_label.styles.display = "block"
else:
# Compressed view
# Compressed view - truncate for single line display
self.subject_label.update(
f"[b bright_white]{self._full_subject}[/b bright_white]"
)
self.from_label.update(
f"[b]From:[/b] {self._compress_recipients(self._full_from, max_shown=1)}"
)
@@ -238,13 +251,11 @@ class EnvelopeHeader(Vertical):
def update(self, subject, from_, to, date, cc=None):
# Store full values
self._full_subject = subject or ""
self._full_from = from_ or ""
self._full_to = to or ""
self._full_cc = cc or ""
# Subject is prominent - bold, bright white, no label needed
self.subject_label.update(f"[b bright_white]{subject}[/b bright_white]")
# Format the date for better readability
if date:
try:
@@ -334,15 +345,25 @@ class ContentContainer(ScrollableContainer):
self.border_subtitle = f"{mode_icon} {mode_label}"
async def action_toggle_mode(self):
"""Toggle between markdown and HTML viewing modes."""
"""Toggle between markdown/compressed and HTML viewing modes.
For notification emails: cycles between compressed view and HTML.
For regular emails: cycles between markdown and HTML.
"""
if self.current_mode == "html":
self.current_mode = "markdown"
else:
self.current_mode = "html"
# Reload the content if we have a message ID
# This will re-apply compression if applicable for markdown mode
if self.current_message_id:
self.display_content(self.current_message_id)
self.display_content(
self.current_message_id,
folder=self.current_folder,
account=self.current_account,
envelope=self.current_envelope,
)
def update_header(self, subject, from_, to, date, cc=None):
self.header.update(subject, from_, to, date, cc)