home *** CD-ROM | disk | FTP | other *** search
- /*
- cmwintty.c
-
- % function that puts chars in a cmap TTY style.
-
- 3/28/88 by Ted
-
- OWL 1.1
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 8/06/89 jmd Changed interface, now gets passed a string
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
- #include "cmwinobj.h"
- #include "cmapdecl.h"
-
- #include "scancode.h"
-
- #include <ctype.h>
-
- /* -------------------------------------------------------------------------- */
-
- void cmwin_PlotTTY(win, string)
- win_type win;
- char *string;
- {
- int row, col;
- int orow, ocol;
- ocbox relcbox, scrollcbox;
-
- boolean build, backspace;
- int startcol, plen;
- char *p;
-
- win_GetBox(win, &relcbox);
- win_GetCursorPos(win, &row, &col);
-
- row = (row < 0) ? 0 : row;
- col = (col < 0) ? 0 : col;
-
- while(*string != '\0') {
- orow = row;
- ocol = col;
-
- p = NULL;
- build = TRUE;
- backspace = FALSE;
-
- while(*string != '\0' && build) {
- build = FALSE;
-
- switch (*string) {
- default:
- build = TRUE;
- if (p == NULL) {
- plen = 0;
- startcol = col;
- p = string;
- }
-
- col += 1;
- plen++;
- break;
-
- case '\n':
- /* newline */
- col = 0;
- row += 1;
- break;
-
- case '\r':
- /* carriage return */
- col = 0;
- break;
-
- case '\f':
- /* form feed */
- row += win_GetHeight(win);
- break;
-
- case '\t':
- /* tab */
- col += 4;
- break;
-
- case '\b':
- /* backspace */
- if (col > 0) {
- col -= 1;
- backspace = TRUE;
- }
- break;
-
- case '\v':
- /* vertical tab */
- row -= 1;
- break;
- }
-
- /* get next character */
- string++;
- }
-
- if (p != NULL) {
- /* output built up string */
- cmwin_DrawString(win, orow, startcol, p, win_GetAttr(win), plen);
- }
-
- if (backspace) {
- cmwin_DrawChar(win, row, col, ' ', win_GetAttr(win));
- }
-
- if (row < relcbox.toprow) {
- row = relcbox.toprow;
- }
- if (col < relcbox.leftcol) {
- col = relcbox.leftcol;
- }
- if (col > relcbox.rightcol) {
- col = relcbox.rightcol;
- }
-
- if (row > relcbox.botrow) {
- /* Scroll the whole cmap above the cursor, not just the visible part */
- scrollcbox.leftcol = -cmwin_GetColoffs(win);
- scrollcbox.rightcol = scrollcbox.leftcol + cmap_GetWidth(cmwin_GetCmap(win));
- scrollcbox.toprow = -cmwin_GetRowoffs(win);
- scrollcbox.botrow = relcbox.botrow;
-
- cmwin_ScrollBoxVt(win, &relcbox, 1);
- orow--; /* account for cursor scrolling up too */
- row = relcbox.botrow;
- }
-
- if (row != orow || col != ocol) {
- win_SetCursorPos(win, row, col);
- }
-
- }
- }
- /* -------------------------------------------------------------------------- */
-
-