From b998317bda5bc8a373abce1144273344f3f37f44 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Fri, 2 Aug 2019 13:07:08 -0700 Subject: [PATCH] isearch highlight implemented in I.M. rendering, fixes to enclosures --- 4coder_base_commands.cpp | 45 ++--------- 4coder_default_framework.cpp | 2 + 4coder_default_framework_variables.cpp | 2 + 4coder_default_hooks.cpp | 105 ++++++++++++++++++------- 4coder_generated/command_metadata.h | 62 +++++++-------- 4coder_helper.cpp | 26 ++++++ things_ive_broken.txt | 2 - 7 files changed, 145 insertions(+), 99 deletions(-) diff --git a/4coder_base_commands.cpp b/4coder_base_commands.cpp index 3219e47e..0b73fca6 100644 --- a/4coder_base_commands.cpp +++ b/4coder_base_commands.cpp @@ -871,16 +871,11 @@ CUSTOM_DOC("Queries the user for a number, and jumps the cursor to the correspon CUSTOM_COMMAND_SIG(search); CUSTOM_COMMAND_SIG(reverse_search); -#if 0 static void -isearch__update_highlight(Application_Links *app, View_ID view, Managed_Object highlight, Range_i64 range){ - Marker markers[4] = {}; - markers[0].pos = (i32)range.start; - markers[1].pos = (i32)range.end; - managed_object_store_data(app, highlight, 0, 2, markers); +isearch__update_highlight(Application_Links *app, View_ID view, Range_i64 range){ + view_set_highlight_range(app, view, range); view_set_cursor(app, view, seek_pos(range.start), true); } -#endif static void isearch(Application_Links *app, b32 start_reversed, String_Const_u8 query_init, b32 on_the_query_init_string){ @@ -916,18 +911,7 @@ isearch(Application_Links *app, b32 start_reversed, String_Const_u8 query_init, b32 first_step = true; // TODO(allen): rewrite -#if 0 - Managed_Scope view_scope = view_get_managed_scope(app, view); - Managed_Object highlight = alloc_buffer_markers_on_buffer(app, buffer, 2, &view_scope); - Marker_Visual visual = create_marker_visual(app, highlight); - marker_visual_set_effect(app, visual, - VisualType_CharacterHighlightRanges, - Stag_Highlight, - Stag_At_Highlight, 0); - marker_visual_set_view_key(app, visual, view); - marker_visual_set_priority(app, visual, VisualPriority_Default + 1); - isearch__update_highlight(app, view, highlight, match); -#endif + isearch__update_highlight(app, view, match); cursor_is_hidden = true; User_Input in = {}; @@ -1064,15 +1048,11 @@ isearch(Application_Links *app, b32 start_reversed, String_Const_u8 query_init, } if (!suppress_highligh_update){ -#if 0 - isearch__update_highlight(app, view, highlight, match); -#endif + isearch__update_highlight(app, view, match); } } -#if 0 - managed_object_free(app, highlight); -#endif + view_disable_highlight_range(app, view); cursor_is_hidden = false; if (in.abort){ @@ -1198,13 +1178,6 @@ query_replace_base(Application_Links *app, View_ID view, Buffer_ID buffer_id, i6 i64 new_pos = 0; buffer_seek_string_forward(app, buffer_id, pos - 1, 0, r, &new_pos); -#if 0 - Managed_Scope view_scope = view_get_managed_scope(app, view); - Managed_Object highlight = alloc_buffer_markers_on_buffer(app, buffer_id, 2, &view_scope); - Marker_Visual visual = create_marker_visual(app, highlight); - marker_visual_set_effect(app, visual, VisualType_CharacterHighlightRanges, Stag_Highlight, Stag_At_Highlight, 0); - marker_visual_set_view_key(app, visual, view); -#endif cursor_is_hidden = true; i64 buffer_size = buffer_get_size(app, buffer_id); @@ -1212,9 +1185,7 @@ query_replace_base(Application_Links *app, View_ID view, Buffer_ID buffer_id, i6 User_Input in = {}; for (;new_pos < buffer_size;){ Range_i64 match = Ii64(new_pos, new_pos + r.size); -#if 0 - isearch__update_highlight(app, view, highlight, match); -#endif + isearch__update_highlight(app, view, match); in = get_user_input(app, EventOnAnyKey, EventOnMouseLeftButton|EventOnMouseRightButton); if (in.abort || in.key.keycode == key_esc || !key_is_unmodified(&in.key)) break; @@ -1231,9 +1202,7 @@ query_replace_base(Application_Links *app, View_ID view, Buffer_ID buffer_id, i6 buffer_seek_string_forward(app, buffer_id, pos, 0, r, &new_pos); } -#if 0 - managed_object_free(app, highlight); -#endif + view_disable_highlight_range(app, view); cursor_is_hidden = false; if (in.abort){ diff --git a/4coder_default_framework.cpp b/4coder_default_framework.cpp index 8573a890..d2717c7d 100644 --- a/4coder_default_framework.cpp +++ b/4coder_default_framework.cpp @@ -384,6 +384,8 @@ default_4coder_initialize(Application_Links *app, char **command_line_files, i32 view_is_passive_loc = managed_variable_create_or_get_id(app, "DEFAULT.is_passive" , 0); view_snap_mark_to_cursor = managed_variable_create_or_get_id(app, "DEFAULT.mark_to_cursor", 0); view_ui_data = managed_variable_create_or_get_id(app, "DEFAULT.ui_data" , 0); + view_highlight_range = managed_variable_create_or_get_id(app, "DEFAULT.highlight" , 0); + view_highlight_buffer = managed_variable_create_or_get_id(app, "DEFAULT.highlight_buf" , 0); // open command line files Arena *scratch = context_get_arena(app); diff --git a/4coder_default_framework_variables.cpp b/4coder_default_framework_variables.cpp index 72744bc8..36208515 100644 --- a/4coder_default_framework_variables.cpp +++ b/4coder_default_framework_variables.cpp @@ -40,6 +40,8 @@ static Managed_Variable_ID view_paste_index_loc = 0; static Managed_Variable_ID view_is_passive_loc = 0; static Managed_Variable_ID view_snap_mark_to_cursor = 0; static Managed_Variable_ID view_ui_data = 0; +static Managed_Variable_ID view_highlight_range = 0; +static Managed_Variable_ID view_highlight_buffer = 0; static u8 out_buffer_space[1024]; static u8 command_space[1024]; diff --git a/4coder_default_hooks.cpp b/4coder_default_hooks.cpp index 2d5663b6..3d863b6a 100644 --- a/4coder_default_hooks.cpp +++ b/4coder_default_hooks.cpp @@ -176,16 +176,40 @@ draw_enclosures(Application_Links *app, Text_Layout_ID text_layout_id, Buffer_ID Range_i64_Array ranges = get_enclosure_ranges(app, scratch, buffer, pos, flags); i32 color_index = 0; - for (i32 i = 0; i < ranges.count; i += 1){ + for (i32 i = ranges.count - 1; i >= 0; i -= 1){ Range_i64 range = ranges.ranges[i]; if (kind == RangeHighlightKind_LineHighlight){ - Range_i64 line_range = get_line_range_from_pos_range(app, buffer, range); - if (back_colors != 0){ - draw_line_highlight(app, text_layout_id, line_range, back_colors[color_index]); + Range_i64 r[2] = {}; + if (i > 0){ + Range_i64 inner_range = ranges.ranges[i - 1]; + Range_i64 lines = get_line_range_from_pos_range(app, buffer, range); + Range_i64 inner_lines = get_line_range_from_pos_range(app, buffer, inner_range); + inner_lines.min = clamp_bot(lines.min, inner_lines.min); + inner_lines.max = clamp_top(inner_lines.max, lines.max); + inner_lines.min -= 1; + inner_lines.max += 1; + if (lines.min <= inner_lines.min){ + r[0] = Ii64(lines.min, inner_lines.min); + } + if (inner_lines.max <= lines.max){ + r[1] = Ii64(inner_lines.max, lines.max); + } } - if (fore_colors != 0){ - Range_i64 pos_range = get_pos_range_from_line_range(app, buffer, line_range); - paint_text_color(app, text_layout_id, pos_range, fore_colors[color_index]); + else{ + r[0] = get_line_range_from_pos_range(app, buffer, range); + } + for (i32 j = 0; j < 2; j += 1){ + if (r[j].min == 0){ + continue; + } + Range_i64 line_range = r[j]; + if (back_colors != 0){ + draw_line_highlight(app, text_layout_id, line_range, back_colors[color_index]); + } + if (fore_colors != 0){ + Range_i64 pos_range = get_pos_range_from_line_range(app, buffer, line_range); + paint_text_color(app, text_layout_id, pos_range, fore_colors[color_index]); + } } } else{ @@ -543,12 +567,58 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View colors, 0, color_count); } + // NOTE(allen): Color parens + if (do_matching_paren_highlight){ + i64 pos = cursor_pos; + if (buffer_get_char(app, buffer, pos) == '('){ + pos += 1; + } + else if (pos > 0){ + if (buffer_get_char(app, buffer, pos - 1) == ')'){ + pos -= 1; + } + } + static const i32 color_count = 4; + int_color colors[color_count]; + for (u16 i = 0; i < color_count; i += 1){ + colors[i] = Stag_Text_Cycle_1 + i; + } + draw_enclosures(app, text_layout_id, buffer, + cursor_pos, FindScope_Paren, RangeHighlightKind_CharacterHighlight, + 0, colors, color_count); + } + // NOTE(allen): Line highlight if (highlight_line_at_cursor && is_active_view){ i64 line_number = get_line_number_from_pos(app, buffer, cursor_pos); draw_line_highlight(app, text_layout_id, line_number, Stag_Highlight_Cursor_Line); } + // NOTE(allen): Highlight range + b32 has_highlight_range = false; + { + Managed_Scope scope = view_get_managed_scope(app, view_id); + u64 highlight_buffer = 0; + managed_variable_get(app, scope, view_highlight_buffer, &highlight_buffer); + if (highlight_buffer != 0){ + if ((Buffer_ID)highlight_buffer != buffer){ + view_disable_highlight_range(app, view_id); + } + else{ + has_highlight_range = true; + Managed_Object highlight = 0; + managed_variable_get(app, scope, view_highlight_range, &highlight); + Marker marker_range[2]; + if (managed_object_load_data(app, highlight, 0, 2, marker_range)){ + Range_i64 range = Ii64(marker_range[0].pos, + marker_range[1].pos); + draw_character_block(app, text_layout_id, range, Stag_Highlight); + paint_text_color(app, text_layout_id, range, Stag_At_Highlight); + } + } + } + } + // NOTE(allen): Cursor and mark b32 cursor_is_hidden_in_this_view = (cursor_is_hidden && is_active_view); if (!cursor_is_hidden_in_this_view){ @@ -578,27 +648,6 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View } } - // NOTE(allen): Matching enclosure highlight setup - if (do_matching_paren_highlight){ - i64 pos = cursor_pos; - if (buffer_get_char(app, buffer, pos) == '('){ - pos += 1; - } - else if (pos > 0){ - if (buffer_get_char(app, buffer, pos - 1) == ')'){ - pos -= 1; - } - } - static const i32 color_count = 4; - int_color colors[color_count]; - for (u16 i = 0; i < color_count; i += 1){ - colors[i] = Stag_Text_Cycle_1 + i; - } - draw_enclosures(app, text_layout_id, buffer, - cursor_pos, FindScope_Paren, RangeHighlightKind_CharacterHighlight, - 0, colors, color_count); - } - draw_clip_push(app, buffer_rect); draw_render_layout(app, view_id); text_layout_free(app, text_layout_id); diff --git a/4coder_generated/command_metadata.h b/4coder_generated/command_metadata.h index d8a8a4aa..af59d5e7 100644 --- a/4coder_generated/command_metadata.h +++ b/4coder_generated/command_metadata.h @@ -347,37 +347,37 @@ static Command_Metadata fcoder_metacmd_table[237] = { { PROC_LINKS(eol_nixify, 0), "eol_nixify", 10, "Puts the buffer in NIX line ending mode.", 40, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 840 }, { PROC_LINKS(exit_4coder, 0), "exit_4coder", 11, "Attempts to close 4coder.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 848 }, { PROC_LINKS(goto_line, 0), "goto_line", 9, "Queries the user for a number, and jumps the cursor to the corresponding line.", 78, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 856 }, -{ PROC_LINKS(search, 0), "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1087 }, -{ PROC_LINKS(reverse_search, 0), "reverse_search", 14, "Begins an incremental search up through the current buffer for a user specified string.", 87, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1093 }, -{ PROC_LINKS(search_identifier, 0), "search_identifier", 17, "Begins an incremental search down through the current buffer for the word or token under the cursor.", 100, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1099 }, -{ PROC_LINKS(reverse_search_identifier, 0), "reverse_search_identifier", 25, "Begins an incremental search up through the current buffer for the word or token under the cursor.", 98, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1110 }, -{ PROC_LINKS(replace_in_range, 0), "replace_in_range", 16, "Queries the user for a needle and string. Replaces all occurences of needle with string in the range between cursor and the mark in the active buffer.", 150, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1161 }, -{ PROC_LINKS(replace_in_buffer, 0), "replace_in_buffer", 17, "Queries the user for a needle and string. Replaces all occurences of needle with string in the active buffer.", 109, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1170 }, -{ PROC_LINKS(replace_in_all_buffers, 0), "replace_in_all_buffers", 22, "Queries the user for a needle and string. Replaces all occurences of needle with string in all editable buffers.", 112, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1179 }, -{ PROC_LINKS(query_replace, 0), "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1278 }, -{ PROC_LINKS(query_replace_identifier, 0), "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1298 }, -{ PROC_LINKS(query_replace_selection, 0), "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1314 }, -{ PROC_LINKS(save_all_dirty_buffers, 0), "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1349 }, -{ PROC_LINKS(delete_file_query, 0), "delete_file_query", 17, "Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.", 125, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1374 }, -{ PROC_LINKS(save_to_query, 0), "save_to_query", 13, "Queries the user for a file name and saves the contents of the current buffer, altering the buffer's name too.", 110, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1412 }, -{ PROC_LINKS(rename_file_query, 0), "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1447 }, -{ PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1487 }, -{ PROC_LINKS(move_line_up, 0), "move_line_up", 12, "Swaps the line under the cursor with the line above it, and moves the cursor up with it.", 88, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1520 }, -{ PROC_LINKS(move_line_down, 0), "move_line_down", 14, "Swaps the line under the cursor with the line below it, and moves the cursor down with it.", 90, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1526 }, -{ PROC_LINKS(duplicate_line, 0), "duplicate_line", 14, "Create a copy of the line on which the cursor sits.", 51, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1532 }, -{ PROC_LINKS(delete_line, 0), "delete_line", 11, "Delete the line the on which the cursor sits.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1546 }, -{ PROC_LINKS(open_file_in_quotes, 0), "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1611 }, -{ PROC_LINKS(open_matching_file_cpp, 0), "open_matching_file_cpp", 22, "If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.", 110, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1643 }, -{ PROC_LINKS(view_buffer_other_panel, 0), "view_buffer_other_panel", 23, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1656 }, -{ PROC_LINKS(swap_buffers_between_panels, 0), "swap_buffers_between_panels", 27, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1668 }, -{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1702 }, -{ PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1710 }, -{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1722 }, -{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history of the current buffer.", 66, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1780 }, -{ PROC_LINKS(redo, 0), "redo", 4, "Advances forwards through the undo history of the current buffer.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1793 }, -{ PROC_LINKS(undo_all_buffers, 0), "undo_all_buffers", 16, "Advances backward through the undo history in the buffer containing the most recent regular edit.", 97, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1807 }, -{ PROC_LINKS(redo_all_buffers, 0), "redo_all_buffers", 16, "Advances forward through the undo history in the buffer containing the most recent regular edit.", 96, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1881 }, -{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1984 }, +{ PROC_LINKS(search, 0), "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1067 }, +{ PROC_LINKS(reverse_search, 0), "reverse_search", 14, "Begins an incremental search up through the current buffer for a user specified string.", 87, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1073 }, +{ PROC_LINKS(search_identifier, 0), "search_identifier", 17, "Begins an incremental search down through the current buffer for the word or token under the cursor.", 100, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1079 }, +{ PROC_LINKS(reverse_search_identifier, 0), "reverse_search_identifier", 25, "Begins an incremental search up through the current buffer for the word or token under the cursor.", 98, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1090 }, +{ PROC_LINKS(replace_in_range, 0), "replace_in_range", 16, "Queries the user for a needle and string. Replaces all occurences of needle with string in the range between cursor and the mark in the active buffer.", 150, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1141 }, +{ PROC_LINKS(replace_in_buffer, 0), "replace_in_buffer", 17, "Queries the user for a needle and string. Replaces all occurences of needle with string in the active buffer.", 109, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1150 }, +{ PROC_LINKS(replace_in_all_buffers, 0), "replace_in_all_buffers", 22, "Queries the user for a needle and string. Replaces all occurences of needle with string in all editable buffers.", 112, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1159 }, +{ PROC_LINKS(query_replace, 0), "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1247 }, +{ PROC_LINKS(query_replace_identifier, 0), "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1267 }, +{ PROC_LINKS(query_replace_selection, 0), "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1283 }, +{ PROC_LINKS(save_all_dirty_buffers, 0), "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1318 }, +{ PROC_LINKS(delete_file_query, 0), "delete_file_query", 17, "Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.", 125, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1343 }, +{ PROC_LINKS(save_to_query, 0), "save_to_query", 13, "Queries the user for a file name and saves the contents of the current buffer, altering the buffer's name too.", 110, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1381 }, +{ PROC_LINKS(rename_file_query, 0), "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1416 }, +{ PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1456 }, +{ PROC_LINKS(move_line_up, 0), "move_line_up", 12, "Swaps the line under the cursor with the line above it, and moves the cursor up with it.", 88, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1489 }, +{ PROC_LINKS(move_line_down, 0), "move_line_down", 14, "Swaps the line under the cursor with the line below it, and moves the cursor down with it.", 90, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1495 }, +{ PROC_LINKS(duplicate_line, 0), "duplicate_line", 14, "Create a copy of the line on which the cursor sits.", 51, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1501 }, +{ PROC_LINKS(delete_line, 0), "delete_line", 11, "Delete the line the on which the cursor sits.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1515 }, +{ PROC_LINKS(open_file_in_quotes, 0), "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1580 }, +{ PROC_LINKS(open_matching_file_cpp, 0), "open_matching_file_cpp", 22, "If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.", 110, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1612 }, +{ PROC_LINKS(view_buffer_other_panel, 0), "view_buffer_other_panel", 23, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1625 }, +{ PROC_LINKS(swap_buffers_between_panels, 0), "swap_buffers_between_panels", 27, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1637 }, +{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1671 }, +{ PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1679 }, +{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1691 }, +{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history of the current buffer.", 66, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1749 }, +{ PROC_LINKS(redo, 0), "redo", 4, "Advances forwards through the undo history of the current buffer.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1762 }, +{ PROC_LINKS(undo_all_buffers, 0), "undo_all_buffers", 16, "Advances backward through the undo history in the buffer containing the most recent regular edit.", 97, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1776 }, +{ PROC_LINKS(redo_all_buffers, 0), "redo_all_buffers", 16, "Advances forward through the undo history in the buffer containing the most recent regular edit.", 96, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1850 }, +{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1953 }, { PROC_LINKS(lister__quit, 0), "lister__quit", 12, "A lister mode command that quits the list without executing any actions.", 72, "w:\\4ed\\code\\4coder_lists.cpp", 28, 8 }, { PROC_LINKS(lister__activate, 0), "lister__activate", 16, "A lister mode command that activates the list's action on the highlighted item.", 79, "w:\\4ed\\code\\4coder_lists.cpp", 28, 15 }, { PROC_LINKS(lister__write_character, 0), "lister__write_character", 23, "A lister mode command that dispatches to the lister's write character handler.", 78, "w:\\4ed\\code\\4coder_lists.cpp", 28, 30 }, diff --git a/4coder_helper.cpp b/4coder_helper.cpp index 7abddfed..ddf92876 100644 --- a/4coder_helper.cpp +++ b/4coder_helper.cpp @@ -1779,6 +1779,32 @@ view_open_file(Application_Links *app, View_ID view, String_Const_u8 file_name, return(result); } +internal void +view_disable_highlight_range(Application_Links *app, View_ID view){ + Managed_Scope scope = view_get_managed_scope(app, view); + Managed_Object highlight = 0; + if (managed_variable_get(app, scope, view_highlight_range, &highlight)){ + managed_object_free(app, highlight); + } + managed_variable_set(app, scope, view_highlight_range, 0); + managed_variable_set(app, scope, view_highlight_buffer, 0); +} + +internal void +view_set_highlight_range(Application_Links *app, View_ID view, Range_i64 range){ + view_disable_highlight_range(app, view); + + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); + Managed_Scope scope = view_get_managed_scope(app, view); + Managed_Object highlight = alloc_buffer_markers_on_buffer(app, buffer, 2, &scope); + managed_variable_set(app, scope, view_highlight_range, highlight); + Marker markers[2] = {}; + markers[0].pos = (i32)range.min; + markers[1].pos = (i32)range.max; + managed_object_store_data(app, highlight, 0, 2, markers); + managed_variable_set(app, scope, view_highlight_buffer, buffer); +} + //////////////////////////////// internal View_ID diff --git a/things_ive_broken.txt b/things_ive_broken.txt index 1503df9f..87eb4c27 100644 --- a/things_ive_broken.txt +++ b/things_ive_broken.txt @@ -47,6 +47,4 @@ set_global_face_by_name -> set_buffer_face_by_font_load_location (with id = 0) mark_enclosures -> draw_enclosures -isearch__update_highlight - all *marker_visuals* -> immediate mode rendering \ No newline at end of file