ui: fix pager from_buf reflowing incompatibility
parent
0b76307e30
commit
2b06dd1aca
|
@ -326,17 +326,25 @@ impl Component for MailView {
|
||||||
}
|
}
|
||||||
ViewMode::Subview | ViewMode::ContactSelector(_) => {}
|
ViewMode::Subview | ViewMode::ContactSelector(_) => {}
|
||||||
_ => {
|
_ => {
|
||||||
let buf = {
|
let text = {
|
||||||
|
self.attachment_to_text(&body)
|
||||||
|
/*
|
||||||
let text = self.attachment_to_text(&body);
|
let text = self.attachment_to_text(&body);
|
||||||
// URL indexes must be colored (ugh..)
|
// URL indexes must be colored (ugh..)
|
||||||
MailView::plain_text_to_buf(&text, self.mode == ViewMode::Url)
|
MailView::plain_text_to_buf(&text, self.mode == ViewMode::Url)
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
let cursor_pos = if self.mode.is_attachment() {
|
let cursor_pos = if self.mode.is_attachment() {
|
||||||
Some(0)
|
Some(0)
|
||||||
} else {
|
} else {
|
||||||
self.pager.as_mut().map(|p| p.cursor_pos())
|
self.pager.as_mut().map(|p| p.cursor_pos())
|
||||||
};
|
};
|
||||||
self.pager = Some(Pager::from_buf(buf.split_newlines(), cursor_pos));
|
self.pager = Some(Pager::from_string(
|
||||||
|
text,
|
||||||
|
Some(context),
|
||||||
|
cursor_pos,
|
||||||
|
Some(width!(area)),
|
||||||
|
));
|
||||||
self.subview = None;
|
self.subview = None;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -160,6 +160,9 @@ impl EnvelopeView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* TODO: add recolor changes so that this function returns a vector of required highlights
|
||||||
|
* to pass to write_string...
|
||||||
pub fn plain_text_to_buf(s: &str, highlight_urls: bool) -> CellBuffer {
|
pub fn plain_text_to_buf(s: &str, highlight_urls: bool) -> CellBuffer {
|
||||||
let mut buf = CellBuffer::from(s);
|
let mut buf = CellBuffer::from(s);
|
||||||
|
|
||||||
|
@ -192,6 +195,7 @@ impl EnvelopeView {
|
||||||
}
|
}
|
||||||
buf
|
buf
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component for EnvelopeView {
|
impl Component for EnvelopeView {
|
||||||
|
@ -294,17 +298,25 @@ impl Component for EnvelopeView {
|
||||||
self.mode = ViewMode::Subview;
|
self.mode = ViewMode::Subview;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let buf = {
|
let text = {
|
||||||
|
self.attachment_to_text(&body)
|
||||||
|
/*
|
||||||
let text = self.attachment_to_text(&body);
|
let text = self.attachment_to_text(&body);
|
||||||
// URL indexes must be colored (ugh..)
|
// URL indexes must be colored (ugh..)
|
||||||
EnvelopeView::plain_text_to_buf(&text, self.mode == ViewMode::Url)
|
EnvelopeView::plain_text_to_buf(&text, self.mode == ViewMode::Url)
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
let cursor_pos = if self.mode.is_attachment() {
|
let cursor_pos = if self.mode.is_attachment() {
|
||||||
Some(0)
|
Some(0)
|
||||||
} else {
|
} else {
|
||||||
self.pager.as_mut().map(|p| p.cursor_pos())
|
self.pager.as_mut().map(|p| p.cursor_pos())
|
||||||
};
|
};
|
||||||
self.pager = Some(Pager::from_buf(buf.split_newlines(), cursor_pos));
|
self.pager = Some(Pager::from_string(
|
||||||
|
text,
|
||||||
|
Some(context),
|
||||||
|
cursor_pos,
|
||||||
|
Some(width!(area)),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.dirty = false;
|
self.dirty = false;
|
||||||
|
@ -380,7 +392,7 @@ impl Component for EnvelopeView {
|
||||||
self.mode = ViewMode::Subview;
|
self.mode = ViewMode::Subview;
|
||||||
self.subview = Some(Box::new(Pager::from_string(
|
self.subview = Some(Box::new(Pager::from_string(
|
||||||
String::from_utf8_lossy(&decode_rec(u, None)).to_string(),
|
String::from_utf8_lossy(&decode_rec(u, None)).to_string(),
|
||||||
context,
|
Some(context),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
)));
|
)));
|
||||||
|
|
|
@ -49,8 +49,7 @@ impl HtmlView {
|
||||||
&html_filter.wait_with_output().unwrap().stdout,
|
&html_filter.wait_with_output().unwrap().stdout,
|
||||||
));
|
));
|
||||||
|
|
||||||
let buf = MailView::plain_text_to_buf(&display_text, true);
|
let pager = Pager::from_string(display_text, None, None, None);
|
||||||
let pager = Pager::from_buf(buf.split_newlines(), None);
|
|
||||||
HtmlView { pager, bytes }
|
HtmlView { pager, bytes }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,12 +254,17 @@ impl Pager {
|
||||||
}
|
}
|
||||||
pub fn from_string(
|
pub fn from_string(
|
||||||
mut text: String,
|
mut text: String,
|
||||||
context: &mut Context,
|
context: Option<&Context>,
|
||||||
cursor_pos: Option<usize>,
|
cursor_pos: Option<usize>,
|
||||||
width: Option<usize>,
|
width: Option<usize>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let pager_filter: Option<&String> = context.settings.pager.filter.as_ref();
|
let pager_filter: Option<&String> = if let Some(context) = context {
|
||||||
|
context.settings.pager.filter.as_ref()
|
||||||
//let format_flowed: bool = context.settings.pager.format_flowed;
|
//let format_flowed: bool = context.settings.pager.format_flowed;
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(bin) = pager_filter {
|
if let Some(bin) = pager_filter {
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
|
|
|
@ -157,9 +157,11 @@ impl Component for Field {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UIEventType::InsertInput(Key::Char(k)) => if let Text(ref mut s, _) = self {
|
UIEventType::InsertInput(Key::Char(k)) => {
|
||||||
s.insert_char(k);
|
if let Text(ref mut s, _) = self {
|
||||||
},
|
s.insert_char(k);
|
||||||
|
}
|
||||||
|
}
|
||||||
UIEventType::InsertInput(Key::Backspace) => match self {
|
UIEventType::InsertInput(Key::Backspace) => match self {
|
||||||
Text(ref mut s, auto_complete) => {
|
Text(ref mut s, auto_complete) => {
|
||||||
s.backspace();
|
s.backspace();
|
||||||
|
|
Loading…
Reference in New Issue