1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 21:32:13 +03:00

sixel: respect Dec Private Mode 8452

This adjusts the cursor position after emitting a sixel.

@dankamongmen: I don't have much of a sixel test suite to speak
of (cat snake.six :-p); I'd appreciate it if you could run
notcurses against this and confirm that it is doing something
sane!

At the very least, we shouldn't be warning about the unhandled
mode any more!

refs: https://github.com/wez/wezterm/issues/863
refs: https://github.com/dankamongmen/notcurses/issues/1743
This commit is contained in:
Wez Furlong 2021-06-19 21:07:44 -07:00
parent ae4bfae5c4
commit ccd66c01a9
2 changed files with 20 additions and 2 deletions

View File

@ -302,6 +302,7 @@ pub struct TerminalState {
writer: Box<dyn std::io::Write>,
image_cache: lru::LruCache<[u8; 32], Arc<ImageData>>,
sixel_scrolls_right: bool,
user_vars: HashMap<String, String>,
}
@ -472,6 +473,7 @@ impl TerminalState {
bracketed_paste: false,
focus_tracking: false,
sgr_mouse: false,
sixel_scrolls_right: false,
any_event_mouse: false,
button_event_mouse: false,
mouse_tracking: false,
@ -1626,8 +1628,9 @@ impl TerminalState {
}
// Sixel places the cursor under the left corner of the image,
// but iTerm places it after the bottom right corner.
if iterm_cursor_position {
// unless sixel_scrolls_right is enabled.
// iTerm places it after the bottom right corner.
if iterm_cursor_position || self.sixel_scrolls_right {
self.set_cursor_pos(
&Position::Relative(width_in_cells as i64),
&Position::Relative(-1),
@ -2088,6 +2091,17 @@ impl TerminalState {
self.last_mouse_move.take();
}
Mode::SetDecPrivateMode(DecPrivateMode::Code(
DecPrivateModeCode::SixelScrollsRight,
)) => {
self.sixel_scrolls_right = true;
}
Mode::ResetDecPrivateMode(DecPrivateMode::Code(
DecPrivateModeCode::SixelScrollsRight,
)) => {
self.sixel_scrolls_right = false;
}
Mode::SetDecPrivateMode(DecPrivateMode::Code(
DecPrivateModeCode::ClearAndEnableAlternateScreen,
)) => {
@ -3275,6 +3289,7 @@ impl<'a> Performer<'a> {
self.bracketed_paste = false;
self.focus_tracking = false;
self.sgr_mouse = false;
self.sixel_scrolls_right = false;
self.any_event_mouse = false;
self.button_event_mouse = false;
self.current_mouse_button = MouseButton::None;

View File

@ -691,6 +691,9 @@ pub enum DecPrivateModeCode {
BracketedPaste = 2004,
/// Applies to sixel and regis modes
UsePrivateColorRegistersForEachGraphic = 1070,
/// xterm: adjust cursor positioning after emitting sixel
SixelScrollsRight = 8452,
}
#[derive(Debug, Clone, PartialEq, Eq)]