diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-06-25 15:48:25 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-06-25 15:48:25 +0000 |
commit | 28bcf774e5cc13a1a7ab84b0c217c7286b179ea3 (patch) | |
tree | 264795ba6c54a95ca0bfeb09e5a2aa5f3dcfe4de /screen-write.c | |
parent | 1e06ec41dc0bc9e99674d11ad3c810b579450e12 (diff) | |
download | rtmux-28bcf774e5cc13a1a7ab84b0c217c7286b179ea3.tar.gz rtmux-28bcf774e5cc13a1a7ab84b0c217c7286b179ea3.tar.bz2 rtmux-28bcf774e5cc13a1a7ab84b0c217c7286b179ea3.zip |
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).
Diffstat (limited to 'screen-write.c')
-rw-r--r-- | screen-write.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/screen-write.c b/screen-write.c index 08156d54..118a6bad 100644 --- a/screen-write.c +++ b/screen-write.c @@ -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> @@ -53,8 +53,8 @@ screen_write_putc( } /* Calculate string length. */ -size_t printflike1 -screen_write_strlen(const char *fmt, ...) +size_t printflike2 +screen_write_strlen(int utf8flag, const char *fmt, ...) { va_list ap; char *msg; @@ -67,7 +67,7 @@ screen_write_strlen(const char *fmt, ...) ptr = msg; while (*ptr != '\0') { - if (*ptr > 0x7f) { /* Assume this is UTF-8. */ + if (utf8flag && *ptr > 0x7f) { memset(utf8buf, 0xff, sizeof utf8buf); left = strlen(ptr); @@ -94,7 +94,7 @@ screen_write_strlen(const char *fmt, ...) return (size); } -/* Write string. */ +/* Write simple string (no UTF-8 or maximum length). */ void printflike3 screen_write_puts( struct screen_write_ctx *ctx, struct grid_cell *gc, const char *fmt, ...) @@ -102,25 +102,25 @@ screen_write_puts( va_list ap; va_start(ap, fmt); - screen_write_vnputs(ctx, -1, gc, fmt, ap); + screen_write_vnputs(ctx, -1, gc, 0, fmt, ap); va_end(ap); } /* Write string with length limit (-1 for unlimited). */ -void printflike4 +void printflike5 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_start(ap, fmt); - screen_write_vnputs(ctx, maxlen, gc, fmt, ap); + screen_write_vnputs(ctx, maxlen, gc, utf8flag, fmt, ap); va_end(ap); } void -screen_write_vnputs(struct screen_write_ctx *ctx, - ssize_t maxlen, struct grid_cell *gc, const char *fmt, va_list ap) +screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen, + struct grid_cell *gc, int utf8flag, const char *fmt, va_list ap) { char *msg; u_char *ptr, utf8buf[4]; @@ -131,7 +131,7 @@ screen_write_vnputs(struct screen_write_ctx *ctx, ptr = msg; while (*ptr != '\0') { - if (*ptr > 0x7f) { /* Assume this is UTF-8. */ + if (utf8flag && *ptr > 0x7f) { memset(utf8buf, 0xff, sizeof utf8buf); left = strlen(ptr); |