-
-
Notifications
You must be signed in to change notification settings - Fork 782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve VT102 compliance #904
Changes from all commits
3c86470
25b72fa
83155fe
c64c812
4b2f2ae
cf024f9
952ba0b
309139a
558eebd
eb88843
2a33f63
1a54d1b
e284d97
4983dc2
6420222
a8ef67a
c4f4d4b
99c355a
957140f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,8 +93,10 @@ impl TabStop { | |
*t = false; | ||
} | ||
} | ||
TabulationClear::ClearAllCharacterTabStops | ||
| TabulationClear::ClearCharacterTabStopsAtActiveLine => { | ||
// If we want to exactly match VT100/xterm behavior, then | ||
// we cannot honor ClearCharacterTabStopsAtActiveLine. | ||
TabulationClear::ClearAllCharacterTabStops => { | ||
// | TabulationClear::ClearCharacterTabStopsAtActiveLine | ||
for t in &mut self.tabs { | ||
*t = false; | ||
} | ||
|
@@ -240,6 +242,9 @@ pub struct TerminalState { | |
/// Reverse Wraparound Mode | ||
reverse_wraparound_mode: bool, | ||
|
||
/// Reverse video mode | ||
reverse_video_mode: bool, | ||
|
||
/// https://vt100.net/docs/vt510-rm/DECOM.html | ||
/// When OriginMode is enabled, cursor is constrained to the | ||
/// scroll region and its position is relative to the scroll | ||
|
@@ -290,6 +295,7 @@ pub struct TerminalState { | |
g0_charset: CharSet, | ||
g1_charset: CharSet, | ||
shift_out: bool, | ||
newline_mode: bool, | ||
|
||
tabs: TabStop, | ||
|
||
|
@@ -475,6 +481,7 @@ impl TerminalState { | |
// a dec terminal is false, because it is more useful this way. | ||
dec_auto_wrap: true, | ||
reverse_wraparound_mode: false, | ||
reverse_video_mode: false, | ||
dec_origin_mode: false, | ||
insert: false, | ||
application_cursor_keys: false, | ||
|
@@ -495,6 +502,7 @@ impl TerminalState { | |
g0_charset: CharSet::Ascii, | ||
g1_charset: CharSet::DecLineDrawing, | ||
shift_out: false, | ||
newline_mode: false, | ||
current_mouse_button: MouseButton::None, | ||
tabs: TabStop::new(size.physical_cols, 8), | ||
title: "wezterm".to_string(), | ||
|
@@ -1028,6 +1036,9 @@ impl TerminalState { | |
buf.push(0x1b as char); | ||
} | ||
buf.push(c); | ||
if self.newline_mode && key == Enter { | ||
buf.push(0x0a as char); | ||
} | ||
} | ||
buf.as_str() | ||
} | ||
|
@@ -1795,6 +1806,7 @@ impl TerminalState { | |
self.screen.saved_cursor().take(); | ||
|
||
self.reverse_wraparound_mode = false; | ||
self.reverse_video_mode = false; | ||
} | ||
Device::RequestPrimaryDeviceAttributes => { | ||
let mut ident = "\x1b[?65".to_string(); // Vt500 | ||
|
@@ -1819,6 +1831,12 @@ impl TerminalState { | |
self.writer.write(ST.as_bytes()).ok(); | ||
self.writer.flush().ok(); | ||
} | ||
Device::RequestTerminalParameters(a) => { | ||
self.writer | ||
.write(format!("\x1b[{};1;1;128;128;1;0x", a + 2).as_bytes()) | ||
.ok(); | ||
self.writer.flush().ok(); | ||
} | ||
Device::StatusReport => { | ||
self.writer.write(b"\x1b[0n").ok(); | ||
self.writer.flush().ok(); | ||
|
@@ -1949,10 +1967,16 @@ impl TerminalState { | |
// We always output at our "best" rate | ||
} | ||
|
||
Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::ReverseVideo)) | ||
| Mode::ResetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::ReverseVideo)) => { | ||
// I'm mostly intentionally ignoring this in favor | ||
// of respecting the configured colors | ||
Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::ReverseVideo)) => { | ||
// Turn on reverse video for all of the lines on the | ||
// display. | ||
self.reverse_video_mode = true; | ||
} | ||
|
||
Mode::ResetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::ReverseVideo)) => { | ||
// Turn off reverse video for all of the lines on the | ||
// display. | ||
self.reverse_video_mode = false; | ||
} | ||
|
||
Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::Select132Columns)) | ||
|
@@ -1977,6 +2001,13 @@ impl TerminalState { | |
self.insert = false; | ||
} | ||
|
||
Mode::SetMode(TerminalMode::Code(TerminalModeCode::AutomaticNewline)) => { | ||
self.newline_mode = true; | ||
} | ||
Mode::ResetMode(TerminalMode::Code(TerminalModeCode::AutomaticNewline)) => { | ||
self.newline_mode = false; | ||
} | ||
|
||
Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::BracketedPaste)) => { | ||
self.bracketed_paste = true; | ||
} | ||
|
@@ -2824,6 +2855,7 @@ impl TerminalState { | |
self.g0_charset = saved.g0_charset; | ||
self.g1_charset = saved.g1_charset; | ||
self.shift_out = false; | ||
self.newline_mode = false; | ||
} | ||
|
||
fn perform_csi_sgr(&mut self, sgr: Sgr) { | ||
|
@@ -2941,6 +2973,11 @@ impl TerminalState { | |
|
||
Ok(zones) | ||
} | ||
|
||
#[inline] | ||
pub fn get_reverse_video(&self) -> bool { | ||
self.reverse_video_mode | ||
} | ||
} | ||
|
||
/// A helper struct for implementing `vtparse::VTActor` while compartmentalizing | ||
|
@@ -3189,6 +3226,9 @@ impl<'a> Performer<'a> { | |
self.cursor.y = y; | ||
self.wrap_next = false; | ||
} | ||
if self.newline_mode { | ||
self.cursor.x = 0; | ||
} | ||
} | ||
ControlCode::CarriageReturn => { | ||
if self.cursor.x >= self.left_and_right_margins.start { | ||
|
@@ -3258,6 +3298,15 @@ impl<'a> Performer<'a> { | |
ControlCode::ShiftOut => { | ||
self.shift_out = true; | ||
} | ||
|
||
ControlCode::Enquiry => { | ||
let response = self.config.enq_answerback(); | ||
if response.len() > 0 { | ||
write!(self.writer, "{}", response).ok(); | ||
self.writer.flush().ok(); | ||
} | ||
} | ||
|
||
_ => log::warn!("unhandled ControlCode {:?}", control), | ||
} | ||
} | ||
|
@@ -3318,6 +3367,23 @@ impl<'a> Performer<'a> { | |
Esc::Code(EscCode::DecSaveCursorPosition) => self.dec_save_cursor(), | ||
Esc::Code(EscCode::DecRestoreCursorPosition) => self.dec_restore_cursor(), | ||
|
||
Esc::Code(EscCode::DecDoubleHeightTopHalfLine) => { | ||
let idx = self.screen.phys_row(self.cursor.y); | ||
self.screen.line_mut(idx).set_double_height_top(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it would be great to add a some test coverage for these attributes, especially because we're not rendering them :-) I don't think we have any existing tests or conveniences for inspecting |
||
} | ||
Esc::Code(EscCode::DecDoubleHeightBottomHalfLine) => { | ||
let idx = self.screen.phys_row(self.cursor.y); | ||
self.screen.line_mut(idx).set_double_height_bottom(); | ||
} | ||
Esc::Code(EscCode::DecDoubleWidthLine) => { | ||
let idx = self.screen.phys_row(self.cursor.y); | ||
self.screen.line_mut(idx).set_double_width(); | ||
} | ||
Esc::Code(EscCode::DecSingleWidthLine) => { | ||
let idx = self.screen.phys_row(self.cursor.y); | ||
self.screen.line_mut(idx).set_single_width(); | ||
} | ||
|
||
Esc::Code(EscCode::DecScreenAlignmentDisplay) => { | ||
// This one is just to make vttest happy; | ||
// its original purpose was for aligning the CRT. | ||
|
@@ -3351,6 +3417,7 @@ impl<'a> Performer<'a> { | |
self.insert = false; | ||
self.dec_auto_wrap = true; | ||
self.reverse_wraparound_mode = false; | ||
self.reverse_video_mode = false; | ||
self.dec_origin_mode = false; | ||
self.use_private_color_registers_for_each_graphic = false; | ||
self.color_map = default_color_map(); | ||
|
@@ -3369,6 +3436,7 @@ impl<'a> Performer<'a> { | |
self.g0_charset = CharSet::Ascii; | ||
self.g1_charset = CharSet::DecLineDrawing; | ||
self.shift_out = false; | ||
self.newline_mode = false; | ||
self.tabs = TabStop::new(self.screen().physical_cols, 8); | ||
self.palette.take(); | ||
self.top_and_bottom_margins = 0..self.screen().physical_rows as VisibleRowIndex; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you mind adding a unit test for this?
It can be similar to the one from your previous PR!