aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-03-08 23:43:23 -0500
committerJesse Luehrs <doy@tozt.net>2023-03-09 00:29:47 -0500
commit68c36be2e26813a2a3d7210ae82824de06b3d3ee (patch)
tree19f345f7e05c6cb8c210657e6f0f671113f56f09 /src
parenta705c1f07de2b8ec3ba4fe46377242f151b996c1 (diff)
downloadvt100-rust-68c36be2e26813a2a3d7210ae82824de06b3d3ee.tar.gz
vt100-rust-68c36be2e26813a2a3d7210ae82824de06b3d3ee.zip
implement callback for terminal resize request
Diffstat (limited to 'src')
-rw-r--r--src/callbacks.rs3
-rw-r--r--src/screen.rs14
-rw-r--r--src/state.rs14
3 files changed, 31 insertions, 0 deletions
diff --git a/src/callbacks.rs b/src/callbacks.rs
index 256eb58..70331eb 100644
--- a/src/callbacks.rs
+++ b/src/callbacks.rs
@@ -7,6 +7,9 @@ pub trait Callbacks {
/// This callback is called when the terminal requests an visual bell
/// (typically with `\eg`).
fn visual_bell(&mut self, _: &mut crate::Screen) {}
+ /// This callback is called when the terminal requests a resize
+ /// (typically with `\e[8;<rows>;<cols>t`).
+ fn resize(&mut self, _: &mut crate::Screen, _request: (u16, u16)) {}
/// This callback is called when the terminal receives invalid input
/// (such as an invalid UTF-8 character or an used control character).
fn error(&mut self, _: &mut crate::Screen) {}
diff --git a/src/screen.rs b/src/screen.rs
index 9da62c7..c64f8e9 100644
--- a/src/screen.rs
+++ b/src/screen.rs
@@ -1447,6 +1447,19 @@ impl Screen {
self.grid_mut().set_scroll_region(top - 1, bottom - 1);
}
+ // CSI t
+ #[allow(clippy::unused_self)]
+ fn xtwinops(&self, params: &vte::Params) {
+ let mut iter = params.iter();
+ let op = iter.next().and_then(|x| x.first().copied());
+ match op {
+ Some(8) => {}
+ _ => {
+ log::debug!("unhandled XTWINOPS: {}", param_str(params));
+ }
+ }
+ }
+
// osc codes
fn osc0(&mut self, s: &[u8]) {
@@ -1544,6 +1557,7 @@ impl vte::Perform for Screen {
params,
self.grid().size(),
)),
+ 't' => self.xtwinops(params),
_ => {
if log::log_enabled!(log::Level::Debug) {
log::debug!(
diff --git a/src/state.rs b/src/state.rs
index c84fa2b..5471bdd 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -42,6 +42,20 @@ impl<'a, T: crate::callbacks::Callbacks> vte::Perform for State<'a, T> {
ignore: bool,
c: char,
) {
+ if intermediates.first().is_none() && c == 't' {
+ let mut iter = params.iter();
+ let op = iter.next().and_then(|x| x.first().copied());
+ if op == Some(8) {
+ let (screen_rows, screen_cols) = self.screen.size();
+ let rows = iter.next().map_or(screen_rows, |x| {
+ *x.first().unwrap_or(&screen_rows)
+ });
+ let cols = iter.next().map_or(screen_cols, |x| {
+ *x.first().unwrap_or(&screen_cols)
+ });
+ self.callbacks.resize(self.screen, (rows, cols));
+ }
+ }
self.screen.csi_dispatch(params, intermediates, ignore, c);
}