[qwaq] Implement missing addch

I either forgot about it, or just didn't need it at the time, but I'm
sure it will be useful later when more stuff is implemented.
This commit is contained in:
Bill Currie 2020-03-06 17:57:33 +09:00
parent 9a96a9b2c9
commit b8b74fc074
6 changed files with 54 additions and 4 deletions

View file

@ -72,6 +72,7 @@ typedef enum qwaq_commands_e {
qwaq_cmd_mvwaddstr,
qwaq_cmd_waddstr,
qwaq_cmd_mvwaddch,
qwaq_cmd_waddch,
qwaq_cmd_wrefresh,
qwaq_cmd_init_pair,
qwaq_cmd_wbkgd,
@ -532,6 +533,16 @@ cmd_mvwaddch (qwaq_resources_t *res)
mvwaddch (window->win, y, x, ch);
}
static void
cmd_waddch (qwaq_resources_t *res)
{
int window_id = RB_PEEK_DATA (res->command_queue, 2);
int ch = RB_PEEK_DATA (res->command_queue, 3);
window_t *window = get_window (res, __FUNCTION__, window_id);
waddch (window->win, ch);
}
static void
cmd_wrefresh (qwaq_resources_t *res)
{
@ -665,6 +676,9 @@ process_commands (qwaq_resources_t *res)
case qwaq_cmd_mvwaddch:
cmd_mvwaddch (res);
break;
case qwaq_cmd_waddch:
cmd_waddch (res);
break;
case qwaq_cmd_wrefresh:
cmd_wrefresh (res);
break;
@ -1102,6 +1116,27 @@ bi_wvprintf (progs_t *pr)
qwaq_wvprintf (pr, window_id, fmt, args);
}
static void
qwaq_waddch (progs_t *pr, int window_id, int ch)
{
qwaq_resources_t *res = PR_Resources_Find (pr, "qwaq");
if (get_window (res, __FUNCTION__, window_id)) {
int command[] = { qwaq_cmd_waddch, 0, window_id, ch };
command[1] = CMD_SIZE(command);
qwaq_submit_command (res, command);
}
}
static void
bi_waddch (progs_t *pr)
{
int window_id = P_INT (pr, 0);
int ch = P_INT (pr, 0);
qwaq_waddch (pr, window_id, ch);
}
static void
qwaq_mvwvprintf (progs_t *pr, int window_id, int x, int y,
const char *fmt, pr_va_list_t *args)
@ -1451,7 +1486,7 @@ bi_i_TextContext__printf_ (progs_t *pr)
}
static void
bi_i_TextContext__vprintf_ (progs_t *pr)
bi_i_TextContext__addch_ (progs_t *pr)
{
int window_id = P_STRUCT (pr, qwaq_textcontext_t, 0).window;
const char *fmt = P_GSTRING (pr, 2);
@ -1460,6 +1495,15 @@ bi_i_TextContext__vprintf_ (progs_t *pr)
qwaq_wvprintf (pr, window_id, fmt, args);
}
static void
bi_i_TextContext__vprintf_ (progs_t *pr)
{
int window_id = P_STRUCT (pr, qwaq_textcontext_t, 0).window;
int ch = P_INT (pr, 1);
qwaq_waddch (pr, window_id, ch);
}
static void
bi_i_TextContext__mvvprintf_ (progs_t *pr)
{
@ -1551,6 +1595,7 @@ static builtin_t builtins[] = {
{"wvprintf", bi_wvprintf, -1},
{"mvwvprintf", bi_mvwvprintf, -1},
{"mvwaddch", bi_mvwaddch, -1},
{"waddch", bi_waddch, -1},
{"wrefresh", bi_wrefresh, -1},
{"get_event", bi_get_event, -1},
{"max_colors", bi_max_colors, -1},
@ -1574,6 +1619,7 @@ static builtin_t builtins[] = {
{"_i_TextContext__mvprintf_", bi_i_TextContext__mvprintf_, -1},
{"_i_TextContext__printf_", bi_i_TextContext__printf_, -1},
{"_i_TextContext__vprintf_", bi_i_TextContext__vprintf_, -1},
{"_i_TextContext__addch_", bi_i_TextContext__addch_, -1},
{"_i_TextContext__mvvprintf_", bi_i_TextContext__mvvprintf_, -1},
{"_i_TextContext__refresh", bi_i_TextContext__refresh, -1},
{"_i_TextContext__mvaddch_", bi_i_TextContext__mvaddch_, -1},

View file

@ -94,6 +94,7 @@ typedef struct panel_s *panel_t;
string fmt, @va_list args);
@extern void wrefresh (window_t win);
@extern void mvwaddch (window_t win, int x, int y, int ch);
@extern void waddch (window_t win, int ch);
@extern panel_t create_panel (window_t window);
@extern void destroy_panel (panel_t panel);

View file

@ -27,6 +27,7 @@
- (void) printf: (string) fmt, ...;
- (void) vprintf: (string) mft, @va_list args;
- (void) addch: (int) ch;
- (void) mvprintf: (Point) pos, string fmt, ...;
- (void) mvvprintf: (Point) pos, string mft, @va_list args;
- (void) mvaddch: (Point) pos, int ch;

View file

@ -62,6 +62,7 @@ static TextContext *screen;
- (void) mvprintf: (Point) pos, string fmt, ... = #0;
- (void) printf: (string) fmt, ... = #0;
- (void) vprintf: (string) mft, @va_list args = #0;
- (void) addch: (int) ch = #0;
- (void) mvvprintf: (Point) pos, string mft, @va_list args = #0;
- (void) refresh = #0;
- (void) mvaddch: (Point) pos, int ch = #0;
@ -82,6 +83,7 @@ void wvprintf (window_t win, string fmt, @va_list args) = #0;
void mvwvprintf (window_t win, int x, int y, string fmt, @va_list args) = #0;
void wrefresh (window_t win) = #0;
void mvwaddch (window_t win, int x, int y, int ch) = #0;
void waddch (window_t win, int ch) = #0;
int get_event (qwaq_event_t *event) = #0;
int max_colors (void) = #0;
int max_color_pairs (void) = #0;

View file

@ -61,7 +61,7 @@ enum {
- (void) refresh;
- (void) printf: (string) fmt, ...;
- (void) vprintf: (string) fmt, @va_list args;
//- (void) addch: (int) ch;
- (void) addch: (int) ch;
- (void) mvprintf: (Point) pos, string fmt, ...;
- (void) mvvprintf: (Point) pos, string fmt, @va_list args;
- (void) mvaddch: (Point) pos, int ch;

View file

@ -119,11 +119,11 @@ updateScreenCursor (View *view)
{
[textContext refresh];
}
/*
- (void) addch: (int) ch
{
[textContext addch:ch];
}*/
}
- (void) mvprintf: (Point) pos, string fmt, ...
{