Edit handler hook, edit reflection for search buffer, history setting for buffer
This commit is contained in:
parent
90163a2f85
commit
4a5388f901
|
@ -127,6 +127,9 @@ ENUM(int32_t, Buffer_Setting_ID){
|
|||
|
||||
/* DOC(The BufferSetting_VirtualWhitespace setting enables virtual whitespace on a buffer. Text buffers with virtual whitespace will set the indentation of every line to zero. Buffers with lexing enabled will use virtual white space to present the code with appealing indentation.) */
|
||||
BufferSetting_VirtualWhitespace,
|
||||
|
||||
/* DOC(TODO) */
|
||||
BufferSetting_RecordsHistory,
|
||||
};
|
||||
|
||||
/* DOC(A View_Setting_ID names an adjustable setting in a view.) */
|
||||
|
@ -556,6 +559,9 @@ STRUCT Partial_Cursor{
|
|||
int32_t character;
|
||||
};
|
||||
|
||||
TYPEDEF_FUNC bool32 Buffer_Edit_Handler(struct Application_Links *app, Buffer_ID buffer_id, int32_t start, int32_t one_past_last, String str);
|
||||
// TODO(allen): what to do with batches???
|
||||
|
||||
/* DOC(Buffer_Summary acts as a handle to a buffer and describes the state of the buffer.)
|
||||
DOC_SEE(Access_Flag)
|
||||
DOC_SEE(Dirty_State) */
|
||||
|
@ -569,6 +575,9 @@ STRUCT Buffer_Summary{
|
|||
/* DOC(If this is not a null summary, this field contains flags describing the protection status of the buffer.) */
|
||||
Access_Flag lock_flags;
|
||||
|
||||
/* DOC(TODO) */
|
||||
Buffer_Edit_Handler *edit_handler;
|
||||
|
||||
/* DOC(If this is not a null summary, this field specifies the number of bytes in the buffer.) */
|
||||
int32_t size;
|
||||
/* DOC(If this is not a null summary, this field specifies the number of lines in the buffer.) */
|
||||
|
|
|
@ -184,12 +184,14 @@ CUSTOM_DOC("Create a new panel by horizontally splitting the active panel.")
|
|||
// NOTE(allen): Credits to nj/FlyingSolomon for authoring the original version of this helper.
|
||||
|
||||
static Buffer_ID
|
||||
create_or_switch_to_buffer_by_name(Application_Links *app, char *name, int32_t name_length,
|
||||
View_Summary default_target_view){
|
||||
create_or_switch_to_buffer_by_name(Application_Links *app, char *name, int32_t name_length, View_Summary default_target_view){
|
||||
uint32_t access = AccessAll;
|
||||
Buffer_Summary search_buffer = get_buffer_by_name(app, name, name_length, access);
|
||||
|
||||
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_Summary view_with_buffer_already_open = get_first_view_with_buffer(app, search_buffer.buffer_id);
|
||||
|
|
|
@ -13,7 +13,8 @@ struct Application_Links;
|
|||
#define GET_BUFFER_BY_NAME_SIG(n) Buffer_Summary n(Application_Links *app, char *name, int32_t len, Access_Flag access)
|
||||
#define GET_BUFFER_BY_FILE_NAME_SIG(n) Buffer_Summary n(Application_Links *app, char *name, int32_t len, Access_Flag access)
|
||||
#define BUFFER_READ_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out)
|
||||
#define BUFFER_REPLACE_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len)
|
||||
#define BUFFER_REPLACE_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t one_past_last, char *str, int32_t len)
|
||||
#define BUFFER_SET_EDIT_HANDLER_SIG(n) bool32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Edit_Handler *handler)
|
||||
#define BUFFER_COMPUTE_CURSOR_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out)
|
||||
#define BUFFER_BATCH_EDIT_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, char *str, int32_t str_len, Buffer_Edit *edits, int32_t edit_count, Buffer_Batch_Edit_Type type)
|
||||
#define BUFFER_GET_SETTING_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out)
|
||||
|
@ -150,6 +151,7 @@ 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_GET_SETTING_SIG(Buffer_Get_Setting_Function);
|
||||
|
@ -288,6 +290,7 @@ 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_Get_Setting_Function *buffer_get_setting;
|
||||
|
@ -425,6 +428,7 @@ 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_Get_Setting_Function *buffer_get_setting_;
|
||||
|
@ -570,6 +574,7 @@ 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_get_setting_ = Buffer_Get_Setting;\
|
||||
|
@ -706,7 +711,8 @@ static Buffer_Summary get_buffer(Application_Links *app, Buffer_ID buffer_id, Ac
|
|||
static Buffer_Summary get_buffer_by_name(Application_Links *app, char *name, int32_t len, Access_Flag access){return(app->get_buffer_by_name(app, name, len, access));}
|
||||
static Buffer_Summary get_buffer_by_file_name(Application_Links *app, char *name, int32_t len, Access_Flag access){return(app->get_buffer_by_file_name(app, name, len, access));}
|
||||
static bool32 buffer_read_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out){return(app->buffer_read_range(app, buffer, start, end, out));}
|
||||
static bool32 buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len){return(app->buffer_replace_range(app, buffer, start, end, str, len));}
|
||||
static bool32 buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t one_past_last, char *str, int32_t len){return(app->buffer_replace_range(app, buffer, start, one_past_last, str, len));}
|
||||
static bool32 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 bool32 buffer_compute_cursor(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out){return(app->buffer_compute_cursor(app, buffer, seek, cursor_out));}
|
||||
static bool32 buffer_batch_edit(Application_Links *app, Buffer_Summary *buffer, char *str, int32_t str_len, Buffer_Edit *edits, int32_t edit_count, Buffer_Batch_Edit_Type type){return(app->buffer_batch_edit(app, buffer, str, str_len, edits, edit_count, type));}
|
||||
static bool32 buffer_get_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out){return(app->buffer_get_setting(app, buffer, setting, value_out));}
|
||||
|
@ -843,7 +849,8 @@ static Buffer_Summary get_buffer(Application_Links *app, Buffer_ID buffer_id, Ac
|
|||
static Buffer_Summary get_buffer_by_name(Application_Links *app, char *name, int32_t len, Access_Flag access){return(app->get_buffer_by_name_(app, name, len, access));}
|
||||
static Buffer_Summary get_buffer_by_file_name(Application_Links *app, char *name, int32_t len, Access_Flag access){return(app->get_buffer_by_file_name_(app, name, len, access));}
|
||||
static bool32 buffer_read_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out){return(app->buffer_read_range_(app, buffer, start, end, out));}
|
||||
static bool32 buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len){return(app->buffer_replace_range_(app, buffer, start, end, str, len));}
|
||||
static bool32 buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t one_past_last, char *str, int32_t len){return(app->buffer_replace_range_(app, buffer, start, one_past_last, str, len));}
|
||||
static bool32 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 bool32 buffer_compute_cursor(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out){return(app->buffer_compute_cursor_(app, buffer, seek, cursor_out));}
|
||||
static bool32 buffer_batch_edit(Application_Links *app, Buffer_Summary *buffer, char *str, int32_t str_len, Buffer_Edit *edits, int32_t edit_count, Buffer_Batch_Edit_Type type){return(app->buffer_batch_edit_(app, buffer, str, str_len, edits, edit_count, type));}
|
||||
static bool32 buffer_get_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out){return(app->buffer_get_setting_(app, buffer, setting, value_out));}
|
||||
|
|
|
@ -241,7 +241,7 @@ int32_t source_name_len;
|
|||
int32_t line_number;
|
||||
};
|
||||
static Command_Metadata fcoder_metacmd_table[220] = {
|
||||
{ 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, 240 },
|
||||
{ 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, 242 },
|
||||
{ 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, 721 },
|
||||
{ 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, 732 },
|
||||
{ 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, 711 },
|
||||
|
@ -285,21 +285,21 @@ static Command_Metadata fcoder_metacmd_table[220] = {
|
|||
{ PROC_LINKS(goto_beginning_of_file, 0), "goto_beginning_of_file", 22, "Sets the cursor to the beginning of the file.", 45, "w:\\4ed\\code\\4coder_seek.cpp", 27, 1177 },
|
||||
{ PROC_LINKS(goto_end_of_file, 0), "goto_end_of_file", 16, "Sets the cursor to the end of the file.", 39, "w:\\4ed\\code\\4coder_seek.cpp", 27, 1185 },
|
||||
{ PROC_LINKS(goto_first_jump_direct, 0), "goto_first_jump_direct", 22, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer.", 95, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 84 },
|
||||
{ PROC_LINKS(goto_first_jump_same_panel_sticky, 0), "goto_first_jump_same_panel_sticky", 33, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer and views the buffer in the panel where the jump list was.", 153, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 550 },
|
||||
{ PROC_LINKS(goto_first_jump_sticky, 0), "goto_first_jump_sticky", 22, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer.", 95, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 532 },
|
||||
{ PROC_LINKS(goto_first_jump_same_panel_sticky, 0), "goto_first_jump_same_panel_sticky", 33, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer and views the buffer in the panel where the jump list was.", 153, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 551 },
|
||||
{ PROC_LINKS(goto_first_jump_sticky, 0), "goto_first_jump_sticky", 22, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer.", 95, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 533 },
|
||||
{ PROC_LINKS(goto_jump_at_cursor_direct, 0), "goto_jump_at_cursor_direct", 26, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in another view and changes the active panel to the view containing the jump.", 187, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 8 },
|
||||
{ PROC_LINKS(goto_jump_at_cursor_same_panel_direct, 0), "goto_jump_at_cursor_same_panel_direct", 37, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in this view, losing the compilation output or jump list..", 168, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 29 },
|
||||
{ PROC_LINKS(goto_jump_at_cursor_same_panel_sticky, 0), "goto_jump_at_cursor_same_panel_sticky", 37, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in this view, losing the compilation output or jump list.", 167, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 376 },
|
||||
{ PROC_LINKS(goto_jump_at_cursor_sticky, 0), "goto_jump_at_cursor_sticky", 26, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in another view and changes the active panel to the view containing the jump.", 187, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 348 },
|
||||
{ PROC_LINKS(goto_jump_at_cursor_same_panel_sticky, 0), "goto_jump_at_cursor_same_panel_sticky", 37, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in this view, losing the compilation output or jump list.", 167, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 377 },
|
||||
{ PROC_LINKS(goto_jump_at_cursor_sticky, 0), "goto_jump_at_cursor_sticky", 26, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in another view and changes the active panel to the view containing the jump.", 187, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 349 },
|
||||
{ PROC_LINKS(goto_line, 0), "goto_line", 9, "Queries the user for a number, and jumps the cursor to the corresponding line.", 78, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 673 },
|
||||
{ PROC_LINKS(goto_next_jump_direct, 0), "goto_next_jump_direct", 21, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, skipping sub jump locations.", 123, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 48 },
|
||||
{ PROC_LINKS(goto_next_jump_no_skips_direct, 0), "goto_next_jump_no_skips_direct", 30, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, and does not skip sub jump locations.", 132, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 66 },
|
||||
{ PROC_LINKS(goto_next_jump_no_skips_sticky, 0), "goto_next_jump_no_skips_sticky", 30, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, and does not skip sub jump locations.", 132, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 501 },
|
||||
{ PROC_LINKS(goto_next_jump_sticky, 0), "goto_next_jump_sticky", 21, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, skipping sub jump locations.", 123, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 471 },
|
||||
{ PROC_LINKS(goto_next_jump_no_skips_sticky, 0), "goto_next_jump_no_skips_sticky", 30, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, and does not skip sub jump locations.", 132, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 502 },
|
||||
{ PROC_LINKS(goto_next_jump_sticky, 0), "goto_next_jump_sticky", 21, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, skipping sub jump locations.", 123, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 472 },
|
||||
{ PROC_LINKS(goto_prev_jump_direct, 0), "goto_prev_jump_direct", 21, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, skipping sub jump locations.", 127, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 57 },
|
||||
{ PROC_LINKS(goto_prev_jump_no_skips_direct, 0), "goto_prev_jump_no_skips_direct", 30, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 75 },
|
||||
{ PROC_LINKS(goto_prev_jump_no_skips_sticky, 0), "goto_prev_jump_no_skips_sticky", 30, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 517 },
|
||||
{ PROC_LINKS(goto_prev_jump_sticky, 0), "goto_prev_jump_sticky", 21, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, skipping sub jump locations.", 127, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 487 },
|
||||
{ PROC_LINKS(goto_prev_jump_no_skips_sticky, 0), "goto_prev_jump_no_skips_sticky", 30, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 518 },
|
||||
{ PROC_LINKS(goto_prev_jump_sticky, 0), "goto_prev_jump_sticky", 21, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, skipping sub jump locations.", 127, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 488 },
|
||||
{ PROC_LINKS(hide_filebar, 0), "hide_filebar", 12, "Sets the current view to hide it's filebar.", 43, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 542 },
|
||||
{ PROC_LINKS(hide_scrollbar, 0), "hide_scrollbar", 14, "Sets the current view to hide it's scrollbar.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 528 },
|
||||
{ PROC_LINKS(if0_off, 0), "if0_off", 7, "Surround the range between the cursor and mark with an '#if 0' and an '#endif'", 78, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 79 },
|
||||
|
@ -316,16 +316,16 @@ static Command_Metadata fcoder_metacmd_table[220] = {
|
|||
{ 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, 769 },
|
||||
{ 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, 783 },
|
||||
{ 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, 797 },
|
||||
{ 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, 804 },
|
||||
{ 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, 811 },
|
||||
{ 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, 818 },
|
||||
{ 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, 825 },
|
||||
{ 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, 836 },
|
||||
{ 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, 776 },
|
||||
{ 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, 790 },
|
||||
{ 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, 776 },
|
||||
{ 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, 790 },
|
||||
{ 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, 804 },
|
||||
{ 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, 811 },
|
||||
{ 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, 818 },
|
||||
{ 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, 825 },
|
||||
{ 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, 832 },
|
||||
{ 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, 843 },
|
||||
{ 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, 783 },
|
||||
{ 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, 797 },
|
||||
{ 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, 146 },
|
||||
|
@ -359,7 +359,7 @@ static Command_Metadata fcoder_metacmd_table[220] = {
|
|||
{ PROC_LINKS(newline_or_goto_position_direct, 0), "newline_or_goto_position_direct", 31, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 101 },
|
||||
{ PROC_LINKS(newline_or_goto_position_same_panel_direct, 0), "newline_or_goto_position_same_panel_direct", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 116 },
|
||||
{ PROC_LINKS(newline_or_goto_position_same_panel_sticky, 0), "newline_or_goto_position_same_panel_sticky", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 588 },
|
||||
{ PROC_LINKS(newline_or_goto_position_sticky, 0), "newline_or_goto_position_sticky", 31, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 573 },
|
||||
{ PROC_LINKS(newline_or_goto_position_sticky, 0), "newline_or_goto_position_sticky", 31, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 574 },
|
||||
{ PROC_LINKS(open_all_code, 0), "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 1067 },
|
||||
{ PROC_LINKS(open_all_code_recursive, 0), "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 1074 },
|
||||
{ PROC_LINKS(open_color_tweaker, 0), "open_color_tweaker", 18, "Opens the 4coder theme selector list.", 37, "w:\\4ed\\code\\4coder_lists.cpp", 28, 938 },
|
||||
|
@ -386,7 +386,7 @@ static Command_Metadata fcoder_metacmd_table[220] = {
|
|||
{ 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, 1089 },
|
||||
{ PROC_LINKS(redo, 0), "redo", 4, "Advances forwards through the undo history.", 43, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1622 },
|
||||
{ PROC_LINKS(reload_themes, 0), "reload_themes", 13, "Loads all the theme files in the theme folder, replacing duplicates with the new theme data.", 92, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1637 },
|
||||
{ PROC_LINKS(remap_interactive, 0), "remap_interactive", 17, "Switch to a named key binding map.", 34, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 290 },
|
||||
{ PROC_LINKS(remap_interactive, 0), "remap_interactive", 17, "Switch to a named key binding map.", 34, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 292 },
|
||||
{ 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, 1229 },
|
||||
{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1600 },
|
||||
{ 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, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 928 },
|
||||
|
@ -424,8 +424,8 @@ static Command_Metadata fcoder_metacmd_table[220] = {
|
|||
{ 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, 116 },
|
||||
{ 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, 258 },
|
||||
{ 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, 252 },
|
||||
{ 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, 260 },
|
||||
{ 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, 254 },
|
||||
{ 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 },
|
||||
|
@ -435,24 +435,24 @@ static Command_Metadata fcoder_metacmd_table[220] = {
|
|||
{ 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, 1270 },
|
||||
{ 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, 1276 },
|
||||
{ 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, 234 },
|
||||
{ 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, 236 },
|
||||
{ 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, 1552 },
|
||||
{ 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, 419 },
|
||||
{ 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, 399 },
|
||||
{ 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, 549 },
|
||||
{ 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, 282 },
|
||||
{ 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, 270 },
|
||||
{ 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, 264 },
|
||||
{ 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, 284 },
|
||||
{ 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, 272 },
|
||||
{ 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, 266 },
|
||||
{ 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, 558 },
|
||||
{ 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, 246 },
|
||||
{ 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, 276 },
|
||||
{ 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, 248 },
|
||||
{ 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, 278 },
|
||||
{ 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, 642 },
|
||||
{ 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, 631 },
|
||||
{ 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 },
|
||||
{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history.", 44, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1610 },
|
||||
{ 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, 1542 },
|
||||
{ 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, 108 },
|
||||
{ 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, 856 },
|
||||
{ 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, 863 },
|
||||
{ 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, 744 },
|
||||
{ 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, 63 },
|
||||
|
|
|
@ -697,7 +697,8 @@ get_view_range(View_Summary *view){
|
|||
}
|
||||
|
||||
static bool32
|
||||
read_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32_t line, String *str){
|
||||
read_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32_t line, String *str,
|
||||
Partial_Cursor *start_out, Partial_Cursor *one_past_last_out){
|
||||
Partial_Cursor begin = {};
|
||||
Partial_Cursor end = {};
|
||||
|
||||
|
@ -711,10 +712,13 @@ read_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32
|
|||
char *memory = push_array(part, char, alloc_size);
|
||||
if (memory != 0){
|
||||
*str = make_string(memory, 0, alloc_size);
|
||||
success = true;
|
||||
buffer_read_range(app, buffer, begin.pos, end.pos, str->str);
|
||||
str->size = size;
|
||||
terminate_with_null(str);
|
||||
|
||||
*start_out = begin;
|
||||
*one_past_last_out = end;
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -724,6 +728,12 @@ read_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32
|
|||
return(success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
read_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32_t line, String *str){
|
||||
Partial_Cursor ignore = {};
|
||||
return(read_line(app, part, buffer, line, str, &ignore, &ignore));
|
||||
}
|
||||
|
||||
static int32_t
|
||||
buffer_get_line_start(Application_Links *app, Buffer_Summary *buffer, int32_t line){
|
||||
int32_t result = buffer->size;
|
||||
|
|
|
@ -268,6 +268,7 @@ get_all_stored_jumps_from_list(Application_Links *app, Partition *arena, Marker_
|
|||
|
||||
static bool32
|
||||
get_jump_from_list(Application_Links *app, Marker_List *list, int32_t index, ID_Pos_Jump_Location *location){
|
||||
bool32 result = false;
|
||||
Sticky_Jump_Stored stored = {};
|
||||
if (get_stored_jump_from_list(app, list, index, &stored)){
|
||||
Buffer_ID target_buffer_id = stored.jump_buffer_id;
|
||||
|
@ -284,10 +285,10 @@ get_jump_from_list(Application_Links *app, Marker_List *list, int32_t index, ID_
|
|||
managed_object_load_data(app, marker_array, stored.index_into_marker_array, 1, &marker);
|
||||
location->buffer_id = target_buffer_id;
|
||||
location->pos = marker.pos;
|
||||
return(true);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return(false);
|
||||
return(result);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
|
@ -575,7 +576,6 @@ CUSTOM_DOC("If the buffer in the active view is writable, inserts a character, o
|
|||
{
|
||||
View_Summary view = get_active_view(app, AccessProtected);
|
||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected);
|
||||
|
||||
if (buffer.lock_flags & AccessProtected){
|
||||
goto_jump_at_cursor_sticky(app);
|
||||
lock_jump_buffer(buffer);
|
||||
|
@ -590,7 +590,6 @@ CUSTOM_DOC("If the buffer in the active view is writable, inserts a character, o
|
|||
{
|
||||
View_Summary view = get_active_view(app, AccessProtected);
|
||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected);
|
||||
|
||||
if (buffer.lock_flags & AccessProtected){
|
||||
goto_jump_at_cursor_same_panel_sticky(app);
|
||||
lock_jump_buffer(buffer);
|
||||
|
@ -614,5 +613,130 @@ OPEN_FILE_HOOK_SIG(end_file_close_jump_list){
|
|||
return(0);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
static bool32
|
||||
search_buffer_edit_handler__inner(Application_Links *app, Partition *part, Buffer_ID buffer_id, int32_t start, int32_t one_past_last, String text){
|
||||
Buffer_Summary buffer = get_buffer(app, buffer_id, AccessProtected);
|
||||
|
||||
// NOTE(allen): get the list for this buffer
|
||||
Marker_List *list = get_or_make_list_for_buffer(app, part, &global_heap, buffer_id);
|
||||
if (list == 0){
|
||||
return(false);
|
||||
}
|
||||
|
||||
// NOTE(allen): activate jumps
|
||||
if (match(text, "\n")){
|
||||
// TODO(allen): do(determine when shift is held here and do *same_panel* version of goto_jump_at_cursor_sticky)
|
||||
goto_jump_at_cursor_sticky(app);
|
||||
lock_jump_buffer(buffer);
|
||||
return(false);
|
||||
}
|
||||
|
||||
// NOTE(allen): do not allow new lines to be inserted ever
|
||||
if (find_s_char(text, 0, '\n') != text.size){
|
||||
return(false);
|
||||
}
|
||||
|
||||
// NOTE(allen): check that the range is entirely inside an editable range
|
||||
Partial_Cursor start_cursor = {};
|
||||
Partial_Cursor one_past_last_cursor = {};
|
||||
if (!(buffer_compute_cursor(app, &buffer, seek_pos(start), &start_cursor) &&
|
||||
buffer_compute_cursor(app, &buffer, seek_pos(one_past_last), &one_past_last_cursor))){
|
||||
return(false);
|
||||
}
|
||||
if (start_cursor.line != one_past_last_cursor.line){
|
||||
return(false);
|
||||
}
|
||||
|
||||
int32_t line_number = start_cursor.line;
|
||||
Partial_Cursor line_start_cursor = {};
|
||||
Partial_Cursor line_one_past_last_cursor = {};
|
||||
String line = {};
|
||||
if (!read_line(app, part, &buffer, line_number, &line, &line_start_cursor, &line_one_past_last_cursor)){
|
||||
return(false);
|
||||
}
|
||||
|
||||
int32_t line_start = line_start_cursor.pos;
|
||||
int32_t line_one_past_last = line_one_past_last_cursor.pos;
|
||||
|
||||
int32_t colon_index = find_substr(line, 0, make_lit_string(": "));
|
||||
if (colon_index == line.size){
|
||||
return(false);
|
||||
}
|
||||
|
||||
int32_t editable_start = line_start + colon_index + 2;
|
||||
int32_t editable_one_past_last = line_one_past_last;
|
||||
if (!(editable_start <= start && one_past_last <= editable_one_past_last)){
|
||||
return(false);
|
||||
}
|
||||
|
||||
// NOTE(allen): figure out the target buffer make sure we want to edit it
|
||||
int32_t list_index = get_index_exact_from_list(app, part, list, line_number);
|
||||
if (list_index < 0){
|
||||
return(false);
|
||||
}
|
||||
|
||||
ID_Pos_Jump_Location location = {};
|
||||
if (!get_jump_from_list(app, list, list_index, &location)){
|
||||
return(false);
|
||||
}
|
||||
|
||||
Buffer_Summary target_buffer = {};
|
||||
if (!get_jump_buffer(app, &target_buffer, &location, AccessOpen)){
|
||||
return(false);
|
||||
}
|
||||
|
||||
int32_t is_unimportant = false;
|
||||
if (!buffer_get_setting(app, &target_buffer, BufferSetting_Unimportant, &is_unimportant)){
|
||||
return(false);
|
||||
}
|
||||
|
||||
if (is_unimportant){
|
||||
return(false);
|
||||
}
|
||||
|
||||
// NOTE(allen): figure out the shift of the edit from the search buffer to the target buffer
|
||||
Partial_Cursor target_pos = {};
|
||||
if (!buffer_compute_cursor(app, &target_buffer, seek_pos(location.pos), &target_pos)){
|
||||
return(false);
|
||||
}
|
||||
|
||||
int32_t target_line_number = target_pos.line;
|
||||
Partial_Cursor target_line_start_cursor = {};
|
||||
Partial_Cursor target_line_one_past_last_cursor = {};
|
||||
String target_line = {};
|
||||
if (!read_line(app, part, &target_buffer, target_line_number, &target_line, &target_line_start_cursor, &target_line_one_past_last_cursor)){
|
||||
return(false);
|
||||
}
|
||||
|
||||
int32_t target_line_start = target_line_start_cursor.pos;
|
||||
//int32_t target_line_one_past_last = target_line_one_past_last_cursor.pos;
|
||||
|
||||
String target_line_skip_whitespace = skip_whitespace(target_line);
|
||||
int32_t skip_into_line_amount = (int32_t)(target_line_skip_whitespace.str - target_line.str);
|
||||
|
||||
int32_t target_editable_start = target_line_start + skip_into_line_amount;
|
||||
int32_t edit_range_shift = target_editable_start - editable_start;
|
||||
|
||||
// NOTE(allen): try to apply the edits
|
||||
if (buffer_replace_range(app, &target_buffer, start + edit_range_shift, one_past_last + edit_range_shift, text.str, text.size)){
|
||||
if (buffer_replace_range(app, &buffer, start, one_past_last, text.str, text.size)){
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
static bool32
|
||||
search_buffer_edit_handler(Application_Links *app, Buffer_ID buffer_id, int32_t start, int32_t one_past_last, String text){
|
||||
Partition *scratch = &global_part;
|
||||
Temp_Memory temp = begin_temp_memory(scratch);
|
||||
bool32 result = search_buffer_edit_handler__inner(app, scratch, buffer_id, start, one_past_last, text);
|
||||
end_temp_memory(temp);
|
||||
return(result);
|
||||
}
|
||||
|
||||
// BOTTOM
|
||||
|
||||
|
|
|
@ -221,18 +221,18 @@ parse_jump_from_buffer_line(Application_Links *app, Partition *arena,
|
|||
|
||||
static bool32
|
||||
get_jump_buffer(Application_Links *app, Buffer_Summary *buffer, Name_Line_Column_Location *location){
|
||||
bool32 result = open_file(app, buffer, location->file.str, location->file.size, false, true);
|
||||
return(result);
|
||||
return(open_file(app, buffer, location->file.str, location->file.size, false, true));
|
||||
}
|
||||
|
||||
static bool32
|
||||
get_jump_buffer(Application_Links *app, Buffer_Summary *buffer, ID_Pos_Jump_Location *location, Access_Flag access){
|
||||
*buffer = get_buffer(app, location->buffer_id, access);
|
||||
return((bool32)buffer->exists);
|
||||
}
|
||||
|
||||
static bool32
|
||||
get_jump_buffer(Application_Links *app, Buffer_Summary *buffer, ID_Pos_Jump_Location *location){
|
||||
*buffer = get_buffer(app, location->buffer_id, AccessAll);
|
||||
bool32 result = false;
|
||||
if (buffer->exists){
|
||||
result = true;
|
||||
}
|
||||
return(result);
|
||||
return(get_jump_buffer(app, buffer, location, AccessAll));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -590,7 +590,8 @@ buffered_memory_reserve(Application_Links *app, Partition *part, Temp_Memory tem
|
|||
}
|
||||
|
||||
static void
|
||||
buffered_print_match_jump_line(Application_Links *app, Partition *part, Temp_Memory temp, Partition *line_part, Buffer_Summary *output_buffer, Buffer_Summary *match_buffer, Partial_Cursor word_pos){
|
||||
buffered_print_match_jump_line(Application_Links *app, Partition *part, Temp_Memory temp, Partition *line_part, Buffer_Summary *output_buffer,
|
||||
Buffer_Summary *match_buffer, Partial_Cursor word_pos){
|
||||
char *file_name = match_buffer->buffer_name;
|
||||
int32_t file_len = match_buffer->buffer_name_len;
|
||||
|
||||
|
@ -622,14 +623,16 @@ buffered_print_match_jump_line(Application_Links *app, Partition *part, Temp_Mem
|
|||
end_temp_memory(line_temp);
|
||||
}
|
||||
|
||||
static bool32
|
||||
search_buffer_edit_handler(Application_Links *app, Buffer_ID buffer_id, int32_t start, int32_t one_past_last, String text);
|
||||
|
||||
static void
|
||||
list__parameters(Application_Links *app, Heap *heap, Partition *scratch,
|
||||
String *strings, int32_t count, Search_Range_Flag match_flags,
|
||||
View_Summary default_target_view){
|
||||
// Open the search buffer
|
||||
String search_name = make_lit_string("*search*");
|
||||
Buffer_ID search_buffer_id = create_or_switch_to_buffer_by_name(app, search_name.str, search_name.size,
|
||||
default_target_view);
|
||||
Buffer_ID search_buffer_id = create_or_switch_to_buffer_by_name(app, search_name.str, search_name.size, default_target_view);
|
||||
Buffer_Summary search_buffer = get_buffer(app, search_buffer_id, AccessAll);
|
||||
|
||||
// Initialize a generic search all buffers
|
||||
|
@ -672,6 +675,10 @@ list__parameters(Application_Links *app, Heap *heap, Partition *scratch,
|
|||
|
||||
// Lock *search* as the jump buffer
|
||||
lock_jump_buffer(search_name.str, search_name.size);
|
||||
|
||||
// Setup the search buffer for 'reference editing' mode
|
||||
buffer_set_setting(app, &search_buffer, BufferSetting_ReadOnly, false);
|
||||
buffer_set_edit_handler(app, search_buffer_id, search_buffer_edit_handler);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -621,21 +621,21 @@ DOC_SEE(4coder_Buffer_Positioning_System)
|
|||
}
|
||||
|
||||
API_EXPORT bool32
|
||||
Buffer_Replace_Range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len)
|
||||
Buffer_Replace_Range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t one_past_last, char *str, int32_t len)
|
||||
/*
|
||||
DOC_PARAM(buffer, This parameter specifies the buffer to edit.)
|
||||
DOC_PARAM(start, This parameter specifies absolute position of the first character in the replace range.)
|
||||
DOC_PARAM(end, This parameter specifies the absolute position of the the character one past the end of the replace range.)
|
||||
DOC_PARAM(one_past_last, This parameter specifies the absolute position of the the character one past the end of the replace range.)
|
||||
DOC_PARAM(str, This parameter specifies the the string to write into the range; it need not be null terminated.)
|
||||
DOC_PARAM(len, This parameter specifies the length of the str string.)
|
||||
DOC_RETURN(This call returns non-zero if the replacement succeeds.)
|
||||
DOC
|
||||
(
|
||||
If this call succeeds it deletes the range from start to end
|
||||
and writes str in the same position. If end == start then
|
||||
If this call succeeds it deletes the range from start to one_past_last
|
||||
and writes str in the same position. If one_past_last == start then
|
||||
this call is equivalent to inserting the string at start.
|
||||
If len == 0 this call is equivalent to deleteing the range
|
||||
from start to end.
|
||||
from start to one_past_last.
|
||||
|
||||
This call fails if the buffer does not exist, or if the replace
|
||||
range is not within the bounds of the buffer.
|
||||
|
@ -648,21 +648,40 @@ DOC_SEE(4coder_Buffer_Positioning_System)
|
|||
int32_t size = 0;
|
||||
if (file != 0){
|
||||
size = buffer_size(&file->state.buffer);
|
||||
if (0 <= start && start <= end && end <= size){
|
||||
Edit edit = {};
|
||||
edit.str = str;
|
||||
edit.length = len;
|
||||
edit.range.first = start;
|
||||
edit.range.one_past_last = end;
|
||||
Edit_Behaviors behaviors = {};
|
||||
edit_single(models->system, models, file, edit, behaviors);
|
||||
result = true;
|
||||
if (0 <= start && start <= one_past_last && one_past_last <= size){
|
||||
b32 do_low_level_edit = (file->settings.edit_handler == 0 || file->state.in_edit_handler);
|
||||
if (do_low_level_edit){
|
||||
Edit edit = {};
|
||||
edit.str = str;
|
||||
edit.length = len;
|
||||
edit.range.first = start;
|
||||
edit.range.one_past_last = one_past_last;
|
||||
Edit_Behaviors behaviors = {};
|
||||
edit_single(models->system, models, file, edit, behaviors);
|
||||
result = true;
|
||||
}
|
||||
else{
|
||||
file->state.in_edit_handler = true;
|
||||
result = file->settings.edit_handler(app, buffer->buffer_id, start, one_past_last, make_string(str, len));
|
||||
file->state.in_edit_handler = false;
|
||||
}
|
||||
}
|
||||
fill_buffer_summary(buffer, file, &models->working_set);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
API_EXPORT bool32
|
||||
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);
|
||||
bool32 result = (file != 0);
|
||||
if (result){
|
||||
file->settings.edit_handler = handler;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
API_EXPORT bool32
|
||||
Buffer_Compute_Cursor(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out)
|
||||
/*
|
||||
|
@ -683,8 +702,8 @@ DOC_SEE(Partial_Cursor)
|
|||
bool32 result = false;
|
||||
if (file != 0){
|
||||
if (file_compute_partial_cursor(file, seek, cursor_out)){
|
||||
result = true;
|
||||
fill_buffer_summary(buffer, file, &models->working_set);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
|
@ -805,6 +824,11 @@ DOC_RETURN(returns non-zero on success)
|
|||
*value_out = file->settings.virtual_white;
|
||||
}break;
|
||||
|
||||
case BufferSetting_RecordsHistory:
|
||||
{
|
||||
*value_out = history_is_activated(&file->state.history);
|
||||
}break;
|
||||
|
||||
default:
|
||||
{
|
||||
result = 0;
|
||||
|
@ -989,7 +1013,24 @@ DOC_SEE(Buffer_Setting_ID)
|
|||
}
|
||||
}break;
|
||||
|
||||
default: result = 0; break;
|
||||
case BufferSetting_RecordsHistory:
|
||||
{
|
||||
if (value){
|
||||
if (!history_is_activated(&file->state.history)){
|
||||
history_init(app, &file->state.history);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (history_is_activated(&file->state.history)){
|
||||
history_free(&models->mem.heap, &file->state.history);
|
||||
}
|
||||
}
|
||||
}break;
|
||||
|
||||
default:
|
||||
{
|
||||
result = 0;
|
||||
}break;
|
||||
}
|
||||
fill_buffer_summary(buffer, file, &models->working_set);
|
||||
}
|
||||
|
|
|
@ -212,6 +212,8 @@ file_compute_partial_cursor(Editing_File *file, Buffer_Seek seek, Partial_Cursor
|
|||
*cursor = buffer_partial_from_line_character(&file->state.buffer, seek.line, seek.character);
|
||||
}break;
|
||||
|
||||
// TODO(allen): do(support buffer_seek_character_pos and character_pos coordiantes in partial cursor system)
|
||||
|
||||
default:
|
||||
{
|
||||
result = false;
|
||||
|
|
|
@ -39,6 +39,7 @@ 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;
|
||||
|
@ -80,8 +81,9 @@ struct Editing_File_State{
|
|||
Cpp_Token_Array token_array;
|
||||
Cpp_Token_Array swap_array;
|
||||
u32 lex_job;
|
||||
b32 tokens_complete;
|
||||
b32 still_lexing;
|
||||
b8 tokens_complete;
|
||||
b8 still_lexing;
|
||||
b8 in_edit_handler;
|
||||
|
||||
Text_Effect paste_effect;
|
||||
|
||||
|
|
Loading…
Reference in New Issue