* This source herein may be modified and/or distributed by anybody who
* so desires, with the following restrictions:
* 1.) No portion of this notice shall be removed.
* 2.) Credit shall not be taken for the creation of this source.
* 3.) This code is not to be traded, sold, or used for personal
static char sccsid
[] = "@(#)curses.c 5.1 (Berkeley) 11/25/87";
/* The following is a curses emulation package suitable for the rogue program
* in which it is included. No other suitability is claimed or suspected.
* Only those routines currently needed by this rogue program are included.
* This is being provided for those systems that don't have a suitable
* curses package and want to run this rogue program.
* Compile the entire program with -DCURSES to incorporate this package.
* The following is NOT supported:
* "%D", "%B", "%n", or "%>" inside a cursor motion (cm) termcap string.
* Terminals in which the cursor motion addresses the row differently from
* the column, as in ":cm=\E%2,%3" or ":cm=\EY%+x;%+y"
* Termcap database stored in the TERMCAP environ variable as returned
* from md_getenv(). Only the termcap file name can be stored there.
* See the comments for md_getenv() in machdep.c.
* Terminals without non-destructive backspace. Backspace (^H) is used
* for cursor motion regardless of any termcap entries.
* The ":tc=" termcap entry is ignored.
* Use line-feed as your termcap "do" entry: ":do=^J", ":do=\012" or
* ":do=\n" This will help cursor motion optimization. If line-feed
* won't work, then a short escape sequence will do.
char terminal
[DROWS
][DCOLS
];
char buffer
[DROWS
][DCOLS
];
boolean lines_dirty
[DROWS
];
boolean buf_stand_out
= 0;
boolean term_stand_out
= 0;
WINDOW
*curscr
= &scr_buf
;
char *UC
= (char *) 0; /* UP */
md_cbreak_no_echo_nonl(0);
buffer
[row
][col
] = (char) ch
;
short old_row
, old_col
, first_row
;
for (i
= 0; i
< DROWS
; i
++) {
line
= (first_row
+ i
) % DROWS
;
for (j
= 0; j
< DCOLS
; j
++) {
if (buffer
[line
][j
] != terminal
[line
][j
]) {
put_char_at(line
, j
, buffer
[line
][j
]);
put_cursor(old_row
, old_col
);
for (i
= 0; i
< DROWS
; i
++) {
while ((col
< DCOLS
) && (buffer
[i
][col
] == ' ')) {
while ((col
< DCOLS
) && (buffer
[i
][col
] != ' ')) {
put_st_char((int) buffer
[i
][col
]);
put_cursor(curscr
->_cury
, curscr
->_curx
);
scr
= scr
; /* make lint happy */
return((int) buffer
[row
][col
]);
for (col
= curscr
->_curx
; col
< DCOLS
; col
++) {
md_cbreak_no_echo_nonl(1);
/* crmode() takes care of this */
/* crmode() takes care of this */
for (i
= 0; i
< DROWS
; i
++) {
for (j
= 0; j
< DCOLS
; j
++) {
put_char_at(row
, col
, ch
)
terminal
[row
][col
] = (char) ch
;
rdif
= (row
> cur_row
) ? row
- cur_row
: cur_row
- row
;
cdif
= (col
> cur_col
) ? col
- cur_col
: cur_col
- col
;
if (((row
> cur_row
) && DO
) || ((cur_row
> row
) && UC
)) {
if ((rdif
< 4) && (cdif
< 4)) {
for (i
= 0; i
< rdif
; i
++) {
printf("%s", ((row
< cur_row
) ? UC
: DO
));
for (i
= 0; i
< cdif
; i
++) {
ch
= (col
< cur_col
) ? BS
:
terminal
[row
][cur_col
+ i
];
printf("%s%02d%s%02d%s", cm_esc
, row
, cm_sep
, col
, cm_end
);
printf("%s%03d%s%03d%s", cm_esc
, row
, cm_sep
, col
, cm_end
);
printf("%s%c%s%c%s", cm_esc
, row
, cm_sep
, col
, cm_end
);
printf("%s%d%s%d%s", cm_esc
, row
, cm_sep
, col
, cm_end
);
if ((ch
& ST_MASK
) && (!term_stand_out
)) {
} else if ((!(ch
& ST_MASK
)) && term_stand_out
) {
if (tcf
= md_getenv("TERMCAP")) {
clean_up("TERMCAP file name too long");
if (!(tc_file
= md_gdtcf())) {
clean_up("I need a termcap file");
if (!(term
= md_getenv("TERM"))) {
clean_up("Cannot find TERM variable in environ");
if ((fp
= fopen(tc_file
, "r")) == NULL
) {
sprintf(buf
, "Cannot open TERMCAP file: %s", tc_file
);
if (!tc_tname(fp
, term
, buf
)) {
sprintf(buf
, "Cannot find TERM type: %s in TERMCAP file: %s", term
,
fg
= fgets(buf
, BUFLEN
, fp
);
if ( (buf
[0] != '#') && (buf
[0] != ' ') && (buf
[0] != TAB
) &&
(buf
[0] != CR
) && (buf
[0] != LF
)) {
while (buf
[i
] && (!found
)) {
while (buf
[i
] == term
[j
]) {
if ((!term
[j
]) && ((buf
[i
] == '|') || (buf
[i
] == ':'))) {
while (buf
[i
] && (buf
[i
] != '|') && (buf
[i
] != ':')) {
if ((buf
[0] != TAB
) && (buf
[0] != ' ')) {
while (buf
[i
] && (buf
[i
] != ':')) {
if (!strncmp(buf
+ i
, ":cl=", 4)) {
} else if (!strncmp(buf
+ i
, ":cm=", 4)) {
} else if (!strncmp(buf
+ i
, ":up=", 4)) {
} else if (!strncmp(buf
+ i
, ":do=", 4)) {
} else if (!strncmp(buf
+ i
, ":vs=", 4)) {
} else if (!strncmp(buf
+ i
, ":ve=", 4)) {
} else if (!strncmp(buf
+ i
, ":ti=", 4)) {
} else if (!strncmp(buf
+ i
, ":te=", 4)) {
} else if (!strncmp(buf
+ i
, ":vs=", 4)) {
} else if (!strncmp(buf
+ i
, ":ve=", 4)) {
} else if (!strncmp(buf
+ i
, ":so=", 4)) {
} else if (!strncmp(buf
+ i
, ":se=", 4)) {
} else if (!strncmp(buf
+ i
, ":li#", 4)) {
tc_gnum(buf
+ i
, &LINES
);
} else if (!strncmp(buf
+ i
, ":co#", 4)) {
} while (fgets(buf
, BUFLEN
, fp
) != NULL
);
clean_up("Terminal and termcap must have cm and cl");
while (ibuf
[i
] && is_digit(ibuf
[i
])) {
while (ibuf
[i
] && (ibuf
[i
] != ':')) {
while (k
< 3 && ibuf
[i
] && is_digit(ibuf
[i
])) {
n
= (8 * n
) + (ibuf
[i
] - '0');
} else if (ibuf
[i
] == '^') {
obuf
[j
] = ibuf
[i
+1] - 64;
if (!(*tcstr
= md_malloc(j
+ 1))) {
clean_up("cannot alloc() memory");
(void) strcpy(*tcstr
, obuf
);
while (is_digit(ibuf
[i
])) {
r
= (r
* 10) + (ibuf
[i
] - '0');
short i
= 0, j
= 0, rc_spec
= 0;
while (CM
[i
] && (CM
[i
] != '%') && (j
< 15)) {
while (CM
[i
] && (rc_spec
< 2)) {
while (CM
[i
] && (CM
[i
] != '%')) {
while (CM
[i
] && (j
< 15)) {