diff options
Diffstat (limited to 'TUI/module.jai')
| -rw-r--r-- | TUI/module.jai | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/TUI/module.jai b/TUI/module.jai index c1f40ce..f113c2a 100644 --- a/TUI/module.jai +++ b/TUI/module.jai @@ -138,14 +138,16 @@ process_input :: (thread: *Thread) -> s64 { return 0; } -process_resize :: (signal : s32) #c_call { +process_resize :: (signal_code : s32) #c_call { new_context : Context; push_context new_context { - if signal != SIGWINCH return; + print("SIGNAL:%", signal_code); + if signal_code != SIGWINCH return; + print("RESIZE\n"); lock(*key_mutex); defer unlock(*key_mutex); // TODO Only signal the key_semaphore if we don't already have a Resize on the queue. - if key_resize != Key.None continue; + if key_resize != Keys.None return; key_resize = Keys.Resize; signal(*key_semaphore); } @@ -167,6 +169,24 @@ get_key :: (wait_milliseconds: s32) -> Key { } +// TODO Rename this procedure. +set_handler :: () { + sa : sigaction_t; + sa.sa_handler = process_resize; + sigemptyset(*(sa.sa_mask)); + sa.sa_flags = SA_RESTART; + sigaction(SIGWINCH, *sa, null); +} + +// TODO Rename this procedure. +restore_handler :: () { + sa : sigaction_t; + sa.sa_handler = SIG_DFL; + sigaction(SIGWINCH, null, *sa); +} + + + start :: () { if initialized == true return; dam("A"); @@ -182,18 +202,22 @@ dam("C"); dam("D"); initialized = true; thread_start(*input_process_thread); + set_handler(); // TODO Move to beter place. dam("E"); + } stop :: () { if initialized == false return; initialized = false; + + restore_handler(); // TODO Move to beter place. thread_deinit(*input_process_thread); destroy(*key_semaphore); OS_reset_terminal(); - // write_strings(Commands.EnterMainBuffer, Commands.RestoreCursorPosition, Commands.ShowCursor); + write_strings(Commands.EnterMainBuffer, Commands.RestoreCursorPosition, Commands.ShowCursor); } get_str :: () -> string { |
