ui: Add some docs and mini cleanups
parent
9b4b6051f1
commit
b741899fcf
|
@ -163,6 +163,13 @@ pub trait MailBackend: ::std::fmt::Debug {
|
|||
/// We need a way to do various operations on individual mails regardless of what backend they come
|
||||
/// from (eg local or imap).
|
||||
///
|
||||
/// # Creation
|
||||
/// ```no_run
|
||||
/// /* Create operation from Backend */
|
||||
///
|
||||
/// let op = backend.operation(message.hash(), mailbox.folder.hash());
|
||||
/// ```
|
||||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// use melib::mailbox::backends::{BackendOp, BackendOpGenerator};
|
||||
|
@ -193,7 +200,6 @@ pub trait MailBackend: ::std::fmt::Debug {
|
|||
/// let foogen = BackendOpGenerator::new(Box::new(|| Box::new(FooOp {})));
|
||||
/// let operation = foogen.generate();
|
||||
/// assert_eq!("Foobar", &operation.description());
|
||||
///
|
||||
/// ```
|
||||
pub trait BackendOp: ::std::fmt::Debug + ::std::marker::Send {
|
||||
fn description(&self) -> String;
|
||||
|
|
|
@ -301,7 +301,7 @@ impl Component for Composer {
|
|||
let area = (upper_left, set_x(bottom_right, mid - 1));
|
||||
let view = &mut self.reply_context.as_mut().unwrap().1;
|
||||
view.set_dirty();
|
||||
view.draw(grid, std::dbg!(area), context);
|
||||
view.draw(grid, area, context);
|
||||
}
|
||||
|
||||
let header_area = if self.reply_context.is_some() {
|
||||
|
@ -328,12 +328,12 @@ impl Component for Composer {
|
|||
change_colors(grid, (set_x(pos_dec(upper_left!(header_area), (0, 1)), x), set_y(bottom_right!(header_area), y)), Color::Byte(189), Color::Byte(167));
|
||||
|
||||
/* Regardless of view mode, do the following */
|
||||
self.form.draw(grid, std::dbg!(header_area), context);
|
||||
self.form.draw(grid, header_area, context);
|
||||
|
||||
match self.mode {
|
||||
ViewMode::Overview | ViewMode::Pager => {
|
||||
self.pager.set_dirty();
|
||||
self.pager.draw(grid, std::dbg!(body_area), context);
|
||||
self.pager.draw(grid, body_area, context);
|
||||
}
|
||||
ViewMode::Discard(_) => {
|
||||
/* Let user choose whether to quit with/without saving or cancel */
|
||||
|
|
|
@ -406,7 +406,7 @@ impl ThreadView {
|
|||
|
||||
/* First draw the thread subject on the first row */
|
||||
let y = {
|
||||
let mailbox = &mut context.accounts[self.coordinates.0][self.coordinates.1]
|
||||
let mailbox = &context.accounts[self.coordinates.0][self.coordinates.1]
|
||||
.as_ref()
|
||||
.unwrap();
|
||||
let threads = &mailbox.collection.threads;
|
||||
|
|
|
@ -12,10 +12,15 @@ pub struct Shortcuts {
|
|||
pub pager: PagerShortcuts,
|
||||
}
|
||||
|
||||
/// Create a struct holding all of a Component's shortcuts.
|
||||
#[macro_export]
|
||||
macro_rules! key_values {
|
||||
( $cname:expr, derive ($($derives:ident),*) : pub struct $name:ident { $($fname:ident : Key |> $fdesc:expr),* }) => {
|
||||
#[derive($($derives),*)]
|
||||
macro_rules! shortcut_key_values {
|
||||
(
|
||||
$cname:expr,
|
||||
$(#[$outer:meta])*
|
||||
pub struct $name:ident { $($fname:ident : Key |> $fdesc:expr),* }) => {
|
||||
$(#[$outer])*
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(default)]
|
||||
#[serde(rename = $cname)]
|
||||
pub struct $name {
|
||||
|
@ -23,12 +28,14 @@ macro_rules! key_values {
|
|||
}
|
||||
|
||||
impl $name {
|
||||
/// Returns a shortcut's description
|
||||
pub fn key_desc(&self, key: &str) -> &'static str {
|
||||
match key {
|
||||
$(stringify!($fname) => $fdesc),*,
|
||||
_ => unreachable!()
|
||||
}
|
||||
}
|
||||
/// Returns a hashmap of all shortcuts and their values
|
||||
pub fn key_values(&self) -> FnvHashMap<&'static str, &Key> {
|
||||
let mut map: FnvHashMap<&'static str, &Key> = Default::default();
|
||||
$(map.insert(stringify!($fname),&(self.$fname));)*
|
||||
|
@ -38,7 +45,8 @@ macro_rules! key_values {
|
|||
}
|
||||
}
|
||||
|
||||
key_values! { "compact-listing", derive (Debug, Clone, Deserialize) :
|
||||
shortcut_key_values! { "compact-listing",
|
||||
/// Shortcut listing for a mail listing in compact mode.
|
||||
pub struct CompactListingShortcuts {
|
||||
open_thread: Key |> "Open thread.",
|
||||
exit_thread: Key |> "Exit thread view.",
|
||||
|
@ -68,7 +76,8 @@ impl Default for CompactListingShortcuts {
|
|||
}
|
||||
}
|
||||
|
||||
key_values! { "contact-list", derive (Debug, Clone, Deserialize) :
|
||||
shortcut_key_values! { "contact-list",
|
||||
/// Shortcut listing for the contact list view
|
||||
pub struct ContactListShortcuts {
|
||||
create_contact: Key |> "Create new contact.",
|
||||
edit_contact: Key |> "Edit contact under cursor."
|
||||
|
@ -84,7 +93,8 @@ impl Default for ContactListShortcuts {
|
|||
}
|
||||
}
|
||||
|
||||
key_values! { "pager", derive (Debug, Clone, Deserialize) :
|
||||
shortcut_key_values! { "pager",
|
||||
/// Shortcut listing for the text pager
|
||||
pub struct PagerShortcuts {
|
||||
scroll_up: Key |> "Scroll up pager.",
|
||||
scroll_down: Key |> "Scroll down pager.",
|
||||
|
|
|
@ -762,7 +762,6 @@ pub fn word_break_string(mut s: &str, width: usize) -> Vec<&str> {
|
|||
{
|
||||
let next_idx = graphemes[next_idx].0;
|
||||
ret.push(&s[..next_idx]);
|
||||
eprintln!("width = {} w = {} l = {:?}\n\n", width, ret.last().unwrap().grapheme_width(), ret.last().unwrap());
|
||||
s = &s[next_idx + 1..];
|
||||
} else {
|
||||
ret.push(&s[..width]);
|
||||
|
|
|
@ -170,8 +170,9 @@ macro_rules! csi {
|
|||
|
||||
/// Derive a CSI sequence struct.
|
||||
macro_rules! derive_csi_sequence {
|
||||
($doc:expr, $name:ident, $value:expr) => {
|
||||
///$doc
|
||||
($(#[$outer:meta])*
|
||||
($name:ident, $value:expr)) => {
|
||||
$(#[$outer])*
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct $name;
|
||||
|
||||
|
@ -195,8 +196,9 @@ macro_rules! derive_csi_sequence {
|
|||
};
|
||||
}
|
||||
|
||||
derive_csi_sequence!("Start Bracketed Paste Mode", BracketModeStart, "?2004h"); //
|
||||
derive_csi_sequence!("End Bracketed Paste Mode", BracketModeEnd, "?2003l");
|
||||
derive_csi_sequence!(#[doc="Empty struct with a Display implementation that returns the byte sequence to start [Bracketed Paste Mode](http://www.xfree86.org/current/ctlseqs.html#Bracketed%20Paste%20Mode)"] (BracketModeStart, "?2004h"));
|
||||
|
||||
derive_csi_sequence!(#[doc="Empty struct with a Display implementation that returns the byte sequence to end [Bracketed Paste Mode](http://www.xfree86.org/current/ctlseqs.html#Bracketed%20Paste%20Mode)"] (BracketModeEnd, "?2003l"));
|
||||
|
||||
pub const BRACKET_PASTE_START: &[u8] = b"\x1B[200~";
|
||||
pub const BRACKET_PASTE_END: &[u8] = b"\x1B[201~";
|
||||
|
|
Loading…
Reference in New Issue