mirror of https://git.meli.delivery/meli/meli
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.9 KiB
Rust
97 lines
2.9 KiB
Rust
7 years ago
|
/*
|
||
7 years ago
|
* meli - bin.rs
|
||
7 years ago
|
*
|
||
|
* Copyright 2017 Manos Pitsidianakis
|
||
7 years ago
|
*
|
||
7 years ago
|
* 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/>.
|
||
|
*/
|
||
7 years ago
|
|
||
|
mod ui;
|
||
|
use ui::index::*;
|
||
7 years ago
|
|
||
|
extern crate melib;
|
||
|
use melib::*;
|
||
7 years ago
|
use mailbox::*;
|
||
|
use conf::*;
|
||
|
|
||
7 years ago
|
extern crate ncurses;
|
||
7 years ago
|
|
||
|
fn main() {
|
||
|
let locale_conf = ncurses::LcCategory::all;
|
||
|
ncurses::setlocale(locale_conf, "en_US.UTF-8");
|
||
7 years ago
|
let set = Settings::new();
|
||
|
let ui = ui::TUI::initialize();
|
||
|
let mut j = 0;
|
||
7 years ago
|
let folder_length = set.accounts["norn"].folders.len();
|
||
7 years ago
|
'main : loop {
|
||
|
ncurses::touchwin(ncurses::stdscr());
|
||
|
ncurses::mv(0,0);
|
||
7 years ago
|
let mailbox = Mailbox::new(&set.accounts["norn"].folders[j],
|
||
|
Some(&set.accounts["norn"].sent_folder));
|
||
7 years ago
|
let mut index: Box<Window> = match mailbox {
|
||
7 years ago
|
Ok(v) => {
|
||
7 years ago
|
Box::new(Index::new(v))
|
||
|
},
|
||
|
Err(v) => {
|
||
|
Box::new(ErrorWindow::new(v))
|
||
|
}
|
||
|
};
|
||
|
//eprintln!("{:?}", set);
|
||
|
ncurses::refresh();
|
||
7 years ago
|
|
||
7 years ago
|
index.draw();
|
||
7 years ago
|
|
||
7 years ago
|
let mut ch;
|
||
|
'inner : loop {
|
||
|
ch = ncurses::get_wch();
|
||
|
match ch {
|
||
|
Some(ncurses::WchResult::KeyCode(k @ ncurses::KEY_UP)) |
|
||
|
Some(ncurses::WchResult::KeyCode(k @ ncurses::KEY_DOWN)) => {
|
||
|
index.handle_input(k);
|
||
|
continue;
|
||
|
}
|
||
|
Some(ncurses::WchResult::Char(k @ 10)) => {
|
||
|
index.handle_input(k as i32);
|
||
|
continue;
|
||
|
}
|
||
|
Some(ncurses::WchResult::KeyCode(ncurses::KEY_F1)) |
|
||
|
Some(ncurses::WchResult::Char(113)) => {
|
||
|
break 'main;
|
||
|
},
|
||
|
Some(ncurses::WchResult::Char(74)) => {
|
||
|
if j < folder_length - 1 {
|
||
|
j += 1;
|
||
|
break 'inner;
|
||
|
}
|
||
|
},
|
||
|
Some(ncurses::WchResult::Char(75)) => {
|
||
|
if j > 0 {
|
||
|
j -= 1;
|
||
|
break 'inner;
|
||
|
}
|
||
|
},
|
||
7 years ago
|
Some(ncurses::WchResult::KeyCode(ncurses::KEY_RESIZE)) => {
|
||
|
eprintln!("key_resize");
|
||
|
index.redraw();
|
||
|
continue;
|
||
|
},
|
||
7 years ago
|
_ => {}
|
||
7 years ago
|
}
|
||
|
}
|
||
|
}
|
||
7 years ago
|
drop(ui);
|
||
7 years ago
|
}
|