mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-20 06:46:26 -04:00
csi: implement private modes 2034 + 2038
2034 enables window resize notifications, with the notifications being in pixels. 2038 does the same, but in characters instead of pixels. See https://gist.github.com/rockorager/e695fb2924d36b2bcf1fff4a3704bd83 for specification
This commit is contained in:
parent
cbe399ecd9
commit
774c60602b
6 changed files with 119 additions and 30 deletions
69
terminal.c
69
terminal.c
|
|
@ -44,6 +44,7 @@
|
|||
#include "util.h"
|
||||
#include "vt.h"
|
||||
#include "xmalloc.h"
|
||||
#include "xsnprintf.h"
|
||||
|
||||
#define PTMX_TIMING 0
|
||||
|
||||
|
|
@ -4098,3 +4099,71 @@ term_set_user_mouse_cursor(struct terminal *term, const char *cursor)
|
|||
: NULL;
|
||||
term_xcursor_update(term);
|
||||
}
|
||||
|
||||
void
|
||||
term_enable_size_notifications_pixels(struct terminal *term)
|
||||
{
|
||||
if (term->size_notifications_pixels)
|
||||
return;
|
||||
|
||||
term->size_notifications_pixels = true;
|
||||
term_report_window_size_pixels(term, false);
|
||||
}
|
||||
|
||||
void
|
||||
term_disable_size_notifications_pixels(struct terminal *term)
|
||||
{
|
||||
if (!term->size_notifications_pixels)
|
||||
return;
|
||||
|
||||
term->size_notifications_chars = false;
|
||||
}
|
||||
|
||||
void
|
||||
term_enable_size_notifications_chars(struct terminal *term)
|
||||
{
|
||||
if (term->size_notifications_chars)
|
||||
return;
|
||||
|
||||
term->size_notifications_chars = true;
|
||||
term_report_window_size_chars(term);
|
||||
}
|
||||
|
||||
void
|
||||
term_disable_size_notifications_chars(struct terminal *term)
|
||||
{
|
||||
if (!term->size_notifications_chars)
|
||||
return;
|
||||
|
||||
term->size_notifications_chars = false;
|
||||
}
|
||||
|
||||
void
|
||||
term_report_window_size_pixels(struct terminal *term, bool include_padding)
|
||||
{
|
||||
int width = -1;
|
||||
int height = -1;
|
||||
|
||||
if (!include_padding) {
|
||||
/* The text area only */
|
||||
width = term->width - term->margins.left - term->margins.right;
|
||||
height = term->height - term->margins.top - term->margins.bottom;
|
||||
} else {
|
||||
/* The entire window, including padding */
|
||||
width = term->width;
|
||||
height = term->height;
|
||||
}
|
||||
|
||||
char reply[64];
|
||||
size_t n = xsnprintf(reply, sizeof(reply), "\033[4;%d;%dt", height, width);
|
||||
term_to_slave(term, reply, n);
|
||||
}
|
||||
|
||||
void
|
||||
term_report_window_size_chars(struct terminal *term)
|
||||
{
|
||||
char reply[64];
|
||||
size_t n = xsnprintf(
|
||||
reply, sizeof(reply), "\033[8;%d;%dt", term->rows, term->cols);
|
||||
term_to_slave(term, reply, n);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue