diff options
author | james <> | 2008-02-04 20:23:55 +0000 |
---|---|---|
committer | james <> | 2008-02-04 20:23:55 +0000 |
commit | 28a52b2df7761bd97d74938d582b1f678d23c756 (patch) | |
tree | 731cb3fc7bfe081dd49264142def881b0adf2776 /src/ansi.c | |
parent | a1b65048ff1a96b50d30d327c969e10b77856499 (diff) | |
download | sympathy-28a52b2df7761bd97d74938d582b1f678d23c756.tar.gz sympathy-28a52b2df7761bd97d74938d582b1f678d23c756.tar.bz2 sympathy-28a52b2df7761bd97d74938d582b1f678d23c756.zip |
*** empty log message ***
Diffstat (limited to 'src/ansi.c')
-rw-r--r-- | src/ansi.c | 41 |
1 files changed, 26 insertions, 15 deletions
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.4 2008/02/04 20:23:55 james + * *** empty log message *** + * * Revision 1.3 2008/02/04 05:45:55 james * :: * @@ -28,17 +31,20 @@ ansi_write (ANSI * a, char *buf, int n) write (a->fd, buf, n); } -void -ansi_getsize(ANSI *a) +void +ansi_getsize (ANSI * a) { -struct winsize sz={0}; -if (ioctl(a->fd,TIOCGWINSZ,&sz)) { - a->size.x=CRT_COLS; - a->size.y=CRT_ROWS; -} else { - a->size.x=sz.ws_col; - a->size.y=sz.ws_row; -} + struct winsize sz = { 0 }; + if (ioctl (a->fd, TIOCGWINSZ, &sz)) + { + a->size.x = CRT_COLS; + a->size.y = CRT_ROWS; + } + else + { + a->size.x = sz.ws_col; + a->size.y = sz.ws_row; + } } @@ -48,9 +54,10 @@ ansi_move (ANSI * a, CRT_Pos p) { char buf[16]; int n; - int dx = a->pos.x - p.x; - int dy = a->pos.y - p.y; + int dx = p.x - a->pos.x; + int dy = p.y - a->pos.y; +// a->pos.x = ANSI_INVAL; if (a->pos.x != ANSI_INVAL) { @@ -107,12 +114,12 @@ ansi_move (ANSI * a, CRT_Pos p) } else if (dy > 0) { - n = snprintf (buf, sizeof (buf), "\033[%dE", -dy); + n = snprintf (buf, sizeof (buf), "\033[%dE", dy); ansi_write (a, buf, n); } else { - n = snprintf (buf, sizeof (buf), "\033[%dF", dy); + n = snprintf (buf, sizeof (buf), "\033[%dF", -dy); ansi_write (a, buf, n); } } @@ -168,6 +175,8 @@ ansi_set_attr (ANSI * a, int attr) if (!dif) return; + a->attr = attr; + if (attr == CRT_ATTR_NORMAL) { ansi_force_attr_normal (a); @@ -207,6 +216,7 @@ ansi_set_attr (ANSI * a, int attr) ansi_write (a, "\033[22m", 5); } } + } @@ -240,6 +250,7 @@ ansi_cls (ANSI * a) CRT_Pos p = { 0 }; crt_cls (&a->crt); + ansi_force_attr_normal (a); ansi_move (a, p); ansi_write (a, "\033[2J", 4); @@ -287,7 +298,7 @@ ansi_reset (ANSI * a) { // FIXME: -- echos back crap? // ansi_write (a, "\033[c", 3); - ansi_getsize(a); + ansi_getsize (a); a->pos.x = ANSI_INVAL; a->hide_cursor = ANSI_INVAL; |