list editor: refactor cursor handling
This commit is contained in:
parent
9905a2376f
commit
2563e06000
5 changed files with 632 additions and 377 deletions
nested/src
35
nested/src/list/cursor.rs
Normal file
35
nested/src/list/cursor.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
pub enum ListCursorMode {
|
||||
Insert,
|
||||
Select,
|
||||
Modify
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
pub struct ListCursor {
|
||||
pub mode: ListCursorMode,
|
||||
pub idx: usize
|
||||
}
|
||||
|
||||
impl Default for ListCursor {
|
||||
fn default() -> Self {
|
||||
ListCursor {
|
||||
mode: ListCursorMode::Insert,
|
||||
idx: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
pub trait ListNav {
|
||||
fn pxev(&mut self) -> ListNavResult;
|
||||
fn nexd(&mut self) -> ListNavResult;
|
||||
fn pua(&mut self) -> ListNavResult;
|
||||
fn end(&mut self) -> ListNavResult;
|
||||
|
||||
fn set_cursor(&mut self, new_cursor: Option<ListCursor>) -> ListNavResult;
|
||||
fn get_cursor(&self) -> Option<ListCursor>;
|
||||
}
|
||||
*/
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,9 @@
|
|||
|
||||
pub mod editor;
|
||||
pub mod sexpr;
|
||||
pub mod cursor;
|
||||
pub mod editor;
|
||||
|
||||
pub use editor::{ListEditor, ListEditorStyle};
|
||||
pub use sexpr::{SExprView, ListDecoration};
|
||||
pub use cursor::{ListCursorMode, ListCursor};
|
||||
pub use editor::{ListEditor, ListEditorStyle};
|
||||
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
|
||||
#[derive(Eq, PartialEq)]
|
||||
use crate::list::ListCursorMode;
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
pub enum TreeNavResult {
|
||||
Continue,
|
||||
Exit
|
||||
}
|
||||
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
pub struct TreeCursor {
|
||||
pub leaf_mode: ListCursorMode,
|
||||
pub tree_addr: Vec<usize>
|
||||
}
|
||||
|
||||
pub trait TreeNav {
|
||||
fn up(&mut self) -> TreeNavResult {
|
||||
TreeNavResult::Exit
|
||||
|
@ -30,11 +38,11 @@ pub trait TreeNav {
|
|||
TreeNavResult::Exit
|
||||
}
|
||||
|
||||
fn goto(&mut self, tree_addr: Vec<usize>) -> TreeNavResult {
|
||||
fn goto(&mut self, new_cursor: Option<TreeCursor>) -> TreeNavResult {
|
||||
TreeNavResult::Exit
|
||||
}
|
||||
|
||||
fn get_cursor(&self) -> Option<Vec<usize>> {
|
||||
fn get_cursor(&self) -> Option<TreeCursor> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue