mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-18 15:53:37 +00:00
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>
This commit is contained in:
parent
acb97117e3
commit
17c98d6dab
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=186729
|
@ -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 ' '
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
*/
|
||||
#define TEKEN_UTF8
|
||||
#endif
|
||||
/* Emulate cons25-like behaviour. */
|
||||
#define TEKEN_CONS25
|
||||
|
||||
#ifdef TEKEN_UTF8
|
||||
typedef uint32_t teken_char_t;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue