Fix dynamic multi-color escape codes
This commit is contained in:
parent
f59aa19892
commit
204c46c7f9
|
@ -392,6 +392,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Pressing enter on the numpad should now insert a newline
|
- Pressing enter on the numpad should now insert a newline
|
||||||
- The mouse bindings now support keyboard modifiers (shift/ctrl/alt/super)
|
- The mouse bindings now support keyboard modifiers (shift/ctrl/alt/super)
|
||||||
- Add support for the bright foreground color
|
- Add support for the bright foreground color
|
||||||
|
- Support for setting foreground, background colors in one escape sequence
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -537,10 +537,10 @@ pub enum NamedColor {
|
||||||
Foreground = 256,
|
Foreground = 256,
|
||||||
/// The background color
|
/// The background color
|
||||||
Background,
|
Background,
|
||||||
/// Color for the text under the cursor
|
|
||||||
CursorText,
|
|
||||||
/// Color for the cursor itself
|
/// Color for the cursor itself
|
||||||
Cursor,
|
Cursor,
|
||||||
|
/// Color for the text under the cursor
|
||||||
|
CursorText,
|
||||||
/// Dim black
|
/// Dim black
|
||||||
DimBlack,
|
DimBlack,
|
||||||
/// Dim red
|
/// Dim red
|
||||||
|
@ -793,47 +793,30 @@ where
|
||||||
unhandled(params);
|
unhandled(params);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Get/set foreground color
|
// Get/set Foreground, Background, Cursor colors
|
||||||
b"10" => {
|
b"10" | b"11" | b"12" => {
|
||||||
if params.len() >= 2 {
|
if params.len() >= 2 {
|
||||||
if let Some(color) = parse_rgb_color(params[1]) {
|
if let Some(mut dynamic_code) = parse_number(params[0]) {
|
||||||
self.handler.set_color(NamedColor::Foreground as usize, color);
|
for param in ¶ms[1..] {
|
||||||
return;
|
// 10 is the first dynamic color, also the foreground
|
||||||
} else if params[1] == b"?" {
|
let offset = dynamic_code as usize - 10;
|
||||||
self.handler.dynamic_color_sequence(
|
let index = NamedColor::Foreground as usize + offset;
|
||||||
writer,
|
|
||||||
10,
|
|
||||||
NamedColor::Foreground as usize,
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unhandled(params);
|
|
||||||
},
|
|
||||||
|
|
||||||
// Get/set background color
|
// End of setting dynamic colors
|
||||||
b"11" => {
|
if index > NamedColor::Cursor as usize {
|
||||||
if params.len() >= 2 {
|
unhandled(params);
|
||||||
if let Some(color) = parse_rgb_color(params[1]) {
|
break;
|
||||||
self.handler.set_color(NamedColor::Background as usize, color);
|
}
|
||||||
return;
|
|
||||||
} else if params[1] == b"?" {
|
|
||||||
self.handler.dynamic_color_sequence(
|
|
||||||
writer,
|
|
||||||
11,
|
|
||||||
NamedColor::Background as usize,
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unhandled(params);
|
|
||||||
},
|
|
||||||
|
|
||||||
// Set text cursor color
|
if let Some(color) = parse_rgb_color(param) {
|
||||||
b"12" => {
|
self.handler.set_color(index, color);
|
||||||
if params.len() >= 2 {
|
} else if param == b"?" {
|
||||||
if let Some(color) = parse_rgb_color(params[1]) {
|
self.handler.dynamic_color_sequence(writer, dynamic_code, index);
|
||||||
self.handler.set_color(NamedColor::Cursor as usize, color);
|
} else {
|
||||||
|
unhandled(params);
|
||||||
|
}
|
||||||
|
dynamic_code += 1;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue