mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-07 04:06:07 -05:00
sixel: implement private mode 8452 - cursor positioning after sixel
When disabled (the default), the cursor is positioned on a new line after emitting a sixel image. When enabled, the cursor is positioned to the right of the sixel image. Closes #363
This commit is contained in:
parent
9666d1d0b7
commit
03c675c6e2
5 changed files with 37 additions and 2 deletions
|
|
@ -47,6 +47,8 @@
|
|||
(https://codeberg.org/dnkl/foot/issues/347)
|
||||
* `DECSET 1070` - sixel private color palette
|
||||
(https://codeberg.org/dnkl/foot/issues/362).
|
||||
* `DECSET 8452` - position cursor to the right of sixels
|
||||
(https://codeberg.org/dnkl/foot/issues/363).
|
||||
|
||||
|
||||
### Changed
|
||||
|
|
|
|||
7
csi.c
7
csi.c
|
|
@ -552,6 +552,10 @@ decset_decrst(struct terminal *term, unsigned param, bool enable)
|
|||
term->bracketed_paste = enable;
|
||||
break;
|
||||
|
||||
case 8452:
|
||||
term->sixel.cursor_right_of_graphics = enable;
|
||||
break;
|
||||
|
||||
case 27127:
|
||||
term->modify_escape_key = enable;
|
||||
break;
|
||||
|
|
@ -613,6 +617,7 @@ decrqm(const struct terminal *term, unsigned param, bool *enabled)
|
|||
case 1049: *enabled = term->grid == &term->alt; return true;
|
||||
case 1079: *enabled = term->sixel.use_private_palette; return true;
|
||||
case 2004: *enabled = term->bracketed_paste; return true;
|
||||
case 8452: *enabled = term->sixel.cursor_right_of_graphics; return true;
|
||||
case 27127: *enabled = term->modify_escape_key; return true;
|
||||
case 737769: *enabled = term_ime_is_enabled(term); return true;
|
||||
}
|
||||
|
|
@ -653,6 +658,7 @@ xtsave(struct terminal *term, unsigned param)
|
|||
case 1049: term->xtsave.alt_screen = term->grid == &term->alt; break;
|
||||
case 1070: term->xtsave.sixel_private_palette = term->sixel.use_private_palette; break;
|
||||
case 2004: term->xtsave.bracketed_paste = term->bracketed_paste; break;
|
||||
case 8452: term->xtsave.sixel_cursor_right_of_graphics = term->sixel.cursor_right_of_graphics; break;
|
||||
case 27127: term->xtsave.modify_escape_key = term->modify_escape_key; break;
|
||||
case 737769: term->xtsave.ime = term_ime_is_enabled(term); break;
|
||||
}
|
||||
|
|
@ -692,6 +698,7 @@ xtrestore(struct terminal *term, unsigned param)
|
|||
case 1049: enable = term->xtsave.alt_screen; break;
|
||||
case 1070: enable = term->xtsave.sixel_private_palette; break;
|
||||
case 2004: enable = term->xtsave.bracketed_paste; break;
|
||||
case 8452: enable = term->xtsave.sixel_cursor_right_of_graphics; break;
|
||||
case 27127: enable = term->xtsave.modify_escape_key; break;
|
||||
case 737769: enable = term->xtsave.ime; break;
|
||||
|
||||
|
|
|
|||
|
|
@ -316,6 +316,9 @@ that corresponds to one of the following modes:
|
|||
| 2004
|
||||
: xterm
|
||||
: Wrap pasted text with start/end delimiters (bracketed paste mode)
|
||||
| 8452
|
||||
: xterm
|
||||
: Position cursor to the right of sixels, instead of on the next line
|
||||
| 737769
|
||||
: foot
|
||||
: Input Method Editor (IME) mode
|
||||
|
|
|
|||
24
sixel.c
24
sixel.c
|
|
@ -767,9 +767,29 @@ sixel_unhook(struct terminal *term)
|
|||
{
|
||||
row->cells[col].attrs.clean = 0;
|
||||
}
|
||||
term_linefeed(term);
|
||||
|
||||
if (i < image.rows - 1 || !term->sixel.cursor_right_of_graphics)
|
||||
term_linefeed(term);
|
||||
}
|
||||
term_carriage_return(term);
|
||||
|
||||
/*
|
||||
* Position cursor
|
||||
*
|
||||
* Private mode 8452 controls where we leave the cursor after
|
||||
* emitting a sixel:
|
||||
*
|
||||
* When disabled (the default), the cursor is positioned on a
|
||||
* new line.
|
||||
*
|
||||
* When enabled, the cursor is positioned to the right of the
|
||||
* sixel.
|
||||
*/
|
||||
term_cursor_to(
|
||||
term,
|
||||
term->grid->cursor.point.row,
|
||||
(term->sixel.cursor_right_of_graphics
|
||||
? min(image.pos.col + image.cols, term->cols - 1)
|
||||
: 0));
|
||||
|
||||
_sixel_overwrite_by_rectangle(
|
||||
term, image.pos.row, image.pos.col, image.rows, image.cols);
|
||||
|
|
|
|||
|
|
@ -361,6 +361,7 @@ struct terminal {
|
|||
uint32_t ime:1;
|
||||
|
||||
uint32_t sixel_private_palette:1;
|
||||
uint32_t sixel_cursor_right_of_graphics:1;
|
||||
} xtsave;
|
||||
|
||||
char *window_title;
|
||||
|
|
@ -538,6 +539,8 @@ struct terminal {
|
|||
unsigned param; /* Currently collecting parameter, for RASTER, COLOR_SPEC and REPEAT */
|
||||
unsigned param_idx; /* Parameters seen */
|
||||
|
||||
bool cursor_right_of_graphics:1; /* Private mode 8452 */
|
||||
|
||||
/* Application configurable */
|
||||
unsigned palette_size; /* Number of colors in palette */
|
||||
unsigned max_width; /* Maximum image width, in pixels */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue