Simplifying the edit position structure

master
Allen Webster 2019-02-09 16:20:55 -08:00
parent 4bdc1e6d21
commit b0007d387f
8 changed files with 112 additions and 145 deletions

View File

@ -83,7 +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;
edit_pos.mark = edit_pos.cursor_pos;
view_set_edit_pos(view, edit_pos);
}
}
@ -1314,11 +1314,6 @@ App_Step_Sig(app_step){
app_result.animating = true;
}
if (file_scroll){
// TODO(allen): do(eliminate view_set_edit_pos if it is redundant)
view_set_edit_pos(view, edit_pos);
}
if (memcmp(scroll_vars, &ip_result.scroll, sizeof(*scroll_vars)) != 0){
if (file_scroll){
view_set_scroll(system, view, ip_result.scroll);

View File

@ -68,9 +68,9 @@ 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), 0);
view->mark = file_compute_cursor(system, data->file, seek_pos(edit_pos.mark));
view->cursor = file_compute_cursor(system, data->file, seek_pos(edit_pos.cursor_pos));
view->cursor = edit_pos.cursor;
view->preferred_x = edit_pos.preferred_x;
view->view_region = vptr->transient.panel->rect_inner;
@ -1396,7 +1396,6 @@ Reopen_Buffer(Application_Links *app, Buffer_Summary *buffer, Buffer_Reopen_Flag
// TODO(allen): try(perform a diff maybe apply edits in reopen)
File_Edit_Positions edit_positions[16];
int32_t line_numbers[16];
int32_t column_numbers[16];
View *vptrs[16];
@ -1412,9 +1411,9 @@ Reopen_Buffer(Application_Links *app, Buffer_Summary *buffer, Buffer_Reopen_Flag
}
vptrs[vptr_count] = view_it;
File_Edit_Positions edit_pos = view_get_edit_pos(view_it);
edit_positions[vptr_count] = edit_pos;
line_numbers[vptr_count] = edit_pos.cursor.line;
column_numbers[vptr_count] = edit_pos.cursor.character;
Full_Cursor cursor = file_compute_cursor(system, view_it->transient.file_data.file, seek_pos(edit_pos.cursor_pos));
line_numbers[vptr_count] = cursor.line;
column_numbers[vptr_count] = cursor.character;
view_it->transient.file_data.file = models->scratch_buffer;
++vptr_count;
}
@ -1427,10 +1426,9 @@ Reopen_Buffer(Application_Links *app, Buffer_Summary *buffer, Buffer_Reopen_Flag
view_set_file(system, models, vptrs[i], file);
vptrs[i]->transient.file_data.file = file;
view_set_edit_pos(vptrs[i], edit_positions[i]);
Full_Cursor cursor = file_compute_cursor(system, file, seek_line_char(line_numbers[i], column_numbers[i]), 0);
Full_Cursor cursor = file_compute_cursor(system, file, seek_line_char(line_numbers[i], column_numbers[i]));
view_set_cursor(vptrs[i], cursor, true, file->settings.unwrapped_lines);
view_set_cursor(system, vptrs[i], cursor, true, file->settings.unwrapped_lines);
}
result = BufferReopenResult_Reopened;
@ -1864,7 +1862,7 @@ DOC_SEE(Full_Cursor)
Assert(file != 0);
if (!file->is_loading){
result = true;
*cursor_out = file_compute_cursor(system, file, seek, 0);
*cursor_out = file_compute_cursor(system, file, seek);
fill_view_summary(system, view, vptr, models);
}
}
@ -1891,8 +1889,8 @@ DOC_SEE(Buffer_Seek)
Editing_File *file = vptr->transient.file_data.file;
if (!file->is_loading){
result = true;
Full_Cursor cursor = file_compute_cursor(system, file, seek, 0);
view_set_cursor(vptr, cursor, set_preferred_x, file->settings.unwrapped_lines);
Full_Cursor cursor = file_compute_cursor(system, file, seek);
view_set_cursor(system, vptr, cursor, set_preferred_x, file->settings.unwrapped_lines);
fill_view_summary(system, view, vptr, models);
}
}
@ -1948,17 +1946,19 @@ DOC_SEE(Buffer_Seek)
Editing_File *file = vptr->transient.file_data.file;
Assert(file != 0);
if (!file->is_loading){
File_Edit_Positions edit_pos = view_get_edit_pos(vptr);
if (seek.type != buffer_seek_pos){
result = true;
Full_Cursor cursor = file_compute_cursor(system, file, seek, 0);
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);
}
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);
}
view_set_edit_pos(vptr, edit_pos);
fill_view_summary(system, view, vptr, models);
}
}
@ -1968,36 +1968,10 @@ DOC_SEE(Buffer_Seek)
API_EXPORT bool32
View_Set_Highlight(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on)/*
DOC_PARAM(view, The view parameter specifies the view in which to set the highlight.)
DOC_PARAM(start, This parameter specifies the absolute position of the first character of the highlight range.)
DOC_PARAM(end, This parameter specifies the absolute position of the character one past the end of the highlight range.)
DOC_PARAM(turn_on, This parameter indicates whether the highlight is being turned on or off.)
DOC_RETURN(This call returns non-zero on success.)
DOC
(
The highlight is mutually exclusive to the cursor. When the turn_on parameter
is set to true the highlight will be shown and the cursor will be hidden. After
that either setting the cursor with view_set_cursor or calling view_set_highlight
and the turn_on set to false, will switch back to showing the cursor.
)
DOC(This feature has been removed. Transition to the new highlighting system view markers which allow for
arbitrarily many highlights, and cursors, at the same time.)
*/{
Models *models = (Models*)app->cmd_context;
System_Functions *system = models->system;
View *vptr = imp_get_view(models, view);
bool32 result = false;
if (vptr != 0){
result = true;
if (turn_on){
view_set_temp_highlight(system, vptr, start, end);
}
else{
vptr->transient.file_data.show_temp_highlight = false;
}
fill_view_summary(system, view, vptr, models);
}
return(result);
return(false);
}
API_EXPORT bool32

