added dependency: tim

This commit is contained in:
2026-01-09 06:12:17 +05:00
parent 0132e71c88
commit 151ad13853
8 changed files with 58 additions and 6 deletions

View File

@@ -2,6 +2,7 @@
#include "tlibc/filesystem.h"
#include "tlibc/term.h"
#include "network/tcp-chat-protocol/v1.h"
#include "tim.h"
static const str greeting_art = STR(
" ^,,^ |\n"
@@ -48,7 +49,33 @@ void ClientCLI_construct(ClientCLI* self){
Result(void) ClientCLI_run(ClientCLI* self) {
Deferral(16);
try_void(term_init());
TimEditState e;
TimEditState_init(&e, 32, "Greetings!");
bool edit_enabled = false;
while(tim_run(0)){
uint64_t c = 0x0f040f;
tim_frame(0, 0, ~0, ~0, c);
tim_label(e.s, A, 2, A, A, c);
if(edit_enabled){
TimKey key = tim_edit(&e, A, 5, tim->scopes[tim->scope].w - 4, c);
if(key == TimKey_Escape || key == TimKey_Enter)
edit_enabled = false;
}
else {
if(tim_button("[Enter] Edit text", A, 5, tim->scopes[tim->scope].w - 4, A, c) || tim_is_key_press(TimKey_Enter)){
edit_enabled = true;
tim->focus = &e;
tim->event.type = TimEvent_Void; // consume key event
}
}
if(tim_button("[Q] Quit", A, ~1, 10, A, c) || tim_is_key_press('q'))
break;
}
term_clear();
printf(FMT_str"\n", greeting_art.len, greeting_art.data);