Compare commits

..

5 Commits

Author SHA1 Message Date
Thomas Adam
b777780720 Merge branch 'obsd-master' 2023-09-19 12:01:11 +01:00
nicm
347cd0b5f8 Fix a couple of mouse mode flag names. 2023-09-19 08:35:44 +00:00
Nicholas Marriott
0ca28b362e Add combined character test. 2023-09-19 09:29:20 +01:00
Nicholas Marriott
51b80b985e Restore utf8proc code. 2023-09-19 09:29:04 +01:00
Nicholas Marriott
789a98982e Reply to SMGRAPHICS. 2023-09-19 09:27:59 +01:00
8 changed files with 91 additions and 4 deletions

View File

@ -23,7 +23,6 @@
#include "tmux.h"
#define SIXEL_COLOUR_REGISTERS 1024
#define SIXEL_WIDTH_LIMIT 10000
#define SIXEL_HEIGHT_LIMIT 10000

16
input.c
View File

@ -1839,8 +1839,22 @@ input_csi_dispatch_sm_private(struct input_ctx *ictx)
/* Handle CSI graphics SM. */
static void
input_csi_dispatch_sm_graphics(__unused struct input_ctx *ictx)
input_csi_dispatch_sm_graphics(struct input_ctx *ictx)
{
#ifdef ENABLE_SIXEL
int n, m, o;
if (ictx->param_list_len > 3)
return;
n = input_get(ictx, 0, 0, 0);
m = input_get(ictx, 1, 0, 0);
o = input_get(ictx, 2, 0, 0);
if (n == 1 && (m == 1 || m == 2 || m == 4))
input_reply(ictx, "\033[?%d;0;%uS", n, SIXEL_COLOUR_REGISTERS);
else
input_reply(ictx, "\033[?%d;3;%dS", n, o);
#endif
}
/* Handle CSI window operations. */

View File

@ -0,0 +1,24 @@
0
Λ̊1
🏻2
👍🏻3
👍🏻 👍🏻4
🤷5
♂️ 7
🤷8
🤷9
🤷10
🇪11
🇸🇪12
🇸🇪13

37
regress/combine-test.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/sh
PATH=/bin:/usr/bin
TERM=screen
[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux)
TMUX="$TEST_TMUX -Ltest"
$TMUX kill-server 2>/dev/null
TMP=$(mktemp)
trap "rm -f $TMP" 0 1 15
$TMUX -f/dev/null new -d "
printf '\e[H\e[J'
printf '\e[3;1H\316\233\e[3;1H\314\2120\n'
printf '\e[4;1H\316\233\e[4;2H\314\2121\n'
printf '\e[5;1H👍\e[5;1H🏻2\n'
printf '\e[6;1H👍\e[6;3H🏻3\n'
printf '\e[7;1H👍\e[7;10H👍\e[7;3H🏻\e[7;12H🏻4\n'
printf '\e[8;1H\360\237\244\267\342\200\215\342\231\202\357\270\2175\n'
printf '\e[9;1H\360\237\244\267\e[9;1H\342\200\215\342\231\202\357\270\2176\n'
printf '\e[9;1H\360\237\244\267\e[9;1H\342\200\215\342\231\202\357\270\2177\n'
printf '\e[10;1H\360\237\244\267\e[10;3H\342\200\215\342\231\202\357\270\2178\n'
printf '\e[11;1H\360\237\244\267\e[11;3H\342\200\215\e[11;3H\342\231\202\357\270\2179\n'
printf '\e[12;1H\360\237\244\267\e[12;3H\342\200\215\342\231\202\357\270\21710\n'
printf '\e[13;1H\360\237\207\25211\n'
printf '\e[14;1H\360\237\207\270\360\237\207\25212\n'
printf '\e[15;1H\360\237\207\270 \010\010\360\237\207\25213\n'
$TMUX capturep -pe >>$TMP"
sleep 1
cmp $TMP combine-test.result || exit 1
$TMUX has 2>/dev/null && exit 1
exit 0

View File

@ -1418,7 +1418,9 @@ screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped, u_int bg)
struct screen *s = ctx->s;
struct grid *gd = s->grid;
struct grid_line *gl;
#ifdef ENABLE_SIXEL
int redraw = 0;
#endif
u_int rupper = s->rupper, rlower = s->rlower;
gl = grid_get_line(gd, gd->hsize + s->cy);

View File

@ -716,9 +716,9 @@ screen_mode_to_string(int mode)
if (mode & MODE_CURSOR_VERY_VISIBLE)
strlcat(tmp, "CURSOR_VERY_VISIBLE,", sizeof tmp);
if (mode & MODE_MOUSE_UTF8)
strlcat(tmp, "UTF8,", sizeof tmp);
strlcat(tmp, "MOUSE_UTF8,", sizeof tmp);
if (mode & MODE_MOUSE_SGR)
strlcat(tmp, "SGR,", sizeof tmp);
strlcat(tmp, "MOUSE_SGR,", sizeof tmp);
if (mode & MODE_BRACKETPASTE)
strlcat(tmp, "BRACKETPASTE,", sizeof tmp);
if (mode & MODE_FOCUSON)

2
tmux.h
View File

@ -3343,6 +3343,7 @@ int utf8_cstrhas(const char *, const struct utf8_data *);
char *osdep_get_name(int, char *);
char *osdep_get_cwd(int);
struct event_base *osdep_event_init(void);
/* utf8-combined.c */
int utf8_has_zwj(const struct utf8_data *);
int utf8_is_zwj(const struct utf8_data *);
@ -3432,6 +3433,7 @@ int image_check_area(struct screen *, u_int, u_int, u_int, u_int);
int image_scroll_up(struct screen *, u_int);
/* image-sixel.c */
#define SIXEL_COLOUR_REGISTERS 1024
struct sixel_image *sixel_parse(const char *, size_t, u_int, u_int);
void sixel_free(struct sixel_image *);
void sixel_log(struct sixel_image *);

9
utf8.c
View File

@ -409,6 +409,10 @@ utf8_width(struct utf8_data *ud, int *width)
*width = 2;
return (UTF8_DONE);
}
#ifdef HAVE_UTF8PROC
*width = utf8proc_wcwidth(wc);
log_debug("utf8proc_wcwidth(%05X) returned %d", (u_int)wc, *width);
#else
*width = wcwidth(wc);
log_debug("wcwidth(%05X) returned %d", (u_int)wc, *width);
if (*width < 0) {
@ -418,6 +422,7 @@ utf8_width(struct utf8_data *ud, int *width)
*/
*width = (wc >= 0x80 && wc <= 0x9f) ? 0 : 1;
}
#endif
if (*width >= 0 && *width <= 0xff)
return (UTF8_DONE);
return (UTF8_ERROR);
@ -427,7 +432,11 @@ utf8_width(struct utf8_data *ud, int *width)
enum utf8_state
utf8_towc(const struct utf8_data *ud, wchar_t *wc)
{
#ifdef HAVE_UTF8PROC
switch (utf8proc_mbtowc(wc, ud->data, ud->size)) {
#else
switch (mbtowc(wc, ud->data, ud->size)) {
#endif
case -1:
log_debug("UTF-8 %.*s, mbtowc() %d", (int)ud->size, ud->data,
errno);