diff --git a/custom/4coder_combined_write_commands.cpp b/custom/4coder_combined_write_commands.cpp index eb10adf8..5b95af14 100644 --- a/custom/4coder_combined_write_commands.cpp +++ b/custom/4coder_combined_write_commands.cpp @@ -172,10 +172,8 @@ static Snippet default_snippets[] = { {"forj", "for (j = 0; j < ; j += 1){\n\n}\n", 5, 16}, {"fork", "for (k = 0; k < ; k += 1){\n\n}\n", 5, 16}, {"for", "for (;;){\n\n}\n", 5, 10}, - {"case", "case :\n{\n\n}break;\n", 5, 9}, {"///", "////////////////////////////////", 32, 32}, {"#guard", "#if !defined(Z)\n#define Z\n#endif\n", 0, 26}, - {"space", "char space[256];", 0, 14}, {"op+", "Z\noperator+(Z a, Z b){\n,\n}\n", 0, 23}, {"op-", "Z\noperator-(Z a, Z b){\n,\n}\n", 0, 23}, diff --git a/custom/4coder_default_framework.cpp b/custom/4coder_default_framework.cpp index 44c18e5d..90da0819 100644 --- a/custom/4coder_default_framework.cpp +++ b/custom/4coder_default_framework.cpp @@ -448,8 +448,9 @@ default_4coder_initialize(Application_Links *app, String_Const_u8_Array file_nam view_ui_data = managed_id_declare(app, SCu8("DEFAULT.ui_data" )); view_highlight_range = managed_id_declare(app, SCu8("DEFAULT.highlight" )); view_highlight_buffer = managed_id_declare(app, SCu8("DEFAULT.highlight_buf" )); - view_render_hook = managed_id_declare(app, SCu8("DEFAULT.render" )); - view_call_next = managed_id_declare(app, SCu8("DEFAULT.call_next" )); + view_render_hook = managed_id_declare(app, SCu8("DEFAULT.render" )); + view_call_next = managed_id_declare(app, SCu8("DEFAULT.call_next" )); + view_word_complete_menu = managed_id_declare(app, SCu8("DEFAULT.word_complete_menu")); buffer_map_id = managed_id_declare(app, SCu8("DEFAULT.buffer_map_id" )); buffer_eol_setting = managed_id_declare(app, SCu8("DEFAULT.buffer_eol_setting")); diff --git a/custom/4coder_default_framework_variables.cpp b/custom/4coder_default_framework_variables.cpp index 61f538b5..3b84f3bc 100644 --- a/custom/4coder_default_framework_variables.cpp +++ b/custom/4coder_default_framework_variables.cpp @@ -41,6 +41,7 @@ global Managed_ID view_highlight_range = 0; global Managed_ID view_highlight_buffer = 0; global Managed_ID view_render_hook = 0; global Managed_ID view_call_next = 0; +global Managed_ID view_word_complete_menu = 0; global Managed_ID buffer_map_id = 0; global Managed_ID buffer_eol_setting = 0; diff --git a/custom/4coder_draw.cpp b/custom/4coder_draw.cpp index eb3346f8..c496e1d3 100644 --- a/custom/4coder_draw.cpp +++ b/custom/4coder_draw.cpp @@ -25,13 +25,13 @@ get_margin_color(i32 level){ return(margin); } -internal Vec2_f32 +function Vec2_f32 draw_string(Application_Links *app, Face_ID font_id, String_Const_u8 string, Vec2_f32 p, FColor color){ return(draw_string_oriented(app, font_id, color, string, p, 0, V2(1.f, 0.f))); } -internal void +function void draw_margin(Application_Links *app, Rect_f32 outer, Rect_f32 inner, FColor color){ draw_rectangle(app, Rf32(outer.x0, outer.y0, outer.x1, inner.y0), 0.f, color); draw_rectangle(app, Rf32(outer.x0, inner.y1, outer.x1, outer.y1), 0.f, color); @@ -39,14 +39,14 @@ draw_margin(Application_Links *app, Rect_f32 outer, Rect_f32 inner, FColor color draw_rectangle(app, Rf32(inner.x1, inner.y0, outer.x1, inner.y1), 0.f, color); } -internal void +function void draw_character_block(Application_Links *app, Text_Layout_ID layout, i64 pos, f32 roundness, FColor color){ Rect_f32 rect = text_layout_character_on_screen(app, layout, pos); draw_rectangle(app, rect, roundness, color); } -internal void +function void draw_character_block(Application_Links *app, Text_Layout_ID layout, Range_i64 range, f32 roundness, FColor color){ if (range.first < range.one_past_last){ @@ -82,14 +82,14 @@ draw_character_block(Application_Links *app, Text_Layout_ID layout, Range_i64 ra } } -internal void +function void draw_character_wire_frame(Application_Links *app, Text_Layout_ID layout, i64 pos, f32 roundness, f32 thickness, FColor color){ Rect_f32 rect = text_layout_character_on_screen(app, layout, pos); draw_rectangle_outline(app, rect, roundness, thickness, color); } -internal void +function void draw_character_wire_frame(Application_Links *app, Text_Layout_ID layout, Range_i64 range, f32 roundness, f32 thickness, FColor color){ @@ -98,7 +98,7 @@ draw_character_wire_frame(Application_Links *app, Text_Layout_ID layout, } } -internal void +function void draw_character_i_bar(Application_Links *app, Text_Layout_ID layout, i64 pos, FColor color){ Rect_f32 rect = text_layout_character_on_screen(app, layout, pos); @@ -106,7 +106,7 @@ draw_character_i_bar(Application_Links *app, Text_Layout_ID layout, i64 pos, draw_rectangle(app, rect, 0.f, color); } -internal void +function void draw_line_highlight(Application_Links *app, Text_Layout_ID layout, Range_i64 line_range, FColor color){ Range_f32 y1 = text_layout_line_on_screen(app, layout, line_range.min); @@ -118,13 +118,13 @@ draw_line_highlight(Application_Links *app, Text_Layout_ID layout, } } -internal void +function void draw_line_highlight(Application_Links *app, Text_Layout_ID layout, i64 line, FColor color){ draw_line_highlight(app, layout, Ii64(line), color); } -internal void +function void paint_text_color_pos(Application_Links *app, Text_Layout_ID layout, i64 pos, FColor color){ paint_text_color(app, layout, Ii64(pos, pos + 1), color); @@ -462,7 +462,7 @@ draw_comment_highlights(Application_Links *app, Buffer_ID buffer, Text_Layout_ID } } -internal Range_i64_Array +function Range_i64_Array get_enclosure_ranges(Application_Links *app, Arena *arena, Buffer_ID buffer, i64 pos, u32 flags){ Range_i64_Array array = {}; i32 max = 100; @@ -674,7 +674,7 @@ draw_notepad_style_cursor_highlight(Application_Links *app, View_ID view_id, //////////////////////////////// function Rect_f32 -get_tool_tip_box(Rect_f32 container, Vec2_f32 p, Vec2_f32 box_dims){ +get_contained_box_near_point(Rect_f32 container, Vec2_f32 p, Vec2_f32 box_dims){ Vec2_f32 container_dims = rect_dim(container); box_dims.x = clamp_top(box_dims.x, container_dims.x); box_dims.y = clamp_top(box_dims.y, container_dims.y); @@ -699,7 +699,11 @@ draw_tool_tip(Application_Links *app, Face_ID face, Fancy_Block *block, if (block->line_count > 0){ Vec2_f32 dims = get_fancy_block_dim(app, face, block); dims += V2f32(x_padding, 2.f); - box = get_tool_tip_box(region, p, dims); + box = get_contained_box_near_point(region, p, dims); + box.x0 = f32_round32(box.x0); + box.y0 = f32_round32(box.y0); + box.x1 = f32_round32(box.x1); + box.y1 = f32_round32(box.y1); Rect_f32 prev_clip = draw_set_clip(app, box); draw_rectangle(app, box, 6.f, back_color); draw_fancy_block(app, face, fcolor_zero(), block, @@ -709,5 +713,28 @@ draw_tool_tip(Application_Links *app, Face_ID face, Fancy_Block *block, return(box); } +function Rect_f32 +draw_drop_down(Application_Links *app, Face_ID face, Fancy_Block *block, + Vec2_f32 p, Rect_f32 region, f32 x_padding, f32 x_half_padding, + FColor outline_color, FColor back_color){ + Rect_f32 box = Rf32(p, p); + if (block->line_count > 0){ + Vec2_f32 dims = get_fancy_block_dim(app, face, block); + dims += V2f32(x_padding, 4.f); + box = get_contained_box_near_point(region, p, dims); + box.x0 = f32_round32(box.x0); + box.y0 = f32_round32(box.y0); + box.x1 = f32_round32(box.x1); + box.y1 = f32_round32(box.y1); + Rect_f32 prev_clip = draw_set_clip(app, box); + draw_rectangle(app, box, 0.f, back_color); + draw_margin(app, box, rect_inner(box, 1.f), outline_color); + draw_fancy_block(app, face, fcolor_zero(), block, + box.p0 + V2f32(x_half_padding, 2.f)); + draw_set_clip(app, prev_clip); + } + return(box); +} + // BOTTOM diff --git a/custom/4coder_fancy.cpp b/custom/4coder_fancy.cpp index 2fe210f4..344dce7f 100644 --- a/custom/4coder_fancy.cpp +++ b/custom/4coder_fancy.cpp @@ -727,8 +727,12 @@ global FColor f_light_gray = fcolor_argb(0.7f, 0.7f, 0.7f, 1.0f); global FColor f_gray = fcolor_argb(0.5f, 0.5f, 0.5f, 1.0f); global FColor f_dark_gray = fcolor_argb(0.3f, 0.3f, 0.3f, 1.0f); global FColor f_black = fcolor_argb(0.0f, 0.0f, 0.0f, 1.0f); -global FColor f_pink = fcolor_argb(1.0f, 0.0f, 1.0f, 1.0f); +global FColor f_red = fcolor_argb(1.0f, 0.0f, 0.0f, 1.0f); global FColor f_green = fcolor_argb(0.0f, 1.0f, 0.0f, 1.0f); +global FColor f_blue = fcolor_argb(0.0f, 0.0f, 1.0f, 1.0f); +global FColor f_yellow = fcolor_argb(1.0f, 1.0f, 0.0f, 1.0f); +global FColor f_pink = fcolor_argb(1.0f, 0.0f, 1.0f, 1.0f); +global FColor f_cyan = fcolor_argb(0.0f, 1.0f, 1.0f, 1.0f); // BOTTOM diff --git a/custom/4coder_lister_base.cpp b/custom/4coder_lister_base.cpp index 26b72389..53d1b3c3 100644 --- a/custom/4coder_lister_base.cpp +++ b/custom/4coder_lister_base.cpp @@ -452,7 +452,7 @@ run_lister(Application_Links *app, Lister *lister){ lister->filter_restore_point = begin_temp(lister->arena); lister_update_filtered_list(app, lister); - View_ID view = get_this_ctx_view(app, Access_Always);; + View_ID view = get_this_ctx_view(app, Access_Always); View_Context ctx = view_current_context(app, view); ctx.render_caller = lister_render; ctx.hides_buffer = true; diff --git a/custom/4coder_search.cpp b/custom/4coder_search.cpp index 736a494d..16a25580 100644 --- a/custom/4coder_search.cpp +++ b/custom/4coder_search.cpp @@ -5,10 +5,6 @@ and list all locations. // TOP -// -// Search Iteration Systems -// - global String_Const_u8 search_name = string_u8_litexpr("*search*"); internal void @@ -305,49 +301,39 @@ word_complete_list_extend_from_raw(Application_Links *app, Arena *arena, } } -internal Word_Complete_Iterator -get_word_complete_it(Application_Links *app, Arena *arena, - Buffer_ID buffer, Range_i64 range){ - Base_Allocator *allocator = get_base_allocator_system(); - - Scratch_Block scratch(app); - String_Const_u8 needle = push_buffer_range(app, arena, buffer, range); - String_Match_List list = get_complete_list_raw(app, scratch, buffer, range, needle); - - Word_Complete_Iterator it = {}; - it.app = app; - it.arena = arena; - it.arena_restore = begin_temp(arena); - it.first_buffer = buffer; - it.current_buffer = buffer; - it.needle = needle; - - it.already_used_table = make_table_Data_u64(allocator, 100); - word_complete_list_extend_from_raw(app, arena, - &list, &it.list, &it.already_used_table); - return(it); -} - function void -word_complete_it_release(Word_Complete_Iterator *it){ - if (it->arena != 0){ - end_temp(it->arena_restore); - table_clear(&it->already_used_table); +word_complete_iter_init(Buffer_ID buffer, Range_i64 range, Word_Complete_Iterator *iter){ + if (iter->app != 0 && iter->arena != 0){ + Base_Allocator *allocator = get_base_allocator_system(); + + Application_Links *app = iter->app; + Arena *arena = iter->arena; + + if (iter->already_used_table.allocator != 0){ + end_temp(iter->arena_restore); + table_clear(&iter->already_used_table); + } + + block_zero_struct(iter); + iter->app = app; + iter->arena = arena; + + Scratch_Block scratch(app); + String_Const_u8 needle = push_buffer_range(app, arena, buffer, range); + String_Match_List list = get_complete_list_raw(app, scratch, buffer, range, needle); + + iter->arena_restore = begin_temp(arena); + iter->first_buffer = buffer; + iter->current_buffer = buffer; + iter->needle = needle; + + iter->already_used_table = make_table_Data_u64(allocator, 100); + word_complete_list_extend_from_raw(app, arena, &list, &iter->list, &iter->already_used_table); } } -function Word_Complete_State -get_word_complete_state(Application_Links *app, Arena *arena, - Buffer_ID buffer, Range_i64 needle_range){ - Word_Complete_State state = {}; - state.initialized = true; - state.range = needle_range; - state.it = get_word_complete_it(app, arena, buffer, needle_range); - return(state); -} - function void -word_complete_it_next(Word_Complete_Iterator *it){ +word_complete_iter_next(Word_Complete_Iterator *it){ for (;;){ if (it->node == 0){ it->node = it->list.first; @@ -377,7 +363,7 @@ word_complete_it_next(Word_Complete_Iterator *it){ } function String_Const_u8 -word_complete_it_read(Word_Complete_Iterator *it){ +word_complete_iter_read(Word_Complete_Iterator *it){ String_Const_u8 result = {}; if (it->node == 0){ result = it->needle; @@ -388,6 +374,24 @@ word_complete_it_read(Word_Complete_Iterator *it){ return(result); } + +function b32 +word_complete_iter_is_at_base_slot(Word_Complete_Iterator *it){ + return(it->node == 0); +} + +function Word_Complete_Iterator* +word_complete_get_shared_iter(Application_Links *app){ + local_persist Arena *completion_arena = {}; + local_persist Word_Complete_Iterator it = {}; + if (completion_arena == 0){ + completion_arena = reserve_arena(app); + } + it.app = app; + it.arena = completion_arena; + return(&it); +} + CUSTOM_COMMAND_SIG(word_complete) CUSTOM_DOC("Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.") { @@ -407,38 +411,247 @@ CUSTOM_DOC("Iteratively tries completing the word to the left of the cursor with Rewrite_Type *next_rewrite = scope_attachment(app, scope, view_next_rewrite_loc, Rewrite_Type); *next_rewrite = Rewrite_WordComplete; - local_persist Arena *completion_arena = {}; - if (completion_arena == 0){ - completion_arena = reserve_arena(app); - } - local_persist Word_Complete_State state = {}; + Word_Complete_Iterator *it = word_complete_get_shared_iter(app); + local_persist b32 initialized = false; + local_persist Range_i64 range = {}; - if (first_completion || !state.initialized){ + if (first_completion || !initialized){ ProfileBlock(app, "word complete state init"); - word_complete_it_release(&state.it); - block_zero_struct(&state); - i64 pos = view_get_cursor_pos(app, view); Range_i64 needle_range = get_word_complete_needle_range(app, buffer, pos); if (range_size(needle_range) > 0){ - state = get_word_complete_state(app, completion_arena, buffer, - needle_range); + initialized = true; + range = needle_range; + word_complete_iter_init(buffer, needle_range, it); } } - if (state.initialized){ + if (initialized){ ProfileBlock(app, "word complete apply"); - word_complete_it_next(&state.it); - String_Const_u8 str = word_complete_it_read(&state.it); + word_complete_iter_next(it); + String_Const_u8 str = word_complete_iter_read(it); - buffer_replace_range(app, buffer, state.range, str); + buffer_replace_range(app, buffer, range, str); - state.range.max = state.range.min + str.size; - view_set_cursor_and_preferred_x(app, view, seek_pos(state.range.max)); + range.max = range.min + str.size; + view_set_cursor_and_preferred_x(app, view, seek_pos(range.max)); + } + } +} + +function Word_Complete_Menu +make_word_complete_menu(Render_Caller_Function *prev_render_caller, Word_Complete_Iterator *it){ + Word_Complete_Menu menu = {}; + menu.prev_render_caller = prev_render_caller; + menu.it = it; + return(menu); +} + +function void +word_complete_menu_next(Word_Complete_Menu *menu){ + i32 count = 0; + for (i32 i = 0; i < ArrayCount(menu->options); i += 1){ + word_complete_iter_next(menu->it); + if (word_complete_iter_is_at_base_slot(menu->it)){ + break; + } + else{ + menu->options[i] = word_complete_iter_read(menu->it); + count += 1; + } + } + menu->count = count; +} + +function void +word_complete_menu_render(Application_Links *app, Frame_Info frame_info, View_ID view){ + Managed_Scope scope = view_get_managed_scope(app, view); + Word_Complete_Menu **menu_ptr = scope_attachment(app, scope, view_word_complete_menu, Word_Complete_Menu*); + Word_Complete_Menu *menu = *menu_ptr; + + if (menu != 0){ + menu->prev_render_caller(app, frame_info, view); + + Buffer_ID buffer = view_get_buffer(app, view, Access_Always); + Face_ID face = get_face_id(app, buffer); + + Scratch_Block scratch(app); + + Fancy_Block block = {}; + for (i32 i = 0; i < menu->count; i += 1){ + if (menu->options[i].size > 0){ + Fancy_Line *line = push_fancy_line(scratch, &block, face); + push_fancy_stringf(scratch, line, fcolor_id(Stag_Pop1), "F%d:", i + 1); + push_fancy_string(scratch, line, fcolor_id(Stag_Default), menu->options[i]); + } + } + + Rect_f32 region = view_get_buffer_region(app, view); + + Buffer_Scroll scroll = view_get_buffer_scroll(app, view); + Buffer_Point buffer_point = scroll.position; + i64 pos = view_get_cursor_pos(app, view); + Vec2_f32 cursor_p = view_relative_xy_of_pos(app, view, buffer_point.line_number, pos); + cursor_p -= buffer_point.pixel_shift; + cursor_p += region.p0; + + Face_Metrics metrics = get_face_metrics(app, face); + f32 x_padding = metrics.normal_advance; + f32 x_half_padding = x_padding*0.5f; + + draw_drop_down(app, face, &block, cursor_p, region, x_padding, x_half_padding, + fcolor_id(Stag_Margin_Hover), fcolor_id(Stag_Back)); + } +} + +function Edit +get_word_complete_from_user_drop_down(Application_Links *app){ + View_ID view = get_this_ctx_view(app, Access_Always); + View_Context ctx = view_current_context(app, view); + Render_Caller_Function *prev_render_caller = ctx.render_caller; + ctx.render_caller = word_complete_menu_render; + view_push_context(app, view, &ctx); + + Edit result = {}; + + Word_Complete_Iterator *it = word_complete_get_shared_iter(app); + + i64 pos = view_get_cursor_pos(app, view); + Buffer_ID buffer = view_get_buffer(app, view, Access_ReadWriteVisible); + Range_i64 range = get_word_complete_needle_range(app, buffer, pos); + if (range_size(range) != 0){ + word_complete_iter_init(buffer, range, it); + Word_Complete_Menu menu = make_word_complete_menu(prev_render_caller, it); + word_complete_menu_next(&menu); + + Managed_Scope scope = view_get_managed_scope(app, view); + Word_Complete_Menu **menu_ptr = scope_attachment(app, scope, view_word_complete_menu, Word_Complete_Menu*); + *menu_ptr = &menu; + + b32 keep_looping_menu = true; + for (;keep_looping_menu;){ + User_Input in = get_next_input(app, EventPropertyGroup_Any, + EventProperty_Escape); + if (in.abort){ + break; + } + + b32 handled = true; + switch (in.event.kind){ + case InputEventKind_TextInsert: + { + write_text_input(app); + pos = view_get_cursor_pos(app, view); + range = get_word_complete_needle_range(app, buffer, pos); + if (range_size(range) == 0){ + keep_looping_menu = false; + } + else{ + word_complete_iter_init(buffer, range, it); + menu = make_word_complete_menu(prev_render_caller, it); + word_complete_menu_next(&menu); + if (menu.count == 0){ + keep_looping_menu = false; + } + } + }break; + + case InputEventKind_KeyStroke: + { + switch (in.event.key.code){ + case KeyCode_Return: + { + result.text = menu.options[0]; + result.range = range; + keep_looping_menu = false; + }break; + + case KeyCode_Tab: + { + word_complete_menu_next(&menu); + }break; + + case KeyCode_F1: + case KeyCode_F2: + case KeyCode_F3: + case KeyCode_F4: + case KeyCode_F5: + case KeyCode_F6: + case KeyCode_F7: + case KeyCode_F8: + { + i32 index = (in.event.key.code - KeyCode_F1); + result.text = menu.options[index]; + result.range = range; + keep_looping_menu = false; + }break; + + case KeyCode_Backspace: + { + backspace_char(app); + pos = view_get_cursor_pos(app, view); + range = get_word_complete_needle_range(app, buffer, pos); + if (range_size(range) == 0){ + keep_looping_menu = false; + } + else{ + word_complete_iter_init(buffer, range, it); + menu = make_word_complete_menu(prev_render_caller, it); + word_complete_menu_next(&menu); + if (menu.count == 0){ + keep_looping_menu = false; + } + } + }break; + + default: + { + leave_current_input_unhandled(app); + }break; + } + }break; + + case InputEventKind_MouseButton: + { + leave_current_input_unhandled(app); + keep_looping_menu = false; + }break; + + default: + { + handled = false; + }break; + } + + if (!handled){ + leave_current_input_unhandled(app); + } + } + + scope = view_get_managed_scope(app, view); + menu_ptr = scope_attachment(app, scope, view_word_complete_menu, Word_Complete_Menu*); + *menu_ptr = 0; + + view_pop_context(app, view); + } + + return(result); +} + +CUSTOM_COMMAND_SIG(word_complete_drop_down) +CUSTOM_DOC("Word complete with drop down menu.") +{ + View_ID view = get_active_view(app, Access_ReadWriteVisible); + Buffer_ID buffer = view_get_buffer(app, view, Access_ReadWriteVisible); + if (buffer != 0){ + Edit edit = get_word_complete_from_user_drop_down(app); + if (edit.text.size > 0){ + buffer_replace_range(app, buffer, edit.range, edit.text); + view_set_cursor_and_preferred_x(app, view, seek_pos(edit.range.min + edit.text.size)); } } } diff --git a/custom/4coder_search.h b/custom/4coder_search.h index 872d33d2..2da0dd8b 100644 --- a/custom/4coder_search.h +++ b/custom/4coder_search.h @@ -16,6 +16,7 @@ enum{ struct Word_Complete_Iterator{ Application_Links *app; Arena *arena; + Temp_Memory arena_restore; Buffer_ID first_buffer; Buffer_ID current_buffer; @@ -26,10 +27,11 @@ struct Word_Complete_Iterator{ Table_Data_u64 already_used_table; }; -struct Word_Complete_State{ - b32 initialized; - Range_i64 range; - Word_Complete_Iterator it; +struct Word_Complete_Menu{ + Render_Caller_Function *prev_render_caller; + Word_Complete_Iterator *it; + String_Const_u8 options[8]; + i32 count; }; #endif diff --git a/custom/4coder_types.h b/custom/4coder_types.h index fc410da5..a1c90ef0 100644 --- a/custom/4coder_types.h +++ b/custom/4coder_types.h @@ -95,7 +95,7 @@ enum{ struct Buffer_Point{ i64 line_number; - Vec2 pixel_shift; + Vec2_f32 pixel_shift; }; struct Line_Shift_Vertical{ diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index 78b00ce6..4d5dc2c5 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 213 +#define command_one_past_last_id 214 #if defined(CUSTOM_COMMAND_SIG) #define PROC_LINKS(x,y) x #else @@ -153,6 +153,7 @@ CUSTOM_COMMAND_SIG(list_all_locations_of_selection_case_insensitive); CUSTOM_COMMAND_SIG(list_all_locations_of_type_definition); CUSTOM_COMMAND_SIG(list_all_locations_of_type_definition_of_identifier); CUSTOM_COMMAND_SIG(word_complete); +CUSTOM_COMMAND_SIG(word_complete_drop_down); CUSTOM_COMMAND_SIG(goto_jump_at_cursor); CUSTOM_COMMAND_SIG(goto_jump_at_cursor_same_panel); CUSTOM_COMMAND_SIG(goto_next_jump); @@ -234,7 +235,7 @@ char *source_name; i32 source_name_len; i32 line_number; }; -static Command_Metadata fcoder_metacmd_table[213] = { +static Command_Metadata fcoder_metacmd_table[214] = { { PROC_LINKS(default_view_input_handler, 0), false, "default_view_input_handler", 26, "Input consumption loop for default view behavior", 48, "w:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 57 }, { PROC_LINKS(profile_enable, 0), false, "profile_enable", 14, "Allow 4coder's self profiler to gather new profiling information.", 65, "w:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 207 }, { PROC_LINKS(profile_disable, 0), false, "profile_disable", 15, "Prevent 4coder's self profiler from gathering new profiling information.", 72, "w:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 214 }, @@ -368,17 +369,18 @@ static Command_Metadata fcoder_metacmd_table[213] = { { 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, 377 }, { 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, 387 }, { PROC_LINKS(write_text_and_auto_indent, 0), false, "write_text_and_auto_indent", 26, "Inserts text and auto-indents the line on which the cursor sits if any of the text contains 'layout punctuation' such as ;:{}()[]# and new lines.", 145, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 397 }, -{ PROC_LINKS(list_all_locations, 0), false, "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 166 }, -{ PROC_LINKS(list_all_substring_locations, 0), false, "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 172 }, -{ PROC_LINKS(list_all_locations_case_insensitive, 0), false, "list_all_locations_case_insensitive", 35, "Queries the user for a string and lists all exact case-insensitive matches found in all open buffers.", 101, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 178 }, -{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), false, "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 184 }, -{ PROC_LINKS(list_all_locations_of_identifier, 0), false, "list_all_locations_of_identifier", 32, "Reads a token or word under the cursor and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 190 }, -{ PROC_LINKS(list_all_locations_of_identifier_case_insensitive, 0), false, "list_all_locations_of_identifier_case_insensitive", 49, "Reads a token or word under the cursor and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 196 }, -{ PROC_LINKS(list_all_locations_of_selection, 0), false, "list_all_locations_of_selection", 31, "Reads the string in the selected range and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 202 }, -{ PROC_LINKS(list_all_locations_of_selection_case_insensitive, 0), false, "list_all_locations_of_selection_case_insensitive", 48, "Reads the string in the selected range and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 208 }, -{ PROC_LINKS(list_all_locations_of_type_definition, 0), false, "list_all_locations_of_type_definition", 37, "Queries user for string, lists all locations of strings that appear to define a type whose name matches the input string.", 121, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 214 }, -{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), false, "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 222 }, -{ PROC_LINKS(word_complete, 0), false, "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 391 }, +{ PROC_LINKS(list_all_locations, 0), false, "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 162 }, +{ PROC_LINKS(list_all_substring_locations, 0), false, "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 168 }, +{ PROC_LINKS(list_all_locations_case_insensitive, 0), false, "list_all_locations_case_insensitive", 35, "Queries the user for a string and lists all exact case-insensitive matches found in all open buffers.", 101, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 174 }, +{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), false, "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 180 }, +{ PROC_LINKS(list_all_locations_of_identifier, 0), false, "list_all_locations_of_identifier", 32, "Reads a token or word under the cursor and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 186 }, +{ PROC_LINKS(list_all_locations_of_identifier_case_insensitive, 0), false, "list_all_locations_of_identifier_case_insensitive", 49, "Reads a token or word under the cursor and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 192 }, +{ PROC_LINKS(list_all_locations_of_selection, 0), false, "list_all_locations_of_selection", 31, "Reads the string in the selected range and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 198 }, +{ PROC_LINKS(list_all_locations_of_selection_case_insensitive, 0), false, "list_all_locations_of_selection_case_insensitive", 48, "Reads the string in the selected range and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 204 }, +{ PROC_LINKS(list_all_locations_of_type_definition, 0), false, "list_all_locations_of_type_definition", 37, "Queries user for string, lists all locations of strings that appear to define a type whose name matches the input string.", 121, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 210 }, +{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), false, "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 218 }, +{ PROC_LINKS(word_complete, 0), false, "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 395 }, +{ PROC_LINKS(word_complete_drop_down, 0), false, "word_complete_drop_down", 23, "Word complete with drop down menu.", 34, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 645 }, { PROC_LINKS(goto_jump_at_cursor, 0), false, "goto_jump_at_cursor", 19, "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\\custom\\4coder_jump_sticky.cpp", 41, 346 }, { PROC_LINKS(goto_jump_at_cursor_same_panel, 0), false, "goto_jump_at_cursor_same_panel", 30, "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\\custom\\4coder_jump_sticky.cpp", 41, 373 }, { PROC_LINKS(goto_next_jump, 0), false, "goto_next_jump", 14, "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\\custom\\4coder_jump_sticky.cpp", 41, 462 }, @@ -438,7 +440,7 @@ static Command_Metadata fcoder_metacmd_table[213] = { { PROC_LINKS(comment_line, 0), false, "comment_line", 12, "Insert '//' at the beginning of the line after leading whitespace.", 66, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 125 }, { 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 }, { PROC_LINKS(comment_line_toggle, 0), false, "comment_line_toggle", 19, "Turns uncommented lines into commented lines and vice versa for comments starting with '//'.", 92, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 149 }, -{ PROC_LINKS(snippet_lister, 0), false, "snippet_lister", 14, "Opens a snippet lister for inserting whole pre-written snippets of text.", 72, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 239 }, +{ PROC_LINKS(snippet_lister, 0), false, "snippet_lister", 14, "Opens a snippet lister for inserting whole pre-written snippets of text.", 72, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 237 }, { PROC_LINKS(miblo_increment_basic, 0), false, "miblo_increment_basic", 21, "Increment an integer under the cursor by one.", 45, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 29 }, { PROC_LINKS(miblo_decrement_basic, 0), false, "miblo_decrement_basic", 21, "Decrement an integer under the cursor by one.", 45, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 44 }, { PROC_LINKS(miblo_increment_time_stamp, 0), false, "miblo_increment_time_stamp", 26, "Increment a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 231 }, @@ -593,73 +595,74 @@ static i32 fcoder_metacmd_ID_list_all_locations_of_selection_case_insensitive = static i32 fcoder_metacmd_ID_list_all_locations_of_type_definition = 141; static i32 fcoder_metacmd_ID_list_all_locations_of_type_definition_of_identifier = 142; static i32 fcoder_metacmd_ID_word_complete = 143; -static i32 fcoder_metacmd_ID_goto_jump_at_cursor = 144; -static i32 fcoder_metacmd_ID_goto_jump_at_cursor_same_panel = 145; -static i32 fcoder_metacmd_ID_goto_next_jump = 146; -static i32 fcoder_metacmd_ID_goto_prev_jump = 147; -static i32 fcoder_metacmd_ID_goto_next_jump_no_skips = 148; -static i32 fcoder_metacmd_ID_goto_prev_jump_no_skips = 149; -static i32 fcoder_metacmd_ID_goto_first_jump = 150; -static i32 fcoder_metacmd_ID_goto_first_jump_same_panel_sticky = 151; -static i32 fcoder_metacmd_ID_if_read_only_goto_position = 152; -static i32 fcoder_metacmd_ID_if_read_only_goto_position_same_panel = 153; -static i32 fcoder_metacmd_ID_view_jump_list_with_lister = 154; -static i32 fcoder_metacmd_ID_show_the_log_graph = 155; -static i32 fcoder_metacmd_ID_copy = 156; -static i32 fcoder_metacmd_ID_cut = 157; -static i32 fcoder_metacmd_ID_paste = 158; -static i32 fcoder_metacmd_ID_paste_next = 159; -static i32 fcoder_metacmd_ID_paste_and_indent = 160; -static i32 fcoder_metacmd_ID_paste_next_and_indent = 161; -static i32 fcoder_metacmd_ID_execute_previous_cli = 162; -static i32 fcoder_metacmd_ID_execute_any_cli = 163; -static i32 fcoder_metacmd_ID_build_search = 164; -static i32 fcoder_metacmd_ID_build_in_build_panel = 165; -static i32 fcoder_metacmd_ID_close_build_panel = 166; -static i32 fcoder_metacmd_ID_change_to_build_panel = 167; -static i32 fcoder_metacmd_ID_close_all_code = 168; -static i32 fcoder_metacmd_ID_open_all_code = 169; -static i32 fcoder_metacmd_ID_open_all_code_recursive = 170; -static i32 fcoder_metacmd_ID_load_project = 171; -static i32 fcoder_metacmd_ID_project_fkey_command = 172; -static i32 fcoder_metacmd_ID_project_go_to_root_directory = 173; -static i32 fcoder_metacmd_ID_setup_new_project = 174; -static i32 fcoder_metacmd_ID_setup_build_bat = 175; -static i32 fcoder_metacmd_ID_setup_build_sh = 176; -static i32 fcoder_metacmd_ID_setup_build_bat_and_sh = 177; -static i32 fcoder_metacmd_ID_project_command_lister = 178; -static i32 fcoder_metacmd_ID_list_all_functions_current_buffer = 179; -static i32 fcoder_metacmd_ID_list_all_functions_current_buffer_lister = 180; -static i32 fcoder_metacmd_ID_list_all_functions_all_buffers = 181; -static i32 fcoder_metacmd_ID_list_all_functions_all_buffers_lister = 182; -static i32 fcoder_metacmd_ID_select_surrounding_scope = 183; -static i32 fcoder_metacmd_ID_select_surrounding_scope_maximal = 184; -static i32 fcoder_metacmd_ID_select_next_scope_absolute = 185; -static i32 fcoder_metacmd_ID_select_next_scope_after_current = 186; -static i32 fcoder_metacmd_ID_select_prev_scope_absolute = 187; -static i32 fcoder_metacmd_ID_select_prev_top_most_scope = 188; -static i32 fcoder_metacmd_ID_place_in_scope = 189; -static i32 fcoder_metacmd_ID_delete_current_scope = 190; -static i32 fcoder_metacmd_ID_open_long_braces = 191; -static i32 fcoder_metacmd_ID_open_long_braces_semicolon = 192; -static i32 fcoder_metacmd_ID_open_long_braces_break = 193; -static i32 fcoder_metacmd_ID_if0_off = 194; -static i32 fcoder_metacmd_ID_write_todo = 195; -static i32 fcoder_metacmd_ID_write_hack = 196; -static i32 fcoder_metacmd_ID_write_note = 197; -static i32 fcoder_metacmd_ID_write_block = 198; -static i32 fcoder_metacmd_ID_write_zero_struct = 199; -static i32 fcoder_metacmd_ID_comment_line = 200; -static i32 fcoder_metacmd_ID_uncomment_line = 201; -static i32 fcoder_metacmd_ID_comment_line_toggle = 202; -static i32 fcoder_metacmd_ID_snippet_lister = 203; -static i32 fcoder_metacmd_ID_miblo_increment_basic = 204; -static i32 fcoder_metacmd_ID_miblo_decrement_basic = 205; -static i32 fcoder_metacmd_ID_miblo_increment_time_stamp = 206; -static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp = 207; -static i32 fcoder_metacmd_ID_miblo_increment_time_stamp_minute = 208; -static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp_minute = 209; -static i32 fcoder_metacmd_ID_profile_inspect = 210; -static i32 fcoder_metacmd_ID_default_startup = 211; -static i32 fcoder_metacmd_ID_default_try_exit = 212; +static i32 fcoder_metacmd_ID_word_complete_drop_down = 144; +static i32 fcoder_metacmd_ID_goto_jump_at_cursor = 145; +static i32 fcoder_metacmd_ID_goto_jump_at_cursor_same_panel = 146; +static i32 fcoder_metacmd_ID_goto_next_jump = 147; +static i32 fcoder_metacmd_ID_goto_prev_jump = 148; +static i32 fcoder_metacmd_ID_goto_next_jump_no_skips = 149; +static i32 fcoder_metacmd_ID_goto_prev_jump_no_skips = 150; +static i32 fcoder_metacmd_ID_goto_first_jump = 151; +static i32 fcoder_metacmd_ID_goto_first_jump_same_panel_sticky = 152; +static i32 fcoder_metacmd_ID_if_read_only_goto_position = 153; +static i32 fcoder_metacmd_ID_if_read_only_goto_position_same_panel = 154; +static i32 fcoder_metacmd_ID_view_jump_list_with_lister = 155; +static i32 fcoder_metacmd_ID_show_the_log_graph = 156; +static i32 fcoder_metacmd_ID_copy = 157; +static i32 fcoder_metacmd_ID_cut = 158; +static i32 fcoder_metacmd_ID_paste = 159; +static i32 fcoder_metacmd_ID_paste_next = 160; +static i32 fcoder_metacmd_ID_paste_and_indent = 161; +static i32 fcoder_metacmd_ID_paste_next_and_indent = 162; +static i32 fcoder_metacmd_ID_execute_previous_cli = 163; +static i32 fcoder_metacmd_ID_execute_any_cli = 164; +static i32 fcoder_metacmd_ID_build_search = 165; +static i32 fcoder_metacmd_ID_build_in_build_panel = 166; +static i32 fcoder_metacmd_ID_close_build_panel = 167; +static i32 fcoder_metacmd_ID_change_to_build_panel = 168; +static i32 fcoder_metacmd_ID_close_all_code = 169; +static i32 fcoder_metacmd_ID_open_all_code = 170; +static i32 fcoder_metacmd_ID_open_all_code_recursive = 171; +static i32 fcoder_metacmd_ID_load_project = 172; +static i32 fcoder_metacmd_ID_project_fkey_command = 173; +static i32 fcoder_metacmd_ID_project_go_to_root_directory = 174; +static i32 fcoder_metacmd_ID_setup_new_project = 175; +static i32 fcoder_metacmd_ID_setup_build_bat = 176; +static i32 fcoder_metacmd_ID_setup_build_sh = 177; +static i32 fcoder_metacmd_ID_setup_build_bat_and_sh = 178; +static i32 fcoder_metacmd_ID_project_command_lister = 179; +static i32 fcoder_metacmd_ID_list_all_functions_current_buffer = 180; +static i32 fcoder_metacmd_ID_list_all_functions_current_buffer_lister = 181; +static i32 fcoder_metacmd_ID_list_all_functions_all_buffers = 182; +static i32 fcoder_metacmd_ID_list_all_functions_all_buffers_lister = 183; +static i32 fcoder_metacmd_ID_select_surrounding_scope = 184; +static i32 fcoder_metacmd_ID_select_surrounding_scope_maximal = 185; +static i32 fcoder_metacmd_ID_select_next_scope_absolute = 186; +static i32 fcoder_metacmd_ID_select_next_scope_after_current = 187; +static i32 fcoder_metacmd_ID_select_prev_scope_absolute = 188; +static i32 fcoder_metacmd_ID_select_prev_top_most_scope = 189; +static i32 fcoder_metacmd_ID_place_in_scope = 190; +static i32 fcoder_metacmd_ID_delete_current_scope = 191; +static i32 fcoder_metacmd_ID_open_long_braces = 192; +static i32 fcoder_metacmd_ID_open_long_braces_semicolon = 193; +static i32 fcoder_metacmd_ID_open_long_braces_break = 194; +static i32 fcoder_metacmd_ID_if0_off = 195; +static i32 fcoder_metacmd_ID_write_todo = 196; +static i32 fcoder_metacmd_ID_write_hack = 197; +static i32 fcoder_metacmd_ID_write_note = 198; +static i32 fcoder_metacmd_ID_write_block = 199; +static i32 fcoder_metacmd_ID_write_zero_struct = 200; +static i32 fcoder_metacmd_ID_comment_line = 201; +static i32 fcoder_metacmd_ID_uncomment_line = 202; +static i32 fcoder_metacmd_ID_comment_line_toggle = 203; +static i32 fcoder_metacmd_ID_snippet_lister = 204; +static i32 fcoder_metacmd_ID_miblo_increment_basic = 205; +static i32 fcoder_metacmd_ID_miblo_decrement_basic = 206; +static i32 fcoder_metacmd_ID_miblo_increment_time_stamp = 207; +static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp = 208; +static i32 fcoder_metacmd_ID_miblo_increment_time_stamp_minute = 209; +static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp_minute = 210; +static i32 fcoder_metacmd_ID_profile_inspect = 211; +static i32 fcoder_metacmd_ID_default_startup = 212; +static i32 fcoder_metacmd_ID_default_try_exit = 213; #endif diff --git a/custom/generated/remapping.h b/custom/generated/remapping.h index 771ce3a5..b4348329 100644 --- a/custom/generated/remapping.h +++ b/custom/generated/remapping.h @@ -126,9 +126,10 @@ setup_default_mapping(Mapping *mapping){ Bind(move_left_alpha_numeric_or_camel_boundary, KeyCode_Left, KeyCode_Alt); Bind(move_right_alpha_numeric_or_camel_boundary, KeyCode_Right, KeyCode_Alt); Bind(comment_line_toggle, KeyCode_Semicolon, KeyCode_Control); - Bind(word_complete, KeyCode_Tab); + Bind(word_complete_drop_down, KeyCode_Tab); Bind(auto_indent_range, KeyCode_Tab, KeyCode_Control); Bind(auto_indent_line_at_cursor, KeyCode_Tab, KeyCode_Shift); + Bind(word_complete, KeyCode_Tab, KeyCode_Shift, KeyCode_Control); Bind(write_block, KeyCode_R, KeyCode_Alt); Bind(write_todo, KeyCode_T, KeyCode_Alt); Bind(write_note, KeyCode_Y, KeyCode_Alt);