From e32ce0cfdccf5240ae29ef06a13078ae37ee521a Mon Sep 17 00:00:00 2001 From: james <> Date: Wed, 13 Feb 2008 16:57:29 +0000 Subject: *** empty log message *** --- src/Makefile.am | 15 +++- src/ansi.c | 207 +++++++++++++++++++++++++++++++++++++++++-------- src/ansi.h | 8 +- src/history.c | 26 ++++++- src/history.h | 5 ++ src/libsympathy.c | 71 +---------------- src/project.h | 18 ++--- src/prototypes.h | 24 +++++- src/ring.c | 24 ++++++ src/slide.c | 84 ++++++++++++++++++++ src/slide.h | 44 +++++++++++ src/sympathy.h.head.in | 55 +++++++++++++ src/sympathy.h.in | 56 ------------- src/sympathy.h.tail | 5 ++ src/terminal.c | 23 +++++- src/tty.c | 27 +++++++ 16 files changed, 510 insertions(+), 182 deletions(-) create mode 100644 src/slide.c create mode 100644 src/slide.h create mode 100644 src/sympathy.h.head.in delete mode 100644 src/sympathy.h.in create mode 100644 src/sympathy.h.tail diff --git a/src/Makefile.am b/src/Makefile.am index 968d9de..efbeda7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,6 +8,9 @@ # $Id$ # # $Log$ +# Revision 1.9 2008/02/13 16:57:29 james +# *** empty log message *** +# # Revision 1.8 2008/02/13 09:12:20 james # *** empty log message *** # @@ -38,11 +41,12 @@ INCLUDES= -HDRS=ansi.h context.h crt.h history.h keys.h project.h prototypes.h \ - ring.h sympathy.h tty.h vt102.h +PROJECTHDRS= crt.h tty.h ansi.h vt102.h keys.h history.h ring.h slide.h log.h ipc.h context.h prototypes.h + +HDRS=project.h SRCS=ansi.c crt.c html.c libsympathy.c render.c version.c vt102.c tty.c \ - history.c ring.c ptty.c terminal.c util.c + history.c ring.c ptty.c terminal.c util.c log.c ipc.c slide.c CPROTO=cproto @@ -56,7 +60,7 @@ libsympathy_la_SOURCES = ${SYMPATHYSRCS} libsympathy_a_CFLAGS = ${AM_CFLAGS} -BUILT_SOURCES = version.h +BUILT_SOURCES = version.h sympathy.h lib_LIBRARIES=libsympathy.a lib_LTLIBRARIES=libsympathy.la @@ -85,6 +89,9 @@ protos: tidy: ${SRCS} ${HDRS} indent -i2 -ts0 ${SRCS} ${HDRS} +sympathy.h: ${PROJECTHDRS} sympathy.h.head sympathy.h.tail + cat sympathy.h.head ${PROJECTHDRS} sympathy.h.tail > $@ || /bin/rm -f $@ + version.h: $(VFD)/version-files $(VFD)/version-major \ $(VFD)/version-minor $(VFD)/version-micro \ $(VFD)/version-md5sums ${VFS} Makefile diff --git a/src/ansi.c b/src/ansi.c index 12a0563..7f44957 100644 --- a/src/ansi.c +++ b/src/ansi.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.19 2008/02/13 16:57:29 james + * *** empty log message *** + * * Revision 1.18 2008/02/13 09:12:21 james * *** empty log message *** * @@ -316,7 +319,7 @@ ansi_cls (ANSI * a) crt_cls (&a->crt); - ansi_force_attr_normal (a); + ansi_set_attr (a, CRT_ATTR_NORMAL); ansi_set_color (a, CRT_COLOR_NORMAL); ansi_move (a, p); a->terminal->xmit (a->terminal, "\033[2J", 4); @@ -410,67 +413,173 @@ ansi_spot_scroll (ANSI * a, CRT * c) void -ansi_draw (ANSI * a, CRT * c) +ansi_draw_line (ANSI * a, CRT_CA * cap, int y) { - CRT_Pos p; - int o; - int hidden_cursor = 0; + CRT_Pos p = { 0, y }; + CRT_CA *acap = &a->crt.screen[CRT_ADDR_POS (&p)]; - if (crt_pos_cmp (a->terminal->size, a->size)) + for (p.x = 0; p.x < CRT_COLS; ++p.x) { - terminal_getsize (a->terminal); + if (p.x >= a->size.x) + continue; - a->size = a->terminal->size; + if (crt_ca_cmp (*acap, *cap)) + { + ansi_showhide_cursor (a, 1); + *acap = *cap; - a->pos.x = ANSI_INVAL; - a->hide_cursor = ANSI_INVAL; + ansi_move (a, p); + ansi_render (a, *acap); + } - crt_reset (&a->crt); + acap++; + cap++; + } +} + +void +ansi_resize_check (ANSI * a) +{ + + if (!crt_pos_cmp (a->terminal->size, a->size)) + return; + + 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); + 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); + +} + +#define HISTORY_GUESS_SCROLL 24 /*guess all 24 lines usually scroll */ +/*if they haven't then ansi_draw will patch it up*/ + +void +ansi_history (ANSI * a, History * h) +{ + char buf[32]; + int i; +/*Do we need to catch up on history?*/ + + if (a->history_ptr == h->wptr) + return; + ansi_resize_check (a); + + if ((a->size.x < CRT_COLS) || (a->size.y < CRT_ROWS)) + return; + + ansi_force_attr_normal (a); + ansi_set_color (a, CRT_COLOR_NORMAL); + + i = sprintf (buf, "\033[%d;%dr", 1, HISTORY_GUESS_SCROLL); + a->terminal->xmit (a->terminal, buf, i); + + + while (a->history_ptr != h->wptr) + { + + History_ent *e = &h->lines[a->history_ptr]; + + HISTORY_INC (h, a->history_ptr); + + if (!e->valid) + continue; + + /*If so write the line ot the top of the screen */ + ansi_draw_line (a, e->line, 0); + + + /*Roll HISTORY_GUESS_SCROLL lines up putting the top line into the xterm's history */ + + + ansi_showhide_cursor (a, 1); + i = sprintf (buf, "\033[%d;%dH", HISTORY_GUESS_SCROLL, 1); + a->terminal->xmit (a->terminal, buf, i); + a->terminal->xmit (a->terminal, "\033D", 2); + a->pos.x = ANSI_INVAL; + + /*now do the same in our image of the screen */ + + { + CRT_Pos s = { 0 } + , e = + { + 0}; + + /*scroll lines up */ + for (s.y++; s.y < HISTORY_GUESS_SCROLL; s.y++, e.y++) + { + memcpy (&a->crt.screen[CRT_ADDR_POS (&e)], + &a->crt.screen[CRT_ADDR_POS (&s)], + sizeof (CRT_CA) * CRT_COLS); + } + + /* erase new line */ + s.y = e.y; + e.x = CRT_COLS - 1; + crt_erase (&a->crt, s, e, 1); + } } +/*reset margins*/ + a->terminal->xmit (a->terminal, "\033[r", 3); + a->pos.x = ANSI_INVAL; + +} + + + + +void +ansi_draw (ANSI * a, CRT * c) +{ + CRT_Pos p; + int o; + int hidden_cursor = 0; + + ansi_resize_check (a); + for (p.y = 0; p.y < CRT_ROWS; ++p.y) { if (p.y >= a->size.y) continue; - o = CRT_ADDR (p.y, 0); - for (p.x = 0; p.x < CRT_COLS; ++p.x, ++o) - { - if (p.x >= a->size.x) - continue; - if (crt_ca_cmp (a->crt.screen[o], c->screen[o])) - { - ansi_showhide_cursor (a, 1); - a->crt.screen[o] = c->screen[o]; - ansi_move (a, p); - ansi_render (a, a->crt.screen[o]); - } - } + ansi_draw_line (a, &c->screen[CRT_ADDR (p.y, 0)], p.y); + } if ((CRT_COLS > a->size.x) || (CRT_ROWS > a->size.y)) { - char msg[] = "Window is too small"; + char msg[1024]; // = "Window is too small"; + int i; p.x = 0; p.y = 0; + i = + sprintf (msg, "Window too small (%dx%d need %dx%d)", a->size.x, + a->size.y, CRT_COLS, CRT_ROWS); + ansi_showhide_cursor (a, 1); ansi_set_attr (a, CRT_ATTR_REVERSE); ansi_set_color (a, CRT_MAKE_COLOR (CRT_COLOR_WHITE, CRT_COLOR_RED)); ansi_move (a, p); - a->terminal->xmit (a->terminal, msg, sizeof (msg)); + a->terminal->xmit (a->terminal, msg, i); a->pos.x = ANSI_INVAL; } @@ -489,10 +598,19 @@ ansi_draw (ANSI * a, CRT * c) } void -ansi_reset (ANSI * a) +ansi_reset (ANSI * a, CRT * c) { a->size.x = -1; - ansi_draw (a, &a->crt); + ansi_draw (a, c ? c : &a->crt); +} + +void +ansi_terminal_reset (ANSI * a) +{ + CRT_Pos p = { 0, CRT_ROWS }; + ansi_force_attr_normal (a); + + ansi_move (a, p); } void @@ -682,6 +800,10 @@ ansi_dispatch (ANSI * a, Context * c) ansi_check_escape (a, c); + + if (!a->terminal) + return; + red = a->terminal->recv (a->terminal, buf, sizeof (buf)); if (red <= 0) return red; @@ -691,9 +813,18 @@ ansi_dispatch (ANSI * a, Context * c) return -1; #endif -#if 0 +#if 1 if (*buf == 1) - return 1; + { + ansi_reset (a, NULL); + return 0; + } + if (*buf == 2) + { + a->history_ptr = c->h->wptr; + HISTORY_INC (c->h, a->history_ptr); + return 0; + } #endif @@ -701,3 +832,11 @@ ansi_dispatch (ANSI * a, Context * c) return 0; } + + +void +ansi_update (ANSI * a, Context * c) +{ + ansi_history (a, c->h); + ansi_draw (a, &c->v->crt); +} diff --git a/src/ansi.h b/src/ansi.h index 1368ada..7aa5935 100644 --- a/src/ansi.h +++ b/src/ansi.h @@ -12,6 +12,9 @@ /* * $Log$ + * Revision 1.7 2008/02/13 16:57:29 james + * *** empty log message *** + * * Revision 1.6 2008/02/13 01:08:18 james * *** empty log message *** * @@ -50,6 +53,8 @@ typedef struct typedef struct { + ANSI_Parser parser; + TTY *terminal; CRT crt; @@ -59,7 +64,8 @@ typedef struct int attr; int color; - ANSI_Parser parser; + + int history_ptr; } ANSI; diff --git a/src/history.c b/src/history.c index b8637aa..24d3692 100644 --- a/src/history.c +++ b/src/history.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.3 2008/02/13 16:57:29 james + * *** empty log message *** + * * Revision 1.2 2008/02/12 22:36:46 james * *** empty log message *** * @@ -49,13 +52,28 @@ history_free (History * h) void history_add (History * h, CRT_CA * c) { + History_ent *e; if (!h) return; - memcpy (h->lines[h->wptr].line, c, sizeof (CRT_CA) * CRT_COLS); - h->wptr++; + e = &h->lines[h->wptr]; + HISTORY_INC (h, h->wptr); + + memcpy (e->line, c, sizeof (CRT_CA) * CRT_COLS); + time (&e->t); + e->valid = 1; + +#if 0 + { + int i = CRT_COLS; + while (i--) + { + fputc (c->chr, stderr); + c++; + } + fputc ('\n', stderr); + } +#endif - if (h->wptr == h->nlines) - h->wptr = 0; } diff --git a/src/history.h b/src/history.h index 79661af..5c5dd52 100644 --- a/src/history.h +++ b/src/history.h @@ -12,6 +12,9 @@ /* * $Log$ + * Revision 1.3 2008/02/13 16:57:29 james + * *** empty log message *** + * * Revision 1.2 2008/02/12 22:36:46 james * *** empty log message *** * @@ -37,4 +40,6 @@ typedef struct int wptr; } History; +#define HISTORY_INC(h,a) do { (a)++; if ((a)==((h)->nlines)) { (a)=0; }; } while (0) + #endif /* __HISTORY_H__ */ diff --git a/src/libsympathy.c b/src/libsympathy.c index 989b664..d05ad13 100644 --- a/src/libsympathy.c +++ b/src/libsympathy.c @@ -11,6 +11,9 @@ static char rcsid[] = /* * $Log$ + * Revision 1.17 2008/02/13 16:57:29 james + * *** empty log message *** + * * Revision 1.16 2008/02/13 09:12:21 james * *** empty log message *** * @@ -64,71 +67,3 @@ static char rcsid[] = #include "project.h" - - -void -testy (void) -{ - fd_set rfd; - struct termios raw = { 0 }; - ANSI a = { 0 }; - Context c; - -#if 0 - int fd; - char c; - - TTY *t; - VT102 *v; - History *h; - int i; -#endif - - - - ansi_reset (&a); - - - c.t = ptty_open (NULL, NULL); - c.v = vt102_new (); - c.h = history_new (200); - c.l = NULL; - - terminal_register_handlers (); - a.terminal = terminal_open (0, 1); - - - FD_ZERO (&rfd); - for (;;) - { - struct timeval tv = { 0, 100000 }; - - - FD_SET (c.t->rfd, &rfd); - FD_SET (a.terminal->rfd, &rfd); - - select (FD_SETSIZE, &rfd, NULL, NULL, &tv); - - ansi_dispatch (&a, &c); - - if (FD_ISSET (c.t->rfd, &rfd)) - { - if (vt102_dispatch (&c)) - break; - } - -#if 0 - if (had_winch) - { - had_winch = 0; - ansi_getsize (&a); - ansi_reset (&a); - ansi_draw (&a, &v->crt); - } -#endif - //FIXME history - ansi_draw (&a, &c.v->crt); - } - - terminal_atexit (); -} diff --git a/src/project.h b/src/project.h index ed33123..c30ff77 100644 --- a/src/project.h +++ b/src/project.h @@ -12,6 +12,9 @@ /* * $Log$ + * Revision 1.8 2008/02/13 16:57:29 james + * *** empty log message *** + * * Revision 1.7 2008/02/13 09:12:21 james * *** empty log message *** * @@ -78,6 +81,8 @@ #include #endif +#include +#include #include #include #include @@ -87,17 +92,6 @@ #include #include -#include "crt.h" -#include "tty.h" -#include "ansi.h" -#include "vt102.h" -#include "keys.h" -#include "history.h" -#include "ring.h" -#include "log.h" - -#include "context.h" - -#include "prototypes.h" +#include "sympathy.h" #endif /* __PROJECT_H__ */ diff --git a/src/prototypes.h b/src/prototypes.h index f1f0742..635f594 100644 --- a/src/prototypes.h +++ b/src/prototypes.h @@ -6,8 +6,12 @@ void ansi_set_color (ANSI * a, int color); void ansi_set_attr (ANSI * a, int attr); void ansi_render (ANSI * a, CRT_CA ca); void ansi_cls (ANSI * a); +void ansi_draw_line (ANSI * a, CRT_CA * cap, int y); +void ansi_resize_check (ANSI * a); +void ansi_history (ANSI * a, History * h); void ansi_draw (ANSI * a, CRT * c); -void ansi_reset (ANSI * a); +void ansi_reset (ANSI * a, CRT * c); +void ansi_terminal_reset (ANSI * a); void ansi_flush_escape (ANSI * a, Context * c); void ansi_parse_deckey (ANSI * a, Context * c); void ansi_parse_ansikey (ANSI * a, Context * c); @@ -29,10 +33,12 @@ void html_render (FILE * f, CRT_CA c); void html_draw (FILE * f, CRT * c); /* libsympathy.c */ void testy (void); +void ring_test (void); /* render.c */ /* version.c */ /* vt102.c */ void vt102_log_line (Context * c, int line); +void vt102_history (Context * c, CRT_Pos t, CRT_Pos b); void vt102_clip_cursor (VT102 * v, CRT_Pos tl, CRT_Pos br); void vt102_cursor_normalize (VT102 * v); void vt102_cursor_carriage_return (VT102 * v); @@ -74,6 +80,8 @@ void history_add (History * h, CRT_CA * c); /* ring.c */ int ring_read (Ring * r, void *b, int n); int ring_write (Ring * r, void *b, int n); +int ring_space (Ring * r); +int ring_bytes (Ring * r); Ring *ring_new (int n); /* ptty.c */ TTY *ptty_open (char *path, char *argv[]); @@ -91,3 +99,17 @@ void set_nonblocking (int fd); void set_blocking (int fd); void raw_termios (struct termios *termios); void default_termios (struct termios *termios); +/* log.c */ +Log *file_log_new (char *fn); +/* ipc.c */ +Socket *socket_listen (char *path); +Socket *socket_accept (Socket * l); +Socket *socket_connect (char *path); +void socket_postselect (Socket * s, fd_set * rfds, fd_set * wfds); +void socket_preselect (Socket * s, fd_set * rfds, fd_set * wfds); +/* slide.c */ +void slide_free (Slide * s); +void slide_consume (Slide * s, int n); +void slide_added (Slide * s, int n); +Slide *slide_new (int n); +void slide_expand (Slide * s, int n); diff --git a/src/ring.c b/src/ring.c index ccd97ed..ca412ab 100644 --- a/src/ring.c +++ b/src/ring.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.4 2008/02/13 16:57:29 james + * *** empty log message *** + * * Revision 1.3 2008/02/13 09:12:21 james * *** empty log message *** * @@ -59,6 +62,27 @@ ring_write (Ring * r, void *b, int n) return writ; } +int +ring_space (Ring * r) +{ + int i; + + i = r->size - RING_NEXT_W (r) + r->rptr; + i %= r->size; + return i; +} + +int +ring_bytes (Ring * r) +{ + int i; + + i = r->size + r->wptr - r->rptr; + i %= r->size; + return i; +} + + Ring * diff --git a/src/slide.c b/src/slide.c new file mode 100644 index 0000000..e20d0be --- /dev/null +++ b/src/slide.c @@ -0,0 +1,84 @@ +/* + * slide.c: + * + * Copyright (c) 2008 James McKenzie , + * All rights reserved. + * + */ + +static char rcsid[] = "$Id$"; + +/* + * $Log$ + * Revision 1.1 2008/02/13 16:57:29 james + * *** empty log message *** + * + * Revision 1.3 2008/02/13 09:12:21 james + * *** empty log message *** + * + * Revision 1.2 2008/02/12 22:36:46 james + * *** empty log message *** + * + * Revision 1.1 2008/02/08 15:06:42 james + * *** empty log message *** + * + */ + +#include "project.h" + +void +slide_free (Slide * s) +{ + free (s->slide); + free (s); +} + +void +slide_consume (Slide * s, int n) +{ + s->nbytes -= n; + memmove (s->slide, s->slide + n, s->nbytes); + + if ((s->size > s->target_size) && (s->nbytes <= s->size)) + { + s->size = s->target_size; + s->slide = realloc (s->slide, s->size); + } + +} + +void +slide_added (Slide * s, int n) +{ + s->nbytes += n; +} + +Slide * +slide_new (int n) +{ + Slide *ret = (Slide *) malloc (sizeof (Slide)); + + ret->slide = (uint8_t *) malloc (n); + ret->size = n; + ret->target_size = n; + ret->nbytes = 0; + + return ret; +} + + +void +slide_expand (Slide * s, int n) +{ + n += s->nbytes; + + if (n <= s->size) + return; + + while (n > s->size) + s->size <<= 1; + +//FIXME -- might fail + s->slide = realloc (s->slide, s->size); + +} diff --git a/src/slide.h b/src/slide.h new file mode 100644 index 0000000..d9a7059 --- /dev/null +++ b/src/slide.h @@ -0,0 +1,44 @@ +/* + * ring.h: + * + * Copyright (c) 2008 James McKenzie , + * All rights reserved. + * + */ + +/* + * $Id$ + */ + +/* + * $Log$ + * Revision 1.1 2008/02/13 16:57:29 james + * *** empty log message *** + * + * Revision 1.2 2008/02/12 22:36:46 james + * *** empty log message *** + * + * Revision 1.1 2008/02/08 15:06:42 james + * *** empty log message *** + * + */ + +#ifndef __SLIDE_H__ +#define __SLIDE_H__ + +typedef struct +{ + uint8_t *slide; + int nbytes; + int target_size; + int size; +} Slide; + +#define SLIDE_FULL(s) ((s)->nbytes==(s)->size) +#define SLIDE_EMPTY(s) (!((s)->nbytes)) +#define SLIDE_SPACE(s) (((s)->size)-((s)->nbytes)) +#define SLIDE_BYTES(s) ((s)->nbytes) +#define SLIDE_RPTR(s) ((s)->slide) +#define SLIDE_WPTR(s) (((s)->slide)+((s)->nbytes)) + +#endif /* __SLIDE_H__ */ diff --git a/src/sympathy.h.head.in b/src/sympathy.h.head.in new file mode 100644 index 0000000..a703ce2 --- /dev/null +++ b/src/sympathy.h.head.in @@ -0,0 +1,55 @@ +/* + * sympathy.h.head.in: + * + * Copyright (c) 2008 James McKenzie , + * All rights reserved. + * + */ + +/* + * $Id$ + */ + +/* + * $Log$ + * Revision 1.1 2008/02/13 16:57:29 james + * *** empty log message *** + * + * Revision 1.1 2008/02/03 16:20:24 james + * *** empty log message *** + * + * + */ + +/* MAKE ABSOLUTELY SURE THAT YOU ARE EDITING THE sympathy.h.in */ +/* FILE FROM WHICH THIS IS GENERATED - OTHERWISE YOUR EDITS */ +/* WILL BE LOST */ + +#ifndef __SYMPATHY_H__ +#define __SYMPATHY_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/*the integer constants here are set by configure*/ + +/*get uint32_t and friends defined */ +#if @G2_HAVE_STDINT_H@ +#include +#elif @G2_HAVE_SYS_INT_TYPES_H@ +#include +#endif +#if @G2_HAVE_UNISTD_H@ +#include +#endif + +/* If the following is <> then configure failed to find where */ +/* struct tm was defined - report it as a bug */ + +/*get struct tm defined*/ +#include <@G2_TM_H@> + + diff --git a/src/sympathy.h.in b/src/sympathy.h.in deleted file mode 100644 index ea79d89..0000000 --- a/src/sympathy.h.in +++ /dev/null @@ -1,56 +0,0 @@ -/* - * sympathy.h.in: - * - * Copyright (c) 2008 James McKenzie , - * All rights reserved. - * - */ - -/* - * $Id$ - */ - -/* - * $Log$ - * Revision 1.1 2008/02/03 16:20:24 james - * *** empty log message *** - * - * - */ - -/* MAKE ABSOLUTELY SURE THAT YOU ARE EDITING THE sympathy.h.in */ -/* FILE FROM WHICH THIS IS GENERATED - OTHERWISE YOUR EDITS */ -/* WILL BE LOST */ - -#ifndef __SYMPATHY_H__ -#define __SYMPATHY_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/*the integer constants here are set by configure*/ - -/*get uint32_t and friends defined */ -#if @G2_HAVE_STDINT_H@ -#include -#elif @G2_HAVE_SYS_INT_TYPES_H@ -#include -#endif -#if @G2_HAVE_UNISTD_H@ -#include -#endif - -/* If the following is <> then configure failed to find where */ -/* struct tm was defined - report it as a bug */ - -/*get struct tm defined*/ -#include <@G2_TM_H@> - -#ifdef __cplusplus -} -#endif - -#endif /* __SYMPATHY_H__ */ diff --git a/src/sympathy.h.tail b/src/sympathy.h.tail new file mode 100644 index 0000000..19a7bad --- /dev/null +++ b/src/sympathy.h.tail @@ -0,0 +1,5 @@ +#ifdef __cplusplus +} +#endif + +#endif /* __SYMPATHY_H__ */ diff --git a/src/terminal.c b/src/terminal.c index 1223c0f..7bbc761 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.4 2008/02/13 16:57:29 james + * *** empty log message *** + * * Revision 1.3 2008/02/13 09:12:21 james * *** empty log message *** * @@ -58,6 +61,9 @@ int terminal_winches; static void terminal_close (TTY * _t) { + char buf[32]; + int i; + TERMINAL *t = (TERMINAL *) _t; TERMINAL **ptr = &terminal_list; @@ -73,6 +79,14 @@ terminal_close (TTY * _t) tcsetattr (t->wfd, TCSANOW, &t->orig_termios); + set_nonblocking (t->wfd); + + + t->xmit (t, "\033[r", 3); + t->xmit (t, "\033[0m", 4); + i = sprintf (buf, "\033[%d;%dH", CRT_ROWS + 1, 1); + t->xmit (t, buf, i); + set_blocking (t->rfd); set_blocking (t->wfd); @@ -147,6 +161,7 @@ terminal_read (TTY * _t, void *buf, int len) int red, done = 0; terminal_dispatch (); + set_nonblocking (t->rfd); do { @@ -176,14 +191,17 @@ terminal_write (TTY * _t, void *buf, int len) terminal_dispatch (); + set_blocking (t->wfd); + do { writ = wrap_write (t->wfd, buf, len); if (writ < 0) return -1; + if (!writ) - sleep (1); + usleep (1000); buf += writ; len -= writ; @@ -234,7 +252,8 @@ terminal_open (int rfd, int wfd) set_nonblocking (wfd); - raw_termios (&termios); + cfmakeraw (&termios); + //raw_termios (&termios); tcsetattr (wfd, TCSANOW, &termios); diff --git a/src/tty.c b/src/tty.c index e38ee51..72b31a1 100644 --- a/src/tty.c +++ b/src/tty.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.5 2008/02/13 16:57:29 james + * *** empty log message *** + * * Revision 1.4 2008/02/12 22:36:46 james * *** empty log message *** * @@ -17,3 +20,27 @@ static char rcsid[] = "$Id$"; * *** empty log message *** * */ + + + + +void +tty_pre_select (TTY * t, fd_set * rfds, fd_set * wfds) +{ + FD_SET (t->rfd, &rfds); +} + +#if 0 +int +tty_post_select (Context * c, fd_set * rfds, fd_set * wfds) +{ + + if (FD_ISSET (c->t->rfd, rfds)) + { + if (vt102_dispatch (&c)) + return -1; + } + return 0; +} + +#endif -- cgit v1.2.3