diff -Naur links-2.1pre17-orig/charsets.c links-2.1pre17/charsets.c --- links-2.1pre17-orig/charsets.c 2005-01-02 17:17:25.000000000 -0300 +++ links-2.1pre17/charsets.c 2005-03-19 22:23:28.000000000 -0300 @@ -92,7 +92,7 @@ #define U_EQUAL(a, b) (a).x == (b) #define U_ABOVE(a, b) (a).x > (b) -static inline unsigned char *u2cp(int u, int to) +unsigned char *u2cp(int u, int to) { int j, s; if (u < 128) return strings[u]; @@ -152,6 +152,22 @@ return utf_buffer; } +/* this slow and ugly code is used by the terminal utf_8_io */ +unsigned char *cp2utf_8(int from, int c) +{ + int j; + + if (codepages[from].table == table_utf_8) return strings[c]; + for (j = 0; codepages[from].table[j].c; j++) { + if (codepages[from].table[j].c == c) + { + return encode_utf_8(codepages[from].table[j].u); + } + } + if (c < 128) return strings[c]; + return encode_utf_8(UCS_NO_CHAR); +} + void add_utf_8(struct conv_table *ct, int u, unsigned char *str) { unsigned char *p = encode_utf_8(u); diff -Naur links-2.1pre17-orig/default.c links-2.1pre17/default.c --- links-2.1pre17-orig/default.c 2005-01-22 17:51:53.000000000 -0300 +++ links-2.1pre17/default.c 2005-03-19 22:28:24.000000000 -0300 @@ -720,6 +720,7 @@ } } +/* terminal NAME(str) MODE(0-3) M11_HACK(0-1) BLOCK_CURSOR.RESTRICT_852.COL(0-7) CHARSET(str) [ UTF_8_IO("utf-8") ]*/ unsigned char *term_rd(struct option *o, unsigned char *c) { struct term_spec *ts; @@ -730,6 +731,7 @@ mem_free(w); goto end; } + ts->utf_8_io = 0; mem_free(w); if (!(w = get_token(&c))) goto err; if (strlen(w) != 1 || w[0] < '0' || w[0] > '4') goto err_f; @@ -750,6 +752,9 @@ if ((i = get_cp_index(w)) == -1 || is_cp_special(i)) goto err_f; ts->charset = i; mem_free(w); + if (!(w = get_token(&c))) goto end; + if (!(strcasecmp(w, "utf-8"))) ts->utf_8_io = 1; + mem_free(w); end: return NULL; err_f: @@ -758,6 +763,7 @@ return "Error reading terminal specification"; } +/* terminal2 NAME(str) MODE(0-3) M11_HACK(0-1) RESTRICT_852(0-1) COL(0-1) CHARSET(str) [ UTF_8_IO("utf-8") ]*/ unsigned char *term2_rd(struct option *o, unsigned char *c) { struct term_spec *ts; @@ -768,6 +774,7 @@ mem_free(w); goto end; } + ts->utf_8_io = 0; mem_free(w); if (!(w = get_token(&c))) goto err; if (strlen(w) != 1 || w[0] < '0' || w[0] > '3') goto err_f; @@ -789,6 +796,9 @@ if ((i = get_cp_index(w)) == -1 || is_cp_special(i)) goto err_f; ts->charset = i; mem_free(w); + if (!(w = get_token(&c))) goto end; + if (!(strcasecmp(w, "utf-8"))) ts->utf_8_io = 1; + mem_free(w); end: return NULL; err_f: @@ -811,6 +821,10 @@ add_num_to_str(s, l, !!ts->col + !!ts->restrict_852 * 2 + !!ts->block_cursor * 4); add_to_str(s, l, " "); add_to_str(s, l, get_cp_mime_name(ts->charset)); + if (ts->utf_8_io) + { + add_to_str(s, l, " utf-8"); + } } } diff -Naur links-2.1pre17-orig/intl/belarusian.lng links-2.1pre17/intl/belarusian.lng --- links-2.1pre17-orig/intl/belarusian.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/belarusian.lng 2005-03-19 22:31:22.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/brazilian_portuguese.lng links-2.1pre17/intl/brazilian_portuguese.lng --- links-2.1pre17-orig/intl/brazilian_portuguese.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/brazilian_portuguese.lng 2005-03-19 22:31:16.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/bulgarian.lng links-2.1pre17/intl/bulgarian.lng --- links-2.1pre17-orig/intl/bulgarian.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/bulgarian.lng 2005-03-19 22:31:08.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/catalan.lng links-2.1pre17/intl/catalan.lng --- links-2.1pre17-orig/intl/catalan.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/catalan.lng 2005-03-19 22:31:00.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/croatian.lng links-2.1pre17/intl/croatian.lng --- links-2.1pre17-orig/intl/croatian.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/croatian.lng 2005-03-19 22:31:47.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/czech.lng links-2.1pre17/intl/czech.lng --- links-2.1pre17-orig/intl/czech.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/czech.lng 2005-03-19 22:31:58.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, "C", T_HK_BLOCK_URL, "B", T_HK_BLOCK_LIST, "B", +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/danish.lng links-2.1pre17/intl/danish.lng --- links-2.1pre17-orig/intl/danish.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/danish.lng 2005-03-19 22:32:13.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/dutch.lng links-2.1pre17/intl/dutch.lng --- links-2.1pre17-orig/intl/dutch.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/dutch.lng 2005-03-19 22:32:17.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/english.lng links-2.1pre17/intl/english.lng --- links-2.1pre17-orig/intl/english.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/english.lng 2005-03-19 22:33:32.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, "C", T_HK_BLOCK_URL, "B", T_HK_BLOCK_LIST, "B", +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/estonian.lng links-2.1pre17/intl/estonian.lng --- links-2.1pre17-orig/intl/estonian.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/estonian.lng 2005-03-19 22:33:38.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/finnish.lng links-2.1pre17/intl/finnish.lng --- links-2.1pre17-orig/intl/finnish.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/finnish.lng 2005-03-19 22:35:22.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, "U", T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/french.lng links-2.1pre17/intl/french.lng --- links-2.1pre17-orig/intl/french.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/french.lng 2005-03-19 22:35:18.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/galician.lng links-2.1pre17/intl/galician.lng --- links-2.1pre17-orig/intl/galician.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/galician.lng 2005-03-19 22:35:14.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/german.lng links-2.1pre17/intl/german.lng --- links-2.1pre17-orig/intl/german.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/german.lng 2005-03-19 22:35:05.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, "U", T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/greek.lng links-2.1pre17/intl/greek.lng --- links-2.1pre17-orig/intl/greek.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/greek.lng 2005-03-19 22:35:02.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/hungarian.lng links-2.1pre17/intl/hungarian.lng --- links-2.1pre17-orig/intl/hungarian.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/hungarian.lng 2005-03-19 22:34:59.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/icelandic.lng links-2.1pre17/intl/icelandic.lng --- links-2.1pre17-orig/intl/icelandic.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/icelandic.lng 2005-03-19 22:34:55.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/indonesian.lng links-2.1pre17/intl/indonesian.lng --- links-2.1pre17-orig/intl/indonesian.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/indonesian.lng 2005-03-19 22:34:49.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/italian.lng links-2.1pre17/intl/italian.lng --- links-2.1pre17-orig/intl/italian.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/italian.lng 2005-03-19 22:34:43.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/lithuanian.lng links-2.1pre17/intl/lithuanian.lng --- links-2.1pre17-orig/intl/lithuanian.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/lithuanian.lng 2005-03-19 22:34:39.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/norwegian.lng links-2.1pre17/intl/norwegian.lng --- links-2.1pre17-orig/intl/norwegian.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/norwegian.lng 2005-03-19 22:34:36.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/polish.lng links-2.1pre17/intl/polish.lng --- links-2.1pre17-orig/intl/polish.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/polish.lng 2005-03-19 22:34:32.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/portuguese.lng links-2.1pre17/intl/portuguese.lng --- links-2.1pre17-orig/intl/portuguese.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/portuguese.lng 2005-03-19 22:34:28.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/romanian.lng links-2.1pre17/intl/romanian.lng --- links-2.1pre17-orig/intl/romanian.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/romanian.lng 2005-03-19 22:34:24.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/russian.lng links-2.1pre17/intl/russian.lng --- links-2.1pre17-orig/intl/russian.lng 2005-02-24 13:18:04.000000000 -0300 +++ links-2.1pre17/intl/russian.lng 2005-03-19 22:34:21.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/serbian.lng links-2.1pre17/intl/serbian.lng --- links-2.1pre17-orig/intl/serbian.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/serbian.lng 2005-03-19 22:34:17.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, "â", T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/slovak.lng links-2.1pre17/intl/slovak.lng --- links-2.1pre17-orig/intl/slovak.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/slovak.lng 2005-03-19 22:34:14.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/spanish.lng links-2.1pre17/intl/spanish.lng --- links-2.1pre17-orig/intl/spanish.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/spanish.lng 2005-03-19 22:34:10.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/swedish.lng links-2.1pre17/intl/swedish.lng --- links-2.1pre17-orig/intl/swedish.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/swedish.lng 2005-03-19 22:34:07.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/turkish.lng links-2.1pre17/intl/turkish.lng --- links-2.1pre17-orig/intl/turkish.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/turkish.lng 2005-03-19 22:33:59.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/ukrainian.lng links-2.1pre17/intl/ukrainian.lng --- links-2.1pre17-orig/intl/ukrainian.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/ukrainian.lng 2005-03-19 22:33:55.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/intl/upper_sorbian.lng links-2.1pre17/intl/upper_sorbian.lng --- links-2.1pre17-orig/intl/upper_sorbian.lng 2005-01-22 17:51:58.000000000 -0300 +++ links-2.1pre17/intl/upper_sorbian.lng 2005-03-19 22:33:52.000000000 -0300 @@ -506,3 +506,4 @@ T_HK_COPY_URL_LOCATION, NULL, T_HK_BLOCK_URL, NULL, T_HK_BLOCK_LIST, NULL, +T_UTF_8_IO, "UTF-8 I/O", diff -Naur links-2.1pre17-orig/links.h links-2.1pre17/links.h --- links-2.1pre17-orig/links.h 2005-02-24 13:17:58.000000000 -0300 +++ links-2.1pre17/links.h 2005-03-19 22:38:41.000000000 -0300 @@ -1840,6 +1840,11 @@ #ifdef G struct graphics_device *dev; #endif + struct { + int ucs; + int len; + int min; + } utf_8; }; struct term_spec { @@ -1848,6 +1853,7 @@ unsigned char term[MAX_TERM_LEN]; int mode; int m11_hack; + int utf_8_io; int restrict_852; int block_cursor; int col; @@ -3337,6 +3343,9 @@ /* charsets.c */ +/* UCS/Unicode replacement character */ +#define UCS_NO_CHAR 0xFFFD + #include "codepage.h" extern int utf8_table; @@ -3359,6 +3368,8 @@ void free_conv_table(void); unsigned char *encode_utf_8(int); int cp2u(unsigned char, int); +unsigned char *cp2utf_8(int, int); +unsigned char *u2cp(int, int); #ifdef G int get_utf_8(unsigned char **p); diff -Naur links-2.1pre17-orig/menu.c links-2.1pre17/menu.c --- links-2.1pre17-orig/menu.c 2005-01-22 17:51:55.000000000 -0300 +++ links-2.1pre17/menu.c 2005-03-19 22:44:36.000000000 -0300 @@ -534,14 +534,14 @@ cls_redraw_all_terminals(); } -unsigned char *td_labels[] = { TEXT(T_NO_FRAMES), TEXT(T_VT_100_FRAMES), TEXT(T_LINUX_OR_OS2_FRAMES), TEXT(T_KOI8R_FRAMES), TEXT(T_FREEBSD_FRAMES), TEXT(T_USE_11M), TEXT(T_RESTRICT_FRAMES_IN_CP850_852), TEXT(T_BLOCK_CURSOR), TEXT(T_COLOR), TEXT(T_BRAILLE_TERMINAL), NULL }; +unsigned char *td_labels[] = { TEXT(T_NO_FRAMES), TEXT(T_VT_100_FRAMES), TEXT(T_LINUX_OR_OS2_FRAMES), TEXT(T_KOI8R_FRAMES), TEXT(T_FREEBSD_FRAMES), TEXT(T_USE_11M), TEXT(T_RESTRICT_FRAMES_IN_CP850_852), TEXT(T_BLOCK_CURSOR), TEXT(T_COLOR), TEXT(T_BRAILLE_TERMINAL), TEXT(T_UTF_8_IO), NULL }; void terminal_options(struct terminal *term, void *xxx, struct session *ses) { struct dialog *d; struct term_spec *ts = new_term_spec(term->term); if (!ts) return; - d = mem_calloc(sizeof(struct dialog) + 12 * sizeof(struct dialog_item)); + d = mem_calloc(sizeof(struct dialog) + 14 * sizeof(struct dialog_item)); d->title = TEXT(T_TERMINAL_OPTIONS); d->fn = checkbox_list_fn; d->udata = td_labels; @@ -591,15 +591,19 @@ d->items[9].gid = 0; d->items[9].dlen = sizeof(int); d->items[9].data = (void *)&ts->braille; - d->items[10].type = D_BUTTON; - d->items[10].gid = B_ENTER; - d->items[10].fn = ok_dialog; - d->items[10].text = TEXT(T_OK); + d->items[10].type = D_CHECKBOX; + d->items[10].gid = 0; + d->items[10].dlen = sizeof(int); + d->items[10].data = (void *)&ts->utf_8_io; d->items[11].type = D_BUTTON; - d->items[11].gid = B_ESC; - d->items[11].fn = cancel_dialog; - d->items[11].text = TEXT(T_CANCEL); - d->items[12].type = D_END; + d->items[11].gid = B_ENTER; + d->items[11].fn = ok_dialog; + d->items[11].text = TEXT(T_OK); + d->items[12].type = D_BUTTON; + d->items[12].gid = B_ESC; + d->items[12].fn = cancel_dialog; + d->items[12].text = TEXT(T_CANCEL); + d->items[13].type = D_END; do_dialog(term, d, getml(d, NULL)); } diff -Naur links-2.1pre17-orig/terminal.c links-2.1pre17/terminal.c --- links-2.1pre17-orig/terminal.c 2005-01-02 17:17:26.000000000 -0300 +++ links-2.1pre17/terminal.c 2005-03-19 22:50:18.000000000 -0300 @@ -690,6 +690,25 @@ #endif +static inline void term_send_event(struct terminal *term, struct event *ev) +{ + ((struct window *)&term->windows)->next->handler(term->windows.next, ev, 0); +} + +static inline void term_send_ucs(struct terminal *term, struct event *ev, int u) +{ + unsigned char *recoded; + + if (u == 0xA0) u = ' '; + recoded = u2cp(u, term->spec->charset); + if (! recoded) recoded = "*"; + while (*recoded) { + ev->x = *recoded; + term_send_event(term, ev); + recoded ++; + } +} + void in_term(struct terminal *term) { struct event *ev; @@ -749,7 +768,40 @@ goto send_redraw; } else if (ev->ev == EV_KBD && ev->x == KBD_CTRL_C) ((struct window *)&term->windows)->prev->handler(term->windows.prev, ev, 0); - else ((struct window *)&term->windows)->next->handler(term->windows.next, ev, 0); + else if (ev->ev == EV_KBD) { + if (term->utf_8.len) { + if ((ev->x & 0xC0) == 0x80 && term->spec->utf_8_io) { + term->utf_8.ucs <<= 6; + term->utf_8.ucs |= ev->x & 0x3F; + if (! --term->utf_8.len) { + int u = term->utf_8.ucs; + + if (u < term->utf_8.min) u = UCS_NO_CHAR; + term_send_ucs(term, ev, u); + } + goto mm; + } else { + term->utf_8.len = 0; + term_send_ucs(term, ev, UCS_NO_CHAR); + } + } + if (ev->x < 0x80 || ev->x > 0xFF || ! term->spec->utf_8_io) { + term_send_event(term, ev); + goto mm; + } else if ((ev->x & 0xC0) == 0xC0 && (ev->x & 0xFE) != 0xFE) { + int mask, len = 0, cov = 0x80; + + for (mask = 0x80; ev->x & mask; mask >>= 1) { + len++; + term->utf_8.min = cov; + cov = 1 << (1 + 5 * len); + } + term->utf_8.len = len - 1; + term->utf_8.ucs = ev->x & (mask - 1); + goto mm; + } + term_send_ucs(term, ev, UCS_NO_CHAR); + } else term_send_event(term, ev); } if (ev->ev == EV_ABORT) { destroy_terminal(term); @@ -769,6 +821,14 @@ unsigned char frame_dumb[48] = " ||||++||++++++--|-+||++--|-+----++++++++ "; unsigned char frame_vt100[48] = "aaaxuuukkuxkjjjkmvwtqnttmlvwtqnvvwwmmllnnjla "; +unsigned char frame_vt100_u[48] = { + 177,177,177,179,180,180,180,191, + 191,180,179,191,217,217,217,191, + 192,193,194,195,196,197,195,195, + 192,218,193,194,195,196,197,193, + 193,194,194,192,192,218,218,197, + 197,217,218,177, 32, 32, 32, 32 +}; unsigned char frame_koi[48] = { 144,145,146,129,135,178,180,167, 166,181,161,168,174,173,172,131, @@ -800,7 +860,7 @@ unsigned char c = ch & 0xff; \ unsigned char A = ch >> 8 & 0x7f; \ if (s->mode == TERM_LINUX) { \ - if (s->m11_hack) { \ + if (s->m11_hack && !s->utf_8_io) { \ if ((int)(ch >> 15) != mode) { \ if (!(mode = ch >> 15)) add_to_str(&a, &l, "\033[10m"); \ else add_to_str(&a, &l, "\033[11m"); \ @@ -809,12 +869,14 @@ if (s->restrict_852 && (ch >> 15) && c >= 176 && c < 224) { \ if (frame_restrict[c - 176]) c = frame_restrict[c - 176]; \ } \ - } else if (s->mode == TERM_VT100) { \ + } else if (s->mode == TERM_VT100 && !s->utf_8_io) { \ if ((int)(ch >> 15) != mode) { \ if (!(mode = ch >> 15)) add_to_str(&a, &l, "\x0f"); \ else add_to_str(&a, &l, "\x0e"); \ } \ if (mode && c >= 176 && c < 224) c = frame_vt100[c - 176]; \ + } else if (s->mode == TERM_VT100 && (ch >> 15) && c >= 176 && c < 224) { \ + c = frame_vt100_u[c - 176]; \ } else if (s->mode == TERM_KOI8 && (ch >> 15) && c >= 176 && c < 224) { c = frame_koi[c - 176];\ } else if (s->mode == TERM_FREEBSD && (ch >> 15) && c >= 176 && c < 224) { c = frame_freebsd[c - 176];\ } else if (s->mode == TERM_DUMB && (ch >> 15) && c >= 176 && c < 224) c = frame_dumb[c - 176];\ @@ -835,7 +897,20 @@ if (attrib & 0100) add_to_str(&a, &l, ";1"); \ add_to_str(&a, &l, "m"); \ } \ - if (c >= ' ' && c != 127/* && c != 155*/) add_chr_to_str(&a, &l, c); \ + if (c >= ' ' && c != 127/* && c != 155*/) { \ + int charset = s->charset; \ + \ + if (ch >> 15) { \ + int frames_charset = (s->mode == TERM_LINUX || s->mode == TERM_VT100) \ + ? get_cp_index("cp437") \ + : s->mode == TERM_KOI8 \ + ? get_cp_index("koi8-r") \ + : -1; \ + if (frames_charset != -1) charset = frames_charset; \ + } \ + if (s->utf_8_io) add_to_str(&a, &l, cp2utf_8(charset, c)); \ + else add_chr_to_str(&a, &l, c); \ + } \ else if (!c || c == 1) add_chr_to_str(&a, &l, ' '); \ else add_chr_to_str(&a, &l, '.'); \ cx++; \