summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2019-02-19 17:43:13 -0500
committerJiayi Zhao <jeff.no.zhao@gmail.com>2019-02-19 17:43:25 -0500
commit0be734a6d7154573d8e570980f0af27ac5cb8190 (patch)
tree76789bee4f068ba000a13921ae5caec0a8c4cabe
parent348ef3c36115ac7060f141c27157b6b2f5c91f37 (diff)
rust 2018 and clippy
-rw-r--r--lib/wordexp-rs/src/lib.rs14
-rw-r--r--src/commands/change_directory.rs10
-rw-r--r--src/commands/cursor_move.rs8
-rw-r--r--src/commands/delete_files.rs11
-rw-r--r--src/commands/file_operations.rs50
-rw-r--r--src/commands/mod.rs6
-rw-r--r--src/commands/new_directory.rs10
-rw-r--r--src/commands/open_file.rs22
-rw-r--r--src/commands/parent_directory.rs10
-rw-r--r--src/commands/quit.rs6
-rw-r--r--src/commands/reload_dir.rs8
-rw-r--r--src/commands/rename_file.rs12
-rw-r--r--src/commands/search.rs10
-rw-r--r--src/commands/selection.rs4
-rw-r--r--src/commands/set_mode.rs15
-rw-r--r--src/commands/show_hidden.rs6
-rw-r--r--src/commands/tab_operations.rs8
-rw-r--r--src/commands/tab_switch.rs6
-rw-r--r--src/config/config.rs10
-rw-r--r--src/config/keymap.rs43
-rw-r--r--src/config/mimetype.rs8
-rw-r--r--src/config/mod.rs6
-rw-r--r--src/config/preview.rs8
-rw-r--r--src/config/theme.rs8
-rw-r--r--src/context.rs8
-rw-r--r--src/history.rs4
-rw-r--r--src/main.rs8
-rw-r--r--src/preview.rs9
-rw-r--r--src/run.rs16
-rw-r--r--src/sort.rs2
-rw-r--r--src/structs.rs4
-rw-r--r--src/tab.rs16
-rw-r--r--src/textfield.rs8
-rw-r--r--src/ui.rs16
-rw-r--r--src/unix.rs5
-rw-r--r--src/window/panel.rs6
-rw-r--r--src/window/view.rs4
37 files changed, 161 insertions, 244 deletions
diff --git a/lib/wordexp-rs/src/lib.rs b/lib/wordexp-rs/src/lib.rs
index 0a2e1bf..57dd9b7 100644
--- a/lib/wordexp-rs/src/lib.rs
+++ b/lib/wordexp-rs/src/lib.rs
@@ -4,7 +4,7 @@ mod ll;
use std::ffi::{CStr, CString};
-pub const WRDE_DOOFFS: i32 = (1 << 0);
+pub const WRDE_DOOFFS: i32 = 1;
pub const WRDE_APPEND: i32 = (1 << 1);
pub const WRDE_NOCMD: i32 = (1 << 2);
pub const WRDE_REUSE: i32 = (1 << 3);
@@ -36,7 +36,7 @@ impl<'a> Wordexp<'a> {
let ptr: *const *const libc::c_char = wordexp_ref.we_wordv;
for i in 0..we_wordc {
- let cstr = CStr::from_ptr(*ptr.offset(i as isize));
+ let cstr = CStr::from_ptr(*ptr.add(i));
if let Ok(s) = cstr.to_str() {
we_wordv.push(s);
}
@@ -51,12 +51,6 @@ impl<'a> Wordexp<'a> {
}
}
-impl<'a> std::ops::Drop for Wordexp<'a> {
- fn drop(&mut self) {
- drop(&self.wordexp_ref);
- }
-}
-
impl<'a> std::iter::Iterator for Wordexp<'a> {
type Item = &'a str;
@@ -66,7 +60,7 @@ impl<'a> std::iter::Iterator for Wordexp<'a> {
None
} else {
let item = self.we_wordv[self.counter];
- self.counter = self.counter + 1;
+ self.counter += 1;
Some(item)
}
}
@@ -91,7 +85,7 @@ impl std::fmt::Display for WordexpError {
impl std::error::Error for WordexpError {}
-pub fn wordexp<'a>(s: &str, flags: i32) -> Result<Wordexp, WordexpError> {
+pub fn wordexp(s: &str, flags: i32) -> Result<Wordexp, WordexpError> {
let mut wordexp = ll::wordexp_t {
we_wordc: 0,
we_wordv: std::ptr::null(),
diff --git a/src/commands/change_directory.rs b/src/commands/change_directory.rs
index 40ea6d8..87a23bb 100644
--- a/src/commands/change_directory.rs
+++ b/src/commands/change_directory.rs
@@ -1,12 +1,10 @@
-extern crate ncurses;
-
use std::path;
use std::process;
-use commands::{JoshutoCommand, JoshutoRunnable};
-use context::JoshutoContext;
-use preview;
-use ui;
+use crate::commands::{JoshutoCommand, JoshutoRunnable};
+use crate::context::JoshutoContext;
+use crate::preview;
+use crate::ui;
#[derive(Clone, Debug)]
pub struct ChangeDirectory {
diff --git a/src/commands/cursor_move.rs b/src/commands/cursor_move.rs
index d48d2bb..04e6da4 100644
--- a/src/commands/cursor_move.rs
+++ b/src/commands/cursor_move.rs
@@ -1,8 +1,6 @@
-extern crate ncurses;
-
-use commands::{JoshutoCommand, JoshutoRunnable};
-use context::JoshutoContext;
-use preview;
+use crate::commands::{JoshutoCommand, JoshutoRunnable};
+use crate::context::JoshutoContext;
+use crate::preview;
#[derive(Clone, Debug)]
pub struct CursorMove {
diff --git a/src/commands/delete_files.rs b/src/commands/delete_files.rs
index e6c8467..e72d364 100644
--- a/src/commands/delete_files.rs
+++ b/src/commands/delete_files.rs
@@ -1,13 +1,10 @@
-extern crate ncurses;
-
use std::fs;
use std::path;
-use commands::{self, JoshutoCommand, JoshutoRunnable};
-use config::keymap;
-use context::JoshutoContext;
-use preview;
-use ui;
+use crate::commands::{self, JoshutoCommand, JoshutoRunnable};
+use crate::config::keymap;
+use crate::context::JoshutoContext;
+use crate::ui;
#[derive(Clone, Debug)]
pub struct DeleteFiles;
diff --git a/src/commands/file_operations.rs b/src/commands/file_operations.rs
index be6cce5..0c064b8 100644
--- a/src/commands/file_operations.rs
+++ b/src/commands/file_operations.rs
@@ -1,34 +1,31 @@
-extern crate fs_extra;
-extern crate ncurses;
-
+use lazy_static::lazy_static;
use std::path;
-use std::sync;
+use std::sync::{mpsc, Mutex, atomic};
use std::thread;
use std::time;
-use commands::{self, JoshutoCommand, JoshutoRunnable, ProgressInfo};
-use context::JoshutoContext;
-use preview;
-use structs::JoshutoDirList;
+use crate::commands::{self, JoshutoCommand, JoshutoRunnable, ProgressInfo};
+use crate::context::JoshutoContext;
+use crate::structs::JoshutoDirList;
lazy_static! {
- static ref selected_files: sync::Mutex<Vec<path::PathBuf>> = sync::Mutex::new(vec![]);
- static ref fileop: sync::Mutex<FileOp> = sync::Mutex::new(FileOp::Copy);
- static ref tab_src: sync::Mutex<usize> = sync::Mutex::new(0);
+ static ref selected_files: Mutex<Vec<path::PathBuf>> = Mutex::new(vec![]);
+ static ref fileop: Mutex<FileOp> = Mutex::new(FileOp::Copy);
+ static ref tab_src: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
}
pub struct FileOperationThread {
pub tab_src: usize,
pub tab_dest: usize,
pub handle: thread::JoinHandle<i32>,
- pub recv: sync::mpsc::Receiver<ProgressInfo>,
+ pub recv: mpsc::Receiver<ProgressInfo>,
}
impl FileOperationThread {
pub fn recv_timeout(
&self,
wait_duration: &time::Duration,
- ) -> Result<ProgressInfo, std::sync::mpsc::RecvTimeoutError> {
+ ) -> Result<ProgressInfo, mpsc::RecvTimeoutError> {
self.recv.recv_timeout(*wait_duration)
}
}
@@ -39,8 +36,7 @@ fn set_file_op(operation: FileOp) {
}
fn set_tab_src(tab_index: usize) {
- let mut data = tab_src.lock().unwrap();
- *data = tab_index;
+ tab_src.store(tab_index, atomic::Ordering::Release);
}
fn repopulated_selected_files(dirlist: &JoshutoDirList) -> bool {
@@ -144,10 +140,8 @@ impl PasteFiles {
use std::os::linux::fs::MetadataExt;
let tab_dest = context.curr_tab_index;
- let tab_src_index: usize;
- {
- tab_src_index = *tab_src.lock().unwrap();
- }
+ let tab_src_index = tab_src.load(atomic::Ordering::SeqCst);
+
let mut destination = context.tabs[tab_dest].curr_path.clone();
let options = self.options.clone();
@@ -164,7 +158,7 @@ impl PasteFiles {
path_ino = paths[0].metadata()?.st_dev();
}
- let (tx, rx) = sync::mpsc::channel();
+ let (tx, rx) = mpsc::channel();
let handle = if dest_ino == path_ino {
thread::spawn(move || {
let mut paths = selected_files.lock().unwrap();
@@ -224,10 +218,8 @@ impl PasteFiles {
#[cfg(not(target_os = "linux"))]
fn cut(&self, context: &mut JoshutoContext) -> Result<FileOperationThread, std::io::Error> {
let tab_dest = context.curr_tab_index;
- let tab_src_index: usize;
- {
- tab_src_index = *tab_src.lock().unwrap();
- }
+ let tab_src_index = tab_src.load(atomic::Ordering::SeqCst);
+
let mut destination = context.tabs[tab_dest].curr_path.clone();
let options = self.options.clone();
@@ -240,7 +232,7 @@ impl PasteFiles {
));
}
}
- let (tx, rx) = sync::mpsc::channel();
+ let (tx, rx) = mpsc::channel();
let handle = thread::spawn(move || {
let mut paths = selected_files.lock().unwrap();
@@ -269,14 +261,12 @@ impl PasteFiles {
fn copy(&self, context: &mut JoshutoContext) -> Result<FileOperationThread, std::io::Error> {
let tab_dest = context.curr_tab_index;
- let tab_src_index: usize;
- {
- tab_src_index = *tab_src.lock().unwrap();
- }
+ let tab_src_index = tab_src.load(atomic::Ordering::SeqCst);
+
let destination = context.tabs[tab_dest].curr_path.clone();
let options = self.options.clone();
- let (tx, rx) = sync::mpsc::channel();
+ let (tx, rx) = mpsc::channel();
let handle = thread::spawn(move || {
let mut paths = selected_files.lock().unwrap();
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index c055d64..9130cac 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -1,5 +1,3 @@
-extern crate wordexp;
-
mod change_directory;
mod cursor_move;
mod delete_files;
@@ -41,8 +39,8 @@ use std::collections::HashMap;
use std::fmt;
use std::path::PathBuf;
-use context::JoshutoContext;
-use structs;
+use crate::context::JoshutoContext;
+use crate::structs;
#[derive(Debug)]
pub enum CommandKeybind {
diff --git a/src/commands/new_directory.rs b/src/commands/new_directory.rs
index 2ff5701..788d576 100644
--- a/src/commands/new_directory.rs
+++ b/src/commands/new_directory.rs
@@ -1,11 +1,9 @@
-extern crate ncurses;
-
use std::path;
-use commands::{JoshutoCommand, JoshutoRunnable, ReloadDirList};
-use context::JoshutoContext;
-use textfield::JoshutoTextField;
-use ui;
+use crate::commands::{JoshutoCommand, JoshutoRunnable, ReloadDirList};
+use crate::context::JoshutoContext;
+use crate::textfield::JoshutoTextField;
+use crate::ui;
#[derive(Clone, Debug)]
pub struct NewDirectory;
diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs
index 3facb4f..7ff7e0a 100644
--- a/src/commands/open_file.rs
+++ b/src/commands/open_file.rs
@@ -1,20 +1,16 @@
-extern crate fs_extra;
-extern crate ncurses;
-extern crate open;
-
use std::env;
use std::path::{Path, PathBuf};
-use commands::{self, JoshutoCommand, JoshutoRunnable};
-use config::mimetype;
-use context::JoshutoContext;
-use preview;
-use textfield::JoshutoTextField;
-use ui;
-use unix;
-use window;
+use crate::commands::{self, JoshutoCommand, JoshutoRunnable};
+use crate::config::mimetype;
+use crate::context::JoshutoContext;
+use crate::preview;
+use crate::textfield::JoshutoTextField;
+use crate::ui;
+use crate::unix;
+use crate::window;
-use mimetype_t;
+use crate::mimetype_t;
#[derive(Clone, Debug)]
pub struct OpenFile;
diff --git a/src/commands/parent_directory.rs b/src/commands/parent_directory.rs
index d158d3b..15d3556 100644
--- a/src/commands/parent_directory.rs
+++ b/src/commands/parent_directory.rs
@@ -1,9 +1,7 @@
-extern crate ncurses;
-
-use commands::{JoshutoCommand, JoshutoRunnable};
-use context::JoshutoContext;
-use preview;
-use ui;
+use crate::commands::{JoshutoCommand, JoshutoRunnable};
+use crate::context::JoshutoContext;
+use crate::preview;
+use crate::ui;
#[derive(Clone, Debug)]
pub struct ParentDirectory;
diff --git a/src/commands/quit.rs b/src/commands/quit.rs
index e5410f9..8f8d66f 100644
--- a/src/commands/quit.rs
+++ b/src/commands/quit.rs
@@ -1,6 +1,6 @@
-use commands::{JoshutoCommand, JoshutoRunnable};
-use context::JoshutoContext;
-use ui;
+use crate::commands::{JoshutoCommand, JoshutoRunnable};
+use crate::context::JoshutoContext;
+use crate::ui;
#[derive(Clone, Debug)]
pub struct Quit;
diff --git a/src/commands/reload_dir.rs b/src/commands/reload_dir.rs
index 3853810..20981bc 100644
--- a/src/commands/reload_dir.rs
+++ b/src/commands/reload_dir.rs
@@ -1,8 +1,6 @@
-extern crate ncurses;
-
-use commands::{JoshutoCommand, JoshutoRunnable};
-use context::JoshutoContext;
-use preview;
+use crate::commands::{JoshutoCommand, JoshutoRunnable};
+use crate::context::JoshutoContext;
+use crate::preview;
#[derive(Clone, Debug)]
pub struct ReloadDirList;
diff --git a/src/commands/rename_file.rs b/src/commands/rename_file.rs
index f61ab4c..9de918b 100644
--- a/src/commands/rename_file.rs
+++ b/src/commands/rename_file.rs
@@ -1,13 +1,11 @@
-extern crate ncurses;
-
use std::fs;
use std::path;
-use commands::{JoshutoCommand, JoshutoRunnable};
-use context::JoshutoContext;
-use preview;
-use textfield::JoshutoTextField;
-use ui;
+use crate::commands::{JoshutoCommand, JoshutoRunnable};
+use crate::context::JoshutoContext;
+use crate::preview;
+use crate::textfield::JoshutoTextField;
+use crate::ui;
#[derive(Clone, Debug)]
pub enum RenameFileMethod {
diff --git a/src/commands/search.rs b/src/commands/search.rs
index a8c1edb..f2d55e2 100644
--- a/src/commands/search.rs
+++ b/src/commands/search.rs
@@ -1,9 +1,7 @@
-extern crate ncurses;
-
-use commands::{CursorMove, JoshutoCommand, JoshutoRunnable};
-use context::JoshutoContext;
-use textfield::JoshutoTextField;
-use ui;
+use crate::commands::{CursorMove, JoshutoCommand, JoshutoRunnable};
+use crate::context::JoshutoContext;
+use crate::textfield::JoshutoTextField;
+use crate::ui;
#[derive(Clone, Debug)]
pub struct Search;
diff --git a/src/commands/selection.rs b/src/commands/selection.rs
index 3d82215..37009ac 100644
--- a/src/commands/selection.rs
+++ b/src/commands/selection.rs
@@ -1,5 +1,5 @@
-use commands::{CursorMove, JoshutoCommand, JoshutoRunnable};
-use context::JoshutoContext;
+use crate::commands::{CursorMove, JoshutoCommand, JoshutoRunnable};
+use crate::context::JoshutoContext;
#[derive(Debug, Clone)]
pub struct SelectFiles {
diff --git a/src/commands/set_mode.rs b/src/commands/set_mode.rs
index 27b0b4a..ee7efd8 100644
--- a/src/commands/set_mode.rs
+++ b/src/commands/set_mode.rs
@@ -1,12 +1,9 @@
-extern crate libc;
-extern crate ncurses;
-
-use commands::{JoshutoCommand, JoshutoRunnable};
-use context::JoshutoContext;
-use structs::JoshutoDirEntry;
-use textfield::JoshutoTextField;
-use ui;
-use unix;
+use crate::commands::{JoshutoCommand, JoshutoRunnable};
+use crate::context::JoshutoContext;
+use crate::structs::JoshutoDirEntry;
+use crate::textfield::JoshutoTextField;
+use crate::ui;
+use crate::unix;
#[derive(Clone, Debug)]
pub struct SetMode;
diff --git a/src/commands/show_hidden.rs b/src/commands/show_hidden.rs
index aacac3b..bf9de41 100644
--- a/src/commands/show_hidden.rs
+++ b/src/commands/show_hidden.rs
@@ -1,7 +1,5 @@
-extern crate ncurses;
-
-use commands::{JoshutoCommand, JoshutoRunnable};
-use context::JoshutoContext;
+use crate::commands::{JoshutoCommand, JoshutoRunnable};
+use crate::context::JoshutoContext;
#[derive(Clone, Debug)]
pub struct ToggleHiddenFiles;
diff --git a/src/commands/tab_operations.rs b/src/commands/tab_operations.rs
index 05948a7..91cddd5 100644
--- a/src/commands/tab_operations.rs
+++ b/src/commands/tab_operations.rs
@@ -1,10 +1,10 @@
use std::env;
use std::path;
-use commands::{JoshutoCommand, JoshutoRunnable, Quit, TabSwitch};
-use context::JoshutoContext;
-use tab::JoshutoTab;
-use ui;
+use crate::commands::{JoshutoCommand, JoshutoRunnable, Quit, TabSwitch};
+use crate::context::JoshutoContext;
+use crate::tab::JoshutoTab;
+use crate::ui;
#[derive(Clone, Debug)]
pub struct NewTab;
diff --git a/src/commands/tab_switch.rs b/src/commands/tab_switch.rs
index 719b9cb..cf5131b 100644
--- a/src/commands/tab_switch.rs
+++ b/src/commands/tab_switch.rs
@@ -1,6 +1,6 @@
-use commands::{JoshutoCommand, JoshutoRunnable};
-use context::JoshutoContext;
-use ui;
+use crate::commands::{JoshutoCommand, JoshutoRunnable};
+use crate::context::JoshutoContext;
+use crate::ui;
#[derive(Clone, Debug)]
pub struct TabSwitch {
diff --git a/src/config/config.rs b/src/config/config.rs
index f6adb04..6bfa627 100644
--- a/src/config/config.rs
+++ b/src/config/config.rs
@@ -1,11 +1,9 @@
-extern crate toml;
-extern crate whoami;
-extern crate xdg;
+use serde_derive::Deserialize;
-use config::{parse_config_file, Flattenable};
-use sort;
+use crate::config::{parse_config_file, Flattenable};
+use crate::sort;
-use CONFIG_FILE;
+use crate::CONFIG_FILE;
#[derive(Clone, Debug, Deserialize)]
pub struct SortRawOption {
diff --git a/src/config/keymap.rs b/src/config/keymap.rs
index 83e48e4..eb0c81c 100644
--- a/src/config/keymap.rs
+++ b/src/config/keymap.rs
@@ -1,13 +1,10 @@
-extern crate fs_extra;
-extern crate toml;
-extern crate xdg;
-
+use serde_derive::Deserialize;
use std::collections::HashMap;
use std::process::exit;
-use commands;
-use config::{parse_config_file, Flattenable};
-use KEYMAP_FILE;
+use crate::commands;
+use crate::config::{parse_config_file, Flattenable};
+use crate::KEYMAP_FILE;
pub const BACKSPACE: i32 = 0x7F;
pub const TAB: i32 = 0x9;
@@ -73,25 +70,23 @@ fn insert_keycommand(
if let Some(s) = key_to_i32(&keys[0]) {
map.insert(s, commands::CommandKeybind::SimpleKeybind(keycommand));
}
- } else {
- if let Some(s) = key_to_i32(&keys[0]) {
- let mut new_map: HashMap<i32, commands::CommandKeybind>;
- match map.remove(&s) {
- Some(commands::CommandKeybind::CompositeKeybind(mut m)) => {
- new_map = m;
- }
- Some(_) => {
- eprintln!("Error: Keybindings ambiguous");
- exit(1);
- }
- None => {
- new_map = HashMap::new();
- }
+ } else if let Some(s) = key_to_i32(&keys[0]) {
+ let mut new_map: HashMap<i32, commands::CommandKeybind>;
+ match map.remove(&s) {
+ Some(commands::CommandKeybind::CompositeKeybind(m)) => {
+ new_map = m;
+ }
+ Some(_) => {
+ eprintln!("Error: Keybindings ambiguous");
+ exit(1);
+ }
+ None => {
+ new_map = HashMap::new();
}
- insert_keycommand(&mut new_map, keycommand, &keys[1..]);
- let composite_command = commands::CommandKeybind::CompositeKeybind(new_map);
- map.insert(s as i32, composite_command);
}
+ insert_keycommand(&mut new_map, keycommand, &keys[1..]);
+ let composite_command = commands::CommandKeybind::CompositeKeybind(new_map);
+ map.insert(s as i32, composite_command);
}
}
diff --git a/src/config/mimetype.rs b/src/config/mimetype.rs
index 256aa9e..8c730c0 100644
--- a/src/config/mimetype.rs
+++ b/src/config/mimetype.rs
@@ -1,11 +1,9 @@
-extern crate toml;
-extern crate xdg;
-
+use serde_derive::Deserialize;
use std::collections::HashMap;
use std::fmt;
-use config::{parse_config_file, Flattenable};
-use MIMETYPE_FILE;
+use crate::config::{parse_config_file, Flattenable};
+use crate::MIMETYPE_FILE;
#[derive(Debug, Deserialize)]
pub struct JoshutoMimetypeEntry {
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 273b9ab..dca9f3d 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -1,5 +1,3 @@
-extern crate serde;
-
pub mod config;
pub mod keymap;
pub mod mimetype;
@@ -12,11 +10,11 @@ pub use self::mimetype::JoshutoMimetype;
pub use self::preview::JoshutoPreview;
pub use self::theme::{JoshutoColorTheme, JoshutoTheme};
-use self::serde::de::DeserializeOwned;
+use serde::de::DeserializeOwned;
use std::fs;
use std::path::{Path, PathBuf};
-use CONFIG_HIERARCHY;
+use crate::CONFIG_HIERARCHY;
// implemented by config file implementations to turn a RawConfig into a Config
trait Flattenable<T> {
diff --git a/src/config/preview.rs b/src/config/preview.rs
index b24e5c9..939c45f 100644
--- a/src/config/preview.rs
+++ b/src/config/preview.rs
@@ -1,10 +1,8 @@
-extern crate toml;
-extern crate xdg;
-
+use serde_derive::Deserialize;
use std::collections::HashMap;
-use config::{parse_config_file, Flattenable};
-use PREVIEW_FILE;
+use crate::config::{parse_config_file, Flattenable};
+use crate::PREVIEW_FILE;
#[derive(Debug, Deserialize)]
pub struct JoshutoPreviewEntry {
diff --git a/src/config/theme.rs b/src/config/theme.rs
index 0c43ed8..31ccbdc 100644
--- a/src/config/theme.rs
+++ b/src/config/theme.rs
@@ -1,9 +1,7 @@
-extern crate toml;
-extern crate xdg;
-
+use serde_derive::Deserialize;
use std::collections::HashMap;
-use config::{parse_config_file, Flattenable};
+use crate::config::{parse_config_file, Flattenable};
#[derive(Debug, Deserialize, Clone)]
pub struct JoshutoColorPair {
@@ -224,7 +222,7 @@ impl JoshutoTheme {
}
pub fn get_config() -> JoshutoTheme {
- parse_config_file::<JoshutoRawTheme, JoshutoTheme>(::THEME_FILE)
+ parse_config_file::<JoshutoRawTheme, JoshutoTheme>(crate::THEME_FILE)
.unwrap_or_else(JoshutoTheme::new)
}
}
diff --git a/src/context.rs b/src/context.rs
index 863acbc..1e9883b 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -1,7 +1,7 @@
-use commands::FileOperationThread;
-use config;
-use tab::JoshutoTab;
-use window::JoshutoView;
+use crate::commands::FileOperationThread;
+use crate::config;
+use crate::tab::JoshutoTab;
+use crate::window::JoshutoView;
pub struct JoshutoContext {
pub username: String,
diff --git a/src/history.rs b/src/history.rs
index bc1fe7c..fc69338 100644
--- a/src/history.rs
+++ b/src/history.rs
@@ -1,8 +1,8 @@
use std::collections::{hash_map::Entry, HashMap};
use std::path::{Path, PathBuf};
-use sort;
-use structs;
+use crate::sort;
+use crate::structs;
pub struct DirHistory {
map: HashMap<PathBuf, structs::JoshutoDirList>,
diff --git a/src/main.rs b/src/main.rs
index 7c6efdd..9287ce1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,10 +1,3 @@
-#[macro_use]
-extern crate lazy_static;
-#[macro_use]
-extern crate serde_derive;
-extern crate structopt;
-extern crate xdg;
-
mod commands;
mod config;
mod context;
@@ -19,6 +12,7 @@ mod ui;
mod unix;
mod window;
+use lazy_static::lazy_static;
use std::path::PathBuf;
use structopt::StructOpt;
diff --git a/src/preview.rs b/src/preview.rs
index d5ff4ca..45b2fb0 100644
--- a/src/preview.rs
+++ b/src/preview.rs
@@ -1,13 +1,8 @@
-extern crate mime;
-extern crate mime_detective;
-extern crate ncurses;
-
use std::path::PathBuf;
use std::process;
-use context::JoshutoContext;
-use ui;
-use window;
+use crate::context::JoshutoContext;
+use crate::window;
pub fn preview_file(context: &mut JoshutoContext) {
/*
diff --git a/src/run.rs b/src/run.rs
index ea560d3..aef5e97 100644
--- a/src/run.rs
+++ b/src/run.rs
@@ -1,15 +1,13 @@
-extern crate ncurses;
-
use std::collections::HashMap;
use std::time;
-use commands;
-use commands::{CommandKeybind, JoshutoCommand};
-use config;
-use context::JoshutoContext;
-use preview;
-use ui;
-use window::JoshutoPanel;
+use crate::commands;
+use crate::commands::{CommandKeybind, JoshutoCommand};
+use crate::config;
+use crate::context::JoshutoContext;
+use crate::preview;
+use crate::ui;
+use crate::window::JoshutoPanel;
fn recurse_get_keycommand(
keymap: &HashMap<i32, CommandKeybind>,
diff --git a/src/sort.rs b/src/sort.rs
index b1f01fc..cbfc635 100644
--- a/src/sort.rs
+++ b/src/sort.rs
@@ -2,7 +2,7 @@ use std::cmp;
use std::fs;
use std::time;
-use structs;
+use crate::structs;
#[derive(Debug, Clone)]
pub struct SortOption {
diff --git a/src/structs.rs b/src/structs.rs
index 070e7b3..c41cb52 100644
--- a/src/structs.rs
+++ b/src/structs.rs
@@ -3,8 +3,8 @@ use std::fs;
use std::path::{Path, PathBuf};