Skip to content

Commit

Permalink
#133 AutomaticNewline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Autumn Lamonte authored and wez committed Jul 25, 2021
1 parent ad30664 commit e3cadc5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions term/src/terminalstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ pub struct TerminalState {
g1_charset: CharSet,
shift_out: bool,

newline_mode: bool,

tabs: TabStop,

/// The terminal title string (OSC 2)
Expand Down Expand Up @@ -507,6 +509,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(),
Expand Down Expand Up @@ -1048,6 +1051,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()
}
Expand Down Expand Up @@ -2170,6 +2176,16 @@ impl TerminalState {
self.decqrm_response(mode, true, self.insert);
}

Mode::SetMode(TerminalMode::Code(TerminalModeCode::AutomaticNewline)) => {
self.newline_mode = true;
}
Mode::ResetMode(TerminalMode::Code(TerminalModeCode::AutomaticNewline)) => {
self.newline_mode = false;
}
Mode::QueryMode(TerminalMode::Code(TerminalModeCode::AutomaticNewline)) => {
self.decqrm_response(mode, true, self.newline_mode);
}

Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::BracketedPaste)) => {
self.bracketed_paste = true;
}
Expand Down Expand Up @@ -3055,6 +3071,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) {
Expand Down Expand Up @@ -3441,6 +3458,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 {
Expand Down Expand Up @@ -3622,6 +3642,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;
Expand Down

0 comments on commit e3cadc5

Please sign in to comment.