Skip to content
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

support DECSET/DECRST (CSI ? Pm h) to change where the cursor ends up #6

Merged
merged 3 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions alacritty_terminal/src/ansi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ pub enum Mode {
SixelPrivateColorRegisters = 1070,
/// ?2004
BracketedPaste = 2004,
/// Sixel scrolling leaves cursor to right of graphic.
SixelCursorToTheRight = 8452,
}

impl Mode {
Expand Down Expand Up @@ -600,6 +602,7 @@ impl Mode {
1049 => Mode::SwapScreenAndSetRestoreCursor,
1070 => Mode::SixelPrivateColorRegisters,
2004 => Mode::BracketedPaste,
8452 => Mode::SixelCursorToTheRight,
_ => {
trace!("[unimplemented] primitive mode: {}", num);
return None;
Expand Down
15 changes: 13 additions & 2 deletions alacritty_terminal/src/term/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ bitflags! {
const URGENCY_HINTS = 0b0010_0000_0000_0000_0000;
const SIXEL_SCROLLING = 0b0100_0000_0000_0000_0000;
const SIXEL_PRIV_PALETTE = 0b1000_0000_0000_0000_0000;
const SIXEL_CURSOR_TO_THE_RIGHT = 0b0001_0000_0000_0000_0000_0000;
const ANY = std::u32::MAX;
}
}
Expand Down Expand Up @@ -1585,6 +1586,9 @@ impl<T: EventListener> Handler for Term<T> {
ansi::Mode::SixelPrivateColorRegisters => {
self.mode.insert(TermMode::SIXEL_PRIV_PALETTE)
},
ansi::Mode::SixelCursorToTheRight => {
self.mode.insert(TermMode::SIXEL_CURSOR_TO_THE_RIGHT);
},
}
}

Expand Down Expand Up @@ -1632,6 +1636,9 @@ impl<T: EventListener> Handler for Term<T> {
self.graphics.sixel_shared_palette = None;
self.mode.remove(TermMode::SIXEL_PRIV_PALETTE);
},
ansi::Mode::SixelCursorToTheRight => {
self.mode.remove(TermMode::SIXEL_CURSOR_TO_THE_RIGHT)
},
}
}

Expand Down Expand Up @@ -1855,12 +1862,16 @@ impl<T: EventListener> Handler for Term<T> {
let graphic_cell = GraphicCell { texture: texture.clone(), offset_x: 0, offset_y };
self.grid[line][Column(left)].set_graphic(graphic_cell);

if scrolling {
if scrolling && offset_y < height - self.cell_height as u16 {
self.linefeed();
}
}

if scrolling {
if self.mode.contains(TermMode::SIXEL_CURSOR_TO_THE_RIGHT) {
let graphic_columns = (graphic.width + self.cell_width - 1) / self.cell_width;
self.move_forward(Column(graphic_columns));
} else if scrolling {
self.linefeed();
self.carriage_return();
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/escape_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ brevity.
| `CSI ? h` | PARTIAL | Supported modes: |
| | | `1`, `3`, `6`, `7`, `12`, `25`, `1000`, `1002` |
| | | `1004`, `1005`, `1006`, `1007`, `1042`, `1049` |
| | | `2004` |
| | | `2004`, `8452` |
| `CSI I` | IMPLEMENTED | |
| `CSI J` | IMPLEMENTED | |
| `CSI K` | IMPLEMENTED | |
Expand Down