diff options
author | ache <ache@FreeBSD.org> | 1994-09-20 08:07:52 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1994-09-20 08:07:52 +0000 |
commit | 3704208ad62eb595c034205f77468a9730c4538d (patch) | |
tree | 44190e4adf5465576ffcc05f2fdc1613a8c2da81 /usr.bin/talk | |
parent | 61ca3e5cab982a6c4de55a3abc1aca6c8da81ab9 (diff) | |
download | FreeBSD-src-3704208ad62eb595c034205f77468a9730c4538d.zip FreeBSD-src-3704208ad62eb595c034205f77468a9730c4538d.tar.gz |
Make talk ctype-aware, handle controns as tcsh does, use human-oriented
scroll, most of changes from 1.x
Diffstat (limited to 'usr.bin/talk')
-rw-r--r-- | usr.bin/talk/display.c | 56 | ||||
-rw-r--r-- | usr.bin/talk/init_disp.c | 4 |
2 files changed, 22 insertions, 38 deletions
diff --git a/usr.bin/talk/display.c b/usr.bin/talk/display.c index e5c059e..076c6e1 100644 --- a/usr.bin/talk/display.c +++ b/usr.bin/talk/display.c @@ -40,6 +40,7 @@ static char sccsid[] = "@(#)display.c 8.1 (Berkeley) 6/6/93"; * displaying of text */ #include "talk.h" +#include <ctype.h> xwin_t my_win; xwin_t his_win; @@ -64,20 +65,24 @@ max(a,b) */ display(win, text, size) register xwin_t *win; - register char *text; + register unsigned char *text; int size; { register int i; char cch; for (i = 0; i < size; i++) { - if (*text == '\n') { - xscroll(win, 0); + if (*text == '\n' || *text == '\r') { + waddch(win->x_win, '\n'); + getyx(win->x_win, win->x_line, win->x_col); text++; continue; } /* erase character */ - if (*text == win->cerase) { + if ( *text == win->cerase + || *text == 010 /* BS */ + || *text == 0177 /* DEL */ + ) { wmove(win->x_win, win->x_line, max(--win->x_col, 0)); getyx(win->x_win, win->x_line, win->x_col); waddch(win->x_win, ' '); @@ -91,7 +96,9 @@ display(win, text, size) * the beginning of a word or the beginning of * the line. */ - if (*text == win->werase) { + if ( *text == win->werase + || *text == 027 /* ^W */ + ) { int endcol, xcol, i, c; endcol = win->x_col; @@ -117,7 +124,9 @@ display(win, text, size) continue; } /* line kill */ - if (*text == win->kill) { + if ( *text == win->kill + || *text == 025 /* ^U */ + ) { wmove(win->x_win, win->x_line, 0); wclrtoeol(win->x_win); getyx(win->x_win, win->x_line, win->x_col); @@ -130,15 +139,14 @@ display(win, text, size) text++; continue; } - if (win->x_col == COLS-1) { - /* check for wraparound */ - xscroll(win, 0); + if (*text == '\7') { + _putchar(*text); + text++; + continue; } - if (*text < ' ' && *text != '\t') { + if (!isprint(*text) && *text != '\t') { waddch(win->x_win, '^'); getyx(win->x_win, win->x_line, win->x_col); - if (win->x_col == COLS-1) /* check for wraparound */ - xscroll(win, 0); cch = (*text & 63) + 64; waddch(win->x_win, cch); } else @@ -164,27 +172,3 @@ readwin(win, line, col) wmove(win, oldline, oldcol); return (c); } - -/* - * Scroll a window, blanking out the line following the current line - * so that the current position is obvious - */ -xscroll(win, flag) - register xwin_t *win; - int flag; -{ - - if (flag == -1) { - wmove(win->x_win, 0, 0); - win->x_line = 0; - win->x_col = 0; - return; - } - win->x_line = (win->x_line + 1) % win->x_nlines; - win->x_col = 0; - wmove(win->x_win, win->x_line, win->x_col); - wclrtoeol(win->x_win); - wmove(win->x_win, (win->x_line + 1) % win->x_nlines, win->x_col); - wclrtoeol(win->x_win); - wmove(win->x_win, win->x_line, win->x_col); -} diff --git a/usr.bin/talk/init_disp.c b/usr.bin/talk/init_disp.c index 517e51c..5bebcd8 100644 --- a/usr.bin/talk/init_disp.c +++ b/usr.bin/talk/init_disp.c @@ -72,14 +72,14 @@ init_display() my_win.x_nlines = LINES / 2; my_win.x_ncols = COLS; my_win.x_win = newwin(my_win.x_nlines, my_win.x_ncols, 0, 0); - scrollok(my_win.x_win, FALSE); + scrollok(my_win.x_win, TRUE); wclear(my_win.x_win); his_win.x_nlines = LINES / 2 - 1; his_win.x_ncols = COLS; his_win.x_win = newwin(his_win.x_nlines, his_win.x_ncols, my_win.x_nlines+1, 0); - scrollok(his_win.x_win, FALSE); + scrollok(his_win.x_win, TRUE); wclear(his_win.x_win); line_win = newwin(1, COLS, my_win.x_nlines, 0); |