diff --git a/4ed.cpp b/4ed.cpp index b18172a5..ec75bc9a 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -462,8 +462,8 @@ App_Step_Sig(app_step){ if (clipboard.str != 0){ String_Const_u8 *dest = working_set_next_clipboard_string(&models->heap, &models->working_set, clipboard.size); dest->size = eol_convert_in((char*)dest->str, (char*)clipboard.str, (i32)clipboard.size); - if (input->clipboard_changed && models->clipboard_change != 0){ - models->clipboard_change(&models->app_links, *dest, ClipboardFlag_FromOS); + if (input->clipboard_changed){ + co_send_core_event(models, CoreCode_NewClipboardContents, *dest); } } @@ -525,11 +525,7 @@ App_Step_Sig(app_step){ } } - // NOTE(allen): input filter and simulated events - if (models->input_filter != 0){ - models->input_filter(&input->mouse); - } - + // NOTE(allen): simulated events Input_List input_list = input->events; Input_Modifier_Set modifiers = system_get_keyboard_modifiers(scratch); if (input->mouse.press_l){ @@ -623,13 +619,28 @@ App_Step_Sig(app_step){ // NOTE(allen): First frame initialization if (input->first_step){ - if (models->hook_start != 0){ - char **files = models->settings.init_files; - i32 files_count = models->settings.init_files_count; - char **flags = models->settings.custom_flags; - i32 flags_count = models->settings.custom_flags_count; - models->hook_start(&models->app_links, files, files_count, flags, flags_count); + Temp_Memory_Block temp(scratch); + + String_Const_u8_Array file_names = {}; + file_names.count = models->settings.init_files_count; + file_names.vals = push_array(scratch, String_Const_u8, file_names.count); + for (i32 i = 0; i < file_names.count; i += 1){ + file_names.vals[i] = SCu8(models->settings.init_files[i]); } + + String_Const_u8_Array flags = {}; + flags.count = models->settings.custom_flags_count; + flags.vals = push_array(scratch, String_Const_u8, flags.count); + for (i32 i = 0; i < flags.count; i += 1){ + flags.vals[i] = SCu8(models->settings.custom_flags[i]); + } + + Input_Event event = {}; + event.kind = InputEventKind_Core; + event.core.code = CoreCode_Startup; + event.core.flag_strings = flags; + event.core.file_names = file_names; + co_send_event(models, &event); } // NOTE(allen): consume event stream @@ -795,20 +806,17 @@ App_Step_Sig(app_step){ // NOTE(allen): hook for files reloaded { - File_Externally_Modified_Function *hook_file_externally_modified = models->hook_file_externally_modified; - if (hook_file_externally_modified != 0){ - Working_Set *working_set = &models->working_set; - Assert(working_set->has_external_mod_sentinel.next != 0); - if (working_set->has_external_mod_sentinel.next != &working_set->has_external_mod_sentinel){ - for (Node *node = working_set->has_external_mod_sentinel.next, *next = 0; - node != &working_set->has_external_mod_sentinel; - node = next){ - next = node->next; - Editing_File *file = CastFromMember(Editing_File, external_mod_node, node); - dll_remove(node); - block_zero_struct(node); - hook_file_externally_modified(&models->app_links, file->id); - } + Working_Set *working_set = &models->working_set; + Assert(working_set->has_external_mod_sentinel.next != 0); + if (working_set->has_external_mod_sentinel.next != &working_set->has_external_mod_sentinel){ + for (Node *node = working_set->has_external_mod_sentinel.next, *next = 0; + node != &working_set->has_external_mod_sentinel; + node = next){ + next = node->next; + Editing_File *file = CastFromMember(Editing_File, external_mod_node, node); + dll_remove(node); + block_zero_struct(node); + co_send_core_event(models, CoreCode_FileExternallyModified, file->id); } } } @@ -818,12 +826,8 @@ App_Step_Sig(app_step){ models->keep_playing = false; } if (!models->keep_playing){ - Hook_Function *exit_func = models->exit; - if (exit_func != 0){ - if (exit_func(&models->app_links) == 0){ - models->animate_next_frame = true; - models->keep_playing = true; - } + if (co_send_core_event(models, CoreCode_TryExit)){ + models->keep_playing = true; } } @@ -836,6 +840,7 @@ App_Step_Sig(app_step){ { Color_Table color_table = models->fallback_color_table; +#if 0 if (models->modify_color_table != 0){ color_table = models->modify_color_table(&models->app_links, frame); if (color_table.count < models->fallback_color_table.count){ @@ -843,6 +848,7 @@ App_Step_Sig(app_step){ color_table = models->fallback_color_table; } } +#endif models->color_table = color_table; } @@ -850,7 +856,6 @@ App_Step_Sig(app_step){ models->in_render_mode = true; Live_Views *live_views = &models->live_set; - Layout *layout = &models->layout; for (Node *node = layout->open_panels.next; node != &layout->open_panels; node = node->next){ diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 1da048fe..6463193d 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -810,8 +810,8 @@ buffer_kill(Application_Links *app, Buffer_ID buffer_id, Buffer_Kill_Flag flags) if (!file->settings.never_kill){ b32 needs_to_save = file_needs_save(file); if (!needs_to_save || (flags & BufferKill_AlwaysKill) != 0){ - if (models->hook_end_file != 0){ - models->hook_end_file(&models->app_links, file->id); + if (models->end_buffer != 0){ + models->end_buffer(&models->app_links, file->id); } buffer_unbind_name_low_level(working_set, file); @@ -2003,58 +2003,61 @@ managed_object_load_data(Application_Links *app, Managed_Object object, u32 firs } api(custom) function User_Input -get_user_input(Application_Links *app, Event_Property get_properties, Event_Property abort_properties) +get_next_input(Application_Links *app, Event_Property get_properties, Event_Property abort_properties) { Models *models = (Models*)app->cmd_context; User_Input result = {}; if (app->type_coroutine == Co_View){ Coroutine *coroutine = (Coroutine*)app->current_coroutine; - Assert(coroutine != 0); - Co_Out *out = (Co_Out*)coroutine->out; - out->request = CoRequest_None; - out->get_flags = get_properties; - out->abort_flags = abort_properties; - coroutine_yield(coroutine); - Co_In *in = (Co_In*)coroutine->in; - result = in->user_input; + if (coroutine != 0){ + Co_Out *out = (Co_Out*)coroutine->out; + out->request = CoRequest_None; + out->get_flags = get_properties; + out->abort_flags = abort_properties; + coroutine_yield(coroutine); + Co_In *in = (Co_In*)coroutine->in; + result = in->user_input; + } + else{ +#define M "ERROR: get_next_input called in a hook that may not make calls to blocking APIs" + print_message(app, string_u8_litexpr(M)); +#undef M + } } return(result); } +api(custom) function i64 +get_current_input_sequence_number(Application_Links *app) +{ + Models *models = (Models*)app->cmd_context; + return(models->current_input_sequence_number); +} + api(custom) function User_Input -get_command_input(Application_Links *app) +get_current_input(Application_Links *app) { Models *models = (Models*)app->cmd_context; - User_Input result = {}; - result.event = models->event; - return(result); + return(models->current_input); } api(custom) function void -set_command_input(Application_Links *app, Input_Event *event) +set_current_input(Application_Links *app, User_Input *input) { Models *models = (Models*)app->cmd_context; - models->event = *event; + block_copy_struct(&models->current_input, input); } api(custom) function void -leave_command_input_unhandled(Application_Links *app){ +leave_current_input_unhandled(Application_Links *app){ Models *models = (Models*)app->cmd_context; - models->event_unhandled = true; + models->current_input_unhandled = true; } api(custom) function void set_custom_hook(Application_Links *app, Hook_ID hook_id, Void_Func *func_ptr){ Models *models = (Models*)app->cmd_context; switch (hook_id){ - case HookID_FileOutOfSync: - { - models->file_out_of_sync = (Hook_Function*)func_ptr; - }break; - case HookID_Exit: - { - models->exit = (Hook_Function*)func_ptr; - }break; case HookID_BufferViewerUpdate: { models->buffer_viewer_update = (Hook_Function*)func_ptr; @@ -2063,30 +2066,6 @@ set_custom_hook(Application_Links *app, Hook_ID hook_id, Void_Func *func_ptr){ { models->scroll_rule = (Delta_Rule_Function*)func_ptr; }break; - case HookID_NewFile: - { - models->hook_new_file = (Buffer_Hook_Function*)func_ptr; - }break; - case HookID_OpenFile: - { - models->hook_open_file = (Buffer_Hook_Function*)func_ptr; - }break; - case HookID_SaveFile: - { - models->hook_save_file = (Buffer_Hook_Function*)func_ptr; - }break; - case HookID_EndFile: - { - models->hook_end_file = (Buffer_Hook_Function*)func_ptr; - }break; - case HookID_FileEditRange: - { - models->hook_file_edit_range = (File_Edit_Range_Function*)func_ptr; - }break; - case HookID_FileExternallyModified: - { - models->hook_file_externally_modified = (File_Externally_Modified_Function*)func_ptr; - }break; case HookID_ViewEventHandler: { models->view_event_handler = (Custom_Command_Function*)func_ptr; @@ -2095,29 +2074,29 @@ set_custom_hook(Application_Links *app, Hook_ID hook_id, Void_Func *func_ptr){ { models->render_caller = (Render_Caller_Function*)func_ptr; }break; - case HookID_InputFilter: - { - models->input_filter = (Input_Filter_Function*)func_ptr; - }break; - case HookID_Start: - { - models->hook_start = (Start_Hook_Function*)func_ptr; - }break; case HookID_BufferNameResolver: { models->buffer_name_resolver = (Buffer_Name_Resolver_Function*)func_ptr; }break; - case HookID_ModifyColorTable: + case HookID_BeginBuffer: { - models->modify_color_table = (Modify_Color_Table_Function*)func_ptr; + models->begin_buffer = (Buffer_Hook_Function*)func_ptr; }break; - case HookID_ClipboardChange: + case HookID_EndBuffer: { - models->clipboard_change = (Clipboard_Change_Hook_Function*)func_ptr; + models->end_buffer = (Buffer_Hook_Function*)func_ptr; }break; - case HookID_GetViewBufferRegion: + case HookID_NewFile: { - models->get_view_buffer_region = (Get_View_Buffer_Region_Function*)func_ptr; + models->new_file = (Buffer_Hook_Function*)func_ptr; + }break; + case HookID_SaveFile: + { + models->save_file = (Buffer_Hook_Function*)func_ptr; + }break; + case HookID_BufferEditRange: + { + models->buffer_edit_range = (Buffer_Edit_Range_Function*)func_ptr; }break; } } diff --git a/4ed_app_models.h b/4ed_app_models.h index 68238e04..24423c37 100644 --- a/4ed_app_models.h +++ b/4ed_app_models.h @@ -52,24 +52,17 @@ struct Models{ Application_Links app_links; - Hook_Function *file_out_of_sync; - Hook_Function *exit; Hook_Function *buffer_viewer_update; Delta_Rule_Function *scroll_rule; - Buffer_Hook_Function *hook_new_file; - Buffer_Hook_Function *hook_open_file; - Buffer_Hook_Function *hook_save_file; - Buffer_Hook_Function *hook_end_file; - File_Edit_Range_Function *hook_file_edit_range; - File_Externally_Modified_Function *hook_file_externally_modified; Custom_Command_Function *view_event_handler; Render_Caller_Function *render_caller; - Input_Filter_Function *input_filter; - Start_Hook_Function *hook_start; Buffer_Name_Resolver_Function *buffer_name_resolver; - Modify_Color_Table_Function *modify_color_table; - Clipboard_Change_Hook_Function *clipboard_change; - Get_View_Buffer_Region_Function *get_view_buffer_region; + Buffer_Hook_Function *begin_buffer; + Buffer_Hook_Function *end_buffer; + Buffer_Hook_Function *new_file; + Buffer_Hook_Function *save_file; + Buffer_Edit_Range_Function *buffer_edit_range; + Buffer_Region_Function *buffer_region; Color_Table fallback_color_table; Color_Table color_table; @@ -118,8 +111,9 @@ struct Models{ // Event Context Application_Step_Input *input; - Input_Event event; - b8 event_unhandled; + i64 current_input_sequence_number; + User_Input current_input; + b8 current_input_unhandled; b8 in_render_mode; Render_Target *target; diff --git a/4ed_edit.cpp b/4ed_edit.cpp index 098eabc5..18e63143 100644 --- a/4ed_edit.cpp +++ b/4ed_edit.cpp @@ -200,7 +200,7 @@ edit_single(Models *models, Editing_File *file, Interval_i64 range, String_Const // NOTE(allen): save the original text for the edit range hook. String_Const_u8 original_text = {}; - if (models->hook_file_edit_range != 0){ + if (models->buffer_edit_range != 0){ original_text = buffer_stringify(scratch, &file->state.buffer, edit.range); } @@ -224,16 +224,16 @@ edit_single(Models *models, Editing_File *file, Interval_i64 range, String_Const edit_fix_markers(models, file, edit); // NOTE(allen): edit range hook - if (models->hook_file_edit_range != 0){ + if (models->buffer_edit_range != 0){ Interval_i64 new_range = Ii64(edit.range.first, edit.range.first + edit.text.size); - models->hook_file_edit_range(&models->app_links, file->id, new_range, original_text); + models->buffer_edit_range(&models->app_links, file->id, new_range, original_text); } } internal void file_end_file(Models *models, Editing_File *file){ - if (models->hook_end_file != 0){ - models->hook_end_file(&models->app_links, file->id); + if (models->end_buffer != 0){ + models->end_buffer(&models->app_links, file->id); } Lifetime_Allocator *lifetime_allocator = &models->lifetime_allocator; lifetime_free_object(lifetime_allocator, file->lifetime_object); @@ -544,8 +544,8 @@ create_file(Models *models, String_Const_u8 file_name, Buffer_Create_Flag flags) if (file != 0 && buffer_is_for_new_file && !HasFlag(flags, BufferCreate_SuppressNewFileHook) && - models->hook_new_file != 0){ - models->hook_new_file(&models->app_links, file->id); + models->new_file != 0){ + models->new_file(&models->app_links, file->id); } } diff --git a/4ed_file.cpp b/4ed_file.cpp index d8d23bbf..4d868570 100644 --- a/4ed_file.cpp +++ b/4ed_file.cpp @@ -148,8 +148,8 @@ save_file_to_name(Models *models, Editing_File *file, u8 *file_name){ } if (file_name != 0){ - if (models->hook_save_file != 0){ - models->hook_save_file(&models->app_links, file->id); + if (models->save_file != 0){ + models->save_file(&models->app_links, file->id); } Gap_Buffer *buffer = &file->state.buffer; @@ -244,9 +244,8 @@ file_create_from_string(Models *models, Editing_File *file, String_Const_u8 val, //////////////////////////////// - Buffer_Hook_Function *hook_open_file = models->hook_open_file; - if (hook_open_file != 0){ - hook_open_file(&models->app_links, file->id); + if (models->begin_buffer != 0){ + models->begin_buffer(&models->app_links, file->id); } } diff --git a/4ed_generate_keycodes.cpp b/4ed_generate_keycodes.cpp index f54ec9ab..622da54b 100644 --- a/4ed_generate_keycodes.cpp +++ b/4ed_generate_keycodes.cpp @@ -145,9 +145,13 @@ make_core_list(Arena *arena){ Event_Code_List list = {}; list.code_prefix = string_u8_litexpr("CoreCode"); list.name_table = string_u8_litexpr("core_code_name"); + add_code(arena, &list, string_u8_litexpr("Startup")); add_code(arena, &list, string_u8_litexpr("Animate")); add_code(arena, &list, string_u8_litexpr("ClickActivateView")); add_code(arena, &list, string_u8_litexpr("ClickDeactivateView")); + add_code(arena, &list, string_u8_litexpr("TryExit")); + add_code(arena, &list, string_u8_litexpr("FileExternallyModified")); + add_code(arena, &list, string_u8_litexpr("NewClipboardContents")); return(list); } diff --git a/4ed_view.cpp b/4ed_view.cpp index d7f40705..daec613a 100644 --- a/4ed_view.cpp +++ b/4ed_view.cpp @@ -9,6 +9,14 @@ // TOP +function void +begin_handling_input(Models *models, User_Input *input){ + block_copy_struct(&models->current_input, input); + models->current_input_sequence_number += 1; +} + +//////////////////////////////// + internal void init_query_set(Query_Set *set){ Query_Slot *slot = set->slots; @@ -142,10 +150,10 @@ view_set_edit_pos(View *view, File_Edit_Positions edit_pos){ internal Rect_f32 view_get_buffer_rect(Models *models, View *view){ Rect_f32 region = {}; - if (models->get_view_buffer_region != 0){ + if (models->buffer_region != 0){ Rect_f32 rect = Rf32(view->panel->rect_inner); Rect_f32 sub_region = Rf32(V2(0, 0), rect_dim(rect)); - sub_region = models->get_view_buffer_region(&models->app_links, view_get_id(&models->live_set, view), sub_region); + sub_region = models->buffer_region(&models->app_links, view_get_id(&models->live_set, view), sub_region); region.p0 = rect.p0 + sub_region.p0; region.p1 = rect.p0 + sub_region.p1; region.x1 = clamp_top(region.x1, rect.x1); @@ -631,30 +639,71 @@ co_send_event(Models *models, View *view, Input_Event *event){ Event_Property event_flags = get_event_properties(event); if ((get_flags&event_flags) != 0){ - models->event_unhandled = false; + models->current_input_unhandled = false; Co_In in = {}; in.user_input.event = *event; in.user_input.abort = ((abort_flags & event_flags) != 0); - block_copy_struct(&models->event, &in.user_input.event); + begin_handling_input(models, &in.user_input); view->co = co_run(models, Co_View, view->co, &in, &view->co_out); view_check_co_exited(models, view); if (!HasFlag(event_flags, EventProperty_Animate)){ models->animate_next_frame = true; } - event_was_handled = !models->event_unhandled; + event_was_handled = !models->current_input_unhandled; } return(event_was_handled); } function b32 -co_send_core_event(Models *models, View *view, Core_Code code){ +co_send_core_event(Models *models, View *view, Core_Code code, String_Const_u8 string){ Input_Event event = {}; event.kind = InputEventKind_Core; event.core.code = code; + event.core.string = string; return(co_send_event(models, view, &event)); } +function b32 +co_send_core_event(Models *models, View *view, Core_Code code, Buffer_ID id){ + Input_Event event = {}; + event.kind = InputEventKind_Core; + event.core.code = code; + event.core.id = id; + return(co_send_event(models, view, &event)); +} + +function b32 +co_send_core_event(Models *models, View *view, Core_Code code){ + return(co_send_core_event(models, view, code, SCu8())); +} + +function b32 +co_send_event(Models *models, Input_Event *event){ + Panel *active_panel = models->layout.active_panel; + View *view = active_panel->view; + return(co_send_event(models, view, event)); +} + +function b32 +co_send_core_event(Models *models, Core_Code code, String_Const_u8 string){ + Panel *active_panel = models->layout.active_panel; + View *view = active_panel->view; + return(co_send_core_event(models, view, code, string)); +} + +function b32 +co_send_core_event(Models *models, Core_Code code, Buffer_ID buffer_id){ + Panel *active_panel = models->layout.active_panel; + View *view = active_panel->view; + return(co_send_core_event(models, view, code, buffer_id)); +} + +function b32 +co_send_core_event(Models *models, Core_Code code){ + return(co_send_core_event(models, code, SCu8())); +} + //////////////////////////////// internal b32 diff --git a/custom/4coder_auto_indent.cpp b/custom/4coder_auto_indent.cpp index e234bcb9..d5249c0f 100644 --- a/custom/4coder_auto_indent.cpp +++ b/custom/4coder_auto_indent.cpp @@ -385,7 +385,7 @@ CUSTOM_DOC("Auto-indents the range between the cursor and the mark.") CUSTOM_COMMAND_SIG(write_text_and_auto_indent) CUSTOM_DOC("Inserts text and auto-indents the line on which the cursor sits if any of the text contains 'layout punctuation' such as ;:{}()[]# and new lines.") { - User_Input in = get_command_input(app); + User_Input in = get_current_input(app); String_Const_u8 insert = to_writable(&in); if (insert.str != 0 && insert.size > 0){ b32 do_auto_indent = false; diff --git a/custom/4coder_base_commands.cpp b/custom/4coder_base_commands.cpp index 3d0a99c6..40bb30b4 100644 --- a/custom/4coder_base_commands.cpp +++ b/custom/4coder_base_commands.cpp @@ -58,7 +58,7 @@ write_character_parameter(Application_Links *app, String_Const_u8 insert){ CUSTOM_COMMAND_SIG(write_text_input) CUSTOM_DOC("Inserts whatever character was used to trigger this command.") { - User_Input in = get_command_input(app); + User_Input in = get_current_input(app); String_Const_u8 insert = to_writable(&in); write_character_parameter(app, insert); } @@ -830,8 +830,7 @@ isearch(Application_Links *app, Scan_Direction start_scan, i64 first_pos, } isearch__update_highlight(app, view, Ii64_size(pos, match_size)); - in = get_user_input(app, - EventPropertyGroup_AnyKeyboardEvent, + in = get_next_input(app, EventPropertyGroup_AnyKeyboardEvent, EventProperty_Escape|EventProperty_ViewActivation); if (in.abort){ break; @@ -951,7 +950,7 @@ isearch(Application_Links *app, Scan_Direction start_scan, i64 first_pos, mouse_wheel_scroll(app); } else{ - leave_command_input_unhandled(app); + leave_current_input_unhandled(app); } } @@ -1104,7 +1103,7 @@ query_replace_base(Application_Links *app, View_ID view, Buffer_ID buffer_id, i6 Range_i64 match = Ii64(new_pos, new_pos + r.size); isearch__update_highlight(app, view, match); - in = get_user_input(app, EventProperty_AnyKey, EventProperty_MouseButton); + in = get_next_input(app, EventProperty_AnyKey, EventProperty_MouseButton); if (in.abort || match_key_code(&in, KeyCode_Escape) || !is_unmodified_key(&in.event)){ break; } @@ -1275,7 +1274,7 @@ CUSTOM_DOC("Deletes the file of the current buffer if 4coder has the appropriate if (start_query_bar(app, &bar, 0) != 0){ b32 cancelled = false; for (;!cancelled;){ - User_Input in = get_user_input(app, EventProperty_AnyKey, 0); + User_Input in = get_next_input(app, EventProperty_AnyKey, 0); if (in.abort){ cancelled = true; } @@ -1728,7 +1727,7 @@ multi_paste_interactive_up_down(Application_Links *app, i32 paste_count, i32 cli User_Input in = {}; for (;;){ - in = get_user_input(app, EventProperty_AnyKey, EventProperty_Escape); + in = get_next_input(app, EventProperty_AnyKey, EventProperty_Escape); if (in.abort) break; b32 did_modify = false; @@ -2045,5 +2044,18 @@ CUSTOM_DOC("Interactively opens a file in the other panel.") interactive_open_or_new(app); } +CUSTOM_COMMAND_SIG(default_file_externally_modified) +CUSTOM_DOC("Notes the external modification of attached files by printing a message.") +{ + User_Input input = get_current_input(app); + if (match_core_code(&input, CoreCode_FileExternallyModified)){ + Scratch_Block scratch(app); + Buffer_ID buffer_id = input.event.core.id; + String_Const_u8 name = push_buffer_unique_name(app, scratch, buffer_id); + String_Const_u8 str = push_u8_stringf(scratch, "Modified externally: %s\n", name.str); + print_message(app, str); + } +} + // BOTTOM diff --git a/custom/4coder_combined_write_commands.cpp b/custom/4coder_combined_write_commands.cpp index 543b2595..386d0b0c 100644 --- a/custom/4coder_combined_write_commands.cpp +++ b/custom/4coder_combined_write_commands.cpp @@ -198,7 +198,7 @@ static Snippet default_snippets[] = { static Lister_Activation_Code activate_snippet(Application_Links *app, View_ID view, Lister *lister, String_Const_u8 text_field, void *user_data, b32 activated_by_mouse){ i32 index = (i32)PtrAsInt(user_data); - Snippet_Array snippets = *(Snippet_Array*)lister->data.user_data; + Snippet_Array snippets = *(Snippet_Array*)lister->user_data; if (0 <= index && index < snippets.count){ Snippet snippet = snippets.snippets[index]; lister_default(app, view, lister, ListerActivation_Finished); diff --git a/custom/4coder_default_bindings.cpp b/custom/4coder_default_bindings.cpp index c7979ffe..5b45e75f 100644 --- a/custom/4coder_default_bindings.cpp +++ b/custom/4coder_default_bindings.cpp @@ -10,11 +10,8 @@ #include "4coder_default_include.cpp" #include "generated/remapping.h" -// NOTE(allen|a4.0.22): This no longer serves as very good example code. -// Good example code will be coming soon, but in the mean time you can go -// to 4coder_remapping_commands.cpp for examples of what binding code looks like. - #if !defined(NO_BINDING) + void custom_layer_init(Application_Links *app){ set_all_default_hooks(app); @@ -22,7 +19,8 @@ custom_layer_init(Application_Links *app){ mapping_init(tctx, &framework_mapping); setup_default_mapping(&framework_mapping); } -#endif //NO_BINDING + +#endif #endif //FCODER_DEFAULT_BINDINGS diff --git a/custom/4coder_default_framework.cpp b/custom/4coder_default_framework.cpp index 3edb3020..ab87ff89 100644 --- a/custom/4coder_default_framework.cpp +++ b/custom/4coder_default_framework.cpp @@ -345,7 +345,8 @@ CUSTOM_DOC("Toggle fullscreen mode on or off. The change(s) do not take effect //////////////////////////////// static void -default_4coder_initialize(Application_Links *app, char **command_line_files, i32 file_count, i32 override_font_size, b32 override_hinting){ +default_4coder_initialize(Application_Links *app, String_Const_u8_Array file_names, + i32 override_font_size, b32 override_hinting){ Thread_Context *tctx = get_thread_context(app); heap_init(&global_heap, tctx->allocator); @@ -383,39 +384,46 @@ default_4coder_initialize(Application_Links *app, char **command_line_files, i32 // open command line files Scratch_Block scratch(app); String_Const_u8 hot_directory = push_hot_directory(app, scratch); - for (i32 i = 0; i < file_count; i += 1){ - Temp_Memory temp2 = begin_temp(scratch); - String_Const_u8 input_name = SCu8(command_line_files[i]); - String_Const_u8 file_name = push_u8_stringf(scratch, "%.*s/%.*s", string_expand(hot_directory), string_expand(input_name)); - Buffer_ID new_buffer = create_buffer(app, file_name, BufferCreate_NeverNew|BufferCreate_MustAttachToFile); + for (i32 i = 0; i < file_names.count; i += 1){ + Temp_Memory_Block temp(scratch); + String_Const_u8 input_name = file_names.vals[i]; + String_Const_u8 full_name = push_u8_stringf(scratch, "%.*s/%.*s", + string_expand(hot_directory), + string_expand(input_name)); + Buffer_ID new_buffer = create_buffer(app, full_name, BufferCreate_NeverNew|BufferCreate_MustAttachToFile); if (new_buffer == 0){ create_buffer(app, input_name, 0); } - end_temp(temp2); } } static void -default_4coder_initialize(Application_Links *app, i32 override_font_size, b32 override_hinting){ - default_4coder_initialize(app, 0, 0, override_font_size, override_hinting); +default_4coder_initialize(Application_Links *app, + i32 override_font_size, b32 override_hinting){ + String_Const_u8_Array file_names = {}; + default_4coder_initialize(app, file_names, override_font_size, override_hinting); } static void -default_4coder_initialize(Application_Links *app, char **command_line_files, i32 file_count){ - Face_Description command_line_description = get_face_description(app, 0); - default_4coder_initialize(app, command_line_files, file_count, command_line_description.parameters.pt_size, command_line_description.parameters.hinting); +default_4coder_initialize(Application_Links *app, String_Const_u8_Array file_names){ + Face_Description description = get_face_description(app, 0); + default_4coder_initialize(app, file_names, + description.parameters.pt_size, + description.parameters.hinting); } static void default_4coder_initialize(Application_Links *app){ Face_Description command_line_description = get_face_description(app, 0); - default_4coder_initialize(app, 0, 0, command_line_description.parameters.pt_size, command_line_description.parameters.hinting); + String_Const_u8_Array file_names = {}; + default_4coder_initialize(app, file_names, command_line_description.parameters.pt_size, command_line_description.parameters.hinting); } static void -default_4coder_side_by_side_panels(Application_Links *app, Buffer_Identifier left_buffer, Buffer_Identifier right_buffer){ - Buffer_ID left_id = buffer_identifier_to_id(app, left_buffer); - Buffer_ID right_id = buffer_identifier_to_id(app, right_buffer); +default_4coder_side_by_side_panels(Application_Links *app, + Buffer_Identifier left, Buffer_Identifier right){ + Buffer_ID left_id = buffer_identifier_to_id(app, left); + Buffer_ID right_id = buffer_identifier_to_id(app, right); // Left Panel View_ID view = get_active_view(app, AccessAll); @@ -432,26 +440,29 @@ default_4coder_side_by_side_panels(Application_Links *app, Buffer_Identifier lef } static void -default_4coder_side_by_side_panels(Application_Links *app, Buffer_Identifier left, Buffer_Identifier right, char **command_line_files, i32 file_count){ - if (file_count > 0){ - left = buffer_identifier(SCu8(command_line_files[0])); - if (file_count > 1){ - right = buffer_identifier(SCu8(command_line_files[1])); +default_4coder_side_by_side_panels(Application_Links *app, + Buffer_Identifier left, Buffer_Identifier right, + String_Const_u8_Array file_names){ + if (file_names.count > 0){ + left = buffer_identifier(file_names.vals[0]); + if (file_names.count > 1){ + right = buffer_identifier(file_names.vals[1]); } } default_4coder_side_by_side_panels(app, left, right); } static void -default_4coder_side_by_side_panels(Application_Links *app, char **command_line_files, i32 file_count){ +default_4coder_side_by_side_panels(Application_Links *app, String_Const_u8_Array file_names){ Buffer_Identifier left = buffer_identifier(string_u8_litexpr("*scratch*")); Buffer_Identifier right = buffer_identifier(string_u8_litexpr("*messages*")); - default_4coder_side_by_side_panels(app, left, right, command_line_files, file_count); + default_4coder_side_by_side_panels(app, left, right, file_names); } static void default_4coder_side_by_side_panels(Application_Links *app){ - default_4coder_side_by_side_panels(app, 0, 0); + String_Const_u8_Array file_names = {}; + default_4coder_side_by_side_panels(app, file_names); } static void @@ -463,17 +474,18 @@ default_4coder_one_panel(Application_Links *app, Buffer_Identifier buffer){ } static void -default_4coder_one_panel(Application_Links *app, char **command_line_files, i32 file_count){ +default_4coder_one_panel(Application_Links *app, String_Const_u8_Array file_names){ Buffer_Identifier buffer = buffer_identifier(string_u8_litexpr("*messages*")); - if (file_count > 0){ - buffer = buffer_identifier(SCu8(command_line_files[0])); + if (file_names.count > 0){ + buffer = buffer_identifier(file_names.vals[0]); } default_4coder_one_panel(app, buffer); } static void default_4coder_one_panel(Application_Links *app){ - default_4coder_one_panel(app, 0, 0); + String_Const_u8_Array file_names = {}; + default_4coder_one_panel(app, file_names); } // BOTTOM diff --git a/custom/4coder_default_framework.h b/custom/4coder_default_framework.h index c4d23203..cae3ed55 100644 --- a/custom/4coder_default_framework.h +++ b/custom/4coder_default_framework.h @@ -65,10 +65,10 @@ typedef void View_Render_Hook(Application_Links *app, View_ID view, Frame_Info f //////////////////////////////// -static void +function b32 do_gui_sure_to_kill(Application_Links *app, Buffer_ID buffer, View_ID view); -static void +function b32 do_gui_sure_to_close_4coder(Application_Links *app, View_ID view); #endif diff --git a/custom/4coder_default_hooks.cpp b/custom/4coder_default_hooks.cpp index d142ba1a..e518e92d 100644 --- a/custom/4coder_default_hooks.cpp +++ b/custom/4coder_default_hooks.cpp @@ -4,26 +4,71 @@ // TOP -START_HOOK_SIG(default_start){ - default_4coder_initialize(app, files, file_count); - default_4coder_side_by_side_panels(app, files, file_count); - if (global_config.automatically_load_project){ - load_project(app); +CUSTOM_COMMAND_SIG(default_startup) +CUSTOM_DOC("Default command for responding to a startup event") +{ + User_Input input = get_current_input(app); + if (match_core_code(&input, CoreCode_Startup)){ + String_Const_u8_Array file_names = input.event.core.file_names; + default_4coder_initialize(app, file_names); + default_4coder_side_by_side_panels(app, file_names); + if (global_config.automatically_load_project){ + load_project(app); + } } - // no meaning for return - return(0); } +CUSTOM_COMMAND_SIG(default_try_exit) +CUSTOM_DOC("Default command for responding to a try-exit event") +{ + User_Input input = get_current_input(app); + if (match_core_code(&input, CoreCode_TryExit)){ + b32 do_exit = true; + if (!allow_immediate_close_without_checking_for_changes){ + b32 has_unsaved_changes = false; + for (Buffer_ID buffer = get_buffer_next(app, 0, AccessAll); + buffer != 0; + buffer = get_buffer_next(app, buffer, AccessAll)){ + Dirty_State dirty = buffer_get_dirty_state(app, buffer); + if (HasFlag(dirty, DirtyState_UnsavedChanges)){ + has_unsaved_changes = true; + break; + } + } + if (has_unsaved_changes){ + View_ID view = get_active_view(app, AccessAll); + do_exit = do_gui_sure_to_close_4coder(app, view); + } + } + if (do_exit){ + // NOTE(allen): By leaving try exit unhandled we indicate + // that the core should take responsibility for handling this, + // and it will handle it by exiting 4coder. If we leave this + // event marked as handled on the other hand (for instance by + // running a confirmation GUI that cancels the exit) then 4coder + // will not exit. + leave_current_input_unhandled(app); + } + } +} + + CUSTOM_COMMAND_SIG(default_view_input_handler) -CUSTOM_DOC("Input consumption loop for base view behavior") +CUSTOM_DOC("Input consumption loop for default view behavior") { for (;;){ // NOTE(allen): Get the binding from the buffer's current map - User_Input input = get_user_input(app, EventPropertyGroup_Any, 0); + User_Input input = get_next_input(app, EventPropertyGroup_Any, 0); if (input.abort){ break; } + Event_Property event_properties = get_event_properties(&input.event); + + if (suppressing_mouse && (event_properties & EventPropertyGroup_AnyMouseEvent) != 0){ + continue; + } + View_ID view = get_active_view(app, AccessAll); Buffer_ID buffer = view_get_buffer(app, view, AccessAll); @@ -41,7 +86,7 @@ CUSTOM_DOC("Input consumption loop for base view behavior") // NOTE(allen): we don't have anything to do with this input, // leave it marked unhandled so that if there's a follow up // event it is not blocked. - leave_command_input_unhandled(app); + leave_current_input_unhandled(app); } else{ // NOTE(allen): before the command is called do some book keeping @@ -170,8 +215,8 @@ draw_enclosures(Application_Links *app, Text_Layout_ID text_layout_id, Buffer_ID } } +#if 0 static argb_color default_colors[Stag_COUNT] = {}; - MODIFY_COLOR_TABLE_SIG(default_modify_color_table){ if (default_colors[Stag_NOOP] == 0){ default_colors[Stag_NOOP] = 0xFFFF00FF; @@ -231,8 +276,10 @@ MODIFY_COLOR_TABLE_SIG(default_modify_color_table){ color_table.count = ArrayCount(default_colors); return(color_table); } +#endif -GET_VIEW_BUFFER_REGION_SIG(default_view_buffer_region){ +function Rect_f32 +default_view_buffer_region(Application_Links *app, View_ID view_id, Rect_f32 sub_region){ Buffer_ID buffer = view_get_buffer(app, view_id, AccessAll); Face_ID face_id = get_face_id(app, buffer); Face_Metrics metrics = get_face_metrics(app, face_id); @@ -714,31 +761,6 @@ default_render_caller(Application_Links *app, Frame_Info frame_info, View_ID vie draw_set_clip(app, prev_clip); } -HOOK_SIG(default_exit){ - // If this returns false it cancels the exit. - b32 result = true; - - if (!allow_immediate_close_without_checking_for_changes){ - b32 has_unsaved_changes = false; - for (Buffer_ID buffer = get_buffer_next(app, 0, AccessAll); - buffer != 0; - buffer = get_buffer_next(app, buffer, AccessAll)){ - Dirty_State dirty = buffer_get_dirty_state(app, buffer); - if (HasFlag(dirty, DirtyState_UnsavedChanges)){ - has_unsaved_changes = true; - break; - } - } - if (has_unsaved_changes){ - View_ID view = get_active_view(app, AccessAll); - do_gui_sure_to_close_4coder(app, view); - result = false; - } - } - - return(result); -} - HOOK_SIG(default_view_adjust){ // NOTE(allen): Called whenever the view layout/sizes have been modified, including // by full window resize. @@ -1000,7 +1022,7 @@ BUFFER_HOOK_SIG(default_file_save){ return(0); } -FILE_EDIT_RANGE_SIG(default_file_edit_range){ +BUFFER_EDIT_RANGE_SIG(default_buffer_edit_range){ // buffer_id, range, text Interval_i64 replace_range = Ii64(range.first, range.first + text.size); @@ -1089,16 +1111,6 @@ FILE_EDIT_RANGE_SIG(default_file_edit_range){ return(0); } -FILE_EXTERNALLY_MODIFIED_SIG(default_file_externally_modified){ - // buffer_id - Scratch_Block scratch(app); - String_Const_u8 name = push_buffer_unique_name(app, scratch, buffer_id); - String_Const_u8 str = push_u8_stringf(scratch, "Modified externally: %s\n", name.str); - print_message(app, str); - // no meaning for return - return(0); -} - BUFFER_HOOK_SIG(default_end_file){ Scratch_Block scratch(app); String_Const_u8 buffer_name = push_buffer_unique_name(app, scratch, buffer_id); @@ -1108,19 +1120,6 @@ BUFFER_HOOK_SIG(default_end_file){ return(0); } -// NOTE(allen|a4.0.9): The input filter allows you to modify the input -// to a frame before 4coder starts processing it at all. -// -// Right now it only has access to the mouse state, but it will be -// extended to have access to the key presses soon. -INPUT_FILTER_SIG(default_suppress_mouse_filter){ - if (suppressing_mouse){ - block_zero_struct(mouse); - mouse->p.x = -100; - mouse->p.y = -100; - } -} - // TODO(allen): FIX FIX FIX FIX // NOTE(allen|a4): scroll rule information // @@ -1202,24 +1201,27 @@ DELTA_RULE_SIG(smooth_scroll_rule){ internal void set_all_default_hooks(Application_Links *app){ +#if 0 set_custom_hook(app, HookID_Exit, default_exit); - set_custom_hook(app, HookID_BufferViewerUpdate, default_view_adjust); - set_custom_hook(app, HookID_Start, default_start); - set_custom_hook(app, HookID_OpenFile, default_file_settings); - set_custom_hook(app, HookID_NewFile, default_new_file); - set_custom_hook(app, HookID_SaveFile, default_file_save); - set_custom_hook(app, HookID_FileEditRange, default_file_edit_range); set_custom_hook(app, HookID_FileExternallyModified, default_file_externally_modified); - set_custom_hook(app, HookID_EndFile, end_file_close_jump_list); + set_custom_hook(app, HookID_InputFilter, default_suppress_mouse_filter); + set_custom_hook(app, HookID_ModifyColorTable, default_modify_color_table); +#endif + + set_custom_hook(app, HookID_BufferViewerUpdate, default_view_adjust); set_custom_hook(app, HookID_ViewEventHandler, default_view_input_handler); set_custom_hook(app, HookID_RenderCaller, default_render_caller); - set_custom_hook(app, HookID_InputFilter, default_suppress_mouse_filter); set_custom_hook(app, HookID_ScrollRule, smooth_scroll_rule); set_custom_hook(app, HookID_BufferNameResolver, default_buffer_name_resolution); - set_custom_hook(app, HookID_ModifyColorTable, default_modify_color_table); - set_custom_hook(app, HookID_GetViewBufferRegion, default_view_buffer_region); + + set_custom_hook(app, HookID_BeginBuffer, default_file_settings); + set_custom_hook(app, HookID_EndBuffer, end_file_close_jump_list); + set_custom_hook(app, HookID_NewFile, default_new_file); + set_custom_hook(app, HookID_SaveFile, default_file_save); + set_custom_hook(app, HookID_BufferEditRange, default_buffer_edit_range); + set_custom_hook(app, HookID_BufferRegion, default_view_buffer_region); } // BOTTOM diff --git a/custom/4coder_default_include.cpp b/custom/4coder_default_include.cpp index 15efbaef..13359933 100644 --- a/custom/4coder_default_include.cpp +++ b/custom/4coder_default_include.cpp @@ -9,8 +9,8 @@ #include "4coder_base_types.h" #include "4coder_version.h" -#include "4coder_events.h" #include "4coder_default_colors.h" +#include "4coder_events.h" #include "4coder_types.h" #define DYNAMIC_LINK_API #include "generated/custom_api.h" diff --git a/custom/4coder_events.cpp b/custom/4coder_events.cpp index 217fb56c..7db404d6 100644 --- a/custom/4coder_events.cpp +++ b/custom/4coder_events.cpp @@ -212,6 +212,26 @@ get_event_properties(Input_Event *event){ { flags |= EventProperty_ViewActivation; }break; + + case CoreCode_FileExternallyModified: + { + flags |= EventProperty_AnyFile; + }break; + + case CoreCode_Startup: + { + flags |= EventProperty_Startup; + }break; + + case CoreCode_TryExit: + { + flags |= EventProperty_Exit; + }break; + + case CoreCode_NewClipboardContents: + { + flags |= EventProperty_Clipboard; + }break; } }break; } diff --git a/custom/4coder_events.h b/custom/4coder_events.h index 5368d961..288b6017 100644 --- a/custom/4coder_events.h +++ b/custom/4coder_events.h @@ -69,6 +69,14 @@ struct Input_Event{ } mouse_move; struct{ Core_Code code; + union{ + String_Const_u8 string; + i32 id; + struct{ + String_Const_u8_Array flag_strings; + String_Const_u8_Array file_names; + }; + }; } core; }; }; @@ -96,6 +104,10 @@ enum{ EventProperty_Animate = 0x80, EventProperty_ViewActivation = 0x100, EventProperty_TextInsert = 0x200, + EventProperty_AnyFile = 0x400, + EventProperty_Startup = 0x800, + EventProperty_Exit = 0x1000, + EventProperty_Clipboard = 0x2000, }; enum{ EventPropertyGroup_AnyKeyboardEvent = @@ -114,7 +126,11 @@ enum{ EventPropertyGroup_Any = EventPropertyGroup_AnyUserInput| EventProperty_Animate| - EventProperty_ViewActivation, + EventProperty_ViewActivation| + EventProperty_AnyFile| + EventProperty_Startup| + EventProperty_Exit| + EventProperty_Clipboard, }; #endif diff --git a/custom/4coder_helper.cpp b/custom/4coder_helper.cpp index 48eef7bc..998c7f1f 100644 --- a/custom/4coder_helper.cpp +++ b/custom/4coder_helper.cpp @@ -1301,14 +1301,15 @@ query_user_general(Application_Links *app, Query_Bar *bar, b32 force_number){ for (;;){ // NOTE(allen|a3.4.4): This call will block until the user does one of the input - // types specified in the flags. The first set of flags are inputs you'd like to intercept - // that you don't want to abort on. The second set are inputs that you'd like to cause - // the command to abort. If an event satisfies both flags, it is treated as an abort. - User_Input in = get_user_input(app, EventPropertyGroup_AnyKeyboardEvent, + // types specified in the flags. The first set of flags are inputs you'd like to + // intercept that you don't want to abort on. The second set are inputs that + // you'd like to cause the command to abort. If an event satisfies both flags, it + // is treated as an abort. + User_Input in = get_next_input(app, EventPropertyGroup_AnyKeyboardEvent, EventProperty_Escape|EventProperty_MouseButton); // NOTE(allen|a3.4.4): The responsible thing to do on abort is to end the command - // without waiting on get_user_input again. + // without waiting on get_next_input again. if (in.abort){ success = false; break; @@ -1351,7 +1352,7 @@ query_user_general(Application_Links *app, Query_Bar *bar, b32 force_number){ bar->string = string.string; } else{ - leave_command_input_unhandled(app); + leave_current_input_unhandled(app); } } @@ -1675,7 +1676,9 @@ internal Buffer_Kill_Result try_buffer_kill(Application_Links *app, Buffer_ID buffer, View_ID gui_view_id, Buffer_Kill_Flag flags){ Buffer_Kill_Result result = buffer_kill(app, buffer, flags); if (result == BufferKillResult_Dirty){ - do_gui_sure_to_kill(app, buffer, gui_view_id); + if (do_gui_sure_to_kill(app, buffer, gui_view_id)){ + result = buffer_kill(app, buffer, BufferKill_AlwaysKill); + } } return(result); } diff --git a/custom/4coder_jump_lister.cpp b/custom/4coder_jump_lister.cpp index 9ef4f800..cb61a37b 100644 --- a/custom/4coder_jump_lister.cpp +++ b/custom/4coder_jump_lister.cpp @@ -10,7 +10,7 @@ activate_jump(Application_Links *app, String_Const_u8 text_field, void *user_data, b32 activated_by_mouse){ Lister_Activation_Code result_code = ListerActivation_Finished; i32 list_index = (i32)PtrAsInt(user_data); - Jump_Lister_Parameters *params = (Jump_Lister_Parameters*)lister->data.user_data; + Jump_Lister_Parameters *params = (Jump_Lister_Parameters*)lister->user_data; Marker_List *list = get_marker_list_for_buffer(params->list_buffer_id); if (list != 0){ View_ID target_view = {}; diff --git a/custom/4coder_jump_sticky.cpp b/custom/4coder_jump_sticky.cpp index 283d3f64..9a0f1dd2 100644 --- a/custom/4coder_jump_sticky.cpp +++ b/custom/4coder_jump_sticky.cpp @@ -572,7 +572,7 @@ CUSTOM_DOC("If the buffer in the active view is writable, inserts a character, o } } else{ - leave_command_input_unhandled(app); + leave_current_input_unhandled(app); } } @@ -589,7 +589,7 @@ CUSTOM_DOC("If the buffer in the active view is writable, inserts a character, o } } else{ - leave_command_input_unhandled(app); + leave_current_input_unhandled(app); } } diff --git a/custom/4coder_lister_base.cpp b/custom/4coder_lister_base.cpp index efd89cde..fc8143b3 100644 --- a/custom/4coder_lister_base.cpp +++ b/custom/4coder_lister_base.cpp @@ -50,24 +50,95 @@ view_get_lister(View_ID view){ } function Lister* -begin_lister(Application_Links *app, Arena *arena, View_ID view, void *user_data, umem user_data_size){ +begin_lister(Application_Links *app, Arena *arena, View_ID view, + void *user_data, umem user_data_size){ Lister *lister = push_array_zero(arena, Lister, 1); lister->arena = arena; - lister->data.query = Su8(lister->data.query_space, 0, sizeof(lister->data.query_space)); - lister->data.text_field = Su8(lister->data.text_field_space, 0, sizeof(lister->data.text_field_space)); - lister->data.key_string = Su8(lister->data.key_string_space, 0, sizeof(lister->data.key_string_space)); - lister->data.user_data_size = user_data_size; - if (user_data_size > 0){ - lister->data.user_data = push_array(lister->arena, u8, user_data_size); - if (user_data != 0){ - block_copy(lister->data.user_data, user_data, user_data_size); - } + lister->query = Su8(lister->query_space, 0, sizeof(lister->query_space)); + lister->text_field = Su8(lister->text_field_space, 0, sizeof(lister->text_field_space)); + lister->key_string = Su8(lister->key_string_space, 0, sizeof(lister->key_string_space)); + lister->user_data = user_data; + lister->user_data_size = user_data_size; + if (user_data == 0){ + lister->user_data = push_array_zero(arena, u8, user_data_size); } global_lister_state[view - 1] = lister; lister->restore_all_point = begin_temp(lister->arena); return(lister); } +function void +lister_set_map(Lister *lister, Mapping *mapping, Command_Map *map){ + lister->mapping = mapping; + lister->map = map; +} + +function void +lister_set_map(Lister *lister, Mapping *mapping, Command_Map_ID map){ + lister->mapping = mapping; + lister->map = mapping_get_map(mapping, map); +} + +function void +lister_set_string(String_Const_u8 string, String_u8 *target){ + target->size = 0; + string_append(target, string); +} +function void +lister_append_string(String_Const_u8 string, String_u8 *target){ + string_append(target, string); +} + +function void +lister_set_query(Lister *lister, String_Const_u8 string){ + lister_set_string(string, &lister->query); +} +function void +lister_set_query(Lister *lister, char *string){ + lister_set_string(SCu8(string), &lister->query); +} +function void +lister_set_text_field(Lister *lister, String_Const_u8 string){ + lister_set_string(string, &lister->text_field); +} +function void +lister_set_text_field(Lister *lister, char *string){ + lister_set_string(SCu8(string), &lister->text_field); +} +function void +lister_set_key(Lister *lister, String_Const_u8 string){ + lister_set_string(string, &lister->key_string); +} +function void +lister_set_key(Lister *lister, char *string){ + lister_set_string(SCu8(string), &lister->key_string); +} + +function void +lister_append_query(Lister *lister, String_Const_u8 string){ + lister_append_string(string, &lister->query); +} +function void +lister_append_query(Lister *lister, char *string){ + lister_append_string(SCu8(string), &lister->query); +} +function void +lister_append_text_field(Lister *lister, String_Const_u8 string){ + lister_append_string(string, &lister->text_field); +} +function void +lister_append_text_field(Lister *lister, char *string){ + lister_append_string(SCu8(string), &lister->text_field); +} +function void +lister_append_key(Lister *lister, String_Const_u8 string){ + lister_append_string(string, &lister->key_string); +} +function void +lister_append_key(Lister *lister, char *string){ + lister_append_string(SCu8(string), &lister->key_string); +} + function void lister_render(Application_Links *app, Frame_Info frame_info, View_ID view){ Scratch_Block scratch(app); @@ -105,10 +176,10 @@ lister_render(Application_Links *app, Frame_Info frame_info, View_ID view){ { Fancy_String_List text_field = {}; push_fancy_string(scratch, &text_field, fancy_id(Stag_Pop1), - lister->data.query.string); + lister->query.string); push_fancy_stringf(scratch, &text_field, fancy_id(Stag_Pop1), " "); push_fancy_string(scratch, &text_field, fancy_id(Stag_Default), - lister->data.text_field.string); + lister->text_field.string); draw_fancy_string(app, face_id, text_field.first, V2f32(layout.text_field_rect.x0 + 3.f, layout.text_field_rect.y0), Stag_Default, Stag_Back, 0, V2f32(1.f, 0.f)); @@ -117,24 +188,24 @@ lister_render(Application_Links *app, Frame_Info frame_info, View_ID view){ Range_f32 x = rect_range_x(layout.list_rect); draw_set_clip(app, layout.list_rect); - i32 count = lister->data.filtered.count; + i32 count = lister->filtered.count; Range_f32 scroll_range = If32(0.f, clamp_bot(0.f, count*block_height - block_height)); - lister->data.scroll.position.y = clamp_range(scroll_range, lister->data.scroll.position.y); - lister->data.scroll.position.x = 0.f; - lister->data.scroll.target.y = clamp_range(scroll_range, lister->data.scroll.target.y); - lister->data.scroll.target.x = 0.f; + lister->scroll.position.y = clamp_range(scroll_range, lister->scroll.position.y); + lister->scroll.position.x = 0.f; + lister->scroll.target.y = clamp_range(scroll_range, lister->scroll.target.y); + lister->scroll.target.x = 0.f; // TODO(allen): get scroll rule from context - lister->data.scroll.position = lister->data.scroll.target; + lister->scroll.position = lister->scroll.target; - f32 scroll_y = lister->data.scroll.position.y; + f32 scroll_y = lister->scroll.position.y; f32 y_pos = layout.list_rect.y0 - scroll_y; i32 first_index = (i32)(scroll_y/block_height); y_pos += first_index*block_height; for (i32 i = first_index; i < count; i += 1){ - Lister_Node *node = lister->data.filtered.node_ptrs[i]; + Lister_Node *node = lister->filtered.node_ptrs[i]; Range_f32 y = If32(y_pos, y_pos + block_height); y_pos = y.max; @@ -144,10 +215,10 @@ lister_render(Application_Links *app, Frame_Info frame_info, View_ID view){ b32 hovered = rect_contains_point(item_rect, m_p); UI_Highlight_Level highlight = UIHighlight_None; - if (node == lister->data.highlighted_node){ + if (node == lister->highlighted_node){ highlight = UIHighlight_Active; } - else if (node->user_data == lister->data.hot_user_data){ + else if (node->user_data == lister->hot_user_data){ if (hovered){ highlight = UIHighlight_Active; } @@ -177,9 +248,9 @@ lister_render(Application_Links *app, Frame_Info frame_info, View_ID view){ function void* lister_get_user_data(Lister *lister, i32 index){ void *result = 0; - if (0 <= index && index < lister->data.options.count){ + if (0 <= index && index < lister->options.count){ i32 counter = 0; - for (Lister_Node *node = lister->data.options.first; + for (Lister_Node *node = lister->options.first; node != 0; node = node->next, counter += 1){ if (counter == index){ @@ -193,7 +264,7 @@ lister_get_user_data(Lister *lister, i32 index){ function Lister_Filtered lister_get_filtered(Arena *arena, Lister *lister){ - i32 node_count = lister->data.options.count; + i32 node_count = lister->options.count; Lister_Filtered filtered = {}; filtered.exact_matches.node_ptrs = push_array(arena, Lister_Node*, 1); @@ -202,7 +273,7 @@ lister_get_filtered(Arena *arena, Lister *lister){ Temp_Memory_Block temp(arena); - String_Const_u8 key = lister->data.key_string.string; + String_Const_u8 key = lister->key_string.string; key = push_string_copy(arena, key); string_mod_replace_character(key, '_', '*'); string_mod_replace_character(key, ' ', '*'); @@ -214,7 +285,7 @@ lister_get_filtered(Arena *arena, Lister *lister){ string_list_push(&absolutes, &splits); string_list_push(arena, &absolutes, string_u8_litexpr("")); - for (Lister_Node *node = lister->data.options.first; + for (Lister_Node *node = lister->options.first; node != 0; node = node->next){ String_Const_u8 node_string = node->string; @@ -250,7 +321,7 @@ lister_update_filtered_list(Application_Links *app, View_ID view, Lister *lister }; Arena *arena = lister->arena; - end_temp(lister->data.filter_restore_point); + end_temp(lister->filter_restore_point); i32 total_count = 0; for (i32 array_index = 0; array_index < ArrayCount(node_ptr_arrays); array_index += 1){ @@ -259,11 +330,11 @@ lister_update_filtered_list(Application_Links *app, View_ID view, Lister *lister } Lister_Node **node_ptrs = push_array(arena, Lister_Node*, total_count); - lister->data.filtered.node_ptrs = node_ptrs; - lister->data.filtered.count = total_count; + lister->filtered.node_ptrs = node_ptrs; + lister->filtered.count = total_count; - lister->data.raw_item_index = -1; - lister->data.highlighted_node = 0; + lister->raw_item_index = -1; + lister->highlighted_node = 0; i32 counter = 0; for (i32 array_index = 0; array_index < ArrayCount(node_ptr_arrays); array_index += 1){ @@ -271,9 +342,9 @@ lister_update_filtered_list(Application_Links *app, View_ID view, Lister *lister for (i32 node_index = 0; node_index < node_ptr_array.count; node_index += 1){ Lister_Node *node = node_ptr_array.node_ptrs[node_index]; node_ptrs[counter] = node; - if (lister->data.item_index == counter){ - lister->data.highlighted_node = node; - lister->data.raw_item_index = node->raw_index; + if (lister->item_index == counter){ + lister->highlighted_node = node; + lister->raw_item_index = node->raw_index; } counter += 1; } @@ -282,9 +353,9 @@ lister_update_filtered_list(Application_Links *app, View_ID view, Lister *lister function void lister_call_refresh_handler(Application_Links *app, View_ID view, Lister *lister){ - if (lister->data.handlers.refresh != 0){ - lister->data.handlers.refresh(app, lister); - lister->data.filter_restore_point = begin_temp(lister->arena); + if (lister->handlers.refresh != 0){ + lister->handlers.refresh(app, lister); + lister->filter_restore_point = begin_temp(lister->arena); lister_update_filtered_list(app, view, lister); } } @@ -300,7 +371,7 @@ lister_default(Application_Links *app, View_ID view, Lister *lister, Lister_Acti case ListerActivation_ContinueAndRefresh: { - lister->data.item_index = 0; + lister->item_index = 0; lister_call_refresh_handler(app, view, lister); }break; } @@ -310,9 +381,9 @@ function Lister_Activation_Code lister_call_activate_handler(Application_Links *app, View_ID view, Lister *lister, void *user_data, b32 activated_by_mouse){ Lister_Activation_Code result = ListerActivation_Finished; - if (lister->data.handlers.activate != 0){ - result = lister->data.handlers.activate(app, view, lister, lister->data.text_field.string, - user_data, activated_by_mouse); + if (lister->handlers.activate != 0){ + result = lister->handlers.activate(app, view, lister, lister->text_field.string, + user_data, activated_by_mouse); } else{ lister_default(app, view, lister, ListerActivation_Finished); @@ -336,10 +407,10 @@ lister_user_data_at_p(Application_Links *app, View_ID view, Lister *lister, Vec2 void *result = 0; if (rect_contains_point(layout.list_rect, m_p)){ - f32 y = m_p.y - layout.list_rect.y0 + lister->data.scroll.position.y; + f32 y = m_p.y - layout.list_rect.y0 + lister->scroll.position.y; i32 index = (i32)(y/block_height); - if (0 < index && index < lister->data.filtered.count){ - Lister_Node *node = lister->data.filtered.node_ptrs[index]; + if (0 < index && index < lister->filtered.count){ + Lister_Node *node = lister->filtered.node_ptrs[index]; result = node->user_data; } } @@ -349,15 +420,16 @@ lister_user_data_at_p(Application_Links *app, View_ID view, Lister *lister, Vec2 function void lister_run(Application_Links *app, View_ID view, Lister *lister){ - lister->data.filter_restore_point = begin_temp(lister->arena); + lister->filter_restore_point = begin_temp(lister->arena); lister_update_filtered_list(app, view, lister); View_Context ctx = view_current_context(app, view); ctx.render_caller = lister_render; + ctx.hides_buffer = true; view_push_context(app, view, &ctx); for (;;){ - User_Input in = get_user_input(app, EventPropertyGroup_Any, EventProperty_Escape); + User_Input in = get_next_input(app, EventPropertyGroup_Any, EventProperty_Escape); if (in.abort){ break; } @@ -367,8 +439,8 @@ lister_run(Application_Links *app, View_ID view, Lister *lister){ switch (in.event.kind){ case InputEventKind_TextInsert: { - if (lister->data.handlers.write_character != 0){ - lister->data.handlers.write_character(app); + if (lister->handlers.write_character != 0){ + lister->handlers.write_character(app); } }break; @@ -379,9 +451,9 @@ lister_run(Application_Links *app, View_ID view, Lister *lister){ case KeyCode_Tab: { void *user_data = 0; - if (0 <= lister->data.raw_item_index && - lister->data.raw_item_index < lister->data.options.count){ - user_data = lister_get_user_data(lister, lister->data.raw_item_index); + if (0 <= lister->raw_item_index && + lister->raw_item_index < lister->options.count){ + user_data = lister_get_user_data(lister, lister->raw_item_index); } result = lister_call_activate_handler(app, view, lister, user_data, false); @@ -389,11 +461,11 @@ lister_run(Application_Links *app, View_ID view, Lister *lister){ case KeyCode_Backspace: { - if (lister->data.handlers.backspace != 0){ - lister->data.handlers.backspace(app); + if (lister->handlers.backspace != 0){ + lister->handlers.backspace(app); } - else if (lister->data.handlers.key_stroke != 0){ - result = lister->data.handlers.key_stroke(app); + else if (lister->handlers.key_stroke != 0){ + result = lister->handlers.key_stroke(app); } else{ handled = false; @@ -402,8 +474,8 @@ lister_run(Application_Links *app, View_ID view, Lister *lister){ case KeyCode_Up: { - if (lister->data.handlers.navigate_up != 0){ - lister->data.handlers.navigate_up(app); + if (lister->handlers.navigate_up != 0){ + lister->handlers.navigate_up(app); } else{ handled = false; @@ -412,8 +484,8 @@ lister_run(Application_Links *app, View_ID view, Lister *lister){ case KeyCode_Down: { - if (lister->data.handlers.navigate_down != 0){ - lister->data.handlers.navigate_down(app); + if (lister->handlers.navigate_down != 0){ + lister->handlers.navigate_down(app); } else{ handled = false; @@ -422,8 +494,8 @@ lister_run(Application_Links *app, View_ID view, Lister *lister){ default: { - if (lister->data.handlers.key_stroke != 0){ - result = lister->data.handlers.key_stroke(app); + if (lister->handlers.key_stroke != 0){ + result = lister->handlers.key_stroke(app); } else{ handled = false; @@ -439,7 +511,7 @@ lister_run(Application_Links *app, View_ID view, Lister *lister){ { Vec2_f32 p = V2f32(in.event.mouse.p); void *clicked = lister_user_data_at_p(app, view, lister, p); - lister->data.hot_user_data = clicked; + lister->hot_user_data = clicked; }break; default: @@ -454,15 +526,15 @@ lister_run(Application_Links *app, View_ID view, Lister *lister){ switch (in.event.mouse.code){ case MouseCode_Left: { - if (lister->data.hot_user_data != 0){ + if (lister->hot_user_data != 0){ Vec2_f32 p = V2f32(in.event.mouse.p); void *clicked = lister_user_data_at_p(app, view, lister, p); - if (lister->data.hot_user_data == clicked){ + if (lister->hot_user_data == clicked){ result = lister_call_activate_handler(app, view, lister, clicked, true); } } - lister->data.hot_user_data = 0; + lister->hot_user_data = 0; }break; default: @@ -475,7 +547,7 @@ lister_run(Application_Links *app, View_ID view, Lister *lister){ case InputEventKind_MouseWheel: { Mouse_State mouse = get_mouse_state(app); - lister->data.scroll.target.y += mouse.wheel; + lister->scroll.target.y += mouse.wheel; lister_update_filtered_list(app, view, lister); }break; @@ -494,8 +566,28 @@ lister_run(Application_Links *app, View_ID view, Lister *lister){ if (result == ListerActivation_Finished){ break; } + if (!handled){ - leave_command_input_unhandled(app); + Mapping *mapping = lister->mapping; + Command_Map *map = lister->map; + if (mapping != 0 && map != 0){ + Command_Binding binding = + map_get_binding_recursive(mapping, map, &in.event); + if (binding.custom != 0){ + i64 old_num = get_current_input_sequence_number(app); + binding.custom(app); + i64 num = get_current_input_sequence_number(app); + if (old_num < num){ + break; + } + } + else{ + leave_current_input_unhandled(app); + } + } + else{ + leave_current_input_unhandled(app); + } } } @@ -512,8 +604,8 @@ lister_prealloced(String_Const_u8 string){ function void lister_begin_new_item_set(Application_Links *app, Lister *lister){ end_temp(lister->restore_all_point); - block_zero_struct(&lister->data.options); - block_zero_struct(&lister->data.filtered); + block_zero_struct(&lister->options); + block_zero_struct(&lister->filtered); } function void* @@ -524,9 +616,9 @@ lister_add_item(Lister *lister, Lister_Prealloced_String string, Lister_Prealloc node->string = string.string; node->status = status.string; node->user_data = user_data; - node->raw_index = lister->data.options.count; - zdll_push_back(lister->data.options.first, lister->data.options.last, node); - lister->data.options.count += 1; + node->raw_index = lister->options.count; + zdll_push_back(lister->options.first, lister->options.last, node); + lister->options.count += 1; void *result = (node + 1); return(result); } @@ -553,88 +645,5 @@ lister_add_item(Lister *lister, String_Const_u8 string, String_Const_u8 status, user_data, extra_space)); } -function void* -lister_add_theme_item(Lister *lister, - Lister_Prealloced_String string, i32 index, - void *user_data, i32 extra_space){ - Lister_Node *node = push_array(lister->arena, Lister_Node, 1); - node->string = string.string; - node->index = index; - node->user_data = user_data; - node->raw_index = lister->data.options.count; - zdll_push_back(lister->data.options.first, lister->data.options.last, node); - lister->data.options.count += 1; - void *result = push_array(lister->arena, char, extra_space); - push_align(lister->arena, 8); - return(result); -} - -function void* -lister_add_theme_item(Lister *lister, String_Const_u8 string, i32 index, - void *user_data, i32 extra_space){ - return(lister_add_theme_item(lister, lister_prealloced(push_string_copy(lister->arena, string)), index, - user_data, extra_space)); -} - -function void -lister_set_string(String_Const_u8 string, String_u8 *target){ - target->size = 0; - string_append(target, string); -} -function void -lister_append_string(String_Const_u8 string, String_u8 *target){ - string_append(target, string); -} - -function void -lister_set_query(Lister *lister, String_Const_u8 string){ - lister_set_string(string, &lister->data.query); -} -function void -lister_set_query(Lister *lister, char *string){ - lister_set_string(SCu8(string), &lister->data.query); -} -function void -lister_set_text_field(Lister *lister, String_Const_u8 string){ - lister_set_string(string, &lister->data.text_field); -} -function void -lister_set_text_field(Lister *lister, char *string){ - lister_set_string(SCu8(string), &lister->data.text_field); -} -function void -lister_set_key(Lister *lister, String_Const_u8 string){ - lister_set_string(string, &lister->data.key_string); -} -function void -lister_set_key(Lister *lister, char *string){ - lister_set_string(SCu8(string), &lister->data.key_string); -} - -function void -lister_append_query(Lister *lister, String_Const_u8 string){ - lister_append_string(string, &lister->data.query); -} -function void -lister_append_query(Lister *lister, char *string){ - lister_append_string(SCu8(string), &lister->data.query); -} -function void -lister_append_text_field(Lister *lister, String_Const_u8 string){ - lister_append_string(string, &lister->data.text_field); -} -function void -lister_append_text_field(Lister *lister, char *string){ - lister_append_string(SCu8(string), &lister->data.text_field); -} -function void -lister_append_key(Lister *lister, String_Const_u8 string){ - lister_append_string(string, &lister->data.key_string); -} -function void -lister_append_key(Lister *lister, char *string){ - lister_append_string(SCu8(string), &lister->data.key_string); -} - // BOTTOM diff --git a/custom/4coder_lister_base.h b/custom/4coder_lister_base.h index ddb4d29c..7e7524dc 100644 --- a/custom/4coder_lister_base.h +++ b/custom/4coder_lister_base.h @@ -59,29 +59,32 @@ struct Lister{ Arena *arena; Temp_Memory restore_all_point; - struct{ - Lister_Handlers handlers; - - void *user_data; - umem user_data_size; - u8 query_space[256]; - u8 text_field_space[256]; - u8 key_string_space[256]; - String_u8 query; - String_u8 text_field; - String_u8 key_string; - Lister_Node_List options; - Temp_Memory filter_restore_point; - Lister_Node_Ptr_Array filtered; - - b32 set_view_vertical_focus_to_item; - Lister_Node *highlighted_node; - void *hot_user_data; - i32 item_index; - i32 raw_item_index; - - Basic_Scroll scroll; - } data; + Lister_Handlers handlers; + + Mapping *mapping; + Command_Map *map; + + void *user_data; + umem user_data_size; + + u8 query_space[256]; + u8 text_field_space[256]; + u8 key_string_space[256]; + String_u8 query; + String_u8 text_field; + String_u8 key_string; + + Lister_Node_List options; + Temp_Memory filter_restore_point; + Lister_Node_Ptr_Array filtered; + + b32 set_view_vertical_focus_to_item; + Lister_Node *highlighted_node; + void *hot_user_data; + i32 item_index; + i32 raw_item_index; + + Basic_Scroll scroll; }; struct Lister_Prealloced_String{ diff --git a/custom/4coder_lists.cpp b/custom/4coder_lists.cpp index e31f7bd9..9349598c 100644 --- a/custom/4coder_lists.cpp +++ b/custom/4coder_lists.cpp @@ -10,12 +10,12 @@ lister__write_string__default(Application_Links *app){ View_ID view = get_active_view(app, AccessAll); Lister *lister = view_get_lister(view); if (lister != 0){ - User_Input in = get_command_input(app); + User_Input in = get_current_input(app); String_Const_u8 string = to_writable(&in); if (string.str != 0 && string.size > 0){ lister_append_text_field(lister, string); lister_append_key(lister, string); - lister->data.item_index = 0; + lister->item_index = 0; view_zero_scroll(app, view); lister_update_filtered_list(app, view, lister); } @@ -27,9 +27,9 @@ lister__backspace_text_field__default(Application_Links *app){ View_ID view = get_active_view(app, AccessAll); Lister *lister = view_get_lister(view); if (lister != 0){ - lister->data.text_field.string = backspace_utf8(lister->data.text_field.string); - lister->data.key_string.string = backspace_utf8(lister->data.key_string.string); - lister->data.item_index = 0; + lister->text_field.string = backspace_utf8(lister->text_field.string); + lister->key_string.string = backspace_utf8(lister->key_string.string); + lister->item_index = 0; view_zero_scroll(app, view); lister_update_filtered_list(app, view, lister); } @@ -40,11 +40,11 @@ lister__move_up__default(Application_Links *app){ View_ID view = get_active_view(app, AccessAll); Lister *lister = view_get_lister(view); if (lister != 0){ - lister->data.item_index = lister->data.item_index - 1; - if (lister->data.item_index < 0){ - lister->data.item_index = lister->data.filtered.count - 1; + lister->item_index = lister->item_index - 1; + if (lister->item_index < 0){ + lister->item_index = lister->filtered.count - 1; } - lister->data.set_view_vertical_focus_to_item = true; + lister->set_view_vertical_focus_to_item = true; lister_update_filtered_list(app, view, lister); } } @@ -54,11 +54,11 @@ lister__move_down__default(Application_Links *app){ View_ID view = get_active_view(app, AccessAll); Lister *lister = view_get_lister(view); if (lister != 0){ - lister->data.item_index = lister->data.item_index + 1; - if (lister->data.item_index > lister->data.filtered.count - 1){ - lister->data.item_index = 0; + lister->item_index = lister->item_index + 1; + if (lister->item_index > lister->filtered.count - 1){ + lister->item_index = 0; } - lister->data.set_view_vertical_focus_to_item = true; + lister->set_view_vertical_focus_to_item = true; lister_update_filtered_list(app, view, lister); } } @@ -68,18 +68,18 @@ lister__write_character__file_path(Application_Links *app){ View_ID view = get_active_view(app, AccessAll); Lister *lister = view_get_lister(view); if (lister != 0){ - User_Input in = get_command_input(app); + User_Input in = get_current_input(app); String_Const_u8 string = to_writable(&in); if (string.str != 0 && string.size > 0){ lister_append_text_field(lister, string); - String_Const_u8 front_name = string_front_of_path(lister->data.text_field.string); + String_Const_u8 front_name = string_front_of_path(lister->text_field.string); lister_set_key(lister, front_name); if (character_is_slash(string.str[0])){ - String_Const_u8 new_hot = lister->data.text_field.string; + String_Const_u8 new_hot = lister->text_field.string; set_hot_directory(app, new_hot); lister_call_refresh_handler(app, view, lister); } - lister->data.item_index = 0; + lister->item_index = 0; view_zero_scroll(app, view); lister_update_filtered_list(app, view, lister); } @@ -91,32 +91,32 @@ lister__backspace_text_field__file_path(Application_Links *app){ View_ID view = get_active_view(app, AccessAll); Lister *lister = view_get_lister(view); if (lister != 0){ - if (lister->data.text_field.size > 0){ - char last_char = lister->data.text_field.str[lister->data.text_field.size - 1]; - lister->data.text_field.string = backspace_utf8(lister->data.text_field.string); + if (lister->text_field.size > 0){ + char last_char = lister->text_field.str[lister->text_field.size - 1]; + lister->text_field.string = backspace_utf8(lister->text_field.string); if (character_is_slash(last_char)){ - User_Input input = get_command_input(app); - String_Const_u8 text_field = lister->data.text_field.string; + User_Input input = get_current_input(app); + String_Const_u8 text_field = lister->text_field.string; String_Const_u8 new_hot = string_remove_last_folder(text_field); b32 is_modified = has_modifier(&input, KeyCode_Control); b32 whole_word_backspace = (is_modified == global_config.lister_whole_word_backspace_when_modified); if (whole_word_backspace){ - lister->data.text_field.size = new_hot.size; + lister->text_field.size = new_hot.size; } set_hot_directory(app, new_hot); // TODO(allen): We have to protect against lister_call_refresh_handler changing // the text_field here. Clean this up. - String_u8 dingus = lister->data.text_field; + String_u8 dingus = lister->text_field; lister_call_refresh_handler(app, view, lister); - lister->data.text_field = dingus; + lister->text_field = dingus; } else{ - String_Const_u8 text_field = lister->data.text_field.string; + String_Const_u8 text_field = lister->text_field.string; String_Const_u8 new_key = string_front_of_path(text_field); lister_set_key(lister, new_key); } - lister->data.item_index = 0; + lister->item_index = 0; view_zero_scroll(app, view); lister_update_filtered_list(app, view, lister); } @@ -129,11 +129,11 @@ lister__key_stroke__fixed_list(Application_Links *app){ View_ID view = get_active_view(app, AccessAll); Lister *lister = view_get_lister(view); if (lister != 0){ - User_Input in = get_command_input(app); + User_Input in = get_current_input(app); if (in.event.kind == InputEventKind_KeyStroke){ void *user_data = 0; b32 did_shortcut_key = false; - for (Lister_Node *node = lister->data.options.first; + for (Lister_Node *node = lister->options.first; node != 0; node = node->next){ Key_Code *key_code = (Key_Code*)(node + 1); @@ -180,8 +180,9 @@ run_lister_with_refresh_handler(Application_Links *app, char *query_string, if (handlers.refresh != 0){ Scratch_Block scratch(app); Lister *lister = begin_lister(app, scratch, view, user_data, user_data_size); + lister_set_map(lister, &framework_mapping, mapid_global); lister_set_query(lister, query_string); - lister->data.handlers = handlers; + lister->handlers = handlers; handlers.refresh(app, lister); lister_run(app, view, lister); } @@ -214,12 +215,13 @@ run_lister_with_options_array(Application_Links *app, char *query_string, View_ID view){ Scratch_Block scratch(app); Lister *lister = begin_lister(app, scratch, view, user_data, user_data_size); + lister_set_map(lister, &framework_mapping, mapid_global); for (i32 i = 0; i < option_count; i += 1){ lister_add_item(lister, options[i].string, options[i].status, options[i].user_data, 0); } lister_set_query(lister, query_string); - lister->data.handlers = lister_get_default_handlers(); - lister->data.handlers.activate = activate; + lister->handlers = lister_get_default_handlers(); + lister->handlers.activate = activate; lister_run(app, view, lister); } @@ -232,6 +234,7 @@ run_lister_with_fixed_options(Application_Links *app, char *query_string, View_ID view){ Scratch_Block scratch(app); Lister *lister = begin_lister(app, scratch, view, user_data, user_data_size); + lister_set_map(lister, &framework_mapping, mapid_global); for (i32 i = 0; i < option_count; i += 1){ Key_Code code = options[i].key_code; void *extra = lister_add_item(lister, SCu8(options[i].string), SCu8(options[i].status), @@ -239,8 +242,8 @@ run_lister_with_fixed_options(Application_Links *app, char *query_string, block_copy(extra, &code, sizeof(code)); } lister_set_query(lister, query_string); - lister->data.handlers = handlers; - lister->data.handlers.refresh = 0; + lister->handlers = handlers; + lister->handlers.refresh = 0; lister_run(app, view, lister); } @@ -434,26 +437,31 @@ enum{ SureToKill_Save = 3, }; +struct Confirm_Kill_Data{ + Buffer_ID id; + b32 do_kill; +}; + function Lister_Activation_Code activate_confirm_kill(Application_Links *app, View_ID view, Lister *lister, String_Const_u8 text_field, void *user_data, b32 clicked){ i32 behavior = (i32)PtrAsInt(user_data); - Buffer_ID buffer_id = *(Buffer_ID*)(lister->data.user_data); + Confirm_Kill_Data *data = (Confirm_Kill_Data*)(lister->user_data); switch (behavior){ case SureToKill_No: {}break; case SureToKill_Yes: { - buffer_kill(app, buffer_id, BufferKill_AlwaysKill); + data->do_kill = true; }break; case SureToKill_Save: { Scratch_Block scratch(app); - String_Const_u8 file_name = push_buffer_file_name(app, scratch, buffer_id); - if (buffer_save(app, buffer_id, file_name, BufferSave_IgnoreDirtyFlag)){ - buffer_kill(app, buffer_id, BufferKill_AlwaysKill); + String_Const_u8 file_name = push_buffer_file_name(app, scratch, data->id); + if (buffer_save(app, data->id, file_name, BufferSave_IgnoreDirtyFlag)){ + data->do_kill = true; } else{ String_Const_u8 str = push_u8_stringf(scratch, "Did not close '%.*s' because it did not successfully save.", @@ -466,7 +474,7 @@ activate_confirm_kill(Application_Links *app, View_ID view, Lister *lister, return(ListerActivation_Finished); } -function void +function b32 do_gui_sure_to_kill(Application_Links *app, Buffer_ID buffer, View_ID view){ Lister_Fixed_Option options[] = { {"(N)o" , "", KeyCode_N, IntAsPtr(SureToKill_No) }, @@ -474,10 +482,13 @@ do_gui_sure_to_kill(Application_Links *app, Buffer_ID buffer, View_ID view){ {"(S)ave and Kill", "", KeyCode_S, IntAsPtr(SureToKill_Save)}, }; i32 option_count = sizeof(options)/sizeof(options[0]); + Confirm_Kill_Data data = {}; + data.id = buffer; run_lister_with_fixed_options(app, "There are unsaved changes, close anyway?", - activate_confirm_kill, &buffer, sizeof(buffer), + activate_confirm_kill, &data, sizeof(data), options, option_count, default_string_size_estimation, view); + return(data.do_kill); } function Lister_Activation_Code @@ -485,6 +496,7 @@ activate_confirm_close_4coder(Application_Links *app, View_ID view, Lister *lister, String_Const_u8 text_field, void *user_data, b32 clicked){ i32 behavior = (i32)PtrAsInt(user_data); + b32 *do_exit = (b32*)user_data; switch (behavior){ case SureToKill_No: {}break; @@ -492,21 +504,21 @@ activate_confirm_close_4coder(Application_Links *app, case SureToKill_Yes: { allow_immediate_close_without_checking_for_changes = true; - send_exit_signal(app); + *do_exit = true; }break; case SureToKill_Save: { save_all_dirty_buffers(app); allow_immediate_close_without_checking_for_changes = true; - send_exit_signal(app); + *do_exit = true; }break; } lister_default(app, view, lister, ListerActivation_Finished); return(ListerActivation_Finished); } -function void +function b32 do_gui_sure_to_close_4coder(Application_Links *app, View_ID view){ Lister_Fixed_Option options[] = { {"(N)o" , "", KeyCode_N, (void*)SureToKill_No }, @@ -514,10 +526,13 @@ do_gui_sure_to_close_4coder(Application_Links *app, View_ID view){ {"(S)ave All and Close", "", KeyCode_S, (void*)SureToKill_Save}, }; i32 option_count = sizeof(options)/sizeof(options[0]); + b32 do_exit = false; run_lister_with_fixed_options(app, "There are one or more buffers with unsave changes, close anyway?", - activate_confirm_close_4coder, 0, 0, + activate_confirm_close_4coder, + &do_exit, sizeof(do_exit), options, option_count, default_string_size_estimation, view); + return(do_exit); } //////////////////////////////// @@ -611,7 +626,7 @@ activate_open_or_new(Application_Links *app, result = ListerActivation_Finished; } else{ - String_Const_u8 path = lister->data.text_field.string; + String_Const_u8 path = lister->text_field.string; if (!character_is_slash(string_get_character(path, path.size - 1))){ path = string_remove_last_folder(path); } @@ -650,7 +665,7 @@ activate_new(Application_Links *app, result = ListerActivation_Finished; } else{ - String_Const_u8 path = lister->data.text_field.string; + String_Const_u8 path = lister->text_field.string; if (character_is_slash(string_get_character(path, path.size - 1))){ path = string_remove_last_folder(path); } @@ -683,7 +698,7 @@ activate_open(Application_Links *app, result = ListerActivation_Finished; } else{ - String_Const_u8 path = lister->data.text_field.string; + String_Const_u8 path = lister->text_field.string; if (!character_is_slash(string_get_character(path, path.size - 1))){ path = string_remove_last_folder(path); } diff --git a/custom/4coder_log_parser.cpp b/custom/4coder_log_parser.cpp index 98907069..98c1fa0e 100644 --- a/custom/4coder_log_parser.cpp +++ b/custom/4coder_log_parser.cpp @@ -1002,7 +1002,7 @@ CUSTOM_DOC("Parses *log* and displays the 'log graph' UI") view_push_context(app, log_view, &ctx); for (;;){ - User_Input in = get_user_input(app, EventPropertyGroup_AnyUserInput, KeyCode_Escape); + User_Input in = get_next_input(app, EventPropertyGroup_AnyUserInput, KeyCode_Escape); if (in.abort){ log_view = 0; break; diff --git a/custom/4coder_project_commands.cpp b/custom/4coder_project_commands.cpp index 67e68878..808dc463 100644 --- a/custom/4coder_project_commands.cpp +++ b/custom/4coder_project_commands.cpp @@ -944,7 +944,7 @@ CUSTOM_DOC("Looks for a project.4coder file in the current directory and tries t CUSTOM_COMMAND_SIG(project_fkey_command) CUSTOM_DOC("Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.") { - User_Input input = get_command_input(app); + User_Input input = get_current_input(app); b32 got_ind = false; i32 ind = 0; if (input.event.kind == InputEventKind_KeyStroke){ diff --git a/custom/4coder_types.h b/custom/4coder_types.h index 053c0761..663ce09c 100644 --- a/custom/4coder_types.h +++ b/custom/4coder_types.h @@ -107,14 +107,6 @@ struct Frame_Info{ f32 animation_dt; }; -typedef void Render_Caller_Function(Application_Links *app, Frame_Info frame_info, View_ID view); -#define RENDER_CALLER_SIG(name) void name(Application_Links *app, Frame_Info frame_info, View_ID view) - -struct View_Context{ - Render_Caller_Function *render_caller; - b32 hides_buffer; -}; - ENUM(i32, View_Setting_ID){ ViewSetting_Null, ViewSetting_ShowWhitespace, @@ -483,63 +475,23 @@ STRUCT User_Input{ typedef i32 Hook_ID; enum{ - HookID_FileOutOfSync, - HookID_Exit, + HookID_RenderCaller, HookID_BufferViewerUpdate, HookID_ScrollRule, - HookID_NewFile, - HookID_OpenFile, - HookID_SaveFile, - HookID_EndFile, - HookID_FileEditRange, - HookID_FileExternallyModified, HookID_ViewEventHandler, - HookID_RenderCaller, - HookID_InputFilter, - HookID_Start, HookID_BufferNameResolver, - HookID_ModifyColorTable, - HookID_ClipboardChange, - HookID_GetViewBufferRegion, + HookID_BeginBuffer, + HookID_EndBuffer, + HookID_NewFile, + HookID_SaveFile, + HookID_BufferEditRange, + HookID_BufferRegion, }; -TYPEDEF_FUNC i32 Hook_Function(struct Application_Links *app); -#define HOOK_SIG(name) i32 name(struct Application_Links *app) +typedef i32 Hook_Function(Application_Links *app); +#define HOOK_SIG(name) i32 name(Application_Links *app) -TYPEDEF_FUNC i32 Buffer_Hook_Function(struct Application_Links *app, Buffer_ID buffer_id); -#define BUFFER_HOOK_SIG(name) i32 name(struct Application_Links *app, Buffer_ID buffer_id) - -TYPEDEF_FUNC i32 File_Edit_Range_Function(struct Application_Links *app, Buffer_ID buffer_id, - Interval_i64 range, String_Const_u8 text); -#define FILE_EDIT_RANGE_SIG(name) i32 name(struct Application_Links *app, Buffer_ID buffer_id, Interval_i64 range, String_Const_u8 text) - -TYPEDEF_FUNC i32 File_Externally_Modified_Function(struct Application_Links *app, Buffer_ID buffer_id); -#define FILE_EXTERNALLY_MODIFIED_SIG(name) i32 name(struct Application_Links *app, Buffer_ID buffer_id) - -TYPEDEF_FUNC void Input_Filter_Function(Mouse_State *mouse); -#define INPUT_FILTER_SIG(name) void name(Mouse_State *mouse) - -TYPEDEF_FUNC Vec2_f32 Delta_Rule_Function(Vec2_f32 pending_delta, View_ID view_id, b32 is_new_target, f32 dt); -#define DELTA_RULE_SIG(name) Vec2_f32 name(Vec2_f32 pending_delta, View_ID view_id, b32 is_new_target, f32 dt) - -STRUCT Color_Table{ - argb_color *vals; - u32 count; -}; - -TYPEDEF_FUNC Color_Table Modify_Color_Table_Function(struct Application_Links *app, Frame_Info frame); -#define MODIFY_COLOR_TABLE_SIG(name) Color_Table name(struct Application_Links *app, Frame_Info frame) - -ENUM(u32, Clipboard_Change_Flag){ - ClipboardFlag_FromOS = 0x1, -}; -TYPEDEF_FUNC void Clipboard_Change_Hook_Function(struct Application_Links *app, String_Const_u8 contents, Clipboard_Change_Flag flags); -#define CLIPBOARD_CHANGE_HOOK_SIG(name) void name(struct Application_Links *app, String_Const_u8 contents, Clipboard_Change_Flag flags) - -TYPEDEF_FUNC Rect_f32 Get_View_Buffer_Region_Function(struct Application_Links *app, View_ID view_id, Rect_f32 sub_region); -#define GET_VIEW_BUFFER_REGION_SIG(name) Rect_f32 name(struct Application_Links *app, View_ID view_id, Rect_f32 sub_region) - -STRUCT Buffer_Name_Conflict_Entry{ +struct Buffer_Name_Conflict_Entry{ Buffer_ID buffer_id; String_Const_u8 file_name; String_Const_u8 base_name; @@ -548,16 +500,40 @@ STRUCT Buffer_Name_Conflict_Entry{ umem unique_name_capacity; }; -TYPEDEF_FUNC void Buffer_Name_Resolver_Function(struct Application_Links *app, Buffer_Name_Conflict_Entry *conflicts, i32 conflict_count); +typedef void Buffer_Name_Resolver_Function(Application_Links *app, Buffer_Name_Conflict_Entry *conflicts, i32 conflict_count); #define BUFFER_NAME_RESOLVER_SIG(n) \ -void n(struct Application_Links *app, Buffer_Name_Conflict_Entry *conflicts, i32 conflict_count) +void n(Application_Links *app, Buffer_Name_Conflict_Entry *conflicts, i32 conflict_count) -TYPEDEF_FUNC i32 Start_Hook_Function(struct Application_Links *app, char **files, i32 file_count, char **flags, i32 flag_count); -#define START_HOOK_SIG(name) \ -i32 name(struct Application_Links *app, char **files, i32 file_count, char **flags, i32 flag_count) +typedef i32 Buffer_Hook_Function(Application_Links *app, Buffer_ID buffer_id); +#define BUFFER_HOOK_SIG(name) i32 name(Application_Links *app, Buffer_ID buffer_id) -TYPEDEF_FUNC i32 Get_Binding_Data_Function(void *data, i32 size); -#define GET_BINDING_DATA(name) i32 name(void *data, i32 size) +typedef i32 Buffer_Edit_Range_Function(Application_Links *app, Buffer_ID buffer_id, + Range_i64 range, String_Const_u8 text); +#define BUFFER_EDIT_RANGE_SIG(name) i32 name(Application_Links *app, Buffer_ID buffer_id,\ +Interval_i64 range, String_Const_u8 text) + +typedef Vec2_f32 Delta_Rule_Function(Vec2_f32 pending_delta, View_ID view_id, b32 is_new_target, f32 dt); +#define DELTA_RULE_SIG(name) \ +Vec2_f32 name(Vec2_f32 pending_delta, View_ID view_id, b32 is_new_target, f32 dt) + +typedef Rect_f32 Buffer_Region_Function(Application_Links *app, View_ID view_id, Rect_f32 region); + +struct Color_Table{ + argb_color *vals; + u32 count; +}; + +typedef void New_Clipboard_Contents_Function(Application_Links *app, String_Const_u8 contents); +#define NEW_CLIPBOARD_CONTENTS_SIG(name) \ +void name(Application_Links *app, String_Const_u8 contents) + +typedef void Render_Caller_Function(Application_Links *app, Frame_Info frame_info, View_ID view); +#define RENDER_CALLER_SIG(name) void name(Application_Links *app, Frame_Info frame_info, View_ID view) + +struct View_Context{ + Render_Caller_Function *render_caller; + b32 hides_buffer; +}; typedef i64 Command_Map_ID; diff --git a/custom/generated/4coder_event_codes.h b/custom/generated/4coder_event_codes.h index 3619a45e..8358d6a2 100644 --- a/custom/generated/4coder_event_codes.h +++ b/custom/generated/4coder_event_codes.h @@ -1,204 +1,212 @@ enum{ - KeyCode_A = 1, - KeyCode_B = 2, - KeyCode_C = 3, - KeyCode_D = 4, - KeyCode_E = 5, - KeyCode_F = 6, - KeyCode_G = 7, - KeyCode_H = 8, - KeyCode_I = 9, - KeyCode_J = 10, - KeyCode_K = 11, - KeyCode_L = 12, - KeyCode_M = 13, - KeyCode_N = 14, - KeyCode_O = 15, - KeyCode_P = 16, - KeyCode_Q = 17, - KeyCode_R = 18, - KeyCode_S = 19, - KeyCode_T = 20, - KeyCode_U = 21, - KeyCode_V = 22, - KeyCode_W = 23, - KeyCode_X = 24, - KeyCode_Y = 25, - KeyCode_Z = 26, - KeyCode_0 = 27, - KeyCode_1 = 28, - KeyCode_2 = 29, - KeyCode_3 = 30, - KeyCode_4 = 31, - KeyCode_5 = 32, - KeyCode_6 = 33, - KeyCode_7 = 34, - KeyCode_8 = 35, - KeyCode_9 = 36, - KeyCode_Space = 37, - KeyCode_Tick = 38, - KeyCode_Minus = 39, - KeyCode_Equal = 40, - KeyCode_LeftBracket = 41, - KeyCode_RightBracket = 42, - KeyCode_Semicolon = 43, - KeyCode_Quote = 44, - KeyCode_Comma = 45, - KeyCode_Period = 46, - KeyCode_ForwardSlash = 47, - KeyCode_BackwardSlash = 48, - KeyCode_Tab = 49, - KeyCode_Escape = 50, - KeyCode_Pause = 51, - KeyCode_Up = 52, - KeyCode_Down = 53, - KeyCode_Left = 54, - KeyCode_Right = 55, - KeyCode_Backspace = 56, - KeyCode_Return = 57, - KeyCode_Delete = 58, - KeyCode_Insert = 59, - KeyCode_Home = 60, - KeyCode_End = 61, - KeyCode_PageUp = 62, - KeyCode_PageDown = 63, - KeyCode_CapsLock = 64, - KeyCode_NumLock = 65, - KeyCode_ScrollLock = 66, - KeyCode_Menu = 67, - KeyCode_Shift = 68, - KeyCode_Control = 69, - KeyCode_Alt = 70, - KeyCode_Command = 71, - KeyCode_F1 = 72, - KeyCode_F2 = 73, - KeyCode_F3 = 74, - KeyCode_F4 = 75, - KeyCode_F5 = 76, - KeyCode_F6 = 77, - KeyCode_F7 = 78, - KeyCode_F8 = 79, - KeyCode_F9 = 80, - KeyCode_F10 = 81, - KeyCode_F11 = 82, - KeyCode_F12 = 83, - KeyCode_F13 = 84, - KeyCode_F14 = 85, - KeyCode_F15 = 86, - KeyCode_F16 = 87, - KeyCode_COUNT = 88, +KeyCode_A = 1, +KeyCode_B = 2, +KeyCode_C = 3, +KeyCode_D = 4, +KeyCode_E = 5, +KeyCode_F = 6, +KeyCode_G = 7, +KeyCode_H = 8, +KeyCode_I = 9, +KeyCode_J = 10, +KeyCode_K = 11, +KeyCode_L = 12, +KeyCode_M = 13, +KeyCode_N = 14, +KeyCode_O = 15, +KeyCode_P = 16, +KeyCode_Q = 17, +KeyCode_R = 18, +KeyCode_S = 19, +KeyCode_T = 20, +KeyCode_U = 21, +KeyCode_V = 22, +KeyCode_W = 23, +KeyCode_X = 24, +KeyCode_Y = 25, +KeyCode_Z = 26, +KeyCode_0 = 27, +KeyCode_1 = 28, +KeyCode_2 = 29, +KeyCode_3 = 30, +KeyCode_4 = 31, +KeyCode_5 = 32, +KeyCode_6 = 33, +KeyCode_7 = 34, +KeyCode_8 = 35, +KeyCode_9 = 36, +KeyCode_Space = 37, +KeyCode_Tick = 38, +KeyCode_Minus = 39, +KeyCode_Equal = 40, +KeyCode_LeftBracket = 41, +KeyCode_RightBracket = 42, +KeyCode_Semicolon = 43, +KeyCode_Quote = 44, +KeyCode_Comma = 45, +KeyCode_Period = 46, +KeyCode_ForwardSlash = 47, +KeyCode_BackwardSlash = 48, +KeyCode_Tab = 49, +KeyCode_Escape = 50, +KeyCode_Pause = 51, +KeyCode_Up = 52, +KeyCode_Down = 53, +KeyCode_Left = 54, +KeyCode_Right = 55, +KeyCode_Backspace = 56, +KeyCode_Return = 57, +KeyCode_Delete = 58, +KeyCode_Insert = 59, +KeyCode_Home = 60, +KeyCode_End = 61, +KeyCode_PageUp = 62, +KeyCode_PageDown = 63, +KeyCode_CapsLock = 64, +KeyCode_NumLock = 65, +KeyCode_ScrollLock = 66, +KeyCode_Menu = 67, +KeyCode_Shift = 68, +KeyCode_Control = 69, +KeyCode_Alt = 70, +KeyCode_Command = 71, +KeyCode_F1 = 72, +KeyCode_F2 = 73, +KeyCode_F3 = 74, +KeyCode_F4 = 75, +KeyCode_F5 = 76, +KeyCode_F6 = 77, +KeyCode_F7 = 78, +KeyCode_F8 = 79, +KeyCode_F9 = 80, +KeyCode_F10 = 81, +KeyCode_F11 = 82, +KeyCode_F12 = 83, +KeyCode_F13 = 84, +KeyCode_F14 = 85, +KeyCode_F15 = 86, +KeyCode_F16 = 87, +KeyCode_COUNT = 88, }; global char* key_code_name[KeyCode_COUNT] = { - "None", - "A", - "B", - "C", - "D", - "E", - "F", - "G", - "H", - "I", - "J", - "K", - "L", - "M", - "N", - "O", - "P", - "Q", - "R", - "S", - "T", - "U", - "V", - "W", - "X", - "Y", - "Z", - "0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "Space", - "Tick", - "Minus", - "Equal", - "LeftBracket", - "RightBracket", - "Semicolon", - "Quote", - "Comma", - "Period", - "ForwardSlash", - "BackwardSlash", - "Tab", - "Escape", - "Pause", - "Up", - "Down", - "Left", - "Right", - "Backspace", - "Return", - "Delete", - "Insert", - "Home", - "End", - "PageUp", - "PageDown", - "CapsLock", - "NumLock", - "ScrollLock", - "Menu", - "Shift", - "Control", - "Alt", - "Command", - "F1", - "F2", - "F3", - "F4", - "F5", - "F6", - "F7", - "F8", - "F9", - "F10", - "F11", - "F12", - "F13", - "F14", - "F15", - "F16", +"None", +"A", +"B", +"C", +"D", +"E", +"F", +"G", +"H", +"I", +"J", +"K", +"L", +"M", +"N", +"O", +"P", +"Q", +"R", +"S", +"T", +"U", +"V", +"W", +"X", +"Y", +"Z", +"0", +"1", +"2", +"3", +"4", +"5", +"6", +"7", +"8", +"9", +"Space", +"Tick", +"Minus", +"Equal", +"LeftBracket", +"RightBracket", +"Semicolon", +"Quote", +"Comma", +"Period", +"ForwardSlash", +"BackwardSlash", +"Tab", +"Escape", +"Pause", +"Up", +"Down", +"Left", +"Right", +"Backspace", +"Return", +"Delete", +"Insert", +"Home", +"End", +"PageUp", +"PageDown", +"CapsLock", +"NumLock", +"ScrollLock", +"Menu", +"Shift", +"Control", +"Alt", +"Command", +"F1", +"F2", +"F3", +"F4", +"F5", +"F6", +"F7", +"F8", +"F9", +"F10", +"F11", +"F12", +"F13", +"F14", +"F15", +"F16", }; enum{ - MouseCode_Left = 1, - MouseCode_Middle = 2, - MouseCode_Right = 3, - MouseCode_COUNT = 4, +MouseCode_Left = 1, +MouseCode_Middle = 2, +MouseCode_Right = 3, +MouseCode_COUNT = 4, }; global char* mouse_code_name[MouseCode_COUNT] = { - "None", - "Left", - "Middle", - "Right", +"None", +"Left", +"Middle", +"Right", }; enum{ - CoreCode_Animate = 1, - CoreCode_ClickActivateView = 2, - CoreCode_ClickDeactivateView = 3, - CoreCode_COUNT = 4, +CoreCode_Startup = 1, +CoreCode_Animate = 2, +CoreCode_ClickActivateView = 3, +CoreCode_ClickDeactivateView = 4, +CoreCode_TryExit = 5, +CoreCode_FileExternallyModified = 6, +CoreCode_NewClipboardContents = 7, +CoreCode_COUNT = 8, }; global char* core_code_name[CoreCode_COUNT] = { - "None", - "Animate", - "ClickActivateView", - "ClickDeactivateView", +"None", +"Startup", +"Animate", +"ClickActivateView", +"ClickDeactivateView", +"TryExit", +"FileExternallyModified", +"NewClipboardContents", }; diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index f535b684..bb235c3b 100644 --- a/custom/generated/command_metadata.h +++ b/custom/generated/command_metadata.h @@ -2,7 +2,7 @@ #define command_id(c) (fcoder_metacmd_ID_##c) #define command_metadata(c) (&fcoder_metacmd_table[command_id(c)]) #define command_metadata_by_id(id) (&fcoder_metacmd_table[id]) -#define command_one_past_last_id 202 +#define command_one_past_last_id 205 #if defined(CUSTOM_COMMAND_SIG) #define PROC_LINKS(x,y) x #else @@ -126,6 +126,7 @@ CUSTOM_COMMAND_SIG(redo); CUSTOM_COMMAND_SIG(undo_all_buffers); CUSTOM_COMMAND_SIG(redo_all_buffers); CUSTOM_COMMAND_SIG(open_in_other); +CUSTOM_COMMAND_SIG(default_file_externally_modified); CUSTOM_COMMAND_SIG(interactive_switch_buffer); CUSTOM_COMMAND_SIG(interactive_kill_buffer); CUSTOM_COMMAND_SIG(interactive_open_or_new); @@ -211,6 +212,8 @@ CUSTOM_COMMAND_SIG(miblo_increment_time_stamp); CUSTOM_COMMAND_SIG(miblo_decrement_time_stamp); CUSTOM_COMMAND_SIG(miblo_increment_time_stamp_minute); CUSTOM_COMMAND_SIG(miblo_decrement_time_stamp_minute); +CUSTOM_COMMAND_SIG(default_startup); +CUSTOM_COMMAND_SIG(default_try_exit); #endif struct Command_Metadata{ PROC_LINKS(Custom_Command_Function, void) *proc; @@ -222,14 +225,14 @@ char *source_name; i32 source_name_len; i32 line_number; }; -static Command_Metadata fcoder_metacmd_table[202] = { -{ PROC_LINKS(default_view_input_handler, 0), "default_view_input_handler", 26, "Input consumption loop for base view behavior", 45, "w:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 17 }, -{ PROC_LINKS(seek_beginning_of_textual_line, 0), "seek_beginning_of_textual_line", 30, "Seeks the cursor to the beginning of the line across all text.", 62, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1976 }, -{ PROC_LINKS(seek_end_of_textual_line, 0), "seek_end_of_textual_line", 24, "Seeks the cursor to the end of the line across all text.", 56, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1982 }, -{ PROC_LINKS(seek_beginning_of_line, 0), "seek_beginning_of_line", 22, "Seeks the cursor to the beginning of the visual line.", 53, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1988 }, -{ PROC_LINKS(seek_end_of_line, 0), "seek_end_of_line", 16, "Seeks the cursor to the end of the visual line.", 47, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1994 }, -{ PROC_LINKS(goto_beginning_of_file, 0), "goto_beginning_of_file", 22, "Sets the cursor to the beginning of the file.", 45, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2000 }, -{ PROC_LINKS(goto_end_of_file, 0), "goto_end_of_file", 16, "Sets the cursor to the end of the file.", 39, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2008 }, +static Command_Metadata fcoder_metacmd_table[205] = { +{ PROC_LINKS(default_view_input_handler, 0), "default_view_input_handler", 26, "Input consumption loop for default view behavior", 48, "w:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 56 }, +{ PROC_LINKS(seek_beginning_of_textual_line, 0), "seek_beginning_of_textual_line", 30, "Seeks the cursor to the beginning of the line across all text.", 62, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1979 }, +{ PROC_LINKS(seek_end_of_textual_line, 0), "seek_end_of_textual_line", 24, "Seeks the cursor to the end of the line across all text.", 56, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1985 }, +{ PROC_LINKS(seek_beginning_of_line, 0), "seek_beginning_of_line", 22, "Seeks the cursor to the beginning of the visual line.", 53, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1991 }, +{ PROC_LINKS(seek_end_of_line, 0), "seek_end_of_line", 16, "Seeks the cursor to the end of the visual line.", 47, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1997 }, +{ PROC_LINKS(goto_beginning_of_file, 0), "goto_beginning_of_file", 22, "Sets the cursor to the beginning of the file.", 45, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2003 }, +{ PROC_LINKS(goto_end_of_file, 0), "goto_end_of_file", 16, "Sets the cursor to the end of the file.", 39, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2011 }, { PROC_LINKS(change_active_panel, 0), "change_active_panel", 19, "Change the currently active panel, moving to the panel with the next highest view_id.", 85, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 196 }, { PROC_LINKS(change_active_panel_backwards, 0), "change_active_panel_backwards", 29, "Change the currently active panel, moving to the panel with the next lowest view_id.", 84, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 206 }, { PROC_LINKS(open_panel_vsplit, 0), "open_panel_vsplit", 17, "Create a new panel by vertically splitting the active panel.", 60, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 216 }, @@ -309,43 +312,44 @@ static Command_Metadata fcoder_metacmd_table[202] = { { PROC_LINKS(eol_nixify, 0), "eol_nixify", 10, "Puts the buffer in NIX line ending mode.", 40, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 749 }, { PROC_LINKS(exit_4coder, 0), "exit_4coder", 11, "Attempts to close 4coder.", 25, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 757 }, { PROC_LINKS(goto_line, 0), "goto_line", 9, "Queries the user for a number, and jumps the cursor to the corresponding line.", 78, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 765 }, -{ PROC_LINKS(search, 0), "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 994 }, -{ PROC_LINKS(reverse_search, 0), "reverse_search", 14, "Begins an incremental search up through the current buffer for a user specified string.", 87, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1000 }, -{ PROC_LINKS(search_identifier, 0), "search_identifier", 17, "Begins an incremental search down through the current buffer for the word or token under the cursor.", 100, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1006 }, -{ PROC_LINKS(reverse_search_identifier, 0), "reverse_search_identifier", 25, "Begins an incremental search up through the current buffer for the word or token under the cursor.", 98, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1012 }, -{ PROC_LINKS(replace_in_range, 0), "replace_in_range", 16, "Queries the user for a needle and string. Replaces all occurences of needle with string in the range between cursor and the mark in the active buffer.", 150, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1059 }, -{ PROC_LINKS(replace_in_buffer, 0), "replace_in_buffer", 17, "Queries the user for a needle and string. Replaces all occurences of needle with string in the active buffer.", 109, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1068 }, -{ PROC_LINKS(replace_in_all_buffers, 0), "replace_in_all_buffers", 22, "Queries the user for a needle and string. Replaces all occurences of needle with string in all editable buffers.", 112, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1077 }, -{ PROC_LINKS(query_replace, 0), "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1167 }, -{ PROC_LINKS(query_replace_identifier, 0), "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1188 }, -{ PROC_LINKS(query_replace_selection, 0), "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1204 }, -{ PROC_LINKS(save_all_dirty_buffers, 0), "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1239 }, -{ PROC_LINKS(delete_file_query, 0), "delete_file_query", 17, "Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.", 125, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1264 }, -{ PROC_LINKS(save_to_query, 0), "save_to_query", 13, "Queries the user for a file name and saves the contents of the current buffer, altering the buffer's name too.", 110, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1308 }, -{ PROC_LINKS(rename_file_query, 0), "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1341 }, -{ PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1379 }, -{ PROC_LINKS(move_line_up, 0), "move_line_up", 12, "Swaps the line under the cursor with the line above it, and moves the cursor up with it.", 88, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1413 }, -{ PROC_LINKS(move_line_down, 0), "move_line_down", 14, "Swaps the line under the cursor with the line below it, and moves the cursor down with it.", 90, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1419 }, -{ PROC_LINKS(duplicate_line, 0), "duplicate_line", 14, "Create a copy of the line on which the cursor sits.", 51, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1425 }, -{ PROC_LINKS(delete_line, 0), "delete_line", 11, "Delete the line the on which the cursor sits.", 45, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1439 }, -{ PROC_LINKS(open_file_in_quotes, 0), "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1504 }, -{ PROC_LINKS(open_matching_file_cpp, 0), "open_matching_file_cpp", 22, "If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.", 110, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1536 }, -{ PROC_LINKS(view_buffer_other_panel, 0), "view_buffer_other_panel", 23, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1549 }, -{ PROC_LINKS(swap_buffers_between_panels, 0), "swap_buffers_between_panels", 27, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1561 }, -{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1595 }, -{ PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1603 }, -{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1613 }, -{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history of the current buffer.", 66, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1842 }, -{ PROC_LINKS(redo, 0), "redo", 4, "Advances forwards through the undo history of the current buffer.", 65, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1855 }, -{ PROC_LINKS(undo_all_buffers, 0), "undo_all_buffers", 16, "Advances backward through the undo history in the buffer containing the most recent regular edit.", 97, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1869 }, -{ PROC_LINKS(redo_all_buffers, 0), "redo_all_buffers", 16, "Advances forward through the undo history in the buffer containing the most recent regular edit.", 96, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1940 }, -{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2041 }, -{ PROC_LINKS(interactive_switch_buffer, 0), "interactive_switch_buffer", 25, "Interactively switch to an open buffer.", 39, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 537 }, -{ PROC_LINKS(interactive_kill_buffer, 0), "interactive_kill_buffer", 23, "Interactively kill an open buffer.", 34, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 556 }, -{ PROC_LINKS(interactive_open_or_new, 0), "interactive_open_or_new", 23, "Interactively open a file out of the file system.", 49, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 627 }, -{ PROC_LINKS(interactive_new, 0), "interactive_new", 15, "Interactively creates a new file.", 33, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 666 }, -{ PROC_LINKS(interactive_open, 0), "interactive_open", 16, "Interactively opens a file.", 27, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 699 }, -{ PROC_LINKS(command_lister, 0), "command_lister", 14, "Opens an interactive list of all registered commands.", 53, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 759 }, +{ PROC_LINKS(search, 0), "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 993 }, +{ PROC_LINKS(reverse_search, 0), "reverse_search", 14, "Begins an incremental search up through the current buffer for a user specified string.", 87, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 999 }, +{ PROC_LINKS(search_identifier, 0), "search_identifier", 17, "Begins an incremental search down through the current buffer for the word or token under the cursor.", 100, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1005 }, +{ PROC_LINKS(reverse_search_identifier, 0), "reverse_search_identifier", 25, "Begins an incremental search up through the current buffer for the word or token under the cursor.", 98, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1011 }, +{ PROC_LINKS(replace_in_range, 0), "replace_in_range", 16, "Queries the user for a needle and string. Replaces all occurences of needle with string in the range between cursor and the mark in the active buffer.", 150, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1058 }, +{ PROC_LINKS(replace_in_buffer, 0), "replace_in_buffer", 17, "Queries the user for a needle and string. Replaces all occurences of needle with string in the active buffer.", 109, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1067 }, +{ PROC_LINKS(replace_in_all_buffers, 0), "replace_in_all_buffers", 22, "Queries the user for a needle and string. Replaces all occurences of needle with string in all editable buffers.", 112, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1076 }, +{ PROC_LINKS(query_replace, 0), "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1166 }, +{ PROC_LINKS(query_replace_identifier, 0), "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1187 }, +{ PROC_LINKS(query_replace_selection, 0), "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1203 }, +{ PROC_LINKS(save_all_dirty_buffers, 0), "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1238 }, +{ PROC_LINKS(delete_file_query, 0), "delete_file_query", 17, "Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.", 125, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1263 }, +{ PROC_LINKS(save_to_query, 0), "save_to_query", 13, "Queries the user for a file name and saves the contents of the current buffer, altering the buffer's name too.", 110, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1307 }, +{ PROC_LINKS(rename_file_query, 0), "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1340 }, +{ PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1378 }, +{ PROC_LINKS(move_line_up, 0), "move_line_up", 12, "Swaps the line under the cursor with the line above it, and moves the cursor up with it.", 88, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1412 }, +{ PROC_LINKS(move_line_down, 0), "move_line_down", 14, "Swaps the line under the cursor with the line below it, and moves the cursor down with it.", 90, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1418 }, +{ PROC_LINKS(duplicate_line, 0), "duplicate_line", 14, "Create a copy of the line on which the cursor sits.", 51, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1424 }, +{ PROC_LINKS(delete_line, 0), "delete_line", 11, "Delete the line the on which the cursor sits.", 45, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1438 }, +{ PROC_LINKS(open_file_in_quotes, 0), "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1503 }, +{ PROC_LINKS(open_matching_file_cpp, 0), "open_matching_file_cpp", 22, "If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.", 110, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1535 }, +{ PROC_LINKS(view_buffer_other_panel, 0), "view_buffer_other_panel", 23, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1548 }, +{ PROC_LINKS(swap_buffers_between_panels, 0), "swap_buffers_between_panels", 27, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1560 }, +{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1594 }, +{ PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1602 }, +{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1612 }, +{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history of the current buffer.", 66, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1841 }, +{ PROC_LINKS(redo, 0), "redo", 4, "Advances forwards through the undo history of the current buffer.", 65, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1854 }, +{ PROC_LINKS(undo_all_buffers, 0), "undo_all_buffers", 16, "Advances backward through the undo history in the buffer containing the most recent regular edit.", 97, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1868 }, +{ PROC_LINKS(redo_all_buffers, 0), "redo_all_buffers", 16, "Advances forward through the undo history in the buffer containing the most recent regular edit.", 96, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1939 }, +{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2040 }, +{ PROC_LINKS(default_file_externally_modified, 0), "default_file_externally_modified", 32, "Notes the external modification of attached files by printing a message.", 72, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2047 }, +{ PROC_LINKS(interactive_switch_buffer, 0), "interactive_switch_buffer", 25, "Interactively switch to an open buffer.", 39, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 552 }, +{ PROC_LINKS(interactive_kill_buffer, 0), "interactive_kill_buffer", 23, "Interactively kill an open buffer.", 34, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 571 }, +{ PROC_LINKS(interactive_open_or_new, 0), "interactive_open_or_new", 23, "Interactively open a file out of the file system.", 49, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 642 }, +{ PROC_LINKS(interactive_new, 0), "interactive_new", 15, "Interactively creates a new file.", 33, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 681 }, +{ PROC_LINKS(interactive_open, 0), "interactive_open", 16, "Interactively opens a file.", 27, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 714 }, +{ PROC_LINKS(command_lister, 0), "command_lister", 14, "Opens an interactive list of all registered commands.", 53, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 774 }, { PROC_LINKS(auto_indent_whole_file, 0), "auto_indent_whole_file", 22, "Audo-indents the entire current buffer.", 39, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 356 }, { PROC_LINKS(auto_indent_line_at_cursor, 0), "auto_indent_line_at_cursor", 26, "Auto-indents the line on which the cursor sits.", 47, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 365 }, { PROC_LINKS(auto_indent_range, 0), "auto_indent_range", 17, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 375 }, @@ -425,6 +429,8 @@ static Command_Metadata fcoder_metacmd_table[202] = { { PROC_LINKS(miblo_decrement_time_stamp, 0), "miblo_decrement_time_stamp", 26, "Decrement a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 237 }, { PROC_LINKS(miblo_increment_time_stamp_minute, 0), "miblo_increment_time_stamp_minute", 33, "Increment a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 243 }, { PROC_LINKS(miblo_decrement_time_stamp_minute, 0), "miblo_decrement_time_stamp_minute", 33, "Decrement a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 249 }, +{ PROC_LINKS(default_startup, 0), "default_startup", 15, "Default command for responding to a startup event", 49, "w:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 7 }, +{ PROC_LINKS(default_try_exit, 0), "default_try_exit", 16, "Default command for responding to a try-exit event", 50, "w:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 21 }, }; static i32 fcoder_metacmd_ID_default_view_input_handler = 0; static i32 fcoder_metacmd_ID_seek_beginning_of_textual_line = 1; @@ -543,89 +549,92 @@ static i32 fcoder_metacmd_ID_redo = 113; static i32 fcoder_metacmd_ID_undo_all_buffers = 114; static i32 fcoder_metacmd_ID_redo_all_buffers = 115; static i32 fcoder_metacmd_ID_open_in_other = 116; -static i32 fcoder_metacmd_ID_interactive_switch_buffer = 117; -static i32 fcoder_metacmd_ID_interactive_kill_buffer = 118; -static i32 fcoder_metacmd_ID_interactive_open_or_new = 119; -static i32 fcoder_metacmd_ID_interactive_new = 120; -static i32 fcoder_metacmd_ID_interactive_open = 121; -static i32 fcoder_metacmd_ID_command_lister = 122; -static i32 fcoder_metacmd_ID_auto_indent_whole_file = 123; -static i32 fcoder_metacmd_ID_auto_indent_line_at_cursor = 124; -static i32 fcoder_metacmd_ID_auto_indent_range = 125; -static i32 fcoder_metacmd_ID_write_text_and_auto_indent = 126; -static i32 fcoder_metacmd_ID_list_all_locations = 127; -static i32 fcoder_metacmd_ID_list_all_substring_locations = 128; -static i32 fcoder_metacmd_ID_list_all_locations_case_insensitive = 129; -static i32 fcoder_metacmd_ID_list_all_substring_locations_case_insensitive = 130; -static i32 fcoder_metacmd_ID_list_all_locations_of_identifier = 131; -static i32 fcoder_metacmd_ID_list_all_locations_of_identifier_case_insensitive = 132; -static i32 fcoder_metacmd_ID_list_all_locations_of_selection = 133; -static i32 fcoder_metacmd_ID_list_all_locations_of_selection_case_insensitive = 134; -static i32 fcoder_metacmd_ID_list_all_locations_of_type_definition = 135; -static i32 fcoder_metacmd_ID_list_all_locations_of_type_definition_of_identifier = 136; -static i32 fcoder_metacmd_ID_word_complete = 137; -static i32 fcoder_metacmd_ID_goto_jump_at_cursor = 138; -static i32 fcoder_metacmd_ID_goto_jump_at_cursor_same_panel = 139; -static i32 fcoder_metacmd_ID_goto_next_jump = 140; -static i32 fcoder_metacmd_ID_goto_prev_jump = 141; -static i32 fcoder_metacmd_ID_goto_next_jump_no_skips = 142; -static i32 fcoder_metacmd_ID_goto_prev_jump_no_skips = 143; -static i32 fcoder_metacmd_ID_goto_first_jump = 144; -static i32 fcoder_metacmd_ID_goto_first_jump_same_panel_sticky = 145; -static i32 fcoder_metacmd_ID_if_read_only_goto_position = 146; -static i32 fcoder_metacmd_ID_if_read_only_goto_position_same_panel = 147; -static i32 fcoder_metacmd_ID_view_jump_list_with_lister = 148; -static i32 fcoder_metacmd_ID_show_the_log_graph = 149; -static i32 fcoder_metacmd_ID_copy = 150; -static i32 fcoder_metacmd_ID_cut = 151; -static i32 fcoder_metacmd_ID_paste = 152; -static i32 fcoder_metacmd_ID_paste_next = 153; -static i32 fcoder_metacmd_ID_paste_and_indent = 154; -static i32 fcoder_metacmd_ID_paste_next_and_indent = 155; -static i32 fcoder_metacmd_ID_execute_previous_cli = 156; -static i32 fcoder_metacmd_ID_execute_any_cli = 157; -static i32 fcoder_metacmd_ID_build_search = 158; -static i32 fcoder_metacmd_ID_build_in_build_panel = 159; -static i32 fcoder_metacmd_ID_close_build_panel = 160; -static i32 fcoder_metacmd_ID_change_to_build_panel = 161; -static i32 fcoder_metacmd_ID_close_all_code = 162; -static i32 fcoder_metacmd_ID_open_all_code = 163; -static i32 fcoder_metacmd_ID_open_all_code_recursive = 164; -static i32 fcoder_metacmd_ID_load_project = 165; -static i32 fcoder_metacmd_ID_project_fkey_command = 166; -static i32 fcoder_metacmd_ID_project_go_to_root_directory = 167; -static i32 fcoder_metacmd_ID_setup_new_project = 168; -static i32 fcoder_metacmd_ID_setup_build_bat = 169; -static i32 fcoder_metacmd_ID_setup_build_sh = 170; -static i32 fcoder_metacmd_ID_setup_build_bat_and_sh = 171; -static i32 fcoder_metacmd_ID_project_command_lister = 172; -static i32 fcoder_metacmd_ID_list_all_functions_current_buffer = 173; -static i32 fcoder_metacmd_ID_list_all_functions_current_buffer_lister = 174; -static i32 fcoder_metacmd_ID_list_all_functions_all_buffers = 175; -static i32 fcoder_metacmd_ID_list_all_functions_all_buffers_lister = 176; -static i32 fcoder_metacmd_ID_select_surrounding_scope = 177; -static i32 fcoder_metacmd_ID_select_next_scope_absolute = 178; -static i32 fcoder_metacmd_ID_select_next_scope_after_current = 179; -static i32 fcoder_metacmd_ID_select_prev_scope_absolute = 180; -static i32 fcoder_metacmd_ID_place_in_scope = 181; -static i32 fcoder_metacmd_ID_delete_current_scope = 182; -static i32 fcoder_metacmd_ID_open_long_braces = 183; -static i32 fcoder_metacmd_ID_open_long_braces_semicolon = 184; -static i32 fcoder_metacmd_ID_open_long_braces_break = 185; -static i32 fcoder_metacmd_ID_if0_off = 186; -static i32 fcoder_metacmd_ID_write_todo = 187; -static i32 fcoder_metacmd_ID_write_hack = 188; -static i32 fcoder_metacmd_ID_write_note = 189; -static i32 fcoder_metacmd_ID_write_block = 190; -static i32 fcoder_metacmd_ID_write_zero_struct = 191; -static i32 fcoder_metacmd_ID_comment_line = 192; -static i32 fcoder_metacmd_ID_uncomment_line = 193; -static i32 fcoder_metacmd_ID_comment_line_toggle = 194; -static i32 fcoder_metacmd_ID_snippet_lister = 195; -static i32 fcoder_metacmd_ID_miblo_increment_basic = 196; -static i32 fcoder_metacmd_ID_miblo_decrement_basic = 197; -static i32 fcoder_metacmd_ID_miblo_increment_time_stamp = 198; -static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp = 199; -static i32 fcoder_metacmd_ID_miblo_increment_time_stamp_minute = 200; -static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp_minute = 201; +static i32 fcoder_metacmd_ID_default_file_externally_modified = 117; +static i32 fcoder_metacmd_ID_interactive_switch_buffer = 118; +static i32 fcoder_metacmd_ID_interactive_kill_buffer = 119; +static i32 fcoder_metacmd_ID_interactive_open_or_new = 120; +static i32 fcoder_metacmd_ID_interactive_new = 121; +static i32 fcoder_metacmd_ID_interactive_open = 122; +static i32 fcoder_metacmd_ID_command_lister = 123; +static i32 fcoder_metacmd_ID_auto_indent_whole_file = 124; +static i32 fcoder_metacmd_ID_auto_indent_line_at_cursor = 125; +static i32 fcoder_metacmd_ID_auto_indent_range = 126; +static i32 fcoder_metacmd_ID_write_text_and_auto_indent = 127; +static i32 fcoder_metacmd_ID_list_all_locations = 128; +static i32 fcoder_metacmd_ID_list_all_substring_locations = 129; +static i32 fcoder_metacmd_ID_list_all_locations_case_insensitive = 130; +static i32 fcoder_metacmd_ID_list_all_substring_locations_case_insensitive = 131; +static i32 fcoder_metacmd_ID_list_all_locations_of_identifier = 132; +static i32 fcoder_metacmd_ID_list_all_locations_of_identifier_case_insensitive = 133; +static i32 fcoder_metacmd_ID_list_all_locations_of_selection = 134; +static i32 fcoder_metacmd_ID_list_all_locations_of_selection_case_insensitive = 135; +static i32 fcoder_metacmd_ID_list_all_locations_of_type_definition = 136; +static i32 fcoder_metacmd_ID_list_all_locations_of_type_definition_of_identifier = 137; +static i32 fcoder_metacmd_ID_word_complete = 138; +static i32 fcoder_metacmd_ID_goto_jump_at_cursor = 139; +static i32 fcoder_metacmd_ID_goto_jump_at_cursor_same_panel = 140; +static i32 fcoder_metacmd_ID_goto_next_jump = 141; +static i32 fcoder_metacmd_ID_goto_prev_jump = 142; +static i32 fcoder_metacmd_ID_goto_next_jump_no_skips = 143; +static i32 fcoder_metacmd_ID_goto_prev_jump_no_skips = 144; +static i32 fcoder_metacmd_ID_goto_first_jump = 145; +static i32 fcoder_metacmd_ID_goto_first_jump_same_panel_sticky = 146; +static i32 fcoder_metacmd_ID_if_read_only_goto_position = 147; +static i32 fcoder_metacmd_ID_if_read_only_goto_position_same_panel = 148; +static i32 fcoder_metacmd_ID_view_jump_list_with_lister = 149; +static i32 fcoder_metacmd_ID_show_the_log_graph = 150; +static i32 fcoder_metacmd_ID_copy = 151; +static i32 fcoder_metacmd_ID_cut = 152; +static i32 fcoder_metacmd_ID_paste = 153; +static i32 fcoder_metacmd_ID_paste_next = 154; +static i32 fcoder_metacmd_ID_paste_and_indent = 155; +static i32 fcoder_metacmd_ID_paste_next_and_indent = 156; +static i32 fcoder_metacmd_ID_execute_previous_cli = 157; +static i32 fcoder_metacmd_ID_execute_any_cli = 158; +static i32 fcoder_metacmd_ID_build_search = 159; +static i32 fcoder_metacmd_ID_build_in_build_panel = 160; +static i32 fcoder_metacmd_ID_close_build_panel = 161; +static i32 fcoder_metacmd_ID_change_to_build_panel = 162; +static i32 fcoder_metacmd_ID_close_all_code = 163; +static i32 fcoder_metacmd_ID_open_all_code = 164; +static i32 fcoder_metacmd_ID_open_all_code_recursive = 165; +static i32 fcoder_metacmd_ID_load_project = 166; +static i32 fcoder_metacmd_ID_project_fkey_command = 167; +static i32 fcoder_metacmd_ID_project_go_to_root_directory = 168; +static i32 fcoder_metacmd_ID_setup_new_project = 169; +static i32 fcoder_metacmd_ID_setup_build_bat = 170; +static i32 fcoder_metacmd_ID_setup_build_sh = 171; +static i32 fcoder_metacmd_ID_setup_build_bat_and_sh = 172; +static i32 fcoder_metacmd_ID_project_command_lister = 173; +static i32 fcoder_metacmd_ID_list_all_functions_current_buffer = 174; +static i32 fcoder_metacmd_ID_list_all_functions_current_buffer_lister = 175; +static i32 fcoder_metacmd_ID_list_all_functions_all_buffers = 176; +static i32 fcoder_metacmd_ID_list_all_functions_all_buffers_lister = 177; +static i32 fcoder_metacmd_ID_select_surrounding_scope = 178; +static i32 fcoder_metacmd_ID_select_next_scope_absolute = 179; +static i32 fcoder_metacmd_ID_select_next_scope_after_current = 180; +static i32 fcoder_metacmd_ID_select_prev_scope_absolute = 181; +static i32 fcoder_metacmd_ID_place_in_scope = 182; +static i32 fcoder_metacmd_ID_delete_current_scope = 183; +static i32 fcoder_metacmd_ID_open_long_braces = 184; +static i32 fcoder_metacmd_ID_open_long_braces_semicolon = 185; +static i32 fcoder_metacmd_ID_open_long_braces_break = 186; +static i32 fcoder_metacmd_ID_if0_off = 187; +static i32 fcoder_metacmd_ID_write_todo = 188; +static i32 fcoder_metacmd_ID_write_hack = 189; +static i32 fcoder_metacmd_ID_write_note = 190; +static i32 fcoder_metacmd_ID_write_block = 191; +static i32 fcoder_metacmd_ID_write_zero_struct = 192; +static i32 fcoder_metacmd_ID_comment_line = 193; +static i32 fcoder_metacmd_ID_uncomment_line = 194; +static i32 fcoder_metacmd_ID_comment_line_toggle = 195; +static i32 fcoder_metacmd_ID_snippet_lister = 196; +static i32 fcoder_metacmd_ID_miblo_increment_basic = 197; +static i32 fcoder_metacmd_ID_miblo_decrement_basic = 198; +static i32 fcoder_metacmd_ID_miblo_increment_time_stamp = 199; +static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp = 200; +static i32 fcoder_metacmd_ID_miblo_increment_time_stamp_minute = 201; +static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp_minute = 202; +static i32 fcoder_metacmd_ID_default_startup = 203; +static i32 fcoder_metacmd_ID_default_try_exit = 204; #endif diff --git a/custom/generated/custom_api.cpp b/custom/generated/custom_api.cpp index e7c96a09..14d90ba4 100644 --- a/custom/generated/custom_api.cpp +++ b/custom/generated/custom_api.cpp @@ -111,10 +111,11 @@ vtable->managed_object_get_containing_scope = managed_object_get_containing_scop vtable->managed_object_free = managed_object_free; vtable->managed_object_store_data = managed_object_store_data; vtable->managed_object_load_data = managed_object_load_data; -vtable->get_user_input = get_user_input; -vtable->get_command_input = get_command_input; -vtable->set_command_input = set_command_input; -vtable->leave_command_input_unhandled = leave_command_input_unhandled; +vtable->get_next_input = get_next_input; +vtable->get_current_input_sequence_number = get_current_input_sequence_number; +vtable->get_current_input = get_current_input; +vtable->set_current_input = set_current_input; +vtable->leave_current_input_unhandled = leave_current_input_unhandled; vtable->set_custom_hook = set_custom_hook; vtable->get_mouse_state = get_mouse_state; vtable->get_active_query_bars = get_active_query_bars; @@ -282,10 +283,11 @@ managed_object_get_containing_scope = vtable->managed_object_get_containing_scop managed_object_free = vtable->managed_object_free; managed_object_store_data = vtable->managed_object_store_data; managed_object_load_data = vtable->managed_object_load_data; -get_user_input = vtable->get_user_input; -get_command_input = vtable->get_command_input; -set_command_input = vtable->set_command_input; -leave_command_input_unhandled = vtable->leave_command_input_unhandled; +get_next_input = vtable->get_next_input; +get_current_input_sequence_number = vtable->get_current_input_sequence_number; +get_current_input = vtable->get_current_input; +set_current_input = vtable->set_current_input; +leave_current_input_unhandled = vtable->leave_current_input_unhandled; set_custom_hook = vtable->set_custom_hook; get_mouse_state = vtable->get_mouse_state; get_active_query_bars = vtable->get_active_query_bars; diff --git a/custom/generated/custom_api.h b/custom/generated/custom_api.h index 867e486f..5ce998cc 100644 --- a/custom/generated/custom_api.h +++ b/custom/generated/custom_api.h @@ -109,10 +109,11 @@ #define custom_managed_object_free_sig() b32 custom_managed_object_free(Application_Links* app, Managed_Object object) #define custom_managed_object_store_data_sig() b32 custom_managed_object_store_data(Application_Links* app, Managed_Object object, u32 first_index, u32 count, void* mem) #define custom_managed_object_load_data_sig() b32 custom_managed_object_load_data(Application_Links* app, Managed_Object object, u32 first_index, u32 count, void* mem_out) -#define custom_get_user_input_sig() User_Input custom_get_user_input(Application_Links* app, Event_Property get_properties, Event_Property abort_properties) -#define custom_get_command_input_sig() User_Input custom_get_command_input(Application_Links* app) -#define custom_set_command_input_sig() void custom_set_command_input(Application_Links* app, Input_Event* event) -#define custom_leave_command_input_unhandled_sig() void custom_leave_command_input_unhandled(Application_Links* app) +#define custom_get_next_input_sig() User_Input custom_get_next_input(Application_Links* app, Event_Property get_properties, Event_Property abort_properties) +#define custom_get_current_input_sequence_number_sig() i64 custom_get_current_input_sequence_number(Application_Links* app) +#define custom_get_current_input_sig() User_Input custom_get_current_input(Application_Links* app) +#define custom_set_current_input_sig() void custom_set_current_input(Application_Links* app, User_Input* input) +#define custom_leave_current_input_unhandled_sig() void custom_leave_current_input_unhandled(Application_Links* app) #define custom_set_custom_hook_sig() void custom_set_custom_hook(Application_Links* app, Hook_ID hook_id, Void_Func* func_ptr) #define custom_get_mouse_state_sig() Mouse_State custom_get_mouse_state(Application_Links* app) #define custom_get_active_query_bars_sig() b32 custom_get_active_query_bars(Application_Links* app, View_ID view_id, i32 max_result_count, Query_Bar_Ptr_Array* array_out) @@ -276,10 +277,11 @@ typedef Managed_Scope custom_managed_object_get_containing_scope_type(Applicatio typedef b32 custom_managed_object_free_type(Application_Links* app, Managed_Object object); typedef b32 custom_managed_object_store_data_type(Application_Links* app, Managed_Object object, u32 first_index, u32 count, void* mem); typedef b32 custom_managed_object_load_data_type(Application_Links* app, Managed_Object object, u32 first_index, u32 count, void* mem_out); -typedef User_Input custom_get_user_input_type(Application_Links* app, Event_Property get_properties, Event_Property abort_properties); -typedef User_Input custom_get_command_input_type(Application_Links* app); -typedef void custom_set_command_input_type(Application_Links* app, Input_Event* event); -typedef void custom_leave_command_input_unhandled_type(Application_Links* app); +typedef User_Input custom_get_next_input_type(Application_Links* app, Event_Property get_properties, Event_Property abort_properties); +typedef i64 custom_get_current_input_sequence_number_type(Application_Links* app); +typedef User_Input custom_get_current_input_type(Application_Links* app); +typedef void custom_set_current_input_type(Application_Links* app, User_Input* input); +typedef void custom_leave_current_input_unhandled_type(Application_Links* app); typedef void custom_set_custom_hook_type(Application_Links* app, Hook_ID hook_id, Void_Func* func_ptr); typedef Mouse_State custom_get_mouse_state_type(Application_Links* app); typedef b32 custom_get_active_query_bars_type(Application_Links* app, View_ID view_id, i32 max_result_count, Query_Bar_Ptr_Array* array_out); @@ -444,10 +446,11 @@ custom_managed_object_get_containing_scope_type *managed_object_get_containing_s custom_managed_object_free_type *managed_object_free; custom_managed_object_store_data_type *managed_object_store_data; custom_managed_object_load_data_type *managed_object_load_data; -custom_get_user_input_type *get_user_input; -custom_get_command_input_type *get_command_input; -custom_set_command_input_type *set_command_input; -custom_leave_command_input_unhandled_type *leave_command_input_unhandled; +custom_get_next_input_type *get_next_input; +custom_get_current_input_sequence_number_type *get_current_input_sequence_number; +custom_get_current_input_type *get_current_input; +custom_set_current_input_type *set_current_input; +custom_leave_current_input_unhandled_type *leave_current_input_unhandled; custom_set_custom_hook_type *set_custom_hook; custom_get_mouse_state_type *get_mouse_state; custom_get_active_query_bars_type *get_active_query_bars; @@ -613,10 +616,11 @@ internal Managed_Scope managed_object_get_containing_scope(Application_Links* ap internal b32 managed_object_free(Application_Links* app, Managed_Object object); internal b32 managed_object_store_data(Application_Links* app, Managed_Object object, u32 first_index, u32 count, void* mem); internal b32 managed_object_load_data(Application_Links* app, Managed_Object object, u32 first_index, u32 count, void* mem_out); -internal User_Input get_user_input(Application_Links* app, Event_Property get_properties, Event_Property abort_properties); -internal User_Input get_command_input(Application_Links* app); -internal void set_command_input(Application_Links* app, Input_Event* event); -internal void leave_command_input_unhandled(Application_Links* app); +internal User_Input get_next_input(Application_Links* app, Event_Property get_properties, Event_Property abort_properties); +internal i64 get_current_input_sequence_number(Application_Links* app); +internal User_Input get_current_input(Application_Links* app); +internal void set_current_input(Application_Links* app, User_Input* input); +internal void leave_current_input_unhandled(Application_Links* app); internal void set_custom_hook(Application_Links* app, Hook_ID hook_id, Void_Func* func_ptr); internal Mouse_State get_mouse_state(Application_Links* app); internal b32 get_active_query_bars(Application_Links* app, View_ID view_id, i32 max_result_count, Query_Bar_Ptr_Array* array_out); @@ -782,10 +786,11 @@ global custom_managed_object_get_containing_scope_type *managed_object_get_conta global custom_managed_object_free_type *managed_object_free = 0; global custom_managed_object_store_data_type *managed_object_store_data = 0; global custom_managed_object_load_data_type *managed_object_load_data = 0; -global custom_get_user_input_type *get_user_input = 0; -global custom_get_command_input_type *get_command_input = 0; -global custom_set_command_input_type *set_command_input = 0; -global custom_leave_command_input_unhandled_type *leave_command_input_unhandled = 0; +global custom_get_next_input_type *get_next_input = 0; +global custom_get_current_input_sequence_number_type *get_current_input_sequence_number = 0; +global custom_get_current_input_type *get_current_input = 0; +global custom_set_current_input_type *set_current_input = 0; +global custom_leave_current_input_unhandled_type *leave_current_input_unhandled = 0; global custom_set_custom_hook_type *set_custom_hook = 0; global custom_get_mouse_state_type *get_mouse_state = 0; global custom_get_active_query_bars_type *get_active_query_bars = 0; diff --git a/custom/generated/custom_api_master_list.h b/custom/generated/custom_api_master_list.h index 6e01199f..1f6eee70 100644 --- a/custom/generated/custom_api_master_list.h +++ b/custom/generated/custom_api_master_list.h @@ -109,10 +109,11 @@ api(custom) function Managed_Scope managed_object_get_containing_scope(Applicati api(custom) function b32 managed_object_free(Application_Links* app, Managed_Object object); api(custom) function b32 managed_object_store_data(Application_Links* app, Managed_Object object, u32 first_index, u32 count, void* mem); api(custom) function b32 managed_object_load_data(Application_Links* app, Managed_Object object, u32 first_index, u32 count, void* mem_out); -api(custom) function User_Input get_user_input(Application_Links* app, Event_Property get_properties, Event_Property abort_properties); -api(custom) function User_Input get_command_input(Application_Links* app); -api(custom) function void set_command_input(Application_Links* app, Input_Event* event); -api(custom) function void leave_command_input_unhandled(Application_Links* app); +api(custom) function User_Input get_next_input(Application_Links* app, Event_Property get_properties, Event_Property abort_properties); +api(custom) function i64 get_current_input_sequence_number(Application_Links* app); +api(custom) function User_Input get_current_input(Application_Links* app); +api(custom) function void set_current_input(Application_Links* app, User_Input* input); +api(custom) function void leave_current_input_unhandled(Application_Links* app); api(custom) function void set_custom_hook(Application_Links* app, Hook_ID hook_id, Void_Func* func_ptr); api(custom) function Mouse_State get_mouse_state(Application_Links* app); api(custom) function b32 get_active_query_bars(Application_Links* app, View_ID view_id, i32 max_result_count, Query_Bar_Ptr_Array* array_out); diff --git a/custom/generated/remapping.h b/custom/generated/remapping.h index 1dbcbb28..e0198dc8 100644 --- a/custom/generated/remapping.h +++ b/custom/generated/remapping.h @@ -10,6 +10,8 @@ setup_default_mapping(Mapping *mapping){ SelectMapping(mapping); SelectMap(mapid_global); + BindCore(default_startup , CoreCode_Startup); + BindCore(default_try_exit, CoreCode_TryExit); Bind(change_active_panel, KeyCode_Comma, KeyCode_Control); Bind(change_active_panel_backwards, KeyCode_Comma, KeyCode_Control, KeyCode_Shift); Bind(interactive_new, KeyCode_N, KeyCode_Control);