Moved built-in mark out of the edit pos

master
Allen Webster 2019-02-09 16:35:47 -08:00
parent b0007d387f
commit 66a06053b6
6 changed files with 12 additions and 17 deletions

View File

@ -83,8 +83,7 @@ file_cursor_to_end(System_Functions *system, Models *models, Editing_File *file)
} }
view_cursor_move(system, view, pos); view_cursor_move(system, view, pos);
File_Edit_Positions edit_pos = view_get_edit_pos(view); File_Edit_Positions edit_pos = view_get_edit_pos(view);
edit_pos.mark = edit_pos.cursor_pos; view->transient.mark = edit_pos.cursor_pos;
view_set_edit_pos(view, edit_pos);
} }
} }

View File

@ -68,7 +68,7 @@ fill_view_summary(System_Functions *system, View_Summary *view, View *vptr, Live
Assert(data->file != 0); Assert(data->file != 0);
File_Edit_Positions edit_pos = view_get_edit_pos(vptr); File_Edit_Positions edit_pos = view_get_edit_pos(vptr);
view->mark = file_compute_cursor(system, data->file, seek_pos(edit_pos.mark)); view->mark = file_compute_cursor(system, data->file, seek_pos(vptr->transient.mark));
view->cursor = file_compute_cursor(system, data->file, seek_pos(edit_pos.cursor_pos)); view->cursor = file_compute_cursor(system, data->file, seek_pos(edit_pos.cursor_pos));
view->preferred_x = edit_pos.preferred_x; view->preferred_x = edit_pos.preferred_x;
@ -1948,16 +1948,12 @@ DOC_SEE(Buffer_Seek)
if (!file->is_loading){ if (!file->is_loading){
if (seek.type != buffer_seek_pos){ if (seek.type != buffer_seek_pos){
result = true; result = true;
File_Edit_Positions edit_pos = view_get_edit_pos(vptr);
Full_Cursor cursor = file_compute_cursor(system, file, seek); Full_Cursor cursor = file_compute_cursor(system, file, seek);
edit_pos.mark = cursor.pos; vptr->transient.mark = cursor.pos;
view_set_edit_pos(vptr, edit_pos);
} }
else{ else{
result = true; result = true;
File_Edit_Positions edit_pos = view_get_edit_pos(vptr); vptr->transient.mark = seek.pos;
edit_pos.mark = seek.pos;
view_set_edit_pos(vptr, edit_pos);
} }
fill_view_summary(system, view, vptr, models); fill_view_summary(system, view, vptr, models);
} }

View File

@ -115,9 +115,9 @@ edit_fix_markers(System_Functions *system, Models *models, Editing_File *file, E
View *view = panel->view; View *view = panel->view;
if (view->transient.file_data.file == file){ if (view->transient.file_data.file == file){
File_Edit_Positions edit_pos = view_get_edit_pos(view); File_Edit_Positions edit_pos = view_get_edit_pos(view);
write_cursor_with_index(cursors, &cursor_count, edit_pos.cursor_pos); write_cursor_with_index(cursors, &cursor_count, edit_pos.cursor_pos );
write_cursor_with_index(cursors, &cursor_count, edit_pos.mark ); write_cursor_with_index(cursors, &cursor_count, view->transient.mark);
write_cursor_with_index(cursors, &cursor_count, edit_pos.scroll_i ); write_cursor_with_index(cursors, &cursor_count, edit_pos.scroll_i );
} }
} }
@ -165,8 +165,7 @@ edit_fix_markers(System_Functions *system, Models *models, Editing_File *file, E
File_Edit_Positions edit_pos = view_get_edit_pos(view); File_Edit_Positions edit_pos = view_get_edit_pos(view);
GUI_Scroll_Vars scroll = edit_pos.scroll; GUI_Scroll_Vars scroll = edit_pos.scroll;
edit_pos.mark = cursors[cursor_count++].pos; view->transient.mark = cursors[cursor_count++].pos;
view_set_edit_pos(view, edit_pos);
i32 new_scroll_i = cursors[cursor_count++].pos; i32 new_scroll_i = cursors[cursor_count++].pos;
if (edit_pos.scroll_i != new_scroll_i){ if (edit_pos.scroll_i != new_scroll_i){
edit_pos.scroll_i = new_scroll_i; edit_pos.scroll_i = new_scroll_i;

View File

@ -20,7 +20,6 @@ enum Edit_Pos_Set_Type{
struct File_Edit_Positions{ struct File_Edit_Positions{
GUI_Scroll_Vars scroll; GUI_Scroll_Vars scroll;
i32 cursor_pos; i32 cursor_pos;
i32 mark;
f32 preferred_x; f32 preferred_x;
i32 scroll_i; i32 scroll_i;
i32 last_set_type; i32 last_set_type;

View File

@ -342,8 +342,9 @@ view_set_file(System_Functions *system, Models *models, View *view, Editing_File
block_zero(&view->transient.file_data, sizeof(view->transient.file_data)); block_zero(&view->transient.file_data, sizeof(view->transient.file_data));
view->transient.file_data.file = file; view->transient.file_data.file = file;
// TODO(allen): do(set edit pos without updating file when popping) File_Edit_Positions edit_pos = file_edit_positions_pop(file);
view->transient.edit_pos_ = file_edit_positions_pop(file); view_set_edit_pos(view, edit_pos);
view->transient.mark = edit_pos.cursor_pos;
Font_Pointers font = system->font.get_pointers_by_id(file->settings.font_id); Font_Pointers font = system->font.get_pointers_by_id(file->settings.font_id);
view->transient.line_height = font.metrics->height; view->transient.line_height = font.metrics->height;

View File

@ -37,6 +37,7 @@ struct View_Transient{
i32_Rect scroll_region; i32_Rect scroll_region;
File_Edit_Positions edit_pos_; File_Edit_Positions edit_pos_;
i32 mark;
b32 ui_mode; b32 ui_mode;
UI_Quit_Function_Type *ui_quit; UI_Quit_Function_Type *ui_quit;