View File

@ -115,7 +115,7 @@ 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.cursor_pos);
write_cursor_with_index(cursors, &cursor_count, edit_pos.mark );
write_cursor_with_index(cursors, &cursor_count, edit_pos.scroll_i );
}
@ -160,17 +160,19 @@ edit_fix_markers(System_Functions *system, Models *models, Editing_File *file, E
View *view = panel->view;
if (view->transient.file_data.file == file){
i32 cursor_pos = cursors[cursor_count++].pos;
Full_Cursor new_cursor = file_compute_cursor(system, file, seek_pos(cursor_pos), 0);
Full_Cursor new_cursor = file_compute_cursor(system, file, seek_pos(cursor_pos));
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);
i32 new_scroll_i = cursors[cursor_count++].pos;
if (edit_pos.scroll_i != new_scroll_i){
edit_pos.scroll_i = new_scroll_i;
view_set_edit_pos(view, edit_pos);
Full_Cursor temp_cursor = file_compute_cursor(system, file, seek_pos(edit_pos.scroll_i), 0);
Full_Cursor temp_cursor = file_compute_cursor(system, file, seek_pos(edit_pos.scroll_i));
f32 y_offset = MOD(edit_pos.scroll.scroll_y, view->transient.line_height);
f32 y_position = temp_cursor.wrapped_y;
@ -183,8 +185,6 @@ edit_fix_markers(System_Functions *system, Models *models, Editing_File *file, E
scroll.scroll_y = y_position;
}
// TODO(allen): do(remove view_set_edit_pos from marker unrolling if it is redundant)
view_set_edit_pos(view, edit_pos);
view_set_cursor_and_scroll(view, new_cursor, true, view->transient.file_data.file->settings.unwrapped_lines, scroll);
}
}
@ -436,12 +436,13 @@ edit_clear(System_Functions *system, Models *models, Editing_File *file){
cursor.line = 1;
cursor.character = 1;
cursor.wrap_line = 1;
view_set_cursor(view, cursor, true, file->settings.unwrapped_lines);
view_set_cursor(system, view, cursor, true, file->settings.unwrapped_lines);
no_views_see_file = false;
}
}
if (no_views_see_file){
block_zero_struct(&file->state.edit_pos_most_recent);
block_zero(file->state.edit_pos_stack, sizeof(file->state.edit_pos_stack));
file->state.edit_pos_stack_top = -1;
}

View File

