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>pull/299/head
parent
a615b4701b
commit
f0075b86cf
|
@ -138,14 +138,20 @@ impl ViewMode {
|
|||
|
||||
impl std::fmt::Display for Composer {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
if self.reply_context.is_some() {
|
||||
write!(
|
||||
f,
|
||||
"reply: {}",
|
||||
(&self.draft.headers()[HeaderName::SUBJECT]).trim_at_boundary(8)
|
||||
)
|
||||
let subject = self.draft.headers().get(HeaderName::SUBJECT);
|
||||
if let Some(ref val) = subject.filter(|s| !s.is_empty()) {
|
||||
val.trim_at_boundary(4);
|
||||
write!(f, "{}", val)
|
||||
} else if let Some(ref val) = self
|
||||
.draft
|
||||
.headers()
|
||||
.get(HeaderName::TO)
|
||||
.filter(|s| !s.is_empty())
|
||||
{
|
||||
val.trim_at_boundary(4);
|
||||
write!(f, "to {}", val)
|
||||
} else {
|
||||
write!(f, "composing")
|
||||
write!(f, "draft")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1195,6 +1201,7 @@ impl Component for Composer {
|
|||
&& self.form.process_event(event, context)
|
||||
{
|
||||
if let UIEvent::InsertInput(_) = event {
|
||||
self.update_draft();
|
||||
self.has_changes = true;
|
||||
}
|
||||
self.set_dirty(true);
|
||||
|
|
|
@ -69,7 +69,7 @@ pub struct MailView {
|
|||
|
||||
impl std::fmt::Display for MailView {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "view mail")
|
||||
self.state.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use melib::{Envelope, Error, Mail, Result};
|
||||
use melib::{text_processing::Truncate, Envelope, Error, Mail, Result};
|
||||
|
||||
use super::{EnvelopeView, MailView, ViewSettings};
|
||||
use crate::{jobs::JoinHandle, mailbox_settings, Component, Context, ShortcutMaps, UIEvent};
|
||||
|
@ -53,6 +53,23 @@ pub enum MailViewState {
|
|||
},
|
||||
}
|
||||
|
||||
impl std::fmt::Display for MailViewState {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Init { .. } | Self::LoadingBody { .. } => {
|
||||
write!(fmt, "loading")
|
||||
}
|
||||
Self::Error { err } => {
|
||||
let err = err.to_string();
|
||||
write!(fmt, "{}", err.trim_at_boundary(8))
|
||||
}
|
||||
Self::Loaded { env, .. } => {
|
||||
write!(fmt, "{}", env.subject().as_ref().trim_at_boundary(8))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MailViewState {
|
||||
pub fn load_bytes(self_: &mut MailView, bytes: Vec<u8>, context: &mut Context) {
|
||||
let Some(coordinates) = self_.coordinates else {
|
||||
|
|
|
@ -1034,8 +1034,12 @@ impl ThreadView {
|
|||
}
|
||||
|
||||
impl std::fmt::Display for ThreadView {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "view thread")
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
if let Some(e) = self.entries.get(0) {
|
||||
e.mailview.fmt(fmt)
|
||||
} else {
|
||||
write!(fmt, "view thread")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -860,8 +860,8 @@ impl Tabbed {
|
|||
let bottom_right = bottom_right!(area);
|
||||
|
||||
let tab_bar_attribute = crate::conf::value(context, "tab.bar");
|
||||
clear_area(grid, area, tab_bar_attribute);
|
||||
if self.children.is_empty() {
|
||||
clear_area(grid, area, tab_bar_attribute);
|
||||
return;
|
||||
}
|
||||
let tab_unfocused_attribute = crate::conf::value(context, "tab.unfocused");
|
||||
|
@ -929,6 +929,7 @@ impl Tabbed {
|
|||
|
||||
context.dirty_areas.push_back(area);
|
||||
}
|
||||
|
||||
pub fn add_component(&mut self, new: Box<dyn Component>, context: &mut Context) {
|
||||
new.realize(self.id().into(), context);
|
||||
self.children.push(new);
|
||||
|
|
Loading…
Reference in New Issue