mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-07 04:06:07 -05:00
csi: in-band window resize notifications, private mode 2048
This implements https://gist.github.com/rockorager/e695fb2924d36b2bcf1fff4a3704bd83, in-band window resize notifications. When user enables private mode 2048 (in-band resize notifications), *always* send current size, even if the mode is already active. This ensures applications can rely on getting a reply from the terminal.
This commit is contained in:
parent
e11a4ab6af
commit
38461eef6f
6 changed files with 60 additions and 0 deletions
|
|
@ -67,6 +67,9 @@
|
|||
i.e. color palette stack ([#856][856]).
|
||||
* Log output now respects the [`NO_COLOR`](http://no-color.org/)
|
||||
environment variable ([#1771][1771]).
|
||||
* Support for [in-band window resize
|
||||
notifications](https://gist.github.com/rockorager/e695fb2924d36b2bcf1fff4a3704bd83),
|
||||
private mode `2048`.
|
||||
|
||||
[1707]: https://codeberg.org/dnkl/foot/issues/1707
|
||||
[1738]: https://codeberg.org/dnkl/foot/issues/1738
|
||||
|
|
|
|||
10
csi.c
10
csi.c
|
|
@ -562,6 +562,13 @@ decset_decrst(struct terminal *term, unsigned param, bool enable)
|
|||
term->grapheme_shaping = enable;
|
||||
break;
|
||||
|
||||
case 2048:
|
||||
if (enable)
|
||||
term_enable_size_notifications(term);
|
||||
else
|
||||
term_disable_size_notifications(term);
|
||||
break;
|
||||
|
||||
case 8452:
|
||||
term->sixel.cursor_right_of_graphics = enable;
|
||||
break;
|
||||
|
|
@ -649,6 +656,7 @@ decrqm(const struct terminal *term, unsigned param)
|
|||
case 2027: return term->conf->tweak.grapheme_width_method != GRAPHEME_WIDTH_DOUBLE
|
||||
? DECRPM_PERMANENTLY_RESET
|
||||
: decrpm(term->grapheme_shaping);
|
||||
case 2048: return decrpm(term->size_notifications);
|
||||
case 8452: return decrpm(term->sixel.cursor_right_of_graphics);
|
||||
case 737769: return decrpm(term_ime_is_enabled(term));
|
||||
}
|
||||
|
|
@ -693,6 +701,7 @@ xtsave(struct terminal *term, unsigned param)
|
|||
case 2004: term->xtsave.bracketed_paste = term->bracketed_paste; break;
|
||||
case 2026: term->xtsave.app_sync_updates = term->render.app_sync_updates.enabled; break;
|
||||
case 2027: term->xtsave.grapheme_shaping = term->grapheme_shaping; break;
|
||||
case 2048: term->xtsave.size_notifications = term->size_notifications; break;
|
||||
case 8452: term->xtsave.sixel_cursor_right_of_graphics = term->sixel.cursor_right_of_graphics; break;
|
||||
case 737769: term->xtsave.ime = term_ime_is_enabled(term); break;
|
||||
}
|
||||
|
|
@ -736,6 +745,7 @@ xtrestore(struct terminal *term, unsigned param)
|
|||
case 2004: enable = term->xtsave.bracketed_paste; break;
|
||||
case 2026: enable = term->xtsave.app_sync_updates; break;
|
||||
case 2027: enable = term->xtsave.grapheme_shaping; break;
|
||||
case 2048: enable = term->xtsave.size_notifications; break;
|
||||
case 8452: enable = term->xtsave.sixel_cursor_right_of_graphics; break;
|
||||
case 737769: enable = term->xtsave.ime; break;
|
||||
|
||||
|
|
|
|||
|
|
@ -337,6 +337,9 @@ that corresponds to one of the following modes:
|
|||
| 2027
|
||||
: contour
|
||||
: Grapheme cluster processing
|
||||
| 2048
|
||||
: TODO
|
||||
: In-band window resize notifications
|
||||
| 8452
|
||||
: xterm
|
||||
: Position cursor to the right of sixels, instead of on the next line
|
||||
|
|
|
|||
2
render.c
2
render.c
|
|
@ -4072,6 +4072,8 @@ tiocswinsz(struct terminal *term)
|
|||
{
|
||||
LOG_ERRNO("TIOCSWINSZ");
|
||||
}
|
||||
|
||||
term_send_size_notification(term);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
35
terminal.c
35
terminal.c
|
|
@ -44,6 +44,7 @@
|
|||
#include "util.h"
|
||||
#include "vt.h"
|
||||
#include "xmalloc.h"
|
||||
#include "xsnprintf.h"
|
||||
|
||||
#define PTMX_TIMING 0
|
||||
|
||||
|
|
@ -4240,3 +4241,37 @@ term_set_user_mouse_cursor(struct terminal *term, const char *cursor)
|
|||
: NULL;
|
||||
term_xcursor_update(term);
|
||||
}
|
||||
|
||||
void
|
||||
term_enable_size_notifications(struct terminal *term)
|
||||
{
|
||||
/* Note: always send current size upon activation, regardless of
|
||||
previous state */
|
||||
term->size_notifications = true;
|
||||
term_send_size_notification(term);
|
||||
}
|
||||
|
||||
void
|
||||
term_disable_size_notifications(struct terminal *term)
|
||||
{
|
||||
if (!term->size_notifications)
|
||||
return;
|
||||
|
||||
term->size_notifications = false;
|
||||
}
|
||||
|
||||
void
|
||||
term_send_size_notification(struct terminal *term)
|
||||
{
|
||||
if (!term->size_notifications)
|
||||
return;
|
||||
|
||||
const int height = term->height - term->margins.top - term->margins.bottom;
|
||||
const int width = term->width - term->margins.left - term->margins.right;
|
||||
|
||||
char buf[128];
|
||||
const int n = xsnprintf(
|
||||
buf, sizeof(buf), "\033[48;%d;%d;%d;%dt",
|
||||
term->rows, term->cols, height, width);
|
||||
term_to_slave(term, buf, n);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -541,6 +541,8 @@ struct terminal {
|
|||
bool app_sync_updates:1;
|
||||
bool grapheme_shaping:1;
|
||||
|
||||
bool size_notifications:1;
|
||||
|
||||
bool sixel_display_mode:1;
|
||||
bool sixel_private_palette:1;
|
||||
bool sixel_cursor_right_of_graphics:1;
|
||||
|
|
@ -800,6 +802,7 @@ struct terminal {
|
|||
char *cwd;
|
||||
|
||||
bool grapheme_shaping;
|
||||
bool size_notifications;
|
||||
};
|
||||
|
||||
struct config;
|
||||
|
|
@ -946,6 +949,10 @@ void term_osc8_close(struct terminal *term);
|
|||
bool term_ptmx_pause(struct terminal *term);
|
||||
bool term_ptmx_resume(struct terminal *term);
|
||||
|
||||
void term_enable_size_notifications(struct terminal *term);
|
||||
void term_disable_size_notifications(struct terminal *term);
|
||||
void term_send_size_notification(struct terminal *term);
|
||||
|
||||
static inline void term_reset_grapheme_state(struct terminal *term)
|
||||
{
|
||||
#if defined(FOOT_GRAPHEME_CLUSTERING)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue