diff options
author | jhb <jhb@FreeBSD.org> | 2014-03-06 18:30:56 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2014-03-06 18:30:56 +0000 |
commit | 59b6242e909c7e020d7903a27847e2a465486a45 (patch) | |
tree | 2c015c503188a6a75426ca67e8433237f3533f97 /sys/teken | |
parent | fe643776c1c5732c2d5d8354a64b520b7007e15c (diff) | |
download | FreeBSD-src-59b6242e909c7e020d7903a27847e2a465486a45.zip FreeBSD-src-59b6242e909c7e020d7903a27847e2a465486a45.tar.gz |
MFC 259016,259019,259049,259071,259102,259110,259129,259130,259178,259179,
259203,259221,259261,259532,259615,259650,259651,259667,259680,259727,
259761,259772,259776,259777,259830,259882,259915,260160,260449,260450,
260688,260888,260953,261269,261547,261551,261552,261553,261585:
Merge the vt(4) driver (newcons) to stable/10.
Approved by: ray
Diffstat (limited to 'sys/teken')
-rw-r--r-- | sys/teken/demo/teken_demo.c | 7 | ||||
-rw-r--r-- | sys/teken/teken.c | 25 | ||||
-rw-r--r-- | sys/teken/teken.h | 10 | ||||
-rw-r--r-- | sys/teken/teken_subr.h | 40 |
4 files changed, 61 insertions, 21 deletions
diff --git a/sys/teken/demo/teken_demo.c b/sys/teken/demo/teken_demo.c index 16bb4b7..08323dc 100644 --- a/sys/teken/demo/teken_demo.c +++ b/sys/teken/demo/teken_demo.c @@ -86,9 +86,10 @@ printchar(const teken_pos_t *p) assert(p->tp_row < NROWS); assert(p->tp_col < NCOLS); - getyx(stdscr, y, x); - px = &buffer[p->tp_col][p->tp_row]; + /* No need to print right hand side of CJK character manually. */ + if (px->a.ta_format & TF_CJK_RIGHT) + return; /* Convert Unicode to UTF-8. */ if (px->c < 0x80) { @@ -118,8 +119,8 @@ printchar(const teken_pos_t *p) bkgdset(attr | COLOR_PAIR(teken_256to8(px->a.ta_fgcolor) + 8 * teken_256to8(px->a.ta_bgcolor))); + getyx(stdscr, y, x); mvaddstr(p->tp_row, p->tp_col, str); - move(y, x); } diff --git a/sys/teken/teken.c b/sys/teken/teken.c index 8ca88d2..3002a88 100644 --- a/sys/teken/teken.c +++ b/sys/teken/teken.c @@ -338,15 +338,40 @@ teken_get_winsize(teken_t *t) return (&t->t_winsize); } +static void +teken_trim_cursor_pos(teken_t *t, const teken_pos_t *new) +{ + const teken_pos_t *cur; + + cur = &t->t_winsize; + + if (cur->tp_row < new->tp_row || cur->tp_col < new->tp_col) + return; + if (t->t_cursor.tp_row >= new->tp_row) + t->t_cursor.tp_row = new->tp_row - 1; + if (t->t_cursor.tp_col >= new->tp_col) + t->t_cursor.tp_col = new->tp_col - 1; +} + void teken_set_winsize(teken_t *t, const teken_pos_t *p) { + teken_trim_cursor_pos(t, p); t->t_winsize = *p; teken_subr_do_reset(t); } void +teken_set_winsize_noreset(teken_t *t, const teken_pos_t *p) +{ + + teken_trim_cursor_pos(t, p); + t->t_winsize = *p; + teken_subr_do_resize(t); +} + +void teken_set_8bit(teken_t *t) { diff --git a/sys/teken/teken.h b/sys/teken/teken.h index 2feef6e..27d1ce4 100644 --- a/sys/teken/teken.h +++ b/sys/teken/teken.h @@ -41,10 +41,11 @@ typedef uint32_t teken_char_t; typedef unsigned short teken_unit_t; typedef unsigned char teken_format_t; -#define TF_BOLD 0x01 -#define TF_UNDERLINE 0x02 -#define TF_BLINK 0x04 -#define TF_REVERSE 0x08 +#define TF_BOLD 0x01 /* Bold character. */ +#define TF_UNDERLINE 0x02 /* Underline character. */ +#define TF_BLINK 0x04 /* Blinking character. */ +#define TF_REVERSE 0x08 /* Reverse rendered character. */ +#define TF_CJK_RIGHT 0x10 /* Right-hand side of CJK character. */ typedef unsigned char teken_color_t; #define TC_BLACK 0 #define TC_RED 1 @@ -168,6 +169,7 @@ void teken_set_cursor(teken_t *, const teken_pos_t *); void teken_set_curattr(teken_t *, const teken_attr_t *); void teken_set_defattr(teken_t *, const teken_attr_t *); void teken_set_winsize(teken_t *, const teken_pos_t *); +void teken_set_winsize_noreset(teken_t *, const teken_pos_t *); /* Key input escape sequences. */ #define TKEY_UP 0x00 diff --git a/sys/teken/teken_subr.h b/sys/teken/teken_subr.h index 64f4e54..2eee627 100644 --- a/sys/teken/teken_subr.h +++ b/sys/teken/teken_subr.h @@ -791,21 +791,19 @@ teken_subr_do_putchar(teken_t *t, const teken_pos_t *tp, teken_char_t c, teken_funcs_copy(t, &ctr, &ctp); } + teken_funcs_putchar(t, tp, c, &t->t_curattr); + if (width == 2 && tp->tp_col + 1 < t->t_winsize.tp_col) { teken_pos_t tp2; + teken_attr_t attr; - /* - * Store a space behind double width characters before - * actually printing them. This prevents artifacts when - * the consumer doesn't render it using double width - * glyphs. - */ + /* Print second half of CJK fullwidth character. */ tp2.tp_row = tp->tp_row; tp2.tp_col = tp->tp_col + 1; - teken_funcs_putchar(t, &tp2, BLANK, &t->t_curattr); + attr = t->t_curattr; + attr.ta_format |= TF_CJK_RIGHT; + teken_funcs_putchar(t, &tp2, c, &attr); } - - teken_funcs_putchar(t, tp, c, &t->t_curattr); } static void @@ -842,13 +840,18 @@ teken_subr_regular_character(teken_t *t, teken_char_t c) } t->t_cursor.tp_col = 0; } - } else if (t->t_cursor.tp_col == t->t_winsize.tp_col - 1 && - (t->t_stateflags & (TS_WRAPPED|TS_AUTOWRAP)) == - (TS_WRAPPED|TS_AUTOWRAP)) { + } else if (t->t_stateflags & TS_AUTOWRAP && + ((t->t_stateflags & TS_WRAPPED && + t->t_cursor.tp_col + 1 == t->t_winsize.tp_col) || + t->t_cursor.tp_col + width > t->t_winsize.tp_col)) { teken_pos_t tp; - /* Perform line wrapping. */ - + /* + * Perform line wrapping, if: + * - Autowrapping is enabled, and + * - We're in the wrapped state at the last column, or + * - The character to be printed does not fit anymore. + */ if (t->t_cursor.tp_row == t->t_scrollreg.ts_end - 1) { /* Perform scrolling. */ teken_subr_do_scroll(t, 1); @@ -956,6 +959,15 @@ teken_subr_reset_mode(teken_t *t, unsigned int cmd) } static void +teken_subr_do_resize(teken_t *t) +{ + + t->t_scrollreg.ts_begin = 0; + t->t_scrollreg.ts_end = t->t_winsize.tp_row; + t->t_originreg = t->t_scrollreg; +} + +static void teken_subr_do_reset(teken_t *t) { |