diff options
author | Tiago Cunha <tcunha@gmx.com> | 2009-10-23 17:16:25 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2009-10-23 17:16:25 +0000 |
commit | f41a3914a55cd61223418a019cb23e6aee173098 (patch) | |
tree | 6be4c3c02ff9f53a4b84ec354b2cb084d38f827b /tmux.h | |
parent | c643ac48278b793d17d0e8edd140af6d9d68128a (diff) | |
download | rtmux-f41a3914a55cd61223418a019cb23e6aee173098.tar.gz rtmux-f41a3914a55cd61223418a019cb23e6aee173098.tar.bz2 rtmux-f41a3914a55cd61223418a019cb23e6aee173098.zip |
Sync OpenBSD patchset 421:
Try to reduce the UTF-8 mess.
Get rid of passing around u_char[4]s and define a struct utf8_data which has
character data, size (sequence length) and width. Move UTF-8 character
collection into two functions utf8_open/utf8_append in utf8.c which fill in
this struct and use these functions from input.c and the various functions in
screen-write.c.
Space for rather more data than is necessary for one UTF-8 sequence is in the
utf8_data struct because screen_write_copy is still nasty and needs to reinject
the character (after combining) into screen_write_cell.
Diffstat (limited to 'tmux.h')
-rw-r--r-- | tmux.h | 31 |
1 files changed, 23 insertions, 8 deletions
@@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.480 2009-10-23 17:13:10 tcunha Exp $ */ +/* $Id: tmux.h,v 1.481 2009-10-23 17:16:24 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -475,6 +475,23 @@ struct mode_key_table { #define MODE_KKEYPAD 0x8 #define MODE_MOUSE 0x10 +/* + * A single UTF-8 character. + * + * The data member in this must be UTF8_SIZE to allow screen_write_copy to + * reinject stored UTF-8 data back into screen_write_cell after combining (ugh + * XXX XXX). + */ +#define UTF8_SIZE 9 +struct utf8_data { + u_char data[UTF8_SIZE]; + + size_t have; + size_t size; + + u_int width; +}; + /* Grid output. */ #if defined(DEBUG) && \ ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ @@ -514,7 +531,6 @@ struct grid_cell { } __packed; /* Grid cell UTF-8 data. Used instead of data in grid_cell for UTF-8 cells. */ -#define UTF8_SIZE 9 struct grid_utf8 { u_char width; u_char data[UTF8_SIZE]; @@ -670,9 +686,7 @@ struct input_ctx { #define STRING_APPLICATION 1 #define STRING_NAME 2 - u_char utf8_buf[4]; - u_int utf8_len; - u_int utf8_off; + struct utf8_data utf8data; u_char intermediate; void *(*state)(u_char, struct input_ctx *); @@ -1680,8 +1694,8 @@ void screen_write_kkeypadmode(struct screen_write_ctx *, int); void screen_write_clearendofscreen(struct screen_write_ctx *); void screen_write_clearstartofscreen(struct screen_write_ctx *); void screen_write_clearscreen(struct screen_write_ctx *); -void screen_write_cell( - struct screen_write_ctx *, const struct grid_cell *, u_char *); +void screen_write_cell(struct screen_write_ctx *, + const struct grid_cell *, const struct utf8_data *); /* screen-redraw.c */ void screen_redraw_screen(struct client *, int); @@ -1836,7 +1850,8 @@ void session_group_synchronize1(struct session *, struct session *); /* utf8.c */ void utf8_build(void); -int utf8_width(const u_char *); +int utf8_open(struct utf8_data *, u_char); +int utf8_append(struct utf8_data *, u_char); /* osdep-*.c */ char *osdep_get_name(int, char *); |