api: generate ui events

This commit is contained in:
Björn Linse
2017-04-29 13:06:14 +02:00
parent d9023b84e6
commit 489d10c57c
10 changed files with 325 additions and 463 deletions

View File

@@ -19,6 +19,7 @@
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "api/ui.c.generated.h"
# include "ui_events_remote.generated.h"
#endif
typedef struct {
@@ -236,100 +237,6 @@ static void push_call(UI *ui, char *name, Array args)
kv_A(data->buffer, kv_size(data->buffer) - 1).data.array = call;
}
static void remote_ui_resize(UI *ui, int width, int height)
{
Array args = ARRAY_DICT_INIT;
ADD(args, INTEGER_OBJ(width));
ADD(args, INTEGER_OBJ(height));
push_call(ui, "resize", args);
}
static void remote_ui_clear(UI *ui)
{
Array args = ARRAY_DICT_INIT;
push_call(ui, "clear", args);
}
static void remote_ui_eol_clear(UI *ui)
{
Array args = ARRAY_DICT_INIT;
push_call(ui, "eol_clear", args);
}
static void remote_ui_cursor_goto(UI *ui, int row, int col)
{
Array args = ARRAY_DICT_INIT;
ADD(args, INTEGER_OBJ(row));
ADD(args, INTEGER_OBJ(col));
push_call(ui, "cursor_goto", args);
}
static void remote_ui_update_menu(UI *ui)
{
Array args = ARRAY_DICT_INIT;
push_call(ui, "update_menu", args);
}
static void remote_ui_busy_start(UI *ui)
{
Array args = ARRAY_DICT_INIT;
push_call(ui, "busy_start", args);
}
static void remote_ui_busy_stop(UI *ui)
{
Array args = ARRAY_DICT_INIT;
push_call(ui, "busy_stop", args);
}
static void remote_ui_mouse_on(UI *ui)
{
Array args = ARRAY_DICT_INIT;
push_call(ui, "mouse_on", args);
}
static void remote_ui_mouse_off(UI *ui)
{
Array args = ARRAY_DICT_INIT;
push_call(ui, "mouse_off", args);
}
static void remote_ui_mode_change(UI *ui, int mode_idx)
{
Array args = ARRAY_DICT_INIT;
char *full_name = shape_table[mode_idx].full_name;
ADD(args, STRING_OBJ(cstr_to_string(full_name)));
ADD(args, INTEGER_OBJ(mode_idx));
push_call(ui, "mode_change", args);
}
static void remote_ui_set_scroll_region(UI *ui, int top, int bot, int left,
int right)
{
Array args = ARRAY_DICT_INIT;
ADD(args, INTEGER_OBJ(top));
ADD(args, INTEGER_OBJ(bot));
ADD(args, INTEGER_OBJ(left));
ADD(args, INTEGER_OBJ(right));
push_call(ui, "set_scroll_region", args);
}
static void remote_ui_scroll(UI *ui, int count)
{
Array args = ARRAY_DICT_INIT;
ADD(args, INTEGER_OBJ(count));
push_call(ui, "scroll", args);
}
static void remote_ui_mode_info_set(UI *ui, bool guicursor_enabled, Array data)
{
Array args = ARRAY_DICT_INIT;
ADD(args, BOOLEAN_OBJ(guicursor_enabled));
ADD(args, copy_object(ARRAY_OBJ(data)));
push_call(ui, "mode_info_set", args);
}
static void remote_ui_highlight_set(UI *ui, HlAttrs attrs)
{
@@ -372,47 +279,6 @@ static void remote_ui_highlight_set(UI *ui, HlAttrs attrs)
push_call(ui, "highlight_set", args);
}
static void remote_ui_put(UI *ui, uint8_t *data, size_t size)
{
Array args = ARRAY_DICT_INIT;
String str = { .data = xmemdupz(data, size), .size = size };
ADD(args, STRING_OBJ(str));
push_call(ui, "put", args);
}
static void remote_ui_bell(UI *ui)
{
Array args = ARRAY_DICT_INIT;
push_call(ui, "bell", args);
}
static void remote_ui_visual_bell(UI *ui)
{
Array args = ARRAY_DICT_INIT;
push_call(ui, "visual_bell", args);
}
static void remote_ui_update_fg(UI *ui, int fg)
{
Array args = ARRAY_DICT_INIT;
ADD(args, INTEGER_OBJ(fg));
push_call(ui, "update_fg", args);
}
static void remote_ui_update_bg(UI *ui, int bg)
{
Array args = ARRAY_DICT_INIT;
ADD(args, INTEGER_OBJ(bg));
push_call(ui, "update_bg", args);
}
static void remote_ui_update_sp(UI *ui, int sp)
{
Array args = ARRAY_DICT_INIT;
ADD(args, INTEGER_OBJ(sp));
push_call(ui, "update_sp", args);
}
static void remote_ui_flush(UI *ui)
{
UIData *data = ui->data;
@@ -422,26 +288,6 @@ static void remote_ui_flush(UI *ui)
}
}
static void remote_ui_suspend(UI *ui)
{
Array args = ARRAY_DICT_INIT;
push_call(ui, "suspend", args);
}
static void remote_ui_set_title(UI *ui, char *title)
{
Array args = ARRAY_DICT_INIT;
ADD(args, STRING_OBJ(cstr_to_string(title)));
push_call(ui, "set_title", args);
}
static void remote_ui_set_icon(UI *ui, char *icon)
{
Array args = ARRAY_DICT_INIT;
ADD(args, STRING_OBJ(cstr_to_string(icon)));
push_call(ui, "set_icon", args);
}
static void remote_ui_event(UI *ui, char *name, Array args, bool *args_consumed)
{
Array my_args = ARRAY_DICT_INIT;