aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Brooks <db48x@db48x.net>2021-06-11 01:59:17 -0700
committerDaniel Brooks <db48x@db48x.net>2021-06-11 02:04:06 -0700
commitae7aa4b5a3ef01a323fa27e0a208d40111b6b11a (patch)
treef58efe4e4ab5f2cf072a054f8586d6b956cb1c50
parent3caa09ef9b339ebed1329eed016b8a5704bd2c77 (diff)
downloadr-alacritty-ae7aa4b5a3ef01a323fa27e0a208d40111b6b11a.tar.gz
r-alacritty-ae7aa4b5a3ef01a323fa27e0a208d40111b6b11a.tar.bz2
r-alacritty-ae7aa4b5a3ef01a323fa27e0a208d40111b6b11a.zip
support DECSET/DECRST (CSI ? Pm h) to change where the cursor ends up
after printing a sixel image. The default is for the cursor to be moved to the first column of the line after the image. When we receive CSI ? 8452 h, we will instead leave the cursor on the last line of the image, on the next column past the end of the image.
-rw-r--r--alacritty_terminal/src/ansi.rs3
-rw-r--r--alacritty_terminal/src/term/mod.rs20
-rw-r--r--docs/escape_support.md2
3 files changed, 20 insertions, 5 deletions
diff --git a/alacritty_terminal/src/ansi.rs b/alacritty_terminal/src/ansi.rs
index 14617de1..35763f92 100644
--- a/alacritty_terminal/src/ansi.rs
+++ b/alacritty_terminal/src/ansi.rs
@@ -569,6 +569,8 @@ pub enum Mode {
SixelPrivateColorRegisters = 1070,
/// ?2004
BracketedPaste = 2004,
+ /// Sixel scrolling leaves cursor to right of graphic.
+ SixelCursorToTheRight = 8452,
}
impl Mode {
@@ -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;
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs
index 959f99ef..7849dd5e 100644
--- a/alacritty_terminal/src/term/mod.rs
+++ b/alacritty_terminal/src/term/mod.rs
@@ -46,7 +46,7 @@ const TITLE_STACK_MAX_DEPTH: usize = 4096;
const INITIAL_TABSTOPS: usize = 8;
bitflags! {
- pub struct TermMode: u32 {
+ pub struct TermMode: u64 {
const NONE = 0;
const SHOW_CURSOR = 0b0000_0000_0000_0000_0001;
const APP_CURSOR = 0b0000_0000_0000_0000_0010;
@@ -69,7 +69,8 @@ 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 ANY = std::u32::MAX;
+ const SIXEL_CURSOR_TO_THE_RIGHT = 0b0001_0000_0000_0000_0000_0000;
+ const ANY = std::u64::MAX;
}
}
@@ -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);
+ },
}
}
@@ -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)
+ },
}
}
@@ -1855,12 +1862,17 @@ 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;
+ let right = min(self.columns(), left + graphic_columns);
+ self.move_forward(Column(right));
+ } else if scrolling {
+ self.linefeed();
self.carriage_return();
}
}
diff --git a/docs/escape_support.md b/docs/escape_support.md
index bc951753..4673cedc 100644
--- a/docs/escape_support.md
+++ b/docs/escape_support.md
@@ -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 | |