| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#include "header.h" |
| 9 |
|
| 10 |
|
| 11 |
#define TRUE 1 |
| 12 |
#define FALSE 0 |
| 13 |
#define EOS '\0' |
| 14 |
#define LINEMAX 200 |
| 15 |
#define WORDMAX 100 |
| 16 |
|
| 17 |
|
| 18 |
char line[LINEMAX+1]; |
| 19 |
|
| 20 |
|
| 21 |
static int col,maxcol,row,maxrow; |
| 22 |
static int scnt,wcnt; |
| 23 |
static char word[WORDMAX+1],*wptr; |
| 24 |
static FILE *logfp = NULL; |
| 25 |
|
| 26 |
|
| 27 |
char *trm_line(char *line); |
| 28 |
|
| 29 |
|
| 30 |
void trm_init(int rows, int cols, char *name) |
| 31 |
{ |
| 32 |
|
| 33 |
maxcol = cols-1; col = 0; |
| 34 |
maxrow = rows-1; row = 0; |
| 35 |
wptr = word; wcnt = 0; |
| 36 |
scnt = 0; |
| 37 |
|
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
void trm_done() |
| 42 |
{ |
| 43 |
|
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
char *trm_get(char *line) |
| 48 |
{ |
| 49 |
return (trm_line(line)); |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
void trm_str(char *str) |
| 54 |
{ |
| 55 |
glk_put_string(str); |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
void trm_xstr(char *str) |
| 60 |
{ |
| 61 |
glk_put_string(str); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
void trm_chr(int ch) |
| 66 |
{ |
| 67 |
if (ch == '\t') |
| 68 |
glk_put_string(" "); |
| 69 |
else |
| 70 |
glk_put_char(ch); |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
void trm_word() |
| 75 |
{ |
| 76 |
|
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
void trm_eol() |
| 81 |
{ |
| 82 |
glk_put_char('\n'); |
| 83 |
|
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
void trm_wait() |
| 88 |
{ |
| 89 |
|
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
char *trm_line(char *line) |
| 94 |
{ |
| 95 |
event_t event; |
| 96 |
|
| 97 |
glk_request_line_event(window, line, LINEMAX, 0); |
| 98 |
do { |
| 99 |
glk_select(&event); |
| 100 |
} while (event.type != evtype_LineInput); |
| 101 |
|
| 102 |
|
| 103 |
line[event.val1] = 0; |
| 104 |
|
| 105 |
return line; |
| 106 |
} |
| 107 |
|