mirror of
https://github.com/helix-editor/termina.git
synced 2025-10-06 00:22:43 +02:00
Fold Contour theme mode VT extension into Csi::Mode
This commit is contained in:
@@ -29,7 +29,6 @@ pub enum Csi {
|
||||
Mouse(MouseReport),
|
||||
Keyboard(Keyboard),
|
||||
Device(Device),
|
||||
Theme(Theme),
|
||||
// TODO: Window(Box<Window>),
|
||||
}
|
||||
|
||||
@@ -45,7 +44,6 @@ impl Display for Csi {
|
||||
Self::Mouse(report) => report.fmt(f),
|
||||
Self::Keyboard(keyboard) => keyboard.fmt(f),
|
||||
Self::Device(device) => device.fmt(f),
|
||||
Self::Theme(theme) => theme.fmt(f),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -629,6 +627,9 @@ pub enum Mode {
|
||||
resource: XtermKeyModifierResource,
|
||||
value: Option<i64>,
|
||||
},
|
||||
// <https://github.com/contour-terminal/contour/blob/master/docs/vt-extensions/color-palette-update-notifications.md>
|
||||
QueryTheme,
|
||||
ReportTheme(ThemeMode),
|
||||
}
|
||||
|
||||
impl Display for Mode {
|
||||
@@ -654,6 +655,8 @@ impl Display for Mode {
|
||||
}
|
||||
write!(f, "m")
|
||||
}
|
||||
Self::QueryTheme => write!(f, "?996n"),
|
||||
Self::ReportTheme(mode) => write!(f, "?997;{}n", *mode as u8),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -819,6 +822,12 @@ pub enum DecModeSetting {
|
||||
PermanentlyReset = 4,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ThemeMode {
|
||||
Dark = 1,
|
||||
Light = 2,
|
||||
}
|
||||
|
||||
// Mouse
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
@@ -1066,29 +1075,6 @@ impl Display for Device {
|
||||
}
|
||||
}
|
||||
|
||||
// Theme
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Theme {
|
||||
Query,
|
||||
Report(ThemeMode),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ThemeMode {
|
||||
Dark = 1,
|
||||
Light = 2,
|
||||
}
|
||||
|
||||
impl Display for Theme {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Query => write!(f, "?996n"),
|
||||
Self::Report(mode) => write!(f, "?997;{}n", *mode as u8),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
@@ -938,7 +938,9 @@ fn parse_csi_theme_mode(buffer: &[u8]) -> Result<Option<Event>> {
|
||||
_ => bail!(),
|
||||
};
|
||||
|
||||
Ok(Some(Event::Csi(Csi::Theme(csi::Theme::Report(theme_mode)))))
|
||||
Ok(Some(Event::Csi(Csi::Mode(csi::Mode::ReportTheme(
|
||||
theme_mode,
|
||||
)))))
|
||||
}
|
||||
|
||||
fn parse_csi_synchronized_output_mode(buffer: &[u8]) -> Result<Option<Event>> {
|
||||
|
Reference in New Issue
Block a user