We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 24c65d6 commit abd1ed3Copy full SHA for abd1ed3
core/src/event.rs
@@ -111,6 +111,8 @@ pub enum KeyEvent {
111
DollarSign,
112
Caret,
113
QuestionMark,
114
+ AngleBracketOpen,
115
+ AngleBracketClose,
116
Num(NumKey),
117
Left,
118
Right,
core/src/state/notebook.rs
@@ -268,6 +268,8 @@ impl NotebookState {
268
"[k] Select previous".to_owned(),
269
"[G] Select last".to_owned(),
270
"[1-9] Add steps".to_owned(),
271
+ "[>] Expand width".to_owned(),
272
+ "[<] Shrink width".to_owned(),
273
"[Space] Move note".to_owned(),
274
"[m] Show more actions".to_owned(),
275
];
@@ -287,6 +289,8 @@ impl NotebookState {
287
289
288
290
291
292
293
294
"[Space] Move directory".to_owned(),
295
296
@@ -304,6 +308,8 @@ impl NotebookState {
304
308
format!("[k] Select {n} previous"),
305
309
306
310
"[0-9] Append steps".to_owned(),
311
+ format!("[>] Expand width by {n}"),
312
+ format!("[<] Shrink width by {n}"),
307
313
"[Esc] Cancel".to_owned(),
314
]
315
}
core/src/state/notebook/inner_state/note_tree/directory_selected.rs
@@ -81,6 +81,12 @@ pub async fn consume(
81
Ok(NotebookTransition::None)
82
83
Key(KeyEvent::CapG) => Ok(NotebookTransition::NoteTree(NoteTreeTransition::SelectLast)),
84
+ Key(KeyEvent::AngleBracketOpen) => Ok(NotebookTransition::NoteTree(
85
+ NoteTreeTransition::ShrinkWidth(1),
86
+ )),
87
+ Key(KeyEvent::AngleBracketClose) => Ok(NotebookTransition::NoteTree(
88
+ NoteTreeTransition::ExpandWidth(1),
89
90
Key(KeyEvent::Tab) if !state.tabs.is_empty() => tabs::focus_editor(db, state).await,
91
event @ Key(_) => Ok(NotebookTransition::Inedible(event)),
92
_ => Err(Error::Wip("todo: Notebook::consume".to_owned())),
core/src/state/notebook/inner_state/note_tree/note_selected.rs
@@ -70,6 +70,12 @@ pub async fn consume(
70
71
72
73
74
75
76
77
78
79
80
core/src/state/notebook/inner_state/note_tree/numbering.rs
@@ -56,6 +56,18 @@ pub async fn consume(
56
reset_state(state);
57
Ok(NotebookTransition::NoteTree(NoteTreeTransition::SelectLast))
58
59
+ Key(KeyEvent::AngleBracketOpen) => {
60
+ reset_state(state);
61
+ Ok(NotebookTransition::NoteTree(
62
+ NoteTreeTransition::ShrinkWidth(n),
63
+ ))
64
+ }
65
+ Key(KeyEvent::AngleBracketClose) => {
66
67
68
+ NoteTreeTransition::ExpandWidth(n),
69
event @ Key(_) => {
Ok(NotebookTransition::Inedible(event))
core/src/transition.rs
@@ -95,6 +95,8 @@ pub enum NoteTreeTransition {
95
SelectNext(usize),
96
SelectPrev(usize),
97
SelectLast,
98
+ ExpandWidth(usize),
99
+ ShrinkWidth(usize),
100
101
102
pub enum MoveModeTransition {
tui/src/action.rs
@@ -433,6 +433,8 @@ fn to_event(input: Input) -> Option<KeyEvent> {
433
KeyCode::Char('^') => KeyEvent::Caret,
434
KeyCode::Char('~') => KeyEvent::Tilde,
435
KeyCode::Char('?') => KeyEvent::QuestionMark,
436
+ KeyCode::Char('<') => KeyEvent::AngleBracketOpen,
437
+ KeyCode::Char('>') => KeyEvent::AngleBracketClose,
438
KeyCode::Char('.') => KeyEvent::Dot,
439
KeyCode::Char('-') => KeyEvent::Dash,
440
KeyCode::Char(' ') => KeyEvent::Space,
tui/src/context/notebook.rs
@@ -71,6 +71,7 @@ pub struct NotebookContext {
// note tree
pub tree_state: ListState,
pub tree_items: Vec<TreeItem>,
+ pub tree_width: u16,
// note actions
pub note_actions_state: ListState,
@@ -101,6 +102,7 @@ impl Default for NotebookContext {
state: ContextState::NoteTreeBrowsing,
103
tree_state: ListState::default().with_selected(Some(0)),
104
tree_items: vec![],
105
+ tree_width: 45,
106
107
note_actions_state: ListState::default(),
108
directory_actions_state: ListState::default(),
tui/src/transitions/notebook/note_tree.rs
@@ -87,6 +87,19 @@ impl App {
let event = get_select_event(selected);
self.glues.dispatch(event).await.log_unwrap();
+ NoteTreeTransition::ExpandWidth(n) => {
+ let n = n.try_into().unwrap_or_default();
+ let width = self.context.notebook.tree_width.saturating_add(n);
93
+
94
+ self.context.notebook.tree_width = width;
+ NoteTreeTransition::ShrinkWidth(n) => {
+ let width = self.context.notebook.tree_width.saturating_sub(n);
+ let width = if width < 11 { 11 } else { width };
NoteTreeTransition::ShowNoteActionsDialog(_)
| NoteTreeTransition::ShowDirectoryActionsDialog(_) => {}
tui/src/views/body/notebook.rs
@@ -19,7 +19,7 @@ pub fn draw(frame: &mut Frame, area: Rect, context: &mut Context) {
19
return;
20
21
22
- let horizontal = Layout::horizontal([Length(45), Percentage(100)]);
+ let horizontal = Layout::horizontal([Length(context.notebook.tree_width), Percentage(100)]);
23
let [note_tree_area, editor_area] = horizontal.areas(area);
24
25
note_tree::draw(frame, note_tree_area, &mut context.notebook);
0 commit comments