From 66a06053b6600cdf72d23155d7518f24ee2a63aa Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sat, 9 Feb 2019 16:35:47 -0800 Subject: [PATCH] Moved built-in mark out of the edit pos --- 4ed.cpp | 3 +-- 4ed_api_implementation.cpp | 10 +++------- 4ed_edit.cpp | 9 ++++----- 4ed_file.h | 1 - 4ed_view.cpp | 5 +++-- 4ed_view.h | 1 + 6 files changed, 12 insertions(+), 17 deletions(-) diff --git a/4ed.cpp b/4ed.cpp index d685e9c9..55aefc68 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -83,8 +83,7 @@ file_cursor_to_end(System_Functions *system, Models *models, Editing_File *file) } view_cursor_move(system, view, pos); File_Edit_Positions edit_pos = view_get_edit_pos(view); - edit_pos.mark = edit_pos.cursor_pos; - view_set_edit_pos(view, edit_pos); + view->transient.mark = edit_pos.cursor_pos; } } diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 1f320a01..95bdca69 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -68,7 +68,7 @@ fill_view_summary(System_Functions *system, View_Summary *view, View *vptr, Live Assert(data->file != 0); 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->preferred_x = edit_pos.preferred_x; @@ -1948,16 +1948,12 @@ DOC_SEE(Buffer_Seek) if (!file->is_loading){ if (seek.type != buffer_seek_pos){ result = true; - File_Edit_Positions edit_pos = view_get_edit_pos(vptr); Full_Cursor cursor = file_compute_cursor(system, file, seek); - edit_pos.mark = cursor.pos; - view_set_edit_pos(vptr, edit_pos); + vptr->transient.mark = cursor.pos; } else{ result = true; - File_Edit_Positions edit_pos = view_get_edit_pos(vptr); - edit_pos.mark = seek.pos; - view_set_edit_pos(vptr, edit_pos); + vptr->transient.mark = seek.pos; } fill_view_summary(system, view, vptr, models); } diff --git a/4ed_edit.cpp b/4ed_edit.cpp index 496fd875..af03300b 100644 --- a/4ed_edit.cpp +++ b/4ed_edit.cpp @@ -115,9 +115,9 @@ edit_fix_markers(System_Functions *system, Models *models, Editing_File *file, E View *view = panel->view; if (view->transient.file_data.file == file){ 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.mark ); - write_cursor_with_index(cursors, &cursor_count, edit_pos.scroll_i ); + write_cursor_with_index(cursors, &cursor_count, edit_pos.cursor_pos ); + write_cursor_with_index(cursors, &cursor_count, view->transient.mark); + 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); GUI_Scroll_Vars scroll = edit_pos.scroll; - edit_pos.mark = cursors[cursor_count++].pos; - view_set_edit_pos(view, edit_pos); + view->transient.mark = cursors[cursor_count++].pos; i32 new_scroll_i = cursors[cursor_count++].pos; if (edit_pos.scroll_i != new_scroll_i){ edit_pos.scroll_i = new_scroll_i; diff --git a/4ed_file.h b/4ed_file.h index 6c6e6b28..abdd2c51 100644 --- a/4ed_file.h +++ b/4ed_file.h @@ -20,7 +20,6 @@ enum Edit_Pos_Set_Type{ struct File_Edit_Positions{ GUI_Scroll_Vars scroll; i32 cursor_pos; - i32 mark; f32 preferred_x; i32 scroll_i; i32 last_set_type; diff --git a/4ed_view.cpp b/4ed_view.cpp index c71f1fc3..61582bd0 100644 --- a/4ed_view.cpp +++ b/4ed_view.cpp @@ -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)); view->transient.file_data.file = file; - // TODO(allen): do(set edit pos without updating file when popping) - view->transient.edit_pos_ = file_edit_positions_pop(file); + File_Edit_Positions 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); view->transient.line_height = font.metrics->height; diff --git a/4ed_view.h b/4ed_view.h index 8a222b23..9f631002 100644 --- a/4ed_view.h +++ b/4ed_view.h @@ -37,6 +37,7 @@ struct View_Transient{ i32_Rect scroll_region; File_Edit_Positions edit_pos_; + i32 mark; b32 ui_mode; UI_Quit_Function_Type *ui_quit;