@ -19,8 +19,8 @@ to_file_id(i32 id){
////////////////////////////////
internal void
edit_pos_set_cursor(File_Edit_Positions *edit_pos, Full_Cursor cursor, b32 set_preferred_x, b32 unwrapped_lines){
edit_pos->cursor = cursor;
file_edit_positions_set_cursor(File_Edit_Positions *edit_pos, Full_Cursor cursor, b32 set_preferred_x, b32 unwrapped_lines){
edit_pos->cursor_pos = cursor.pos;
if (set_preferred_x){
if (unwrapped_lines){
edit_pos->preferred_x = cursor.unwrapped_x;
@ -33,13 +33,13 @@ edit_pos_set_cursor(File_Edit_Positions *edit_pos, Full_Cursor cursor, b32 set_p
}
internal void
edit_pos_set_scroll(File_Edit_Positions *edit_pos, GUI_Scroll_Vars scroll){
file_edit_positions_set_scroll(File_Edit_Positions *edit_pos, GUI_Scroll_Vars scroll){
edit_pos->scroll = scroll;
edit_pos->last_set_type = EditPos_ScrollSet;
}
internal void
edit_pos_push(Editing_File *file, File_Edit_Positions edit_pos){
file_edit_positions_push(Editing_File *file, File_Edit_Positions edit_pos){
if (file->state.edit_pos_stack_top + 1 < ArrayCount(file->state.edit_pos_stack)){
file->state.edit_pos_stack_top += 1;
file->state.edit_pos_stack[file->state.edit_pos_stack_top] = edit_pos;
@ -47,7 +47,7 @@ edit_pos_push(Editing_File *file, File_Edit_Positions edit_pos){
}
internal File_Edit_Positions
edit_pos_pop(Editing_File *file){
file_edit_positions_pop(Editing_File *file){
File_Edit_Positions edit_pos = {};
if (file->state.edit_pos_stack_top >= 0){
edit_pos = file->state.edit_pos_stack[file->state.edit_pos_stack_top];
@ -229,7 +229,7 @@ file_compute_partial_cursor(Editing_File *file, Buffer_Seek seek, Partial_Cursor
}
internal Full_Cursor
file_compute_cursor(System_Functions *system, Editing_File *file, Buffer_Seek seek, b32 return_hint){
file_compute_cursor__inner(System_Functions *system, Editing_File *file, Buffer_Seek seek, b32 return_hint){
Font_Pointers font = system->font.get_pointers_by_id(file->settings.font_id);
Assert(font.valid);
@ -252,10 +252,10 @@ file_compute_cursor(System_Functions *system, Editing_File *file, Buffer_Seek se
i32 size = buffer_size(params.buffer);
f32 line_shift = 0.f;
b32 do_wrap = 0;
b32 do_wrap = false;
i32 wrap_unit_end = 0;
b32 first_wrap_determination = 1;
b32 first_wrap_determination = true;
i32 wrap_array_index = 0;
do{
@ -264,7 +264,7 @@ file_compute_cursor(System_Functions *system, Editing_File *file, Buffer_Seek se
case BLStatus_NeedWrapDetermination:
{
if (stop.pos >= size){
do_wrap = 0;
do_wrap = false;
wrap_unit_end = max_i32;
}
else{
@ -272,18 +272,18 @@ file_compute_cursor(System_Functions *system, Editing_File *file, Buffer_Seek se
wrap_array_index = binary_search(file->state.wrap_positions, stop.pos, 0, file->state.wrap_position_count);
++wrap_array_index;
if (file->state.wrap_positions[wrap_array_index] == stop.pos){
do_wrap = 1;
do_wrap = true;
wrap_unit_end = file->state.wrap_positions[wrap_array_index];
}
else{
do_wrap = 0;
do_wrap = false;
wrap_unit_end = file->state.wrap_positions[wrap_array_index];
}
first_wrap_determination = 0;
first_wrap_determination = false;
}
else{
Assert(stop.pos == wrap_unit_end);
do_wrap = 1;
do_wrap = true;
++wrap_array_index;
wrap_unit_end = file->state.wrap_positions[wrap_array_index];
}
@ -301,6 +301,16 @@ file_compute_cursor(System_Functions *system, Editing_File *file, Buffer_Seek se
return(result);
}
internal Full_Cursor
file_compute_cursor(System_Functions *system, Editing_File *file, Buffer_Seek seek){
return(file_compute_cursor__inner(system, file, seek, false));
}
internal Full_Cursor
file_compute_cursor_hint(System_Functions *system, Editing_File *file, Buffer_Seek seek){
return(file_compute_cursor__inner(system, file, seek, true));
}
////////////////////////////////
internal i32

View File

@ -19,7 +19,7 @@ enum Edit_Pos_Set_Type{
};
struct File_Edit_Positions{
GUI_Scroll_Vars scroll;
Full_Cursor cursor;
i32 cursor_pos;
i32 mark;
f32 preferred_x;
i32 scroll_i;
@ -27,11 +27,13 @@ struct File_Edit_Positions{
b32 in_view;
};
// TODO(NAME): Replace this with markers over time.
// TODO(NAME): do(replace Text_Effect with markers over time)
struct Text_Effect{
i32 start, end;
i32 start;
i32 end;
u32 color;
f32 seconds_down, seconds_max;
f32 seconds_down;
f32 seconds_max;
};
union Buffer_Slot_ID{

View File

@ -87,19 +87,16 @@ view_height(View *view){
}
internal Vec2
view_get_cursor_xy(View *view){
Full_Cursor *cursor = 0;
if (view->transient.file_data.show_temp_highlight){
cursor = &view->transient.file_data.temp_highlight;
view_get_cursor_xy(System_Functions *system, View *view){
File_Edit_Positions edit_pos = view_get_edit_pos(view);
i32 pos = edit_pos.cursor_pos;
Full_Cursor cursor = file_compute_cursor(system, view->transient.file_data.file, seek_pos(pos));
Vec2 result = {};
if (view->transient.file_data.file->settings.unwrapped_lines){
result = V2(cursor.unwrapped_x, cursor.unwrapped_y);
}
else{
File_Edit_Positions edit_pos = view_get_edit_pos(view);
cursor = &edit_pos.cursor;
}
Vec2 result = V2(cursor->wrapped_x, cursor->wrapped_y);
if (view->transient.file_data.file->settings.unwrapped_lines){
result.x = cursor->unwrapped_x;
result.y = cursor->unwrapped_y;
result = V2(cursor.wrapped_x, cursor.wrapped_y);
}
return(result);
}
@ -169,12 +166,12 @@ view_lock_flags(View *view){
////////////////////////////////
internal b32
view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll, b32 center_view){
view_move_view_to_cursor(System_Functions *system, View *view, GUI_Scroll_Vars *scroll, b32 center_view){
b32 result = 0;
f32 max_x = view_width(view);
i32 max_y = view_compute_max_target_y(view);
Vec2 cursor = view_get_cursor_xy(view);
Vec2 cursor = view_get_cursor_xy(system, view);
GUI_Scroll_Vars scroll_vars = *scroll;
i32 target_x = scroll_vars.target_x;
@ -218,12 +215,17 @@ view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll, b32 center_view){
}
internal b32
view_move_cursor_to_view(System_Functions *system, View *view, GUI_Scroll_Vars scroll, Full_Cursor *cursor, f32 preferred_x){
i32 line_height = view->transient.line_height;
f32 old_cursor_y = cursor->wrapped_y;
view_move_cursor_to_view(System_Functions *system, View *view, GUI_Scroll_Vars scroll, i32 *pos_in_out, f32 preferred_x){
Editing_File *file = view->transient.file_data.file;
Full_Cursor cursor = file_compute_cursor(system, file, seek_pos(*pos_in_out));
i32 line_height = view->transient.line_height;
f32 old_cursor_y = 0.f;
if (file->settings.unwrapped_lines){
old_cursor_y = cursor->unwrapped_y;
old_cursor_y = cursor.unwrapped_y;
}
else{
old_cursor_y = cursor.wrapped_y;
}
f32 cursor_y = old_cursor_y;
f32 target_y = scroll.target_y + view->transient.widget_height;
@ -246,7 +248,8 @@ view_move_cursor_to_view(System_Functions *system, View *view, GUI_Scroll_Vars s
cursor_y -= line_height;
}
Buffer_Seek seek = seek_xy(preferred_x, cursor_y, false, file->settings.unwrapped_lines);
*cursor = file_compute_cursor(system, file, seek, false);
cursor = file_compute_cursor(system, file, seek);
*pos_in_out = cursor.pos;
result = true;
}
@ -254,39 +257,42 @@ view_move_cursor_to_view(System_Functions *system, View *view, GUI_Scroll_Vars s
}
internal void
view_set_cursor(View *view, Full_Cursor cursor, b32 set_preferred_x, b32 unwrapped_lines){
view_set_cursor(System_Functions *system, View *view, Full_Cursor cursor, b32 set_preferred_x, b32 unwrapped_lines){
File_Edit_Positions edit_pos = view_get_edit_pos(view);
edit_pos_set_cursor(&edit_pos, cursor, set_preferred_x, unwrapped_lines);
GUI_Scroll_Vars scroll = edit_pos.scroll;
if (view_move_view_to_cursor(view, &scroll, 0)){
edit_pos.scroll = scroll;
}
file_edit_positions_set_cursor(&edit_pos, cursor, set_preferred_x, unwrapped_lines);
view_set_edit_pos(view, edit_pos);
GUI_Scroll_Vars scroll = edit_pos.scroll;
if (view_move_view_to_cursor(system, view, &scroll, 0)){
edit_pos.scroll = scroll;
view_set_edit_pos(view, edit_pos);
}
}
internal void
view_set_scroll(System_Functions *system, View *view, GUI_Scroll_Vars scroll){
File_Edit_Positions edit_pos = view_get_edit_pos(view);
edit_pos_set_scroll(&edit_pos, scroll);
Full_Cursor cursor = edit_pos.cursor;
if (view_move_cursor_to_view(system, view, edit_pos.scroll, &cursor, edit_pos.preferred_x)){
edit_pos.cursor = cursor;
}
file_edit_positions_set_scroll(&edit_pos, scroll);
view_set_edit_pos(view, edit_pos);
i32 pos = edit_pos.cursor_pos;
if (view_move_cursor_to_view(system, view, edit_pos.scroll, &pos, edit_pos.preferred_x)){
Full_Cursor cursor = file_compute_cursor(system, view->transient.file_data.file, seek_pos(pos));
edit_pos.cursor_pos = cursor.pos;
view_set_edit_pos(view, edit_pos);
}
}
internal void
view_set_cursor_and_scroll(View *view, Full_Cursor cursor, b32 set_preferred_x, b32 unwrapped_lines, GUI_Scroll_Vars scroll){
File_Edit_Positions edit_pos = view_get_edit_pos(view);
edit_pos_set_cursor(&edit_pos, cursor, set_preferred_x, unwrapped_lines);
edit_pos_set_scroll(&edit_pos, scroll);
file_edit_positions_set_cursor(&edit_pos, cursor, set_preferred_x, unwrapped_lines);
file_edit_positions_set_scroll(&edit_pos, scroll);
edit_pos.last_set_type = EditPos_None;
view_set_edit_pos(view, edit_pos);
}
internal Relative_Scrolling
view_get_relative_scrolling(View *view){
Vec2 cursor = view_get_cursor_xy(view);
view_get_relative_scrolling(System_Functions *system, View *view){
Vec2 cursor = view_get_cursor_xy(system, view);
File_Edit_Positions edit_pos = view_get_edit_pos(view);
Relative_Scrolling result = {};
result.scroll_y = cursor.y - edit_pos.scroll.scroll_y;
@ -295,8 +301,8 @@ view_get_relative_scrolling(View *view){
}
internal void
view_set_relative_scrolling(View *view, Relative_Scrolling scrolling){
Vec2 cursor = view_get_cursor_xy(view);
view_set_relative_scrolling(System_Functions *system, View *view, Relative_Scrolling scrolling){
Vec2 cursor = view_get_cursor_xy(system, view);
File_Edit_Positions edit_pos = view_get_edit_pos(view);
edit_pos.scroll.scroll_y = cursor.y - scrolling.scroll_y;
edit_pos.scroll.target_y = round32(clamp_bottom(0.f, cursor.y - scrolling.target_y));
@ -307,19 +313,8 @@ internal void
view_cursor_move(System_Functions *system, View *view, i32 pos){
Editing_File *file = view->transient.file_data.file;
Assert(file != 0);
Full_Cursor cursor = file_compute_cursor(system, file, seek_pos(pos), 0);
view_set_cursor(view, cursor, true, file->settings.unwrapped_lines);
view->transient.file_data.show_temp_highlight = false;
}
internal void
view_set_temp_highlight(System_Functions *system, View *view, i32 pos, i32 end_pos){
Editing_File *file = view->transient.file_data.file;
Assert(file != 0);
view->transient.file_data.temp_highlight = file_compute_cursor(system, file, seek_pos(pos), 0);
view->transient.file_data.temp_highlight_end_pos = end_pos;
view->transient.file_data.show_temp_highlight = true;
view_set_cursor(view, view->transient.file_data.temp_highlight, 0, file->settings.unwrapped_lines);
Full_Cursor cursor = file_compute_cursor(system, file, seek_pos(pos));
view_set_cursor(system, view, cursor, true, file->settings.unwrapped_lines);
}
internal void
@ -341,22 +336,24 @@ view_set_file(System_Functions *system, Models *models, View *view, Editing_File
Editing_File *old_file = view->transient.file_data.file;
if (old_file != 0){
file_touch(&models->working_set, old_file);
edit_pos_push(old_file, view_get_edit_pos(view));
file_edit_positions_push(old_file, view_get_edit_pos(view));
}
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_ = edit_pos_pop(file);
view->transient.edit_pos_ = file_edit_positions_pop(file);
Font_Pointers font = system->font.get_pointers_by_id(file->settings.font_id);
view->transient.line_height = font.metrics->height;
#if 0
File_Edit_Positions edit_pos = view_get_edit_pos(view);
if (edit_pos.cursor.line == 0){
view_cursor_move(system, view, 0);
}
#endif
}
////////////////////////////////
@ -385,17 +382,9 @@ adjust_views_looking_at_file_to_new_cursor(System_Functions *system, Models *mod
panel = layout_get_next_open_panel(layout, panel)){
View *view = panel->view;
if (view->transient.file_data.file == file){
if (!view->transient.file_data.show_temp_highlight){
File_Edit_Positions edit_pos = view_get_edit_pos(view);
i32 pos = edit_pos.cursor.pos;
Full_Cursor cursor = file_compute_cursor(system, file, seek_pos(pos), 0);
view_set_cursor(view, cursor, 1, file->settings.unwrapped_lines);
}
else{
i32 pos = view->transient.file_data.temp_highlight.pos;
i32 end = view->transient.file_data.temp_highlight_end_pos;
view_set_temp_highlight(system, view, pos, end);
}
File_Edit_Positions edit_pos = view_get_edit_pos(view);
Full_Cursor cursor = file_compute_cursor(system, file, seek_pos(edit_pos.cursor_pos));
view_set_cursor(system, view, cursor, true, file->settings.unwrapped_lines);
}
}
}
@ -1238,10 +1227,10 @@ render_loaded_file_in_view(System_Functions *system, View *view, Models *models,
Full_Cursor render_cursor = {};
if (!file->settings.unwrapped_lines){
render_cursor = file_compute_cursor(system, file, seek_wrapped_xy(0, scroll_y, 0), true);
render_cursor = file_compute_cursor_hint(system, file, seek_wrapped_xy(0, scroll_y, 0));
}
else{
render_cursor = file_compute_cursor(system, file, seek_unwrapped_xy(0, scroll_y, 0), true);
render_cursor = file_compute_cursor_hint(system, file, seek_unwrapped_xy(0, scroll_y, 0));
}
// TODO(allen): do(eliminate scroll_i nonsense)

View File

@ -19,15 +19,9 @@ struct View_Persistent{
struct File_Viewing_Data{
Editing_File *file;
Full_Cursor temp_highlight;
i32 temp_highlight_end_pos;
b32 show_temp_highlight;
b32 show_whitespace;
b32 file_locked;
};
global File_Viewing_Data null_file_viewing_data = {};
struct View_Transient{
struct View *next;

View File

@ -82,7 +82,7 @@ do_step_file_view(System_Functions *system, View *view, Models *models, i32_Rect
i32 target_x = 0;
i32 target_y = 0;
if (file_is_ready(file)){
Vec2 cursor = view_get_cursor_xy(view);
Vec2 cursor = view_get_cursor_xy(system, view);
f32 width = view_width(view);
f32 height = view_height(view);
@ -184,12 +184,14 @@ draw_file_bar(System_Functions *system, Render_Target *target, View *view, Model
}
else{
File_Edit_Positions edit_pos = view_get_edit_pos(view);
Full_Cursor cursor = file_compute_cursor(system, view->transient.file_data.file, seek_pos(edit_pos.cursor_pos));
char bar_space[526];
String bar_text = make_fixed_width_string(bar_space);
append_ss (&bar_text, lit(" L#"));
append_int_to_str(&bar_text, edit_pos.cursor.line);
append_int_to_str(&bar_text, cursor.line);
append_ss (&bar_text, lit(" C#"));
append_int_to_str(&bar_text, edit_pos.cursor.character);
append_int_to_str(&bar_text, cursor.character);
append_ss(&bar_text, lit(" -"));