]> git.pld-linux.org Git - packages/elinks.git/blame - elinks-fbterm.patch
- release ...4
[packages/elinks.git] / elinks-fbterm.patch
CommitLineData
62a6d0af 1commit e23a8ec12164af00922751aea0dfa285d3e240b4
2Author: Witold Filipczyk <witekfl@poczta.onet.pl>
3Date: Fri Mar 27 19:44:46 2009 +0100
4
5 Support for fbterm.
6
7 fbterm uses different 256 color sequences than xterm.
8 color256_seqs are part of the driver info.
9
10diff --git a/src/config/options.c b/src/config/options.c
11index 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;
21 #endif
22 }
23
24diff --git a/src/config/options.inc b/src/config/options.inc
25index 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
31 * graphical.
32+ * 5 (TERM_FBTERM)
33 *
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"),
39- "type", 0, 0, 4, 0,
40+ "type", 0, 0, 5, 0,
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"
46 "3 is KOI-8\n"
47- "4 is FreeBSD")),
48+ "4 is FreeBSD\n"
49+ "5 is fbterm")),
50
51 INIT_OPT_BOOL("terminal._template_", N_("Always encode xterm title in ISO-8859-1"),
52 "latin1_title", 0, 1,
53diff --git a/src/terminal/screen.c b/src/terminal/screen.c
54index 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[] = {
58 *
59 * @todo TODO: termcap/terminfo can maybe gradually be introduced via
60 * this structure. We'll see. --jonas */
61+
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"),
66+};
67+
68+static const struct string fbterm_color256_seqs[] = {
69+ /* foreground: */ TERM_STRING("\033[m\033[1;%d}"),
70+ /* background: */ TERM_STRING("\033[2;%d}"),
71+};
72+#endif
73+
74 struct screen_driver {
75 LIST_HEAD(struct screen_driver);
76
77@@ -215,6 +228,9 @@ struct screen_driver {
78 /** The color mode */
79 enum color_mode color_mode;
80
81+#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
82+ const struct string *color256_seqs;
83+#endif
84 /** These are directly derived from the terminal options. */
85 unsigned int transparent:1;
86
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,
93+#endif
94 /* transparent: */ 1,
95 #ifdef CONFIG_UTF8
96 /* utf8_cp: */ 0,
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,
103+#endif
104 /* transparent: */ 1,
105 #ifdef CONFIG_UTF8
106 /* utf8_cp: */ 0,
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,
113+#endif
114 /* transparent: */ 1,
115 #ifdef CONFIG_UTF8
116 /* utf8_cp: */ 0,
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,
123+#endif
124 /* transparent: */ 1,
125 #ifdef CONFIG_UTF8
126 /* utf8_cp: */ 0,
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,
133+#endif
134 /* transparent: */ 1,
135 #ifdef CONFIG_UTF8
136 /* utf8_cp: */ 0,
137 #endif /* CONFIG_UTF8 */
138+#ifdef CONFIG_COMBINE
139+ /* combine */ 0,
140+#endif /* CONFIG_COMBINE */
141 };
142
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 */
146+ /* frame: */ NULL,
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,
152+#endif
153+ /* transparent: */ 1,
154+#ifdef CONFIG_UTF8
155+ /* utf8_cp: */ 0,
156+#endif /* CONFIG_UTF8 */
157+};
158+
159+
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,
168 };
169
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;
174
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);
182 }
183
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"),
188-};
189
190 static inline void
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])
195
196+#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
197 /** Time critical section. */
198 static inline void
199 add_char256(struct string *screen, struct screen_driver *driver,
200@@ -853,9 +901,9 @@ add_char256(struct string *screen, struct screen_driver *driver,
201 ) {
202 copy_color_256(state->color, ch->color);
203
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);
209 }
210
211 if (ch->attr & SCREEN_ATTR_BOLD)
212diff --git a/src/terminal/terminal.h b/src/terminal/terminal.h
213index c2c1d79..1db36d0 100644
214--- a/src/terminal/terminal.h
215+++ b/src/terminal/terminal.h
216@@ -18,6 +18,7 @@ enum term_mode_type {
217 TERM_LINUX,
218 TERM_KOI8,
219 TERM_FREEBSD,
220+ TERM_FBTERM,
221 };
222
223 /** This is a bitmask describing the environment we are living in,
This page took 0.074728 seconds and 4 git commands to generate.