eliminated some undo bug-prone nonsense
parent
ab4d5bbe02
commit
016d07cce4
|
@ -305,9 +305,9 @@ enum Command_Line_Input_Flag{
|
||||||
CLI_CursorAtEnd = 0x4,
|
CLI_CursorAtEnd = 0x4,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Auto_Tab_Flag{
|
enum Auto_Indent_Flag{
|
||||||
AutoTab_ClearLine = 0x1,
|
AutoIndent_ClearLine = 0x1,
|
||||||
AutoTab_UseTab = 0x2
|
AutoIndent_UseTab = 0x2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Input_Type_Flag{
|
enum Input_Type_Flag{
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#define BUFFER_READ_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *out)
|
#define BUFFER_READ_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *out)
|
||||||
#define BUFFER_REPLACE_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *str, int len)
|
#define BUFFER_REPLACE_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *str, int len)
|
||||||
#define BUFFER_SET_SETTING_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int setting, int value)
|
#define BUFFER_SET_SETTING_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int setting, int value)
|
||||||
|
#define BUFFER_AUTO_INDENT_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, int tab_width, unsigned int flags)
|
||||||
#define CREATE_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, char *filename, int filename_len, unsigned int flags)
|
#define CREATE_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, char *filename, int filename_len, unsigned int flags)
|
||||||
#define SAVE_BUFFER_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, char *filename, int filename_len, unsigned int flags)
|
#define SAVE_BUFFER_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, char *filename, int filename_len, unsigned int flags)
|
||||||
#define KILL_BUFFER_SIG(n) int n(Application_Links *app, Buffer_Identifier buffer, int view_id, unsigned int flags)
|
#define KILL_BUFFER_SIG(n) int n(Application_Links *app, Buffer_Identifier buffer, int view_id, unsigned int flags)
|
||||||
|
@ -24,7 +25,6 @@
|
||||||
#define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view, unsigned int access)
|
#define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view, unsigned int access)
|
||||||
#define GET_VIEW_SIG(n) View_Summary n(Application_Links *app, int view_id, unsigned int access)
|
#define GET_VIEW_SIG(n) View_Summary n(Application_Links *app, int view_id, unsigned int access)
|
||||||
#define GET_ACTIVE_VIEW_SIG(n) View_Summary n(Application_Links *app, unsigned int access)
|
#define GET_ACTIVE_VIEW_SIG(n) View_Summary n(Application_Links *app, unsigned int access)
|
||||||
#define VIEW_AUTO_TAB_SIG(n) int n(Application_Links *app, View_Summary *view, int start, int end, int tab_width, unsigned int flags)
|
|
||||||
#define VIEW_COMPUTE_CURSOR_SIG(n) Full_Cursor n(Application_Links *app, View_Summary *view, Buffer_Seek seek)
|
#define VIEW_COMPUTE_CURSOR_SIG(n) Full_Cursor n(Application_Links *app, View_Summary *view, Buffer_Seek seek)
|
||||||
#define VIEW_SET_CURSOR_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x)
|
#define VIEW_SET_CURSOR_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x)
|
||||||
#define VIEW_SET_MARK_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek)
|
#define VIEW_SET_MARK_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek)
|
||||||
|
@ -64,6 +64,7 @@ extern "C"{
|
||||||
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_SET_SETTING_SIG(Buffer_Set_Setting_Function);
|
typedef BUFFER_SET_SETTING_SIG(Buffer_Set_Setting_Function);
|
||||||
|
typedef BUFFER_AUTO_INDENT_SIG(Buffer_Auto_Indent_Function);
|
||||||
typedef CREATE_BUFFER_SIG(Create_Buffer_Function);
|
typedef CREATE_BUFFER_SIG(Create_Buffer_Function);
|
||||||
typedef SAVE_BUFFER_SIG(Save_Buffer_Function);
|
typedef SAVE_BUFFER_SIG(Save_Buffer_Function);
|
||||||
typedef KILL_BUFFER_SIG(Kill_Buffer_Function);
|
typedef KILL_BUFFER_SIG(Kill_Buffer_Function);
|
||||||
|
@ -71,7 +72,6 @@ extern "C"{
|
||||||
typedef GET_VIEW_NEXT_SIG(Get_View_Next_Function);
|
typedef GET_VIEW_NEXT_SIG(Get_View_Next_Function);
|
||||||
typedef GET_VIEW_SIG(Get_View_Function);
|
typedef GET_VIEW_SIG(Get_View_Function);
|
||||||
typedef GET_ACTIVE_VIEW_SIG(Get_Active_View_Function);
|
typedef GET_ACTIVE_VIEW_SIG(Get_Active_View_Function);
|
||||||
typedef VIEW_AUTO_TAB_SIG(View_Auto_Tab_Function);
|
|
||||||
typedef VIEW_COMPUTE_CURSOR_SIG(View_Compute_Cursor_Function);
|
typedef VIEW_COMPUTE_CURSOR_SIG(View_Compute_Cursor_Function);
|
||||||
typedef VIEW_SET_CURSOR_SIG(View_Set_Cursor_Function);
|
typedef VIEW_SET_CURSOR_SIG(View_Set_Cursor_Function);
|
||||||
typedef VIEW_SET_MARK_SIG(View_Set_Mark_Function);
|
typedef VIEW_SET_MARK_SIG(View_Set_Mark_Function);
|
||||||
|
@ -114,6 +114,7 @@ struct Application_Links{
|
||||||
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_Set_Setting_Function *buffer_set_setting;
|
Buffer_Set_Setting_Function *buffer_set_setting;
|
||||||
|
Buffer_Auto_Indent_Function *buffer_auto_indent;
|
||||||
Create_Buffer_Function *create_buffer;
|
Create_Buffer_Function *create_buffer;
|
||||||
Save_Buffer_Function *save_buffer;
|
Save_Buffer_Function *save_buffer;
|
||||||
Kill_Buffer_Function *kill_buffer;
|
Kill_Buffer_Function *kill_buffer;
|
||||||
|
@ -121,7 +122,6 @@ struct Application_Links{
|
||||||
Get_View_Next_Function *get_view_next;
|
Get_View_Next_Function *get_view_next;
|
||||||
Get_View_Function *get_view;
|
Get_View_Function *get_view;
|
||||||
Get_Active_View_Function *get_active_view;
|
Get_Active_View_Function *get_active_view;
|
||||||
View_Auto_Tab_Function *view_auto_tab;
|
|
||||||
View_Compute_Cursor_Function *view_compute_cursor;
|
View_Compute_Cursor_Function *view_compute_cursor;
|
||||||
View_Set_Cursor_Function *view_set_cursor;
|
View_Set_Cursor_Function *view_set_cursor;
|
||||||
View_Set_Mark_Function *view_set_mark;
|
View_Set_Mark_Function *view_set_mark;
|
||||||
|
@ -166,6 +166,7 @@ app_links->buffer_seek = external_buffer_seek;\
|
||||||
app_links->buffer_read_range = external_buffer_read_range;\
|
app_links->buffer_read_range = external_buffer_read_range;\
|
||||||
app_links->buffer_replace_range = external_buffer_replace_range;\
|
app_links->buffer_replace_range = external_buffer_replace_range;\
|
||||||
app_links->buffer_set_setting = external_buffer_set_setting;\
|
app_links->buffer_set_setting = external_buffer_set_setting;\
|
||||||
|
app_links->buffer_auto_indent = external_buffer_auto_indent;\
|
||||||
app_links->create_buffer = external_create_buffer;\
|
app_links->create_buffer = external_create_buffer;\
|
||||||
app_links->save_buffer = external_save_buffer;\
|
app_links->save_buffer = external_save_buffer;\
|
||||||
app_links->kill_buffer = external_kill_buffer;\
|
app_links->kill_buffer = external_kill_buffer;\
|
||||||
|
@ -173,7 +174,6 @@ app_links->get_view_first = external_get_view_first;\
|
||||||
app_links->get_view_next = external_get_view_next;\
|
app_links->get_view_next = external_get_view_next;\
|
||||||
app_links->get_view = external_get_view;\
|
app_links->get_view = external_get_view;\
|
||||||
app_links->get_active_view = external_get_active_view;\
|
app_links->get_active_view = external_get_active_view;\
|
||||||
app_links->view_auto_tab = external_view_auto_tab;\
|
|
||||||
app_links->view_compute_cursor = external_view_compute_cursor;\
|
app_links->view_compute_cursor = external_view_compute_cursor;\
|
||||||
app_links->view_set_cursor = external_view_set_cursor;\
|
app_links->view_set_cursor = external_view_set_cursor;\
|
||||||
app_links->view_set_mark = external_view_set_mark;\
|
app_links->view_set_mark = external_view_set_mark;\
|
||||||
|
|
|
@ -650,16 +650,16 @@ long_braces(Application_Links *app, char *text, int size){
|
||||||
unsigned int access = AccessOpen;
|
unsigned int access = AccessOpen;
|
||||||
View_Summary view = app->get_active_view(app, access);
|
View_Summary view = app->get_active_view(app, access);
|
||||||
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
||||||
int pos;
|
int pos = view.cursor.pos;
|
||||||
|
|
||||||
pos = view.cursor.pos;
|
|
||||||
app->buffer_replace_range(app, &buffer, pos, pos, text, size);
|
app->buffer_replace_range(app, &buffer, pos, pos, text, size);
|
||||||
app->view_set_cursor(app, &view, seek_pos(pos + 2), true);
|
app->view_set_cursor(app, &view, seek_pos(pos + 2), true);
|
||||||
|
|
||||||
app->view_auto_tab(app, &view,
|
app->buffer_auto_indent(app, &buffer,
|
||||||
pos, pos + size,
|
pos, pos + size,
|
||||||
DEF_TAB_WIDTH,
|
DEF_TAB_WIDTH,
|
||||||
0);
|
0);
|
||||||
|
// TODO(allen): set cursor position
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(open_long_braces){
|
CUSTOM_COMMAND_SIG(open_long_braces){
|
||||||
|
@ -705,10 +705,11 @@ CUSTOM_COMMAND_SIG(if0_off){
|
||||||
|
|
||||||
app->buffer_replace_range(app, &buffer, pos, pos, text1, size1);
|
app->buffer_replace_range(app, &buffer, pos, pos, text1, size1);
|
||||||
|
|
||||||
app->view_auto_tab(app, &view,
|
app->buffer_auto_indent(app, &buffer,
|
||||||
pos, pos,
|
pos, pos,
|
||||||
DEF_TAB_WIDTH,
|
DEF_TAB_WIDTH,
|
||||||
0);
|
0);
|
||||||
|
// TODO(allen): place cursor
|
||||||
|
|
||||||
refresh_view(app, &view);
|
refresh_view(app, &view);
|
||||||
range = get_range(&view);
|
range = get_range(&view);
|
||||||
|
@ -716,10 +717,11 @@ CUSTOM_COMMAND_SIG(if0_off){
|
||||||
|
|
||||||
app->buffer_replace_range(app, &buffer, pos, pos, text2, size2);
|
app->buffer_replace_range(app, &buffer, pos, pos, text2, size2);
|
||||||
|
|
||||||
app->view_auto_tab(app, &view,
|
app->buffer_auto_indent(app, &buffer,
|
||||||
pos, pos,
|
pos, pos,
|
||||||
DEF_TAB_WIDTH,
|
DEF_TAB_WIDTH,
|
||||||
0);
|
0);
|
||||||
|
// TODO(allen): place cursor
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(backspace_word){
|
CUSTOM_COMMAND_SIG(backspace_word){
|
||||||
|
@ -1298,11 +1300,13 @@ CUSTOM_COMMAND_SIG(build_search){
|
||||||
CUSTOM_COMMAND_SIG(auto_tab_line_at_cursor){
|
CUSTOM_COMMAND_SIG(auto_tab_line_at_cursor){
|
||||||
unsigned int access = AccessOpen;
|
unsigned int access = AccessOpen;
|
||||||
View_Summary view = app->get_active_view(app, access);
|
View_Summary view = app->get_active_view(app, access);
|
||||||
|
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
||||||
|
|
||||||
app->view_auto_tab(app, &view,
|
app->buffer_auto_indent(app, &buffer,
|
||||||
view.cursor.pos, view.cursor.pos,
|
view.cursor.pos, view.cursor.pos,
|
||||||
DEF_TAB_WIDTH,
|
DEF_TAB_WIDTH,
|
||||||
0);
|
0);
|
||||||
|
// TODO(allen): place cursor
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(auto_tab_whole_file){
|
CUSTOM_COMMAND_SIG(auto_tab_whole_file){
|
||||||
|
@ -1310,21 +1314,24 @@ CUSTOM_COMMAND_SIG(auto_tab_whole_file){
|
||||||
View_Summary view = app->get_active_view(app, access);
|
View_Summary view = app->get_active_view(app, access);
|
||||||
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
||||||
|
|
||||||
app->view_auto_tab(app, &view,
|
app->buffer_auto_indent(app, &buffer,
|
||||||
0, buffer.size,
|
0, buffer.size,
|
||||||
DEF_TAB_WIDTH,
|
DEF_TAB_WIDTH,
|
||||||
0);
|
0);
|
||||||
|
// TODO(allen): place cursor
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(auto_tab_range){
|
CUSTOM_COMMAND_SIG(auto_tab_range){
|
||||||
unsigned int access = AccessOpen;
|
unsigned int access = AccessOpen;
|
||||||
View_Summary view = app->get_active_view(app, access);
|
View_Summary view = app->get_active_view(app, access);
|
||||||
|
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
||||||
Range range = get_range(&view);
|
Range range = get_range(&view);
|
||||||
|
|
||||||
app->view_auto_tab(app, &view,
|
app->buffer_auto_indent(app, &buffer,
|
||||||
range.min, range.max,
|
range.min, range.max,
|
||||||
DEF_TAB_WIDTH,
|
DEF_TAB_WIDTH,
|
||||||
0);
|
0);
|
||||||
|
// TODO(allen): place cursor
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(write_and_auto_tab){
|
CUSTOM_COMMAND_SIG(write_and_auto_tab){
|
||||||
|
|
|
@ -792,6 +792,46 @@ DOC_SEE(Buffer_Setting_ID)
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BUFFER_AUTO_INDENT_SIG(external_buffer_auto_indent)/*
|
||||||
|
DOC_PARAM(buffer, the buffer in which to apply the auto indenting)
|
||||||
|
DOC_PARAM(start, the position to start the auto indenting)
|
||||||
|
DOC_PARAM(end, the position to end the auto indenting)
|
||||||
|
DOC_PARAM(tab_width, the number of spaces to place as a tab)
|
||||||
|
DOC_PARAM(flags, the auto tab behavior flags)
|
||||||
|
DOC_RETURN(returns non-zero when the call succeeds)
|
||||||
|
DOC
|
||||||
|
(
|
||||||
|
Applies the built in auto-indentation rule to the code in the range from
|
||||||
|
start to end by inserting spaces or tabs at the beginning of the lines.
|
||||||
|
If the buffer does not have lexing enabled or the lexing job has not
|
||||||
|
completed this function will fail.
|
||||||
|
)
|
||||||
|
DOC_SEE(Auto_Tab_Flag)
|
||||||
|
*/{
|
||||||
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
|
System_Functions *system = cmd->system;
|
||||||
|
Models *models = cmd->models;
|
||||||
|
|
||||||
|
Indent_Options opts = {0};
|
||||||
|
int result = false;
|
||||||
|
|
||||||
|
Editing_File *file = imp_get_file(cmd, buffer);
|
||||||
|
if (file && file->state.token_stack.tokens &&
|
||||||
|
file->state.tokens_complete && !file->state.still_lexing){
|
||||||
|
result = true;
|
||||||
|
|
||||||
|
opts.empty_blank_lines = (flags & AutoIndent_ClearLine);
|
||||||
|
opts.use_tabs = (flags & AutoIndent_UseTab);
|
||||||
|
opts.tab_width = tab_width;
|
||||||
|
|
||||||
|
file_auto_tab_tokens(system, models, file, start, start, end, opts);
|
||||||
|
|
||||||
|
fill_buffer_summary(buffer, file, cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
CREATE_BUFFER_SIG(external_create_buffer)/*
|
CREATE_BUFFER_SIG(external_create_buffer)/*
|
||||||
DOC_PARAM(filename, the name of the file to be opened or created)
|
DOC_PARAM(filename, the name of the file to be opened or created)
|
||||||
DOC_PARAM(filename_len, the length of the filename string)
|
DOC_PARAM(filename_len, the length of the filename string)
|
||||||
|
@ -1063,42 +1103,6 @@ DOC_RETURN(returns a summary that describes the active view)
|
||||||
return(view);
|
return(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
VIEW_AUTO_TAB_SIG(external_view_auto_tab)/*
|
|
||||||
DOC_PARAM(start, )
|
|
||||||
DOC_PARAM(end, )
|
|
||||||
DOC_PARAM(tab_width, )
|
|
||||||
DOC_PARAM(flags, )
|
|
||||||
*/{
|
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
||||||
System_Functions *system = cmd->system;
|
|
||||||
Models *models = cmd->models;
|
|
||||||
|
|
||||||
int result = false;
|
|
||||||
|
|
||||||
Editing_File *file = 0;
|
|
||||||
View *vptr = imp_get_view(cmd, view);
|
|
||||||
|
|
||||||
if (vptr){
|
|
||||||
file = vptr->file_data.file;
|
|
||||||
|
|
||||||
if (file && file->state.token_stack.tokens &&
|
|
||||||
file->state.tokens_complete && !file->state.still_lexing){
|
|
||||||
result = true;
|
|
||||||
|
|
||||||
Indent_Options opts;
|
|
||||||
opts.empty_blank_lines = (flags & AutoTab_ClearLine);
|
|
||||||
opts.use_tabs = (flags & AutoTab_UseTab);
|
|
||||||
opts.tab_width = tab_width;
|
|
||||||
|
|
||||||
view_auto_tab_tokens(system, models, vptr, start, end, opts);
|
|
||||||
|
|
||||||
fill_view_summary(view, vptr, cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
VIEW_COMPUTE_CURSOR_SIG(external_view_compute_cursor){
|
VIEW_COMPUTE_CURSOR_SIG(external_view_compute_cursor){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
View *vptr = imp_get_view(cmd, view);
|
View *vptr = imp_get_view(cmd, view);
|
||||||
|
|
|
@ -40,8 +40,6 @@ struct Edit_Step{
|
||||||
struct{
|
struct{
|
||||||
b32 can_merge;
|
b32 can_merge;
|
||||||
Buffer_Edit edit;
|
Buffer_Edit edit;
|
||||||
i32 pre_pos;
|
|
||||||
i32 post_pos;
|
|
||||||
i32 next_block, prev_block;
|
i32 next_block, prev_block;
|
||||||
};
|
};
|
||||||
struct{
|
struct{
|
||||||
|
|
|
@ -1210,8 +1210,6 @@ file_post_undo(General_Memory *general, Editing_File *file,
|
||||||
|
|
||||||
Edit_Step inv_step = {};
|
Edit_Step inv_step = {};
|
||||||
inv_step.edit = inv;
|
inv_step.edit = inv;
|
||||||
inv_step.pre_pos = step.pre_pos;
|
|
||||||
inv_step.post_pos = step.post_pos;
|
|
||||||
inv_step.can_merge = (b8)can_merge;
|
inv_step.can_merge = (b8)can_merge;
|
||||||
inv_step.type = ED_UNDO;
|
inv_step.type = ED_UNDO;
|
||||||
|
|
||||||
|
@ -1222,7 +1220,6 @@ file_post_undo(General_Memory *general, Editing_File *file,
|
||||||
if (prev.edit.end == inv_step.edit.start){
|
if (prev.edit.end == inv_step.edit.start){
|
||||||
did_merge = 1;
|
did_merge = 1;
|
||||||
inv_step.edit.start = prev.edit.start;
|
inv_step.edit.start = prev.edit.start;
|
||||||
inv_step.pre_pos = prev.pre_pos;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1280,8 +1277,6 @@ file_post_redo(General_Memory *general, Editing_File *file, Edit_Step step){
|
||||||
|
|
||||||
Edit_Step inv_step = {};
|
Edit_Step inv_step = {};
|
||||||
inv_step.edit = inv;
|
inv_step.edit = inv;
|
||||||
inv_step.pre_pos = step.pre_pos;
|
|
||||||
inv_step.post_pos = step.post_pos;
|
|
||||||
inv_step.type = ED_REDO;
|
inv_step.type = ED_REDO;
|
||||||
|
|
||||||
if (redo->edit_count == redo->edit_max)
|
if (redo->edit_count == redo->edit_max)
|
||||||
|
@ -1350,19 +1345,16 @@ file_post_history(General_Memory *general, Editing_File *file,
|
||||||
|
|
||||||
Edit_Step inv_step = {};
|
Edit_Step inv_step = {};
|
||||||
inv_step.edit = inv;
|
inv_step.edit = inv;
|
||||||
inv_step.pre_pos = step.pre_pos;
|
|
||||||
inv_step.post_pos = step.post_pos;
|
|
||||||
inv_step.can_merge = (b8)can_merge;
|
inv_step.can_merge = (b8)can_merge;
|
||||||
inv_step.type = reverse_types[step.type];
|
inv_step.type = reverse_types[step.type];
|
||||||
|
|
||||||
bool32 did_merge = 0;
|
b32 did_merge = 0;
|
||||||
if (do_merge && history->edit_count > 0){
|
if (do_merge && history->edit_count > 0){
|
||||||
Edit_Step prev = history->edits[history->edit_count-1];
|
Edit_Step prev = history->edits[history->edit_count-1];
|
||||||
if (prev.can_merge && inv_step.edit.len == 0 && prev.edit.len == 0){
|
if (prev.can_merge && inv_step.edit.len == 0 && prev.edit.len == 0){
|
||||||
if (prev.edit.end == inv_step.edit.start){
|
if (prev.edit.end == inv_step.edit.start){
|
||||||
did_merge = 1;
|
did_merge = 1;
|
||||||
inv_step.edit.start = prev.edit.start;
|
inv_step.edit.start = prev.edit.start;
|
||||||
inv_step.pre_pos = prev.pre_pos;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2218,8 +2210,6 @@ file_replace_range(System_Functions *system, Models *models, Editing_File *file,
|
||||||
spec.step.edit.end = end;
|
spec.step.edit.end = end;
|
||||||
|
|
||||||
spec.step.edit.len = len;
|
spec.step.edit.len = len;
|
||||||
spec.step.pre_pos = file->state.cursor_pos;
|
|
||||||
spec.step.post_pos = next_cursor;
|
|
||||||
spec.str = (u8*)str;
|
spec.str = (u8*)str;
|
||||||
file_do_single_edit(system, models, file, spec, hist_normal, use_high_permission);
|
file_do_single_edit(system, models, file, spec, hist_normal, use_high_permission);
|
||||||
}
|
}
|
||||||
|
@ -2276,8 +2266,7 @@ view_undo_redo(System_Functions *system,
|
||||||
|
|
||||||
file_do_single_edit(system, models, file, spec, hist_normal);
|
file_do_single_edit(system, models, file, spec, hist_normal);
|
||||||
|
|
||||||
if (expected_type == ED_UNDO) view_cursor_move(view, step.pre_pos);
|
view_cursor_move(view, step.edit.start + step.edit.len);
|
||||||
else view_cursor_move(view, step.post_pos);
|
|
||||||
view->recent->mark = view->recent->cursor.pos;
|
view->recent->mark = view->recent->cursor.pos;
|
||||||
|
|
||||||
Style *style = main_style(models);
|
Style *style = main_style(models);
|
||||||
|
@ -2390,7 +2379,7 @@ view_history_step(System_Functions *system, Models *models, View *view, History_
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_history_step){
|
if (do_history_step){
|
||||||
Edit_Spec spec;
|
Edit_Spec spec = {0};
|
||||||
spec.step = step;
|
spec.step = step;
|
||||||
|
|
||||||
if (spec.step.child_count == 0){
|
if (spec.step.child_count == 0){
|
||||||
|
@ -2402,12 +2391,12 @@ view_history_step(System_Functions *system, Models *models, View *view, History_
|
||||||
switch (spec.step.type){
|
switch (spec.step.type){
|
||||||
case ED_NORMAL:
|
case ED_NORMAL:
|
||||||
case ED_REDO:
|
case ED_REDO:
|
||||||
view_cursor_move(view, step.post_pos);
|
view_cursor_move(view, step.edit.start + step.edit.len);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ED_REVERSE_NORMAL:
|
case ED_REVERSE_NORMAL:
|
||||||
case ED_UNDO:
|
case ED_UNDO:
|
||||||
view_cursor_move(view, step.pre_pos);
|
view_cursor_move(view, step.edit.start + step.edit.len);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
view->recent->mark = view->recent->cursor.pos;
|
view->recent->mark = view->recent->cursor.pos;
|
||||||
|
@ -2524,10 +2513,8 @@ file_compute_whitespace_edit(Mem_Options *mem, Editing_File *file, i32 cursor_po
|
||||||
spec.step.special_type = 1;
|
spec.step.special_type = 1;
|
||||||
spec.step.child_count = edit_count;
|
spec.step.child_count = edit_count;
|
||||||
spec.step.inverse_child_count = edit_count;
|
spec.step.inverse_child_count = edit_count;
|
||||||
spec.step.pre_pos = cursor_pos;
|
|
||||||
spec.step.post_pos = cursor_pos;
|
|
||||||
|
|
||||||
return spec;
|
return(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
|
|
|
@ -30,6 +30,7 @@ int Buffer_Read_Range(Application_Links *app, Buffer_Summary *buffer, int start,
|
||||||
|
|
||||||
int Buffer_Replace_Range(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *str, int len);
|
int Buffer_Replace_Range(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *str, int len);
|
||||||
int Buffer_Set_Setting(Application_Links *app, Buffer_Summary *buffer, int setting, int value);
|
int Buffer_Set_Setting(Application_Links *app, Buffer_Summary *buffer, int setting, int value);
|
||||||
|
int Buffer_Auto_Indent(Application_Links *app, Buffer_Summary *buffer, int start, int end, int tab_width, unsigned int flags);
|
||||||
|
|
||||||
Buffer_Summary Create_Buffer(Application_Links *app, char *filename, int filename_len, unsigned int flags);
|
Buffer_Summary Create_Buffer(Application_Links *app, char *filename, int filename_len, unsigned int flags);
|
||||||
int Save_Buffer(Application_Links *app, Buffer_Summary *buffer, char *filename, int filename_len, unsigned int flags);
|
int Save_Buffer(Application_Links *app, Buffer_Summary *buffer, char *filename, int filename_len, unsigned int flags);
|
||||||
|
@ -42,7 +43,6 @@ void Get_View_Next(Application_Links *app, View_Summary *view, unsigned int acce
|
||||||
View_Summary Get_View(Application_Links *app, int view_id, unsigned int access);
|
View_Summary Get_View(Application_Links *app, int view_id, unsigned int access);
|
||||||
View_Summary Get_Active_View(Application_Links *app, unsigned int access);
|
View_Summary Get_Active_View(Application_Links *app, unsigned int access);
|
||||||
|
|
||||||
int View_Auto_Tab (Application_Links *app, View_Summary *view, int start, int end, int tab_width, unsigned int flags);
|
|
||||||
Full_Cursor View_Compute_Cursor (Application_Links *app, View_Summary *view, Buffer_Seek seek);
|
Full_Cursor View_Compute_Cursor (Application_Links *app, View_Summary *view, Buffer_Seek seek);
|
||||||
int View_Set_Cursor (Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x);
|
int View_Set_Cursor (Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x);
|
||||||
int View_Set_Mark (Application_Links *app, View_Summary *view, Buffer_Seek seek);
|
int View_Set_Mark (Application_Links *app, View_Summary *view, Buffer_Seek seek);
|
||||||
|
|
Loading…
Reference in New Issue