summaryrefslogtreecommitdiffstats
path: root/src/joshuto/command/set_mode.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/joshuto/command/set_mode.rs')
-rw-r--r--src/joshuto/command/set_mode.rs51
1 files changed, 26 insertions, 25 deletions
diff --git a/src/joshuto/command/set_mode.rs b/src/joshuto/command/set_mode.rs
index ab16f68..46b4652 100644
--- a/src/joshuto/command/set_mode.rs
+++ b/src/joshuto/command/set_mode.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::structs::JoshutoDirEntry;
use joshuto::textfield::JoshutoTextField;
@@ -14,12 +11,14 @@ use joshuto::unix;
pub struct SetMode;
impl SetMode {
- pub fn new() -> Self { SetMode }
- pub const fn command() -> &'static str { "set_mode" }
+ pub fn new() -> Self {
+ SetMode
+ }
+ pub const fn command() -> &'static str {
+ "set_mode"
+ }
- pub fn set_mode(&self, entry: &mut JoshutoDirEntry, start_str: String)
- -> bool
- {
+ pub fn set_mode(&self, entry: &mut JoshutoDirEntry, start_str: String) -> bool {
use std::os::unix::fs::PermissionsExt;
const PROMPT: &str = ":set_mode ";
@@ -27,23 +26,27 @@ impl SetMode {
let (term_rows, term_cols) = ui::getmaxyx();
let user_input: Option<String>;
{
- let textfield = JoshutoTextField::new(1,
- term_cols, (term_rows as usize - 1, 0), PROMPT.to_string());
+ let textfield = JoshutoTextField::new(
+ 1,
+ term_cols,
+ (term_rows as usize - 1, 0),
+ PROMPT.to_string(),
+ );
user_input = textfield.readline_with_initial(&start_str, "");
}
ncurses::doupdate();
- const LIBC_PERMISSION_VALS : [(u32, char) ; 9] = [
- (libc::S_IRUSR, 'r'),
- (libc::S_IWUSR, 'w'),
- (libc::S_IXUSR, 'x'),
- (libc::S_IRGRP, 'r'),
- (libc::S_IWGRP, 'w'),
- (libc::S_IXGRP, 'x'),
- (libc::S_IROTH, 'r'),
- (libc::S_IWOTH, 'w'),
- (libc::S_IXOTH, 'x'),
+ const LIBC_PERMISSION_VALS: [(u32, char); 9] = [
+ (libc::S_IRUSR, 'r'),
+ (libc::S_IWUSR, 'w'),
+ (libc::S_IXUSR, 'x'),
+ (libc::S_IRGRP, 'r'),
+ (libc::S_IWGRP, 'w'),
+ (libc::S_IXGRP, 'x'),
+ (libc::S_IROTH, 'r'),
+ (libc::S_IWOTH, 'w'),
+ (libc::S_IXOTH, 'x'),
];
if let Some(s) = user_input {
@@ -64,15 +67,13 @@ impl SetMode {
impl JoshutoCommand for SetMode {}
impl std::fmt::Display for SetMode {
- 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())
}
}
impl JoshutoRunnable for SetMode {
- fn execute(&self, context: &mut JoshutoContext)
- {
+ fn execute(&self, context: &mut JoshutoContext) {
let mut ok = false;
{
use std::os::unix::fs::PermissionsExt;