diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-14 10:32:34 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-14 10:32:34 -0400 |
commit | 59ebe918aa4d6753cf061f08b38b84a9d11640e1 (patch) | |
tree | 0769e01cc167f719d8a9b9b9b9fc5262991910bd /src/commands/cursor_move.rs | |
parent | 5c6b1e53e4ebbe65e4299633659b28ff72ef6b56 (diff) |
add stub cursor move command for generating previews
Diffstat (limited to 'src/commands/cursor_move.rs')
-rw-r--r-- | src/commands/cursor_move.rs | 46 |
1 files changed, 40 insertions, 6 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" |