From owner-svn-src-all@FreeBSD.ORG Sat Jan 17 16:37:14 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B8F0F106564A; Sat, 17 Jan 2009 16:37:14 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A62318FC19; Sat, 17 Jan 2009 16:37:14 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0HGbE8h047475; Sat, 17 Jan 2009 16:37:14 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0HGbEGv047470; Sat, 17 Jan 2009 16:37:14 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200901171637.n0HGbEGv047470@svn.freebsd.org> From: Ed Schouten Date: Sat, 17 Jan 2009 16:37:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187367 - in head/sys: conf dev/syscons/teken X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Jan 2009 16:37:15 -0000 Author: ed Date: Sat Jan 17 16:37:13 2009 New Revision: 187367 URL: http://svn.freebsd.org/changeset/base/187367 Log: 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 Modified: head/sys/conf/NOTES head/sys/conf/options head/sys/dev/syscons/teken/teken.c head/sys/dev/syscons/teken/teken.h head/sys/dev/syscons/teken/teken_demo.c head/sys/dev/syscons/teken/teken_subr.h Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Sat Jan 17 15:56:38 2009 (r187366) +++ head/sys/conf/NOTES Sat Jan 17 16:37:13 2009 (r187367) @@ -1370,6 +1370,10 @@ options SC_NO_SUSPEND_VTYSWITCH # 0x80 Put the video card in the VESA 800x600 dots, 16 color mode # 0x100 Probe for a keyboard device periodically if one is not present +# Enable experimental features of the syscons terminal emulator (teken). +options TEKEN_UTF8 # UTF-8 output handling +options TEKEN_XTERM # xterm-style terminal emulation + # # Optional devices: # Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Sat Jan 17 15:56:38 2009 (r187366) +++ head/sys/conf/options Sat Jan 17 16:37:13 2009 (r187367) @@ -726,6 +726,10 @@ SC_PIXEL_MODE opt_syscons.h SC_RENDER_DEBUG opt_syscons.h SC_TWOBUTTON_MOUSE opt_syscons.h +# teken terminal emulator options +TEKEN_UTF8 opt_teken.h +TEKEN_XTERM opt_teken.h + # options for printf PRINTF_BUFR_SIZE opt_printf.h Modified: head/sys/dev/syscons/teken/teken.c ============================================================================== --- head/sys/dev/syscons/teken/teken.c Sat Jan 17 15:56:38 2009 (r187366) +++ head/sys/dev/syscons/teken/teken.c Sat Jan 17 16:37:13 2009 (r187367) @@ -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 ' ' Modified: head/sys/dev/syscons/teken/teken.h ============================================================================== --- head/sys/dev/syscons/teken/teken.h Sat Jan 17 15:56:38 2009 (r187366) +++ head/sys/dev/syscons/teken/teken.h Sat Jan 17 16:37:13 2009 (r187367) @@ -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; Modified: head/sys/dev/syscons/teken/teken_demo.c ============================================================================== --- head/sys/dev/syscons/teken/teken_demo.c Sat Jan 17 15:56:38 2009 (r187366) +++ head/sys/dev/syscons/teken/teken_demo.c Sat Jan 17 16:37:13 2009 (r187367) @@ -279,11 +279,11 @@ main(int argc __unused, char *argv[] __u 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 */ Modified: head/sys/dev/syscons/teken/teken_subr.h ============================================================================== --- head/sys/dev/syscons/teken/teken_subr.h Sat Jan 17 15:56:38 2009 (r187366) +++ head/sys/dev/syscons/teken/teken_subr.h Sat Jan 17 16:37:13 2009 (r187367) @@ -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( 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, 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, 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); }