From d6c2a27d3304842fab285a4217518046b57b771b Mon Sep 17 00:00:00 2001 From: james <> Date: Wed, 27 Feb 2008 09:42:22 +0000 Subject: *** empty log message *** --- apps/mainloop.c | 7 +++-- apps/mainloop.h | 5 +++- apps/sympathy.c | 35 ++++++++++++++++++----- apps/usage.c | 6 ++++ src/ansi.c | 42 +++++++++++++++------------ src/crt.c | 6 +++- src/crt.h | 5 +++- src/html.c | 7 +++-- src/prototypes.h | 5 ++-- src/ptty.c | 9 ++++-- src/version.c | 7 +++-- src/vt102.c | 68 +++++++++++++++++++++++++++----------------- test/vttest-20071216.tar.gz | Bin 0 -> 155273 bytes version-files | 55 +++++++++++++++++++++++++++++++++-- 14 files changed, 190 insertions(+), 67 deletions(-) create mode 100644 test/vttest-20071216.tar.gz diff --git a/apps/mainloop.c b/apps/mainloop.c index d546ac5..146ebdd 100644 --- a/apps/mainloop.c +++ b/apps/mainloop.c @@ -11,6 +11,9 @@ static char rcsid[] = /* * $Log$ + * Revision 1.16 2008/02/27 09:42:21 james + * *** empty log message *** + * * Revision 1.15 2008/02/27 01:31:38 james * *** empty log message *** * @@ -397,7 +400,7 @@ msg_from_server (ANSI * a, IPC_Msg * m, Context * c) void mainloop (TTY * tty, Socket * server_socket, Socket * client_socket, - ANSI * ansi, Log * log, int nhistory, int width) + ANSI * ansi, Log * log, int nhistory, CRT_Pos *size ) { fd_set rfds, wfds; Context c = { 0 }; @@ -408,7 +411,7 @@ mainloop (TTY * tty, Socket * server_socket, Socket * client_socket, c.tp = tty_parser_new (); c.u = utf8_new (); - c.v = vt102_new (width); + c.v = vt102_new (size); c.h = history_new (nhistory); c.l = log; /* are we being fed by a tty or a socket */ diff --git a/apps/mainloop.h b/apps/mainloop.h index 5d347e7..cea139e 100644 --- a/apps/mainloop.h +++ b/apps/mainloop.h @@ -12,6 +12,9 @@ /* * $Log$ + * Revision 1.4 2008/02/27 09:42:21 james + * *** empty log message *** + * * Revision 1.3 2008/02/27 01:31:14 james * *** empty log message *** * @@ -30,6 +33,6 @@ extern void mainloop (TTY * tty, Socket * server_socket, Socket * client_socket, ANSI * a, - Log * log, int nhistory, int width); + Log * log, int nhistory, CRT_Pos *size); #endif /* __MAINLOOP_H__ */ diff --git a/apps/sympathy.c b/apps/sympathy.c index a8dba28..e93c930 100644 --- a/apps/sympathy.c +++ b/apps/sympathy.c @@ -11,6 +11,9 @@ static char rcsid[] = /* * $Log$ + * Revision 1.17 2008/02/27 09:42:21 james + * *** empty log message *** + * * Revision 1.16 2008/02/27 01:31:38 james * *** empty log message *** * @@ -245,7 +248,7 @@ main (int argc, char *argv[]) int c; extern char *optarg; extern int optind, opterr, optopt; - int width = VT102_COLS_80; + CRT_Pos size={VT102_COLS_80,VT102_ROWS}; int oflags[128]; char *oargs[128]; @@ -262,7 +265,7 @@ main (int argc, char *argv[]) memset (oflags, 0, sizeof (oflags)); memset (oargs, 0, sizeof (oargs)); - while ((c = getopt (argc, argv, "w:utscr:lKHd:pb:fL:Fk:n:")) != EOF) + while ((c = getopt (argc, argv, "vw:utscr:lKHd:pb:fL:Fk:n:")) != EOF) { switch (c) { @@ -310,11 +313,16 @@ main (int argc, char *argv[]) sum += (oflags['s'] || oflags['c']) ? 1 : 0; sum += oflags['r']; sum += oflags['l']; + sum += oflags['v']; if (sum != 1) - fatal_moan ("specifiy exactly one of ( -c and or -s ), -t, -r and -l"); + fatal_moan ("specifiy exactly one of ( -c and or -s ), -t, -r, -l and -v"); } + if (oflags['v']) { + fprintf("Version: %s\n",libsympathy_version()); + return 0; + } if (oflags['l']) return list_sockets (); @@ -420,9 +428,22 @@ main (int argc, char *argv[]) if (oflags['w']) { - width = safe_atoi (oargs['w']); - if ((width > VT102_MAX_COLS) || (width < 1)) + char buf[128],*ptr; + strcpy(buf,oargs['w']); + ptr=index(buf,'x'); + if (ptr) { + *ptr=0; + ptr++; + size.y=safe_atoi(ptr); + } + size.x=safe_atoi(buf); + + if ((size.x > VT102_MAX_COLS) || (size.x < 1)) fatal_moan ("-w requires a width between 1 and %d\n", VT102_MAX_COLS); + + if ((size.y > VT102_ROWS) || (size.y < 1)) + fatal_moan ("-w requires a height between 1 and %d\n", VT102_MAX_COLS); + } if (oflags['s'] && !oflags['F']) @@ -443,7 +464,7 @@ main (int argc, char *argv[]) if (oflags['p']) { - tty = ptty_open (NULL, NULL, width); + tty = ptty_open (NULL, NULL, &size); if (!tty) fatal_moan ("unable to open a ptty"); } @@ -500,7 +521,7 @@ main (int argc, char *argv[]) } } - mainloop (tty, server_socket, client_socket, ansi, log, history, width); + mainloop (tty, server_socket, client_socket, ansi, log, history, &size); if (ansi) { diff --git a/apps/usage.c b/apps/usage.c index cf79d6d..598ccb7 100644 --- a/apps/usage.c +++ b/apps/usage.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.12 2008/02/27 09:42:21 james + * *** empty log message *** + * * Revision 1.11 2008/02/27 01:31:38 james * *** empty log message *** * @@ -61,6 +64,7 @@ usage (void) "sympathy -c [-H] [-u] -k skt\n" "sympathy -r id [-H] [-u]\n" "sympathy {-l|-ls}\n" + "sympathy -v\n" "sympathy -h\n" "\n" "Main mode:\n" @@ -75,6 +79,8 @@ usage (void) " -r id client mode: connect to server mode process on socket\n" " ~/.sympathy/id\n" " -l or -ls list active sockets in ~/.sympathy\n" + " -v show version\n" + " -h show help\n" "\n" "Options:\n" " -K lock the serial device. By default sympathy checks that no\n" diff --git a/src/ansi.c b/src/ansi.c index e029c25..42f6a4c 100644 --- a/src/ansi.c +++ b/src/ansi.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.33 2008/02/27 09:42:21 james + * *** empty log message *** + * * Revision 1.32 2008/02/26 23:56:12 james * *** empty log message *** * @@ -502,7 +505,7 @@ ansi_draw_line (ANSI * a, CRT_CA * cap, int y) CRT_Pos p = { 0, y }; CRT_CA *acap = &a->crt.screen[CRT_ADDR_POS (&p)]; - for (p.x = 0; p.x < a->crt.width; ++p.x) + for (p.x = 0; p.x < a->crt.size.x; ++p.x) { if (p.x >= a->size.x) continue; @@ -522,10 +525,10 @@ ansi_draw_line (ANSI * a, CRT_CA * cap, int y) } static void -ansi_resize_check (ANSI * a, int new_width) +ansi_resize_check (ANSI * a, CRT_Pos *size) { - if ((new_width && (new_width != a->crt.width)) + if ((size && crt_pos_cmp(a->crt.size,*size)) || crt_pos_cmp (a->terminal->size, a->size)) { @@ -538,8 +541,8 @@ ansi_resize_check (ANSI * a, int new_width) crt_reset (&a->crt); - if (new_width) - a->crt.width = new_width; + if (size) + a->crt.size =*size; // FIXME: -- echos back crap? // a->terminal->xmit (a->terminal, "\033[c", 3); @@ -564,7 +567,6 @@ ansi_resize_check (ANSI * a, int new_width) } } -#define HISTORY_GUESS_SCROLL 24 /*guess all 24 lines usually scroll */ /*if they haven't then ansi_draw will patch it up*/ static void @@ -572,19 +574,23 @@ ansi_history (ANSI * a, History * h) { char buf[32]; int i; + int guess_scroll; /*Do we need to catch up on history?*/ if (a->history_ptr == h->wptr) return; - ansi_resize_check (a, 0); + ansi_resize_check (a, NULL); - if ((a->size.x < a->crt.width) || (a->size.y < CRT_ROWS)) + if ((a->size.x < a->crt.size.x) || (a->size.y < a->crt.size.y)) return; + guess_scroll=a->crt.size.y-1; /*Bototm line should be a status line*/ + + ansi_force_attr_normal (a); ansi_set_color (a, CRT_COLOR_NORMAL); - i = sprintf (buf, "\033[%d;%dr", 1, HISTORY_GUESS_SCROLL); + i = sprintf (buf, "\033[%d;%dr", 1, guess_scroll); a->terminal->xmit (a->terminal, buf, i); @@ -602,14 +608,14 @@ ansi_history (ANSI * a, History * h) ansi_draw_line (a, e->line, 0); - /*Roll HISTORY_GUESS_SCROLL lines up putting the top line into the xterm's history */ + /*Roll guess_scroll lines up putting the top line into the xterm's history */ /*Make extra lines a predictable colour */ ansi_set_color (a, CRT_COLOR_NORMAL); ansi_showhide_cursor (a, 1); - i = sprintf (buf, "\033[%d;%dH", HISTORY_GUESS_SCROLL, 1); + i = sprintf (buf, "\033[%d;%dH", guess_scroll, 1); a->terminal->xmit (a->terminal, buf, i); a->terminal->xmit (a->terminal, "\033D", 2); a->pos.x = ANSI_INVAL; @@ -623,11 +629,11 @@ ansi_history (ANSI * a, History * h) 0}; /*scroll lines up */ - for (s.y++; s.y < HISTORY_GUESS_SCROLL; s.y++, e.y++) + for (s.y++; s.y < guess_scroll; s.y++, e.y++) { memcpy (&a->crt.screen[CRT_ADDR_POS (&e)], &a->crt.screen[CRT_ADDR_POS (&s)], - sizeof (CRT_CA) * a->crt.width); + sizeof (CRT_CA) * a->crt.size.x); } /* erase new line */ @@ -653,10 +659,10 @@ ansi_draw (ANSI * a, CRT * c) int o; int hidden_cursor = 0; - ansi_resize_check (a, c->width); + ansi_resize_check (a, &c->size); - for (p.y = 0; p.y < CRT_ROWS; ++p.y) + for (p.y = 0; p.y < a->crt.size.y; ++p.y) { if (p.y >= a->size.y) continue; @@ -666,7 +672,7 @@ ansi_draw (ANSI * a, CRT * c) } - if ((c->width > a->size.x) || (CRT_ROWS > a->size.y)) + if ((c->size.x > a->size.x) || (c->size.y > a->size.y)) { char msg[1024]; // = "Window is too small"; int i; @@ -675,7 +681,7 @@ ansi_draw (ANSI * a, CRT * c) i = sprintf (msg, "Window too small (%dx%d need %dx%d)", a->size.x, - a->size.y, c->width, CRT_ROWS); + a->size.y, c->size.x, c->size.y); ansi_showhide_cursor (a, 1); ansi_set_attr (a, CRT_ATTR_REVERSE); @@ -710,7 +716,7 @@ ansi_reset (ANSI * a, CRT * c) static void ansi_terminal_reset (ANSI * a) { - CRT_Pos p = { 0, CRT_ROWS }; + CRT_Pos p = { 0, a->crt.size.y}; ansi_force_attr_normal (a); ansi_move (a, p); diff --git a/src/crt.c b/src/crt.c index 9d6606a..7e7c647 100644 --- a/src/crt.c +++ b/src/crt.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.15 2008/02/27 09:42:21 james + * *** empty log message *** + * * Revision 1.14 2008/02/27 00:27:21 james * *** empty log message *** * @@ -167,7 +170,8 @@ crt_reset (CRT * c) c->pos.x = 0; c->pos.y = 0; c->hide_cursor = 1; - c->width = CRT_COLS; + c->size.x = CRT_COLS; + c->size.y = CRT_ROWS; #if 0 c->sh.dir = 0; #endif diff --git a/src/crt.h b/src/crt.h index 5883c04..bc58a5d 100644 --- a/src/crt.h +++ b/src/crt.h @@ -12,6 +12,9 @@ /* * $Log$ + * Revision 1.13 2008/02/27 09:42:22 james + * *** empty log message *** + * * Revision 1.12 2008/02/26 23:23:17 james * *** empty log message *** * @@ -119,7 +122,7 @@ typedef struct CRT_struct CRT_CA screen[CRT_CELS]; CRT_Pos pos; int hide_cursor; - int width; + CRT_Pos size; } CRT; diff --git a/src/html.c b/src/html.c index 5a0bf4a..15ca782 100644 --- a/src/html.c +++ b/src/html.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.9 2008/02/27 09:42:22 james + * *** empty log message *** + * * Revision 1.8 2008/02/27 01:52:38 james * *** empty log message *** * @@ -156,13 +159,13 @@ html_draw (FILE * f, CRT * c) #else fprintf (f, "