Add option for setting dim font weight
Allows users to set this to a value lower than default font weight. Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
This commit is contained in:
parent
f34116f3f7
commit
e56e582f90
4 changed files with 45 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ advanced-font-settings = Advanced Font Settings
|
||||||
default-font = Default font
|
default-font = Default font
|
||||||
default-font-stretch = Default font stretch
|
default-font-stretch = Default font stretch
|
||||||
default-font-weight = Default font weight
|
default-font-weight = Default font weight
|
||||||
|
default-dim-font-weight = Default dim font weight
|
||||||
default-bold-font-weight = Default bold font weight
|
default-bold-font-weight = Default bold font weight
|
||||||
use-bright-bold = Use bright colors with bold text
|
use-bright-bold = Use bright colors with bold text
|
||||||
default-font-size = Default font size
|
default-font-size = Default font size
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ pub struct Config {
|
||||||
pub font_name: String,
|
pub font_name: String,
|
||||||
pub font_size: u16,
|
pub font_size: u16,
|
||||||
pub font_weight: u16,
|
pub font_weight: u16,
|
||||||
|
pub dim_font_weight: u16,
|
||||||
pub bold_font_weight: u16,
|
pub bold_font_weight: u16,
|
||||||
pub font_stretch: u16,
|
pub font_stretch: u16,
|
||||||
pub font_size_zoom_step_mul_100: u16,
|
pub font_size_zoom_step_mul_100: u16,
|
||||||
|
|
@ -51,6 +52,7 @@ impl Default for Config {
|
||||||
font_name: "Fira Mono".to_string(),
|
font_name: "Fira Mono".to_string(),
|
||||||
font_size: 14,
|
font_size: 14,
|
||||||
font_weight: Weight::NORMAL.0,
|
font_weight: Weight::NORMAL.0,
|
||||||
|
dim_font_weight: Weight::NORMAL.0,
|
||||||
bold_font_weight: Weight::BOLD.0,
|
bold_font_weight: Weight::BOLD.0,
|
||||||
font_stretch: Stretch::Normal.to_number(),
|
font_stretch: Stretch::Normal.to_number(),
|
||||||
font_size_zoom_step_mul_100: 100,
|
font_size_zoom_step_mul_100: 100,
|
||||||
|
|
|
||||||
31
src/main.rs
31
src/main.rs
|
|
@ -160,6 +160,7 @@ pub enum Message {
|
||||||
DefaultFontSize(usize),
|
DefaultFontSize(usize),
|
||||||
DefaultFontStretch(usize),
|
DefaultFontStretch(usize),
|
||||||
DefaultFontWeight(usize),
|
DefaultFontWeight(usize),
|
||||||
|
DefaultDimFontWeight(usize),
|
||||||
DefaultBoldFontWeight(usize),
|
DefaultBoldFontWeight(usize),
|
||||||
DefaultZoomStep(usize),
|
DefaultZoomStep(usize),
|
||||||
Find(bool),
|
Find(bool),
|
||||||
|
|
@ -350,6 +351,14 @@ impl App {
|
||||||
self.config.font_weight = Weight::NORMAL.0;
|
self.config.font_weight = Weight::NORMAL.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !self
|
||||||
|
.curr_font_weights
|
||||||
|
.contains(&self.config.dim_font_weight)
|
||||||
|
{
|
||||||
|
self.config.dim_font_weight = Weight::NORMAL.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if !self
|
if !self
|
||||||
.curr_font_weights
|
.curr_font_weights
|
||||||
.contains(&self.config.bold_font_weight)
|
.contains(&self.config.bold_font_weight)
|
||||||
|
|
@ -391,6 +400,10 @@ impl App {
|
||||||
.curr_font_weights
|
.curr_font_weights
|
||||||
.iter()
|
.iter()
|
||||||
.position(|font_weight| font_weight == &self.config.font_weight);
|
.position(|font_weight| font_weight == &self.config.font_weight);
|
||||||
|
let dim_font_weight_selected = self
|
||||||
|
.curr_font_weights
|
||||||
|
.iter()
|
||||||
|
.position(|font_weight| font_weight == &self.config.dim_font_weight);
|
||||||
let bold_font_weight_selected = self
|
let bold_font_weight_selected = self
|
||||||
.curr_font_weights
|
.curr_font_weights
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -420,6 +433,15 @@ impl App {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.add(
|
||||||
|
widget::settings::item::builder(fl!("default-dim-font-weight")).control(
|
||||||
|
widget::dropdown(
|
||||||
|
&self.curr_font_weight_names,
|
||||||
|
dim_font_weight_selected,
|
||||||
|
|index| Message::DefaultDimFontWeight(index),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
.add(
|
.add(
|
||||||
widget::settings::item::builder(fl!("default-bold-font-weight")).control(
|
widget::settings::item::builder(fl!("default-bold-font-weight")).control(
|
||||||
widget::dropdown(
|
widget::dropdown(
|
||||||
|
|
@ -778,6 +800,15 @@ impl Application for App {
|
||||||
log::warn!("failed to find font weight with index {}", index);
|
log::warn!("failed to find font weight with index {}", index);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Message::DefaultDimFontWeight(index) => match self.curr_font_weights.get(index) {
|
||||||
|
Some(font_weight) => {
|
||||||
|
self.config.dim_font_weight = *font_weight;
|
||||||
|
return self.save_config();
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
log::warn!("failed to find dim font weight with index {}", index);
|
||||||
|
}
|
||||||
|
},
|
||||||
Message::DefaultBoldFontWeight(index) => match self.curr_font_weights.get(index) {
|
Message::DefaultBoldFontWeight(index) => match self.curr_font_weights.get(index) {
|
||||||
Some(font_weight) => {
|
Some(font_weight) => {
|
||||||
self.config.bold_font_weight = *font_weight;
|
self.config.bold_font_weight = *font_weight;
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,7 @@ pub struct Terminal {
|
||||||
size: Size,
|
size: Size,
|
||||||
pub term: Arc<FairMutex<Term<EventProxy>>>,
|
pub term: Arc<FairMutex<Term<EventProxy>>>,
|
||||||
colors: Colors,
|
colors: Colors,
|
||||||
|
dim_font_weight: Weight,
|
||||||
bold_font_weight: Weight,
|
bold_font_weight: Weight,
|
||||||
use_bright_bold: bool,
|
use_bright_bold: bool,
|
||||||
notifier: Notifier,
|
notifier: Notifier,
|
||||||
|
|
@ -158,6 +159,7 @@ impl Terminal {
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let font_stretch = app_config.typed_font_stretch();
|
let font_stretch = app_config.typed_font_stretch();
|
||||||
let font_weight = app_config.font_weight;
|
let font_weight = app_config.font_weight;
|
||||||
|
let dim_font_weight = app_config.dim_font_weight;
|
||||||
let bold_font_weight = app_config.bold_font_weight;
|
let bold_font_weight = app_config.bold_font_weight;
|
||||||
let use_bright_bold = app_config.use_bright_bold;
|
let use_bright_bold = app_config.use_bright_bold;
|
||||||
|
|
||||||
|
|
@ -206,6 +208,7 @@ impl Terminal {
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
colors,
|
colors,
|
||||||
|
dim_font_weight: Weight(dim_font_weight),
|
||||||
bold_font_weight: Weight(bold_font_weight),
|
bold_font_weight: Weight(bold_font_weight),
|
||||||
use_bright_bold,
|
use_bright_bold,
|
||||||
default_attrs,
|
default_attrs,
|
||||||
|
|
@ -455,6 +458,11 @@ impl Terminal {
|
||||||
update_cell_size = true;
|
update_cell_size = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.dim_font_weight.0 != config.dim_font_weight {
|
||||||
|
self.dim_font_weight = Weight(config.dim_font_weight);
|
||||||
|
update_cell_size = true;
|
||||||
|
}
|
||||||
|
|
||||||
if self.bold_font_weight.0 != config.font_weight {
|
if self.bold_font_weight.0 != config.font_weight {
|
||||||
self.bold_font_weight = Weight(config.bold_font_weight);
|
self.bold_font_weight = Weight(config.bold_font_weight);
|
||||||
update_cell_size = true;
|
update_cell_size = true;
|
||||||
|
|
@ -639,6 +647,9 @@ impl Terminal {
|
||||||
//TODO: more flags
|
//TODO: more flags
|
||||||
if indexed.cell.flags.contains(Flags::BOLD) {
|
if indexed.cell.flags.contains(Flags::BOLD) {
|
||||||
attrs = attrs.weight(self.bold_font_weight);
|
attrs = attrs.weight(self.bold_font_weight);
|
||||||
|
} else if indexed.cell.flags.contains(Flags::DIM) {
|
||||||
|
// if DIM and !BOLD
|
||||||
|
attrs = attrs.weight(self.dim_font_weight);
|
||||||
}
|
}
|
||||||
if indexed.cell.flags.contains(Flags::ITALIC) {
|
if indexed.cell.flags.contains(Flags::ITALIC) {
|
||||||
//TODO: automatically use fake italic
|
//TODO: automatically use fake italic
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue