remove test code, fix os_console_log additional new line
This commit is contained in:
@@ -24,7 +24,7 @@ fn void os_error_box(char *str) {
|
|||||||
|
|
||||||
fn void os_console_log(char *str) {
|
fn void os_console_log(char *str) {
|
||||||
OutputDebugStringA(str);
|
OutputDebugStringA(str);
|
||||||
puts(str);
|
fputs(str, stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn f64 os_parse_float(char *str) {
|
fn f64 os_parse_float(char *str) {
|
||||||
|
|||||||
@@ -89,6 +89,58 @@ fn s8_t mtts(ast_t *row, char *name) {
|
|||||||
return v->string;
|
return v->string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn s8_t mt_templatize_string(ma_arena_t *arena, s8_t string, lex_array_t tokens, ast_t *n) {
|
||||||
|
ma_temp_t scratch = ma_begin_scratch1(arena);
|
||||||
|
sb8_t *sb = sb8_serial_begin(scratch.arena);
|
||||||
|
parser_t *par = parser_make(arena, tokens.data);
|
||||||
|
|
||||||
|
for (i64 i = 0; i < string.len;) {
|
||||||
|
if (par->at->str != string.str + i) {
|
||||||
|
sb8_append(sb, s8(string.str + i, 1));
|
||||||
|
i += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
lex_t *token = parser_next(par); i += token->len;
|
||||||
|
if (token->kind == lex_kind_tag && char_is_alphanumeric(string.str[i])) {
|
||||||
|
lex_t *ident = parser_expect(par, lex_kind_ident); i += ident->len;
|
||||||
|
sb8_append(sb, mtt_gets(n, ident->string));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
sb8_append(sb, token->string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
s8_t result = sb8_serial_end(arena, sb);
|
||||||
|
ma_end_scratch(scratch);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn s8_t mt_print(ma_arena_t *arena, ast_t *n, s8_t string) {
|
||||||
|
ma_temp_t scratch = ma_begin_scratch1(arena);
|
||||||
|
lex_array_t tokens = lex_tokens(scratch.arena, "mt_print", string);
|
||||||
|
string = mt_templatize_string(arena, string, tokens, n);
|
||||||
|
ma_end_scratch(scratch);
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn s8_t mt_printf(ma_arena_t *arena, ast_t *n, char *str, ...) {
|
||||||
|
ma_temp_t scratch = ma_begin_scratch1(arena);
|
||||||
|
S8_FMT(scratch.arena, str, string);
|
||||||
|
s8_t result = mt_print(arena, n, string);
|
||||||
|
ma_end_scratch(scratch);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn s8_t mt_sbprintf(sb8_t *sb, char *str, ...) {
|
||||||
|
assert(sb->user_data);
|
||||||
|
ma_temp_t scratch = ma_begin_scratch1(sb->arena);
|
||||||
|
S8_FMT(scratch.arena, str, string);
|
||||||
|
s8_t result = mt_print(sb->arena, (ast_t *)sb->user_data, string);
|
||||||
|
sb8_append(sb, result);
|
||||||
|
ma_end_scratch(scratch);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
fn void mtt_serialb(sb8_t *c, sb8_t *h, ast_t *table, s8_t decl) {
|
fn void mtt_serialb(sb8_t *c, sb8_t *h, ast_t *table, s8_t decl) {
|
||||||
s8_t name_t = s8_printf(c->arena, "%S_t", decl);
|
s8_t name_t = s8_printf(c->arena, "%S_t", decl);
|
||||||
|
|
||||||
|
|||||||
148
src/ui/ui.meta.c
148
src/ui/ui.meta.c
@@ -1,152 +1,4 @@
|
|||||||
fn ast_t *mt_ast_string(ma_arena_t *arena, s8_t string) {
|
|
||||||
ast_t *n = mt_create_ast(arena, &lex_null, set_bit(ast_flag_string));
|
|
||||||
n->string = string;
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn ast_t *mt_kv(ma_arena_t *arena, s8_t key, s8_t value) {
|
|
||||||
ast_t *n = mt_ast_string(arena, key);
|
|
||||||
mt_ast_append(n, mt_ast_string(arena, value));
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn s8_t mt_templatize_string(ma_arena_t *arena, s8_t string, lex_array_t tokens, ast_t *n) {
|
|
||||||
ma_temp_t scratch = ma_begin_scratch1(arena);
|
|
||||||
sb8_t *sb = sb8_serial_begin(scratch.arena);
|
|
||||||
parser_t *par = parser_make(arena, tokens.data);
|
|
||||||
|
|
||||||
for (i64 i = 0; i < string.len;) {
|
|
||||||
if (par->at->str != string.str + i) {
|
|
||||||
sb8_append(sb, s8(string.str + i, 1));
|
|
||||||
i += 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
lex_t *token = parser_next(par); i += token->len;
|
|
||||||
if (token->kind == lex_kind_tag && char_is_alphanumeric(string.str[i])) {
|
|
||||||
lex_t *ident = parser_expect(par, lex_kind_ident); i += ident->len;
|
|
||||||
sb8_append(sb, mtt_gets(n, ident->string));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
sb8_append(sb, token->string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
s8_t result = sb8_serial_end(arena, sb);
|
|
||||||
ma_end_scratch(scratch);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn s8_t mt_print(ma_arena_t *arena, ast_t *n, s8_t string) {
|
|
||||||
ma_temp_t scratch = ma_begin_scratch1(arena);
|
|
||||||
lex_array_t tokens = lex_tokens(scratch.arena, "mt_print", string);
|
|
||||||
string = mt_templatize_string(arena, string, tokens, n);
|
|
||||||
ma_end_scratch(scratch);
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn s8_t mt_printf(ma_arena_t *arena, ast_t *n, char *str, ...) {
|
|
||||||
ma_temp_t scratch = ma_begin_scratch1(arena);
|
|
||||||
S8_FMT(scratch.arena, str, string);
|
|
||||||
s8_t result = mt_print(arena, n, string);
|
|
||||||
ma_end_scratch(scratch);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn s8_t mt_sbprintf(sb8_t *sb, char *str, ...) {
|
|
||||||
assert(sb->user_data);
|
|
||||||
ma_temp_t scratch = ma_begin_scratch1(sb->arena);
|
|
||||||
S8_FMT(scratch.arena, str, string);
|
|
||||||
s8_t result = mt_print(sb->arena, (ast_t *)sb->user_data, string);
|
|
||||||
sb8_append(sb, result);
|
|
||||||
ma_end_scratch(scratch);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn void mt_test_replace(ma_arena_t *arena) {
|
|
||||||
ast_t *table = mtt_parse(arena, __FILE__, S8_CODE(
|
|
||||||
// javascript filter out
|
|
||||||
{ name js1 js2 jf windows1 windows2 }
|
|
||||||
{ null XXX XXX 1 XXX XXX }
|
|
||||||
{ 1 1 XXX 0 `'1'` XXX }
|
|
||||||
{ 2 2 XXX 0 `'2'` XXX }
|
|
||||||
{ 3 3 XXX 0 `'3'` XXX }
|
|
||||||
{ 4 4 XXX 0 `'4'` XXX }
|
|
||||||
{ 5 5 XXX 0 `'5'` XXX }
|
|
||||||
{ 6 6 XXX 0 `'6'` XXX }
|
|
||||||
{ 7 7 XXX 0 `'7'` XXX }
|
|
||||||
{ 8 8 XXX 0 `'8'` XXX }
|
|
||||||
{ 9 9 XXX 0 `'9'` XXX }
|
|
||||||
{ 0 0 XXX 0 `'0'` XXX }
|
|
||||||
{ f1 F1 XXX 1 VK_F1 XXX }
|
|
||||||
{ f2 F2 XXX 1 VK_F2 XXX }
|
|
||||||
{ f3 F3 XXX 1 VK_F3 XXX }
|
|
||||||
{ f4 F4 XXX 1 VK_F4 XXX }
|
|
||||||
{ f5 F5 XXX 1 VK_F5 XXX }
|
|
||||||
{ f6 F6 XXX 1 VK_F6 XXX }
|
|
||||||
{ f7 F7 XXX 1 VK_F7 XXX }
|
|
||||||
{ f8 F8 XXX 1 VK_F8 XXX }
|
|
||||||
{ f9 F9 XXX 1 VK_F9 XXX }
|
|
||||||
{ f10 F10 XXX 1 VK_F10 XXX }
|
|
||||||
{ f11 F11 XXX 1 VK_F11 XXX }
|
|
||||||
{ f12 F12 XXX 1 VK_F12 XXX }
|
|
||||||
{ a a XXX 0 `'A'` XXX }
|
|
||||||
{ b b XXX 0 `'B'` XXX }
|
|
||||||
{ c c XXX 0 `'C'` XXX }
|
|
||||||
{ d d XXX 0 `'D'` XXX }
|
|
||||||
{ e e XXX 0 `'E'` XXX }
|
|
||||||
{ f f XXX 0 `'F'` XXX }
|
|
||||||
{ g g XXX 0 `'G'` XXX }
|
|
||||||
{ h h XXX 0 `'H'` XXX }
|
|
||||||
{ i i XXX 0 `'I'` XXX }
|
|
||||||
{ j j XXX 0 `'J'` XXX }
|
|
||||||
{ k k XXX 0 `'K'` XXX }
|
|
||||||
{ l l XXX 0 `'L'` XXX }
|
|
||||||
{ m m XXX 0 `'M'` XXX }
|
|
||||||
{ n n XXX 0 `'N'` XXX }
|
|
||||||
{ o o XXX 0 `'O'` XXX }
|
|
||||||
{ p p XXX 0 `'P'` XXX }
|
|
||||||
{ q q XXX 0 `'Q'` XXX }
|
|
||||||
{ r r XXX 0 `'R'` XXX }
|
|
||||||
{ s s XXX 0 `'S'` XXX }
|
|
||||||
{ _t t XXX 0 `'T'` XXX }
|
|
||||||
{ u u XXX 0 `'U'` XXX }
|
|
||||||
{ v v XXX 0 `'V'` XXX }
|
|
||||||
{ w w XXX 0 `'W'` XXX }
|
|
||||||
{ x x XXX 0 `'X'` XXX }
|
|
||||||
{ y y XXX 0 `'Y'` XXX }
|
|
||||||
{ z z XXX 0 `'Z'` XXX }
|
|
||||||
{ space ` ` XXX 0 VK_SPACE XXX }
|
|
||||||
{ enter Enter XXX 1 VK_RETURN XXX }
|
|
||||||
{ escape Escape XXX 1 VK_ESCAPE XXX }
|
|
||||||
{ left ArrowLeft XXX 1 VK_LEFT XXX }
|
|
||||||
{ up ArrowUp XXX 1 VK_UP XXX }
|
|
||||||
{ right ArrowRight XXX 1 VK_RIGHT XXX }
|
|
||||||
{ down ArrowDown XXX 1 VK_DOWN XXX }
|
|
||||||
{ tab Tab XXX 1 VK_TAB XXX }
|
|
||||||
{ backspace Backspace XXX 1 VK_BACK XXX }
|
|
||||||
{ control Control XXX 1 VK_CONTROL XXX }
|
|
||||||
{ shift Shift XXX 1 VK_SHIFT XXX }
|
|
||||||
{ alt Alt AltGraph 1 VK_LMENU VK_RMENU }
|
|
||||||
{ meta Meta XXX 1 VK_LWIN VK_RWIN }
|
|
||||||
{ caps_lock CapsLock XXX 1 VK_CAPITAL XXX }
|
|
||||||
{ delete Delete XXX 1 VK_DELETE XXX }
|
|
||||||
{ home Home XXX 1 VK_HOME XXX }
|
|
||||||
{ end End XXX 1 VK_END XXX }
|
|
||||||
{ insert Insert XXX 1 VK_NEXT XXX }
|
|
||||||
{ page_up PageUp XXX 1 VK_INSERT XXX }
|
|
||||||
{ page_down PageDown XXX 1 VK_PRIOR XXX }
|
|
||||||
));
|
|
||||||
sb8_t *sb = sb8_serial_begin(arena);
|
|
||||||
for (ast_t *it = table->first; it; it = it->next) {
|
|
||||||
sb->user_data = it;
|
|
||||||
mt_sbprintf(sb, "@name = @windows1 @windows2\n");
|
|
||||||
}
|
|
||||||
debugf("%S", sb8_serial_end(arena, sb));
|
|
||||||
}
|
|
||||||
|
|
||||||
void mt_ui(ma_arena_t *arena) {
|
void mt_ui(ma_arena_t *arena) {
|
||||||
mt_test_replace(arena);
|
|
||||||
typedef struct mt_ui_stacks_t mt_ui_stacks_t;
|
typedef struct mt_ui_stacks_t mt_ui_stacks_t;
|
||||||
struct mt_ui_stacks_t {
|
struct mt_ui_stacks_t {
|
||||||
s8_t type;
|
s8_t type;
|
||||||
|
|||||||
Reference in New Issue
Block a user