diff options
Diffstat (limited to 'mbbsd/term.c')
-rw-r--r-- | mbbsd/term.c | 98 |
1 files changed, 58 insertions, 40 deletions
diff --git a/mbbsd/term.c b/mbbsd/term.c index 4cab3e2c..aa310212 100644 --- a/mbbsd/term.c +++ b/mbbsd/term.c @@ -1,28 +1,31 @@ -/* $Id: term.c,v 1.3 2002/06/04 13:08:34 in2 Exp $ */ +/* $Id: term.c,v 1.4 2002/07/05 17:10:28 in2 Exp $ */ #include "bbs.h" -int tgetent(const char *bp, char *name); -char *tgetstr(const char *id, char **area); -int tgetflag(const char *id); -int tgetnum(const char *id); -int tputs(const char *str, int affcnt, int (*putc)(int)); -char *tparm(const char *str, ...); -char *tgoto(const char *cap, int col, int row); +int tgetent(const char *bp, char *name); +char *tgetstr(const char *id, char **area); +int tgetflag(const char *id); +int tgetnum(const char *id); +int tputs(const char *str, int affcnt, int (*putc) (int)); +char *tparm(const char *str,...); +char *tgoto(const char *cap, int col, int row); static struct termios tty_state, tty_new; /* ----------------------------------------------------- */ /* basic tty control */ /* ----------------------------------------------------- */ -void init_tty() { - if(tcgetattr(1, &tty_state) < 0) { +void +init_tty() +{ + if (tcgetattr(1, &tty_state) < 0) { syslog(LOG_ERR, "tcgetattr(): %m"); return; } memcpy(&tty_new, &tty_state, sizeof(tty_new)); tty_new.c_lflag &= ~(ICANON | ECHO | ISIG); -/* tty_new.c_cc[VTIME] = 0; - tty_new.c_cc[VMIN] = 1; */ + /* + * tty_new.c_cc[VTIME] = 0; tty_new.c_cc[VMIN] = 1; + */ tcsetattr(1, TCSANOW, &tty_new); system("stty raw -echo"); } @@ -35,11 +38,13 @@ void init_tty() { #define TERMCOMSIZE (40) #if 0 -static char *outp; -static int *outlp; +static char *outp; +static int *outlp; -static int outcf(int ch) { - if(*outlp < TERMCOMSIZE) { +static int +outcf(int ch) +{ + if (*outlp < TERMCOMSIZE) { (*outlp)++; *outp++ = ch; } @@ -47,64 +52,77 @@ static int outcf(int ch) { } #endif -static void term_resize(int sig) { - struct winsize newsize; - screenline_t *new_picture; +static void +term_resize(int sig) +{ + struct winsize newsize; + screenline_t *new_picture; signal(SIGWINCH, SIG_IGN); /* Don't bother me! */ ioctl(0, TIOCGWINSZ, &newsize); - if(newsize.ws_row > t_lines) { - new_picture = (screenline_t *)calloc(newsize.ws_row, - sizeof(screenline_t)); - if(new_picture == NULL) { + if (newsize.ws_row > t_lines) { + new_picture = (screenline_t *) calloc(newsize.ws_row, + sizeof(screenline_t)); + if (new_picture == NULL) { syslog(LOG_ERR, "calloc(): %m"); return; } free(big_picture); big_picture = new_picture; } - - t_lines=newsize.ws_row; - b_lines=t_lines-1; - p_lines=t_lines-4; + t_lines = newsize.ws_row; + b_lines = t_lines - 1; + p_lines = t_lines - 4; signal(SIGWINCH, term_resize); } -int term_init() { +int +term_init() +{ signal(SIGWINCH, term_resize); return YEA; } -char term_buf[32]; +char term_buf[32]; + +void +do_move(int destcol, int destline) +{ + char buf[16], *p; -void do_move(int destcol, int destline) { - char buf[16], *p; - sprintf(buf, "\33[%d;%dH", destline + 1, destcol + 1); - for(p = buf; *p; p++) + for (p = buf; *p; p++) ochar(*p); } -void save_cursor() { +void +save_cursor() +{ ochar('\33'); ochar('7'); } -void restore_cursor() { +void +restore_cursor() +{ ochar('\33'); ochar('8'); } -void change_scroll_range(int top, int bottom) { - char buf[16], *p; - +void +change_scroll_range(int top, int bottom) +{ + char buf[16], *p; + sprintf(buf, "\33[%d;%dr", top + 1, bottom + 1); - for(p = buf; *p; p++) + for (p = buf; *p; p++) ochar(*p); } -void scroll_forward() { +void +scroll_forward() +{ ochar('\33'); ochar('D'); } |