Deprecated mirrors

master
Allen Webster 2019-03-31 20:05:48 -07:00
parent 731a162d9c
commit e57e927e07
12 changed files with 51 additions and 1205 deletions

View File

@ -629,9 +629,6 @@ STRUCT Partial_Cursor{
i32 character;
};
TYPEDEF_FUNC b32 Buffer_Edit_Handler(struct Application_Links *app, Buffer_ID buffer_id, i32 start, i32 one_past_last, String str);
// TODO(allen): what to do with batches???
STRUCT File_Attributes{
u64 size;
u64 last_write_time;

View File

@ -280,7 +280,6 @@ create_or_switch_to_buffer_by_name(Application_Links *app, char *name, i32 name_
if (search_buffer.exists){
buffer_set_setting(app, &search_buffer, BufferSetting_ReadOnly, true);
buffer_set_edit_handler(app, search_buffer.buffer_id, 0);
View_Summary target_view = default_target_view;

View File

@ -30,7 +30,6 @@
#include "4coder_fancy.h"
#include "4coder_ui_helper.h"
#include "4coder_default_framework.h"
#include "4coder_mirror.h"
#include "4coder_config.h"
#include "4coder_seek.h"
#include "4coder_auto_indent.h"
@ -54,7 +53,6 @@
#include "4coder_config.cpp"
#include "4coder_default_framework.cpp"
#include "4coder_insertion.cpp"
#include "4coder_mirror.cpp"
#include "4coder_seek.cpp"
#include "4coder_base_commands.cpp"
#include "4coder_lists.cpp"

View File

@ -19,7 +19,6 @@ struct Application_Links;
#define GET_BUFFER_BY_FILE_NAME_SIG(n) b32 n(Application_Links *app, String file_name, Access_Flag access, Buffer_ID *buffer_id_out)
#define BUFFER_READ_RANGE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 one_past_last, char *out)
#define BUFFER_REPLACE_RANGE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 one_past_last, String string)
#define BUFFER_SET_EDIT_HANDLER_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Edit_Handler *handler)
#define BUFFER_COMPUTE_CURSOR_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Seek seek, Partial_Cursor *cursor_out)
#define BUFFER_BATCH_EDIT_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, char *str, i32 str_len, Buffer_Edit *edits, i32 edit_count, Buffer_Batch_Edit_Type type)
#define BUFFER_EXISTS_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id)
@ -43,7 +42,7 @@ struct Application_Links;
#define CREATE_BUFFER_SIG(n) b32 n(Application_Links *app, String file_name, Buffer_Create_Flag flags, Buffer_ID *new_buffer_id_out)
#define BUFFER_SAVE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, String file_name, u32 flags)
#define BUFFER_KILL_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Kill_Flag flags, Buffer_Kill_Result *result)
#define BUFFER_REOPEN_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags, Buffer_Reopen_Result *result)
#define BUFFER_REOPEN_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags, Buffer_Reopen_Result *result_out)
#define BUFFER_GET_FILE_ATTRIBUTES_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, File_Attributes *attributes_out)
#define GET_VIEW_NEXT_SIG(n) b32 n(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out)
#define GET_VIEW_PREV_SIG(n) b32 n(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out)
@ -197,7 +196,6 @@ typedef GET_BUFFER_BY_NAME_SIG(Get_Buffer_By_Name_Function);
typedef GET_BUFFER_BY_FILE_NAME_SIG(Get_Buffer_By_File_Name_Function);
typedef BUFFER_READ_RANGE_SIG(Buffer_Read_Range_Function);
typedef BUFFER_REPLACE_RANGE_SIG(Buffer_Replace_Range_Function);
typedef BUFFER_SET_EDIT_HANDLER_SIG(Buffer_Set_Edit_Handler_Function);
typedef BUFFER_COMPUTE_CURSOR_SIG(Buffer_Compute_Cursor_Function);
typedef BUFFER_BATCH_EDIT_SIG(Buffer_Batch_Edit_Function);
typedef BUFFER_EXISTS_SIG(Buffer_Exists_Function);
@ -377,7 +375,6 @@ Get_Buffer_By_Name_Function *get_buffer_by_name;
Get_Buffer_By_File_Name_Function *get_buffer_by_file_name;
Buffer_Read_Range_Function *buffer_read_range;
Buffer_Replace_Range_Function *buffer_replace_range;
Buffer_Set_Edit_Handler_Function *buffer_set_edit_handler;
Buffer_Compute_Cursor_Function *buffer_compute_cursor;
Buffer_Batch_Edit_Function *buffer_batch_edit;
Buffer_Exists_Function *buffer_exists;
@ -556,7 +553,6 @@ Get_Buffer_By_Name_Function *get_buffer_by_name_;
Get_Buffer_By_File_Name_Function *get_buffer_by_file_name_;
Buffer_Read_Range_Function *buffer_read_range_;
Buffer_Replace_Range_Function *buffer_replace_range_;
Buffer_Set_Edit_Handler_Function *buffer_set_edit_handler_;
Buffer_Compute_Cursor_Function *buffer_compute_cursor_;
Buffer_Batch_Edit_Function *buffer_batch_edit_;
Buffer_Exists_Function *buffer_exists_;
@ -743,7 +739,6 @@ app_links->get_buffer_by_name_ = Get_Buffer_By_Name;\
app_links->get_buffer_by_file_name_ = Get_Buffer_By_File_Name;\
app_links->buffer_read_range_ = Buffer_Read_Range;\
app_links->buffer_replace_range_ = Buffer_Replace_Range;\
app_links->buffer_set_edit_handler_ = Buffer_Set_Edit_Handler;\
app_links->buffer_compute_cursor_ = Buffer_Compute_Cursor;\
app_links->buffer_batch_edit_ = Buffer_Batch_Edit;\
app_links->buffer_exists_ = Buffer_Exists;\
@ -922,7 +917,6 @@ static b32 get_buffer_by_name(Application_Links *app, String name, Access_Flag a
static b32 get_buffer_by_file_name(Application_Links *app, String file_name, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_by_file_name(app, file_name, access, buffer_id_out));}
static b32 buffer_read_range(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 one_past_last, char *out){return(app->buffer_read_range(app, buffer_id, start, one_past_last, out));}
static b32 buffer_replace_range(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 one_past_last, String string){return(app->buffer_replace_range(app, buffer_id, start, one_past_last, string));}
static b32 buffer_set_edit_handler(Application_Links *app, Buffer_ID buffer_id, Buffer_Edit_Handler *handler){return(app->buffer_set_edit_handler(app, buffer_id, handler));}
static b32 buffer_compute_cursor(Application_Links *app, Buffer_ID buffer_id, Buffer_Seek seek, Partial_Cursor *cursor_out){return(app->buffer_compute_cursor(app, buffer_id, seek, cursor_out));}
static b32 buffer_batch_edit(Application_Links *app, Buffer_ID buffer_id, char *str, i32 str_len, Buffer_Edit *edits, i32 edit_count, Buffer_Batch_Edit_Type type){return(app->buffer_batch_edit(app, buffer_id, str, str_len, edits, edit_count, type));}
static b32 buffer_exists(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_exists(app, buffer_id));}
@ -946,7 +940,7 @@ static b32 buffer_send_end_signal(Application_Links *app, Buffer_ID buffer_id){r
static b32 create_buffer(Application_Links *app, String file_name, Buffer_Create_Flag flags, Buffer_ID *new_buffer_id_out){return(app->create_buffer(app, file_name, flags, new_buffer_id_out));}
static b32 buffer_save(Application_Links *app, Buffer_ID buffer_id, String file_name, u32 flags){return(app->buffer_save(app, buffer_id, file_name, flags));}
static b32 buffer_kill(Application_Links *app, Buffer_ID buffer_id, Buffer_Kill_Flag flags, Buffer_Kill_Result *result){return(app->buffer_kill(app, buffer_id, flags, result));}
static b32 buffer_reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags, Buffer_Reopen_Result *result){return(app->buffer_reopen(app, buffer_id, flags, result));}
static b32 buffer_reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags, Buffer_Reopen_Result *result_out){return(app->buffer_reopen(app, buffer_id, flags, result_out));}
static b32 buffer_get_file_attributes(Application_Links *app, Buffer_ID buffer_id, File_Attributes *attributes_out){return(app->buffer_get_file_attributes(app, buffer_id, attributes_out));}
static b32 get_view_next(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out){return(app->get_view_next(app, view_id, access, view_id_out));}
static b32 get_view_prev(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out){return(app->get_view_prev(app, view_id, access, view_id_out));}
@ -1101,7 +1095,6 @@ static b32 get_buffer_by_name(Application_Links *app, String name, Access_Flag a
static b32 get_buffer_by_file_name(Application_Links *app, String file_name, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_by_file_name_(app, file_name, access, buffer_id_out));}
static b32 buffer_read_range(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 one_past_last, char *out){return(app->buffer_read_range_(app, buffer_id, start, one_past_last, out));}
static b32 buffer_replace_range(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 one_past_last, String string){return(app->buffer_replace_range_(app, buffer_id, start, one_past_last, string));}
static b32 buffer_set_edit_handler(Application_Links *app, Buffer_ID buffer_id, Buffer_Edit_Handler *handler){return(app->buffer_set_edit_handler_(app, buffer_id, handler));}
static b32 buffer_compute_cursor(Application_Links *app, Buffer_ID buffer_id, Buffer_Seek seek, Partial_Cursor *cursor_out){return(app->buffer_compute_cursor_(app, buffer_id, seek, cursor_out));}
static b32 buffer_batch_edit(Application_Links *app, Buffer_ID buffer_id, char *str, i32 str_len, Buffer_Edit *edits, i32 edit_count, Buffer_Batch_Edit_Type type){return(app->buffer_batch_edit_(app, buffer_id, str, str_len, edits, edit_count, type));}
static b32 buffer_exists(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_exists_(app, buffer_id));}
@ -1125,7 +1118,7 @@ static b32 buffer_send_end_signal(Application_Links *app, Buffer_ID buffer_id){r
static b32 create_buffer(Application_Links *app, String file_name, Buffer_Create_Flag flags, Buffer_ID *new_buffer_id_out){return(app->create_buffer_(app, file_name, flags, new_buffer_id_out));}
static b32 buffer_save(Application_Links *app, Buffer_ID buffer_id, String file_name, u32 flags){return(app->buffer_save_(app, buffer_id, file_name, flags));}
static b32 buffer_kill(Application_Links *app, Buffer_ID buffer_id, Buffer_Kill_Flag flags, Buffer_Kill_Result *result){return(app->buffer_kill_(app, buffer_id, flags, result));}
static b32 buffer_reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags, Buffer_Reopen_Result *result){return(app->buffer_reopen_(app, buffer_id, flags, result));}
static b32 buffer_reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags, Buffer_Reopen_Result *result_out){return(app->buffer_reopen_(app, buffer_id, flags, result_out));}
static b32 buffer_get_file_attributes(Application_Links *app, Buffer_ID buffer_id, File_Attributes *attributes_out){return(app->buffer_get_file_attributes_(app, buffer_id, attributes_out));}
static b32 get_view_next(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out){return(app->get_view_next_(app, view_id, access, view_id_out));}
static b32 get_view_prev(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out){return(app->get_view_prev_(app, view_id, access, view_id_out));}

