2017-01-23 06:19:43 +00:00
/*
2017-11-15 23:57:21 +00:00
4 coder_direct_jump . cpp - Commands and helpers for parsing jump locations from
2017-01-23 06:19:43 +00:00
compiler errors and jumping to them in the corresponding buffer .
*/
// TOP
2017-11-15 23:57:21 +00:00
CUSTOM_COMMAND_SIG ( goto_jump_at_cursor_direct )
CUSTOM_DOC ( " 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. " )
{
2016-07-13 19:59:42 +00:00
Temp_Memory temp = begin_temp_memory ( & global_part ) ;
2019-04-07 17:36:24 +00:00
View_ID view = 0 ;
get_active_view ( app , AccessProtected , & view ) ;
Buffer_ID buffer = 0 ;
view_get_buffer ( app , view , AccessProtected , & buffer ) ;
i32 pos = 0 ;
view_get_cursor_pos ( app , view , & pos ) ;
Full_Cursor cursor = { } ;
view_compute_cursor ( app , view , seek_pos ( pos ) , & cursor ) ;
2016-07-13 19:59:42 +00:00
2019-04-07 17:36:24 +00:00
Parsed_Jump jump = parse_jump_from_buffer_line ( app , & global_part , buffer , cursor . line , false ) ;
2019-04-01 03:50:37 +00:00
if ( jump . success ) {
2017-03-29 22:37:17 +00:00
change_active_panel ( app ) ;
2019-04-06 19:40:36 +00:00
View_ID target_view = 0 ;
get_active_view ( app , AccessAll , & target_view ) ;
2019-04-01 03:50:37 +00:00
if ( get_jump_buffer ( app , & buffer , & jump . location ) ) {
2019-04-06 19:40:36 +00:00
switch_to_existing_view ( app , target_view , buffer ) ;
jump_to_location ( app , target_view , buffer , jump . location ) ;
2017-03-29 16:32:06 +00:00
}
2016-07-13 19:59:42 +00:00
}
end_temp_memory ( temp ) ;
}
2017-11-15 23:57:21 +00:00
CUSTOM_COMMAND_SIG ( goto_jump_at_cursor_same_panel_direct )
CUSTOM_DOC ( " 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.. " )
{
2017-03-29 16:32:06 +00:00
Temp_Memory temp = begin_temp_memory ( & global_part ) ;
2019-04-07 17:36:24 +00:00
View_ID view = 0 ;
get_active_view ( app , AccessProtected , & view ) ;
Buffer_ID buffer = 0 ;
view_get_buffer ( app , view , AccessProtected , & buffer ) ;
i32 pos = 0 ;
view_get_cursor_pos ( app , view , & pos ) ;
Full_Cursor cursor = { } ;
view_compute_cursor ( app , view , seek_pos ( pos ) , & cursor ) ;
2017-03-29 16:32:06 +00:00
2019-04-07 17:36:24 +00:00
Parsed_Jump jump = parse_jump_from_buffer_line ( app , & global_part , buffer , cursor . line , false ) ;
2019-04-01 03:50:37 +00:00
if ( jump . success ) {
2019-04-07 17:36:24 +00:00
View_ID target_view = view ;
2019-04-01 03:50:37 +00:00
if ( get_jump_buffer ( app , & buffer , & jump . location ) ) {
2019-04-07 17:36:24 +00:00
jump_to_location ( app , target_view , buffer , jump . location ) ;
2017-03-29 16:32:06 +00:00
}
}
end_temp_memory ( temp ) ;
}
2016-09-01 00:26:52 +00:00
2017-11-15 23:57:21 +00:00
CUSTOM_COMMAND_SIG ( goto_next_jump_direct )
CUSTOM_DOC ( " If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, skipping sub jump locations. " )
{
2019-02-26 23:08:42 +00:00
b32 skip_repeats = true ;
b32 skip_sub_errors = true ;
i32 dir = 1 ;
2017-01-29 00:03:23 +00:00
seek_jump ( app , & global_part , skip_repeats , skip_sub_errors , dir ) ;
2016-07-13 19:59:42 +00:00
}
2017-11-15 23:57:21 +00:00
CUSTOM_COMMAND_SIG ( goto_prev_jump_direct )
CUSTOM_DOC ( " If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, skipping sub jump locations. " )
{
2019-02-26 23:08:42 +00:00
b32 skip_repeats = true ;
b32 skip_sub_errors = true ;
i32 dir = - 1 ;
2017-01-29 00:03:23 +00:00
seek_jump ( app , & global_part , skip_repeats , skip_sub_errors , dir ) ;
2016-07-13 19:59:42 +00:00
}
2017-11-15 23:57:21 +00:00
CUSTOM_COMMAND_SIG ( goto_next_jump_no_skips_direct )
CUSTOM_DOC ( " 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. " )
{
2019-02-26 23:08:42 +00:00
b32 skip_repeats = false ;
b32 skip_sub_errors = true ;
i32 dir = 1 ;
2017-01-29 00:03:23 +00:00
seek_jump ( app , & global_part , skip_repeats , skip_sub_errors , dir ) ;
2016-07-18 19:02:22 +00:00
}
2017-11-15 23:57:21 +00:00
CUSTOM_COMMAND_SIG ( goto_prev_jump_no_skips_direct )
CUSTOM_DOC ( " 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. " )
{
2019-02-26 23:08:42 +00:00
b32 skip_repeats = false ;
b32 skip_sub_errors = true ;
i32 dir = - 1 ;
2017-01-29 00:03:23 +00:00
seek_jump ( app , & global_part , skip_repeats , skip_sub_errors , dir ) ;
2016-07-18 19:02:22 +00:00
}
2017-11-15 23:57:21 +00:00
CUSTOM_COMMAND_SIG ( goto_first_jump_direct )
CUSTOM_DOC ( " If a buffer containing jump locations has been locked in, goes to the first jump in the buffer. " )
{
2016-07-13 19:59:42 +00:00
Temp_Memory temp = begin_temp_memory ( & global_part ) ;
2019-04-06 19:40:36 +00:00
View_ID view = get_view_for_locked_jump_buffer ( app ) ;
if ( view ! = 0 ) {
view_set_cursor ( app , view , seek_pos ( 0 ) , true ) ;
2018-05-09 05:22:33 +00:00
memset ( & prev_location , 0 , sizeof ( prev_location ) ) ;
2017-01-29 00:03:23 +00:00
seek_jump ( app , & global_part , false , true , 1 ) ;
2016-09-01 00:26:52 +00:00
}
2016-07-13 19:59:42 +00:00
end_temp_memory ( temp ) ;
}
2017-01-29 00:03:23 +00:00
//
2017-02-24 16:48:56 +00:00
// Insert Newline or Tigger Jump on Read Only Buffer
2017-01-29 00:03:23 +00:00
//
2017-11-15 23:57:21 +00:00
CUSTOM_COMMAND_SIG ( newline_or_goto_position_direct )
CUSTOM_DOC ( " If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor. " )
{
2019-04-07 17:36:24 +00:00
View_ID view = 0 ;
get_active_view ( app , AccessProtected , & view ) ;
2019-04-05 02:03:36 +00:00
Buffer_ID buffer = 0 ;
2019-04-07 17:36:24 +00:00
if ( view_get_buffer ( app , view , AccessOpen , & buffer ) ) {
2017-03-29 16:32:06 +00:00
write_character ( app ) ;
}
2019-04-07 17:36:24 +00:00
else if ( view_get_buffer ( app , view , AccessProtected , & buffer ) ) {
2019-04-05 02:03:36 +00:00
goto_jump_at_cursor_direct ( app ) ;
lock_jump_buffer ( app , buffer ) ;
}
2017-03-29 16:32:06 +00:00
}
2017-11-15 23:57:21 +00:00
CUSTOM_COMMAND_SIG ( newline_or_goto_position_same_panel_direct )
CUSTOM_DOC ( " If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel. " )
{
2019-04-07 17:36:24 +00:00
View_ID view = 0 ;
get_active_view ( app , AccessProtected , & view ) ;
2019-04-05 02:03:36 +00:00
Buffer_ID buffer = 0 ;
2019-04-07 17:36:24 +00:00
if ( view_get_buffer ( app , view , AccessOpen , & buffer ) ) {
2017-03-29 16:32:06 +00:00
write_character ( app ) ;
2017-01-29 00:03:23 +00:00
}
2019-04-07 17:36:24 +00:00
else if ( view_get_buffer ( app , view , AccessProtected , & buffer ) ) {
2019-04-05 02:03:36 +00:00
goto_jump_at_cursor_same_panel_direct ( app ) ;
lock_jump_buffer ( app , buffer ) ;
}
2017-01-29 00:03:23 +00:00
}
2017-01-23 06:19:43 +00:00
// BOTTOM