diff options
author | ed <ed@FreeBSD.org> | 2009-01-17 16:37:13 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-01-17 16:37:13 +0000 |
commit | 7b600fafdef3ffa79eb3537bbb9296653a1cc94f (patch) | |
tree | 6a314587fc48cc3b8c2c9c27753bfa1fec506187 /sys/dev/syscons | |
parent | dea83348494de12395a3332e12f74e329a43f33e (diff) | |
download | FreeBSD-src-7b600fafdef3ffa79eb3537bbb9296653a1cc94f.zip FreeBSD-src-7b600fafdef3ffa79eb3537bbb9296653a1cc94f.tar.gz |
Allow experimental libteken features to be tested without changing code.
The teken library already supports UTF-8 handling and xterm emulation,
but we have reasons to disable this right now. Because we should make it
easy and interesting for people to experiment with these features, allow
them to be set in kernel configuration files.
Before this commit we had a flag called `TEKEN_CONS25' to enable
cons25-style emulation. I'm calling it the opposite now, `TEKEN_XTERM',
because we want to enable it in kernel configuration files explicitly.
Requested by: kib
Diffstat (limited to 'sys/dev/syscons')
-rw-r--r-- | sys/dev/syscons/teken/teken.c | 16 | ||||
-rw-r--r-- | sys/dev/syscons/teken/teken.h | 18 | ||||
-rw-r--r-- | sys/dev/syscons/teken/teken_demo.c | 8 | ||||
-rw-r--r-- | sys/dev/syscons/teken/teken_subr.h | 70 |
4 files changed, 55 insertions, 57 deletions
diff --git a/sys/dev/syscons/teken/teken.c b/sys/dev/syscons/teken/teken.c index 62ded27..575ffce 100644 --- a/sys/dev/syscons/teken/teken.c +++ b/sys/dev/syscons/teken/teken.c @@ -56,11 +56,11 @@ static inline int teken_wcwidth(teken_char_t c __unused) { -#ifdef TEKEN_CONS25 - return (1); -#else /* !TEKEN_CONS25 */ +#ifdef TEKEN_XTERM return (c <= 0x1B) ? -1 : 1; -#endif /* TEKEN_CONS25 */ +#else /* !TEKEN_XTERM */ + return (1); +#endif /* TEKEN_XTERM */ } #endif /* TEKEN_UTF8 */ @@ -72,11 +72,11 @@ teken_wcwidth(teken_char_t c __unused) #define TS_INSERT 0x02 /* Insert mode. */ #define TS_AUTOWRAP 0x04 /* Autowrap. */ #define TS_ORIGIN 0x08 /* Origin mode. */ -#ifdef TEKEN_CONS25 -#define TS_WRAPPED 0x00 /* Simple line wrapping. */ -#else /* !TEKEN_CONS25 */ +#ifdef TEKEN_XTERM #define TS_WRAPPED 0x10 /* Next character should be printed on col 0. */ -#endif /* TEKEN_CONS25 */ +#else /* !TEKEN_XTERM */ +#define TS_WRAPPED 0x00 /* Simple line wrapping. */ +#endif /* TEKEN_XTERM */ /* Character that blanks a cell. */ #define BLANK ' ' diff --git a/sys/dev/syscons/teken/teken.h b/sys/dev/syscons/teken/teken.h index 61c8afe..025d8aa 100644 --- a/sys/dev/syscons/teken/teken.h +++ b/sys/dev/syscons/teken/teken.h @@ -33,18 +33,16 @@ * libteken: terminal emulation library. * * This library converts an UTF-8 stream of bytes to terminal drawing - * commands. It implements commands similar to xterm-color. + * commands. + * + * Configuration switches: + * - TEKEN_UTF8: Enable/disable UTF-8 handling. + * - TEKEN_XTERM: Enable xterm-style emulation, instead of cons25. */ -#if 0 -/* - * XXX: Disable UTF-8 support for now. It requires UTF-8 keyboard input - * and rendering, which we do not yet support. - */ -#define TEKEN_UTF8 -#endif -/* Emulate cons25-like behaviour. */ -#define TEKEN_CONS25 +#if defined(__FreeBSD__) && defined(_KERNEL) +#include "opt_teken.h" +#endif /* __FreeBSD__ && _KERNEL */ #ifdef TEKEN_UTF8 typedef uint32_t teken_char_t; diff --git a/sys/dev/syscons/teken/teken_demo.c b/sys/dev/syscons/teken/teken_demo.c index 2d0a4bf..7fea64e 100644 --- a/sys/dev/syscons/teken/teken_demo.c +++ b/sys/dev/syscons/teken/teken_demo.c @@ -279,11 +279,11 @@ main(int argc __unused, char *argv[] __unused) perror("forkpty"); exit(1); case 0: -#ifdef TEKEN_CONS25 - setenv("TERM", "cons25", 1); -#else /* !TEKEN_CONS25 */ +#ifdef TEKEN_XTERM setenv("TERM", "xterm", 1); -#endif /* TEKEN_CONS25 */ +#else /* !TEKEN_XTERM */ + setenv("TERM", "cons25", 1); +#endif /* TEKEN_XTERM */ #ifdef TEKEN_UTF8 setenv("LC_CTYPE", "UTF-8", 0); #endif /* TEKEN_UTF8 */ diff --git a/sys/dev/syscons/teken/teken_subr.h b/sys/dev/syscons/teken/teken_subr.h index f26dc89..d0fbd5e 100644 --- a/sys/dev/syscons/teken/teken_subr.h +++ b/sys/dev/syscons/teken/teken_subr.h @@ -198,7 +198,13 @@ static void teken_subr_backspace(teken_t *t) { -#ifdef TEKEN_CONS25 +#ifdef TEKEN_XTERM + if (t->t_cursor.tp_col == 0) + return; + + t->t_cursor.tp_col--; + t->t_stateflags &= ~TS_WRAPPED; +#else /* !TEKEN_XTERM */ if (t->t_cursor.tp_col == 0) { if (t->t_cursor.tp_row == t->t_originreg.ts_begin) return; @@ -207,13 +213,7 @@ teken_subr_backspace(teken_t *t) } else { t->t_cursor.tp_col--; } -#else /* !TEKEN_CONS25 */ - if (t->t_cursor.tp_col == 0) - return; - - t->t_cursor.tp_col--; - t->t_stateflags &= ~TS_WRAPPED; -#endif /* TEKEN_CONS25 */ +#endif /* TEKEN_XTERM */ teken_funcs_cursor(t); } @@ -542,10 +542,7 @@ teken_subr_horizontal_position_absolute(teken_t *t, unsigned int col) static void teken_subr_horizontal_tab(teken_t *t) { -#ifdef TEKEN_CONS25 - - teken_subr_cursor_forward_tabulation(t, 1); -#else /* !TEKEN_CONS25 */ +#ifdef TEKEN_XTERM teken_rect_t tr; tr.tr_begin = t->t_cursor; @@ -556,7 +553,10 @@ teken_subr_horizontal_tab(teken_t *t) /* Blank region that we skipped. */ if (tr.tr_end.tp_col > tr.tr_begin.tp_col) teken_funcs_fill(t, &tr, BLANK, &t->t_curattr); -#endif /* TEKEN_CONS25 */ +#else /* !TEKEN_XTERM */ + + teken_subr_cursor_forward_tabulation(t, 1); +#endif /* TEKEN_XTERM */ } static void @@ -664,7 +664,10 @@ teken_subr_newline(teken_t *t) static void teken_subr_newpage(teken_t *t) { -#ifdef TEKEN_CONS25 +#ifdef TEKEN_XTERM + + teken_subr_newline(t); +#else /* !TEKEN_XTERM */ teken_rect_t tr; tr.tr_begin.tp_row = tr.tr_begin.tp_col = 0; @@ -673,10 +676,7 @@ teken_subr_newpage(teken_t *t) t->t_cursor.tp_row = t->t_cursor.tp_col = 0; teken_funcs_cursor(t); -#else /* !TEKEN_CONS25 */ - - teken_subr_newline(t); -#endif /* TEKEN_CONS25 */ +#endif /* TEKEN_XTERM */ } static void @@ -746,22 +746,7 @@ teken_subr_regular_character(teken_t *t, teken_char_t c) if (width <= 0) return; -#ifdef TEKEN_CONS25 - teken_subr_do_putchar(t, &t->t_cursor, c, width); - t->t_cursor.tp_col += width; - - if (t->t_cursor.tp_col >= t->t_winsize.tp_col) { - if (t->t_cursor.tp_row == t->t_scrollreg.ts_end - 1) { - /* Perform scrolling. */ - teken_subr_do_scroll(t, 1); - } else { - /* No scrolling needed. */ - if (t->t_cursor.tp_row < t->t_winsize.tp_row - 1) - t->t_cursor.tp_row++; - } - t->t_cursor.tp_col = 0; - } -#else /* !TEKEN_CONS25 */ +#ifdef TEKEN_XTERM if (t->t_cursor.tp_col == t->t_winsize.tp_col - 1 && (t->t_stateflags & (TS_WRAPPED|TS_AUTOWRAP)) == (TS_WRAPPED|TS_AUTOWRAP)) { @@ -806,7 +791,22 @@ teken_subr_regular_character(teken_t *t, teken_char_t c) t->t_stateflags &= ~TS_WRAPPED; } } -#endif /* TEKEN_CONS25 */ +#else /* !TEKEN_XTERM */ + teken_subr_do_putchar(t, &t->t_cursor, c, width); + t->t_cursor.tp_col += width; + + if (t->t_cursor.tp_col >= t->t_winsize.tp_col) { + if (t->t_cursor.tp_row == t->t_scrollreg.ts_end - 1) { + /* Perform scrolling. */ + teken_subr_do_scroll(t, 1); + } else { + /* No scrolling needed. */ + if (t->t_cursor.tp_row < t->t_winsize.tp_row - 1) + t->t_cursor.tp_row++; + } + t->t_cursor.tp_col = 0; + } +#endif /* TEKEN_XTERM */ teken_funcs_cursor(t); } |