mirror of
https://github.com/jj-vcs/jj.git
synced 2026-07-03 14:02:54 +08:00
colors config: crossed-out text formatting support
to allow
```
"diff removed" = { crossed-out=true }
```
This commit is contained in:
@@ -51,6 +51,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
* Add a `forks()` revset function that yields all commits with more than 1 child.
|
||||
|
||||
* `colors` config now supports crossed-out text styling with
|
||||
`{ crossed-out = true }`.
|
||||
|
||||
### Fixed bugs
|
||||
|
||||
* On Windows, querying a path's file identity no longer follows symbolic links,
|
||||
|
||||
@@ -397,6 +397,9 @@
|
||||
"underline": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"crossed-out": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"reverse": {
|
||||
"type": "boolean"
|
||||
}
|
||||
|
||||
@@ -300,6 +300,7 @@ pub struct Style {
|
||||
pub dim: Option<bool>,
|
||||
pub italic: Option<bool>,
|
||||
pub underline: Option<bool>,
|
||||
pub crossed_out: Option<bool>,
|
||||
pub reverse: Option<bool>,
|
||||
}
|
||||
|
||||
@@ -311,6 +312,7 @@ impl Style {
|
||||
self.dim = other.dim.or(self.dim);
|
||||
self.italic = other.italic.or(self.italic);
|
||||
self.underline = other.underline.or(self.underline);
|
||||
self.crossed_out = other.crossed_out.or(self.crossed_out);
|
||||
self.reverse = other.reverse.or(self.reverse);
|
||||
}
|
||||
}
|
||||
@@ -443,6 +445,13 @@ impl<W: Write> ColorFormatter<W> {
|
||||
queue!(self.output, SetAttribute(Attribute::NoUnderline))?;
|
||||
}
|
||||
}
|
||||
if new_style.crossed_out != self.current_style.crossed_out {
|
||||
if new_style.crossed_out.unwrap_or_default() {
|
||||
queue!(self.output, SetAttribute(Attribute::CrossedOut))?;
|
||||
} else {
|
||||
queue!(self.output, SetAttribute(Attribute::NotCrossedOut))?;
|
||||
}
|
||||
}
|
||||
if new_style.reverse != self.current_style.reverse {
|
||||
if new_style.reverse.unwrap_or_default() {
|
||||
queue!(self.output, SetAttribute(Attribute::Reverse))?;
|
||||
@@ -491,6 +500,7 @@ fn rules_from_config(config: &StackedConfig) -> Result<Rules, ConfigGetError> {
|
||||
dim: None,
|
||||
italic: None,
|
||||
underline: None,
|
||||
crossed_out: None,
|
||||
reverse: None,
|
||||
})
|
||||
} else if value.is_inline_table() {
|
||||
@@ -1050,8 +1060,9 @@ mod tests {
|
||||
colors.dim_font = { dim = true }
|
||||
colors.italic_text = { italic = true }
|
||||
colors.underlined_text = { underline = true }
|
||||
colors.crossed_out_text = { crossed-out = true }
|
||||
colors.reversed_colors = { reverse = true }
|
||||
colors.multiple = { fg = "green", bg = "yellow", bold = true, italic = true, underline = true, reverse = true }
|
||||
colors.multiple = { fg = "green", bg = "yellow", bold = true, italic = true, underline = true, crossed-out = true, reverse = true }
|
||||
"#,
|
||||
);
|
||||
let mut output: Vec<u8> = vec![];
|
||||
@@ -1080,6 +1091,10 @@ mod tests {
|
||||
write!(formatter, " underlined only ")?;
|
||||
formatter.pop_label();
|
||||
writeln!(formatter)?;
|
||||
formatter.push_label("crossed_out_text");
|
||||
write!(formatter, " crossed-out only ")?;
|
||||
formatter.pop_label();
|
||||
writeln!(formatter)?;
|
||||
formatter.push_label("reversed_colors");
|
||||
write!(formatter, " reverse only ")?;
|
||||
formatter.pop_label();
|
||||
@@ -1102,8 +1117,9 @@ mod tests {
|
||||
[2m dim only [0m
|
||||
[3m italic only [23m
|
||||
[4m underlined only [24m
|
||||
[9m crossed-out only [29m
|
||||
[7m reverse only [27m
|
||||
[1m[3m[4m[7m[38;5;2m[48;5;3m single rule [0m
|
||||
[1m[3m[4m[9m[7m[38;5;2m[48;5;3m single rule [0m
|
||||
[38;5;1m[48;5;4m two rules [39m[49m
|
||||
[EOF]
|
||||
");
|
||||
|
||||
@@ -191,8 +191,8 @@ commit_id = "ansi-color-81"
|
||||
|
||||
If you use a string value for a color, as in the examples above, it will be used
|
||||
for the foreground color. You can also set the background color, reverse colors
|
||||
(swap foreground and background), or make the text bold, dim, italic, or
|
||||
underlined. For that, you need to use a table:
|
||||
(swap foreground and background), or make the text bold, dim, italic,
|
||||
underlined, or crossed-out. For that, you need to use a table:
|
||||
|
||||
```toml
|
||||
[colors]
|
||||
|
||||
@@ -143,8 +143,8 @@ commit_id = "ansi-color-81"
|
||||
|
||||
If you use a string value for a color, as in the examples above, it will be used
|
||||
for the foreground color. You can also set the background color, reverse colors
|
||||
(swap foreground and background), or make the text bold, dim, italic, or
|
||||
underlined. For that, you need to use a table:
|
||||
(swap foreground and background), or make the text bold, dim, italic,
|
||||
underlined, or crossed-out. For that, you need to use a table:
|
||||
|
||||
```toml
|
||||
[colors]
|
||||
|
||||
Reference in New Issue
Block a user