From 793ba6fc83a3ef2f056ef8f79cf7d63dc7e0364b Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Tue, 21 Nov 2017 13:25:19 -0500 Subject: [PATCH] Lots of new convenience features --- 4coder_base_commands.cpp | 131 ++-- 4coder_default_include.cpp | 109 ++++ 4coder_generated/command_metadata.h | 479 +++++++------- 4coder_generated/remapping.h | 86 ++- 4coder_project_commands.cpp | 77 ++- 4coder_scope_commands.cpp | 812 +++++++++++++++++++++++ 4coder_search.cpp | 48 ++ meta/4ed_metagen.cpp | 40 +- power/4coder_experiments.cpp | 886 +++----------------------- site/source_material/binding_list.txt | 6 +- 10 files changed, 1567 insertions(+), 1107 deletions(-) create mode 100644 4coder_scope_commands.cpp diff --git a/4coder_base_commands.cpp b/4coder_base_commands.cpp index 2aa599a7..21500d1e 100644 --- a/4coder_base_commands.cpp +++ b/4coder_base_commands.cpp @@ -19,17 +19,12 @@ TYPE: 'drop-in-command-pack' // Fundamental Editing Commands // -CUSTOM_COMMAND_SIG(write_character) -CUSTOM_DOC("Inserts whatever character was used to trigger this command.") -{ - uint32_t access = AccessOpen; - View_Summary view = get_active_view(app, access); - - User_Input in = get_command_input(app); - - uint8_t character[4]; - uint32_t length = to_writable_character(in, character); +static void +write_character_parameter(Application_Links *app, uint8_t *character, uint32_t length){ if (length != 0){ + uint32_t access = AccessOpen; + View_Summary view = get_active_view(app, access); + Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); int32_t pos = view.cursor.pos; @@ -49,6 +44,22 @@ CUSTOM_DOC("Inserts whatever character was used to trigger this command.") } } +CUSTOM_COMMAND_SIG(write_character) +CUSTOM_DOC("Inserts whatever character was used to trigger this command.") +{ + User_Input in = get_command_input(app); + uint8_t character[4]; + uint32_t length = to_writable_character(in, character); + write_character_parameter(app, character, length); +} + +CUSTOM_COMMAND_SIG(write_underscore) +CUSTOM_DOC("Inserts an underscore.") +{ + uint8_t character = '_'; + write_character_parameter(app, &character, 1); +} + CUSTOM_COMMAND_SIG(delete_char) CUSTOM_DOC("Deletes the character to the right of the cursor.") { @@ -589,6 +600,30 @@ CUSTOM_DOC("Decrases the current buffer's width for line wrapping.") buffer_set_setting(app, &buffer, BufferSetting_WrapPosition, wrap - 10); } +CUSTOM_COMMAND_SIG(increase_face_size) +CUSTOM_DOC("Increase the size of the face used by the current buffer.") +{ + View_Summary view = get_active_view(app, AccessAll); + Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessAll); + + Face_ID face_id = get_face_id(app, &buffer); + Face_Description description = get_face_description(app, face_id); + ++description.pt_size; + try_modify_face(app, face_id, &description); +} + +CUSTOM_COMMAND_SIG(decrease_face_size) +CUSTOM_DOC("Decrease the size of the face used by the current buffer.") +{ + View_Summary view = get_active_view(app, AccessAll); + Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessAll); + + Face_ID face_id = get_face_id(app, &buffer); + Face_Description description = get_face_description(app, face_id); + --description.pt_size; + try_modify_face(app, face_id, &description); +} + CUSTOM_COMMAND_SIG(toggle_virtual_whitespace) CUSTOM_DOC("Toggles the current buffer's virtual whitespace status.") { @@ -912,22 +947,21 @@ query_replace(Application_Links *app, View_Summary *view, Buffer_Summary *buffer view_set_cursor(app, view, seek_pos(pos), true); } -CUSTOM_COMMAND_SIG(query_replace) -CUSTOM_DOC("Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.") -{ +static void +query_replace_parameter(Application_Links *app, String replace_str, int32_t start_pos, bool32 add_replace_query_bar){ Query_Bar replace; - char replace_space[1024]; replace.prompt = make_lit_string("Replace: "); - replace.string = make_fixed_width_string(replace_space); + replace.string = replace_str; + + if (add_replace_query_bar){ + start_query_bar(app, &replace, 0); + } Query_Bar with; char with_space[1024]; with.prompt = make_lit_string("With: "); with.string = make_fixed_width_string(with_space); - if (!query_user_string(app, &replace)) return; - if (replace.string.size == 0) return; - if (!query_user_string(app, &with)) return; String r = replace.string; @@ -935,7 +969,7 @@ CUSTOM_DOC("Queries the user for two strings, and incrementally replaces every o View_Summary view = get_active_view(app, AccessOpen); Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen); - int32_t pos = view.cursor.pos; + int32_t pos = start_pos; Query_Bar bar; bar.prompt = make_lit_string("Replace? (y)es, (n)ext, (esc)\n"); @@ -945,42 +979,43 @@ CUSTOM_DOC("Queries the user for two strings, and incrementally replaces every o query_replace(app, &view, &buffer, pos, r, w); } +CUSTOM_COMMAND_SIG(query_replace) +CUSTOM_DOC("Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.") +{ + View_Summary view = get_active_view(app, AccessOpen); + Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen); + + if (!buffer.exists){ + return; + } + + Query_Bar replace; + char replace_space[1024]; + replace.prompt = make_lit_string("Replace: "); + replace.string = make_fixed_width_string(replace_space); + + if (!query_user_string(app, &replace)) return; + if (replace.string.size == 0) return; + + query_replace_parameter(app, replace.string, view.cursor.pos, false); +} + CUSTOM_COMMAND_SIG(query_replace_identifier) CUSTOM_DOC("Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.") { - View_Summary view = get_active_view(app, AccessProtected); - Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected); + View_Summary view = get_active_view(app, AccessOpen); + Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen); + + if (!buffer.exists){ + return; + } Range range = {0}; char space[256]; - String query = read_identifier_at_pos(app, &buffer, view.cursor.pos, space, sizeof(space), &range); + String replace = read_identifier_at_pos(app, &buffer, view.cursor.pos, space, sizeof(space), &range); - if (query.size != 0){ - Query_Bar replace; - replace.prompt = make_lit_string("Replace: "); - replace.string = query; - if (start_query_bar(app, &replace, 0) == 0) return; - - Query_Bar with; - char with_space[1024]; - with.prompt = make_lit_string("With: "); - with.string = make_fixed_width_string(with_space); - - if (!query_user_string(app, &with)) return; - - String r = replace.string; - String w = with.string; - - view = get_active_view(app, AccessOpen); - buffer = get_buffer(app, view.buffer_id, AccessOpen); - int32_t pos = range.start; - - Query_Bar bar; - bar.prompt = make_lit_string("Replace? (y)es, (n)ext, (esc)\n"); - bar.string = null_string; - start_query_bar(app, &bar, 0); - - query_replace(app, &view, &buffer, pos, r, w); + if (replace.size != 0){ + query_replace_parameter(app, replace, range.min, true); } } diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index 4c190f41..cd626358 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -22,6 +22,7 @@ TYPE: 'major-system-include' #include "4coder_build_commands.cpp" #include "4coder_project_commands.cpp" #include "4coder_function_list.cpp" +#include "4coder_scope_commands.cpp" // NOTE(allen): Define USE_OLD_STYLE_JUMPS before 4coder_default_include.cpp to get // the direct jumps (instead of sticky jumps). @@ -211,10 +212,118 @@ CUSTOM_DOC("Delete a single, whole token on or to the right of the cursor.") buffer_replace_range(app, &buffer, range.start, range.end, 0, 0); } + +// +// Quer Replace Selection +// + +CUSTOM_COMMAND_SIG(query_replace_selection) +CUSTOM_DOC("Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.") +{ + View_Summary view = get_active_view(app, AccessOpen); + Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen); + + if (!buffer.exists){ + return; + } + + Partition *part = &global_part; + Temp_Memory temp = begin_temp_memory(part); + + Range range = get_range(&view); + int32_t replace_length = range.max - range.min; + if (replace_length != 0){ + char *replace_space = push_array(part, char, replace_length); + if (buffer_read_range(app, &buffer, range.min, range.max, replace_space)){ + String replace = make_string(replace_space, replace_length); + query_replace_parameter(app, replace, range.min, true); + } + } + + end_temp_memory(temp); +} + + // // Line Manipulation // +CUSTOM_COMMAND_SIG(move_line_up) +CUSTOM_DOC("Swaps the line under the cursor with the line above it, and moves the cursor up with it.") +{ + View_Summary view = get_active_view(app, AccessOpen); + + if (view.cursor.line <= 1){ + return; + } + + Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen); + if (!buffer.exists){ + return; + } + + Full_Cursor prev_line_cursor = {0}; + Full_Cursor this_line_cursor = {0}; + Full_Cursor next_line_cursor = {0}; + + int32_t this_line = view.cursor.line; + int32_t prev_line = this_line - 1; + int32_t next_line = this_line +1; + + if (view_compute_cursor(app, &view, seek_line_char(prev_line, 1), &prev_line_cursor) && + view_compute_cursor(app, &view, seek_line_char(this_line, 1), &this_line_cursor) && + view_compute_cursor(app, &view, seek_line_char(next_line, 1), &next_line_cursor)){ + + int32_t prev_line_pos = prev_line_cursor.pos; + int32_t this_line_pos = this_line_cursor.pos; + int32_t next_line_pos = next_line_cursor.pos; + + Partition *part = &global_part; + Temp_Memory temp = begin_temp_memory(part); + + int32_t length = next_line_pos - prev_line_pos; + char *swap = push_array(part, char, length); + int32_t first_len = next_line_pos - this_line_pos; + + if (buffer_read_range(app, &buffer, this_line_pos, next_line_pos, swap) && + buffer_read_range(app, &buffer, prev_line_pos, this_line_pos, swap + first_len)){ + buffer_replace_range(app, &buffer, prev_line_pos, next_line_pos, swap, length); + view_set_cursor(app, &view, seek_line_char(prev_line, 1), true); + } + + end_temp_memory(temp); + } +} + +CUSTOM_COMMAND_SIG(move_down_textual) +CUSTOM_DOC("Moves down to the next line of actual text, regardless of line wrapping.") +{ + View_Summary view = get_active_view(app, AccessOpen); + if (!view.exists){ + return; + } + + int32_t next_line = view.cursor.line + 1; + view_set_cursor(app, &view, seek_line_char(next_line, 1), true); +} + +CUSTOM_COMMAND_SIG(move_line_down) +CUSTOM_DOC("Swaps the line under the cursor with the line below it, and moves the cursor down with it.") +{ + View_Summary view = get_active_view(app, AccessOpen); + if (!view.exists){ + return; + } + Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen); + if (!buffer.exists){ + return; + } + + move_down_textual(app); + move_line_up(app); + move_down_textual(app); +} + CUSTOM_COMMAND_SIG(duplicate_line) CUSTOM_DOC("Create a copy of the line on which the cursor sits.") { diff --git a/4coder_generated/command_metadata.h b/4coder_generated/command_metadata.h index f888dceb..982f982e 100644 --- a/4coder_generated/command_metadata.h +++ b/4coder_generated/command_metadata.h @@ -1,7 +1,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 172 +#define command_one_past_last_id 175 #if defined(CUSTOM_COMMAND_SIG) #define PROC_LINKS(x,y) x #else @@ -13,6 +13,7 @@ CUSTOM_COMMAND_SIG(auto_tab_line_at_cursor); CUSTOM_COMMAND_SIG(auto_tab_range); CUSTOM_COMMAND_SIG(write_and_auto_tab); CUSTOM_COMMAND_SIG(write_character); +CUSTOM_COMMAND_SIG(write_underscore); CUSTOM_COMMAND_SIG(delete_char); CUSTOM_COMMAND_SIG(backspace_char); CUSTOM_COMMAND_SIG(set_mark); @@ -52,6 +53,8 @@ CUSTOM_COMMAND_SIG(toggle_filebar); CUSTOM_COMMAND_SIG(toggle_line_wrap); CUSTOM_COMMAND_SIG(increase_line_wrap); CUSTOM_COMMAND_SIG(decrease_line_wrap); +CUSTOM_COMMAND_SIG(increase_face_size); +CUSTOM_COMMAND_SIG(decrease_face_size); CUSTOM_COMMAND_SIG(toggle_virtual_whitespace); CUSTOM_COMMAND_SIG(toggle_show_whitespace); CUSTOM_COMMAND_SIG(eol_dosify); @@ -191,77 +194,80 @@ char *source_name; int32_t source_name_len; int32_t line_number; }; -static Command_Metadata fcoder_metacmd_table[172] = { +static Command_Metadata fcoder_metacmd_table[175] = { { PROC_LINKS(auto_tab_whole_file, 0), "auto_tab_whole_file", 19, "Audo-indents the entire current buffer.", 39, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 608 }, { PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 618 }, { PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 629 }, { PROC_LINKS(write_and_auto_tab, 0), "write_and_auto_tab", 18, "Inserts a character and auto-indents the line on which the cursor sits.", 71, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 641 }, -{ PROC_LINKS(write_character, 0), "write_character", 15, "Inserts whatever character was used to trigger this command.", 60, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 22 }, -{ PROC_LINKS(delete_char, 0), "delete_char", 11, "Deletes the character to the right of the cursor.", 49, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 52 }, -{ PROC_LINKS(backspace_char, 0), "backspace_char", 14, "Deletes the character to the left of the cursor.", 48, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 70 }, -{ PROC_LINKS(set_mark, 0), "set_mark", 8, "Sets the mark to the current position of the cursor.", 52, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 89 }, -{ PROC_LINKS(cursor_mark_swap, 0), "cursor_mark_swap", 16, "Swaps the position of the cursor and the mark.", 46, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 98 }, -{ PROC_LINKS(delete_range, 0), "delete_range", 12, "Deletes the text in the range between the cursor and the mark.", 62, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 110 }, -{ PROC_LINKS(center_view, 0), "center_view", 11, "Centers the view vertically on the line on which the cursor sits.", 65, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 125 }, -{ PROC_LINKS(left_adjust_view, 0), "left_adjust_view", 16, "Sets the left size of the view near the x position of the cursor.", 65, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 140 }, -{ PROC_LINKS(click_set_cursor, 0), "click_set_cursor", 16, "Sets the cursor position to the mouse position.", 47, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 179 }, -{ PROC_LINKS(click_set_mark, 0), "click_set_mark", 14, "Sets the mark position to the mouse position.", 45, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 192 }, -{ PROC_LINKS(move_up, 0), "move_up", 7, "Moves the cursor up one line.", 29, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 216 }, -{ PROC_LINKS(move_down, 0), "move_down", 9, "Moves the cursor down one line.", 31, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 222 }, -{ PROC_LINKS(move_up_10, 0), "move_up_10", 10, "Moves the cursor up ten lines.", 30, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 228 }, -{ PROC_LINKS(move_down_10, 0), "move_down_10", 12, "Moves the cursor down ten lines.", 32, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 234 }, -{ PROC_LINKS(page_up, 0), "page_up", 7, "Scrolls the view up one view height and moves the cursor up one view height.", 76, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 256 }, -{ PROC_LINKS(page_down, 0), "page_down", 9, "Scrolls the view down one view height and moves the cursor down one view height.", 80, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 265 }, -{ PROC_LINKS(move_left, 0), "move_left", 9, "Moves the cursor one character to the left.", 43, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 275 }, -{ PROC_LINKS(move_right, 0), "move_right", 10, "Moves the cursor one character to the right.", 44, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 284 }, -{ PROC_LINKS(select_all, 0), "select_all", 10, "Puts the cursor at the top of the file, and the mark at the bottom of the file.", 79, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 293 }, -{ PROC_LINKS(seek_whitespace_up, 0), "seek_whitespace_up", 18, "Seeks the cursor up to the next blank line.", 43, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 306 }, -{ PROC_LINKS(seek_whitespace_down, 0), "seek_whitespace_down", 20, "Seeks the cursor down to the next blank line.", 45, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 317 }, -{ PROC_LINKS(seek_beginning_of_textual_line, 0), "seek_beginning_of_textual_line", 30, "Seeks the cursor to the beginning of the line across all text.", 62, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 328 }, -{ PROC_LINKS(seek_end_of_textual_line, 0), "seek_end_of_textual_line", 24, "Seeks the cursor to the end of the line across all text.", 56, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 339 }, -{ PROC_LINKS(seek_beginning_of_line, 0), "seek_beginning_of_line", 22, "Seeks the cursor to the beginning of the visual line.", 53, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 350 }, -{ PROC_LINKS(seek_end_of_line, 0), "seek_end_of_line", 16, "Seeks the cursor to the end of the visual line.", 47, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 363 }, -{ PROC_LINKS(seek_whitespace_up_end_line, 0), "seek_whitespace_up_end_line", 27, "Seeks the cursor up to the next blank line and places it at the end of the line.", 80, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 376 }, -{ PROC_LINKS(seek_whitespace_down_end_line, 0), "seek_whitespace_down_end_line", 29, "Seeks the cursor down to the next blank line and places it at the end of the line.", 82, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 383 }, -{ PROC_LINKS(to_uppercase, 0), "to_uppercase", 12, "Converts all ascii text in the range between the cursor and the mark to uppercase.", 82, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 395 }, -{ PROC_LINKS(to_lowercase, 0), "to_lowercase", 12, "Converts all ascii text in the range between the cursor and the mark to lowercase.", 82, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 415 }, -{ PROC_LINKS(clean_all_lines, 0), "clean_all_lines", 15, "Removes trailing whitespace from all lines in the current buffer.", 65, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 435 }, -{ PROC_LINKS(basic_change_active_panel, 0), "basic_change_active_panel", 25, "Change the currently active panel, moving to the panel with the next highest view_id. Will not skipe the build panel if it is open.", 132, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 503 }, -{ PROC_LINKS(close_panel, 0), "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 511 }, -{ PROC_LINKS(show_scrollbar, 0), "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 523 }, -{ PROC_LINKS(hide_scrollbar, 0), "hide_scrollbar", 14, "Sets the current view to hide it's scrollbar.", 45, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 530 }, -{ PROC_LINKS(show_filebar, 0), "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 537 }, -{ PROC_LINKS(hide_filebar, 0), "hide_filebar", 12, "Sets the current view to hide it's filebar.", 43, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 544 }, -{ PROC_LINKS(toggle_filebar, 0), "toggle_filebar", 14, "Toggles the visibility status of the current view's filebar.", 60, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 551 }, -{ PROC_LINKS(toggle_line_wrap, 0), "toggle_line_wrap", 16, "Toggles the current buffer's line wrapping status.", 50, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 560 }, -{ PROC_LINKS(increase_line_wrap, 0), "increase_line_wrap", 18, "Increases the current buffer's width for line wrapping.", 55, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 570 }, -{ PROC_LINKS(decrease_line_wrap, 0), "decrease_line_wrap", 18, "Decrases the current buffer's width for line wrapping.", 54, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 581 }, -{ PROC_LINKS(toggle_virtual_whitespace, 0), "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 592 }, -{ PROC_LINKS(toggle_show_whitespace, 0), "toggle_show_whitespace", 22, "Toggles the current buffer's whitespace visibility status.", 58, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 603 }, -{ PROC_LINKS(eol_dosify, 0), "eol_dosify", 10, "Puts the buffer in DOS line ending mode.", 40, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 610 }, -{ PROC_LINKS(eol_nixify, 0), "eol_nixify", 10, "Puts the buffer in NIX line ending mode.", 40, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 618 }, -{ PROC_LINKS(exit_4coder, 0), "exit_4coder", 11, "Attempts to close 4coder.", 25, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 626 }, -{ PROC_LINKS(goto_line, 0), "goto_line", 9, "Queries the user for a number, and jumps the cursor to the corresponding line.", 78, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 636 }, -{ PROC_LINKS(search, 0), "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 809 }, -{ PROC_LINKS(reverse_search, 0), "reverse_search", 14, "Begins an incremental search up through the current buffer for a user specified string.", 87, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 816 }, -{ 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, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 823 }, -{ 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, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 834 }, -{ PROC_LINKS(replace_in_range, 0), "replace_in_range", 16, "Queries the user for two strings, and replaces all occurences of the first string in the range between the cursor and the mark with the second string.", 150, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 845 }, -{ 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, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 915 }, -{ 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, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 948 }, -{ PROC_LINKS(save_all_dirty_buffers, 0), "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 991 }, -{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history.", 44, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1007 }, -{ PROC_LINKS(redo, 0), "redo", 4, "Advances forewards through the undo history.", 44, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1013 }, -{ PROC_LINKS(interactive_new, 0), "interactive_new", 15, "Interactively creates a new file.", 33, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1019 }, -{ PROC_LINKS(interactive_open, 0), "interactive_open", 16, "Interactively opens a file.", 27, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1025 }, -{ PROC_LINKS(interactive_open_or_new, 0), "interactive_open_or_new", 23, "Interactively opens or creates a new file.", 42, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1031 }, -{ PROC_LINKS(interactive_switch_buffer, 0), "interactive_switch_buffer", 25, "Interactively switch to an open buffer.", 39, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1037 }, -{ PROC_LINKS(interactive_kill_buffer, 0), "interactive_kill_buffer", 23, "Interactively kill an open buffer.", 34, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1043 }, -{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1049 }, -{ PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1055 }, -{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1061 }, -{ PROC_LINKS(open_color_tweaker, 0), "open_color_tweaker", 18, "Opens the 4coder colors and fonts selector menu.", 48, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1067 }, -{ PROC_LINKS(open_debug, 0), "open_debug", 10, "Opens a debug view for internal use.", 36, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1073 }, +{ PROC_LINKS(write_character, 0), "write_character", 15, "Inserts whatever character was used to trigger this command.", 60, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 47 }, +{ PROC_LINKS(write_underscore, 0), "write_underscore", 16, "Inserts an underscore.", 22, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 56 }, +{ PROC_LINKS(delete_char, 0), "delete_char", 11, "Deletes the character to the right of the cursor.", 49, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 63 }, +{ PROC_LINKS(backspace_char, 0), "backspace_char", 14, "Deletes the character to the left of the cursor.", 48, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 81 }, +{ PROC_LINKS(set_mark, 0), "set_mark", 8, "Sets the mark to the current position of the cursor.", 52, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 100 }, +{ PROC_LINKS(cursor_mark_swap, 0), "cursor_mark_swap", 16, "Swaps the position of the cursor and the mark.", 46, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 109 }, +{ PROC_LINKS(delete_range, 0), "delete_range", 12, "Deletes the text in the range between the cursor and the mark.", 62, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 121 }, +{ PROC_LINKS(center_view, 0), "center_view", 11, "Centers the view vertically on the line on which the cursor sits.", 65, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 136 }, +{ PROC_LINKS(left_adjust_view, 0), "left_adjust_view", 16, "Sets the left size of the view near the x position of the cursor.", 65, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 151 }, +{ PROC_LINKS(click_set_cursor, 0), "click_set_cursor", 16, "Sets the cursor position to the mouse position.", 47, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 190 }, +{ PROC_LINKS(click_set_mark, 0), "click_set_mark", 14, "Sets the mark position to the mouse position.", 45, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 203 }, +{ PROC_LINKS(move_up, 0), "move_up", 7, "Moves the cursor up one line.", 29, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 227 }, +{ PROC_LINKS(move_down, 0), "move_down", 9, "Moves the cursor down one line.", 31, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 233 }, +{ PROC_LINKS(move_up_10, 0), "move_up_10", 10, "Moves the cursor up ten lines.", 30, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 239 }, +{ PROC_LINKS(move_down_10, 0), "move_down_10", 12, "Moves the cursor down ten lines.", 32, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 245 }, +{ PROC_LINKS(page_up, 0), "page_up", 7, "Scrolls the view up one view height and moves the cursor up one view height.", 76, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 267 }, +{ PROC_LINKS(page_down, 0), "page_down", 9, "Scrolls the view down one view height and moves the cursor down one view height.", 80, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 276 }, +{ PROC_LINKS(move_left, 0), "move_left", 9, "Moves the cursor one character to the left.", 43, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 286 }, +{ PROC_LINKS(move_right, 0), "move_right", 10, "Moves the cursor one character to the right.", 44, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 295 }, +{ PROC_LINKS(select_all, 0), "select_all", 10, "Puts the cursor at the top of the file, and the mark at the bottom of the file.", 79, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 304 }, +{ PROC_LINKS(seek_whitespace_up, 0), "seek_whitespace_up", 18, "Seeks the cursor up to the next blank line.", 43, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 317 }, +{ PROC_LINKS(seek_whitespace_down, 0), "seek_whitespace_down", 20, "Seeks the cursor down to the next blank line.", 45, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 328 }, +{ PROC_LINKS(seek_beginning_of_textual_line, 0), "seek_beginning_of_textual_line", 30, "Seeks the cursor to the beginning of the line across all text.", 62, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 339 }, +{ PROC_LINKS(seek_end_of_textual_line, 0), "seek_end_of_textual_line", 24, "Seeks the cursor to the end of the line across all text.", 56, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 350 }, +{ PROC_LINKS(seek_beginning_of_line, 0), "seek_beginning_of_line", 22, "Seeks the cursor to the beginning of the visual line.", 53, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 361 }, +{ PROC_LINKS(seek_end_of_line, 0), "seek_end_of_line", 16, "Seeks the cursor to the end of the visual line.", 47, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 374 }, +{ PROC_LINKS(seek_whitespace_up_end_line, 0), "seek_whitespace_up_end_line", 27, "Seeks the cursor up to the next blank line and places it at the end of the line.", 80, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 387 }, +{ PROC_LINKS(seek_whitespace_down_end_line, 0), "seek_whitespace_down_end_line", 29, "Seeks the cursor down to the next blank line and places it at the end of the line.", 82, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 394 }, +{ PROC_LINKS(to_uppercase, 0), "to_uppercase", 12, "Converts all ascii text in the range between the cursor and the mark to uppercase.", 82, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 406 }, +{ PROC_LINKS(to_lowercase, 0), "to_lowercase", 12, "Converts all ascii text in the range between the cursor and the mark to lowercase.", 82, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 426 }, +{ PROC_LINKS(clean_all_lines, 0), "clean_all_lines", 15, "Removes trailing whitespace from all lines in the current buffer.", 65, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 446 }, +{ PROC_LINKS(basic_change_active_panel, 0), "basic_change_active_panel", 25, "Change the currently active panel, moving to the panel with the next highest view_id. Will not skipe the build panel if it is open.", 132, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 514 }, +{ PROC_LINKS(close_panel, 0), "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 522 }, +{ PROC_LINKS(show_scrollbar, 0), "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 534 }, +{ PROC_LINKS(hide_scrollbar, 0), "hide_scrollbar", 14, "Sets the current view to hide it's scrollbar.", 45, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 541 }, +{ PROC_LINKS(show_filebar, 0), "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 548 }, +{ PROC_LINKS(hide_filebar, 0), "hide_filebar", 12, "Sets the current view to hide it's filebar.", 43, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 555 }, +{ PROC_LINKS(toggle_filebar, 0), "toggle_filebar", 14, "Toggles the visibility status of the current view's filebar.", 60, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 562 }, +{ PROC_LINKS(toggle_line_wrap, 0), "toggle_line_wrap", 16, "Toggles the current buffer's line wrapping status.", 50, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 571 }, +{ PROC_LINKS(increase_line_wrap, 0), "increase_line_wrap", 18, "Increases the current buffer's width for line wrapping.", 55, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 581 }, +{ PROC_LINKS(decrease_line_wrap, 0), "decrease_line_wrap", 18, "Decrases the current buffer's width for line wrapping.", 54, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 592 }, +{ PROC_LINKS(increase_face_size, 0), "increase_face_size", 18, "Increase the size of the face used by the current buffer.", 57, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 603 }, +{ PROC_LINKS(decrease_face_size, 0), "decrease_face_size", 18, "Decrease the size of the face used by the current buffer.", 57, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 615 }, +{ PROC_LINKS(toggle_virtual_whitespace, 0), "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 627 }, +{ PROC_LINKS(toggle_show_whitespace, 0), "toggle_show_whitespace", 22, "Toggles the current buffer's whitespace visibility status.", 58, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 638 }, +{ PROC_LINKS(eol_dosify, 0), "eol_dosify", 10, "Puts the buffer in DOS line ending mode.", 40, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 645 }, +{ PROC_LINKS(eol_nixify, 0), "eol_nixify", 10, "Puts the buffer in NIX line ending mode.", 40, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 653 }, +{ PROC_LINKS(exit_4coder, 0), "exit_4coder", 11, "Attempts to close 4coder.", 25, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 661 }, +{ PROC_LINKS(goto_line, 0), "goto_line", 9, "Queries the user for a number, and jumps the cursor to the corresponding line.", 78, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 671 }, +{ PROC_LINKS(search, 0), "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 844 }, +{ PROC_LINKS(reverse_search, 0), "reverse_search", 14, "Begins an incremental search up through the current buffer for a user specified string.", 87, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 851 }, +{ 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, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 858 }, +{ 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, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 869 }, +{ PROC_LINKS(replace_in_range, 0), "replace_in_range", 16, "Queries the user for two strings, and replaces all occurences of the first string in the range between the cursor and the mark with the second string.", 150, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 880 }, +{ 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, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 950 }, +{ 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, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 983 }, +{ PROC_LINKS(save_all_dirty_buffers, 0), "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1026 }, +{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history.", 44, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1042 }, +{ PROC_LINKS(redo, 0), "redo", 4, "Advances forewards through the undo history.", 44, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1048 }, +{ PROC_LINKS(interactive_new, 0), "interactive_new", 15, "Interactively creates a new file.", 33, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1054 }, +{ PROC_LINKS(interactive_open, 0), "interactive_open", 16, "Interactively opens a file.", 27, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1060 }, +{ PROC_LINKS(interactive_open_or_new, 0), "interactive_open_or_new", 23, "Interactively opens or creates a new file.", 42, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1066 }, +{ PROC_LINKS(interactive_switch_buffer, 0), "interactive_switch_buffer", 25, "Interactively switch to an open buffer.", 39, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1072 }, +{ PROC_LINKS(interactive_kill_buffer, 0), "interactive_kill_buffer", 23, "Interactively kill an open buffer.", 34, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1078 }, +{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1084 }, +{ PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1090 }, +{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1096 }, +{ PROC_LINKS(open_color_tweaker, 0), "open_color_tweaker", 18, "Opens the 4coder colors and fonts selector menu.", 48, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1102 }, +{ PROC_LINKS(open_debug, 0), "open_debug", 10, "Opens a debug view for internal use.", 36, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1108 }, { PROC_LINKS(build_search, 0), "build_search", 12, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*.", 153, "C:\\work\\4ed\\code\\4coder_build_commands.cpp", 46, 169 }, { PROC_LINKS(build_in_build_panel, 0), "build_in_build_panel", 20, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*. Puts the *compilation* buffer in a panel at the footer of the current view.", 230, "C:\\work\\4ed\\code\\4coder_build_commands.cpp", 46, 203 }, { PROC_LINKS(close_build_panel, 0), "close_build_panel", 17, "If the special build panel is open, closes it.", 46, "C:\\work\\4ed\\code\\4coder_build_commands.cpp", 46, 219 }, @@ -370,170 +376,173 @@ static int32_t fcoder_metacmd_ID_auto_tab_line_at_cursor = 1; static int32_t fcoder_metacmd_ID_auto_tab_range = 2; static int32_t fcoder_metacmd_ID_write_and_auto_tab = 3; static int32_t fcoder_metacmd_ID_write_character = 4; -static int32_t fcoder_metacmd_ID_delete_char = 5; -static int32_t fcoder_metacmd_ID_backspace_char = 6; -static int32_t fcoder_metacmd_ID_set_mark = 7; -static int32_t fcoder_metacmd_ID_cursor_mark_swap = 8; -static int32_t fcoder_metacmd_ID_delete_range = 9; -static int32_t fcoder_metacmd_ID_center_view = 10; -static int32_t fcoder_metacmd_ID_left_adjust_view = 11; -static int32_t fcoder_metacmd_ID_click_set_cursor = 12; -static int32_t fcoder_metacmd_ID_click_set_mark = 13; -static int32_t fcoder_metacmd_ID_move_up = 14; -static int32_t fcoder_metacmd_ID_move_down = 15; -static int32_t fcoder_metacmd_ID_move_up_10 = 16; -static int32_t fcoder_metacmd_ID_move_down_10 = 17; -static int32_t fcoder_metacmd_ID_page_up = 18; -static int32_t fcoder_metacmd_ID_page_down = 19; -static int32_t fcoder_metacmd_ID_move_left = 20; -static int32_t fcoder_metacmd_ID_move_right = 21; -static int32_t fcoder_metacmd_ID_select_all = 22; -static int32_t fcoder_metacmd_ID_seek_whitespace_up = 23; -static int32_t fcoder_metacmd_ID_seek_whitespace_down = 24; -static int32_t fcoder_metacmd_ID_seek_beginning_of_textual_line = 25; -static int32_t fcoder_metacmd_ID_seek_end_of_textual_line = 26; -static int32_t fcoder_metacmd_ID_seek_beginning_of_line = 27; -static int32_t fcoder_metacmd_ID_seek_end_of_line = 28; -static int32_t fcoder_metacmd_ID_seek_whitespace_up_end_line = 29; -static int32_t fcoder_metacmd_ID_seek_whitespace_down_end_line = 30; -static int32_t fcoder_metacmd_ID_to_uppercase = 31; -static int32_t fcoder_metacmd_ID_to_lowercase = 32; -static int32_t fcoder_metacmd_ID_clean_all_lines = 33; -static int32_t fcoder_metacmd_ID_basic_change_active_panel = 34; -static int32_t fcoder_metacmd_ID_close_panel = 35; -static int32_t fcoder_metacmd_ID_show_scrollbar = 36; -static int32_t fcoder_metacmd_ID_hide_scrollbar = 37; -static int32_t fcoder_metacmd_ID_show_filebar = 38; -static int32_t fcoder_metacmd_ID_hide_filebar = 39; -static int32_t fcoder_metacmd_ID_toggle_filebar = 40; -static int32_t fcoder_metacmd_ID_toggle_line_wrap = 41; -static int32_t fcoder_metacmd_ID_increase_line_wrap = 42; -static int32_t fcoder_metacmd_ID_decrease_line_wrap = 43; -static int32_t fcoder_metacmd_ID_toggle_virtual_whitespace = 44; -static int32_t fcoder_metacmd_ID_toggle_show_whitespace = 45; -static int32_t fcoder_metacmd_ID_eol_dosify = 46; -static int32_t fcoder_metacmd_ID_eol_nixify = 47; -static int32_t fcoder_metacmd_ID_exit_4coder = 48; -static int32_t fcoder_metacmd_ID_goto_line = 49; -static int32_t fcoder_metacmd_ID_search = 50; -static int32_t fcoder_metacmd_ID_reverse_search = 51; -static int32_t fcoder_metacmd_ID_search_identifier = 52; -static int32_t fcoder_metacmd_ID_reverse_search_identifier = 53; -static int32_t fcoder_metacmd_ID_replace_in_range = 54; -static int32_t fcoder_metacmd_ID_query_replace = 55; -static int32_t fcoder_metacmd_ID_query_replace_identifier = 56; -static int32_t fcoder_metacmd_ID_save_all_dirty_buffers = 57; -static int32_t fcoder_metacmd_ID_undo = 58; -static int32_t fcoder_metacmd_ID_redo = 59; -static int32_t fcoder_metacmd_ID_interactive_new = 60; -static int32_t fcoder_metacmd_ID_interactive_open = 61; -static int32_t fcoder_metacmd_ID_interactive_open_or_new = 62; -static int32_t fcoder_metacmd_ID_interactive_switch_buffer = 63; -static int32_t fcoder_metacmd_ID_interactive_kill_buffer = 64; -static int32_t fcoder_metacmd_ID_reopen = 65; -static int32_t fcoder_metacmd_ID_save = 66; -static int32_t fcoder_metacmd_ID_kill_buffer = 67; -static int32_t fcoder_metacmd_ID_open_color_tweaker = 68; -static int32_t fcoder_metacmd_ID_open_debug = 69; -static int32_t fcoder_metacmd_ID_build_search = 70; -static int32_t fcoder_metacmd_ID_build_in_build_panel = 71; -static int32_t fcoder_metacmd_ID_close_build_panel = 72; -static int32_t fcoder_metacmd_ID_change_to_build_panel = 73; -static int32_t fcoder_metacmd_ID_copy = 74; -static int32_t fcoder_metacmd_ID_cut = 75; -static int32_t fcoder_metacmd_ID_paste = 76; -static int32_t fcoder_metacmd_ID_paste_next = 77; -static int32_t fcoder_metacmd_ID_change_active_panel = 78; -static int32_t fcoder_metacmd_ID_change_active_panel_backwards = 79; -static int32_t fcoder_metacmd_ID_open_panel_vsplit = 80; -static int32_t fcoder_metacmd_ID_open_panel_hsplit = 81; -static int32_t fcoder_metacmd_ID_suppress_mouse = 82; -static int32_t fcoder_metacmd_ID_allow_mouse = 83; -static int32_t fcoder_metacmd_ID_toggle_mouse = 84; -static int32_t fcoder_metacmd_ID_toggle_fullscreen = 85; -static int32_t fcoder_metacmd_ID_remap_interactive = 86; -static int32_t fcoder_metacmd_ID_seek_whitespace_right = 87; -static int32_t fcoder_metacmd_ID_seek_whitespace_left = 88; -static int32_t fcoder_metacmd_ID_seek_token_right = 89; -static int32_t fcoder_metacmd_ID_seek_token_left = 90; -static int32_t fcoder_metacmd_ID_seek_white_or_token_right = 91; -static int32_t fcoder_metacmd_ID_seek_white_or_token_left = 92; -static int32_t fcoder_metacmd_ID_seek_alphanumeric_right = 93; -static int32_t fcoder_metacmd_ID_seek_alphanumeric_left = 94; -static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_right = 95; -static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_left = 96; -static int32_t fcoder_metacmd_ID_backspace_word = 97; -static int32_t fcoder_metacmd_ID_delete_word = 98; -static int32_t fcoder_metacmd_ID_snipe_token_or_word = 99; -static int32_t fcoder_metacmd_ID_snipe_token_or_word_right = 100; -static int32_t fcoder_metacmd_ID_duplicate_line = 101; -static int32_t fcoder_metacmd_ID_delete_line = 102; -static int32_t fcoder_metacmd_ID_paste_and_indent = 103; -static int32_t fcoder_metacmd_ID_paste_next_and_indent = 104; -static int32_t fcoder_metacmd_ID_open_long_braces = 105; -static int32_t fcoder_metacmd_ID_open_long_braces_semicolon = 106; -static int32_t fcoder_metacmd_ID_open_long_braces_break = 107; -static int32_t fcoder_metacmd_ID_if0_off = 108; -static int32_t fcoder_metacmd_ID_write_todo = 109; -static int32_t fcoder_metacmd_ID_write_hack = 110; -static int32_t fcoder_metacmd_ID_write_note = 111; -static int32_t fcoder_metacmd_ID_write_block = 112; -static int32_t fcoder_metacmd_ID_write_zero_struct = 113; -static int32_t fcoder_metacmd_ID_open_file_in_quotes = 114; -static int32_t fcoder_metacmd_ID_open_in_other = 115; -static int32_t fcoder_metacmd_ID_open_matching_file_cpp = 116; -static int32_t fcoder_metacmd_ID_execute_arbitrary_command = 117; -static int32_t fcoder_metacmd_ID_list_all_functions_current_buffer = 118; -static int32_t fcoder_metacmd_ID_goto_jump_at_cursor_direct = 119; -static int32_t fcoder_metacmd_ID_goto_jump_at_cursor_same_panel_direct = 120; -static int32_t fcoder_metacmd_ID_goto_next_jump_direct = 121; -static int32_t fcoder_metacmd_ID_goto_prev_jump_direct = 122; -static int32_t fcoder_metacmd_ID_goto_next_jump_no_skips_direct = 123; -static int32_t fcoder_metacmd_ID_goto_prev_jump_no_skips_direct = 124; -static int32_t fcoder_metacmd_ID_goto_first_jump_direct = 125; -static int32_t fcoder_metacmd_ID_newline_or_goto_position_direct = 126; -static int32_t fcoder_metacmd_ID_newline_or_goto_position_same_panel_direct = 127; -static int32_t fcoder_metacmd_ID_goto_jump_at_cursor_sticky = 128; -static int32_t fcoder_metacmd_ID_goto_jump_at_cursor_same_panel_sticky = 129; -static int32_t fcoder_metacmd_ID_goto_next_jump_sticky = 130; -static int32_t fcoder_metacmd_ID_goto_prev_jump_sticky = 131; -static int32_t fcoder_metacmd_ID_goto_next_jump_no_skips_sticky = 132; -static int32_t fcoder_metacmd_ID_goto_prev_jump_no_skips_sticky = 133; -static int32_t fcoder_metacmd_ID_goto_first_jump_sticky = 134; -static int32_t fcoder_metacmd_ID_newline_or_goto_position_sticky = 135; -static int32_t fcoder_metacmd_ID_newline_or_goto_position_same_panel_sticky = 136; -static int32_t fcoder_metacmd_ID_open_all_code = 137; -static int32_t fcoder_metacmd_ID_open_all_code_recursive = 138; -static int32_t fcoder_metacmd_ID_close_all_code = 139; -static int32_t fcoder_metacmd_ID_load_project = 140; -static int32_t fcoder_metacmd_ID_project_fkey_command = 141; -static int32_t fcoder_metacmd_ID_project_go_to_root_directory = 142; -static int32_t fcoder_metacmd_ID_setup_new_project = 143; -static int32_t fcoder_metacmd_ID_set_bindings_choose = 144; -static int32_t fcoder_metacmd_ID_set_bindings_default = 145; -static int32_t fcoder_metacmd_ID_set_bindings_mac_default = 146; -static int32_t fcoder_metacmd_ID_list_all_locations = 147; -static int32_t fcoder_metacmd_ID_list_all_substring_locations = 148; -static int32_t fcoder_metacmd_ID_list_all_locations_case_insensitive = 149; -static int32_t fcoder_metacmd_ID_list_all_substring_locations_case_insensitive = 150; -static int32_t fcoder_metacmd_ID_list_all_locations_of_identifier = 151; -static int32_t fcoder_metacmd_ID_list_all_locations_of_identifier_case_insensitive = 152; -static int32_t fcoder_metacmd_ID_word_complete = 153; -static int32_t fcoder_metacmd_ID_execute_previous_cli = 154; -static int32_t fcoder_metacmd_ID_execute_any_cli = 155; -static int32_t fcoder_metacmd_ID_kill_rect = 156; -static int32_t fcoder_metacmd_ID_multi_line_edit = 157; -static int32_t fcoder_metacmd_ID_highlight_surrounding_scope = 158; -static int32_t fcoder_metacmd_ID_highlight_next_scope_absolute = 159; -static int32_t fcoder_metacmd_ID_highlight_prev_scope_absolute = 160; -static int32_t fcoder_metacmd_ID_place_in_scope = 161; -static int32_t fcoder_metacmd_ID_delete_current_scope = 162; -static int32_t fcoder_metacmd_ID_scope_absorb_down = 163; -static int32_t fcoder_metacmd_ID_rename_parameter = 164; -static int32_t fcoder_metacmd_ID_write_explicit_enum_values = 165; -static int32_t fcoder_metacmd_ID_miblo_increment_basic = 166; -static int32_t fcoder_metacmd_ID_miblo_decrement_basic = 167; -static int32_t fcoder_metacmd_ID_miblo_increment_time_stamp = 168; -static int32_t fcoder_metacmd_ID_miblo_decrement_time_stamp = 169; -static int32_t fcoder_metacmd_ID_miblo_increment_time_stamp_minute = 170; -static int32_t fcoder_metacmd_ID_miblo_decrement_time_stamp_minute = 171; +static int32_t fcoder_metacmd_ID_write_underscore = 5; +static int32_t fcoder_metacmd_ID_delete_char = 6; +static int32_t fcoder_metacmd_ID_backspace_char = 7; +static int32_t fcoder_metacmd_ID_set_mark = 8; +static int32_t fcoder_metacmd_ID_cursor_mark_swap = 9; +static int32_t fcoder_metacmd_ID_delete_range = 10; +static int32_t fcoder_metacmd_ID_center_view = 11; +static int32_t fcoder_metacmd_ID_left_adjust_view = 12; +static int32_t fcoder_metacmd_ID_click_set_cursor = 13; +static int32_t fcoder_metacmd_ID_click_set_mark = 14; +static int32_t fcoder_metacmd_ID_move_up = 15; +static int32_t fcoder_metacmd_ID_move_down = 16; +static int32_t fcoder_metacmd_ID_move_up_10 = 17; +static int32_t fcoder_metacmd_ID_move_down_10 = 18; +static int32_t fcoder_metacmd_ID_page_up = 19; +static int32_t fcoder_metacmd_ID_page_down = 20; +static int32_t fcoder_metacmd_ID_move_left = 21; +static int32_t fcoder_metacmd_ID_move_right = 22; +static int32_t fcoder_metacmd_ID_select_all = 23; +static int32_t fcoder_metacmd_ID_seek_whitespace_up = 24; +static int32_t fcoder_metacmd_ID_seek_whitespace_down = 25; +static int32_t fcoder_metacmd_ID_seek_beginning_of_textual_line = 26; +static int32_t fcoder_metacmd_ID_seek_end_of_textual_line = 27; +static int32_t fcoder_metacmd_ID_seek_beginning_of_line = 28; +static int32_t fcoder_metacmd_ID_seek_end_of_line = 29; +static int32_t fcoder_metacmd_ID_seek_whitespace_up_end_line = 30; +static int32_t fcoder_metacmd_ID_seek_whitespace_down_end_line = 31; +static int32_t fcoder_metacmd_ID_to_uppercase = 32; +static int32_t fcoder_metacmd_ID_to_lowercase = 33; +static int32_t fcoder_metacmd_ID_clean_all_lines = 34; +static int32_t fcoder_metacmd_ID_basic_change_active_panel = 35; +static int32_t fcoder_metacmd_ID_close_panel = 36; +static int32_t fcoder_metacmd_ID_show_scrollbar = 37; +static int32_t fcoder_metacmd_ID_hide_scrollbar = 38; +static int32_t fcoder_metacmd_ID_show_filebar = 39; +static int32_t fcoder_metacmd_ID_hide_filebar = 40; +static int32_t fcoder_metacmd_ID_toggle_filebar = 41; +static int32_t fcoder_metacmd_ID_toggle_line_wrap = 42; +static int32_t fcoder_metacmd_ID_increase_line_wrap = 43; +static int32_t fcoder_metacmd_ID_decrease_line_wrap = 44; +static int32_t fcoder_metacmd_ID_increase_face_size = 45; +static int32_t fcoder_metacmd_ID_decrease_face_size = 46; +static int32_t fcoder_metacmd_ID_toggle_virtual_whitespace = 47; +static int32_t fcoder_metacmd_ID_toggle_show_whitespace = 48; +static int32_t fcoder_metacmd_ID_eol_dosify = 49; +static int32_t fcoder_metacmd_ID_eol_nixify = 50; +static int32_t fcoder_metacmd_ID_exit_4coder = 51; +static int32_t fcoder_metacmd_ID_goto_line = 52; +static int32_t fcoder_metacmd_ID_search = 53; +static int32_t fcoder_metacmd_ID_reverse_search = 54; +static int32_t fcoder_metacmd_ID_search_identifier = 55; +static int32_t fcoder_metacmd_ID_reverse_search_identifier = 56; +static int32_t fcoder_metacmd_ID_replace_in_range = 57; +static int32_t fcoder_metacmd_ID_query_replace = 58; +static int32_t fcoder_metacmd_ID_query_replace_identifier = 59; +static int32_t fcoder_metacmd_ID_save_all_dirty_buffers = 60; +static int32_t fcoder_metacmd_ID_undo = 61; +static int32_t fcoder_metacmd_ID_redo = 62; +static int32_t fcoder_metacmd_ID_interactive_new = 63; +static int32_t fcoder_metacmd_ID_interactive_open = 64; +static int32_t fcoder_metacmd_ID_interactive_open_or_new = 65; +static int32_t fcoder_metacmd_ID_interactive_switch_buffer = 66; +static int32_t fcoder_metacmd_ID_interactive_kill_buffer = 67; +static int32_t fcoder_metacmd_ID_reopen = 68; +static int32_t fcoder_metacmd_ID_save = 69; +static int32_t fcoder_metacmd_ID_kill_buffer = 70; +static int32_t fcoder_metacmd_ID_open_color_tweaker = 71; +static int32_t fcoder_metacmd_ID_open_debug = 72; +static int32_t fcoder_metacmd_ID_build_search = 73; +static int32_t fcoder_metacmd_ID_build_in_build_panel = 74; +static int32_t fcoder_metacmd_ID_close_build_panel = 75; +static int32_t fcoder_metacmd_ID_change_to_build_panel = 76; +static int32_t fcoder_metacmd_ID_copy = 77; +static int32_t fcoder_metacmd_ID_cut = 78; +static int32_t fcoder_metacmd_ID_paste = 79; +static int32_t fcoder_metacmd_ID_paste_next = 80; +static int32_t fcoder_metacmd_ID_change_active_panel = 81; +static int32_t fcoder_metacmd_ID_change_active_panel_backwards = 82; +static int32_t fcoder_metacmd_ID_open_panel_vsplit = 83; +static int32_t fcoder_metacmd_ID_open_panel_hsplit = 84; +static int32_t fcoder_metacmd_ID_suppress_mouse = 85; +static int32_t fcoder_metacmd_ID_allow_mouse = 86; +static int32_t fcoder_metacmd_ID_toggle_mouse = 87; +static int32_t fcoder_metacmd_ID_toggle_fullscreen = 88; +static int32_t fcoder_metacmd_ID_remap_interactive = 89; +static int32_t fcoder_metacmd_ID_seek_whitespace_right = 90; +static int32_t fcoder_metacmd_ID_seek_whitespace_left = 91; +static int32_t fcoder_metacmd_ID_seek_token_right = 92; +static int32_t fcoder_metacmd_ID_seek_token_left = 93; +static int32_t fcoder_metacmd_ID_seek_white_or_token_right = 94; +static int32_t fcoder_metacmd_ID_seek_white_or_token_left = 95; +static int32_t fcoder_metacmd_ID_seek_alphanumeric_right = 96; +static int32_t fcoder_metacmd_ID_seek_alphanumeric_left = 97; +static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_right = 98; +static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_left = 99; +static int32_t fcoder_metacmd_ID_backspace_word = 100; +static int32_t fcoder_metacmd_ID_delete_word = 101; +static int32_t fcoder_metacmd_ID_snipe_token_or_word = 102; +static int32_t fcoder_metacmd_ID_snipe_token_or_word_right = 103; +static int32_t fcoder_metacmd_ID_duplicate_line = 104; +static int32_t fcoder_metacmd_ID_delete_line = 105; +static int32_t fcoder_metacmd_ID_paste_and_indent = 106; +static int32_t fcoder_metacmd_ID_paste_next_and_indent = 107; +static int32_t fcoder_metacmd_ID_open_long_braces = 108; +static int32_t fcoder_metacmd_ID_open_long_braces_semicolon = 109; +static int32_t fcoder_metacmd_ID_open_long_braces_break = 110; +static int32_t fcoder_metacmd_ID_if0_off = 111; +static int32_t fcoder_metacmd_ID_write_todo = 112; +static int32_t fcoder_metacmd_ID_write_hack = 113; +static int32_t fcoder_metacmd_ID_write_note = 114; +static int32_t fcoder_metacmd_ID_write_block = 115; +static int32_t fcoder_metacmd_ID_write_zero_struct = 116; +static int32_t fcoder_metacmd_ID_open_file_in_quotes = 117; +static int32_t fcoder_metacmd_ID_open_in_other = 118; +static int32_t fcoder_metacmd_ID_open_matching_file_cpp = 119; +static int32_t fcoder_metacmd_ID_execute_arbitrary_command = 120; +static int32_t fcoder_metacmd_ID_list_all_functions_current_buffer = 121; +static int32_t fcoder_metacmd_ID_goto_jump_at_cursor_direct = 122; +static int32_t fcoder_metacmd_ID_goto_jump_at_cursor_same_panel_direct = 123; +static int32_t fcoder_metacmd_ID_goto_next_jump_direct = 124; +static int32_t fcoder_metacmd_ID_goto_prev_jump_direct = 125; +static int32_t fcoder_metacmd_ID_goto_next_jump_no_skips_direct = 126; +static int32_t fcoder_metacmd_ID_goto_prev_jump_no_skips_direct = 127; +static int32_t fcoder_metacmd_ID_goto_first_jump_direct = 128; +static int32_t fcoder_metacmd_ID_newline_or_goto_position_direct = 129; +static int32_t fcoder_metacmd_ID_newline_or_goto_position_same_panel_direct = 130; +static int32_t fcoder_metacmd_ID_goto_jump_at_cursor_sticky = 131; +static int32_t fcoder_metacmd_ID_goto_jump_at_cursor_same_panel_sticky = 132; +static int32_t fcoder_metacmd_ID_goto_next_jump_sticky = 133; +static int32_t fcoder_metacmd_ID_goto_prev_jump_sticky = 134; +static int32_t fcoder_metacmd_ID_goto_next_jump_no_skips_sticky = 135; +static int32_t fcoder_metacmd_ID_goto_prev_jump_no_skips_sticky = 136; +static int32_t fcoder_metacmd_ID_goto_first_jump_sticky = 137; +static int32_t fcoder_metacmd_ID_newline_or_goto_position_sticky = 138; +static int32_t fcoder_metacmd_ID_newline_or_goto_position_same_panel_sticky = 139; +static int32_t fcoder_metacmd_ID_open_all_code = 140; +static int32_t fcoder_metacmd_ID_open_all_code_recursive = 141; +static int32_t fcoder_metacmd_ID_close_all_code = 142; +static int32_t fcoder_metacmd_ID_load_project = 143; +static int32_t fcoder_metacmd_ID_project_fkey_command = 144; +static int32_t fcoder_metacmd_ID_project_go_to_root_directory = 145; +static int32_t fcoder_metacmd_ID_setup_new_project = 146; +static int32_t fcoder_metacmd_ID_set_bindings_choose = 147; +static int32_t fcoder_metacmd_ID_set_bindings_default = 148; +static int32_t fcoder_metacmd_ID_set_bindings_mac_default = 149; +static int32_t fcoder_metacmd_ID_list_all_locations = 150; +static int32_t fcoder_metacmd_ID_list_all_substring_locations = 151; +static int32_t fcoder_metacmd_ID_list_all_locations_case_insensitive = 152; +static int32_t fcoder_metacmd_ID_list_all_substring_locations_case_insensitive = 153; +static int32_t fcoder_metacmd_ID_list_all_locations_of_identifier = 154; +static int32_t fcoder_metacmd_ID_list_all_locations_of_identifier_case_insensitive = 155; +static int32_t fcoder_metacmd_ID_word_complete = 156; +static int32_t fcoder_metacmd_ID_execute_previous_cli = 157; +static int32_t fcoder_metacmd_ID_execute_any_cli = 158; +static int32_t fcoder_metacmd_ID_kill_rect = 159; +static int32_t fcoder_metacmd_ID_multi_line_edit = 160; +static int32_t fcoder_metacmd_ID_highlight_surrounding_scope = 161; +static int32_t fcoder_metacmd_ID_highlight_next_scope_absolute = 162; +static int32_t fcoder_metacmd_ID_highlight_prev_scope_absolute = 163; +static int32_t fcoder_metacmd_ID_place_in_scope = 164; +static int32_t fcoder_metacmd_ID_delete_current_scope = 165; +static int32_t fcoder_metacmd_ID_scope_absorb_down = 166; +static int32_t fcoder_metacmd_ID_rename_parameter = 167; +static int32_t fcoder_metacmd_ID_write_explicit_enum_values = 168; +static int32_t fcoder_metacmd_ID_miblo_increment_basic = 169; +static int32_t fcoder_metacmd_ID_miblo_decrement_basic = 170; +static int32_t fcoder_metacmd_ID_miblo_increment_time_stamp = 171; +static int32_t fcoder_metacmd_ID_miblo_decrement_time_stamp = 172; +static int32_t fcoder_metacmd_ID_miblo_increment_time_stamp_minute = 173; +static int32_t fcoder_metacmd_ID_miblo_decrement_time_stamp_minute = 174; diff --git a/4coder_generated/remapping.h b/4coder_generated/remapping.h index 54216e71..2a3186cf 100644 --- a/4coder_generated/remapping.h +++ b/4coder_generated/remapping.h @@ -12,6 +12,7 @@ bind(context, 'o', MDFR_ALT, open_in_other); bind(context, 'k', MDFR_CTRL, interactive_kill_buffer); bind(context, 'i', MDFR_CTRL, interactive_switch_buffer); bind(context, 'h', MDFR_CTRL, project_go_to_root_directory); +bind(context, 'H', MDFR_CTRL, reload_current_project); bind(context, 'S', MDFR_CTRL, save_all_dirty_buffers); bind(context, 'c', MDFR_ALT, open_color_tweaker); bind(context, 'd', MDFR_ALT, open_debug); @@ -30,6 +31,8 @@ bind(context, 'b', MDFR_ALT, toggle_filebar); bind(context, '@', MDFR_ALT, toggle_mouse); bind(context, key_page_up, MDFR_CTRL, toggle_fullscreen); bind(context, 'E', MDFR_ALT, exit_4coder); +bind(context, '+', MDFR_CTRL, increase_face_size); +bind(context, '-', MDFR_CTRL, decrease_face_size); bind(context, key_f1, MDFR_NONE, project_fkey_command); bind(context, key_f2, MDFR_NONE, project_fkey_command); bind(context, key_f3, MDFR_NONE, project_fkey_command); @@ -68,8 +71,8 @@ bind(context, key_right, MDFR_CTRL, seek_whitespace_right); bind(context, key_left, MDFR_CTRL, seek_whitespace_left); bind(context, key_up, MDFR_CTRL, seek_whitespace_up_end_line); bind(context, key_down, MDFR_CTRL, seek_whitespace_down_end_line); -bind(context, key_up, MDFR_ALT, move_up_10); -bind(context, key_down, MDFR_ALT, move_down_10); +bind(context, key_up, MDFR_ALT, move_line_up); +bind(context, key_down, MDFR_ALT, move_line_down); bind(context, key_back, MDFR_CTRL, backspace_word); bind(context, key_del, MDFR_CTRL, delete_word); bind(context, key_back, MDFR_ALT, snipe_token_or_word); @@ -78,19 +81,23 @@ bind(context, ' ', MDFR_CTRL, set_mark); bind(context, 'a', MDFR_CTRL, replace_in_range); bind(context, 'c', MDFR_CTRL, copy); bind(context, 'd', MDFR_CTRL, delete_range); +bind(context, 'D', MDFR_CTRL, delete_line); bind(context, 'e', MDFR_CTRL, center_view); bind(context, 'E', MDFR_CTRL, left_adjust_view); bind(context, 'f', MDFR_CTRL, search); bind(context, 'F', MDFR_CTRL, list_all_locations); bind(context, 'F', MDFR_ALT, list_all_substring_locations_case_insensitive); bind(context, 'g', MDFR_CTRL, goto_line); +bind(context, 'G', MDFR_CTRL, list_all_locations_of_selection); bind(context, 'j', MDFR_CTRL, to_lowercase); bind(context, 'K', MDFR_CTRL, kill_buffer); bind(context, 'l', MDFR_CTRL, toggle_line_wrap); +bind(context, 'L', MDFR_CTRL, duplicate_line); bind(context, 'm', MDFR_CTRL, cursor_mark_swap); bind(context, 'O', MDFR_CTRL, reopen); bind(context, 'q', MDFR_CTRL, query_replace); bind(context, 'Q', MDFR_CTRL, query_replace_identifier); +bind(context, 'q', MDFR_ALT, query_replace_selection); bind(context, 'r', MDFR_CTRL, reverse_search); bind(context, 's', MDFR_CTRL, save); bind(context, 't', MDFR_CTRL, search_identifier); @@ -108,7 +115,7 @@ bind(context, '?', MDFR_CTRL, toggle_show_whitespace); bind(context, '~', MDFR_CTRL, clean_all_lines); bind(context, '\n', MDFR_NONE, newline_or_goto_position); bind(context, '\n', MDFR_SHIFT, newline_or_goto_position_same_panel); -bind(context, ' ', MDFR_SHIFT, write_character); +bind(context, ' ', MDFR_SHIFT, write_underscore); end_map(context); begin_map(context, default_code_map); inherit_map(context, mapid_file); @@ -131,6 +138,12 @@ bind(context, 'y', MDFR_ALT, write_note); bind(context, '[', MDFR_CTRL, open_long_braces); bind(context, '{', MDFR_CTRL, open_long_braces_semicolon); bind(context, '}', MDFR_CTRL, open_long_braces_break); +bind(context, '[', MDFR_ALT, highlight_surrounding_scope); +bind(context, ']', MDFR_ALT, highlight_prev_scope_absolute); +bind(context, '\'', MDFR_ALT, highlight_next_scope_absolute); +bind(context, '/', MDFR_ALT, place_in_scope); +bind(context, '-', MDFR_ALT, delete_current_scope); +bind(context, 'j', MDFR_ALT, scope_absorb_down); bind(context, 'i', MDFR_ALT, if0_off); bind(context, '1', MDFR_ALT, open_file_in_quotes); bind(context, '2', MDFR_ALT, open_matching_file_cpp); @@ -151,6 +164,7 @@ bind(context, 'o', MDFR_CTRL, open_in_other); bind(context, 'k', MDFR_CMND, interactive_kill_buffer); bind(context, 'i', MDFR_CMND, interactive_switch_buffer); bind(context, 'h', MDFR_CMND, project_go_to_root_directory); +bind(context, 'H', MDFR_CMND, reload_current_project); bind(context, 'S', MDFR_CMND, save_all_dirty_buffers); bind(context, 'c', MDFR_CTRL, open_color_tweaker); bind(context, 'd', MDFR_CTRL, open_debug); @@ -216,15 +230,18 @@ bind(context, '/', MDFR_CMND, set_mark); bind(context, 'a', MDFR_CMND, replace_in_range); bind(context, 'c', MDFR_CMND, copy); bind(context, 'd', MDFR_CMND, delete_range); +bind(context, 'D', MDFR_CMND, delete_line); bind(context, 'e', MDFR_CMND, center_view); bind(context, 'E', MDFR_CMND, left_adjust_view); bind(context, 'f', MDFR_CMND, search); bind(context, 'F', MDFR_CMND, list_all_locations); bind(context, 'F', MDFR_CTRL, list_all_substring_locations_case_insensitive); bind(context, 'g', MDFR_CMND, goto_line); +bind(context, 'G', MDFR_CMND, list_all_locations_of_selection); bind(context, 'j', MDFR_CMND, to_lowercase); bind(context, 'K', MDFR_CMND, kill_buffer); bind(context, 'l', MDFR_CMND, toggle_line_wrap); +bind(context, 'L', MDFR_CMND, duplicate_line); bind(context, 'm', MDFR_CMND, cursor_mark_swap); bind(context, 'O', MDFR_CMND, reopen); bind(context, 'q', MDFR_CMND, query_replace); @@ -246,7 +263,7 @@ bind(context, '?', MDFR_CMND, toggle_show_whitespace); bind(context, '~', MDFR_CMND, clean_all_lines); bind(context, '\n', MDFR_NONE, newline_or_goto_position); bind(context, '\n', MDFR_SHIFT, newline_or_goto_position_same_panel); -bind(context, ' ', MDFR_SHIFT, write_character); +bind(context, ' ', MDFR_SHIFT, write_underscore); end_map(context); begin_map(context, default_code_map); inherit_map(context, mapid_file); @@ -269,6 +286,12 @@ bind(context, 'y', MDFR_CTRL, write_note); bind(context, '[', MDFR_CMND, open_long_braces); bind(context, '{', MDFR_CMND, open_long_braces_semicolon); bind(context, '}', MDFR_CMND, open_long_braces_break); +bind(context, '[', MDFR_CTRL, highlight_surrounding_scope); +bind(context, ']', MDFR_CTRL, highlight_prev_scope_absolute); +bind(context, '\'', MDFR_CTRL, highlight_next_scope_absolute); +bind(context, '/', MDFR_CTRL, place_in_scope); +bind(context, '-', MDFR_CTRL, delete_current_scope); +bind(context, 'j', MDFR_CTRL, scope_absorb_down); bind(context, 'i', MDFR_CTRL, if0_off); bind(context, '1', MDFR_CTRL, open_file_in_quotes); bind(context, '2', MDFR_CTRL, open_matching_file_cpp); @@ -309,7 +332,7 @@ Meta_Sub_Map *sub_maps; int32_t sub_map_count; LINK_PROCS(void (*fill_keys_proc)(Bind_Helper *context);) }; -static Meta_Key_Bind fcoder_binds_for_default_mapid_global[45] = { +static Meta_Key_Bind fcoder_binds_for_default_mapid_global[48] = { {0, 112, 1, "open_panel_vsplit", 17, LINK_PROCS(open_panel_vsplit)}, {0, 95, 1, "open_panel_hsplit", 17, LINK_PROCS(open_panel_hsplit)}, {0, 80, 1, "close_panel", 11, LINK_PROCS(close_panel)}, @@ -321,6 +344,7 @@ static Meta_Key_Bind fcoder_binds_for_default_mapid_global[45] = { {0, 107, 1, "interactive_kill_buffer", 23, LINK_PROCS(interactive_kill_buffer)}, {0, 105, 1, "interactive_switch_buffer", 25, LINK_PROCS(interactive_switch_buffer)}, {0, 104, 1, "project_go_to_root_directory", 28, LINK_PROCS(project_go_to_root_directory)}, +{0, 72, 1, "reload_current_project", 22, LINK_PROCS(reload_current_project)}, {0, 83, 1, "save_all_dirty_buffers", 22, LINK_PROCS(save_all_dirty_buffers)}, {0, 99, 2, "open_color_tweaker", 18, LINK_PROCS(open_color_tweaker)}, {0, 100, 2, "open_debug", 10, LINK_PROCS(open_debug)}, @@ -339,6 +363,8 @@ static Meta_Key_Bind fcoder_binds_for_default_mapid_global[45] = { {0, 64, 2, "toggle_mouse", 12, LINK_PROCS(toggle_mouse)}, {0, 55305, 1, "toggle_fullscreen", 17, LINK_PROCS(toggle_fullscreen)}, {0, 69, 2, "exit_4coder", 11, LINK_PROCS(exit_4coder)}, +{0, 43, 1, "increase_face_size", 18, LINK_PROCS(increase_face_size)}, +{0, 45, 1, "decrease_face_size", 18, LINK_PROCS(decrease_face_size)}, {0, 55312, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55313, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55314, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, @@ -356,7 +382,7 @@ static Meta_Key_Bind fcoder_binds_for_default_mapid_global[45] = { {0, 55326, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55327, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, }; -static Meta_Key_Bind fcoder_binds_for_default_mapid_file[61] = { +static Meta_Key_Bind fcoder_binds_for_default_mapid_file[65] = { {1, 0, 0, "write_character", 15, LINK_PROCS(write_character)}, {0, 55308, 0, "click_set_cursor", 16, LINK_PROCS(click_set_cursor)}, {0, 55310, 0, "click_set_mark", 14, LINK_PROCS(click_set_mark)}, @@ -377,8 +403,8 @@ static Meta_Key_Bind fcoder_binds_for_default_mapid_file[61] = { {0, 55299, 1, "seek_whitespace_left", 20, LINK_PROCS(seek_whitespace_left)}, {0, 55297, 1, "seek_whitespace_up_end_line", 27, LINK_PROCS(seek_whitespace_up_end_line)}, {0, 55298, 1, "seek_whitespace_down_end_line", 29, LINK_PROCS(seek_whitespace_down_end_line)}, -{0, 55297, 2, "move_up_10", 10, LINK_PROCS(move_up_10)}, -{0, 55298, 2, "move_down_10", 12, LINK_PROCS(move_down_10)}, +{0, 55297, 2, "move_line_up", 12, LINK_PROCS(move_line_up)}, +{0, 55298, 2, "move_line_down", 14, LINK_PROCS(move_line_down)}, {0, 55296, 1, "backspace_word", 14, LINK_PROCS(backspace_word)}, {0, 55301, 1, "delete_word", 11, LINK_PROCS(delete_word)}, {0, 55296, 2, "snipe_token_or_word", 19, LINK_PROCS(snipe_token_or_word)}, @@ -387,19 +413,23 @@ static Meta_Key_Bind fcoder_binds_for_default_mapid_file[61] = { {0, 97, 1, "replace_in_range", 16, LINK_PROCS(replace_in_range)}, {0, 99, 1, "copy", 4, LINK_PROCS(copy)}, {0, 100, 1, "delete_range", 12, LINK_PROCS(delete_range)}, +{0, 68, 1, "delete_line", 11, LINK_PROCS(delete_line)}, {0, 101, 1, "center_view", 11, LINK_PROCS(center_view)}, {0, 69, 1, "left_adjust_view", 16, LINK_PROCS(left_adjust_view)}, {0, 102, 1, "search", 6, LINK_PROCS(search)}, {0, 70, 1, "list_all_locations", 18, LINK_PROCS(list_all_locations)}, {0, 70, 2, "list_all_substring_locations_case_insensitive", 45, LINK_PROCS(list_all_substring_locations_case_insensitive)}, {0, 103, 1, "goto_line", 9, LINK_PROCS(goto_line)}, +{0, 71, 1, "list_all_locations_of_selection", 31, LINK_PROCS(list_all_locations_of_selection)}, {0, 106, 1, "to_lowercase", 12, LINK_PROCS(to_lowercase)}, {0, 75, 1, "kill_buffer", 11, LINK_PROCS(kill_buffer)}, {0, 108, 1, "toggle_line_wrap", 16, LINK_PROCS(toggle_line_wrap)}, +{0, 76, 1, "duplicate_line", 14, LINK_PROCS(duplicate_line)}, {0, 109, 1, "cursor_mark_swap", 16, LINK_PROCS(cursor_mark_swap)}, {0, 79, 1, "reopen", 6, LINK_PROCS(reopen)}, {0, 113, 1, "query_replace", 13, LINK_PROCS(query_replace)}, {0, 81, 1, "query_replace_identifier", 24, LINK_PROCS(query_replace_identifier)}, +{0, 113, 2, "query_replace_selection", 23, LINK_PROCS(query_replace_selection)}, {0, 114, 1, "reverse_search", 14, LINK_PROCS(reverse_search)}, {0, 115, 1, "save", 4, LINK_PROCS(save)}, {0, 116, 1, "search_identifier", 17, LINK_PROCS(search_identifier)}, @@ -417,9 +447,9 @@ static Meta_Key_Bind fcoder_binds_for_default_mapid_file[61] = { {0, 126, 1, "clean_all_lines", 15, LINK_PROCS(clean_all_lines)}, {0, 10, 0, "newline_or_goto_position", 24, LINK_PROCS(newline_or_goto_position)}, {0, 10, 8, "newline_or_goto_position_same_panel", 35, LINK_PROCS(newline_or_goto_position_same_panel)}, -{0, 32, 8, "write_character", 15, LINK_PROCS(write_character)}, +{0, 32, 8, "write_underscore", 16, LINK_PROCS(write_underscore)}, }; -static Meta_Key_Bind fcoder_binds_for_default_default_code_map[24] = { +static Meta_Key_Bind fcoder_binds_for_default_default_code_map[30] = { {0, 55300, 1, "seek_alphanumeric_or_camel_right", 32, LINK_PROCS(seek_alphanumeric_or_camel_right)}, {0, 55299, 1, "seek_alphanumeric_or_camel_left", 31, LINK_PROCS(seek_alphanumeric_or_camel_left)}, {0, 10, 0, "write_and_auto_tab", 18, LINK_PROCS(write_and_auto_tab)}, @@ -439,6 +469,12 @@ static Meta_Key_Bind fcoder_binds_for_default_default_code_map[24] = { {0, 91, 1, "open_long_braces", 16, LINK_PROCS(open_long_braces)}, {0, 123, 1, "open_long_braces_semicolon", 26, LINK_PROCS(open_long_braces_semicolon)}, {0, 125, 1, "open_long_braces_break", 22, LINK_PROCS(open_long_braces_break)}, +{0, 91, 2, "highlight_surrounding_scope", 27, LINK_PROCS(highlight_surrounding_scope)}, +{0, 93, 2, "highlight_prev_scope_absolute", 29, LINK_PROCS(highlight_prev_scope_absolute)}, +{0, 39, 2, "highlight_next_scope_absolute", 29, LINK_PROCS(highlight_next_scope_absolute)}, +{0, 47, 2, "place_in_scope", 14, LINK_PROCS(place_in_scope)}, +{0, 45, 2, "delete_current_scope", 20, LINK_PROCS(delete_current_scope)}, +{0, 106, 2, "scope_absorb_down", 17, LINK_PROCS(scope_absorb_down)}, {0, 105, 2, "if0_off", 7, LINK_PROCS(if0_off)}, {0, 49, 2, "open_file_in_quotes", 19, LINK_PROCS(open_file_in_quotes)}, {0, 50, 2, "open_matching_file_cpp", 22, LINK_PROCS(open_matching_file_cpp)}, @@ -446,11 +482,11 @@ static Meta_Key_Bind fcoder_binds_for_default_default_code_map[24] = { {0, 73, 1, "list_all_functions_current_buffer", 33, LINK_PROCS(list_all_functions_current_buffer)}, }; static Meta_Sub_Map fcoder_submaps_for_default[3] = { -{"mapid_global", 12, "TODO", 4, 0, 0, fcoder_binds_for_default_mapid_global, 45}, -{"mapid_file", 10, "TODO", 4, 0, 0, fcoder_binds_for_default_mapid_file, 61}, -{"default_code_map", 16, "TODO", 4, "mapid_file", 10, fcoder_binds_for_default_default_code_map, 24}, +{"mapid_global", 12, "TODO", 4, 0, 0, fcoder_binds_for_default_mapid_global, 48}, +{"mapid_file", 10, "TODO", 4, 0, 0, fcoder_binds_for_default_mapid_file, 65}, +{"default_code_map", 16, "TODO", 4, "mapid_file", 10, fcoder_binds_for_default_default_code_map, 30}, }; -static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_global[45] = { +static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_global[46] = { {0, 112, 4, "open_panel_vsplit", 17, LINK_PROCS(open_panel_vsplit)}, {0, 95, 4, "open_panel_hsplit", 17, LINK_PROCS(open_panel_hsplit)}, {0, 80, 4, "close_panel", 11, LINK_PROCS(close_panel)}, @@ -462,6 +498,7 @@ static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_global[45] = { {0, 107, 4, "interactive_kill_buffer", 23, LINK_PROCS(interactive_kill_buffer)}, {0, 105, 4, "interactive_switch_buffer", 25, LINK_PROCS(interactive_switch_buffer)}, {0, 104, 4, "project_go_to_root_directory", 28, LINK_PROCS(project_go_to_root_directory)}, +{0, 72, 4, "reload_current_project", 22, LINK_PROCS(reload_current_project)}, {0, 83, 4, "save_all_dirty_buffers", 22, LINK_PROCS(save_all_dirty_buffers)}, {0, 99, 1, "open_color_tweaker", 18, LINK_PROCS(open_color_tweaker)}, {0, 100, 1, "open_debug", 10, LINK_PROCS(open_debug)}, @@ -497,7 +534,7 @@ static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_global[45] = { {0, 55326, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55327, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, }; -static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_file[60] = { +static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_file[63] = { {1, 0, 0, "write_character", 15, LINK_PROCS(write_character)}, {1, 0, 2, "write_character", 15, LINK_PROCS(write_character)}, {0, 55308, 0, "click_set_cursor", 16, LINK_PROCS(click_set_cursor)}, @@ -527,15 +564,18 @@ static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_file[60] = { {0, 97, 4, "replace_in_range", 16, LINK_PROCS(replace_in_range)}, {0, 99, 4, "copy", 4, LINK_PROCS(copy)}, {0, 100, 4, "delete_range", 12, LINK_PROCS(delete_range)}, +{0, 68, 4, "delete_line", 11, LINK_PROCS(delete_line)}, {0, 101, 4, "center_view", 11, LINK_PROCS(center_view)}, {0, 69, 4, "left_adjust_view", 16, LINK_PROCS(left_adjust_view)}, {0, 102, 4, "search", 6, LINK_PROCS(search)}, {0, 70, 4, "list_all_locations", 18, LINK_PROCS(list_all_locations)}, {0, 70, 1, "list_all_substring_locations_case_insensitive", 45, LINK_PROCS(list_all_substring_locations_case_insensitive)}, {0, 103, 4, "goto_line", 9, LINK_PROCS(goto_line)}, +{0, 71, 4, "list_all_locations_of_selection", 31, LINK_PROCS(list_all_locations_of_selection)}, {0, 106, 4, "to_lowercase", 12, LINK_PROCS(to_lowercase)}, {0, 75, 4, "kill_buffer", 11, LINK_PROCS(kill_buffer)}, {0, 108, 4, "toggle_line_wrap", 16, LINK_PROCS(toggle_line_wrap)}, +{0, 76, 4, "duplicate_line", 14, LINK_PROCS(duplicate_line)}, {0, 109, 4, "cursor_mark_swap", 16, LINK_PROCS(cursor_mark_swap)}, {0, 79, 4, "reopen", 6, LINK_PROCS(reopen)}, {0, 113, 4, "query_replace", 13, LINK_PROCS(query_replace)}, @@ -557,9 +597,9 @@ static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_file[60] = { {0, 126, 4, "clean_all_lines", 15, LINK_PROCS(clean_all_lines)}, {0, 10, 0, "newline_or_goto_position", 24, LINK_PROCS(newline_or_goto_position)}, {0, 10, 8, "newline_or_goto_position_same_panel", 35, LINK_PROCS(newline_or_goto_position_same_panel)}, -{0, 32, 8, "write_character", 15, LINK_PROCS(write_character)}, +{0, 32, 8, "write_underscore", 16, LINK_PROCS(write_underscore)}, }; -static Meta_Key_Bind fcoder_binds_for_mac_default_default_code_map[24] = { +static Meta_Key_Bind fcoder_binds_for_mac_default_default_code_map[30] = { {0, 55300, 4, "seek_alphanumeric_or_camel_right", 32, LINK_PROCS(seek_alphanumeric_or_camel_right)}, {0, 55299, 4, "seek_alphanumeric_or_camel_left", 31, LINK_PROCS(seek_alphanumeric_or_camel_left)}, {0, 10, 0, "write_and_auto_tab", 18, LINK_PROCS(write_and_auto_tab)}, @@ -579,6 +619,12 @@ static Meta_Key_Bind fcoder_binds_for_mac_default_default_code_map[24] = { {0, 91, 4, "open_long_braces", 16, LINK_PROCS(open_long_braces)}, {0, 123, 4, "open_long_braces_semicolon", 26, LINK_PROCS(open_long_braces_semicolon)}, {0, 125, 4, "open_long_braces_break", 22, LINK_PROCS(open_long_braces_break)}, +{0, 91, 1, "highlight_surrounding_scope", 27, LINK_PROCS(highlight_surrounding_scope)}, +{0, 93, 1, "highlight_prev_scope_absolute", 29, LINK_PROCS(highlight_prev_scope_absolute)}, +{0, 39, 1, "highlight_next_scope_absolute", 29, LINK_PROCS(highlight_next_scope_absolute)}, +{0, 47, 1, "place_in_scope", 14, LINK_PROCS(place_in_scope)}, +{0, 45, 1, "delete_current_scope", 20, LINK_PROCS(delete_current_scope)}, +{0, 106, 1, "scope_absorb_down", 17, LINK_PROCS(scope_absorb_down)}, {0, 105, 1, "if0_off", 7, LINK_PROCS(if0_off)}, {0, 49, 1, "open_file_in_quotes", 19, LINK_PROCS(open_file_in_quotes)}, {0, 50, 1, "open_matching_file_cpp", 22, LINK_PROCS(open_matching_file_cpp)}, @@ -586,9 +632,9 @@ static Meta_Key_Bind fcoder_binds_for_mac_default_default_code_map[24] = { {0, 73, 4, "list_all_functions_current_buffer", 33, LINK_PROCS(list_all_functions_current_buffer)}, }; static Meta_Sub_Map fcoder_submaps_for_mac_default[3] = { -{"mapid_global", 12, "TODO", 4, 0, 0, fcoder_binds_for_mac_default_mapid_global, 45}, -{"mapid_file", 10, "TODO", 4, 0, 0, fcoder_binds_for_mac_default_mapid_file, 60}, -{"default_code_map", 16, "TODO", 4, "mapid_file", 10, fcoder_binds_for_mac_default_default_code_map, 24}, +{"mapid_global", 12, "TODO", 4, 0, 0, fcoder_binds_for_mac_default_mapid_global, 46}, +{"mapid_file", 10, "TODO", 4, 0, 0, fcoder_binds_for_mac_default_mapid_file, 63}, +{"default_code_map", 16, "TODO", 4, "mapid_file", 10, fcoder_binds_for_mac_default_default_code_map, 30}, }; static Meta_Mapping fcoder_meta_maps[2] = { {"default", 7, "TODO", 4, fcoder_submaps_for_default, 3, LINK_PROCS(fill_keys_default)}, diff --git a/4coder_project_commands.cpp b/4coder_project_commands.cpp index dde3e1b0..896daab1 100644 --- a/4coder_project_commands.cpp +++ b/4coder_project_commands.cpp @@ -400,28 +400,30 @@ load_project_from_config_data(Application_Links *app, Partition *part, char *con CUSTOM_COMMAND_SIG(load_project) CUSTOM_DOC("Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.") { + save_all_dirty_buffers(app); + Partition *part = &global_part; Temp_Memory temp = begin_temp_memory(part); char project_file_space[512]; - String project_name = make_fixed_width_string(project_file_space); - project_name.size = directory_get_hot(app, project_name.str, project_name.memory_size); - if (project_name.size >= project_name.memory_size){ - project_name.size = 0; + String project_path = make_fixed_width_string(project_file_space); + project_path.size = directory_get_hot(app, project_path.str, project_path.memory_size); + if (project_path.size >= project_path.memory_size){ + project_path.size = 0; } - if (project_name.size != 0){ + if (project_path.size != 0){ bool32 load_failed = false; for(;;){ - int32_t original_size = project_name.size; - append_sc(&project_name, "project.4coder"); - terminate_with_null(&project_name); + int32_t original_size = project_path.size; + append_sc(&project_path, "project.4coder"); + terminate_with_null(&project_path); - FILE *file = fopen(project_name.str, "rb"); - if (file){ - project_name.size = original_size; - terminate_with_null(&project_name); + FILE *file = fopen(project_path.str, "rb"); + if (file != 0){ + project_path.size = original_size; + terminate_with_null(&project_path); char *mem = 0; int32_t size = 0; @@ -429,15 +431,15 @@ CUSTOM_DOC("Looks for a project.4coder file in the current directory and tries t fclose(file); if (file_read_success){ - load_project_from_config_data(app, part, mem, size, project_name); + load_project_from_config_data(app, part, mem, size, project_path); } break; } else{ - project_name.size = original_size; - remove_last_folder(&project_name); + project_path.size = original_size; + remove_last_folder(&project_path); - if (project_name.size >= original_size){ + if (project_path.size >= original_size){ load_failed = true; break; } @@ -466,6 +468,47 @@ CUSTOM_DOC("Looks for a project.4coder file in the current directory and tries t end_temp_memory(temp); } +CUSTOM_COMMAND_SIG(reload_current_project) +CUSTOM_DOC("If a project file has already been loaded, reloads the same file. Useful for when the project configuration is changed.") +{ + if (current_project.loaded){ + save_all_dirty_buffers(app); + + char space[512]; + String project_path = make_fixed_width_string(space); + append(&project_path, make_string(current_project.dir, current_project.dir_len)); + if (project_path.size < 1 || !char_is_slash(project_path.str[project_path.size - 1])){ + append(&project_path, "/"); + } + int32_t path_size = project_path.size; + append(&project_path, "project.4coder"); + terminate_with_null(&project_path); + + FILE *file = fopen(project_path.str, "rb"); + if (file != 0){ + project_path.size = path_size; + terminate_with_null(&project_path); + + Partition *part = &global_part; + Temp_Memory temp = begin_temp_memory(part); + + char *mem = 0; + int32_t size = 0; + bool32 file_read_success = file_handle_dump(part, file, &mem, &size); + fclose(file); + + if (file_read_success){ + load_project_from_config_data(app, part, mem, size, project_path); + } + + end_temp_memory(temp); + } + else{ + print_message(app, literal("project.4coder file not found. Previous configuration left unchanged.")); + } + } +} + /////////////////////////////// static void @@ -766,6 +809,8 @@ CUSTOM_DOC("Queries the user for several configuration options and initializes a else{ print_message(app, literal("project already setup, no changes made\n")); } + + load_project(app); } #endif diff --git a/4coder_scope_commands.cpp b/4coder_scope_commands.cpp new file mode 100644 index 00000000..7b2c50d6 --- /dev/null +++ b/4coder_scope_commands.cpp @@ -0,0 +1,812 @@ +/* +4coder_scope_commands.cpp - A set of commands and helpers relevant for scope level navigation and editing. + +TYPE: 'drop-in-command-pack' +*/ + +// TOP + +enum{ + FindScope_Parent = 0x1, + FindScope_NextSibling = 0x1, + FindScope_EndOfToken = 0x2, +}; + +static bool32 +find_scope_top(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){ + Cpp_Get_Token_Result get_result = {0}; + + bool32 success = 0; + int32_t position = 0; + + if (buffer_get_token_index(app, buffer, start_pos, &get_result)){ + int32_t token_index = get_result.token_index; + if (flags & FindScope_Parent){ + --token_index; + if (get_result.in_whitespace){ + ++token_index; + } + } + + if (token_index >= 0){ + static const int32_t chunk_cap = 512; + Cpp_Token chunk[chunk_cap]; + Stream_Tokens stream = {0}; + + if (init_stream_tokens(&stream, app, buffer, token_index, chunk, chunk_cap)){int32_t nest_level = 0; + bool32 still_looping = 0; + do{ + for (; token_index >= stream.start; --token_index){ + Cpp_Token *token = &stream.tokens[token_index]; + + switch (token->type){ + case CPP_TOKEN_BRACE_OPEN: + { + if (nest_level == 0){ + success = 1; + position = token->start; + if (flags & FindScope_EndOfToken){ + position += token->size; + } + goto finished; + } + else{ + --nest_level; + } + }break; + + case CPP_TOKEN_BRACE_CLOSE: + { + ++nest_level; + }break; + } + } + still_looping = backward_stream_tokens(&stream); + }while(still_looping); + } + } + } + + finished:; + *end_pos_out = position; + return(success); +} + +static bool32 +find_scope_bottom(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){ + Cpp_Get_Token_Result get_result = {0}; + + bool32 success = 0; + int32_t position = 0; + + if (buffer_get_token_index(app, buffer, start_pos, &get_result)){ + int32_t token_index = get_result.token_index+1; + if (flags & FindScope_Parent){ + --token_index; + if (get_result.in_whitespace){ + ++token_index; + } + } + + if (token_index >= 0){ + static const int32_t chunk_cap = 512; + Cpp_Token chunk[chunk_cap]; + Stream_Tokens stream = {0}; + + if (init_stream_tokens(&stream, app, buffer, token_index, chunk, chunk_cap)){ + int32_t nest_level = 0; + bool32 still_looping = 0; + do{ + for (; token_index < stream.end; ++token_index){ + Cpp_Token *token = &stream.tokens[token_index]; + + switch (token->type){ + case CPP_TOKEN_BRACE_OPEN: + { + ++nest_level; + }break; + + case CPP_TOKEN_BRACE_CLOSE: + { + if (nest_level == 0){ + success = 1; + position = token->start; + if (flags & FindScope_EndOfToken){ + position += token->size; + } + goto finished; + } + else{ + --nest_level; + } + }break; + } + } + still_looping = forward_stream_tokens(&stream); + }while(still_looping); + } + } + } + + finished:; + *end_pos_out = position; + return(success); +} + +static bool32 +find_next_scope(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){ + Cpp_Get_Token_Result get_result = {0}; + + bool32 success = 0; + int32_t position = 0; + + if (buffer_get_token_index(app, buffer, start_pos, &get_result)){ + int32_t token_index = get_result.token_index+1; + + if (token_index >= 0){ + static const int32_t chunk_cap = 512; + Cpp_Token chunk[chunk_cap]; + Stream_Tokens stream = {0}; + + if (init_stream_tokens(&stream, app, buffer, token_index, chunk, chunk_cap)){ + if (flags & FindScope_NextSibling){ + int32_t nest_level = 1; + + bool32 still_looping = 0; + do{ + for (; token_index < stream.end; ++token_index){ + Cpp_Token *token = &stream.tokens[token_index]; + + switch (token->type){ + case CPP_TOKEN_BRACE_OPEN: + { + if (nest_level == 0){ + success = 1; + position = token->start; + if (flags & FindScope_EndOfToken){ + position += token->size; + } + goto finished; + } + else{ + ++nest_level; + } + }break; + + case CPP_TOKEN_BRACE_CLOSE: + { + --nest_level; + if (nest_level == -1){ + position = start_pos; + goto finished; + } + }break; + } + } + still_looping = forward_stream_tokens(&stream); + }while(still_looping); + } + else{ + bool32 still_looping = 0; + do{ + for (; token_index < stream.end; ++token_index){ + Cpp_Token *token = &stream.tokens[token_index]; + + if (token->type == CPP_TOKEN_BRACE_OPEN){ + success = 1; + position = token->start; + if (flags & FindScope_EndOfToken){ + position += token->size; + } + goto finished; + } + } + still_looping = forward_stream_tokens(&stream); + }while(still_looping); + } + } + } + } + + finished:; + *end_pos_out = position; + return(success); +} + +static bool32 +find_prev_scope(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){ + Cpp_Get_Token_Result get_result = {0}; + + bool32 success = 0; + int32_t position = 0; + + if (buffer_get_token_index(app, buffer, start_pos, &get_result)){ + int32_t token_index = get_result.token_index-1; + + if (token_index >= 0){ + static const int32_t chunk_cap = 512; + Cpp_Token chunk[chunk_cap]; + Stream_Tokens stream = {0}; + + if (init_stream_tokens(&stream, app, buffer, token_index, chunk, chunk_cap)){ + if (flags & FindScope_NextSibling){ + int32_t nest_level = -1; + bool32 still_looping = 0; + do{ + for (; token_index >= stream.start; --token_index){ + Cpp_Token *token = &stream.tokens[token_index]; + + switch (token->type){ + case CPP_TOKEN_BRACE_OPEN: + { + if (nest_level == -1){ + position = start_pos; + goto finished; + } + else if (nest_level == 0){ + success = 1; + position = token->start; + if (flags & FindScope_EndOfToken){ + position += token->size; + } + goto finished; + } + else{ + --nest_level; + } + }break; + + case CPP_TOKEN_BRACE_CLOSE: + { + ++nest_level; + }break; + } + } + still_looping = backward_stream_tokens(&stream); + }while(still_looping); + } + else{ + bool32 still_looping = 0; + do{ + for (; token_index >= stream.start; --token_index){ + Cpp_Token *token = &stream.tokens[token_index]; + + if (token->type == CPP_TOKEN_BRACE_OPEN){ + success = 1; + position = token->start; + if (flags & FindScope_EndOfToken){ + position += token->size; + } + goto finished; + } + } + still_looping = backward_stream_tokens(&stream); + }while(still_looping); + } + } + } + } + + finished:; + *end_pos_out = position; + return(success); +} + +static void +view_set_to_region(Application_Links *app, View_Summary *view, int32_t major_pos, int32_t minor_pos, float normalized_threshold){ + Range range = make_range(major_pos, minor_pos); + bool32 bottom_major = false; + if (major_pos == range.max){ + bottom_major = true; + } + + Full_Cursor top, bottom; + if (view_compute_cursor(app, view, seek_pos(range.min), &top)){ + if (view_compute_cursor(app, view, seek_pos(range.max), &bottom)){ + float top_y = top.wrapped_y; + float bottom_y = bottom.wrapped_y; + if (view->unwrapped_lines){ + top_y = top.unwrapped_y; + bottom_y = bottom.unwrapped_y; + } + + GUI_Scroll_Vars scroll = view->scroll_vars; + float half_view_height = .5f*(float)(view->file_region.y1 - view->file_region.y0); + float threshold = normalized_threshold * half_view_height; + float current_center_y = ((float)scroll.target_y) + half_view_height; + + if (top_y < current_center_y - threshold || bottom_y > current_center_y + threshold){ + float center_target_y = .5f*(top_y + bottom_y); + + if (bottom_major){ + if (center_target_y < bottom_y - half_view_height * .9f){ + center_target_y = bottom_y - half_view_height * .9f; + } + } + else{ + if (center_target_y > top_y + half_view_height * .9f){ + center_target_y = top_y + half_view_height * .9f; + } + } + + float target_y = center_target_y - half_view_height; + if (target_y < 0){ + target_y = 0; + } + + scroll.target_y = (int32_t)(target_y); + view_set_scroll(app, view, scroll); + } + } + } +} + +static float scope_center_threshold = 0.75f; + +CUSTOM_COMMAND_SIG(highlight_surrounding_scope) +CUSTOM_DOC("Finds the scope enclosed by '{' '}' surrounding the cursor and puts the cursor and mark on the '{' and '}'.") +{ + uint32_t access = AccessProtected; + View_Summary view = get_active_view(app, access); + Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); + + int32_t start_pos = view.cursor.pos; + int32_t top = 0, bottom = 0; + if (find_scope_top(app, &buffer, start_pos, FindScope_Parent, &top)){ + view_set_cursor(app, &view, seek_pos(top), true); + if (find_scope_bottom(app, &buffer, start_pos, FindScope_Parent | FindScope_EndOfToken, &bottom)){ + view_set_mark(app, &view, seek_pos(bottom)); + view_set_to_region(app, &view, top, bottom, scope_center_threshold); + } + else{ + view_set_to_region(app, &view, top, top, scope_center_threshold); + } + } +} + +CUSTOM_COMMAND_SIG(highlight_next_scope_absolute) +CUSTOM_DOC("Finds the first scope started by '{' after the cursor and puts the cursor and mark on the '{' and '}'.") +{ + uint32_t access = AccessProtected; + View_Summary view = get_active_view(app, access); + Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); + + int32_t start_pos = view.cursor.pos; + int32_t top = 0, bottom = 0; + if (find_next_scope(app, &buffer, start_pos, 0, &top)){ + if (find_scope_bottom(app, &buffer, top, FindScope_EndOfToken, &bottom)){ + view_set_cursor(app, &view, seek_pos(top), true); + view_set_mark(app, &view, seek_pos(bottom)); + view_set_to_region(app, &view, top, bottom, scope_center_threshold); + } + } +} + +CUSTOM_COMMAND_SIG(highlight_prev_scope_absolute) +CUSTOM_DOC("Finds the first scope started by '{' before the cursor and puts the cursor and mark on the '{' and '}'.") +{ + uint32_t access = AccessProtected; + View_Summary view = get_active_view(app, access); + Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); + + int32_t start_pos = view.cursor.pos; + int32_t top = 0, bottom = 0; + if (find_prev_scope(app, &buffer, start_pos, 0, &top)){ + if (find_scope_bottom(app, &buffer, top, FindScope_EndOfToken, &bottom)){ + view_set_cursor(app, &view, seek_pos(top), true); + view_set_mark(app, &view, seek_pos(bottom)); + view_set_to_region(app, &view, top, bottom, scope_center_threshold); + } + } +} + +CUSTOM_COMMAND_SIG(place_in_scope) +CUSTOM_DOC("Wraps the code contained in the range between cursor and mark with a new curly brace scope.") +{ + uint32_t access = AccessOpen; + View_Summary view = get_active_view(app, access); + Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); + + Range lines; + Range range = get_range(&view); + lines.min = buffer_get_line_index(app, &buffer, range.min); + range.min = buffer_get_line_start(app, &buffer, lines.min); + + lines.max = buffer_get_line_index(app, &buffer, range.max); + range.max = buffer_get_line_end(app, &buffer, lines.max); + + bool32 do_full = false; + + if (lines.min < lines.max){ + do_full = true; + } + else if (!buffer_line_is_blank(app, &buffer, lines.min)){ + do_full = true; + } + + if (do_full){ + Buffer_Edit edits[2]; + char str[5] = "{\n\n}"; + + int32_t min_adjustment = 0; + int32_t max_adjustment = 4; + + if (buffer_line_is_blank(app, &buffer, lines.min)){ + str[0] = '\n'; + str[1] = '{'; + ++min_adjustment; + } + + if (buffer_line_is_blank(app, &buffer, lines.max)){ + str[2] = '}'; + str[3] = '\n'; + --max_adjustment; + } + + int32_t min_pos = range.min + min_adjustment; + int32_t max_pos = range.max + max_adjustment; + + int32_t cursor_pos = min_pos; + int32_t mark_pos = max_pos; + + if (view.cursor.pos > view.mark.pos){ + cursor_pos = max_pos; + mark_pos = min_pos; + } + + edits[0].str_start = 0; + edits[0].len = 2; + edits[0].start = range.min; + edits[0].end = range.min; + + edits[1].str_start = 2; + edits[1].len = 2; + edits[1].start = range.max; + edits[1].end = range.max; + + buffer_batch_edit(app, &buffer, str, 4, edits, 2, BatchEdit_Normal); + + view_set_cursor(app, &view, seek_pos(cursor_pos), true); + view_set_mark(app, &view, seek_pos(mark_pos)); + } + else{ + buffer_replace_range(app, &buffer, range.min, range.max, "{\n\n}", 4); + view_set_cursor(app, &view, seek_pos(range.min + 2), true); + view_set_mark(app, &view, seek_pos(range.min + 2)); + } +} + +CUSTOM_COMMAND_SIG(delete_current_scope) +CUSTOM_DOC("Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.") +{ + uint32_t access = AccessOpen; + View_Summary view = get_active_view(app, access); + Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); + + int32_t top = view.cursor.pos; + int32_t bottom = view.mark.pos; + + if (top > bottom){ + int32_t x = top; + top = bottom; + bottom = x; + } + + if (buffer_get_char(app, &buffer, top) == '{' && buffer_get_char(app, &buffer, bottom-1) == '}'){ + int32_t top_len = 1; + int32_t bottom_len = 1; + if (buffer_get_char(app, &buffer, top-1) == '\n'){ + top_len = 2; + } + if (buffer_get_char(app, &buffer, bottom+1) == '\n'){ + bottom_len = 2; + } + + Buffer_Edit edits[2]; + edits[0].str_start = 0; + edits[0].len = 0; + edits[0].start = top+1 - top_len; + edits[0].end = top+1; + + edits[1].str_start = 0; + edits[1].len = 0; + edits[1].start = bottom-1; + edits[1].end = bottom-1 + bottom_len; + + buffer_batch_edit(app, &buffer, 0, 0, edits, 2, BatchEdit_Normal); + } +} + +struct Statement_Parser{ + Stream_Tokens stream; + int32_t token_index; + Buffer_Summary *buffer; +}; + +static Cpp_Token* +parser_next_token(Statement_Parser *parser){ + Cpp_Token *result = 0; + bool32 still_looping = true; + while (parser->token_index >= parser->stream.end && still_looping){ + still_looping = forward_stream_tokens(&parser->stream); + } + if (parser->token_index < parser->stream.end){ + result = &parser->stream.tokens[parser->token_index]; + ++parser->token_index; + } + return(result); +} + +static bool32 parse_statement_down(Application_Links *app, Statement_Parser *parser, Cpp_Token *token_out); + +static bool32 +parse_for_down(Application_Links *app, Statement_Parser *parser, Cpp_Token *token_out){ + bool32 success = false; + Cpp_Token *token = parser_next_token(parser); + + int32_t paren_level = 0; + while (token != 0){ + if (!(token->flags & CPP_TFLAG_PP_BODY)){ + switch (token->type){ + case CPP_TOKEN_PARENTHESE_OPEN: + { + ++paren_level; + }break; + + case CPP_TOKEN_PARENTHESE_CLOSE: + { + --paren_level; + if (paren_level == 0){ + success = parse_statement_down(app, parser, token_out); + goto finished; + } + else if (paren_level < 0){ + success = false; + goto finished; + } + }break; + } + } + + token = parser_next_token(parser); + } + + finished:; + return(success); +} + +static bool32 +parse_if_down(Application_Links *app, Statement_Parser *parser, Cpp_Token *token_out){ + bool32 success = false; + Cpp_Token *token = parser_next_token(parser); + + if (token != 0){ + success = parse_statement_down(app, parser, token_out); + if (success){ + token = parser_next_token(parser); + if (token != 0 && token->type == CPP_TOKEN_KEY_CONTROL_FLOW){ + char lexeme[32]; + if (sizeof(lexeme)-1 >= token->size){ + if (buffer_read_range(app, parser->buffer, token->start, token->start + token->size, lexeme)){ + lexeme[token->size] = 0; + if (match(lexeme, "else")){ + success = parse_statement_down(app, parser, token_out); + } + } + } + } + } + } + + return(success); +} + +static bool32 +parse_block_down(Application_Links *app, Statement_Parser *parser, Cpp_Token *token_out){ + bool32 success = false; + Cpp_Token *token = parser_next_token(parser); + + int32_t nest_level = 0; + while (token != 0){ + switch (token->type){ + case CPP_TOKEN_BRACE_OPEN: + { + ++nest_level; + }break; + + case CPP_TOKEN_BRACE_CLOSE: + { + if (nest_level == 0){ + *token_out = *token; + success = true; + goto finished; + } + --nest_level; + }break; + } + token = parser_next_token(parser); + } + + finished:; + return(success); +} + +static bool32 +parse_statement_down(Application_Links *app, Statement_Parser *parser, Cpp_Token *token_out){ + bool32 success = false; + Cpp_Token *token = parser_next_token(parser); + + if (token != 0){ + bool32 not_getting_block = false; + + do{ + switch (token->type){ + case CPP_TOKEN_BRACE_CLOSE: + { + goto finished; + }break; + + case CPP_TOKEN_KEY_CONTROL_FLOW: + { + char lexeme[32]; + if (sizeof(lexeme)-1 >= token->size){ + if (buffer_read_range(app, parser->buffer, token->start, token->start + token->size, lexeme)){ + lexeme[token->size] = 0; + if (match(lexeme, "for")){ + success = parse_for_down(app, parser, token_out); + goto finished; + } + else if (match(lexeme, "if")){ + success = parse_if_down(app, parser, token_out); + goto finished; + } + else if (match(lexeme, "else")){ + success = false; + goto finished; + } + } + } + }break; + + case CPP_TOKEN_BRACE_OPEN: + { + if (!not_getting_block){ + success = parse_block_down(app, parser, token_out); + goto finished; + } + }break; + + case CPP_TOKEN_SEMICOLON: + { + success = true; + *token_out = *token; + goto finished; + }break; + + case CPP_TOKEN_EQ: + { + not_getting_block = true; + }break; + } + + token = parser_next_token(parser); + }while(token != 0); + } + + finished:; + return(success); +} + +static bool32 +find_whole_statement_down(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t *start_out, int32_t *end_out){ + bool32 result = false; + int32_t start = pos; + int32_t end = start; + + Cpp_Get_Token_Result get_result = {0}; + + if (buffer_get_token_index(app, buffer, pos, &get_result)){ + Statement_Parser parser = {0}; + parser.token_index = get_result.token_index; + + if (parser.token_index < 0){ + parser.token_index = 0; + } + if (get_result.in_whitespace){ + parser.token_index += 1; + } + + static const int32_t chunk_cap = 512; + Cpp_Token chunk[chunk_cap]; + + if (init_stream_tokens(&parser.stream, app, buffer, parser.token_index, chunk, chunk_cap)){ + parser.buffer = buffer; + + Cpp_Token end_token = {0}; + if (parse_statement_down(app, &parser, &end_token)){ + end = end_token.start + end_token.size; + result = true; + } + } + } + + *start_out = start; + *end_out = end; + return(result); +} + +CUSTOM_COMMAND_SIG(scope_absorb_down) +CUSTOM_DOC("If a scope is currently selected, and a statement or block statement is present below the current scope, the statement is moved into the scope.") +{ + uint32_t access = AccessOpen; + View_Summary view = get_active_view(app, access); + Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); + + int32_t top = view.cursor.pos; + int32_t bottom = view.mark.pos; + + if (top > bottom){ + int32_t x = top; + top = bottom; + bottom = x; + } + + Partition *part = &global_part; + + Temp_Memory temp = begin_temp_memory(part); + if (buffer_get_char(app, &buffer, top) == '{' && buffer_get_char(app, &buffer, bottom-1) == '}'){ + Range range; + if (find_whole_statement_down(app, &buffer, bottom, &range.start, &range.end)){ + char *string_space = push_array(part, char, range.end - range.start); + buffer_read_range(app, &buffer, range.start, range.end, string_space); + + String string = make_string(string_space, range.end - range.start); + string = skip_chop_whitespace(string); + + int32_t newline_count = 0; + for (char *ptr = string_space; ptr < string.str; ++ptr){ + if (*ptr == '\n'){ + ++newline_count; + } + } + + bool32 extra_newline = false; + if (newline_count >= 2){ + extra_newline = true; + } + + int32_t edit_len = string.size + 1; + if (extra_newline){ + edit_len += 1; + } + + char *edit_str = push_array(part, char, edit_len); + if (extra_newline){ + edit_str[0] = '\n'; + copy_fast_unsafe(edit_str+1, string); + edit_str[edit_len-1] = '\n'; + } + else{ + copy_fast_unsafe(edit_str, string); + edit_str[edit_len-1] = '\n'; + } + + Buffer_Edit edits[2]; + edits[0].str_start = 0; + edits[0].len = edit_len; + edits[0].start = bottom-1; + edits[0].end = bottom-1; + + edits[1].str_start = 0; + edits[1].len = 0; + edits[1].start = range.start; + edits[1].end = range.end; + + buffer_batch_edit(app, &buffer, edit_str, edit_len, edits, 2, BatchEdit_Normal); + } + } + end_temp_memory(temp); +} + +// BOTTOM + diff --git a/4coder_search.cpp b/4coder_search.cpp index 7dd2d54c..7781d355 100644 --- a/4coder_search.cpp +++ b/4coder_search.cpp @@ -733,6 +733,54 @@ CUSTOM_DOC("Reads a token or word under the cursor and lists all exact case-inse list_all_locations_of_identifier_parameters(app, false, true); } +static void +list_all_locations_of_selection_parameters(Application_Links *app, bool32 substrings, bool32 case_insensitive){ + View_Summary view = get_active_view(app, AccessProtected); + Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected); + + if (!buffer.exists){ + return; + } + + Partition *part = &global_part; + Temp_Memory temp = begin_temp_memory(part); + + Range range = get_range(&view); + int32_t query_length = range.max - range.min; + if (query_length != 0){ + char *query_space = push_array(part, char, query_length); + if (buffer_read_range(app, &buffer, range.min, range.max, query_space)){ + String query = make_string(query_space, query_length); + + uint32_t flags = 0; + if (substrings){ + flags |= SearchFlag_MatchSubstring; + } + else{ + flags |= SearchFlag_MatchWholeWord; + } + if (case_insensitive){ + flags |= SearchFlag_CaseInsensitive; + } + generic_search_all_buffers(app, &global_general, &global_part, query, flags); + } + } + + end_temp_memory(temp); +} + +CUSTOM_COMMAND_SIG(list_all_locations_of_selection) +CUSTOM_DOC("Reads the string in the selected range and lists all exact case-sensitive mathces in all open buffers.") +{ + list_all_locations_of_selection_parameters(app, false, false); +} + +CUSTOM_COMMAND_SIG(list_all_locations_of_selection_case_insensitive) +CUSTOM_DOC("Reads the string in the selected range and lists all exact case-insensitive mathces in all open buffers.") +{ + list_all_locations_of_selection_parameters(app, false, true); +} + // // Word Complete Command // diff --git a/meta/4ed_metagen.cpp b/meta/4ed_metagen.cpp index 49c4df0f..9510c01a 100644 --- a/meta/4ed_metagen.cpp +++ b/meta/4ed_metagen.cpp @@ -713,6 +713,7 @@ generate_remapping_code_and_data(){ bind(mappings, 'k', MDFR_CTRL, interactive_kill_buffer); bind(mappings, 'i', MDFR_CTRL, interactive_switch_buffer); bind(mappings, 'h', MDFR_CTRL, project_go_to_root_directory); + bind(mappings, 'H', MDFR_CTRL, reload_current_project); bind(mappings, 'S', MDFR_CTRL, save_all_dirty_buffers); bind(mappings, 'c', MDFR_ALT, open_color_tweaker); @@ -738,6 +739,9 @@ generate_remapping_code_and_data(){ bind(mappings, key_page_up, MDFR_CTRL, toggle_fullscreen); bind(mappings, 'E', MDFR_ALT, exit_4coder); + bind(mappings, '+', MDFR_CTRL, increase_face_size); + bind(mappings, '-', MDFR_CTRL, decrease_face_size); + bind(mappings, key_f1, MDFR_NONE, project_fkey_command); bind(mappings, key_f2, MDFR_NONE, project_fkey_command); bind(mappings, key_f3, MDFR_NONE, project_fkey_command); @@ -787,8 +791,8 @@ generate_remapping_code_and_data(){ bind(mappings, key_up, MDFR_CTRL, seek_whitespace_up_end_line); bind(mappings, key_down, MDFR_CTRL, seek_whitespace_down_end_line); - bind(mappings, key_up, MDFR_ALT, move_up_10); - bind(mappings, key_down, MDFR_ALT, move_down_10); + bind(mappings, key_up, MDFR_ALT, move_line_up); + bind(mappings, key_down, MDFR_ALT, move_line_down); bind(mappings, key_back, MDFR_CTRL, backspace_word); bind(mappings, key_del, MDFR_CTRL, delete_word); @@ -799,19 +803,23 @@ generate_remapping_code_and_data(){ bind(mappings, 'a', MDFR_CTRL, replace_in_range); bind(mappings, 'c', MDFR_CTRL, copy); bind(mappings, 'd', MDFR_CTRL, delete_range); + bind(mappings, 'D', MDFR_CTRL, delete_line); bind(mappings, 'e', MDFR_CTRL, center_view); bind(mappings, 'E', MDFR_CTRL, left_adjust_view); bind(mappings, 'f', MDFR_CTRL, search); bind(mappings, 'F', MDFR_CTRL, list_all_locations); bind(mappings, 'F', MDFR_ALT , list_all_substring_locations_case_insensitive); bind(mappings, 'g', MDFR_CTRL, goto_line); + bind(mappings, 'G', MDFR_CTRL, list_all_locations_of_selection); bind(mappings, 'j', MDFR_CTRL, to_lowercase); bind(mappings, 'K', MDFR_CTRL, kill_buffer); bind(mappings, 'l', MDFR_CTRL, toggle_line_wrap); + bind(mappings, 'L', MDFR_CTRL, duplicate_line); bind(mappings, 'm', MDFR_CTRL, cursor_mark_swap); bind(mappings, 'O', MDFR_CTRL, reopen); bind(mappings, 'q', MDFR_CTRL, query_replace); bind(mappings, 'Q', MDFR_CTRL, query_replace_identifier); + bind(mappings, 'q', MDFR_ALT , query_replace_selection); bind(mappings, 'r', MDFR_CTRL, reverse_search); bind(mappings, 's', MDFR_CTRL, save); bind(mappings, 't', MDFR_CTRL, search_identifier); @@ -831,7 +839,7 @@ generate_remapping_code_and_data(){ bind(mappings, '~', MDFR_CTRL, clean_all_lines); bind(mappings, '\n', MDFR_NONE, newline_or_goto_position); bind(mappings, '\n', MDFR_SHIFT, newline_or_goto_position_same_panel); - bind(mappings, ' ', MDFR_SHIFT, write_character); + bind(mappings, ' ', MDFR_SHIFT, write_underscore); end_map(mappings); @@ -859,10 +867,20 @@ generate_remapping_code_and_data(){ bind(mappings, 'r', MDFR_ALT, write_block); bind(mappings, 't', MDFR_ALT, write_todo); bind(mappings, 'y', MDFR_ALT, write_note); + bind(mappings, '[', MDFR_CTRL, open_long_braces); bind(mappings, '{', MDFR_CTRL, open_long_braces_semicolon); bind(mappings, '}', MDFR_CTRL, open_long_braces_break); + + bind(mappings, '[', MDFR_ALT, highlight_surrounding_scope); + bind(mappings, ']', MDFR_ALT, highlight_prev_scope_absolute); + bind(mappings, '\'', MDFR_ALT, highlight_next_scope_absolute); + bind(mappings, '/', MDFR_ALT, place_in_scope); + bind(mappings, '-', MDFR_ALT, delete_current_scope); + bind(mappings, 'j', MDFR_ALT, scope_absorb_down); + bind(mappings, 'i', MDFR_ALT, if0_off); + bind(mappings, '1', MDFR_ALT, open_file_in_quotes); bind(mappings, '2', MDFR_ALT, open_matching_file_cpp); bind(mappings, '0', MDFR_CTRL, write_zero_struct); @@ -889,6 +907,7 @@ generate_remapping_code_and_data(){ bind(mappings, 'k', MDFR_CMND, interactive_kill_buffer); bind(mappings, 'i', MDFR_CMND, interactive_switch_buffer); bind(mappings, 'h', MDFR_CMND, project_go_to_root_directory); + bind(mappings, 'H', MDFR_CMND, reload_current_project); bind(mappings, 'S', MDFR_CMND, save_all_dirty_buffers); bind(mappings, 'c', MDFR_CTRL, open_color_tweaker); @@ -973,15 +992,18 @@ generate_remapping_code_and_data(){ bind(mappings, 'a', MDFR_CMND, replace_in_range); bind(mappings, 'c', MDFR_CMND, copy); bind(mappings, 'd', MDFR_CMND, delete_range); + bind(mappings, 'D', MDFR_CMND, delete_line); bind(mappings, 'e', MDFR_CMND, center_view); bind(mappings, 'E', MDFR_CMND, left_adjust_view); bind(mappings, 'f', MDFR_CMND, search); bind(mappings, 'F', MDFR_CMND, list_all_locations); bind(mappings, 'F', MDFR_CTRL, list_all_substring_locations_case_insensitive); bind(mappings, 'g', MDFR_CMND, goto_line); + bind(mappings, 'G', MDFR_CMND, list_all_locations_of_selection); bind(mappings, 'j', MDFR_CMND, to_lowercase); bind(mappings, 'K', MDFR_CMND, kill_buffer); bind(mappings, 'l', MDFR_CMND, toggle_line_wrap); + bind(mappings, 'L', MDFR_CMND, duplicate_line); bind(mappings, 'm', MDFR_CMND, cursor_mark_swap); bind(mappings, 'O', MDFR_CMND, reopen); bind(mappings, 'q', MDFR_CMND, query_replace); @@ -1005,7 +1027,7 @@ generate_remapping_code_and_data(){ bind(mappings, '~', MDFR_CMND, clean_all_lines); bind(mappings, '\n', MDFR_NONE, newline_or_goto_position); bind(mappings, '\n', MDFR_SHIFT, newline_or_goto_position_same_panel); - bind(mappings, ' ', MDFR_SHIFT, write_character); + bind(mappings, ' ', MDFR_SHIFT, write_underscore); end_map(mappings); @@ -1033,10 +1055,20 @@ generate_remapping_code_and_data(){ bind(mappings, 'r', MDFR_CTRL, write_block); bind(mappings, 't', MDFR_CTRL, write_todo); bind(mappings, 'y', MDFR_CTRL, write_note); + bind(mappings, '[', MDFR_CMND, open_long_braces); bind(mappings, '{', MDFR_CMND, open_long_braces_semicolon); bind(mappings, '}', MDFR_CMND, open_long_braces_break); + + bind(mappings, '[', MDFR_CTRL, highlight_surrounding_scope); + bind(mappings, ']', MDFR_CTRL, highlight_prev_scope_absolute); + bind(mappings, '\'', MDFR_CTRL, highlight_next_scope_absolute); + bind(mappings, '/', MDFR_CTRL, place_in_scope); + bind(mappings, '-', MDFR_CTRL, delete_current_scope); + bind(mappings, 'j', MDFR_CTRL, scope_absorb_down); + bind(mappings, 'i', MDFR_CTRL, if0_off); + bind(mappings, '1', MDFR_CTRL, open_file_in_quotes); bind(mappings, '2', MDFR_CTRL, open_matching_file_cpp); bind(mappings, '0', MDFR_CMND, write_zero_struct); diff --git a/power/4coder_experiments.cpp b/power/4coder_experiments.cpp index 27aae2b4..e88744e6 100644 --- a/power/4coder_experiments.cpp +++ b/power/4coder_experiments.cpp @@ -204,810 +204,138 @@ CUSTOM_DOC("Begin multi-line mode. In multi-line mode characters are inserted a } } -// -// Scope-Smart Editing Basics -// +// NOTE(allen): An experimental mutli-pasting thing -enum{ - FindScope_Parent = 0x1, - FindScope_NextSibling = 0x1, - FindScope_EndOfToken = 0x2, -}; - -static bool32 -find_scope_top(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){ - Cpp_Get_Token_Result get_result = {0}; - - bool32 success = 0; - int32_t position = 0; - - if (buffer_get_token_index(app, buffer, start_pos, &get_result)){ - int32_t token_index = get_result.token_index; - if (flags & FindScope_Parent){ - --token_index; - if (get_result.in_whitespace){ - ++token_index; - } - } +CUSTOM_COMMAND_SIG(multi_paste){ + uint32_t access = AccessOpen; + int32_t count = clipboard_count(app, 0); + if (count > 0){ + View_Summary view = get_active_view(app, access); - if (token_index >= 0){ - static const int32_t chunk_cap = 512; - Cpp_Token chunk[chunk_cap]; - Stream_Tokens stream = {0}; + if (view_paste_index[view.view_id].rewrite == RewritePaste){ + view_paste_index[view.view_id].next_rewrite = RewritePaste; - if (init_stream_tokens(&stream, app, buffer, token_index, chunk, chunk_cap)){int32_t nest_level = 0; - bool32 still_looping = 0; - do{ - for (; token_index >= stream.start; --token_index){ - Cpp_Token *token = &stream.tokens[token_index]; - - switch (token->type){ - case CPP_TOKEN_BRACE_OPEN: - { - if (nest_level == 0){ - success = 1; - position = token->start; - if (flags & FindScope_EndOfToken){ - position += token->size; - } - goto finished; - } - else{ - --nest_level; - } - }break; - - case CPP_TOKEN_BRACE_CLOSE: - { - ++nest_level; - }break; - } - } - still_looping = backward_stream_tokens(&stream); - }while(still_looping); - } - } - } - - finished:; - *end_pos_out = position; - return(success); -} - -static bool32 -find_scope_bottom(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){ - Cpp_Get_Token_Result get_result = {0}; - - bool32 success = 0; - int32_t position = 0; - - if (buffer_get_token_index(app, buffer, start_pos, &get_result)){ - int32_t token_index = get_result.token_index+1; - if (flags & FindScope_Parent){ - --token_index; - if (get_result.in_whitespace){ - ++token_index; - } - } - - if (token_index >= 0){ - static const int32_t chunk_cap = 512; - Cpp_Token chunk[chunk_cap]; - Stream_Tokens stream = {0}; + int32_t paste_index = view_paste_index[view.view_id].index + 1; + view_paste_index[view.view_id].index = paste_index; - if (init_stream_tokens(&stream, app, buffer, token_index, chunk, chunk_cap)){ - int32_t nest_level = 0; - bool32 still_looping = 0; - do{ - for (; token_index < stream.end; ++token_index){ - Cpp_Token *token = &stream.tokens[token_index]; - - switch (token->type){ - case CPP_TOKEN_BRACE_OPEN: - { - ++nest_level; - }break; - - case CPP_TOKEN_BRACE_CLOSE: - { - if (nest_level == 0){ - success = 1; - position = token->start; - if (flags & FindScope_EndOfToken){ - position += token->size; - } - goto finished; - } - else{ - --nest_level; - } - }break; - } - } - still_looping = forward_stream_tokens(&stream); - }while(still_looping); - } - } - } - - finished:; - *end_pos_out = position; - return(success); -} - -static bool32 -find_next_scope(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){ - Cpp_Get_Token_Result get_result = {0}; - - bool32 success = 0; - int32_t position = 0; - - if (buffer_get_token_index(app, buffer, start_pos, &get_result)){ - int32_t token_index = get_result.token_index+1; - - if (token_index >= 0){ - static const int32_t chunk_cap = 512; - Cpp_Token chunk[chunk_cap]; - Stream_Tokens stream = {0}; + int32_t len = clipboard_index(app, 0, paste_index, 0, 0); - if (init_stream_tokens(&stream, app, buffer, token_index, chunk, chunk_cap)){ - if (flags & FindScope_NextSibling){ - int32_t nest_level = 1; - - bool32 still_looping = 0; - do{ - for (; token_index < stream.end; ++token_index){ - Cpp_Token *token = &stream.tokens[token_index]; - - switch (token->type){ - case CPP_TOKEN_BRACE_OPEN: - { - if (nest_level == 0){ - success = 1; - position = token->start; - if (flags & FindScope_EndOfToken){ - position += token->size; - } - goto finished; - } - else{ - ++nest_level; - } - }break; - - case CPP_TOKEN_BRACE_CLOSE: - { - --nest_level; - if (nest_level == -1){ - position = start_pos; - goto finished; - } - }break; - } - } - still_looping = forward_stream_tokens(&stream); - }while(still_looping); - } - else{ - bool32 still_looping = 0; - do{ - for (; token_index < stream.end; ++token_index){ - Cpp_Token *token = &stream.tokens[token_index]; - - if (token->type == CPP_TOKEN_BRACE_OPEN){ - success = 1; - position = token->start; - if (flags & FindScope_EndOfToken){ - position += token->size; - } - goto finished; - } - } - still_looping = forward_stream_tokens(&stream); - }while(still_looping); - } - } - } - } - - finished:; - *end_pos_out = position; - return(success); -} - -static bool32 -find_prev_scope(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){ - Cpp_Get_Token_Result get_result = {0}; - - bool32 success = 0; - int32_t position = 0; - - if (buffer_get_token_index(app, buffer, start_pos, &get_result)){ - int32_t token_index = get_result.token_index-1; - - if (token_index >= 0){ - static const int32_t chunk_cap = 512; - Cpp_Token chunk[chunk_cap]; - Stream_Tokens stream = {0}; - if (init_stream_tokens(&stream, app, buffer, token_index, chunk, chunk_cap)){ - if (flags & FindScope_NextSibling){ - int32_t nest_level = -1; - bool32 still_looping = 0; - do{ - for (; token_index >= stream.start; --token_index){ - Cpp_Token *token = &stream.tokens[token_index]; - - switch (token->type){ - case CPP_TOKEN_BRACE_OPEN: - { - if (nest_level == -1){ - position = start_pos; - goto finished; - } - else if (nest_level == 0){ - success = 1; - position = token->start; - if (flags & FindScope_EndOfToken){ - position += token->size; - } - goto finished; - } - else{ - --nest_level; - } - }break; - - case CPP_TOKEN_BRACE_CLOSE: - { - ++nest_level; - }break; - } - } - still_looping = backward_stream_tokens(&stream); - }while(still_looping); - } - else{ - bool32 still_looping = 0; - do{ - for (; token_index >= stream.start; --token_index){ - Cpp_Token *token = &stream.tokens[token_index]; - - if (token->type == CPP_TOKEN_BRACE_OPEN){ - success = 1; - position = token->start; - if (flags & FindScope_EndOfToken){ - position += token->size; - } - goto finished; - } - } - still_looping = backward_stream_tokens(&stream); - }while(still_looping); - } - } - } - } - - finished:; - *end_pos_out = position; - return(success); -} - -static void -view_set_to_region(Application_Links *app, View_Summary *view, int32_t major_pos, int32_t minor_pos, float normalized_threshold){ - Range range = make_range(major_pos, minor_pos); - bool32 bottom_major = false; - if (major_pos == range.max){ - bottom_major = true; - } - - Full_Cursor top, bottom; - if (view_compute_cursor(app, view, seek_pos(range.min), &top)){ - if (view_compute_cursor(app, view, seek_pos(range.max), &bottom)){ - float top_y = top.wrapped_y; - float bottom_y = bottom.wrapped_y; - if (view->unwrapped_lines){ - top_y = top.unwrapped_y; - bottom_y = bottom.unwrapped_y; - } - - GUI_Scroll_Vars scroll = view->scroll_vars; - float half_view_height = .5f*(float)(view->file_region.y1 - view->file_region.y0); - float threshold = normalized_threshold * half_view_height; - float current_center_y = ((float)scroll.target_y) + half_view_height; - - if (top_y < current_center_y - threshold || bottom_y > current_center_y + threshold){ - float center_target_y = .5f*(top_y + bottom_y); + if (len + 1 <= app->memory_size){ + char *str = (char*)app->memory; + str[0] = '\n'; + clipboard_index(app, 0, paste_index, str + 1, len); - if (bottom_major){ - if (center_target_y < bottom_y - half_view_height * .9f){ - center_target_y = bottom_y - half_view_height * .9f; - } - } - else{ - if (center_target_y > top_y + half_view_height * .9f){ - center_target_y = top_y + half_view_height * .9f; - } - } + Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); + Range range = get_range(&view); + buffer_replace_range(app, &buffer, range.max, range.max, str, len + 1); + view_set_mark(app, &view, seek_pos(range.max + 1)); + view_set_cursor(app, &view, seek_pos(range.max + len + 1), true); - float target_y = center_target_y - half_view_height; - if (target_y < 0){ - target_y = 0; - } - - scroll.target_y = (int32_t)(target_y); - view_set_scroll(app, view, scroll); + // TODO(allen): Send this to all views. + Theme_Color paste; + paste.tag = Stag_Paste; + get_theme_colors(app, &paste, 1); + view_post_fade(app, &view, 0.667f, range.max + 1, range.max + len + 1, paste.color); } } - } -} - -static float scope_center_threshold = 0.75f; - -CUSTOM_COMMAND_SIG(highlight_surrounding_scope) -CUSTOM_DOC("Finds the scope enclosed by '{' '}' surrounding the cursor and puts the cursor and mark on the '{' and '}'.") -{ - uint32_t access = AccessProtected; - View_Summary view = get_active_view(app, access); - Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); - - int32_t start_pos = view.cursor.pos; - int32_t top = 0, bottom = 0; - if (find_scope_top(app, &buffer, start_pos, FindScope_Parent, &top)){ - view_set_cursor(app, &view, seek_pos(top), true); - if (find_scope_bottom(app, &buffer, start_pos, FindScope_Parent | FindScope_EndOfToken, &bottom)){ - view_set_mark(app, &view, seek_pos(bottom)); - view_set_to_region(app, &view, top, bottom, scope_center_threshold); - } else{ - view_set_to_region(app, &view, top, top, scope_center_threshold); + exec_command(app, paste); } } } -CUSTOM_COMMAND_SIG(highlight_next_scope_absolute) -CUSTOM_DOC("Finds the first scope started by '{' after the cursor and puts the cursor and mark on the '{' and '}'.") -{ - uint32_t access = AccessProtected; - View_Summary view = get_active_view(app, access); - Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); - - int32_t start_pos = view.cursor.pos; - int32_t top = 0, bottom = 0; - if (find_next_scope(app, &buffer, start_pos, 0, &top)){ - if (find_scope_bottom(app, &buffer, top, FindScope_EndOfToken, &bottom)){ - view_set_cursor(app, &view, seek_pos(top), true); - view_set_mark(app, &view, seek_pos(bottom)); - view_set_to_region(app, &view, top, bottom, scope_center_threshold); - } - } -} - -CUSTOM_COMMAND_SIG(highlight_prev_scope_absolute) -CUSTOM_DOC("Finds the first scope started by '{' before the cursor and puts the cursor and mark on the '{' and '}'.") -{ - uint32_t access = AccessProtected; - View_Summary view = get_active_view(app, access); - Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); - - int32_t start_pos = view.cursor.pos; - int32_t top = 0, bottom = 0; - if (find_prev_scope(app, &buffer, start_pos, 0, &top)){ - if (find_scope_bottom(app, &buffer, top, FindScope_EndOfToken, &bottom)){ - view_set_cursor(app, &view, seek_pos(top), true); - view_set_mark(app, &view, seek_pos(bottom)); - view_set_to_region(app, &view, top, bottom, scope_center_threshold); - } - } -} - -CUSTOM_COMMAND_SIG(place_in_scope) -CUSTOM_DOC("Wraps the code contained in the range between cursor and mark with a new curly brace scope.") -{ - uint32_t access = AccessOpen; - View_Summary view = get_active_view(app, access); - Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); - - Range lines; - Range range = get_range(&view); - lines.min = buffer_get_line_index(app, &buffer, range.min); - range.min = buffer_get_line_start(app, &buffer, lines.min); - - lines.max = buffer_get_line_index(app, &buffer, range.max); - range.max = buffer_get_line_end(app, &buffer, lines.max); - - bool32 do_full = false; - - if (lines.min < lines.max){ - do_full = true; - } - else if (!buffer_line_is_blank(app, &buffer, lines.min)){ - do_full = true; - } - - if (do_full){ - Buffer_Edit edits[2]; - char str[5] = "{\n\n}"; - - int32_t min_adjustment = 0; - int32_t max_adjustment = 4; - - if (buffer_line_is_blank(app, &buffer, lines.min)){ - str[0] = '\n'; - str[1] = '{'; - ++min_adjustment; - } - - if (buffer_line_is_blank(app, &buffer, lines.max)){ - str[2] = '}'; - str[3] = '\n'; - --max_adjustment; - } - - int32_t min_pos = range.min + min_adjustment; - int32_t max_pos = range.max + max_adjustment; - - int32_t cursor_pos = min_pos; - int32_t mark_pos = max_pos; - - if (view.cursor.pos > view.mark.pos){ - cursor_pos = max_pos; - mark_pos = min_pos; - } - - edits[0].str_start = 0; - edits[0].len = 2; - edits[0].start = range.min; - edits[0].end = range.min; - - edits[1].str_start = 2; - edits[1].len = 2; - edits[1].start = range.max; - edits[1].end = range.max; - - buffer_batch_edit(app, &buffer, str, 4, edits, 2, BatchEdit_Normal); - - view_set_cursor(app, &view, seek_pos(cursor_pos), true); - view_set_mark(app, &view, seek_pos(mark_pos)); - } - else{ - buffer_replace_range(app, &buffer, range.min, range.max, "{\n\n}", 4); - view_set_cursor(app, &view, seek_pos(range.min + 2), true); - view_set_mark(app, &view, seek_pos(range.min + 2)); - } -} - -CUSTOM_COMMAND_SIG(delete_current_scope) -CUSTOM_DOC("Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.") -{ - uint32_t access = AccessOpen; - View_Summary view = get_active_view(app, access); - Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); - - int32_t top = view.cursor.pos; - int32_t bottom = view.mark.pos; - - if (top > bottom){ - int32_t x = top; - top = bottom; - bottom = x; - } - - if (buffer_get_char(app, &buffer, top) == '{' && buffer_get_char(app, &buffer, bottom-1) == '}'){ - int32_t top_len = 1; - int32_t bottom_len = 1; - if (buffer_get_char(app, &buffer, top-1) == '\n'){ - top_len = 2; - } - if (buffer_get_char(app, &buffer, bottom+1) == '\n'){ - bottom_len = 2; - } - - Buffer_Edit edits[2]; - edits[0].str_start = 0; - edits[0].len = 0; - edits[0].start = top+1 - top_len; - edits[0].end = top+1; - - edits[1].str_start = 0; - edits[1].len = 0; - edits[1].start = bottom-1; - edits[1].end = bottom-1 + bottom_len; - - buffer_batch_edit(app, &buffer, 0, 0, edits, 2, BatchEdit_Normal); - } -} - -struct Statement_Parser{ - Stream_Tokens stream; - int32_t token_index; - Buffer_Summary *buffer; -}; - -static Cpp_Token* -parser_next_token(Statement_Parser *parser){ - Cpp_Token *result = 0; - bool32 still_looping = true; - while (parser->token_index >= parser->stream.end && still_looping){ - still_looping = forward_stream_tokens(&parser->stream); - } - if (parser->token_index < parser->stream.end){ - result = &parser->stream.tokens[parser->token_index]; - ++parser->token_index; - } - return(result); -} - -static bool32 parse_statement_down(Application_Links *app, Statement_Parser *parser, Cpp_Token *token_out); - -static bool32 -parse_for_down(Application_Links *app, Statement_Parser *parser, Cpp_Token *token_out){ - bool32 success = false; - Cpp_Token *token = parser_next_token(parser); - - int32_t paren_level = 0; - while (token != 0){ - if (!(token->flags & CPP_TFLAG_PP_BODY)){ - switch (token->type){ - case CPP_TOKEN_PARENTHESE_OPEN: - { - ++paren_level; - }break; +static Range +multi_paste_range(Application_Links *app, View_Summary *view, Range range, int32_t paste_count){ + Range finish_range = range; + if (paste_count >= 1){ + Buffer_Summary buffer = get_buffer(app, view->buffer_id, AccessOpen); + if (buffer.exists){ + int32_t total_size = 0; + for (int32_t paste_index = 0; paste_index < paste_count; ++paste_index){ + total_size += 1 + clipboard_index(app, 0, paste_index, 0, 0); + } + total_size -= 1; + + if (total_size <= app->memory_size){ + char *str = (char*)app->memory; + int32_t position = 0; + for (int32_t paste_index = paste_count - 1; paste_index >= 0; --paste_index){ + if (paste_index != paste_count - 1){ + str[position] = '\n'; + ++position; + } + + int32_t len = clipboard_index(app, 0, paste_index, str + position, total_size - position); + position += len; + } - case CPP_TOKEN_PARENTHESE_CLOSE: - { - --paren_level; - if (paren_level == 0){ - success = parse_statement_down(app, parser, token_out); - goto finished; - } - else if (paren_level < 0){ - success = false; - goto finished; - } - }break; + int32_t pos = range.min; + buffer_replace_range(app, &buffer, range.min, range.max, str, total_size); + finish_range.min = pos; + finish_range.max = pos + total_size; + view_set_mark(app, view, seek_pos(finish_range.min)); + view_set_cursor(app, view, seek_pos(finish_range.max), true); + + // TODO(allen): Send this to all views. + Theme_Color paste; + paste.tag = Stag_Paste; + get_theme_colors(app, &paste, 1); + view_post_fade(app, view, 0.667f, finish_range.min, finish_range.max, paste.color); } } - - token = parser_next_token(parser); } - - finished:; - return(success); + return(finish_range); } -static bool32 -parse_if_down(Application_Links *app, Statement_Parser *parser, Cpp_Token *token_out){ - bool32 success = false; - Cpp_Token *token = parser_next_token(parser); - - if (token != 0){ - success = parse_statement_down(app, parser, token_out); - if (success){ - token = parser_next_token(parser); - if (token != 0 && token->type == CPP_TOKEN_KEY_CONTROL_FLOW){ - char lexeme[32]; - if (sizeof(lexeme)-1 >= token->size){ - if (buffer_read_range(app, parser->buffer, token->start, token->start + token->size, lexeme)){ - lexeme[token->size] = 0; - if (match(lexeme, "else")){ - success = parse_statement_down(app, parser, token_out); - } - } +CUSTOM_COMMAND_SIG(multi_paste_interactive){ + int32_t clip_count = clipboard_count(app, 0); + if (clip_count > 0){ + View_Summary view = get_active_view(app, AccessOpen); + + int32_t paste_count = 1; + Range range = {0}; + range.min = range.max = view.cursor.pos; + + range = multi_paste_range(app, &view, range, paste_count); + + Query_Bar bar = {0}; + bar.prompt = make_lit_string("Up and Down to condense and expand paste stages; Return to finish; Escape to abort."); + if (start_query_bar(app, &bar, 0) == 0) return; + + User_Input in = {0}; + for (;;){ + in = get_user_input(app, EventOnAnyKey, EventOnEsc); + if (in.abort) break; + Assert(in.type == UserInputKey); + + bool32 did_modify = false; + if (in.key.keycode == key_up){ + if (paste_count > 1){ + --paste_count; + did_modify = true; } } - } - } - - return(success); -} - -static bool32 -parse_block_down(Application_Links *app, Statement_Parser *parser, Cpp_Token *token_out){ - bool32 success = false; - Cpp_Token *token = parser_next_token(parser); - - int32_t nest_level = 0; - while (token != 0){ - switch (token->type){ - case CPP_TOKEN_BRACE_OPEN: - { - ++nest_level; - }break; - - case CPP_TOKEN_BRACE_CLOSE: - { - if (nest_level == 0){ - *token_out = *token; - success = true; - goto finished; - } - --nest_level; - }break; - } - token = parser_next_token(parser); - } - - finished:; - return(success); -} - -static bool32 -parse_statement_down(Application_Links *app, Statement_Parser *parser, Cpp_Token *token_out){ - bool32 success = false; - Cpp_Token *token = parser_next_token(parser); - - if (token != 0){ - bool32 not_getting_block = false; - - do{ - switch (token->type){ - case CPP_TOKEN_BRACE_CLOSE: - { - goto finished; - }break; - - case CPP_TOKEN_KEY_CONTROL_FLOW: - { - char lexeme[32]; - if (sizeof(lexeme)-1 >= token->size){ - if (buffer_read_range(app, parser->buffer, token->start, token->start + token->size, lexeme)){ - lexeme[token->size] = 0; - if (match(lexeme, "for")){ - success = parse_for_down(app, parser, token_out); - goto finished; - } - else if (match(lexeme, "if")){ - success = parse_if_down(app, parser, token_out); - goto finished; - } - else if (match(lexeme, "else")){ - success = false; - goto finished; - } - } - } - }break; - - case CPP_TOKEN_BRACE_OPEN: - { - if (!not_getting_block){ - success = parse_block_down(app, parser, token_out); - goto finished; - } - }break; - - case CPP_TOKEN_SEMICOLON: - { - success = true; - *token_out = *token; - goto finished; - }break; - - case CPP_TOKEN_EQ: - { - not_getting_block = true; - }break; - } - - token = parser_next_token(parser); - }while(token != 0); - } - - finished:; - return(success); -} - -static bool32 -find_whole_statement_down(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t *start_out, int32_t *end_out){ - bool32 result = false; - int32_t start = pos; - int32_t end = start; - - Cpp_Get_Token_Result get_result = {0}; - - if (buffer_get_token_index(app, buffer, pos, &get_result)){ - Statement_Parser parser = {0}; - parser.token_index = get_result.token_index; - - if (parser.token_index < 0){ - parser.token_index = 0; - } - if (get_result.in_whitespace){ - parser.token_index += 1; - } - - static const int32_t chunk_cap = 512; - Cpp_Token chunk[chunk_cap]; - - if (init_stream_tokens(&parser.stream, app, buffer, parser.token_index, chunk, chunk_cap)){ - parser.buffer = buffer; - - Cpp_Token end_token = {0}; - if (parse_statement_down(app, &parser, &end_token)){ - end = end_token.start + end_token.size; - result = true; - } - } - } - - *start_out = start; - *end_out = end; - return(result); -} - -CUSTOM_COMMAND_SIG(scope_absorb_down) -CUSTOM_DOC("If a scope is currently selected, and a statement or block statement is present below the current scope, the statement is moved into the scope.") -{ - uint32_t access = AccessOpen; - View_Summary view = get_active_view(app, access); - Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); - - int32_t top = view.cursor.pos; - int32_t bottom = view.mark.pos; - - if (top > bottom){ - int32_t x = top; - top = bottom; - bottom = x; - } - - Partition *part = &global_part; - - Temp_Memory temp = begin_temp_memory(part); - if (buffer_get_char(app, &buffer, top) == '{' && buffer_get_char(app, &buffer, bottom-1) == '}'){ - Range range; - if (find_whole_statement_down(app, &buffer, bottom, &range.start, &range.end)){ - char *string_space = push_array(part, char, range.end - range.start); - buffer_read_range(app, &buffer, range.start, range.end, string_space); - - String string = make_string(string_space, range.end - range.start); - string = skip_chop_whitespace(string); - - int32_t newline_count = 0; - for (char *ptr = string_space; ptr < string.str; ++ptr){ - if (*ptr == '\n'){ - ++newline_count; + else if (in.key.keycode == key_down){ + if (paste_count < clip_count){ + ++paste_count; + did_modify = true; } } - - bool32 extra_newline = false; - if (newline_count >= 2){ - extra_newline = true; + else if (in.key.keycode == '\n'){ + break; } - int32_t edit_len = string.size + 1; - if (extra_newline){ - edit_len += 1; + if (did_modify){ + range = multi_paste_range(app, &view, range, paste_count); } - - char *edit_str = push_array(part, char, edit_len); - if (extra_newline){ - edit_str[0] = '\n'; - copy_fast_unsafe(edit_str+1, string); - edit_str[edit_len-1] = '\n'; - } - else{ - copy_fast_unsafe(edit_str, string); - edit_str[edit_len-1] = '\n'; - } - - Buffer_Edit edits[2]; - edits[0].str_start = 0; - edits[0].len = edit_len; - edits[0].start = bottom-1; - edits[0].end = bottom-1; - - edits[1].str_start = 0; - edits[1].len = 0; - edits[1].start = range.start; - edits[1].end = range.end; - - buffer_batch_edit(app, &buffer, edit_str, edit_len, edits, 2, BatchEdit_Normal); + } + + if (in.abort){ + Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen); + buffer_replace_range(app, &buffer, range.min, range.max, 0, 0); } } - end_temp_memory(temp); } // NOTE(allen): Some basic code manipulation ideas. @@ -1370,17 +698,11 @@ get_bindings(void *data, int32_t size){ bind(context, key_home, MDFR_ALT, miblo_increment_time_stamp_minute); bind(context, key_end, MDFR_ALT, miblo_decrement_time_stamp_minute); + bind(context, 'b', MDFR_CTRL, multi_paste_interactive); + end_map(context); begin_map(context, default_code_map); - bind(context, '[', MDFR_ALT, highlight_surrounding_scope); - bind(context, ']', MDFR_ALT, highlight_prev_scope_absolute); - bind(context, '\'', MDFR_ALT, highlight_next_scope_absolute); - - bind(context, '/', MDFR_ALT, place_in_scope); - bind(context, '-', MDFR_ALT, delete_current_scope); - bind(context, 'j', MDFR_ALT, scope_absorb_down); - bind(context, key_insert, MDFR_CTRL, write_explicit_enum_values); bind(context, 'p', MDFR_ALT, rename_parameter); end_map(context); diff --git a/site/source_material/binding_list.txt b/site/source_material/binding_list.txt index 5e6d166f..c77b03be 100644 --- a/site/source_material/binding_list.txt +++ b/site/source_material/binding_list.txt @@ -53,6 +53,8 @@ TODO \ITEM \STYLE{code} \END Toggles the mouse suppression mode, see suppress_mouse and allow_mouse. \ITEM \STYLE{code} \END Toggle fullscreen mode on or off. The change(s) do not take effect until the next frame. \ITEM \STYLE{code} \END Attempts to close 4coder. +\ITEM \STYLE{code} \END Increase the size of the face used by the current buffer. +\ITEM \STYLE{code} \END Decrease the size of the face used by the current buffer. \ITEM \STYLE{code} \END Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command. \ITEM \STYLE{code} \END Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command. \ITEM \STYLE{code} \END Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command. @@ -134,7 +136,7 @@ TODO \ITEM \STYLE{code} \END Removes trailing whitespace from all lines in the current buffer. \ITEM \STYLE{code} \END description missing \ITEM \STYLE{code} \END description missing -\ITEM \STYLE{code} \END Inserts whatever character was used to trigger this command. +\ITEM \STYLE{code} \END Inserts an underscore. \END \END \SECTION{default-code-map} @@ -280,7 +282,7 @@ TODO \ITEM \STYLE{code} \END Removes trailing whitespace from all lines in the current buffer. \ITEM \STYLE{code} \END description missing \ITEM \STYLE{code} \END description missing -\ITEM \STYLE{code} \END Inserts whatever character was used to trigger this command. +\ITEM \STYLE{code} \END Inserts an underscore. \END \END \SECTION{default-code-map}