summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2019-02-01 06:31:42 -0500
committerGitHub <noreply@github.com>2019-02-01 06:31:42 -0500
commit1427070950462fdfba92dc08f5e477ebb87da0ad (patch)
tree8b68d49f0d3da5839e1383124b99fe94455e5c23
parentadea8bab51acbae26e143220da2a16f129b63c9c (diff)
parent76874cfcfd1ba40c52c07736d529ab5e58df2cbd (diff)
Merge pull request #18 from cjbassi/reformat
Run cargo fmt and reformat imports
-rw-r--r--lib/wordexp-rs/src/lib.rs26
-rw-r--r--lib/wordexp-rs/src/ll.rs33
-rw-r--r--src/joshuto.rs81
-rw-r--r--src/joshuto/command.rs145
-rw-r--r--src/joshuto/command/change_directory.rs59
-rw-r--r--src/joshuto/command/cursor_move.rs88
-rw-r--r--src/joshuto/command/delete_files.rs (renamed from src/joshuto/command/delete_file.rs)39
-rw-r--r--src/joshuto/command/file_operations.rs (renamed from src/joshuto/command/file_operation.rs)121
-rw-r--r--src/joshuto/command/new_directory.rs30
-rw-r--r--src/joshuto/command/open_file.rs128
-rw-r--r--src/joshuto/command/parent_directory.rs46
-rw-r--r--src/joshuto/command/quit.rs18
-rw-r--r--src/joshuto/command/reload_dir.rs30
-rw-r--r--src/joshuto/command/rename_file.rs52
-rw-r--r--src/joshuto/command/search.rs32
-rw-r--r--src/joshuto/command/selection.rs32
-rw-r--r--src/joshuto/command/set_mode.rs51
-rw-r--r--src/joshuto/command/show_hidden.rs30
-rw-r--r--src/joshuto/command/tab_operations.rs47
-rw-r--r--src/joshuto/command/tab_switch.rs30
-rw-r--r--src/joshuto/config.rs16
-rw-r--r--src/joshuto/config/config.rs50
-rw-r--r--src/joshuto/config/keymap.rs46
-rw-r--r--src/joshuto/config/mimetype.rs19
-rw-r--r--src/joshuto/config/preview.rs14
-rw-r--r--src/joshuto/config/theme.rs69
-rw-r--r--src/joshuto/context.rs17
-rw-r--r--src/joshuto/history.rs49
-rw-r--r--src/joshuto/preview.rs100
-rw-r--r--src/joshuto/sort.rs147
-rw-r--r--src/joshuto/structs.rs82
-rw-r--r--src/joshuto/tab.rs88
-rw-r--r--src/joshuto/textfield.rs46
-rw-r--r--src/joshuto/ui.rs111
-rw-r--r--src/joshuto/unix.rs67
-rw-r--r--src/joshuto/window.rs122
-rw-r--r--src/joshuto/window/test.rs1
-rw-r--r--src/main.rs5
38 files changed, 1074 insertions, 1093 deletions
diff --git a/lib/wordexp-rs/src/lib.rs b/lib/wordexp-rs/src/lib.rs
index 33613c4..0a2e1bf 100644
--- a/lib/wordexp-rs/src/lib.rs
+++ b/lib/wordexp-rs/src/lib.rs
@@ -1,13 +1,12 @@
extern crate libc;
-use std::ffi::CString;
-use std::ffi::CStr;
-
mod ll;
+use std::ffi::{CStr, CString};
+
pub const WRDE_DOOFFS: i32 = (1 << 0);
pub const WRDE_APPEND: i32 = (1 << 1);
-pub const WRDE_NOCMD: i32 = (1 << 2);
+pub const WRDE_NOCMD: i32 = (1 << 2);
pub const WRDE_REUSE: i32 = (1 << 3);
pub const WRDE_SHOWERR: i32 = (1 << 4);
pub const WRDE_UNDEF: i32 = (1 << 5);
@@ -16,7 +15,7 @@ trait ToCStr {
fn to_c_str(&self) -> CString;
}
-impl <'a>ToCStr for &'a str {
+impl<'a> ToCStr for &'a str {
fn to_c_str(&self) -> CString {
CString::new(*self).unwrap()
}
@@ -30,8 +29,7 @@ pub struct Wordexp<'a> {
}
impl<'a> Wordexp<'a> {
- pub fn new(wordexp_ref: ll::wordexp_t) -> Self
- {
+ pub fn new(wordexp_ref: ll::wordexp_t) -> Self {
let we_wordc: usize = wordexp_ref.we_wordc as usize;
let mut we_wordv: Vec<&str> = Vec::with_capacity(we_wordc);
unsafe {
@@ -62,8 +60,7 @@ impl<'a> std::ops::Drop for Wordexp<'a> {
impl<'a> std::iter::Iterator for Wordexp<'a> {
type Item = &'a str;
- fn next(&mut self) -> Option<&'a str>
- {
+ fn next(&mut self) -> Option<&'a str> {
if self.counter >= self.we_wordv.len() {
self.counter = 0;
None
@@ -81,28 +78,25 @@ pub struct WordexpError {
}
impl WordexpError {
- pub fn new(error_type: i32) -> Self
- {
+ pub fn new(error_type: i32) -> Self {
WordexpError { error_type }
}
}
impl std::fmt::Display for WordexpError {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result
- {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.error_type)
}
}
impl std::error::Error for WordexpError {}
-pub fn wordexp<'a>(s: &str, flags: i32) -> Result<Wordexp, WordexpError>
-{
+pub fn wordexp<'a>(s: &str, flags: i32) -> Result<Wordexp, WordexpError> {
let mut wordexp = ll::wordexp_t {
we_wordc: 0,
we_wordv: std::ptr::null(),
we_offs: 0,
- };
+ };
let result: i32;
unsafe {
diff --git a/lib/wordexp-rs/src/ll.rs b/lib/wordexp-rs/src/ll.rs
index f047443..8e790d1 100644
--- a/lib/wordexp-rs/src/ll.rs
+++ b/lib/wordexp-rs/src/ll.rs
@@ -9,27 +9,28 @@ pub struct wordexp_t {
}
impl std::ops::Drop for wordexp_t {
- fn drop(&mut self)
- {
- unsafe { wordfree(self); }
+ fn drop(&mut self) {
+ unsafe {
+ wordfree(self);
+ }
}
}
extern "C" {
-/*
- pub static WRDE_APPEND: i32;
- pub static WRDE_DOOFFS: i32;
- pub static WRDE_NOCMD: i32;
- pub static WRDE_REUSE: i32;
- pub static WRDE_SHOWERR: i32;
- pub static WRDE_UNDEF: i32;
+ /*
+ pub static WRDE_APPEND: i32;
+ pub static WRDE_DOOFFS: i32;
+ pub static WRDE_NOCMD: i32;
+ pub static WRDE_REUSE: i32;
+ pub static WRDE_SHOWERR: i32;
+ pub static WRDE_UNDEF: i32;
- pub static WRDE_BADCHAR: i32;
- pub static WRDE_BADVAL: i32;
- pub static WRDE_CMDSUB: i32;
- pub static WRDE_NOSPACE: i32;
- pub static WRDE_SYNTAX: i32;
-*/
+ pub static WRDE_BADCHAR: i32;
+ pub static WRDE_BADVAL: i32;
+ pub static WRDE_CMDSUB: i32;
+ pub static WRDE_NOSPACE: i32;
+ pub static WRDE_SYNTAX: i32;
+ */
pub fn wordexp(_: *const libc::c_char, _: &mut wordexp_t, _: i32) -> i32;
pub fn wordfree(_: &mut wordexp_t);
diff --git a/src/joshuto.rs b/src/joshuto.rs
index fb1f504..007362e 100644
--- a/src/joshuto.rs
+++ b/src/joshuto.rs
@@ -1,9 +1,5 @@
extern crate ncurses;
-use std;
-use std::collections::HashMap;
-use std::time;
-
pub mod config;
mod command;
@@ -18,12 +14,12 @@ mod ui;
mod unix;
mod window;
-use self::config::JoshutoTheme;
-use self::config::JoshutoMimetype;
-use self::config::JoshutoPreview;
+use std::collections::HashMap;
+use std::time;
+
+use self::command::{CommandKeybind, JoshutoCommand};
+use self::config::{JoshutoMimetype, JoshutoPreview, JoshutoTheme};
use self::context::JoshutoContext;
-use self::command::CommandKeybind;
-use self::command::JoshutoCommand;
lazy_static! {
static ref theme_t: JoshutoTheme = JoshutoTheme::get_config();
@@ -31,17 +27,20 @@ lazy_static! {
static ref preview_t: JoshutoPreview = JoshutoPreview::get_config();
}
-fn recurse_get_keycommand<'a>(keymap: &'a HashMap<i32, CommandKeybind>)
- -> Option<&Box<dyn JoshutoCommand>>
-{
+fn recurse_get_keycommand<'a>(
+ keymap: &'a HashMap<i32, CommandKeybind>,
+) -> Option<&Box<dyn JoshutoCommand>> {
let (term_rows, term_cols) = ui::getmaxyx();
ncurses::timeout(-1);
let ch: i32;
{
let keymap_len = keymap.len();
- let win = window::JoshutoPanel::new(keymap_len as i32 + 1, term_cols,
- ((term_rows - keymap_len as i32 - 2) as usize, 0));
+ let win = window::JoshutoPanel::new(
+ keymap_len as i32 + 1,
+ term_cols,
+ ((term_rows - keymap_len as i32 - 2) as usize, 0),
+ );
let mut display_vec: Vec<String> = Vec::with_capacity(keymap_len);
for (key, val) in keymap {
@@ -62,20 +61,13 @@ fn recurse_get_keycommand<'a>(keymap: &'a HashMap<i32, CommandKeybind>)
}
match keymap.get(&ch) {
- Some(CommandKeybind::CompositeKeybind(m)) => {
- recurse_get_keycommand(&m)
- },
- Some(CommandKeybind::SimpleKeybind(s)) => {
- Some(s)
- },
- _ => {
- None
- }
+ Some(CommandKeybind::CompositeKeybind(m)) => recurse_get_keycommand(&m),
+ Some(CommandKeybind::SimpleKeybind(s)) => Some(s),
+ _ => None,
}
}
-fn process_threads(context: &mut JoshutoContext)
-{
+fn process_threads(context: &mut JoshutoContext) {
let wait_duration: time::Duration = time::Duration::from_millis(100);
let mut something_finished = false;
for i in 0..context.threads.len() {
@@ -87,8 +79,8 @@ fn process_threads(context: &mut JoshutoContext)
something_finished = true;
break;
} else {
- let percent = (progress_info.bytes_finished as f64 /
- progress_info.total_bytes as f64) as f32;
+ let percent =
+ (progress_info.bytes_finished as f64 / progress_info.total_bytes as f64) as f32;
ui::draw_progress_bar(&context.views.bot_win, percent);
ncurses::wnoutrefresh(context.views.bot_win.win);
ncurses::doupdate();
@@ -101,20 +93,22 @@ fn process_threads(context: &mut JoshutoContext)
}
}
-fn resize_handler(context: &mut JoshutoContext)
-{
+fn resize_handler(context: &mut JoshutoContext) {
ui::redraw_tab_view(&context.views.tab_win, &context);
{
let curr_tab = &mut context.tabs[context.curr_tab_index];
- curr_tab.refresh(&context.views, &context.config_t,
- &context.username, &context.hostname);
+ curr_tab.refresh(
+ &context.views,
+ &context.config_t,
+ &context.username,
+ &context.hostname,
+ );
}
preview::preview_file(context);
ncurses::doupdate();
}
-pub fn run(config_t: config::JoshutoConfig, keymap_t: config::JoshutoKeymap)
-{
+pub fn run(config_t: config::JoshutoConfig, keymap_t: config::JoshutoKeymap) {
ui::init_ncurses();
ncurses::doupdate();
@@ -124,9 +118,9 @@ pub fn run(config_t: config::JoshutoConfig, keymap_t: config::JoshutoKeymap)
while let Some(ch) = ncurses::get_wch() {
let ch = match ch {
- ncurses::WchResult::Char(s) => s as i32,
- ncurses::WchResult::KeyCode(s) => s,
- };
+ ncurses::WchResult::Char(s) => s as i32,
+ ncurses::WchResult::KeyCode(s) => s,
+ };
if ch == ncurses::KEY_RESIZE {
context.views.resize_views();
@@ -144,20 +138,15 @@ pub fn run(config_t: config::JoshutoConfig, keymap_t: config::JoshutoKeymap)
let keycommand: &std::boxed::Box<dyn JoshutoCommand>;
match keymap_t.keymaps.get(&ch) {
- Some(CommandKeybind::CompositeKeybind(m)) => {
- match recurse_get_keycommand(&m) {
- Some(s) => {
- keycommand = s;
- }
- None => {
- continue
- },
+ Some(CommandKeybind::CompositeKeybind(m)) => match recurse_get_keycommand(&m) {
+ Some(s) => {
+ keycommand = s;
}
-
+ None => continue,
},
Some(CommandKeybind::SimpleKeybind(s)) => {
keycommand = s;
- },
+ }
None => {
continue;
}
diff --git a/src/joshuto/command.rs b/src/joshuto/command.rs
index 3e32e1a..fa3b3e4 100644
--- a/src/joshuto/command.rs
+++ b/src/joshuto/command.rs
@@ -1,69 +1,47 @@
extern crate wordexp;
-use std;
-use std::collections::HashMap;
-use std::fmt;
-use std::path;
-
-use joshuto::context::JoshutoContext;
-use joshuto::structs;
-
-mod quit;
-pub use self::quit::Quit;
-
-mod parent_directory;
-pub use self::parent_directory::ParentDirectory;
-
-mod open_file;
-pub use self::open_file::OpenFile;
-pub use self::open_file::OpenFileWith;
-
mod change_directory;
-pub use self::change_directory::ChangeDirectory;
-mod reload_dir;
-pub use self::reload_dir::ReloadDirList;
-
mod cursor_move;
-pub use self::cursor_move::CursorMove;
-pub use self::cursor_move::CursorMovePageUp;
-pub use self::cursor_move::CursorMovePageDown;
-pub use self::cursor_move::CursorMoveHome;
-pub use self::cursor_move::CursorMoveEnd;
-
-mod file_operation;
-pub use self::file_operation::CutFiles;
-pub use self::file_operation::CopyFiles;
-pub use self::file_operation::PasteFiles;
-
-mod delete_file;
-pub use self::delete_file::DeleteFiles;
-
-mod rename_file;
-pub use self::rename_file::RenameFile;
-pub use self::rename_file::RenameFileMethod;
-
+mod delete_files;
+mod file_operations;
mod new_directory;
-pub use self::new_directory::NewDirectory;
-
+mod open_file;
+mod parent_directory;
+mod quit;
+mod reload_dir;
+mod rename_file;
mod search;
-pub use self::search::Search;
-
-mod show_hidden;
-pub use self::show_hidden::ToggleHiddenFiles;
-
mod selection;
-pub use self::selection::SelectFiles;
-
+mod set_mode;
+mod show_hidden;
mod tab_operations;
-pub use self::tab_operations::NewTab;
-pub use self::tab_operations::CloseTab;
-
mod tab_switch;
-pub use self::tab_switch::TabSwitch;
-mod set_mode;
+pub use self::change_directory::ChangeDirectory;
+pub use self::cursor_move::{
+ CursorMove, CursorMoveEnd, CursorMoveHome, CursorMovePageDown, CursorMovePageUp,
+};
+pub use self::delete_files::DeleteFiles;
+pub use self::file_operations::{CopyFiles, CutFiles, PasteFiles};
+pub use self::new_directory::NewDirectory;
+pub use self::open_file::{OpenFile, OpenFileWith};
+pub use self::parent_directory::ParentDirectory;
+pub use self::quit::Quit;
+pub use self::reload_dir::ReloadDirList;
+pub use self::rename_file::{RenameFile, RenameFileMethod};
+pub use self::search::Search;
+pub use self::selection::SelectFiles;
pub use self::set_mode::SetMode;
+pub use self::show_hidden::ToggleHiddenFiles;
+pub use self::tab_operations::{CloseTab, NewTab};
+pub use self::tab_switch::TabSwitch;
+use std::collections::HashMap;
+use std::fmt;
+use std::path;
+
+use joshuto::context::JoshutoContext;
+use joshuto::structs;
#[derive(Debug)]
pub enum CommandKeybind {
@@ -92,8 +70,7 @@ pub struct ProgressInfo {
pub total_bytes: u64,
}
-pub fn from_args(command: &str, args: Option<&Vec<String>>) -> Option<Box<dyn JoshutoCommand>>
-{
+pub fn from_args(command: &str, args: Option<&Vec<String>>) -> Option<Box<dyn JoshutoCommand>> {
match command {
"cd" => {
if let Some(args) = args {
@@ -103,14 +80,14 @@ pub fn from_args(command: &str, args: Option<&Vec<String>>) -> Option<Box<dyn Jo
let path = path::PathBuf::from(exp_str);
return Some(Box::new(self::ChangeDirectory::new(path)));
}
- },
+ }
Err(_) => {
eprintln!("Failed to parse: {:?}", args[0]);
}
}
}
return None;
- },
+ }
"close_tab" => Some(Box::new(self::CloseTab::new())),
"copy_files" => Some(Box::new(self::CopyFiles::new())),
"cursor_move" => {
@@ -119,15 +96,15 @@ pub fn from_args(command: &str, args: Option<&Vec<String>>) -> Option<Box<dyn Jo
match args[0].parse::<i32>() {
Ok(s) => {
return Some(Box::new(self::CursorMove::new(s)));
- },
+ }
Err(e) => {
eprintln!("{}", e);
- },
+ }
}
}
}
return None;
- },
+ }
"cursor_move_home" => Some(Box::new(self::CursorMoveHome::new())),
"cursor_move_end" => Some(Box::new(self::CursorMoveEnd::new())),
"cursor_move_page_up" => Some(Box::new(self::CursorMovePageUp::new())),
@@ -152,22 +129,22 @@ pub fn from_args(command: &str, args: Option<&Vec<String>>) -> Option<Box<dyn Jo
} else {
eprintln!("Failed to parse: {}", arg);
}
- },
+ }
"skip_exist" => {
if let Ok(s) = splitarg[1].parse::<bool>() {
options.skip_exist = s;
} else {
eprintln!("Failed to parse: {}", arg);
}
- },
- _ => {},
+ }
+ _ => {}
}
}
}
}
let paste = self::PasteFiles::new(options);
Some(Box::new(paste))
- },
+ }
"quit" => Some(Box::new(self::Quit::new())),
"reload_dir_list" => Some(Box::new(self::ReloadDirList::new())),
"rename_file" => {
@@ -187,7 +164,7 @@ pub fn from_args(command: &str, args: Option<&Vec<String>>) -> Option<Box<dyn Jo
method = self::RenameFileMethod::Append;
}
Some(Box::new(self::RenameFile::new(method)))
- },
+ }
"search" => Some(Box::new(self::Search::new())),
"select_files" => {
let mut toggle = false;
@@ -203,21 +180,21 @@ pub fn from_args(command: &str, args: Option<&Vec<String>>) -> Option<Box<dyn Jo
} else {
eprintln!("Failed to parse: {}", arg);
}
- },
+ }
"all" => {
if let Ok(s) = splitarg[1].parse::<bool>() {
all = s;
} else {
eprintln!("Failed to parse: {}", arg);
}
- },
- _ => {},
+ }
+ _ => {}
}
}
}
}
Some(Box::new(self::SelectFiles::new(toggle, all)))
- },
+ }
"set_mode" => Some(Box::new(self::SetMode::new())),
"tab_switch" => {
if let Some(args) = args {
@@ -225,30 +202,31 @@ pub fn from_args(command: &str, args: Option<&Vec<String>>) -> Option<Box<dyn Jo
match args[0].parse::<i32>() {
Ok(s) => {
return Some(Box::new(self::TabSwitch::new(s)));
- },
+ }
Err(e) => {
eprintln!("{}", e);
- },
+ }
}
}
}
return None;
- },
+ }
"toggle_hidden" => Some(Box::new(self::ToggleHiddenFiles::new())),
_ => None,
}
}
-pub fn collect_selected_paths(dirlist: &structs::JoshutoDirList)
- -> Option<Vec<path::PathBuf>>
-{
+pub fn collect_selected_paths(dirlist: &structs::JoshutoDirList) -> Option<Vec<path::PathBuf>> {
if dirlist.index < 0 {
return None;
}
- let selected: Vec<path::PathBuf> = dirlist.contents.iter()
- .filter(|entry| entry.selected)
- .map(|entry| entry.path.clone()).collect();
+ let selected: Vec<path::PathBuf> = dirlist
+ .contents
+ .iter()
+ .filter(|entry| entry.selected)
+ .map(|entry| entry.path.clone())
+ .collect();
if selected.len() > 0 {
Some(selected)
} else {
@@ -257,8 +235,7 @@ pub fn collect_selected_paths(dirlist: &structs::JoshutoDirList)
}
#[allow(dead_code)]
-pub fn split_shell_style(line: &String) -> Vec<&str>
-{
+pub fn split_shell_style(line: &String) -> Vec<&str> {
let mut args: Vec<&str> = Vec::new();
let mut char_ind = line.char_indices();
@@ -269,14 +246,14 @@ pub fn split_shell_style(line: &String) -> Vec<&str>
if ch == '\'' {
while let Some((j, ch)) = char_ind.next() {
if ch == '\'' {
- args.push(&line[i+1..j]);
+ args.push(&line[i + 1..j]);
break;
}
}
- } else if ch == '"'{
+ } else if ch == '"' {
while let Some((j, ch)) = char_ind.next() {
if ch == '"' {
- args.push(&line[i+1..j]);
+ args.push(&line[i + 1..j]);
break;
}
}
diff --git a/src/joshuto/command/change_directory.rs b/src/joshuto/command/change_directory.rs
index b989dbe..c12aa5e 100644
--- a/src/joshuto/command/change_directory.rs
+++ b/src/joshuto/command/change_directory.rs
@@ -1,12 +1,10 @@
extern crate ncurses;
-use std;
use std::path;
use std::process;
+use joshuto::command::{JoshutoCommand, JoshutoRunnable};
use joshuto::context::JoshutoContext;
-use joshuto::command::JoshutoCommand;
-use joshuto::command::JoshutoRunnable;
use joshuto::preview;
use joshuto::ui;
@@ -16,16 +14,14 @@ pub struct ChangeDirectory {
}
impl ChangeDirectory {
- pub fn new(path: path::PathBuf) -> Self
- {
- ChangeDirectory {
- path,
- }
+ pub fn new(path: path::PathBuf) -> Self {
+ ChangeDirectory { path }
+ }
+ pub const fn command() -> &'static str {
+ "cd"
}
- pub const fn command() -> &'static str { "cd" }
- pub fn change_directory(path: &path::PathBuf, context: &mut JoshutoContext)
- {
+ pub fn change_directory(path: &path::PathBuf, context: &mut JoshutoContext) {
if !path.exists() {
ui::wprint_err(&context.views.bot_win, "Error: No such file or directory");
ncurses::doupdate();
@@ -41,52 +37,59 @@ impl ChangeDirectory {
match std::env::set_current_dir(path.as_path()) {
Ok(_) => {
curr_tab.curr_path = path.clone();
- },
+ }
Err(e) => {
ui::wprint_err(&context.views.bot_win, e.to_string().as_str());
return;
}
}
- curr_tab.history.populate_to_root(&curr_tab.curr_path, &context.config_t.sort_type);
+ curr_tab
+ .history
+ .populate_to_root(&curr_tab.curr_path, &context.config_t.sort_type);
- curr_tab.curr_list = match curr_tab.history.pop_or_create(&curr_tab.curr_path,
- &context.config_t.sort_type) {
- Ok(s) => {
- Some(s)
- },
+ curr_tab.curr_list = match curr_tab
+ .history
+ .pop_or_create(&curr_tab.curr_path, &context.config_t.sort_type)
+ {
+ Ok(s) => Some(s),
Err(e) => {
eprintln!("{}", e);
process::exit(1);
- },
+ }
};
if let Some(parent) = curr_tab.curr_path.parent() {
- curr_tab.parent_list = match curr_tab.history.pop_or_create(&parent, &context.config_t.sort_type) {
- Ok(s) => { Some(s) },
+ curr_tab.parent_list = match curr_tab
+ .history
+ .pop_or_create(&parent, &context.config_t.sort_type)
+ {
+ Ok(s) => Some(s),
Err(e) => {
eprintln!("{}", e);
process::exit(1);
- },
+ }
};
}
- curr_tab.refresh(&context.views, &context.config_t,
- &context.username, &context.hostname);
+ curr_tab.refresh(
+ &context.views,
+ &context.config_t,
+ &context.username,
+ &context.hostname,
+ );
}
}
impl JoshutoCommand for ChangeDirectory {}
impl std::fmt::Display for ChangeDirectory {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result
- {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{} {}", Self::command(), self.path.to_str().unwrap())
}
}
impl JoshutoRunnable for ChangeDirectory {
- fn execute(&self, context: &mut JoshutoContext)
- {
+ fn execute(&self, context: &mut JoshutoContext) {
Self::change_directory(&self.path, context);
preview::preview_file(context);
ncurses::doupdate();
diff --git a/src/joshuto/command/cursor_move.rs b/src/joshuto/command/cursor_move.rs
index c449594..e38e983 100644
--- a/src/joshuto/command/cursor_move.rs
+++ b/src/joshuto/command/cursor_move.rs
@@ -1,9 +1,6 @@
extern crate ncurses;
-use std;
-
-use joshuto::command::JoshutoCommand;
-use joshuto::command::JoshutoRunnable;
+use joshuto::command::{JoshutoCommand, JoshutoRunnable};
use joshuto::context::JoshutoContext;
use joshuto::preview;
@@ -13,16 +10,14 @@ pub struct CursorMove {
}
impl CursorMove {
- pub fn new(movement: i32) -> Self
- {
- CursorMove {
- movement,
- }
+ pub fn new(movement: i32) -> Self {
+ CursorMove { movement }
+ }
+ pub const fn command() -> &'static str {
+ "cursor_move"
}
- pub const fn command() -> &'static str { "cursor_move" }
- pub fn cursor_move(new_index: i32, context: &mut JoshutoContext)
- {
+ pub fn cursor_move(new_index: i32, context: &mut JoshutoContext) {
{
let curr_tab = &mut context.tabs[context.curr_tab_index];
@@ -47,7 +42,12 @@ impl CursorMove {
}
curr_tab.refresh_curr(&context.views.mid_win, context.config_t.scroll_offset);
curr_tab.refresh_file_status(&context.views.bot_win);
- curr_tab.refresh_path_status(&context.views.top_win, &context.username, &context.hostname, context.config_t.tilde_in_titlebar);
+ curr_tab.refresh_path_status(
+ &context.views.top_win,
+ &context.username,
+ &context.hostname,
+ context.config_t.tilde_in_titlebar,
+ );
}
preview::preview_file(context);
ncurses::doupdate();
@@ -57,15 +57,13 @@ impl CursorMove {
impl JoshutoComman