diff options
-rw-r--r-- | src/ansi.rs | 4 | ||||
-rw-r--r-- | src/term/mod.rs | 14 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/ansi.rs b/src/ansi.rs index a3f5c2d2..a2adcf90 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -129,7 +129,7 @@ pub trait Handler { fn identify_terminal<W: io::Write>(&mut self, &mut W) {} // Report device status - fn device_status<W: io::Write>(&mut self, &mut W) {} + fn device_status<W: io::Write>(&mut self, &mut W, usize) {} /// Move cursor forward `cols` fn move_forward(&mut self, Column) {} @@ -874,7 +874,7 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W> i += 1; // C-for expr } } - 'n' => handler.device_status(writer), + 'n' => handler.device_status(writer, arg_or_default!(idx: 0, default: 0) as usize), 'r' => { if private { unhandled!(); diff --git a/src/term/mod.rs b/src/term/mod.rs index e3510b11..0be0eb86 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -1240,8 +1240,18 @@ impl ansi::Handler for Term { } #[inline] - fn device_status<W: io::Write>(&mut self, writer: &mut W) { - let _ = writer.write_all(b"\x1b0n"); + fn device_status<W: io::Write>(&mut self, writer: &mut W, arg: usize) { + trace!("device status: {}", arg); + match arg { + 5 => { + let _ = writer.write_all(b"\x1b[0n"); + }, + 6 => { + let pos = self.cursor.point; + let _ = write!(writer, "\x1b[{};{}R", pos.line + 1, pos.col + 1); + }, + _ => debug!("unknown device status query: {}", arg), + }; } #[inline] |