diff --git a/4coder_API/types.h b/4coder_API/types.h index 28d5ccaa..18a3d7fe 100644 --- a/4coder_API/types.h +++ b/4coder_API/types.h @@ -797,6 +797,8 @@ ENUM(int32_t, Special_Hook_ID){ /* DOC(TODO) */ special_hook_save_file, /* DOC(TODO) */ + special_hook_end_file, + /* DOC(TODO) */ special_hook_command_caller, /* DOC(TODO) */ special_hook_input_filter, diff --git a/4coder_default_hooks.cpp b/4coder_default_hooks.cpp index 5cb5c835..d7bd7564 100644 --- a/4coder_default_hooks.cpp +++ b/4coder_default_hooks.cpp @@ -150,8 +150,7 @@ OPEN_FILE_HOOK_SIG(default_new_file){ } OPEN_FILE_HOOK_SIG(default_file_save){ - uint32_t access = AccessAll; - Buffer_Summary buffer = get_buffer(app, buffer_id, access); + Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll); Assert(buffer.exists); #if defined(FCODER_AUTO_INDENT_CPP) @@ -167,6 +166,22 @@ OPEN_FILE_HOOK_SIG(default_file_save){ return(0); } +OPEN_FILE_HOOK_SIG(default_end_file){ + Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll); + Assert(buffer.exists); + + char space[1024]; + String str = make_fixed_width_string(space); + append(&str, "Ending file: "); + append(&str, make_string(buffer.buffer_name, buffer.buffer_name_len)); + append(&str, "\n"); + + print_message(app, str.str, str.size); + + // no meaning for return + return(0); +} + // NOTE(allen|a4.0.9): The input filter allows you to modify the input // to a frame before 4coder starts processing it at all. // @@ -276,6 +291,8 @@ set_all_default_hooks(Bind_Helper *context){ set_open_file_hook(context, default_file_settings); set_new_file_hook(context, default_new_file); set_save_file_hook(context, default_file_save); + set_end_file_hook(context, default_end_file); + set_command_caller(context, default_command_caller); set_input_filter(context, default_suppress_mouse_filter); set_scroll_rule(context, smooth_scroll_rule); diff --git a/4coder_helper/4coder_bind_helper.h b/4coder_helper/4coder_bind_helper.h index a9d42255..20876203 100644 --- a/4coder_helper/4coder_bind_helper.h +++ b/4coder_helper/4coder_bind_helper.h @@ -195,6 +195,16 @@ set_save_file_hook(Bind_Helper *helper, Open_File_Hook_Function *func){ write_unit(helper, unit); } +inline void +set_end_file_hook(Bind_Helper *helper, Open_File_Hook_Function *func){ + Binding_Unit unit; + unit.type = unit_hook; + unit.hook.hook_id = special_hook_end_file; + unit.hook.func = (void*) func; + + write_unit(helper, unit); +} + inline void set_command_caller(Bind_Helper *helper, Command_Caller_Hook_Function *func){ Binding_Unit unit; diff --git a/4cpp/4cpp_lexer_types.h b/4cpp/4cpp_lexer_types.h index 952e2be0..495c5bf9 100644 --- a/4cpp/4cpp_lexer_types.h +++ b/4cpp/4cpp_lexer_types.h @@ -424,11 +424,6 @@ ENUM_INTERNAL(uint8_t, Cpp_Lex_State){ LS_char = 32, }; -#if 0 -LS_less_less = 23, -LS_more_more = 24, -#endif - // NOTE(allen): These provide names that match the overloaded meanings of string states. #define LS_string_raw LS_string_R #define LS_string_normal LS_string_LUu8 diff --git a/4ed.cpp b/4ed.cpp index f2a89949..202387a1 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -420,17 +420,13 @@ COMMAND_DECL(change_active_panel){ COMMAND_DECL(interactive_switch_buffer){ USE_VIEW(view); - view_show_interactive(system, view, - IAct_Switch, IInt_Live_File_List, - make_lit_string("Switch Buffer: ")); + view_show_interactive(system, view, IAct_Switch, IInt_Live_File_List, make_lit_string("Switch Buffer: ")); } COMMAND_DECL(interactive_kill_buffer){ USE_VIEW(view); - view_show_interactive(system, view, - IAct_Kill, IInt_Live_File_List, - make_lit_string("Kill Buffer: ")); + view_show_interactive(system, view, IAct_Kill, IInt_Live_File_List, make_lit_string("Kill Buffer: ")); } COMMAND_DECL(kill_buffer){ @@ -441,37 +437,6 @@ COMMAND_DECL(kill_buffer){ interactive_try_kill_file(system, models, view, file); } -COMMAND_DECL(toggle_line_wrap){ - REQ_READABLE_VIEW(view); - REQ_FILE(file, view); - - Assert(view->edit_pos); - - Relative_Scrolling scrolling = view_get_relative_scrolling(view); - if (file->settings.unwrapped_lines){ - file->settings.unwrapped_lines = 0; - view->edit_pos->scroll.target_x = 0; - } - else{ - file->settings.unwrapped_lines = 1; - } - view_cursor_move(system, view, view->edit_pos->cursor.pos); - view_set_relative_scrolling(view, scrolling); -} - -COMMAND_DECL(toggle_tokens){ - USE_MODELS(models); - REQ_OPEN_VIEW(view); - REQ_FILE(file, view); - - if (file->settings.tokens_exist){ - file_kill_tokens(system, &models->mem.general, file); - } - else{ - file_first_lex_parallel(system, &models->mem, file); - } -} - internal void case_change_range(System_Functions *system, Mem_Options *mem, View *view, Editing_File *file, u8 a, u8 z, u8 char_delta){ Range range = {0}; @@ -1235,6 +1200,7 @@ App_Init_Sig(app_init){ models->hook_open_file = 0; models->hook_new_file = 0; models->hook_save_file = 0; + models->hook_end_file = 0; models->command_caller = 0; models->input_filter = 0; @@ -1388,6 +1354,11 @@ App_Init_Sig(app_init){ models->hook_save_file = (Open_File_Hook_Function*)unit->hook.func; }break; + case special_hook_end_file: + { + models->hook_end_file = (Open_File_Hook_Function*)unit->hook.func; + }break; + case special_hook_command_caller: { models->command_caller = (Command_Caller_Hook_Function*)unit->hook.func; diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 2d840ed7..e388a967 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -188,7 +188,7 @@ DOC_SEE(Command_ID) return(result); } -// TODO(allen): This is a bit of a mess and needs to be fixed soon. +// TODO(allen): This is a bit of a mess and needs to be fixed. API_EXPORT bool32 Exec_System_Command(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags) /* @@ -273,8 +273,7 @@ DOC_SEE(Command_Line_Interface_Flag) } else{ file = 0; - } - break; + }break; } } @@ -290,8 +289,10 @@ DOC_SEE(Command_Line_Interface_Flag) } } else{ - append_ss(&feedback_str, - make_lit_string("did not begin command-line command because the target buffer is already in use\n")); +#define MSG "did not begin command-line command because the target buffer is already in use\n" + String msg = make_lit_string(MSG); +#undef MSG + append_ss(&feedback_str, msg); do_feedback_message(system, models, feedback_str); result = false; goto done; diff --git a/4ed_app_models.h b/4ed_app_models.h index dbcecda9..2f98ac56 100644 --- a/4ed_app_models.h +++ b/4ed_app_models.h @@ -68,6 +68,7 @@ struct Models{ Open_File_Hook_Function *hook_open_file; Open_File_Hook_Function *hook_new_file; Open_File_Hook_Function *hook_save_file; + Open_File_Hook_Function *hook_end_file; Command_Caller_Hook_Function *command_caller; Input_Filter_Function *input_filter; Scroll_Rule_Function *scroll_rule; diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 87920d9a..03164800 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -3487,16 +3487,12 @@ file_replace_range(System_Functions *system, Models *models, Editing_File *file, inline void file_clear(System_Functions *system, Models *models, Editing_File *file){ + if (models->hook_end_file != 0){ + models->hook_end_file(&models->app_links, file->id.id); + } file_replace_range(system, models, file, 0, buffer_size(&file->state.buffer), 0, 0); } -// TODO(allen): get rid of this -inline void -view_replace_range(System_Functions *system, Models *models, View *view, - i32 start, i32 end, char *str, i32 len){ - file_replace_range(system, models, view->file_data.file, start, end, str, len); -} - inline void view_post_paste_effect(View *view, f32 seconds, i32 start, i32 size, u32 color){ Editing_File *file = view->file_data.file; @@ -3926,7 +3922,6 @@ view_interactive_new_file(System_Functions *system, Models *models, View *view, file_clear(system, models, file); } else{ - Mem_Options *mem = &models->mem; General_Memory *general = &mem->general; @@ -3950,6 +3945,10 @@ kill_file(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(working_set, file); if (file->canon.name.size != 0){ buffer_unbind_file(system, working_set, file); diff --git a/meta/fsm_table_generator.cpp b/meta/fsm_table_generator.cpp index 4acbd26b..2a5009f9 100644 --- a/meta/fsm_table_generator.cpp +++ b/meta/fsm_table_generator.cpp @@ -598,24 +598,6 @@ main_fsm(Cpp_Lex_FSM fsm, uint8_t pp_state, uint8_t c, bool32 ignore_string_deli } }break; -#if 0 - case LS_less_less: - { - switch (c){ - case '=': fsm.emit_token = true; break; - default: fsm.emit_token = true; break; - } - }break; - - case LS_more_more: - { - switch (c){ - case '=': fsm.emit_token = true; break; - default: fsm.emit_token = true; break; - } - }break; -#endif - case LS_comment_pre: { switch (c){ diff --git a/power/4coder_experiments.cpp b/power/4coder_experiments.cpp index 7d6f12b1..8f6cbf31 100644 --- a/power/4coder_experiments.cpp +++ b/power/4coder_experiments.cpp @@ -1380,6 +1380,8 @@ get_bindings(void *data, int32_t size){ set_open_file_hook(context, default_file_settings); set_new_file_hook(context, default_new_file); set_save_file_hook(context, default_file_save); + set_end_file_hook(context, end_file_close_jump_list); + set_input_filter(context, default_suppress_mouse_filter); set_command_caller(context, default_command_caller); diff --git a/power/4coder_sticky_jump.cpp b/power/4coder_sticky_jump.cpp index e5ddbea1..b1f712e0 100644 --- a/power/4coder_sticky_jump.cpp +++ b/power/4coder_sticky_jump.cpp @@ -512,6 +512,22 @@ CUSTOM_COMMAND_SIG(newline_or_goto_position_same_panel){ #define goto_next_error_no_skips goto_next_jump_no_skips #define goto_first_error goto_first_jump +// +// End File Hook +// + +OPEN_FILE_HOOK_SIG(end_file_close_jump_list){ + Marker_List *list = get_marker_list_for_buffer(buffer_id); + if (list != 0){ + free_marker_list(&global_general, *list); + set_marker_list_for_buffer(buffer_id, 0); + } + + default_end_file(app, buffer_id); + + return(0); +} + #endif // BOTTOM