From 096e343f253bdc765ae06a4a81308c44448c3483 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Sat, 15 Oct 2022 03:52:38 +0200 Subject: [PATCH] improve colors --- nested/src/color.rs | 8 +++++--- nested/src/list/nav.rs | 7 ++++++- nested/src/list/pty_editor.rs | 1 - nested/src/list/segment.rs | 11 +++++------ nested/src/product/nav.rs | 3 +-- nested/src/product/segment.rs | 15 +++++++-------- 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/nested/src/color.rs b/nested/src/color.rs index d723636..9f5ae9e 100644 --- a/nested/src/color.rs +++ b/nested/src/color.rs @@ -4,7 +4,9 @@ use { pub fn bg_style_from_depth(depth: usize) -> TerminalStyle { match depth { - 1 => TerminalStyle::bg_color((40,40,40)), + 0 => TerminalStyle::bg_color((150,80,230)), + 1 => TerminalStyle::bg_color((35,35,35)), + 2 => TerminalStyle::bg_color((10,10,10)), _ => TerminalStyle::default(), } } @@ -13,9 +15,9 @@ pub fn fg_style_from_depth(depth: usize) -> TerminalStyle { match depth % 6 { 0 => TerminalStyle::fg_color((40, 180, 230)), 1 => TerminalStyle::fg_color((120, 120, 120)), - 2 => TerminalStyle::fg_color((230, 180, 40)), + 2 => TerminalStyle::fg_color((250, 165, 40)), 3 => TerminalStyle::fg_color((80, 180, 200)), - 4 => TerminalStyle::fg_color((70, 90, 180)), + 4 => TerminalStyle::fg_color((180, 240, 85)), 5 => TerminalStyle::fg_color((200, 190, 70)), _ => TerminalStyle::default() } diff --git a/nested/src/list/nav.rs b/nested/src/list/nav.rs index e667fac..67f5930 100644 --- a/nested/src/list/nav.rs +++ b/nested/src/list/nav.rs @@ -160,10 +160,13 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static if direction.y < 0 { // up + /* self.cursor.set(ListCursor { mode: cur.leaf_mode, idx: None - }); + }); + */ + self.cursor.set(ListCursor::none()); TreeNavResult::Exit } else if direction.y > 0 { // dn @@ -232,6 +235,7 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static mode: cur.leaf_mode, idx: None }); + self.cursor.set(ListCursor::none()); TreeNavResult::Exit } } @@ -282,6 +286,7 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static mode: cur.leaf_mode, idx: None }); + self.cursor.set(ListCursor::none()); TreeNavResult::Exit } } diff --git a/nested/src/list/pty_editor.rs b/nested/src/list/pty_editor.rs index 91e729c..0f61c8b 100644 --- a/nested/src/list/pty_editor.rs +++ b/nested/src/list/pty_editor.rs @@ -220,7 +220,6 @@ impl TerminalTreeEditor for PTYListEditor where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static {} - use crate::{ char_editor::CharEditor, sequence::SequenceViewExt diff --git a/nested/src/list/segment.rs b/nested/src/list/segment.rs index 09cbd0e..6e125e8 100644 --- a/nested/src/list/segment.rs +++ b/nested/src/list/segment.rs @@ -48,15 +48,14 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static let c = e.read().unwrap().get_cursor(); let cur_depth = c.tree_addr.len(); let select = - cur_dist == 0 && - if c.leaf_mode == ListCursorMode::Select { - cur_depth == 0 + if cur_dist == 0 { + cur_depth } else { - cur_depth == 1 + usize::MAX }; atom - .add_style_back(bg_style_from_depth(if select { 1 } else { 0 })) - .add_style_back(TerminalStyle::bold(select)) + .add_style_back(bg_style_from_depth(select)) + .add_style_back(TerminalStyle::bold(select==1)) .add_style_back(fg_style_from_depth(d)) }) } diff --git a/nested/src/product/nav.rs b/nested/src/product/nav.rs index a0d8338..8ff801f 100644 --- a/nested/src/product/nav.rs +++ b/nested/src/product/nav.rs @@ -178,7 +178,7 @@ impl TreeNav for ProductEditor { //\\//\\//\\//\\ match ce.goby(direction) { TreeNavResult::Exit => { - *cur_depth = 1; + // *cur_depth = 1; drop(ce); drop(e); @@ -195,7 +195,6 @@ impl TreeNav for ProductEditor { TreeNavResult::Continue } else if direction.y == 0 { // horizontal - if direction.x != 0 { *cur_depth = 0; } diff --git a/nested/src/product/segment.rs b/nested/src/product/segment.rs index 84587f2..2ceefc6 100644 --- a/nested/src/product/segment.rs +++ b/nested/src/product/segment.rs @@ -49,16 +49,15 @@ impl ProductEditorSegment { let c = e.read().unwrap().get_cursor(); let cur_depth = c.tree_addr.len(); let select = - cur_dist == 0 && - if c.leaf_mode == ListCursorMode::Select { - cur_depth == 0 + if cur_dist == 0 { + cur_depth } else { - cur_depth == 1 + usize::MAX }; return x - .add_style_back(bg_style_from_depth(if select { 1 } else { 0 })) - .add_style_back(TerminalStyle::bold(select)) + .add_style_back(bg_style_from_depth(select)) + .add_style_back(TerminalStyle::bold(select==1)) .add_style_back(fg_style_from_depth(d)); } }), @@ -71,8 +70,8 @@ impl ProductEditorSegment { let cur_dist = *cur_dist; move |i, x| - x.add_style_back(TerminalStyle::fg_color((130,90,40))) - .add_style_back(bg_style_from_depth(if cur_dist == 0 { 1 } else { 0 })) + x.add_style_back(TerminalStyle::fg_color((215,140,95))) + .add_style_back(bg_style_from_depth(if cur_dist == 0 { 0 } else { usize::MAX })) .add_style_back(TerminalStyle::bold(cur_dist == 0)) }) }