add device attributes answerback
This commit is contained in:
1 parent
1059620233
commit
13a856bbb2
2 files changed
+27
-2
No files matched your search
@@ -42,6 +42,7 @@ pub enum CSIAction {
|
||||
DeviceStatusReport,
|
||||
ReportCursorPosition,
|
||||
SetScrollingRegion { top: usize, bottom: usize },
|
||||
RequestDeviceAttributes,
|
||||
}
|
||||
|
||||
/// Constrol Sequence Initiator (CSI) Parser.
|
||||
@@ -416,6 +417,20 @@ impl<'a> CSIParser<'a> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn device_attributes(&mut self, params: &'a [i64]) -> Option<CSIAction> {
|
||||
match params {
|
||||
&[] => Some(CSIAction::RequestDeviceAttributes),
|
||||
&[0] => {
|
||||
self.advance_by(1, params);
|
||||
Some(CSIAction::RequestDeviceAttributes)
|
||||
}
|
||||
_ => {
|
||||
println!("device_attributes: invalid sequence: {:?}", params);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Iterator for CSIParser<'a> {
|
||||
@@ -425,6 +440,7 @@ impl<'a> Iterator for CSIParser<'a> {
|
||||
let params = self.params.take();
|
||||
match (self.byte, self.intermediates, params) {
|
||||
(_, _, None) => None,
|
||||
('c', &[b'>'], Some(params)) => self.device_attributes(params),
|
||||
('h', &[b'?'], Some(params)) => self.dec_set_mode(params),
|
||||
('l', &[b'?'], Some(params)) => self.dec_reset_mode(params),
|
||||
('r', &[], Some(params)) => self.set_scroll_region(params),
|
||||
|
||||
+11
-2
@@ -10,6 +10,12 @@ pub mod color;
|
||||
mod csi;
|
||||
use self::csi::*;
|
||||
|
||||
/// The response we given when queries for device attributes.
|
||||
/// This particular string says "we are a VT102".
|
||||
/// TODO: Consider VT220 extended response which can advertise
|
||||
/// certain feature sets.
|
||||
const DEVICE_IDENT: &[u8] = b"\x1b[?6c";
|
||||
|
||||
bitflags! {
|
||||
#[derive(Default)]
|
||||
pub struct KeyModifiers :u8{
|
||||
@@ -458,7 +464,7 @@ impl TerminalState {
|
||||
fn set_cursor_pos(&mut self, x: usize, y: usize) {
|
||||
let rows = self.screen().physical_rows;
|
||||
self.cursor_x = x;
|
||||
self.cursor_y = y.min(rows-1);
|
||||
self.cursor_y = y.min(rows - 1);
|
||||
self.state_changed = true;
|
||||
}
|
||||
|
||||
@@ -656,9 +662,12 @@ impl vte::Perform for TerminalState {
|
||||
let col = self.cursor_x + 1;
|
||||
self.push_answerback(format!("\x1b[{};{}R", row, col).as_bytes());
|
||||
}
|
||||
CSIAction::SetScrollingRegion{top, bottom} => {
|
||||
CSIAction::SetScrollingRegion { top, bottom } => {
|
||||
println!("unhandled: SetScrollingRegion {}-{}", top, bottom);
|
||||
}
|
||||
CSIAction::RequestDeviceAttributes => {
|
||||
self.push_answerback(DEVICE_IDENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user