mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside it is always UTF-8 (as when the utf8 and status-utf8 options were on).
This commit is contained in:
		@@ -51,7 +51,6 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
			
		||||
	char				*action, *action_data;
 | 
			
		||||
	const char			*template;
 | 
			
		||||
	u_int				 idx;
 | 
			
		||||
	int				 utf8flag;
 | 
			
		||||
 | 
			
		||||
	if ((c = cmd_find_client(cmdq, NULL, 1)) == NULL) {
 | 
			
		||||
		cmdq_error(cmdq, "no client available");
 | 
			
		||||
@@ -63,7 +62,6 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
			
		||||
 | 
			
		||||
	if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
 | 
			
		||||
		return (CMD_RETURN_ERROR);
 | 
			
		||||
	utf8flag = options_get_number(wl->window->options, "utf8");
 | 
			
		||||
 | 
			
		||||
	if (paste_get_top(NULL) == NULL)
 | 
			
		||||
		return (CMD_RETURN_NORMAL);
 | 
			
		||||
@@ -83,7 +81,7 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
			
		||||
		cdata->idx = idx;
 | 
			
		||||
 | 
			
		||||
		cdata->ft_template = xstrdup(template);
 | 
			
		||||
		format_defaults_paste_buffer(cdata->ft, pb, utf8flag);
 | 
			
		||||
		format_defaults_paste_buffer(cdata->ft, pb);
 | 
			
		||||
 | 
			
		||||
		xasprintf(&action_data, "%s", paste_buffer_name(pb));
 | 
			
		||||
		cdata->command = cmd_template_replace(action, action_data, 1);
 | 
			
		||||
 
 | 
			
		||||
@@ -55,7 +55,7 @@ cmd_list_buffers_exec(unused struct cmd *self, struct cmd_q *cmdq)
 | 
			
		||||
	pb = NULL;
 | 
			
		||||
	while ((pb = paste_walk(pb)) != NULL) {
 | 
			
		||||
		ft = format_create();
 | 
			
		||||
		format_defaults_paste_buffer(ft, pb, 0);
 | 
			
		||||
		format_defaults_paste_buffer(ft, pb);
 | 
			
		||||
 | 
			
		||||
		line = format_expand(ft, template);
 | 
			
		||||
		cmdq_print(cmdq, "%s", line);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								format.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								format.c
									
									
									
									
									
								
							@@ -1144,8 +1144,7 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
 | 
			
		||||
 | 
			
		||||
/* Set default format keys for paste buffer. */
 | 
			
		||||
void
 | 
			
		||||
format_defaults_paste_buffer(struct format_tree *ft, struct paste_buffer *pb,
 | 
			
		||||
    int utf8flag)
 | 
			
		||||
format_defaults_paste_buffer(struct format_tree *ft, struct paste_buffer *pb)
 | 
			
		||||
{
 | 
			
		||||
	size_t	 bufsize;
 | 
			
		||||
	char	*s;
 | 
			
		||||
@@ -1154,7 +1153,7 @@ format_defaults_paste_buffer(struct format_tree *ft, struct paste_buffer *pb,
 | 
			
		||||
	format_add(ft, "buffer_size", "%zu", bufsize);
 | 
			
		||||
	format_add(ft, "buffer_name", "%s", paste_buffer_name(pb));
 | 
			
		||||
 | 
			
		||||
	s = paste_make_sample(pb, utf8flag);
 | 
			
		||||
	s = paste_make_sample(pb);
 | 
			
		||||
	format_add(ft, "buffer_sample", "%s", s);
 | 
			
		||||
	free(s);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								input.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								input.c
									
									
									
									
									
								
							@@ -1921,11 +1921,6 @@ input_exit_rename(struct input_ctx *ictx)
 | 
			
		||||
int
 | 
			
		||||
input_utf8_open(struct input_ctx *ictx)
 | 
			
		||||
{
 | 
			
		||||
	if (!options_get_number(ictx->wp->window->options, "utf8")) {
 | 
			
		||||
		/* Print, and do not switch state. */
 | 
			
		||||
		input_print(ictx);
 | 
			
		||||
		return (-1);
 | 
			
		||||
	}
 | 
			
		||||
	log_debug("%s", __func__);
 | 
			
		||||
 | 
			
		||||
	utf8_open(&ictx->utf8data, ictx->ch);
 | 
			
		||||
 
 | 
			
		||||
@@ -416,11 +416,6 @@ const struct options_table_entry session_options_table[] = {
 | 
			
		||||
	  .default_str = "bg=green,fg=black"
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	{ .name = "status-utf8",
 | 
			
		||||
	  .type = OPTIONS_TABLE_FLAG,
 | 
			
		||||
	  .default_num = 0 /* overridden in main() */
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	{ .name = "update-environment",
 | 
			
		||||
	  .type = OPTIONS_TABLE_STRING,
 | 
			
		||||
	  .default_str = "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID "
 | 
			
		||||
@@ -624,11 +619,6 @@ const struct options_table_entry window_options_table[] = {
 | 
			
		||||
	  .default_num = 0
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	{ .name = "utf8",
 | 
			
		||||
	  .type = OPTIONS_TABLE_FLAG,
 | 
			
		||||
	  .default_num = 0 /* overridden in main() */
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	{ .name = "window-active-style",
 | 
			
		||||
	  .type = OPTIONS_TABLE_STYLE,
 | 
			
		||||
	  .default_str = "default"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										7
									
								
								paste.c
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								paste.c
									
									
									
									
									
								
							@@ -275,7 +275,7 @@ paste_set(char *data, size_t size, const char *name, char **cause)
 | 
			
		||||
 | 
			
		||||
/* Convert start of buffer into a nice string. */
 | 
			
		||||
char *
 | 
			
		||||
paste_make_sample(struct paste_buffer *pb, int utf8flag)
 | 
			
		||||
paste_make_sample(struct paste_buffer *pb)
 | 
			
		||||
{
 | 
			
		||||
	char		*buf;
 | 
			
		||||
	size_t		 len, used;
 | 
			
		||||
@@ -287,10 +287,7 @@ paste_make_sample(struct paste_buffer *pb, int utf8flag)
 | 
			
		||||
		len = width;
 | 
			
		||||
	buf = xreallocarray(NULL, len, 4 + 4);
 | 
			
		||||
 | 
			
		||||
	if (utf8flag)
 | 
			
		||||
		used = utf8_strvis(buf, pb->data, len, flags);
 | 
			
		||||
	else
 | 
			
		||||
		used = strvisx(buf, pb->data, len, flags);
 | 
			
		||||
	used = utf8_strvis(buf, pb->data, len, flags);
 | 
			
		||||
	if (pb->size > width || used > width)
 | 
			
		||||
		strlcpy(buf + width, "...", 4);
 | 
			
		||||
	return (buf);
 | 
			
		||||
 
 | 
			
		||||
@@ -73,7 +73,7 @@ screen_write_putc(struct screen_write_ctx *ctx, struct grid_cell *gc,
 | 
			
		||||
 | 
			
		||||
/* Calculate string length, with embedded formatting. */
 | 
			
		||||
size_t
 | 
			
		||||
screen_write_cstrlen(int utf8flag, const char *fmt, ...)
 | 
			
		||||
screen_write_cstrlen(const char *fmt, ...)
 | 
			
		||||
{
 | 
			
		||||
	va_list	ap;
 | 
			
		||||
	char   *msg, *msg2, *ptr, *ptr2;
 | 
			
		||||
@@ -98,7 +98,7 @@ screen_write_cstrlen(int utf8flag, const char *fmt, ...)
 | 
			
		||||
	}
 | 
			
		||||
	*ptr2 = '\0';
 | 
			
		||||
 | 
			
		||||
	size = screen_write_strlen(utf8flag, "%s", msg2);
 | 
			
		||||
	size = screen_write_strlen("%s", msg2);
 | 
			
		||||
 | 
			
		||||
	free(msg);
 | 
			
		||||
	free(msg2);
 | 
			
		||||
@@ -108,7 +108,7 @@ screen_write_cstrlen(int utf8flag, const char *fmt, ...)
 | 
			
		||||
 | 
			
		||||
/* Calculate string length. */
 | 
			
		||||
size_t
 | 
			
		||||
screen_write_strlen(int utf8flag, const char *fmt, ...)
 | 
			
		||||
screen_write_strlen(const char *fmt, ...)
 | 
			
		||||
{
 | 
			
		||||
	va_list			ap;
 | 
			
		||||
	char   	       	       *msg;
 | 
			
		||||
@@ -122,7 +122,7 @@ screen_write_strlen(int utf8flag, const char *fmt, ...)
 | 
			
		||||
 | 
			
		||||
	ptr = msg;
 | 
			
		||||
	while (*ptr != '\0') {
 | 
			
		||||
		if (utf8flag && *ptr > 0x7f && utf8_open(&utf8data, *ptr)) {
 | 
			
		||||
		if (*ptr > 0x7f && utf8_open(&utf8data, *ptr)) {
 | 
			
		||||
			ptr++;
 | 
			
		||||
 | 
			
		||||
			left = strlen(ptr);
 | 
			
		||||
@@ -134,7 +134,8 @@ screen_write_strlen(int utf8flag, const char *fmt, ...)
 | 
			
		||||
 | 
			
		||||
			size += utf8data.width;
 | 
			
		||||
		} else {
 | 
			
		||||
			size++;
 | 
			
		||||
			if (*ptr > 0x1f && *ptr < 0x7f)
 | 
			
		||||
				size++;
 | 
			
		||||
			ptr++;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -151,25 +152,25 @@ screen_write_puts(struct screen_write_ctx *ctx, struct grid_cell *gc,
 | 
			
		||||
	va_list	ap;
 | 
			
		||||
 | 
			
		||||
	va_start(ap, fmt);
 | 
			
		||||
	screen_write_vnputs(ctx, -1, gc, 0, fmt, ap);
 | 
			
		||||
	screen_write_vnputs(ctx, -1, gc, fmt, ap);
 | 
			
		||||
	va_end(ap);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Write string with length limit (-1 for unlimited). */
 | 
			
		||||
void
 | 
			
		||||
screen_write_nputs(struct screen_write_ctx *ctx, ssize_t maxlen,
 | 
			
		||||
    struct grid_cell *gc, int utf8flag, const char *fmt, ...)
 | 
			
		||||
    struct grid_cell *gc, const char *fmt, ...)
 | 
			
		||||
{
 | 
			
		||||
	va_list	ap;
 | 
			
		||||
 | 
			
		||||
	va_start(ap, fmt);
 | 
			
		||||
	screen_write_vnputs(ctx, maxlen, gc, utf8flag, fmt, ap);
 | 
			
		||||
	screen_write_vnputs(ctx, maxlen, gc, fmt, ap);
 | 
			
		||||
	va_end(ap);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
 | 
			
		||||
    struct grid_cell *gc, int utf8flag, const char *fmt, va_list ap)
 | 
			
		||||
    struct grid_cell *gc, const char *fmt, va_list ap)
 | 
			
		||||
{
 | 
			
		||||
	char   		       *msg;
 | 
			
		||||
	struct utf8_data	utf8data;
 | 
			
		||||
@@ -180,7 +181,7 @@ screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
 | 
			
		||||
 | 
			
		||||
	ptr = msg;
 | 
			
		||||
	while (*ptr != '\0') {
 | 
			
		||||
		if (utf8flag && *ptr > 0x7f && utf8_open(&utf8data, *ptr)) {
 | 
			
		||||
		if (*ptr > 0x7f && utf8_open(&utf8data, *ptr)) {
 | 
			
		||||
			ptr++;
 | 
			
		||||
 | 
			
		||||
			left = strlen(ptr);
 | 
			
		||||
@@ -208,7 +209,7 @@ screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
 | 
			
		||||
 | 
			
		||||
			if (*ptr == '\001')
 | 
			
		||||
				gc->attr ^= GRID_ATTR_CHARSET;
 | 
			
		||||
			else {
 | 
			
		||||
			else if (*ptr > 0x1f && *ptr < 0x7f) {
 | 
			
		||||
				size++;
 | 
			
		||||
				screen_write_putc(ctx, gc, *ptr);
 | 
			
		||||
			}
 | 
			
		||||
@@ -221,8 +222,8 @@ screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
 | 
			
		||||
 | 
			
		||||
/* Write string, similar to nputs, but with embedded formatting (#[]). */
 | 
			
		||||
void
 | 
			
		||||
screen_write_cnputs(struct screen_write_ctx *ctx,
 | 
			
		||||
    ssize_t maxlen, struct grid_cell *gc, int utf8flag, const char *fmt, ...)
 | 
			
		||||
screen_write_cnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
 | 
			
		||||
    struct grid_cell *gc, const char *fmt, ...)
 | 
			
		||||
{
 | 
			
		||||
	struct grid_cell	 lgc;
 | 
			
		||||
	struct utf8_data	 utf8data;
 | 
			
		||||
@@ -253,7 +254,7 @@ screen_write_cnputs(struct screen_write_ctx *ctx,
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (utf8flag && *ptr > 0x7f && utf8_open(&utf8data, *ptr)) {
 | 
			
		||||
		if (*ptr > 0x7f && utf8_open(&utf8data, *ptr)) {
 | 
			
		||||
			ptr++;
 | 
			
		||||
 | 
			
		||||
			left = strlen(ptr);
 | 
			
		||||
@@ -279,8 +280,10 @@ screen_write_cnputs(struct screen_write_ctx *ctx,
 | 
			
		||||
			if (maxlen > 0 && size + 1 > (size_t) maxlen)
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
			size++;
 | 
			
		||||
			screen_write_putc(ctx, &lgc, *ptr);
 | 
			
		||||
			if (*ptr > 0x1f && *ptr < 0x7f) {
 | 
			
		||||
				size++;
 | 
			
		||||
				screen_write_putc(ctx, &lgc, *ptr);
 | 
			
		||||
			}
 | 
			
		||||
			ptr++;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										62
									
								
								status.c
									
									
									
									
									
								
							
							
						
						
									
										62
									
								
								status.c
									
									
									
									
									
								
							@@ -29,10 +29,10 @@
 | 
			
		||||
 | 
			
		||||
#include "tmux.h"
 | 
			
		||||
 | 
			
		||||
char   *status_redraw_get_left(struct client *, time_t, int, struct grid_cell *,
 | 
			
		||||
char   *status_redraw_get_left(struct client *, time_t, struct grid_cell *,
 | 
			
		||||
	    size_t *);
 | 
			
		||||
char   *status_redraw_get_right(struct client *, time_t, struct grid_cell *,
 | 
			
		||||
	    size_t *);
 | 
			
		||||
char   *status_redraw_get_right(struct client *, time_t, int,
 | 
			
		||||
	    struct grid_cell *, size_t *);
 | 
			
		||||
char   *status_print(struct client *, struct winlink *, time_t,
 | 
			
		||||
	    struct grid_cell *);
 | 
			
		||||
char   *status_replace(struct client *, struct winlink *, const char *, time_t);
 | 
			
		||||
@@ -208,8 +208,8 @@ status_at_line(struct client *c)
 | 
			
		||||
 | 
			
		||||
/* Retrieve options for left string. */
 | 
			
		||||
char *
 | 
			
		||||
status_redraw_get_left(struct client *c, time_t t, int utf8flag,
 | 
			
		||||
    struct grid_cell *gc, size_t *size)
 | 
			
		||||
status_redraw_get_left(struct client *c, time_t t, struct grid_cell *gc,
 | 
			
		||||
    size_t *size)
 | 
			
		||||
{
 | 
			
		||||
	struct session	*s = c->session;
 | 
			
		||||
	const char	*template;
 | 
			
		||||
@@ -222,7 +222,7 @@ status_redraw_get_left(struct client *c, time_t t, int utf8flag,
 | 
			
		||||
	left = status_replace(c, NULL, template, t);
 | 
			
		||||
 | 
			
		||||
	*size = options_get_number(s->options, "status-left-length");
 | 
			
		||||
	leftlen = screen_write_cstrlen(utf8flag, "%s", left);
 | 
			
		||||
	leftlen = screen_write_cstrlen("%s", left);
 | 
			
		||||
	if (leftlen < *size)
 | 
			
		||||
		*size = leftlen;
 | 
			
		||||
	return (left);
 | 
			
		||||
@@ -230,8 +230,8 @@ status_redraw_get_left(struct client *c, time_t t, int utf8flag,
 | 
			
		||||
 | 
			
		||||
/* Retrieve options for right string. */
 | 
			
		||||
char *
 | 
			
		||||
status_redraw_get_right(struct client *c, time_t t, int utf8flag,
 | 
			
		||||
    struct grid_cell *gc, size_t *size)
 | 
			
		||||
status_redraw_get_right(struct client *c, time_t t, struct grid_cell *gc,
 | 
			
		||||
    size_t *size)
 | 
			
		||||
{
 | 
			
		||||
	struct session	*s = c->session;
 | 
			
		||||
	const char	*template;
 | 
			
		||||
@@ -244,7 +244,7 @@ status_redraw_get_right(struct client *c, time_t t, int utf8flag,
 | 
			
		||||
	right = status_replace(c, NULL, template, t);
 | 
			
		||||
 | 
			
		||||
	*size = options_get_number(s->options, "status-right-length");
 | 
			
		||||
	rightlen = screen_write_cstrlen(utf8flag, "%s", right);
 | 
			
		||||
	rightlen = screen_write_cstrlen("%s", right);
 | 
			
		||||
	if (rightlen < *size)
 | 
			
		||||
		*size = rightlen;
 | 
			
		||||
	return (right);
 | 
			
		||||
@@ -286,7 +286,7 @@ status_redraw(struct client *c)
 | 
			
		||||
	u_int			offset, needed;
 | 
			
		||||
	u_int			wlstart, wlwidth, wlavailable, wloffset, wlsize;
 | 
			
		||||
	size_t			llen, rlen, seplen;
 | 
			
		||||
	int			larrow, rarrow, utf8flag;
 | 
			
		||||
	int			larrow, rarrow;
 | 
			
		||||
 | 
			
		||||
	/* No status line? */
 | 
			
		||||
	if (c->tty.sy == 0 || !options_get_number(s->options, "status"))
 | 
			
		||||
@@ -312,14 +312,11 @@ status_redraw(struct client *c)
 | 
			
		||||
	if (c->tty.sy <= 1)
 | 
			
		||||
		goto out;
 | 
			
		||||
 | 
			
		||||
	/* Get UTF-8 flag. */
 | 
			
		||||
	utf8flag = options_get_number(s->options, "status-utf8");
 | 
			
		||||
 | 
			
		||||
	/* Work out left and right strings. */
 | 
			
		||||
	memcpy(&lgc, &stdgc, sizeof lgc);
 | 
			
		||||
	left = status_redraw_get_left(c, t, utf8flag, &lgc, &llen);
 | 
			
		||||
	left = status_redraw_get_left(c, t, &lgc, &llen);
 | 
			
		||||
	memcpy(&rgc, &stdgc, sizeof rgc);
 | 
			
		||||
	right = status_redraw_get_right(c, t, utf8flag, &rgc, &rlen);
 | 
			
		||||
	right = status_redraw_get_right(c, t, &rgc, &rlen);
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Figure out how much space we have for the window list. If there
 | 
			
		||||
@@ -340,15 +337,14 @@ status_redraw(struct client *c)
 | 
			
		||||
		free(wl->status_text);
 | 
			
		||||
		memcpy(&wl->status_cell, &stdgc, sizeof wl->status_cell);
 | 
			
		||||
		wl->status_text = status_print(c, wl, t, &wl->status_cell);
 | 
			
		||||
		wl->status_width =
 | 
			
		||||
		    screen_write_cstrlen(utf8flag, "%s", wl->status_text);
 | 
			
		||||
		wl->status_width = screen_write_cstrlen("%s", wl->status_text);
 | 
			
		||||
 | 
			
		||||
		if (wl == s->curw)
 | 
			
		||||
			wloffset = wlwidth;
 | 
			
		||||
 | 
			
		||||
		oo = wl->window->options;
 | 
			
		||||
		sep = options_get_string(oo, "window-status-separator");
 | 
			
		||||
		seplen = screen_write_strlen(utf8flag, "%s", sep);
 | 
			
		||||
		seplen = screen_write_strlen("%s", sep);
 | 
			
		||||
		wlwidth += wl->status_width + seplen;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -358,12 +354,12 @@ status_redraw(struct client *c)
 | 
			
		||||
	/* And draw the window list into it. */
 | 
			
		||||
	screen_write_start(&ctx, NULL, &window_list);
 | 
			
		||||
	RB_FOREACH(wl, winlinks, &s->windows) {
 | 
			
		||||
		screen_write_cnputs(&ctx,
 | 
			
		||||
		    -1, &wl->status_cell, utf8flag, "%s", wl->status_text);
 | 
			
		||||
		screen_write_cnputs(&ctx, -1, &wl->status_cell, "%s",
 | 
			
		||||
		    wl->status_text);
 | 
			
		||||
 | 
			
		||||
		oo = wl->window->options;
 | 
			
		||||
		sep = options_get_string(oo, "window-status-separator");
 | 
			
		||||
		screen_write_nputs(&ctx, -1, &stdgc, utf8flag, "%s", sep);
 | 
			
		||||
		screen_write_nputs(&ctx, -1, &stdgc, "%s", sep);
 | 
			
		||||
	}
 | 
			
		||||
	screen_write_stop(&ctx);
 | 
			
		||||
 | 
			
		||||
@@ -435,7 +431,7 @@ draw:
 | 
			
		||||
	/* Draw the left string and arrow. */
 | 
			
		||||
	screen_write_cursormove(&ctx, 0, 0);
 | 
			
		||||
	if (llen != 0)
 | 
			
		||||
		screen_write_cnputs(&ctx, llen, &lgc, utf8flag, "%s", left);
 | 
			
		||||
		screen_write_cnputs(&ctx, llen, &lgc, "%s", left);
 | 
			
		||||
	if (larrow != 0) {
 | 
			
		||||
		memcpy(&gc, &stdgc, sizeof gc);
 | 
			
		||||
		if (larrow == -1)
 | 
			
		||||
@@ -453,7 +449,7 @@ draw:
 | 
			
		||||
	} else
 | 
			
		||||
		screen_write_cursormove(&ctx, c->tty.sx - rlen, 0);
 | 
			
		||||
	if (rlen != 0)
 | 
			
		||||
		screen_write_cnputs(&ctx, rlen, &rgc, utf8flag, "%s", right);
 | 
			
		||||
		screen_write_cnputs(&ctx, rlen, &rgc, "%s", right);
 | 
			
		||||
 | 
			
		||||
	/* Figure out the offset for the window list. */
 | 
			
		||||
	if (llen != 0)
 | 
			
		||||
@@ -624,16 +620,13 @@ status_message_redraw(struct client *c)
 | 
			
		||||
	struct screen		        old_status;
 | 
			
		||||
	size_t			        len;
 | 
			
		||||
	struct grid_cell		gc;
 | 
			
		||||
	int				utf8flag;
 | 
			
		||||
 | 
			
		||||
	if (c->tty.sx == 0 || c->tty.sy == 0)
 | 
			
		||||
		return (0);
 | 
			
		||||
	memcpy(&old_status, &c->status, sizeof old_status);
 | 
			
		||||
	screen_init(&c->status, c->tty.sx, 1, 0);
 | 
			
		||||
 | 
			
		||||
	utf8flag = options_get_number(s->options, "status-utf8");
 | 
			
		||||
 | 
			
		||||
	len = screen_write_strlen(utf8flag, "%s", c->message_string);
 | 
			
		||||
	len = screen_write_strlen("%s", c->message_string);
 | 
			
		||||
	if (len > c->tty.sx)
 | 
			
		||||
		len = c->tty.sx;
 | 
			
		||||
 | 
			
		||||
@@ -642,7 +635,7 @@ status_message_redraw(struct client *c)
 | 
			
		||||
	screen_write_start(&ctx, NULL, &c->status);
 | 
			
		||||
 | 
			
		||||
	screen_write_cursormove(&ctx, 0, 0);
 | 
			
		||||
	screen_write_nputs(&ctx, len, &gc, utf8flag, "%s", c->message_string);
 | 
			
		||||
	screen_write_nputs(&ctx, len, &gc, "%s", c->message_string);
 | 
			
		||||
	for (; len < c->tty.sx; len++)
 | 
			
		||||
		screen_write_putc(&ctx, &gc, ' ');
 | 
			
		||||
 | 
			
		||||
@@ -754,16 +747,13 @@ status_prompt_redraw(struct client *c)
 | 
			
		||||
	struct screen		        old_status;
 | 
			
		||||
	size_t			        i, size, left, len, off;
 | 
			
		||||
	struct grid_cell		gc, *gcp;
 | 
			
		||||
	int				utf8flag;
 | 
			
		||||
 | 
			
		||||
	if (c->tty.sx == 0 || c->tty.sy == 0)
 | 
			
		||||
		return (0);
 | 
			
		||||
	memcpy(&old_status, &c->status, sizeof old_status);
 | 
			
		||||
	screen_init(&c->status, c->tty.sx, 1, 0);
 | 
			
		||||
 | 
			
		||||
	utf8flag = options_get_number(s->options, "status-utf8");
 | 
			
		||||
 | 
			
		||||
	len = screen_write_strlen(utf8flag, "%s", c->prompt_string);
 | 
			
		||||
	len = screen_write_strlen("%s", c->prompt_string);
 | 
			
		||||
	if (len > c->tty.sx)
 | 
			
		||||
		len = c->tty.sx;
 | 
			
		||||
	off = 0;
 | 
			
		||||
@@ -777,19 +767,19 @@ status_prompt_redraw(struct client *c)
 | 
			
		||||
	screen_write_start(&ctx, NULL, &c->status);
 | 
			
		||||
 | 
			
		||||
	screen_write_cursormove(&ctx, 0, 0);
 | 
			
		||||
	screen_write_nputs(&ctx, len, &gc, utf8flag, "%s", c->prompt_string);
 | 
			
		||||
	screen_write_nputs(&ctx, len, &gc, "%s", c->prompt_string);
 | 
			
		||||
 | 
			
		||||
	left = c->tty.sx - len;
 | 
			
		||||
	if (left != 0) {
 | 
			
		||||
		size = screen_write_strlen(utf8flag, "%s", c->prompt_buffer);
 | 
			
		||||
		size = screen_write_strlen("%s", c->prompt_buffer);
 | 
			
		||||
		if (c->prompt_index >= left) {
 | 
			
		||||
			off = c->prompt_index - left + 1;
 | 
			
		||||
			if (c->prompt_index == size)
 | 
			
		||||
				left--;
 | 
			
		||||
			size = left;
 | 
			
		||||
		}
 | 
			
		||||
		screen_write_nputs(
 | 
			
		||||
		    &ctx, left, &gc, utf8flag, "%s", c->prompt_buffer + off);
 | 
			
		||||
		screen_write_nputs(&ctx, left, &gc, "%s", c->prompt_buffer +
 | 
			
		||||
		    off);
 | 
			
		||||
 | 
			
		||||
		for (i = len + size; i < c->tty.sx; i++)
 | 
			
		||||
			screen_write_putc(&ctx, &gc, ' ');
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										40
									
								
								tmux.1
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								tmux.1
									
									
									
									
									
								
							@@ -190,13 +190,11 @@ flag explicitly informs
 | 
			
		||||
.Nm
 | 
			
		||||
that UTF-8 is supported.
 | 
			
		||||
.Pp
 | 
			
		||||
If the server is started from a client passed
 | 
			
		||||
.Fl u
 | 
			
		||||
or where UTF-8 is detected, the
 | 
			
		||||
.Ic utf8
 | 
			
		||||
and
 | 
			
		||||
.Ic status-utf8
 | 
			
		||||
options are enabled in the global window and session options respectively.
 | 
			
		||||
Note that
 | 
			
		||||
.Nm
 | 
			
		||||
itself always accepts UTF-8, this controls whether it will send UTF-8
 | 
			
		||||
characters to the terminal it is running it (if not, they are replaced by
 | 
			
		||||
.Ql _ ) .
 | 
			
		||||
.It Fl v
 | 
			
		||||
Request verbose logging.
 | 
			
		||||
This option may be specified multiple times for increasing verbosity.
 | 
			
		||||
@@ -2770,12 +2768,6 @@ Examples are:
 | 
			
		||||
#[fg=yellow,bold]#(apm -l)%%#[default] [#S]
 | 
			
		||||
.Ed
 | 
			
		||||
.Pp
 | 
			
		||||
By default, UTF-8 in
 | 
			
		||||
.Ar string
 | 
			
		||||
is not interpreted, to enable UTF-8, use the
 | 
			
		||||
.Ic status-utf8
 | 
			
		||||
option.
 | 
			
		||||
.Pp
 | 
			
		||||
The default is
 | 
			
		||||
.Ql "[#S] " .
 | 
			
		||||
.It Ic status-left-length Ar length
 | 
			
		||||
@@ -2805,9 +2797,7 @@ As with
 | 
			
		||||
.Ar string
 | 
			
		||||
will be passed to
 | 
			
		||||
.Xr strftime 3 ,
 | 
			
		||||
character pairs are replaced, and UTF-8 is dependent on the
 | 
			
		||||
.Ic status-utf8
 | 
			
		||||
option.
 | 
			
		||||
character pairs are replaced.
 | 
			
		||||
.It Ic status-right-length Ar length
 | 
			
		||||
Set the maximum
 | 
			
		||||
.Ar length
 | 
			
		||||
@@ -2827,17 +2817,6 @@ For how to specify
 | 
			
		||||
see the
 | 
			
		||||
.Ic message-command-style
 | 
			
		||||
option.
 | 
			
		||||
.It Xo Ic status-utf8
 | 
			
		||||
.Op Ic on | off
 | 
			
		||||
.Xc
 | 
			
		||||
Instruct
 | 
			
		||||
.Nm
 | 
			
		||||
to treat top-bit-set characters in the
 | 
			
		||||
.Ic status-left
 | 
			
		||||
and
 | 
			
		||||
.Ic status-right
 | 
			
		||||
strings as UTF-8; notably, this is important for wide characters.
 | 
			
		||||
This option defaults to off.
 | 
			
		||||
.It Ic update-environment Ar variables
 | 
			
		||||
Set a space-separated string containing a list of environment variables to be
 | 
			
		||||
copied into the session environment when a new session is created or an
 | 
			
		||||
@@ -3084,13 +3063,6 @@ command.
 | 
			
		||||
Duplicate input to any pane to all other panes in the same window (only
 | 
			
		||||
for panes that are not in any special mode).
 | 
			
		||||
.Pp
 | 
			
		||||
.It Xo Ic utf8
 | 
			
		||||
.Op Ic on | off
 | 
			
		||||
.Xc
 | 
			
		||||
Instructs
 | 
			
		||||
.Nm
 | 
			
		||||
to expect UTF-8 sequences to appear in this window.
 | 
			
		||||
.Pp
 | 
			
		||||
.It Ic window-active-style Ar style
 | 
			
		||||
Set the style for the window's active pane.
 | 
			
		||||
For how to specify
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								tmux.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								tmux.c
									
									
									
									
									
								
							@@ -291,12 +291,6 @@ main(int argc, char **argv)
 | 
			
		||||
	global_w_options = options_create(NULL);
 | 
			
		||||
	options_table_populate_tree(window_options_table, global_w_options);
 | 
			
		||||
 | 
			
		||||
	/* Enable UTF-8 if the first client is on UTF-8 terminal. */
 | 
			
		||||
	if (flags & CLIENT_UTF8) {
 | 
			
		||||
		options_set_number(global_s_options, "status-utf8", 1);
 | 
			
		||||
		options_set_number(global_w_options, "utf8", 1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Override keys to vi if VISUAL or EDITOR are set. */
 | 
			
		||||
	if ((s = getenv("VISUAL")) != NULL || (s = getenv("EDITOR")) != NULL) {
 | 
			
		||||
		if (strrchr(s, '/') != NULL)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										32
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1456,7 +1456,7 @@ void		 paste_free(struct paste_buffer *);
 | 
			
		||||
void		 paste_add(char *, size_t);
 | 
			
		||||
int		 paste_rename(const char *, const char *, char **);
 | 
			
		||||
int		 paste_set(char *, size_t, const char *, char **);
 | 
			
		||||
char		*paste_make_sample(struct paste_buffer *, int);
 | 
			
		||||
char		*paste_make_sample(struct paste_buffer *);
 | 
			
		||||
 | 
			
		||||
/* format.c */
 | 
			
		||||
#define FORMAT_STATUS 0x1
 | 
			
		||||
@@ -1475,7 +1475,7 @@ void		 format_defaults_window(struct format_tree *, struct window *);
 | 
			
		||||
void		 format_defaults_pane(struct format_tree *,
 | 
			
		||||
		     struct window_pane *);
 | 
			
		||||
void		 format_defaults_paste_buffer(struct format_tree *,
 | 
			
		||||
		     struct paste_buffer *, int);
 | 
			
		||||
		     struct paste_buffer *);
 | 
			
		||||
 | 
			
		||||
/* mode-key.c */
 | 
			
		||||
extern const struct mode_key_table mode_key_tables[];
 | 
			
		||||
@@ -1892,24 +1892,24 @@ void	 grid_view_delete_cells(struct grid *, u_int, u_int, u_int);
 | 
			
		||||
char	*grid_view_string_cells(struct grid *, u_int, u_int, u_int);
 | 
			
		||||
 | 
			
		||||
/* screen-write.c */
 | 
			
		||||
void	 screen_write_start(
 | 
			
		||||
	     struct screen_write_ctx *, struct window_pane *, struct screen *);
 | 
			
		||||
void	 screen_write_start(struct screen_write_ctx *, struct window_pane *,
 | 
			
		||||
	     struct screen *);
 | 
			
		||||
void	 screen_write_stop(struct screen_write_ctx *);
 | 
			
		||||
void	 screen_write_reset(struct screen_write_ctx *);
 | 
			
		||||
size_t printflike(2, 3) screen_write_cstrlen(int, const char *, ...);
 | 
			
		||||
void printflike(5, 6) screen_write_cnputs(struct screen_write_ctx *,
 | 
			
		||||
	     ssize_t, struct grid_cell *, int, const char *, ...);
 | 
			
		||||
size_t printflike(2, 3) screen_write_strlen(int, const char *, ...);
 | 
			
		||||
size_t printflike(1, 2) screen_write_cstrlen(const char *, ...);
 | 
			
		||||
void printflike(4, 5) screen_write_cnputs(struct screen_write_ctx *,
 | 
			
		||||
	     ssize_t, struct grid_cell *, const char *, ...);
 | 
			
		||||
size_t printflike(1, 2) screen_write_strlen(const char *, ...);
 | 
			
		||||
void printflike(3, 4) screen_write_puts(struct screen_write_ctx *,
 | 
			
		||||
	     struct grid_cell *, const char *, ...);
 | 
			
		||||
void printflike(5, 6) screen_write_nputs(struct screen_write_ctx *,
 | 
			
		||||
	     ssize_t, struct grid_cell *, int, const char *, ...);
 | 
			
		||||
void	 screen_write_vnputs(struct screen_write_ctx *,
 | 
			
		||||
	     ssize_t, struct grid_cell *, int, const char *, va_list);
 | 
			
		||||
void	 screen_write_putc(
 | 
			
		||||
	     struct screen_write_ctx *, struct grid_cell *, u_char);
 | 
			
		||||
void	 screen_write_copy(struct screen_write_ctx *,
 | 
			
		||||
	     struct screen *, u_int, u_int, u_int, u_int);
 | 
			
		||||
void printflike(4, 5) screen_write_nputs(struct screen_write_ctx *,
 | 
			
		||||
	     ssize_t, struct grid_cell *, const char *, ...);
 | 
			
		||||
void	 screen_write_vnputs(struct screen_write_ctx *, ssize_t,
 | 
			
		||||
	     struct grid_cell *, const char *, va_list);
 | 
			
		||||
void	 screen_write_putc(struct screen_write_ctx *, struct grid_cell *,
 | 
			
		||||
	     u_char);
 | 
			
		||||
void	 screen_write_copy(struct screen_write_ctx *, struct screen *, u_int,
 | 
			
		||||
	     u_int, u_int, u_int);
 | 
			
		||||
void	 screen_write_backspace(struct screen_write_ctx *);
 | 
			
		||||
void	 screen_write_mode_set(struct screen_write_ctx *, int);
 | 
			
		||||
void	 screen_write_mode_clear(struct screen_write_ctx *, int);
 | 
			
		||||
 
 | 
			
		||||
@@ -754,13 +754,12 @@ window_choose_write_line(struct window_pane *wp, struct screen_write_ctx *ctx,
 | 
			
		||||
	struct grid_cell		 gc;
 | 
			
		||||
	size_t				 last, xoff = 0;
 | 
			
		||||
	char				 hdr[32], label[32];
 | 
			
		||||
	int				 utf8flag, key;
 | 
			
		||||
	int				 key;
 | 
			
		||||
 | 
			
		||||
	if (data->callbackfn == NULL)
 | 
			
		||||
		fatalx("called before callback assigned");
 | 
			
		||||
 | 
			
		||||
	last = screen_size_y(s) - 1;
 | 
			
		||||
	utf8flag = options_get_number(wp->window->options, "utf8");
 | 
			
		||||
	memcpy(&gc, &grid_default_cell, sizeof gc);
 | 
			
		||||
	if (data->selected == data->top + py)
 | 
			
		||||
		style_apply(&gc, oo, "mode-style");
 | 
			
		||||
@@ -777,7 +776,7 @@ window_choose_write_line(struct window_pane *wp, struct screen_write_ctx *ctx,
 | 
			
		||||
			xsnprintf(label, sizeof label, "(%c)", key);
 | 
			
		||||
		else
 | 
			
		||||
			xsnprintf(label, sizeof label, "(%d)", item->pos);
 | 
			
		||||
		screen_write_nputs(ctx, screen_size_x(s) - 1, &gc, utf8flag,
 | 
			
		||||
		screen_write_nputs(ctx, screen_size_x(s) - 1, &gc,
 | 
			
		||||
		    "%*s %s %s", data->width + 2, label,
 | 
			
		||||
		    /*
 | 
			
		||||
		     * Add indication to tree if necessary about whether it's
 | 
			
		||||
 
 | 
			
		||||
@@ -280,13 +280,11 @@ window_copy_vadd(struct window_pane *wp, const char *fmt, va_list ap)
 | 
			
		||||
	struct screen			*backing = data->backing;
 | 
			
		||||
	struct screen_write_ctx	 	 back_ctx, ctx;
 | 
			
		||||
	struct grid_cell		 gc;
 | 
			
		||||
	int				 utf8flag;
 | 
			
		||||
	u_int				 old_hsize, old_cy;
 | 
			
		||||
 | 
			
		||||
	if (backing == &wp->base)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	utf8flag = options_get_number(wp->window->options, "utf8");
 | 
			
		||||
	memcpy(&gc, &grid_default_cell, sizeof gc);
 | 
			
		||||
 | 
			
		||||
	old_hsize = screen_hsize(data->backing);
 | 
			
		||||
@@ -301,7 +299,7 @@ window_copy_vadd(struct window_pane *wp, const char *fmt, va_list ap)
 | 
			
		||||
	} else
 | 
			
		||||
		data->backing_written = 1;
 | 
			
		||||
	old_cy = backing->cy;
 | 
			
		||||
	screen_write_vnputs(&back_ctx, 0, &gc, utf8flag, fmt, ap);
 | 
			
		||||
	screen_write_vnputs(&back_ctx, 0, &gc, fmt, ap);
 | 
			
		||||
	screen_write_stop(&back_ctx);
 | 
			
		||||
 | 
			
		||||
	data->oy += screen_hsize(data->backing) - old_hsize;
 | 
			
		||||
@@ -1021,19 +1019,18 @@ window_copy_search_up(struct window_pane *wp, const char *searchstr)
 | 
			
		||||
	struct grid_cell	 	 gc;
 | 
			
		||||
	size_t				 searchlen;
 | 
			
		||||
	u_int				 i, last, fx, fy, px;
 | 
			
		||||
	int				 utf8flag, n, wrapped, wrapflag, cis;
 | 
			
		||||
	int				 n, wrapped, wrapflag, cis;
 | 
			
		||||
	const char			*ptr;
 | 
			
		||||
 | 
			
		||||
	if (*searchstr == '\0')
 | 
			
		||||
		return;
 | 
			
		||||
	utf8flag = options_get_number(wp->window->options, "utf8");
 | 
			
		||||
	wrapflag = options_get_number(wp->window->options, "wrap-search");
 | 
			
		||||
	searchlen = screen_write_strlen(utf8flag, "%s", searchstr);
 | 
			
		||||
	searchlen = screen_write_strlen("%s", searchstr);
 | 
			
		||||
 | 
			
		||||
	screen_init(&ss, searchlen, 1, 0);
 | 
			
		||||
	screen_write_start(&ctx, NULL, &ss);
 | 
			
		||||
	memcpy(&gc, &grid_default_cell, sizeof gc);
 | 
			
		||||
	screen_write_nputs(&ctx, -1, &gc, utf8flag, "%s", searchstr);
 | 
			
		||||
	screen_write_nputs(&ctx, -1, &gc, "%s", searchstr);
 | 
			
		||||
	screen_write_stop(&ctx);
 | 
			
		||||
 | 
			
		||||
	fx = data->cx;
 | 
			
		||||
@@ -1088,19 +1085,18 @@ window_copy_search_down(struct window_pane *wp, const char *searchstr)
 | 
			
		||||
	struct grid_cell	 	 gc;
 | 
			
		||||
	size_t				 searchlen;
 | 
			
		||||
	u_int				 i, first, fx, fy, px;
 | 
			
		||||
	int				 utf8flag, n, wrapped, wrapflag, cis;
 | 
			
		||||
	int				 n, wrapped, wrapflag, cis;
 | 
			
		||||
	const char			*ptr;
 | 
			
		||||
 | 
			
		||||
	if (*searchstr == '\0')
 | 
			
		||||
		return;
 | 
			
		||||
	utf8flag = options_get_number(wp->window->options, "utf8");
 | 
			
		||||
	wrapflag = options_get_number(wp->window->options, "wrap-search");
 | 
			
		||||
	searchlen = screen_write_strlen(utf8flag, "%s", searchstr);
 | 
			
		||||
	searchlen = screen_write_strlen("%s", searchstr);
 | 
			
		||||
 | 
			
		||||
	screen_init(&ss, searchlen, 1, 0);
 | 
			
		||||
	screen_write_start(&ctx, NULL, &ss);
 | 
			
		||||
	memcpy(&gc, &grid_default_cell, sizeof gc);
 | 
			
		||||
	screen_write_nputs(&ctx, -1, &gc, utf8flag, "%s", searchstr);
 | 
			
		||||
	screen_write_nputs(&ctx, -1, &gc, "%s", searchstr);
 | 
			
		||||
	screen_write_stop(&ctx);
 | 
			
		||||
 | 
			
		||||
	fx = data->cx;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user