Author: ed
Date: Sat Jan  3 22:51:54 2009
New Revision: 186729
URL: http://svn.freebsd.org/changeset/base/186729

Log:
  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>

Modified:
  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/dev/syscons/teken/teken.c
==============================================================================
--- head/sys/dev/syscons/teken/teken.c  Sat Jan  3 19:38:47 2009        
(r186728)
+++ head/sys/dev/syscons/teken/teken.c  Sat Jan  3 22:51:54 2009        
(r186729)
@@ -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   ' '

Modified: head/sys/dev/syscons/teken/teken.h
==============================================================================
--- head/sys/dev/syscons/teken/teken.h  Sat Jan  3 19:38:47 2009        
(r186728)
+++ head/sys/dev/syscons/teken/teken.h  Sat Jan  3 22:51:54 2009        
(r186729)
@@ -43,6 +43,8 @@
  */
 #define        TEKEN_UTF8
 #endif
+/* Emulate cons25-like behaviour. */
+#define        TEKEN_CONS25
 
 #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  3 19:38:47 2009        
(r186728)
+++ head/sys/dev/syscons/teken/teken_demo.c     Sat Jan  3 22:51:54 2009        
(r186729)
@@ -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[] __u
                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);

Modified: head/sys/dev/syscons/teken/teken_subr.h
==============================================================================
--- head/sys/dev/syscons/teken/teken_subr.h     Sat Jan  3 19:38:47 2009        
(r186728)
+++ head/sys/dev/syscons/teken/teken_subr.h     Sat Jan  3 22:51:54 2009        
(r186729)
@@ -250,6 +250,8 @@ teken_subr_cursor_backward_tabulation(te
                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(tek
                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(
 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,
        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,
                        t->t_stateflags &= ~TS_WRAPPED;
                }
        }
+#endif /* TEKEN_CONS25 */
 
        teken_funcs_cursor(t);
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to