summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2020-03-14 10:32:34 -0400
committerJiayi Zhao <jeff.no.zhao@gmail.com>2020-03-14 10:32:34 -0400
commit59ebe918aa4d6753cf061f08b38b84a9d11640e1 (patch)
tree0769e01cc167f719d8a9b9b9b9fc5262991910bd /src
parent5c6b1e53e4ebbe65e4299633659b28ff72ef6b56 (diff)
add stub cursor move command for generating previews
Diffstat (limited to 'src')
-rw-r--r--src/commands/cursor_move.rs46
-rw-r--r--src/commands/mod.rs2
2 files changed, 41 insertions, 7 deletions
diff --git a/src/commands/cursor_move.rs b/src/commands/cursor_move.rs
index d249181..0306d93 100644
--- a/src/commands/cursor_move.rs
+++ b/src/commands/cursor_move.rs
@@ -36,13 +36,47 @@ pub fn cursor_move(new_index: usize, context: &mut JoshutoContext) {
}
#[derive(Clone, Debug)]
+pub struct CursorMoveStub {}
+
+impl CursorMoveStub {
+ pub fn new() -> Self {
+ Self {}
+ }
+ pub const fn command() -> &'static str {
+ "cursor_move_stub"
+ }
+}
+
+impl JoshutoCommand for CursorMoveStub {}
+
+impl std::fmt::Display for CursorMoveStub {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ write!(f, "{}", Self::command())
+ }
+}
+
+impl JoshutoRunnable for CursorMoveStub {
+ fn execute(&self, context: &mut JoshutoContext, _: &mut TuiBackend) -> JoshutoResult<()> {
+ let new_index = match context.curr_tab_ref().curr_list_ref() {
+ Some(curr_list) => curr_list.index,
+ None => None,
+ };
+
+ if let Some(s) = new_index {
+ cursor_move(s, context)
+ }
+ Ok(())
+ }
+}
+
+#[derive(Clone, Debug)]
pub struct CursorMoveDown {
movement: usize,
}
impl CursorMoveDown {
pub fn new(movement: usize) -> Self {
- CursorMoveDown { movement }
+ Self { movement }
}
pub const fn command() -> &'static str {
"cursor_move_up"
@@ -78,7 +112,7 @@ pub struct CursorMoveUp {
impl CursorMoveUp {
pub fn new(movement: usize) -> Self {
- CursorMoveUp { movement }
+ Self { movement }
}
pub const fn command() -> &'static str {
"cursor_move_down"
@@ -118,7 +152,7 @@ pub struct CursorMovePageUp;
impl CursorMovePageUp {
pub fn new() -> Self {
- CursorMovePageUp
+ Self
}
pub const fn command() -> &'static str {
"cursor_move_page_up"
@@ -163,7 +197,7 @@ pub struct CursorMovePageDown;
impl CursorMovePageDown {
pub fn new() -> Self {
- CursorMovePageDown
+ Self
}
pub const fn command() -> &'static str {
"cursor_move_page_down"
@@ -213,7 +247,7 @@ pub struct CursorMoveHome;
impl CursorMoveHome {
pub fn new() -> Self {
- CursorMoveHome
+ Self
}
pub const fn command() -> &'static str {
"cursor_move_home"
@@ -254,7 +288,7 @@ pub struct CursorMoveEnd;
impl CursorMoveEnd {
pub fn new() -> Self {
- CursorMoveEnd
+ Self
}
pub const fn command() -> &'static str {
"cursor_move_end"
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index 6d31197..cca9b20 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -22,7 +22,7 @@ pub use self::change_directory::ChangeDirectory;
pub use self::command_line::CommandLine;
pub use self::cursor_move::{
CursorMoveDown, CursorMoveEnd, CursorMoveHome, CursorMovePageDown, CursorMovePageUp,
- CursorMoveUp,
+ CursorMoveStub, CursorMoveUp,
};
pub use self::delete_files::DeleteFiles;
pub use self::file_ops::{CopyFiles, CutFiles, PasteFiles};