diff --git a/src/config/options.inc b/src/config/options.inc index cfbedc85..f01be47b 100644 --- a/src/config/options.inc +++ b/src/config/options.inc @@ -816,6 +816,27 @@ static struct option_info config_options_info[] = { "_template_", 0, N_("Options specific to this terminal type (according to $TERM value).")), + /* TODO: Incorporate some of the following to the option text. + * + * When UTF-8 I/O is disabled: + * 0 (TERM_DUMB) outputs ASCII -+| characters. + * 1 (TERM_VT100) switches charsets with ^N and ^O. + * 2 (TERM_LINUX) outputs CP437 characters without switching + * charsets, so it works correctly only if the terminal uses + * CP437. Can also be made CP850 and CP852 compatible with + * the restrict_852 option. + * 3 (TERM_KOI8) outputs KOI8-R characters without switching + * charsets, so it works correctly only if the terminal uses + * KOI8-R and the user has selected either KOI8-R or ASCII + * in ELinks. It is also mostly compatible with KOI8-U. + * 4 (TERM_FREEBSD) outputs characters in the 0x80...0x9F + * range, which FreeBSD 4.0 (but not 5.0) treated as + * graphical. + * + * When UTF-8 I/O is enabled, ELinks outputs (almost) the same + * characters as above but encodes them in UTF-8 and does not + * switch charsets. So, it will work in any terminal that + * understands UTF-8 and has the characters in its font. */ INIT_OPT_INT("terminal._template_", N_("Type"), "type", 0, 0, 4, 0, N_("Terminal type; matters mostly only when drawing frames and\n" @@ -829,8 +850,8 @@ static struct option_info config_options_info[] = { INIT_OPT_BOOL("terminal._template_", N_("Switch fonts for line drawing"), "m11_hack", 0, 0, N_("Switch fonts when drawing lines, enabling both local characters\n" - "and lines working at the same time. Makes sense only with linux\n" - "terminal.")), + "and lines working at the same time. ELinks uses this option only if\n" + "UTF-8 I/O is disabled and the terminal type is Linux or FreeBSD.")), /* When CONFIG_UTF8 is defined, any code that reads the "utf_8_io" * option should also check whether the "codepage" option is UTF-8, diff --git a/src/terminal/screen.c b/src/terminal/screen.c index a8bc6d0d..dcb1aae1 100644 --- a/src/terminal/screen.c +++ b/src/terminal/screen.c @@ -31,7 +31,7 @@ const unsigned char frame_dumb[48] = " ||||++||++++++--|-+||++--|-+----++++++++ "; static const unsigned char frame_vt100[48] = "aaaxuuukkuxkjjjkmvwtqnttmlvwtqnvvwwmmllnnjla "; -/* For UTF8 I/O */ +/* For UTF-8 I/O */ static const unsigned char frame_vt100_u[48] = { 177, 177, 177, 179, 180, 180, 180, 191, 191, 180, 179, 191, 217, 217, 217, 191, @@ -136,6 +136,9 @@ static const unsigned char frame_restrict[48] = { #define add_term_string(str, tstr) \ add_bytes_to_string(str, (tstr).source, (tstr).length) +/* ECMA-48: CSI Ps... 06/13 = SGR - SELECT GRAPHIC RENDITION + * Ps = 10 = primary (default) font + * Ps = 11 = first alternative font */ static const struct string m11_hack_frame_seqs[] = { /* end border: */ TERM_STRING("\033[10m"), /* begin border: */ TERM_STRING("\033[11m"), @@ -165,7 +168,7 @@ struct screen_driver { struct screen_driver_opt { /* Charsets when doing UTF8 I/O. */ /* [0] is the common charset and [1] is the frame charset. - * Test whether to use UTF8 I/O using the use_utf8_io() macro. */ + * Test whether to use UTF8 I/O using the use_utf8_io() macro. */ int charsets[2]; /* The frame translation table. May be NULL. */ @@ -203,7 +206,7 @@ static const struct screen_driver_opt dumb_screen_driver_opt = { /* color_mode: */ COLOR_MODE_16, /* transparent: */ 1, #ifdef CONFIG_UTF8 - /* utf8: */ 0, + /* utf8_cp: */ 0, #endif /* CONFIG_UTF8 */ }; @@ -215,7 +218,7 @@ static const struct screen_driver_opt vt100_screen_driver_opt = { /* color_mode: */ COLOR_MODE_16, /* transparent: */ 1, #ifdef CONFIG_UTF8 - /* utf8: */ 0, + /* utf8_cp: */ 0, #endif /* CONFIG_UTF8 */ }; @@ -227,7 +230,7 @@ static const struct screen_driver_opt linux_screen_driver_opt = { /* color_mode: */ COLOR_MODE_16, /* transparent: */ 1, #ifdef CONFIG_UTF8 - /* utf8: */ 0, + /* utf8_cp: */ 0, #endif /* CONFIG_UTF8 */ }; @@ -239,7 +242,7 @@ static const struct screen_driver_opt koi8_screen_driver_opt = { /* color_mode: */ COLOR_MODE_16, /* transparent: */ 1, #ifdef CONFIG_UTF8 - /* utf8: */ 0, + /* utf8_cp: */ 0, #endif /* CONFIG_UTF8 */ }; @@ -251,7 +254,7 @@ static const struct screen_driver_opt freebsd_screen_driver_opt = { /* color_mode: */ COLOR_MODE_16, /* transparent: */ 1, #ifdef CONFIG_UTF8 - /* utf8: */ 0, + /* utf8_cp: */ 0, #endif /* CONFIG_UTF8 */ }; @@ -269,7 +272,10 @@ static const struct screen_driver_opt *const screen_driver_opts[] = { static INIT_LIST_HEAD(active_screen_drivers); /* Set driver->opt according to driver->type and term_spec. - * Other members of *driver need not have been initialized. */ + * Other members of *driver need not have been initialized. + * + * If you modify anything here, check whether option descriptions + * should be updated. */ static void set_screen_driver_opt(struct screen_driver *driver, struct option *term_spec) { @@ -393,8 +399,8 @@ add_screen_driver(enum term_mode_type type, struct terminal *term, int env_len) term->spec->change_hook = screen_driver_change_hook; #ifdef CONFIG_UTF8 - term->utf8_io = use_utf8_io(driver); term->utf8_cp = driver->opt.utf8_cp; + term->utf8_io = use_utf8_io(driver); #endif /* CONFIG_UTF8 */ return driver; @@ -416,8 +422,8 @@ get_screen_driver(struct terminal *term) move_to_top_of_list(active_screen_drivers, driver); #ifdef CONFIG_UTF8 - term->utf8_io = use_utf8_io(driver); term->utf8_cp = driver->opt.utf8_cp; + term->utf8_io = use_utf8_io(driver); #endif /* CONFIG_UTF8 */ return driver; }