fixed the really tricky thing with the cursor positions

This commit is contained in:
Allen Webster 2016-07-06 18:28:39 -04:00
parent 42cab1b573
commit 245d61d6a6
4 changed files with 21 additions and 12 deletions

18
4ed.cpp
View File

@ -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);

View File

@ -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;

View File

@ -6,9 +6,6 @@
*
* 24.10.2015
*
* Buffer data object
* type - Golden Array
*
*/
// TOP

View File

@ -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;
}