Add a disabled-by-default toggle for using bright colors for bold text
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
This commit is contained in:
parent
fc6e2de78b
commit
b161db94d1
4 changed files with 32 additions and 8 deletions
|
|
@ -16,6 +16,7 @@ default-font = Default font
|
|||
default-font-stretch = Default font stretch
|
||||
default-font-weight = Default font weight
|
||||
default-bold-font-weight = Default bold font weight
|
||||
use-bright-bold = Use bright colors with bold text
|
||||
default-font-size = Default font size
|
||||
default-zoom-step = Default zoom step
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ pub struct Config {
|
|||
pub font_stretch: u16,
|
||||
pub font_size_zoom_step_mul_100: u16,
|
||||
pub show_headerbar: bool,
|
||||
pub use_bright_bold: bool,
|
||||
pub syntax_theme_dark: String,
|
||||
pub syntax_theme_light: String,
|
||||
}
|
||||
|
|
@ -54,6 +55,7 @@ impl Default for Config {
|
|||
font_stretch: Stretch::Normal.to_number(),
|
||||
font_size_zoom_step_mul_100: 100,
|
||||
show_headerbar: true,
|
||||
use_bright_bold: false,
|
||||
syntax_theme_dark: "COSMIC Dark".to_string(),
|
||||
syntax_theme_light: "COSMIC Light".to_string(),
|
||||
}
|
||||
|
|
|
|||
15
src/main.rs
15
src/main.rs
|
|
@ -147,6 +147,7 @@ pub enum Message {
|
|||
Paste(Option<segmented_button::Entity>),
|
||||
PasteValue(Option<segmented_button::Entity>, String),
|
||||
SelectAll(Option<segmented_button::Entity>),
|
||||
UseBrightBold(bool),
|
||||
ShowHeaderBar(bool),
|
||||
SyntaxTheme(usize, bool),
|
||||
SystemThemeModeChange(cosmic_theme::ThemeMode),
|
||||
|
|
@ -426,6 +427,10 @@ impl App {
|
|||
}
|
||||
|
||||
let settings_view = settings_view
|
||||
.add(
|
||||
widget::settings::item::builder(fl!("use-bright-bold"))
|
||||
.toggler(self.config.use_bright_bold, Message::UseBrightBold),
|
||||
)
|
||||
.add(
|
||||
widget::settings::item::builder(fl!("default-font-size")).control(
|
||||
widget::dropdown(&self.font_size_names, font_size_selected, |index| {
|
||||
|
|
@ -734,6 +739,12 @@ impl Application for App {
|
|||
return self.save_config();
|
||||
}
|
||||
}
|
||||
Message::UseBrightBold(use_bright_bold) => {
|
||||
if use_bright_bold != self.config.use_bright_bold {
|
||||
self.config.use_bright_bold = use_bright_bold;
|
||||
return self.save_config();
|
||||
}
|
||||
}
|
||||
Message::SystemThemeModeChange(_theme_mode) => {
|
||||
return self.update_config();
|
||||
}
|
||||
|
|
@ -814,9 +825,7 @@ impl Application for App {
|
|||
entity,
|
||||
term_event_tx.clone(),
|
||||
self.term_config.clone(),
|
||||
self.config.typed_font_stretch(),
|
||||
self.config.font_weight,
|
||||
self.config.bold_font_weight,
|
||||
&self.config,
|
||||
colors.clone(),
|
||||
);
|
||||
terminal.set_config(&self.config, &self.themes, self.zoom_adj);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ use tokio::sync::mpsc;
|
|||
|
||||
pub use alacritty_terminal::grid::Scroll as TerminalScroll;
|
||||
|
||||
use crate::config::Config as AppConfig;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Size {
|
||||
pub width: u32,
|
||||
|
|
@ -129,6 +131,7 @@ pub struct Terminal {
|
|||
pub term: Arc<FairMutex<Term<EventProxy>>>,
|
||||
colors: Colors,
|
||||
bold_font_weight: Weight,
|
||||
use_bright_bold: bool,
|
||||
notifier: Notifier,
|
||||
pub context_menu: Option<cosmic::iced::Point>,
|
||||
pub needs_update: bool,
|
||||
|
|
@ -140,11 +143,14 @@ impl Terminal {
|
|||
entity: segmented_button::Entity,
|
||||
event_tx: mpsc::Sender<(segmented_button::Entity, Event)>,
|
||||
config: Config,
|
||||
font_stretch: Stretch,
|
||||
font_weight: u16,
|
||||
bold_font_weight: u16,
|
||||
app_config: &AppConfig,
|
||||
colors: Colors,
|
||||
) -> Self {
|
||||
let font_stretch = app_config.typed_font_stretch();
|
||||
let font_weight = app_config.font_weight;
|
||||
let bold_font_weight = app_config.bold_font_weight;
|
||||
let use_bright_bold = app_config.use_bright_bold;
|
||||
|
||||
let metrics = Metrics::new(14.0, 20.0);
|
||||
//TODO: set color to default fg
|
||||
let default_attrs = Attrs::new()
|
||||
|
|
@ -191,6 +197,7 @@ impl Terminal {
|
|||
Self {
|
||||
colors,
|
||||
bold_font_weight: Weight(bold_font_weight),
|
||||
use_bright_bold,
|
||||
default_attrs,
|
||||
buffer: Arc::new(buffer),
|
||||
size,
|
||||
|
|
@ -334,7 +341,7 @@ impl Terminal {
|
|||
|
||||
pub fn set_config(
|
||||
&mut self,
|
||||
config: &crate::Config,
|
||||
config: &AppConfig,
|
||||
themes: &HashMap<String, Colors>,
|
||||
zoom_adj: i8,
|
||||
) {
|
||||
|
|
@ -357,6 +364,11 @@ impl Terminal {
|
|||
update_cell_size = true;
|
||||
}
|
||||
|
||||
if self.use_bright_bold != config.use_bright_bold {
|
||||
self.use_bright_bold = config.use_bright_bold;
|
||||
update_cell_size = true;
|
||||
}
|
||||
|
||||
let metrics = config.metrics(zoom_adj);
|
||||
if metrics != self.buffer.metrics() {
|
||||
{
|
||||
|
|
@ -473,7 +485,7 @@ impl Terminal {
|
|||
|
||||
let mut attrs = self.default_attrs;
|
||||
|
||||
let cell_fg = if indexed.cell.flags.contains(Flags::BOLD) {
|
||||
let cell_fg = if self.use_bright_bold && indexed.cell.flags.contains(Flags::BOLD) {
|
||||
as_bright(indexed.cell.fg)
|
||||
} else {
|
||||
indexed.cell.fg
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue