2018-05-09 07:10:07 +00:00
|
|
|
/*
|
|
|
|
4coder_jumping.cpp - Routines commonly used when writing code to jump to locations and seek through jump lists.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
2019-02-26 23:08:42 +00:00
|
|
|
static b32
|
2019-06-01 23:58:28 +00:00
|
|
|
ms_style_verify(String_Const_u8 line, umem left_paren_pos, umem right_paren_pos){
|
2019-02-26 23:08:42 +00:00
|
|
|
i32 result = false;
|
2019-06-01 23:58:28 +00:00
|
|
|
String_Const_u8 line_part = string_skip(line, right_paren_pos);
|
|
|
|
if (string_match(string_prefix(line_part, 4), string_u8_litexpr(") : "))){
|
2018-05-09 07:10:07 +00:00
|
|
|
result = true;
|
|
|
|
}
|
2019-06-01 23:58:28 +00:00
|
|
|
else if (string_match(string_prefix(line_part, 3), string_u8_litexpr("): "))){
|
2018-05-09 07:10:07 +00:00
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
if (result){
|
2019-06-01 23:58:28 +00:00
|
|
|
String_Const_u8 number = string_skip(string_prefix(line, right_paren_pos - 1), left_paren_pos + 1);
|
|
|
|
if (!string_is_integer(number, 10)){
|
2018-05-09 07:10:07 +00:00
|
|
|
result = false;
|
2019-06-01 23:58:28 +00:00
|
|
|
umem comma_pos = string_find_first(number, ',');
|
2018-05-09 07:10:07 +00:00
|
|
|
if (comma_pos < number.size){
|
2019-06-01 23:58:28 +00:00
|
|
|
String_Const_u8 sub_number0 = string_prefix(number, comma_pos);
|
|
|
|
String_Const_u8 sub_number1 = string_skip(number, comma_pos + 1);
|
|
|
|
if (string_is_integer(sub_number0, 10) && string_is_integer(sub_number1, 10)){
|
2018-05-09 07:10:07 +00:00
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2019-06-01 23:58:28 +00:00
|
|
|
static umem
|
|
|
|
try_skip_rust_arrow(String_Const_u8 line){
|
|
|
|
umem pos = 0;
|
|
|
|
if (string_match(string_prefix(line, 3), string_u8_litexpr("-->"))){
|
|
|
|
String_Const_u8 sub = string_skip(line, 3);
|
|
|
|
sub = string_skip_chop_whitespace(sub);
|
|
|
|
pos = (umem)(sub.str - line.str);
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
return(pos);
|
|
|
|
}
|
|
|
|
|
2019-02-26 23:08:42 +00:00
|
|
|
static b32
|
2019-06-01 23:58:28 +00:00
|
|
|
check_is_note(String_Const_u8 line, umem colon_pos){
|
2019-02-26 23:08:42 +00:00
|
|
|
b32 is_note = false;
|
2019-06-01 23:58:28 +00:00
|
|
|
umem note_pos = colon_pos + string_find_first(string_skip(line, colon_pos), string_u8_litexpr("note"));
|
2018-11-29 21:17:34 +00:00
|
|
|
if (note_pos < line.size){
|
2019-02-26 23:08:42 +00:00
|
|
|
b32 is_all_whitespace = true;
|
2019-06-01 23:58:28 +00:00
|
|
|
for (umem i = colon_pos + 1; i < note_pos; i += 1){
|
|
|
|
if (!character_is_whitespace(line.str[i])){
|
2018-11-29 21:17:34 +00:00
|
|
|
is_all_whitespace = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (is_all_whitespace){
|
|
|
|
is_note = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(is_note);
|
|
|
|
}
|
|
|
|
|
2019-04-01 03:50:37 +00:00
|
|
|
static Parsed_Jump
|
2019-06-01 23:58:28 +00:00
|
|
|
parse_jump_location(String_Const_u8 line){
|
2019-04-01 03:50:37 +00:00
|
|
|
Parsed_Jump jump = {};
|
2019-06-01 23:58:28 +00:00
|
|
|
jump.sub_jump_indented = (string_get_character(line, 0) == ' ');
|
2018-05-09 07:10:07 +00:00
|
|
|
|
2019-06-01 23:58:28 +00:00
|
|
|
String_Const_u8 reduced_line = string_skip_chop_whitespace(line);
|
|
|
|
umem whitespace_length = (umem)(reduced_line.str - line.str);
|
|
|
|
line = reduced_line;
|
2018-05-09 07:10:07 +00:00
|
|
|
|
2019-06-01 23:58:28 +00:00
|
|
|
umem left_paren_pos = string_find_first(line, '(');
|
|
|
|
umem right_paren_pos = left_paren_pos + string_find_first(string_skip(line, left_paren_pos), ')');
|
2019-04-01 03:50:37 +00:00
|
|
|
for (;!jump.is_ms_style && right_paren_pos < line.size;){
|
2018-05-09 07:10:07 +00:00
|
|
|
if (ms_style_verify(line, left_paren_pos, right_paren_pos)){
|
2019-04-01 03:50:37 +00:00
|
|
|
jump.is_ms_style = true;
|
2019-06-01 23:58:28 +00:00
|
|
|
jump.colon_position = (i32)(right_paren_pos + string_find_first(string_skip(line, right_paren_pos), ':'));
|
2019-04-01 03:50:37 +00:00
|
|
|
if (jump.colon_position < line.size){
|
|
|
|
if (check_is_note(line, jump.colon_position)){
|
|
|
|
jump.sub_jump_note = true;
|
2018-11-29 21:17:34 +00:00
|
|
|
}
|
|
|
|
|
2019-06-01 23:58:28 +00:00
|
|
|
String_Const_u8 location_str = string_prefix(line, jump.colon_position);
|
|
|
|
location_str = string_skip_chop_whitespace(location_str);
|
2018-05-09 07:10:07 +00:00
|
|
|
|
2019-06-01 23:58:28 +00:00
|
|
|
i32 close_pos = (i32)right_paren_pos;
|
|
|
|
i32 open_pos = (i32)left_paren_pos;
|
2018-05-09 07:10:07 +00:00
|
|
|
|
|
|
|
if (0 < open_pos && open_pos < location_str.size){
|
2019-06-01 23:58:28 +00:00
|
|
|
String_Const_u8 file = SCu8(location_str.str, open_pos);
|
|
|
|
file = string_skip_chop_whitespace(file);
|
2018-05-09 07:10:07 +00:00
|
|
|
|
|
|
|
if (file.size > 0){
|
2019-06-01 23:58:28 +00:00
|
|
|
String_Const_u8 line_number = string_skip(string_prefix(location_str, close_pos), open_pos + 1);
|
|
|
|
line_number = string_skip_chop_whitespace(line_number);
|
2018-05-09 07:10:07 +00:00
|
|
|
|
|
|
|
if (line_number.size > 0){
|
2019-06-01 23:58:28 +00:00
|
|
|
umem comma_pos = string_find_first(line_number, ',');
|
2018-05-09 07:10:07 +00:00
|
|
|
if (comma_pos < line_number.size){
|
2019-06-01 23:58:28 +00:00
|
|
|
String_Const_u8 column_number = string_skip(line_number, comma_pos + 1);
|
|
|
|
line_number = string_prefix(line_number, comma_pos);
|
|
|
|
jump.location.line = (i32)string_to_integer(line_number, 10);
|
|
|
|
jump.location.column = (i32)string_to_integer(column_number, 10);
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
else{
|
2019-06-01 23:58:28 +00:00
|
|
|
jump.location.line = (i32)string_to_integer(line_number, 10);
|
2019-04-01 03:50:37 +00:00
|
|
|
jump.location.column = 0;
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
2019-04-01 03:50:37 +00:00
|
|
|
jump.location.file = file;
|
2019-06-01 23:58:28 +00:00
|
|
|
jump.colon_position = jump.colon_position + (i32)whitespace_length;
|
2019-04-01 03:50:37 +00:00
|
|
|
jump.success = true;
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
2019-06-01 23:58:28 +00:00
|
|
|
left_paren_pos = string_find_first(string_skip(line, left_paren_pos + 1), '(') + left_paren_pos + 1;
|
|
|
|
right_paren_pos = string_find_first(string_skip(line, left_paren_pos), ')') + left_paren_pos;
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-01 03:50:37 +00:00
|
|
|
if (!jump.is_ms_style){
|
2019-06-01 23:58:28 +00:00
|
|
|
i32 start = (i32)try_skip_rust_arrow(line);
|
2019-04-01 03:50:37 +00:00
|
|
|
if (start != 0){
|
|
|
|
jump.has_rust_arrow = true;
|
|
|
|
}
|
2018-05-09 07:10:07 +00:00
|
|
|
|
2019-06-01 23:58:28 +00:00
|
|
|
umem colon_pos1 = string_find_first(string_skip(line, start), ':') + start;
|
2018-05-09 07:10:07 +00:00
|
|
|
if (line.size > colon_pos1 + 1){
|
2019-06-01 23:58:28 +00:00
|
|
|
if (character_is_slash(string_get_character(line, colon_pos1 + 1))){
|
|
|
|
colon_pos1 = string_find_first(string_skip(line, colon_pos1 + 1), ':') + colon_pos1 + 1;
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-01 23:58:28 +00:00
|
|
|
umem colon_pos2 = string_find_first(string_skip(line, colon_pos1 + 1), ':') + colon_pos1 + 1;
|
|
|
|
umem colon_pos3 = string_find_first(string_skip(line, colon_pos2 + 1), ':') + colon_pos2 + 1;
|
2018-05-09 07:10:07 +00:00
|
|
|
|
2018-11-29 21:17:34 +00:00
|
|
|
if (colon_pos3 < line.size){
|
|
|
|
if (check_is_note(line, colon_pos3)){
|
2019-04-01 03:50:37 +00:00
|
|
|
jump.sub_jump_note = true;
|
2018-11-29 21:17:34 +00:00
|
|
|
}
|
|
|
|
|
2019-06-01 23:58:28 +00:00
|
|
|
String_Const_u8 file_name = string_skip(string_prefix(line, colon_pos1), start);
|
|
|
|
String_Const_u8 line_number = string_skip(string_prefix(line, colon_pos2), colon_pos1 + 1);
|
|
|
|
String_Const_u8 column_number = string_skip(string_prefix(line, colon_pos3), colon_pos2 + 1);
|
2018-05-09 07:10:07 +00:00
|
|
|
|
2019-06-01 23:58:28 +00:00
|
|
|
if (file_name.size > 0 && line_number.size > 0 && column_number.size > 0){
|
|
|
|
jump.location.file = file_name;
|
|
|
|
jump.location.line = (i32)string_to_integer(line_number, 10);
|
|
|
|
jump.location.column = (i32)string_to_integer(column_number, 10);
|
|
|
|
jump.colon_position = (i32)(colon_pos3 + whitespace_length);
|
2019-04-01 03:50:37 +00:00
|
|
|
jump.success = true;
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
2018-11-29 21:17:34 +00:00
|
|
|
if (colon_pos2 < line.size){
|
|
|
|
if (check_is_note(line, colon_pos2)){
|
2019-04-01 03:50:37 +00:00
|
|
|
jump.sub_jump_note = true;
|
2018-11-29 21:17:34 +00:00
|
|
|
}
|
|
|
|
|
2019-06-01 23:58:28 +00:00
|
|
|
String_Const_u8 file_name = string_prefix(line, colon_pos1);
|
|
|
|
String_Const_u8 line_number = string_skip(string_prefix(line, colon_pos2), colon_pos1 + 1);
|
2018-05-09 07:10:07 +00:00
|
|
|
|
2019-06-01 23:58:28 +00:00
|
|
|
if (string_is_integer(line_number, 10)){
|
|
|
|
if (file_name.size > 0 && line_number.size > 0){
|
|
|
|
jump.location.file = file_name;
|
|
|
|
jump.location.line = (i32)string_to_integer(line_number, 10);
|
2019-04-01 03:50:37 +00:00
|
|
|
jump.location.column = 0;
|
2019-06-01 23:58:28 +00:00
|
|
|
jump.colon_position = (i32)(colon_pos3 + whitespace_length);
|
2019-04-01 03:50:37 +00:00
|
|
|
jump.success = true;
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-01 03:50:37 +00:00
|
|
|
if (!jump.success){
|
|
|
|
memset(&jump, 0, sizeof(jump));
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
2019-04-01 03:50:37 +00:00
|
|
|
else{
|
|
|
|
jump.is_sub_jump = (jump.sub_jump_indented || jump.sub_jump_note);
|
|
|
|
}
|
|
|
|
return(jump);
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
|
2019-04-01 03:50:37 +00:00
|
|
|
static Parsed_Jump
|
2019-06-01 23:58:28 +00:00
|
|
|
parse_jump_location(String_Const_u8 line, Jump_Flag flags){
|
2019-04-01 03:50:37 +00:00
|
|
|
Parsed_Jump jump = parse_jump_location(line);
|
2019-06-01 23:58:28 +00:00
|
|
|
if (HasFlag(flags, JumpFlag_SkipSubs) && jump.is_sub_jump){
|
|
|
|
block_zero_struct(&jump);
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
2019-04-01 03:50:37 +00:00
|
|
|
return(jump);
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
|
2019-04-01 03:50:37 +00:00
|
|
|
static Parsed_Jump
|
2019-06-20 23:43:27 +00:00
|
|
|
parse_jump_from_buffer_line(Application_Links *app, Arena *arena, Buffer_ID buffer, i64 line, Jump_Flag flags){
|
2019-04-01 03:50:37 +00:00
|
|
|
Parsed_Jump jump = {};
|
2019-06-20 23:43:27 +00:00
|
|
|
String_Const_u8 line_str = push_buffer_line(app, arena, buffer, line);
|
2019-06-01 23:58:28 +00:00
|
|
|
if (line_str.size > 0){
|
|
|
|
jump = parse_jump_location(line_str, flags);
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
2019-04-01 03:50:37 +00:00
|
|
|
return(jump);
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
2019-02-26 23:08:42 +00:00
|
|
|
static b32
|
2019-04-04 08:25:16 +00:00
|
|
|
get_jump_buffer(Application_Links *app, Buffer_ID *buffer, Name_Line_Column_Location *location){
|
2019-06-01 23:58:28 +00:00
|
|
|
return(open_file(app, buffer, location->file, false, true));
|
2019-02-12 02:33:11 +00:00
|
|
|
}
|
|
|
|
|
2019-02-26 23:08:42 +00:00
|
|
|
static b32
|
2019-04-04 08:25:16 +00:00
|
|
|
get_jump_buffer(Application_Links *app, Buffer_ID *buffer, ID_Pos_Jump_Location *location, Access_Flag access){
|
|
|
|
*buffer = location->buffer_id;
|
|
|
|
return(buffer_exists(app, *buffer));
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
|
2019-02-26 23:08:42 +00:00
|
|
|
static b32
|
2019-04-04 08:25:16 +00:00
|
|
|
get_jump_buffer(Application_Links *app, Buffer_ID *buffer, ID_Pos_Jump_Location *location){
|
2019-02-12 02:33:11 +00:00
|
|
|
return(get_jump_buffer(app, buffer, location, AccessAll));
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:40:36 +00:00
|
|
|
static View_ID
|
|
|
|
switch_to_existing_view(Application_Links *app, View_ID view, Buffer_ID buffer){
|
2019-06-19 02:31:59 +00:00
|
|
|
Buffer_ID current_buffer = view_get_buffer(app, view, AccessAll);
|
2019-04-06 19:40:36 +00:00
|
|
|
if (view != 0 || current_buffer != buffer){
|
|
|
|
View_ID existing_view = get_first_view_with_buffer(app, buffer);
|
|
|
|
if (existing_view != 0){
|
|
|
|
view = existing_view;
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-06 19:40:36 +00:00
|
|
|
return(view);
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-04-06 19:40:36 +00:00
|
|
|
set_view_to_location(Application_Links *app, View_ID view, Buffer_ID buffer, Buffer_Seek seek){
|
2019-06-19 02:31:59 +00:00
|
|
|
Buffer_ID current_buffer = view_get_buffer(app, view, AccessAll);
|
2019-04-06 19:40:36 +00:00
|
|
|
if (current_buffer != buffer){
|
2019-04-04 08:25:16 +00:00
|
|
|
view_set_buffer(app, view, buffer, 0);
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
2019-09-02 21:32:52 +00:00
|
|
|
view_set_cursor_and_preferred_x(app, view, seek);
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-04-06 19:40:36 +00:00
|
|
|
jump_to_location(Application_Links *app, View_ID view, Buffer_ID buffer, Name_Line_Column_Location location){
|
|
|
|
view_set_active(app, view);
|
2019-09-02 18:59:36 +00:00
|
|
|
set_view_to_location(app, view, buffer, seek_line_col(location.line, location.column));
|
2018-05-09 07:10:07 +00:00
|
|
|
if (auto_center_after_jumps){
|
|
|
|
center_view(app);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-04-06 19:40:36 +00:00
|
|
|
jump_to_location(Application_Links *app, View_ID view, Buffer_ID buffer, ID_Pos_Jump_Location location){
|
|
|
|
view_set_active(app, view);
|
2018-05-09 07:10:07 +00:00
|
|
|
set_view_to_location(app, view, buffer, seek_pos(location.pos));
|
|
|
|
if (auto_center_after_jumps){
|
|
|
|
center_view(app);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
2019-06-20 23:43:27 +00:00
|
|
|
// TODO(allen): rewrite
|
2019-04-01 03:50:37 +00:00
|
|
|
static Parsed_Jump
|
2019-06-01 23:58:28 +00:00
|
|
|
seek_next_jump_in_buffer(Application_Links *app, Arena *arena,
|
2019-06-20 23:43:27 +00:00
|
|
|
Buffer_ID buffer, i64 first_line, Jump_Flag flags, Scan_Direction direction,
|
|
|
|
i64 *line_out){
|
2018-05-09 07:10:07 +00:00
|
|
|
Assert(direction == 1 || direction == -1);
|
2019-04-01 03:50:37 +00:00
|
|
|
Parsed_Jump jump = {};
|
2019-06-20 23:43:27 +00:00
|
|
|
i64 line = first_line;
|
2018-05-09 07:10:07 +00:00
|
|
|
for (;;){
|
2019-06-20 23:43:27 +00:00
|
|
|
if (is_valid_line(app, buffer, line)){
|
|
|
|
String_Const_u8 line_str = push_buffer_line(app, arena, buffer, line);
|
2019-06-01 23:58:28 +00:00
|
|
|
jump = parse_jump_location(line_str, flags);
|
2019-04-01 03:50:37 +00:00
|
|
|
if (jump.success){
|
2018-05-09 07:10:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
line += direction;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-04-01 03:50:37 +00:00
|
|
|
if (jump.success){
|
2019-06-01 23:58:28 +00:00
|
|
|
*line_out = clamp_bot(line, 0);
|
2019-04-01 03:50:37 +00:00
|
|
|
}
|
|
|
|
return(jump);
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
|
2018-08-12 03:45:09 +00:00
|
|
|
static ID_Line_Column_Jump_Location
|
|
|
|
convert_name_based_to_id_based(Application_Links *app, Name_Line_Column_Location loc){
|
2018-11-20 08:18:54 +00:00
|
|
|
ID_Line_Column_Jump_Location result = {};
|
2019-06-19 02:31:59 +00:00
|
|
|
Buffer_ID buffer = get_buffer_by_name(app, loc.file, AccessAll);
|
2019-04-05 02:03:36 +00:00
|
|
|
if (buffer != 0){
|
|
|
|
result.buffer_id = buffer;
|
2018-05-09 07:10:07 +00:00
|
|
|
result.line = loc.line;
|
|
|
|
result.column = loc.column;
|
|
|
|
}
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2019-04-01 03:50:37 +00:00
|
|
|
static Parsed_Jump
|
2019-06-20 23:43:27 +00:00
|
|
|
seek_next_jump_in_view(Application_Links *app, Arena *arena, View_ID view, i32 skip_sub_errors, Scan_Direction direction, i64 *line_out){
|
|
|
|
i64 cursor_position = view_get_cursor_pos(app, view);
|
2019-09-02 18:59:36 +00:00
|
|
|
Buffer_Cursor cursor = view_compute_cursor(app, view, seek_pos(cursor_position));
|
2019-06-20 23:43:27 +00:00
|
|
|
i64 line = cursor.line;
|
2019-06-19 02:31:59 +00:00
|
|
|
Buffer_ID buffer = view_get_buffer(app, view, AccessAll);
|
2019-06-01 23:58:28 +00:00
|
|
|
Parsed_Jump jump = seek_next_jump_in_buffer(app, arena, buffer, line + direction, skip_sub_errors, direction, &line);
|
2019-04-01 03:50:37 +00:00
|
|
|
if (jump.success){
|
2018-05-09 07:10:07 +00:00
|
|
|
*line_out = line;
|
|
|
|
}
|
2019-04-01 03:50:37 +00:00
|
|
|
return(jump);
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
|
2019-02-26 23:08:42 +00:00
|
|
|
static b32
|
2018-08-12 03:45:09 +00:00
|
|
|
skip_this_jump(ID_Line_Column_Jump_Location prev, ID_Line_Column_Jump_Location jump){
|
2019-02-26 23:08:42 +00:00
|
|
|
b32 result = false;
|
2018-05-09 07:10:07 +00:00
|
|
|
if (prev.buffer_id != 0 && prev.buffer_id == jump.buffer_id && prev.line == jump.line && prev.column <= jump.column){
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2019-08-24 01:34:42 +00:00
|
|
|
#if 0
|
2019-02-26 23:08:42 +00:00
|
|
|
static b32
|
2019-06-20 23:43:27 +00:00
|
|
|
advance_cursor_in_jump_view(Application_Links *app, View_ID view, b32 skip_repeats, b32 skip_sub_error, Scan_Direction direction, Name_Line_Column_Location *location_out){
|
2019-02-26 23:08:42 +00:00
|
|
|
b32 result = true;
|
2018-05-09 07:10:07 +00:00
|
|
|
|
2018-11-20 08:18:54 +00:00
|
|
|
Name_Line_Column_Location location = {};
|
|
|
|
ID_Line_Column_Jump_Location jump = {};
|
2019-06-20 23:43:27 +00:00
|
|
|
i64 line = 0;
|
|
|
|
i64 colon_index = 0;
|
2018-05-09 07:10:07 +00:00
|
|
|
|
|
|
|
do{
|
2019-06-01 23:58:28 +00:00
|
|
|
Arena *scratch = context_get_arena(app);
|
|
|
|
Temp_Memory temp = begin_temp(scratch);
|
|
|
|
Parsed_Jump parsed_jump = seek_next_jump_in_view(app, scratch, view, skip_sub_error, direction, &line);
|
2019-04-01 03:50:37 +00:00
|
|
|
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);
|
2018-05-09 07:10:07 +00:00
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
jump.buffer_id = 0;
|
|
|
|
result = false;
|
|
|
|
}
|
2019-06-01 23:58:28 +00:00
|
|
|
end_temp(temp);
|
2018-05-09 07:10:07 +00:00
|
|
|
}while(skip_repeats && skip_this_jump(prev_location, jump));
|
|
|
|
|
|
|
|
if (result){
|
|
|
|
*location_out = location;
|
2018-08-12 03:45:09 +00:00
|
|
|
view_set_cursor(app, view, seek_line_char(line, colon_index + 1), true);
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
prev_location = jump;
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2019-02-26 23:08:42 +00:00
|
|
|
static b32
|
2019-08-24 01:34:42 +00:00
|
|
|
seek_jump_(Application_Links *app, b32 skip_repeats, b32 skip_sub_errors, i32 direction){
|
2019-02-26 23:08:42 +00:00
|
|
|
b32 result = false;
|
2018-05-09 07:10:07 +00:00
|
|
|
|
2019-04-06 19:40:36 +00:00
|
|
|
View_ID view = get_view_for_locked_jump_buffer(app);
|
|
|
|
if (view != 0){
|
2018-11-20 08:18:54 +00:00
|
|
|
Name_Line_Column_Location location = {};
|
2019-06-01 23:58:28 +00:00
|
|
|
if (advance_cursor_in_jump_view(app, view, skip_repeats, skip_sub_errors, direction, &location)){
|
2019-04-04 08:25:16 +00:00
|
|
|
Buffer_ID buffer = {};
|
2018-05-09 07:10:07 +00:00
|
|
|
if (get_jump_buffer(app, &buffer, &location)){
|
2019-06-19 02:31:59 +00:00
|
|
|
View_ID target_view = get_active_view(app, AccessAll);
|
2019-04-06 19:40:36 +00:00
|
|
|
if (target_view == view){
|
2018-05-09 07:10:07 +00:00
|
|
|
change_active_panel(app);
|
2019-06-19 02:31:59 +00:00
|
|
|
target_view = get_active_view(app, AccessAll);
|
2018-05-09 07:10:07 +00:00
|
|
|
}
|
2019-04-06 19:40:36 +00:00
|
|
|
switch_to_existing_view(app, target_view, buffer);
|
|
|
|
jump_to_location(app, target_view, buffer, location);
|
2018-05-09 07:10:07 +00:00
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
2018-05-09 18:58:21 +00:00
|
|
|
#endif
|
|
|
|
|
2018-05-09 07:10:07 +00:00
|
|
|
// BOTTOM
|
|
|
|
|