Fix clippy warnings
parent
d4c64916f0
commit
5e306130fb
|
@ -146,7 +146,7 @@ impl Card {
|
||||||
self.id = new;
|
self.id = new;
|
||||||
}
|
}
|
||||||
pub fn set_title(&mut self, new: &str) {
|
pub fn set_title(&mut self, new: &str) {
|
||||||
self.title = new.to_string();()
|
self.title = new.to_string();
|
||||||
}
|
}
|
||||||
pub fn set_firstname(&mut self, new: &str) {
|
pub fn set_firstname(&mut self, new: &str) {
|
||||||
self.firstname = new.to_string();
|
self.firstname = new.to_string();
|
||||||
|
@ -217,3 +217,9 @@ impl From<FnvHashMap<String, String>> for Card {
|
||||||
card
|
card
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Card {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ impl Backends {
|
||||||
self.map[key]()
|
self.map[key]()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register(&mut self, key: String, backend: Box<Fn() -> BackendCreator>) -> () {
|
pub fn register(&mut self, key: String, backend: Box<Fn() -> BackendCreator>) {
|
||||||
if self.map.contains_key(&key) {
|
if self.map.contains_key(&key) {
|
||||||
panic!("{} is an already registered backend", key);
|
panic!("{} is an already registered backend", key);
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ impl RefreshEventConsumer {
|
||||||
pub fn new(b: Box<Fn(RefreshEvent) -> ()>) -> Self {
|
pub fn new(b: Box<Fn(RefreshEvent) -> ()>) -> Self {
|
||||||
RefreshEventConsumer(b)
|
RefreshEventConsumer(b)
|
||||||
}
|
}
|
||||||
pub fn send(&self, r: RefreshEvent) -> () {
|
pub fn send(&self, r: RefreshEvent) {
|
||||||
self.0(r);
|
self.0(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ impl NotifyFn {
|
||||||
pub fn new(b: Box<Fn() -> ()>) -> Self {
|
pub fn new(b: Box<Fn() -> ()>) -> Self {
|
||||||
NotifyFn(b)
|
NotifyFn(b)
|
||||||
}
|
}
|
||||||
pub fn notify(&self) -> () {
|
pub fn notify(&self) {
|
||||||
self.0();
|
self.0();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ pub trait BackendOp: ::std::fmt::Debug + ::std::marker::Send {
|
||||||
fn fetch_headers(&mut self) -> Result<&[u8]>;
|
fn fetch_headers(&mut self) -> Result<&[u8]>;
|
||||||
fn fetch_body(&mut self) -> Result<&[u8]>;
|
fn fetch_body(&mut self) -> Result<&[u8]>;
|
||||||
fn fetch_flags(&self) -> Flag;
|
fn fetch_flags(&self) -> Flag;
|
||||||
fn set_flag(&mut self, &mut Envelope, &Flag) -> Result<()>;
|
fn set_flag(&mut self, &mut Envelope, Flag) -> Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `BackendOpGenerator` is a wrapper for a closure that returns a `BackendOp` object
|
/// `BackendOpGenerator` is a wrapper for a closure that returns a `BackendOp` object
|
||||||
|
|
|
@ -123,7 +123,7 @@ impl<'a> BackendOp for MaildirOp {
|
||||||
flag
|
flag
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_flag(&mut self, envelope: &mut Envelope, f: &Flag) -> Result<()> {
|
fn set_flag(&mut self, envelope: &mut Envelope, f: Flag) -> Result<()> {
|
||||||
let path = self.path();
|
let path = self.path();
|
||||||
let path = path.to_str().unwrap(); // Assume UTF-8 validity
|
let path = path.to_str().unwrap(); // Assume UTF-8 validity
|
||||||
let idx: usize = path
|
let idx: usize = path
|
||||||
|
@ -132,10 +132,10 @@ impl<'a> BackendOp for MaildirOp {
|
||||||
+ 3;
|
+ 3;
|
||||||
let mut new_name: String = path[..idx].to_string();
|
let mut new_name: String = path[..idx].to_string();
|
||||||
let mut flags = self.fetch_flags();
|
let mut flags = self.fetch_flags();
|
||||||
if !(flags & *f).is_empty() {
|
if !(flags & f).is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
flags.toggle(*f);
|
flags.toggle(f);
|
||||||
if !(flags & Flag::DRAFT).is_empty() {
|
if !(flags & Flag::DRAFT).is_empty() {
|
||||||
new_name.push('D');
|
new_name.push('D');
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,7 +342,7 @@ impl MailBackend for MaildirType {
|
||||||
eprintln!("saving at {}", path.display());
|
eprintln!("saving at {}", path.display());
|
||||||
let file = fs::File::create(path)?;
|
let file = fs::File::create(path)?;
|
||||||
let mut writer = io::BufWriter::new(file);
|
let mut writer = io::BufWriter::new(file);
|
||||||
writer.write(&message.into_bytes())?;
|
writer.write_all(&message.into_bytes())?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -616,22 +616,22 @@ impl Envelope {
|
||||||
pub fn message_id_raw(&self) -> Cow<str> {
|
pub fn message_id_raw(&self) -> Cow<str> {
|
||||||
String::from_utf8_lossy(self.message_id.raw())
|
String::from_utf8_lossy(self.message_id.raw())
|
||||||
}
|
}
|
||||||
fn set_date(&mut self, new_val: &[u8]) -> () {
|
fn set_date(&mut self, new_val: &[u8]) {
|
||||||
self.date = String::from_utf8_lossy(new_val).into_owned();
|
self.date = String::from_utf8_lossy(new_val).into_owned();
|
||||||
}
|
}
|
||||||
fn set_bcc(&mut self, new_val: Vec<Address>) -> () {
|
fn set_bcc(&mut self, new_val: Vec<Address>) {
|
||||||
self.bcc = new_val;
|
self.bcc = new_val;
|
||||||
}
|
}
|
||||||
fn set_cc(&mut self, new_val: Vec<Address>) -> () {
|
fn set_cc(&mut self, new_val: Vec<Address>) {
|
||||||
self.cc = new_val;
|
self.cc = new_val;
|
||||||
}
|
}
|
||||||
fn set_from(&mut self, new_val: Vec<Address>) -> () {
|
fn set_from(&mut self, new_val: Vec<Address>) {
|
||||||
self.from = new_val;
|
self.from = new_val;
|
||||||
}
|
}
|
||||||
fn set_to(&mut self, new_val: Vec<Address>) -> () {
|
fn set_to(&mut self, new_val: Vec<Address>) {
|
||||||
self.to = new_val;
|
self.to = new_val;
|
||||||
}
|
}
|
||||||
fn set_in_reply_to(&mut self, new_val: &[u8]) -> () {
|
fn set_in_reply_to(&mut self, new_val: &[u8]) {
|
||||||
let slice = match parser::message_id(new_val).to_full_result() {
|
let slice = match parser::message_id(new_val).to_full_result() {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
@ -641,10 +641,10 @@ impl Envelope {
|
||||||
};
|
};
|
||||||
self.in_reply_to = Some(MessageID::new(new_val, slice));
|
self.in_reply_to = Some(MessageID::new(new_val, slice));
|
||||||
}
|
}
|
||||||
fn set_subject(&mut self, new_val: Vec<u8>) -> () {
|
fn set_subject(&mut self, new_val: Vec<u8>) {
|
||||||
self.subject = Some(new_val);
|
self.subject = Some(new_val);
|
||||||
}
|
}
|
||||||
fn set_message_id(&mut self, new_val: &[u8]) -> () {
|
fn set_message_id(&mut self, new_val: &[u8]) {
|
||||||
let slice = match parser::message_id(new_val).to_full_result() {
|
let slice = match parser::message_id(new_val).to_full_result() {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
@ -653,7 +653,7 @@ impl Envelope {
|
||||||
};
|
};
|
||||||
self.message_id = MessageID::new(new_val, slice);
|
self.message_id = MessageID::new(new_val, slice);
|
||||||
}
|
}
|
||||||
fn push_references(&mut self, new_val: &[u8]) -> () {
|
fn push_references(&mut self, new_val: &[u8]) {
|
||||||
let slice = match parser::message_id(new_val).to_full_result() {
|
let slice = match parser::message_id(new_val).to_full_result() {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
@ -685,7 +685,7 @@ impl Envelope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn set_references(&mut self, new_val: &[u8]) -> () {
|
fn set_references(&mut self, new_val: &[u8]) {
|
||||||
match self.references {
|
match self.references {
|
||||||
Some(ref mut s) => {
|
Some(ref mut s) => {
|
||||||
s.raw = new_val.into();
|
s.raw = new_val.into();
|
||||||
|
@ -713,14 +713,14 @@ impl Envelope {
|
||||||
pub fn thread(&self) -> usize {
|
pub fn thread(&self) -> usize {
|
||||||
self.thread
|
self.thread
|
||||||
}
|
}
|
||||||
pub fn set_thread(&mut self, new_val: usize) -> () {
|
pub fn set_thread(&mut self, new_val: usize) {
|
||||||
self.thread = new_val;
|
self.thread = new_val;
|
||||||
}
|
}
|
||||||
pub fn set_datetime(&mut self, new_val: chrono::DateTime<chrono::FixedOffset>) -> () {
|
pub fn set_datetime(&mut self, new_val: chrono::DateTime<chrono::FixedOffset>) {
|
||||||
self.timestamp = new_val.timestamp() as UnixTimestamp;
|
self.timestamp = new_val.timestamp() as UnixTimestamp;
|
||||||
}
|
}
|
||||||
pub fn set_flag(&mut self, f: Flag, mut operation: Box<BackendOp>) -> Result<()> {
|
pub fn set_flag(&mut self, f: Flag, mut operation: Box<BackendOp>) -> Result<()> {
|
||||||
operation.set_flag(self, &f)?;
|
operation.set_flag(self, f)?;
|
||||||
self.flags |= f;
|
self.flags |= f;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::str;
|
||||||
mod random;
|
mod random;
|
||||||
mod mime;
|
mod mime;
|
||||||
|
|
||||||
use self::mime::*;
|
//use self::mime::*;
|
||||||
|
|
||||||
use super::parser;
|
use super::parser;
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
use super::*;
|
//use super::*;
|
||||||
|
|
|
@ -48,7 +48,7 @@ pub trait BytesExt {
|
||||||
impl BytesExt for [u8] {
|
impl BytesExt for [u8] {
|
||||||
fn rtrim(&self) -> &Self {
|
fn rtrim(&self) -> &Self {
|
||||||
if let Some(last) = self.iter().rposition(|b| !is_whitespace!(*b)) {
|
if let Some(last) = self.iter().rposition(|b| !is_whitespace!(*b)) {
|
||||||
&self[..last + 1]
|
&self[..=last]
|
||||||
} else {
|
} else {
|
||||||
&[]
|
&[]
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ pub fn headers_raw(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
||||||
}
|
}
|
||||||
for (i, x) in input.iter().enumerate() {
|
for (i, x) in input.iter().enumerate() {
|
||||||
if *x == b'\n' && i + 1 < input.len() && input[i + 1] == b'\n' {
|
if *x == b'\n' && i + 1 < input.len() && input[i + 1] == b'\n' {
|
||||||
return IResult::Done(&input[(i + 1)..], &input[0..i + 1]);
|
return IResult::Done(&input[(i + 1)..], &input[0..=i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IResult::Error(error_code!(ErrorKind::Custom(43)))
|
IResult::Error(error_code!(ErrorKind::Custom(43)))
|
||||||
|
@ -383,14 +383,14 @@ fn addr_spec(input: &[u8]) -> IResult<&[u8], Address> {
|
||||||
IResult::Done(
|
IResult::Done(
|
||||||
&input[end..],
|
&input[end..],
|
||||||
Address::Mailbox(MailboxAddress {
|
Address::Mailbox(MailboxAddress {
|
||||||
raw: input[0..end + 1].into(),
|
raw: input[0..=end].into(),
|
||||||
display_name: StrBuilder {
|
display_name: StrBuilder {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
length: 0,
|
length: 0,
|
||||||
},
|
},
|
||||||
address_spec: StrBuilder {
|
address_spec: StrBuilder {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
length: input[0..end + 1].len(),
|
length: input[0..=end].len(),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
@ -517,7 +517,7 @@ fn message_id_peek(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
||||||
} else {
|
} else {
|
||||||
for (i, &x) in input.iter().take(input_length).enumerate().skip(1) {
|
for (i, &x) in input.iter().take(input_length).enumerate().skip(1) {
|
||||||
if x == b'>' {
|
if x == b'>' {
|
||||||
return IResult::Done(&input[i + 1..], &input[0..i + 1]);
|
return IResult::Done(&input[i + 1..], &input[0..=i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IResult::Incomplete(Needed::Unknown)
|
IResult::Incomplete(Needed::Unknown)
|
||||||
|
|
|
@ -512,16 +512,14 @@ impl Threads {
|
||||||
remove_from_parent!(thread_nodes, idx);
|
remove_from_parent!(thread_nodes, idx);
|
||||||
remove_from_parent!(thread_nodes, child);
|
remove_from_parent!(thread_nodes, child);
|
||||||
return true; // Pruned
|
return true; // Pruned
|
||||||
} else {
|
} else if let Some(p) = thread_nodes[idx].parent {
|
||||||
if let Some(p) = thread_nodes[idx].parent {
|
let orphans = thread_nodes[idx].children.clone();
|
||||||
let orphans = thread_nodes[idx].children.clone();
|
for c in orphans {
|
||||||
for c in orphans {
|
make!((p) parent of (c), thread_nodes);
|
||||||
make!((p) parent of (c), thread_nodes);
|
|
||||||
}
|
|
||||||
remove_from_parent!(thread_nodes, idx);
|
|
||||||
thread_nodes[idx].children.clear();
|
|
||||||
return true; // Pruned
|
|
||||||
}
|
}
|
||||||
|
remove_from_parent!(thread_nodes, idx);
|
||||||
|
thread_nodes[idx].children.clear();
|
||||||
|
return true; // Pruned
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,10 @@ pub use self::contact_list::*;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum ViewMode {
|
enum ViewMode {
|
||||||
ReadOnly,
|
//ReadOnly,
|
||||||
Read,
|
Read,
|
||||||
Edit,
|
//Edit,
|
||||||
New,
|
//New,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -69,9 +69,9 @@ impl fmt::Display for ContactManager {
|
||||||
|
|
||||||
impl ContactManager {
|
impl ContactManager {
|
||||||
fn initialize(&mut self) {
|
fn initialize(&mut self) {
|
||||||
let (width, height) = self.content.size();
|
let (width, _) = self.content.size();
|
||||||
|
|
||||||
let (x, y) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
"Contact Name ",
|
"Contact Name ",
|
||||||
&mut self.content,
|
&mut self.content,
|
||||||
Color::Byte(33),
|
Color::Byte(33),
|
||||||
|
@ -79,7 +79,7 @@ impl ContactManager {
|
||||||
((0, 0), (width, 0)),
|
((0, 0), (width, 0)),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
let (x, y) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
"Last edited: ",
|
"Last edited: ",
|
||||||
&mut self.content,
|
&mut self.content,
|
||||||
Color::Byte(250),
|
Color::Byte(250),
|
||||||
|
@ -87,7 +87,7 @@ impl ContactManager {
|
||||||
((x, 0), (width, 0)),
|
((x, 0), (width, 0)),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
let (x, y) = write_string_to_grid(
|
write_string_to_grid(
|
||||||
&self.card.last_edited(),
|
&self.card.last_edited(),
|
||||||
&mut self.content,
|
&mut self.content,
|
||||||
Color::Byte(250),
|
Color::Byte(250),
|
||||||
|
@ -115,7 +115,7 @@ impl Component for ContactManager {
|
||||||
self.initialized = true;
|
self.initialized = true;
|
||||||
}
|
}
|
||||||
clear_area(grid, area);
|
clear_area(grid, area);
|
||||||
let (width, height) = self.content.size();
|
let (width, _height) = self.content.size();
|
||||||
copy_area(grid, &self.content, area, ((0, 0), (width - 1, 0)));
|
copy_area(grid, &self.content, area, ((0, 0), (width - 1, 0)));
|
||||||
|
|
||||||
let upper_left = upper_left!(area);
|
let upper_left = upper_left!(area);
|
||||||
|
|
|
@ -19,10 +19,6 @@
|
||||||
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mod contacts;
|
|
||||||
|
|
||||||
pub use contacts::*;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
|
|
|
@ -1,105 +0,0 @@
|
||||||
/*
|
|
||||||
* meli - ui crate.
|
|
||||||
*
|
|
||||||
* Copyright 2019 Manos Pitsidianakis
|
|
||||||
*
|
|
||||||
* This file is part of meli.
|
|
||||||
*
|
|
||||||
* meli is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* meli is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct ContactsPanel {
|
|
||||||
content: CellBuffer,
|
|
||||||
dirty: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for ContactsPanel {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "contacts")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
impl Component for ContactsPanel {
|
|
||||||
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
|
||||||
if self.dirty {
|
|
||||||
self.dirty = false;
|
|
||||||
}
|
|
||||||
clear_area(grid, area);
|
|
||||||
|
|
||||||
let (width, height) = self.content.size();
|
|
||||||
copy_area(grid, &self.content, area, ((0, 0), (width - 1, height - 1)));
|
|
||||||
context.dirty_areas.push_back(area);
|
|
||||||
}
|
|
||||||
fn process_event(&mut self, _event: &mut UIEvent, _context: &mut Context) -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
fn is_dirty(&self) -> bool {
|
|
||||||
self.dirty
|
|
||||||
}
|
|
||||||
fn set_dirty(&mut self) {
|
|
||||||
self.dirty = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ContactsPanel {
|
|
||||||
pub fn new(context: &Context) -> ContactsPanel {
|
|
||||||
let mut content = CellBuffer::new(120, 25 + context.accounts.len() * 20, Cell::default());
|
|
||||||
write_string_to_grid(
|
|
||||||
"Contacts",
|
|
||||||
&mut content,
|
|
||||||
Color::Default,
|
|
||||||
Color::Default,
|
|
||||||
((2, 3), (120 - 1, 3)),
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
|
|
||||||
for (i, a) in context.accounts.iter().enumerate() {
|
|
||||||
create_box(&mut content, ((2,5+i*10 ), (120-1, 15+i*10)));
|
|
||||||
let (x, y) = write_string_to_grid(
|
|
||||||
a.name(),
|
|
||||||
&mut content,
|
|
||||||
Color::Default,
|
|
||||||
Color::Default,
|
|
||||||
((3, 5 + i*10), (120 - 2, 5 + i*10)),
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
write_string_to_grid(
|
|
||||||
" ▒██▒ ",
|
|
||||||
&mut content,
|
|
||||||
Color::Byte(32),
|
|
||||||
Color::Default,
|
|
||||||
((x, y), (120 - 2, 5 + i*10)),
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
write_string_to_grid(
|
|
||||||
&a.runtime_settings.account().identity,
|
|
||||||
&mut content,
|
|
||||||
Color::Default,
|
|
||||||
Color::Default,
|
|
||||||
((4, y + 2), (120 - 2, y + 2)),
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ContactsPanel {
|
|
||||||
content,
|
|
||||||
dirty: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -29,7 +29,7 @@ use std::str::FromStr;
|
||||||
enum Cursor {
|
enum Cursor {
|
||||||
Headers,
|
Headers,
|
||||||
Body,
|
Body,
|
||||||
Attachments,
|
//Attachments,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -71,7 +71,7 @@ impl Default for Composer {
|
||||||
enum ViewMode {
|
enum ViewMode {
|
||||||
Discard(Uuid),
|
Discard(Uuid),
|
||||||
Pager,
|
Pager,
|
||||||
Selector(Selector),
|
//Selector(Selector),
|
||||||
Overview,
|
Overview,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,14 +99,6 @@ impl ViewMode {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_selector(&self) -> bool {
|
|
||||||
if let ViewMode::Selector(_) = self {
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Composer {
|
impl fmt::Display for Composer {
|
||||||
|
@ -183,34 +175,7 @@ impl Composer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_header_table(&mut self, grid: &mut CellBuffer, area: Area) {
|
/*
|
||||||
let upper_left = upper_left!(area);
|
|
||||||
let bottom_right = bottom_right!(area);
|
|
||||||
|
|
||||||
let headers = self.draft.headers();
|
|
||||||
{
|
|
||||||
let (mut x, mut y) = upper_left;
|
|
||||||
for &k in &["Date", "From", "To", "Cc", "Bcc", "Subject"] {
|
|
||||||
let bg_color = Color::Default;
|
|
||||||
|
|
||||||
|
|
||||||
let update = {
|
|
||||||
let (x, y) = write_string_to_grid(
|
|
||||||
k,
|
|
||||||
grid,
|
|
||||||
Color::Default,
|
|
||||||
bg_color,
|
|
||||||
((x, y), set_y(bottom_right, y)),
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
let (x, y) = write_string_to_grid(
|
|
||||||
": ",
|
|
||||||
grid,
|
|
||||||
Color::Default,
|
|
||||||
bg_color,
|
|
||||||
((x, y), set_y(bottom_right, y)),
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
let (x, y) = if k == "From" {
|
let (x, y) = if k == "From" {
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
"◀ ",
|
"◀ ",
|
||||||
|
@ -240,15 +205,7 @@ impl Composer {
|
||||||
((x, y), set_y(bottom_right, y)),
|
((x, y), set_y(bottom_right, y)),
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
} else {
|
*/
|
||||||
(x, y)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
x = get_x(upper_left);
|
|
||||||
y = update.1 + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component for Composer {
|
impl Component for Composer {
|
||||||
|
@ -341,9 +298,6 @@ impl Component for Composer {
|
||||||
ViewMode::Overview | ViewMode::Pager => {
|
ViewMode::Overview | ViewMode::Pager => {
|
||||||
self.pager.draw(grid, body_area, context);
|
self.pager.draw(grid, body_area, context);
|
||||||
},
|
},
|
||||||
ViewMode::Selector(ref mut s) => {
|
|
||||||
s.draw(grid, body_area, context);
|
|
||||||
},
|
|
||||||
ViewMode::Discard(_) => {
|
ViewMode::Discard(_) => {
|
||||||
/* Let user choose whether to quit with/without saving or cancel */
|
/* Let user choose whether to quit with/without saving or cancel */
|
||||||
let mid_x = width!(area) / 2;
|
let mid_x = width!(area) / 2;
|
||||||
|
@ -421,12 +375,6 @@ impl Component for Composer {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(ViewMode::Selector(ref mut s), _) => {
|
|
||||||
if s.process_event(event, context) {
|
|
||||||
self.dirty = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
if self.form.process_event(event, context) {
|
if self.form.process_event(event, context) {
|
||||||
|
@ -434,19 +382,6 @@ impl Component for Composer {
|
||||||
}
|
}
|
||||||
|
|
||||||
match event.event_type {
|
match event.event_type {
|
||||||
UIEventType::Input(Key::Esc) if self.mode.is_selector() => {
|
|
||||||
self.mode = ViewMode::Overview;
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
UIEventType::Input(Key::Char('\n')) if self.mode.is_selector() => {
|
|
||||||
let mut old_mode = std::mem::replace(&mut self.mode, ViewMode::Overview);
|
|
||||||
if let ViewMode::Selector(s) = old_mode {
|
|
||||||
eprintln!("collected {:?}", s.collect());
|
|
||||||
} else {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
UIEventType::Resize => {
|
UIEventType::Resize => {
|
||||||
self.set_dirty();
|
self.set_dirty();
|
||||||
},
|
},
|
||||||
|
|
|
@ -525,7 +525,7 @@ impl Component for CompactListing {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_shortcuts(&self) -> ShortcutMap {
|
fn get_shortcuts(&self) -> ShortcutMap {
|
||||||
let mut map = self.view.as_ref().map(|p| p.get_shortcuts()).unwrap_or(ShortcutMap::default());
|
let mut map = self.view.as_ref().map(|p| p.get_shortcuts()).unwrap_or_default();
|
||||||
|
|
||||||
map.insert(Key::Char('\n'), "Open thread.".into());
|
map.insert(Key::Char('\n'), "Open thread.".into());
|
||||||
map.insert(Key::PageUp, "Go to previous page.".into());
|
map.insert(Key::PageUp, "Go to previous page.".into());
|
||||||
|
|
|
@ -397,7 +397,7 @@ impl Component for Pager {
|
||||||
}
|
}
|
||||||
context.dirty_areas.push_back(area);
|
context.dirty_areas.push_back(area);
|
||||||
}
|
}
|
||||||
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
|
fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool {
|
||||||
match event.event_type {
|
match event.event_type {
|
||||||
UIEventType::Input(Key::Char('k')) => {
|
UIEventType::Input(Key::Char('k')) => {
|
||||||
if self.cursor_pos > 0 {
|
if self.cursor_pos > 0 {
|
||||||
|
@ -937,7 +937,7 @@ impl Component for Selector {
|
||||||
);
|
);
|
||||||
context.dirty_areas.push_back(area);
|
context.dirty_areas.push_back(area);
|
||||||
}
|
}
|
||||||
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
|
fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool {
|
||||||
let (width, height) = self.content.size();
|
let (width, height) = self.content.size();
|
||||||
match event.event_type {
|
match event.event_type {
|
||||||
UIEventType::Input(Key::Char(' ')) => {
|
UIEventType::Input(Key::Char(' ')) => {
|
||||||
|
|
|
@ -72,7 +72,7 @@ impl Field {
|
||||||
},
|
},
|
||||||
TextArea(_, _) => {
|
TextArea(_, _) => {
|
||||||
},
|
},
|
||||||
Choice(_, cursor) => {
|
Choice(_, _cursor) => {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ impl Field {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component for Field {
|
impl Component for Field {
|
||||||
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
fn draw(&mut self, grid: &mut CellBuffer, area: Area, _context: &mut Context) {
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
self.as_str(),
|
self.as_str(),
|
||||||
grid,
|
grid,
|
||||||
|
@ -89,7 +89,7 @@ impl Component for Field {
|
||||||
area,
|
area,
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
|
fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool {
|
||||||
match event.event_type {
|
match event.event_type {
|
||||||
UIEventType::InsertInput(Key::Right) => {
|
UIEventType::InsertInput(Key::Right) => {
|
||||||
match self {
|
match self {
|
||||||
|
@ -294,10 +294,8 @@ impl Component for FormWidget {
|
||||||
context.dirty_areas.push_back(area);
|
context.dirty_areas.push_back(area);
|
||||||
}
|
}
|
||||||
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
|
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
|
||||||
if self.focus == FormFocus::Buttons {
|
if self.focus == FormFocus::Buttons && self.buttons.process_event(event, context) {
|
||||||
if self.buttons.process_event(event, context) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match event.event_type {
|
match event.event_type {
|
||||||
|
@ -341,7 +339,7 @@ impl Component for FormWidget {
|
||||||
UIEventType::ChangeMode(UIMode::Normal) if self.focus == FormFocus::TextInput => {
|
UIEventType::ChangeMode(UIMode::Normal) if self.focus == FormFocus::TextInput => {
|
||||||
self.focus = FormFocus::Fields;
|
self.focus = FormFocus::Fields;
|
||||||
},
|
},
|
||||||
UIEventType::InsertInput(Key::Char(k)) if self.focus == FormFocus::TextInput => {
|
UIEventType::InsertInput(Key::Char(_)) if self.focus == FormFocus::TextInput => {
|
||||||
let field = self.fields.get_mut(&self.layout[self.cursor]).unwrap();
|
let field = self.fields.get_mut(&self.layout[self.cursor]).unwrap();
|
||||||
field.process_event(event, context);
|
field.process_event(event, context);
|
||||||
},
|
},
|
||||||
|
@ -402,14 +400,13 @@ impl<T> ButtonWidget<T> where T: std::fmt::Debug + Default + Send {
|
||||||
|
|
||||||
|
|
||||||
impl<T> Component for ButtonWidget<T> where T: std::fmt::Debug + Default + Send {
|
impl<T> Component for ButtonWidget<T> where T: std::fmt::Debug + Default + Send {
|
||||||
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
fn draw(&mut self, grid: &mut CellBuffer, area: Area, _context: &mut Context) {
|
||||||
let upper_left = upper_left!(area);
|
let upper_left = upper_left!(area);
|
||||||
let bottom_right = bottom_right!(area);
|
|
||||||
|
|
||||||
let mut len = 0;
|
let mut len = 0;
|
||||||
for (i, k) in self.layout.iter().enumerate() {
|
for (i, k) in self.layout.iter().enumerate() {
|
||||||
let cur_len = k.len();
|
let cur_len = k.len();
|
||||||
let (x, y) = write_string_to_grid(
|
write_string_to_grid(
|
||||||
k.as_str(),
|
k.as_str(),
|
||||||
grid,
|
grid,
|
||||||
Color::Default,
|
Color::Default,
|
||||||
|
@ -420,7 +417,7 @@ impl<T> Component for ButtonWidget<T> where T: std::fmt::Debug + Default + Send
|
||||||
len += cur_len + 3;
|
len += cur_len + 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
|
fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool {
|
||||||
match event.event_type {
|
match event.event_type {
|
||||||
UIEventType::Input(Key::Char('\n')) => {
|
UIEventType::Input(Key::Char('\n')) => {
|
||||||
self.result = Some(self.buttons.remove(&self.layout[self.cursor]).unwrap_or_default());
|
self.result = Some(self.buttons.remove(&self.layout[self.cursor]).unwrap_or_default());
|
||||||
|
|
|
@ -201,7 +201,7 @@ derive_csi_sequence!("End Bracketed Paste Mode", BracketModeEnd, "?2003l");
|
||||||
pub const BRACKET_PASTE_START: &[u8] = b"\x1B[200~";
|
pub const BRACKET_PASTE_START: &[u8] = b"\x1B[200~";
|
||||||
pub const BRACKET_PASTE_END: &[u8] = b"\x1B[201~";
|
pub const BRACKET_PASTE_END: &[u8] = b"\x1B[201~";
|
||||||
|
|
||||||
const FIELDS: &'static [&'static str] = &[];
|
const FIELDS: &[&str] = &[];
|
||||||
|
|
||||||
|
|
||||||
impl<'de> Deserialize<'de> for Key {
|
impl<'de> Deserialize<'de> for Key {
|
||||||
|
|
Loading…
Reference in New Issue