[qwaq] Add printf builtin to ease debugging

This commit is contained in:
Bill Currie 2020-03-13 02:37:25 +09:00
parent 7f9a415cbc
commit 3defe50be6
3 changed files with 20 additions and 0 deletions

View file

@ -1468,6 +1468,20 @@ bi_initialize (progs_t *pr)
res->stdscr.win = stdscr;
}
static void
bi_printf (progs_t *pr)
{
const char *fmt = P_GSTRING (pr, 0);
int count = pr->pr_argc - 1;
pr_type_t **args = pr->pr_params + 1;
dstring_t *dstr = dstring_new ();
PR_Sprintf (pr, dstr, "bi_printf", fmt, count, args);
if (dstr->str)
Sys_Printf (dstr->str, stdout);
dstring_delete (dstr);
}
static void
bi_c_TextContext__is_initialized (progs_t *pr)
{
@ -1674,6 +1688,8 @@ static builtin_t builtins[] = {
{"wborder", bi_wborder, -1},
{"mvwblit_line", bi_mvwblit_line, -1},
{"printf", bi_printf, -1},
{"_c_TextContext__is_initialized", bi_c_TextContext__is_initialized, -1},
{"_c_TextContext__max_colors", bi_c_TextContext__max_colors, -1},
{"_c_TextContext__max_color_pairs", bi_c_TextContext__max_color_pairs, -1},

View file

@ -121,6 +121,8 @@ typedef struct panel_s *panel_t;
@extern void wborder (window_t window,
box_sides_t sides, box_corners_t corners);
@extern void mvwblit_line (window_t window, int x, int y, int *wch, int len);
@extern void printf(string fmt, ...);
#endif
#endif//__qwaq_curses_h

View file

@ -166,3 +166,5 @@ int curs_set (int visibility) = #0;
int move (int x, int y) = #0;
void wborder (window_t window, box_sides_t sides, box_corners_t corners) = #0;
void mvwblit_line (window_t window, int x, int y, int *wch, int len) = #0;
void printf(string fmt, ...) = #0;