jumping, set dirty state API, fix null dereference crash

master
Allen Webster 2019-03-31 20:50:37 -07:00
parent e57e927e07
commit 27214f4bf9
7 changed files with 140 additions and 127 deletions

View File

@ -41,6 +41,17 @@ struct Name_Line_Column_Location{
i32 column;
};
struct Parsed_Jump{
b32 success;
Name_Line_Column_Location location;
i32 colon_position;
b32 is_sub_jump;
b32 sub_jump_indented;
b32 sub_jump_note;
b32 is_ms_style;
b32 has_rust_arrow;
};
struct ID_Pos_Jump_Location_Array{
struct ID_Pos_Jump_Location *jumps;
i32 count;

View File

@ -30,6 +30,7 @@ struct Application_Links;
#define BUFFER_GET_UNIQUE_BUFFER_NAME_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, String *name_out, i32 *required_size_out)
#define BUFFER_GET_FILE_NAME_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, String *name_out, i32 *required_size_out)
#define BUFFER_GET_DIRTY_STATE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Dirty_State *dirty_state_out)
#define BUFFER_DIRECTLY_SET_DIRTY_STATE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Dirty_State dirty_state)
#define BUFFER_TOKENS_ARE_READY_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id)
#define BUFFER_GET_SETTING_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i32 *value_out)
#define BUFFER_SET_SETTING_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i32 value)
@ -207,6 +208,7 @@ typedef BUFFER_GET_BASE_BUFFER_NAME_SIG(Buffer_Get_Base_Buffer_Name_Function);
typedef BUFFER_GET_UNIQUE_BUFFER_NAME_SIG(Buffer_Get_Unique_Buffer_Name_Function);
typedef BUFFER_GET_FILE_NAME_SIG(Buffer_Get_File_Name_Function);
typedef BUFFER_GET_DIRTY_STATE_SIG(Buffer_Get_Dirty_State_Function);
typedef BUFFER_DIRECTLY_SET_DIRTY_STATE_SIG(Buffer_Directly_Set_Dirty_State_Function);
typedef BUFFER_TOKENS_ARE_READY_SIG(Buffer_Tokens_Are_Ready_Function);
typedef BUFFER_GET_SETTING_SIG(Buffer_Get_Setting_Function);
typedef BUFFER_SET_SETTING_SIG(Buffer_Set_Setting_Function);
@ -386,6 +388,7 @@ Buffer_Get_Base_Buffer_Name_Function *buffer_get_base_buffer_name;
Buffer_Get_Unique_Buffer_Name_Function *buffer_get_unique_buffer_name;
Buffer_Get_File_Name_Function *buffer_get_file_name;
Buffer_Get_Dirty_State_Function *buffer_get_dirty_state;
Buffer_Directly_Set_Dirty_State_Function *buffer_directly_set_dirty_state;
Buffer_Tokens_Are_Ready_Function *buffer_tokens_are_ready;
Buffer_Get_Setting_Function *buffer_get_setting;
Buffer_Set_Setting_Function *buffer_set_setting;
@ -564,6 +567,7 @@ Buffer_Get_Base_Buffer_Name_Function *buffer_get_base_buffer_name_;
Buffer_Get_Unique_Buffer_Name_Function *buffer_get_unique_buffer_name_;
Buffer_Get_File_Name_Function *buffer_get_file_name_;
Buffer_Get_Dirty_State_Function *buffer_get_dirty_state_;
Buffer_Directly_Set_Dirty_State_Function *buffer_directly_set_dirty_state_;
Buffer_Tokens_Are_Ready_Function *buffer_tokens_are_ready_;
Buffer_Get_Setting_Function *buffer_get_setting_;
Buffer_Set_Setting_Function *buffer_set_setting_;
@ -750,6 +754,7 @@ app_links->buffer_get_base_buffer_name_ = Buffer_Get_Base_Buffer_Name;\
app_links->buffer_get_unique_buffer_name_ = Buffer_Get_Unique_Buffer_Name;\
app_links->buffer_get_file_name_ = Buffer_Get_File_Name;\
app_links->buffer_get_dirty_state_ = Buffer_Get_Dirty_State;\
app_links->buffer_directly_set_dirty_state_ = Buffer_Directly_Set_Dirty_State;\
app_links->buffer_tokens_are_ready_ = Buffer_Tokens_Are_Ready;\
app_links->buffer_get_setting_ = Buffer_Get_Setting;\
app_links->buffer_set_setting_ = Buffer_Set_Setting;\
@ -928,6 +933,7 @@ static b32 buffer_get_base_buffer_name(Application_Links *app, Buffer_ID buffer_
static b32 buffer_get_unique_buffer_name(Application_Links *app, Buffer_ID buffer_id, String *name_out, i32 *required_size_out){return(app->buffer_get_unique_buffer_name(app, buffer_id, name_out, required_size_out));}
static b32 buffer_get_file_name(Application_Links *app, Buffer_ID buffer_id, String *name_out, i32 *required_size_out){return(app->buffer_get_file_name(app, buffer_id, name_out, required_size_out));}
static b32 buffer_get_dirty_state(Application_Links *app, Buffer_ID buffer_id, Dirty_State *dirty_state_out){return(app->buffer_get_dirty_state(app, buffer_id, dirty_state_out));}
static b32 buffer_directly_set_dirty_state(Application_Links *app, Buffer_ID buffer_id, Dirty_State dirty_state){return(app->buffer_directly_set_dirty_state(app, buffer_id, dirty_state));}
static b32 buffer_tokens_are_ready(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_tokens_are_ready(app, buffer_id));}
static b32 buffer_get_setting(Application_Links *app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i32 *value_out){return(app->buffer_get_setting(app, buffer_id, setting, value_out));}
static b32 buffer_set_setting(Application_Links *app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i32 value){return(app->buffer_set_setting(app, buffer_id, setting, value));}
@ -1106,6 +1112,7 @@ static b32 buffer_get_base_buffer_name(Application_Links *app, Buffer_ID buffer_
static b32 buffer_get_unique_buffer_name(Application_Links *app, Buffer_ID buffer_id, String *name_out, i32 *required_size_out){return(app->buffer_get_unique_buffer_name_(app, buffer_id, name_out, required_size_out));}
static b32 buffer_get_file_name(Application_Links *app, Buffer_ID buffer_id, String *name_out, i32 *required_size_out){return(app->buffer_get_file_name_(app, buffer_id, name_out, required_size_out));}
static b32 buffer_get_dirty_state(Application_Links *app, Buffer_ID buffer_id, Dirty_State *dirty_state_out){return(app->buffer_get_dirty_state_(app, buffer_id, dirty_state_out));}
static b32 buffer_directly_set_dirty_state(Application_Links *app, Buffer_ID buffer_id, Dirty_State dirty_state){return(app->buffer_directly_set_dirty_state_(app, buffer_id, dirty_state));}
static b32 buffer_tokens_are_ready(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_tokens_are_ready_(app, buffer_id));}
static b32 buffer_get_setting(Application_Links *app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i32 *value_out){return(app->buffer_get_setting_(app, buffer_id, setting, value_out));}
static b32 buffer_set_setting(Application_Links *app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i32 value){return(app->buffer_set_setting_(app, buffer_id, setting, value));}

View File

@ -298,22 +298,22 @@ static Command_Metadata fcoder_metacmd_table[234] = {
{ PROC_LINKS(exit_4coder, 0), "exit_4coder", 11, "Attempts to close 4coder.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 682 },
{ PROC_LINKS(goto_beginning_of_file, 0), "goto_beginning_of_file", 22, "Sets the cursor to the beginning of the file.", 45, "w:\\4ed\\code\\4coder_seek.cpp", 27, 1131 },
{ PROC_LINKS(goto_end_of_file, 0), "goto_end_of_file", 16, "Sets the cursor to the end of the file.", 39, "w:\\4ed\\code\\4coder_seek.cpp", 27, 1139 },
{ PROC_LINKS(goto_first_jump_direct, 0), "goto_first_jump_direct", 22, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer.", 95, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 84 },
{ PROC_LINKS(goto_first_jump_same_panel_sticky, 0), "goto_first_jump_same_panel_sticky", 33, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer and views the buffer in the panel where the jump list was.", 153, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 547 },
{ PROC_LINKS(goto_first_jump_sticky, 0), "goto_first_jump_sticky", 22, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer.", 95, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 529 },
{ PROC_LINKS(goto_first_jump_direct, 0), "goto_first_jump_direct", 22, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer.", 95, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 82 },
{ PROC_LINKS(goto_first_jump_same_panel_sticky, 0), "goto_first_jump_same_panel_sticky", 33, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer and views the buffer in the panel where the jump list was.", 153, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 546 },
{ PROC_LINKS(goto_first_jump_sticky, 0), "goto_first_jump_sticky", 22, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer.", 95, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 528 },
{ PROC_LINKS(goto_jump_at_cursor_direct, 0), "goto_jump_at_cursor_direct", 26, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in another view and changes the active panel to the view containing the jump.", 187, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 8 },
{ PROC_LINKS(goto_jump_at_cursor_same_panel_direct, 0), "goto_jump_at_cursor_same_panel_direct", 37, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in this view, losing the compilation output or jump list..", 168, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 29 },
{ PROC_LINKS(goto_jump_at_cursor_same_panel_sticky, 0), "goto_jump_at_cursor_same_panel_sticky", 37, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in this view, losing the compilation output or jump list.", 167, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 373 },
{ PROC_LINKS(goto_jump_at_cursor_sticky, 0), "goto_jump_at_cursor_sticky", 26, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in another view and changes the active panel to the view containing the jump.", 187, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 345 },
{ PROC_LINKS(goto_jump_at_cursor_same_panel_direct, 0), "goto_jump_at_cursor_same_panel_direct", 37, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in this view, losing the compilation output or jump list..", 168, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 28 },
{ PROC_LINKS(goto_jump_at_cursor_same_panel_sticky, 0), "goto_jump_at_cursor_same_panel_sticky", 37, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in this view, losing the compilation output or jump list.", 167, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 372 },
{ PROC_LINKS(goto_jump_at_cursor_sticky, 0), "goto_jump_at_cursor_sticky", 26, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in another view and changes the active panel to the view containing the jump.", 187, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 344 },
{ PROC_LINKS(goto_line, 0), "goto_line", 9, "Queries the user for a number, and jumps the cursor to the corresponding line.", 78, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 690 },
{ PROC_LINKS(goto_next_jump_direct, 0), "goto_next_jump_direct", 21, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, skipping sub jump locations.", 123, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 48 },
{ PROC_LINKS(goto_next_jump_no_skips_direct, 0), "goto_next_jump_no_skips_direct", 30, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, and does not skip sub jump locations.", 132, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 66 },
{ PROC_LINKS(goto_next_jump_no_skips_sticky, 0), "goto_next_jump_no_skips_sticky", 30, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, and does not skip sub jump locations.", 132, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 498 },
{ PROC_LINKS(goto_next_jump_sticky, 0), "goto_next_jump_sticky", 21, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, skipping sub jump locations.", 123, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 468 },
{ PROC_LINKS(goto_prev_jump_direct, 0), "goto_prev_jump_direct", 21, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, skipping sub jump locations.", 127, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 57 },
{ PROC_LINKS(goto_prev_jump_no_skips_direct, 0), "goto_prev_jump_no_skips_direct", 30, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 75 },
{ PROC_LINKS(goto_prev_jump_no_skips_sticky, 0), "goto_prev_jump_no_skips_sticky", 30, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 514 },
{ PROC_LINKS(goto_prev_jump_sticky, 0), "goto_prev_jump_sticky", 21, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, skipping sub jump locations.", 127, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 484 },
{ PROC_LINKS(goto_next_jump_direct, 0), "goto_next_jump_direct", 21, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, skipping sub jump locations.", 123, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 46 },
{ PROC_LINKS(goto_next_jump_no_skips_direct, 0), "goto_next_jump_no_skips_direct", 30, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, and does not skip sub jump locations.", 132, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 64 },
{ PROC_LINKS(goto_next_jump_no_skips_sticky, 0), "goto_next_jump_no_skips_sticky", 30, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, and does not skip sub jump locations.", 132, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 497 },
{ PROC_LINKS(goto_next_jump_sticky, 0), "goto_next_jump_sticky", 21, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, skipping sub jump locations.", 123, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 467 },
{ PROC_LINKS(goto_prev_jump_direct, 0), "goto_prev_jump_direct", 21, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, skipping sub jump locations.", 127, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 55 },
{ PROC_LINKS(goto_prev_jump_no_skips_direct, 0), "goto_prev_jump_no_skips_direct", 30, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 73 },
{ PROC_LINKS(goto_prev_jump_no_skips_sticky, 0), "goto_prev_jump_no_skips_sticky", 30, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 513 },
{ PROC_LINKS(goto_prev_jump_sticky, 0), "goto_prev_jump_sticky", 21, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, skipping sub jump locations.", 127, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 483 },
{ PROC_LINKS(hide_filebar, 0), "hide_filebar", 12, "Sets the current view to hide it's filebar.", 43, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 548 },
{ PROC_LINKS(hide_scrollbar, 0), "hide_scrollbar", 14, "Sets the current view to hide it's scrollbar.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 534 },
{ 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", 46, 79 },
@ -378,10 +378,10 @@ static Command_Metadata fcoder_metacmd_table[234] = {
{ PROC_LINKS(move_up, 0), "move_up", 7, "Moves the cursor up one line.", 29, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 314 },
{ PROC_LINKS(move_up_10, 0), "move_up_10", 10, "Moves the cursor up ten lines.", 30, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 326 },
{ PROC_LINKS(multi_line_edit, 0), "multi_line_edit", 15, "Begin multi-line mode. In multi-line mode characters are inserted at every line between the mark and cursor. All characters are inserted at the same character offset into the line. This mode uses line_char coordinates.", 221, "w:\\4ed\\code\\4coder_experiments.cpp", 34, 117 },
{ PROC_LINKS(newline_or_goto_position_direct, 0), "newline_or_goto_position_direct", 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_direct.cpp", 34, 101 },
{ PROC_LINKS(newline_or_goto_position_same_panel_direct, 0), "newline_or_goto_position_same_panel_direct", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 116 },
{ PROC_LINKS(newline_or_goto_position_same_panel_sticky, 0), "newline_or_goto_position_same_panel_sticky", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 584 },
{ 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", 34, 570 },
{ PROC_LINKS(newline_or_goto_position_direct, 0), "newline_or_goto_position_direct", 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_direct.cpp", 34, 99 },
{ PROC_LINKS(newline_or_goto_position_same_panel_direct, 0), "newline_or_goto_position_same_panel_direct", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 114 },
{ PROC_LINKS(newline_or_goto_position_same_panel_sticky, 0), "newline_or_goto_position_same_panel_sticky", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 583 },
{ 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", 34, 569 },
{ 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", 39, 1067 },
{ 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", 39, 1074 },
{ 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", 36, 1525 },

View File

@ -11,15 +11,14 @@ CUSTOM_DOC("If the cursor is found to be on a jump location, parses the jump loc
Temp_Memory temp = begin_temp_memory(&global_part);
View_Summary view = get_active_view(app, AccessProtected);
Name_Line_Column_Location location = {};
if (parse_jump_from_buffer_line(app, &global_part, view.buffer_id, view.cursor.line, false, &location)){
Parsed_Jump jump = parse_jump_from_buffer_line(app, &global_part, view.buffer_id, view.cursor.line, false);
if (jump.success){
change_active_panel(app);
View_Summary target_view = get_active_view(app, AccessAll);
Buffer_Summary buffer = {};
if (get_jump_buffer(app, &buffer, &location)){
if (get_jump_buffer(app, &buffer, &jump.location)){
switch_to_existing_view(app, &target_view, &buffer);
jump_to_location(app, &target_view, &buffer, location);
jump_to_location(app, &target_view, &buffer, jump.location);
}
}
@ -32,13 +31,12 @@ CUSTOM_DOC("If the cursor is found to be on a jump location, parses the jump loc
Temp_Memory temp = begin_temp_memory(&global_part);
View_Summary view = get_active_view(app, AccessProtected);
Name_Line_Column_Location location = {};
if (parse_jump_from_buffer_line(app, &global_part, view.buffer_id, view.cursor.line, false, &location)){
Parsed_Jump jump = parse_jump_from_buffer_line(app, &global_part, view.buffer_id, view.cursor.line, false);
if (jump.success){
View_Summary target_view = view;
Buffer_Summary buffer = {};
if (get_jump_buffer(app, &buffer, &location)){
jump_to_location(app, &target_view, &buffer, location);
if (get_jump_buffer(app, &buffer, &jump.location)){
jump_to_location(app, &target_view, &buffer, jump.location);
}
}

View File

@ -53,19 +53,17 @@ parse_buffer_to_jump_array(Application_Links *app, Partition *arena, Buffer_Summ
Temp_Memory temp = begin_temp_memory(arena);
String line_str = {};
if (read_line(app, arena, buffer.buffer_id, line, &line_str)){
Name_Line_Column_Location location = {};
if (parse_jump_location(line_str, &location, &colon_index, &is_sub_error)){
Parsed_Jump parsed_jump = parse_jump_location(line_str);
if (parsed_jump.success){
Buffer_Summary jump_buffer = {};
if (open_file(app, &jump_buffer, location.file.str, location.file.size, false, true)){
if (jump_buffer.exists){
Partial_Cursor cursor = {};
if (buffer_compute_cursor(app, &jump_buffer,
seek_line_char(location.line, location.column),
&cursor)){
out_buffer_id = jump_buffer.buffer_id;
out_pos = cursor.pos;
output_jump = true;
}
if (open_file(app, &jump_buffer, parsed_jump.location.file.str, parsed_jump.location.file.size, false, true) && jump_buffer.exists){
Partial_Cursor cursor = {};
if (buffer_compute_cursor(app, &jump_buffer,
seek_line_char(parsed_jump.location.line, parsed_jump.location.column),
&cursor)){
out_buffer_id = jump_buffer.buffer_id;
out_pos = cursor.pos;
output_jump = true;
}
}
}

View File

@ -61,29 +61,26 @@ check_is_note(String line, i32 colon_pos){
return(is_note);
}
static b32
parse_jump_location(String line, Name_Line_Column_Location *location, i32 *colon_char, b32 *is_sub_error){
b32 result = false;
*is_sub_error = (line.str[0] == ' ');
static Parsed_Jump
parse_jump_location(String line){
Parsed_Jump jump = {};
jump.sub_jump_indented = (line.str[0] == ' ');
i32 whitespace_length = 0;
line = skip_chop_whitespace(line, &whitespace_length);
i32 colon_pos = 0;
b32 is_ms_style = false;
i32 left_paren_pos = find_s_char(line, 0, '(');
i32 right_paren_pos = find_s_char(line, left_paren_pos, ')');
while (!is_ms_style && right_paren_pos < line.size){
for (;!jump.is_ms_style && right_paren_pos < line.size;){
if (ms_style_verify(line, left_paren_pos, right_paren_pos)){
is_ms_style = true;
colon_pos = find_s_char(line, right_paren_pos, ':');
if (colon_pos < line.size){
if (check_is_note(line, colon_pos)){
*is_sub_error = true;
jump.is_ms_style = true;
jump.colon_position = find_s_char(line, right_paren_pos, ':');
if (jump.colon_position < line.size){
if (check_is_note(line, jump.colon_position)){
jump.sub_jump_note = true;
}
String location_str = substr(line, 0, colon_pos);
String location_str = substr(line, 0, jump.is_sub_jump);
location_str = skip_chop_whitespace(location_str);
@ -95,30 +92,25 @@ parse_jump_location(String line, Name_Line_Column_Location *location, i32 *colon
file = skip_chop_whitespace(file);
if (file.size > 0){
String line_number = substr(location_str,
open_pos+1,
close_pos-open_pos-1);
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;
i32 comma_pos = find_s_char(line_number, 0, ',');
if (comma_pos < line_number.size){
i32 start = comma_pos+1;
i32 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);
jump.location.line = str_to_int_s(line_number);
jump.location.column = str_to_int_s(column_number);
}
else{
location->line = str_to_int_s(line_number);
location->column = 1;
jump.location.line = str_to_int_s(line_number);
jump.location.column = 0;
}
*colon_char = colon_pos + whitespace_length;
result = true;
jump.location.file = file;
jump.colon_position = jump.colon_position + whitespace_length;
jump.success = true;
}
}
}
@ -130,8 +122,11 @@ parse_jump_location(String line, Name_Line_Column_Location *location, i32 *colon
}
}
if (!is_ms_style){
if (!jump.is_ms_style){
i32 start = try_skip_rust_arrow(line);
if (start != 0){
jump.has_rust_arrow = true;
}
i32 colon_pos1 = find_s_char(line, start, ':');
if (line.size > colon_pos1 + 1){
@ -145,7 +140,7 @@ parse_jump_location(String line, Name_Line_Column_Location *location, i32 *colon
if (colon_pos3 < line.size){
if (check_is_note(line, colon_pos3)){
*is_sub_error = true;
jump.sub_jump_note = true;
}
String filename = substr(line, start, colon_pos1 - start);
@ -155,17 +150,17 @@ parse_jump_location(String line, Name_Line_Column_Location *location, i32 *colon
if (filename.size > 0 &&
line_number.size > 0 &&
column_number.size > 0){
location->file = filename;
location->line = str_to_int_s(line_number);
location->column = str_to_int_s(column_number);
*colon_char = colon_pos3 + whitespace_length;
result = true;
jump.location.file = filename;
jump.location.line = str_to_int_s(line_number);
jump.location.column = str_to_int_s(column_number);
jump.colon_position = colon_pos3 + whitespace_length;
jump.success = true;
}
}
else{
if (colon_pos2 < line.size){
if (check_is_note(line, colon_pos2)){
*is_sub_error = true;
jump.sub_jump_note = true;
}
String filename = substr(line, 0, colon_pos1);
@ -173,47 +168,43 @@ parse_jump_location(String line, Name_Line_Column_Location *location, i32 *colon
if (str_is_int_s(line_number)){
if (filename.size > 0 && line_number.size > 0){
location->file = filename;
location->line = str_to_int_s(line_number);
location->column = 0;
*colon_char = colon_pos2 + whitespace_length;
result = true;
jump.location.file = filename;
jump.location.line = str_to_int_s(line_number);
jump.location.column = 0;
jump.colon_position = colon_pos3 + whitespace_length;
jump.success = true;
}
}
}
}
}
if (!result){
*is_sub_error = false;
if (!jump.success){
memset(&jump, 0, sizeof(jump));
}
return(result);
else{
jump.is_sub_jump = (jump.sub_jump_indented || jump.sub_jump_note);
}
return(jump);
}
static b32
parse_jump_location(String line, b32 skip_sub_error, Name_Line_Column_Location *location, i32 *colon_char){
b32 is_sub_error = false;
b32 result = parse_jump_location(line, location, colon_char, &is_sub_error);
if (is_sub_error && skip_sub_error){
result = false;
static Parsed_Jump
parse_jump_location(String line, b32 skip_sub_jump){
Parsed_Jump jump = parse_jump_location(line);
if (jump.is_sub_jump && skip_sub_jump){
memset(&jump, 0, sizeof(jump));
}
return(result);
return(jump);
}
static i32
parse_jump_from_buffer_line(Application_Links *app, Partition *arena,
i32 buffer_id, i32 line,
b32 skip_sub_errors, Name_Line_Column_Location *location){
i32 result = false;
static Parsed_Jump
parse_jump_from_buffer_line(Application_Links *app, Partition *arena, Buffer_ID buffer_id, i32 line, b32 skip_sub_errors){
Parsed_Jump jump = {};
String line_str = {};
if (read_line(app, arena, buffer_id, line, &line_str)){
i32 colon_char = 0;
if (parse_jump_location(line_str, skip_sub_errors, location, &colon_char)){
result = true;
}
jump = parse_jump_location(line_str, skip_sub_errors);
}
return(result);
return(jump);
}
////////////////////////////////
@ -272,19 +263,18 @@ jump_to_location(Application_Links *app, View_Summary *view, Buffer_Summary *buf
////////////////////////////////
static b32
static Parsed_Jump
seek_next_jump_in_buffer(Application_Links *app, Partition *part,
i32 buffer_id, i32 first_line, b32 skip_sub_errors,
i32 direction,
i32 *line_out, i32 *colon_index_out, Name_Line_Column_Location *location_out){
i32 buffer_id, i32 first_line, b32 skip_sub_errors, i32 direction,
i32 *line_out){
Assert(direction == 1 || direction == -1);
b32 result = false;
Parsed_Jump jump = {};
i32 line = first_line;
String line_str = {};
for (;;){
if (read_line(app, part, buffer_id, line, &line_str)){
if (parse_jump_location(line_str, skip_sub_errors, location_out, colon_index_out)){
result = true;
Parsed_Jump jump = parse_jump_location(line_str, skip_sub_errors);
if (jump.success){
break;
}
line += direction;
@ -296,8 +286,10 @@ seek_next_jump_in_buffer(Application_Links *app, Partition *part,
if (line < 0){
line = 0;
}
*line_out = line;
return(result);
if (jump.success){
*line_out = line;
}
return(jump);
}
static ID_Line_Column_Jump_Location
@ -312,21 +304,15 @@ convert_name_based_to_id_based(Application_Links *app, Name_Line_Column_Location
return(result);
}
static i32
seek_next_jump_in_view(Application_Links *app, Partition *part, View_Summary *view, i32 skip_sub_errors, i32 direction, i32 *line_out, i32 *colon_index_out, Name_Line_Column_Location *location_out){
i32 result = false;
Name_Line_Column_Location location = {};
static Parsed_Jump
seek_next_jump_in_view(Application_Links *app, Partition *part, View_Summary *view, i32 skip_sub_errors, i32 direction, i32 *line_out){
Parsed_Jump jump = {};
i32 line = view->cursor.line;
i32 colon_index = 0;
if (seek_next_jump_in_buffer(app, part, view->buffer_id, line+direction, skip_sub_errors, direction, &line, &colon_index, &location)){
result = true;
jump = seek_next_jump_in_buffer(app, part, view->buffer_id, line + direction, skip_sub_errors, direction, &line);
if (jump.success){
*line_out = line;
*colon_index_out = colon_index;
*location_out = location;
}
return(result);
return(jump);
}
static b32
@ -349,9 +335,10 @@ advance_cursor_in_jump_view(Application_Links *app, Partition *part, View_Summar
do{
Temp_Memory temp = begin_temp_memory(part);
if (seek_next_jump_in_view(app, part, view, skip_sub_error, direction, &line, &colon_index, &location)){
jump = convert_name_based_to_id_based(app, location);
view_set_cursor(app, view, seek_line_char(line, colon_index+1), true);
Parsed_Jump parsed_jump = seek_next_jump_in_view(app, part, view, skip_sub_error, direction, &line);
if (parsed_jump.success){
jump = convert_name_based_to_id_based(app, parsed_jump.location);
view_set_cursor(app, view, seek_line_char(line, parsed_jump.colon_position + 1), true);
result = true;
}
else{

View File

@ -991,6 +991,18 @@ Buffer_Get_Dirty_State(Application_Links *app, Buffer_ID buffer_id, Dirty_State
return(result);
}
API_EXPORT b32
Buffer_Directly_Set_Dirty_State(Application_Links *app, Buffer_ID buffer_id, Dirty_State dirty_state){
Models *models = (Models*)app->cmd_context;
Editing_File *file = imp_get_file(models, buffer_id);
b32 result = false;
if (buffer_api_check_file(file)){
file->state.dirty = dirty_state;
result = true;
}
return(result);
}
API_EXPORT b32
Buffer_Tokens_Are_Ready(Application_Links *app, Buffer_ID buffer_id){
Models *models = (Models*)app->cmd_context;
@ -1396,9 +1408,9 @@ DOC_SEE(cpp_get_token)
*/{
Models *models = (Models*)app->cmd_context;
Editing_File *file = imp_get_file(models, buffer_id);
Cpp_Token_Array token_array = file->state.token_array;
b32 result = false;
if (buffer_api_check_file_and_tokens(file)){
Cpp_Token_Array token_array = file->state.token_array;
*get_result = cpp_get_token(token_array, pos);
result = true;
}