From 6993c3c0d50b8e63884b59e60b8f4f56b5dfee56 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Fri, 13 Dec 2019 15:36:28 -0800 Subject: [PATCH 1/2] Code index types --- custom/4coder_code_index.cpp | 207 ++++++++++++++--- custom/4coder_code_index.h | 29 +++ custom/4coder_code_index_listers.cpp | 52 +++++ custom/4coder_default_include.cpp | 1 + custom/4coder_jumping.cpp | 37 +-- custom/generated/command_metadata.h | 331 ++++++++++++++------------- 6 files changed, 446 insertions(+), 211 deletions(-) create mode 100644 custom/4coder_code_index_listers.cpp diff --git a/custom/4coder_code_index.cpp b/custom/4coder_code_index.cpp index cd4f1f38..daa95538 100644 --- a/custom/4coder_code_index.cpp +++ b/custom/4coder_code_index.cpp @@ -41,7 +41,7 @@ code_index_push_nest(Code_Index_Nest_List *list, Code_Index_Nest *nest){ } function Code_Index_Nest_Ptr_Array -code_index_nest_ptr_array_from_list(Arena *arena, Code_Index_Nest_List *list){ +code_index_nest_ptr_array_from_list(Arena *arena, Code_Index_Nest_List *list){ Code_Index_Nest_Ptr_Array array = {}; array.ptrs = push_array_zero(arena, Code_Index_Nest*, list->count); array.count = list->count; @@ -55,6 +55,21 @@ code_index_nest_ptr_array_from_list(Arena *arena, Code_Index_Nest_List *list){ return(array); } +function Code_Index_Note_Ptr_Array +code_index_note_ptr_array_from_list(Arena *arena, Code_Index_Note_List *list){ + Code_Index_Note_Ptr_Array array = {}; + array.ptrs = push_array_zero(arena, Code_Index_Note*, list->count); + array.count = list->count; + i32 counter = 0; + for (Code_Index_Note *node = list->first; + node != 0; + node = node->next){ + array.ptrs[counter] = node; + counter += 1; + } + return(array); +} + function void code_index_lock(void){ system_mutex_acquire(global_code_index.mutex); @@ -223,6 +238,55 @@ generic_parse_init(Application_Links *app, Arena *arena, String_Const_u8 content state->prev_line_start = contents.str; } +//////////////////////////////// + +#if 0 +// NOTE(allen): grammar syntax +(X) = X +X Y = X and then Y +X? = zero or one X +$X = check for X but don't consume +[X] = zero or more Xs +X | Y = either X or Y +* = anything that does not match previous options in a X | Y | ... chain +* - X = anything that does not match X or previous options in a Y | Z | ... chain + = a token of type X +"X" = literally the string "X" +X{Y} = X with flag Y + +// NOTE(allen): grammar of code index parse +file: [preprocessor | scope | parens | type | * - ] +preprocessor: [scope | parens | stmnt]{pp-body} +scope: [preprocessor | scope | parens | * - ] +paren: [preprocessor | scope | parens | * - ] +stmnt-close-pattern: | | | | | +stmnt: [type | * - stmnt-close-pattern] stmnt-close-pattern +type: struct | union | enum | typedef +struct: "struct" $(";" | "{") +union: "union" $(";" | "{") +enum: "enum" $(";" | "{") +typedef: "typedef" [* - ( (";" | "("))] $(";" | "(") + +#endif + +//////////////////////////////// + +function Code_Index_Note* +index_new_note(Code_Index_File *index, Generic_Parse_State *state, Range_i64 range, Code_Index_Note_Kind kind, Code_Index_Nest *parent){ + Code_Index_Note *result = push_array(state->arena, Code_Index_Note, 1); + sll_queue_push(index->note_list.first, index->note_list.last, result); + index->note_list.count += 1; + result->note_kind = kind; + result->pos = range; + result->text = push_string_copy(state->arena, string_substring(state->contents, range)); + result->file = index; + result->parent = parent; + return(result); +} + +function Code_Index_Nest* +generic_parse_statement(Code_Index_File *index, Generic_Parse_State *state); + function Code_Index_Nest* generic_parse_preprocessor(Code_Index_File *index, Generic_Parse_State *state); @@ -268,8 +332,7 @@ generic_parse_statement(Code_Index_File *index, Generic_Parse_State *state){ if (token->kind == TokenBaseKind_ScopeOpen || token->kind == TokenBaseKind_ScopeClose || - token->kind == TokenBaseKind_ParentheticalOpen || - token->kind == TokenBaseKind_ParentheticalClose){ + token->kind == TokenBaseKind_ParentheticalOpen){ result->is_closed = true; result->close = Ii64(token->pos); break; @@ -495,10 +558,72 @@ generic_parse_paren(Code_Index_File *index, Generic_Parse_State *state){ return(result); } +function void +cpp_parse_type_structure(Code_Index_File *index, Generic_Parse_State *state, Code_Index_Nest *parent){ + generic_parse_inc(state); + generic_parse_skip_soft_tokens(index, state); + Token *token = token_it_read(&state->it); + if (token != 0 && token->kind == TokenBaseKind_Identifier){ + generic_parse_inc(state); + generic_parse_skip_soft_tokens(index, state); + Token *peek = token_it_read(&state->it); + if (peek != 0 && peek->kind == TokenBaseKind_StatementClose || + peek->kind == TokenBaseKind_ScopeOpen){ + index_new_note(index, state, Ii64(token), CodeIndexNote_Type, parent); + } + } +} + +function void +cpp_parse_type_def(Code_Index_File *index, Generic_Parse_State *state, Code_Index_Nest *parent){ + generic_parse_inc(state); + generic_parse_skip_soft_tokens(index, state); + for (;;){ + b32 did_advance = false; + Token *token = token_it_read(&state->it); + if (token == 0){ + break; + } + if (token->kind == TokenBaseKind_Identifier){ + generic_parse_inc(state); + generic_parse_skip_soft_tokens(index, state); + did_advance = true; + Token *peek = token_it_read(&state->it); + if (peek != 0 && peek->kind == TokenBaseKind_StatementClose || + peek->kind == TokenBaseKind_ParentheticalOpen){ + index_new_note(index, state, Ii64(token), CodeIndexNote_Type, parent); + break; + } + } + else if (token->kind == TokenBaseKind_StatementClose || + token->kind == TokenBaseKind_ScopeOpen || + token->kind == TokenBaseKind_ScopeClose || + token->kind == TokenBaseKind_ScopeOpen || + token->kind == TokenBaseKind_ScopeClose){ + break; + } + else if (token->kind == TokenBaseKind_Keyword){ + String_Const_u8 lexeme = string_substring(state->contents, Ii64(token)); + if (string_match(lexeme, string_u8_litexpr("struct")) || + string_match(lexeme, string_u8_litexpr("union")) || + string_match(lexeme, string_u8_litexpr("enum"))){ + break; + } + } + if (!did_advance){ + generic_parse_inc(state); + generic_parse_skip_soft_tokens(index, state); + } + } +} + function b32 generic_parse_full_input_breaks(Code_Index_File *index, Generic_Parse_State *state, i32 limit){ b32 result = false; + // TODO(allen): abstract the C++ parse parts somehow? + b32 do_cpp_parse = true; + i64 first_index = token_it_index(&state->it); i64 one_past_last_index = first_index + limit; for (;;){ @@ -522,6 +647,21 @@ generic_parse_full_input_breaks(Code_Index_File *index, Generic_Parse_State *sta Code_Index_Nest *nest = generic_parse_paren(index, state); code_index_push_nest(&index->nest_list, nest); } + else if (token->kind == TokenBaseKind_Keyword && do_cpp_parse){ + String_Const_u8 lexeme = string_substring(state->contents, Ii64(token)); + if (string_match(lexeme, string_u8_litexpr("struct")) || + string_match(lexeme, string_u8_litexpr("union")) || + string_match(lexeme, string_u8_litexpr("enum"))){ + cpp_parse_type_structure(index, state, 0); + } + else if (string_match(lexeme, string_u8_litexpr("typedef"))){ + cpp_parse_type_def(index, state, 0); + } + else{ + generic_parse_inc(state); + } + + } else{ generic_parse_inc(state); } @@ -538,6 +678,7 @@ generic_parse_full_input_breaks(Code_Index_File *index, Generic_Parse_State *sta if (result){ index->nest_array = code_index_nest_ptr_array_from_list(state->arena, &index->nest_list); + index->note_array = code_index_note_ptr_array_from_list(state->arena, &index->note_list); } return(result); @@ -563,10 +704,10 @@ layout_token_pair(Token_Array *tokens, i64 pos){ Token_Iterator_Array it = token_iterator_pos(0, tokens, pos); Token *b = token_it_read(&it); if (b != 0){ - if (b->kind == TokenBaseKind_Whitespace){ - token_it_inc_non_whitespace(&it); - b = token_it_read(&it); - } + if (b->kind == TokenBaseKind_Whitespace){ + token_it_inc_non_whitespace(&it); + b = token_it_read(&it); + } } token_it_dec_non_whitespace(&it); Token *a = token_it_read(&it); @@ -640,29 +781,29 @@ layout_index__emit_chunk(LefRig_TopBot_Layout_Vars *pos_vars, Arena *arena, u8 * for (;ptr < end;){ Character_Consume_Result consume = utf8_consume(ptr, (umem)(end - ptr)); if (consume.codepoint != '\r'){ - i64 index = layout_index_from_ptr(ptr, text_str, range_first); - if (consume.codepoint != max_u32){ - lr_tb_write(pos_vars, arena, list, index, consume.codepoint); - } - else{ - lr_tb_write_byte(pos_vars, arena, list, index, *ptr); - } + i64 index = layout_index_from_ptr(ptr, text_str, range_first); + if (consume.codepoint != max_u32){ + lr_tb_write(pos_vars, arena, list, index, consume.codepoint); + } + else{ + lr_tb_write_byte(pos_vars, arena, list, index, *ptr); + } } ptr += consume.inc; } } - function i32 - layout_token_score_wrap_token(Token_Pair *pair, Token_Cpp_Kind kind){ - i32 result = 0; - if (pair->a.sub_kind != kind && pair->b.sub_kind == kind){ - result -= 1; - } - else if (pair->a.sub_kind == kind && pair->b.sub_kind != kind){ - result += 1; - } - return(result); +function i32 +layout_token_score_wrap_token(Token_Pair *pair, Token_Cpp_Kind kind){ + i32 result = 0; + if (pair->a.sub_kind != kind && pair->b.sub_kind == kind){ + result -= 1; } + else if (pair->a.sub_kind == kind && pair->b.sub_kind != kind){ + result += 1; + } + return(result); +} function Layout_Item_List layout_index__inner(Application_Links *app, Arena *arena, Buffer_ID buffer, Range_i64 range, Face_ID face, f32 width, Code_Index_File *file, Layout_Wrap_Kind kind){ @@ -779,8 +920,8 @@ layout_index__inner(Application_Links *app, Arena *arena, Buffer_ID buffer, Rang #if 0 f32 shift = layout_index_x_shift(app, &reflex, file, index, metrics.space_advance); lr_tb_advance_x_without_item(&pos_vars, shift); - #endif - +#endif + ptr = pending_wrap_ptr; pending_wrap_accumulated_w = 0.f; first_of_the_line = true; @@ -919,15 +1060,15 @@ layout_virt_indent_index(Application_Links *app, Arena *arena, Buffer_ID buffer, Layout_Item_List result = {}; if (global_config.enable_virtual_whitespace){ - code_index_lock(); - Code_Index_File *file = code_index_get_file(buffer); - if (file != 0){ + code_index_lock(); + Code_Index_File *file = code_index_get_file(buffer); + if (file != 0){ result = layout_index__inner(app, arena, buffer, range, face, width, file, kind); - } - code_index_unlock(); - if (file == 0){ + } + code_index_unlock(); + if (file == 0){ result = layout_virt_indent_literal(app, arena, buffer, range, face, width, kind); - } + } } else{ result = layout_basic(app, arena, buffer, range, face, width, kind); diff --git a/custom/4coder_code_index.h b/custom/4coder_code_index.h index a46a14fd..71962556 100644 --- a/custom/4coder_code_index.h +++ b/custom/4coder_code_index.h @@ -41,9 +41,38 @@ struct Code_Index_Nest{ Code_Index_Nest_Ptr_Array nest_array; }; +typedef i64 Code_Index_Note_Kind; +enum{ + CodeIndexNote_Type, + CodeIndexNote_Function, + CodeIndexNote_Macro, +}; + +struct Code_Index_Note{ + Code_Index_Note *next; + Code_Index_Note_Kind note_kind; + Range_i64 pos; + String_Const_u8 text; + struct Code_Index_File *file; + Code_Index_Nest *parent; +}; + +struct Code_Index_Note_List{ + Code_Index_Note *first; + Code_Index_Note *last; + i32 count; +}; + +struct Code_Index_Note_Ptr_Array{ + Code_Index_Note **ptrs; + i32 count; +}; + struct Code_Index_File{ Code_Index_Nest_List nest_list; Code_Index_Nest_Ptr_Array nest_array; + Code_Index_Note_List note_list; + Code_Index_Note_Ptr_Array note_array; Buffer_ID buffer; }; diff --git a/custom/4coder_code_index_listers.cpp b/custom/4coder_code_index_listers.cpp new file mode 100644 index 00000000..892de4e1 --- /dev/null +++ b/custom/4coder_code_index_listers.cpp @@ -0,0 +1,52 @@ +/* +4coder_code_index_listers.cpp - Listers for exploring the contents of the code index. +*/ + +// TOP + +struct Tiny_Jump{ + Buffer_ID buffer; + i64 pos; +}; + +CUSTOM_UI_COMMAND_SIG(jump_to_type_definition) +CUSTOM_DOC("List all types in the code index and jump to one chosen by the user.") +{ + char *query = "Type:"; + + Scratch_Block scratch(app, Scratch_Share); + Lister *lister = begin_lister(app, scratch); + lister_set_query(lister, query); + lister->handlers = lister_get_default_handlers(); + + code_index_lock(); + for (Buffer_ID buffer = get_buffer_next(app, 0, Access_Always); + buffer != 0; + buffer = get_buffer_next(app, buffer, Access_Always)){ + Code_Index_File *file = code_index_get_file(buffer); + if (file != 0){ + for (i32 i = 0; i < file->note_array.count; i += 1){ + Code_Index_Note *note = file->note_array.ptrs[i]; + Tiny_Jump *jump = push_array(scratch, Tiny_Jump, 1); + jump->buffer = buffer; + jump->pos = note->pos.first; + lister_add_item(lister, note->text, string_u8_litexpr("type"), jump, 0); + } + } + } + code_index_unlock(); + + Lister_Result l_result = run_lister(app, lister); + Tiny_Jump result = {}; + if (!l_result.canceled && l_result.user_data != 0){ + block_copy_struct(&result, (Tiny_Jump*)l_result.user_data); + } + + if (result.buffer != 0){ + View_ID view = get_this_ctx_view(app, Access_Always); + jump_to_location(app, view, result.buffer, result.pos); + } +} + +// BOTTOM + diff --git a/custom/4coder_default_include.cpp b/custom/4coder_default_include.cpp index 626815ba..673b18aa 100644 --- a/custom/4coder_default_include.cpp +++ b/custom/4coder_default_include.cpp @@ -98,6 +98,7 @@ #include "4coder_jumping.cpp" #include "4coder_jump_sticky.cpp" #include "4coder_jump_lister.cpp" +#include "4coder_code_index_listers.cpp" #include "4coder_log_parser.cpp" #include "4coder_clipboard.cpp" #include "4coder_keyboard_macro.cpp" diff --git a/custom/4coder_jumping.cpp b/custom/4coder_jumping.cpp index e80494cd..654e2cea 100644 --- a/custom/4coder_jumping.cpp +++ b/custom/4coder_jumping.cpp @@ -4,7 +4,7 @@ // TOP -static b32 +function b32 ms_style_verify(String_Const_u8 line, umem left_paren_pos, umem right_paren_pos){ i32 result = false; String_Const_u8 line_part = string_skip(line, right_paren_pos); @@ -31,7 +31,7 @@ ms_style_verify(String_Const_u8 line, umem left_paren_pos, umem right_paren_pos) return(result); } -static umem +function umem try_skip_rust_arrow(String_Const_u8 line){ umem pos = 0; if (string_match(string_prefix(line, 3), string_u8_litexpr("-->"))){ @@ -42,7 +42,7 @@ try_skip_rust_arrow(String_Const_u8 line){ return(pos); } -static b32 +function b32 check_is_note(String_Const_u8 line, umem colon_pos){ b32 is_note = false; umem note_pos = colon_pos + string_find_first(string_skip(line, colon_pos), string_u8_litexpr("note")); @@ -61,7 +61,7 @@ check_is_note(String_Const_u8 line, umem colon_pos){ return(is_note); } -static Parsed_Jump +function Parsed_Jump parse_jump_location(String_Const_u8 line){ Parsed_Jump jump = {}; jump.sub_jump_indented = (string_get_character(line, 0) == ' '); @@ -185,7 +185,7 @@ parse_jump_location(String_Const_u8 line){ return(jump); } -static Parsed_Jump +function Parsed_Jump parse_jump_location(String_Const_u8 line, Jump_Flag flags){ Parsed_Jump jump = parse_jump_location(line); if (HasFlag(flags, JumpFlag_SkipSubs) && jump.is_sub_jump){ @@ -194,7 +194,7 @@ parse_jump_location(String_Const_u8 line, Jump_Flag flags){ return(jump); } -static Parsed_Jump +function Parsed_Jump parse_jump_from_buffer_line(Application_Links *app, Arena *arena, Buffer_ID buffer, i64 line, Jump_Flag flags){ Parsed_Jump jump = {}; String_Const_u8 line_str = push_buffer_line(app, arena, buffer, line); @@ -206,23 +206,23 @@ parse_jump_from_buffer_line(Application_Links *app, Arena *arena, Buffer_ID buff //////////////////////////////// -static b32 +function b32 get_jump_buffer(Application_Links *app, Buffer_ID *buffer, Name_Line_Column_Location *location){ return(open_file(app, buffer, location->file, false, true)); } -static b32 +function b32 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)); } -static b32 +function b32 get_jump_buffer(Application_Links *app, Buffer_ID *buffer, ID_Pos_Jump_Location *location){ return(get_jump_buffer(app, buffer, location, Access_Always)); } -static View_ID +function View_ID switch_to_existing_view(Application_Links *app, View_ID view, Buffer_ID buffer){ Buffer_ID current_buffer = view_get_buffer(app, view, Access_Always); if (view != 0 || current_buffer != buffer){ @@ -234,7 +234,7 @@ switch_to_existing_view(Application_Links *app, View_ID view, Buffer_ID buffer){ return(view); } -static void +function void set_view_to_location(Application_Links *app, View_ID view, Buffer_ID buffer, Buffer_Seek seek){ Buffer_ID current_buffer = view_get_buffer(app, view, Access_Always); if (current_buffer != buffer){ @@ -243,7 +243,16 @@ set_view_to_location(Application_Links *app, View_ID view, Buffer_ID buffer, Buf view_set_cursor_and_preferred_x(app, view, seek); } -static void +function void +jump_to_location(Application_Links *app, View_ID view, Buffer_ID buffer, i64 pos){ + view_set_active(app, view); + set_view_to_location(app, view, buffer, seek_pos(pos)); + if (auto_center_after_jumps){ + center_view(app); + } +} + +function void jump_to_location(Application_Links *app, View_ID view, Buffer_ID buffer, Name_Line_Column_Location location){ view_set_active(app, view); @@ -253,7 +262,7 @@ jump_to_location(Application_Links *app, View_ID view, Buffer_ID buffer, } } -static void +function void jump_to_location(Application_Links *app, View_ID view, Name_Line_Column_Location location){ Buffer_ID buffer = 0; @@ -262,7 +271,7 @@ jump_to_location(Application_Links *app, View_ID view, } } -static void +function void jump_to_location(Application_Links *app, View_ID view, Buffer_ID buffer, ID_Pos_Jump_Location location){ view_set_active(app, view); set_view_to_location(app, view, buffer, seek_pos(location.pos)); diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index c70bff37..ced8e98c 100644 --- a/custom/generated/command_metadata.h +++ b/custom/generated/command_metadata.h @@ -2,7 +2,7 @@ #define command_id(c) (fcoder_metacmd_ID_##c) #define command_metadata(c) (&fcoder_metacmd_table[command_id(c)]) #define command_metadata_by_id(id) (&fcoder_metacmd_table[id]) -#define command_one_past_last_id 227 +#define command_one_past_last_id 228 #if defined(CUSTOM_COMMAND_SIG) #define PROC_LINKS(x,y) x #else @@ -75,6 +75,7 @@ CUSTOM_COMMAND_SIG(interactive_new); CUSTOM_COMMAND_SIG(interactive_open); CUSTOM_COMMAND_SIG(interactive_open_or_new); CUSTOM_COMMAND_SIG(interactive_switch_buffer); +CUSTOM_COMMAND_SIG(jump_to_type_definition); CUSTOM_COMMAND_SIG(keyboard_macro_finish_recording); CUSTOM_COMMAND_SIG(keyboard_macro_replay); CUSTOM_COMMAND_SIG(keyboard_macro_start_recording); @@ -248,7 +249,7 @@ char *source_name; i32 source_name_len; i32 line_number; }; -static Command_Metadata fcoder_metacmd_table[227] = { +static Command_Metadata fcoder_metacmd_table[228] = { { PROC_LINKS(allow_mouse, 0), false, "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 409 }, { PROC_LINKS(auto_indent_line_at_cursor, 0), false, "auto_indent_line_at_cursor", 26, "Auto-indents the line on which the cursor sits.", 47, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 375 }, { PROC_LINKS(auto_indent_range, 0), false, "auto_indent_range", 17, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 385 }, @@ -315,6 +316,7 @@ static Command_Metadata fcoder_metacmd_table[227] = { { PROC_LINKS(interactive_open, 0), true, "interactive_open", 16, "Interactively opens a file.", 27, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 634 }, { PROC_LINKS(interactive_open_or_new, 0), true, "interactive_open_or_new", 23, "Interactively open a file out of the file system.", 49, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 563 }, { PROC_LINKS(interactive_switch_buffer, 0), true, "interactive_switch_buffer", 25, "Interactively switch to an open buffer.", 39, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 505 }, +{ PROC_LINKS(jump_to_type_definition, 0), true, "jump_to_type_definition", 23, "List all types in the code index and jump to one chosen by the user.", 68, "w:\\4ed\\code\\custom\\4coder_code_index_listers.cpp", 48, 12 }, { PROC_LINKS(keyboard_macro_finish_recording, 0), false, "keyboard_macro_finish_recording", 31, "Stop macro recording, do nothing if macro recording is not already started", 74, "w:\\4ed\\code\\custom\\4coder_keyboard_macro.cpp", 44, 57 }, { PROC_LINKS(keyboard_macro_replay, 0), false, "keyboard_macro_replay", 21, "Replay the most recently recorded keyboard macro", 48, "w:\\4ed\\code\\custom\\4coder_keyboard_macro.cpp", 44, 80 }, { PROC_LINKS(keyboard_macro_start_recording, 0), false, "keyboard_macro_start_recording", 30, "Start macro recording, do nothing if macro recording is already started", 71, "w:\\4ed\\code\\custom\\4coder_keyboard_macro.cpp", 44, 44 }, @@ -457,7 +459,7 @@ static Command_Metadata fcoder_metacmd_table[227] = { { PROC_LINKS(toggle_mouse, 0), false, "toggle_mouse", 12, "Toggles the mouse suppression mode, see suppress_mouse and allow_mouse.", 71, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 415 }, { PROC_LINKS(toggle_paren_matching_helper, 0), false, "toggle_paren_matching_helper", 28, "In code files matching parentheses pairs are colored with distinguishing colors.", 80, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 445 }, { PROC_LINKS(toggle_show_whitespace, 0), false, "toggle_show_whitespace", 22, "Toggles the current buffer's whitespace visibility status.", 58, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 712 }, -{ PROC_LINKS(toggle_virtual_whitespace, 0), false, "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "w:\\4ed\\code\\custom\\4coder_code_index.cpp", 40, 957 }, +{ PROC_LINKS(toggle_virtual_whitespace, 0), false, "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "w:\\4ed\\code\\custom\\4coder_code_index.cpp", 40, 1098 }, { PROC_LINKS(tutorial_maximize, 0), false, "tutorial_maximize", 17, "Expand the tutorial window", 26, "w:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 20 }, { PROC_LINKS(tutorial_minimize, 0), false, "tutorial_minimize", 17, "Shrink the tutorial window", 26, "w:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 34 }, { PROC_LINKS(uncomment_line, 0), false, "uncomment_line", 14, "If present, delete '//' at the beginning of the line after leading whitespace.", 78, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 137 }, @@ -543,165 +545,166 @@ static i32 fcoder_metacmd_ID_interactive_new = 62; static i32 fcoder_metacmd_ID_interactive_open = 63; static i32 fcoder_metacmd_ID_interactive_open_or_new = 64; static i32 fcoder_metacmd_ID_interactive_switch_buffer = 65; -static i32 fcoder_metacmd_ID_keyboard_macro_finish_recording = 66; -static i32 fcoder_metacmd_ID_keyboard_macro_replay = 67; -static i32 fcoder_metacmd_ID_keyboard_macro_start_recording = 68; -static i32 fcoder_metacmd_ID_kill_buffer = 69; -static i32 fcoder_metacmd_ID_kill_tutorial = 70; -static i32 fcoder_metacmd_ID_left_adjust_view = 71; -static i32 fcoder_metacmd_ID_list_all_functions_all_buffers = 72; -static i32 fcoder_metacmd_ID_list_all_functions_all_buffers_lister = 73; -static i32 fcoder_metacmd_ID_list_all_functions_current_buffer = 74; -static i32 fcoder_metacmd_ID_list_all_functions_current_buffer_lister = 75; -static i32 fcoder_metacmd_ID_list_all_locations = 76; -static i32 fcoder_metacmd_ID_list_all_locations_case_insensitive = 77; -static i32 fcoder_metacmd_ID_list_all_locations_of_identifier = 78; -static i32 fcoder_metacmd_ID_list_all_locations_of_identifier_case_insensitive = 79; -static i32 fcoder_metacmd_ID_list_all_locations_of_selection = 80; -static i32 fcoder_metacmd_ID_list_all_locations_of_selection_case_insensitive = 81; -static i32 fcoder_metacmd_ID_list_all_locations_of_type_definition = 82; -static i32 fcoder_metacmd_ID_list_all_locations_of_type_definition_of_identifier = 83; -static i32 fcoder_metacmd_ID_list_all_substring_locations = 84; -static i32 fcoder_metacmd_ID_list_all_substring_locations_case_insensitive = 85; -static i32 fcoder_metacmd_ID_load_project = 86; -static i32 fcoder_metacmd_ID_load_themes_default_folder = 87; -static i32 fcoder_metacmd_ID_load_themes_hot_directory = 88; -static i32 fcoder_metacmd_ID_make_directory_query = 89; -static i32 fcoder_metacmd_ID_miblo_decrement_basic = 90; -static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp = 91; -static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp_minute = 92; -static i32 fcoder_metacmd_ID_miblo_increment_basic = 93; -static i32 fcoder_metacmd_ID_miblo_increment_time_stamp = 94; -static i32 fcoder_metacmd_ID_miblo_increment_time_stamp_minute = 95; -static i32 fcoder_metacmd_ID_mouse_wheel_change_face_size = 96; -static i32 fcoder_metacmd_ID_mouse_wheel_scroll = 97; -static i32 fcoder_metacmd_ID_move_down = 98; -static i32 fcoder_metacmd_ID_move_down_10 = 99; -static i32 fcoder_metacmd_ID_move_down_textual = 100; -static i32 fcoder_metacmd_ID_move_down_to_blank_line = 101; -static i32 fcoder_metacmd_ID_move_down_to_blank_line_end = 102; -static i32 fcoder_metacmd_ID_move_down_to_blank_line_skip_whitespace = 103; -static i32 fcoder_metacmd_ID_move_left = 104; -static i32 fcoder_metacmd_ID_move_left_alpha_numeric_boundary = 105; -static i32 fcoder_metacmd_ID_move_left_alpha_numeric_or_camel_boundary = 106; -static i32 fcoder_metacmd_ID_move_left_token_boundary = 107; -static i32 fcoder_metacmd_ID_move_left_whitespace_boundary = 108; -static i32 fcoder_metacmd_ID_move_left_whitespace_or_token_boundary = 109; -static i32 fcoder_metacmd_ID_move_line_down = 110; -static i32 fcoder_metacmd_ID_move_line_up = 111; -static i32 fcoder_metacmd_ID_move_right = 112; -static i32 fcoder_metacmd_ID_move_right_alpha_numeric_boundary = 113; -static i32 fcoder_metacmd_ID_move_right_alpha_numeric_or_camel_boundary = 114; -static i32 fcoder_metacmd_ID_move_right_token_boundary = 115; -static i32 fcoder_metacmd_ID_move_right_whitespace_boundary = 116; -static i32 fcoder_metacmd_ID_move_right_whitespace_or_token_boundary = 117; -static i32 fcoder_metacmd_ID_move_up = 118; -static i32 fcoder_metacmd_ID_move_up_10 = 119; -static i32 fcoder_metacmd_ID_move_up_to_blank_line = 120; -static i32 fcoder_metacmd_ID_move_up_to_blank_line_end = 121; -static i32 fcoder_metacmd_ID_move_up_to_blank_line_skip_whitespace = 122; -static i32 fcoder_metacmd_ID_open_all_code = 123; -static i32 fcoder_metacmd_ID_open_all_code_recursive = 124; -static i32 fcoder_metacmd_ID_open_documentation = 125; -static i32 fcoder_metacmd_ID_open_file_in_quotes = 126; -static i32 fcoder_metacmd_ID_open_in_other = 127; -static i32 fcoder_metacmd_ID_open_long_braces = 128; -static i32 fcoder_metacmd_ID_open_long_braces_break = 129; -static i32 fcoder_metacmd_ID_open_long_braces_semicolon = 130; -static i32 fcoder_metacmd_ID_open_matching_file_cpp = 131; -static i32 fcoder_metacmd_ID_open_panel_hsplit = 132; -static i32 fcoder_metacmd_ID_open_panel_vsplit = 133; -static i32 fcoder_metacmd_ID_page_down = 134; -static i32 fcoder_metacmd_ID_page_up = 135; -static i32 fcoder_metacmd_ID_paste = 136; -static i32 fcoder_metacmd_ID_paste_and_indent = 137; -static i32 fcoder_metacmd_ID_paste_next = 138; -static i32 fcoder_metacmd_ID_paste_next_and_indent = 139; -static i32 fcoder_metacmd_ID_place_in_scope = 140; -static i32 fcoder_metacmd_ID_profile_clear = 141; -static i32 fcoder_metacmd_ID_profile_disable = 142; -static i32 fcoder_metacmd_ID_profile_enable = 143; -static i32 fcoder_metacmd_ID_profile_inspect = 144; -static i32 fcoder_metacmd_ID_project_command_lister = 145; -static i32 fcoder_metacmd_ID_project_fkey_command = 146; -static i32 fcoder_metacmd_ID_project_go_to_root_directory = 147; -static i32 fcoder_metacmd_ID_query_replace = 148; -static i32 fcoder_metacmd_ID_query_replace_identifier = 149; -static i32 fcoder_metacmd_ID_query_replace_selection = 150; -static i32 fcoder_metacmd_ID_redo = 151; -static i32 fcoder_metacmd_ID_redo_all_buffers = 152; -static i32 fcoder_metacmd_ID_rename_file_query = 153; -static i32 fcoder_metacmd_ID_reopen = 154; -static i32 fcoder_metacmd_ID_replace_in_all_buffers = 155; -static i32 fcoder_metacmd_ID_replace_in_buffer = 156; -static i32 fcoder_metacmd_ID_replace_in_range = 157; -static i32 fcoder_metacmd_ID_reverse_search = 158; -static i32 fcoder_metacmd_ID_reverse_search_identifier = 159; -static i32 fcoder_metacmd_ID_save = 160; -static i32 fcoder_metacmd_ID_save_all_dirty_buffers = 161; -static i32 fcoder_metacmd_ID_save_to_query = 162; -static i32 fcoder_metacmd_ID_search = 163; -static i32 fcoder_metacmd_ID_search_identifier = 164; -static i32 fcoder_metacmd_ID_seek_beginning_of_line = 165; -static i32 fcoder_metacmd_ID_seek_beginning_of_textual_line = 166; -static i32 fcoder_metacmd_ID_seek_end_of_line = 167; -static i32 fcoder_metacmd_ID_seek_end_of_textual_line = 168; -static i32 fcoder_metacmd_ID_select_all = 169; -static i32 fcoder_metacmd_ID_select_next_scope_absolute = 170; -static i32 fcoder_metacmd_ID_select_next_scope_after_current = 171; -static i32 fcoder_metacmd_ID_select_prev_scope_absolute = 172; -static i32 fcoder_metacmd_ID_select_prev_top_most_scope = 173; -static i32 fcoder_metacmd_ID_select_surrounding_scope = 174; -static i32 fcoder_metacmd_ID_select_surrounding_scope_maximal = 175; -static i32 fcoder_metacmd_ID_set_eol_mode_from_contents = 176; -static i32 fcoder_metacmd_ID_set_eol_mode_to_binary = 177; -static i32 fcoder_metacmd_ID_set_eol_mode_to_crlf = 178; -static i32 fcoder_metacmd_ID_set_eol_mode_to_lf = 179; -static i32 fcoder_metacmd_ID_set_mark = 180; -static i32 fcoder_metacmd_ID_set_mode_to_notepad_like = 181; -static i32 fcoder_metacmd_ID_set_mode_to_original = 182; -static i32 fcoder_metacmd_ID_setup_build_bat = 183; -static i32 fcoder_metacmd_ID_setup_build_bat_and_sh = 184; -static i32 fcoder_metacmd_ID_setup_build_sh = 185; -static i32 fcoder_metacmd_ID_setup_new_project = 186; -static i32 fcoder_metacmd_ID_show_filebar = 187; -static i32 fcoder_metacmd_ID_show_scrollbar = 188; -static i32 fcoder_metacmd_ID_show_the_log_graph = 189; -static i32 fcoder_metacmd_ID_snipe_backward_whitespace_or_token_boundary = 190; -static i32 fcoder_metacmd_ID_snipe_forward_whitespace_or_token_boundary = 191; -static i32 fcoder_metacmd_ID_snippet_lister = 192; -static i32 fcoder_metacmd_ID_suppress_mouse = 193; -static i32 fcoder_metacmd_ID_swap_panels = 194; -static i32 fcoder_metacmd_ID_theme_lister = 195; -static i32 fcoder_metacmd_ID_to_lowercase = 196; -static i32 fcoder_metacmd_ID_to_uppercase = 197; -static i32 fcoder_metacmd_ID_toggle_filebar = 198; -static i32 fcoder_metacmd_ID_toggle_fps_meter = 199; -static i32 fcoder_metacmd_ID_toggle_fullscreen = 200; -static i32 fcoder_metacmd_ID_toggle_highlight_enclosing_scopes = 201; -static i32 fcoder_metacmd_ID_toggle_highlight_line_at_cursor = 202; -static i32 fcoder_metacmd_ID_toggle_line_numbers = 203; -static i32 fcoder_metacmd_ID_toggle_line_wrap = 204; -static i32 fcoder_metacmd_ID_toggle_mouse = 205; -static i32 fcoder_metacmd_ID_toggle_paren_matching_helper = 206; -static i32 fcoder_metacmd_ID_toggle_show_whitespace = 207; -static i32 fcoder_metacmd_ID_toggle_virtual_whitespace = 208; -static i32 fcoder_metacmd_ID_tutorial_maximize = 209; -static i32 fcoder_metacmd_ID_tutorial_minimize = 210; -static i32 fcoder_metacmd_ID_uncomment_line = 211; -static i32 fcoder_metacmd_ID_undo = 212; -static i32 fcoder_metacmd_ID_undo_all_buffers = 213; -static i32 fcoder_metacmd_ID_view_buffer_other_panel = 214; -static i32 fcoder_metacmd_ID_view_jump_list_with_lister = 215; -static i32 fcoder_metacmd_ID_word_complete = 216; -static i32 fcoder_metacmd_ID_word_complete_drop_down = 217; -static i32 fcoder_metacmd_ID_write_block = 218; -static i32 fcoder_metacmd_ID_write_hack = 219; -static i32 fcoder_metacmd_ID_write_note = 220; -static i32 fcoder_metacmd_ID_write_space = 221; -static i32 fcoder_metacmd_ID_write_text_and_auto_indent = 222; -static i32 fcoder_metacmd_ID_write_text_input = 223; -static i32 fcoder_metacmd_ID_write_todo = 224; -static i32 fcoder_metacmd_ID_write_underscore = 225; -static i32 fcoder_metacmd_ID_write_zero_struct = 226; +static i32 fcoder_metacmd_ID_jump_to_type_definition = 66; +static i32 fcoder_metacmd_ID_keyboard_macro_finish_recording = 67; +static i32 fcoder_metacmd_ID_keyboard_macro_replay = 68; +static i32 fcoder_metacmd_ID_keyboard_macro_start_recording = 69; +static i32 fcoder_metacmd_ID_kill_buffer = 70; +static i32 fcoder_metacmd_ID_kill_tutorial = 71; +static i32 fcoder_metacmd_ID_left_adjust_view = 72; +static i32 fcoder_metacmd_ID_list_all_functions_all_buffers = 73; +static i32 fcoder_metacmd_ID_list_all_functions_all_buffers_lister = 74; +static i32 fcoder_metacmd_ID_list_all_functions_current_buffer = 75; +static i32 fcoder_metacmd_ID_list_all_functions_current_buffer_lister = 76; +static i32 fcoder_metacmd_ID_list_all_locations = 77; +static i32 fcoder_metacmd_ID_list_all_locations_case_insensitive = 78; +static i32 fcoder_metacmd_ID_list_all_locations_of_identifier = 79; +static i32 fcoder_metacmd_ID_list_all_locations_of_identifier_case_insensitive = 80; +static i32 fcoder_metacmd_ID_list_all_locations_of_selection = 81; +static i32 fcoder_metacmd_ID_list_all_locations_of_selection_case_insensitive = 82; +static i32 fcoder_metacmd_ID_list_all_locations_of_type_definition = 83; +static i32 fcoder_metacmd_ID_list_all_locations_of_type_definition_of_identifier = 84; +static i32 fcoder_metacmd_ID_list_all_substring_locations = 85; +static i32 fcoder_metacmd_ID_list_all_substring_locations_case_insensitive = 86; +static i32 fcoder_metacmd_ID_load_project = 87; +static i32 fcoder_metacmd_ID_load_themes_default_folder = 88; +static i32 fcoder_metacmd_ID_load_themes_hot_directory = 89; +static i32 fcoder_metacmd_ID_make_directory_query = 90; +static i32 fcoder_metacmd_ID_miblo_decrement_basic = 91; +static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp = 92; +static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp_minute = 93; +static i32 fcoder_metacmd_ID_miblo_increment_basic = 94; +static i32 fcoder_metacmd_ID_miblo_increment_time_stamp = 95; +static i32 fcoder_metacmd_ID_miblo_increment_time_stamp_minute = 96; +static i32 fcoder_metacmd_ID_mouse_wheel_change_face_size = 97; +static i32 fcoder_metacmd_ID_mouse_wheel_scroll = 98; +static i32 fcoder_metacmd_ID_move_down = 99; +static i32 fcoder_metacmd_ID_move_down_10 = 100; +static i32 fcoder_metacmd_ID_move_down_textual = 101; +static i32 fcoder_metacmd_ID_move_down_to_blank_line = 102; +static i32 fcoder_metacmd_ID_move_down_to_blank_line_end = 103; +static i32 fcoder_metacmd_ID_move_down_to_blank_line_skip_whitespace = 104; +static i32 fcoder_metacmd_ID_move_left = 105; +static i32 fcoder_metacmd_ID_move_left_alpha_numeric_boundary = 106; +static i32 fcoder_metacmd_ID_move_left_alpha_numeric_or_camel_boundary = 107; +static i32 fcoder_metacmd_ID_move_left_token_boundary = 108; +static i32 fcoder_metacmd_ID_move_left_whitespace_boundary = 109; +static i32 fcoder_metacmd_ID_move_left_whitespace_or_token_boundary = 110; +static i32 fcoder_metacmd_ID_move_line_down = 111; +static i32 fcoder_metacmd_ID_move_line_up = 112; +static i32 fcoder_metacmd_ID_move_right = 113; +static i32 fcoder_metacmd_ID_move_right_alpha_numeric_boundary = 114; +static i32 fcoder_metacmd_ID_move_right_alpha_numeric_or_camel_boundary = 115; +static i32 fcoder_metacmd_ID_move_right_token_boundary = 116; +static i32 fcoder_metacmd_ID_move_right_whitespace_boundary = 117; +static i32 fcoder_metacmd_ID_move_right_whitespace_or_token_boundary = 118; +static i32 fcoder_metacmd_ID_move_up = 119; +static i32 fcoder_metacmd_ID_move_up_10 = 120; +static i32 fcoder_metacmd_ID_move_up_to_blank_line = 121; +static i32 fcoder_metacmd_ID_move_up_to_blank_line_end = 122; +static i32 fcoder_metacmd_ID_move_up_to_blank_line_skip_whitespace = 123; +static i32 fcoder_metacmd_ID_open_all_code = 124; +static i32 fcoder_metacmd_ID_open_all_code_recursive = 125; +static i32 fcoder_metacmd_ID_open_documentation = 126; +static i32 fcoder_metacmd_ID_open_file_in_quotes = 127; +static i32 fcoder_metacmd_ID_open_in_other = 128; +static i32 fcoder_metacmd_ID_open_long_braces = 129; +static i32 fcoder_metacmd_ID_open_long_braces_break = 130; +static i32 fcoder_metacmd_ID_open_long_braces_semicolon = 131; +static i32 fcoder_metacmd_ID_open_matching_file_cpp = 132; +static i32 fcoder_metacmd_ID_open_panel_hsplit = 133; +static i32 fcoder_metacmd_ID_open_panel_vsplit = 134; +static i32 fcoder_metacmd_ID_page_down = 135; +static i32 fcoder_metacmd_ID_page_up = 136; +static i32 fcoder_metacmd_ID_paste = 137; +static i32 fcoder_metacmd_ID_paste_and_indent = 138; +static i32 fcoder_metacmd_ID_paste_next = 139; +static i32 fcoder_metacmd_ID_paste_next_and_indent = 140; +static i32 fcoder_metacmd_ID_place_in_scope = 141; +static i32 fcoder_metacmd_ID_profile_clear = 142; +static i32 fcoder_metacmd_ID_profile_disable = 143; +static i32 fcoder_metacmd_ID_profile_enable = 144; +static i32 fcoder_metacmd_ID_profile_inspect = 145; +static i32 fcoder_metacmd_ID_project_command_lister = 146; +static i32 fcoder_metacmd_ID_project_fkey_command = 147; +static i32 fcoder_metacmd_ID_project_go_to_root_directory = 148; +static i32 fcoder_metacmd_ID_query_replace = 149; +static i32 fcoder_metacmd_ID_query_replace_identifier = 150; +static i32 fcoder_metacmd_ID_query_replace_selection = 151; +static i32 fcoder_metacmd_ID_redo = 152; +static i32 fcoder_metacmd_ID_redo_all_buffers = 153; +static i32 fcoder_metacmd_ID_rename_file_query = 154; +static i32 fcoder_metacmd_ID_reopen = 155; +static i32 fcoder_metacmd_ID_replace_in_all_buffers = 156; +static i32 fcoder_metacmd_ID_replace_in_buffer = 157; +static i32 fcoder_metacmd_ID_replace_in_range = 158; +static i32 fcoder_metacmd_ID_reverse_search = 159; +static i32 fcoder_metacmd_ID_reverse_search_identifier = 160; +static i32 fcoder_metacmd_ID_save = 161; +static i32 fcoder_metacmd_ID_save_all_dirty_buffers = 162; +static i32 fcoder_metacmd_ID_save_to_query = 163; +static i32 fcoder_metacmd_ID_search = 164; +static i32 fcoder_metacmd_ID_search_identifier = 165; +static i32 fcoder_metacmd_ID_seek_beginning_of_line = 166; +static i32 fcoder_metacmd_ID_seek_beginning_of_textual_line = 167; +static i32 fcoder_metacmd_ID_seek_end_of_line = 168; +static i32 fcoder_metacmd_ID_seek_end_of_textual_line = 169; +static i32 fcoder_metacmd_ID_select_all = 170; +static i32 fcoder_metacmd_ID_select_next_scope_absolute = 171; +static i32 fcoder_metacmd_ID_select_next_scope_after_current = 172; +static i32 fcoder_metacmd_ID_select_prev_scope_absolute = 173; +static i32 fcoder_metacmd_ID_select_prev_top_most_scope = 174; +static i32 fcoder_metacmd_ID_select_surrounding_scope = 175; +static i32 fcoder_metacmd_ID_select_surrounding_scope_maximal = 176; +static i32 fcoder_metacmd_ID_set_eol_mode_from_contents = 177; +static i32 fcoder_metacmd_ID_set_eol_mode_to_binary = 178; +static i32 fcoder_metacmd_ID_set_eol_mode_to_crlf = 179; +static i32 fcoder_metacmd_ID_set_eol_mode_to_lf = 180; +static i32 fcoder_metacmd_ID_set_mark = 181; +static i32 fcoder_metacmd_ID_set_mode_to_notepad_like = 182; +static i32 fcoder_metacmd_ID_set_mode_to_original = 183; +static i32 fcoder_metacmd_ID_setup_build_bat = 184; +static i32 fcoder_metacmd_ID_setup_build_bat_and_sh = 185; +static i32 fcoder_metacmd_ID_setup_build_sh = 186; +static i32 fcoder_metacmd_ID_setup_new_project = 187; +static i32 fcoder_metacmd_ID_show_filebar = 188; +static i32 fcoder_metacmd_ID_show_scrollbar = 189; +static i32 fcoder_metacmd_ID_show_the_log_graph = 190; +static i32 fcoder_metacmd_ID_snipe_backward_whitespace_or_token_boundary = 191; +static i32 fcoder_metacmd_ID_snipe_forward_whitespace_or_token_boundary = 192; +static i32 fcoder_metacmd_ID_snippet_lister = 193; +static i32 fcoder_metacmd_ID_suppress_mouse = 194; +static i32 fcoder_metacmd_ID_swap_panels = 195; +static i32 fcoder_metacmd_ID_theme_lister = 196; +static i32 fcoder_metacmd_ID_to_lowercase = 197; +static i32 fcoder_metacmd_ID_to_uppercase = 198; +static i32 fcoder_metacmd_ID_toggle_filebar = 199; +static i32 fcoder_metacmd_ID_toggle_fps_meter = 200; +static i32 fcoder_metacmd_ID_toggle_fullscreen = 201; +static i32 fcoder_metacmd_ID_toggle_highlight_enclosing_scopes = 202; +static i32 fcoder_metacmd_ID_toggle_highlight_line_at_cursor = 203; +static i32 fcoder_metacmd_ID_toggle_line_numbers = 204; +static i32 fcoder_metacmd_ID_toggle_line_wrap = 205; +static i32 fcoder_metacmd_ID_toggle_mouse = 206; +static i32 fcoder_metacmd_ID_toggle_paren_matching_helper = 207; +static i32 fcoder_metacmd_ID_toggle_show_whitespace = 208; +static i32 fcoder_metacmd_ID_toggle_virtual_whitespace = 209; +static i32 fcoder_metacmd_ID_tutorial_maximize = 210; +static i32 fcoder_metacmd_ID_tutorial_minimize = 211; +static i32 fcoder_metacmd_ID_uncomment_line = 212; +static i32 fcoder_metacmd_ID_undo = 213; +static i32 fcoder_metacmd_ID_undo_all_buffers = 214; +static i32 fcoder_metacmd_ID_view_buffer_other_panel = 215; +static i32 fcoder_metacmd_ID_view_jump_list_with_lister = 216; +static i32 fcoder_metacmd_ID_word_complete = 217; +static i32 fcoder_metacmd_ID_word_complete_drop_down = 218; +static i32 fcoder_metacmd_ID_write_block = 219; +static i32 fcoder_metacmd_ID_write_hack = 220; +static i32 fcoder_metacmd_ID_write_note = 221; +static i32 fcoder_metacmd_ID_write_space = 222; +static i32 fcoder_metacmd_ID_write_text_and_auto_indent = 223; +static i32 fcoder_metacmd_ID_write_text_input = 224; +static i32 fcoder_metacmd_ID_write_todo = 225; +static i32 fcoder_metacmd_ID_write_underscore = 226; +static i32 fcoder_metacmd_ID_write_zero_struct = 227; #endif From c9a01fbe0e7de3910144c466e935feba6932bd64 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Fri, 13 Dec 2019 16:20:59 -0800 Subject: [PATCH 2/2] Basics of the entire code index in place for jump to definition --- custom/4coder_code_index.cpp | 164 +++++++++++++++------------ custom/4coder_code_index.h | 3 + custom/4coder_code_index_listers.cpp | 26 ++++- custom/4coder_default_hooks.cpp | 3 + custom/4coder_helper.cpp | 10 +- custom/4coder_types.h | 4 - custom/generated/command_metadata.h | 8 +- 7 files changed, 130 insertions(+), 88 deletions(-) diff --git a/custom/4coder_code_index.cpp b/custom/4coder_code_index.cpp index daa95538..6bd1f40a 100644 --- a/custom/4coder_code_index.cpp +++ b/custom/4coder_code_index.cpp @@ -255,7 +255,7 @@ X | Y = either X or Y X{Y} = X with flag Y // NOTE(allen): grammar of code index parse -file: [preprocessor | scope | parens | type | * - ] +file: [preprocessor | scope | parens | function | type | * - ] preprocessor: [scope | parens | stmnt]{pp-body} scope: [preprocessor | scope | parens | * - ] paren: [preprocessor | scope | parens | * - ] @@ -266,6 +266,7 @@ struct: "struct" $(";" | "{") union: "union" $(";" | "{") enum: "enum" $(";" | "{") typedef: "typedef" [* - ( (";" | "("))] $(";" | "(") +function: >"(" #endif @@ -284,6 +285,76 @@ index_new_note(Code_Index_File *index, Generic_Parse_State *state, Range_i64 ran return(result); } +function void +cpp_parse_type_structure(Code_Index_File *index, Generic_Parse_State *state, Code_Index_Nest *parent){ + generic_parse_inc(state); + generic_parse_skip_soft_tokens(index, state); + Token *token = token_it_read(&state->it); + if (token != 0 && token->kind == TokenBaseKind_Identifier){ + generic_parse_inc(state); + generic_parse_skip_soft_tokens(index, state); + Token *peek = token_it_read(&state->it); + if (peek != 0 && peek->kind == TokenBaseKind_StatementClose || + peek->kind == TokenBaseKind_ScopeOpen){ + index_new_note(index, state, Ii64(token), CodeIndexNote_Type, parent); + } + } +} + +function void +cpp_parse_type_def(Code_Index_File *index, Generic_Parse_State *state, Code_Index_Nest *parent){ + generic_parse_inc(state); + generic_parse_skip_soft_tokens(index, state); + for (;;){ + b32 did_advance = false; + Token *token = token_it_read(&state->it); + if (token == 0){ + break; + } + if (token->kind == TokenBaseKind_Identifier){ + generic_parse_inc(state); + generic_parse_skip_soft_tokens(index, state); + did_advance = true; + Token *peek = token_it_read(&state->it); + if (peek != 0 && peek->kind == TokenBaseKind_StatementClose || + peek->kind == TokenBaseKind_ParentheticalOpen){ + index_new_note(index, state, Ii64(token), CodeIndexNote_Type, parent); + break; + } + } + else if (token->kind == TokenBaseKind_StatementClose || + token->kind == TokenBaseKind_ScopeOpen || + token->kind == TokenBaseKind_ScopeClose || + token->kind == TokenBaseKind_ScopeOpen || + token->kind == TokenBaseKind_ScopeClose){ + break; + } + else if (token->kind == TokenBaseKind_Keyword){ + String_Const_u8 lexeme = string_substring(state->contents, Ii64(token)); + if (string_match(lexeme, string_u8_litexpr("struct")) || + string_match(lexeme, string_u8_litexpr("union")) || + string_match(lexeme, string_u8_litexpr("enum"))){ + break; + } + } + if (!did_advance){ + generic_parse_inc(state); + generic_parse_skip_soft_tokens(index, state); + } + } +} + +function void +cpp_parse_function(Code_Index_File *index, Generic_Parse_State *state, Code_Index_Nest *parent){ + Token *token = token_it_read(&state->it); + generic_parse_inc(state); + generic_parse_skip_soft_tokens(index, state); + Token *peek = token_it_read(&state->it); + if (peek != 0 && peek->sub_kind == TokenCppKind_ParenOp){ + index_new_note(index, state, Ii64(token), CodeIndexNote_Function, parent); + } +} + function Code_Index_Nest* generic_parse_statement(Code_Index_File *index, Generic_Parse_State *state); @@ -364,6 +435,13 @@ generic_parse_preprocessor(Code_Index_File *index, Generic_Parse_State *state){ state->in_preprocessor = true; + b32 potential_macro = false; + if (state->do_cpp_parse){ + if (token->sub_kind == TokenCppKind_PPDefine){ + potential_macro = true; + } + } + generic_parse_inc(state); for (;;){ generic_parse_skip_soft_tokens(index, state); @@ -379,6 +457,13 @@ generic_parse_preprocessor(Code_Index_File *index, Generic_Parse_State *state){ break; } + if (state->do_cpp_parse && potential_macro){ + if (token->sub_kind == TokenCppKind_Identifier){ + index_new_note(index, state, Ii64(token), CodeIndexNote_Macro, result); + } + potential_macro = false; + } + if (token->kind == TokenBaseKind_ScopeOpen){ Code_Index_Nest *nest = generic_parse_scope(index, state); nest->parent = result; @@ -558,72 +643,10 @@ generic_parse_paren(Code_Index_File *index, Generic_Parse_State *state){ return(result); } -function void -cpp_parse_type_structure(Code_Index_File *index, Generic_Parse_State *state, Code_Index_Nest *parent){ - generic_parse_inc(state); - generic_parse_skip_soft_tokens(index, state); - Token *token = token_it_read(&state->it); - if (token != 0 && token->kind == TokenBaseKind_Identifier){ - generic_parse_inc(state); - generic_parse_skip_soft_tokens(index, state); - Token *peek = token_it_read(&state->it); - if (peek != 0 && peek->kind == TokenBaseKind_StatementClose || - peek->kind == TokenBaseKind_ScopeOpen){ - index_new_note(index, state, Ii64(token), CodeIndexNote_Type, parent); - } - } -} - -function void -cpp_parse_type_def(Code_Index_File *index, Generic_Parse_State *state, Code_Index_Nest *parent){ - generic_parse_inc(state); - generic_parse_skip_soft_tokens(index, state); - for (;;){ - b32 did_advance = false; - Token *token = token_it_read(&state->it); - if (token == 0){ - break; - } - if (token->kind == TokenBaseKind_Identifier){ - generic_parse_inc(state); - generic_parse_skip_soft_tokens(index, state); - did_advance = true; - Token *peek = token_it_read(&state->it); - if (peek != 0 && peek->kind == TokenBaseKind_StatementClose || - peek->kind == TokenBaseKind_ParentheticalOpen){ - index_new_note(index, state, Ii64(token), CodeIndexNote_Type, parent); - break; - } - } - else if (token->kind == TokenBaseKind_StatementClose || - token->kind == TokenBaseKind_ScopeOpen || - token->kind == TokenBaseKind_ScopeClose || - token->kind == TokenBaseKind_ScopeOpen || - token->kind == TokenBaseKind_ScopeClose){ - break; - } - else if (token->kind == TokenBaseKind_Keyword){ - String_Const_u8 lexeme = string_substring(state->contents, Ii64(token)); - if (string_match(lexeme, string_u8_litexpr("struct")) || - string_match(lexeme, string_u8_litexpr("union")) || - string_match(lexeme, string_u8_litexpr("enum"))){ - break; - } - } - if (!did_advance){ - generic_parse_inc(state); - generic_parse_skip_soft_tokens(index, state); - } - } -} - function b32 generic_parse_full_input_breaks(Code_Index_File *index, Generic_Parse_State *state, i32 limit){ b32 result = false; - // TODO(allen): abstract the C++ parse parts somehow? - b32 do_cpp_parse = true; - i64 first_index = token_it_index(&state->it); i64 one_past_last_index = first_index + limit; for (;;){ @@ -647,20 +670,21 @@ generic_parse_full_input_breaks(Code_Index_File *index, Generic_Parse_State *sta Code_Index_Nest *nest = generic_parse_paren(index, state); code_index_push_nest(&index->nest_list, nest); } - else if (token->kind == TokenBaseKind_Keyword && do_cpp_parse){ - String_Const_u8 lexeme = string_substring(state->contents, Ii64(token)); - if (string_match(lexeme, string_u8_litexpr("struct")) || - string_match(lexeme, string_u8_litexpr("union")) || - string_match(lexeme, string_u8_litexpr("enum"))){ + else if (state->do_cpp_parse){ + if (token->sub_kind == TokenCppKind_Struct || + token->sub_kind == TokenCppKind_Union || + token->sub_kind == TokenCppKind_Enum){ cpp_parse_type_structure(index, state, 0); } - else if (string_match(lexeme, string_u8_litexpr("typedef"))){ + else if (token->sub_kind == TokenCppKind_Typedef){ cpp_parse_type_def(index, state, 0); } + else if (token->sub_kind == TokenCppKind_Identifier){ + cpp_parse_function(index, state, 0); + } else{ generic_parse_inc(state); } - } else{ generic_parse_inc(state); diff --git a/custom/4coder_code_index.h b/custom/4coder_code_index.h index 71962556..3e75c258 100644 --- a/custom/4coder_code_index.h +++ b/custom/4coder_code_index.h @@ -46,6 +46,7 @@ enum{ CodeIndexNote_Type, CodeIndexNote_Function, CodeIndexNote_Macro, + CodeIndexNote_4coderCommand, }; struct Code_Index_Note{ @@ -111,6 +112,8 @@ struct Generic_Parse_State{ i32 paren_counter; b32 in_preprocessor; b32 in_statement; + + b32 do_cpp_parse; }; #endif diff --git a/custom/4coder_code_index_listers.cpp b/custom/4coder_code_index_listers.cpp index 892de4e1..fdc24c24 100644 --- a/custom/4coder_code_index_listers.cpp +++ b/custom/4coder_code_index_listers.cpp @@ -9,12 +9,12 @@ struct Tiny_Jump{ i64 pos; }; -CUSTOM_UI_COMMAND_SIG(jump_to_type_definition) -CUSTOM_DOC("List all types in the code index and jump to one chosen by the user.") +CUSTOM_UI_COMMAND_SIG(jump_to_definition) +CUSTOM_DOC("List all definitions in the code index and jump to one chosen by the user.") { - char *query = "Type:"; + char *query = "Definition:"; - Scratch_Block scratch(app, Scratch_Share); + Scratch_Block scratch(app); Lister *lister = begin_lister(app, scratch); lister_set_query(lister, query); lister->handlers = lister_get_default_handlers(); @@ -30,7 +30,23 @@ CUSTOM_DOC("List all types in the code index and jump to one chosen by the user. Tiny_Jump *jump = push_array(scratch, Tiny_Jump, 1); jump->buffer = buffer; jump->pos = note->pos.first; - lister_add_item(lister, note->text, string_u8_litexpr("type"), jump, 0); + + String_Const_u8 sort = {}; + switch (note->note_kind){ + case CodeIndexNote_Type: + { + sort = string_u8_litexpr("type"); + }break; + case CodeIndexNote_Function: + { + sort = string_u8_litexpr("function"); + }break; + case CodeIndexNote_Macro: + { + sort = string_u8_litexpr("macro"); + }break; + } + lister_add_item(lister, note->text, sort, jump, 0); } } } diff --git a/custom/4coder_default_hooks.cpp b/custom/4coder_default_hooks.cpp index e9896dbb..1f696f93 100644 --- a/custom/4coder_default_hooks.cpp +++ b/custom/4coder_default_hooks.cpp @@ -182,6 +182,9 @@ default_tick(Application_Links *app, Frame_Info frame_info){ Generic_Parse_State state = {}; generic_parse_init(app, &arena, contents, &tokens, &state); + // TODO(allen): Actually determine this in a fair way. + // Maybe switch to an enum. + state.do_cpp_parse = true; generic_parse_full_input_breaks(index, &state, max_i32); code_index_lock(); diff --git a/custom/4coder_helper.cpp b/custom/4coder_helper.cpp index af8ad70f..831a8372 100644 --- a/custom/4coder_helper.cpp +++ b/custom/4coder_helper.cpp @@ -351,8 +351,8 @@ internal Range_Cursor get_line_range(Application_Links *app, Buffer_ID buffer, i64 line_number){ b32 success = false; Range_Cursor result = {}; - result.begin = get_line_start(app, buffer, line_number); - if (result.begin.line != 0){ + result.start = get_line_start(app, buffer, line_number); + if (result.start.line != 0){ result.end = get_line_end(app, buffer, line_number); if (result.end.line != 0){ success = true; @@ -369,15 +369,15 @@ internal Range_i64 get_line_pos_range(Application_Links *app, Buffer_ID buffer, i64 line_number){ Range_Cursor range = get_line_range(app, buffer, line_number); Range_i64 result = {}; - if (range.begin.line != 0 && range.end.line != 0){ - result = Ii64(range.begin.pos, range.end.pos); + if (range.start.line != 0 && range.end.line != 0){ + result = Ii64(range.start.pos, range.end.pos); } return(result); } internal Range_i64 make_range_from_cursors(Range_Cursor range){ - return(Ii64(range.begin.pos, range.end.pos)); + return(Ii64(range.start.pos, range.end.pos)); } internal i64 diff --git a/custom/4coder_types.h b/custom/4coder_types.h index 184fa6f5..8d2b179a 100644 --- a/custom/4coder_types.h +++ b/custom/4coder_types.h @@ -358,10 +358,6 @@ struct Range_Cursor{ Buffer_Cursor min; Buffer_Cursor max; }; - struct{ - Buffer_Cursor begin; - Buffer_Cursor end; - }; struct{ Buffer_Cursor start; Buffer_Cursor end; diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index ced8e98c..836c98df 100644 --- a/custom/generated/command_metadata.h +++ b/custom/generated/command_metadata.h @@ -75,7 +75,7 @@ CUSTOM_COMMAND_SIG(interactive_new); CUSTOM_COMMAND_SIG(interactive_open); CUSTOM_COMMAND_SIG(interactive_open_or_new); CUSTOM_COMMAND_SIG(interactive_switch_buffer); -CUSTOM_COMMAND_SIG(jump_to_type_definition); +CUSTOM_COMMAND_SIG(jump_to_definition); CUSTOM_COMMAND_SIG(keyboard_macro_finish_recording); CUSTOM_COMMAND_SIG(keyboard_macro_replay); CUSTOM_COMMAND_SIG(keyboard_macro_start_recording); @@ -316,7 +316,7 @@ static Command_Metadata fcoder_metacmd_table[228] = { { PROC_LINKS(interactive_open, 0), true, "interactive_open", 16, "Interactively opens a file.", 27, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 634 }, { PROC_LINKS(interactive_open_or_new, 0), true, "interactive_open_or_new", 23, "Interactively open a file out of the file system.", 49, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 563 }, { PROC_LINKS(interactive_switch_buffer, 0), true, "interactive_switch_buffer", 25, "Interactively switch to an open buffer.", 39, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 505 }, -{ PROC_LINKS(jump_to_type_definition, 0), true, "jump_to_type_definition", 23, "List all types in the code index and jump to one chosen by the user.", 68, "w:\\4ed\\code\\custom\\4coder_code_index_listers.cpp", 48, 12 }, +{ PROC_LINKS(jump_to_definition, 0), true, "jump_to_definition", 18, "List all definitions in the code index and jump to one chosen by the user.", 74, "w:\\4ed\\code\\custom\\4coder_code_index_listers.cpp", 48, 12 }, { PROC_LINKS(keyboard_macro_finish_recording, 0), false, "keyboard_macro_finish_recording", 31, "Stop macro recording, do nothing if macro recording is not already started", 74, "w:\\4ed\\code\\custom\\4coder_keyboard_macro.cpp", 44, 57 }, { PROC_LINKS(keyboard_macro_replay, 0), false, "keyboard_macro_replay", 21, "Replay the most recently recorded keyboard macro", 48, "w:\\4ed\\code\\custom\\4coder_keyboard_macro.cpp", 44, 80 }, { PROC_LINKS(keyboard_macro_start_recording, 0), false, "keyboard_macro_start_recording", 30, "Start macro recording, do nothing if macro recording is already started", 71, "w:\\4ed\\code\\custom\\4coder_keyboard_macro.cpp", 44, 44 }, @@ -459,7 +459,7 @@ static Command_Metadata fcoder_metacmd_table[228] = { { PROC_LINKS(toggle_mouse, 0), false, "toggle_mouse", 12, "Toggles the mouse suppression mode, see suppress_mouse and allow_mouse.", 71, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 415 }, { PROC_LINKS(toggle_paren_matching_helper, 0), false, "toggle_paren_matching_helper", 28, "In code files matching parentheses pairs are colored with distinguishing colors.", 80, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 445 }, { PROC_LINKS(toggle_show_whitespace, 0), false, "toggle_show_whitespace", 22, "Toggles the current buffer's whitespace visibility status.", 58, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 712 }, -{ PROC_LINKS(toggle_virtual_whitespace, 0), false, "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "w:\\4ed\\code\\custom\\4coder_code_index.cpp", 40, 1098 }, +{ PROC_LINKS(toggle_virtual_whitespace, 0), false, "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "w:\\4ed\\code\\custom\\4coder_code_index.cpp", 40, 1122 }, { PROC_LINKS(tutorial_maximize, 0), false, "tutorial_maximize", 17, "Expand the tutorial window", 26, "w:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 20 }, { PROC_LINKS(tutorial_minimize, 0), false, "tutorial_minimize", 17, "Shrink the tutorial window", 26, "w:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 34 }, { PROC_LINKS(uncomment_line, 0), false, "uncomment_line", 14, "If present, delete '//' at the beginning of the line after leading whitespace.", 78, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 137 }, @@ -545,7 +545,7 @@ static i32 fcoder_metacmd_ID_interactive_new = 62; static i32 fcoder_metacmd_ID_interactive_open = 63; static i32 fcoder_metacmd_ID_interactive_open_or_new = 64; static i32 fcoder_metacmd_ID_interactive_switch_buffer = 65; -static i32 fcoder_metacmd_ID_jump_to_type_definition = 66; +static i32 fcoder_metacmd_ID_jump_to_definition = 66; static i32 fcoder_metacmd_ID_keyboard_macro_finish_recording = 67; static i32 fcoder_metacmd_ID_keyboard_macro_replay = 68; static i32 fcoder_metacmd_ID_keyboard_macro_start_recording = 69;