[qwaq] Don't call wrefresh in cmd_mvwaddstr

There is now an implementation for wrefresh.
This commit is contained in:
Bill Currie 2020-02-29 14:43:08 +09:00
parent f5f50ae231
commit ec4e9b326d
2 changed files with 37 additions and 5 deletions

View file

@ -8,6 +8,7 @@ void initialize (void) = #0;
window_t create_window (int xpos, int ypos, int xlen, int ylen) = #0;
void destroy_window (window_t win) = #0;
void mvwprintf (window_t win, int x, int y, string fmt, ...) = #0;
void wrefresh (window_t win) = #0;
int get_event (qwaq_event_t *event) = #0;
@ -18,20 +19,22 @@ int main (int argc, string *argv)
initialize ();
window_t win = create_window (20, 5, 50, 10);
mvwprintf (win, 0, 0, "Hi there! (q to quit)\n");
mvwprintf (win, 1, 1, "(?)Oo.\n");
mvwprintf (win, 1, 2, " \\_O>\n");
mvwprintf (win, 0, 0, "Hi there! (q to quit)");
mvwprintf (win, 1, 1, "(?)Oo.");
mvwprintf (win, 1, 2, " \\_O>");
wrefresh (win);
do {
if (get_event (&event)) {
if (event.event_type == qe_key) {
ch = event.e.key;
mvwprintf (win, 1, 1, "key: %d\n", ch);
mvwprintf (win, 1, 1, "key: %d", ch);
} else if (event.event_type == qe_mouse) {
mvwprintf (win, 1, 2, "mouse: %2d %2d %08x\n",
mvwprintf (win, 1, 2, "mouse: %2d %2d %08x",
event.e.mouse.x,
event.e.mouse.y,
event.e.mouse.buttons);
}
wrefresh (win);
}
} while (ch != 'q' && ch != 'Q');
destroy_window (win);

View file

@ -62,6 +62,7 @@ typedef enum qwaq_commands_e {
qwaq_cmd_bottom_panel,
qwaq_cmd_move_panel,
qwaq_cmd_mvwaddstr,
qwaq_cmd_wrefresh,
} qwaq_commands;
#define RING_BUFFER(type, size) \
@ -384,6 +385,14 @@ cmd_mvwaddstr (qwaq_resources_t *res)
window_t *window = get_window (res, __FUNCTION__, window_id);
mvwaddstr (window->win, y, x, res->strings[string_id].str);
release_string (res, string_id);
}
static void
cmd_wrefresh (qwaq_resources_t *res)
{
int window_id = RB_PEEK_DATA (res->command_queue, 2);
window_t *window = get_window (res, __FUNCTION__, window_id);
wrefresh (window->win);
}
@ -422,6 +431,9 @@ process_commands (qwaq_resources_t *res)
case qwaq_cmd_mvwaddstr:
cmd_mvwaddstr (res);
break;
case qwaq_cmd_wrefresh:
cmd_wrefresh (res);
break;
}
RB_DROP_DATA (res->command_queue, RB_PEEK_DATA (res->command_queue, 1));
}
@ -659,6 +671,22 @@ bi_mvwprintf (progs_t *pr)
}
}
static void
bi_wrefresh (progs_t *pr)
{
qwaq_resources_t *res = PR_Resources_Find (pr, "qwaq");
int window_id = P_INT (pr, 0);
if (get_window (res, __FUNCTION__, window_id)) {
int command[] = { qwaq_cmd_wrefresh, 0, window_id, };
command[1] = CMD_SIZE(command);
if (RB_SPACE_AVAILABLE (res->command_queue) >= CMD_SIZE(command)) {
RB_WRITE_DATA (res->command_queue, command, CMD_SIZE(command));
}
}
}
static void
bi_get_event (progs_t *pr)
{
@ -715,6 +743,7 @@ static builtin_t builtins[] = {
{"bottom_panel", bi_bottom_panel, -1},
{"move_panel", bi_move_panel, -1},
{"mvwprintf", bi_mvwprintf, -1},
{"wrefresh", bi_wrefresh, -1},
{"get_event", bi_get_event, -1},
{0}
};