aboutsummaryrefslogtreecommitdiffstats
path: root/src/ansi.c
diff options
context:
space:
mode:
authorjames <>2008-02-13 09:12:21 +0000
committerjames <>2008-02-13 09:12:21 +0000
commit23dc931ca671e938da071d24d8e9b6052e49923a (patch)
treef60e7ebd00db56a2757479334f4c8742cd6fcc13 /src/ansi.c
parent4d50b220e63c52d412bacebb3e44cc712f2e2804 (diff)
downloadsympathy-23dc931ca671e938da071d24d8e9b6052e49923a.tar.gz
sympathy-23dc931ca671e938da071d24d8e9b6052e49923a.tar.bz2
sympathy-23dc931ca671e938da071d24d8e9b6052e49923a.zip
*** empty log message ***
Diffstat (limited to 'src/ansi.c')
-rw-r--r--src/ansi.c112
1 files changed, 50 insertions, 62 deletions
diff --git a/src/ansi.c b/src/ansi.c
index b6f30f9..12a0563 100644
--- a/src/ansi.c
+++ b/src/ansi.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.18 2008/02/13 09:12:21 james
+ * *** empty log message ***
+ *
* Revision 1.17 2008/02/13 01:08:18 james
* *** empty log message ***
*
@@ -64,24 +67,6 @@ static char rcsid[] = "$Id$";
*/
#include "project.h"
-static void
-set_nonblocking (int fd)
-{
- long arg;
- arg = fcntl (fd, F_GETFL, arg);
- arg |= O_NONBLOCK;
- fcntl (fd, F_SETFL, arg);
-}
-
-static void
-set_blocking (int fd)
-{
- long arg;
- arg = fcntl (fd, F_GETFL, arg);
- arg &= ~O_NONBLOCK;
- fcntl (fd, F_SETFL, arg);
-}
-
void
ansi_move (ANSI * a, CRT_Pos p)
@@ -431,7 +416,26 @@ ansi_draw (ANSI * a, CRT * c)
int o;
int hidden_cursor = 0;
- if (crt_pos_cmp(a->terminal.size,a->size)) {
+ if (crt_pos_cmp (a->terminal->size, a->size))
+ {
+ terminal_getsize (a->terminal);
+
+ a->size = a->terminal->size;
+
+ a->pos.x = ANSI_INVAL;
+ a->hide_cursor = ANSI_INVAL;
+
+ crt_reset (&a->crt);
+
+// FIXME: -- echos back crap?
+// a->terminal->xmit (a->terminal, "\033[c", 3);
+
+ ansi_cls (a);
+ a->terminal->xmit (a->terminal, "\033=", 2);
+ a->terminal->xmit (a->terminal, "\033[?6l", 5);
+ a->terminal->xmit (a->terminal, "\033[r", 3);
+
+ }
for (p.y = 0; p.y < CRT_ROWS; ++p.y)
@@ -487,34 +491,19 @@ ansi_draw (ANSI * a, CRT * c)
void
ansi_reset (ANSI * a)
{
-// FIXME: -- echos back crap?
-// a->terminal->xmit (a->terminal, "\033[c", 3);
-
- terminal_getsize(a->terminal);
-
- a->size=a->terminal->size;
-
- a->pos.x = ANSI_INVAL;
- a->hide_cursor = ANSI_INVAL;
-
- crt_reset (&a->crt);
-
- ansi_cls (a);
- a->terminal->xmit (a->terminal, "\033=", 2);
- a->terminal->xmit (a->terminal, "\033[?6l", 5);
- a->terminal->xmit (a->terminal, "\033[r", 3);
+ a->size.x = -1;
ansi_draw (a, &a->crt);
}
void
-ansi_flush_escape (ANSI * a, Context *c)
+ansi_flush_escape (ANSI * a, Context * c)
{
ANSI_Parser *p = &a->parser;
int i;
for (i = 0; i < p->escape_ptr; ++i)
{
- vt102_send (c->v, p->escape_buf[i], c->t);
+ vt102_send (c, p->escape_buf[i]);
}
p->escape_ptr = 0;
@@ -522,7 +511,7 @@ ansi_flush_escape (ANSI * a, Context *c)
}
void
-ansi_parse_deckey (ANSI * a, Context *c)
+ansi_parse_deckey (ANSI * a, Context * c)
{
ANSI_Parser *p = &a->parser;
if ((p->escape_buf[1] != '[') && (p->escape_buf[1] != 'O'))
@@ -533,15 +522,15 @@ ansi_parse_deckey (ANSI * a, Context *c)
if ((p->escape_buf[2] >= 'A') || (p->escape_buf[2] <= 'Z'))
{
- vt102_send (c->v, KEY_UP + (p->escape_buf[2] - 'A'), c->t);
+ vt102_send (c, KEY_UP + (p->escape_buf[2] - 'A'));
}
else if ((p->escape_buf[2] >= 'a') || (p->escape_buf[2] <= 'z'))
{
- vt102_send (c->v, KEY_154 + (p->escape_buf[2] - 'a'), c->t);
+ vt102_send (c, KEY_154 + (p->escape_buf[2] - 'a'));
}
else
{
- ansi_flush_escape (a,c);
+ ansi_flush_escape (a, c);
return;
}
p->in_escape = 0;
@@ -549,7 +538,7 @@ ansi_parse_deckey (ANSI * a, Context *c)
}
void
-ansi_parse_ansikey (ANSI * a,Context *c)
+ansi_parse_ansikey (ANSI * a, Context * c)
{
ANSI_Parser *p = &a->parser;
@@ -560,11 +549,11 @@ ansi_parse_ansikey (ANSI * a,Context *c)
}
if ((p->escape_buf[2] >= '0') || (p->escape_buf[2] <= '9'))
{
- vt102_send (c->v, KEY_180 + (p->escape_buf[2] - '0'), c->t);
+ vt102_send (c, KEY_180 + (p->escape_buf[2] - '0'));
}
else
{
- ansi_flush_escape (a,c);
+ ansi_flush_escape (a, c);
return;
}
@@ -575,7 +564,7 @@ ansi_parse_ansikey (ANSI * a,Context *c)
void
-ansi_parse_escape (ANSI * a,Context *c)
+ansi_parse_escape (ANSI * a, Context * c)
{
ANSI_Parser *p = &a->parser;
switch (p->escape_ptr)
@@ -590,7 +579,7 @@ ansi_parse_escape (ANSI * a,Context *c)
case 'O':
break;
default:
- ansi_flush_escape (a,c);
+ ansi_flush_escape (a, c);
}
break;
case 3:
@@ -601,10 +590,10 @@ ansi_parse_escape (ANSI * a,Context *c)
break;
case '[':
if ((p->escape_buf[2] >= 'A') && (p->escape_buf[2] <= 'Z'))
- ansi_parse_deckey (a,c);
+ ansi_parse_deckey (a, c);
break;
default:
- ansi_flush_escape (a,c);
+ ansi_flush_escape (a, c);
}
break;
case 4:
@@ -614,17 +603,17 @@ ansi_parse_escape (ANSI * a,Context *c)
ansi_parse_ansikey (a, c);
break;
default:
- ansi_flush_escape (a,c);
+ ansi_flush_escape (a, c);
}
break;
case 5:
- ansi_flush_escape (a,c);
+ ansi_flush_escape (a, c);
}
}
void
-ansi_check_escape (ANSI * a, Context *c)
+ansi_check_escape (ANSI * a, Context * c)
{
ANSI_Parser *p = &a->parser;
struct timeval now, diff;
@@ -642,13 +631,13 @@ ansi_check_escape (ANSI * a, Context *c)
/*Time up? */
if (diff.tv_sec || (diff.tv_usec > ANSI_ESCAPE_TIMEOUT))
- ansi_flush_escape (a,c);
+ ansi_flush_escape (a, c);
}
void
-ansi_parse_char (ANSI * a,Context *c, int ch)
+ansi_parse_char (ANSI * a, Context * c, int ch)
{
ANSI_Parser *p = &a->parser;
@@ -659,7 +648,7 @@ ansi_parse_char (ANSI * a,Context *c, int ch)
if (ch == 033)
{
if (p->in_escape)
- ansi_flush_escape (a,c);
+ ansi_flush_escape (a, c);
p->in_escape++;
p->escape_ptr = 0;
@@ -669,32 +658,31 @@ ansi_parse_char (ANSI * a,Context *c, int ch)
if (p->in_escape)
{
p->escape_buf[p->escape_ptr++] = ch;
- ansi_parse_escape (a,c);
+ ansi_parse_escape (a, c);
}
else
{
- vt102_send (c->v, ch, c->t);
+ vt102_send (c, ch);
}
}
void
-ansi_parse (ANSI * a,Context *c, char *buf, int len)
+ansi_parse (ANSI * a, Context * c, char *buf, int len)
{
while (len--)
- ansi_parse_char (a,c, *(buf++));
+ ansi_parse_char (a, c, *(buf++));
}
int
-ansi_dispatch (ANSI * a, Context *c)
+ansi_dispatch (ANSI * a, Context * c)
{
char buf[1024];
int red;
ansi_check_escape (a, c);
-
- red = a->terminal->recv(a->terminal,buf,sizeof(buf));
+ red = a->terminal->recv (a->terminal, buf, sizeof (buf));
if (red <= 0)
return red;
@@ -709,7 +697,7 @@ ansi_dispatch (ANSI * a, Context *c)
#endif
- ansi_parse (a,c, buf, red );
+ ansi_parse (a, c, buf, red);
return 0;
}