Added end file hook, got the sticky jumps pretty much finished for 4.0.19

master
Allen Webster 2017-04-18 11:41:49 -04:00
parent a5936fa734
commit aba023aff8
11 changed files with 71 additions and 75 deletions

View File

@ -797,6 +797,8 @@ ENUM(int32_t, Special_Hook_ID){
/* DOC(TODO) */ /* DOC(TODO) */
special_hook_save_file, special_hook_save_file,
/* DOC(TODO) */ /* DOC(TODO) */
special_hook_end_file,
/* DOC(TODO) */
special_hook_command_caller, special_hook_command_caller,
/* DOC(TODO) */ /* DOC(TODO) */
special_hook_input_filter, special_hook_input_filter,

View File

@ -150,8 +150,7 @@ OPEN_FILE_HOOK_SIG(default_new_file){
} }
OPEN_FILE_HOOK_SIG(default_file_save){ OPEN_FILE_HOOK_SIG(default_file_save){
uint32_t access = AccessAll; Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll);
Buffer_Summary buffer = get_buffer(app, buffer_id, access);
Assert(buffer.exists); Assert(buffer.exists);
#if defined(FCODER_AUTO_INDENT_CPP) #if defined(FCODER_AUTO_INDENT_CPP)
@ -167,6 +166,22 @@ OPEN_FILE_HOOK_SIG(default_file_save){
return(0); 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 // NOTE(allen|a4.0.9): The input filter allows you to modify the input
// to a frame before 4coder starts processing it at all. // 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_open_file_hook(context, default_file_settings);
set_new_file_hook(context, default_new_file); set_new_file_hook(context, default_new_file);
set_save_file_hook(context, default_file_save); set_save_file_hook(context, default_file_save);
set_end_file_hook(context, default_end_file);
set_command_caller(context, default_command_caller); set_command_caller(context, default_command_caller);
set_input_filter(context, default_suppress_mouse_filter); set_input_filter(context, default_suppress_mouse_filter);
set_scroll_rule(context, smooth_scroll_rule); set_scroll_rule(context, smooth_scroll_rule);

View File

@ -195,6 +195,16 @@ set_save_file_hook(Bind_Helper *helper, Open_File_Hook_Function *func){
write_unit(helper, unit); 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 inline void
set_command_caller(Bind_Helper *helper, Command_Caller_Hook_Function *func){ set_command_caller(Bind_Helper *helper, Command_Caller_Hook_Function *func){
Binding_Unit unit; Binding_Unit unit;

View File

@ -424,11 +424,6 @@ ENUM_INTERNAL(uint8_t, Cpp_Lex_State){
LS_char = 32, 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. // NOTE(allen): These provide names that match the overloaded meanings of string states.
#define LS_string_raw LS_string_R #define LS_string_raw LS_string_R
#define LS_string_normal LS_string_LUu8 #define LS_string_normal LS_string_LUu8

45
4ed.cpp
View File

@ -420,17 +420,13 @@ COMMAND_DECL(change_active_panel){
COMMAND_DECL(interactive_switch_buffer){ COMMAND_DECL(interactive_switch_buffer){
USE_VIEW(view); USE_VIEW(view);
view_show_interactive(system, view, view_show_interactive(system, view, IAct_Switch, IInt_Live_File_List, make_lit_string("Switch Buffer: "));
IAct_Switch, IInt_Live_File_List,
make_lit_string("Switch Buffer: "));
} }
COMMAND_DECL(interactive_kill_buffer){ COMMAND_DECL(interactive_kill_buffer){
USE_VIEW(view); USE_VIEW(view);
view_show_interactive(system, view, view_show_interactive(system, view, IAct_Kill, IInt_Live_File_List, make_lit_string("Kill Buffer: "));
IAct_Kill, IInt_Live_File_List,
make_lit_string("Kill Buffer: "));
} }
COMMAND_DECL(kill_buffer){ COMMAND_DECL(kill_buffer){
@ -441,37 +437,6 @@ COMMAND_DECL(kill_buffer){
interactive_try_kill_file(system, models, view, file); 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 internal void
case_change_range(System_Functions *system, Mem_Options *mem, View *view, Editing_File *file, u8 a, u8 z, u8 char_delta){ case_change_range(System_Functions *system, Mem_Options *mem, View *view, Editing_File *file, u8 a, u8 z, u8 char_delta){
Range range = {0}; Range range = {0};
@ -1235,6 +1200,7 @@ App_Init_Sig(app_init){
models->hook_open_file = 0; models->hook_open_file = 0;
models->hook_new_file = 0; models->hook_new_file = 0;
models->hook_save_file = 0; models->hook_save_file = 0;
models->hook_end_file = 0;
models->command_caller = 0; models->command_caller = 0;
models->input_filter = 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; models->hook_save_file = (Open_File_Hook_Function*)unit->hook.func;
}break; }break;
case special_hook_end_file:
{
models->hook_end_file = (Open_File_Hook_Function*)unit->hook.func;
}break;
case special_hook_command_caller: case special_hook_command_caller:
{ {
models->command_caller = (Command_Caller_Hook_Function*)unit->hook.func; models->command_caller = (Command_Caller_Hook_Function*)unit->hook.func;

View File

@ -188,7 +188,7 @@ DOC_SEE(Command_ID)
return(result); 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 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) 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{ else{
file = 0; file = 0;
} }break;
break;
} }
} }
@ -290,8 +289,10 @@ DOC_SEE(Command_Line_Interface_Flag)
} }
} }
else{ else{
append_ss(&feedback_str, #define MSG "did not begin command-line command because the target buffer is already in use\n"
make_lit_string("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); do_feedback_message(system, models, feedback_str);
result = false; result = false;
goto done; goto done;

View File

@ -68,6 +68,7 @@ struct Models{
Open_File_Hook_Function *hook_open_file; Open_File_Hook_Function *hook_open_file;
Open_File_Hook_Function *hook_new_file; Open_File_Hook_Function *hook_new_file;
Open_File_Hook_Function *hook_save_file; Open_File_Hook_Function *hook_save_file;
Open_File_Hook_Function *hook_end_file;
Command_Caller_Hook_Function *command_caller; Command_Caller_Hook_Function *command_caller;
Input_Filter_Function *input_filter; Input_Filter_Function *input_filter;
Scroll_Rule_Function *scroll_rule; Scroll_Rule_Function *scroll_rule;

View File

@ -3487,16 +3487,12 @@ file_replace_range(System_Functions *system, Models *models, Editing_File *file,
inline void inline void
file_clear(System_Functions *system, Models *models, Editing_File *file){ 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); 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 inline void
view_post_paste_effect(View *view, f32 seconds, i32 start, i32 size, u32 color){ view_post_paste_effect(View *view, f32 seconds, i32 start, i32 size, u32 color){
Editing_File *file = view->file_data.file; 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); file_clear(system, models, file);
} }
else{ else{
Mem_Options *mem = &models->mem; Mem_Options *mem = &models->mem;
General_Memory *general = &mem->general; 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; Working_Set *working_set = &models->working_set;
if (file != 0 && !file->settings.never_kill){ 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); buffer_unbind_name(working_set, file);
if (file->canon.name.size != 0){ if (file->canon.name.size != 0){
buffer_unbind_file(system, working_set, file); buffer_unbind_file(system, working_set, file);

View File

@ -598,24 +598,6 @@ main_fsm(Cpp_Lex_FSM fsm, uint8_t pp_state, uint8_t c, bool32 ignore_string_deli
} }
}break; }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: case LS_comment_pre:
{ {
switch (c){ switch (c){

View File

@ -1380,6 +1380,8 @@ get_bindings(void *data, int32_t size){
set_open_file_hook(context, default_file_settings); set_open_file_hook(context, default_file_settings);
set_new_file_hook(context, default_new_file); set_new_file_hook(context, default_new_file);
set_save_file_hook(context, default_file_save); 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_input_filter(context, default_suppress_mouse_filter);
set_command_caller(context, default_command_caller); set_command_caller(context, default_command_caller);

View File

@ -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_next_error_no_skips goto_next_jump_no_skips
#define goto_first_error goto_first_jump #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 #endif
// BOTTOM // BOTTOM