summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config/theme/app_theme.rs27
-rw-r--r--src/config/theme/style.rs15
-rw-r--r--src/ui/widgets/tui_tab.rs8
3 files changed, 44 insertions, 6 deletions
diff --git a/src/config/theme/app_theme.rs b/src/config/theme/app_theme.rs
index cdf5eac..fdf3ca0 100644
--- a/src/config/theme/app_theme.rs
+++ b/src/config/theme/app_theme.rs
@@ -9,6 +9,8 @@ use crate::error::JoshutoResult;
#[derive(Clone, Debug, Deserialize, Default)]
pub struct AppThemeRaw {
#[serde(default)]
+ pub tabs: TabThemeRaw,
+ #[serde(default)]
pub regular: AppStyleRaw,
#[serde(default)]
pub selection: AppStyleRaw,
@@ -28,8 +30,25 @@ pub struct AppThemeRaw {
pub ext: HashMap<String, AppStyleRaw>,
}
+#[derive(Clone, Debug, Deserialize, Default)]
+pub struct TabThemeRaw {
+ #[serde(default)]
+ pub inactive: AppStyleRaw,
+ #[serde(default)]
+ pub active: AppStyleRaw,
+}
+
+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 }
+ }
+}
+
impl From<AppThemeRaw> for AppTheme {
fn from(crude: AppThemeRaw) -> Self {
+ let tabs = crude.tabs;
let selection = crude.selection.to_style_theme();
let visual_mode_selection = crude.visual_mode_selection.to_style_theme();
let executable = crude.executable.to_style_theme();
@@ -57,12 +76,14 @@ impl From<AppThemeRaw> for AppTheme {
link_invalid,
socket,
ext,
+ tabs: TabTheme::from(tabs),
}
}
}
#[derive(Clone, Debug)]
pub struct AppTheme {
+ pub tabs: TabTheme,
pub regular: AppStyle,
pub selection: AppStyle,
pub visual_mode_selection: AppStyle,
@@ -94,3 +115,9 @@ impl std::default::Default for AppTheme {
Self::default_res().unwrap()
}
}
+
+#[derive(Clone, Debug)]
+pub struct TabTheme {
+ pub inactive: AppStyle,
+ pub active: AppStyle,
+}
diff --git a/src/config/theme/style.rs b/src/config/theme/style.rs
index 5fecdf8..e4ee599 100644
--- a/src/config/theme/style.rs
+++ b/src/config/theme/style.rs
@@ -2,7 +2,7 @@ use colors_transform::{Color, Rgb};
use serde_derive::Deserialize;
-use tui::style;
+use tui::style::{self, Style};
const fn default_color() -> style::Color {
style::Color::Reset
@@ -117,6 +117,10 @@ impl AppStyle {
self.modifier.insert(modifier);
self
}
+
+ pub fn as_style(&self) -> Style {
+ Style::from(self)
+ }
}
impl std::default::Default for AppStyle {
@@ -128,3 +132,12 @@ impl std::default::Default for AppStyle {
}
}
}
+
+impl From<&AppStyle> for Style {
+ fn from(style: &AppStyle) -> Self {
+ Self::default()
+ .fg(style.fg)
+ .bg(style.bg)
+ .add_modifier(style.modifier)
+ }
+}
diff --git a/src/ui/widgets/tui_tab.rs b/src/ui/widgets/tui_tab.rs
index 76bfca5..35f6630 100644
--- a/src/ui/widgets/tui_tab.rs
+++ b/src/ui/widgets/tui_tab.rs
@@ -2,11 +2,11 @@ use std::ffi::OsStr;
use tui::buffer::Buffer;
use tui::layout::Rect;
-use tui::style::{Color, Modifier, Style};
use tui::text::{Line, Span};
use tui::widgets::{Paragraph, Widget, Wrap};
use crate::context::TabContext;
+use crate::THEME_T;
pub struct TuiTabBar<'a> {
context: &'a TabContext,
@@ -20,10 +20,8 @@ impl<'a> TuiTabBar<'a> {
impl<'a> Widget for TuiTabBar<'a> {
fn render(self, area: Rect, buf: &mut Buffer) {
- let regular_style = Style::default().fg(Color::White);
- let selected_style = Style::default()
- .fg(Color::White)
- .add_modifier(Modifier::REVERSED);
+ let regular_style = THEME_T.tabs.inactive.as_style();
+ let selected_style = THEME_T.tabs.active.as_style();
let index = self.context.index;
let tab_order = self.context.tab_order.as_slice();