View File

@ -255,7 +255,7 @@ int32_t source_name_len;
int32_t line_number;
};
static Command_Metadata fcoder_metacmd_table[234] = {
{ PROC_LINKS(allow_mouse, 0), "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 332 },
{ PROC_LINKS(allow_mouse, 0), "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 331 },
{ PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 629 },
{ PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 640 },
{ PROC_LINKS(auto_tab_whole_file, 0), "auto_tab_whole_file", 19, "Audo-indents the entire current buffer.", 39, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 619 },
@ -331,16 +331,16 @@ static Command_Metadata fcoder_metacmd_table[234] = {
{ PROC_LINKS(list_all_functions_all_buffers_lister, 0), "list_all_functions_all_buffers_lister", 37, "Creates a lister of locations that look like function definitions and declarations all buffers.", 95, "w:\\4ed\\code\\4coder_function_list.cpp", 36, 338 },
{ PROC_LINKS(list_all_functions_current_buffer, 0), "list_all_functions_current_buffer", 33, "Creates a jump list of lines of the current buffer that appear to define or declare functions.", 94, "w:\\4ed\\code\\4coder_function_list.cpp", 36, 309 },
{ PROC_LINKS(list_all_functions_current_buffer_lister, 0), "list_all_functions_current_buffer_lister", 40, "Creates a lister of locations that look like function definitions and declarations in the buffer.", 97, "w:\\4ed\\code\\4coder_function_list.cpp", 36, 319 },
{ PROC_LINKS(list_all_locations, 0), "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "w:\\4ed\\code\\4coder_search.cpp", 29, 871 },
{ PROC_LINKS(list_all_locations_case_insensitive, 0), "list_all_locations_case_insensitive", 35, "Queries the user for a string and lists all exact case-insensitive matches found in all open buffers.", 101, "w:\\4ed\\code\\4coder_search.cpp", 29, 885 },
{ PROC_LINKS(list_all_locations_of_identifier, 0), "list_all_locations_of_identifier", 32, "Reads a token or word under the cursor and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 899 },
{ PROC_LINKS(list_all_locations_of_identifier_case_insensitive, 0), "list_all_locations_of_identifier_case_insensitive", 49, "Reads a token or word under the cursor and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 906 },
{ PROC_LINKS(list_all_locations_of_selection, 0), "list_all_locations_of_selection", 31, "Reads the string in the selected range and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 913 },
{ PROC_LINKS(list_all_locations_of_selection_case_insensitive, 0), "list_all_locations_of_selection_case_insensitive", 48, "Reads the string in the selected range and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 920 },
{ PROC_LINKS(list_all_locations_of_type_definition, 0), "list_all_locations_of_type_definition", 37, "Queries user for string, lists all locations of strings that appear to define a type whose name matches the input string.", 121, "w:\\4ed\\code\\4coder_search.cpp", 29, 927 },
{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "w:\\4ed\\code\\4coder_search.cpp", 29, 938 },
{ PROC_LINKS(list_all_substring_locations, 0), "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "w:\\4ed\\code\\4coder_search.cpp", 29, 878 },
{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "w:\\4ed\\code\\4coder_search.cpp", 29, 892 },
{ PROC_LINKS(list_all_locations, 0), "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "w:\\4ed\\code\\4coder_search.cpp", 29, 833 },
{ PROC_LINKS(list_all_locations_case_insensitive, 0), "list_all_locations_case_insensitive", 35, "Queries the user for a string and lists all exact case-insensitive matches found in all open buffers.", 101, "w:\\4ed\\code\\4coder_search.cpp", 29, 847 },
{ PROC_LINKS(list_all_locations_of_identifier, 0), "list_all_locations_of_identifier", 32, "Reads a token or word under the cursor and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 861 },
{ PROC_LINKS(list_all_locations_of_identifier_case_insensitive, 0), "list_all_locations_of_identifier_case_insensitive", 49, "Reads a token or word under the cursor and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 868 },
{ PROC_LINKS(list_all_locations_of_selection, 0), "list_all_locations_of_selection", 31, "Reads the string in the selected range and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 875 },
{ PROC_LINKS(list_all_locations_of_selection_case_insensitive, 0), "list_all_locations_of_selection_case_insensitive", 48, "Reads the string in the selected range and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 882 },
{ PROC_LINKS(list_all_locations_of_type_definition, 0), "list_all_locations_of_type_definition", 37, "Queries user for string, lists all locations of strings that appear to define a type whose name matches the input string.", 121, "w:\\4ed\\code\\4coder_search.cpp", 29, 889 },
{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "w:\\4ed\\code\\4coder_search.cpp", 29, 900 },
{ PROC_LINKS(list_all_substring_locations, 0), "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "w:\\4ed\\code\\4coder_search.cpp", 29, 840 },
{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "w:\\4ed\\code\\4coder_search.cpp", 29, 854 },
{ PROC_LINKS(lister__activate, 0), "lister__activate", 16, "A lister mode command that activates the list's action on the highlighted item.", 79, "w:\\4ed\\code\\4coder_lists.cpp", 28, 15 },
{ PROC_LINKS(lister__backspace_text_field, 0), "lister__backspace_text_field", 28, "A lister mode command that dispatches to the lister's backspace text field handler.", 83, "w:\\4ed\\code\\4coder_lists.cpp", 28, 41 },
{ PROC_LINKS(lister__backspace_text_field__default, 0), "lister__backspace_text_field__default", 37, "A lister mode command that backspaces one character from the text field.", 72, "w:\\4ed\\code\\4coder_lists.cpp", 28, 145 },
@ -407,7 +407,7 @@ static Command_Metadata fcoder_metacmd_table[234] = {
{ PROC_LINKS(query_replace_selection, 0), "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1117 },
{ PROC_LINKS(redo, 0), "redo", 4, "Advances forward through the undo history in the buffer containing the most recent regular edit.", 96, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1808 },
{ PROC_LINKS(redo_this_buffer, 0), "redo_this_buffer", 16, "Advances forwards through the undo history of the current buffer.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1716 },
{ PROC_LINKS(remap_interactive, 0), "remap_interactive", 17, "Switch to a named key binding map.", 34, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 382 },
{ PROC_LINKS(remap_interactive, 0), "remap_interactive", 17, "Switch to a named key binding map.", 34, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 381 },
{ PROC_LINKS(rename_file_query, 0), "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1257 },
{ PROC_LINKS(rename_parameter, 0), "rename_parameter", 16, "If the cursor is found to be on the name of a function parameter in the signature of a function definition, all occurences within the scope of the function will be replaced with a new provided string.", 200, "w:\\4ed\\code\\4coder_experiments.cpp", 34, 383 },
{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1640 },
@ -447,8 +447,8 @@ static Command_Metadata fcoder_metacmd_table[234] = {
{ PROC_LINKS(set_bindings_default, 0), "set_bindings_default", 20, "Remap keybindings using the 'default' mapping rule.", 51, "w:\\4ed\\code\\4coder_remapping_commands.cpp", 41, 61 },
{ PROC_LINKS(set_bindings_mac_default, 0), "set_bindings_mac_default", 24, "Remap keybindings using the 'mac-default' mapping rule.", 55, "w:\\4ed\\code\\4coder_remapping_commands.cpp", 41, 75 },
{ PROC_LINKS(set_mark, 0), "set_mark", 8, "Sets the mark to the current position of the cursor.", 52, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 121 },
{ PROC_LINKS(set_mode_to_notepad_like, 0), "set_mode_to_notepad_like", 24, "Sets the edit mode to Notepad like.", 35, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 350 },
{ PROC_LINKS(set_mode_to_original, 0), "set_mode_to_original", 20, "Sets the edit mode to 4coder original.", 38, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 344 },
{ PROC_LINKS(set_mode_to_notepad_like, 0), "set_mode_to_notepad_like", 24, "Sets the edit mode to Notepad like.", 35, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 349 },
{ PROC_LINKS(set_mode_to_original, 0), "set_mode_to_original", 20, "Sets the edit mode to 4coder original.", 38, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 343 },
{ PROC_LINKS(setup_build_bat, 0), "setup_build_bat", 15, "Queries the user for several configuration options and initializes a new build batch script.", 92, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 1498 },
{ PROC_LINKS(setup_build_bat_and_sh, 0), "setup_build_bat_and_sh", 22, "Queries the user for several configuration options and initializes a new build batch script.", 92, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 1510 },
{ PROC_LINKS(setup_build_sh, 0), "setup_build_sh", 14, "Queries the user for several configuration options and initializes a new build shell script.", 92, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 1504 },
@ -458,19 +458,19 @@ static Command_Metadata fcoder_metacmd_table[234] = {
{ PROC_LINKS(snipe_token_or_word, 0), "snipe_token_or_word", 19, "Delete a single, whole token on or to the left of the cursor and post it to the clipboard.", 90, "w:\\4ed\\code\\4coder_seek.cpp", 27, 1224 },
{ PROC_LINKS(snipe_token_or_word_right, 0), "snipe_token_or_word_right", 25, "Delete a single, whole token on or to the right of the cursor and post it to the clipboard.", 91, "w:\\4ed\\code\\4coder_seek.cpp", 27, 1230 },
{ PROC_LINKS(snippet_lister, 0), "snippet_lister", 14, "Opens a snippet lister for inserting whole pre-written snippets of text.", 72, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 248 },
{ PROC_LINKS(suppress_mouse, 0), "suppress_mouse", 14, "Hides the mouse and causes all mosue input (clicks, position, wheel) to be ignored.", 83, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 326 },
{ PROC_LINKS(suppress_mouse, 0), "suppress_mouse", 14, "Hides the mouse and causes all mosue input (clicks, position, wheel) to be ignored.", 83, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 325 },
{ PROC_LINKS(swap_buffers_between_panels, 0), "swap_buffers_between_panels", 27, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1592 },
{ PROC_LINKS(to_lowercase, 0), "to_lowercase", 12, "Converts all ascii text in the range between the cursor and the mark to lowercase.", 82, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 421 },
{ PROC_LINKS(to_uppercase, 0), "to_uppercase", 12, "Converts all ascii text in the range between the cursor and the mark to uppercase.", 82, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 401 },
{ PROC_LINKS(toggle_filebar, 0), "toggle_filebar", 14, "Toggles the visibility status of the current view's filebar.", 60, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 555 },
{ PROC_LINKS(toggle_fps_meter, 0), "toggle_fps_meter", 16, "Toggles the visibility of the FPS performance meter", 51, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 573 },
{ PROC_LINKS(toggle_fullscreen, 0), "toggle_fullscreen", 17, "Toggle fullscreen mode on or off. The change(s) do not take effect until the next frame.", 89, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 374 },
{ PROC_LINKS(toggle_highlight_enclosing_scopes, 0), "toggle_highlight_enclosing_scopes", 33, "In code files scopes surrounding the cursor are highlighted with distinguishing colors.", 87, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 362 },
{ PROC_LINKS(toggle_highlight_line_at_cursor, 0), "toggle_highlight_line_at_cursor", 31, "Toggles the line highlight at the cursor.", 41, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 356 },
{ PROC_LINKS(toggle_fullscreen, 0), "toggle_fullscreen", 17, "Toggle fullscreen mode on or off. The change(s) do not take effect until the next frame.", 89, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 373 },
{ PROC_LINKS(toggle_highlight_enclosing_scopes, 0), "toggle_highlight_enclosing_scopes", 33, "In code files scopes surrounding the cursor are highlighted with distinguishing colors.", 87, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 361 },
{ PROC_LINKS(toggle_highlight_line_at_cursor, 0), "toggle_highlight_line_at_cursor", 31, "Toggles the line highlight at the cursor.", 41, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 355 },
{ PROC_LINKS(toggle_line_numbers, 0), "toggle_line_numbers", 19, "Toggles the left margin line numbers.", 37, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 660 },
{ PROC_LINKS(toggle_line_wrap, 0), "toggle_line_wrap", 16, "Toggles the current buffer's line wrapping status.", 50, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 564 },
{ PROC_LINKS(toggle_mouse, 0), "toggle_mouse", 12, "Toggles the mouse suppression mode, see suppress_mouse and allow_mouse.", 71, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 338 },
{ PROC_LINKS(toggle_paren_matching_helper, 0), "toggle_paren_matching_helper", 28, "In code files matching parentheses pairs are colored with distinguishing colors.", 80, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 368 },
{ PROC_LINKS(toggle_mouse, 0), "toggle_mouse", 12, "Toggles the mouse suppression mode, see suppress_mouse and allow_mouse.", 71, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 337 },
{ PROC_LINKS(toggle_paren_matching_helper, 0), "toggle_paren_matching_helper", 28, "In code files matching parentheses pairs are colored with distinguishing colors.", 80, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 367 },
{ PROC_LINKS(toggle_show_whitespace, 0), "toggle_show_whitespace", 22, "Toggles the current buffer's whitespace visibility status.", 58, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 653 },
{ PROC_LINKS(toggle_virtual_whitespace, 0), "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 642 },
{ PROC_LINKS(uncomment_line, 0), "uncomment_line", 14, "If present, delete '//' at the beginning of the line after leading whitespace.", 78, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 147 },
@ -478,7 +478,7 @@ static Command_Metadata fcoder_metacmd_table[234] = {
{ PROC_LINKS(undo_this_buffer, 0), "undo_this_buffer", 16, "Advances backwards through the undo history of the current buffer.", 66, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1702 },
{ PROC_LINKS(view_buffer_other_panel, 0), "view_buffer_other_panel", 23, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1582 },
{ PROC_LINKS(view_jump_list_with_lister, 0), "view_jump_list_with_lister", 26, "When executed on a buffer with jumps, creates a persistent lister for all the jumps", 83, "w:\\4ed\\code\\4coder_jump_lister.cpp", 34, 106 },
{ PROC_LINKS(word_complete, 0), "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "w:\\4ed\\code\\4coder_search.cpp", 29, 958 },
{ PROC_LINKS(word_complete, 0), "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "w:\\4ed\\code\\4coder_search.cpp", 29, 920 },
{ 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, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 652 },
{ PROC_LINKS(write_block, 0), "write_block", 11, "At the cursor, insert a block comment.", 38, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 103 },
{ PROC_LINKS(write_character, 0), "write_character", 15, "Inserts whatever character was used to trigger this command.", 60, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 67 },

View File

@ -101,14 +101,5 @@ insert_line_from_buffer(Buffer_Insertion *insertion, Buffer_ID buffer_id, i32 li
return(insert_line_from_buffer(insertion, buffer_id, line, 0));
}
static b32
insert_mirror_range(Buffer_Insertion *insertion, Buffer_ID source, i32 source_first, i32 length){
b32 result = mirror_buffer_insert_range(insertion->app, insertion->buffer, source, insertion->at, source_first, length);
if (result){
insertion->at += length;
}
return(result);
}
// BOTTOM

View File

@ -1,956 +0,0 @@
/*
4coder_mirror.cpp - Commands and helpers for parsing jump locations from
compiler errors, sticking markers on jump locations, and jumping to them.
*/
// TOP
static Managed_Variable_ID mirror_root_loc = 0;
#define DefaultMirrorRootName "DEFAULT.mirror_root"
static b32
mirror_edit_handler(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 one_past_last, String text);
////////////////////////////////
static void
mirror__global_init(Application_Links *app){
if (mirror_root_loc == 0){
mirror_root_loc = managed_variable_create_or_get_id(app, DefaultMirrorRootName, 0);
}
}
static Managed_Object
mirror__check_scope_for_mirror(Application_Links *app, Managed_Scope scope){
Managed_Object result = 0;
Managed_Object mirror = 0;
if (managed_variable_get(app, scope, mirror_root_loc, &mirror)){
if (mirror != 0){
Managed_Object_Type object_type = managed_object_get_type(app, mirror);
if (object_type == ManagedObjectType_Memory){
result = mirror;
}
else{
managed_variable_set(app, scope, mirror_root_loc, 0);
}
}
}
return(result);
}
static b32
mirror_init__inner(Application_Links *app, Buffer_ID buffer, Mirror_Flags flags, Managed_Object *mirror_object_out){
b32 result = false;
Managed_Scope scope = 0;
if (buffer_get_managed_scope(app, buffer, &scope)){
Managed_Object mirror = mirror__check_scope_for_mirror(app, scope);
if (mirror == 0){
mirror = alloc_managed_memory_in_scope(app, scope, sizeof(Mirror), 1);
if (managed_variable_set(app, scope, mirror_root_loc, mirror)){
Mirror mirror_data = {};
mirror_data.mirror_buffer_id = buffer;
mirror_data.mode = MirrorMode_Constructing;
mirror_data.flags = flags;
mirror_data.mirror_scope = create_user_managed_scope(app);
*mirror_object_out = mirror;
managed_object_store_data(app, mirror, 0, 1, &mirror_data);
buffer_set_edit_handler(app, buffer, mirror_edit_handler);
result = true;
}
}
}
return(result);
}
static b32
mirror_end__inner(Application_Links *app, Managed_Object mirror){
b32 result = false;
Managed_Scope scope = managed_object_get_containing_scope(app, mirror);
Managed_Object mirror_check = mirror__check_scope_for_mirror(app, scope);
if (mirror_check == mirror){
Mirror mirror_data = {};
if (managed_object_load_data(app, mirror, 0, 1, &mirror_data)){
destroy_user_managed_scope(app, mirror_data.mirror_scope);
buffer_set_edit_handler(app, mirror_data.mirror_buffer_id, 0);
result = true;
}
managed_variable_set(app, scope, mirror_root_loc, 0);
managed_object_free(app, mirror);
}
return(result);
}
struct Mirror__Binary_Search_Result{
b32 abutting;
i32 index;
};
static Mirror__Binary_Search_Result
mirror__binary_search_max_point_below(Marker *ranges, i32 target, i32 first, i32 one_past_last){
Mirror__Binary_Search_Result result = {};
result.index = -1;
first = (first*2) - 1;
one_past_last = one_past_last*2;
for (;;){
i32 mid = (first + one_past_last)/2;
i32 pos = -1;
if (mid != -1){
Marker *marker = ranges + mid;
pos = marker->pos;
}
if (pos > target){
one_past_last = mid;
}
else if (pos < target){
first = mid;
}
else{
result.abutting = true;
result.index = mid;
break;
}
if (first + 1 >= one_past_last){
result.index = first;
break;
}
}
return(result);
}
static Mirror__Binary_Search_Result
mirror__binary_search_min_point_above(Marker *ranges, i32 target, i32 first, i32 one_past_last,
i32 fake_index, i32 fake_pos){
Mirror__Binary_Search_Result result = {};
result.index = -1;
first = first*2;
one_past_last = (one_past_last*2) + 1;
for (;;){
i32 mid = (first + one_past_last - 1)/2;
i32 pos = fake_pos;
if (mid != fake_index){
Marker *marker = ranges + mid;
pos = marker->pos;
}
if (pos > target){
one_past_last = mid + 1;
}
else if (pos < target){
first = mid + 1;
}
else{
result.abutting = true;
result.index = mid;
break;
}
if (first + 1 >= one_past_last){
result.index = first;
break;
}
}
return(result);
}
static Mirror_Hot
mirror__hot_from_data(Application_Links *app, Arena *arena, Mirror mirror_data){
Mirror_Hot result = {};
Mirror_Hot mirror_hot = {};
mirror_hot.count = mirror_data.count;
mirror_hot.source_buffer_ids = push_array(arena, Buffer_ID, mirror_hot.count);
mirror_hot.mirror_ranges = push_array(arena, Marker, (mirror_hot.count)*2);
mirror_hot.source_ranges = push_array(arena, Managed_Object, mirror_hot.count);
if (managed_object_load_data(app, mirror_data.source_buffer_ids, 0, mirror_hot.count, mirror_hot.source_buffer_ids) &&
managed_object_load_data(app, mirror_data.mirror_ranges, 0, mirror_hot.count*2, mirror_hot.mirror_ranges) &&
managed_object_load_data(app, mirror_data.source_ranges, 0, mirror_hot.count, mirror_hot.source_ranges)){
result = mirror_hot;
}
return(result);
}
static b32
mirror__min_max_point_indices_not_intersecting(i32 above_point, i32 below_point, i32 *range_index_out){
b32 result = false;
if (below_point < above_point && (above_point%2) == 0 && ((below_point + 2)%2) == 1){
*range_index_out = above_point/2;
result = true;
}
return(result);
}
static b32
mirror__min_max_point_indices_contained(i32 above_point, i32 below_point, i32 *range_index_out){
b32 result = false;
if (below_point < above_point && (above_point%2) == 1 && ((below_point + 2)%2) == 0){
*range_index_out = above_point/2;
result = true;
}
return(result);
}
struct Mirror__Check_Range_Result{
b32 passed_checks;
i32 insert_index;
};
static Mirror__Check_Range_Result
mirror__check_range_to_add(Application_Links *app, Arena *scratch, i32 mirror_first, i32 source_first, i32 length,
Buffer_Summary *source_buffer, Buffer_Summary *mirror_buffer, Mirror_Hot *mirror_hot,
i32 collidable_indices_first, b32 auto_trust_text){
// check the new range for the following rules and determine the insert index
Mirror__Check_Range_Result result = {};
result.insert_index = -1;
// 1. the source range must be entirely contained in the source buffer and
// the mirror range must be entirely contained in the mirror buffer
i32 source_one_past_last = source_first + length;
i32 mirror_one_past_last = mirror_first + length;
if (0 <= source_first && source_one_past_last <= source_buffer->size &&
0 <= mirror_first && mirror_one_past_last <= mirror_buffer->size){
// 2. the mirror range must not overlap or abut any existing mirror ranges
b32 independent_range = false;
if (mirror_hot->count == 0){
independent_range = true;
result.insert_index = 0;
}
else{
i32 fake_index = mirror_hot->count*2;
i32 fake_pos = mirror_buffer->size + 1;
Mirror__Binary_Search_Result above_point = mirror__binary_search_min_point_above(mirror_hot->mirror_ranges, mirror_first,
collidable_indices_first, mirror_hot->count,
fake_index, fake_pos);
Mirror__Binary_Search_Result below_point = {};
if (!above_point.abutting){
below_point = mirror__binary_search_max_point_below(mirror_hot->mirror_ranges, mirror_first,
collidable_indices_first, mirror_hot->count);
if (!below_point.abutting){
if (mirror__min_max_point_indices_not_intersecting(above_point.index, below_point.index, &result.insert_index)){
independent_range = true;
Assert(0 <= result.insert_index && result.insert_index <= mirror_hot->count);
}
}
}
}
if (independent_range){
// 3. the text in the source range must exactly match the text in the mirror range
if (auto_trust_text){
result.passed_checks = true;
}
else{
char *buffer_1 = push_array(scratch, char, length);
char *buffer_2 = push_array(scratch, char, length);
if (buffer_read_range(app, source_buffer->buffer_id, source_first, source_first + length, buffer_1)){
if (buffer_read_range(app, mirror_buffer->buffer_id, mirror_first, mirror_first + length, buffer_2)){
if (memcmp(buffer_1, buffer_2, length) == 0){
result.passed_checks = true;
}
}
}
}
}
}
return(result);
}
static b32
mirror_add_range__inner_check_optimization(Application_Links *app, Managed_Object mirror, Buffer_ID source,
i32 mirror_first, i32 source_first, i32 length,
i32 collidable_indices_first, b32 auto_trust_text, i32 *insert_index_out){
b32 result = false;
if (length > 0){
Buffer_Summary source_buffer = {};
if (get_buffer_summary(app, source, AccessAll, &source_buffer)){
Managed_Scope scope = managed_object_get_containing_scope(app, mirror);
Managed_Object mirror_check = mirror__check_scope_for_mirror(app, scope);
Mirror mirror_data = {};
if (mirror_check == mirror && managed_object_load_data(app, mirror, 0, 1, &mirror_data)){
Buffer_Summary mirror_buffer = {};
Buffer_ID mirror_id = mirror_data.mirror_buffer_id;
if (get_buffer_summary(app, mirror_id, AccessAll, &mirror_buffer)){
Arena *arena = context_get_arena(app);
Temp_Memory_Arena temp = begin_temp_memory(arena);
// read mirror data into hot structure
Mirror_Hot mirror_hot = {};
mirror_hot.count = mirror_data.count;
mirror_hot.source_buffer_ids = push_array(arena, Buffer_ID, mirror_hot.count);
mirror_hot.mirror_ranges = push_array(arena, Marker, (mirror_hot.count)*2);
mirror_hot.source_ranges = push_array(arena, Managed_Object, mirror_hot.count);
b32 load_success = false;
if (mirror_hot.count == 0){
load_success = true;
}
else{
load_success = (managed_object_load_data(app, mirror_data.source_buffer_ids, 0, mirror_hot.count , mirror_hot.source_buffer_ids) &&
managed_object_load_data(app, mirror_data.mirror_ranges , 0, mirror_hot.count*2, mirror_hot.mirror_ranges ) &&
managed_object_load_data(app, mirror_data.source_ranges , 0, mirror_hot.count , mirror_hot.source_ranges ));
}
if (load_success){
Mirror__Check_Range_Result check = mirror__check_range_to_add(app, arena, mirror_first, source_first, length,
&source_buffer, &mirror_buffer, &mirror_hot,
collidable_indices_first, auto_trust_text);
if (check.passed_checks){
// insert the new range at the insert index
b32 r = true;
i32 insert_index = check.insert_index;
*insert_index_out = insert_index;
Marker mirror_range[2] = {};
mirror_range[0].pos = mirror_first;
mirror_range[0].lean_right = false;
mirror_range[1].pos = mirror_first + length;
mirror_range[1].lean_right = true;
Marker source_range[2] = {};
source_range[0].pos = source_first;
source_range[0].lean_right = false;
source_range[1].pos = source_first + length;
source_range[1].lean_right = true;
Managed_Scope scopes[3] = {};
scopes[0] = scope;
scopes[1] = mirror_data.mirror_scope;
buffer_get_managed_scope(app, source, &scopes[2]);
Managed_Scope source_sub_scope = get_managed_scope_with_multiple_dependencies(app, scopes, 3);
Managed_Object new_source_range = alloc_buffer_markers_on_buffer(app, source, 2, &source_sub_scope);
r = r && managed_object_store_data(app, new_source_range, 0, 2, &source_range);
if (mirror_data.count + 1 > mirror_data.max){
if (mirror_data.count != 0){
r = r && managed_object_free(app, mirror_data.source_buffer_ids);
r = r && managed_object_free(app, mirror_data.mirror_ranges);
r = r && managed_object_free(app, mirror_data.source_ranges);
}
Managed_Scope mirror_sub_scope = get_managed_scope_with_multiple_dependencies(app, scopes, 2);
i32 new_max = 256;
if (new_max <= mirror_data.max){
new_max = mirror_data.max*2;
}
mirror_data.source_buffer_ids = alloc_managed_memory_in_scope(app, mirror_sub_scope, sizeof(Buffer_ID), new_max);
mirror_data.mirror_ranges = alloc_buffer_markers_on_buffer(app, mirror_id, new_max*2, &mirror_sub_scope);
mirror_data.source_ranges = alloc_managed_memory_in_scope(app, mirror_sub_scope, sizeof(Managed_Object), new_max);
mirror_data.max = new_max;
// head ranges
i32 head_count = insert_index;
if (head_count > 0){
r = r && managed_object_store_data(app, mirror_data.source_buffer_ids, 0, head_count , mirror_hot.source_buffer_ids);
r = r && managed_object_store_data(app, mirror_data.mirror_ranges , 0, head_count*2, mirror_hot.mirror_ranges );
r = r && managed_object_store_data(app, mirror_data.source_ranges , 0, head_count , mirror_hot.source_ranges );
}
}
// tail ranges
i32 tail_count = mirror_hot.count - insert_index;
if (tail_count > 0){
i32 to = insert_index + 1;
i32 from = insert_index;
r = r && managed_object_store_data(app, mirror_data.source_buffer_ids, to , tail_count , mirror_hot.source_buffer_ids + from);
r = r && managed_object_store_data(app, mirror_data.mirror_ranges , to*2, tail_count*2, mirror_hot.mirror_ranges + from*2 );
r = r && managed_object_store_data(app, mirror_data.source_ranges , to , tail_count , mirror_hot.source_ranges + from );
}
// new range
r = r && managed_object_store_data(app, mirror_data.source_buffer_ids, insert_index , 1, &source );
r = r && managed_object_store_data(app, mirror_data.mirror_ranges , insert_index*2, 2, mirror_range );
r = r && managed_object_store_data(app, mirror_data.source_ranges , insert_index , 1, &new_source_range);
mirror_data.count += 1;
managed_object_store_data(app, mirror, 0, 1, &mirror_data);
result = r;
}
}
end_temp_memory(temp);
}
}
}
}
return(result);
}
static b32
mirror_add_range__inner(Application_Links *app, Managed_Object mirror, Buffer_ID source,
i32 mirror_first, i32 source_first, i32 length){
i32 ignore = 0;
return(mirror_add_range__inner_check_optimization(app, mirror, source, mirror_first, source_first, length, 0, false, &ignore));
}
static b32
mirror_set_mode__inner(Application_Links *app, Managed_Object mirror, Mirror_Mode mode){
b32 result = false;
Managed_Scope scope = managed_object_get_containing_scope(app, mirror);
Managed_Object mirror_check = mirror__check_scope_for_mirror(app, scope);
if (mirror_check == mirror){
Mirror mirror_data = {};
if (managed_object_load_data(app, mirror, 0, 1, &mirror_data)){
mirror_data.mode = mode;
if (managed_object_store_data(app, mirror, 0, 1, &mirror_data)){
result = true;
}
}
}
return(result);
}
static b32
mirror_get_mode__inner(Application_Links *app, Managed_Object mirror, Mirror_Mode *mode_out){
b32 result = false;
Managed_Scope scope = managed_object_get_containing_scope(app, mirror);
Managed_Object mirror_check = mirror__check_scope_for_mirror(app, scope);
if (mirror_check == mirror){
Mirror mirror_data = {};
if (managed_object_load_data(app, mirror, 0, 1, &mirror_data)){
*mode_out = mirror_data.mode;
result = true;
}
}
return(result);
}
static b32
mirror_set_flags__inner(Application_Links *app, Managed_Object mirror, Mirror_Flags flags){
b32 result = false;
Managed_Scope scope = managed_object_get_containing_scope(app, mirror);
Managed_Object mirror_check = mirror__check_scope_for_mirror(app, scope);
if (mirror_check == mirror){
Mirror mirror_data = {};
if (managed_object_load_data(app, mirror, 0, 1, &mirror_data)){
mirror_data.flags = flags;
if (managed_object_store_data(app, mirror, 0, 1, &mirror_data)){
result = true;
}
}
}
return(result);
}
static b32
mirror_get_flags__inner(Application_Links *app, Managed_Object mirror, Mirror_Flags *flags_out){
b32 result = false;
Managed_Scope scope = managed_object_get_containing_scope(app, mirror);
Managed_Object mirror_check = mirror__check_scope_for_mirror(app, scope);
if (mirror_check == mirror){
Mirror mirror_data = {};
if (managed_object_load_data(app, mirror, 0, 1, &mirror_data)){
*flags_out = mirror_data.flags;
result = true;
}
}
return(result);
}
////////////////////////////////
static b32
mirror_init(Application_Links *app, Buffer_ID buffer, Mirror_Flags flags, Managed_Object *mirror_object_out){
mirror__global_init(app);
return(mirror_init__inner(app, buffer, flags, mirror_object_out));
}
static b32
mirror_end(Application_Links *app, Managed_Object mirror){
mirror__global_init(app);
return(mirror_end__inner(app, mirror));
}
static b32
mirror_add_range(Application_Links *app, Managed_Object mirror, Buffer_ID source,
i32 mirror_first, i32 source_first, i32 length){
mirror__global_init(app);
return(mirror_add_range__inner(app, mirror, source, mirror_first, source_first, length));
}
static b32
mirror_set_mode(Application_Links *app, Managed_Object mirror, Mirror_Mode mode){
mirror__global_init(app);
return(mirror_set_mode__inner(app, mirror, mode));
}
static b32
mirror_get_mode(Application_Links *app, Managed_Object mirror, Mirror_Mode *mode_out){
mirror__global_init(app);
return(mirror_get_mode__inner(app, mirror, mode_out));
}
static b32
mirror_set_flags(Application_Links *app, Managed_Object mirror, Mirror_Flags flags){
mirror__global_init(app);
return(mirror_set_flags__inner(app, mirror, flags));
}
static b32
mirror_get_flags(Application_Links *app, Managed_Object mirror, Mirror_Flags *flags_out){
mirror__global_init(app);
return(mirror_get_flags__inner(app, mirror, flags_out));
}
////////////////////////////////
static b32
mirror_buffer_create(Application_Links *app, String buffer_name, Mirror_Flags flags, Buffer_ID *mirror_buffer_id_out){
mirror__global_init(app);
b32 result = false;
Buffer_ID new_buffer = 0;
if (!get_buffer_by_name(app, buffer_name, AccessAll, &new_buffer)){
if (new_buffer == 0){
if (create_buffer(app, buffer_name, BufferCreate_NeverAttachToFile|BufferCreate_AlwaysNew, &new_buffer)){
Managed_Object ignore_object = 0;
if (mirror_init__inner(app, new_buffer, flags, &ignore_object)){
*mirror_buffer_id_out = new_buffer;
result = true;
}
}
}
}
return(false);
}
static Managed_Scope
mirror__buffer_to_object(Application_Links *app, Buffer_ID buffer){
Managed_Object result = 0;
Managed_Scope scope = 0;
if (buffer_get_managed_scope(app, buffer, &scope)){
result = mirror__check_scope_for_mirror(app, scope);
}
return(result);
}
static b32
mirror_buffer_end(Application_Links *app, Buffer_ID mirror){
mirror__global_init(app);
b32 result = false;
Managed_Object mirror_object = mirror__buffer_to_object(app, mirror);
if (mirror_object != 0){
result = mirror_end__inner(app, mirror_object);
}
return(result);
}
static b32
mirror_buffer_add_range_exact(Application_Links *app, Buffer_ID mirror, Buffer_ID source,
i32 mirror_first, i32 source_first, i32 length){
mirror__global_init(app);
b32 result = false;
Managed_Object mirror_object = mirror__buffer_to_object(app, mirror);
if (mirror_object != 0){
result = mirror_add_range__inner(app, mirror_object, source, mirror_first, source_first, length);
}
return(result);
}
static i32
mirror__range_loose_get_length(Application_Links *app, Buffer_ID mirror, Buffer_ID source,
i32 mirror_first, i32 source_first, i32 max_length){
i32 result = 0;
Arena *arena = context_get_arena(app);
Temp_Memory_Arena temp = begin_temp_memory(arena);
char *buffer_1 = push_array(arena, char, max_length);
char *buffer_2 = push_array(arena, char, max_length);
if (buffer_read_range(app, source, source_first, source_first + max_length, buffer_1)){
if (buffer_read_range(app, mirror, mirror_first, mirror_first + max_length, buffer_2)){
for (; result < max_length;
result += 1){
if (buffer_1[result] != buffer_2[result]){
break;
}
}
}
}
end_temp_memory(temp);
return(result);
}
static b32
mirror_buffer_add_range_loose(Application_Links *app, Buffer_ID mirror, Buffer_ID source,
i32 mirror_first, i32 source_first, i32 max_length){
mirror__global_init(app);
b32 result = false;
i32 length = mirror__range_loose_get_length(app, mirror, source, mirror_first, source_first, max_length);
if (length > 0){
Managed_Object mirror_object = mirror__buffer_to_object(app, mirror);
if (mirror_object != 0){
result = mirror_add_range__inner(app, mirror_object, source, mirror_first, source_first, length);
}
}
return(result);
}
static b32
mirror_buffer_insert_range(Application_Links *app, Buffer_ID mirror, Buffer_ID source,
i32 mirror_insert_pos, i32 source_first, i32 length){
mirror__global_init(app);
b32 result = false;
Managed_Object mirror_object = mirror__buffer_to_object(app, mirror);
if (mirror_object != 0){
Mirror_Mode mode = 0;
if (mirror_get_mode__inner(app, mirror_object, &mode)){
if (mode == MirrorMode_Constructing){
b32 did_insert = false;
{
Arena *arena = context_get_arena(app);
Temp_Memory_Arena temp = begin_temp_memory(arena);
char *buffer = push_array(arena, char, length);
if (buffer_read_range(app, source, source_first, source_first + length, buffer)){
String string = make_string(buffer, length);
if (buffer_replace_range(app, mirror, mirror_insert_pos, mirror_insert_pos, string)){
did_insert = true;
}
}
end_temp_memory(temp);
}
if (did_insert){
result = mirror_add_range__inner(app, mirror_object, source, mirror_insert_pos, source_first, length);
}
}
}
}
return(result);
}
static b32
mirror_buffer_set_mode(Application_Links *app, Buffer_ID mirror, Mirror_Mode mode){
mirror__global_init(app);
b32 result = false;
Managed_Object mirror_object = mirror__buffer_to_object(app, mirror);
if (mirror_object != 0){
result = mirror_set_mode__inner(app, mirror_object, mode);
}
return(result);
}
static b32
mirror_buffer_get_mode(Application_Links *app, Buffer_ID mirror, Mirror_Mode *mode_out){
mirror__global_init(app);
b32 result = false;
Managed_Object mirror_object = mirror__buffer_to_object(app, mirror);
if (mirror_object != 0){
result = mirror_get_mode__inner(app, mirror_object, mode_out);
}
return(result);
}
static b32
mirror_buffer_set_flags(Application_Links *app, Buffer_ID mirror, Mirror_Flags flags){
mirror__global_init(app);
b32 result = false;
Managed_Object mirror_object = mirror__buffer_to_object(app, mirror);
if (mirror_object != 0){
result = mirror_set_flags__inner(app, mirror_object, flags);
}
return(result);
}
static b32
mirror_buffer_get_flags(Application_Links *app, Buffer_ID mirror, Mirror_Flags *flags_out){
mirror__global_init(app);
b32 result = false;
Managed_Object mirror_object = mirror__buffer_to_object(app, mirror);
if (mirror_object != 0){
result = mirror_get_flags__inner(app, mirror_object, flags_out);
}
return(result);
}
static b32
mirror_buffer_refresh(Application_Links *app, Buffer_ID mirror){
mirror__global_init(app);
b32 result = false;
Managed_Object mirror_object = mirror__buffer_to_object(app, mirror);
if (mirror_object != 0){
// TODO(allen):
}
return(result);
}
static void
mirror_quick_sort_mirror_ranges(Mirror_Range *ranges, i32 first, i32 one_past_last){
i32 last = one_past_last - 1;
if (first < last){
i32 pivot_mirror_first = ranges[last].mirror_first;
i32 j = first;
for (i32 i = first; i < last; i += 1){
i32 mirror_first = ranges[i].mirror_first;
if (mirror_first < pivot_mirror_first){
if (j < i){
Mirror_Range t = ranges[i];
ranges[i] = ranges[j];
ranges[j] = t;
}
j += 1;
}
}
{
Mirror_Range t = ranges[last];
ranges[last] = ranges[j];
ranges[j] = t;
}
i32 pivot = j;
mirror_quick_sort_mirror_ranges(ranges, first, pivot);
mirror_quick_sort_mirror_ranges(ranges, pivot + 1, one_past_last);
}
}
static b32
mirror__check_range_array_sorting(Mirror_Range *ranges, i32 count){
b32 result = true;
i32 prev_pos = -1;
for (i32 i = 0; i < count; i += 1){
i32 first = ranges[i].mirror_first;
i32 one_past_last = first + ranges[i].length;
if (prev_pos < first && first <= one_past_last){
prev_pos = one_past_last;
}
else{
result = false;
break;
}
}
return(result);
}
static b32
mirror_buffer_add_range_exact_array(Application_Links *app, Buffer_ID mirror, Mirror_Range *ranges, i32 count){
mirror__global_init(app);
b32 result = false;
Managed_Object mirror_object = mirror__buffer_to_object(app, mirror);
if (mirror_object != 0){
if (mirror__check_range_array_sorting(ranges, count)){
b32 r = true;
Mirror_Range *range = ranges;
i32 safe_to_ignore_index = 0;
for (i32 i = 0; i < count; i += 1, range += 1){
i32 new_range_index = 0;
if (range->length > 0){
if (!mirror_add_range__inner_check_optimization(app, mirror_object, range->source_buffer_id,
range->mirror_first, range->source_first, range->length,
safe_to_ignore_index, false, &new_range_index)){
r = false;
}
else{
safe_to_ignore_index = new_range_index + 1;
}
}
}
result = r;
}
}
return(result);
}
static b32
mirror_buffer_add_range_loose_array(Application_Links *app, Buffer_ID mirror, Mirror_Range *ranges, i32 count){
mirror__global_init(app);
b32 result = false;
Managed_Object mirror_object = mirror__buffer_to_object(app, mirror);
if (mirror_object != 0){
{
Mirror_Range *range = ranges;
for (i32 i = 0; i < count; i += 1, range += 1){
range->length = mirror__range_loose_get_length(app, mirror, range->source_buffer_id, range->mirror_first, range->source_first, range->length);
}
}
if (mirror__check_range_array_sorting(ranges, count)){
b32 r = true;
Mirror_Range *range = ranges;
i32 safe_to_ignore_index = 0;
for (i32 i = 0; i < count; i += 1, range += 1){
i32 new_range_index = 0;
if (range->length > 0){
if (!mirror_add_range__inner_check_optimization(app, mirror_object, range->source_buffer_id,
range->mirror_first, range->source_first, range->length,
safe_to_ignore_index, false, &new_range_index)){
r = false;
}
else{
safe_to_ignore_index = new_range_index + 1;
}
}
}
result = r;
}
}
return(result);
}
static b32
mirror_buffer_insert_range_array(Application_Links *app, Buffer_ID mirror, Mirror_Range *ranges, i32 count){
mirror__global_init(app);
b32 result = false;
Managed_Object mirror_object = mirror__buffer_to_object(app, mirror);
if (mirror_object != 0){
Mirror_Mode mode = 0;
if (mirror_get_mode__inner(app, mirror_object, &mode)){
if (mode == MirrorMode_Constructing){
if (mirror__check_range_array_sorting(ranges, count)){
b32 r = true;
Mirror_Range *range = ranges;
i32 safe_to_ignore_index = 0;
i32 total_shift = 0;
Arena *arena = context_get_arena(app);
Temp_Memory_Arena temp = begin_temp_memory(arena);
for (i32 i = 0; i < count; i += 1, range += 1){
i32 mirror_first = range->mirror_first + total_shift;
b32 did_insert = false;
{
Temp_Memory_Arena buffer_temp = begin_temp_memory(arena);
char *buffer = push_array(arena, char, range->length);
if (buffer_read_range(app, range->source_buffer_id, range->source_first, range->source_first + range->length, buffer)){
String string = make_string(buffer, range->length);
if (buffer_replace_range(app, mirror, mirror_first, mirror_first, string)){
did_insert = true;
}
}
end_temp_memory(buffer_temp);
}
i32 new_range_index = 0;
if (range->length > 0){
if (!mirror_add_range__inner_check_optimization(app, mirror_object, range->source_buffer_id,
mirror_first, range->source_first, range->length,
safe_to_ignore_index, false, &new_range_index)){
r = false;
}
else{
safe_to_ignore_index = new_range_index + 1;
}
}
total_shift += range->length;
}
end_temp_memory(temp);
result = r;
}
}
}
}
return(result);
}
////////////////////////////////
static b32
mirror_edit_handler(Application_Links *app, Buffer_ID buffer_id, i32 first, i32 one_past_last, String text){
mirror__global_init(app);
b32 result = false;
Buffer_Summary mirror_buffer = {};
if (get_buffer_summary(app, buffer_id, AccessAll, &mirror_buffer)){
Managed_Object mirror = mirror__buffer_to_object(app, buffer_id);
if (mirror != 0){
Mirror_Mode mode = 0;
if (mirror_get_mode__inner(app, mirror, &mode)){
Mirror mirror_data = {};
if (managed_object_load_data(app, mirror, 0, 1, &mirror_data)){
Arena *arena = context_get_arena(app);
Temp_Memory_Arena temp = begin_temp_memory(arena);
Mirror_Hot mirror_hot = mirror__hot_from_data(app, arena, mirror_data);
switch (mode){
case MirrorMode_Constructing:
{
b32 unreflected_range = false;
if (mirror_hot.count == 0){
unreflected_range = true;
}
else{
i32 fake_index = mirror_hot.count*2;
i32 fake_pos = mirror_buffer.size + 1;
Mirror__Binary_Search_Result above_point = mirror__binary_search_min_point_above(mirror_hot.mirror_ranges, first,
0, mirror_hot.count,
fake_index, fake_pos);
Mirror__Binary_Search_Result below_point = mirror__binary_search_max_point_below(mirror_hot.mirror_ranges, one_past_last,
0, mirror_hot.count);
i32 ignore = 0;
if (mirror__min_max_point_indices_not_intersecting(above_point.index, below_point.index, &ignore)){
unreflected_range = true;
}
}
if (unreflected_range){
result = buffer_replace_range(app, buffer_id, first, one_past_last, text);
}
}break;
case MirrorMode_Reflecting:
{
b32 newlines_are_jumps = ((mirror_data.flags & MirrorFlag_NewlinesAreJumps) != 0);
b32 blocked = false;
if (newlines_are_jumps){
if (has_substr(text, make_lit_string("\n"))){
blocked = true;
}
if (match(text, "\n")){
User_Input in = get_command_input(app);
if (in.key.modifiers[MDFR_SHIFT_INDEX]){
goto_jump_at_cursor_same_panel_sticky(app);
}
else{
goto_jump_at_cursor_sticky(app);
}
lock_jump_buffer(app, buffer_id);
}
}
if (!blocked){
b32 reflected_range = false;
i32 range_index = 0;
if (mirror_hot.count > 0){
i32 fake_index = mirror_hot.count*2;
i32 fake_pos = mirror_buffer.size + 1;
Mirror__Binary_Search_Result above_point = mirror__binary_search_min_point_above(mirror_hot.mirror_ranges, first,
0, mirror_hot.count,
fake_index, fake_pos);
Mirror__Binary_Search_Result below_point = mirror__binary_search_max_point_below(mirror_hot.mirror_ranges, one_past_last,
0, mirror_hot.count);
if (mirror__min_max_point_indices_contained(above_point.index, below_point.index, &range_index)){
reflected_range = true;
}
}
if (reflected_range){
// check that the range_index is valid and get source if it is
Managed_Object source_range_object = mirror_hot.source_ranges[range_index];
if (managed_object_get_type(app, source_range_object) == ManagedObjectType_Markers){
Buffer_ID source = mirror_hot.source_buffer_ids[range_index];
Marker *mirror_range = mirror_hot.mirror_ranges + range_index*2;
Marker source_range[2];
if (managed_object_load_data(app, source_range_object, 0, 2, source_range)){
i32 base_source_first = source_range[0].pos;
//i32 base_source_one_past_last = source_range[1].pos;
i32 base_mirror_first = mirror_range[0].pos;
//i32 base_mirror_one_past_last = mirror_range[1].pos;
i32 source_first = base_source_first + (first - base_mirror_first);
i32 source_one_past_last = source_first + (one_past_last - first);
global_history_edit_group_begin(app);
if (buffer_replace_range(app, source, source_first, source_one_past_last, text)){
result = buffer_replace_range(app, buffer_id, first, one_past_last, text);
}
global_history_edit_group_end(app);
}
}
}
}
}break;
}
end_temp_memory(temp);
}
}
}
}
return(result);
}
// BOTTOM

View File

@ -1,92 +0,0 @@
/*
4coder_mirror.h - Types for the mirror buffer system.
*/
#if !defined(FCODER_MIRROR_H)
#define FCODER_MIRROR_H
struct Mirror_Range{
Buffer_ID source_buffer_id;
i32 mirror_first;
i32 source_first;
i32 length;
};
////////////////////////////////
typedef i32 Mirror_Mode;
enum{
MirrorMode_Constructing,
MirrorMode_Reflecting,
};
typedef u32 Mirror_Flags;
enum{
MirrorFlag_NoHighlight = 0x0,
MirrorFlag_CharacterRangeHighlight = 0x1,
MirrorFlag_LineRangeHighlight = 0x2,
MirrorFlag_UnusedHighlight = 0x3,
MirrorFlag_HighlightMask = 0x3,
MirrorFlag_NewlinesAreJumps = 0x4,
};
struct Mirror{
Buffer_ID mirror_buffer_id;
Mirror_Mode mode;
Mirror_Flags flags;
Managed_Scope mirror_scope;
i32 count;
i32 max;
Managed_Object source_buffer_ids;
Managed_Object mirror_ranges;
Managed_Object source_ranges;
};
struct Mirror_Hot{
i32 count;
Buffer_ID *source_buffer_ids;
Marker *mirror_ranges;
Managed_Object *source_ranges;
};
////////////////////////////////
// The primary API for mirrors.
static b32 mirror_init(Application_Links *app, Buffer_ID buffer, Mirror_Flags flags, Managed_Object *mirror_object_out);
static b32 mirror_end(Application_Links *app, Managed_Object mirror);
static b32 mirror_add_range(Application_Links *app, Managed_Object mirror, Buffer_ID source,
i32 mirror_first, i32 source_first, i32 length);
static b32 mirror_set_mode(Application_Links *app, Managed_Object mirror, Mirror_Mode mode);
static b32 mirror_get_mode(Application_Links *app, Managed_Object mirror, Mirror_Mode *mode_out);
static b32 mirror_set_flags(Application_Links *app, Managed_Object mirror, Mirror_Flags flags);
static b32 mirror_get_flags(Application_Links *app, Managed_Object mirror, Mirror_Flags *flags_out);
////////////////////////////////
// Extra helpers for mirrors (all implemented on the primary API)
static b32 mirror_buffer_create(Application_Links *app, String buffer_name, Mirror_Flags flags, Buffer_ID *mirror_buffer_id_out);
static b32 mirror_buffer_end(Application_Links *app, Buffer_ID mirror);
static b32 mirror_buffer_add_range_exact(Application_Links *app, Buffer_ID mirror, Buffer_ID source,
i32 mirror_first, i32 source_first, i32 length);
static b32 mirror_buffer_add_range_loose(Application_Links *app, Buffer_ID mirror, Buffer_ID source,
i32 mirror_first, i32 source_first, i32 max_length);
static b32 mirror_buffer_insert_range(Application_Links *app, Buffer_ID mirror, Buffer_ID source,
i32 mirror_insert_pos, i32 source_first, i32 length);
static b32 mirror_buffer_set_mode(Application_Links *app, Buffer_ID mirror, Mirror_Mode mode);
static b32 mirror_buffer_get_mode(Application_Links *app, Buffer_ID mirror, Mirror_Mode *mode_out);
static b32 mirror_buffer_set_flags(Application_Links *app, Buffer_ID mirror, Mirror_Flags flags);
static b32 mirror_buffer_get_flags(Application_Links *app, Buffer_ID mirror, Mirror_Flags *flags_out);
static b32 mirror_buffer_refresh(Application_Links *app, Buffer_ID mirror);
static void mirror_quick_sort_mirror_ranges(Mirror_Range *ranges, i32 first, i32 one_past_last);
static b32 mirror_buffer_add_range_exact_array(Application_Links *app, Buffer_ID mirror, Mirror_Range *ranges, i32 count);
static b32 mirror_buffer_add_range_loose_array(Application_Links *app, Buffer_ID mirror, Mirror_Range *ranges, i32 count);
static b32 mirror_buffer_insert_range_array(Application_Links *app, Buffer_ID mirror, Mirror_Range *ranges, i32 count);
#endif
// TOP

View File

@ -650,13 +650,9 @@ list__parameters_buffer(Application_Links *app, Heap *heap, Partition *scratch,
Buffer_ID search_buffer_id){
Buffer_Summary search_buffer = get_buffer(app, search_buffer_id, AccessAll);
// Setup the search buffer for 'init' mode - the history will begin only AFTER the buffer is filled
// Setup the search buffer for 'init' mode
buffer_set_setting(app, &search_buffer, BufferSetting_ReadOnly, true);
buffer_set_setting(app, &search_buffer, BufferSetting_RecordsHistory, false);
{
mirror_buffer_end(app, search_buffer_id);
Managed_Object ignore = 0;
mirror_init(app, search_buffer_id, MirrorFlag_CharacterRangeHighlight|MirrorFlag_NewlinesAreJumps, &ignore);
}
// Initialize a generic search all buffers
Search_Set set = {};
@ -665,11 +661,7 @@ list__parameters_buffer(Application_Links *app, Heap *heap, Partition *scratch,
// List all locations into search buffer
Temp_Memory all_temp = begin_temp_memory(scratch);
Partition line_part = part_sub_part(scratch, (4 << 10));
int32_t mirror_range_count = 0;
int32_t mirror_range_max = (1 << 10);
Mirror_Range *mirror_ranges = push_array(scratch, Mirror_Range, mirror_range_max);
Temp_Memory temp = begin_temp_memory(scratch);
Buffer_ID prev_match_id = 0;
@ -698,25 +690,11 @@ list__parameters_buffer(Application_Links *app, Heap *heap, Partition *scratch,
Partial_Cursor line_one_past_last_cursor = {};
String full_line_str = {};
if (read_line(app, &line_part, match.buffer.buffer_id, word_pos.line, &full_line_str, &line_start_cursor, &line_one_past_last_cursor)){
int32_t source_full_line_start = line_start_cursor.pos;
String line_str = skip_chop_whitespace(full_line_str);
int32_t source_line_start = source_full_line_start + (int32_t)(line_str.str - full_line_str.str);
int32_t out_pos = search_buffer.size + buffered_print_buffer_length(scratch, temp);
if (mirror_range_count == mirror_range_max){
buffered_print_flush(app, scratch, temp, &search_buffer);
mirror_buffer_add_range_exact_array(app, search_buffer_id, mirror_ranges, mirror_range_count);
mirror_range_count = 0;
Assert(out_pos == search_buffer.size);
}
b32 flushed = false;
int32_t str_len = file_len + 1 + line_num_len + 1 + column_num_len + 1 + 1 + line_str.size + 1;
char *spare = buffered_memory_reserve(app, scratch, temp, &search_buffer, str_len, &flushed);
if (flushed){
mirror_buffer_add_range_exact_array(app, search_buffer_id, mirror_ranges, mirror_range_count);
mirror_range_count = 0;
}
search_buffer = get_buffer(app, search_buffer_id, AccessAll);
String out_line = make_string_cap(spare, 0, str_len);
@ -727,18 +705,9 @@ list__parameters_buffer(Application_Links *app, Heap *heap, Partition *scratch,
append_int_to_str(&out_line, word_pos.character);
append_s_char(&out_line, ':');
append_s_char(&out_line, ' ');
int32_t mirror_range_start = out_pos + out_line.size;
append_ss(&out_line, line_str);
append_s_char(&out_line, '\n');
Assert(out_line.size == str_len);
Assert(mirror_range_count < mirror_range_max);
Mirror_Range *mirror_range = &mirror_ranges[mirror_range_count];
mirror_range_count += 1;
mirror_range->source_buffer_id = match.buffer.buffer_id;
mirror_range->mirror_first = mirror_range_start;
mirror_range->source_first = source_line_start;
mirror_range->length = line_str.size;
}
end_temp_memory(line_temp);
@ -754,18 +723,11 @@ list__parameters_buffer(Application_Links *app, Heap *heap, Partition *scratch,
}
buffered_print_flush(app, scratch, temp, &search_buffer);
mirror_buffer_add_range_exact_array(app, search_buffer_id, mirror_ranges, mirror_range_count);
mirror_range_count = 0;
end_temp_memory(all_temp);
// Lock *search* as the jump buffer
lock_jump_buffer(search_name.str, search_name.size);
// Setup the search buffer for 'reflecting' mode
mirror_buffer_set_mode(app, search_buffer_id, MirrorMode_Reflecting);
buffer_set_setting(app, &search_buffer, BufferSetting_ReadOnly, false);
buffer_set_setting(app, &search_buffer, BufferSetting_RecordsHistory, true);
}
static void

View File

@ -808,33 +808,15 @@ DOC_SEE(4coder_Buffer_Positioning_System)
if (buffer_api_check_file(file)){
size = buffer_size(&file->state.buffer);
if (0 <= start && start <= one_past_last && one_past_last <= size){
if (edit_abstract_mode(file)){
file->state.in_edit_handler = true;
result = file->settings.edit_handler(app, buffer_id, start, one_past_last, string);
file->state.in_edit_handler = false;
}
else{
Edit_Behaviors behaviors = {};
Range range = {start, one_past_last};
edit_single(models->system, models, file, range, string, behaviors);
result = true;
}
Edit_Behaviors behaviors = {};
Range range = {start, one_past_last};
edit_single(models->system, models, file, range, string, behaviors);
result = true;
}
}
return(result);
}
API_EXPORT b32
Buffer_Set_Edit_Handler(Application_Links *app, Buffer_ID buffer_id, Buffer_Edit_Handler *handler){
Models *models = (Models*)app->cmd_context;
Editing_File *file = imp_get_file(models, buffer_id);
b32 result = buffer_api_check_file(file);
if (result){
file->settings.edit_handler = handler;
}
return(result);
}
// TODO(allen): redocument
API_EXPORT b32
Buffer_Compute_Cursor(Application_Links *app, Buffer_ID buffer_id, Buffer_Seek seek, Partial_Cursor *cursor_out)
@ -887,44 +869,21 @@ DOC_SEE(Buffer_Batch_Edit_Type)
result = true;
if (edit_count > 0){
global_history_edit_group_begin(app);
if (edit_abstract_mode(file)){
Lifetime_Object *lifetime_object = file->lifetime_object;
Dynamic_Workspace *workspace = &lifetime_object->workspace;
Marker *markers = 0;
Managed_Object markers_object = managed_object_alloc_buffer_markers(&models->mem.heap, workspace, buffer_id, edit_count*2, &markers);
for (i32 i = 0; i < edit_count; i += 1){
markers[2*i].pos = edits[i].start;
markers[2*i].lean_right = false;
markers[2*i + 1].pos = edits[i].end;
markers[2*i + 1].lean_right = false;
Buffer_Edit *edit_in = edits;
Buffer_Edit *one_past_last = edits + edit_count;
i32 shift = 0;
for (;edit_in < one_past_last; edit_in += 1){
char *edit_str = str + edit_in->str_start;
i32 edit_length = edit_in->len;
Range edit_range = {edit_in->start, edit_in->end};
i32 shift_change = edit_length - (edit_range.one_past_last - edit_range.first);
edit_range.first += shift;
edit_range.one_past_last += shift;
if (!buffer_replace_range(app, buffer_id, edit_range.first, edit_range.one_past_last, make_string(edit_str, edit_length))){
result = false;
}
for (i32 i = 0; i < edit_count; i += 1){
char *edit_str = str + edits[i].str_start;
i32 edit_length = edits[i].len;
Range edit_range = {markers[2*i].pos, markers[2*i + 1].pos};
if (!buffer_replace_range(app, buffer_id, edit_range.first, edit_range.one_past_last, make_string(edit_str, edit_length))){
result = false;
}
}
managed_object_free(app, markers_object);
}
else{
Buffer_Edit *edit_in = edits;
Buffer_Edit *one_past_last = edits + edit_count;
i32 shift = 0;
for (;edit_in < one_past_last; edit_in += 1){
char *edit_str = str + edit_in->str_start;
i32 edit_length = edit_in->len;
Range edit_range = {edit_in->start, edit_in->end};
i32 shift_change = edit_length - (edit_range.one_past_last - edit_range.first);
edit_range.first += shift;
edit_range.one_past_last += shift;
if (!buffer_replace_range(app, buffer_id, edit_range.first, edit_range.one_past_last, make_string(edit_str, edit_length))){
result = false;
}
else{
shift += shift_change;
}
else{
shift += shift_change;
}
}
global_history_edit_group_end(app);
@ -1730,12 +1689,12 @@ DOC_SEE(Buffer_Identifier)
}
API_EXPORT b32
Buffer_Reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags, Buffer_Reopen_Result *result)
Buffer_Reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags, Buffer_Reopen_Result *result_out)
{
Models *models = (Models*)app->cmd_context;
System_Functions *system = models->system;
Editing_File *file = imp_get_file(models, buffer_id);
*result = BufferReopenResult_Failed;
Buffer_Reopen_Result result = BufferReopenResult_Failed;
if (buffer_api_check_file(file)){
if (file->canon.name.str != 0 && file->canon.name.size != 0){
Plat_Handle handle = {};
@ -1786,8 +1745,7 @@ Buffer_Reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag fl
view_set_cursor(system, models, vptrs[i], cursor, true);
}
*result = BufferReopenResult_Reopened;
result = BufferReopenResult_Reopened;
}
else{
system->load_close(handle);
@ -1801,8 +1759,10 @@ Buffer_Reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag fl
}
}
}
return(*result == BufferReopenResult_Reopened);
if (result_out != 0){
*result_out = result;
}
return(result == BufferReopenResult_Reopened);
}
API_EXPORT b32

View File

@ -229,11 +229,6 @@ edit_fix_markers(System_Functions *system, Models *models, Editing_File *file, E
end_temp_memory(cursor_temp);
}
internal b32
edit_abstract_mode(Editing_File *file){
return(file->settings.edit_handler != 0 && !file->state.in_edit_handler);
}
internal void
edit_single(System_Functions *system, Models *models, Editing_File *file, Edit edit, Edit_Behaviors behaviors){
Mem_Options *mem = &models->mem;

View File

@ -39,7 +39,6 @@ union Buffer_Slot_ID{
};
struct Editing_File_Settings{
Buffer_Edit_Handler *edit_handler;
i32 base_map_id;
i32 display_width;
i32 minimum_base_display_width;