aboutsummaryrefslogtreecommitdiffstats
path: root/src/ansi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ansi.c')
-rw-r--r--src/ansi.c71
1 files changed, 49 insertions, 22 deletions
diff --git a/src/ansi.c b/src/ansi.c
index 3e925c5..4e951bb 100644
--- a/src/ansi.c
+++ b/src/ansi.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.7 2008/02/06 20:26:57 james
+ * *** empty log message ***
+ *
* Revision 1.6 2008/02/06 17:53:28 james
* *** empty log message ***
*
@@ -271,10 +274,7 @@ ansi_draw (ANSI * a, CRT * c)
{
CRT_Pos p;
int o;
- int hidden_cursor=0;
-
-
-
+ int hidden_cursor = 0;
for (p.y = 0; p.y < CRT_ROWS; ++p.y)
{
@@ -287,7 +287,7 @@ ansi_draw (ANSI * a, CRT * c)
continue;
if (crt_ca_cmp (a->crt.screen[o], c->screen[o]))
{
- ansi_showhide_cursor (a, 1);
+ ansi_showhide_cursor (a, 1);
a->crt.screen[o] = c->screen[o];
ansi_move (a, p);
@@ -297,25 +297,26 @@ ansi_draw (ANSI * a, CRT * c)
}
- if ((CRT_COLS>a->size.x) || (CRT_ROWS>a->size.y)) {
- char msg[]="Window is too small";
- p.x=0;
- p.y=0;
+ if ((CRT_COLS > a->size.x) || (CRT_ROWS > a->size.y))
+ {
+ char msg[] = "Window is too small";
+ p.x = 0;
+ p.y = 0;
+
+ ansi_showhide_cursor (a, 1);
+ ansi_set_attr (a, CRT_ATTR_REVERSE);
+ ansi_move (a, p);
+
+ ansi_write (a, msg, sizeof (msg));
+ a->pos.x = ANSI_INVAL;
+ }
- ansi_showhide_cursor (a, 1);
- ansi_set_attr (a, CRT_ATTR_REVERSE);
- ansi_move(a,p);
-
- ansi_write (a, msg, sizeof(msg));
- a->pos.x = ANSI_INVAL;
- }
-
- if ((c->pos.x>=a->size.x)
- || (c->pos.y>=a->size.y)) {
- ansi_showhide_cursor (a, 1);
- return;
- }
+ if ((c->pos.x >= a->size.x) || (c->pos.y >= a->size.y))
+ {
+ ansi_showhide_cursor (a, 1);
+ return;
+ }
a->crt.pos = c->pos;
ansi_move (a, a->crt.pos);
@@ -339,3 +340,29 @@ ansi_reset (ANSI * a)
ansi_cls (a);
ansi_draw (a, &a->crt);
}
+
+void ansi_parse_char(ANSI *a,int c,VT102 *v)
+{
+vt102_send(v,c);
+}
+
+void ansi_parse(ANSI *a,char *buf,int len,VT102 *v)
+{
+while (len--)
+ansi_parse_char(a,*(buf++),v);
+}
+
+int ansi_dispatch(ANSI *a,VT102 *v)
+{
+char buf[1024];
+int red;
+
+red=read(a.fd,buf,sizeof(buf));
+if (red<0) return -1;
+if (!red) return -1;
+
+ansi_parse(a,buf,red,v);
+
+return 0;
+}
+int