Cleanup cleanup cleanup; shrinking api implementation file size mostly
This commit is contained in:
parent
3911eb2197
commit
e6451a3871
|
@ -862,14 +862,6 @@ STRUCT Face_Metrics{
|
||||||
f32 typical_character_width;
|
f32 typical_character_width;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* DOC(A Buffer_Batch_Edit_Type is a type of batch operation.) */
|
|
||||||
ENUM(i32, Buffer_Batch_Edit_Type){
|
|
||||||
/* DOC(The BatchEdit_Normal operation is always correct but does the most work if there are tokens to correct.) */
|
|
||||||
BatchEdit_Normal,
|
|
||||||
/* DOC(The BatchEdit_PreserveTokens operation is one in which none of the edits add, delete, or change any tokens. This usually applies when whitespace is being replaced with whitespace.) */
|
|
||||||
BatchEdit_PreserveTokens
|
|
||||||
};
|
|
||||||
|
|
||||||
/* DOC(Buffer_Edit describes a range of a buffer and string to replace that range. A Buffer_Edit has to be paired with a string that contains the actual
|
/* DOC(Buffer_Edit describes a range of a buffer and string to replace that range. A Buffer_Edit has to be paired with a string that contains the actual
|
||||||
text that will be replaced into the buffer.) */
|
text that will be replaced into the buffer.) */
|
||||||
STRUCT Buffer_Edit{
|
STRUCT Buffer_Edit{
|
||||||
|
|
|
@ -130,7 +130,7 @@ exec_system_command(Application_Links *app, View_Summary *view, Buffer_Identifie
|
||||||
if (child_process_set_target_buffer(app, child_process_id, buffer_attach_id, set_buffer_flags)){
|
if (child_process_set_target_buffer(app, child_process_id, buffer_attach_id, set_buffer_flags)){
|
||||||
Buffer_Summary buffer = {};
|
Buffer_Summary buffer = {};
|
||||||
get_buffer_summary(app, buffer_attach_id, AccessAll, &buffer);
|
get_buffer_summary(app, buffer_attach_id, AccessAll, &buffer);
|
||||||
buffer_replace_range(app, buffer_attach_id, 0, buffer.size, make_lit_string(""));
|
buffer_replace_range(app, buffer_attach_id, make_range(0, buffer.size), make_lit_string(""));
|
||||||
if (HasFlag(flags, CLI_SendEndSignal)){
|
if (HasFlag(flags, CLI_SendEndSignal)){
|
||||||
buffer_send_end_signal(app, buffer_attach_id);
|
buffer_send_end_signal(app, buffer_attach_id);
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ static Buffer_Summary
|
||||||
get_buffer_first(Application_Links *app, Access_Flag access){
|
get_buffer_first(Application_Links *app, Access_Flag access){
|
||||||
Buffer_ID buffer_id = 0;
|
Buffer_ID buffer_id = 0;
|
||||||
Buffer_Summary buffer = {};
|
Buffer_Summary buffer = {};
|
||||||
if (get_buffer_first(app, access, &buffer_id)){
|
if (get_buffer_next(app, 0, access, &buffer_id)){
|
||||||
get_buffer_summary(app, buffer_id, access, &buffer);
|
get_buffer_summary(app, buffer_id, access, &buffer);
|
||||||
}
|
}
|
||||||
return(buffer);
|
return(buffer);
|
||||||
|
@ -229,7 +229,7 @@ static b32
|
||||||
buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, i32 start, i32 one_past_last, char *str, i32 len){
|
buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, i32 start, i32 one_past_last, char *str, i32 len){
|
||||||
b32 result = false;
|
b32 result = false;
|
||||||
if (buffer != 0 && buffer->exists){
|
if (buffer != 0 && buffer->exists){
|
||||||
result = buffer_replace_range(app, buffer->buffer_id, start, one_past_last, make_string(str, len));
|
result = buffer_replace_range(app, buffer->buffer_id, make_range(start, one_past_last), make_string(str, len));
|
||||||
get_buffer_summary(app, buffer->buffer_id, AccessAll, buffer);
|
get_buffer_summary(app, buffer->buffer_id, AccessAll, buffer);
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
|
@ -246,10 +246,10 @@ buffer_compute_cursor(Application_Links *app, Buffer_Summary *buffer, Buffer_See
|
||||||
}
|
}
|
||||||
|
|
||||||
static b32
|
static b32
|
||||||
buffer_batch_edit(Application_Links *app, Buffer_Summary *buffer, char *str, i32 str_len, Buffer_Edit *edits, i32 edit_count, Buffer_Batch_Edit_Type type){
|
buffer_batch_edit(Application_Links *app, Buffer_Summary *buffer, char *str, i32 str_len, Buffer_Edit *edits, i32 edit_count, i32 type){
|
||||||
b32 result = false;
|
b32 result = false;
|
||||||
if (buffer != 0 && buffer->exists){
|
if (buffer != 0 && buffer->exists){
|
||||||
result = buffer_batch_edit(app, buffer->buffer_id, str, str_len, edits, edit_count, type);
|
result = buffer_batch_edit(app, buffer->buffer_id, str, edits, edit_count);
|
||||||
get_buffer_summary(app, buffer->buffer_id, AccessAll, buffer);
|
get_buffer_summary(app, buffer->buffer_id, AccessAll, buffer);
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
|
|
||||||
#if !defined(REMOVE_TRANSITION_HELPER_31)
|
#if !defined(REMOVE_TRANSITION_HELPER_31)
|
||||||
|
|
||||||
|
#define BatchEdit_PreserveTokens 0
|
||||||
|
#define BatchEdit_Normal 0
|
||||||
|
|
||||||
/* DOC(Buffer_Summary acts as a handle to a buffer and describes the state of the buffer.)
|
/* DOC(Buffer_Summary acts as a handle to a buffer and describes the state of the buffer.)
|
||||||
DOC_SEE(Access_Flag)
|
DOC_SEE(Access_Flag)
|
||||||
DOC_SEE(Dirty_State) */
|
DOC_SEE(Dirty_State) */
|
||||||
|
|
|
@ -123,7 +123,7 @@ static void
|
||||||
set_line_indents(Application_Links *app, Partition *part, Buffer_ID buffer, i32 first_line, i32 one_past_last_line, i32 *indent_marks, Indent_Options opts){
|
set_line_indents(Application_Links *app, Partition *part, Buffer_ID buffer, i32 first_line, i32 one_past_last_line, i32 *indent_marks, Indent_Options opts){
|
||||||
Buffer_Batch_Edit batch = make_batch_from_indent_marks(app, part, buffer, first_line, one_past_last_line, indent_marks, opts);
|
Buffer_Batch_Edit batch = make_batch_from_indent_marks(app, part, buffer, first_line, one_past_last_line, indent_marks, opts);
|
||||||
if (batch.edit_count > 0){
|
if (batch.edit_count > 0){
|
||||||
buffer_batch_edit(app, buffer, batch.str, batch.str_len, batch.edits, batch.edit_count, BatchEdit_PreserveTokens);
|
buffer_batch_edit(app, buffer, batch.str, batch.edits, batch.edit_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ write_character_parameter(Application_Links *app, u8 *character, u32 length){
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(allen): perform the edit
|
// NOTE(allen): perform the edit
|
||||||
b32 edit_success = buffer_replace_range(app, buffer, pos, pos, make_string((char*)character, length));
|
b32 edit_success = buffer_replace_range(app, buffer, make_range(pos), make_string((char*)character, length));
|
||||||
|
|
||||||
// NOTE(allen): finish merging records if necessary
|
// NOTE(allen): finish merging records if necessary
|
||||||
if (do_merge){
|
if (do_merge){
|
||||||
|
@ -96,7 +96,7 @@ CUSTOM_DOC("Deletes the character to the right of the cursor.")
|
||||||
Full_Cursor cursor = {};
|
Full_Cursor cursor = {};
|
||||||
view_compute_cursor(app, &view, seek_character_pos(view.cursor.character_pos + 1), &cursor);
|
view_compute_cursor(app, &view, seek_character_pos(view.cursor.character_pos + 1), &cursor);
|
||||||
i32 end = cursor.pos;
|
i32 end = cursor.pos;
|
||||||
buffer_replace_range(app, buffer, start, end, make_lit_string(""));
|
buffer_replace_range(app, buffer, make_range(start, end), make_lit_string(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ CUSTOM_DOC("Deletes the character to the left of the cursor.")
|
||||||
Full_Cursor cursor = {};
|
Full_Cursor cursor = {};
|
||||||
view_compute_cursor(app, &view, seek_character_pos(view.cursor.character_pos - 1), &cursor);
|
view_compute_cursor(app, &view, seek_character_pos(view.cursor.character_pos - 1), &cursor);
|
||||||
i32 start = cursor.pos;
|
i32 start = cursor.pos;
|
||||||
if (buffer_replace_range(app, buffer, start, end, make_lit_string(""))){
|
if (buffer_replace_range(app, buffer, make_range(start, end), make_lit_string(""))){
|
||||||
view_set_cursor(app, &view, seek_character_pos(view.cursor.character_pos - 1), true);
|
view_set_cursor(app, &view, seek_character_pos(view.cursor.character_pos - 1), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ CUSTOM_DOC("Deletes the text in the range between the cursor and the mark.")
|
||||||
Buffer_ID buffer = 0;
|
Buffer_ID buffer = 0;
|
||||||
view_get_buffer(app, view.view_id, AccessOpen, &buffer);
|
view_get_buffer(app, view.view_id, AccessOpen, &buffer);
|
||||||
Range range = get_view_range(&view);
|
Range range = get_view_range(&view);
|
||||||
buffer_replace_range(app, buffer, range.min, range.max, make_lit_string(""));
|
buffer_replace_range(app, buffer, range, make_lit_string(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
@ -420,7 +420,7 @@ CUSTOM_DOC("Converts all ascii text in the range between the cursor and the mark
|
||||||
for (i32 i = 0; i < size; ++i){
|
for (i32 i = 0; i < size; ++i){
|
||||||
mem[i] = char_to_upper(mem[i]);
|
mem[i] = char_to_upper(mem[i]);
|
||||||
}
|
}
|
||||||
buffer_replace_range(app, buffer, range.min, range.max, make_string(mem, size));
|
buffer_replace_range(app, buffer, range, make_string(mem, size));
|
||||||
view_set_cursor(app, &view, seek_pos(range.max), true);
|
view_set_cursor(app, &view, seek_pos(range.max), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,7 +439,7 @@ CUSTOM_DOC("Converts all ascii text in the range between the cursor and the mark
|
||||||
for (i32 i = 0; i < size; ++i){
|
for (i32 i = 0; i < size; ++i){
|
||||||
mem[i] = char_to_lower(mem[i]);
|
mem[i] = char_to_lower(mem[i]);
|
||||||
}
|
}
|
||||||
buffer_replace_range(app, buffer, range.min, range.max, make_string(mem, size));
|
buffer_replace_range(app, buffer, range, make_string(mem, size));
|
||||||
view_set_cursor(app, &view, seek_pos(range.max), true);
|
view_set_cursor(app, &view, seek_pos(range.max), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ CUSTOM_DOC("Removes trailing whitespace from all lines in the current buffer.")
|
||||||
}
|
}
|
||||||
|
|
||||||
i32 edit_count = (i32)(edit - edits);
|
i32 edit_count = (i32)(edit - edits);
|
||||||
buffer_batch_edit(app, buffer_id, 0, 0, edits, edit_count, BatchEdit_PreserveTokens);
|
buffer_batch_edit(app, buffer_id, 0, edits, edit_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -990,7 +990,7 @@ CUSTOM_DOC("Queries the user for two strings, and replaces all occurences of the
|
||||||
|
|
||||||
global_history_edit_group_begin(app);
|
global_history_edit_group_begin(app);
|
||||||
for (;new_pos + r.size <= range.end;){
|
for (;new_pos + r.size <= range.end;){
|
||||||
buffer_replace_range(app, buffer_id, new_pos, new_pos + r.size, w);
|
buffer_replace_range(app, buffer_id, make_range(new_pos, new_pos + r.size), w);
|
||||||
refresh_view(app, &view);
|
refresh_view(app, &view);
|
||||||
range = get_view_range(&view);
|
range = get_view_range(&view);
|
||||||
pos = new_pos + w.size;
|
pos = new_pos + w.size;
|
||||||
|
@ -1027,7 +1027,7 @@ query_replace_base(Application_Links *app, View_Summary *view, Buffer_ID buffer_
|
||||||
|
|
||||||
if (in.key.character == 'y' || in.key.character == 'Y' ||
|
if (in.key.character == 'y' || in.key.character == 'Y' ||
|
||||||
in.key.character == '\n' || in.key.character == '\t'){
|
in.key.character == '\n' || in.key.character == '\t'){
|
||||||
buffer_replace_range(app, buffer_id, match.min, match.max, w);
|
buffer_replace_range(app, buffer_id, match, w);
|
||||||
pos = match.start + w.size;
|
pos = match.start + w.size;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -1397,7 +1397,7 @@ CUSTOM_DOC("Swaps the line under the cursor with the line above it, and moves th
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer_read_range(app, buffer, prev_line_pos, this_line_pos, swap + first_len)){
|
if (buffer_read_range(app, buffer, prev_line_pos, this_line_pos, swap + first_len)){
|
||||||
buffer_replace_range(app, buffer, prev_line_pos, next_line_pos, make_string(swap, length));
|
buffer_replace_range(app, buffer, make_range(prev_line_pos, next_line_pos), make_string(swap, length));
|
||||||
view_set_cursor(app, &view, seek_line_char(prev_line, 1), true);
|
view_set_cursor(app, &view, seek_line_char(prev_line, 1), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1443,7 +1443,7 @@ CUSTOM_DOC("Create a copy of the line on which the cursor sits.")
|
||||||
line_string.size += 1;
|
line_string.size += 1;
|
||||||
|
|
||||||
i32 pos = buffer_get_line_end(app, buffer_id, view.cursor.line);
|
i32 pos = buffer_get_line_end(app, buffer_id, view.cursor.line);
|
||||||
buffer_replace_range(app, buffer_id, pos, pos, line_string);
|
buffer_replace_range(app, buffer_id, make_range(pos), line_string);
|
||||||
}
|
}
|
||||||
end_temp_memory(temp);
|
end_temp_memory(temp);
|
||||||
}
|
}
|
||||||
|
@ -1473,7 +1473,7 @@ CUSTOM_DOC("Delete the line the on which the cursor sits.")
|
||||||
}
|
}
|
||||||
|
|
||||||
String zero = {};
|
String zero = {};
|
||||||
buffer_replace_range(app, buffer_id, start, end, zero);
|
buffer_replace_range(app, buffer_id, make_range(start, end), zero);
|
||||||
|
|
||||||
end_temp_memory(temp);
|
end_temp_memory(temp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -863,6 +863,12 @@ make_range(i32 p1, i32 p2){
|
||||||
return(range);
|
return(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Range
|
||||||
|
make_range(i32 p){
|
||||||
|
Range range = {p, p};
|
||||||
|
return(range);
|
||||||
|
}
|
||||||
|
|
||||||
static Range
|
static Range
|
||||||
rectify(Range range) {
|
rectify(Range range) {
|
||||||
return(make_range(range.min, range.max));
|
return(make_range(range.min, range.max));
|
||||||
|
@ -905,6 +911,16 @@ interval_is_valid(Range range){
|
||||||
return(range.start <= range.one_past_last);
|
return(range.start <= range.one_past_last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static i32
|
||||||
|
replace_range_compute_shift(i32 replace_start, i32 replace_end, i32 insert_length){
|
||||||
|
return(insert_length - (replace_end - replace_start));
|
||||||
|
}
|
||||||
|
|
||||||
|
static i32
|
||||||
|
replace_range_compute_shift(Range range, i32 insert_length){
|
||||||
|
return(replace_range_compute_shift(range.first, range.one_past_last, insert_length));
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
static i32_Rect
|
static i32_Rect
|
||||||
|
|
|
@ -41,7 +41,7 @@ CUSTOM_DOC("Cut the text in the range from the cursor to the mark onto the clipb
|
||||||
view_get_buffer(app, view.view_id, AccessOpen, &buffer);
|
view_get_buffer(app, view.view_id, AccessOpen, &buffer);
|
||||||
Range range = get_view_range(&view);
|
Range range = get_view_range(&view);
|
||||||
if (post_buffer_range_to_clipboard(app, &global_part, 0, buffer, range.min, range.max)){
|
if (post_buffer_range_to_clipboard(app, &global_part, 0, buffer, range.min, range.max)){
|
||||||
buffer_replace_range(app, buffer, range.min, range.max, make_lit_string(""));
|
buffer_replace_range(app, buffer, range, make_lit_string(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ CUSTOM_DOC("At the cursor, insert the text at the top of the clipboard.")
|
||||||
view_get_buffer(app, view.view_id, AccessOpen, &buffer);
|
view_get_buffer(app, view.view_id, AccessOpen, &buffer);
|
||||||
|
|
||||||
i32 pos = view.cursor.pos;
|
i32 pos = view.cursor.pos;
|
||||||
buffer_replace_range(app, buffer, pos, pos, make_string(str, len));
|
buffer_replace_range(app, buffer, make_range(pos), make_string(str, len));
|
||||||
view_set_mark(app, &view, seek_pos(pos));
|
view_set_mark(app, &view, seek_pos(pos));
|
||||||
view_set_cursor(app, &view, seek_pos(pos + len), true);
|
view_set_cursor(app, &view, seek_pos(pos + len), true);
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ CUSTOM_DOC("If the previous command was paste or paste_next, replaces the paste
|
||||||
Range range = get_view_range(&view);
|
Range range = get_view_range(&view);
|
||||||
i32 pos = range.min;
|
i32 pos = range.min;
|
||||||
|
|
||||||
buffer_replace_range(app, buffer, range.min, range.max, make_string(str, len));
|
buffer_replace_range(app, buffer, range, make_string(str, len));
|
||||||
view_set_cursor(app, &view, seek_pos(pos + len), true);
|
view_set_cursor(app, &view, seek_pos(pos + len), true);
|
||||||
|
|
||||||
// TODO(allen): Send this to all views.
|
// TODO(allen): Send this to all views.
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_string(Application_Links *app, View_Summary *view, Buffer_ID buffer, String string){
|
write_string(Application_Links *app, View_Summary *view, Buffer_ID buffer, String string){
|
||||||
buffer_replace_range(app, buffer, view->cursor.pos, view->cursor.pos, string);
|
buffer_replace_range(app, buffer, make_range(view->cursor.pos), string);
|
||||||
view_set_cursor(app, view, seek_pos(view->cursor.pos + string.size), 1);
|
view_set_cursor(app, view, seek_pos(view->cursor.pos + string.size), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ long_braces(Application_Links *app, char *text, i32 size){
|
||||||
Buffer_ID buffer = 0;
|
Buffer_ID buffer = 0;
|
||||||
view_get_buffer(app, view.view_id, AccessOpen, &buffer);
|
view_get_buffer(app, view.view_id, AccessOpen, &buffer);
|
||||||
i32 pos = view.cursor.pos;
|
i32 pos = view.cursor.pos;
|
||||||
buffer_replace_range(app, buffer, pos, pos, make_string(text, size));
|
buffer_replace_range(app, buffer, make_range(pos), make_string(text, size));
|
||||||
view_set_cursor(app, &view, seek_pos(pos + 2), true);
|
view_set_cursor(app, &view, seek_pos(pos + 2), true);
|
||||||
buffer_auto_indent(app, &global_part, buffer, pos, pos + size, DEF_TAB_WIDTH, DEFAULT_INDENT_FLAGS | AutoIndent_FullTokens);
|
buffer_auto_indent(app, &global_part, buffer, pos, pos + size, DEF_TAB_WIDTH, DEFAULT_INDENT_FLAGS | AutoIndent_FullTokens);
|
||||||
move_past_lead_whitespace(app, &view, buffer);
|
move_past_lead_whitespace(app, &view, buffer);
|
||||||
|
@ -141,7 +141,7 @@ CUSTOM_DOC("Insert '//' at the beginning of the line after leading whitespace.")
|
||||||
i32 pos = get_start_of_line_at_cursor(app, &view, buffer);
|
i32 pos = get_start_of_line_at_cursor(app, &view, buffer);
|
||||||
b32 alread_has_comment = c_line_comment_starts_at_position(app, buffer, pos);
|
b32 alread_has_comment = c_line_comment_starts_at_position(app, buffer, pos);
|
||||||
if (!alread_has_comment){
|
if (!alread_has_comment){
|
||||||
buffer_replace_range(app, buffer, pos, pos, make_lit_string("//"));
|
buffer_replace_range(app, buffer, make_range(pos), make_lit_string("//"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ CUSTOM_DOC("If present, delete '//' at the beginning of the line after leading w
|
||||||
i32 pos = get_start_of_line_at_cursor(app, &view, buffer);
|
i32 pos = get_start_of_line_at_cursor(app, &view, buffer);
|
||||||
b32 alread_has_comment = c_line_comment_starts_at_position(app, buffer, pos);
|
b32 alread_has_comment = c_line_comment_starts_at_position(app, buffer, pos);
|
||||||
if (alread_has_comment){
|
if (alread_has_comment){
|
||||||
buffer_replace_range(app, buffer, pos, pos + 2, make_lit_string(""));
|
buffer_replace_range(app, buffer, make_range(pos, pos + 2), make_lit_string(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,10 +167,10 @@ CUSTOM_DOC("Turns uncommented lines into commented lines and vice versa for comm
|
||||||
i32 pos = get_start_of_line_at_cursor(app, &view, buffer);
|
i32 pos = get_start_of_line_at_cursor(app, &view, buffer);
|
||||||
b32 alread_has_comment = c_line_comment_starts_at_position(app, buffer, pos);
|
b32 alread_has_comment = c_line_comment_starts_at_position(app, buffer, pos);
|
||||||
if (alread_has_comment){
|
if (alread_has_comment){
|
||||||
buffer_replace_range(app, buffer, pos, pos + 2, make_lit_string(""));
|
buffer_replace_range(app, buffer, make_range(pos, pos + 2), make_lit_string(""));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
buffer_replace_range(app, buffer, pos, pos, make_lit_string("//"));
|
buffer_replace_range(app, buffer, make_range(pos), make_lit_string("//"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ activate_snippet(Application_Links *app, Partition *scratch, Heap *heap,
|
||||||
Buffer_ID buffer = 0;
|
Buffer_ID buffer = 0;
|
||||||
view_get_buffer(app, view->view_id, AccessOpen, &buffer);
|
view_get_buffer(app, view->view_id, AccessOpen, &buffer);
|
||||||
i32 pos = view->cursor.pos;
|
i32 pos = view->cursor.pos;
|
||||||
buffer_replace_range(app, buffer, pos, pos, make_string_slowly(snippet.text));
|
buffer_replace_range(app, buffer, make_range(pos), make_string_slowly(snippet.text));
|
||||||
view_set_cursor(app, view, seek_pos(pos + snippet.cursor_offset), true);
|
view_set_cursor(app, view, seek_pos(pos + snippet.cursor_offset), true);
|
||||||
view_set_mark(app, view, seek_pos(pos + snippet.mark_offset));
|
view_set_mark(app, view, seek_pos(pos + snippet.mark_offset));
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,7 +299,7 @@ create_or_switch_to_buffer_by_name(Application_Links *app, char *name, i32 name_
|
||||||
buffer_get_size(app, search_buffer, &buffer_size);
|
buffer_get_size(app, search_buffer, &buffer_size);
|
||||||
|
|
||||||
buffer_send_end_signal(app, search_buffer);
|
buffer_send_end_signal(app, search_buffer);
|
||||||
buffer_replace_range(app, search_buffer, 0, buffer_size, make_lit_string(""));
|
buffer_replace_range(app, search_buffer, make_range(0, buffer_size), make_lit_string(""));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
create_buffer(app, name_string, BufferCreate_AlwaysNew, &search_buffer);
|
create_buffer(app, name_string, BufferCreate_AlwaysNew, &search_buffer);
|
||||||
|
|
|
@ -54,7 +54,7 @@ CUSTOM_DOC("Delete characters in a rectangular region. Range testing is done by
|
||||||
end = cursor.pos;
|
end = cursor.pos;
|
||||||
|
|
||||||
if (success){
|
if (success){
|
||||||
buffer_replace_range(app, buffer, start, end, make_lit_string(""));
|
buffer_replace_range(app, buffer, make_range(start, end), make_lit_string(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ pad_buffer_line(Application_Links *app, Partition *part, Buffer_ID buffer, i32 l
|
||||||
i32 size = target - (end.character - 1);
|
i32 size = target - (end.character - 1);
|
||||||
char *str = push_array(part, char, size);
|
char *str = push_array(part, char, size);
|
||||||
memset(str, ' ', size);
|
memset(str, ' ', size);
|
||||||
buffer_replace_range(app, buffer, end.pos, end.pos, make_string(str, size));
|
buffer_replace_range(app, buffer, make_range(end.pos), make_string(str, size));
|
||||||
end_temp_memory(temp);
|
end_temp_memory(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ CUSTOM_DOC("Begin multi-line mode. In multi-line mode characters are inserted a
|
||||||
}
|
}
|
||||||
|
|
||||||
i32 edit_count = (int)(edit - edits);
|
i32 edit_count = (int)(edit - edits);
|
||||||
buffer_batch_edit(app, buffer, &str, 1, edits, edit_count, BatchEdit_Normal);
|
buffer_batch_edit(app, buffer, &str, edits, edit_count);
|
||||||
|
|
||||||
end_temp_memory(temp);
|
end_temp_memory(temp);
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ CUSTOM_DOC("Begin multi-line mode. In multi-line mode characters are inserted a
|
||||||
}
|
}
|
||||||
|
|
||||||
i32 edit_count = (int)(edit - edits);
|
i32 edit_count = (int)(edit - edits);
|
||||||
buffer_batch_edit(app, buffer, 0, 0, edits, edit_count, BatchEdit_Normal);
|
buffer_batch_edit(app, buffer, 0, edits, edit_count);
|
||||||
|
|
||||||
end_temp_memory(temp);
|
end_temp_memory(temp);
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ CUSTOM_COMMAND_SIG(multi_paste){
|
||||||
Buffer_ID buffer = 0;
|
Buffer_ID buffer = 0;
|
||||||
view_get_buffer(app, view.view_id, AccessOpen, &buffer);
|
view_get_buffer(app, view.view_id, AccessOpen, &buffer);
|
||||||
Range range = get_view_range(&view);
|
Range range = get_view_range(&view);
|
||||||
buffer_replace_range(app, buffer, range.max, range.max, make_string(str, len + 1));
|
buffer_replace_range(app, buffer, make_range(range.max), make_string(str, len + 1));
|
||||||
view_set_mark(app, &view, seek_pos(range.max + 1));
|
view_set_mark(app, &view, seek_pos(range.max + 1));
|
||||||
view_set_cursor(app, &view, seek_pos(range.max + len + 1), true);
|
view_set_cursor(app, &view, seek_pos(range.max + len + 1), true);
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ multi_paste_range(Application_Links *app, View_Summary *view, Range range, i32 p
|
||||||
}
|
}
|
||||||
|
|
||||||
i32 pos = range.min;
|
i32 pos = range.min;
|
||||||
buffer_replace_range(app, buffer, range.min, range.max, make_string(str, total_size));
|
buffer_replace_range(app, buffer, range, make_string(str, total_size));
|
||||||
finish_range.min = pos;
|
finish_range.min = pos;
|
||||||
finish_range.max = pos + total_size;
|
finish_range.max = pos + total_size;
|
||||||
view_set_mark(app, view, seek_pos(finish_range.min));
|
view_set_mark(app, view, seek_pos(finish_range.min));
|
||||||
|
@ -348,7 +348,7 @@ multi_paste_interactive_up_down(Application_Links *app, i32 paste_count, i32 cli
|
||||||
if (in.abort){
|
if (in.abort){
|
||||||
Buffer_ID buffer = 0;
|
Buffer_ID buffer = 0;
|
||||||
view_get_buffer(app, view.view_id, AccessOpen, &buffer);
|
view_get_buffer(app, view.view_id, AccessOpen, &buffer);
|
||||||
buffer_replace_range(app, buffer, range.min, range.max, make_lit_string(""));
|
buffer_replace_range(app, buffer, range, make_lit_string(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,7 +522,7 @@ CUSTOM_DOC("If the cursor is found to be on the name of a function parameter in
|
||||||
doublebreak2:;
|
doublebreak2:;
|
||||||
|
|
||||||
if (closed_correctly){
|
if (closed_correctly){
|
||||||
buffer_batch_edit(app, buffer, replace_string.str, replace_string.size, edits, edit_count, BatchEdit_Normal);
|
buffer_batch_edit(app, buffer, replace_string.str, edits, edit_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -684,7 +684,7 @@ write_explicit_enum_values_parameters(Application_Links *app, Write_Explicit_Enu
|
||||||
|
|
||||||
finished:;
|
finished:;
|
||||||
if (closed_correctly){
|
if (closed_correctly){
|
||||||
buffer_batch_edit(app, buffer, string_base, string.size, edits, edit_count, BatchEdit_Normal);
|
buffer_batch_edit(app, buffer, string_base, edits, edit_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -766,7 +766,7 @@ replace_all_occurrences_parameters(Application_Links *app, Heap *heap, Partition
|
||||||
current_offset = 0;
|
current_offset = 0;
|
||||||
}
|
}
|
||||||
i32 pos = target->start_pos + current_offset;
|
i32 pos = target->start_pos + current_offset;
|
||||||
buffer_replace_range(app, target->buffer_id, pos, pos + target_string.size, new_string);
|
buffer_replace_range(app, target->buffer_id, make_range(pos, pos + target_string.size), new_string);
|
||||||
current_offset += shift_per_replacement;
|
current_offset += shift_per_replacement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ buffered_write_stream_flush(Application_Links *app, Buffered_Write_Stream *strea
|
||||||
i32 buffer_size = 0;
|
i32 buffer_size = 0;
|
||||||
buffer_get_size(app, buffer, &buffer_size);
|
buffer_get_size(app, buffer, &buffer_size);
|
||||||
i32 stream_size = (i32)(push_array(stream->buffering_arena, char, 0) - stream->buffer);
|
i32 stream_size = (i32)(push_array(stream->buffering_arena, char, 0) - stream->buffer);
|
||||||
buffer_replace_range(app, buffer, buffer_size, buffer_size, make_string(stream->buffer, stream_size));
|
buffer_replace_range(app, buffer, make_range(buffer_size), make_string(stream->buffer, stream_size));
|
||||||
stream->buffering_arena->pos -= stream_size;
|
stream->buffering_arena->pos -= stream_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ list_all_functions(Application_Links *app, Partition *part, Buffer_ID optional_t
|
||||||
buffer_send_end_signal(app, decls_buffer);
|
buffer_send_end_signal(app, decls_buffer);
|
||||||
i32 size = 0;
|
i32 size = 0;
|
||||||
buffer_get_size(app, decls_buffer, &size);
|
buffer_get_size(app, decls_buffer, &size);
|
||||||
buffer_replace_range(app, decls_buffer, 0, size, make_lit_string(""));
|
buffer_replace_range(app, decls_buffer, make_range(0, size), make_lit_string(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
Temp_Memory temp = begin_temp_memory(part);
|
Temp_Memory temp = begin_temp_memory(part);
|
||||||
|
|
|
@ -13,14 +13,13 @@ struct Application_Links;
|
||||||
#define CLIPBOARD_INDEX_SIG(n) b32 n(Application_Links *app, i32 clipboard_id, i32 item_index, String *string_out, i32 *required_size_out)
|
#define CLIPBOARD_INDEX_SIG(n) b32 n(Application_Links *app, i32 clipboard_id, i32 item_index, String *string_out, i32 *required_size_out)
|
||||||
#define CREATE_PARSE_CONTEXT_SIG(n) Parse_Context_ID n(Application_Links *app, Parser_String_And_Type *kw, u32 kw_count, Parser_String_And_Type *pp, u32 pp_count)
|
#define CREATE_PARSE_CONTEXT_SIG(n) Parse_Context_ID n(Application_Links *app, Parser_String_And_Type *kw, u32 kw_count, Parser_String_And_Type *pp, u32 pp_count)
|
||||||
#define GET_BUFFER_COUNT_SIG(n) i32 n(Application_Links *app)
|
#define GET_BUFFER_COUNT_SIG(n) i32 n(Application_Links *app)
|
||||||
#define GET_BUFFER_FIRST_SIG(n) b32 n(Application_Links *app, Access_Flag access, Buffer_ID *buffer_id_out)
|
|
||||||
#define GET_BUFFER_NEXT_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_ID *buffer_id_out)
|
#define GET_BUFFER_NEXT_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_ID *buffer_id_out)
|
||||||
#define GET_BUFFER_BY_NAME_SIG(n) b32 n(Application_Links *app, String name, Access_Flag access, Buffer_ID *buffer_id_out)
|
#define GET_BUFFER_BY_NAME_SIG(n) b32 n(Application_Links *app, String name, Access_Flag access, Buffer_ID *buffer_id_out)
|
||||||
#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 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_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_REPLACE_RANGE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Range range, String string)
|
||||||
|
#define BUFFER_BATCH_EDIT_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, char *str, Buffer_Edit *edits, i32 edit_count)
|
||||||
#define BUFFER_COMPUTE_CURSOR_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Seek seek, Partial_Cursor *cursor_out)
|
#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)
|
#define BUFFER_EXISTS_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id)
|
||||||
#define BUFFER_READY_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id)
|
#define BUFFER_READY_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id)
|
||||||
#define BUFFER_GET_ACCESS_FLAGS_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Access_Flag *access_flags_out)
|
#define BUFFER_GET_ACCESS_FLAGS_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Access_Flag *access_flags_out)
|
||||||
|
@ -198,14 +197,13 @@ typedef CLIPBOARD_COUNT_SIG(Clipboard_Count_Function);
|
||||||
typedef CLIPBOARD_INDEX_SIG(Clipboard_Index_Function);
|
typedef CLIPBOARD_INDEX_SIG(Clipboard_Index_Function);
|
||||||
typedef CREATE_PARSE_CONTEXT_SIG(Create_Parse_Context_Function);
|
typedef CREATE_PARSE_CONTEXT_SIG(Create_Parse_Context_Function);
|
||||||
typedef GET_BUFFER_COUNT_SIG(Get_Buffer_Count_Function);
|
typedef GET_BUFFER_COUNT_SIG(Get_Buffer_Count_Function);
|
||||||
typedef GET_BUFFER_FIRST_SIG(Get_Buffer_First_Function);
|
|
||||||
typedef GET_BUFFER_NEXT_SIG(Get_Buffer_Next_Function);
|
typedef GET_BUFFER_NEXT_SIG(Get_Buffer_Next_Function);
|
||||||
typedef GET_BUFFER_BY_NAME_SIG(Get_Buffer_By_Name_Function);
|
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 GET_BUFFER_BY_FILE_NAME_SIG(Get_Buffer_By_File_Name_Function);
|
||||||
typedef BUFFER_READ_RANGE_SIG(Buffer_Read_Range_Function);
|
typedef BUFFER_READ_RANGE_SIG(Buffer_Read_Range_Function);
|
||||||
typedef BUFFER_REPLACE_RANGE_SIG(Buffer_Replace_Range_Function);
|
typedef BUFFER_REPLACE_RANGE_SIG(Buffer_Replace_Range_Function);
|
||||||
typedef BUFFER_COMPUTE_CURSOR_SIG(Buffer_Compute_Cursor_Function);
|
|
||||||
typedef BUFFER_BATCH_EDIT_SIG(Buffer_Batch_Edit_Function);
|
typedef BUFFER_BATCH_EDIT_SIG(Buffer_Batch_Edit_Function);
|
||||||
|
typedef BUFFER_COMPUTE_CURSOR_SIG(Buffer_Compute_Cursor_Function);
|
||||||
typedef BUFFER_EXISTS_SIG(Buffer_Exists_Function);
|
typedef BUFFER_EXISTS_SIG(Buffer_Exists_Function);
|
||||||
typedef BUFFER_READY_SIG(Buffer_Ready_Function);
|
typedef BUFFER_READY_SIG(Buffer_Ready_Function);
|
||||||
typedef BUFFER_GET_ACCESS_FLAGS_SIG(Buffer_Get_Access_Flags_Function);
|
typedef BUFFER_GET_ACCESS_FLAGS_SIG(Buffer_Get_Access_Flags_Function);
|
||||||
|
@ -385,14 +383,13 @@ Clipboard_Count_Function *clipboard_count;
|
||||||
Clipboard_Index_Function *clipboard_index;
|
Clipboard_Index_Function *clipboard_index;
|
||||||
Create_Parse_Context_Function *create_parse_context;
|
Create_Parse_Context_Function *create_parse_context;
|
||||||
Get_Buffer_Count_Function *get_buffer_count;
|
Get_Buffer_Count_Function *get_buffer_count;
|
||||||
Get_Buffer_First_Function *get_buffer_first;
|
|
||||||
Get_Buffer_Next_Function *get_buffer_next;
|
Get_Buffer_Next_Function *get_buffer_next;
|
||||||
Get_Buffer_By_Name_Function *get_buffer_by_name;
|
Get_Buffer_By_Name_Function *get_buffer_by_name;
|
||||||
Get_Buffer_By_File_Name_Function *get_buffer_by_file_name;
|
Get_Buffer_By_File_Name_Function *get_buffer_by_file_name;
|
||||||
Buffer_Read_Range_Function *buffer_read_range;
|
Buffer_Read_Range_Function *buffer_read_range;
|
||||||
Buffer_Replace_Range_Function *buffer_replace_range;
|
Buffer_Replace_Range_Function *buffer_replace_range;
|
||||||
Buffer_Compute_Cursor_Function *buffer_compute_cursor;
|
|
||||||
Buffer_Batch_Edit_Function *buffer_batch_edit;
|
Buffer_Batch_Edit_Function *buffer_batch_edit;
|
||||||
|
Buffer_Compute_Cursor_Function *buffer_compute_cursor;
|
||||||
Buffer_Exists_Function *buffer_exists;
|
Buffer_Exists_Function *buffer_exists;
|
||||||
Buffer_Ready_Function *buffer_ready;
|
Buffer_Ready_Function *buffer_ready;
|
||||||
Buffer_Get_Access_Flags_Function *buffer_get_access_flags;
|
Buffer_Get_Access_Flags_Function *buffer_get_access_flags;
|
||||||
|
@ -571,14 +568,13 @@ Clipboard_Count_Function *clipboard_count_;
|
||||||
Clipboard_Index_Function *clipboard_index_;
|
Clipboard_Index_Function *clipboard_index_;
|
||||||
Create_Parse_Context_Function *create_parse_context_;
|
Create_Parse_Context_Function *create_parse_context_;
|
||||||
Get_Buffer_Count_Function *get_buffer_count_;
|
Get_Buffer_Count_Function *get_buffer_count_;
|
||||||
Get_Buffer_First_Function *get_buffer_first_;
|
|
||||||
Get_Buffer_Next_Function *get_buffer_next_;
|
Get_Buffer_Next_Function *get_buffer_next_;
|
||||||
Get_Buffer_By_Name_Function *get_buffer_by_name_;
|
Get_Buffer_By_Name_Function *get_buffer_by_name_;
|
||||||
Get_Buffer_By_File_Name_Function *get_buffer_by_file_name_;
|
Get_Buffer_By_File_Name_Function *get_buffer_by_file_name_;
|
||||||
Buffer_Read_Range_Function *buffer_read_range_;
|
Buffer_Read_Range_Function *buffer_read_range_;
|
||||||
Buffer_Replace_Range_Function *buffer_replace_range_;
|
Buffer_Replace_Range_Function *buffer_replace_range_;
|
||||||
Buffer_Compute_Cursor_Function *buffer_compute_cursor_;
|
|
||||||
Buffer_Batch_Edit_Function *buffer_batch_edit_;
|
Buffer_Batch_Edit_Function *buffer_batch_edit_;
|
||||||
|
Buffer_Compute_Cursor_Function *buffer_compute_cursor_;
|
||||||
Buffer_Exists_Function *buffer_exists_;
|
Buffer_Exists_Function *buffer_exists_;
|
||||||
Buffer_Ready_Function *buffer_ready_;
|
Buffer_Ready_Function *buffer_ready_;
|
||||||
Buffer_Get_Access_Flags_Function *buffer_get_access_flags_;
|
Buffer_Get_Access_Flags_Function *buffer_get_access_flags_;
|
||||||
|
@ -765,14 +761,13 @@ app_links->clipboard_count_ = Clipboard_Count;\
|
||||||
app_links->clipboard_index_ = Clipboard_Index;\
|
app_links->clipboard_index_ = Clipboard_Index;\
|
||||||
app_links->create_parse_context_ = Create_Parse_Context;\
|
app_links->create_parse_context_ = Create_Parse_Context;\
|
||||||
app_links->get_buffer_count_ = Get_Buffer_Count;\
|
app_links->get_buffer_count_ = Get_Buffer_Count;\
|
||||||
app_links->get_buffer_first_ = Get_Buffer_First;\
|
|
||||||
app_links->get_buffer_next_ = Get_Buffer_Next;\
|
app_links->get_buffer_next_ = Get_Buffer_Next;\
|
||||||
app_links->get_buffer_by_name_ = Get_Buffer_By_Name;\
|
app_links->get_buffer_by_name_ = Get_Buffer_By_Name;\
|
||||||
app_links->get_buffer_by_file_name_ = Get_Buffer_By_File_Name;\
|
app_links->get_buffer_by_file_name_ = Get_Buffer_By_File_Name;\
|
||||||
app_links->buffer_read_range_ = Buffer_Read_Range;\
|
app_links->buffer_read_range_ = Buffer_Read_Range;\
|
||||||
app_links->buffer_replace_range_ = Buffer_Replace_Range;\
|
app_links->buffer_replace_range_ = Buffer_Replace_Range;\
|
||||||
app_links->buffer_compute_cursor_ = Buffer_Compute_Cursor;\
|
|
||||||
app_links->buffer_batch_edit_ = Buffer_Batch_Edit;\
|
app_links->buffer_batch_edit_ = Buffer_Batch_Edit;\
|
||||||
|
app_links->buffer_compute_cursor_ = Buffer_Compute_Cursor;\
|
||||||
app_links->buffer_exists_ = Buffer_Exists;\
|
app_links->buffer_exists_ = Buffer_Exists;\
|
||||||
app_links->buffer_ready_ = Buffer_Ready;\
|
app_links->buffer_ready_ = Buffer_Ready;\
|
||||||
app_links->buffer_get_access_flags_ = Buffer_Get_Access_Flags;\
|
app_links->buffer_get_access_flags_ = Buffer_Get_Access_Flags;\
|
||||||
|
@ -951,14 +946,13 @@ static b32 clipboard_count(Application_Links *app, i32 clipboard_id, i32 *count_
|
||||||
static b32 clipboard_index(Application_Links *app, i32 clipboard_id, i32 item_index, String *string_out, i32 *required_size_out){return(app->clipboard_index(app, clipboard_id, item_index, string_out, required_size_out));}
|
static b32 clipboard_index(Application_Links *app, i32 clipboard_id, i32 item_index, String *string_out, i32 *required_size_out){return(app->clipboard_index(app, clipboard_id, item_index, string_out, required_size_out));}
|
||||||
static Parse_Context_ID create_parse_context(Application_Links *app, Parser_String_And_Type *kw, u32 kw_count, Parser_String_And_Type *pp, u32 pp_count){return(app->create_parse_context(app, kw, kw_count, pp, pp_count));}
|
static Parse_Context_ID create_parse_context(Application_Links *app, Parser_String_And_Type *kw, u32 kw_count, Parser_String_And_Type *pp, u32 pp_count){return(app->create_parse_context(app, kw, kw_count, pp, pp_count));}
|
||||||
static i32 get_buffer_count(Application_Links *app){return(app->get_buffer_count(app));}
|
static i32 get_buffer_count(Application_Links *app){return(app->get_buffer_count(app));}
|
||||||
static b32 get_buffer_first(Application_Links *app, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_first(app, access, buffer_id_out));}
|
|
||||||
static b32 get_buffer_next(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_next(app, buffer_id, access, buffer_id_out));}
|
static b32 get_buffer_next(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_next(app, buffer_id, access, buffer_id_out));}
|
||||||
static b32 get_buffer_by_name(Application_Links *app, String name, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_by_name(app, name, access, buffer_id_out));}
|
static b32 get_buffer_by_name(Application_Links *app, String name, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_by_name(app, name, access, buffer_id_out));}
|
||||||
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 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_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_replace_range(Application_Links *app, Buffer_ID buffer_id, Range range, String string){return(app->buffer_replace_range(app, buffer_id, range, string));}
|
||||||
|
static b32 buffer_batch_edit(Application_Links *app, Buffer_ID buffer_id, char *str, Buffer_Edit *edits, i32 edit_count){return(app->buffer_batch_edit(app, buffer_id, str, edits, edit_count));}
|
||||||
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_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));}
|
static b32 buffer_exists(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_exists(app, buffer_id));}
|
||||||
static b32 buffer_ready(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_ready(app, buffer_id));}
|
static b32 buffer_ready(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_ready(app, buffer_id));}
|
||||||
static b32 buffer_get_access_flags(Application_Links *app, Buffer_ID buffer_id, Access_Flag *access_flags_out){return(app->buffer_get_access_flags(app, buffer_id, access_flags_out));}
|
static b32 buffer_get_access_flags(Application_Links *app, Buffer_ID buffer_id, Access_Flag *access_flags_out){return(app->buffer_get_access_flags(app, buffer_id, access_flags_out));}
|
||||||
|
@ -1137,14 +1131,13 @@ static b32 clipboard_count(Application_Links *app, i32 clipboard_id, i32 *count_
|
||||||
static b32 clipboard_index(Application_Links *app, i32 clipboard_id, i32 item_index, String *string_out, i32 *required_size_out){return(app->clipboard_index_(app, clipboard_id, item_index, string_out, required_size_out));}
|
static b32 clipboard_index(Application_Links *app, i32 clipboard_id, i32 item_index, String *string_out, i32 *required_size_out){return(app->clipboard_index_(app, clipboard_id, item_index, string_out, required_size_out));}
|
||||||
static Parse_Context_ID create_parse_context(Application_Links *app, Parser_String_And_Type *kw, u32 kw_count, Parser_String_And_Type *pp, u32 pp_count){return(app->create_parse_context_(app, kw, kw_count, pp, pp_count));}
|
static Parse_Context_ID create_parse_context(Application_Links *app, Parser_String_And_Type *kw, u32 kw_count, Parser_String_And_Type *pp, u32 pp_count){return(app->create_parse_context_(app, kw, kw_count, pp, pp_count));}
|
||||||
static i32 get_buffer_count(Application_Links *app){return(app->get_buffer_count_(app));}
|
static i32 get_buffer_count(Application_Links *app){return(app->get_buffer_count_(app));}
|
||||||
static b32 get_buffer_first(Application_Links *app, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_first_(app, access, buffer_id_out));}
|
|
||||||
static b32 get_buffer_next(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_next_(app, buffer_id, access, buffer_id_out));}
|
static b32 get_buffer_next(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_next_(app, buffer_id, access, buffer_id_out));}
|
||||||
static b32 get_buffer_by_name(Application_Links *app, String name, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_by_name_(app, name, access, buffer_id_out));}
|
static b32 get_buffer_by_name(Application_Links *app, String name, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_by_name_(app, name, access, buffer_id_out));}
|
||||||
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 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_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_replace_range(Application_Links *app, Buffer_ID buffer_id, Range range, String string){return(app->buffer_replace_range_(app, buffer_id, range, string));}
|
||||||
|
static b32 buffer_batch_edit(Application_Links *app, Buffer_ID buffer_id, char *str, Buffer_Edit *edits, i32 edit_count){return(app->buffer_batch_edit_(app, buffer_id, str, edits, edit_count));}
|
||||||
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_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));}
|
static b32 buffer_exists(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_exists_(app, buffer_id));}
|
||||||
static b32 buffer_ready(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_ready_(app, buffer_id));}
|
static b32 buffer_ready(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_ready_(app, buffer_id));}
|
||||||
static b32 buffer_get_access_flags(Application_Links *app, Buffer_ID buffer_id, Access_Flag *access_flags_out){return(app->buffer_get_access_flags_(app, buffer_id, access_flags_out));}
|
static b32 buffer_get_access_flags(Application_Links *app, Buffer_ID buffer_id, Access_Flag *access_flags_out){return(app->buffer_get_access_flags_(app, buffer_id, access_flags_out));}
|
||||||
|
|
|
@ -360,12 +360,12 @@ static Command_Metadata fcoder_metacmd_table[234] = {
|
||||||
{ PROC_LINKS(lister__write_character__fixed_list, 0), "lister__write_character__fixed_list", 35, "A lister mode command that handles input for the fixed sure to kill list.", 73, "c:\\4ed\\code\\4coder_lists.cpp", 28, 256 },
|
{ PROC_LINKS(lister__write_character__fixed_list, 0), "lister__write_character__fixed_list", 35, "A lister mode command that handles input for the fixed sure to kill list.", 73, "c:\\4ed\\code\\4coder_lists.cpp", 28, 256 },
|
||||||
{ PROC_LINKS(load_project, 0), "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "c:\\4ed\\code\\4coder_project_commands.cpp", 39, 1085 },
|
{ PROC_LINKS(load_project, 0), "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "c:\\4ed\\code\\4coder_project_commands.cpp", 39, 1085 },
|
||||||
{ PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "c:\\4ed\\code\\4coder_base_commands.cpp", 36, 1319 },
|
{ PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "c:\\4ed\\code\\4coder_base_commands.cpp", 36, 1319 },
|
||||||
{ PROC_LINKS(miblo_decrement_basic, 0), "miblo_decrement_basic", 21, "Decrement an integer under the cursor by one.", 45, "c:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 109 },
|
{ PROC_LINKS(miblo_decrement_basic, 0), "miblo_decrement_basic", 21, "Decrement an integer under the cursor by one.", 45, "c:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 113 },
|
||||||
{ PROC_LINKS(miblo_decrement_time_stamp, 0), "miblo_decrement_time_stamp", 26, "Decrement a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "c:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 383 },
|
{ PROC_LINKS(miblo_decrement_time_stamp, 0), "miblo_decrement_time_stamp", 26, "Decrement a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "c:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 391 },
|
||||||
{ PROC_LINKS(miblo_decrement_time_stamp_minute, 0), "miblo_decrement_time_stamp_minute", 33, "Decrement a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "c:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 395 },
|
{ PROC_LINKS(miblo_decrement_time_stamp_minute, 0), "miblo_decrement_time_stamp_minute", 33, "Decrement a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "c:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 403 },
|
||||||
{ PROC_LINKS(miblo_increment_basic, 0), "miblo_increment_basic", 21, "Increment an integer under the cursor by one.", 45, "c:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 93 },
|
{ PROC_LINKS(miblo_increment_basic, 0), "miblo_increment_basic", 21, "Increment an integer under the cursor by one.", 45, "c:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 97 },
|
||||||
{ PROC_LINKS(miblo_increment_time_stamp, 0), "miblo_increment_time_stamp", 26, "Increment a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "c:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 377 },
|
{ PROC_LINKS(miblo_increment_time_stamp, 0), "miblo_increment_time_stamp", 26, "Increment a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "c:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 385 },
|
||||||
{ PROC_LINKS(miblo_increment_time_stamp_minute, 0), "miblo_increment_time_stamp_minute", 33, "Increment a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "c:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 389 },
|
{ PROC_LINKS(miblo_increment_time_stamp_minute, 0), "miblo_increment_time_stamp_minute", 33, "Increment a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "c:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 397 },
|
||||||
{ PROC_LINKS(mouse_wheel_change_face_size, 0), "mouse_wheel_change_face_size", 28, "Reads the state of the mouse wheel and uses it to either increase or decrease the face size.", 92, "c:\\4ed\\code\\4coder_base_commands.cpp", 36, 634 },
|
{ PROC_LINKS(mouse_wheel_change_face_size, 0), "mouse_wheel_change_face_size", 28, "Reads the state of the mouse wheel and uses it to either increase or decrease the face size.", 92, "c:\\4ed\\code\\4coder_base_commands.cpp", 36, 634 },
|
||||||
{ PROC_LINKS(mouse_wheel_scroll, 0), "mouse_wheel_scroll", 18, "Reads the scroll wheel value from the mouse state and scrolls accordingly.", 74, "c:\\4ed\\code\\4coder_base_commands.cpp", 36, 259 },
|
{ PROC_LINKS(mouse_wheel_scroll, 0), "mouse_wheel_scroll", 18, "Reads the scroll wheel value from the mouse state and scrolls accordingly.", 74, "c:\\4ed\\code\\4coder_base_commands.cpp", 36, 259 },
|
||||||
{ PROC_LINKS(move_down, 0), "move_down", 9, "Moves the cursor down one line.", 31, "c:\\4ed\\code\\4coder_base_commands.cpp", 36, 325 },
|
{ PROC_LINKS(move_down, 0), "move_down", 9, "Moves the cursor down one line.", 31, "c:\\4ed\\code\\4coder_base_commands.cpp", 36, 325 },
|
||||||
|
|
|
@ -491,11 +491,6 @@ query_user_number(Application_Links *app, Query_Bar *bar){
|
||||||
return(query_user_general(app, bar, true));
|
return(query_user_general(app, bar, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
static i32
|
|
||||||
buffer_replace_range_compute_shift(i32 start, i32 end, i32 len){
|
|
||||||
return(len - (end - start));
|
|
||||||
}
|
|
||||||
|
|
||||||
static char
|
static char
|
||||||
buffer_get_char(Application_Links *app, Buffer_ID buffer_id, i32 pos){
|
buffer_get_char(Application_Links *app, Buffer_ID buffer_id, i32 pos){
|
||||||
i32 buffer_size = 0;
|
i32 buffer_size = 0;
|
||||||
|
@ -935,7 +930,7 @@ static void
|
||||||
clear_buffer(Application_Links *app, Buffer_ID buffer_id){
|
clear_buffer(Application_Links *app, Buffer_ID buffer_id){
|
||||||
i32 buffer_size = 0;
|
i32 buffer_size = 0;
|
||||||
buffer_get_size(app, buffer_id, &buffer_size);
|
buffer_get_size(app, buffer_id, &buffer_size);
|
||||||
buffer_replace_range(app, buffer_id, 0, buffer_size, make_lit_string(""));
|
buffer_replace_range(app, buffer_id, make_range(0, buffer_size), make_lit_string(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
@ -1583,7 +1578,7 @@ if_view_has_highlighted_range_delete_range(Application_Links *app, View_ID view_
|
||||||
Range range = get_view_range(&view);
|
Range range = get_view_range(&view);
|
||||||
Buffer_ID buffer = 0;
|
Buffer_ID buffer = 0;
|
||||||
view_get_buffer(app, view.view_id, AccessOpen, &buffer);
|
view_get_buffer(app, view.view_id, AccessOpen, &buffer);
|
||||||
buffer_replace_range(app, buffer, range.min, range.max, make_lit_string(""));
|
buffer_replace_range(app, buffer, range, make_lit_string(""));
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
|
|
|
@ -36,7 +36,7 @@ begin_buffer_insertion(Application_Links *app){
|
||||||
|
|
||||||
static void
|
static void
|
||||||
insert_string__no_buffering(Buffer_Insertion *insertion, String string){
|
insert_string__no_buffering(Buffer_Insertion *insertion, String string){
|
||||||
buffer_replace_range(insertion->app, insertion->buffer, insertion->at, insertion->at, string);
|
buffer_replace_range(insertion->app, insertion->buffer, make_range(insertion->at), string);
|
||||||
insertion->at += string.size;
|
insertion->at += string.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,11 @@ get_numeric_string_at_cursor(Application_Links *app, Buffer_ID buffer, i32 start
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Miblo_Number_Info{
|
struct Miblo_Number_Info{
|
||||||
i32 start, end;
|
union{
|
||||||
|
Range range;
|
||||||
|
i32 start;
|
||||||
|
i32 end;
|
||||||
|
};
|
||||||
i32 x;
|
i32 x;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101,7 +105,7 @@ CUSTOM_DOC("Increment an integer under the cursor by one.")
|
||||||
char str_space[1024];
|
char str_space[1024];
|
||||||
String str = make_fixed_width_string(str_space);
|
String str = make_fixed_width_string(str_space);
|
||||||
int_to_str(&str, number.x + 1);
|
int_to_str(&str, number.x + 1);
|
||||||
buffer_replace_range(app, buffer, number.start, number.end, str);
|
buffer_replace_range(app, buffer, number.range, str);
|
||||||
view_set_cursor(app, &view, seek_pos(number.start + str.size - 1), 1);
|
view_set_cursor(app, &view, seek_pos(number.start + str.size - 1), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +121,7 @@ CUSTOM_DOC("Decrement an integer under the cursor by one.")
|
||||||
char str_space[1024];
|
char str_space[1024];
|
||||||
String str = make_fixed_width_string(str_space);
|
String str = make_fixed_width_string(str_space);
|
||||||
int_to_str(&str, number.x - 1);
|
int_to_str(&str, number.x - 1);
|
||||||
buffer_replace_range(app, buffer, number.start, number.end, str);
|
buffer_replace_range(app, buffer, number.range, str);
|
||||||
view_set_cursor(app, &view, seek_pos(number.start + str.size - 1), 1);
|
view_set_cursor(app, &view, seek_pos(number.start + str.size - 1), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,7 +278,11 @@ timestamp_to_str(String *dest, Miblo_Timestamp t){
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Miblo_Timestamp_Info{
|
struct Miblo_Timestamp_Info{
|
||||||
i32 start, end;
|
union{
|
||||||
|
Range range;
|
||||||
|
i32 start;
|
||||||
|
i32 end;
|
||||||
|
};
|
||||||
Miblo_Timestamp time;
|
Miblo_Timestamp time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -369,7 +377,7 @@ miblo_time_stamp_alter(Application_Links *app, i32 unit_type, i32 amt){
|
||||||
|
|
||||||
Miblo_Timestamp inc_timestamp = increment_timestamp(timestamp.time, unit_type, amt);
|
Miblo_Timestamp inc_timestamp = increment_timestamp(timestamp.time, unit_type, amt);
|
||||||
timestamp_to_str(&str, inc_timestamp);
|
timestamp_to_str(&str, inc_timestamp);
|
||||||
buffer_replace_range(app, buffer, timestamp.start, timestamp.end, str);
|
buffer_replace_range(app, buffer, timestamp.range, str);
|
||||||
view_set_cursor(app, &view, seek_pos(timestamp.start + str.size - 1), 1);
|
view_set_cursor(app, &view, seek_pos(timestamp.start + str.size - 1), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -457,13 +457,13 @@ place_begin_and_end_on_own_lines(Application_Links *app, Partition *scratch, cha
|
||||||
edits[1].start = range.max;
|
edits[1].start = range.max;
|
||||||
edits[1].end = range.max;
|
edits[1].end = range.max;
|
||||||
|
|
||||||
buffer_batch_edit(app, buffer, str, str_size, edits, 2, BatchEdit_Normal);
|
buffer_batch_edit(app, buffer, str, edits, 2);
|
||||||
|
|
||||||
view_set_cursor(app, &view, seek_pos(cursor_pos), true);
|
view_set_cursor(app, &view, seek_pos(cursor_pos), true);
|
||||||
view_set_mark(app, &view, seek_pos(mark_pos));
|
view_set_mark(app, &view, seek_pos(mark_pos));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
buffer_replace_range(app, buffer, range.min, range.max, make_string(str, str_size));
|
buffer_replace_range(app, buffer, range, make_string(str, str_size));
|
||||||
i32 center_pos = range.min + begin_len + 1;
|
i32 center_pos = range.min + begin_len + 1;
|
||||||
view_set_cursor(app, &view, seek_pos(center_pos), true);
|
view_set_cursor(app, &view, seek_pos(center_pos), true);
|
||||||
view_set_mark(app, &view, seek_pos(center_pos));
|
view_set_mark(app, &view, seek_pos(center_pos));
|
||||||
|
@ -515,7 +515,7 @@ CUSTOM_DOC("Deletes the braces surrounding the currently selected scope. Leaves
|
||||||
edits[1].start = bottom - 1;
|
edits[1].start = bottom - 1;
|
||||||
edits[1].end = bottom - 1 + bottom_len;
|
edits[1].end = bottom - 1 + bottom_len;
|
||||||
|
|
||||||
buffer_batch_edit(app, buffer, 0, 0, edits, 2, BatchEdit_Normal);
|
buffer_batch_edit(app, buffer, 0, edits, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -780,7 +780,7 @@ CUSTOM_DOC("If a scope is currently selected, and a statement or block statement
|
||||||
edits[1].start = range.start;
|
edits[1].start = range.start;
|
||||||
edits[1].end = range.end;
|
edits[1].end = range.end;
|
||||||
|
|
||||||
buffer_batch_edit(app, buffer, edit_str, edit_len, edits, 2, BatchEdit_Normal);
|
buffer_batch_edit(app, buffer, edit_str, edits, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end_temp_memory(temp);
|
end_temp_memory(temp);
|
||||||
|
|
|
@ -592,7 +592,7 @@ static void
|
||||||
buffered_print_flush(Application_Links *app, Buffered_Printing *out){
|
buffered_print_flush(Application_Links *app, Buffered_Printing *out){
|
||||||
i32 write_size = out->part->pos - out->temp.pos;
|
i32 write_size = out->part->pos - out->temp.pos;
|
||||||
char *str = out->part->base + out->temp.pos;
|
char *str = out->part->base + out->temp.pos;
|
||||||
buffer_replace_range(app, out->buffer, out->pos, out->pos, make_string(str, write_size));
|
buffer_replace_range(app, out->buffer, make_range(out->pos), make_string(str, write_size));
|
||||||
out->pos += write_size;
|
out->pos += write_size;
|
||||||
end_temp_memory(out->temp);
|
end_temp_memory(out->temp);
|
||||||
}
|
}
|
||||||
|
@ -1011,7 +1011,7 @@ CUSTOM_DOC("Iteratively tries completing the word to the left of the cursor with
|
||||||
buffer_read_range(app, match.buffer, match.start, match.end, spare);
|
buffer_read_range(app, match.buffer, match.start, match.end, spare);
|
||||||
|
|
||||||
if (search_hit_add(&global_heap, &complete_state.hits, &complete_state.str, spare, match_size)){
|
if (search_hit_add(&global_heap, &complete_state.hits, &complete_state.str, spare, match_size)){
|
||||||
buffer_replace_range(app, buffer, word_start, word_end, make_string(spare, match_size));
|
buffer_replace_range(app, buffer, make_range(word_start, word_end), make_string(spare, match_size));
|
||||||
view_set_cursor(app, &view, seek_pos(word_start + match_size), true);
|
view_set_cursor(app, &view, seek_pos(word_start + match_size), true);
|
||||||
|
|
||||||
complete_state.word_end = word_start + match_size;
|
complete_state.word_end = word_start + match_size;
|
||||||
|
@ -1031,7 +1031,7 @@ CUSTOM_DOC("Iteratively tries completing the word to the left of the cursor with
|
||||||
|
|
||||||
match_size = word.size;
|
match_size = word.size;
|
||||||
char *str = word.str;
|
char *str = word.str;
|
||||||
buffer_replace_range(app, buffer, word_start, word_end, make_string(str, match_size));
|
buffer_replace_range(app, buffer, make_range(word_start, word_end), make_string(str, match_size));
|
||||||
view_set_cursor(app, &view, seek_pos(word_start + match_size), true);
|
view_set_cursor(app, &view, seek_pos(word_start + match_size), true);
|
||||||
|
|
||||||
complete_state.word_end = word_start + match_size;
|
complete_state.word_end = word_start + match_size;
|
||||||
|
|
|
@ -1021,7 +1021,7 @@ current_view_boundary_delete(Application_Links *app, i32 dir, u32 flags){
|
||||||
view_get_buffer(app, view.view_id, AccessOpen, &buffer_id);
|
view_get_buffer(app, view.view_id, AccessOpen, &buffer_id);
|
||||||
Range range = view_buffer_boundary_range(app, &view, buffer_id, dir, flags);
|
Range range = view_buffer_boundary_range(app, &view, buffer_id, dir, flags);
|
||||||
String zero = {};
|
String zero = {};
|
||||||
buffer_replace_range(app, buffer_id, range.min, range.max, zero);
|
buffer_replace_range(app, buffer_id, range, zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1031,7 +1031,7 @@ current_view_snipe_delete(Application_Links *app, i32 dir, u32 flags){
|
||||||
view_get_buffer(app, view.view_id, AccessOpen, &buffer_id);
|
view_get_buffer(app, view.view_id, AccessOpen, &buffer_id);
|
||||||
Range range = view_buffer_snipe_range(app, &view, buffer_id, dir, flags);
|
Range range = view_buffer_snipe_range(app, &view, buffer_id, dir, flags);
|
||||||
String zero = {};
|
String zero = {};
|
||||||
buffer_replace_range(app, buffer_id, range.min, range.max, zero);
|
buffer_replace_range(app, buffer_id, range, zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
17
4ed.cpp
17
4ed.cpp
|
@ -58,14 +58,8 @@ internal void
|
||||||
output_file_append(System_Functions *system, Models *models, Editing_File *file, String value){
|
output_file_append(System_Functions *system, Models *models, Editing_File *file, String value){
|
||||||
if (!file->is_dummy){
|
if (!file->is_dummy){
|
||||||
i32 end = buffer_size(&file->state.buffer);
|
i32 end = buffer_size(&file->state.buffer);
|
||||||
Edit edit = {};
|
|
||||||
edit.str = value.str;
|
|
||||||
edit.length = value.size;
|
|
||||||
edit.range.first = end;
|
|
||||||
edit.range.one_past_last = end;
|
|
||||||
|
|
||||||
Edit_Behaviors behaviors = {};
|
Edit_Behaviors behaviors = {};
|
||||||
edit_single(system, models, file, edit, behaviors);
|
edit_single(system, models, file, make_range(end), value, behaviors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -919,12 +913,11 @@ App_Init_Sig(app_init){
|
||||||
*init_files[i].ptr = file;
|
*init_files[i].ptr = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File_Attributes attributes = {};
|
||||||
|
file_create_from_string(system, models, file, make_lit_string(""), attributes);
|
||||||
if (init_files[i].read_only){
|
if (init_files[i].read_only){
|
||||||
init_read_only_file(system, models, file);
|
file->settings.read_only = true;
|
||||||
}
|
history_free(&models->mem.heap, &file->state.history);
|
||||||
else{
|
|
||||||
File_Attributes attributes = {};
|
|
||||||
init_normal_file(system, models, 0, 0, attributes, file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file->settings.never_kill = true;
|
file->settings.never_kill = true;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
57
4ed_cli.cpp
57
4ed_cli.cpp
|
@ -89,5 +89,62 @@ child_process_lookup_return_code(Child_Process_Container *container, Child_Proce
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
child_process_call(Models *models, System_Functions *system, String path, String command, Child_Process_ID *id_out){
|
||||||
|
b32 result = false;
|
||||||
|
char *path_cstr = 0;
|
||||||
|
char *command_cstr = 0;
|
||||||
|
if (terminate_with_null(&path)){
|
||||||
|
path_cstr = path.str;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
String s = string_push_copy(&models->mem.part, path);
|
||||||
|
path_cstr = s.str;
|
||||||
|
}
|
||||||
|
if (terminate_with_null(&command)){
|
||||||
|
command_cstr = command.str;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
String s = string_push_copy(&models->mem.part, command);
|
||||||
|
command_cstr = s.str;
|
||||||
|
}
|
||||||
|
CLI_Handles cli_handles = {};
|
||||||
|
if (system->cli_call(path_cstr, command_cstr, &cli_handles)){
|
||||||
|
Child_Process_And_ID new_process = child_process_alloc_new(models, &models->child_processes);
|
||||||
|
*id_out = new_process.id;
|
||||||
|
new_process.process->cli = cli_handles;
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
child_process_set_target_buffer(Models *models, Child_Process *child_process, Editing_File *file, Child_Process_Set_Target_Flags flags){
|
||||||
|
b32 result = false;
|
||||||
|
b32 fail_if_process_has_buffer = HasFlag(flags, ChildProcessSet_FailIfProcessAlreadyAttachedToABuffer);
|
||||||
|
b32 fail_if_buffer_has_process = HasFlag(flags, ChildProcessSet_FailIfBufferAlreadyAttachedToAProcess);
|
||||||
|
b32 process_has_buffer = (child_process->out_file != 0);
|
||||||
|
b32 buffer_has_process = (file->state.attached_child_process != 0);
|
||||||
|
b32 fail = ((process_has_buffer && fail_if_process_has_buffer) ||
|
||||||
|
(buffer_has_process && fail_if_buffer_has_process));
|
||||||
|
if (!fail){
|
||||||
|
if (process_has_buffer){
|
||||||
|
child_process->out_file->state.attached_child_process = 0;
|
||||||
|
}
|
||||||
|
if (buffer_has_process){
|
||||||
|
Child_Process *attached_child_process = child_process_from_id(&models->child_processes, file->state.attached_child_process);
|
||||||
|
if (attached_child_process != 0){
|
||||||
|
attached_child_process->out_file = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
child_process->out_file = file;
|
||||||
|
file->state.attached_child_process = child_process->id;
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
||||||
|
|
190
4ed_edit.cpp
190
4ed_edit.cpp
|
@ -230,7 +230,12 @@ edit_fix_markers(System_Functions *system, Models *models, Editing_File *file, E
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
edit_single(System_Functions *system, Models *models, Editing_File *file, Edit edit, Edit_Behaviors behaviors){
|
edit_single(System_Functions *system, Models *models, Editing_File *file, Range range, String string, Edit_Behaviors behaviors){
|
||||||
|
Edit edit = {};
|
||||||
|
edit.str = string.str;
|
||||||
|
edit.length = string.size;
|
||||||
|
edit.range = range;
|
||||||
|
|
||||||
Mem_Options *mem = &models->mem;
|
Mem_Options *mem = &models->mem;
|
||||||
Heap *heap = &mem->heap;
|
Heap *heap = &mem->heap;
|
||||||
Partition *part = &mem->part;
|
Partition *part = &mem->part;
|
||||||
|
@ -313,13 +318,34 @@ edit_single(System_Functions *system, Models *models, Editing_File *file, Edit e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal b32
|
||||||
edit_single(System_Functions *system, Models *models, Editing_File *file, Range range, String string, Edit_Behaviors behaviors){
|
edit_batch(System_Functions *system, Models *models, Editing_File *file, char *str, Buffer_Edit *edits, i32 edit_count, Edit_Behaviors behaviors){
|
||||||
Edit edit = {};
|
b32 result = true;
|
||||||
edit.str = string.str;
|
if (edit_count > 0){
|
||||||
edit.length = string.size;
|
global_history_adjust_edit_grouping_counter(&models->global_history, 1);
|
||||||
edit.range = range;
|
|
||||||
edit_single(system, models, file, edit, behaviors);
|
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){
|
||||||
|
String insert_string = make_string(str + edit_in->str_start, edit_in->len);
|
||||||
|
Range edit_range = {edit_in->start, edit_in->end};
|
||||||
|
edit_range.first += shift;
|
||||||
|
edit_range.one_past_last += shift;
|
||||||
|
i32 size = buffer_size(&file->state.buffer);
|
||||||
|
if (0 <= edit_range.first && edit_range.first <= edit_range.one_past_last && edit_range.one_past_last <= size){
|
||||||
|
edit_single(system, models, file, edit_range, insert_string, behaviors);
|
||||||
|
shift += replace_range_compute_shift(edit_range, insert_string.size);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
result = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
global_history_adjust_edit_grouping_counter(&models->global_history, -1);
|
||||||
|
}
|
||||||
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
|
@ -341,12 +367,9 @@ edit__apply_record_forward(System_Functions *system, Models *models, Editing_Fil
|
||||||
switch (record->kind){
|
switch (record->kind){
|
||||||
case RecordKind_Single:
|
case RecordKind_Single:
|
||||||
{
|
{
|
||||||
Edit edit = {};
|
String str = make_string(record->single.str_forward, record->single.length_forward);
|
||||||
edit.str = record->single.str_forward;
|
Range range = {record->single.first, record->single.first + record->single.length_backward};
|
||||||
edit.length = record->single.length_forward;
|
edit_single(system, models, file, range, str, behaviors_prototype);
|
||||||
edit.range.first = record->single.first;
|
|
||||||
edit.range.one_past_last = edit.range.first + record->single.length_backward;
|
|
||||||
edit_single(system, models, file, edit, behaviors_prototype);
|
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case RecordKind_Group:
|
case RecordKind_Group:
|
||||||
|
@ -375,12 +398,9 @@ edit__apply_record_backward(System_Functions *system, Models *models, Editing_Fi
|
||||||
switch (record->kind){
|
switch (record->kind){
|
||||||
case RecordKind_Single:
|
case RecordKind_Single:
|
||||||
{
|
{
|
||||||
Edit edit = {};
|
String str = make_string(record->single.str_backward, record->single.length_backward);
|
||||||
edit.str = record->single.str_backward;
|
Range range = {record->single.first, record->single.first + record->single.length_forward};
|
||||||
edit.length = record->single.length_backward;
|
edit_single(system, models, file, range, str, behaviors_prototype);
|
||||||
edit.range.first = record->single.first;
|
|
||||||
edit.range.one_past_last = edit.range.first + record->single.length_forward;
|
|
||||||
edit_single(system, models, file, edit, behaviors_prototype);
|
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case RecordKind_Group:
|
case RecordKind_Group:
|
||||||
|
@ -436,5 +456,135 @@ edit_change_current_history_state(System_Functions *system, Models *models, Edit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
internal Editing_File*
|
||||||
|
create_file(Models *models, String file_name, Buffer_Create_Flag flags){
|
||||||
|
Editing_File *result = 0;
|
||||||
|
|
||||||
|
if (file_name.size > 0){
|
||||||
|
System_Functions *system = models->system;
|
||||||
|
Working_Set *working_set = &models->working_set;
|
||||||
|
Heap *heap = &models->mem.heap;
|
||||||
|
Partition *part = &models->mem.part;
|
||||||
|
|
||||||
|
Temp_Memory temp = begin_temp_memory(part);
|
||||||
|
|
||||||
|
Editing_File *file = 0;
|
||||||
|
b32 do_empty_buffer = false;
|
||||||
|
Editing_File_Name canon = {};
|
||||||
|
b32 has_canon_name = false;
|
||||||
|
b32 buffer_is_for_new_file = false;
|
||||||
|
|
||||||
|
// NOTE(allen): Try to get the file by canon name.
|
||||||
|
if ((flags & BufferCreate_NeverAttachToFile) == 0){
|
||||||
|
if (get_canon_name(system, file_name, &canon)){
|
||||||
|
has_canon_name = true;
|
||||||
|
file = working_set_contains_canon(working_set, canon.name);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
do_empty_buffer = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE(allen): Try to get the file by buffer name.
|
||||||
|
if ((flags & BufferCreate_MustAttachToFile) == 0){
|
||||||
|
if (file == 0){
|
||||||
|
file = working_set_contains_name(working_set, file_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE(allen): If there is still no file, create a new buffer.
|
||||||
|
if (file == 0){
|
||||||
|
Plat_Handle handle = {};
|
||||||
|
|
||||||
|
// NOTE(allen): Figure out whether this is a new file, or an existing file.
|
||||||
|
if (!do_empty_buffer){
|
||||||
|
if ((flags & BufferCreate_AlwaysNew) != 0){
|
||||||
|
do_empty_buffer = true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (!system->load_handle(canon.name.str, &handle)){
|
||||||
|
do_empty_buffer = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (do_empty_buffer){
|
||||||
|
if (has_canon_name){
|
||||||
|
buffer_is_for_new_file = true;
|
||||||
|
}
|
||||||
|
if (!HasFlag(flags, BufferCreate_NeverNew)){
|
||||||
|
file = working_set_alloc_always(working_set, heap, &models->lifetime_allocator);
|
||||||
|
if (file != 0){
|
||||||
|
if (has_canon_name){
|
||||||
|
file_bind_file_name(system, heap, working_set, file, canon.name);
|
||||||
|
}
|
||||||
|
buffer_bind_name(models, heap, part, working_set, file, front_of_directory(file_name));
|
||||||
|
File_Attributes attributes = {};
|
||||||
|
file_create_from_string(system, models, file, make_lit_string(""), attributes);
|
||||||
|
result = file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
File_Attributes attributes = system->load_attributes(handle);
|
||||||
|
b32 in_heap_mem = false;
|
||||||
|
char *buffer = push_array(part, char, (i32)attributes.size);
|
||||||
|
|
||||||
|
if (buffer == 0){
|
||||||
|
buffer = heap_array(heap, char, (i32)attributes.size);
|
||||||
|
Assert(buffer != 0);
|
||||||
|
in_heap_mem = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (system->load_file(handle, buffer, (i32)attributes.size)){
|
||||||
|
system->load_close(handle);
|
||||||
|
file = working_set_alloc_always(working_set, heap, &models->lifetime_allocator);
|
||||||
|
if (file != 0){
|
||||||
|
file_bind_file_name(system, heap, working_set, file, canon.name);
|
||||||
|
buffer_bind_name(models, heap, part, working_set, file, front_of_directory(file_name));
|
||||||
|
file_create_from_string(system, models, file, make_string(buffer, (i32)attributes.size), attributes);
|
||||||
|
result = file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
system->load_close(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_heap_mem){
|
||||||
|
heap_free(heap, buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
result = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file != 0 && HasFlag(flags, BufferCreate_JustChangedFile)){
|
||||||
|
file->state.ignore_behind_os = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file != 0 && HasFlag(flags, BufferCreate_AlwaysNew)){
|
||||||
|
i32 size = buffer_size(&file->state.buffer);
|
||||||
|
if (size > 0){
|
||||||
|
Edit_Behaviors behaviors = {};
|
||||||
|
edit_single(system, models, file, make_range(0, size), make_lit_string(""), behaviors);
|
||||||
|
if (has_canon_name){
|
||||||
|
buffer_is_for_new_file = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file != 0 && buffer_is_for_new_file && !HasFlag(flags, BufferCreate_SuppressNewFileHook) && models->hook_new_file != 0){
|
||||||
|
models->hook_new_file(&models->app_links, file->id.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
end_temp_memory(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
||||||
|
|
33
4ed_file.cpp
33
4ed_file.cpp
|
@ -421,7 +421,7 @@ file_allocate_wrap_positions_as_needed(Heap *heap, Editing_File *file, i32 min_l
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
file_create_from_string(System_Functions *system, Models *models, Editing_File *file, String val, File_Attributes attributes, u32 flags){
|
file_create_from_string(System_Functions *system, Models *models, Editing_File *file, String val, File_Attributes attributes){
|
||||||
Heap *heap = &models->mem.heap;
|
Heap *heap = &models->mem.heap;
|
||||||
Partition *part = &models->mem.part;
|
Partition *part = &models->mem.part;
|
||||||
Application_Links *app_links = &models->app_links;
|
Application_Links *app_links = &models->app_links;
|
||||||
|
@ -463,11 +463,7 @@ file_create_from_string(System_Functions *system, Models *models, Editing_File *
|
||||||
//adjust_views_looking_at_files_to_new_cursor(system, models, file);
|
//adjust_views_looking_at_files_to_new_cursor(system, models, file);
|
||||||
|
|
||||||
file->lifetime_object = lifetime_alloc_object(heap, &models->lifetime_allocator, DynamicWorkspace_Buffer, file);
|
file->lifetime_object = lifetime_alloc_object(heap, &models->lifetime_allocator, DynamicWorkspace_Buffer, file);
|
||||||
|
history_init(&models->app_links, &file->state.history);
|
||||||
file->settings.read_only = ((flags & FileCreateFlag_ReadOnly) != 0);
|
|
||||||
if (!file->settings.read_only){
|
|
||||||
history_init(&models->app_links, &file->state.history);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(allen): do(cleanup the create and settings dance)
|
// TODO(allen): do(cleanup the create and settings dance)
|
||||||
// Right now we have this thing where we call hook_open_file, which may or may not
|
// Right now we have this thing where we call hook_open_file, which may or may not
|
||||||
|
@ -521,19 +517,6 @@ file_free(System_Functions *system, Heap *heap, Lifetime_Allocator *lifetime_all
|
||||||
file_unmark_edit_finished(file);
|
file_unmark_edit_finished(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
|
||||||
init_normal_file(System_Functions *system, Models *models, char *buffer, i32 size, File_Attributes attributes, Editing_File *file){
|
|
||||||
String val = make_string(buffer, size);
|
|
||||||
file_create_from_string(system, models, file, val, attributes, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void
|
|
||||||
init_read_only_file(System_Functions *system, Models *models, Editing_File *file){
|
|
||||||
String val = {};
|
|
||||||
File_Attributes attributes = {};
|
|
||||||
file_create_from_string(system, models, file, val, attributes, FileCreateFlag_ReadOnly);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
internal i32
|
internal i32
|
||||||
|
@ -541,12 +524,20 @@ file_get_current_record_index(Editing_File *file){
|
||||||
return(file->state.current_record_index);
|
return(file->state.current_record_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
|
|
||||||
internal b32
|
internal b32
|
||||||
file_tokens_are_ready(Editing_File *file){
|
file_tokens_are_ready(Editing_File *file){
|
||||||
return(file->state.token_array.tokens != 0 && file->state.tokens_complete && !file->state.still_lexing);
|
return(file->state.token_array.tokens != 0 && file->state.tokens_complete && !file->state.still_lexing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal Managed_Scope
|
||||||
|
file_get_managed_scope(Editing_File *file){
|
||||||
|
Managed_Scope scope = 0;
|
||||||
|
if (file != 0){
|
||||||
|
Assert(file->lifetime_object != 0);
|
||||||
|
scope = (Managed_Scope)file->lifetime_object->workspace.scope_id;
|
||||||
|
}
|
||||||
|
return(scope);
|
||||||
|
}
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
||||||
|
|
|
@ -32,14 +32,6 @@ struct Record{
|
||||||
i32 first;
|
i32 first;
|
||||||
} single;
|
} single;
|
||||||
|
|
||||||
struct{
|
|
||||||
Buffer_Batch_Edit_Type type;
|
|
||||||
i32 count;
|
|
||||||
char *str_base_forward;
|
|
||||||
char *str_base_backward;
|
|
||||||
Record_Batch_Slot *batch_records;
|
|
||||||
} batch;
|
|
||||||
|
|
||||||
struct{
|
struct{
|
||||||
Node children;
|
Node children;
|
||||||
i32 count;
|
i32 count;
|
||||||
|
|
|
@ -455,5 +455,17 @@ panel_get_id(Layout *layout, Panel *panel){
|
||||||
return(id);
|
return(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
internal Panel*
|
||||||
|
imp_get_panel(Models *models, Panel_ID panel_id){
|
||||||
|
Layout *layout = &models->layout;
|
||||||
|
Panel *panel = layout->panel_first + panel_id - 1;
|
||||||
|
if (!(layout->panel_first <= panel && panel < layout->panel_one_past_last)){
|
||||||
|
panel = 0;
|
||||||
|
}
|
||||||
|
return(panel);
|
||||||
|
}
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
||||||
|
|
68
4ed_view.cpp
68
4ed_view.cpp
|
@ -1195,26 +1195,6 @@ render_loaded_file_in_view__inner(Models *models, Render_Target *target, View *v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
internal void
|
|
||||||
dont_do_core_render(Application_Links *app){}
|
|
||||||
|
|
||||||
internal void
|
|
||||||
do_core_render(Application_Links *app){
|
|
||||||
Models *models = (Models*)app->cmd_context;
|
|
||||||
Render_Target *target = models->target;
|
|
||||||
View *view = models->render_view;
|
|
||||||
i32_Rect rect = models->render_buffer_rect;
|
|
||||||
Full_Cursor render_cursor = models->render_cursor;
|
|
||||||
Range on_screen_range = models->render_range;
|
|
||||||
Buffer_Render_Item *items = models->render_items;
|
|
||||||
i32 item_count = models->render_item_count;
|
|
||||||
draw_push_clip(target, rect);
|
|
||||||
render_loaded_file_in_view__inner(models, target, view, rect, render_cursor, on_screen_range, items, item_count);
|
|
||||||
draw_pop_clip(target);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
internal Full_Cursor
|
internal Full_Cursor
|
||||||
file_get_render_cursor(System_Functions *system, Editing_File *file, f32 scroll_y){
|
file_get_render_cursor(System_Functions *system, Editing_File *file, f32 scroll_y){
|
||||||
Full_Cursor result = {};
|
Full_Cursor result = {};
|
||||||
|
@ -1248,36 +1228,30 @@ view_get_render_cursor_target(System_Functions *system, View *view){
|
||||||
return(view_get_render_cursor(system, view, scroll_y));
|
return(view_get_render_cursor(system, view, scroll_y));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
internal void
|
internal void
|
||||||
view_call_render_caller(Models *models, Render_Target *target, View *view,
|
view_quit_ui(System_Functions *system, Models *models, View *view){
|
||||||
i32_Rect rect, Full_Cursor render_cursor, Range on_screen_range, Buffer_Render_Item *items, i32 item_count, Render_Callback *core_render){
|
Assert(view != 0);
|
||||||
if (models->render_caller != 0){
|
view->ui_mode = false;
|
||||||
View_ID view_id = view_get_id(&models->live_set, view);
|
if (view->ui_quit != 0){
|
||||||
models->render_view = view;
|
view->ui_quit(&models->app_links, view_get_id(&models->live_set, view));
|
||||||
models->render_view_rect = view->panel->rect_inner;
|
|
||||||
models->render_buffer_rect = rect;
|
|
||||||
models->render_cursor = render_cursor;
|
|
||||||
models->render_range = on_screen_range;
|
|
||||||
models->render_items = items;
|
|
||||||
models->render_item_count = item_count;
|
|
||||||
|
|
||||||
Frame_Info frame = {};
|
|
||||||
frame.index = target->frame_index;
|
|
||||||
frame.literal_dt = target->literal_dt;
|
|
||||||
frame.animation_dt = target->animation_dt;
|
|
||||||
#if 0
|
|
||||||
Render_Parameters params = {};
|
|
||||||
params.view_id = view_id;
|
|
||||||
params.on_screen_range = on_screen_range;
|
|
||||||
params.buffer_region = rect;
|
|
||||||
params.do_core_render = core_render;
|
|
||||||
#endif
|
|
||||||
models->render_caller(&models->app_links, frame);
|
|
||||||
models->render_view = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
internal View*
|
||||||
|
imp_get_view(Models *models, View_ID view_id){
|
||||||
|
Live_Views *live_set = &models->live_set;
|
||||||
|
View *view = 0;
|
||||||
|
view_id -= 1;
|
||||||
|
if (0 <= view_id && view_id < live_set->max){
|
||||||
|
view = live_set->views + view_id;
|
||||||
|
if (!view->in_use){
|
||||||
|
view = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(view);
|
||||||
|
}
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
||||||
|
|
|
@ -147,10 +147,6 @@ struct View_Step_Result{
|
||||||
b32 consume_esc;
|
b32 consume_esc;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum{
|
|
||||||
FileCreateFlag_ReadOnly = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Render_Marker_Brush{
|
struct Render_Marker_Brush{
|
||||||
b8 color_noop;
|
b8 color_noop;
|
||||||
b8 text_color_noop;
|
b8 text_color_noop;
|
||||||
|
|
|
@ -120,27 +120,23 @@ internal Editing_File*
|
||||||
working_set_index(Working_Set *working_set, Buffer_Slot_ID id){
|
working_set_index(Working_Set *working_set, Buffer_Slot_ID id){
|
||||||
Editing_File *result = 0;
|
Editing_File *result = 0;
|
||||||
File_Array *array = 0;
|
File_Array *array = 0;
|
||||||
|
|
||||||
if (id.part[1] >= 0 && id.part[1] < working_set->array_count){
|
if (id.part[1] >= 0 && id.part[1] < working_set->array_count){
|
||||||
array = working_set->file_arrays + id.part[1];
|
array = working_set->file_arrays + id.part[1];
|
||||||
if (id.part[0] >= 0 && id.part[0] < array->size){
|
if (id.part[0] >= 0 && id.part[0] < array->size){
|
||||||
result = array->files + id.part[0];
|
result = array->files + id.part[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Editing_File*
|
internal Editing_File*
|
||||||
working_set_index(Working_Set *working_set, i32 id){
|
working_set_index(Working_Set *working_set, i32 id){
|
||||||
Editing_File *result = working_set_index(working_set, to_file_id(id));
|
return(working_set_index(working_set, to_file_id(id)));
|
||||||
return(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Editing_File*
|
internal Editing_File*
|
||||||
working_set_get_active_file(Working_Set *working_set, Buffer_Slot_ID id){
|
working_set_get_active_file(Working_Set *working_set, Buffer_Slot_ID id){
|
||||||
Editing_File *result = 0;
|
Editing_File *result = working_set_index(working_set, id);
|
||||||
result = working_set_index(working_set, id);
|
|
||||||
if (result != 0 && result->is_dummy){
|
if (result != 0 && result->is_dummy){
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
|
@ -148,9 +144,8 @@ working_set_get_active_file(Working_Set *working_set, Buffer_Slot_ID id){
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Editing_File*
|
internal Editing_File*
|
||||||
working_set_get_active_file(Working_Set *working_set, i32 id){
|
working_set_get_active_file(Working_Set *working_set, Buffer_ID id){
|
||||||
Editing_File *result= working_set_get_active_file(working_set, to_file_id(id));
|
return(working_set_get_active_file(working_set, to_file_id(id)));
|
||||||
return(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
|
@ -269,8 +264,7 @@ working_set_canon_remove(Working_Set *working_set, String name){
|
||||||
|
|
||||||
internal Editing_File*
|
internal Editing_File*
|
||||||
working_set_contains_name(Working_Set *working_set, String name){
|
working_set_contains_name(Working_Set *working_set, String name){
|
||||||
Editing_File *result = working_set_contains_basic(working_set, &working_set->name_table, name);
|
return(working_set_contains_basic(working_set, &working_set->name_table, name));
|
||||||
return(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal b32
|
internal b32
|
||||||
|
@ -284,35 +278,16 @@ working_set_remove_name(Working_Set *working_set, String name){
|
||||||
working_set_remove_basic(working_set, &working_set->name_table, name);
|
working_set_remove_basic(working_set, &working_set->name_table, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO(allen): Pick better first options.
|
|
||||||
internal Editing_File*
|
internal Editing_File*
|
||||||
working_set_lookup_file(Working_Set *working_set, String string){
|
get_file_from_identifier(System_Functions *system, Working_Set *working_set, Buffer_Identifier buffer){
|
||||||
Editing_File *file = 0;
|
Editing_File *file = 0;
|
||||||
|
if (buffer.id != 0){
|
||||||
// TODO(allen): use the name table for this
|
file = working_set_get_active_file(working_set, buffer.id);
|
||||||
for (Node *node = working_set->used_sentinel.next;
|
|
||||||
node != &working_set->used_sentinel;
|
|
||||||
node = node->next){
|
|
||||||
Editing_File *nfile = CastFromMember(Editing_File, main_chain_node, node);
|
|
||||||
if (string.size == 0 || match_ss(string, nfile->unique_name.name)){
|
|
||||||
file = nfile;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (buffer.name != 0){
|
||||||
if (file == 0){
|
String name = make_string(buffer.name, buffer.name_len);
|
||||||
for (Node *node = working_set->used_sentinel.next;
|
file = working_set_contains_name(working_set, name);
|
||||||
node != &working_set->used_sentinel;
|
|
||||||
node = node->next){
|
|
||||||
Editing_File *nfile = CastFromMember(Editing_File, main_chain_node, node);
|
|
||||||
if (string.size == 0 || has_substr_s(nfile->unique_name.name, string)){
|
|
||||||
file = nfile;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(file);
|
return(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,6 +548,23 @@ file_touch(Working_Set *working_set, Editing_File *file){
|
||||||
dll_insert(&working_set->used_sentinel, &file->main_chain_node);
|
dll_insert(&working_set->used_sentinel, &file->main_chain_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal Editing_File*
|
||||||
|
file_get_next(Working_Set *working_set, Editing_File *file){
|
||||||
|
if (file != 0){
|
||||||
|
file = CastFromMember(Editing_File, main_chain_node, file->main_chain_node.next);
|
||||||
|
if (file == CastFromMember(Editing_File, main_chain_node, &working_set->used_sentinel)){
|
||||||
|
file = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (working_set->file_count > 0){
|
||||||
|
Node *node = working_set->used_sentinel.next;
|
||||||
|
file = CastFromMember(Editing_File, main_chain_node, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(file);
|
||||||
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
file_mark_edit_finished(Working_Set *working_set, Editing_File *file){
|
file_mark_edit_finished(Working_Set *working_set, Editing_File *file){
|
||||||
// TODO(allen): do(propogate do_not_mark_edits down the edit pipeline to here)
|
// TODO(allen): do(propogate do_not_mark_edits down the edit pipeline to here)
|
||||||
|
@ -595,5 +587,17 @@ file_unmark_edit_finished(Editing_File *file){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
internal Editing_File*
|
||||||
|
imp_get_file(Models *models, Buffer_ID buffer_id){
|
||||||
|
Working_Set *working_set = &models->working_set;
|
||||||
|
Editing_File *file = working_set_get_active_file(working_set, buffer_id);
|
||||||
|
if (file != 0 && !file_is_ready(file)){
|
||||||
|
file = 0;
|
||||||
|
}
|
||||||
|
return(file);
|
||||||
|
}
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue