mirror of
https://github.com/tmux/tmux.git
synced 2024-11-16 17:39:09 +00:00
New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8; otherwise passed through).
This commit is contained in:
parent
1e06ec41dc
commit
28bcf774e5
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-option.c,v 1.60 2009-03-21 12:44:06 nicm Exp $ */
|
/* $OpenBSD: cmd-set-option.c,v 1.2 2009/06/03 16:54:26 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -73,6 +73,7 @@ const struct set_option_entry set_option_table[NSETOPTION] = {
|
|||||||
{ "status-left-length", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
{ "status-left-length", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
||||||
{ "status-right", SET_OPTION_STRING, 0, 0, NULL },
|
{ "status-right", SET_OPTION_STRING, 0, 0, NULL },
|
||||||
{ "status-right-length", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
{ "status-right-length", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
||||||
|
{ "status-utf8", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: screen-write.c,v 1.2 2009/06/03 16:05:46 nicm Exp $ */
|
/* $OpenBSD: screen-write.c,v 1.3 2009/06/03 16:54:26 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -53,8 +53,8 @@ screen_write_putc(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate string length. */
|
/* Calculate string length. */
|
||||||
size_t printflike1
|
size_t printflike2
|
||||||
screen_write_strlen(const char *fmt, ...)
|
screen_write_strlen(int utf8flag, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *msg;
|
char *msg;
|
||||||
@ -67,7 +67,7 @@ screen_write_strlen(const char *fmt, ...)
|
|||||||
|
|
||||||
ptr = msg;
|
ptr = msg;
|
||||||
while (*ptr != '\0') {
|
while (*ptr != '\0') {
|
||||||
if (*ptr > 0x7f) { /* Assume this is UTF-8. */
|
if (utf8flag && *ptr > 0x7f) {
|
||||||
memset(utf8buf, 0xff, sizeof utf8buf);
|
memset(utf8buf, 0xff, sizeof utf8buf);
|
||||||
|
|
||||||
left = strlen(ptr);
|
left = strlen(ptr);
|
||||||
@ -94,7 +94,7 @@ screen_write_strlen(const char *fmt, ...)
|
|||||||
return (size);
|
return (size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write string. */
|
/* Write simple string (no UTF-8 or maximum length). */
|
||||||
void printflike3
|
void printflike3
|
||||||
screen_write_puts(
|
screen_write_puts(
|
||||||
struct screen_write_ctx *ctx, struct grid_cell *gc, const char *fmt, ...)
|
struct screen_write_ctx *ctx, struct grid_cell *gc, const char *fmt, ...)
|
||||||
@ -102,25 +102,25 @@ screen_write_puts(
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
screen_write_vnputs(ctx, -1, gc, fmt, ap);
|
screen_write_vnputs(ctx, -1, gc, 0, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write string with length limit (-1 for unlimited). */
|
/* Write string with length limit (-1 for unlimited). */
|
||||||
void printflike4
|
void printflike5
|
||||||
screen_write_nputs(struct screen_write_ctx *ctx,
|
screen_write_nputs(struct screen_write_ctx *ctx,
|
||||||
ssize_t maxlen, struct grid_cell *gc, const char *fmt, ...)
|
ssize_t maxlen, struct grid_cell *gc, int utf8flag, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
screen_write_vnputs(ctx, maxlen, gc, fmt, ap);
|
screen_write_vnputs(ctx, maxlen, gc, utf8flag, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
screen_write_vnputs(struct screen_write_ctx *ctx,
|
screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
||||||
ssize_t maxlen, struct grid_cell *gc, const char *fmt, va_list ap)
|
struct grid_cell *gc, int utf8flag, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
char *msg;
|
char *msg;
|
||||||
u_char *ptr, utf8buf[4];
|
u_char *ptr, utf8buf[4];
|
||||||
@ -131,7 +131,7 @@ screen_write_vnputs(struct screen_write_ctx *ctx,
|
|||||||
|
|
||||||
ptr = msg;
|
ptr = msg;
|
||||||
while (*ptr != '\0') {
|
while (*ptr != '\0') {
|
||||||
if (*ptr > 0x7f) { /* Assume this is UTF-8. */
|
if (utf8flag && *ptr > 0x7f) {
|
||||||
memset(utf8buf, 0xff, sizeof utf8buf);
|
memset(utf8buf, 0xff, sizeof utf8buf);
|
||||||
|
|
||||||
left = strlen(ptr);
|
left = strlen(ptr);
|
||||||
|
17
status.c
17
status.c
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: status.c,v 1.2 2009/06/03 16:05:46 nicm Exp $ */
|
/* $OpenBSD: status.c,v 1.3 2009/06/03 16:54:26 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -50,7 +50,7 @@ status_redraw(struct client *c)
|
|||||||
size_t llen, llen2, rlen, rlen2, offset;
|
size_t llen, llen2, rlen, rlen2, offset;
|
||||||
size_t xx, yy, sy, size, start, width;
|
size_t xx, yy, sy, size, start, width;
|
||||||
struct grid_cell stdgc, gc;
|
struct grid_cell stdgc, gc;
|
||||||
int larrow, rarrow;
|
int larrow, rarrow, utf8flag;
|
||||||
|
|
||||||
left = right = NULL;
|
left = right = NULL;
|
||||||
|
|
||||||
@ -74,18 +74,21 @@ status_redraw(struct client *c)
|
|||||||
if (yy == 0)
|
if (yy == 0)
|
||||||
goto blank;
|
goto blank;
|
||||||
|
|
||||||
|
/* Caring about UTF-8 in status line? */
|
||||||
|
utf8flag = options_get_number(&s->options, "status-utf8");
|
||||||
|
|
||||||
/* Work out the left and right strings. */
|
/* Work out the left and right strings. */
|
||||||
left = status_replace(s, options_get_string(
|
left = status_replace(s, options_get_string(
|
||||||
&s->options, "status-left"), c->status_timer.tv_sec);
|
&s->options, "status-left"), c->status_timer.tv_sec);
|
||||||
llen = options_get_number(&s->options, "status-left-length");
|
llen = options_get_number(&s->options, "status-left-length");
|
||||||
llen2 = screen_write_strlen("%s", left);
|
llen2 = screen_write_strlen(utf8flag, "%s", left);
|
||||||
if (llen2 < llen)
|
if (llen2 < llen)
|
||||||
llen = llen2;
|
llen = llen2;
|
||||||
|
|
||||||
right = status_replace(s, options_get_string(
|
right = status_replace(s, options_get_string(
|
||||||
&s->options, "status-right"), c->status_timer.tv_sec);
|
&s->options, "status-right"), c->status_timer.tv_sec);
|
||||||
rlen = options_get_number(&s->options, "status-right-length");
|
rlen = options_get_number(&s->options, "status-right-length");
|
||||||
rlen2 = screen_write_strlen("%s", right);
|
rlen2 = screen_write_strlen(utf8flag, "%s", right);
|
||||||
if (rlen2 < rlen)
|
if (rlen2 < rlen)
|
||||||
rlen = rlen2;
|
rlen = rlen2;
|
||||||
right[rlen] = '\0';
|
right[rlen] = '\0';
|
||||||
@ -164,7 +167,8 @@ draw:
|
|||||||
screen_write_start(&ctx, NULL, &c->status);
|
screen_write_start(&ctx, NULL, &c->status);
|
||||||
if (llen != 0) {
|
if (llen != 0) {
|
||||||
screen_write_cursormove(&ctx, 0, yy);
|
screen_write_cursormove(&ctx, 0, yy);
|
||||||
screen_write_nputs(&ctx, llen + 1, &stdgc, "%s ", left);
|
screen_write_nputs(
|
||||||
|
&ctx, llen + 1, &stdgc, utf8flag, "%s ", left);
|
||||||
if (larrow)
|
if (larrow)
|
||||||
screen_write_putc(&ctx, &stdgc, ' ');
|
screen_write_putc(&ctx, &stdgc, ' ');
|
||||||
} else {
|
} else {
|
||||||
@ -221,7 +225,8 @@ draw:
|
|||||||
/* Draw the last item. */
|
/* Draw the last item. */
|
||||||
if (rlen != 0) {
|
if (rlen != 0) {
|
||||||
screen_write_cursormove(&ctx, c->tty.sx - rlen - 1, yy);
|
screen_write_cursormove(&ctx, c->tty.sx - rlen - 1, yy);
|
||||||
screen_write_nputs(&ctx, rlen + 1, &stdgc, " %s", right);
|
screen_write_nputs(
|
||||||
|
&ctx, rlen + 1, &stdgc, utf8flag, " %s", right);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw the arrows. */
|
/* Draw the arrows. */
|
||||||
|
2
tmux.1
2
tmux.1
@ -1,4 +1,4 @@
|
|||||||
.\" $Id: tmux.1,v 1.98 2009-06-25 15:30:29 nicm Exp $
|
.\" $OpenBSD: tmux.1,v 1.10 2009/06/03 16:54:26 nicm Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
.\"
|
.\"
|
||||||
|
3
tmux.c
3
tmux.c
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: tmux.c,v 1.4 2009/06/02 16:53:20 sobrado Exp $ */
|
/* $OpenBSD: tmux.c,v 1.5 2009/06/03 16:54:26 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -315,6 +315,7 @@ main(int argc, char **argv)
|
|||||||
options_set_string(&global_options, "status-left", "[#S]");
|
options_set_string(&global_options, "status-left", "[#S]");
|
||||||
options_set_string(
|
options_set_string(
|
||||||
&global_options, "status-right", "\"#24T\" %%H:%%M %%d-%%b-%%y");
|
&global_options, "status-right", "\"#24T\" %%H:%%M %%d-%%b-%%y");
|
||||||
|
options_set_number(&global_options, "status-utf8", 0);
|
||||||
|
|
||||||
options_init(&global_window_options, NULL);
|
options_init(&global_window_options, NULL);
|
||||||
options_set_number(&global_window_options, "aggressive-resize", 0);
|
options_set_number(&global_window_options, "aggressive-resize", 0);
|
||||||
|
13
tmux.h
13
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: tmux.h,v 1.3 2009/06/03 16:05:46 nicm Exp $ */
|
/* $OpenBSD: tmux.h,v 1.4 2009/06/03 16:54:26 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -138,6 +138,7 @@ extern const char *__progname;
|
|||||||
#define printflike2 __attribute__ ((format (printf, 2, 3)))
|
#define printflike2 __attribute__ ((format (printf, 2, 3)))
|
||||||
#define printflike3 __attribute__ ((format (printf, 3, 4)))
|
#define printflike3 __attribute__ ((format (printf, 3, 4)))
|
||||||
#define printflike4 __attribute__ ((format (printf, 4, 5)))
|
#define printflike4 __attribute__ ((format (printf, 4, 5)))
|
||||||
|
#define printflike5 __attribute__ ((format (printf, 5, 6)))
|
||||||
|
|
||||||
/* Number of items in array. */
|
/* Number of items in array. */
|
||||||
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
|
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
|
||||||
@ -997,7 +998,7 @@ struct set_option_entry {
|
|||||||
};
|
};
|
||||||
extern const struct set_option_entry set_option_table[];
|
extern const struct set_option_entry set_option_table[];
|
||||||
extern const struct set_option_entry set_window_option_table[];
|
extern const struct set_option_entry set_window_option_table[];
|
||||||
#define NSETOPTION 24
|
#define NSETOPTION 25
|
||||||
#define NSETWINDOWOPTION 19
|
#define NSETWINDOWOPTION 19
|
||||||
|
|
||||||
#ifndef HAVE_STRTONUM
|
#ifndef HAVE_STRTONUM
|
||||||
@ -1468,13 +1469,13 @@ void grid_view_delete_cells(struct grid *, u_int, u_int, u_int);
|
|||||||
void screen_write_start(
|
void screen_write_start(
|
||||||
struct screen_write_ctx *, struct window_pane *, struct screen *);
|
struct screen_write_ctx *, struct window_pane *, struct screen *);
|
||||||
void screen_write_stop(struct screen_write_ctx *);
|
void screen_write_stop(struct screen_write_ctx *);
|
||||||
size_t printflike1 screen_write_strlen(const char *, ...);
|
size_t printflike2 screen_write_strlen(int, const char *, ...);
|
||||||
void printflike3 screen_write_puts(struct screen_write_ctx *,
|
void printflike3 screen_write_puts(struct screen_write_ctx *,
|
||||||
struct grid_cell *, const char *, ...);
|
struct grid_cell *, const char *, ...);
|
||||||
void printflike4 screen_write_nputs(struct screen_write_ctx *,
|
void printflike5 screen_write_nputs(struct screen_write_ctx *,
|
||||||
ssize_t, struct grid_cell *, const char *, ...);
|
ssize_t, struct grid_cell *, int, const char *, ...);
|
||||||
void screen_write_vnputs(struct screen_write_ctx *,
|
void screen_write_vnputs(struct screen_write_ctx *,
|
||||||
ssize_t, struct grid_cell *, const char *, va_list);
|
ssize_t, struct grid_cell *, int, const char *, va_list);
|
||||||
void screen_write_putc(
|
void screen_write_putc(
|
||||||
struct screen_write_ctx *, struct grid_cell *, u_char);
|
struct screen_write_ctx *, struct grid_cell *, u_char);
|
||||||
void screen_write_copy(struct screen_write_ctx *,
|
void screen_write_copy(struct screen_write_ctx *,
|
||||||
|
Loading…
Reference in New Issue
Block a user