summaryrefslogtreecommitdiffstats
path: root/sys/teken/teken.c
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-09-12 12:44:21 +0000
committered <ed@FreeBSD.org>2009-09-12 12:44:21 +0000
commit6047d14a18b1b4e8084fe0b353740ae91abd3fe7 (patch)
tree10b40ef171c3256b962afcb40e7cfb809b0a0e3f /sys/teken/teken.c
parente0831cf5d0a0f960d8518c8d799dada4d6c332ae (diff)
downloadFreeBSD-src-6047d14a18b1b4e8084fe0b353740ae91abd3fe7.zip
FreeBSD-src-6047d14a18b1b4e8084fe0b353740ae91abd3fe7.tar.gz
Commit all local modifications I have to libteken:
- Make xterm/cons25 support runtime configurable. This allows me to share libteken between syscons and my new vt driver. - Add a fix to print blanks after printing a double width character to prevent rendering artifacts. - Add some more utility functions that I use in the vt driver.
Diffstat (limited to 'sys/teken/teken.c')
-rw-r--r--sys/teken/teken.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/sys/teken/teken.c b/sys/teken/teken.c
index 92a81f1..da5c056 100644
--- a/sys/teken/teken.c
+++ b/sys/teken/teken.c
@@ -50,27 +50,16 @@ static FILE *df;
#include "teken.h"
#include "teken_wcwidth.h"
-
-#ifdef TEKEN_XTERM
#include "teken_scs.h"
-#else /* !TEKEN_XTERM */
-#define teken_scs_process(t, c) (c)
-#define teken_scs_restore(t)
-#define teken_scs_save(t)
-#define teken_scs_set(t, g, ts)
-#define teken_scs_switch(t, g)
-#endif /* TEKEN_XTERM */
/* Private flags for t_stateflags. */
#define TS_FIRSTDIGIT 0x01 /* First numeric digit in escape sequence. */
#define TS_INSERT 0x02 /* Insert mode. */
#define TS_AUTOWRAP 0x04 /* Autowrap. */
#define TS_ORIGIN 0x08 /* Origin mode. */
-#ifdef TEKEN_XTERM
#define TS_WRAPPED 0x10 /* Next character should be printed on col 0. */
-#else /* !TEKEN_XTERM */
-#define TS_WRAPPED 0x00 /* Simple line wrapping. */
-#endif /* TEKEN_XTERM */
+#define TS_8BIT 0x20 /* UTF-8 disabled. */
+#define TS_CONS25 0x40 /* cons25 emulation. */
/* Character that blanks a cell. */
#define BLANK ' '
@@ -172,14 +161,14 @@ teken_init(teken_t *t, const teken_funcs_t *tf, void *softc)
t->t_softc = softc;
t->t_nextstate = teken_state_init;
+ t->t_stateflags = 0;
+ t->t_utf8_left = 0;
t->t_defattr.ta_format = 0;
t->t_defattr.ta_fgcolor = TC_WHITE;
t->t_defattr.ta_bgcolor = TC_BLACK;
teken_subr_do_reset(t);
- t->t_utf8_left = 0;
-
teken_set_winsize(t, &tp);
}
@@ -203,14 +192,18 @@ teken_input_char(teken_t *t, teken_char_t c)
case '\x0C':
teken_subr_newpage(t);
break;
-#ifdef TEKEN_XTERM
case '\x0E':
- teken_scs_switch(t, 1);
+ if (t->t_stateflags & TS_CONS25)
+ t->t_nextstate(t, c);
+ else
+ teken_scs_switch(t, 1);
break;
case '\x0F':
- teken_scs_switch(t, 0);
+ if (t->t_stateflags & TS_CONS25)
+ t->t_nextstate(t, c);
+ else
+ teken_scs_switch(t, 0);
break;
-#endif /* TEKEN_XTERM */
case '\r':
teken_subr_carriage_return(t);
break;
@@ -245,10 +238,7 @@ teken_input_byte(teken_t *t, unsigned char c)
/*
* UTF-8 handling.
*/
- if (t->t_utf8_left == -1) {
- /* UTF-8 disabled. */
- teken_input_char(t, c);
- } else if ((c & 0x80) == 0x00) {
+ if ((c & 0x80) == 0x00 || t->t_stateflags & TS_8BIT) {
/* One-byte sequence. */
t->t_utf8_left = 0;
teken_input_char(t, c);
@@ -285,6 +275,13 @@ teken_input(teken_t *t, const void *buf, size_t len)
teken_input_byte(t, *c++);
}
+const teken_pos_t *
+teken_get_cursor(teken_t *t)
+{
+
+ return (&t->t_cursor);
+}
+
void
teken_set_cursor(teken_t *t, const teken_pos_t *p)
{
@@ -324,6 +321,13 @@ teken_set_defattr(teken_t *t, const teken_attr_t *a)
t->t_curattr = t->t_saved_curattr = t->t_defattr = *a;
}
+const teken_pos_t *
+teken_get_winsize(teken_t *t)
+{
+
+ return (&t->t_winsize);
+}
+
void
teken_set_winsize(teken_t *t, const teken_pos_t *p)
{
@@ -336,7 +340,14 @@ void
teken_set_8bit(teken_t *t)
{
- t->t_utf8_left = -1;
+ t->t_stateflags |= TS_8BIT;
+}
+
+void
+teken_set_cons25(teken_t *t)
+{
+
+ t->t_stateflags |= TS_CONS25;
}
/*
OpenPOWER on IntegriCloud