From 2bfab678603bfd8ed675bf0d1b62afa1a784d237 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sat, 22 Apr 2017 20:53:19 -0400 Subject: [PATCH] 4.0.19 bug fixes, all features ready to go --- 4coder_API/app_functions.h | 7 + 4coder_base_commands.cpp | 12 -- 4coder_default_framework.h | 54 ++++--- 4coder_function_list.cpp | 1 + 4coder_helper/4coder_jump_parsing.h | 89 ++++++----- 4coder_search.cpp | 15 +- 4cpp/4cpp_lexer.h | 2 +- 4ed_api_implementation.cpp | 27 +++- power/4coder_sticky_jump.cpp | 229 ++++++++++++++++++---------- 9 files changed, 273 insertions(+), 163 deletions(-) diff --git a/4coder_API/app_functions.h b/4coder_API/app_functions.h index 496c6c70..aeb11a85 100644 --- a/4coder_API/app_functions.h +++ b/4coder_API/app_functions.h @@ -23,6 +23,7 @@ struct Application_Links; #define BUFFER_TOKEN_COUNT_SIG(n) int32_t n(Application_Links *app, Buffer_Summary *buffer) #define BUFFER_READ_TOKENS_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start_token, int32_t end_token, Cpp_Token *tokens_out) #define BUFFER_GET_TOKEN_INDEX_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result) +#define BUFFER_SEND_END_SIGNAL_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer) #define BEGIN_BUFFER_CREATION_SIG(n) bool32 n(Application_Links *app, Buffer_Creation_Data *data, Buffer_Create_Flag flags) #define BUFFER_CREATION_NAME_SIG(n) bool32 n(Application_Links *app, Buffer_Creation_Data *data, char *filename, int32_t filename_len, uint32_t flags) #define END_BUFFER_CREATION_SIG(n) Buffer_Summary n(Application_Links *app, Buffer_Creation_Data *data) @@ -95,6 +96,7 @@ typedef BUFFER_SET_SETTING_SIG(Buffer_Set_Setting_Function); typedef BUFFER_TOKEN_COUNT_SIG(Buffer_Token_Count_Function); typedef BUFFER_READ_TOKENS_SIG(Buffer_Read_Tokens_Function); typedef BUFFER_GET_TOKEN_INDEX_SIG(Buffer_Get_Token_Index_Function); +typedef BUFFER_SEND_END_SIGNAL_SIG(Buffer_Send_End_Signal_Function); typedef BEGIN_BUFFER_CREATION_SIG(Begin_Buffer_Creation_Function); typedef BUFFER_CREATION_NAME_SIG(Buffer_Creation_Name_Function); typedef END_BUFFER_CREATION_SIG(End_Buffer_Creation_Function); @@ -169,6 +171,7 @@ Buffer_Set_Setting_Function *buffer_set_setting; Buffer_Token_Count_Function *buffer_token_count; Buffer_Read_Tokens_Function *buffer_read_tokens; Buffer_Get_Token_Index_Function *buffer_get_token_index; +Buffer_Send_End_Signal_Function *buffer_send_end_signal; Begin_Buffer_Creation_Function *begin_buffer_creation; Buffer_Creation_Name_Function *buffer_creation_name; End_Buffer_Creation_Function *end_buffer_creation; @@ -242,6 +245,7 @@ Buffer_Set_Setting_Function *buffer_set_setting_; Buffer_Token_Count_Function *buffer_token_count_; Buffer_Read_Tokens_Function *buffer_read_tokens_; Buffer_Get_Token_Index_Function *buffer_get_token_index_; +Buffer_Send_End_Signal_Function *buffer_send_end_signal_; Begin_Buffer_Creation_Function *begin_buffer_creation_; Buffer_Creation_Name_Function *buffer_creation_name_; End_Buffer_Creation_Function *end_buffer_creation_; @@ -323,6 +327,7 @@ app_links->buffer_set_setting_ = Buffer_Set_Setting;\ app_links->buffer_token_count_ = Buffer_Token_Count;\ app_links->buffer_read_tokens_ = Buffer_Read_Tokens;\ app_links->buffer_get_token_index_ = Buffer_Get_Token_Index;\ +app_links->buffer_send_end_signal_ = Buffer_Send_End_Signal;\ app_links->begin_buffer_creation_ = Begin_Buffer_Creation;\ app_links->buffer_creation_name_ = Buffer_Creation_Name;\ app_links->end_buffer_creation_ = End_Buffer_Creation;\ @@ -396,6 +401,7 @@ static inline bool32 buffer_set_setting(Application_Links *app, Buffer_Summary * static inline int32_t buffer_token_count(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_token_count(app, buffer));} static inline bool32 buffer_read_tokens(Application_Links *app, Buffer_Summary *buffer, int32_t start_token, int32_t end_token, Cpp_Token *tokens_out){return(app->buffer_read_tokens(app, buffer, start_token, end_token, tokens_out));} static inline bool32 buffer_get_token_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result){return(app->buffer_get_token_index(app, buffer, pos, get_result));} +static inline bool32 buffer_send_end_signal(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_send_end_signal(app, buffer));} static inline bool32 begin_buffer_creation(Application_Links *app, Buffer_Creation_Data *data, Buffer_Create_Flag flags){return(app->begin_buffer_creation(app, data, flags));} static inline bool32 buffer_creation_name(Application_Links *app, Buffer_Creation_Data *data, char *filename, int32_t filename_len, uint32_t flags){return(app->buffer_creation_name(app, data, filename, filename_len, flags));} static inline Buffer_Summary end_buffer_creation(Application_Links *app, Buffer_Creation_Data *data){return(app->end_buffer_creation(app, data));} @@ -469,6 +475,7 @@ static inline bool32 buffer_set_setting(Application_Links *app, Buffer_Summary * static inline int32_t buffer_token_count(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_token_count_(app, buffer));} static inline bool32 buffer_read_tokens(Application_Links *app, Buffer_Summary *buffer, int32_t start_token, int32_t end_token, Cpp_Token *tokens_out){return(app->buffer_read_tokens_(app, buffer, start_token, end_token, tokens_out));} static inline bool32 buffer_get_token_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result){return(app->buffer_get_token_index_(app, buffer, pos, get_result));} +static inline bool32 buffer_send_end_signal(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_send_end_signal_(app, buffer));} static inline bool32 begin_buffer_creation(Application_Links *app, Buffer_Creation_Data *data, Buffer_Create_Flag flags){return(app->begin_buffer_creation_(app, data, flags));} static inline bool32 buffer_creation_name(Application_Links *app, Buffer_Creation_Data *data, char *filename, int32_t filename_len, uint32_t flags){return(app->buffer_creation_name_(app, data, filename, filename_len, flags));} static inline Buffer_Summary end_buffer_creation(Application_Links *app, Buffer_Creation_Data *data){return(app->end_buffer_creation_(app, data));} diff --git a/4coder_base_commands.cpp b/4coder_base_commands.cpp index 5b209de2..d907c017 100644 --- a/4coder_base_commands.cpp +++ b/4coder_base_commands.cpp @@ -451,18 +451,6 @@ CUSTOM_COMMAND_SIG(close_panel){ close_view(app, &view); } -CUSTOM_COMMAND_SIG(open_panel_vsplit){ - View_Summary view = get_active_view(app, AccessAll); - View_Summary new_view = open_view(app, &view, ViewSplit_Right); - view_set_setting(app, &new_view, ViewSetting_ShowScrollbar, false); -} - -CUSTOM_COMMAND_SIG(open_panel_hsplit){ - View_Summary view = get_active_view(app, AccessAll); - View_Summary new_view = open_view(app, &view, ViewSplit_Bottom); - view_set_setting(app, &new_view, ViewSetting_ShowScrollbar, false); -} - // // Common Settings Commands diff --git a/4coder_default_framework.h b/4coder_default_framework.h index 259cb191..d7426486 100644 --- a/4coder_default_framework.h +++ b/4coder_default_framework.h @@ -84,6 +84,19 @@ get_view_for_locked_jump_buffer(Application_Links *app){ static View_ID special_note_view_id = 0; +static bool32 default_use_scrollbars = false; +static bool32 default_use_file_bars = true; + +static void +new_view_settings(Application_Links *app, View_Summary *view){ + if (!default_use_scrollbars){ + view_set_setting(app, view, ViewSetting_ShowScrollbar, false); + } + if (!default_use_file_bars){ + view_set_setting(app, view, ViewSetting_ShowFileBar, false); + } +} + static void close_special_note_view(Application_Links *app){ View_Summary special_view = get_view(app, special_note_view_id, AccessAll); @@ -100,7 +113,7 @@ open_special_note_view(Application_Links *app, bool32 create_if_not_exist = true if (create_if_not_exist && !special_view.exists){ View_Summary view = get_active_view(app, AccessAll); special_view = open_view(app, &view, ViewSplit_Bottom); - view_set_setting(app, &special_view, ViewSetting_ShowScrollbar, false); + new_view_settings(app, &special_view); view_set_split_proportion(app, &special_view, .2f); set_active_view(app, &view); special_note_view_id = special_view.view_id; @@ -141,6 +154,18 @@ CUSTOM_COMMAND_SIG(change_active_panel_backwards){ } } +CUSTOM_COMMAND_SIG(open_panel_vsplit){ + View_Summary view = get_active_view(app, AccessAll); + View_Summary new_view = open_view(app, &view, ViewSplit_Right); + new_view_settings(app, &new_view); +} + +CUSTOM_COMMAND_SIG(open_panel_hsplit){ + View_Summary view = get_active_view(app, AccessAll); + View_Summary new_view = open_view(app, &view, ViewSplit_Bottom); + new_view_settings(app, &new_view); +} + // // View Variabls // @@ -789,9 +814,6 @@ init_memory(Application_Links *app){ general_memory_open(&global_general, general_mem, general_size); } -static bool32 default_use_scrollbars = false; -static bool32 default_use_file_bars = true; - static void default_4coder_initialize(Application_Links *app, bool32 use_scrollbars, bool32 use_file_bars){ init_memory(app); @@ -814,30 +836,16 @@ default_4coder_initialize(Application_Links *app){ static void default_4coder_side_by_side_panels(Application_Links *app){ + View_Summary view = get_active_view(app, AccessAll); + new_view_settings(app, &view); open_panel_vsplit(app); - if (!default_use_scrollbars){ - hide_scrollbar(app); - } - if (!default_use_file_bars){ - hide_filebar(app); - } - change_active_panel(app); - if (!default_use_scrollbars){ - hide_scrollbar(app); - } - if (!default_use_file_bars){ - hide_filebar(app); - } + set_active_view(app, &view); } static void default_4coder_one_panel(Application_Links *app){ - if (!default_use_scrollbars){ - hide_scrollbar(app); - } - if (!default_use_file_bars){ - hide_filebar(app); - } + View_Summary view = get_active_view(app, AccessAll); + new_view_settings(app, &view); } static void diff --git a/4coder_function_list.cpp b/4coder_function_list.cpp index 55831edb..50975908 100644 --- a/4coder_function_list.cpp +++ b/4coder_function_list.cpp @@ -315,6 +315,7 @@ list_all_functions(Application_Links *app, Partition *part, Buffer_Summary *buff buffer_set_setting(app, &decls_buffer, BufferSetting_WrapLine, false); } else{ + buffer_send_end_signal(app, &decls_buffer); buffer_replace_range(app, &decls_buffer, 0, decls_buffer.size, 0, 0); } diff --git a/4coder_helper/4coder_jump_parsing.h b/4coder_helper/4coder_jump_parsing.h index 932da31a..d374d854 100644 --- a/4coder_helper/4coder_jump_parsing.h +++ b/4coder_helper/4coder_jump_parsing.h @@ -36,61 +36,64 @@ ms_style_verify(String line, int32_t paren_pos){ return(result); } -static int32_t -parse_jump_location(String line, Name_Based_Jump_Location *location, int32_t skip_sub_errors, int32_t *colon_char){ - int32_t result = false; +static bool32 +parse_jump_location(String line, Name_Based_Jump_Location *location, int32_t *colon_char, bool32 *is_sub_error){ + bool32 result = false; int32_t whitespace_length = 0; String original_line = line; line = skip_chop_whitespace(line, &whitespace_length); int32_t colon_pos = 0; - int32_t is_ms_style = 0; + bool32 is_ms_style = false; + + *is_sub_error = false; + if (original_line.str[0] == ' '){ + *is_sub_error = true; + } int32_t paren_pos = find_s_char(line, 0, ')'); while (!is_ms_style && paren_pos < line.size){ if (ms_style_verify(line, paren_pos)){ - is_ms_style = 1; + is_ms_style = true; colon_pos = find_s_char(line, paren_pos, ':'); if (colon_pos < line.size){ String location_str = substr(line, 0, colon_pos); - if (!(skip_sub_errors && original_line.str[0] == ' ')){ - location_str = skip_chop_whitespace(location_str); + location_str = skip_chop_whitespace(location_str); + + int32_t close_pos = paren_pos; + int32_t open_pos = rfind_s_char(location_str, close_pos, '('); + + if (0 < open_pos && open_pos < location_str.size){ + String file = substr(location_str, 0, open_pos); + file = skip_chop_whitespace(file); - int32_t close_pos = paren_pos; - int32_t open_pos = rfind_s_char(location_str, close_pos, '('); - - if (0 < open_pos && open_pos < location_str.size){ - String file = substr(location_str, 0, open_pos); - file = skip_chop_whitespace(file); + if (file.size > 0){ + String line_number = substr(location_str, + open_pos+1, + close_pos-open_pos-1); + line_number = skip_chop_whitespace(line_number); - if (file.size > 0){ - String line_number = substr(location_str, - open_pos+1, - close_pos-open_pos-1); - line_number = skip_chop_whitespace(line_number); + if (line_number.size > 0){ + location->file = file; - if (line_number.size > 0){ - location->file = file; + int32_t comma_pos = find_s_char(line_number, 0, ','); + if (comma_pos < line_number.size){ + int32_t start = comma_pos+1; + String column_number = substr(line_number, start, line_number.size-start); + line_number = substr(line_number, 0, comma_pos); - int32_t comma_pos = find_s_char(line_number, 0, ','); - if (comma_pos < line_number.size){ - int32_t start = comma_pos+1; - String column_number = substr(line_number, start, line_number.size-start); - line_number = substr(line_number, 0, comma_pos); - - location->line = str_to_int_s(line_number); - location->column = str_to_int_s(column_number); - } - else{ - location->line = str_to_int_s(line_number); - location->column = 1; - } - - *colon_char = colon_pos + whitespace_length; - result = true; + location->line = str_to_int_s(line_number); + location->column = str_to_int_s(column_number); } + else{ + location->line = str_to_int_s(line_number); + location->column = 1; + } + + *colon_char = colon_pos + whitespace_length; + result = true; } } } @@ -145,6 +148,20 @@ parse_jump_location(String line, Name_Based_Jump_Location *location, int32_t ski } } + if (!result){ + *is_sub_error = false; + } + + return(result); +} + +static bool32 +parse_jump_location(String line, Name_Based_Jump_Location *location, bool32 skip_sub_error, int32_t *colon_char){ + bool32 is_sub_error = false; + bool32 result = parse_jump_location(line, location, colon_char, &is_sub_error); + if (is_sub_error && skip_sub_error){ + result = false; + } return(result); } diff --git a/4coder_search.cpp b/4coder_search.cpp index 0915a06a..be46d78b 100644 --- a/4coder_search.cpp +++ b/4coder_search.cpp @@ -535,6 +535,7 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part buffer_set_setting(app, &search_buffer, BufferSetting_WrapLine, false); } else{ + buffer_send_end_signal(app, &search_buffer); buffer_replace_range(app, &search_buffer, 0, search_buffer.size, 0, 0); } @@ -559,12 +560,14 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part get_buffer_next(app, &buffer_it, AccessAll)){ if (buffer.buffer_id != buffer_it.buffer_id){ if (search_buffer.buffer_id != buffer_it.buffer_id){ - ranges[j].type = SearchRange_FrontToBack; - ranges[j].flags = match_flags; - ranges[j].buffer = buffer_it.buffer_id; - ranges[j].start = 0; - ranges[j].size = buffer_it.size; - ++j; + if (buffer_it.buffer_name[0] != '*'){ + ranges[j].type = SearchRange_FrontToBack; + ranges[j].flags = match_flags; + ranges[j].buffer = buffer_it.buffer_id; + ranges[j].start = 0; + ranges[j].size = buffer_it.size; + ++j; + } } } } diff --git a/4cpp/4cpp_lexer.h b/4cpp/4cpp_lexer.h index 02592fe9..c495adb5 100644 --- a/4cpp/4cpp_lexer.h +++ b/4cpp/4cpp_lexer.h @@ -1285,7 +1285,7 @@ The start and end points are based on the edited region of the file before the e if (end_pos > array->tokens[range.end_token_index].start){ ++range.end_token_index; } - ++range.end_token_index; + //++range.end_token_index; if (range.end_token_index < 0){ range.end_token_index = 0; } diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index e388a967..cb8f3c66 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -1085,12 +1085,27 @@ DOC_SEE(cpp_get_token) Editing_File *file = imp_get_file(cmd, buffer); Cpp_Token_Array token_array = file->state.token_array; - bool32 result = 0; - if (file && token_array.tokens && file->state.tokens_complete){ - result = 1; - Cpp_Get_Token_Result get = {0}; - get = cpp_get_token(token_array, pos); - *get_result = get; + bool32 result = false; + if (file != 0 && token_array.tokens != 0 && file->state.tokens_complete){ + result = true; + *get_result = cpp_get_token(token_array, pos); + } + + return(result); +} + +API_EXPORT bool32 +Buffer_Send_End_Signal(Application_Links *app, Buffer_Summary *buffer){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Models *models = cmd->models; + Editing_File *file = imp_get_file(cmd, buffer); + + bool32 result = false; + if (file != 0){ + Open_File_Hook_Function *hook_end_file = models->hook_end_file; + if (hook_end_file != 0){ + hook_end_file(app, file->id.id); + } } return(result); diff --git a/power/4coder_sticky_jump.cpp b/power/4coder_sticky_jump.cpp index b1f712e0..ae8c12ca 100644 --- a/power/4coder_sticky_jump.cpp +++ b/power/4coder_sticky_jump.cpp @@ -46,10 +46,15 @@ binary_search(uint32_t *array, uint32_t count, uint32_t x){ return(i); } +enum Jump_Location_Flag{ + JumpFlag_IsSubJump = 0x1, +}; + struct Marker_List{ uint32_t *handle_starts; Marker_Handle *handles; uint32_t *jump_line_numbers; + uint32_t *jump_flags; uint32_t handle_count; uint32_t handle_max; int32_t jump_max; @@ -60,6 +65,7 @@ static void double_jump_max(General_Memory *general, Marker_List *list){ uint32_t new_jump_max = list->jump_max*2; list->jump_line_numbers = gen_realloc_array(general, uint32_t, list->jump_line_numbers, list->jump_max, new_jump_max); + list->jump_flags = gen_realloc_array(general, uint32_t, list->jump_flags, list->jump_max, new_jump_max); list->jump_max = new_jump_max; } @@ -74,9 +80,9 @@ double_handle_max(General_Memory *general, Marker_List *list){ // TODO(allen): what to do when a push returns 0? static Marker_List make_marker_list(Application_Links *app, Partition *part, General_Memory *general, int32_t buffer_id){ - Marker_List list = {0}; + Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll); - int32_t line = 1; + Marker_List list = {0}; Temp_Memory temp = begin_temp_memory(part); ID_Based_Jump_Location *location_list = (ID_Based_Jump_Location*)partition_current(part); @@ -88,15 +94,31 @@ make_marker_list(Application_Links *app, Partition *part, General_Memory *genera list.jump_max = 64; list.jump_line_numbers = gen_array(general, uint32_t, list.jump_max); + list.jump_flags = gen_array(general, uint32_t, list.jump_max); uint32_t prev_jump_count = 0; - for (;;){ - int32_t this_jump_line = 0; - int32_t colon_index = 0; + for (int32_t this_jump_line = 1;; ++this_jump_line){ + bool32 output_jump = false; Name_Based_Jump_Location location = {0}; + bool32 is_sub_error = false; Temp_Memory temp_name = begin_temp_memory(part); - if (seek_next_jump_in_buffer(app, part, buffer_id, line, false, 1, &this_jump_line, &colon_index, &location)){ + String line_str = {0}; + if (read_line(app, part, &buffer, this_jump_line, &line_str)){ + int32_t colon_index = 0; + if (parse_jump_location(line_str, &location, &colon_index, &is_sub_error)){ + output_jump = true; + } + else{ + end_temp_memory(temp_name); + } + } + else{ + end_temp_memory(temp_name); + break; + } + + if (output_jump){ Buffer_Summary jump_buffer = {0}; if (open_file(app, &jump_buffer, location.file.str, location.file.size, false, true)){ ID_Based_Jump_Location id_location = {0}; @@ -151,18 +173,19 @@ make_marker_list(Application_Links *app, Partition *part, General_Memory *genera double_jump_max(general, &list); } list.jump_line_numbers[list.jump_count] = this_jump_line; + + uint32_t flags = 0; + if (is_sub_error){ + flags |= JumpFlag_IsSubJump; + } + + list.jump_flags[list.jump_count] = flags; ++list.jump_count; } } else{ end_temp_memory(temp_name); } - - line = this_jump_line+1; - } - else{ - end_temp_memory(temp_name); - break; } } @@ -382,35 +405,87 @@ CUSTOM_COMMAND_SIG(goto_jump_at_cursor_same_panel){ end_temp_memory(temp); } -// TODO(allen): MASSIVELY DEDUPLICATE THIS PLEASE. +static void +goto_jump_in_order(Application_Links *app, Marker_List *list, View_Summary *jump_view, ID_Pos_Jump_Location location){ + Buffer_Summary buffer = {0}; + if (get_jump_buffer(app, &buffer, &location)){ + View_Summary target_view = get_active_view(app, AccessAll); + if (target_view.view_id == jump_view->view_id){ + change_active_panel(app); + target_view = get_active_view(app, AccessAll); + } + switch_to_existing_view(app, &target_view, &buffer); + jump_to_location(app, &target_view, &buffer, location); + prev_location.buffer_id = location.buffer_id; + prev_location.line = location.pos; + prev_location.column = 0; + } +} + +static bool32 +skip_this_jump(ID_Based_Jump_Location prev, ID_Pos_Jump_Location location){ + bool32 skip = false; + if (prev.buffer_id == location.buffer_id && prev.line == location.pos){ + skip = true; + } + return(skip); +} + +static void +goto_next_filtered_jump(Application_Links *app, Marker_List *list, View_Summary *jump_view, int32_t list_index, int32_t direction, bool32 skip_repeats, bool32 skip_sub_errors){ + Assert(direction == 1 || direction == -1); + + while (list_index >= 0 && list_index < list->jump_count){ + ID_Pos_Jump_Location location = {0}; + if (get_jump_from_list(app, list, list_index, &location)){ + bool32 skip_this = false; + if (skip_repeats && skip_this_jump(prev_location, location)){ + skip_this = true; + } + else if (skip_sub_errors && (list->jump_flags[list_index] & JumpFlag_IsSubJump)){ + skip_this = true; + } + + if (!skip_this){ + goto_jump_in_order(app, list, jump_view, location); + int32_t updated_line = get_line_from_list(list, list_index); + view_set_cursor(app, jump_view, seek_line_char(updated_line, 1), true); + break; + } + } + + list_index += direction; + } +} + +struct Locked_Jump_State{ + View_Summary view; + Marker_List *list; + int32_t list_index; +}; + +static Locked_Jump_State +get_locked_jump_state(Application_Links *app, Partition *part, General_Memory *general){ + Locked_Jump_State result = {0}; + result.view = get_view_for_locked_jump_buffer(app); + if (result.view.exists){ + result.list = get_or_make_list_for_buffer(app, part, general, result.view.buffer_id); + result.list_index = get_index_nearest_from_list(result.list, result.view.cursor.line); + } + return(result); +} + CUSTOM_COMMAND_SIG(goto_next_jump){ General_Memory *general = &global_general; Partition *part = &global_part; - View_Summary view = get_view_for_locked_jump_buffer(app); - if (view.exists){ - Marker_List *list = get_or_make_list_for_buffer(app, part, general, view.buffer_id); - int32_t list_index = get_index_nearest_from_list(list, view.cursor.line); - ++list_index; - - if (list_index >= 0 && list_index < list->jump_count){ - ID_Pos_Jump_Location location = {0}; - if (get_jump_from_list(app, list, list_index, &location)){ - Buffer_Summary buffer = {0}; - if (get_jump_buffer(app, &buffer, &location)){ - View_Summary target_view = get_active_view(app, AccessAll); - if (target_view.view_id == view.view_id){ - change_active_panel(app); - target_view = get_active_view(app, AccessAll); - } - switch_to_existing_view(app, &target_view, &buffer); - jump_to_location(app, &target_view, &buffer, location); - } - - int32_t updated_line = get_line_from_list(list, list_index); - view_set_cursor(app, &view, seek_line_char(updated_line, 1), true); - } + Locked_Jump_State jump_state = get_locked_jump_state(app, part, general); + if (jump_state.view.exists){ + int32_t line = get_line_from_list(jump_state.list, jump_state.list_index); + if (line <= jump_state.view.cursor.line){ + ++jump_state.list_index; } + goto_next_filtered_jump(app, jump_state.list, &jump_state.view, jump_state.list_index, 1, true, true); } } @@ -418,30 +493,39 @@ CUSTOM_COMMAND_SIG(goto_prev_jump){ General_Memory *general = &global_general; Partition *part = &global_part; - View_Summary view = get_view_for_locked_jump_buffer(app); - if (view.exists){ - Marker_List *list = get_or_make_list_for_buffer(app, part, general, view.buffer_id); - int32_t list_index = get_index_nearest_from_list(list, view.cursor.line); - --list_index; - - if (list_index >= 0 && list_index < list->jump_count){ - ID_Pos_Jump_Location location = {0}; - if (get_jump_from_list(app, list, list_index, &location)){ - Buffer_Summary buffer = {0}; - if (get_jump_buffer(app, &buffer, &location)){ - View_Summary target_view = get_active_view(app, AccessAll); - if (target_view.view_id == view.view_id){ - change_active_panel(app); - target_view = get_active_view(app, AccessAll); - } - switch_to_existing_view(app, &target_view, &buffer); - jump_to_location(app, &target_view, &buffer, location); - } - - int32_t updated_line = get_line_from_list(list, list_index); - view_set_cursor(app, &view, seek_line_char(updated_line, 1), true); - } + Locked_Jump_State jump_state = get_locked_jump_state(app, part, general); + if (jump_state.view.exists){ + if (jump_state.list_index > 0){ + --jump_state.list_index; } + goto_next_filtered_jump(app, jump_state.list, &jump_state.view, jump_state.list_index, -1, true, true); + } +} + +CUSTOM_COMMAND_SIG(goto_next_jump_no_skips){ + General_Memory *general = &global_general; + Partition *part = &global_part; + + Locked_Jump_State jump_state = get_locked_jump_state(app, part, general); + if (jump_state.view.exists){ + int32_t line = get_line_from_list(jump_state.list, jump_state.list_index); + if (line <= jump_state.view.cursor.line){ + ++jump_state.list_index; + } + goto_next_filtered_jump(app, jump_state.list, &jump_state.view, jump_state.list_index, 1, true, false); + } +} + +CUSTOM_COMMAND_SIG(goto_prev_jump_no_skips){ + General_Memory *general = &global_general; + Partition *part = &global_part; + + Locked_Jump_State jump_state = get_locked_jump_state(app, part, general); + if (jump_state.view.exists){ + if (jump_state.list_index > 0){ + --jump_state.list_index; + } + goto_next_filtered_jump(app, jump_state.list, &jump_state.view, jump_state.list_index, -1, true, false); } } @@ -449,26 +533,14 @@ CUSTOM_COMMAND_SIG(goto_first_jump){ General_Memory *general = &global_general; Partition *part = &global_part; - View_Summary view = get_view_for_locked_jump_buffer(app); - if (view.exists){ - Marker_List *list = get_or_make_list_for_buffer(app, part, general, view.buffer_id); + Locked_Jump_State jump_state = get_locked_jump_state(app, part, general); + if (jump_state.view.exists){ int32_t list_index = 0; - ID_Pos_Jump_Location location = {0}; - if (get_jump_from_list(app, list, list_index, &location)){ - Buffer_Summary buffer = {0}; - if (get_jump_buffer(app, &buffer, &location)){ - View_Summary target_view = get_active_view(app, AccessAll); - if (target_view.view_id == view.view_id){ - change_active_panel(app); - target_view = get_active_view(app, AccessAll); - } - switch_to_existing_view(app, &target_view, &buffer); - jump_to_location(app, &target_view, &buffer, location); - } - - int32_t updated_line = get_line_from_list(list, list_index); - view_set_cursor(app, &view, seek_line_char(updated_line, 1), true); + if (get_jump_from_list(app, jump_state.list, list_index, &location)){ + goto_jump_in_order(app, jump_state.list, &jump_state.view, location); + int32_t updated_line = get_line_from_list(jump_state.list, list_index); + view_set_cursor(app, &jump_state.view, seek_line_char(updated_line, 1), true); } } } @@ -504,12 +576,11 @@ CUSTOM_COMMAND_SIG(newline_or_goto_position_same_panel){ } -#define goto_next_jump_no_skips goto_next_jump -#define goto_prev_jump_no_skips goto_prev_jump #define seek_error seek_jump #define goto_next_error goto_next_jump #define goto_prev_error goto_prev_jump #define goto_next_error_no_skips goto_next_jump_no_skips +#define goto_prev_error_no_skips goto_prev_jump_no_skips #define goto_first_error goto_first_jump //