From 9e3e7519d01d862c6bd87247700a209acd986b84 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sun, 5 Aug 2018 00:09:18 -0700 Subject: [PATCH] Lister wrappers and fixed option lists --- 4coder_API/types.h | 39 +- 4coder_base_commands.cpp | 23 +- 4coder_default_framework.h | 8 + 4coder_default_framework_variables.cpp | 5 +- 4coder_default_hooks.cpp | 23 +- 4coder_experiments.cpp | 1 - 4coder_generated/app_functions.h | 6 +- 4coder_generated/command_metadata.h | 333 +++++----- 4coder_generated/remapping.h | 112 ++-- 4coder_helper.cpp | 26 + 4coder_lists.cpp | 692 ++++++++++++-------- 4coder_ui_helper.cpp | 62 +- 4coder_ui_helper.h | 19 +- 4ed.cpp | 263 +------- 4ed.h | 2 - 4ed_api_implementation.cpp | 121 ++-- 4ed_app_models.h | 10 - 4ed_app_target.cpp | 1 - 4ed_input_simulation.cpp | 222 ------- 4ed_input_simulation.h | 34 - 4ed_input_simulation_event.h | 49 -- 4ed_system.h | 4 - 4ed_view.cpp | 38 -- 4ed_view.h | 6 - 4ed_view_ui.cpp | 20 - build_tests.bat | 32 - generate_tests.bat | 25 - meta/4ed_metagen.cpp | 56 +- meta/4ed_test_builder.cpp | 716 --------------------- meta/4ed_test_generator.cpp | 457 ------------- platform_all/4ed_link_system_functions.cpp | 1 - platform_linux/linux_4ed.cpp | 6 - platform_mac/mac_4ed.cpp | 6 - platform_win32/win32_4ed.cpp | 136 ++-- 34 files changed, 961 insertions(+), 2593 deletions(-) delete mode 100644 4ed_input_simulation.cpp delete mode 100644 4ed_input_simulation.h delete mode 100644 4ed_input_simulation_event.h delete mode 100644 build_tests.bat delete mode 100644 generate_tests.bat delete mode 100644 meta/4ed_test_builder.cpp delete mode 100644 meta/4ed_test_generator.cpp diff --git a/4coder_API/types.h b/4coder_API/types.h index 2df24f7f..5268ffa8 100644 --- a/4coder_API/types.h +++ b/4coder_API/types.h @@ -61,33 +61,14 @@ ENUM(uint32_t, Key_Modifier_Flag){ ENUM(uint64_t, Command_ID){ /* DOC(cmdid_null is set aside to always be zero and is not associated with any command.) */ cmdid_null, - /* DOC(cmdid_undo performs a standard undo behavior.) */ cmdid_undo, /* DOC(cmdid_redo reperforms an edit that was undone.) */ cmdid_redo, - - /* DOC(cmdid_interactive_new begins an interactive dialogue to create a new buffer.) */ - cmdid_interactive_new, - /* DOC(cmdid_interactive_open begins an interactive dialogue to open a file into a buffer.) */ - cmdid_interactive_open, - /* DOC(cmdid_interactive_open_or_new begins an interactive dialogue to open a file into a buffer, if the name specified does not match any existing buffer, a new buffer is created instead.) */ - cmdid_interactive_open_or_new, - /* DOC(cmdid_interactive_switch_buffer begins an interactive dialogue to choose an open buffer to swap into the active view.) */ - cmdid_interactive_switch_buffer, - /* DOC(cmdid_interactive_kill_buffer begins an interactive dialogue to choose an open buffer to kill.) */ - cmdid_interactive_kill_buffer, - /* DOC(cmdid_reopen reloads the active buffer's associated file and discards the old buffer contents for the reloaded file.) */ cmdid_reopen, /* DOC(cmdid_save saves the buffer's contents into the associated file.) */ cmdid_save, - /* DOC(cmdid_kill_buffer tries to kill the active buffer.) */ - cmdid_kill_buffer, - - /* DOC(cmdid_open_color_tweaker opens the theme editing GUI.) */ - cmdid_open_color_tweaker, - // count cmdid_count }; @@ -105,11 +86,11 @@ ENUM(uint32_t, Memory_Protect_Flags){ /* DOC(User_Input_Type_ID specifies a type of user input event.) */ ENUM(int32_t, User_Input_Type_ID){ /* DOC(UserInputNone indicates that no event has occurred.) */ - UserInputNone, + UserInputNone = 0, /* DOC(UserInputKey indicates an event which can be described by a Key_Event_Data struct.) */ - UserInputKey, + UserInputKey = 1, /* DOC(UserInputMouse indicates an event which can be described by a Mouse_State struct.) */ - UserInputMouse + UserInputMouse = 2 }; /* DOC(A Wrap_Indicator_Mode is used in the buffer setting BufferSetting_WrapIndicator to specify how to indicate that line has been wrapped.) */ @@ -203,9 +184,12 @@ ENUM(uint32_t, Buffer_Create_Flag){ BufferCreate_NeverNew = 0x4, /* DOC(When BufferCreate_JustChangedFile is set it indicates that the file to load has just been saved in the same frame and a change notification for the file should be ignored.) */ BufferCreate_JustChangedFile = 0x8, + /* DOC(Indicates that when create_buffer searches for already existing buffers that match the name parameter, it should only search by file name, and that if it cannot create the buffer with the file attached, it should not create the buffer at all.) */ + BufferCreate_MustAttachToFile = 0x10, + /* DOC(Indicates that when create_buffer searches for already existing buffers that match the name parameter, it should only search by buffer name, and that it should not attach a file to the buffer even if it can. Caution! Buffers that don't have attached files cannot be saved.) */ + BufferCreate_NeverAttachToFile = 0x20, }; - /* DOC(Buffer_Creation_Data is a struct used as a local handle for the creation of a buffer. ) HIDE_MEMBERS() */ STRUCT Buffer_Creation_Data{ @@ -222,13 +206,18 @@ ENUM(uint32_t, Buffer_Save_Flag){ /* DOC(A Buffer_Kill_Flag field specifies how a buffer should be killed.) */ ENUM(uint32_t, Buffer_Kill_Flag){ - /* DOC(BufferKill_Background is not currently implemented.) */ - BufferKill_Background = 0x1, /* DOC(When BufferKill_AlwaysKill is set it indicates the buffer should be killed without asking, even when the buffer is dirty.) */ BufferKill_AlwaysKill = 0x2, }; +ENUM(int32_t, Buffer_Kill_Result){ + BufferKillResult_Killed = 0, + BufferKillResult_Dirty = 1, + BufferKillResult_Unkillable = 2, + BufferKillResult_DoesNotExist = 3, +}; + /* DOC(An Access_Flag field specifies what sort of permission you grant to an access call. An access call is usually one the returns a summary struct. If a 4coder object has a particular protection flag set and the corresponding bit is not set in the access field, that 4coder object is hidden. On the other hand if a protection flag is set in the access parameter and the object does not have that protection flag, the object is still returned from the access call.) */ ENUM(uint32_t, Access_Flag){ /* DOC(AccessOpen does not include any bits, it indicates that the access should only return objects that have no protection flags set.) */ diff --git a/4coder_base_commands.cpp b/4coder_base_commands.cpp index 03343f3d..720136c9 100644 --- a/4coder_base_commands.cpp +++ b/4coder_base_commands.cpp @@ -1429,6 +1429,15 @@ CUSTOM_DOC("Set the other non-active panel to view the buffer that the active pa //////////////////////////////// +CUSTOM_COMMAND_SIG(kill_buffer) +CUSTOM_DOC("Kills the current buffer.") +{ + View_Summary view = get_active_view(app, AccessProtected); + kill_buffer(app, buffer_identifier(view.buffer_id), view.view_id, 0); +} + +//////////////////////////////// + CUSTOM_COMMAND_SIG(undo) CUSTOM_DOC("Advances backwards through the undo history.") { @@ -1453,16 +1462,16 @@ CUSTOM_DOC("Saves the current buffer.") exec_command(app, cmdid_save); } -CUSTOM_COMMAND_SIG(kill_buffer) -CUSTOM_DOC("Kills the current buffer.") -{ - exec_command(app, cmdid_kill_buffer); -} - CUSTOM_COMMAND_SIG(open_color_tweaker) CUSTOM_DOC("Opens the 4coder colors and fonts selector menu.") { - exec_command(app, cmdid_open_color_tweaker); + // TODO(allen): TODO(allen): TODO(allen): TODO(allen): TODO(allen): TODO(allen): TODO(allen): + // TODO(allen): TODO(allen): TODO(allen): TODO(allen): TODO(allen): TODO(allen): + // TODO(allen): TODO(allen): TODO(allen): TODO(allen): TODO(allen): + // TODO(allen): TODO(allen): TODO(allen): TODO(allen): + // TODO(allen): TODO(allen): TODO(allen): + // TODO(allen): TODO(allen): + // TODO(allen): } //////////////////////////////// diff --git a/4coder_default_framework.h b/4coder_default_framework.h index 9ff87dc7..b542abf4 100644 --- a/4coder_default_framework.h +++ b/4coder_default_framework.h @@ -36,6 +36,14 @@ struct Named_Mapping{ Custom_Command_Function *remap_command; }; +//////////////////////////////// + +static void +do_gui_sure_to_kill(Application_Links *app, Buffer_Summary *buffer, View_Summary *view); + +static void +do_gui_sure_to_close_4coder(Application_Links *app, View_Summary *view); + #endif // BOTTOM diff --git a/4coder_default_framework_variables.cpp b/4coder_default_framework_variables.cpp index aab46e83..69b0665b 100644 --- a/4coder_default_framework_variables.cpp +++ b/4coder_default_framework_variables.cpp @@ -8,6 +8,8 @@ the default 4coder behavior. static Named_Mapping *named_maps = 0; static int32_t named_map_count = 0; +static bool32 allow_immediate_close_without_checking_for_changes = false; + static char *default_extensions[] = { "cpp", "hpp", @@ -49,4 +51,5 @@ static Config_Data global_config = {0}; static char previous_isearch_query[256] = {0}; -// BOTTOM \ No newline at end of file +// BOTTOM + diff --git a/4coder_default_hooks.cpp b/4coder_default_hooks.cpp index 9b963919..90536c46 100644 --- a/4coder_default_hooks.cpp +++ b/4coder_default_hooks.cpp @@ -53,7 +53,28 @@ COMMAND_CALLER_HOOK(default_command_caller){ } HOOK_SIG(default_exit){ - // if this returns zero it cancels the exit. + // If this returns zero it cancels the exit. + if (allow_immediate_close_without_checking_for_changes){ + return(1); + } + + bool32 has_unsaved_changes = false; + + for (Buffer_Summary buffer = get_buffer_first(app, AccessAll); + buffer.exists; + get_buffer_next(app, &buffer, AccessAll)){ + if (buffer.dirty == DirtyState_UnsavedChanges){ + has_unsaved_changes = true; + break; + } + } + + if (has_unsaved_changes){ + View_Summary view = get_active_view(app, AccessAll); + do_gui_sure_to_close_4coder(app, &view); + return(0); + } + return(1); } diff --git a/4coder_experiments.cpp b/4coder_experiments.cpp index e24800d0..157dc916 100644 --- a/4coder_experiments.cpp +++ b/4coder_experiments.cpp @@ -191,7 +191,6 @@ CUSTOM_DOC("Begin multi-line mode. In multi-line mode characters are inserted a --pos; } - } else{ break; diff --git a/4coder_generated/app_functions.h b/4coder_generated/app_functions.h index 08dfced1..44ab436c 100644 --- a/4coder_generated/app_functions.h +++ b/4coder_generated/app_functions.h @@ -31,7 +31,7 @@ struct Application_Links; #define BUFFER_SEND_END_SIGNAL_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer) #define CREATE_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags) #define SAVE_BUFFER_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, char *file_name, int32_t file_name_len, uint32_t flags) -#define KILL_BUFFER_SIG(n) bool32 n(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags) +#define KILL_BUFFER_SIG(n) Buffer_Kill_Result n(Application_Links *app, Buffer_Identifier buffer, Buffer_Kill_Flag flags) #define GET_VIEW_FIRST_SIG(n) View_Summary n(Application_Links *app, Access_Flag access) #define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view, Access_Flag access) #define GET_VIEW_SIG(n) View_Summary n(Application_Links *app, View_ID view_id, Access_Flag access) @@ -509,7 +509,7 @@ static inline bool32 buffer_get_token_index(Application_Links *app, Buffer_Summa static inline bool32 buffer_send_end_signal(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_send_end_signal(app, buffer));} static inline Buffer_Summary create_buffer(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags){return(app->create_buffer(app, filename, filename_len, flags));} static inline bool32 save_buffer(Application_Links *app, Buffer_Summary *buffer, char *file_name, int32_t file_name_len, uint32_t flags){return(app->save_buffer(app, buffer, file_name, file_name_len, flags));} -static inline bool32 kill_buffer(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags){return(app->kill_buffer(app, buffer, view_id, flags));} +static inline Buffer_Kill_Result kill_buffer(Application_Links *app, Buffer_Identifier buffer, Buffer_Kill_Flag flags){return(app->kill_buffer(app, buffer, flags));} static inline View_Summary get_view_first(Application_Links *app, Access_Flag access){return(app->get_view_first(app, access));} static inline void get_view_next(Application_Links *app, View_Summary *view, Access_Flag access){(app->get_view_next(app, view, access));} static inline View_Summary get_view(Application_Links *app, View_ID view_id, Access_Flag access){return(app->get_view(app, view_id, access));} @@ -603,7 +603,7 @@ static inline bool32 buffer_get_token_index(Application_Links *app, Buffer_Summa static inline bool32 buffer_send_end_signal(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_send_end_signal_(app, buffer));} static inline Buffer_Summary create_buffer(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags){return(app->create_buffer_(app, filename, filename_len, flags));} static inline bool32 save_buffer(Application_Links *app, Buffer_Summary *buffer, char *file_name, int32_t file_name_len, uint32_t flags){return(app->save_buffer_(app, buffer, file_name, file_name_len, flags));} -static inline bool32 kill_buffer(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags){return(app->kill_buffer_(app, buffer, view_id, flags));} +static inline Buffer_Kill_Result kill_buffer(Application_Links *app, Buffer_Identifier buffer, Buffer_Kill_Flag flags){return(app->kill_buffer_(app, buffer, flags));} static inline View_Summary get_view_first(Application_Links *app, Access_Flag access){return(app->get_view_first_(app, access));} static inline void get_view_next(Application_Links *app, View_Summary *view, Access_Flag access){(app->get_view_next_(app, view, access));} static inline View_Summary get_view(Application_Links *app, View_ID view_id, Access_Flag access){return(app->get_view_(app, view_id, access));} diff --git a/4coder_generated/command_metadata.h b/4coder_generated/command_metadata.h index 26582c3e..c6388db5 100644 --- a/4coder_generated/command_metadata.h +++ b/4coder_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 200 +#define command_one_past_last_id 201 #if defined(CUSTOM_COMMAND_SIG) #define PROC_LINKS(x,y) x #else @@ -90,22 +90,23 @@ CUSTOM_COMMAND_SIG(list_all_locations_of_type_definition); CUSTOM_COMMAND_SIG(list_all_locations_of_type_definition_of_identifier); CUSTOM_COMMAND_SIG(list_all_substring_locations); CUSTOM_COMMAND_SIG(list_all_substring_locations_case_insensitive); -CUSTOM_COMMAND_SIG(list_mode__activate); -CUSTOM_COMMAND_SIG(list_mode__backspace_text_field); -CUSTOM_COMMAND_SIG(list_mode__backspace_text_field__default); -CUSTOM_COMMAND_SIG(list_mode__backspace_text_field__file_path); -CUSTOM_COMMAND_SIG(list_mode__mouse_press); -CUSTOM_COMMAND_SIG(list_mode__mouse_release); -CUSTOM_COMMAND_SIG(list_mode__move_down); -CUSTOM_COMMAND_SIG(list_mode__move_down__default); -CUSTOM_COMMAND_SIG(list_mode__move_up); -CUSTOM_COMMAND_SIG(list_mode__move_up__default); -CUSTOM_COMMAND_SIG(list_mode__quit); -CUSTOM_COMMAND_SIG(list_mode__repaint); -CUSTOM_COMMAND_SIG(list_mode__wheel_scroll); -CUSTOM_COMMAND_SIG(list_mode__write_character); -CUSTOM_COMMAND_SIG(list_mode__write_character__default); -CUSTOM_COMMAND_SIG(list_mode__write_character__file_path); +CUSTOM_COMMAND_SIG(lister__activate); +CUSTOM_COMMAND_SIG(lister__backspace_text_field); +CUSTOM_COMMAND_SIG(lister__backspace_text_field__default); +CUSTOM_COMMAND_SIG(lister__backspace_text_field__file_path); +CUSTOM_COMMAND_SIG(lister__mouse_press); +CUSTOM_COMMAND_SIG(lister__mouse_release); +CUSTOM_COMMAND_SIG(lister__move_down); +CUSTOM_COMMAND_SIG(lister__move_down__default); +CUSTOM_COMMAND_SIG(lister__move_up); +CUSTOM_COMMAND_SIG(lister__move_up__default); +CUSTOM_COMMAND_SIG(lister__quit); +CUSTOM_COMMAND_SIG(lister__repaint); +CUSTOM_COMMAND_SIG(lister__wheel_scroll); +CUSTOM_COMMAND_SIG(lister__write_character); +CUSTOM_COMMAND_SIG(lister__write_character__default); +CUSTOM_COMMAND_SIG(lister__write_character__file_path); +CUSTOM_COMMAND_SIG(lister__write_character__fixed_list); CUSTOM_COMMAND_SIG(load_project); CUSTOM_COMMAND_SIG(make_directory_query); CUSTOM_COMMAND_SIG(move_down); @@ -220,7 +221,7 @@ char *source_name; int32_t source_name_len; int32_t line_number; }; -static Command_Metadata fcoder_metacmd_table[200] = { +static Command_Metadata fcoder_metacmd_table[201] = { { PROC_LINKS(allow_mouse, 0), "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "w:\\4ed\\code\\4coder_default_framework.cpp", 43, 191 }, { PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "w:\\4ed\\code\\4coder_auto_indent.cpp", 37, 722 }, { PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\4coder_auto_indent.cpp", 37, 733 }, @@ -284,12 +285,12 @@ static Command_Metadata fcoder_metacmd_table[200] = { { PROC_LINKS(if0_off, 0), "if0_off", 7, "Surround the range between the cursor and mark with an '#if 0' and an '#endif'", 78, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 49, 82 }, { PROC_LINKS(increase_face_size, 0), "increase_face_size", 18, "Increase the size of the face used by the current buffer.", 57, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 519 }, { PROC_LINKS(increase_line_wrap, 0), "increase_line_wrap", 18, "Increases the current buffer's width for line wrapping.", 55, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 497 }, -{ PROC_LINKS(interactive_kill_buffer, 0), "interactive_kill_buffer", 23, "Interactively kill an open buffer.", 34, "w:\\4ed\\code\\4coder_lists.cpp", 31, 378 }, -{ PROC_LINKS(interactive_new, 0), "interactive_new", 15, "Interactively creates a new file.", 33, "w:\\4ed\\code\\4coder_lists.cpp", 31, 505 }, -{ PROC_LINKS(interactive_open, 0), "interactive_open", 16, "Interactively opens a file.", 27, "w:\\4ed\\code\\4coder_lists.cpp", 31, 564 }, -{ 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\\4coder_lists.cpp", 31, 438 }, -{ PROC_LINKS(interactive_switch_buffer, 0), "interactive_switch_buffer", 25, "Interactively switch to an open buffer.", 39, "w:\\4ed\\code\\4coder_lists.cpp", 31, 349 }, -{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1456 }, +{ PROC_LINKS(interactive_kill_buffer, 0), "interactive_kill_buffer", 23, "Interactively kill an open buffer.", 34, "w:\\4ed\\code\\4coder_lists.cpp", 31, 608 }, +{ PROC_LINKS(interactive_new, 0), "interactive_new", 15, "Interactively creates a new file.", 33, "w:\\4ed\\code\\4coder_lists.cpp", 31, 710 }, +{ PROC_LINKS(interactive_open, 0), "interactive_open", 16, "Interactively opens a file.", 27, "w:\\4ed\\code\\4coder_lists.cpp", 31, 737 }, +{ 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\\4coder_lists.cpp", 31, 677 }, +{ PROC_LINKS(interactive_switch_buffer, 0), "interactive_switch_buffer", 25, "Interactively switch to an open buffer.", 39, "w:\\4ed\\code\\4coder_lists.cpp", 31, 590 }, +{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1432 }, { PROC_LINKS(left_adjust_view, 0), "left_adjust_view", 16, "Sets the left size of the view near the x position of the cursor.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 135 }, { PROC_LINKS(list_all_functions_current_buffer, 0), "list_all_functions_current_buffer", 33, "Creates a jump list of lines of the current buffer that appear to define or declare functions.", 94, "w:\\4ed\\code\\4coder_function_list.cpp", 39, 318 }, { PROC_LINKS(list_all_locations, 0), "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "w:\\4ed\\code\\4coder_search.cpp", 32, 741 }, @@ -302,22 +303,23 @@ static Command_Metadata fcoder_metacmd_table[200] = { { PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "w:\\4ed\\code\\4coder_search.cpp", 32, 800 }, { PROC_LINKS(list_all_substring_locations, 0), "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "w:\\4ed\\code\\4coder_search.cpp", 32, 747 }, { PROC_LINKS(list_all_substring_locations_case_insensitive, 0), "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "w:\\4ed\\code\\4coder_search.cpp", 32, 759 }, -{ PROC_LINKS(list_mode__activate, 0), "list_mode__activate", 19, "A list mode command that activates the list's action on the highlighted item.", 77, "w:\\4ed\\code\\4coder_lists.cpp", 31, 17 }, -{ PROC_LINKS(list_mode__backspace_text_field, 0), "list_mode__backspace_text_field", 31, "A list mode command that backspaces one character from the text field.", 70, "w:\\4ed\\code\\4coder_lists.cpp", 31, 169 }, -{ PROC_LINKS(list_mode__backspace_text_field__default, 0), "list_mode__backspace_text_field__default", 40, "A list mode command that backspaces one character from the text field.", 70, "w:\\4ed\\code\\4coder_lists.cpp", 31, 52 }, -{ PROC_LINKS(list_mode__backspace_text_field__file_path, 0), "list_mode__backspace_text_field__file_path", 42, "A list mode command that backspaces one character from the text field.", 70, "w:\\4ed\\code\\4coder_lists.cpp", 31, 124 }, -{ PROC_LINKS(list_mode__mouse_press, 0), "list_mode__mouse_press", 22, "A list mode command that beings a click interaction with a list item under the mouse.", 85, "w:\\4ed\\code\\4coder_lists.cpp", 31, 214 }, -{ PROC_LINKS(list_mode__mouse_release, 0), "list_mode__mouse_release", 24, "A list mode command that ends a click interaction with a list item under the mouse, possibly activating it.", 107, "w:\\4ed\\code\\4coder_lists.cpp", 31, 226 }, -{ PROC_LINKS(list_mode__move_down, 0), "list_mode__move_down", 20, "A list mode command that moves the highlighted item one down in the list.", 73, "w:\\4ed\\code\\4coder_lists.cpp", 31, 189 }, -{ PROC_LINKS(list_mode__move_down__default, 0), "list_mode__move_down__default", 29, "A list mode command that moves the highlighted item one down in the list.", 73, "w:\\4ed\\code\\4coder_lists.cpp", 31, 83 }, -{ PROC_LINKS(list_mode__move_up, 0), "list_mode__move_up", 18, "A list mode command that moves the highlighted item one up in the list.", 71, "w:\\4ed\\code\\4coder_lists.cpp", 31, 179 }, -{ PROC_LINKS(list_mode__move_up__default, 0), "list_mode__move_up__default", 27, "A list mode command that moves the highlighted item one up in the list.", 71, "w:\\4ed\\code\\4coder_lists.cpp", 31, 67 }, -{ PROC_LINKS(list_mode__quit, 0), "list_mode__quit", 15, "A list mode command that quits the list without executing any actions.", 70, "w:\\4ed\\code\\4coder_lists.cpp", 31, 8 }, -{ PROC_LINKS(list_mode__repaint, 0), "list_mode__repaint", 18, "A list mode command that updates the lists UI data.", 51, "w:\\4ed\\code\\4coder_lists.cpp", 31, 242 }, -{ PROC_LINKS(list_mode__wheel_scroll, 0), "list_mode__wheel_scroll", 23, "A list mode command that scrolls the list in response to the mouse wheel.", 73, "w:\\4ed\\code\\4coder_lists.cpp", 31, 199 }, -{ PROC_LINKS(list_mode__write_character, 0), "list_mode__write_character", 26, "A list mode command that inserts a new character to the text field.", 67, "w:\\4ed\\code\\4coder_lists.cpp", 31, 159 }, -{ PROC_LINKS(list_mode__write_character__default, 0), "list_mode__write_character__default", 35, "A list mode command that inserts a new character to the text field.", 67, "w:\\4ed\\code\\4coder_lists.cpp", 31, 32 }, -{ PROC_LINKS(list_mode__write_character__file_path, 0), "list_mode__write_character__file_path", 37, "A list mode command that inserts a new character to the text field.", 67, "w:\\4ed\\code\\4coder_lists.cpp", 31, 99 }, +{ PROC_LINKS(lister__activate, 0), "lister__activate", 16, "A lister mode command that activates the list's action on the highlighted item.", 79, "w:\\4ed\\code\\4coder_lists.cpp", 31, 17 }, +{ PROC_LINKS(lister__backspace_text_field, 0), "lister__backspace_text_field", 28, "A lister mode command that dispatches to the lister's backspace text field handler.", 83, "w:\\4ed\\code\\4coder_lists.cpp", 31, 44 }, +{ PROC_LINKS(lister__backspace_text_field__default, 0), "lister__backspace_text_field__default", 37, "A lister mode command that backspaces one character from the text field.", 72, "w:\\4ed\\code\\4coder_lists.cpp", 31, 149 }, +{ PROC_LINKS(lister__backspace_text_field__file_path, 0), "lister__backspace_text_field__file_path", 39, "A lister mode command that backspaces one character from the text field of a file system list.", 94, "w:\\4ed\\code\\4coder_lists.cpp", 31, 221 }, +{ PROC_LINKS(lister__mouse_press, 0), "lister__mouse_press", 19, "A lister mode command that beings a click interaction with a list item under the mouse.", 87, "w:\\4ed\\code\\4coder_lists.cpp", 31, 89 }, +{ PROC_LINKS(lister__mouse_release, 0), "lister__mouse_release", 21, "A lister mode command that ends a click interaction with a list item under the mouse, possibly activating it.", 109, "w:\\4ed\\code\\4coder_lists.cpp", 31, 101 }, +{ PROC_LINKS(lister__move_down, 0), "lister__move_down", 17, "A lister mode command that dispatches to the lister's navigate down handler.", 76, "w:\\4ed\\code\\4coder_lists.cpp", 31, 64 }, +{ PROC_LINKS(lister__move_down__default, 0), "lister__move_down__default", 26, "A lister mode command that moves the highlighted item one down in the list.", 75, "w:\\4ed\\code\\4coder_lists.cpp", 31, 180 }, +{ PROC_LINKS(lister__move_up, 0), "lister__move_up", 15, "A lister mode command that dispatches to the lister's navigate up handler.", 74, "w:\\4ed\\code\\4coder_lists.cpp", 31, 54 }, +{ PROC_LINKS(lister__move_up__default, 0), "lister__move_up__default", 24, "A lister mode command that moves the highlighted item one up in the list.", 73, "w:\\4ed\\code\\4coder_lists.cpp", 31, 164 }, +{ PROC_LINKS(lister__quit, 0), "lister__quit", 12, "A lister mode command that quits the list without executing any actions.", 72, "w:\\4ed\\code\\4coder_lists.cpp", 31, 8 }, +{ PROC_LINKS(lister__repaint, 0), "lister__repaint", 15, "A lister mode command that updates the lists UI data.", 53, "w:\\4ed\\code\\4coder_lists.cpp", 31, 118 }, +{ PROC_LINKS(lister__wheel_scroll, 0), "lister__wheel_scroll", 20, "A lister mode command that scrolls the list in response to the mouse wheel.", 75, "w:\\4ed\\code\\4coder_lists.cpp", 31, 74 }, +{ PROC_LINKS(lister__write_character, 0), "lister__write_character", 23, "A lister mode command that dispatches to the lister's write character handler.", 78, "w:\\4ed\\code\\4coder_lists.cpp", 31, 34 }, +{ PROC_LINKS(lister__write_character__default, 0), "lister__write_character__default", 32, "A lister mode command that inserts a new character to the text field.", 69, "w:\\4ed\\code\\4coder_lists.cpp", 31, 129 }, +{ PROC_LINKS(lister__write_character__file_path, 0), "lister__write_character__file_path", 34, "A lister mode command that inserts a character into the text field of a file system list.", 89, "w:\\4ed\\code\\4coder_lists.cpp", 31, 196 }, +{ PROC_LINKS(lister__write_character__fixed_list, 0), "lister__write_character__fixed_list", 35, "A lister mode command that handles input for the fixed sure to kill list.", 73, "w:\\4ed\\code\\4coder_lists.cpp", 31, 256 }, { PROC_LINKS(load_project, 0), "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "w:\\4ed\\code\\4coder_project_commands.cpp", 42, 1071 }, { 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\\4coder_base_commands.cpp", 39, 1120 }, { PROC_LINKS(move_down, 0), "move_down", 9, "Moves the cursor down one line.", 31, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 250 }, @@ -335,9 +337,9 @@ static Command_Metadata fcoder_metacmd_table[200] = { { PROC_LINKS(newline_or_goto_position_sticky, 0), "newline_or_goto_position_sticky", 31, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 37, 556 }, { PROC_LINKS(open_all_code, 0), "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "w:\\4ed\\code\\4coder_project_commands.cpp", 42, 1055 }, { PROC_LINKS(open_all_code_recursive, 0), "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "w:\\4ed\\code\\4coder_project_commands.cpp", 42, 1062 }, -{ PROC_LINKS(open_color_tweaker, 0), "open_color_tweaker", 18, "Opens the 4coder colors and fonts selector menu.", 48, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1462 }, +{ PROC_LINKS(open_color_tweaker, 0), "open_color_tweaker", 18, "Opens the 4coder colors and fonts selector menu.", 48, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1465 }, { 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\\4coder_base_commands.cpp", 39, 1339 }, -{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1470 }, +{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1479 }, { PROC_LINKS(open_long_braces, 0), "open_long_braces", 16, "At the cursor, insert a '{' and '}' separated by a blank line.", 62, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 49, 58 }, { PROC_LINKS(open_long_braces_break, 0), "open_long_braces_break", 22, "At the cursor, insert a '{' and '}break;' separated by a blank line.", 68, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 49, 74 }, { PROC_LINKS(open_long_braces_semicolon, 0), "open_long_braces_semicolon", 26, "At the cursor, insert a '{' and '};' separated by a blank line.", 63, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 49, 66 }, @@ -356,14 +358,14 @@ static Command_Metadata fcoder_metacmd_table[200] = { { 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\\4coder_base_commands.cpp", 39, 912 }, { 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\\4coder_base_commands.cpp", 39, 932 }, { 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\\4coder_base_commands.cpp", 39, 950 }, -{ PROC_LINKS(redo, 0), "redo", 4, "Advances forewards through the undo history.", 44, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1438 }, +{ PROC_LINKS(redo, 0), "redo", 4, "Advances forewards through the undo history.", 44, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1447 }, { PROC_LINKS(remap_interactive, 0), "remap_interactive", 17, "Switch to a named key binding map.", 34, "w:\\4ed\\code\\4coder_default_framework.cpp", 43, 211 }, { 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\\4coder_base_commands.cpp", 39, 1078 }, -{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1444 }, +{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1453 }, { PROC_LINKS(replace_in_range, 0), "replace_in_range", 16, "Queries the user for two strings, and replaces all occurences of the first string in the range between the cursor and the mark with the second string.", 150, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 810 }, { 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\\4coder_base_commands.cpp", 39, 781 }, { 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\\4coder_base_commands.cpp", 39, 799 }, -{ PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1450 }, +{ PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1459 }, { PROC_LINKS(save_all_dirty_buffers, 0), "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 977 }, { PROC_LINKS(save_to_query, 0), "save_to_query", 13, "Queries the user for a name and saves the contents of the current buffer, altering the buffer's name too.", 105, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1038 }, { PROC_LINKS(scope_absorb_down, 0), "scope_absorb_down", 17, "If a scope is currently selected, and a statement or block statement is present below the current scope, the statement is moved into the scope.", 143, "w:\\4ed\\code\\4coder_scope_commands.cpp", 40, 738 }, @@ -410,7 +412,7 @@ static Command_Metadata fcoder_metacmd_table[200] = { { PROC_LINKS(toggle_mouse, 0), "toggle_mouse", 12, "Toggles the mouse suppression mode, see suppress_mouse and allow_mouse.", 71, "w:\\4ed\\code\\4coder_default_framework.cpp", 43, 197 }, { PROC_LINKS(toggle_show_whitespace, 0), "toggle_show_whitespace", 22, "Toggles the current buffer's whitespace visibility status.", 58, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 554 }, { PROC_LINKS(toggle_virtual_whitespace, 0), "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 543 }, -{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history.", 44, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1432 }, +{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history.", 44, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1441 }, { 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\\4coder_base_commands.cpp", 39, 1389 }, { PROC_LINKS(word_complete, 0), "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "w:\\4ed\\code\\4coder_search.cpp", 32, 820 }, { PROC_LINKS(write_and_auto_tab, 0), "write_and_auto_tab", 18, "Inserts a character and auto-indents the line on which the cursor sits.", 71, "w:\\4ed\\code\\4coder_auto_indent.cpp", 37, 745 }, @@ -503,123 +505,124 @@ static int32_t fcoder_metacmd_ID_list_all_locations_of_type_definition = 77; static int32_t fcoder_metacmd_ID_list_all_locations_of_type_definition_of_identifier = 78; static int32_t fcoder_metacmd_ID_list_all_substring_locations = 79; static int32_t fcoder_metacmd_ID_list_all_substring_locations_case_insensitive = 80; -static int32_t fcoder_metacmd_ID_list_mode__activate = 81; -static int32_t fcoder_metacmd_ID_list_mode__backspace_text_field = 82; -static int32_t fcoder_metacmd_ID_list_mode__backspace_text_field__default = 83; -static int32_t fcoder_metacmd_ID_list_mode__backspace_text_field__file_path = 84; -static int32_t fcoder_metacmd_ID_list_mode__mouse_press = 85; -static int32_t fcoder_metacmd_ID_list_mode__mouse_release = 86; -static int32_t fcoder_metacmd_ID_list_mode__move_down = 87; -static int32_t fcoder_metacmd_ID_list_mode__move_down__default = 88; -static int32_t fcoder_metacmd_ID_list_mode__move_up = 89; -static int32_t fcoder_metacmd_ID_list_mode__move_up__default = 90; -static int32_t fcoder_metacmd_ID_list_mode__quit = 91; -static int32_t fcoder_metacmd_ID_list_mode__repaint = 92; -static int32_t fcoder_metacmd_ID_list_mode__wheel_scroll = 93; -static int32_t fcoder_metacmd_ID_list_mode__write_character = 94; -static int32_t fcoder_metacmd_ID_list_mode__write_character__default = 95; -static int32_t fcoder_metacmd_ID_list_mode__write_character__file_path = 96; -static int32_t fcoder_metacmd_ID_load_project = 97; -static int32_t fcoder_metacmd_ID_make_directory_query = 98; -static int32_t fcoder_metacmd_ID_move_down = 99; -static int32_t fcoder_metacmd_ID_move_down_10 = 100; -static int32_t fcoder_metacmd_ID_move_down_textual = 101; -static int32_t fcoder_metacmd_ID_move_left = 102; -static int32_t fcoder_metacmd_ID_move_line_down = 103; -static int32_t fcoder_metacmd_ID_move_line_up = 104; -static int32_t fcoder_metacmd_ID_move_right = 105; -static int32_t fcoder_metacmd_ID_move_up = 106; -static int32_t fcoder_metacmd_ID_move_up_10 = 107; -static int32_t fcoder_metacmd_ID_newline_or_goto_position_direct = 108; -static int32_t fcoder_metacmd_ID_newline_or_goto_position_same_panel_direct = 109; -static int32_t fcoder_metacmd_ID_newline_or_goto_position_same_panel_sticky = 110; -static int32_t fcoder_metacmd_ID_newline_or_goto_position_sticky = 111; -static int32_t fcoder_metacmd_ID_open_all_code = 112; -static int32_t fcoder_metacmd_ID_open_all_code_recursive = 113; -static int32_t fcoder_metacmd_ID_open_color_tweaker = 114; -static int32_t fcoder_metacmd_ID_open_file_in_quotes = 115; -static int32_t fcoder_metacmd_ID_open_in_other = 116; -static int32_t fcoder_metacmd_ID_open_long_braces = 117; -static int32_t fcoder_metacmd_ID_open_long_braces_break = 118; -static int32_t fcoder_metacmd_ID_open_long_braces_semicolon = 119; -static int32_t fcoder_metacmd_ID_open_matching_file_cpp = 120; -static int32_t fcoder_metacmd_ID_open_panel_hsplit = 121; -static int32_t fcoder_metacmd_ID_open_panel_vsplit = 122; -static int32_t fcoder_metacmd_ID_page_down = 123; -static int32_t fcoder_metacmd_ID_page_up = 124; -static int32_t fcoder_metacmd_ID_paste = 125; -static int32_t fcoder_metacmd_ID_paste_and_indent = 126; -static int32_t fcoder_metacmd_ID_paste_next = 127; -static int32_t fcoder_metacmd_ID_paste_next_and_indent = 128; -static int32_t fcoder_metacmd_ID_place_in_scope = 129; -static int32_t fcoder_metacmd_ID_project_fkey_command = 130; -static int32_t fcoder_metacmd_ID_project_go_to_root_directory = 131; -static int32_t fcoder_metacmd_ID_query_replace = 132; -static int32_t fcoder_metacmd_ID_query_replace_identifier = 133; -static int32_t fcoder_metacmd_ID_query_replace_selection = 134; -static int32_t fcoder_metacmd_ID_redo = 135; -static int32_t fcoder_metacmd_ID_remap_interactive = 136; -static int32_t fcoder_metacmd_ID_rename_file_query = 137; -static int32_t fcoder_metacmd_ID_reopen = 138; -static int32_t fcoder_metacmd_ID_replace_in_range = 139; -static int32_t fcoder_metacmd_ID_reverse_search = 140; -static int32_t fcoder_metacmd_ID_reverse_search_identifier = 141; -static int32_t fcoder_metacmd_ID_save = 142; -static int32_t fcoder_metacmd_ID_save_all_dirty_buffers = 143; -static int32_t fcoder_metacmd_ID_save_to_query = 144; -static int32_t fcoder_metacmd_ID_scope_absorb_down = 145; -static int32_t fcoder_metacmd_ID_search = 146; -static int32_t fcoder_metacmd_ID_search_identifier = 147; -static int32_t fcoder_metacmd_ID_seek_alphanumeric_left = 148; -static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_left = 149; -static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_right = 150; -static int32_t fcoder_metacmd_ID_seek_alphanumeric_right = 151; -static int32_t fcoder_metacmd_ID_seek_beginning_of_line = 152; -static int32_t fcoder_metacmd_ID_seek_beginning_of_textual_line = 153; -static int32_t fcoder_metacmd_ID_seek_end_of_line = 154; -static int32_t fcoder_metacmd_ID_seek_end_of_textual_line = 155; -static int32_t fcoder_metacmd_ID_seek_token_left = 156; -static int32_t fcoder_metacmd_ID_seek_token_right = 157; -static int32_t fcoder_metacmd_ID_seek_white_or_token_left = 158; -static int32_t fcoder_metacmd_ID_seek_white_or_token_right = 159; -static int32_t fcoder_metacmd_ID_seek_whitespace_down = 160; -static int32_t fcoder_metacmd_ID_seek_whitespace_down_end_line = 161; -static int32_t fcoder_metacmd_ID_seek_whitespace_left = 162; -static int32_t fcoder_metacmd_ID_seek_whitespace_right = 163; -static int32_t fcoder_metacmd_ID_seek_whitespace_up = 164; -static int32_t fcoder_metacmd_ID_seek_whitespace_up_end_line = 165; -static int32_t fcoder_metacmd_ID_select_all = 166; -static int32_t fcoder_metacmd_ID_set_bindings_choose = 167; -static int32_t fcoder_metacmd_ID_set_bindings_default = 168; -static int32_t fcoder_metacmd_ID_set_bindings_mac_default = 169; -static int32_t fcoder_metacmd_ID_set_mark = 170; -static int32_t fcoder_metacmd_ID_setup_build_bat = 171; -static int32_t fcoder_metacmd_ID_setup_build_bat_and_sh = 172; -static int32_t fcoder_metacmd_ID_setup_build_sh = 173; -static int32_t fcoder_metacmd_ID_setup_new_project = 174; -static int32_t fcoder_metacmd_ID_show_filebar = 175; -static int32_t fcoder_metacmd_ID_show_scrollbar = 176; -static int32_t fcoder_metacmd_ID_snipe_token_or_word = 177; -static int32_t fcoder_metacmd_ID_snipe_token_or_word_right = 178; -static int32_t fcoder_metacmd_ID_suppress_mouse = 179; -static int32_t fcoder_metacmd_ID_swap_buffers_between_panels = 180; -static int32_t fcoder_metacmd_ID_to_lowercase = 181; -static int32_t fcoder_metacmd_ID_to_uppercase = 182; -static int32_t fcoder_metacmd_ID_toggle_filebar = 183; -static int32_t fcoder_metacmd_ID_toggle_fullscreen = 184; -static int32_t fcoder_metacmd_ID_toggle_line_wrap = 185; -static int32_t fcoder_metacmd_ID_toggle_mouse = 186; -static int32_t fcoder_metacmd_ID_toggle_show_whitespace = 187; -static int32_t fcoder_metacmd_ID_toggle_virtual_whitespace = 188; -static int32_t fcoder_metacmd_ID_undo = 189; -static int32_t fcoder_metacmd_ID_view_buffer_other_panel = 190; -static int32_t fcoder_metacmd_ID_word_complete = 191; -static int32_t fcoder_metacmd_ID_write_and_auto_tab = 192; -static int32_t fcoder_metacmd_ID_write_block = 193; -static int32_t fcoder_metacmd_ID_write_character = 194; -static int32_t fcoder_metacmd_ID_write_hack = 195; -static int32_t fcoder_metacmd_ID_write_note = 196; -static int32_t fcoder_metacmd_ID_write_todo = 197; -static int32_t fcoder_metacmd_ID_write_underscore = 198; -static int32_t fcoder_metacmd_ID_write_zero_struct = 199; +static int32_t fcoder_metacmd_ID_lister__activate = 81; +static int32_t fcoder_metacmd_ID_lister__backspace_text_field = 82; +static int32_t fcoder_metacmd_ID_lister__backspace_text_field__default = 83; +static int32_t fcoder_metacmd_ID_lister__backspace_text_field__file_path = 84; +static int32_t fcoder_metacmd_ID_lister__mouse_press = 85; +static int32_t fcoder_metacmd_ID_lister__mouse_release = 86; +static int32_t fcoder_metacmd_ID_lister__move_down = 87; +static int32_t fcoder_metacmd_ID_lister__move_down__default = 88; +static int32_t fcoder_metacmd_ID_lister__move_up = 89; +static int32_t fcoder_metacmd_ID_lister__move_up__default = 90; +static int32_t fcoder_metacmd_ID_lister__quit = 91; +static int32_t fcoder_metacmd_ID_lister__repaint = 92; +static int32_t fcoder_metacmd_ID_lister__wheel_scroll = 93; +static int32_t fcoder_metacmd_ID_lister__write_character = 94; +static int32_t fcoder_metacmd_ID_lister__write_character__default = 95; +static int32_t fcoder_metacmd_ID_lister__write_character__file_path = 96; +static int32_t fcoder_metacmd_ID_lister__write_character__fixed_list = 97; +static int32_t fcoder_metacmd_ID_load_project = 98; +static int32_t fcoder_metacmd_ID_make_directory_query = 99; +static int32_t fcoder_metacmd_ID_move_down = 100; +static int32_t fcoder_metacmd_ID_move_down_10 = 101; +static int32_t fcoder_metacmd_ID_move_down_textual = 102; +static int32_t fcoder_metacmd_ID_move_left = 103; +static int32_t fcoder_metacmd_ID_move_line_down = 104; +static int32_t fcoder_metacmd_ID_move_line_up = 105; +static int32_t fcoder_metacmd_ID_move_right = 106; +static int32_t fcoder_metacmd_ID_move_up = 107; +static int32_t fcoder_metacmd_ID_move_up_10 = 108; +static int32_t fcoder_metacmd_ID_newline_or_goto_position_direct = 109; +static int32_t fcoder_metacmd_ID_newline_or_goto_position_same_panel_direct = 110; +static int32_t fcoder_metacmd_ID_newline_or_goto_position_same_panel_sticky = 111; +static int32_t fcoder_metacmd_ID_newline_or_goto_position_sticky = 112; +static int32_t fcoder_metacmd_ID_open_all_code = 113; +static int32_t fcoder_metacmd_ID_open_all_code_recursive = 114; +static int32_t fcoder_metacmd_ID_open_color_tweaker = 115; +static int32_t fcoder_metacmd_ID_open_file_in_quotes = 116; +static int32_t fcoder_metacmd_ID_open_in_other = 117; +static int32_t fcoder_metacmd_ID_open_long_braces = 118; +static int32_t fcoder_metacmd_ID_open_long_braces_break = 119; +static int32_t fcoder_metacmd_ID_open_long_braces_semicolon = 120; +static int32_t fcoder_metacmd_ID_open_matching_file_cpp = 121; +static int32_t fcoder_metacmd_ID_open_panel_hsplit = 122; +static int32_t fcoder_metacmd_ID_open_panel_vsplit = 123; +static int32_t fcoder_metacmd_ID_page_down = 124; +static int32_t fcoder_metacmd_ID_page_up = 125; +static int32_t fcoder_metacmd_ID_paste = 126; +static int32_t fcoder_metacmd_ID_paste_and_indent = 127; +static int32_t fcoder_metacmd_ID_paste_next = 128; +static int32_t fcoder_metacmd_ID_paste_next_and_indent = 129; +static int32_t fcoder_metacmd_ID_place_in_scope = 130; +static int32_t fcoder_metacmd_ID_project_fkey_command = 131; +static int32_t fcoder_metacmd_ID_project_go_to_root_directory = 132; +static int32_t fcoder_metacmd_ID_query_replace = 133; +static int32_t fcoder_metacmd_ID_query_replace_identifier = 134; +static int32_t fcoder_metacmd_ID_query_replace_selection = 135; +static int32_t fcoder_metacmd_ID_redo = 136; +static int32_t fcoder_metacmd_ID_remap_interactive = 137; +static int32_t fcoder_metacmd_ID_rename_file_query = 138; +static int32_t fcoder_metacmd_ID_reopen = 139; +static int32_t fcoder_metacmd_ID_replace_in_range = 140; +static int32_t fcoder_metacmd_ID_reverse_search = 141; +static int32_t fcoder_metacmd_ID_reverse_search_identifier = 142; +static int32_t fcoder_metacmd_ID_save = 143; +static int32_t fcoder_metacmd_ID_save_all_dirty_buffers = 144; +static int32_t fcoder_metacmd_ID_save_to_query = 145; +static int32_t fcoder_metacmd_ID_scope_absorb_down = 146; +static int32_t fcoder_metacmd_ID_search = 147; +static int32_t fcoder_metacmd_ID_search_identifier = 148; +static int32_t fcoder_metacmd_ID_seek_alphanumeric_left = 149; +static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_left = 150; +static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_right = 151; +static int32_t fcoder_metacmd_ID_seek_alphanumeric_right = 152; +static int32_t fcoder_metacmd_ID_seek_beginning_of_line = 153; +static int32_t fcoder_metacmd_ID_seek_beginning_of_textual_line = 154; +static int32_t fcoder_metacmd_ID_seek_end_of_line = 155; +static int32_t fcoder_metacmd_ID_seek_end_of_textual_line = 156; +static int32_t fcoder_metacmd_ID_seek_token_left = 157; +static int32_t fcoder_metacmd_ID_seek_token_right = 158; +static int32_t fcoder_metacmd_ID_seek_white_or_token_left = 159; +static int32_t fcoder_metacmd_ID_seek_white_or_token_right = 160; +static int32_t fcoder_metacmd_ID_seek_whitespace_down = 161; +static int32_t fcoder_metacmd_ID_seek_whitespace_down_end_line = 162; +static int32_t fcoder_metacmd_ID_seek_whitespace_left = 163; +static int32_t fcoder_metacmd_ID_seek_whitespace_right = 164; +static int32_t fcoder_metacmd_ID_seek_whitespace_up = 165; +static int32_t fcoder_metacmd_ID_seek_whitespace_up_end_line = 166; +static int32_t fcoder_metacmd_ID_select_all = 167; +static int32_t fcoder_metacmd_ID_set_bindings_choose = 168; +static int32_t fcoder_metacmd_ID_set_bindings_default = 169; +static int32_t fcoder_metacmd_ID_set_bindings_mac_default = 170; +static int32_t fcoder_metacmd_ID_set_mark = 171; +static int32_t fcoder_metacmd_ID_setup_build_bat = 172; +static int32_t fcoder_metacmd_ID_setup_build_bat_and_sh = 173; +static int32_t fcoder_metacmd_ID_setup_build_sh = 174; +static int32_t fcoder_metacmd_ID_setup_new_project = 175; +static int32_t fcoder_metacmd_ID_show_filebar = 176; +static int32_t fcoder_metacmd_ID_show_scrollbar = 177; +static int32_t fcoder_metacmd_ID_snipe_token_or_word = 178; +static int32_t fcoder_metacmd_ID_snipe_token_or_word_right = 179; +static int32_t fcoder_metacmd_ID_suppress_mouse = 180; +static int32_t fcoder_metacmd_ID_swap_buffers_between_panels = 181; +static int32_t fcoder_metacmd_ID_to_lowercase = 182; +static int32_t fcoder_metacmd_ID_to_uppercase = 183; +static int32_t fcoder_metacmd_ID_toggle_filebar = 184; +static int32_t fcoder_metacmd_ID_toggle_fullscreen = 185; +static int32_t fcoder_metacmd_ID_toggle_line_wrap = 186; +static int32_t fcoder_metacmd_ID_toggle_mouse = 187; +static int32_t fcoder_metacmd_ID_toggle_show_whitespace = 188; +static int32_t fcoder_metacmd_ID_toggle_virtual_whitespace = 189; +static int32_t fcoder_metacmd_ID_undo = 190; +static int32_t fcoder_metacmd_ID_view_buffer_other_panel = 191; +static int32_t fcoder_metacmd_ID_word_complete = 192; +static int32_t fcoder_metacmd_ID_write_and_auto_tab = 193; +static int32_t fcoder_metacmd_ID_write_block = 194; +static int32_t fcoder_metacmd_ID_write_character = 195; +static int32_t fcoder_metacmd_ID_write_hack = 196; +static int32_t fcoder_metacmd_ID_write_note = 197; +static int32_t fcoder_metacmd_ID_write_todo = 198; +static int32_t fcoder_metacmd_ID_write_underscore = 199; +static int32_t fcoder_metacmd_ID_write_zero_struct = 200; #endif diff --git a/4coder_generated/remapping.h b/4coder_generated/remapping.h index a35debe3..a609e934 100644 --- a/4coder_generated/remapping.h +++ b/4coder_generated/remapping.h @@ -151,20 +151,20 @@ bind(context, '0', MDFR_CTRL, write_zero_struct); bind(context, 'I', MDFR_CTRL, list_all_functions_current_buffer); end_map(context); begin_map(context, default_lister_ui_map); -bind_vanilla_keys(context, list_mode__write_character); -bind(context, key_esc, MDFR_NONE, list_mode__quit); -bind(context, '\n', MDFR_NONE, list_mode__activate); -bind(context, '\t', MDFR_NONE, list_mode__activate); -bind(context, key_back, MDFR_NONE, list_mode__backspace_text_field); -bind(context, key_up, MDFR_NONE, list_mode__move_up); -bind(context, key_page_up, MDFR_NONE, list_mode__move_up); -bind(context, key_down, MDFR_NONE, list_mode__move_down); -bind(context, key_page_down, MDFR_NONE, list_mode__move_down); -bind(context, key_mouse_wheel, MDFR_NONE, list_mode__wheel_scroll); -bind(context, key_mouse_left, MDFR_NONE, list_mode__mouse_press); -bind(context, key_mouse_left_release, MDFR_NONE, list_mode__mouse_release); -bind(context, key_mouse_move, MDFR_NONE, list_mode__repaint); -bind(context, key_animate, MDFR_NONE, list_mode__repaint); +bind_vanilla_keys(context, lister__write_character); +bind(context, key_esc, MDFR_NONE, lister__quit); +bind(context, '\n', MDFR_NONE, lister__activate); +bind(context, '\t', MDFR_NONE, lister__activate); +bind(context, key_back, MDFR_NONE, lister__backspace_text_field); +bind(context, key_up, MDFR_NONE, lister__move_up); +bind(context, key_page_up, MDFR_NONE, lister__move_up); +bind(context, key_down, MDFR_NONE, lister__move_down); +bind(context, key_page_down, MDFR_NONE, lister__move_down); +bind(context, key_mouse_wheel, MDFR_NONE, lister__wheel_scroll); +bind(context, key_mouse_left, MDFR_NONE, lister__mouse_press); +bind(context, key_mouse_left_release, MDFR_NONE, lister__mouse_release); +bind(context, key_mouse_move, MDFR_NONE, lister__repaint); +bind(context, key_animate, MDFR_NONE, lister__repaint); end_map(context); } void fill_keys_mac_default(Bind_Helper *context){ @@ -317,20 +317,20 @@ bind(context, '0', MDFR_CMND, write_zero_struct); bind(context, 'I', MDFR_CMND, list_all_functions_current_buffer); end_map(context); begin_map(context, default_lister_ui_map); -bind_vanilla_keys(context, list_mode__write_character); -bind(context, key_esc, MDFR_NONE, list_mode__quit); -bind(context, '\n', MDFR_NONE, list_mode__activate); -bind(context, '\t', MDFR_NONE, list_mode__activate); -bind(context, key_back, MDFR_NONE, list_mode__backspace_text_field); -bind(context, key_up, MDFR_NONE, list_mode__move_up); -bind(context, key_page_up, MDFR_NONE, list_mode__move_up); -bind(context, key_down, MDFR_NONE, list_mode__move_down); -bind(context, key_page_down, MDFR_NONE, list_mode__move_down); -bind(context, key_mouse_wheel, MDFR_NONE, list_mode__wheel_scroll); -bind(context, key_mouse_left, MDFR_NONE, list_mode__mouse_press); -bind(context, key_mouse_left_release, MDFR_NONE, list_mode__mouse_release); -bind(context, key_mouse_move, MDFR_NONE, list_mode__repaint); -bind(context, key_animate, MDFR_NONE, list_mode__repaint); +bind_vanilla_keys(context, lister__write_character); +bind(context, key_esc, MDFR_NONE, lister__quit); +bind(context, '\n', MDFR_NONE, lister__activate); +bind(context, '\t', MDFR_NONE, lister__activate); +bind(context, key_back, MDFR_NONE, lister__backspace_text_field); +bind(context, key_up, MDFR_NONE, lister__move_up); +bind(context, key_page_up, MDFR_NONE, lister__move_up); +bind(context, key_down, MDFR_NONE, lister__move_down); +bind(context, key_page_down, MDFR_NONE, lister__move_down); +bind(context, key_mouse_wheel, MDFR_NONE, lister__wheel_scroll); +bind(context, key_mouse_left, MDFR_NONE, lister__mouse_press); +bind(context, key_mouse_left_release, MDFR_NONE, lister__mouse_release); +bind(context, key_mouse_move, MDFR_NONE, lister__repaint); +bind(context, key_animate, MDFR_NONE, lister__repaint); end_map(context); } #endif @@ -516,20 +516,20 @@ static Meta_Key_Bind fcoder_binds_for_default_default_code_map[32] = { {0, 73, 1, "list_all_functions_current_buffer", 33, LINK_PROCS(list_all_functions_current_buffer)}, }; static Meta_Key_Bind fcoder_binds_for_default_default_lister_ui_map[14] = { -{1, 0, 0, "list_mode__write_character", 26, LINK_PROCS(list_mode__write_character)}, -{0, 55307, 0, "list_mode__quit", 15, LINK_PROCS(list_mode__quit)}, -{0, 10, 0, "list_mode__activate", 19, LINK_PROCS(list_mode__activate)}, -{0, 9, 0, "list_mode__activate", 19, LINK_PROCS(list_mode__activate)}, -{0, 55296, 0, "list_mode__backspace_text_field", 31, LINK_PROCS(list_mode__backspace_text_field)}, -{0, 55297, 0, "list_mode__move_up", 18, LINK_PROCS(list_mode__move_up)}, -{0, 55305, 0, "list_mode__move_up", 18, LINK_PROCS(list_mode__move_up)}, -{0, 55298, 0, "list_mode__move_down", 20, LINK_PROCS(list_mode__move_down)}, -{0, 55306, 0, "list_mode__move_down", 20, LINK_PROCS(list_mode__move_down)}, -{0, 55312, 0, "list_mode__wheel_scroll", 23, LINK_PROCS(list_mode__wheel_scroll)}, -{0, 55308, 0, "list_mode__mouse_press", 22, LINK_PROCS(list_mode__mouse_press)}, -{0, 55310, 0, "list_mode__mouse_release", 24, LINK_PROCS(list_mode__mouse_release)}, -{0, 55313, 0, "list_mode__repaint", 18, LINK_PROCS(list_mode__repaint)}, -{0, 55314, 0, "list_mode__repaint", 18, LINK_PROCS(list_mode__repaint)}, +{1, 0, 0, "lister__write_character", 23, LINK_PROCS(lister__write_character)}, +{0, 55307, 0, "lister__quit", 12, LINK_PROCS(lister__quit)}, +{0, 10, 0, "lister__activate", 16, LINK_PROCS(lister__activate)}, +{0, 9, 0, "lister__activate", 16, LINK_PROCS(lister__activate)}, +{0, 55296, 0, "lister__backspace_text_field", 28, LINK_PROCS(lister__backspace_text_field)}, +{0, 55297, 0, "lister__move_up", 15, LINK_PROCS(lister__move_up)}, +{0, 55305, 0, "lister__move_up", 15, LINK_PROCS(lister__move_up)}, +{0, 55298, 0, "lister__move_down", 17, LINK_PROCS(lister__move_down)}, +{0, 55306, 0, "lister__move_down", 17, LINK_PROCS(lister__move_down)}, +{0, 55312, 0, "lister__wheel_scroll", 20, LINK_PROCS(lister__wheel_scroll)}, +{0, 55308, 0, "lister__mouse_press", 19, LINK_PROCS(lister__mouse_press)}, +{0, 55310, 0, "lister__mouse_release", 21, LINK_PROCS(lister__mouse_release)}, +{0, 55313, 0, "lister__repaint", 15, LINK_PROCS(lister__repaint)}, +{0, 55314, 0, "lister__repaint", 15, LINK_PROCS(lister__repaint)}, }; static Meta_Sub_Map fcoder_submaps_for_default[4] = { {"mapid_global", 12, "The following bindings apply in all situations.", 47, 0, 0, fcoder_binds_for_default_mapid_global, 45}, @@ -685,20 +685,20 @@ static Meta_Key_Bind fcoder_binds_for_mac_default_default_code_map[32] = { {0, 73, 4, "list_all_functions_current_buffer", 33, LINK_PROCS(list_all_functions_current_buffer)}, }; static Meta_Key_Bind fcoder_binds_for_mac_default_default_lister_ui_map[14] = { -{1, 0, 0, "list_mode__write_character", 26, LINK_PROCS(list_mode__write_character)}, -{0, 55307, 0, "list_mode__quit", 15, LINK_PROCS(list_mode__quit)}, -{0, 10, 0, "list_mode__activate", 19, LINK_PROCS(list_mode__activate)}, -{0, 9, 0, "list_mode__activate", 19, LINK_PROCS(list_mode__activate)}, -{0, 55296, 0, "list_mode__backspace_text_field", 31, LINK_PROCS(list_mode__backspace_text_field)}, -{0, 55297, 0, "list_mode__move_up", 18, LINK_PROCS(list_mode__move_up)}, -{0, 55305, 0, "list_mode__move_up", 18, LINK_PROCS(list_mode__move_up)}, -{0, 55298, 0, "list_mode__move_down", 20, LINK_PROCS(list_mode__move_down)}, -{0, 55306, 0, "list_mode__move_down", 20, LINK_PROCS(list_mode__move_down)}, -{0, 55312, 0, "list_mode__wheel_scroll", 23, LINK_PROCS(list_mode__wheel_scroll)}, -{0, 55308, 0, "list_mode__mouse_press", 22, LINK_PROCS(list_mode__mouse_press)}, -{0, 55310, 0, "list_mode__mouse_release", 24, LINK_PROCS(list_mode__mouse_release)}, -{0, 55313, 0, "list_mode__repaint", 18, LINK_PROCS(list_mode__repaint)}, -{0, 55314, 0, "list_mode__repaint", 18, LINK_PROCS(list_mode__repaint)}, +{1, 0, 0, "lister__write_character", 23, LINK_PROCS(lister__write_character)}, +{0, 55307, 0, "lister__quit", 12, LINK_PROCS(lister__quit)}, +{0, 10, 0, "lister__activate", 16, LINK_PROCS(lister__activate)}, +{0, 9, 0, "lister__activate", 16, LINK_PROCS(lister__activate)}, +{0, 55296, 0, "lister__backspace_text_field", 28, LINK_PROCS(lister__backspace_text_field)}, +{0, 55297, 0, "lister__move_up", 15, LINK_PROCS(lister__move_up)}, +{0, 55305, 0, "lister__move_up", 15, LINK_PROCS(lister__move_up)}, +{0, 55298, 0, "lister__move_down", 17, LINK_PROCS(lister__move_down)}, +{0, 55306, 0, "lister__move_down", 17, LINK_PROCS(lister__move_down)}, +{0, 55312, 0, "lister__wheel_scroll", 20, LINK_PROCS(lister__wheel_scroll)}, +{0, 55308, 0, "lister__mouse_press", 19, LINK_PROCS(lister__mouse_press)}, +{0, 55310, 0, "lister__mouse_release", 21, LINK_PROCS(lister__mouse_release)}, +{0, 55313, 0, "lister__repaint", 15, LINK_PROCS(lister__repaint)}, +{0, 55314, 0, "lister__repaint", 15, LINK_PROCS(lister__repaint)}, }; static Meta_Sub_Map fcoder_submaps_for_mac_default[4] = { {"mapid_global", 12, "The following bindings apply in all situations.", 47, 0, 0, fcoder_binds_for_mac_default_mapid_global, 45}, diff --git a/4coder_helper.cpp b/4coder_helper.cpp index 99c38651..f497235e 100644 --- a/4coder_helper.cpp +++ b/4coder_helper.cpp @@ -564,6 +564,21 @@ buffer_identifier_to_id(Application_Links *app, Buffer_Identifier identifier){ return(id); } +static Buffer_Summary +buffer_identifier_to_buffer_summary(Application_Links *app, Buffer_Identifier identifier, Access_Flag access){ + Buffer_Summary buffer = {0}; + if (identifier.id != 0){ + buffer = get_buffer(app, identifier.id, access); + } + else{ + buffer = get_buffer_by_name(app, identifier.name, identifier.name_len, access); + if (!buffer.exists){ + buffer = get_buffer_by_file_name(app, identifier.name, identifier.name_len, access); + } + } + return(buffer); +} + static bool32 view_open_file(Application_Links *app, View_Summary *view, char *filename, int32_t filename_len, bool32 never_new){ @@ -607,6 +622,17 @@ get_view_prev(Application_Links *app, View_Summary *view, uint32_t access){ } } +static Buffer_Kill_Result +kill_buffer(Application_Links *app, Buffer_Identifier identifier, View_ID gui_view_id, Buffer_Kill_Flag flags){ + Buffer_Kill_Result result = kill_buffer(app, identifier, flags); + if (result == BufferKillResult_Dirty){ + Buffer_Summary buffer = buffer_identifier_to_buffer_summary(app, identifier, AccessAll); + View_Summary view = get_view(app, gui_view_id, AccessAll); + do_gui_sure_to_kill(app, &buffer, &view); + } + return(result); +} + static View_Summary get_view_last(Application_Links *app, uint32_t access){ View_Summary view = {0}; diff --git a/4coder_lists.cpp b/4coder_lists.cpp index eecc6b19..432c0197 100644 --- a/4coder_lists.cpp +++ b/4coder_lists.cpp @@ -5,8 +5,8 @@ such as open file, switch buffer, or kill buffer. // TOP -CUSTOM_COMMAND_SIG(list_mode__quit) -CUSTOM_DOC("A list mode command that quits the list without executing any actions.") +CUSTOM_COMMAND_SIG(lister__quit) +CUSTOM_DOC("A lister mode command that quits the list without executing any actions.") { View_Summary view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(&view); @@ -14,9 +14,11 @@ CUSTOM_DOC("A list mode command that quits the list without executing any action view_end_ui_mode(app, &view); } -CUSTOM_COMMAND_SIG(list_mode__activate) -CUSTOM_DOC("A list mode command that activates the list's action on the highlighted item.") +CUSTOM_COMMAND_SIG(lister__activate) +CUSTOM_DOC("A lister mode command that activates the list's action on the highlighted item.") { + Partition *scratch = &global_part; + General_Memory *general = &global_general; View_Summary view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(&view); if (state->initialized){ @@ -24,13 +26,108 @@ CUSTOM_DOC("A list mode command that activates the list's action on the highligh if (0 <= state->raw_item_index && state->raw_item_index < state->lister.options.count){ user_data = lister_get_user_data(&state->lister, state->raw_item_index); } - lister_call_activate_handler(app, &global_part, &global_general, &view, + lister_call_activate_handler(app, scratch, general, &view, state, user_data, false); } } -CUSTOM_COMMAND_SIG(list_mode__write_character__default) -CUSTOM_DOC("A list mode command that inserts a new character to the text field.") +CUSTOM_COMMAND_SIG(lister__write_character) +CUSTOM_DOC("A lister mode command that dispatches to the lister's write character handler.") +{ + View_Summary view = get_active_view(app, AccessAll); + Lister_State *state = view_get_lister_state(&view); + if (state->lister.handlers.write_character != 0){ + state->lister.handlers.write_character(app); + } +} + +CUSTOM_COMMAND_SIG(lister__backspace_text_field) +CUSTOM_DOC("A lister mode command that dispatches to the lister's backspace text field handler.") +{ + View_Summary view = get_active_view(app, AccessAll); + Lister_State *state = view_get_lister_state(&view); + if (state->lister.handlers.backspace != 0){ + state->lister.handlers.backspace(app); + } +} + +CUSTOM_COMMAND_SIG(lister__move_up) +CUSTOM_DOC("A lister mode command that dispatches to the lister's navigate up handler.") +{ + View_Summary view = get_active_view(app, AccessAll); + Lister_State *state = view_get_lister_state(&view); + if (state->lister.handlers.navigate_up != 0){ + state->lister.handlers.navigate_up(app); + } +} + +CUSTOM_COMMAND_SIG(lister__move_down) +CUSTOM_DOC("A lister mode command that dispatches to the lister's navigate down handler.") +{ + View_Summary view = get_active_view(app, AccessAll); + Lister_State *state = view_get_lister_state(&view); + if (state->lister.handlers.navigate_down != 0){ + state->lister.handlers.navigate_down(app); + } +} + +CUSTOM_COMMAND_SIG(lister__wheel_scroll) +CUSTOM_DOC("A lister mode command that scrolls the list in response to the mouse wheel.") +{ + Partition *scratch = &global_part; + View_Summary view = get_active_view(app, AccessAll); + GUI_Scroll_Vars scroll = view.scroll_vars; + Mouse_State mouse = get_mouse_state(app); + scroll.target_y += mouse.wheel; + view_set_scroll(app, &view, scroll); + Lister_State *state = view_get_lister_state(&view); + if (state->initialized){ + lister_update_ui(app, scratch, &view, state); + } +} + +CUSTOM_COMMAND_SIG(lister__mouse_press) +CUSTOM_DOC("A lister mode command that beings a click interaction with a list item under the mouse.") +{ + Partition *scratch = &global_part; + View_Summary view = get_active_view(app, AccessAll); + Lister_State *state = view_get_lister_state(&view); + if (state->initialized){ + UI_Item clicked = lister_get_clicked_item(app, &view, scratch); + state->hot_user_data = clicked.user_data; + } +} + +CUSTOM_COMMAND_SIG(lister__mouse_release) +CUSTOM_DOC("A lister mode command that ends a click interaction with a list item under the mouse, possibly activating it.") +{ + Partition *scratch = &global_part; + General_Memory *general = &global_general; + View_Summary view = get_active_view(app, AccessAll); + Lister_State *state = view_get_lister_state(&view); + if (state->initialized && state->hot_user_data != 0){ + UI_Item clicked = lister_get_clicked_item(app, &view, scratch); + if (state->hot_user_data == clicked.user_data){ + lister_call_activate_handler(app, scratch, general, &view, + state, clicked.user_data, true); + } + } + state->hot_user_data = 0; +} + +CUSTOM_COMMAND_SIG(lister__repaint) +CUSTOM_DOC("A lister mode command that updates the lists UI data.") +{ + Partition *scratch = &global_part; + View_Summary view = get_active_view(app, AccessAll); + Lister_State *state = view_get_lister_state(&view); + if (state->initialized){ + lister_update_ui(app, scratch, &view, state); + } +} + +CUSTOM_COMMAND_SIG(lister__write_character__default) +CUSTOM_DOC("A lister mode command that inserts a new character to the text field.") { Partition *scratch = &global_part; View_Summary view = get_active_view(app, AccessAll); @@ -49,8 +146,8 @@ CUSTOM_DOC("A list mode command that inserts a new character to the text field." } } -CUSTOM_COMMAND_SIG(list_mode__backspace_text_field__default) -CUSTOM_DOC("A list mode command that backspaces one character from the text field.") +CUSTOM_COMMAND_SIG(lister__backspace_text_field__default) +CUSTOM_DOC("A lister mode command that backspaces one character from the text field.") { Partition *scratch = &global_part; View_Summary view = get_active_view(app, AccessAll); @@ -64,8 +161,8 @@ CUSTOM_DOC("A list mode command that backspaces one character from the text fiel } } -CUSTOM_COMMAND_SIG(list_mode__move_up__default) -CUSTOM_DOC("A list mode command that moves the highlighted item one up in the list.") +CUSTOM_COMMAND_SIG(lister__move_up__default) +CUSTOM_DOC("A lister mode command that moves the highlighted item one up in the list.") { Partition *scratch = &global_part; View_Summary view = get_active_view(app, AccessAll); @@ -80,8 +177,8 @@ CUSTOM_DOC("A list mode command that moves the highlighted item one up in the li } } -CUSTOM_COMMAND_SIG(list_mode__move_down__default) -CUSTOM_DOC("A list mode command that moves the highlighted item one down in the list.") +CUSTOM_COMMAND_SIG(lister__move_down__default) +CUSTOM_DOC("A lister mode command that moves the highlighted item one down in the list.") { Partition *scratch = &global_part; View_Summary view = get_active_view(app, AccessAll); @@ -96,8 +193,8 @@ CUSTOM_DOC("A list mode command that moves the highlighted item one down in the } } -CUSTOM_COMMAND_SIG(list_mode__write_character__file_path) -CUSTOM_DOC("A list mode command that inserts a new character to the text field.") +CUSTOM_COMMAND_SIG(lister__write_character__file_path) +CUSTOM_DOC("A lister mode command that inserts a character into the text field of a file system list.") { Partition *scratch = &global_part; View_Summary view = get_active_view(app, AccessAll); @@ -121,8 +218,8 @@ CUSTOM_DOC("A list mode command that inserts a new character to the text field." } } -CUSTOM_COMMAND_SIG(list_mode__backspace_text_field__file_path) -CUSTOM_DOC("A list mode command that backspaces one character from the text field.") +CUSTOM_COMMAND_SIG(lister__backspace_text_field__file_path) +CUSTOM_DOC("A lister mode command that backspaces one character from the text field of a file system list.") { Partition *scratch = &global_part; View_Summary view = get_active_view(app, AccessAll); @@ -156,110 +253,133 @@ CUSTOM_DOC("A list mode command that backspaces one character from the text fiel } } -CUSTOM_COMMAND_SIG(list_mode__write_character) -CUSTOM_DOC("A list mode command that inserts a new character to the text field.") -{ - View_Summary view = get_active_view(app, AccessAll); - Lister_State *state = view_get_lister_state(&view); - if (state->lister.write_character != 0){ - state->lister.write_character(app); - } -} - -CUSTOM_COMMAND_SIG(list_mode__backspace_text_field) -CUSTOM_DOC("A list mode command that backspaces one character from the text field.") -{ - View_Summary view = get_active_view(app, AccessAll); - Lister_State *state = view_get_lister_state(&view); - if (state->lister.backspace != 0){ - state->lister.backspace(app); - } -} - -CUSTOM_COMMAND_SIG(list_mode__move_up) -CUSTOM_DOC("A list mode command that moves the highlighted item one up in the list.") -{ - View_Summary view = get_active_view(app, AccessAll); - Lister_State *state = view_get_lister_state(&view); - if (state->lister.navigate_up != 0){ - state->lister.navigate_up(app); - } -} - -CUSTOM_COMMAND_SIG(list_mode__move_down) -CUSTOM_DOC("A list mode command that moves the highlighted item one down in the list.") -{ - View_Summary view = get_active_view(app, AccessAll); - Lister_State *state = view_get_lister_state(&view); - if (state->lister.navigate_down != 0){ - state->lister.navigate_down(app); - } -} - -CUSTOM_COMMAND_SIG(list_mode__wheel_scroll) -CUSTOM_DOC("A list mode command that scrolls the list in response to the mouse wheel.") -{ - Partition *scratch = &global_part; - View_Summary view = get_active_view(app, AccessAll); - GUI_Scroll_Vars scroll = view.scroll_vars; - Mouse_State mouse = get_mouse_state(app); - scroll.target_y += mouse.wheel; - view_set_scroll(app, &view, scroll); - Lister_State *state = view_get_lister_state(&view); - if (state->initialized){ - lister_update_ui(app, scratch, &view, state); - } -} - -CUSTOM_COMMAND_SIG(list_mode__mouse_press) -CUSTOM_DOC("A list mode command that beings a click interaction with a list item under the mouse.") +CUSTOM_COMMAND_SIG(lister__write_character__fixed_list) +CUSTOM_DOC("A lister mode command that handles input for the fixed sure to kill list.") { Partition *scratch = &global_part; + General_Memory *general = &global_general; View_Summary view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(&view); if (state->initialized){ - UI_Item clicked = lister_get_clicked_item(app, &view, scratch); - state->hot_user_data = clicked.user_data; - } -} - -CUSTOM_COMMAND_SIG(list_mode__mouse_release) -CUSTOM_DOC("A list mode command that ends a click interaction with a list item under the mouse, possibly activating it.") -{ - Partition *scratch = &global_part; - View_Summary view = get_active_view(app, AccessAll); - Lister_State *state = view_get_lister_state(&view); - if (state->initialized && state->hot_user_data != 0){ - UI_Item clicked = lister_get_clicked_item(app, &view, scratch); - if (state->hot_user_data == clicked.user_data){ - lister_call_activate_handler(app, &global_part, &global_general, &view, - state, clicked.user_data, true); + User_Input in = get_command_input(app); + uint8_t character[4]; + uint32_t length = to_writable_character(in, character); + if (length > 0){ + void *user_data = 0; + bool32 did_shortcut_key = false; + for (Lister_Option_Node *node = state->lister.options.first; + node != 0; + node = node->next){ + char *hotkeys = (char*)(node + 1); + if (has_substr(hotkeys, make_string(character, length))){ + user_data = node->user_data; + did_shortcut_key = true; + break; + } + } + if (did_shortcut_key){ + lister_call_activate_handler(app, scratch, general, + &view, state, + user_data, false); + } } } - state->hot_user_data = 0; -} - -CUSTOM_COMMAND_SIG(list_mode__repaint) -CUSTOM_DOC("A list mode command that updates the lists UI data.") -{ - Partition *scratch = &global_part; - View_Summary view = get_active_view(app, AccessAll); - Lister_State *state = view_get_lister_state(&view); - if (state->initialized){ - lister_update_ui(app, scratch, &view, state); - } } //////////////////////////////// -static void -list_mode_use_default_handlers(Lister *lister){ - lister->write_character = list_mode__write_character__default; - lister->backspace = list_mode__backspace_text_field__default; - lister->navigate_up = list_mode__move_up__default; - lister->navigate_down = list_mode__move_down__default; +static Lister_Handlers +lister_get_default_handlers(void){ + Lister_Handlers handlers = {0}; + handlers.write_character = lister__write_character__default; + handlers.backspace = lister__backspace_text_field__default; + handlers.navigate_up = lister__move_up__default; + handlers.navigate_down = lister__move_down__default; + return(handlers); } +static Lister_Handlers +lister_get_fixed_list_handlers(void){ + Lister_Handlers handlers = {0}; + handlers.write_character = lister__write_character__fixed_list; + handlers.backspace = 0; + handlers.navigate_up = lister__move_up__default; + handlers.navigate_down = lister__move_down__default; + return(handlers); +} + +static void +begin_integrated_lister__with_refresh_handler(Application_Links *app, char *query_string, + Lister_Handlers handlers, void *user_data, + View_Summary *view){ + if (handlers.refresh != 0){ + Partition *scratch = &global_part; + General_Memory *general = &global_general; + view_start_ui_mode(app, view); + view_set_setting(app, view, ViewSetting_UICommandMap, default_lister_ui_map); + Lister_State *state = view_get_lister_state(view); + init_lister_state(state, general); + lister_first_init(&state->lister); + lister_set_query_string(&state->lister, query_string); + state->lister.handlers = handlers; + state->lister.user_data = user_data; + handlers.refresh(app, &state->arena, &state->lister); + lister_update_ui(app, scratch, view, state); + } + else{ + char space[256]; + String str = make_fixed_width_string(space); + append(&str, "ERROR: No refresh handler specified for lister (query_string = \""); + append(&str, query_string); + append(&str, "\")\n"); + print_message(app, str.str, str.size); + } +} + +static void +begin_integrated_lister__with_fixed_options(Application_Links *app, char *query_string, + Lister_Handlers handlers, void *user_data, + Lister_Fixed_Option *options, int32_t option_count, + View_Summary *view){ + Partition *scratch = &global_part; + General_Memory *general = &global_general; + view_start_ui_mode(app, view); + view_set_setting(app, view, ViewSetting_UICommandMap, default_lister_ui_map); + Lister_State *state = view_get_lister_state(view); + init_lister_state(state, general); + lister_first_init(&state->lister); + for (int32_t i = 0; i < option_count; i += 1){ + char *shortcut_chars = options[i].shortcut_chars; + int32_t shortcut_chars_length = str_size(shortcut_chars); + void *extra = lister_add_item(&state->arena, &state->lister, + make_string_slowly(options[i].string), + make_string_slowly(options[i].status), + options[i].user_data, + shortcut_chars_length + 1); + memcpy(extra, shortcut_chars, shortcut_chars_length + 1); + } + lister_set_query_string(&state->lister, query_string); + state->lister.handlers = handlers; + state->lister.handlers.refresh = 0; + state->lister.user_data = user_data; + lister_update_ui(app, scratch, view, state); +} + +static void +begin_integrated_lister__with_fixed_options(Application_Links *app, char *query_string, + Lister_Activation_Function_Type *activate, void *user_data, + Lister_Fixed_Option *options, int32_t option_count, + View_Summary *view){ + Lister_Handlers handlers = lister_get_fixed_list_handlers(); + handlers.activate = activate; + begin_integrated_lister__with_fixed_options(app, query_string, + handlers, user_data, + options, option_count, + view); +} + +//////////////////////////////// + static void generate_all_buffers_list(Application_Links *app, Partition *arena, Lister *lister){ lister_begin_new_item_set(lister); @@ -274,7 +394,7 @@ generate_all_buffers_list(Application_Links *app, Partition *arena, Lister *list case DirtyState_UnsavedChanges: status = make_lit_string(" *"); break; case DirtyState_UnloadedChanges: status = make_lit_string(" !"); break; } - lister_add_item(arena, lister, buffer_name, status, (void*)buffer_id); + lister_add_item(arena, lister, buffer_name, status, (void*)buffer_id, 0); } } @@ -309,7 +429,7 @@ generate_hot_directory_file_list(Application_Links *app, Partition *arena, Liste make_string(info->filename, info->filename_len), "/", ""); String status = make_lit_string(""); - lister_add_item(arena, lister, lister_prealloced(file_name), status, file_name.str); + lister_add_item(arena, lister, lister_prealloced(file_name), status, file_name.str, 0); } for (File_Info *info = file_list.infos, *one_past_last = file_list.infos + file_list.count; @@ -330,12 +450,133 @@ generate_hot_directory_file_list(Application_Links *app, Partition *arena, Liste } } String status = build_string(arena, is_loaded, status_flag, ""); - lister_add_item(arena, lister, lister_prealloced(file_name), lister_prealloced(status), file_name.str); + lister_add_item(arena, lister, lister_prealloced(file_name), lister_prealloced(status), file_name.str, 0); } free_file_list(app, file_list); } } +static void +begin_integrated_lister__buffer_list(Application_Links *app, char *query_string, + Lister_Activation_Function_Type *activate_procedure, void *user_data, + View_Summary *target_view){ + Lister_Handlers handlers = lister_get_default_handlers(); + handlers.activate = activate_procedure; + handlers.refresh = generate_all_buffers_list; + begin_integrated_lister__with_refresh_handler(app, query_string, handlers, user_data, target_view); +} + +static void +begin_integrated_lister__file_system_list(Application_Links *app, char *query_string, + Lister_Activation_Function_Type *activate_procedure, + void *user_data, + View_Summary *target_view){ + Lister_Handlers handlers = lister_get_default_handlers(); + handlers.activate = activate_procedure; + handlers.refresh = generate_hot_directory_file_list; + handlers.write_character = lister__write_character__file_path; + handlers.backspace = lister__backspace_text_field__file_path; + begin_integrated_lister__with_refresh_handler(app, query_string, handlers, user_data, target_view); +} + +//////////////////////////////// + +enum{ + SureToKill_NULL = 0, + SureToKill_No = 1, + SureToKill_Yes = 2, + SureToKill_Save = 3, +}; + +static Lister_Activation_Code +activate_confirm_kill(Application_Links *app, View_Summary *view, String text_field, + void *user_data, bool32 clicked){ + int32_t behavior = (int32_t)user_data; + Lister_State *state = view_get_lister_state(view); + Buffer_ID buffer_id = (Buffer_ID)(state->lister.user_data); + switch (behavior){ + case SureToKill_No: + {}break; + + case SureToKill_Yes: + { + kill_buffer(app, buffer_identifier(buffer_id), BufferKill_AlwaysKill); + }break; + + case SureToKill_Save: + { + Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll); + if (save_buffer(app, &buffer, buffer.file_name, buffer.file_name_len, BufferSave_IgnoreDirtyFlag)){ + kill_buffer(app, buffer_identifier(buffer_id), BufferKill_AlwaysKill); + } + else{ + char space[256]; + String str = make_fixed_width_string(space); + append(&str, "Did not close '"); + append(&str, make_string(buffer.file_name, buffer.file_name_len)); + append(&str, "' because it did not successfully save.\n"); + print_message(app, str.str, str.size); + } + }break; + } + return(ListerActivation_Finished); +} + +static void +do_gui_sure_to_kill(Application_Links *app, Buffer_Summary *buffer, View_Summary *view){ + Lister_Fixed_Option options[] = { + {"(N)o" , "", "Nn", (void*)SureToKill_No }, + {"(Y)es" , "", "Yy", (void*)SureToKill_Yes }, + {"(S)ave and Kill", "", "Ss", (void*)SureToKill_Save}, + }; + int32_t option_count = sizeof(options)/sizeof(options[0]); + begin_integrated_lister__with_fixed_options(app, "There are unsaved changes, close anyway?", + activate_confirm_kill, (void*)buffer->buffer_id, + options, option_count, + view); +} + +static Lister_Activation_Code +activate_confirm_close_4coder(Application_Links *app, View_Summary *view, String text_field, + void *user_data, bool32 clicked){ + int32_t behavior = (int32_t)user_data; + switch (behavior){ + case SureToKill_No: + {}break; + + case SureToKill_Yes: + { + allow_immediate_close_without_checking_for_changes = true; + send_exit_signal(app); + }break; + + case SureToKill_Save: + { + save_all_dirty_buffers(app); + allow_immediate_close_without_checking_for_changes = true; + send_exit_signal(app); + }break; + } + return(ListerActivation_Finished); +} + +static void +do_gui_sure_to_close_4coder(Application_Links *app, View_Summary *view){ + Lister_Fixed_Option options[] = { + {"(N)o" , "", "Nn", (void*)SureToKill_No }, + {"(Y)es" , "", "Yy", (void*)SureToKill_Yes }, + {"(S)ave All and Close", "", "Ss", (void*)SureToKill_Save}, + }; + int32_t option_count = sizeof(options)/sizeof(options[0]); + begin_integrated_lister__with_fixed_options(app, + "There are one or more buffers with unsave changes, close anyway?", + activate_confirm_close_4coder, 0, + options, option_count, + view); +} + +//////////////////////////////// + static Lister_Activation_Code activate_switch_buffer(Application_Links *app, View_Summary *view, String text_field, void *user_data, bool32 activated_by_mouse){ @@ -349,20 +590,9 @@ activate_switch_buffer(Application_Links *app, View_Summary *view, String text_f CUSTOM_COMMAND_SIG(interactive_switch_buffer) CUSTOM_DOC("Interactively switch to an open buffer.") { - Partition *scratch = &global_part; View_Summary view = get_active_view(app, AccessAll); for (;view_end_ui_mode(app, &view);); - view_start_ui_mode(app, &view); - view_set_setting(app, &view, ViewSetting_UICommandMap, default_lister_ui_map); - Lister_State *state = view_get_lister_state(&view); - init_lister_state(state, &global_general); - lister_first_init(&state->lister); - lister_set_query_string(&state->lister, "Switch: "); - list_mode_use_default_handlers(&state->lister); - state->lister.activate = activate_switch_buffer; - state->lister.refresh = generate_all_buffers_list; - generate_all_buffers_list(app, &state->arena, &state->lister); - lister_update_ui(app, scratch, &view, state); + begin_integrated_lister__buffer_list(app, "Switch: ", activate_switch_buffer, 0, &view); } static Lister_Activation_Code @@ -378,106 +608,25 @@ activate_kill_buffer(Application_Links *app, View_Summary *view, String text_fie CUSTOM_COMMAND_SIG(interactive_kill_buffer) CUSTOM_DOC("Interactively kill an open buffer.") { - Partition *scratch = &global_part; View_Summary view = get_active_view(app, AccessAll); for (;view_end_ui_mode(app, &view);); - view_start_ui_mode(app, &view); - view_set_setting(app, &view, ViewSetting_UICommandMap, default_lister_ui_map); - Lister_State *state = view_get_lister_state(&view); - init_lister_state(state, &global_general); - lister_first_init(&state->lister); - lister_set_query_string(&state->lister, "Kill: "); - list_mode_use_default_handlers(&state->lister); - state->lister.activate = activate_kill_buffer; - state->lister.refresh = generate_all_buffers_list; - generate_all_buffers_list(app, &state->arena, &state->lister); - lister_update_ui(app, scratch, &view, state); + begin_integrated_lister__buffer_list(app, "Kill: ", activate_kill_buffer, 0, &view); } static Lister_Activation_Code -activate_open_or_new(Application_Links *app, View_Summary *view, String text_field, - void *user_data, bool32 activated_by_mouse){ - Partition *scratch = &global_part; +activate_open_or_new__generic(Application_Links *app, View_Summary *view, + String file_name, bool32 is_folder, + Buffer_Create_Flag flags){ Lister_Activation_Code result = 0; - Temp_Memory temp = begin_temp_memory(scratch); - String file_name = {0}; - if (user_data == 0){ - file_name = text_field; - } - else{ - file_name = make_string_slowly((char*)user_data); - } - if (file_name.size == 0){ - result = ListerActivation_Finished; - } - else{ - String full_file_name = get_hot_directory(app, scratch); - if (full_file_name.str[full_file_name.size - 1] != '/' && - full_file_name.str[full_file_name.size - 1] != '\\'){ - full_file_name = build_string(scratch, full_file_name, "/", file_name); - } - else{ - full_file_name = build_string(scratch, full_file_name, "", file_name); - } - if (file_name.str[file_name.size - 1] == '/' && user_data != 0){ - directory_set_hot(app, full_file_name.str, full_file_name.size); - result = ListerActivation_ContinueAndRefresh; - } - else{ - Buffer_Summary buffer = create_buffer(app, full_file_name.str, full_file_name.size, 0); - if (buffer.exists){ - view_set_buffer(app, view, buffer.buffer_id, SetBuffer_KeepOriginalGUI); - } - result = ListerActivation_Finished; - } - } - end_temp_memory(temp); - return(result); -} - -CUSTOM_COMMAND_SIG(interactive_open_or_new) -CUSTOM_DOC("Interactively open a file out of the file system.") -{ - Partition *scratch = &global_part; - View_Summary view = get_active_view(app, AccessAll); - for (;view_end_ui_mode(app, &view);); - view_start_ui_mode(app, &view); - view_set_setting(app, &view, ViewSetting_UICommandMap, default_lister_ui_map); - Lister_State *state = view_get_lister_state(&view); - init_lister_state(state, &global_general); - lister_first_init(&state->lister); - lister_set_query_string(&state->lister, "Open: "); - list_mode_use_default_handlers(&state->lister); - state->lister.write_character = list_mode__write_character__file_path; - state->lister.backspace = list_mode__backspace_text_field__file_path; - state->lister.activate = activate_open_or_new; - state->lister.refresh = generate_hot_directory_file_list; - generate_hot_directory_file_list(app, &state->arena, &state->lister); - lister_update_ui(app, scratch, &view, state); -} - -static Lister_Activation_Code -activate_new(Application_Links *app, View_Summary *view, String text_field, - void *user_data, bool32 activated_by_mouse){ - Partition *scratch = &global_part; - Lister_Activation_Code result = 0; - Temp_Memory temp = begin_temp_memory(scratch); - String file_name = front_of_directory(text_field); - bool32 is_folder = false; - if (user_data != 0){ - String item_name = make_string_slowly((char*)user_data); - if (item_name.str[item_name.size - 1] == '/'){ - file_name = item_name; - is_folder = true; - } - else if (activated_by_mouse){ - file_name = item_name; - } - } + if (file_name.size == 0){ + char msg[] = "Zero length file_name passed to activate_open_or_new__generic\n"; + print_message(app, msg, sizeof(msg) - 1); result = ListerActivation_Finished; } else{ + Partition *scratch = &global_part; + Temp_Memory temp = begin_temp_memory(scratch); String full_file_name = get_hot_directory(app, scratch); if (full_file_name.str[full_file_name.size - 1] != '/' && full_file_name.str[full_file_name.size - 1] != '\\'){ @@ -491,44 +640,85 @@ activate_new(Application_Links *app, View_Summary *view, String text_field, result = ListerActivation_ContinueAndRefresh; } else{ - Buffer_Summary buffer = create_buffer(app, full_file_name.str, full_file_name.size, BufferCreate_AlwaysNew); + Buffer_Summary buffer = create_buffer(app, full_file_name.str, full_file_name.size, flags); if (buffer.exists){ view_set_buffer(app, view, buffer.buffer_id, SetBuffer_KeepOriginalGUI); } result = ListerActivation_Finished; } + end_temp_memory(temp); + } + + return(result); +} + +static Lister_Activation_Code +activate_open_or_new(Application_Links *app, View_Summary *view, String text_field, + void *user_data, bool32 clicked){ + Lister_Activation_Code result = 0; + String file_name = {0}; + if (user_data == 0){ + file_name = front_of_directory(text_field); + } + else{ + file_name = make_string_slowly((char*)user_data); + } + if (file_name.size == 0){ + result = ListerActivation_Finished; + } + else{ + bool32 is_folder = (file_name.str[file_name.size - 1] == '/' && user_data != 0); + Buffer_Create_Flag flags = 0; + result = activate_open_or_new__generic(app, view, file_name, is_folder, flags); + } + return(result); +} + +CUSTOM_COMMAND_SIG(interactive_open_or_new) +CUSTOM_DOC("Interactively open a file out of the file system.") +{ + View_Summary view = get_active_view(app, AccessAll); + for (;view_end_ui_mode(app, &view);); + begin_integrated_lister__file_system_list(app, "Open: ", activate_open_or_new, 0, &view); +} + +static Lister_Activation_Code +activate_new(Application_Links *app, View_Summary *view, String text_field, + void *user_data, bool32 clicked){ + Lister_Activation_Code result = 0; + String file_name = front_of_directory(text_field); + if (user_data != 0){ + String item_name = make_string_slowly((char*)user_data); + if (item_name.str[item_name.size - 1] == '/'){ + file_name = item_name; + } + else if (clicked){ + file_name = item_name; + } + } + if (file_name.size == 0){ + result = ListerActivation_Finished; + } + else{ + bool32 is_folder = (file_name.str[file_name.size - 1] == '/' && user_data != 0); + Buffer_Create_Flag flags = BufferCreate_AlwaysNew; + result = activate_open_or_new__generic(app, view, file_name, is_folder, flags); } - end_temp_memory(temp); return(result); } CUSTOM_COMMAND_SIG(interactive_new) CUSTOM_DOC("Interactively creates a new file.") { - Partition *scratch = &global_part; View_Summary view = get_active_view(app, AccessAll); for (;view_end_ui_mode(app, &view);); - view_start_ui_mode(app, &view); - view_set_setting(app, &view, ViewSetting_UICommandMap, default_lister_ui_map); - Lister_State *state = view_get_lister_state(&view); - init_lister_state(state, &global_general); - lister_first_init(&state->lister); - lister_set_query_string(&state->lister, "New: "); - list_mode_use_default_handlers(&state->lister); - state->lister.write_character = list_mode__write_character__file_path; - state->lister.backspace = list_mode__backspace_text_field__file_path; - state->lister.activate = activate_new; - state->lister.refresh = generate_hot_directory_file_list; - generate_hot_directory_file_list(app, &state->arena, &state->lister); - lister_update_ui(app, scratch, &view, state); + begin_integrated_lister__file_system_list(app, "New: ", activate_new, 0, &view); } static Lister_Activation_Code activate_open(Application_Links *app, View_Summary *view, String text_field, - void *user_data, bool32 activated_by_mouse){ - Partition *scratch = &global_part; + void *user_data, bool32 clicked){ Lister_Activation_Code result = 0; - Temp_Memory temp = begin_temp_memory(scratch); String file_name = {0}; if (user_data != 0){ file_name = make_string_slowly((char*)user_data); @@ -537,49 +727,19 @@ activate_open(Application_Links *app, View_Summary *view, String text_field, result = ListerActivation_Finished; } else{ - String full_file_name = get_hot_directory(app, scratch); - if (full_file_name.str[full_file_name.size - 1] != '/' && - full_file_name.str[full_file_name.size - 1] != '\\'){ - full_file_name = build_string(scratch, full_file_name, "/", file_name); - } - else{ - full_file_name = build_string(scratch, full_file_name, "", file_name); - } - if (file_name.str[file_name.size - 1] == '/' && user_data != 0){ - directory_set_hot(app, full_file_name.str, full_file_name.size); - result = ListerActivation_ContinueAndRefresh; - } - else{ - Buffer_Summary buffer = create_buffer(app, full_file_name.str, full_file_name.size, 0); - if (buffer.exists){ - view_set_buffer(app, view, buffer.buffer_id, SetBuffer_KeepOriginalGUI); - } - result = ListerActivation_Finished; - } + bool32 is_folder = (file_name.str[file_name.size - 1] == '/' && user_data != 0); + Buffer_Create_Flag flags = BufferCreate_NeverNew; + result = activate_open_or_new__generic(app, view, file_name, is_folder, flags); } - end_temp_memory(temp); return(result); } CUSTOM_COMMAND_SIG(interactive_open) CUSTOM_DOC("Interactively opens a file.") { - Partition *scratch = &global_part; View_Summary view = get_active_view(app, AccessAll); for (;view_end_ui_mode(app, &view);); - view_start_ui_mode(app, &view); - view_set_setting(app, &view, ViewSetting_UICommandMap, default_lister_ui_map); - Lister_State *state = view_get_lister_state(&view); - init_lister_state(state, &global_general); - lister_first_init(&state->lister); - lister_set_query_string(&state->lister, "Open: "); - list_mode_use_default_handlers(&state->lister); - state->lister.write_character = list_mode__write_character__file_path; - state->lister.backspace = list_mode__backspace_text_field__file_path; - state->lister.activate = activate_open; - state->lister.refresh = generate_hot_directory_file_list; - generate_hot_directory_file_list(app, &state->arena, &state->lister); - lister_update_ui(app, scratch, &view, state); + begin_integrated_lister__file_system_list(app, "Open: ", activate_open, 0, &view); } // BOTTOM diff --git a/4coder_ui_helper.cpp b/4coder_ui_helper.cpp index 37dfc5f0..95f9bdd6 100644 --- a/4coder_ui_helper.cpp +++ b/4coder_ui_helper.cpp @@ -360,46 +360,49 @@ lister_begin_new_item_set(Lister *lister){ memset(&lister->options, 0, sizeof(lister->options)); } -static void +static void* lister_add_item(Partition *arena, Lister *lister, Lister_Prealloced_String string, Lister_Prealloced_String status, - void *user_data){ + void *user_data, int32_t extra_space){ Lister_Option_Node *node = push_array(arena, Lister_Option_Node, 1); node->string = string.string; node->status = status.string; node->user_data = user_data; zdll_push_back(lister->options.first, lister->options.last, node); lister->options.count += 1; + void *result = push_array(arena, char, extra_space); + push_align(arena, 8); + return(result); } -static void +static void* lister_add_item(Partition *arena, Lister *lister, Lister_Prealloced_String string, String status, - void *user_data){ - lister_add_item(arena, lister, - string, - lister_prealloced(push_string_copy(arena, status)), - user_data); + void *user_data, int32_t extra_space){ + return(lister_add_item(arena, lister, + string, + lister_prealloced(push_string_copy(arena, status)), + user_data, extra_space)); } -static void +static void* lister_add_item(Partition *arena, Lister *lister, String string, Lister_Prealloced_String status, - void *user_data){ - lister_add_item(arena, lister, - lister_prealloced(push_string_copy(arena, string)), - status, - user_data); + void *user_data, int32_t extra_space){ + return(lister_add_item(arena, lister, + lister_prealloced(push_string_copy(arena, string)), + status, + user_data, extra_space)); } -static void +static void* lister_add_item(Partition *arena, Lister *lister, String string, String status, - void *user_data){ - lister_add_item(arena, lister, - lister_prealloced(push_string_copy(arena, string)), - lister_prealloced(push_string_copy(arena, status)), - user_data); + void *user_data, int32_t extra_space){ + return(lister_add_item(arena, lister, + lister_prealloced(push_string_copy(arena, string)), + lister_prealloced(push_string_copy(arena, status)), + user_data, extra_space)); } static void* @@ -420,9 +423,9 @@ lister_get_user_data(Lister *lister, int32_t index){ static void lister_call_refresh_handler(Application_Links *app, Partition *arena, Lister *lister){ - if (lister->refresh != 0){ + if (lister->handlers.refresh != 0){ arena->pos = 0; - lister->refresh(app, arena, lister); + lister->handlers.refresh(app, arena, lister); } } @@ -432,17 +435,18 @@ lister_call_activate_handler(Application_Links *app, Partition *scratch, General void *user_data, bool32 activated_by_mouse){ Lister *lister = &state->lister; Lister_Activation_Code code = ListerActivation_Finished; - if (lister->activate != 0){ - code = lister->activate(app, view, lister->text_field, user_data, activated_by_mouse); + if (lister->handlers.activate != 0){ + code = lister->handlers.activate(app, view, lister->text_field, user_data, activated_by_mouse); } switch (code){ case ListerActivation_Finished: { - state->initialized = false; - view_end_ui_mode(app, view); - if (state->arena.base != 0){ - general_memory_free(general, state->arena.base); - memset(&state->arena, 0, sizeof(state->arena)); + if (view_end_ui_mode(app, view) == 0){ + state->initialized = false; + if (state->arena.base != 0){ + general_memory_free(general, state->arena.base); + memset(&state->arena, 0, sizeof(state->arena)); + } } }break; diff --git a/4coder_ui_helper.h b/4coder_ui_helper.h index 1a92b97d..13dc3467 100644 --- a/4coder_ui_helper.h +++ b/4coder_ui_helper.h @@ -33,17 +33,21 @@ struct Lister_Option_List{ int32_t count; }; -struct Lister{ - // Event Handlers +struct Lister_Handlers{ Lister_Activation_Function_Type *activate; Lister_Regenerate_List_Function_Type *refresh; Custom_Command_Function *write_character; Custom_Command_Function *backspace; Custom_Command_Function *navigate_up; Custom_Command_Function *navigate_down; - void *user_data; +}; + +struct Lister{ + // Event Handlers + Lister_Handlers handlers; // List Data + void *user_data; char query_space[256]; String query; char text_field_space[256]; @@ -68,6 +72,15 @@ struct Lister_State{ Lister lister; }; +//////////////////////////////// + +struct Lister_Fixed_Option{ + char *string; + char *status; + char *shortcut_chars; + void *user_data; +}; + #endif // BOTTOM diff --git a/4ed.cpp b/4ed.cpp index 27ddca5b..372f80d9 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -230,18 +230,6 @@ COMMAND_DECL(redo){ Assert(file->state.undo.undo.size >= 0); } -COMMAND_DECL(interactive_new){ - -} - -COMMAND_DECL(interactive_open){ - -} - -COMMAND_DECL(interactive_open_or_new){ - -} - // TODO(allen): Improvements to reopen // - Perform a diff // - If the diff is not tremendously big, apply the edits. @@ -327,23 +315,6 @@ COMMAND_DECL(save){ } } -COMMAND_DECL(interactive_switch_buffer){ - -} - -COMMAND_DECL(interactive_kill_buffer){ - -} - -COMMAND_DECL(kill_buffer){ - USE_MODELS(models); - USE_VIEW(view); - REQ_FILE(file, view); - if (interactive_try_kill_file(system, models, file) == TryKill_NeedDialogue){ - interactive_begin_sure_to_kill(system, view, models, file); - } -} - internal void case_change_range(System_Functions *system, Models *models, View *view, Editing_File *file, u8 a, u8 z, u8 char_delta){ Range range = {0}; @@ -375,10 +346,6 @@ case_change_range(System_Functions *system, Models *models, View *view, Editing_ } } -COMMAND_DECL(open_color_tweaker){ - -} - COMMAND_DECL(user_callback){ USE_MODELS(models); if (binding.custom != 0){ @@ -769,41 +736,15 @@ internal void setup_command_table(void){ #define SET(n) command_table[cmdid_##n] = command_##n SET(null); - SET(undo); SET(redo); - - SET(interactive_new); - SET(interactive_open); - SET(interactive_open_or_new); - SET(interactive_switch_buffer); - SET(interactive_kill_buffer); - SET(reopen); SET(save); - SET(kill_buffer); - - SET(open_color_tweaker); #undef SET } // App Functions -internal void -app_recording_emit_events(System_Functions *system, Models *models, Simulation_Event *new_events, i32 new_event_count){ - if (models->recorded_event_count + new_event_count > models->recorded_event_max){ - i32 new_max = 2*(models->recorded_event_count + new_event_count); - void *new_ptr = system->memory_allocate(sizeof(Simulation_Event)*new_max); - memmove(new_ptr, models->recorded_events, sizeof(*models->recorded_events)*models->recorded_event_count); - system->memory_free(models->recorded_events, sizeof(*models->recorded_events)*models->recorded_event_max); - models->recorded_events = (Simulation_Event*)new_ptr; - models->recorded_event_max = new_max; - } - - memcpy(models->recorded_events + models->recorded_event_count, new_events, sizeof(*new_events)*new_event_count); - models->recorded_event_count += new_event_count; -} - internal void app_hardcode_default_style(Models *models){ Interactive_Style file_info_style = {0}; @@ -906,9 +847,6 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings, case 'l': action = CLAct_LogStdout; --i; break; case 'L': action = CLAct_LogFile; --i; break; - - case 'T': action = CLAct_TestInput; break; - case 'R': action = CLAct_RecordInput; break; } } else if (arg[0] != 0){ @@ -1015,24 +953,6 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings, plat_settings->use_log = LogTo_LogFile; action = CLAct_Nothing; }break; - - case CLAct_TestInput: - { - if (i < argc){ - plat_settings->use_test_input = true; - plat_settings->test_input = argv[i]; - } - action = CLAct_Nothing; - }break; - - case CLAct_RecordInput: - { - if (i < argc){ - settings->make_input_recording = true; - settings->input_recording_output_file = argv[i]; - } - action = CLAct_Nothing; - }break; } }break; @@ -1068,8 +988,7 @@ App_Read_Command_Line_Sig(app_read_command_line){ i32 out_size = 0; App_Vars *vars = app_setup_memory(system, memory); App_Settings *settings = &vars->models.settings; - - *settings = null_app_settings; + memset(settings, 0, sizeof(*settings)); plat_settings->font_size = 16; if (argc > 1){ @@ -1246,16 +1165,6 @@ App_Init_Sig(app_init){ // NOTE(allen): init GUI keys models->user_up_key = key_up; models->user_down_key = key_down; - - // NOTE(allen): init recording - if (models->settings.make_input_recording){ - i32 max = KB(4)/sizeof(Simulation_Event); - void *ptr = system->memory_allocate(max*sizeof(Simulation_Event)); - - models->recorded_events = (Simulation_Event*)ptr; - models->recorded_event_count = 0; - models->recorded_event_max = max; - } } App_Step_Sig(app_step){ @@ -1266,102 +1175,6 @@ App_Step_Sig(app_step){ app_result.mouse_cursor_type = APP_MOUSE_CURSOR_DEFAULT; app_result.lctrl_lalt_is_altgr = models->settings.lctrl_lalt_is_altgr; - // NOTE(allen): Emit recorded events - if (models->settings.make_input_recording){ - local_const i32 max_possible_events = KEY_INPUT_BUFFER_SIZE + KEY_EXTRA_SIZE + 5; - Simulation_Event new_events[max_possible_events]; - i32 new_event_count = 0; - - i32 counter_index = models->frame_counter; - for (i32 i = 0; i < input->keys.count; ++i){ - Assert(new_event_count < max_possible_events); - Key_Event_Data key = input->keys.keys[i]; - Simulation_Event *new_event = new_events + (new_event_count++); - new_event->counter_index = counter_index; - new_event->type = SimulationEvent_Key; - new_event->key.code = key.keycode; - u8 modifier_flags = 0; -#define MDFR_FLAG_READ(I,F) if (key.modifiers[I]) { modifier_flags |= F; } - MDFR_FLAG_READ(MDFR_CONTROL_INDEX, MDFR_CTRL); - MDFR_FLAG_READ(MDFR_ALT_INDEX, MDFR_ALT); - MDFR_FLAG_READ(MDFR_COMMAND_INDEX, MDFR_CMND); - MDFR_FLAG_READ(MDFR_SHIFT_INDEX, MDFR_SHIFT); - new_event->key.modifiers = modifier_flags; - } - - if (input->mouse.press_l){ - Assert(new_event_count < max_possible_events); - Simulation_Event *new_event = new_events + (new_event_count++); - new_event->counter_index = counter_index; - new_event->type = SimulationEvent_MouseLeftPress; - } - - if (input->mouse.release_l){ - Assert(new_event_count < max_possible_events); - Simulation_Event *new_event = new_events + (new_event_count++); - new_event->counter_index = counter_index; - new_event->type = SimulationEvent_MouseLeftRelease; - } - - if (input->mouse.press_r){ - Assert(new_event_count < max_possible_events); - Simulation_Event *new_event = new_events + (new_event_count++); - new_event->counter_index = counter_index; - new_event->type = SimulationEvent_MouseRightPress; - } - - if (input->mouse.release_r){ - Assert(new_event_count < max_possible_events); - Simulation_Event *new_event = new_events + (new_event_count++); - new_event->counter_index = counter_index; - new_event->type = SimulationEvent_MouseRightRelease; - } - - if (input->mouse.wheel != 0){ - Assert(new_event_count < max_possible_events); - Simulation_Event *new_event = new_events + (new_event_count++); - new_event->counter_index = counter_index; - new_event->type = SimulationEvent_MouseWheel; - new_event->wheel = input->mouse.wheel; - } - - if (input->mouse.x != models->previous_mouse_x || - input->mouse.y != models->previous_mouse_y){ - Assert(new_event_count < max_possible_events); - Simulation_Event *new_event = new_events + (new_event_count++); - new_event->counter_index = counter_index; - new_event->type = SimulationEvent_MouseXY; - new_event->mouse_xy.x = input->mouse.x; - new_event->mouse_xy.y = input->mouse.y; - - models->previous_mouse_x = input->mouse.x; - models->previous_mouse_y = input->mouse.y; - } - - if (input->trying_to_kill){ - Assert(new_event_count < max_possible_events); - Simulation_Event *new_event = new_events + (new_event_count++); - new_event->counter_index = counter_index; - new_event->type = SimulationEvent_Exit; - } - - if (new_event_count > 0){ - app_recording_emit_events(system, models, new_events, new_event_count); - - Partition *scratch = &models->mem.part; - Temp_Memory temp = begin_temp_memory(scratch); - i32 event_count = models->recorded_event_count; - u32 data_size = 4 + sizeof(Simulation_Event)*event_count; - char *data = push_array(scratch, char, 0); - i32 *count = push_array(scratch, i32, 1); - *count = event_count; - Simulation_Event *events = push_array(scratch, Simulation_Event, event_count); - memcpy(events, models->recorded_events, sizeof(*models->recorded_events)*event_count); - system->save_file(models->settings.input_recording_output_file, data, data_size); - end_temp_memory(temp); - } - } - // NOTE(allen): OS clipboard event handling String clipboard = input->clipboard; if (clipboard.str){ @@ -1643,56 +1456,6 @@ App_Step_Sig(app_step){ } } - // NOTE(allen): respond if the user is trying to kill the application - if (input->trying_to_kill){ - b32 there_is_unsaved = false; - app_result.animating = true; - - for (File_Node *node = models->working_set.used_sentinel.next; - node != &models->working_set.used_sentinel; - node = node->next){ - Editing_File *file = (Editing_File*)node; - if (buffer_needs_save(file)){ - there_is_unsaved = true; - break; - } - } - - if (there_is_unsaved){ - Coroutine_Head *command_coroutine = models->command_coroutine; - Command_Data *command = cmd; - USE_VIEW(view); - - for (i32 i = 0; i < 128 && command_coroutine != 0; ++i){ - User_Input user_in = {0}; - user_in.abort = true; - - command_coroutine = app_resume_coroutine(system, &models->app_links, Co_Command, command_coroutine, &user_in, models->command_coroutine_flags); - } - if (command_coroutine != 0){ - // TODO(allen): post grave warning - command_coroutine = 0; - } - if (view != 0){ - init_query_set(&view->transient.query_set); - } - - if (view == 0){ - Panel *panel = models->layout.used_sentinel.next; - view = panel->view; - } - -#if 0 - view_show_interactive(system, view, models, IAct_Sure_To_Close, IInt_Sure_To_Close, make_lit_string("Are you sure?")); -#endif - - models->command_coroutine = command_coroutine; - } - else{ - models->keep_playing = 0; - } - } - // NOTE(allen): Get Available Input vars->available_input = init_available_input(&input->keys, &input->mouse); @@ -1718,9 +1481,12 @@ App_Step_Sig(app_step){ if ((get_flags & EventOnAnyKey) || (get_flags & EventOnEsc)){ for (i32 key_i = 0; key_i < key_data.count; ++key_i){ - Coroutine_Event *new_event = &events[event_count++]; - new_event->type = Event_Keyboard; - new_event->key_i = key_i; + Key_Code keycode = key_data.keys[key_i].keycode; + if (keycode != key_animate && keycode != key_mouse_move){ + Coroutine_Event *new_event = &events[event_count++]; + new_event->type = Event_Keyboard; + new_event->key_i = key_i; + } } } @@ -2110,10 +1876,17 @@ App_Step_Sig(app_step){ } } - // NOTE(allen): if this is the last frame, run the exit hook - if (!models->keep_playing && models->hooks[hook_exit] != 0){ - if (!models->hooks[hook_exit](&models->app_links)){ - models->keep_playing = true; + // NOTE(allen): If the exit signal has been sent, run the exit hook. + if (input->trying_to_kill){ + models->keep_playing = false; + } + if (!models->keep_playing){ + Hook_Function *exit_func = models->hooks[hook_exit]; + if (exit_func != 0){ + if (exit_func(&models->app_links) == 0){ + app_result.animating = true; + models->keep_playing = true; + } } } diff --git a/4ed.h b/4ed.h index 08a62298..ba1e0fd0 100644 --- a/4ed.h +++ b/4ed.h @@ -59,8 +59,6 @@ struct Plat_Settings{ b8 fullscreen_window; u8 use_log; - b8 use_test_input; - char *test_input; i32 window_w, window_h; i32 window_x, window_y; diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 9a4d82e8..a8947655 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -213,7 +213,9 @@ DOC_SEE(Command_ID) Command_Function *function = command_table[command_id]; Command_Binding binding = {}; binding.function = function; - if (function) function(cmd->system, cmd, binding); + if (function != 0){ + function(cmd->system, cmd, binding); + } result = true; } @@ -1313,21 +1315,28 @@ DOC_SEE(Buffer_Create_Flag) if (filename_len > 0){ Temp_Memory temp = begin_temp_memory(part); - // NOTE(allen): Try to get the file by canon name. String fname = make_string(filename, filename_len); Editing_File *file = 0; - b32 do_new_file = false; + b32 do_empty_buffer = false; Editing_File_Name canon = {0}; - if (get_canon_name(system, fname, &canon)){ - file = working_set_contains_canon(working_set, canon.name); - } - else{ - do_new_file = true; + b32 has_canon_name = false; + + // NOTE(allen): Try to get the file by canon name. + if ((flags & BufferCreate_NeverAttachToFile) == 0){ + if (get_canon_name(system, fname, &canon)){ + has_canon_name = true; + file = working_set_contains_canon(working_set, canon.name); + } + else{ + do_empty_buffer = true; + } } // NOTE(allen): Try to get the file by buffer name. - if (file == 0){ - file = working_set_contains_name(working_set, fname); + if ((flags & BufferCreate_MustAttachToFile) == 0){ + if (file == 0){ + file = working_set_contains_name(working_set, fname); + } } // NOTE(allen): If there is still no file, create a new buffer. @@ -1335,21 +1344,24 @@ DOC_SEE(Buffer_Create_Flag) Plat_Handle handle = {0}; // NOTE(allen): Figure out whether this is a new file, or an existing file. - if (!do_new_file){ + if (!do_empty_buffer){ if ((flags & BufferCreate_AlwaysNew) != 0){ - do_new_file = true; + do_empty_buffer = true; } else{ if (!system->load_handle(canon.name.str, &handle)){ - do_new_file = true; + do_empty_buffer = true; } } } - if (do_new_file){ + if (do_empty_buffer){ if ((flags & BufferCreate_NeverNew) == 0){ file = working_set_alloc_always(working_set, general); if (file != 0){ + if (has_canon_name){ + buffer_bind_file(system, general, working_set, file, canon.name); + } buffer_bind_name(models, general, part, working_set, file, front_of_directory(fname)); init_normal_file(system, models, 0, 0, file); fill_buffer_summary(&result, file, cmd); @@ -1448,53 +1460,70 @@ DOC_SEE(Buffer_Save_Flag) return(result); } -API_EXPORT bool32 -Kill_Buffer(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags) +API_EXPORT Buffer_Kill_Result +Kill_Buffer(Application_Links *app, Buffer_Identifier buffer, Buffer_Kill_Flag flags) /* DOC_PARAM(buffer, The buffer parameter specifies the buffer to try to kill.) -DOC_PARAM(view_id, The view_id parameter specifies the view that will contain the "are you sure" dialogue if the buffer is dirty.) DOC_PARAM(flags, The flags parameter specifies behaviors for the buffer kill.) -DOC_RETURN(This call returns non-zero if the buffer is killed.) +DOC_RETURN(This call returns BufferKillResult_Killed if the call successfully kills the buffer, +for extended information on other kill results see the Buffer_Kill_Result enumeration.) -DOC(Tries to kill the idenfied buffer. If the buffer is dirty and the "are you sure" -dialogue needs to be displayed the provided view is used to show the dialogue. -If the view is not open the kill fails.) +DOC(Tries to kill the idenfied buffer, if the buffer is dirty or does not exist then nothing will +happen. The default rules about when to kill or not kill a buffer can be altered by the flags.) +DOC_SEE(Buffer_Kill_Result) DOC_SEE(Buffer_Kill_Flag) DOC_SEE(Buffer_Identifier) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; System_Functions *system = cmd->system; Models *models = cmd->models; - - bool32 result = false; + Buffer_Kill_Result result = BufferKillResult_DoesNotExist; Working_Set *working_set = &models->working_set; Editing_File *file = get_file_from_identifier(system, working_set, buffer); if (file != 0){ - if ((flags & BufferKill_AlwaysKill) != 0){ - result = true; - kill_file_and_update_views(system, models, file); - } - else{ - Try_Kill_Result kill_result = interactive_try_kill_file(system, models, file); - if (kill_result == TryKill_NeedDialogue){ - View *vptr = imp_get_view(cmd, view_id); - if (vptr != 0){ - interactive_begin_sure_to_kill(system, vptr, models, file); + result = BufferKillResult_Unkillable; + if (!file->settings.never_kill){ + b32 needs_to_save = buffer_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.id); } - else{ - char m[] = "WARNING: the buffer is dirty and no view was specified for a dialogue.\n"; - print_message(app, m, sizeof(m) - 1); + + buffer_unbind_name_low_level(working_set, file); + if (file->canon.name.size != 0){ + buffer_unbind_file(system, working_set, file); } + file_free(system, &models->app_links, &models->mem.general, file); + working_set_free_file(&models->mem.general, working_set, file); + + File_Node *used = &working_set->used_sentinel; + File_Node *node = used->next; + for (Panel *panel = models->layout.used_sentinel.next; + panel != &models->layout.used_sentinel; + panel = panel->next){ + View *view = panel->view; + if (view->transient.file_data.file == file){ + Assert(node != used); + view->transient.file_data.file = 0; + view_set_file(system, models, view, (Editing_File*)node); + if (node->next != used){ + node = node->next; + } + else{ + node = node->next->next; + Assert(node != used); + } + } + } + + result = BufferKillResult_Killed; } else{ - if (kill_result == TryKill_Success){ - result = true; - } + result = BufferKillResult_Dirty; } } } - return(result); } @@ -2225,7 +2254,7 @@ View_End_UI_Mode(Application_Links *app, View_Summary *view){ vptr->transient.ui_mode_counter = clamp_bottom(0, vptr->transient.ui_mode_counter); if (vptr->transient.ui_mode_counter > 0){ vptr->transient.ui_mode_counter -= 1; - return(vptr->transient.ui_mode_counter + 1); + return(vptr->transient.ui_mode_counter); } else{ return(0); @@ -3054,11 +3083,15 @@ DOC(This call returns true if the 4coder is in full screen mode. This call take API_EXPORT void Send_Exit_Signal(Application_Links *app) /* -DOC(This call sends a signal to 4coder to attempt to exit. If there are unsaved files this triggers a dialogue ensuring you're okay with closing.) +DOC(This call sends a signal to 4coder to attempt to exit, which will trigger the exit hook before the end of the frame. That hook will have the chance to cancel the exit. + +In the default behavior of the exit hook, the exit is cancelled if there are unsaved changes, and instead a UI querying the user for permission to close without saving is presented, if the user confirms the UI sends another exit signal that will not be canceled. + +To make send_exit_signal exit no matter what, setup your hook in such a way that it knows when you are trying to exit no matter what, such as with a global variable that you set before calling send_exit_signal.) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; - System_Functions *system = cmd->system; - system->send_exit_signal(); + Models *models = cmd->models; + models->keep_playing = false; } API_EXPORT void diff --git a/4ed_app_models.h b/4ed_app_models.h index 4c86dfaf..ceade1f6 100644 --- a/4ed_app_models.h +++ b/4ed_app_models.h @@ -25,11 +25,7 @@ struct App_Settings{ i32 font_size; b32 use_hinting; - - b32 make_input_recording; - char *input_recording_output_file; }; -global_const App_Settings null_app_settings = {0}; struct Models{ Mem_Options mem; @@ -95,10 +91,6 @@ struct Models{ i32 previous_mouse_x; i32 previous_mouse_y; - - Simulation_Event *recorded_events; - i32 recorded_event_count; - i32 recorded_event_max; }; //////////////////////////////// @@ -203,8 +195,6 @@ enum Command_Line_Action{ CLAct_FontUseHinting, CLAct_LogStdout, CLAct_LogFile, - CLAct_TestInput, - CLAct_RecordInput, // CLAct_COUNT, }; diff --git a/4ed_app_target.cpp b/4ed_app_target.cpp index cf4df9d2..23067148 100644 --- a/4ed_app_target.cpp +++ b/4ed_app_target.cpp @@ -19,7 +19,6 @@ #include "4ed_math.h" #include "4ed_font.h" #include "4ed_system.h" -#include "4ed_input_simulation_event.h" #define PREFERRED_ALIGNMENT 8 #define USE_DEBUG_MEMORY diff --git a/4ed_input_simulation.cpp b/4ed_input_simulation.cpp deleted file mode 100644 index 3a64ed34..00000000 --- a/4ed_input_simulation.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Mr. 4th Dimention - Allen Webster - * - * 02.03.2018 - * - * Input simulation implementation - * - */ - -// TOP - -internal void -simulate_key(Application_Step_Input *input, - Key_Code keycode, Key_Code character, Key_Code character_no_caps_lock, i8 *modifiers){ - Key_Input_Data *keys = &input->keys; - Assert(keys->count < ArrayCount(keys->keys)); - Key_Event_Data *key = &keys->keys[keys->count++]; - key->keycode = keycode; - key->character = character; - key->character_no_caps_lock = character_no_caps_lock; - memcpy(key->modifiers, modifiers, sizeof(key->modifiers)); -} - -internal void -simulate_key(Application_Step_Input *input, - Key_Code code, i8 *modifiers){ - i32 size = 0; - char *keycode_name = global_key_name(code, &size); - if (keycode_name != 0){ - simulate_key(input, code, 0, 0, modifiers); - } - else{ - Key_Code no_caps = code; - if (modifiers[MDFR_CAPS_INDEX]){ - if (no_caps >= 'a' && no_caps <= 'z'){ - no_caps -= (u8)('a' - 'A'); - } - else if (no_caps >= 'A' && no_caps <= 'Z'){ - no_caps += (u8)('a' - 'A'); - } - } - simulate_key(input, code, code, no_caps, modifiers); - } -} - -internal void -simulate_key(Application_Step_Input *input, - Key_Code code, u8 modifiers){ - i8 mod_array[MDFR_INDEX_COUNT]; - memset(mod_array, 0, sizeof(mod_array)); - if (modifiers & MDFR_CTRL){ - mod_array[MDFR_CONTROL_INDEX] = 1; - } - if (modifiers & MDFR_ALT){ - mod_array[MDFR_ALT_INDEX] = 1; - } - if (modifiers & MDFR_CMND){ - mod_array[MDFR_COMMAND_INDEX] = 1; - } - if (modifiers & MDFR_SHIFT){ - mod_array[MDFR_SHIFT_INDEX] = 1; - } - simulate_key(input, code, mod_array); -} - -internal void -simulate_mouse_state(Application_Step_Input *input, Mouse_State state){ - input->mouse = state; -} - -internal void -simulate_mouse_update(Application_Step_Input *input, Mouse_State prev_mouse){ - input->mouse = prev_mouse; - input->mouse.press_l = false; - input->mouse.press_r = false; - input->mouse.release_l = false; - input->mouse.release_r = false; - input->mouse.wheel = 0; -} - -internal void -simulate_mouse_xy(Application_Step_Input *input, i32 x, i32 y, i32 width, i32 height){ - input->mouse.x = x; - input->mouse.y = y; - input->mouse.out_of_window = (x < 0 || y < 0 || x > width || y > height); -} - -internal void -simulate_mouse_left_press(Application_Step_Input *input){ - input->mouse.l = true; - input->mouse.press_l = true; -} - -internal void -simulate_mouse_left_release(Application_Step_Input *input){ - input->mouse.l = false; - input->mouse.release_l = true; -} - -internal void -simulate_mouse_right_press(Application_Step_Input *input){ - input->mouse.r = true; - input->mouse.press_r = true; -} - -internal void -simulate_mouse_right_release(Application_Step_Input *input){ - input->mouse.r = false; - input->mouse.release_r = true; -} - -internal void -simulate_mouse_wheel(Application_Step_Input *input, i32 wheel){ - input->mouse.wheel = wheel; -} - -internal void -simulate_exit(Application_Step_Input *input){ - input->trying_to_kill = true; -} - -//////////////// - -internal void -simulation_init(Input_Simulation_Controls *sim_controls){ - memset(sim_controls, 0, sizeof(*sim_controls)); - sim_controls->enforce_regular_mouse = true; -} - -internal void -simulation_step_begin(Input_Simulation_Controls *sim_controls, - Application_Step_Input *input, - b32 first_step, f32 dt){ - if (sim_controls->enforce_regular_mouse){ - simulate_mouse_update(input, sim_controls->prev_mouse); - } - input->first_step = first_step; - input->dt = dt; -} - -internal void -simulation_step_end(Input_Simulation_Controls *sim_controls, - Application_Step_Input *input){ - sim_controls->counter += 1; - sim_controls->prev_mouse = input->mouse; -} - -//////////////// - -internal void -simulation_stream_init(Simulation_Event_Stream_State *stream){ - stream->index = 0; -} - -internal void -simulation_drive_from_events(Input_Simulation_Controls *sim_controls, - Simulation_Event_Stream_State *stream, - Application_Step_Input *input, - Simulation_Event *events, i32 event_count, - i32 width, i32 height){ - Simulation_Event *event = events + stream->index; - for (; stream->index < event_count; ++stream->index, ++event){ - if (event->counter_index > sim_controls->counter){ - break; - } - - switch (event->type){ - case SimulationEvent_Noop:InvalidCodePath; - - case SimulationEvent_DebugNumber: - { - input->debug_number = event->debug_number; - }break; - - case SimulationEvent_Key: - { - simulate_key(input, event->key.code, event->key.modifiers); - }break; - - case SimulationEvent_MouseLeftPress: - { - simulate_mouse_left_press(input); - }break; - - case SimulationEvent_MouseLeftRelease: - { - simulate_mouse_left_release(input); - }break; - - case SimulationEvent_MouseRightPress: - { - simulate_mouse_right_press(input); - }break; - - case SimulationEvent_MouseRightRelease: - { - simulate_mouse_right_release(input); - }break; - - case SimulationEvent_MouseWheel: - { - simulate_mouse_wheel(input, event->wheel); - }break; - - case SimulationEvent_MouseXY: - { - simulate_mouse_xy(input, event->mouse_xy.x, event->mouse_xy.y, - width, height); - }break; - - case SimulationEvent_Exit: - { - simulate_exit(input); - }break; - - default:InvalidCodePath; - } - } -} - -// BOTTOM - diff --git a/4ed_input_simulation.h b/4ed_input_simulation.h deleted file mode 100644 index 48333fcc..00000000 --- a/4ed_input_simulation.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Mr. 4th Dimention - Allen Webster - * - * 02.03.2018 - * - * Input simulation data declarations - * - */ - -// TOP - -#if !defined(FRED_INPUT_SIMULATION_H) -#define FRED_INPUT_SIMULATION_H - -#include "4ed_input_simulation_event.h" - -//////////////// - -struct Input_Simulation_Controls{ - b32 enforce_regular_mouse; - i32 counter; - Mouse_State prev_mouse; -}; - -//////////////// - -struct Simulation_Event_Stream_State{ - i32 index; -}; - -#endif - -// BOTTOM - diff --git a/4ed_input_simulation_event.h b/4ed_input_simulation_event.h deleted file mode 100644 index 63c47933..00000000 --- a/4ed_input_simulation_event.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Mr. 4th Dimention - Allen Webster - * - * 02.03.2018 - * - * Input simulation data declarations ~ events data - * - */ - -// TOP - -#if !defined(FRED_INPUT_SIMULATION_EVENT_H) -#define FRED_INPUT_SIMULATION_EVENT_H - -typedef u32 Simulation_Event_Type; -enum{ - SimulationEvent_Noop, - SimulationEvent_DebugNumber, - SimulationEvent_Key, - SimulationEvent_MouseLeftPress, - SimulationEvent_MouseLeftRelease, - SimulationEvent_MouseRightPress, - SimulationEvent_MouseRightRelease, - SimulationEvent_MouseWheel, - SimulationEvent_MouseXY, - SimulationEvent_Exit, -}; - -struct Simulation_Event{ - i32 counter_index; - Simulation_Event_Type type; - union{ - i32 debug_number; - struct{ - u32 code; - u8 modifiers; - } key; - i32 wheel; - struct{ - i32 x; - i32 y; - } mouse_xy; - }; -}; - -#endif - -// BOTTOM - diff --git a/4ed_system.h b/4ed_system.h index 98ff53a3..929d4c6e 100644 --- a/4ed_system.h +++ b/4ed_system.h @@ -209,9 +209,6 @@ typedef Sys_Set_Fullscreen_Sig(System_Set_Fullscreen); #define Sys_Is_Fullscreen_Sig(name) bool32 name() typedef Sys_Is_Fullscreen_Sig(System_Is_Fullscreen); -#define Sys_Send_Exit_Signal_Sig(name) void name() -typedef Sys_Send_Exit_Signal_Sig(System_Send_Exit_Signal); - // debug #define Sys_Log_Sig(name) void name(char *message, u32 length) typedef Sys_Log_Sig(System_Log); @@ -273,7 +270,6 @@ struct System_Functions{ System_Show_Mouse_Cursor *show_mouse_cursor; System_Set_Fullscreen *set_fullscreen; System_Is_Fullscreen *is_fullscreen; - System_Send_Exit_Signal *send_exit_signal; // debug: 1 System_Log *log; diff --git a/4ed_view.cpp b/4ed_view.cpp index e27c5323..df4267ef 100644 --- a/4ed_view.cpp +++ b/4ed_view.cpp @@ -507,44 +507,6 @@ release_font_and_update_files(System_Functions *system, Models *models, Face_ID return(success); } -internal void -kill_file_and_update_views(System_Functions *system, Models *models, Editing_File *file){ - Working_Set *working_set = &models->working_set; - - if (file != 0 && !file->settings.never_kill){ - if (models->hook_end_file != 0){ - models->hook_end_file(&models->app_links, file->id.id); - } - - buffer_unbind_name_low_level(working_set, file); - if (file->canon.name.size != 0){ - buffer_unbind_file(system, working_set, file); - } - file_free(system, &models->app_links, &models->mem.general, file); - working_set_free_file(&models->mem.general, working_set, file); - - File_Node *used = &working_set->used_sentinel; - File_Node *node = used->next; - for (Panel *panel = models->layout.used_sentinel.next; - panel != &models->layout.used_sentinel; - panel = panel->next){ - View *view = panel->view; - if (view->transient.file_data.file == file){ - Assert(node != used); - view->transient.file_data.file = 0; - view_set_file(system, models, view, (Editing_File*)node); - if (node->next != used){ - node = node->next; - } - else{ - node = node->next->next; - Assert(node != used); - } - } - } - } -} - //////////////////////////////// internal i32 diff --git a/4ed_view.h b/4ed_view.h index 1db352dc..2f8a3693 100644 --- a/4ed_view.h +++ b/4ed_view.h @@ -201,12 +201,6 @@ enum History_Mode{ hist_forward }; -enum Try_Kill_Result{ - TryKill_CannotKill, - TryKill_NeedDialogue, - TryKill_Success -}; - #endif // BOTTOM diff --git a/4ed_view_ui.cpp b/4ed_view_ui.cpp index d08ae60f..9f71358a 100644 --- a/4ed_view_ui.cpp +++ b/4ed_view_ui.cpp @@ -9,26 +9,6 @@ // TOP -internal Try_Kill_Result -interactive_try_kill_file(System_Functions *system, Models *models, Editing_File *file){ - Try_Kill_Result result = TryKill_CannotKill; - if (!file->settings.never_kill){ - if (buffer_needs_save(file)){ - result = TryKill_NeedDialogue; - } - else{ - kill_file_and_update_views(system, models, file); - result = TryKill_Success; - } - } - return(result); -} - -internal void -interactive_begin_sure_to_kill(System_Functions *system, View *view, Models *models, Editing_File *file){ - -} - //////////////////////////////// global_const Style_Color_Edit colors_to_edit[] = { diff --git a/build_tests.bat b/build_tests.bat deleted file mode 100644 index 24775d2b..00000000 --- a/build_tests.bat +++ /dev/null @@ -1,32 +0,0 @@ -@echo off - -if not exist ..\tests (mkdir ..\tests) -if not exist ..\tests\input_data (mkdir ..\tests\input_data) - -set code=%cd% -pushd ..\build -set build=%cd% -popd -pushd ..\4coder-non-source\test_data\input_data -set data=%cd% -popd - -set name=test_builder -set full_name=%build%\%name% -set scripts=%code%\test_input_scripts - -set opts= -set opts=%opts% /W4 /WX /wd4310 /wd4100 /wd4201 /wd4505 /wd4996 /wd4127 /wd4510 /wd4512 /wd4610 /wd4390 -set opts=%opts% /GR- /EHa- /nologo /FC - -set inc=-I%code% - -pushd %build% -cl %opts% %inc% %code%\meta\4ed_test_builder.cpp /Zi /Fe%name% -popd - -pushd %data% -%full_name% %scripts%\*.4is -%full_name% %scripts%\generated\*.4is -popd - diff --git a/generate_tests.bat b/generate_tests.bat deleted file mode 100644 index 9e43bfa2..00000000 --- a/generate_tests.bat +++ /dev/null @@ -1,25 +0,0 @@ -@echo off - -if not exist ..\tests (mkdir ..\tests) -if not exist ..\tests\input_data (mkdir ..\tests\input_data) - -set code=%cd% -pushd ..\build -set build=%cd% -popd - -set name=test_generator -set full_name=%build%\%name% -set scripts=%code%\test_input_scripts\generated - -set opts= -set opts=%opts% /W4 /WX /wd4310 /wd4100 /wd4201 /wd4505 /wd4996 /wd4127 /wd4510 /wd4512 /wd4610 /wd4390 -set opts=%opts% /GR- /EHa- /nologo /FC - -set inc=-I%code% - -pushd %build% -cl %opts% %inc% %code%\meta\4ed_test_generator.cpp /Zi /Fe%name% -popd - -%full_name% %code% diff --git a/meta/4ed_metagen.cpp b/meta/4ed_metagen.cpp index ebaf98e2..302ba912 100644 --- a/meta/4ed_metagen.cpp +++ b/meta/4ed_metagen.cpp @@ -868,20 +868,20 @@ generate_remapping_code_and_data(){ begin_map(mappings, default_lister_ui_map, "These commands apply in 'lister mode' such as when you open a file."); - bind_vanilla_keys(mappings, MDFR_NONE, list_mode__write_character); - bind(mappings, key_esc, MDFR_NONE, list_mode__quit); - bind(mappings, '\n', MDFR_NONE, list_mode__activate); - bind(mappings, '\t', MDFR_NONE, list_mode__activate); - bind(mappings, key_back , MDFR_NONE, list_mode__backspace_text_field); - bind(mappings, key_up , MDFR_NONE, list_mode__move_up); - bind(mappings, key_page_up , MDFR_NONE, list_mode__move_up); - bind(mappings, key_down , MDFR_NONE, list_mode__move_down); - bind(mappings, key_page_down, MDFR_NONE, list_mode__move_down); - bind(mappings, key_mouse_wheel , MDFR_NONE, list_mode__wheel_scroll); - bind(mappings, key_mouse_left , MDFR_NONE, list_mode__mouse_press); - bind(mappings, key_mouse_left_release, MDFR_NONE, list_mode__mouse_release); - bind(mappings, key_mouse_move, MDFR_NONE, list_mode__repaint); - bind(mappings, key_animate , MDFR_NONE, list_mode__repaint); + bind_vanilla_keys(mappings, MDFR_NONE, lister__write_character); + bind(mappings, key_esc, MDFR_NONE, lister__quit); + bind(mappings, '\n', MDFR_NONE, lister__activate); + bind(mappings, '\t', MDFR_NONE, lister__activate); + bind(mappings, key_back , MDFR_NONE, lister__backspace_text_field); + bind(mappings, key_up , MDFR_NONE, lister__move_up); + bind(mappings, key_page_up , MDFR_NONE, lister__move_up); + bind(mappings, key_down , MDFR_NONE, lister__move_down); + bind(mappings, key_page_down, MDFR_NONE, lister__move_down); + bind(mappings, key_mouse_wheel , MDFR_NONE, lister__wheel_scroll); + bind(mappings, key_mouse_left , MDFR_NONE, lister__mouse_press); + bind(mappings, key_mouse_left_release, MDFR_NONE, lister__mouse_release); + bind(mappings, key_mouse_move, MDFR_NONE, lister__repaint); + bind(mappings, key_animate , MDFR_NONE, lister__repaint); end_map(mappings); } @@ -1081,20 +1081,20 @@ generate_remapping_code_and_data(){ begin_map(mappings, default_lister_ui_map, "These commands apply in 'lister mode' such as when you open a file."); - bind_vanilla_keys(mappings, MDFR_NONE, list_mode__write_character); - bind(mappings, key_esc, MDFR_NONE, list_mode__quit); - bind(mappings, '\n', MDFR_NONE, list_mode__activate); - bind(mappings, '\t', MDFR_NONE, list_mode__activate); - bind(mappings, key_back , MDFR_NONE, list_mode__backspace_text_field); - bind(mappings, key_up , MDFR_NONE, list_mode__move_up); - bind(mappings, key_page_up , MDFR_NONE, list_mode__move_up); - bind(mappings, key_down , MDFR_NONE, list_mode__move_down); - bind(mappings, key_page_down, MDFR_NONE, list_mode__move_down); - bind(mappings, key_mouse_wheel , MDFR_NONE, list_mode__wheel_scroll); - bind(mappings, key_mouse_left , MDFR_NONE, list_mode__mouse_press); - bind(mappings, key_mouse_left_release, MDFR_NONE, list_mode__mouse_release); - bind(mappings, key_mouse_move, MDFR_NONE, list_mode__repaint); - bind(mappings, key_animate , MDFR_NONE, list_mode__repaint); + bind_vanilla_keys(mappings, MDFR_NONE, lister__write_character); + bind(mappings, key_esc, MDFR_NONE, lister__quit); + bind(mappings, '\n', MDFR_NONE, lister__activate); + bind(mappings, '\t', MDFR_NONE, lister__activate); + bind(mappings, key_back , MDFR_NONE, lister__backspace_text_field); + bind(mappings, key_up , MDFR_NONE, lister__move_up); + bind(mappings, key_page_up , MDFR_NONE, lister__move_up); + bind(mappings, key_down , MDFR_NONE, lister__move_down); + bind(mappings, key_page_down, MDFR_NONE, lister__move_down); + bind(mappings, key_mouse_wheel , MDFR_NONE, lister__wheel_scroll); + bind(mappings, key_mouse_left , MDFR_NONE, lister__mouse_press); + bind(mappings, key_mouse_left_release, MDFR_NONE, lister__mouse_release); + bind(mappings, key_mouse_move, MDFR_NONE, lister__repaint); + bind(mappings, key_animate , MDFR_NONE, lister__repaint); end_map(mappings); } diff --git a/meta/4ed_test_builder.cpp b/meta/4ed_test_builder.cpp deleted file mode 100644 index 636acd9c..00000000 --- a/meta/4ed_test_builder.cpp +++ /dev/null @@ -1,716 +0,0 @@ -/* - * Mr. 4th Dimention - Allen Webster - * - * 02.03.2018 - * - * Converter for *.4is -> *.4id - * - */ - -// TOP - -#include "4ed_defines.h" -#include "4ed_input_simulation_event.h" -#include "4coder_lib/4coder_string.h" -#include "4coder_generated/style.h" -#include "4coder_API/types.h" -#include "4coder_generated/keycodes.h" - -#include "4coder_file.h" - -#include - -internal void -print_usage(char *name){ - fprintf(stdout, - "usage: %s [ ...]\n" - "all files with the extension .4is in src-root will be converted\n", - name); -} - -// TODO(allen): // TODO(allen): // TODO(allen): // TODO(allen): -// TODO(allen): // TODO(allen): // TODO(allen): // TODO(allen): -// TODO(allen): // TODO(allen): // TODO(allen): // TODO(allen): -// This belongs in the string library or something like that. -struct String_Array{ - String *strings; - i32 count; -}; - -internal String_Array -get_lines(Partition *part, String data){ - String_Array array = {0}; - array.strings = push_array(part, String, 0); - - char *line_ptr = data.str; - for (i32 i = 0; i <= data.size; ++i){ - char *c_ptr = data.str + i; - b32 delim = false; - if (i < data.size){ - switch (*c_ptr){ - case '\n': case '\r': - { - delim = true; - }break; - } - } - else{ - delim = true; - } - - if (delim){ - String s = make_string(line_ptr, (i32)(c_ptr - line_ptr)); - s = skip_chop_whitespace(s); - if (s.size > 0){ - String *new_s = push_array(part, String, 1); - *new_s = s; - array.count += 1; - } - line_ptr = c_ptr + 1; - } - } - - return(array); -} - -internal String_Array -get_words(Partition *part, String data){ - String_Array array = {0}; - array.strings = push_array(part, String, 0); - - char *word_ptr = data.str; - for (i32 i = 0; i <= data.size; ++i){ - char *c_ptr = data.str + i; - b32 delim = false; - if (i < data.size){ - delim = char_is_whitespace(*c_ptr); - } - else{ - delim = true; - } - - if (delim){ - String s = make_string(word_ptr, (i32)(c_ptr - word_ptr)); - if (s.size > 0){ - String *new_s = push_array(part, String, 1); - *new_s = s; - array.count += 1; - } - word_ptr = c_ptr + 1; - } - } - - return(array); -} - -internal String_Array -get_flags(Partition *part, String data){ - String_Array array = {0}; - array.strings = push_array(part, String, 0); - - char *word_ptr = data.str; - for (i32 i = 0; i <= data.size; ++i){ - char *c_ptr = data.str + i; - b32 delim = false; - if (i < data.size){ - delim = (*c_ptr == '|'); - } - else{ - delim = true; - } - - if (delim){ - String s = make_string(word_ptr, (i32)(c_ptr - word_ptr)); - s = skip_chop_whitespace(s); - if (s.size > 0){ - String *new_s = push_array(part, String, 1); - *new_s = s; - array.count += 1; - } - word_ptr = c_ptr + 1; - } - } - - return(array); -} - -internal void -show_error(char *name, String data, char *ptr, char *error_message){ - i32 line = 1; - i32 column = 1; - - i32 stop = (i32)(ptr - data.str); - if (stop > data.size){ - stop = data.size; - } - for (i32 i = 0; i < stop; ++i){ - if (data.str[i] == '\n'){ - line += 1; - column = 1; - } - else{ - column += 1; - } - } - - fprintf(stdout, "%s:%d:%d: error %s\n", name, line, column, error_message); -} - -struct Line_Parse_Context{ - char *name; - String data; - String_Array words; -}; - -internal void -show_error(Line_Parse_Context context, char *ptr, char *error_message){ - show_error(context.name, context.data, ptr, error_message); -} - -internal bool32 -require_blank(Line_Parse_Context context, i32 index){ - bool32 result = (context.words.count <= index); - if (!result){ - show_error(context, context.words.strings[index].str, - "unexpected word"); - } - return(result); -} - -internal bool32 -require_integer(Line_Parse_Context context, i32 index, i32 *int_out){ - bool32 result = false; - if (index < context.words.count){ - String s = context.words.strings[index]; - if (str_is_int(s)){ - *int_out = str_to_int(s); - result = true; - } - else{ - show_error(context, - context.words.strings[index].str, - "expected integer"); - } - } - else{ - show_error(context, - context.words.strings[context.words.count - 1].str, - "expected integer"); - } - return(result); -} - -internal bool32 -require_unquoted_string(Line_Parse_Context context, i32 index, String *str_out){ - bool32 result = false; - if (index < context.words.count){ - String str = context.words.strings[index]; - if (str.str[0] != '"'){ - *str_out = str; - result = true; - } - else{ - show_error(context, - context.words.strings[context.words.count - 1].str, - "expected a simple word (a simple word must be unquoted)"); - } - } - else{ - show_error(context, - context.words.strings[context.words.count - 1].str, - "expected another word"); - } - return(result); -} - -internal bool32 -require_unquoted_multi_string(Line_Parse_Context context, i32 start_index, String *str_out){ - bool32 result = false; - if (start_index < context.words.count){ - String str = context.words.strings[start_index]; - if (str.str[0] != '"'){ - String last_word = context.words.strings[context.words.count - 1]; - char *end = last_word.str + last_word.size; - str.size = (i32)(end - str.str); - *str_out = str; - result = true; - } - else{ - show_error(context, - context.words.strings[context.words.count - 1].str, - "expected a simple word (a simple word must be unquoted)"); - } - } - else{ - show_error(context, - context.words.strings[context.words.count - 1].str, - "expected another word"); - } - return(result); -} - -internal bool32 -require_any_string(Line_Parse_Context context, i32 index, String *str_out){ - bool32 result = require_unquoted_string(context, index, str_out); - return(result); -} - -internal bool32 -key_name_to_code(Line_Parse_Context context, String key_name, u32 *key_code_out){ - bool32 result = false; - if (key_name.size == 1){ - *key_code_out = key_name.str[0]; - result = true; - } - else{ -#define KEY_CODE_CHK_SET(S,N) else if (match(key_name, S)) \ - do{ *key_code_out = N; result = true; }while(0) -#define KEY_CODE_CHK(N) KEY_CODE_CHK_SET(#N,N) - - if (false){} - KEY_CODE_CHK(key_back); - KEY_CODE_CHK(key_up); - KEY_CODE_CHK(key_down); - KEY_CODE_CHK(key_left); - KEY_CODE_CHK(key_right); - KEY_CODE_CHK(key_del); - KEY_CODE_CHK(key_insert); - KEY_CODE_CHK(key_home); - KEY_CODE_CHK(key_end); - KEY_CODE_CHK(key_page_up); - KEY_CODE_CHK(key_page_down); - KEY_CODE_CHK(key_esc); - KEY_CODE_CHK(key_f1); - KEY_CODE_CHK(key_f2); - KEY_CODE_CHK(key_f3); - KEY_CODE_CHK(key_f4); - KEY_CODE_CHK(key_f5); - KEY_CODE_CHK(key_f6); - KEY_CODE_CHK(key_f7); - KEY_CODE_CHK(key_f8); - KEY_CODE_CHK(key_f9); - KEY_CODE_CHK(key_f10); - KEY_CODE_CHK(key_f11); - KEY_CODE_CHK(key_f12); - KEY_CODE_CHK(key_f13); - KEY_CODE_CHK(key_f14); - KEY_CODE_CHK(key_f15); - KEY_CODE_CHK(key_f16); - KEY_CODE_CHK_SET("key_space", ' '); - KEY_CODE_CHK_SET("key_newline", '\n'); - KEY_CODE_CHK_SET("key_tab", '\t'); - } - - if (!result){ - show_error(context, key_name.str, "expected key name"); - } - return(result); -} - -internal bool32 -mod_name_to_flags(Line_Parse_Context context, Partition *part, String mod_name, u8 *modifiers_out){ - bool32 result = true; - - Temp_Memory temp = begin_temp_memory(part); - String_Array flags = get_flags(part, mod_name); - u8 modifiers = 0; - for (i32 i = 0; i < flags.count; ++i){ - String flag_string = flags.strings[i]; - u8 this_flag = 0; - -#define MDFR_FLAG_CHK(N) \ - else if (match(flag_string, #N)) do{ this_flag = N; }while(0) - - if (false){} - MDFR_FLAG_CHK(MDFR_NONE); - MDFR_FLAG_CHK(MDFR_CTRL); - MDFR_FLAG_CHK(MDFR_ALT); - MDFR_FLAG_CHK(MDFR_CMND); - MDFR_FLAG_CHK(MDFR_SHIFT); - else{ - result = false; - show_error(context, flag_string.str, "unrecognized flag string"); - break; - } - - modifiers |= this_flag; - } - end_temp_memory(temp); - - *modifiers_out = modifiers; - return(result); -} - -internal void -process_script__inner(Partition *scratch, char *name){ - String data = file_dump(scratch, name); - String_Array lines = get_lines(scratch, data); - - Simulation_Event *events = push_array(scratch, Simulation_Event, 0); - i32 event_count = 0; - - i32 standard_time_increment = 0; - i32 time_counter = 0; - - for (i32 i = 0; i < lines.count; ++i){ - Temp_Memory word_temp = begin_temp_memory(scratch); - String line = lines.strings[i]; - String_Array words = get_words(scratch, line); - - Line_Parse_Context context = {0}; - context.name = name; - context.data = data; - context.words = words; - - i32 current_debug_number = 0; - - bool32 emit_event = false; - Simulation_Event event = {0}; - - bool32 emit_type = false; - i32 type_increment = 0; - String type_string = {0}; - - bool32 emit_invoke = false; - String invoke_file = {0}; - bool32 invoke_raw_data = false; - - if (words.count != 0){ - String first_word = words.strings[0]; - if (!match(substr(first_word, 0, 2), "//")){ - - if (match(first_word, "debug_number")){ - i32 debug_number = 0; - if (require_integer(context, 1, &debug_number) && - require_blank(context, 2)){ - emit_event = true; - event.counter_index = time_counter; - event.type = SimulationEvent_DebugNumber; - event.debug_number = debug_number; - current_debug_number = debug_number; - } - else{ - return; - } - } - - else if (match(first_word, "wait")){ - i32 increment = 0; - if (require_integer(context, 1, &increment) && - require_blank(context, 2)){ - time_counter += increment; - } - else{ - return; - } - } - - else if (match(first_word, "basewait")){ - i32 increment = 0; - if (require_integer(context, 1, &increment) && - require_blank(context, 2)){ - standard_time_increment = increment; - } - else{ - return; - } - } - - else if (match(first_word, "key")){ - String key_name = {0}; - String mod_name = {0}; - if (require_unquoted_string(context, 1, &key_name) && - require_unquoted_string(context, 2, &mod_name) && - require_blank(context, 3)){ - u32 key_code = 0; - u8 modifiers = 0; - if (key_name_to_code(context, key_name, &key_code) && - mod_name_to_flags(context, scratch, mod_name, &modifiers)){ - emit_event = true; - event.counter_index = time_counter; - event.type = SimulationEvent_Key; - event.key.code = key_code; - event.key.modifiers = modifiers; - } - else{ - return; - } - } - else{ - return; - } - } - - else if (match(first_word, "type")){ - i32 increment = 0; - String string = {0}; - if (require_integer(context, 1, &increment) && - require_unquoted_multi_string(context, 2, &string)){ - emit_type = true; - type_increment = increment; - type_string = string; - } - else{ - return; - } - } - - else if (match(first_word, "invoke")){ - String file = {0}; - if (require_any_string(context, 1, &file) && - require_blank(context, 2)){ - emit_invoke = true; - invoke_file = file; - } - else{ - return; - } - } - - else if (match(first_word, "raw_invoke")){ - String file = {0}; - if (require_any_string(context, 1, &file) && - require_blank(context, 2)){ - emit_invoke = true; - invoke_file = file; - invoke_raw_data = true; - } - else{ - return; - } - } - - else if (match(first_word, "mouse_left_press")){ - if (require_blank(context, 1)){ - emit_event = true; - event.counter_index = time_counter; - event.type = SimulationEvent_MouseLeftPress; - } - else{ - return; - } - } - - else if (match(first_word, "mouse_right_press")){ - if (require_blank(context, 1)){ - emit_event = true; - event.counter_index = time_counter; - event.type = SimulationEvent_MouseRightPress; - } - else{ - return; - } - } - - else if (match(first_word, "mouse_left_release")){ - if (require_blank(context, 1)){ - emit_event = true; - event.counter_index = time_counter; - event.type = SimulationEvent_MouseLeftRelease; - } - else{ - return; - } - } - - else if (match(first_word, "mouse_right_release")){ - if (require_blank(context, 1)){ - emit_event = true; - event.counter_index = time_counter; - event.type = SimulationEvent_MouseRightRelease; - } - else{ - return; - } - } - - else if (match(first_word, "mouse_wheel")){ - i32 wheel = 0; - if (require_integer(context, 1, &wheel) && - require_blank(context, 2)){ - emit_event = true; - event.counter_index = time_counter; - event.type = SimulationEvent_MouseWheel; - event.wheel = wheel; - } - else{ - return; - } - } - - else if (match(first_word, "mouse_xy")){ - i32 x = 0; - i32 y = 0; - if (require_integer(context, 1, &x) && - require_integer(context, 2, &y) && - require_blank(context, 3)){ - emit_event = true; - event.counter_index = time_counter; - event.type = SimulationEvent_MouseXY; - event.mouse_xy.x = x; - event.mouse_xy.y = y; - } - else{ - return; - } - } - - else if (match(first_word, "exit")){ - if (require_blank(context, 1)){ - emit_event = true; - event.counter_index = time_counter; - event.type = SimulationEvent_Exit; - } - else{ - return; - } - } - - else{ - show_error(name, data, first_word.str, "unrecognized control word"); - return; - } - } - } - - end_temp_memory(word_temp); - - if (emit_event){ - Simulation_Event *new_event = push_array(scratch, Simulation_Event, 1); - memset(new_event, 0, sizeof(*new_event)); - *new_event = event; - event_count += 1; - time_counter += standard_time_increment; - } - - if (emit_type){ - for (i32 j = 0; j < type_string.size; ++j){ - Simulation_Event *new_event = push_array(scratch, Simulation_Event, 1); - memset(new_event, 0, sizeof(*new_event)); - new_event->counter_index = time_counter; - new_event->type = SimulationEvent_Key; - new_event->key.code = type_string.str[j]; - new_event->key.modifiers = MDFR_NONE; - event_count += 1; - if (j + 1 < type_string.size){ - time_counter += type_increment; - } - } - time_counter += standard_time_increment; - } - - if (emit_invoke){ - Temp_Memory invoke_temp = begin_temp_memory(scratch); - - char *invoke_name = push_array(scratch, char, invoke_file.size + 1); - push_align(scratch, 8); - memcpy(invoke_name, invoke_file.str, invoke_file.size); - invoke_name[invoke_file.size] = 0; - String invoke_data = file_dump(scratch, invoke_name); - if (invoke_data.str == 0){ - show_error(name, data, invoke_file.str, "could not open invoked file"); - return; - } - i32 count = *(i32*)invoke_data.str; - Simulation_Event *events = (Simulation_Event*)(invoke_data.str + 4); - Simulation_Event *event = events; - for (i32 i = 0; i < count; ++i, ++event){ - event->counter_index = event->counter_index + time_counter; - if (event->type == SimulationEvent_Exit && !invoke_raw_data){ - count = i + 1; - event->type = SimulationEvent_DebugNumber; - } - if (event->type == SimulationEvent_DebugNumber){ - event->debug_number = current_debug_number; - } - } - if (count > 0){ - time_counter = events[count - 1].counter_index + standard_time_increment; - } - end_temp_memory(invoke_temp); - - // NOTE(allen): This is pulling back events from inside a - // closed temp block. Don't let it get separated from the - // end_temp_memory call! - void *ptr = push_array(scratch, Simulation_Event, count); - memmove(ptr, events, sizeof(*events)*count); - event_count += count; - } - } - - String out_name_s = front_of_directory(make_string_slowly(name)); - char *out_name = push_array(scratch, char, out_name_s.size + 1); - memcpy(out_name, out_name_s.str, out_name_s.size); - Assert(out_name[out_name_s.size - 1] == 's'); - out_name[out_name_s.size - 1] = 'd'; - out_name[out_name_s.size] = 0; - - FILE *out = fopen(out_name, "wb"); - if (out != 0){ - fwrite(&event_count, sizeof(event_count), 1, out); - fwrite(events, sizeof(*events), event_count, out); - fclose(out); - } - else{ - fprintf(stdout, "fatal error: cannot open output %s\n", - out_name); - } -} - -internal void -process_script(Partition *scratch, char *name){ - Temp_Memory temp = begin_temp_memory(scratch); - process_script__inner(scratch, name); - end_temp_memory(temp); -} - -int -main(int argc, char **argv){ - if (argc <= 1){ - char *name = "test_builder"; - if (argc > 0){ - name = argv[0]; - } - print_usage(name); - } - - int32_t size = (256 << 20); - void *mem = malloc(size); - Partition part_ = make_part(mem, size); - Partition *part = &part_; - - for (i32 i = 1; i < argc; ++i){ - Cross_Platform_File_List files = get_file_list(part, encode(part, argv[i]), filter_all); - - char *path_name = unencode(part, files.path_name, files.path_length); - String path_name_s = make_string_slowly(path_name); - - Cross_Platform_File_Info *info = files.info; - for (i32 j = 0; j < files.count; ++j, ++info){ - if (info->is_folder){ - continue; - } - - char *name = unencode(part, info->name, info->len); - String s = make_string_slowly(name); - if (!match(substr_tail(s, s.size - 4), ".4is")){ - continue; - } - - i32 whole_name_max = path_name_s.size + 1 + s.size + 1; - char *whole_name = push_array(part, char, whole_name_max); - push_align(part, 8); - - String w = make_string_cap(whole_name, 0, whole_name_max); - append(&w, path_name_s); - append(&w, '/'); - append(&w, s); - terminate_with_null(&w); - - process_script(part, w.str); - } - } -} - -// BOTTOM - diff --git a/meta/4ed_test_generator.cpp b/meta/4ed_test_generator.cpp deleted file mode 100644 index 49dd0e55..00000000 --- a/meta/4ed_test_generator.cpp +++ /dev/null @@ -1,457 +0,0 @@ -/* - * Mr. 4th Dimention - Allen Webster - * - * 16.03.2018 - * - * Converter for *.4is -> *.4id - * - */ - -// TOP - -#include "4ed_defines.h" -#include "4coder_lib/4coder_string.h" -#include "4coder_lib/4coder_mem.h" - -#include "4coder_file.h" - -#include - -//////////////////////////////// - -global char hot_directory_space[4096]; -global String hot_directory = {hot_directory_space, 0, sizeof(hot_directory_space)}; - -internal void -init_hot_directory(char *dir){ - copy(&hot_directory, dir); - replace_char(&hot_directory, '\\', '/'); - if (hot_directory.str[hot_directory.size - 1] != '/'){ - append(&hot_directory, "/"); - } -} - -internal void -set_hot_directory(String str){ - copy(&hot_directory, str); -} - -internal void -set_hot_directory(char *str){ - copy(&hot_directory, str); -} - -internal void -push_folder_hot_directory(String str){ - append(&hot_directory, str); - append(&hot_directory, "/"); -} - -internal void -push_folder_hot_directory(char *str){ - append(&hot_directory, str); - append(&hot_directory, "/"); -} - -internal void -pop_folder_hot_directory(void){ - remove_last_folder(&hot_directory); -} - -internal String -get_hot_directory(Partition *part){ - String hot; - hot.str = push_array(part, char, hot_directory.size); - hot.size = hot_directory.size; - hot.memory_size = hot_directory.size; - memcpy(hot.str, hot_directory.str, hot_directory.size); - return(hot); -} - -internal FILE* -fopen_hot_directory(Partition *scratch, char *file_name, char *flags){ - Temp_Memory temp = begin_temp_memory(scratch); - - char *full_name = push_array(scratch, char, hot_directory.size); - memcpy(full_name, hot_directory.str, hot_directory.size); - - i32 file_name_length = str_size(file_name); - char *full_name_file_portion = push_array(scratch, char, file_name_length); - memcpy(full_name_file_portion, file_name, file_name_length); - - char *terminator = push_array(scratch, char, 1); - *terminator = 0; - - FILE *result = fopen(full_name, flags); - - end_temp_memory(temp); - - return(result); -} - -//////////////////////////////// - -struct Test_Node{ - Test_Node *next; - String name; -}; - -struct Test_List{ - Partition *part; - - Test_Node *first; - Test_Node *last; - i32 count; -}; - -#define zdll_push(f,l,cptr,n) (((f) == 0)?((f) = (l) = (n)):((l)->next = (n), (l) = (n))), (*(cptr)) += 1 - -internal void -push_test(Test_List *list, String name){ - Test_Node *node = push_array(list->part, Test_Node, 1); - node->name = make_string_cap(push_array(list->part, char, name.size), 0, name.size); - push_align(list->part, 8); - copy(&node->name, name); - zdll_push(list->first, list->last, &list->count, node); -} - -internal void -push_test(Test_List *list, char *name){ - push_test(list, make_string_slowly(name)); -} - -//////////////////////////////// - -global String code_root; -global String script_root; -global String sample_root; - -typedef u32 Generate_Flag; -enum{ - GenFlag_RebuildSamples = 1, - GenFlag_RebuildScripts = 2, - GenFlag_OutputTestNames = 4, -}; -enum{ - GenFlag_DoAll = GenFlag_RebuildSamples|GenFlag_RebuildScripts|GenFlag_OutputTestNames, -}; - -#define DoSamples(f) (((f) & GenFlag_RebuildSamples) != 0) -#define DoScripts(f) (((f) & GenFlag_RebuildScripts) != 0) -#define DoTestNames(f) (((f) & GenFlag_OutputTestNames) != 0) - -internal void -print_usage(char *name){ - fprintf(stdout, "usage: %s code-root-directory\n", name); -} - -internal FILE* -try_open_output(Partition *scratch, char *name){ - FILE *out = fopen_hot_directory(scratch, name, "wb"); - if (out == 0){ - fprintf(stdout, "Could not open output file %s\n", name); - } - return(out); -} - -internal void -generate_run_script(Partition *scratch, Test_List list){ - Temp_Memory temp = begin_temp_memory(scratch); - - set_hot_directory(code_root); - FILE *out = try_open_output(scratch, "run_regression_tests.bat"); - if (out != 0){ - fprintf(out, - "@echo off\n" - - "pushd ..\\4coder-non-source\\test_data\n" - "set run_path=%%cd%%\\sample_files\n" - "set data_path=%%cd%%\\input_data\n" - "popd\n" - - "pushd ..\\build\n" - "set build=%%cd%%\n" - "popd\n" - - "pushd %%run_path%%\n"); - - for (Test_Node *node = list.first; - node != 0; - node = node->next){ - fprintf(out, "%%build%%\\4ed -T %%data_path%%\\%.*s\n", - node->name.size, node->name.str); - } - - fprintf(out, "popd\n"); - fclose(out); - } - - end_temp_memory(temp); -} - -internal void -write_open_test_file_default_bindings(FILE *out, - char *src_name, char *dst_name){ - fprintf(out, - "key o MDFR_CTRL\n" - "type 1 %s\n" - "key key_newline MDFR_NONE\n" - "key o MDFR_CTRL\n" - "key key_back MDFR_NONE\n" - "type 1 output/\n" - "key key_esc MDFR_NONE\n" - "key s MDFR_ALT\n" - "type 1 %s\n" - "key key_newline MDFR_NONE\n", - src_name, dst_name); -} - -internal String -generate_token_test_sample_file(Partition *part, i32 index, i32 token_target, Generate_Flag flags){ - i32 name_cap = 512; - String sample_name = make_string_cap(push_array(part, char, name_cap), 0, name_cap); - append(&sample_name, "gentokentest"); - append_int_to_str(&sample_name, index + 1); - append(&sample_name, ".cpp"); - bool32 string_build_success = terminate_with_null(&sample_name); - Assert(string_build_success); - - set_hot_directory(sample_root); - if (DoSamples(flags)){ - FILE *out = try_open_output(part, sample_name.str); - if (out != 0){ - fprintf(out, - "int foo(){\n" - "\n"); - i32 token_count = 6; - Assert(token_count < token_target); - for (;token_count + 10 < token_target;){ - fprintf(out, "int x = 0;\n"); - token_count += 5; - } - Assert(token_count < token_target); - fprintf(out, "}\n"); - fclose(out); - } - else{ - sample_name.str = 0; - sample_name.size = 0; - sample_name.memory_size = 0; - } - } - - return(sample_name); -} - -internal void -generate_token_tests(Partition *scratch, Test_List *test_list, Generate_Flag flags){ - Temp_Memory temp = begin_temp_memory(scratch); - - for (i32 size = 1024, i = 0; i < 5; size <<= 1, ++i){ - char test_name_space[512]; - String test_name = make_fixed_width_string(test_name_space); - append(&test_name, "gentest_capstress"); - append_int_to_str(&test_name, i + 1); - append(&test_name, ".4is"); - bool32 string_build_success = terminate_with_null(&test_name); - Assert(string_build_success); - - String sample_name = generate_token_test_sample_file(scratch, i, size, flags); - - if (sample_name.str != 0){ - set_hot_directory(script_root); - if (DoScripts(flags)){ - FILE *out = try_open_output(scratch, test_name.str); - if (out != 0){ - fprintf(out, - "mouse_xy 20 20\n" - "key P MDFR_CTRL\n" - "basewait 1\n"); - write_open_test_file_default_bindings(out, sample_name.str, sample_name.str); - - fprintf(out, "key key_down MDFR_CTRL\n"); - - for (i32 i = 0; i < 5; ++i){ - fprintf(out, - "type 1 int x = 0;\n" - "key key_newline MDFR_NONE\n"); - } - - fprintf(out, - "key s MDFR_CTRL\n" - "exit\n" - "key Y MDFR_NONE"); - - fclose(out); - } - } - - if (DoTestNames(flags)){ - remove_extension(&test_name); - append(&test_name, "4id"); - bool32 string_build_success = terminate_with_null(&test_name); - Assert(string_build_success); - push_test(test_list, test_name); - } - } - } - - end_temp_memory(temp); -} - -internal String -generate_dupline_test_sample_file(Partition *part, i32 line_count, bool32 always_newline, Generate_Flag flags){ - i32 name_cap = 512; - String sample_name = make_string_cap(push_array(part, char, name_cap), 0, name_cap); - append(&sample_name, "genduplinetest"); - append_int_to_str(&sample_name, line_count); - append(&sample_name, "_"); - append_int_to_str(&sample_name, always_newline); - append(&sample_name, ".cpp"); - bool32 string_build_success = terminate_with_null(&sample_name); - Assert(string_build_success); - - if (DoSamples(flags)){ - set_hot_directory(sample_root); - FILE *out = try_open_output(part, sample_name.str); - if (out != 0){ - for (i32 i = 0; i < line_count; ++i){ - fprintf(out, "abcd"); - if (i + 1 < line_count || always_newline){ - fprintf(out, "\n"); - } - } - fclose(out); - } - } - - return(sample_name); -} - -internal void -generate_dupline_specific_test(Partition *scratch, Test_List *test_list, Generate_Flag flags, - i32 line_count, bool32 always_newline, bool32 read_only){ - char test_name_space[512]; - String test_name = make_fixed_width_string(test_name_space); - if (read_only){ - append(&test_name, "gentest_dupline_readonly.4is"); - } - else{ - append(&test_name, "gentest_dupline"); - append_int_to_str(&test_name, line_count); - append(&test_name, "_"); - append_int_to_str(&test_name, always_newline); - append(&test_name, ".4is"); - } - bool32 string_build_success = terminate_with_null(&test_name); - Assert(string_build_success); - - String sample_name; - if (read_only){ - sample_name = make_lit_string("*messages*"); - } - else{ - sample_name = generate_dupline_test_sample_file(scratch, line_count, always_newline, flags); - } - - if (sample_name.str != 0){ - set_hot_directory(script_root); - if (DoScripts(flags)){ - FILE *out = try_open_output(scratch, test_name.str); - if (out != 0){ - fprintf(out, - "mouse_xy 20 20\n" - "key P MDFR_CTRL\n" - "basewait 1\n"); - if (read_only){ - fprintf(out, - "key i MDFR_CTRL\n" - "type 1 *messages*\n" - "key key_newline MDFR_NONE\n" - "key L MDFR_CTRL\n" - "key s MDFR_CTRL\n" - "exit\n"); - } - else{ - write_open_test_file_default_bindings(out, sample_name.str, sample_name.str); - fprintf(out, - "key L MDFR_CTRL\n" - "key s MDFR_CTRL\n" - "exit\n"); - } - fclose(out); - } - } - - if (DoTestNames(flags)){ - remove_extension(&test_name); - append(&test_name, "4id"); - bool32 string_build_success = terminate_with_null(&test_name); - Assert(string_build_success); - push_test(test_list, test_name); - } - } -} - -internal void -generate_dupline_tests(Partition *scratch, Test_List *test_list, Generate_Flag flags){ - Temp_Memory temp = begin_temp_memory(scratch); - for (i32 line_count = 0; line_count < 2; ++line_count){ - for (bool32 always_newline = 0; always_newline <= 1; ++always_newline){ - generate_dupline_specific_test(scratch, test_list, flags, - line_count, always_newline, false); - } - } - generate_dupline_specific_test(scratch, test_list, flags, 0, false, true); - end_temp_memory(temp); -} - -int -main(int argc, char **argv){ - if (argc != 2){ - print_usage(argv[0]); - exit(1); - } - - // NOTE(allen): Init the hot directory - init_hot_directory(argv[1]); - - // NOTE(allen): Init the partition - i32 memory_size = MB(8); - Partition part_ = make_part(malloc(memory_size), memory_size); - Partition *part = &part_; - - // NOTE(allen): Get various root paths - code_root = get_hot_directory(part); - - push_folder_hot_directory("test_input_scripts/generated"); - script_root = get_hot_directory(part); - - set_hot_directory(code_root); - pop_folder_hot_directory(); - push_folder_hot_directory("4coder-non-source/test_data/sample_files"); - sample_root = get_hot_directory(part); - - // NOTE(allen): Setup the test list - i32 test_list_size = MB(8); - Partition test_list_part = make_part(malloc(test_list_size), test_list_size); - - Test_List test_list = {0}; - test_list.part = &test_list_part; - - // NOTE(allen): Tests - //push_test(&test_list, "test_load_FONT_COURIER_NEW_28_c.4id"); - push_test(&test_list, "test_load_rome_txt.4id"); - //generate_token_tests(part, &test_list, GenFlag_DoAll); - //generate_token_tests(part, &test_list, GenFlag_OutputTestNames); - //generate_dupline_tests(part, &test_list, GenFlag_DoAll); - //generate_dupline_tests(part, &test_list, GenFlag_OutputTestNames); - - // NOTE(allen): Generate the run test script - generate_run_script(part, test_list); - - return(0); -} - -// BOTTOM - diff --git a/platform_all/4ed_link_system_functions.cpp b/platform_all/4ed_link_system_functions.cpp index 0c2ab388..c84fdf27 100644 --- a/platform_all/4ed_link_system_functions.cpp +++ b/platform_all/4ed_link_system_functions.cpp @@ -59,7 +59,6 @@ link_system_code(){ SYSLINK(set_fullscreen); SYSLINK(is_fullscreen); SYSLINK(show_mouse_cursor); - SYSLINK(send_exit_signal); SYSLINK(log); #if defined(FRED_INTERNAL) diff --git a/platform_linux/linux_4ed.cpp b/platform_linux/linux_4ed.cpp index 958b1a0d..f8dcacb2 100644 --- a/platform_linux/linux_4ed.cpp +++ b/platform_linux/linux_4ed.cpp @@ -324,12 +324,6 @@ Sys_Is_Fullscreen_Sig(system_is_fullscreen){ return(result); } -// HACK(allen): Why does this work differently from the win32 version!? -internal -Sys_Send_Exit_Signal_Sig(system_send_exit_signal){ - linuxvars.keep_running = false; -} - #include "4ed_coroutine_functions.cpp" #include "4ed_system_shared.cpp" diff --git a/platform_mac/mac_4ed.cpp b/platform_mac/mac_4ed.cpp index 3372ffd8..2ce40512 100644 --- a/platform_mac/mac_4ed.cpp +++ b/platform_mac/mac_4ed.cpp @@ -200,12 +200,6 @@ Sys_Is_Fullscreen_Sig(system_is_fullscreen){ return(result); } -// HACK(allen): Why does this work differently from the win32 version!? -internal -Sys_Send_Exit_Signal_Sig(system_send_exit_signal){ - osxvars.keep_running = false; -} - #include "4ed_coroutine_functions.cpp" #include "4ed_system_shared.cpp" diff --git a/platform_win32/win32_4ed.cpp b/platform_win32/win32_4ed.cpp index 11aa09e8..b4a1a05f 100644 --- a/platform_win32/win32_4ed.cpp +++ b/platform_win32/win32_4ed.cpp @@ -280,11 +280,6 @@ Sys_Is_Fullscreen_Sig(system_is_fullscreen){ return(result); } -internal -Sys_Send_Exit_Signal_Sig(system_send_exit_signal){ - win32vars.send_exit_signal = true; -} - #include "4ed_coroutine_functions.cpp" #include "4ed_system_shared.cpp" @@ -1174,9 +1169,6 @@ win32_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ #include "4ed_link_system_functions.cpp" #include "4ed_shared_init_logic.cpp" -#include "4ed_input_simulation.h" -#include "4ed_input_simulation.cpp" - int CALL_CONVENTION WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ i32 argc = __argc; @@ -1389,32 +1381,6 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS LOG("Initializing application variables\n"); app.init(&sysfunc, &target, &memory_vars, win32vars.clipboard_contents, curdir, custom_api); - Input_Simulation_Controls sim_controls = {0}; - Simulation_Event_Stream_State sim_stream = {0}; - Simulation_Event *sim_events = 0; - i32 sim_event_count = 0; - - if (plat_settings.use_test_input){ - simulation_init(&sim_controls); - simulation_stream_init(&sim_stream); - - plat_settings.use_test_input = false; - - Plat_Handle file_handle; - if (system_load_handle(plat_settings.test_input, &file_handle)){ - u32 test_size = system_load_size(file_handle); - char *test_buffer = (char*)system_memory_allocate(test_size); - - if (system_load_file(file_handle, test_buffer, test_size)){ - sim_event_count = *(i32*)test_buffer; - sim_events = (Simulation_Event*)(test_buffer + 4); - plat_settings.use_test_input = true; - } - - system_load_close(file_handle); - } - } - // // Main loop // @@ -1449,7 +1415,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS b32 get_more_messages = true; do{ - if (win32vars.got_useful_event == 0 && !plat_settings.use_test_input){ + if (win32vars.got_useful_event == 0){ get_more_messages = GetMessage(&msg, 0, 0, 0); } else{ @@ -1565,66 +1531,56 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS Application_Step_Input input = {0}; - if (!plat_settings.use_test_input){ - input.first_step = win32vars.first; - input.dt = frame_useconds/1000000.f; - - input.keys = input_chunk.trans.key_data; - - input.mouse.out_of_window = input_chunk.trans.out_of_window; - - input.mouse.l = input_chunk.pers.mouse_l; - input.mouse.press_l = input_chunk.trans.mouse_l_press; - input.mouse.release_l = input_chunk.trans.mouse_l_release; - - input.mouse.r = input_chunk.pers.mouse_r; - input.mouse.press_r = input_chunk.trans.mouse_r_press; - input.mouse.release_r = input_chunk.trans.mouse_r_release; - - input.mouse.wheel = input_chunk.trans.mouse_wheel; - input.mouse.x = input_chunk.pers.mouse_x; - input.mouse.y = input_chunk.pers.mouse_y; - - input.trying_to_kill = input_chunk.trans.trying_to_kill; - - // TODO(allen): Not really appropriate to round trip this all the way to the OS layer, redo this system. - // NOTE(allen): Ask the Core About Exiting if We Have an Exit Signal - if (win32vars.send_exit_signal){ - input.trying_to_kill = true; - win32vars.send_exit_signal = false; - } - - // NOTE(allen): Frame Clipboard Input - memset(&win32vars.clipboard_contents, 0, sizeof(win32vars.clipboard_contents)); - if (win32vars.clipboard_sequence != 0){ - DWORD new_number = GetClipboardSequenceNumber(); - if (new_number != win32vars.clipboard_sequence){ - if (win32vars.next_clipboard_is_self){ - win32vars.next_clipboard_is_self = false; - win32vars.clipboard_sequence = new_number; - } - else{ - b32 got_contents = false; - for (i32 R = 0; R < 4; ++R){ - if (win32_read_clipboard_contents()){ - win32vars.clipboard_sequence = new_number; - got_contents = true; - break; - } + input.first_step = win32vars.first; + input.dt = frame_useconds/1000000.f; + + input.keys = input_chunk.trans.key_data; + + input.mouse.out_of_window = input_chunk.trans.out_of_window; + + input.mouse.l = input_chunk.pers.mouse_l; + input.mouse.press_l = input_chunk.trans.mouse_l_press; + input.mouse.release_l = input_chunk.trans.mouse_l_release; + + input.mouse.r = input_chunk.pers.mouse_r; + input.mouse.press_r = input_chunk.trans.mouse_r_press; + input.mouse.release_r = input_chunk.trans.mouse_r_release; + + input.mouse.wheel = input_chunk.trans.mouse_wheel; + input.mouse.x = input_chunk.pers.mouse_x; + input.mouse.y = input_chunk.pers.mouse_y; + + input.trying_to_kill = input_chunk.trans.trying_to_kill; + + // TODO(allen): Not really appropriate to round trip this all the way to the OS layer, redo this system. + // NOTE(allen): Ask the Core About Exiting if We Have an Exit Signal + if (win32vars.send_exit_signal){ + input.trying_to_kill = true; + win32vars.send_exit_signal = false; + } + + // NOTE(allen): Frame Clipboard Input + memset(&win32vars.clipboard_contents, 0, sizeof(win32vars.clipboard_contents)); + if (win32vars.clipboard_sequence != 0){ + DWORD new_number = GetClipboardSequenceNumber(); + if (new_number != win32vars.clipboard_sequence){ + if (win32vars.next_clipboard_is_self){ + win32vars.next_clipboard_is_self = false; + win32vars.clipboard_sequence = new_number; + } + else{ + b32 got_contents = false; + for (i32 R = 0; R < 4; ++R){ + if (win32_read_clipboard_contents()){ + win32vars.clipboard_sequence = new_number; + got_contents = true; + break; } } } } - input.clipboard = win32vars.clipboard_contents; - } - else{ - simulation_step_begin(&sim_controls, &input, - win32vars.first, frame_useconds/1000000.f); - simulation_drive_from_events(&sim_controls, &sim_stream, &input, - sim_events, sim_event_count, - target.width, target.height); - simulation_step_end(&sim_controls, &input); } + input.clipboard = win32vars.clipboard_contents; win32vars.clip_post_len = 0;