misc
This commit is contained in:
@@ -41,7 +41,7 @@ int main(int argc, char **argv) {
|
||||
b32 core_test_target = false;
|
||||
b32 win32_target = true;
|
||||
b32 standalone_w32_target = false;
|
||||
b32 wasm_target = false;
|
||||
b32 wasm_target = true;
|
||||
|
||||
if (run_server) {
|
||||
os_systemf("start /D ..\\package ..\\package\\run_server.bat");
|
||||
@@ -105,7 +105,7 @@ int main(int argc, char **argv) {
|
||||
ok = os_systemf(
|
||||
"clang.exe ../src/wasm_app/main.c -o main.wasm"
|
||||
" -Oz -g -I../src"
|
||||
" -Wall -Wno-missing-braces -Wno-single-bit-bitfield-constant-conversion -Wno-unsequenced"
|
||||
" -Wall -Wno-missing-braces -Wno-single-bit-bitfield-constant-conversion -Wno-unsequenced -Wno-initializer-overrides"
|
||||
" -fdiagnostics-absolute-paths -fdiagnostics-format=msvc"
|
||||
" --target=wasm32 -nostdlib -mbulk-memory -msimd128"
|
||||
" -Wl,-export-dynamic,--allow-undefined,--import-memory,--no-entry,--initial-memory=131072000,--max-memory=4294967296"
|
||||
|
||||
@@ -175,7 +175,7 @@ const wasm_app_imports = {
|
||||
|
||||
addEventListener("resize", (event) => { wake_up(); });
|
||||
addEventListener("keydown", (event) => {
|
||||
event.preventDefault();
|
||||
if (["F1", "F2", "F3", "p"].includes(event.key)) event.preventDefault();
|
||||
wasm_exports["wasm_key_down"](mem.write_string_to_cglobal("wasm_temp_buff1", event.key), event.ctrlKey, event.shiftKey, event.altKey, event.metaKey);
|
||||
wake_up();
|
||||
});
|
||||
|
||||
@@ -98,7 +98,7 @@ fn_wasm_export void wasm_key_down(char *key, b32 ctrl, b32 shift, b32 alt, b32 m
|
||||
});
|
||||
}
|
||||
|
||||
if (map.filter_out) {
|
||||
if (map.filter_out || ctrl) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ const wasm_app_imports = {
|
||||
|
||||
addEventListener("resize", (event) => { wake_up(); });
|
||||
addEventListener("keydown", (event) => {
|
||||
event.preventDefault();
|
||||
if (["F1", "F2", "F3", "p"].includes(event.key)) event.preventDefault();
|
||||
wasm_exports["wasm_key_down"](mem.write_string_to_cglobal("wasm_temp_buff1", event.key), event.ctrlKey, event.shiftKey, event.altKey, event.metaKey);
|
||||
wake_up();
|
||||
});
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#include "os/os.h"
|
||||
#include "app_win32_opengl.c"
|
||||
#include "os/os.c"
|
||||
|
||||
#pragma comment(linker, "/subsystem:windows")
|
||||
#pragma comment(lib, "gdi32.lib")
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#define APP_HOT_RELOAD
|
||||
|
||||
#include "core/core.h"
|
||||
#include "os/os.h"
|
||||
#include "app/app.h"
|
||||
|
||||
#include "core/core.c"
|
||||
#include "os/os.c"
|
||||
#include "app/app.c"
|
||||
|
||||
@@ -532,98 +532,3 @@ fn fuzzy_pair_t *fuzzy_rate_array(ma_arena_t *arena, s8_t needle, s8_t *array, i
|
||||
|
||||
return pairs;
|
||||
}
|
||||
|
||||
fn_test void test_s8(void) {
|
||||
ma_arena_t *arena = ma_create(ma_default_reserve_size);
|
||||
|
||||
{
|
||||
ma_temp_t temp = ma_begin_temp(arena);
|
||||
sb8_t *sb = &(sb8_t){arena};
|
||||
|
||||
s8_t memes = s8_lit("memes");
|
||||
sb8_printf(sb, "%S", memes);
|
||||
assert(sb->first == sb->last);
|
||||
assert(sb->first->len == 5);
|
||||
assert(s8_are_equal(sb->first->string, memes));
|
||||
|
||||
sb8_printf(sb, "%S", s8_lit("things are going fine"));
|
||||
s8_t string = sb8_merge(temp.arena, sb);
|
||||
assert(s8_are_equal(string, s8_lit("memesthings are going fine")));
|
||||
|
||||
ma_end_temp(temp);
|
||||
}
|
||||
|
||||
{
|
||||
s8_t str = s8_lit("thing|another|");
|
||||
sb8_t sb = s8_split(arena, str, s8_lit("|"), s8_split_none);
|
||||
|
||||
assert(s8_are_equal(sb.first->string, s8_lit("thing")));
|
||||
assert(s8_are_equal(sb.first->next->string, s8_lit("another")));
|
||||
assert(sb.first->next->next == NULL);
|
||||
}
|
||||
|
||||
{
|
||||
s8_t str = s8_lit("thing|another|");
|
||||
sb8_t sb = s8_split(arena, str, s8_lit("|"), s8_split_inclusive);
|
||||
|
||||
assert(s8_are_equal(sb.first->string, s8_lit("thing")));
|
||||
assert(s8_are_equal(sb.first->next->string, s8_lit("|")));
|
||||
assert(s8_are_equal(sb.first->next->next->string, s8_lit("another")));
|
||||
assert(s8_are_equal(sb.first->next->next->next->string, s8_lit("|")));
|
||||
assert(sb.first->next->next->next->next == NULL);
|
||||
}
|
||||
|
||||
{
|
||||
s8_t str = s8_lit("aabaaBaa");
|
||||
sb8_t sb = s8_split(arena, str, s8_lit("b"), s8_split_inclusive | s8_split_ignore_case);
|
||||
|
||||
assert(s8_are_equal(sb.first->string, s8_lit("aa")));
|
||||
assert(s8_are_equal(sb.first->next->string, s8_lit("b")));
|
||||
assert(s8_are_equal(sb.first->next->next->string, s8_lit("aa")));
|
||||
assert(s8_are_equal(sb.first->next->next->next->string, s8_lit("B")));
|
||||
assert(s8_are_equal(sb.first->next->next->next->next->string, s8_lit("aa")));
|
||||
assert(sb.first->next->next->next->next->next == NULL);
|
||||
}
|
||||
|
||||
{
|
||||
s8_t str = s8_lit("aabaaBaa");
|
||||
sb8_t sb = s8_split(arena, str, s8_lit("b"), s8_split_inclusive);
|
||||
|
||||
assert(s8_are_equal(sb.first->string, s8_lit("aa")));
|
||||
assert(s8_are_equal(sb.first->next->string, s8_lit("b")));
|
||||
assert(s8_are_equal(sb.first->next->next->string, s8_lit("aaBaa")));
|
||||
}
|
||||
|
||||
{
|
||||
s8_t s = s8_lit("0123456789");
|
||||
assert(s8_are_equal(s8_slice(s, 0, 4), s8_lit("0123")));
|
||||
assert(s8_are_equal(s8_slice(s, -2, -1), s8_lit("89")));
|
||||
assert(s8_are_equal(s8_slice(s, -2, 10), s8_lit("89")));
|
||||
assert(s8_are_equal(s8_slice(s, 8, 10), s8_lit("89")));
|
||||
}
|
||||
|
||||
{
|
||||
s8_t s = s8_lit(" a \n");
|
||||
s = s8_trim(s);
|
||||
assert(s8_are_equal(s, s8_lit("a")));
|
||||
}
|
||||
|
||||
{
|
||||
s8_t s = s8_lit("C:/memes/the_thing.c");
|
||||
s8_t ss = s8_get_name_no_ext(s);
|
||||
assert(s8_are_equal(ss, s8_lit("the_thing")));
|
||||
}
|
||||
|
||||
{
|
||||
s8_t s = s8_printf(arena, "%d%Sv%s", 32, s8_lit("|"), ">");
|
||||
assert(s8_are_equal(s, s8_lit("32|v>")));
|
||||
}
|
||||
|
||||
{
|
||||
s8_t s0 = s8_lit("0123456789");
|
||||
s8_t s1 = s8_cut_start(&s0, 2);
|
||||
assert(s8_are_equal(s0, s8_lit("23456789")));
|
||||
assert(s8_are_equal(s1, s8_lit("01")));
|
||||
}
|
||||
ma_destroy(arena);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#if PLATFORM_WASM
|
||||
#include "os_wasm.c"
|
||||
#elif PLATFORM_WINDOWS
|
||||
#if PLATFORM_WINDOWS
|
||||
#include "os_win32.c"
|
||||
#else
|
||||
#elif PLATFORM_POSIX
|
||||
#include "os_unix.c"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -5,10 +5,12 @@ fn_wasm_import f32 wasm_measure_text(isize str, i32 len, isize font_str, i32 fo
|
||||
fn_wasm_import void wasm_set_clip(f32 x, f32 y, f32 w, f32 h);
|
||||
|
||||
gb_read_only s8_t font_face = s8_const_lit("main_font");
|
||||
fn void rn_reload_font(f32 font_size, f32 dpr);
|
||||
|
||||
typedef struct rn_font_t rn_font_t;
|
||||
struct rn_font_t {
|
||||
f32 size;
|
||||
f32 computed_xchar_size;
|
||||
};
|
||||
|
||||
typedef struct rn_state_t rn_state_t;
|
||||
@@ -18,10 +20,6 @@ struct rn_state_t {
|
||||
};
|
||||
rn_state_t *rn;
|
||||
|
||||
fn void rn_reload_font(f32 font_size, f32 dpr) {
|
||||
rn->main_font->size = font_size * dpr;
|
||||
}
|
||||
|
||||
fn void rn_init(ma_arena_t *perm, f32 font_size, f32 dpr) {
|
||||
tcx->data[tcx_slot_rn] = ma_push_type(perm, rn_state_t);
|
||||
rn = tcx->data[tcx_slot_rn];
|
||||
@@ -50,6 +48,11 @@ fn v2f32_t rn_measure_string(rn_font_t *font, s8_t string) {
|
||||
return (v2f32_t){x, rn->main_font->size};
|
||||
}
|
||||
|
||||
fn void rn_reload_font(f32 font_size, f32 dpr) {
|
||||
rn->main_font->size = font_size * dpr;
|
||||
rn->main_font->computed_xchar_size = rn_measure_string(rn->main_font, s8_lit("_")).x;
|
||||
}
|
||||
|
||||
fn v2f32_t rn_draw_string(rn_font_t *font, v2f32_t pos, v4f32_t color, s8_t string) {
|
||||
wasm_draw_text((isize)string.str, string.len, pos.x, pos.y, (isize) font_face.str, font_face.len, rn->main_font->size, color.r * 255.f, color.g * 255.f, color.b * 255.f, color.a);
|
||||
v2f32_t size = rn_measure_string(font, string);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
fn void run_tests(void) {
|
||||
test_s8();
|
||||
test_hash_table();
|
||||
test_intern_table();
|
||||
}
|
||||
|
||||
@@ -28,9 +28,105 @@ fn void os_test(void) {
|
||||
debugf("%S %S %S", exe_dir, exe, cwd);
|
||||
}
|
||||
|
||||
fn void test_s8(void) {
|
||||
ma_arena_t *arena = ma_create(ma_default_reserve_size);
|
||||
|
||||
{
|
||||
ma_temp_t temp = ma_begin_temp(arena);
|
||||
sb8_t *sb = &(sb8_t){arena};
|
||||
|
||||
s8_t memes = s8_lit("memes");
|
||||
sb8_printf(sb, "%S", memes);
|
||||
assert(sb->first == sb->last);
|
||||
assert(sb->first->len == 5);
|
||||
assert(s8_are_equal(sb->first->string, memes));
|
||||
|
||||
sb8_printf(sb, "%S", s8_lit("things are going fine"));
|
||||
s8_t string = sb8_merge(temp.arena, sb);
|
||||
assert(s8_are_equal(string, s8_lit("memesthings are going fine")));
|
||||
|
||||
ma_end_temp(temp);
|
||||
}
|
||||
|
||||
{
|
||||
s8_t str = s8_lit("thing|another|");
|
||||
sb8_t sb = s8_split(arena, str, s8_lit("|"), s8_split_none);
|
||||
|
||||
assert(s8_are_equal(sb.first->string, s8_lit("thing")));
|
||||
assert(s8_are_equal(sb.first->next->string, s8_lit("another")));
|
||||
assert(sb.first->next->next == NULL);
|
||||
}
|
||||
|
||||
{
|
||||
s8_t str = s8_lit("thing|another|");
|
||||
sb8_t sb = s8_split(arena, str, s8_lit("|"), s8_split_inclusive);
|
||||
|
||||
assert(s8_are_equal(sb.first->string, s8_lit("thing")));
|
||||
assert(s8_are_equal(sb.first->next->string, s8_lit("|")));
|
||||
assert(s8_are_equal(sb.first->next->next->string, s8_lit("another")));
|
||||
assert(s8_are_equal(sb.first->next->next->next->string, s8_lit("|")));
|
||||
assert(sb.first->next->next->next->next == NULL);
|
||||
}
|
||||
|
||||
{
|
||||
s8_t str = s8_lit("aabaaBaa");
|
||||
sb8_t sb = s8_split(arena, str, s8_lit("b"), s8_split_inclusive | s8_split_ignore_case);
|
||||
|
||||
assert(s8_are_equal(sb.first->string, s8_lit("aa")));
|
||||
assert(s8_are_equal(sb.first->next->string, s8_lit("b")));
|
||||
assert(s8_are_equal(sb.first->next->next->string, s8_lit("aa")));
|
||||
assert(s8_are_equal(sb.first->next->next->next->string, s8_lit("B")));
|
||||
assert(s8_are_equal(sb.first->next->next->next->next->string, s8_lit("aa")));
|
||||
assert(sb.first->next->next->next->next->next == NULL);
|
||||
}
|
||||
|
||||
{
|
||||
s8_t str = s8_lit("aabaaBaa");
|
||||
sb8_t sb = s8_split(arena, str, s8_lit("b"), s8_split_inclusive);
|
||||
|
||||
assert(s8_are_equal(sb.first->string, s8_lit("aa")));
|
||||
assert(s8_are_equal(sb.first->next->string, s8_lit("b")));
|
||||
assert(s8_are_equal(sb.first->next->next->string, s8_lit("aaBaa")));
|
||||
}
|
||||
|
||||
{
|
||||
s8_t s = s8_lit("0123456789");
|
||||
assert(s8_are_equal(s8_slice(s, 0, 4), s8_lit("0123")));
|
||||
assert(s8_are_equal(s8_slice(s, -2, -1), s8_lit("89")));
|
||||
assert(s8_are_equal(s8_slice(s, -2, 10), s8_lit("89")));
|
||||
assert(s8_are_equal(s8_slice(s, 8, 10), s8_lit("89")));
|
||||
}
|
||||
|
||||
{
|
||||
s8_t s = s8_lit(" a \n");
|
||||
s = s8_trim(s);
|
||||
assert(s8_are_equal(s, s8_lit("a")));
|
||||
}
|
||||
|
||||
{
|
||||
s8_t s = s8_lit("C:/memes/the_thing.c");
|
||||
s8_t ss = s8_get_name_no_ext(s);
|
||||
assert(s8_are_equal(ss, s8_lit("the_thing")));
|
||||
}
|
||||
|
||||
{
|
||||
s8_t s = s8_printf(arena, "%d%Sv%s", 32, s8_lit("|"), ">");
|
||||
assert(s8_are_equal(s, s8_lit("32|v>")));
|
||||
}
|
||||
|
||||
{
|
||||
s8_t s0 = s8_lit("0123456789");
|
||||
s8_t s1 = s8_cut_start(&s0, 2);
|
||||
assert(s8_are_equal(s0, s8_lit("23456789")));
|
||||
assert(s8_are_equal(s1, s8_lit("01")));
|
||||
}
|
||||
ma_destroy(arena);
|
||||
}
|
||||
|
||||
int main() {
|
||||
core_init();
|
||||
run_tests();
|
||||
test_s8();
|
||||
os_test();
|
||||
return 0;
|
||||
}
|
||||
@@ -1559,11 +1559,10 @@ fn void ui_demo_update(app_frame_t *frame, mt_tweak_t *tweak_table, i32 tweak_co
|
||||
ui_set_lop(ui_lop_cut_top) {
|
||||
locl char buff[128];
|
||||
locl ui_text_input_t text_input;
|
||||
if (text_input.str == NULL) {
|
||||
text_input.str = buff;
|
||||
text_input.cap = lengthof(buff);
|
||||
}
|
||||
ui_signal_t ti_sig = ui_text_input(&text_input, true);
|
||||
if (lister_just_opened) text_input.len = 0;
|
||||
|
||||
ma_temp_t scratch = ma_begin_scratch();
|
||||
s8_t needle = s8(text_input.str, text_input.len);
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
#include "core/core.h"
|
||||
#include "os/os.h"
|
||||
#include "app/app.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
|
||||
#include "core/core.c"
|
||||
#include "os/os.c"
|
||||
#include "app/app.c"
|
||||
#include "render/render.c"
|
||||
#include "ui/ui.c"
|
||||
|
||||
@@ -7,7 +7,6 @@ gb_read_only mt_tweak_t tweak_table[] = {
|
||||
|
||||
};
|
||||
void run_all_tests(void) {
|
||||
test_s8();
|
||||
test_hash_table();
|
||||
test_intern_table();
|
||||
ui_test_text_replace();
|
||||
|
||||
42
todo.txt
42
todo.txt
@@ -1,7 +1,6 @@
|
||||
[ ] app
|
||||
[ ] event playback
|
||||
[ ] win32
|
||||
[x] sleep
|
||||
[ ] hot reload / plugins
|
||||
[ ] tests using yield
|
||||
[ ] touchpad gestures: https://learn.microsoft.com/en-us/windows/win32/wintouch/windows-touch-gestures-overview
|
||||
@@ -10,46 +9,31 @@
|
||||
[ ] drag and drop
|
||||
[ ] open file dialog
|
||||
[ ] os
|
||||
[x] delete all pdbs\dlls on start
|
||||
[?] wasm (explore)
|
||||
[x] win32
|
||||
[ ] linux
|
||||
|
||||
[ ] render
|
||||
[x] fix opengl warnings on win32 -> no need
|
||||
[ ] wasm (maybe try first without opengl and then opengl)
|
||||
[x] canvas
|
||||
[ ] opengl
|
||||
[ ] maybe copy package stuff to build?
|
||||
|
||||
[ ] ui
|
||||
[ ] sleep when not animating
|
||||
[ ] concept of active panel
|
||||
[ ] separate root so can't focus off with keyboard
|
||||
[ ] clicking away from panel, closes it or changes focus
|
||||
[ ] hot to move between panels?
|
||||
[ ] table
|
||||
[ ] scroll
|
||||
[x] basic abstraction
|
||||
[ ] allow for horizontal non-efficient
|
||||
[ ] keyboard handling
|
||||
[x] vertical scroll
|
||||
[x] working
|
||||
[x] horizontal scroll
|
||||
[x] efficient, on fixed size
|
||||
[x] non-efficient
|
||||
[ ] scrolling with keyboard
|
||||
[ ] context menu
|
||||
[x] working
|
||||
[ ] maybe a separate root for context menu?
|
||||
[ ] hover tooltips
|
||||
[ ] separate root which gets drawn on top of all ui
|
||||
[ ] upper left menu dynamics
|
||||
[x] debug console, lines
|
||||
[x] fix elements getting offset when font large and they are on the edge
|
||||
[ ] text input
|
||||
[x] basic working
|
||||
[x] enter signal
|
||||
[ ] ctrl backspace, ctrl delete
|
||||
[ ] set mouse cursor on hover
|
||||
[ ] maybe copy over text editor code from other project?
|
||||
[ ] everything lister (with edits etc.)
|
||||
[ ] pernament storage?
|
||||
[ ] push pop flag
|
||||
@@ -57,13 +41,10 @@
|
||||
- css like based on ids and pre built palettes
|
||||
- fat box with stacks (now)
|
||||
[ ] demo style, with different buttons and controls, headings
|
||||
[x] palette idea, also push pop palette
|
||||
[x] replace padding with something more 'real'
|
||||
[ ] color picker
|
||||
[ ] slider
|
||||
[ ] draw image in box ui
|
||||
[x] rect stack
|
||||
[x] jumping between nodes (get_prev, get_next) needs a fix
|
||||
[ ] push flags?
|
||||
|
||||
[ ] core
|
||||
[ ] ast
|
||||
@@ -74,20 +55,7 @@
|
||||
[ ] explore metadata flags for common formats aka (key_value, list etc.. will
|
||||
[ ] json format
|
||||
[ ] ini format
|
||||
[x] remove dates and time from core
|
||||
[ ] build system
|
||||
[ ] threads
|
||||
[ ] use threads
|
||||
[ ] meta
|
||||
[x] parser errors should not point to location of fatalf call but to the code!!!!!!!!!
|
||||
[x] prototype something like templates, readable string generation
|
||||
[x] search for python snippets and execute meta.py script on that file
|
||||
[x] simplify logging!!!!
|
||||
[x] somehow index properly the meta files and ignore generated files
|
||||
[x] extract declarations from c files meta(introspect)
|
||||
[x] tweak variables and embeds declared in c code
|
||||
[x] replace @tags with mt_tag(dont_serialize)
|
||||
[x] revisit api
|
||||
[ ] s8_bin
|
||||
[x] hash table
|
||||
[x] intern table
|
||||
[x] safe cast
|
||||
|
||||
Reference in New Issue
Block a user