Skip to content

Commit

Permalink
symbol-map in config and docs level
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Feb 24, 2025
1 parent c141024 commit e8cadad
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,27 @@ program = "/opt/homebrew/bin/tmux"
args = ["new-session", "-c", "/var/www"]
```

## symbol-map

Has no default values. Example values are shown below:

```toml
symbol-map = [
{ start = "E0C0", end = "E0C7", font-family = "PowerlineSymbols" }
]
```

Map the specified Unicode codepoints to a particular font. Useful if you need special rendering for some symbols, such as for Powerline. Avoids the need for patched fonts.

In case you would like to map many codepoints:

```toml
symbol-map = [
{ start = "E0A0", end = "E0A3", font-family = "PowerlineSymbols" },
{ start = "E0C0", end = "E0C7", font-family = "PowerlineSymbols" },
]
```

## theme

The configuration property `theme` is used for specifying the theme. Rio will look in the `themes` folder for the theme.
Expand Down
38 changes: 38 additions & 0 deletions rio-backend/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ pub struct Config {
pub draw_bold_text_with_light_colors: bool,
#[serde(default = "default_bool_true", rename = "builtin-box-drawing")]
pub builtin_box_drawing: bool,
#[serde(default = "Option::default", rename = "symbol-map")]
pub symbol_map: Option<Vec<SymbolMap>>,
}

#[derive(Clone, Debug, PartialEq,Serialize, Deserialize)]
pub struct SymbolMap {
pub start: String,
pub end: String,
#[serde(rename = "font-family")]
pub font_family: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
Expand Down Expand Up @@ -510,6 +520,7 @@ impl Default for Config {
hide_cursor_when_typing: false,
draw_bold_text_with_light_colors: false,
builtin_box_drawing: true,
symbol_map: None,
}
}
}
Expand Down Expand Up @@ -1044,4 +1055,31 @@ mod tests {
assert_eq!(result.colors.tabs_active, colors::defaults::tabs_active());
assert_eq!(result.colors.cursor, colors::defaults::cursor());
}

#[test]
fn test_symbol_map() {
fn unsafe_parse_unicode(input: &str) -> char {
let unicode = u32::from_str_radix(input, 16).unwrap();
char::from_u32(unicode).unwrap()
}

let result = create_temporary_config(
"symbol-map",
r#"
symbol-map = [
{ start = "E0C0", end = "E0C7", font-family = "PowerlineSymbols" }
]
"#,
);

assert!(result.symbol_map.is_some());
let symbol_map = result.symbol_map.unwrap();
assert_eq!(symbol_map.len(), 1);
assert_eq!(symbol_map[0].font_family, "PowerlineSymbols");
assert_eq!(symbol_map[0].start, "E0C0");
assert_eq!(symbol_map[0].end, "E0C7");

assert_eq!(unsafe_parse_unicode(&symbol_map[0].start), '\u{E0C0}');
assert_eq!(unsafe_parse_unicode(&symbol_map[0].end), '\u{E0C7}');
}
}

0 comments on commit e8cadad

Please sign in to comment.