1 #include "term/screen-processor.h"
2 #include "io/input-key-acceptor.h"
3 #include "term/term-color-types.h"
4 #include "view/display-messages.h"
5 #include "world/world.h"
8 * Hack -- prevent "accidents" in "screen_save()" or "screen_load()"
10 static int screen_depth = 0;
15 void move_cursor(int row, int col) { term_gotoxy(col, row); }
18 * Flush all input chars. Actually, remember the flush,
19 * and do a "special flush" before the next "inkey()".
21 * This is not only more efficient, but also necessary to make sure
22 * that various "inkey()" codes are not "lost" along the way.
24 void flush(void) { inkey_xtra = TRUE; }
27 * Save the screen, and increase the "icky" depth.
29 * This function must match exactly one call to "screen_load()".
34 if (screen_depth++ == 0)
37 current_world_ptr->character_icky++;
41 * Load the screen, and decrease the "icky" depth.
43 * This function must match exactly one call to "screen_save()".
48 if (--screen_depth == 0)
51 current_world_ptr->character_icky--;
55 * Display a string on the screen using an attribute.
57 * At the given location, using the given attribute, if allowed,
58 * add the given string. Do not clear the line.
60 void c_put_str(TERM_COLOR attr, concptr str, TERM_LEN row, TERM_LEN col) { term_putstr(col, row, -1, attr, str); }
63 * As above, but in "white"
65 void put_str(concptr str, TERM_LEN row, TERM_LEN col) { term_putstr(col, row, -1, TERM_WHITE, str); }
68 * Display a string on the screen using an attribute, and clear
69 * to the end of the line.
71 void c_prt(TERM_COLOR attr, concptr str, TERM_LEN row, TERM_LEN col)
73 term_erase(col, row, 255);
74 term_addstr(-1, attr, str);
78 * As above, but in "white"
80 void prt(concptr str, TERM_LEN row, TERM_LEN col)
83 c_prt(TERM_WHITE, str, row, col);
87 * Print some (colored) text to the screen at the current cursor position,
88 * automatically "wrapping" existing text (at spaces) when necessary to
89 * avoid placing any text into the last column, and clearing every line
90 * before placing any text in that line. Also, allow "newline" to force
91 * a "wrap" to the next line. Advance the cursor as needed so sequential
92 * calls to this function will work correctly.
94 * Once this function has been called, the cursor should not be moved
95 * until all the related "c_roff()" calls to the window are complete.
97 * This function will correctly handle any width up to the maximum legal
98 * value of 256, though it works best for a standard 80 character width.
100 void c_roff(TERM_COLOR a, concptr str)
103 (void)term_get_size(&w, &h);
106 (void)term_locate(&x, &y);
108 if (y == h - 1 && x > w - 3)
111 for (concptr s = str; *s; s++) {
114 int k_flag = iskanji(*s);
122 term_erase(x, y, 255);
127 ch = ((k_flag || isprint(*s)) ? *s : ' ');
129 ch = (isprint(*s) ? *s : ' ');
133 if ((x >= ((k_flag) ? w - 2 : w - 1)) && (ch != ' '))
135 if ((x >= w - 1) && (ch != ' '))
149 for (i = w - 2; i >= 0; i--) {
150 term_what(i, y, &av[i], &cv[i]);
164 /* 文頭が「。」「、」等になるときは、その1つ前の語で改行 */
165 if (strncmp(s, "。", 2) == 0 || strncmp(s, "、", 2) == 0) {
166 term_what(x, y, &av[x], &cv[x]);
167 term_what(x - 1, y, &av[x - 1], &cv[x - 1]);
168 term_what(x - 2, y, &av[x - 2], &cv[x - 2]);
178 term_erase(n, y, 255);
184 term_erase(x, y, 255);
185 for (i = n; i < w - 1; i++) {
190 term_addch(av[i], cv[i]);
197 term_addch((byte)(a | 0x10), ch);
207 term_addch((byte)(a | 0x20), ch);
217 * As above, but in "white"
219 void roff(concptr str)
222 c_roff(TERM_WHITE, str);
226 * Clear part of the screen
228 void clear_from(int row)
230 for (int y = row; y < Term->hgt; y++) {
231 term_erase(0, y, 255);