diff options
Diffstat (limited to 'src/vt102.c')
-rw-r--r-- | src/vt102.c | 132 |
1 files changed, 74 insertions, 58 deletions
diff --git a/src/vt102.c b/src/vt102.c index eb365da..8a7dc56 100644 --- a/src/vt102.c +++ b/src/vt102.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.3 2008/02/04 02:05:06 james + * *** empty log message *** + * * Revision 1.2 2008/02/04 01:32:39 james * *** empty log message *** * @@ -104,6 +107,8 @@ ESC[?8h */ +#include "project.h" + static inline int csi_ender (int c) @@ -128,63 +133,74 @@ csi_starter (int c) return 0; } -void vt102_cursor_normalize(VT102 *v,int wrap,int scroll) +void +vt102_cursor_normalize (VT102 * v, int wrap, int scroll) { - if (v->pos.x<-1) /*don't wrap backwards*/ - c->pos.x=0; - - if (v->pos.x>=CRT_COLS) { - if (wrap) { - c->pos.x=0; - c->pos.y++; - } else { - c->pos.x=CRT_COLS-1; - } - } - - if (v->pos.y<0) - c->pos.y=0 - - if (v->pos.y>=CRT_ROWS) { - if (scroll) - vt102_scroll(v,0,CRT_ROWS-1); - c->pos.y=CRT_ROWS-1; - } + if (v->pos.x < -1) /*don't wrap backwards */ + v->pos.x = 0; + + if (v->pos.x >= CRT_COLS) + { + if (wrap) + { + v->pos.x = 0; + v->pos.y++; + } + else + { + v->pos.x = CRT_COLS - 1; + } + } + + if (v->pos.y < 0) + v->pos.y = 0; + + if (v->pos.y >= CRT_ROWS) + { + if (scroll) + vt102_scroll (v, 0, CRT_ROWS - 1); + v->pos.y = CRT_ROWS - 1; + } } - -void vt102_cursor_motion(VT102 *v,int x,int y,int wrap,scroll) + +void +vt102_cursor_motion (VT102 * v, int x, int y, int wrap, int scroll) { -while (x>0) { - x--; - v->pos.x++; - vt102_cursor_normalize(v,wrap,scroll); -} - -while (x<0) { - x++; - v->pos.x--; - vt102_cursor_normalize(v,wrap,scroll); -} - -while (y>0) { - y--; - v->pos.y++; - vt102_cursor_normalize(v,wrap,scroll); -} - -while (y<0) { - y++; - v->pos.y--; - vt102_cursor_normalize(v,wrap,scroll); + while (x > 0) + { + x--; + v->pos.x++; + vt102_cursor_normalize (v, wrap, scroll); + } + + while (x < 0) + { + x++; + v->pos.x--; + vt102_cursor_normalize (v, wrap, scroll); + } + + while (y > 0) + { + y--; + v->pos.y++; + vt102_cursor_normalize (v, wrap, scroll); + } + + while (y < 0) + { + y++; + v->pos.y--; + vt102_cursor_normalize (v, wrap, scroll); + } } -} void vt102_parse_char (VT102 * v, int c) { - VT102_parser *p = &v->p; + VT102_parser *p = &v->parser; if (p->in_csi) @@ -225,27 +241,27 @@ vt102_parse_char (VT102 * v, int c) /*ACK*/ case 6: /*BEL*/ case 7: /*BS*/ case 8: - vt102_cursor_motion(v,-1,0,0,0); + vt102_cursor_motion (v, -1, 0, 0, 0); break; /*HT*/ case 9: break; /*LF*/ case 10: - vt102_cursor_motion(v,0,1,0,1); + vt102_cursor_motion (v, 0, 1, 0, 1); break; /*VT*/ case 11: break; /*FF*/ case 12: break; /*CR*/ case 13: - v->pos.x=0; + v->pos.x = 0; break; /*SO*/ case 14: /*SI*/ case 15: /*DLE*/ case 16: - /*DC1*/ case 17: - /*DC2*/ case 18: - /*DC3*/ case 19: - /*DC4*/ case 20: + /*DC1 */ case 17: + /*DC2 */ case 18: + /*DC3 */ case 19: + /*DC4 */ case 20: /*NAK*/ case 21: /*SYN*/ case 22: /*ETB*/ case 23: @@ -262,10 +278,10 @@ vt102_parse_char (VT102 * v, int c) /*US*/ case 31: /*DEL*/ case 127: break; - /*regular character*/ default: - v->crt->screen[CRT_ADDR_POS(&v->pos)].chr=c; - v->crt->screen[CRT_ADDR_POS(&v->pos)].attr=v->attr; - vt102_cursor_motion(v,1,0); + /*regular character */ default: + v->crt.screen[CRT_ADDR_POS (&v->pos)].chr = c; + v->crt.screen[CRT_ADDR_POS (&v->pos)].attr = v->attr; + vt102_cursor_motion (v, 1, 0, 1, 1); } } } |