Removed unused fields. Renamed style names to be in line with other ui.editor styles

imgbot
Igor Cohanovschi 2 years ago
parent 9bd9e4cc42
commit 9c15d4fade

@ -499,7 +499,7 @@ impl Explorer {
)); ));
} }
fn fold_current(item: &mut FileInfo, cx: &mut Context, state: &mut State) { fn fold_current(item: &mut FileInfo, _cx: &mut Context, _state: &mut State) {
if item.path.is_dir() { if item.path.is_dir() {
item.expanded = false; item.expanded = false;
} }
@ -590,7 +590,7 @@ impl Explorer {
let preview_area = area.clip_left(side_area.width).clip_bottom(2); let preview_area = area.clip_left(side_area.width).clip_bottom(2);
let prompt_area = area.clip_top(side_area.height); let prompt_area = area.clip_top(side_area.height);
let border_style = cx.editor.theme.get("ui.explore.border"); let border_style = cx.editor.theme.get("ui.explorer.border");
let list_area = render_block( let list_area = render_block(
side_area.clip_left(1), side_area.clip_left(1),
surface, surface,

@ -118,14 +118,12 @@ pub enum TreeOp<T> {
pub struct Elem<T> { pub struct Elem<T> {
item: T, item: T,
level: usize, level: usize,
expanded: bool,
folded: Vec<Self>, folded: Vec<Self>,
} }
impl<T: Clone> Clone for Elem<T> { impl<T: Clone> Clone for Elem<T> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self { Self {
expanded: false,
item: self.item.clone(), item: self.item.clone(),
level: self.level, level: self.level,
folded: self.folded.clone(), folded: self.folded.clone(),
@ -138,7 +136,6 @@ impl<T> Elem<T> {
Self { Self {
item, item,
level, level,
expanded: false,
folded: vec![], folded: vec![],
} }
} }
@ -180,7 +177,7 @@ impl<T: TreeItem> Tree<T> {
col: 0, col: 0,
max_len: 0, max_len: 0,
count: 0, count: 0,
tree_symbol_style: "ui.explore.guide".into(), tree_symbol_style: "ui.explorer.guide".into(),
pre_render: None, pre_render: None,
on_opened_fn: None, on_opened_fn: None,
on_folded_fn: None, on_folded_fn: None,
@ -474,7 +471,6 @@ impl<T: TreeItem> Tree<T> {
self.max_len = 0; self.max_len = 0;
self.row = std::cmp::min(self.row, area.height.saturating_sub(1) as usize); self.row = std::cmp::min(self.row, area.height.saturating_sub(1) as usize);
let style = cx.editor.theme.get(&self.tree_symbol_style); let style = cx.editor.theme.get(&self.tree_symbol_style);
let line_style = cx.editor.theme.get("ui.virtual.ruler");
let folder_style = cx.editor.theme.get("special"); let folder_style = cx.editor.theme.get("special");
let last_item_index = self.items.len().saturating_sub(1); let last_item_index = self.items.len().saturating_sub(1);
let skip = self.selected.saturating_sub(self.row); let skip = self.selected.saturating_sub(self.row);
@ -490,10 +486,8 @@ impl<T: TreeItem> Tree<T> {
let mut area = Rect::new(area.x, area.y + row, area.width, 1); let mut area = Rect::new(area.x, area.y + row, area.width, 1);
let indent = if elem.level > 0 { let indent = if elem.level > 0 {
if index + skip != last_item_index { if index + skip != last_item_index {
//format!("{}├─", "│ ".repeat(elem.level - 1))
format!("{}", "│ ".repeat(elem.level - 1)) format!("{}", "│ ".repeat(elem.level - 1))
} else { } else {
//format!("└─{}", "┴─".repeat(elem.level - 1))
format!("{}", "".repeat(elem.level - 1)) format!("{}", "".repeat(elem.level - 1))
} }
} else { } else {
@ -516,13 +510,14 @@ impl<T: TreeItem> Tree<T> {
return; return;
} }
if start_index == 0 { if start_index == 0 {
//let expanded = elem.folded.len() > 0; let mut icon_offset = 0;
if let Some((icon, color)) = elem.item.icon() { if let Some((icon, color)) = elem.item.icon() {
let style = folder_style.fg(*color); let style = folder_style.fg(*color);
surface.set_string(area.x, area.y, icon, style); surface.set_string(area.x, area.y, icon, style);
icon_offset = 2;
} }
surface.set_span(area.x + 2, area.y, span, area.width - 2); surface.set_span(area.x + icon_offset, area.y, span, area.width - icon_offset);
area = area.clip_left((span.width() - 2) as u16); area = area.clip_left((span.width() - icon_offset as usize) as u16);
} else { } else {
let span_width = span.width(); let span_width = span.width();
if start_index > span_width { if start_index > span_width {

Loading…
Cancel
Save