diff options
author | james <> | 2008-02-13 01:08:38 +0000 |
---|---|---|
committer | james <> | 2008-02-13 01:08:38 +0000 |
commit | 4d50b220e63c52d412bacebb3e44cc712f2e2804 (patch) | |
tree | 57633a5a842ffa00f75ba96c19e653be3fb6bde6 /src/terminal.c | |
parent | 8688a9519c349b6ee8664be6ce2897a59c0f52be (diff) | |
download | sympathy-4d50b220e63c52d412bacebb3e44cc712f2e2804.tar.gz sympathy-4d50b220e63c52d412bacebb3e44cc712f2e2804.tar.bz2 sympathy-4d50b220e63c52d412bacebb3e44cc712f2e2804.zip |
*** empty log message ***
Diffstat (limited to 'src/terminal.c')
-rw-r--r-- | src/terminal.c | 107 |
1 files changed, 79 insertions, 28 deletions
diff --git a/src/terminal.c b/src/terminal.c index a4cd31b..f0472a1 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.2 2008/02/13 01:08:18 james + * *** empty log message *** + * * Revision 1.1 2008/02/12 22:36:46 james * *** empty log message *** * @@ -45,6 +48,8 @@ typedef struct TERMINAL_struct static TERMINAL terminal_list=NULL; +int terminal_winches; + static void @@ -71,6 +76,60 @@ terminal_close (TTY * _t) } +void terminal_atexit(void) +{ +while (terminal_list) + terminal_close(terminal_list); +} + +static void sigint(int dummy) +{ +terminal_atexit(); +exit(-1); +} + +static void +sigwinch (int not) +{ + terminal_winches++; +} + + +void +terminal_getsize (TTY *_t) +{ +TERMINAL *t=(TTY *) _t; + struct winsize sz = { 0 }; + +if (!t) return; + +if (ioctl (a->wfd, TIOCGWINSZ, &sz)) + { + t->size.x = CRT_COLS; + t->size.y = CRT_ROWS; + } + else + { + t->size.x = sz.ws_col; + t->size.y = sz.ws_row; + } +} + + +void terminal_dispatch(void) +{ +TERMINAL *t; + + +if (!terminal_winches) return; + +terminal_winches=0; + +for (t=terminal_list;t;t=t->next) +terminal_getsize(t); + +} + static int terminal_read (TTY * _t, void *buf, int len) @@ -78,6 +137,8 @@ terminal_read (TTY * _t, void *buf, int len) TERMINAL *t = (TERMINAL *) _t; int red, done = 0; + terminal_dispatch(); + do { @@ -104,6 +165,8 @@ terminal_write (TTY * _t, void *buf, int len) int writ, done = 0; TERMINAL *t = (TERMINAL *) _t; + terminal_dispatch(); + do { @@ -123,6 +186,20 @@ terminal_write (TTY * _t, void *buf, int len) return done; } + +void terminal_register_handlers(void) +{ + struct sigaction sa = { 0 }; + + sa.sa_handler = sigwinch; + sa.sa_flags = SA_RESTART; + sigaction (SIGWINCH, &sa, NULL); + + sa.sa_handler = sigint; + sa.sa_flags = SA_RESTART; + sigaction (SIGINT, &sa, NULL); +} + TTY * terminal_open (int rfd,int wfd) { @@ -156,34 +233,8 @@ terminal_open (int rfd,int wfd) t->close = terminal_close; - return (TTY *) t; -} + terminal_getsize((TTY*) t); -void -terminal_getsize (TTY *_t,CRT_POS *pos) -{ -TERMINAL *t=(TTY *) _t; - struct winsize sz = { 0 }; - -if ((!t) || (!pos)) return; - -if (ioctl (a->wfd, TIOCGWINSZ, &sz)) - { - pos->x = CRT_COLS; - pos->y = CRT_ROWS; - } - else - { - pos->x = sz.ws_col; - pos->y = sz.ws_row; - } -} - - -void terminal_atexit(void) -{ -while (terminal_list) - terminal_close(terminal_list); + return (TTY *) t; } - |