summaryrefslogtreecommitdiffstats
path: root/sys/dev/syscons
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-01-03 22:51:54 +0000
committered <ed@FreeBSD.org>2009-01-03 22:51:54 +0000
commite21427fbffccb679cf56cf4596ee409a9ab71340 (patch)
tree190ff1a264e40a3f7b93648fcf9588dad9f46f0c /sys/dev/syscons
parent4ca12119c31e0cd42b3cb4b28dd898b8218290dc (diff)
downloadFreeBSD-src-e21427fbffccb679cf56cf4596ee409a9ab71340.zip
FreeBSD-src-e21427fbffccb679cf56cf4596ee409a9ab71340.tar.gz
Resolve some regressions related to tabs and linewrap handling.
It turns out I was looking too much at mimicing xterm, that I didn't take the differences of cons25 into account. There are some differences between xterm and cons25 that are important. Create a new #define called TEKEN_CONS25 that can be toggled to switch between cons25 and xterm mode. - Don't forget to redraw the cursor after processing a forward/backward tabulation. - Implement cons25-style (WYSE?) autowrapping. This form of autowrapping isn't that nice. It wraps the cursor when printing something on column 80. xterm wraps when printing the first character that doesn't fit. - In cons25, a \t shouldn't overwrite previous contents, while xterm does. Reported by: Garrett Cooper <yanefbsd gmail com>
Diffstat (limited to 'sys/dev/syscons')
-rw-r--r--sys/dev/syscons/teken/teken.c4
-rw-r--r--sys/dev/syscons/teken/teken.h2
-rw-r--r--sys/dev/syscons/teken/teken_demo.c4
-rw-r--r--sys/dev/syscons/teken/teken_subr.h26
4 files changed, 34 insertions, 2 deletions
diff --git a/sys/dev/syscons/teken/teken.c b/sys/dev/syscons/teken/teken.c
index e1efcf7..acf35f7 100644
--- a/sys/dev/syscons/teken/teken.c
+++ b/sys/dev/syscons/teken/teken.c
@@ -68,7 +68,11 @@ teken_wcwidth(teken_char_t c)
#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 */
#define TS_WRAPPED 0x10 /* Next character should be printed on col 0. */
+#endif /* TEKEN_CONS25 */
/* Character that blanks a cell. */
#define BLANK ' '
diff --git a/sys/dev/syscons/teken/teken.h b/sys/dev/syscons/teken/teken.h
index ef107ca..61c8afe 100644
--- a/sys/dev/syscons/teken/teken.h
+++ b/sys/dev/syscons/teken/teken.h
@@ -43,6 +43,8 @@
*/
#define TEKEN_UTF8
#endif
+/* Emulate cons25-like behaviour. */
+#define TEKEN_CONS25
#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 7d01f9b..74b4321 100644
--- a/sys/dev/syscons/teken/teken_demo.c
+++ b/sys/dev/syscons/teken/teken_demo.c
@@ -70,7 +70,7 @@ struct pixel {
};
#define NCOLS 80
-#define NROWS 24
+#define NROWS 25
struct pixel buffer[NCOLS][NROWS];
static int ptfd;
@@ -279,7 +279,7 @@ main(int argc __unused, char *argv[] __unused)
perror("forkpty");
exit(1);
case 0:
- setenv("TERM", "xterm-color", 1);
+ setenv("TERM", "cons25", 1);
setenv("LC_CTYPE", "UTF-8", 0);
execlp("zsh", "-zsh", NULL);
execlp("bash", "-bash", NULL);
diff --git a/sys/dev/syscons/teken/teken_subr.h b/sys/dev/syscons/teken/teken_subr.h
index 53aea0a..d8319f6 100644
--- a/sys/dev/syscons/teken/teken_subr.h
+++ b/sys/dev/syscons/teken/teken_subr.h
@@ -250,6 +250,8 @@ teken_subr_cursor_backward_tabulation(teken_t *t, unsigned int ntabs)
if (teken_tab_isset(t, t->t_cursor.tp_col))
ntabs--;
} while (ntabs > 0);
+
+ teken_funcs_cursor(t);
}
static void
@@ -291,6 +293,8 @@ teken_subr_cursor_forward_tabulation(teken_t *t, unsigned int ntabs)
if (teken_tab_isset(t, t->t_cursor.tp_col))
ntabs--;
} while (ntabs > 0);
+
+ teken_funcs_cursor(t);
}
static void
@@ -527,6 +531,10 @@ 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 */
teken_rect_t tr;
tr.tr_begin = t->t_cursor;
@@ -537,6 +545,7 @@ 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 */
}
static void
@@ -708,6 +717,22 @@ 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 */
if (t->t_cursor.tp_col == t->t_winsize.tp_col - 1 &&
(t->t_stateflags & (TS_WRAPPED|TS_AUTOWRAP)) ==
(TS_WRAPPED|TS_AUTOWRAP)) {
@@ -752,6 +777,7 @@ teken_subr_regular_character(teken_t *t, teken_char_t c)
t->t_stateflags &= ~TS_WRAPPED;
}
}
+#endif /* TEKEN_CONS25 */
teken_funcs_cursor(t);
}
OpenPOWER on IntegriCloud