1 commit e23a8ec12164af00922751aea0dfa285d3e240b4
2 Author: Witold Filipczyk <witekfl@poczta.onet.pl>
3 Date: Fri Mar 27 19:44:46 2009 +0100
7 fbterm uses different 256 color sequences than xterm.
8 color256_seqs are part of the driver info.
10 diff --git a/src/config/options.c b/src/config/options.c
11 index 14ab8db..00c9a25 100644
12 --- a/src/config/options.c
13 +++ b/src/config/options.c
14 @@ -703,6 +703,9 @@ register_autocreated_options(void)
15 get_opt_int("terminal.xterm-256color.type") = 1;
16 get_opt_int("terminal.xterm-256color.colors") = COLOR_MODE_256;
17 get_opt_bool("terminal.xterm-256color.underline") = 1;
18 + get_opt_int("terminal.fbterm.type") = 5;
19 + get_opt_int("terminal.fbterm.colors") = COLOR_MODE_256;
20 + get_opt_bool("terminal.fbterm.underline") = 1;
24 diff --git a/src/config/options.inc b/src/config/options.inc
25 index b9c6a7f..c4e4a9b 100644
26 --- a/src/config/options.inc
27 +++ b/src/config/options.inc
28 @@ -879,20 +879,22 @@ static struct option_info config_options_info[] = {
29 * 4 (TERM_FREEBSD) outputs characters in the 0x80...0x9F
30 * range, which FreeBSD 4.0 (but not 5.0) treated as
34 * When UTF-8 I/O is enabled, ELinks outputs (almost) the same
35 * characters as above but encodes them in UTF-8 and does not
36 * switch charsets. So, it will work in any terminal that
37 * understands UTF-8 and has the characters in its font. */
38 INIT_OPT_INT("terminal._template_", N_("Type"),
41 N_("Terminal type; matters mostly only when drawing frames "
42 "and dialog box borders:\n"
43 "0 is dumb terminal type, ASCII art\n"
44 "1 is VT100, simple but portable\n"
45 "2 is Linux, you get double frames and other goodies\n"
51 INIT_OPT_BOOL("terminal._template_", N_("Always encode xterm title in ISO-8859-1"),
53 diff --git a/src/terminal/screen.c b/src/terminal/screen.c
54 index 8f838a6..bb3cbb1 100644
55 --- a/src/terminal/screen.c
56 +++ b/src/terminal/screen.c
57 @@ -189,6 +189,19 @@ static const struct string underline_seqs[] = {
59 * @todo TODO: termcap/terminfo can maybe gradually be introduced via
60 * this structure. We'll see. --jonas */
62 +#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
63 +static const struct string color256_seqs[] = {
64 + /* foreground: */ TERM_STRING("\033[0;38;5;%dm"),
65 + /* background: */ TERM_STRING("\033[48;5;%dm"),
68 +static const struct string fbterm_color256_seqs[] = {
69 + /* foreground: */ TERM_STRING("\033[m\033[1;%d}"),
70 + /* background: */ TERM_STRING("\033[2;%d}"),
74 struct screen_driver {
75 LIST_HEAD(struct screen_driver);
77 @@ -215,6 +228,9 @@ struct screen_driver {
79 enum color_mode color_mode;
81 +#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
82 + const struct string *color256_seqs;
84 /** These are directly derived from the terminal options. */
85 unsigned int transparent:1;
87 @@ -237,6 +253,9 @@ static const struct screen_driver_opt dumb_screen_driver_opt = {
88 /* frame_seqs: */ NULL,
89 /* underline: */ underline_seqs,
90 /* color_mode: */ COLOR_MODE_16,
91 +#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
92 + /* 256 colors: */ color256_seqs,
97 @@ -250,6 +269,9 @@ static const struct screen_driver_opt vt100_screen_driver_opt = {
98 /* frame_seqs: */ vt100_frame_seqs,
99 /* underline: */ underline_seqs,
100 /* color_mode: */ COLOR_MODE_16,
101 +#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
102 + /* 256 colors: */ color256_seqs,
104 /* transparent: */ 1,
107 @@ -263,6 +285,9 @@ static const struct screen_driver_opt linux_screen_driver_opt = {
108 /* frame_seqs: */ NULL, /* No m11_hack */
109 /* underline: */ underline_seqs,
110 /* color_mode: */ COLOR_MODE_16,
111 +#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
112 + /* 256 colors: */ color256_seqs,
114 /* transparent: */ 1,
117 @@ -276,6 +301,9 @@ static const struct screen_driver_opt koi8_screen_driver_opt = {
118 /* frame_seqs: */ NULL,
119 /* underline: */ underline_seqs,
120 /* color_mode: */ COLOR_MODE_16,
121 +#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
122 + /* 256 colors: */ color256_seqs,
124 /* transparent: */ 1,
127 @@ -289,12 +317,35 @@ static const struct screen_driver_opt freebsd_screen_driver_opt = {
128 /* frame_seqs: */ NULL, /* No m11_hack */
129 /* underline: */ underline_seqs,
130 /* color_mode: */ COLOR_MODE_16,
131 +#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
132 + /* 256 colors: */ color256_seqs,
134 /* transparent: */ 1,
137 #endif /* CONFIG_UTF8 */
138 +#ifdef CONFIG_COMBINE
140 +#endif /* CONFIG_COMBINE */
143 +/** Default options for ::TERM_LINUX. */
144 +static const struct screen_driver_opt fbterm_screen_driver_opt = {
145 + /* charsets: */ { -1, -1 }, /* No UTF8 I/O */
147 + /* frame_seqs: */ NULL, /* No m11_hack */
148 + /* underline: */ underline_seqs,
149 + /* color_mode: */ COLOR_MODE_16,
150 +#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
151 + /* 256 colors: */ fbterm_color256_seqs,
153 + /* transparent: */ 1,
156 +#endif /* CONFIG_UTF8 */
160 /** Default options for all the different types of terminals.
161 * XXX: Keep in sync with enum term_mode_type. */
162 static const struct screen_driver_opt *const screen_driver_opts[] = {
163 @@ -303,6 +354,7 @@ static const struct screen_driver_opt *const screen_driver_opts[] = {
164 /* TERM_LINUX: */ &linux_screen_driver_opt,
165 /* TERM_KOI8: */ &koi8_screen_driver_opt,
166 /* TERM_FREEBSD: */ &freebsd_screen_driver_opt,
167 + /* TERM_FBTERM: */ &fbterm_screen_driver_opt,
170 #define use_utf8_io(driver) ((driver)->opt.charsets[0] != -1)
171 @@ -353,7 +405,7 @@ set_screen_driver_opt(struct screen_driver *driver, struct option *term_spec)
172 * characters encoded in UTF-8 are already unambiguous. */
173 driver->opt.frame_seqs = NULL;
175 - if (driver->type == TERM_LINUX) {
176 + if (driver->type == TERM_LINUX || driver->type == TERM_FBTERM) {
177 if (get_opt_bool_tree(term_spec, "restrict_852"))
178 driver->opt.frame = frame_restrict;
179 driver->opt.charsets[1] = get_cp_index("cp437");
180 @@ -754,11 +806,6 @@ add_char16(struct string *screen, struct screen_driver *driver,
181 add_char_data(screen, driver, ch->data, border);
184 -#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
185 -static const struct string color256_seqs[] = {
186 - /* foreground: */ TERM_STRING("\033[0;38;5;%dm"),
187 - /* background: */ TERM_STRING("\033[48;5;%dm"),
191 add_char_color(struct string *screen, const struct string *seq, unsigned char color)
192 @@ -810,6 +857,7 @@ add_char_color(struct string *screen, const struct string *seq, unsigned char co
193 #define add_background_color(str, seq, chr) add_char_color(str, &(seq)[1], (chr)->color[1])
194 #define add_foreground_color(str, seq, chr) add_char_color(str, &(seq)[0], (chr)->color[0])
196 +#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
197 /** Time critical section. */
199 add_char256(struct string *screen, struct screen_driver *driver,
200 @@ -853,9 +901,9 @@ add_char256(struct string *screen, struct screen_driver *driver,
202 copy_color_256(state->color, ch->color);
204 - add_foreground_color(screen, color256_seqs, ch);
205 + add_foreground_color(screen, driver->opt.color256_seqs, ch);
206 if (!driver->opt.transparent || ch->color[1] != 0) {
207 - add_background_color(screen, color256_seqs, ch);
208 + add_background_color(screen, driver->opt.color256_seqs, ch);
211 if (ch->attr & SCREEN_ATTR_BOLD)
212 diff --git a/src/terminal/terminal.h b/src/terminal/terminal.h
213 index c2c1d79..1db36d0 100644
214 --- a/src/terminal/terminal.h
215 +++ b/src/terminal/terminal.h
216 @@ -18,6 +18,7 @@ enum term_mode_type {
223 /** This is a bitmask describing the environment we are living in,