From 6e5bacf1542c8da6103109a633b2d37339d595cf Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Fri, 6 May 2016 11:04:11 -0400 Subject: [PATCH] deduplicated gui list stuff, more keyboard nonsense --- 4ed_file_view.cpp | 6 ++++++ 4ed_gui.cpp | 37 +++++++++++++++++++++++++++++-------- win32_4ed.cpp | 16 ++++++++++++++++ 3 files changed, 51 insertions(+), 8 deletions(-) diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 9b41be34..b9d39eb3 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -4147,6 +4147,8 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su // TODO(allen): Deduplicate. Perhaps we want a standard list helper? id.id[0] = (u64)(hdir) + 1; if (gui_begin_list(target, id, view->list_i, 0, &update)){ + gui_standard_list(target, id, &keys, &view->list_i, &update); +#if 0 if (update.has_adjustment){ view->list_i = update.adjustment_value; } @@ -4171,6 +4173,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su gui_rollback(target, &update); gui_begin_list(target, id, view->list_i, indirectly_activate, 0); +#endif } { @@ -4243,6 +4246,8 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su // TODO(allen): Deduplicate. Perhaps we want a standard list helper? id.id[0] = (u64)(working_set) + 1; if (gui_begin_list(target, id, view->list_i, 0, &update)){ + gui_standard_list(target, id, &keys, &view->list_i, &update); +#if 0 if (update.has_adjustment){ view->list_i = update.adjustment_value; } @@ -4267,6 +4272,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su gui_rollback(target, &update); gui_begin_list(target, id, view->list_i, indirectly_activate, 0); +#endif } used_nodes = &working_set->used_sentinel; diff --git a/4ed_gui.cpp b/4ed_gui.cpp index 220bd863..df03a238 100644 --- a/4ed_gui.cpp +++ b/4ed_gui.cpp @@ -967,14 +967,6 @@ gui_interpret(GUI_Target *target, GUI_Session *session, GUI_Header *h){ end_section = section; break; -#if 0 - case guicom_text_input: - case guicom_file_input: - always_give_to_user = 1; - do_layout = 0; - break; -#endif - case guicom_color_button: case guicom_font_button: give_to_user = 1; @@ -1146,5 +1138,34 @@ gui_interpret(GUI_Target *target, GUI_Session *session, GUI_Header *h){ return(result); } +internal void +gui_standard_list(GUI_Target *target, GUI_id id, + Key_Summary *keys, i32 *list_i, GUI_Item_Update *update){ + if (update->has_adjustment){ + *list_i = update->adjustment_value; + } + + b32 indirectly_activate = 0; + for (i32 j = 0; j < keys->count; ++j){ + i16 key = keys->keys[j].keycode; + switch (key){ + case key_up: + --*list_i; + break; + + case key_down: + ++*list_i; + break; + + case '\n': + indirectly_activate = 1; + break; + } + } + + gui_rollback(target, update); + gui_begin_list(target, id, *list_i, indirectly_activate, 0); +} + // BOTTOM diff --git a/win32_4ed.cpp b/win32_4ed.cpp index 2da2c9de..36250771 100644 --- a/win32_4ed.cpp +++ b/win32_4ed.cpp @@ -1296,6 +1296,22 @@ Win32Callback(HWND hwnd, UINT uMsg, result2 = 0; } + // TODO(allen): This is becoming a really major issue. Apparently + // control + i outputs a '\t' which is VALID ascii according to this system. + // So it reports the key as '\t'. This wasn't an issue before because we were + // ignoring control when computing character_no_caps_lock which is what + // is used for commands. But that is incorrect for some keyboard layouts where + // control+alt is used to signal AltGr for important keys. + if (result1 && result2){ + char c1 = char_to_upper((char)x1); + char c2 = char_to_upper((char)x2); + char cParam = char_to_upper((char)wParam); + + if (c1 != cParam && c2 == cParam){ + result1 = 0; + } + } + if (result1){ x = x1; state[VK_CONTROL] = control_state;