From 245d61d6a69e9d267f64513b90c69e3c16dff68c Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Wed, 6 Jul 2016 18:28:39 -0400 Subject: [PATCH] fixed the really tricky thing with the cursor positions --- 4ed.cpp | 18 +++++++++++++++--- 4ed_file_view.cpp | 8 ++++---- buffer/4coder_buffer_abstract.cpp | 3 --- buffer/4coder_shared.cpp | 4 ++-- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/4ed.cpp b/4ed.cpp index c702fac4..ba1f4b21 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -2885,15 +2885,27 @@ App_Step_Sig(app_step){ // NOTE(allen): post scroll vars back to the view's gui targets { - Panel *panel = 0, *used_panels = 0; - - used_panels = &models->layout.used_sentinel; + Panel *panel = 0, *used_panels = &models->layout.used_sentinel; for (dll_items(panel, used_panels)){ Assert(panel->view); view_end_cursor_scroll_updates(panel->view); } } + // NOTE(allen): on the first frame there should be no scrolling + if (input->first_step){ + Panel *panel = 0, *used_panels = &models->layout.used_sentinel; + for (dll_items(panel, used_panels)){ + View *view = panel->view; + GUI_Scroll_Vars *scroll_vars = &view->gui_scroll; + if (view->edit_pos){ + scroll_vars = &view->edit_pos->scroll; + } + scroll_vars->scroll_x = (f32)scroll_vars->target_x; + scroll_vars->scroll_y = (f32)scroll_vars->target_y; + } + } + // NOTE(allen): rendering { begin_render_section(target, system); diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 4f70e395..a871fb81 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -2018,8 +2018,8 @@ file_edit_cursor_fix(System_Functions *system, view_measure_wraps(general, view); Assert(view->edit_pos); write_cursor_with_index(cursors, &cursor_count, view->edit_pos->cursor.pos); - write_cursor_with_index(cursors, &cursor_count, view->edit_pos->mark - 1); - write_cursor_with_index(cursors, &cursor_count, view->edit_pos->scroll_i - 1); + write_cursor_with_index(cursors, &cursor_count, view->edit_pos->mark); + write_cursor_with_index(cursors, &cursor_count, view->edit_pos->scroll_i); } } @@ -2048,8 +2048,8 @@ file_edit_cursor_fix(System_Functions *system, GUI_Scroll_Vars scroll = view->edit_pos->scroll; - view->edit_pos->mark = cursors[cursor_count++].pos + 1; - i32 new_scroll_i = cursors[cursor_count++].pos + 1; + view->edit_pos->mark = cursors[cursor_count++].pos; + i32 new_scroll_i = cursors[cursor_count++].pos; if (view->edit_pos->scroll_i != new_scroll_i){ view->edit_pos->scroll_i = new_scroll_i; diff --git a/buffer/4coder_buffer_abstract.cpp b/buffer/4coder_buffer_abstract.cpp index efd0adaf..fba80ba8 100644 --- a/buffer/4coder_buffer_abstract.cpp +++ b/buffer/4coder_buffer_abstract.cpp @@ -6,9 +6,6 @@ * * 24.10.2015 * -* Buffer data object -* type - Golden Array -* */ // TOP diff --git a/buffer/4coder_shared.cpp b/buffer/4coder_shared.cpp index 8a70e3e1..cb1ee47b 100644 --- a/buffer/4coder_shared.cpp +++ b/buffer/4coder_shared.cpp @@ -174,7 +174,7 @@ buffer_update_cursors(Cursor_With_Index *sorted_positions, int count, int start, shift_amount = (len - (end - start)); position = sorted_positions + count - 1; - for (; position >= sorted_positions && position->pos >= end; --position) position->pos += shift_amount; + for (; position >= sorted_positions && position->pos > end; --position) position->pos += shift_amount; for (; position >= sorted_positions && position->pos >= start; --position) position->pos = start; } @@ -239,7 +239,7 @@ buffer_batch_edit_update_cursors(Cursor_With_Index *sorted_positions, int count, position->pos += shift_amount; } - for (; position->pos < end && position < end_position; ++position){ + for (; position->pos <= end && position < end_position; ++position){ position->pos = start + shift_amount; }