set up GUI to consume keys it uses
This commit is contained in:
parent
76b68720ff
commit
ce27493fb3
22
4ed.cpp
22
4ed.cpp
|
@ -3884,14 +3884,13 @@ App_Step_Sig(app_step){
|
||||||
models->command_coroutine = command_coroutine;
|
models->command_coroutine = command_coroutine;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
app_result.perform_kill = 1;
|
models->keep_playing = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(allen): process the command_coroutine if it is unfinished
|
|
||||||
Available_Input available_input = init_available_input(&key_summary, &input->mouse);
|
|
||||||
|
|
||||||
// NOTE(allen): Keyboard input to command coroutine.
|
// NOTE(allen): Keyboard input to command coroutine.
|
||||||
|
Available_Input available_input = init_available_input(&key_summary, &input->mouse);
|
||||||
|
|
||||||
if (models->command_coroutine != 0){
|
if (models->command_coroutine != 0){
|
||||||
Coroutine *command_coroutine = models->command_coroutine;
|
Coroutine *command_coroutine = models->command_coroutine;
|
||||||
u32 get_flags = models->command_coroutine_flags[0];
|
u32 get_flags = models->command_coroutine_flags[0];
|
||||||
|
@ -4028,7 +4027,6 @@ App_Step_Sig(app_step){
|
||||||
update_command_data(vars, cmd);
|
update_command_data(vars, cmd);
|
||||||
|
|
||||||
// NOTE(allen): pass raw input to the panels
|
// NOTE(allen): pass raw input to the panels
|
||||||
|
|
||||||
Input_Summary dead_input = {};
|
Input_Summary dead_input = {};
|
||||||
dead_input.mouse.x = input->mouse.x;
|
dead_input.mouse.x = input->mouse.x;
|
||||||
dead_input.mouse.y = input->mouse.y;
|
dead_input.mouse.y = input->mouse.y;
|
||||||
|
@ -4054,9 +4052,17 @@ App_Step_Sig(app_step){
|
||||||
view = panel->view;
|
view = panel->view;
|
||||||
active = (panel == cmd->panel);
|
active = (panel == cmd->panel);
|
||||||
summary = (active)?(active_input):(dead_input);
|
summary = (active)?(active_input):(dead_input);
|
||||||
if (step_file_view(system, view, active_view, summary)){
|
|
||||||
|
View_Step_Result result = step_file_view(system, view, active_view, summary);
|
||||||
|
if (result.animating){
|
||||||
app_result.animating = 1;
|
app_result.animating = 1;
|
||||||
}
|
}
|
||||||
|
if (result.consume_keys){
|
||||||
|
consume_input(&available_input, Input_AnyKey);
|
||||||
|
}
|
||||||
|
if (result.consume_keys || result.consume_esc){
|
||||||
|
consume_input(&available_input, Input_Esc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (dll_items(panel, used_panels)){
|
for (dll_items(panel, used_panels)){
|
||||||
|
@ -4404,12 +4410,12 @@ App_Step_Sig(app_step){
|
||||||
models->prev_mouse_panel = mouse_panel;
|
models->prev_mouse_panel = mouse_panel;
|
||||||
|
|
||||||
app_result.lctrl_lalt_is_altgr = models->settings.lctrl_lalt_is_altgr;
|
app_result.lctrl_lalt_is_altgr = models->settings.lctrl_lalt_is_altgr;
|
||||||
|
app_result.perform_kill = !models->keep_playing;
|
||||||
|
|
||||||
*result = app_result;
|
*result = app_result;
|
||||||
|
|
||||||
Assert(general_memory_check(&models->mem.general));
|
Assert(general_memory_check(&models->mem.general));
|
||||||
|
|
||||||
app_result.perform_kill = models->keep_playing;
|
|
||||||
|
|
||||||
// end-of-app_step
|
// end-of-app_step
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1811,6 +1811,7 @@ file_pre_edit_maintenance(System_Functions *system,
|
||||||
general_memory_free(general, file->state.swap_stack.tokens);
|
general_memory_free(general, file->state.swap_stack.tokens);
|
||||||
file->state.swap_stack.tokens = 0;
|
file->state.swap_stack.tokens = 0;
|
||||||
}
|
}
|
||||||
|
file->state.still_lexing = 0;
|
||||||
}
|
}
|
||||||
file->state.last_4ed_edit_time = system->now_time_stamp();
|
file->state.last_4ed_edit_time = system->now_time_stamp();
|
||||||
}
|
}
|
||||||
|
@ -3216,9 +3217,7 @@ interactive_view_complete(System_Functions *system, View *view, String dest, i32
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IAct_New:
|
case IAct_New:
|
||||||
// TODO(allen): The !char_is_slash part confuses me... let's investigate this soon.
|
if (dest.size > 0 && !char_is_slash(dest.str[dest.size-1])){
|
||||||
if (dest.size > 0 &&
|
|
||||||
!char_is_slash(models->hot_directory.string.str[dest.size-1])){
|
|
||||||
view_new_file(system, models, view, dest);
|
view_new_file(system, models, view, dest);
|
||||||
view_show_file(view);
|
view_show_file(view);
|
||||||
}break;
|
}break;
|
||||||
|
@ -3782,8 +3781,15 @@ app_single_number_input_step(System_Functions *system, Key_Event_Data key, Strin
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal b32
|
struct View_Step_Result{
|
||||||
|
b32 animating;
|
||||||
|
b32 consume_keys;
|
||||||
|
b32 consume_esc;
|
||||||
|
};
|
||||||
|
|
||||||
|
internal View_Step_Result
|
||||||
step_file_view(System_Functions *system, View *view, View *active_view, Input_Summary input){
|
step_file_view(System_Functions *system, View *view, View *active_view, Input_Summary input){
|
||||||
|
View_Step_Result result = {0};
|
||||||
GUI_Target *target = &view->gui_target;
|
GUI_Target *target = &view->gui_target;
|
||||||
Models *models = view->persistent.models;
|
Models *models = view->persistent.models;
|
||||||
Key_Summary keys = input.keys;
|
Key_Summary keys = input.keys;
|
||||||
|
@ -3792,6 +3798,25 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
|
|
||||||
view->current_scroll = 0;
|
view->current_scroll = 0;
|
||||||
|
|
||||||
|
if (view->showing_ui != VUI_None){
|
||||||
|
b32 did_esc = 0;
|
||||||
|
Key_Event_Data key;
|
||||||
|
i32 i;
|
||||||
|
|
||||||
|
for (i = 0; i < keys.count; ++i){
|
||||||
|
key = get_single_key(&keys, i);
|
||||||
|
if (key.keycode == key_esc){
|
||||||
|
did_esc = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (did_esc){
|
||||||
|
view_show_file(view);
|
||||||
|
result.consume_esc = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gui_begin_top_level(target, input);
|
gui_begin_top_level(target, input);
|
||||||
{
|
{
|
||||||
gui_do_top_bar(target);
|
gui_do_top_bar(target);
|
||||||
|
@ -4009,25 +4034,28 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
for (j = 0; j < keys.count; ++j){
|
for (j = 0; j < keys.count; ++j){
|
||||||
i16 key = keys.keys[j].keycode;
|
i16 key = keys.keys[j].keycode;
|
||||||
switch (key){
|
switch (key){
|
||||||
case key_left: --view->color_cursor; r = 1; break;
|
case key_left: --view->color_cursor; r = 1; result.consume_keys = 1; break;
|
||||||
case key_right: ++view->color_cursor; r = 1; break;
|
case key_right: ++view->color_cursor; r = 1; result.consume_keys = 1; break;
|
||||||
|
|
||||||
case key_up:
|
case key_up:
|
||||||
if (next_color_editing > 0){
|
if (next_color_editing > 0){
|
||||||
--next_color_editing;
|
--next_color_editing;
|
||||||
}
|
}
|
||||||
|
result.consume_keys = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case key_down:
|
case key_down:
|
||||||
if (next_color_editing <= ArrayCount(colors_to_edit)-1){
|
if (next_color_editing <= ArrayCount(colors_to_edit)-1){
|
||||||
++next_color_editing;
|
++next_color_editing;
|
||||||
}
|
}
|
||||||
|
result.consume_keys = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if ((key >= '0' && key <= '9') || (key >= 'a' && key <= 'f') || (key >= 'A' && key <= 'F')){
|
if ((key >= '0' && key <= '9') || (key >= 'a' && key <= 'f') || (key >= 'A' && key <= 'F')){
|
||||||
text.str[view->color_cursor] = (char)key;
|
text.str[view->color_cursor] = (char)key;
|
||||||
r = 1;
|
r = 1;
|
||||||
|
result.consume_keys = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4107,9 +4135,11 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
&hdir->string, hdir, 1, 1, 0);
|
&hdir->string, hdir, 1, 1, 0);
|
||||||
if (step.made_a_change){
|
if (step.made_a_change){
|
||||||
view->list_i = 0;
|
view->list_i = 0;
|
||||||
|
result.consume_keys = 1;
|
||||||
}
|
}
|
||||||
if (!use_item_in_list && (key.keycode == '\n' || key.keycode == '\t')){
|
if (!use_item_in_list && (key.keycode == '\n' || key.keycode == '\t')){
|
||||||
activate_directly = 1;
|
activate_directly = 1;
|
||||||
|
result.consume_keys = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4128,6 +4158,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
|
|
||||||
if (gui_begin_list(target, id, view->list_i, 0,
|
if (gui_begin_list(target, id, view->list_i, 0,
|
||||||
snap_into_view, &update)){
|
snap_into_view, &update)){
|
||||||
|
// TODO(allen): Allow me to handle key consumption correctly here!
|
||||||
gui_standard_list(target, id, view->current_scroll, view->scroll_region,
|
gui_standard_list(target, id, view->current_scroll, view->scroll_region,
|
||||||
&keys, &view->list_i, &update);
|
&keys, &view->list_i, &update);
|
||||||
}
|
}
|
||||||
|
@ -4195,6 +4226,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
step = app_single_line_input_step(system, key, &view->dest);
|
step = app_single_line_input_step(system, key, &view->dest);
|
||||||
if (step.made_a_change){
|
if (step.made_a_change){
|
||||||
view->list_i = 0;
|
view->list_i = 0;
|
||||||
|
result.consume_keys = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4356,7 +4388,9 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gui_end_top_level(target);
|
gui_end_top_level(target);
|
||||||
return(target->animating);
|
|
||||||
|
result.animating = target->animating;
|
||||||
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal f32
|
internal f32
|
||||||
|
@ -4651,27 +4685,6 @@ do_input_file_view(System_Functions *system, Exchange *exchange,
|
||||||
|
|
||||||
result.vars = scroll_vars;
|
result.vars = scroll_vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(allen): GET RID OF THIS!!!
|
|
||||||
{
|
|
||||||
Key_Summary *keys = &user_input->keys;
|
|
||||||
b32 did_esc = 0;
|
|
||||||
Key_Event_Data key;
|
|
||||||
i32 i, count;
|
|
||||||
|
|
||||||
count = keys->count;
|
|
||||||
for (i = 0; i < count; ++i){
|
|
||||||
key = get_single_key(keys, i);
|
|
||||||
if (key.keycode == key_esc){
|
|
||||||
did_esc = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (did_esc && view->showing_ui != VUI_None){
|
|
||||||
view_show_file(view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
|
|
22
TODO.txt
22
TODO.txt
|
@ -1,7 +1,3 @@
|
||||||
|
|
||||||
; before shipping:
|
|
||||||
; [] make sure 4coder_handmade_hero.cpp works
|
|
||||||
|
|
||||||
; Started this list on: (18.01.2016)(dd.mm.yyyy)
|
; Started this list on: (18.01.2016)(dd.mm.yyyy)
|
||||||
; This list is an informal todo list, it may very well miss items
|
; This list is an informal todo list, it may very well miss items
|
||||||
; checked or unchecked, that I inted to do some day. It is included
|
; checked or unchecked, that I inted to do some day. It is included
|
||||||
|
@ -67,12 +63,15 @@
|
||||||
; [X] chronal's map setting issue
|
; [X] chronal's map setting issue
|
||||||
; [X] linux save jankieness
|
; [X] linux save jankieness
|
||||||
; [X] bouncing when scrolling down
|
; [X] bouncing when scrolling down
|
||||||
|
; [X] sometimes the main cursor is not the same width as the mark cursor in the same spot
|
||||||
|
; [X] tab character wrong width
|
||||||
|
; [X] miblo's off screen cursor thing
|
||||||
|
; [X] paste snaps the cursor back into view!
|
||||||
|
; [X] new file is messed up for code files, it never finishes parsing!
|
||||||
; [] indication on failure to save
|
; [] indication on failure to save
|
||||||
; [] clean whitespace doesn't appear to be cleaning trailing whitespace anymore???
|
; [] clean whitespace doesn't appear to be cleaning trailing whitespace anymore???
|
||||||
; [] sometimes the main cursor is not the same width as the mark cursor in the same spot
|
|
||||||
; [] tab character wrong width
|
|
||||||
; [] miblo's off screen cursor thing
|
|
||||||
;
|
;
|
||||||
|
; [] key presses that should be consumed in the GUI are now passed to the file!
|
||||||
;
|
;
|
||||||
|
|
||||||
; TODOS
|
; TODOS
|
||||||
|
@ -117,14 +116,13 @@
|
||||||
; [X] rewrite GUI
|
; [X] rewrite GUI
|
||||||
; [X] arrow navigation of GUIs
|
; [X] arrow navigation of GUIs
|
||||||
; [] GUI API
|
; [] GUI API
|
||||||
; [] text links -> arbitrary commands / callbacks?
|
|
||||||
;
|
;
|
||||||
; search related tech
|
; search related tech
|
||||||
; [X] replace word (incremental and/or in range)
|
; [X] replace word (incremental and/or in range)
|
||||||
|
; [X] caps insensitivety
|
||||||
; [] optimize search
|
; [] optimize search
|
||||||
; [] allow search wrap around beginning/end
|
; [] allow search wrap around beginning/end
|
||||||
; [] improved custom API for text "streams"
|
; [] improved custom API for text "streams"
|
||||||
; [] caps insensitivety
|
|
||||||
;
|
;
|
||||||
; theme related business
|
; theme related business
|
||||||
; [] fix the versioning system for themes
|
; [] fix the versioning system for themes
|
||||||
|
@ -173,12 +171,11 @@
|
||||||
|
|
||||||
; INTERNAL TODOS
|
; INTERNAL TODOS
|
||||||
; [X] switch building non-extensible version by statically linking to custom.cpp
|
; [X] switch building non-extensible version by statically linking to custom.cpp
|
||||||
|
; [X] pack fonts more squarely
|
||||||
; [] general parameter handling
|
; [] general parameter handling
|
||||||
; [] hashed string pool for clipboard/filenames/etc
|
; [] hashed string pool for clipboard/filenames/etc
|
||||||
; [] ask for clipboards to update by request, not on loop
|
|
||||||
; [] pack fonts more squarely
|
|
||||||
; [] setup tests through special tool
|
|
||||||
; [] new profiling/debugging system
|
; [] new profiling/debugging system
|
||||||
|
; [] change job canceling to a polling based thing
|
||||||
;
|
;
|
||||||
|
|
||||||
; EASY TODOS
|
; EASY TODOS
|
||||||
|
@ -199,6 +196,7 @@
|
||||||
; [] fill screen right away
|
; [] fill screen right away
|
||||||
; [] how to get fast repaint (do I really need double buffering?)
|
; [] how to get fast repaint (do I really need double buffering?)
|
||||||
; [] history breaks when heavily used (disk swaping?)
|
; [] history breaks when heavily used (disk swaping?)
|
||||||
|
; [] window stops repainting bug on a handful of machines (Win 10? Driver?)
|
||||||
;
|
;
|
||||||
|
|
||||||
; PORTING TODOS
|
; PORTING TODOS
|
||||||
|
|
|
@ -104,13 +104,11 @@
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "../4coder_default_include.cpp"
|
#include "../4coder_default_include.cpp"
|
||||||
|
|
||||||
enum maps{
|
|
||||||
my_code_map
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef Assert
|
#ifndef Assert
|
||||||
#define internal static
|
#define internal static
|
||||||
#define Assert assert
|
#define Assert assert
|
||||||
|
|
Loading…
Reference in New Issue