summaryrefslogtreecommitdiffstats
path: root/screen-write.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-06-03 16:54:26 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-06-03 16:54:26 +0000
commit6521427a451b4044b9bf035d54c594cb1453ba48 (patch)
treed29c21afa0abf27125edffe09df48653b55d9ccf /screen-write.c
parent7d45e29683119b31179295b3712142ebf8897a0d (diff)
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.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/screen-write.c b/screen-write.c
index d55a29a4..b57b0620 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -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);