Skip to content

Commit

Permalink
background style config
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Jan 22, 2023
1 parent 3d1c524 commit ae63c3a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 10 deletions.
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ The configuration should be the following paths otherwise Rio will use the defau

- macOs path: `~/.rio/config.toml`

#### config.toml
Example of `config.toml`:

```toml
performance = "High"
height = 400
width = 600
```

### List
### Perfomance

#### Perfomance
Description: Set terminal WGPU rendering perfomance.

- High: Adapter that has the highest performance. This is often a discrete GPU.
- Low: Adapter that uses the least possible power. This is often an integrated GPU.
Expand All @@ -66,7 +66,7 @@ performance = "High"

### Height

Sets terminal window height
Description: Set terminal window height.

```toml
# <height> Set default height
Expand All @@ -76,14 +76,26 @@ height = 400

### Width

Sets terminal window width
Description: Set terminal window width.

```toml
# <width> Set default width
# default: 400
width = 600
```

### Style

- `background` - Set background color.

```toml
[style]
background = "#151515"
cursor = "#8E12CC"
```



## TODO

- [x] pty
Expand Down
31 changes: 26 additions & 5 deletions config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ pub enum Performance {
Low,
}

#[derive(Default, Debug, Deserialize, PartialEq, Clone)]
pub struct Style {
background: String,
}

#[derive(Debug, Deserialize, PartialEq)]
pub struct Config {
pub performance: Performance,
pub width: u16,
pub height: u16,
pub style: Style,
}

impl Config {
Expand Down Expand Up @@ -52,6 +58,9 @@ impl Default for Config {
performance: Performance::default(),
width: 600,
height: 400,
style: Style {
background: String::from("#151515"),
},
}
}
}
Expand All @@ -65,6 +74,7 @@ mod tests {
performance: Performance,
width: u16,
height: u16,
style_background: String,
) -> Config {
let toml_str = format!(
r#"
Expand All @@ -83,9 +93,12 @@ mod tests {
# default: 600
width = {}
[style]
background = {:?}
## TODO: Add more configs
"#,
performance, height, width
performance, height, width, style_background
);
let binding = format!("/tmp/{:?}-config.toml", performance);
let file_name = binding.as_str();
Expand All @@ -102,12 +115,16 @@ mod tests {
performance: Performance::High,
width: 300,
height: 200,
style: Style {
background: String::from("#151515"),
},
};

let result = create_temporary_config(
expected.performance,
expected.width,
expected.height,
300,
200,
String::from("#151515"),
);
assert_eq!(result, expected);
}
Expand All @@ -118,12 +135,16 @@ mod tests {
performance: Performance::Low,
width: 400,
height: 400,
style: Style {
background: String::from("#151515"),
},
};

let result = create_temporary_config(
expected.performance,
expected.width,
expected.height,
400,
400,
String::from("#151515"),
);
assert_eq!(result, expected);
}
Expand Down

0 comments on commit ae63c3a

Please sign in to comment.