summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands/mod.rs1
-rw-r--r--src/commands/tab_bar_mode.rs11
-rw-r--r--src/config/clean/app/display/config.rs7
-rw-r--r--src/config/clean/app/tab/config.rs66
-rw-r--r--src/config/clean/theme/tab.rs197
-rw-r--r--src/config/raw/app/display/tab.rs12
-rw-r--r--src/config/raw/theme/style.rs131
-rw-r--r--src/config/raw/theme/tab.rs48
-rw-r--r--src/context/app_context.rs2
-rw-r--r--src/context/tab_context.rs44
-rw-r--r--src/key_command/command.rs2
-rw-r--r--src/key_command/constants.rs1
-rw-r--r--src/key_command/impl_appcommand.rs1
-rw-r--r--src/key_command/impl_appexecute.rs3
-rw-r--r--src/key_command/impl_comment.rs14
-rw-r--r--src/key_command/impl_from_str.rs5
-rw-r--r--src/tab/tab_struct.rs9
-rw-r--r--src/ui/mod.rs2
-rw-r--r--src/ui/tab_list_builder.rs1040
-rw-r--r--src/ui/views/tui_folder_view.rs26
-rw-r--r--src/ui/views/tui_hsplit_view.rs19
-rw-r--r--src/ui/views/tui_worker_view.rs3
-rw-r--r--src/ui/widgets/mod.rs2
-rw-r--r--src/ui/widgets/tui_tab.rs62
-rw-r--r--src/ui/widgets/tui_topbar.rs78
-rw-r--r--src/util/format.rs24
-rw-r--r--src/util/style.rs17
27 files changed, 1425 insertions, 402 deletions
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index fb45e79..8b56f5a 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -40,7 +40,6 @@ pub mod show_tasks;
pub mod sort;
pub mod sub_process;
pub mod subdir_fzf;
-pub mod tab_bar_mode;
pub mod tab_ops;
pub mod touch_file;
pub mod uimodes;
diff --git a/src/commands/tab_bar_mode.rs b/src/commands/tab_bar_mode.rs
deleted file mode 100644
index e292aac..0000000
--- a/src/commands/tab_bar_mode.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-use crate::config::clean::app::tab::TabBarDisplayMode;
-use crate::context::AppContext;
-use crate::error::AppResult;
-
-pub fn set_tab_bar_display_mode(
- context: &mut AppContext,
- mode: &TabBarDisplayMode,
-) -> AppResult<()> {
- context.tab_context_mut().display.mode = *mode;
- Ok(())
-}
diff --git a/src/config/clean/app/display/config.rs b/src/config/clean/app/display/config.rs
index 4bf64de..1f8e51f 100644
--- a/src/config/clean/app/display/config.rs
+++ b/src/config/clean/app/display/config.rs
@@ -26,7 +26,6 @@ pub struct DisplayOption {
pub _show_borders: bool,
pub _show_hidden: bool,
pub _show_icons: bool,
- pub _tilde_in_titlebar: bool,
pub _line_nums: LineNumberStyle,
pub column_ratio: (usize, usize, usize),
pub default_layout: [Constraint; 3],
@@ -71,7 +70,6 @@ impl From<DisplayOptionRaw> for DisplayOption {
_show_borders: raw.show_borders,
_show_hidden: raw.show_hidden,
_show_icons: raw.show_icons,
- _tilde_in_titlebar: raw.tilde_in_titlebar,
_line_nums,
column_ratio,
@@ -120,10 +118,6 @@ impl DisplayOption {
self._show_hidden = show_hidden;
}
- pub fn tilde_in_titlebar(&self) -> bool {
- self._tilde_in_titlebar
- }
-
pub fn line_nums(&self) -> LineNumberStyle {
self._line_nums
}
@@ -164,7 +158,6 @@ impl std::default::Default for DisplayOption {
_show_borders: true,
_show_hidden: false,
_show_icons: false,
- _tilde_in_titlebar: true,
_line_nums: LineNumberStyle::None,
default_layout,
no_preview_layout,
diff --git a/src/config/clean/app/tab/config.rs b/src/config/clean/app/tab/config.rs
index 86e156f..d724e9a 100644
--- a/src/config/clean/app/tab/config.rs
+++ b/src/config/clean/app/tab/config.rs
@@ -1,28 +1,13 @@
-use std::str::FromStr;
-
-use serde::Deserialize;
-
-use crate::{
- config::raw::app::display::tab::TabOptionRaw,
- error::{AppError, AppErrorKind},
- tab::TabHomePage,
-};
+use crate::{config::raw::app::display::tab::TabOptionRaw, tab::TabHomePage};
#[derive(Clone, Debug)]
pub struct TabOption {
pub _home_page: TabHomePage,
- pub display: TabBarDisplayOption,
}
impl TabOption {
- pub fn new(_home_page: TabHomePage, display_mode: TabBarDisplayMode, max_len: usize) -> Self {
- Self {
- _home_page,
- display: TabBarDisplayOption {
- mode: display_mode,
- max_len,
- },
- }
+ pub fn new(_home_page: TabHomePage) -> Self {
+ Self { _home_page }
}
pub fn home_page(&self) -> TabHomePage {
self._home_page
@@ -33,7 +18,6 @@ impl std::default::Default for TabOption {
fn default() -> Self {
Self {
_home_page: TabHomePage::Home,
- display: TabBarDisplayOption::default(),
}
}
}
@@ -42,48 +26,6 @@ impl From<TabOptionRaw> for TabOption {
fn from(raw: TabOptionRaw) -> Self {
let home_page = TabHomePage::from_str(raw.home_page.as_str()).unwrap_or(TabHomePage::Home);
- Self::new(home_page, raw.display_mode, raw.max_len)
- }
-}
-
-#[derive(Clone, Copy, Debug)]
-pub struct TabBarDisplayOption {
- pub mode: TabBarDisplayMode,
- pub max_len: usize,
-}
-
-impl Default for TabBarDisplayOption {
- fn default() -> Self {
- Self {
- mode: Default::default(),
- max_len: 16,
- }
- }
-}
-
-#[derive(Debug, Clone, Copy, Deserialize, Default)]
-pub enum TabBarDisplayMode {
- #[serde(rename = "num")]
- Number,
- #[default]
- #[serde(rename = "dir")]
- Directory,
- #[serde(rename = "all")]
- All,
-}
-
-impl FromStr for TabBarDisplayMode {
- type Err = AppError;
-
- fn from_str(s: &str) -> Result<Self, Self::Err> {
- match s {
- "num" => Ok(Self::Number),
- "dir" => Ok(Self::Directory),
- "all" => Ok(Self::All),
- s => Err(AppError::new(
- AppErrorKind::UnrecognizedArgument,
- format!("tab_bar_mode: `{}` unknown argument.", s),
- )),
- }
+ Self::new(home_page)
}
}
diff --git a/src/config/clean/theme/tab.rs b/src/config/clean/theme/tab.rs
index 6a4a901..f8cf256 100644
--- a/src/config/clean/theme/tab.rs
+++ b/src/config/clean/theme/tab.rs
@@ -1,17 +1,198 @@
-use crate::config::raw::theme::tab::TabThemeRaw;
-
-use super::style::AppStyle;
+use crate::config::raw::theme::tab::{TabThemeCharsRaw, TabThemeColorRaw, TabThemeRaw};
+use crate::util::style::PathStyleIfSome;
+use ratatui::style::{Color, Modifier, Style};
+use unicode_width::UnicodeWidthStr;
#[derive(Clone, Debug)]
pub struct TabTheme {
- pub inactive: AppStyle,
- pub active: AppStyle,
+ pub styles: TabThemeColors,
+ pub chars: TabThemeChars,
+ pub inference: TabThemeCharsInference,
}
impl From<TabThemeRaw> for TabTheme {
fn from(crude: TabThemeRaw) -> Self {
- let inactive = crude.inactive.to_style_theme();
- let active = crude.active.to_style_theme();
- Self { inactive, active }
+ let chars = TabThemeChars::from(crude.chars);
+ Self {
+ styles: TabThemeColors::from(crude.styles),
+ inference: TabThemeCharsInference::from_chars(&chars),
+ chars,
+ }
+ }
+}
+
+#[derive(Clone, Debug)]
+pub struct TabThemeChars {
+ pub divider: String,
+ pub prefix_i: String,
+ pub postfix_i: String,
+ pub prefix_a: String,
+ pub postfix_a: String,
+ pub scroll_front_prefix: String,
+ pub scroll_front_postfix: String,
+ pub scroll_front_prestring: String,
+ pub scroll_front_poststring: String,
+ pub scroll_back_prefix: String,
+ pub scroll_back_postfix: String,
+ pub scroll_back_prestring: String,
+ pub scroll_back_poststring: String,
+ pub padding_prefix: char,
+ pub padding_postfix: char,
+ pub padding_fill: char,
+}
+
+impl From<TabThemeCharsRaw> for TabThemeChars {
+ fn from(crude: TabThemeCharsRaw) -> Self {
+ Self {
+ divider: crude.divider.unwrap_or(" ".to_string()),
+ prefix_i: crude.inactive_prefix.unwrap_or("[".to_string()),
+ postfix_i: crude.inactive_postfix.unwrap_or("]".to_string()),
+ prefix_a: crude.active_prefix.unwrap_or(" ".to_string()),
+ postfix_a: crude.active_postfix.unwrap_or(" ".to_string()),
+ scroll_front_prefix: crude.scroll_front_prefix.unwrap_or("".to_string()),
+ scroll_front_postfix: crude.scroll_front_postfix.unwrap_or("".to_string()),
+ scroll_front_prestring: crude.scroll_front_prestring.unwrap_or("«".to_string()),
+ scroll_front_poststring: crude.scroll_front_poststring.unwrap_or(" ".to_string()),
+ scroll_back_prefix: crude.scroll_back_prefix.unwrap_or("".to_string()),
+ scroll_back_postfix: crude.scroll_back_postfix.unwrap_or("".to_string()),
+ scroll_back_prestring: crude.scroll_back_prestring.unwrap_or(" ".to_string()),
+ scroll_back_poststring: crude.scroll_back_poststring.unwrap_or("»".to_string()),
+ padding_prefix: crude.padding_prefix.unwrap_or(' '),
+ padding_postfix: crude.padding_postfix.unwrap_or(' '),
+ padding_fill: crude.padding_fill.unwrap_or(' '),
+ }
+ }
+}
+
+#[derive(Clone, Debug)]
+pub struct TabThemeCharsInference {
+ pub tab_divider_length: usize,
+ pub tab_prefix_i_length: usize,
+ pub tab_postfix_i_length: usize,
+ pub tab_prefix_a_length: usize,
+ pub tab_postfix_a_length: usize,
+ pub scroll_front_static_length: usize,
+ pub scroll_back_static_length: usize,
+ pub active_tab_extra_width: usize,
+ pub inactive_tab_extra_width: usize,
+}
+
+impl TabThemeCharsInference {
+ fn from_chars(chars: &TabThemeChars) -> Self {
+ Self {
+ tab_divider_length: chars.divider.width(),
+ tab_prefix_i_length: chars.prefix_i.width(),
+ tab_prefix_a_length: chars.prefix_a.width(),
+ tab_postfix_i_length: chars.postfix_i.width(),
+ tab_postfix_a_length: chars.postfix_a.width(),
+ scroll_front_static_length: chars.scroll_front_prefix.width()
+ + chars.scroll_front_postfix.width()
+ + chars.scroll_front_prestring.width()
+ + chars.scroll_front_poststring.width(),
+ scroll_back_static_length: chars.scroll_back_prefix.width()
+ + chars.scroll_back_postfix.width()
+ + chars.scroll_back_prestring.width()
+ + chars.scroll_back_poststring.width(),
+ active_tab_extra_width: chars.prefix_a.width() + chars.postfix_a.width(),
+ inactive_tab_extra_width: chars.prefix_i.width() + chars.postfix_i.width(),
+ }
+ }
+
+ pub fn calc_scroll_tags_width(&self, num_tabs: usize) -> usize {
+ let max_num_width = num_tabs.checked_ilog10().unwrap_or(0) as usize + 1;
+ 2 * max_num_width + self.scroll_front_static_length + self.scroll_back_static_length
+ }
+}
+
+#[derive(Clone, Debug)]
+pub struct TabThemeColors {
+ pub prefix_a: Style,
+ pub postfix_a: Style,
+ pub tab_a: Style,
+ pub prefix_i: Style,
+ pub postfix_i: Style,
+ pub tab_i: Style,
+ pub divider_ii: Style,
+ pub divider_ia: Style,
+ pub divider_ai: Style,
+ pub scroll_front_prefix: Style,
+ pub scroll_front_postfix: Style,
+ pub scroll_front: Style,
+ pub scroll_back_prefix: Style,
+ pub scroll_back_postfix: Style,
+ pub scroll_back: Style,
+ pub padding_prefix: Style,
+ pub padding_postfix: Style,
+ pub padding_fill: Style,
+}
+
+impl From<TabThemeColorRaw> for TabThemeColors {
+ fn from(crude: TabThemeColorRaw) -> Self {
+ let tab_a = crude.active.map(|s| s.as_style()).unwrap_or(
+ Style::new()
+ .bg(Color::LightBlue)
+ .fg(Color::Black)
+ .add_modifier(Modifier::BOLD),
+ );
+ let prefix_a = tab_a.patch_optionally(crude.active_prefix.map(|s| s.as_style()));
+ let postfix_a = prefix_a.patch_optionally(crude.active_postfix.map(|s| s.as_style()));
+
+ let tab_i = crude.inactive.map(|s| s.as_style()).unwrap_or(Style::new());
+ let prefix_i = tab_i.patch_optionally(crude.inactive_prefix.map(|s| s.as_style()));
+ let postfix_i = prefix_i.patch_optionally(crude.inactive_postfix.map(|s| s.as_style()));
+
+ let divider_ii = crude
+ .divider_ii
+ .map(|s| s.as_style())
+ .unwrap_or(Style::new());
+ let divider_ia = divider_ii.patch_optionally(crude.divider_ia.map(|s| s.as_style()));
+ let divider_ai = divider_ia.patch_optionally(crude.divider_ai.map(|s| s.as_style()));
+
+ let scroll_front = crude
+ .scroll_front
+ .map(|s| s.as_style())
+ .unwrap_or(Style::new().fg(Color::Yellow).add_modifier(Modifier::BOLD));
+ let scroll_front_prefix =
+ scroll_front.patch_optionally(crude.scroll_front_prefix.map(|s| s.as_style()));
+ let scroll_front_postfix =
+ scroll_front_prefix.patch_optionally(crude.scroll_front_postfix.map(|s| s.as_style()));
+
+ let scroll_back = crude
+ .scroll_back
+ .map(|s| s.as_style())
+ .unwrap_or(Style::new().fg(Color::Yellow).add_modifier(Modifier::BOLD));
+ let scroll_back_prefix =
+ scroll_back.patch_optionally(crude.scroll_back_prefix.map(|s| s.as_style()));
+ let scroll_back_postfix =
+ scroll_back_prefix.patch_optionally(crude.scroll_back_postfix.map(|s| s.as_style()));
+
+ let padding_fill = crude
+ .padding_fill
+ .map(|s| s.as_style())
+ .unwrap_or(Style::new());
+ let padding_prefix =
+ padding_fill.patch_optionally(crude.padding_prefix.map(|s| s.as_style()));
+ let padding_postfix =
+ padding_prefix.patch_optionally(crude.padding_postfix.map(|s| s.as_style()));
+ Self {
+ prefix_a,
+ postfix_a,
+ tab_a,
+ prefix_i,
+ postfix_i,
+ tab_i,
+ divider_ii,
+ divider_ia,
+ divider_ai,
+ scroll_front_prefix,
+ scroll_front_postfix,
+ scroll_front,
+ scroll_back_prefix,
+ scroll_back_postfix,
+ scroll_back,
+ padding_prefix,
+ padding_postfix,
+ padding_fill,
+ }
}
}
diff --git a/src/config/raw/app/display/tab.rs b/src/config/raw/app/display/tab.rs
index 7a3c853..f3ee50b 100644
--- a/src/config/raw/app/display/tab.rs
+++ b/src/config/raw/app/display/tab.rs
@@ -1,31 +1,19 @@
use serde::Deserialize;
-use crate::config::clean::app::tab::TabBarDisplayMode;
-
fn default_home_page() -> String {
"home".to_string()
}
-const fn default_max_len() -> usize {
- 16
-}
-
#[derive(Clone, Debug, Deserialize)]
pub struct TabOptionRaw {
#[serde(default = "default_home_page")]
pub home_page: String,
- #[serde(default)]
- pub display_mode: TabBarDisplayMode,
- #[serde(default = "default_max_len")]
- pub max_len: usize,
}
impl std::default::Default for TabOptionRaw {
fn default() -> Self {
Self {
home_page: default_home_page(),
- display_mode: TabBarDisplayMode::default(),
- max_len: 16,
}
}
}
diff --git a/src/config/raw/theme/style.rs b/src/config/raw/theme/style.rs
index a588bd5..fd037a7 100644
--- a/src/config/raw/theme/style.rs
+++ b/src/config/raw/theme/style.rs
@@ -1,11 +1,96 @@
use colors_transform::{Color, Rgb};
-
+use ratatui::style::{self, Style};
use serde::Deserialize;
-use ratatui::style;
-
use crate::config::clean::theme::style::AppStyle;
+fn str_to_color(s: &str) -> style::Color {
+ match s {
+ "black" => style::Color::Black,
+ "red" => style::Color::Red,
+ "green" => style::Color::Green,
+ "yellow" => style::Color::Yellow,
+ "blue" => style::Color::Blue,
+ "magenta" => style::Color::Magenta,
+ "cyan" => style::Color::Cyan,
+ "gray" => style::Color::Gray,
+ "dark_gray" => style::Color::DarkGray,
+ "light_red" => style::Color::LightRed,
+ "light_green" => style::Color::LightGreen,
+ "light_yellow" => style::Color::LightYellow,
+ "light_blue" => style::Color::LightBlue,
+ "light_magenta" => style::Color::LightMagenta,
+ "light_cyan" => style::Color::LightCyan,
+ "white" => style::Color::White,
+ "reset" => style::Color::Reset,
+ s if s.starts_with('#') => {
+ let rgb = match Rgb::from_hex_str(s) {
+ Ok(s) => s,
+ _ => return style::Color::Reset,
+ };
+ let r = rgb.get_red() as u8;
+ let g = rgb.get_green() as u8;
+ let b = rgb.get_blue() as u8;
+ style::Color::Rgb(r, g, b)
+ }
+ s if s.is_empty() => style::Color::Reset,
+ s => match s.parse::<Rgb>() {
+ Ok(rgb) => {
+ let r = rgb.get_red() as u8;
+ let g = rgb.get_green() as u8;
+ let b = rgb.get_blue() as u8;
+ style::Color::Rgb(r, g, b)
+ }
+ Err(_) => style::Color::Reset,
+ },
+ }
+}
+
+#[derive(Clone, Debug, Deserialize)]
+
+pub struct AppStyleOptionsRaw {
+ pub fg: Option<String>,
+ pub bg: Option<String>,
+ pub bold: Option<bool>,
+ pub underline: Option<bool>,
+ pub invert: Option<bool>,
+}
+
+impl AppStyleOptionsRaw {
+ pub fn as_style(&self) -> Style {
+ let mut add_modifier = style::Modifier::empty();
+ let mut sub_modifier = style::Modifier::empty();
+ if let Some(bold) = self.bold {
+ if bold {
+ add_modifier.insert(style::Modifier::BOLD);
+ } else {
+ sub_modifier.insert(style::Modifier::BOLD);
+ }
+ }
+ if let Some(underline) = self.underline {
+ if underline {
+ add_modifier.insert(style::Modifier::UNDERLINED);
+ } else {
+ sub_modifier.insert(style::Modifier::UNDERLINED);
+ }
+ }
+ if let Some(invert) = self.invert {
+ if invert {
+ add_modifier.insert(style::Modifier::REVERSED);
+ } else {
+ sub_modifier.insert(style::Modifier::REVERSED);
+ }
+ }
+ Style {
+ fg: self.fg.clone().map(|s| str_to_color(s.as_ref())),
+ bg: self.bg.clone().map(|s| str_to_color(s.as_ref())),
+ add_modifier,
+ sub_modifier,
+ //underline_color: None, # only when ratatui with crossterm
+ }
+ }
+}
+
#[derive(Clone, Debug, Deserialize)]
pub struct AppStyleRaw {
#[serde(default)]
@@ -40,45 +125,7 @@ impl AppStyleRaw {
}
pub fn str_to_color(s: &str) -> style::Color {
- match s {
- "black" => style::Color::Black,
- "red" => style::Color::Red,
- "green" => style::Color::Green,
- "yellow" => style::Color::Yellow,
- "blue" => style::Color::Blue,
- "magenta" => style::Color::Magenta,
- "cyan" => style::Color::Cyan,
- "gray" => style::Color::Gray,
- "dark_gray" => style::Color::DarkGray,
- "light_red" => style::Color::LightRed,
- "light_green" => style::Color::LightGreen,
- "light_yellow" => style::Color::LightYellow,
- "light_blue" => style::Color::LightBlue,
- "light_magenta" => style::Color::LightMagenta,
- "light_cyan" => style::Color::LightCyan,
- "white" => style::Color::White,
- "reset" => style::Color::Reset,
- s if s.starts_with('#') => {
- let rgb = match Rgb::from_hex_str(s) {
- Ok(s) => s,
- _ => return style::Color::Reset,
- };
- let r = rgb.get_red() as u8;
- let g = rgb.get_green() as u8;
- let b = rgb.get_blue() as u8;
- style::Color::Rgb(r, g, b)
- }
- s if s.is_empty() => style::Color::Reset,
- s => match s.parse::<Rgb>() {
- Ok(rgb) => {
- let r = rgb.get_red() as u8;
- let g = rgb.get_green() as u8;
- let b = rgb.get_blue() as u8;
- style::Color::Rgb(r, g, b)
- }
- Err(_) => style::Color::Reset,
- },
- }
+ str_to_color(s)
}
}
diff --git a/src/config/raw/theme/tab.rs b/src/config/raw/theme/tab.rs
index 1e1fef6..be71113 100644
--- a/src/config/raw/theme/tab.rs
+++ b/src/config/raw/theme/tab.rs
@@ -1,11 +1,53 @@
use serde::Deserialize;
-use super::style::AppStyleRaw;
+use super::style::AppStyleOptionsRaw;
#[derive(Clone, Debug, Deserialize, Default)]
pub struct TabThemeRaw {
#[serde(default)]
- pub inactive: AppStyleRaw,
+ pub styles: TabThemeColorRaw,
#[serde(default)]
- pub active: AppStyleRaw,
+ pub chars: TabThemeCharsRaw,
+}
+
+#[derive(Clone, Debug, Deserialize, Default)]
+pub struct TabThemeColorRaw {
+ pub active_prefix: Option<AppStyleOptionsRaw>,
+ pub active_postfix: Option<AppStyleOptionsRaw>,
+ pub active: Option<AppStyleOptionsRaw>,
+ pub inactive_prefix: Option<AppStyleOptionsRaw>,
+ pub inactive_postfix: Option<AppStyleOptionsRaw>,
+ pub inactive: Option<AppStyleOptionsRaw>,
+ pub divider_ii: Option<AppStyleOptionsRaw>,
+ pub divider_ia: Option<AppStyleOptionsRaw>,
+ pub divider_ai: Option<AppStyleOptionsRaw>,
+ pub scroll_front_prefix: Option<AppStyleOptionsRaw>,
+ pub scroll_front_postfix: Option<AppStyleOptionsRaw>,
+ pub scroll_front: Option<AppStyleOptionsRaw>,
+ pub scroll_back_prefix: Option<AppStyleOptionsRaw>,
+ pub scroll_back_postfix: Option<AppStyleOptionsRaw>,
+ pub scroll_back: Option<AppStyleOptionsRaw>,
+ pub padding_prefix: Option<AppStyleOptionsRaw>,
+ pub padding_postfix: Option<AppStyleOptionsRaw>,
+ pub padding_fill: Option<AppStyleOptionsRaw>,
+}
+
+#[derive(Clone, Debug, Deserialize, Default)]
+pub struct TabThemeCharsRaw {
+ pub active_prefix: Option<String>,
+ pub active_postfix: Option<String>,
+ pub inactive_prefix: Option<String>,
+ pub inactive_postfix: Option<String>,
+ pub divider: Option<String>,
+ pub scroll_front_prefix: Option<String>,
+ pub scroll_front_postfix: Option<String>,
+ pub scroll_front_prestring: Option<String>,
+ pub scroll_front_poststring: Option<String>,
+ pub scroll_back_prefix: Option<String>,
+ pub scroll_back_postfix: Option<String>,
+ pub scroll_back_prestring: Option<String>,
+ pub scroll_back_poststring: Option<String>,
+ pub padding_prefix: Option<char>,
+ pub padding_postfix: Option<char>,
+ pub padding_fill: Option<char>,
}
diff --git a/src/context/app_context.rs b/src/context/app_context.rs
index 16401ca..35af553 100644
--- a/src/context/app_context.rs
+++ b/src/context/app_context.rs
@@ -70,7 +70,7 @@ impl AppContext {
quit: QuitAction::DoNot,
events,
args,
- tab_context: TabContext::new(config.tab_options_ref().display),
+ tab_context: TabContext::new(),
local_state: None,
search_context: None,
message_queue: MessageQueue::new(),
diff --git a/src/context/tab_context.rs b/src/context/tab_context.rs
index fa81c4a..1df7295 100644
--- a/src/context/tab_context.rs
+++ b/src/context/tab_context.rs
@@ -3,21 +3,18 @@ use std::collections::HashMap;
use uuid::Uuid;
-use crate::config::clean::app::tab::{TabBarDisplayMode, TabBarDisplayOption};
use crate::tab::JoshutoTab;
#[derive(Default)]
pub struct TabContext {
pub index: usize,
pub tab_order: Vec<Uuid>,
- pub display: TabBarDisplayOption,
tabs: HashMap<Uuid, JoshutoTab>,
}
impl TabContext {
- pub fn new(display: TabBarDisplayOption) -> Self {
+ pub fn new() -> Self {
Self {
- display,
..Default::default()
}
}
@@ -28,6 +25,17 @@ impl TabContext {
pub fn tab_ref(&self, id: &Uuid) -> Option<&JoshutoTab> {
self.tabs.get(id)
}
+
+ pub fn tab_refs_in_order(&self) -> Vec<&JoshutoTab> {
+ let mut tab_refs: Vec<&JoshutoTab> = vec![];
+ for tab_id in self.tab_order.iter() {
+ if let Some(tab_ref) = self.tab_ref(tab_id) {
+ tab_refs.push(tab_ref);
+ }
+ }
+ tab_refs
+ }
+
pub fn tab_mut(&mut self, id: &Uuid) -> Option<&mut JoshutoTab> {
self.tabs.get_mut(id)
}
@@ -61,32 +69,4 @@ impl TabContext {
pub fn iter_mut(&mut self) -> IterMut<Uuid, JoshutoTab> {
self.tabs.iter_mut()
}
-
- pub fn tab_title_width(&self) -> usize {
- self.tabs
- .values()
- .map(|tab| {
- let title_len = tab.tab_title().len();
- (title_len > self.display.max_len)
- .then(|| self.display.max_len)
- .unwrap_or(title_len)
- })
- .sum()
- }
-
- pub fn tab_area_width(&self) -> usize {
- let width_without_divider = match self.display.mode {
- TabBarDisplayMode::Number => (1..=self.len()).map(|n| n.to_string().len() + 2).sum(), // each number has a horizontal padding(1 char width)
- TabBarDisplayMode::Directory => self.tab_title_width(),
- TabBarDisplayMode::All => {
- // [number][: ](width = 2)[title]
- self.tab_title_width()
- + (1..=self.len())
- .map(|n| n.to_string().len() + 2)
- .sum::<usize>()
- }
- };
-
- width_without_divider + 3 * (self.len() - 1)
- }
}
diff --git a/src/key_command/command.rs b/src/key_command/command.rs
index ae2ad66..d218632 100644
--- a/src/key_command/command.rs
+++ b/src/key_command/command.rs
@@ -8,7 +8,6 @@ use crate::config::clean::app::display::line_number::LineNumberStyle;
use crate::config::clean::app::display::new_tab::NewTabMode;
use crate::config::clean::app::display::sort_type::SortType;
use crate::config::clean::app::search::CaseSensitivity;
-use crate::config::clean::app::tab::TabBarDisplayMode;
use crate::io::FileOperationOptions;
#[derive(Clone, Debug)]
@@ -165,7 +164,6 @@ pub enum Command {
pattern: String,
},
- SetTabBarDisplayMode(TabBarDisplayMode),
NewTab {
mode: NewTabMode,
},
diff --git a/src/key_command/constants.rs b/src/key_command/constants.rs
index 765d94b..1edfb42 100644
--- a/src/key_command/constants.rs
+++ b/src/key_command/constants.rs
@@ -72,7 +72,6 @@ cmd_constants![
(CMD_SUBPROCESS_FOREGROUND, "shell"),
(CMD_SUBPROCESS_BACKGROUND, "spawn"),
(CMD_SHOW_TASKS, "show_tasks"),
- (CMD_SET_TAB_BAR_MODE, "tab_bar_mode"),
(CMD_TAB_SWITCH, "tab_switch"),
(CMD_TAB_SWITCH_INDEX, "tab_switch_index"),
(CMD_TOGGLE_HIDDEN, "toggle_hidden"),
diff --git a/src/key_command/impl_appcommand.rs b/src/key_command/impl_appcommand.rs
index 4822ca8..4b86608 100644
--- a/src/key_command/impl_appcommand.rs
+++ b/src/key_command/impl_appcommand.rs
@@ -90,7 +90,6 @@ impl AppCommand for Command {
Self::SwitchLineNums(_) => CMD_SWITCH_LINE_NUMBERS,
Self::SetLineMode(_) => CMD_SET_LINEMODE,
- Self::SetTabBarDisplayMode(_) => CMD_SET_TAB_BAR_MODE,
Self::TabSwitch { .. } => CMD_TAB_SWITCH,
Self::TabSwitchIndex { .. } => CMD_TAB_SWITCH_INDEX,
Self::ToggleHiddenFiles => CMD_TOGGLE_HIDDEN,
diff --git a/src/key_command/impl_appexecute.rs b/src/key_command/impl_appexecute.rs
index 86200da..b4033c2 100644
--- a/src/key_command/impl_appexecute.rs
+++ b/src/key_command/impl_appexecute.rs
@@ -155,9 +155,6 @@ impl AppExecute for Command {