PERFORCE change 154056 for review

Ed Schouten ed at FreeBSD.org
Thu Dec 4 10:40:02 PST 2008


http://perforce.freebsd.org/chv.cgi?CH=154056

Change 154056 by ed at ed_flippo on 2008/12/04 18:39:28

	Make scterm-teken somewhat usable:
	
	- Update libteken to upstream repository sources.
	
	- Implement a basic putchar() routine, which does not take attributes
	  into account yet.
	
	- A horribly slow fill() routine, which just calls putchar() in
	  loops. A simple optimisation would be to call sc_vtb_clear()
	  if c == ' '.
	
	- A broken copy() routine, which copies data from the screen to
	  a different location. We'll implement this using
	  sc_vtb_move(). Right now it only successfully copies data when
	  we start at column 0 and end at xsize - 1.
	
	I can already use it on my system right now, but it's still very
	broken. I guess if I fix it to work properly, we could get rid
	of a lot of LOC from syscons itself. We could even decide to
	replace scterm entirely and let scterm-teken only make calls
	into scvtb.

Affected files ...

.. //depot/projects/mpsafetty/sys/dev/syscons/scterm-teken.c#2 edit
.. //depot/projects/mpsafetty/sys/dev/syscons/teken/teken.h#3 edit
.. //depot/projects/mpsafetty/sys/dev/syscons/teken/teken_subr.h#2 edit

Differences ...

==== //depot/projects/mpsafetty/sys/dev/syscons/scterm-teken.c#2 (text+ko) ====

@@ -227,20 +227,51 @@
 }
 
 static void
-scteken_putchar(void *arg, const teken_pos_t *p, teken_char_t c,
+scteken_putchar(void *arg, const teken_pos_t *tp, teken_char_t c,
     const teken_attr_t *a)
 {
+	scr_stat *scp = arg;
+	u_char *map = scp->sc->scr_map;
+	u_char ch = c;
+	vm_offset_t p;
+	int cursor;
+
+	cursor = tp->tp_row * scp->xsize + tp->tp_col;
+	p = sc_vtb_pointer(&scp->vtb, cursor);
+	sc_vtb_putchar(&scp->vtb, p, map[ch], SC_NORM_ATTR << 8);
+	mark_all(scp);
 }
 
 static void
 scteken_fill(void *arg, const teken_rect_t *r, teken_char_t c,
     const teken_attr_t *a)
 {
+	teken_pos_t p;
+
+	/* Braindead implementation of fill() - just call putchar(). */
+	for (p.tp_row = r->tr_begin.tp_row;
+	    p.tp_row < r->tr_end.tp_row; p.tp_row++)
+		for (p.tp_col = r->tr_begin.tp_col;
+		    p.tp_col < r->tr_end.tp_col; p.tp_col++)
+			scteken_putchar(arg, &p, c, a);
 }
 
 static void
 scteken_copy(void *arg, const teken_rect_t *r, const teken_pos_t *p)
 {
+	scr_stat *scp = arg;
+	int from, to, count;
+
+	/* XXX: only copy whole lines for now! */
+	from = r->tr_begin.tp_row * scp->xsize;
+	to = p->tp_row * scp->xsize;
+	count = (r->tr_end.tp_row - r->tr_begin.tp_row + 1) * scp->xsize - 1;
+
+	if (count <= 0 || from == to)
+		return;
+
+	sc_vtb_move(&scp->vtb, from, to, count);
+	mark_all(scp);
 }
 
 static void

==== //depot/projects/mpsafetty/sys/dev/syscons/teken/teken.h#3 (text+ko) ====

@@ -91,6 +91,7 @@
 #define	TP_SHOWCURSOR	0
 #define	TP_CURSORKEYS	1
 #define	TP_KEYPADAPP	2
+#define	TP_AUTOREPEAT	3
 typedef void tf_respond_t(void *, const void *, size_t);
 
 typedef struct {

==== //depot/projects/mpsafetty/sys/dev/syscons/teken/teken_subr.h#2 (text+ko) ====

@@ -138,10 +138,9 @@
 {
 
 	switch (cmd) {
-	case 5: { /* Operating status. */
+	case 5: /* Operating status. */
 		strcpy(response, "0n");
 		return (2);
-	}
 	case 6: { /* Cursor position. */
 		int len;
 
@@ -153,18 +152,15 @@
 			return (-1);
 		return (len);
 	}
-	case 15: { /* Printer status. */
+	case 15: /* Printer status. */
 		strcpy(response, "13n");
 		return (3);
-	}
-	case 25: { /* UDK status. */
+	case 25: /* UDK status. */
 		strcpy(response, "20n");
 		return (3);
-	}
-	case 26: { /* Keyboard status. */
+	case 26: /* Keyboard status. */
 		strcpy(response, "27;1n");
 		return (5);
-	}
 	default:
 		teken_printf("Unknown DSR\n");
 		return (-1);
@@ -691,6 +687,7 @@
 
 	if (request == 0) {
 		const char response[] = "\x1B[?1;2c";
+
 		teken_funcs_respond(t, response, sizeof response - 1);
 	} else {
 		teken_printf("Unknown DA1\n");
@@ -784,6 +781,9 @@
 		teken_printf("DECRST autowrap mode\n");
 		t->t_stateflags &= ~TS_AUTOWRAP;
 		break;
+	case 8: /* Autorepeat mode. */
+		teken_funcs_param(t, TP_AUTOREPEAT, 0);
+		break;
 	case 25: /* Hide cursor. */
 		teken_funcs_param(t, TP_SHOWCURSOR, 0);
 		break;
@@ -894,6 +894,9 @@
 		teken_printf("DECSET autowrap mode\n");
 		t->t_stateflags |= TS_AUTOWRAP;
 		break;
+	case 8: /* Autorepeat mode. */
+		teken_funcs_param(t, TP_AUTOREPEAT, 1);
+		break;
 	case 25: /* Display cursor. */
 		teken_funcs_param(t, TP_SHOWCURSOR, 1);
 		break;


More information about the p4-projects mailing list