diff --git a/Makefile b/Makefile index a600c19da1..25858301d3 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,10 @@ lint: cargo fmt -- --check --color always cargo clippy --all-targets --all-features -- -D warnings +test: + make lint + cargo test --release + watch: cargo watch -- cargo run diff --git a/README.md b/README.md index 404184ec55..3c4c80d3eb 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Basic features are under development for MacOs right now. | Platform | Development Status | | --- | --- | -| MacOs | In development | +| MacOs | In development 👷 | | Linux | Not started yet | | Windows | Not started yet | @@ -84,16 +84,25 @@ Description: Set terminal window width. width = 600 ``` -### Style +### Colors - `background` - Set background color. ```toml -[style] +[colors] background = "#151515" cursor = "#8E12CC" ``` +### Style + +- `font_size` - Set font size. + +```toml +[style] +font_size = 16.0 +``` + ## TODO @@ -108,7 +117,7 @@ cursor = "#8E12CC" - [ ] Render font with custom color, size and family - [ ] Fix topbar when resize - [ ] Keep rendering with intervals -- [ ] Read and use configuration +- [x] Read and use configuration - [ ] Keyboard input - [ ] Alphabet keys (uppercase/lowcase) - [x] Numbers keys diff --git a/config/src/lib.rs b/config/src/lib.rs index 212828c2c6..677b76f3a5 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -12,7 +12,12 @@ pub enum Performance { #[derive(Default, Debug, Deserialize, PartialEq, Clone)] pub struct Style { - background: String, + pub font_size: f32, +} + +#[derive(Default, Debug, Deserialize, PartialEq, Clone)] +pub struct Colors { + pub background: String, } #[derive(Debug, Deserialize, PartialEq)] @@ -21,6 +26,7 @@ pub struct Config { pub width: u16, pub height: u16, pub style: Style, + pub colors: Colors, } impl Config { @@ -58,9 +64,10 @@ impl Default for Config { performance: Performance::default(), width: 600, height: 400, - style: Style { + colors: Colors { background: String::from("#151515"), }, + style: Style { font_size: 16.0 }, } } } @@ -74,7 +81,8 @@ mod tests { performance: Performance, width: u16, height: u16, - style_background: String, + style_font_size: f32, + color_background: String, ) -> Config { let toml_str = format!( r#" @@ -94,11 +102,14 @@ mod tests { width = {} [style] + font_size = {} + + [colors] background = {:?} ## TODO: Add more configs "#, - performance, height, width, style_background + performance, height, width, style_font_size, color_background ); let binding = format!("/tmp/{:?}-config.toml", performance); let file_name = binding.as_str(); @@ -115,15 +126,17 @@ mod tests { performance: Performance::High, width: 300, height: 200, - style: Style { + colors: Colors { background: String::from("#151515"), }, + style: Style { font_size: 18.0 }, }; let result = create_temporary_config( expected.performance, 300, 200, + 18.0, String::from("#151515"), ); assert_eq!(result, expected); @@ -135,15 +148,17 @@ mod tests { performance: Performance::Low, width: 400, height: 400, - style: Style { + colors: Colors { background: String::from("#151515"), }, + style: Style { font_size: 22.0 }, }; let result = create_temporary_config( expected.performance, 400, 400, + 22.0, String::from("#151515"), ); assert_eq!(result, expected); diff --git a/rio/src/term/mod.rs b/rio/src/term/mod.rs index dfeabea369..1ed8cf7bf5 100644 --- a/rio/src/term/mod.rs +++ b/rio/src/term/mod.rs @@ -11,6 +11,7 @@ use std::sync::Arc; use std::sync::Mutex; pub struct Term { + font_size: f32, device: wgpu::Device, surface: wgpu::Surface, queue: wgpu::Queue, @@ -160,6 +161,8 @@ impl Term { let current_transform = Self::projection(size.width, size.height); Ok(Term { + // TODO: fix style propagation + font_size: config.style.font_size, device, surface, staging_belt, @@ -391,7 +394,7 @@ impl Term { ), text: vec![Text::new(&output.lock().unwrap()) .with_color([1.0, 1.0, 1.0, 1.0]) - .with_scale(18.0 * self.scale)], + .with_scale(self.font_size * self.scale)], ..Section::default() });