improve colors

This commit is contained in:
Michael Sippel 2022-10-15 03:52:38 +02:00
parent 21f7043ef0
commit 096e343f25
6 changed files with 24 additions and 21 deletions

View file

@ -4,7 +4,9 @@ use {
pub fn bg_style_from_depth(depth: usize) -> TerminalStyle { pub fn bg_style_from_depth(depth: usize) -> TerminalStyle {
match depth { 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(), _ => TerminalStyle::default(),
} }
} }
@ -13,9 +15,9 @@ pub fn fg_style_from_depth(depth: usize) -> TerminalStyle {
match depth % 6 { match depth % 6 {
0 => TerminalStyle::fg_color((40, 180, 230)), 0 => TerminalStyle::fg_color((40, 180, 230)),
1 => TerminalStyle::fg_color((120, 120, 120)), 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)), 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)), 5 => TerminalStyle::fg_color((200, 190, 70)),
_ => TerminalStyle::default() _ => TerminalStyle::default()
} }

View file

@ -160,10 +160,13 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static
if direction.y < 0 { if direction.y < 0 {
// up // up
/*
self.cursor.set(ListCursor { self.cursor.set(ListCursor {
mode: cur.leaf_mode, mode: cur.leaf_mode,
idx: None idx: None
}); });
*/
self.cursor.set(ListCursor::none());
TreeNavResult::Exit TreeNavResult::Exit
} else if direction.y > 0 { } else if direction.y > 0 {
// dn // dn
@ -232,6 +235,7 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static
mode: cur.leaf_mode, mode: cur.leaf_mode,
idx: None idx: None
}); });
self.cursor.set(ListCursor::none());
TreeNavResult::Exit TreeNavResult::Exit
} }
} }
@ -282,6 +286,7 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static
mode: cur.leaf_mode, mode: cur.leaf_mode,
idx: None idx: None
}); });
self.cursor.set(ListCursor::none());
TreeNavResult::Exit TreeNavResult::Exit
} }
} }

View file

@ -220,7 +220,6 @@ impl<ItemEditor> TerminalTreeEditor for PTYListEditor<ItemEditor>
where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static
{} {}
use crate::{ use crate::{
char_editor::CharEditor, char_editor::CharEditor,
sequence::SequenceViewExt sequence::SequenceViewExt

View file

@ -48,15 +48,14 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static
let c = e.read().unwrap().get_cursor(); let c = e.read().unwrap().get_cursor();
let cur_depth = c.tree_addr.len(); let cur_depth = c.tree_addr.len();
let select = let select =
cur_dist == 0 && if cur_dist == 0 {
if c.leaf_mode == ListCursorMode::Select { cur_depth
cur_depth == 0
} else { } else {
cur_depth == 1 usize::MAX
}; };
atom atom
.add_style_back(bg_style_from_depth(if select { 1 } else { 0 })) .add_style_back(bg_style_from_depth(select))
.add_style_back(TerminalStyle::bold(select)) .add_style_back(TerminalStyle::bold(select==1))
.add_style_back(fg_style_from_depth(d)) .add_style_back(fg_style_from_depth(d))
}) })
} }

View file

@ -178,7 +178,7 @@ impl TreeNav for ProductEditor {
//\\//\\//\\//\\ //\\//\\//\\//\\
match ce.goby(direction) { match ce.goby(direction) {
TreeNavResult::Exit => { TreeNavResult::Exit => {
*cur_depth = 1; // *cur_depth = 1;
drop(ce); drop(ce);
drop(e); drop(e);
@ -195,7 +195,6 @@ impl TreeNav for ProductEditor {
TreeNavResult::Continue TreeNavResult::Continue
} else if direction.y == 0 { } else if direction.y == 0 {
// horizontal // horizontal
if direction.x != 0 { if direction.x != 0 {
*cur_depth = 0; *cur_depth = 0;
} }

View file

@ -49,16 +49,15 @@ impl ProductEditorSegment {
let c = e.read().unwrap().get_cursor(); let c = e.read().unwrap().get_cursor();
let cur_depth = c.tree_addr.len(); let cur_depth = c.tree_addr.len();
let select = let select =
cur_dist == 0 && if cur_dist == 0 {
if c.leaf_mode == ListCursorMode::Select { cur_depth
cur_depth == 0
} else { } else {
cur_depth == 1 usize::MAX
}; };
return x return x
.add_style_back(bg_style_from_depth(if select { 1 } else { 0 })) .add_style_back(bg_style_from_depth(select))
.add_style_back(TerminalStyle::bold(select)) .add_style_back(TerminalStyle::bold(select==1))
.add_style_back(fg_style_from_depth(d)); .add_style_back(fg_style_from_depth(d));
} }
}), }),
@ -71,8 +70,8 @@ impl ProductEditorSegment {
let cur_dist = *cur_dist; let cur_dist = *cur_dist;
move |i, x| move |i, x|
x.add_style_back(TerminalStyle::fg_color((130,90,40))) x.add_style_back(TerminalStyle::fg_color((215,140,95)))
.add_style_back(bg_style_from_depth(if cur_dist == 0 { 1 } else { 0 })) .add_style_back(bg_style_from_depth(if cur_dist == 0 { 0 } else { usize::MAX }))
.add_style_back(TerminalStyle::bold(cur_dist == 0)) .add_style_back(TerminalStyle::bold(cur_dist == 0))
}) })
} }