Remove the persistent and transient sub parts of the view, just a view now

master
Allen Webster 2019-02-10 01:18:34 -08:00
parent 7b4705be60
commit 90163a2f85
10 changed files with 237 additions and 230 deletions

View File

@ -9,7 +9,7 @@ buffer_find_hard_start(Application_Links *app, Buffer_Summary *buffer, int32_t l
tab_width -= 1; tab_width -= 1;
Hard_Start_Result result = {}; Hard_Start_Result result = {};
result.all_space = 1; result.all_space = true;
result.indent_pos = 0; result.indent_pos = 0;
result.char_pos = line_start; result.char_pos = line_start;
@ -17,7 +17,7 @@ buffer_find_hard_start(Application_Links *app, Buffer_Summary *buffer, int32_t l
Stream_Chunk stream = {}; Stream_Chunk stream = {};
stream.add_null = true; stream.add_null = true;
if (init_stream_chunk(&stream, app, buffer, line_start, data_chunk, sizeof(data_chunk))){ if (init_stream_chunk(&stream, app, buffer, line_start, data_chunk, sizeof(data_chunk))){
int32_t still_looping = 1; bool32 still_looping = true;
do{ do{
for (; result.char_pos < stream.end; ++result.char_pos){ for (; result.char_pos < stream.end; ++result.char_pos){
char c = stream.data[result.char_pos]; char c = stream.data[result.char_pos];
@ -36,7 +36,7 @@ buffer_find_hard_start(Application_Links *app, Buffer_Summary *buffer, int32_t l
} }
if (c != ' '){ if (c != ' '){
result.all_space = 0; result.all_space = false;
} }
result.indent_pos += 1; result.indent_pos += 1;
@ -51,8 +51,7 @@ buffer_find_hard_start(Application_Links *app, Buffer_Summary *buffer, int32_t l
static Buffer_Batch_Edit static Buffer_Batch_Edit
make_batch_from_indent_marks(Application_Links *app, Partition *arena, Buffer_Summary *buffer, make_batch_from_indent_marks(Application_Links *app, Partition *arena, Buffer_Summary *buffer,
int32_t first_line, int32_t one_past_last_line, int32_t first_line, int32_t one_past_last_line, int32_t *indent_marks, Indent_Options opts){
int32_t *indent_marks, Indent_Options opts){
int32_t *shifted_indent_marks = indent_marks - first_line; int32_t *shifted_indent_marks = indent_marks - first_line;
int32_t edit_count = 0; int32_t edit_count = 0;

View File

@ -242,9 +242,9 @@ int32_t line_number;
}; };
static Command_Metadata fcoder_metacmd_table[220] = { static Command_Metadata fcoder_metacmd_table[220] = {
{ PROC_LINKS(allow_mouse, 0), "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 240 }, { PROC_LINKS(allow_mouse, 0), "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 240 },
{ PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 722 }, { PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 721 },
{ PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 733 }, { PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 732 },
{ PROC_LINKS(auto_tab_whole_file, 0), "auto_tab_whole_file", 19, "Audo-indents the entire current buffer.", 39, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 712 }, { PROC_LINKS(auto_tab_whole_file, 0), "auto_tab_whole_file", 19, "Audo-indents the entire current buffer.", 39, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 711 },
{ PROC_LINKS(backspace_char, 0), "backspace_char", 14, "Deletes the character to the left of the cursor.", 48, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 97 }, { PROC_LINKS(backspace_char, 0), "backspace_char", 14, "Deletes the character to the left of the cursor.", 48, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 97 },
{ PROC_LINKS(backspace_word, 0), "backspace_word", 14, "Delete characters between the cursor position and the first alphanumeric boundary to the left.", 94, "w:\\4ed\\code\\4coder_seek.cpp", 27, 1258 }, { PROC_LINKS(backspace_word, 0), "backspace_word", 14, "Delete characters between the cursor position and the first alphanumeric boundary to the left.", 94, "w:\\4ed\\code\\4coder_seek.cpp", 27, 1258 },
{ PROC_LINKS(basic_change_active_panel, 0), "basic_change_active_panel", 25, "Change the currently active panel, moving to the panel with the next highest view_id. Will not skipe the build panel if it is open.", 132, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 504 }, { PROC_LINKS(basic_change_active_panel, 0), "basic_change_active_panel", 25, "Change the currently active panel, moving to the panel with the next highest view_id. Will not skipe the build panel if it is open.", 132, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 504 },
@ -453,7 +453,7 @@ static Command_Metadata fcoder_metacmd_table[220] = {
{ PROC_LINKS(view_buffer_other_panel, 0), "view_buffer_other_panel", 23, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1542 }, { PROC_LINKS(view_buffer_other_panel, 0), "view_buffer_other_panel", 23, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1542 },
{ PROC_LINKS(view_jump_list_with_lister, 0), "view_jump_list_with_lister", 26, "When executed on a buffer with jumps, creates a persistent lister for all the jumps", 83, "w:\\4ed\\code\\4coder_jump_lister.cpp", 34, 108 }, { PROC_LINKS(view_jump_list_with_lister, 0), "view_jump_list_with_lister", 26, "When executed on a buffer with jumps, creates a persistent lister for all the jumps", 83, "w:\\4ed\\code\\4coder_jump_lister.cpp", 34, 108 },
{ PROC_LINKS(word_complete, 0), "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "w:\\4ed\\code\\4coder_search.cpp", 29, 856 }, { PROC_LINKS(word_complete, 0), "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "w:\\4ed\\code\\4coder_search.cpp", 29, 856 },
{ PROC_LINKS(write_and_auto_tab, 0), "write_and_auto_tab", 18, "Inserts a character and auto-indents the line on which the cursor sits.", 71, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 745 }, { PROC_LINKS(write_and_auto_tab, 0), "write_and_auto_tab", 18, "Inserts a character and auto-indents the line on which the cursor sits.", 71, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 744 },
{ PROC_LINKS(write_block, 0), "write_block", 11, "At the cursor, insert a block comment.", 38, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 103 }, { PROC_LINKS(write_block, 0), "write_block", 11, "At the cursor, insert a block comment.", 38, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 103 },
{ PROC_LINKS(write_character, 0), "write_character", 15, "Inserts whatever character was used to trigger this command.", 60, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 63 }, { PROC_LINKS(write_character, 0), "write_character", 15, "Inserts whatever character was used to trigger this command.", 60, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 63 },
{ PROC_LINKS(write_hack, 0), "write_hack", 10, "At the cursor, insert a '// HACK' comment, includes user name if it was specified in config.4coder.", 99, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 91 }, { PROC_LINKS(write_hack, 0), "write_hack", 10, "At the cursor, insert a '// HACK' comment, includes user name if it was specified in config.4coder.", 99, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 91 },

37
4ed.cpp
View File

@ -78,12 +78,12 @@ file_cursor_to_end(System_Functions *system, Models *models, Editing_File *file)
panel != 0; panel != 0;
panel = layout_get_next_open_panel(layout, panel)){ panel = layout_get_next_open_panel(layout, panel)){
View *view = panel->view; View *view = panel->view;
if (view->transient.file_data.file != file){ if (view->file_data.file != file){
continue; continue;
} }
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);
view->transient.mark = edit_pos.cursor_pos; view->mark = edit_pos.cursor_pos;
} }
} }
@ -105,8 +105,8 @@ file_cursor_to_end(System_Functions *system, Models *models, Editing_File *file)
#define REQ_OPEN_VIEW(n) USE_VIEW(n); if (view_lock_flags(n) != 0) return #define REQ_OPEN_VIEW(n) USE_VIEW(n); if (view_lock_flags(n) != 0) return
#define REQ_FILE(n,v) Editing_File *n = (v)->transient.file_data.file; if (n == 0) return #define REQ_FILE(n,v) Editing_File *n = (v)->file_data.file; if (n == 0) return
#define REQ_FILE_HISTORY(n,v) Editing_File *n = (v)->transient.file_data.file; if (n == 0 || n->state.undo.undo.edits == 0) return #define REQ_FILE_HISTORY(n,v) Editing_File *n = (v)->file_data.file; if (n == 0 || n->state.undo.undo.edits == 0) return
SCROLL_RULE_SIG(fallback_scroll_rule){ SCROLL_RULE_SIG(fallback_scroll_rule){
b32 result = false; b32 result = false;
@ -736,7 +736,7 @@ force_abort_coroutine(System_Functions *system, Models *models, View *view){
// TODO(allen): post grave warning // TODO(allen): post grave warning
models->command_coroutine = 0; models->command_coroutine = 0;
} }
init_query_set(&view->transient.query_set); init_query_set(&view->query_set);
} }
internal void internal void
@ -802,20 +802,17 @@ App_Init_Sig(app_init){
models->live_set.views = push_array(part, View, models->live_set.max); models->live_set.views = push_array(part, View, models->live_set.max);
//dll_init_sentinel //dll_init_sentinel
models->live_set.free_sentinel.transient.next = &models->live_set.free_sentinel; models->live_set.free_sentinel.next = &models->live_set.free_sentinel;
models->live_set.free_sentinel.transient.prev = &models->live_set.free_sentinel; models->live_set.free_sentinel.prev = &models->live_set.free_sentinel;
i32 max = models->live_set.max; i32 max = models->live_set.max;
View *view = models->live_set.views; View *view = models->live_set.views;
for (i32 i = 0; i < max; ++i, ++view){ for (i32 i = 0; i < max; ++i, ++view){
//dll_insert(&models->live_set.free_sentinel, view); //dll_insert(&models->live_set.free_sentinel, view);
view->transient.next = models->live_set.free_sentinel.transient.next; view->next = models->live_set.free_sentinel.next;
view->transient.prev = &models->live_set.free_sentinel; view->prev = &models->live_set.free_sentinel;
models->live_set.free_sentinel.transient.next = view; models->live_set.free_sentinel.next = view;
view->transient.next->transient.prev = view; view->next->prev = view;
View_Persistent *persistent = &view->persistent;
persistent->id = i;
} }
} }
@ -907,7 +904,7 @@ App_Init_Sig(app_init){
Panel *panel = layout_initialize(part, &models->layout); Panel *panel = layout_initialize(part, &models->layout);
View *new_view = live_set_alloc_view(&models->mem.heap, &models->lifetime_allocator, &models->live_set); View *new_view = live_set_alloc_view(&models->mem.heap, &models->lifetime_allocator, &models->live_set);
panel->view = new_view; panel->view = new_view;
new_view->transient.panel = panel; new_view->panel = panel;
view_set_file(system, models, new_view, models->scratch_buffer); view_set_file(system, models, new_view, models->scratch_buffer);
} }
@ -1238,7 +1235,7 @@ App_Step_Sig(app_step){
app_result.animating = true; app_result.animating = true;
if (models->command_coroutine == 0){ if (models->command_coroutine == 0){
init_query_set(&view->transient.query_set); init_query_set(&view->query_set);
} }
} }
} }
@ -1294,20 +1291,20 @@ App_Step_Sig(app_step){
i32 max_y = 0; i32 max_y = 0;
b32 file_scroll = false; b32 file_scroll = false;
File_Edit_Positions edit_pos = view_get_edit_pos(view); File_Edit_Positions edit_pos = view_get_edit_pos(view);
if (!view->transient.ui_mode){ if (!view->ui_mode){
scroll_vars = &edit_pos.scroll; scroll_vars = &edit_pos.scroll;
max_y = view_compute_max_target_y(view); max_y = view_compute_max_target_y(view);
file_scroll = true; file_scroll = true;
} }
else{ else{
scroll_vars = &view->transient.ui_scroll; scroll_vars = &view->ui_scroll;
i32 bottom = view->transient.ui_control.bounding_box[UICoordinates_Scrolled].y1; i32 bottom = view->ui_control.bounding_box[UICoordinates_Scrolled].y1;
max_y = view_compute_max_target_y_from_bottom_y(view, (f32)bottom); max_y = view_compute_max_target_y_from_bottom_y(view, (f32)bottom);
file_scroll = false; file_scroll = false;
} }
b32 active = (panel == active_panel); b32 active = (panel == active_panel);
Input_Process_Result ip_result = do_step_file_view(system, view, models, panel->rect_inner, active, dt, *scroll_vars, max_y); Input_Process_Result ip_result = do_step_file_view(system, models, view, panel->rect_inner, active, dt, *scroll_vars, max_y);
if (ip_result.is_animating){ if (ip_result.is_animating){
app_result.animating = true; app_result.animating = true;

View File

@ -51,32 +51,32 @@ fill_buffer_summary(Buffer_Summary *buffer, Editing_File *file, Working_Set *wor
internal void internal void
fill_view_summary(System_Functions *system, View_Summary *view, View *vptr, Live_Views *live_set, Working_Set *working_set){ fill_view_summary(System_Functions *system, View_Summary *view, View *vptr, Live_Views *live_set, Working_Set *working_set){
File_Viewing_Data *data = &vptr->transient.file_data; File_Viewing_Data *data = &vptr->file_data;
memset(view, 0, sizeof(*view)); memset(view, 0, sizeof(*view));
if (vptr->transient.in_use){ if (vptr->in_use){
view->exists = true; view->exists = true;
view->view_id = (int32_t)(vptr - live_set->views) + 1; view->view_id = (int32_t)(vptr - live_set->views) + 1;
view->line_height = (f32)(vptr->transient.line_height); view->line_height = (f32)(vptr->line_height);
view->unwrapped_lines = data->file->settings.unwrapped_lines; view->unwrapped_lines = data->file->settings.unwrapped_lines;
view->show_whitespace = data->show_whitespace; view->show_whitespace = data->show_whitespace;
view->lock_flags = view_lock_flags(vptr); view->lock_flags = view_lock_flags(vptr);
view->buffer_id = vptr->transient.file_data.file->id.id; view->buffer_id = vptr->file_data.file->id.id;
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(vptr->transient.mark)); view->mark = file_compute_cursor(system, data->file, seek_pos(vptr->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 = vptr->preferred_x;
view->view_region = vptr->transient.panel->rect_inner; view->view_region = vptr->panel->rect_inner;
view->file_region = vptr->transient.file_region; view->file_region = vptr->file_region;
if (vptr->transient.ui_mode){ if (vptr->ui_mode){
view->scroll_vars = vptr->transient.ui_scroll; view->scroll_vars = vptr->ui_scroll;
} }
else{ else{
view->scroll_vars = edit_pos.scroll; view->scroll_vars = edit_pos.scroll;
@ -92,11 +92,11 @@ fill_view_summary(System_Functions *system, View_Summary *view, View *vptr, Mode
internal void internal void
view_quit_ui(System_Functions *system, Models *models, View *view){ view_quit_ui(System_Functions *system, Models *models, View *view){
Assert(view != 0); Assert(view != 0);
view->transient.ui_mode = false; view->ui_mode = false;
if (view->transient.ui_quit != 0){ if (view->ui_quit != 0){
View_Summary view_summary = {}; View_Summary view_summary = {};
fill_view_summary(system, &view_summary, view, models); fill_view_summary(system, &view_summary, view, models);
view->transient.ui_quit(&models->app_links, view_summary); view->ui_quit(&models->app_links, view_summary);
} }
} }
@ -139,7 +139,7 @@ imp_get_view(Models *models, View_ID view_id){
view_id = view_id - 1; view_id = view_id - 1;
if (0 <= view_id && view_id < live_set->max){ if (0 <= view_id && view_id < live_set->max){
vptr = live_set->views + view_id; vptr = live_set->views + view_id;
if (!vptr->transient.in_use){ if (!vptr->in_use){
vptr = 0; vptr = 0;
} }
} }
@ -1347,9 +1347,9 @@ DOC_SEE(Buffer_Identifier)
panel != 0; panel != 0;
panel = layout_get_next_open_panel(layout, panel)){ panel = layout_get_next_open_panel(layout, panel)){
View *view = panel->view; View *view = panel->view;
if (view->transient.file_data.file == file){ if (view->file_data.file == file){
Assert(file_node != used); Assert(file_node != used);
view->transient.file_data.file = 0; view->file_data.file = 0;
Editing_File *new_file = CastFromMember(Editing_File, main_chain_node, file_node); Editing_File *new_file = CastFromMember(Editing_File, main_chain_node, file_node);
view_set_file(system, models, view, new_file); view_set_file(system, models, view, new_file);
if (file_node->next != used){ if (file_node->next != used){
@ -1406,15 +1406,15 @@ Reopen_Buffer(Application_Links *app, Buffer_Summary *buffer, Buffer_Reopen_Flag
panel != 0; panel != 0;
panel = layout_get_next_open_panel(layout, panel)){ panel = layout_get_next_open_panel(layout, panel)){
View *view_it = panel->view; View *view_it = panel->view;
if (view_it->transient.file_data.file != file){ if (view_it->file_data.file != file){
continue; continue;
} }
vptrs[vptr_count] = view_it; vptrs[vptr_count] = view_it;
File_Edit_Positions edit_pos = view_get_edit_pos(view_it); File_Edit_Positions edit_pos = view_get_edit_pos(view_it);
Full_Cursor cursor = file_compute_cursor(system, view_it->transient.file_data.file, seek_pos(edit_pos.cursor_pos)); Full_Cursor cursor = file_compute_cursor(system, view_it->file_data.file, seek_pos(edit_pos.cursor_pos));
line_numbers[vptr_count] = cursor.line; line_numbers[vptr_count] = cursor.line;
column_numbers[vptr_count] = cursor.character; column_numbers[vptr_count] = cursor.character;
view_it->transient.file_data.file = models->scratch_buffer; view_it->file_data.file = models->scratch_buffer;
++vptr_count; ++vptr_count;
} }
@ -1425,10 +1425,10 @@ Reopen_Buffer(Application_Links *app, Buffer_Summary *buffer, Buffer_Reopen_Flag
for (i32 i = 0; i < vptr_count; ++i){ for (i32 i = 0; i < vptr_count; ++i){
view_set_file(system, models, vptrs[i], file); view_set_file(system, models, vptrs[i], file);
vptrs[i]->transient.file_data.file = file; vptrs[i]->file_data.file = file;
Full_Cursor cursor = file_compute_cursor(system, file, seek_line_char(line_numbers[i], column_numbers[i])); Full_Cursor cursor = file_compute_cursor(system, file, seek_line_char(line_numbers[i], column_numbers[i]));
view_set_cursor(system, vptrs[i], cursor, true, file->settings.unwrapped_lines); view_set_cursor(system, vptrs[i], cursor, true);
} }
result = BufferReopenResult_Reopened; result = BufferReopenResult_Reopened;
@ -1462,7 +1462,7 @@ get_view_next__internal(Models *models, View_Summary *view){
i32 index = view->view_id - 1; i32 index = view->view_id - 1;
if (index >= 0 && index < live_set->max){ if (index >= 0 && index < live_set->max){
View *vptr = live_set->views + index; View *vptr = live_set->views + index;
Panel *panel = vptr->transient.panel; Panel *panel = vptr->panel;
if (panel != 0){ if (panel != 0){
panel = layout_get_next_open_panel(layout, panel); panel = layout_get_next_open_panel(layout, panel);
} }
@ -1581,7 +1581,7 @@ DOC_SEE(View_Split_Position)
System_Functions *system = models->system; System_Functions *system = models->system;
Layout *layout = &models->layout; Layout *layout = &models->layout;
View *vptr = imp_get_view(models, view_location); View *vptr = imp_get_view(models, view_location);
Panel *panel = vptr->transient.panel; Panel *panel = vptr->panel;
View_Summary result = {}; View_Summary result = {};
b32 vertical_split = ((position == ViewSplit_Left) || (position == ViewSplit_Right)); b32 vertical_split = ((position == ViewSplit_Left) || (position == ViewSplit_Right));
b32 br_split = ((position == ViewSplit_Bottom) || (position == ViewSplit_Right)); b32 br_split = ((position == ViewSplit_Bottom) || (position == ViewSplit_Right));
@ -1589,7 +1589,7 @@ DOC_SEE(View_Split_Position)
if (new_panel != 0){ if (new_panel != 0){
View *new_view = live_set_alloc_view(&models->mem.heap, &models->lifetime_allocator, &models->live_set); View *new_view = live_set_alloc_view(&models->mem.heap, &models->lifetime_allocator, &models->live_set);
new_panel->view = new_view; new_panel->view = new_view;
new_view->transient.panel = new_panel; new_view->panel = new_panel;
view_set_file(system, models, new_view, models->scratch_buffer); view_set_file(system, models, new_view, models->scratch_buffer);
fill_view_summary(system, &result, new_view, models); fill_view_summary(system, &result, new_view, models);
} }
@ -1614,7 +1614,7 @@ in the system, the call will fail.)
bool32 result = false; bool32 result = false;
if (vptr != 0){ if (vptr != 0){
if (layout_close_panel(layout, vptr->transient.panel)){ if (layout_close_panel(layout, vptr->panel)){
live_set_free_view(&models->mem.heap, &models->lifetime_allocator, &models->live_set, vptr); live_set_free_view(&models->mem.heap, &models->lifetime_allocator, &models->live_set, vptr);
result = true; result = true;
} }
@ -1637,7 +1637,7 @@ DOC_SEE(get_active_view)
View *vptr = imp_get_view(models, view); View *vptr = imp_get_view(models, view);
bool32 result = false; bool32 result = false;
if (vptr != 0){ if (vptr != 0){
models->layout.active_panel = vptr->transient.panel; models->layout.active_panel = vptr->panel;
result = true; result = true;
} }
return(result); return(result);
@ -1660,22 +1660,22 @@ DOC_RETURN(returns non-zero on success)
switch (setting){ switch (setting){
case ViewSetting_ShowWhitespace: case ViewSetting_ShowWhitespace:
{ {
*value_out = vptr->transient.file_data.show_whitespace; *value_out = vptr->file_data.show_whitespace;
}break; }break;
case ViewSetting_ShowScrollbar: case ViewSetting_ShowScrollbar:
{ {
*value_out = !vptr->transient.hide_scrollbar; *value_out = !vptr->hide_scrollbar;
}break; }break;
case ViewSetting_ShowFileBar: case ViewSetting_ShowFileBar:
{ {
*value_out = !vptr->transient.hide_file_bar; *value_out = !vptr->hide_file_bar;
}break; }break;
case ViewSetting_UICommandMap: case ViewSetting_UICommandMap:
{ {
*value_out = vptr->transient.ui_map_id; *value_out = vptr->ui_map_id;
}break; }break;
default: default:
@ -1707,22 +1707,22 @@ DOC_SEE(View_Setting_ID)
switch (setting){ switch (setting){
case ViewSetting_ShowWhitespace: case ViewSetting_ShowWhitespace:
{ {
vptr->transient.file_data.show_whitespace = value; vptr->file_data.show_whitespace = value;
}break; }break;
case ViewSetting_ShowScrollbar: case ViewSetting_ShowScrollbar:
{ {
vptr->transient.hide_scrollbar = !value; vptr->hide_scrollbar = !value;
}break; }break;
case ViewSetting_ShowFileBar: case ViewSetting_ShowFileBar:
{ {
vptr->transient.hide_file_bar = !value; vptr->hide_file_bar = !value;
}break; }break;
case ViewSetting_UICommandMap: case ViewSetting_UICommandMap:
{ {
vptr->transient.ui_map_id = value; vptr->ui_map_id = value;
}break; }break;
default: default:
@ -1750,8 +1750,8 @@ If the view_id does not specify a valid view, the returned scope is null.)
View *view = imp_get_view(models, view_id); View *view = imp_get_view(models, view_id);
Managed_Scope lifetime = 0; Managed_Scope lifetime = 0;
if (view != 0){ if (view != 0){
Assert(view->transient.lifetime_object != 0); Assert(view->lifetime_object != 0);
lifetime = (Managed_Scope)(view->transient.lifetime_object->workspace.scope_id); lifetime = (Managed_Scope)(view->lifetime_object->workspace.scope_id);
} }
return(lifetime); return(lifetime);
} }
@ -1776,7 +1776,7 @@ DOC_RETURN(This call returns non-zero on success.)
View *vptr = imp_get_view(models, view); View *vptr = imp_get_view(models, view);
bool32 result = false; bool32 result = false;
if (vptr != 0){ if (vptr != 0){
Panel *panel = vptr->transient.panel; Panel *panel = vptr->panel;
Panel *intermediate = panel->parent; Panel *intermediate = panel->parent;
if (intermediate != 0){ if (intermediate != 0){
Assert(intermediate->kind == PanelKind_Intermediate); Assert(intermediate->kind == PanelKind_Intermediate);
@ -1828,7 +1828,7 @@ DOC_RETURN(The rectangle of the panel containing this view.)
View *vptr = imp_get_view(models, view); View *vptr = imp_get_view(models, view);
i32_Rect result = {}; i32_Rect result = {};
if (vptr != 0){ if (vptr != 0){
Panel *panel = vptr->transient.panel; Panel *panel = vptr->panel;
Assert(panel != 0); Assert(panel != 0);
Panel *parent = panel->parent; Panel *parent = panel->parent;
if (parent != 0){ if (parent != 0){
@ -1858,7 +1858,7 @@ DOC_SEE(Full_Cursor)
bool32 result = false; bool32 result = false;
if (vptr != 0){ if (vptr != 0){
Editing_File *file = vptr->transient.file_data.file; Editing_File *file = vptr->file_data.file;
Assert(file != 0); Assert(file != 0);
if (!file->is_loading){ if (!file->is_loading){
result = true; result = true;
@ -1886,12 +1886,12 @@ DOC_SEE(Buffer_Seek)
bool32 result = false; bool32 result = false;
if (vptr != 0){ if (vptr != 0){
Editing_File *file = vptr->transient.file_data.file; Editing_File *file = vptr->file_data.file;
if (!file->is_loading){ if (!file->is_loading){
result = true;
Full_Cursor cursor = file_compute_cursor(system, file, seek); Full_Cursor cursor = file_compute_cursor(system, file, seek);
view_set_cursor(system, vptr, cursor, set_preferred_x, file->settings.unwrapped_lines); view_set_cursor(system, vptr, cursor, set_preferred_x);
fill_view_summary(system, view, vptr, models); fill_view_summary(system, view, vptr, models);
result = true;
} }
} }
@ -1912,14 +1912,14 @@ DOC_SEE(GUI_Scroll_Vars)
bool32 result = false; bool32 result = false;
if (vptr != 0){ if (vptr != 0){
Editing_File *file = vptr->transient.file_data.file; Editing_File *file = vptr->file_data.file;
if (!file->is_loading){ if (!file->is_loading){
result = true; result = true;
if (!vptr->transient.ui_mode){ if (!vptr->ui_mode){
view_set_scroll(system, vptr, scroll); view_set_scroll(system, vptr, scroll);
} }
else{ else{
vptr->transient.ui_scroll = scroll; vptr->ui_scroll = scroll;
} }
fill_view_summary(system, view, vptr, models); fill_view_summary(system, view, vptr, models);
} }
@ -1943,17 +1943,17 @@ DOC_SEE(Buffer_Seek)
bool32 result = false; bool32 result = false;
if (vptr != 0){ if (vptr != 0){
Editing_File *file = vptr->transient.file_data.file; Editing_File *file = vptr->file_data.file;
Assert(file != 0); Assert(file != 0);
if (!file->is_loading){ if (!file->is_loading){
if (seek.type != buffer_seek_pos){ if (seek.type != buffer_seek_pos){
result = true; result = true;
Full_Cursor cursor = file_compute_cursor(system, file, seek); Full_Cursor cursor = file_compute_cursor(system, file, seek);
vptr->transient.mark = cursor.pos; vptr->mark = cursor.pos;
} }
else{ else{
result = true; result = true;
vptr->transient.mark = seek.pos; vptr->mark = seek.pos;
} }
fill_view_summary(system, view, vptr, models); fill_view_summary(system, view, vptr, models);
} }
@ -1989,7 +1989,7 @@ DOC_SEE(Set_Buffer_Flag)
Editing_File *file = working_set_get_active_file(&models->working_set, buffer_id); Editing_File *file = working_set_get_active_file(&models->working_set, buffer_id);
if (file != 0){ if (file != 0){
result = true; result = true;
if (file != vptr->transient.file_data.file){ if (file != vptr->file_data.file){
view_set_file(system, models, vptr, file); view_set_file(system, models, vptr, file);
if (!(flags & SetBuffer_KeepOriginalGUI)){ if (!(flags & SetBuffer_KeepOriginalGUI)){
view_quit_ui(system, models, vptr); view_quit_ui(system, models, vptr);
@ -2040,11 +2040,11 @@ DOC_SEE(view_set_ui)
Models *models = (Models*)app->cmd_context; Models *models = (Models*)app->cmd_context;
View *vptr = imp_get_view(models, view); View *vptr = imp_get_view(models, view);
if (vptr != 0){ if (vptr != 0){
if (vptr->transient.ui_mode){ if (vptr->ui_mode){
return(false); return(false);
} }
else{ else{
vptr->transient.ui_mode = true; vptr->ui_mode = true;
return(true); return(true);
} }
} }
@ -2067,9 +2067,9 @@ DOC_SEE(view_set_ui)
bool32 result = false; bool32 result = false;
Models *models = (Models*)app->cmd_context; Models *models = (Models*)app->cmd_context;
View *vptr = imp_get_view(models, view); View *vptr = imp_get_view(models, view);
if (vptr != 0 && vptr->transient.ui_mode){ if (vptr != 0 && vptr->ui_mode){
view_quit_ui(models->system, models, vptr); view_quit_ui(models->system, models, vptr);
vptr->transient.ui_mode = false; vptr->ui_mode = false;
result = true; result = true;
} }
return(result); return(result);
@ -2093,11 +2093,11 @@ DOC_SEE(UI_Quit_Function_Type)
Heap *heap = &models->mem.heap; Heap *heap = &models->mem.heap;
View *vptr = imp_get_view(models, view); View *vptr = imp_get_view(models, view);
if (vptr != 0){ if (vptr != 0){
if (vptr->transient.ui_control.items != 0){ if (vptr->ui_control.items != 0){
heap_free(heap, vptr->transient.ui_control.items); heap_free(heap, vptr->ui_control.items);
} }
memset(&vptr->transient.ui_control, 0, sizeof(vptr->transient.ui_control)); memset(&vptr->ui_control, 0, sizeof(vptr->ui_control));
vptr->transient.ui_quit = quit_function; vptr->ui_quit = quit_function;
if (control != 0){ if (control != 0){
if (control->count > 0){ if (control->count > 0){
i32 string_size = 0; i32 string_size = 0;
@ -2168,14 +2168,14 @@ DOC_SEE(UI_Quit_Function_Type)
memcpy(new_str, old.str, old.size); memcpy(new_str, old.str, old.size);
} }
} }
vptr->transient.ui_control.items = new_items; vptr->ui_control.items = new_items;
vptr->transient.ui_control.count = count; vptr->ui_control.count = count;
} }
else{ else{
return(false); return(false);
} }
} }
memcpy(vptr->transient.ui_control.bounding_box, control->bounding_box, memcpy(vptr->ui_control.bounding_box, control->bounding_box,
sizeof(control->bounding_box)); sizeof(control->bounding_box));
} }
return(true); return(true);
@ -2196,7 +2196,7 @@ DOC_SEE(view_set_ui)
View *vptr = imp_get_view(models, view); View *vptr = imp_get_view(models, view);
UI_Control result = {}; UI_Control result = {};
if (vptr != 0 && part != 0){ if (vptr != 0 && part != 0){
UI_Control *control = &vptr->transient.ui_control; UI_Control *control = &vptr->ui_control;
result.items = push_array(part, UI_Item, control->count); result.items = push_array(part, UI_Item, control->count);
if (result.items != 0){ if (result.items != 0){
result.count = control->count; result.count = control->count;
@ -2280,7 +2280,7 @@ get_lifetime_object_from_workspace(Dynamic_Workspace *workspace){
case DynamicWorkspace_View: case DynamicWorkspace_View:
{ {
View *vptr = (View*)workspace->user_back_ptr; View *vptr = (View*)workspace->user_back_ptr;
result = vptr->transient.lifetime_object; result = vptr->lifetime_object;
}break; }break;
default: default:
{ {
@ -3044,7 +3044,7 @@ max_result_count of 1 and be assured you will get the most recent bar if any exi
Models *models = (Models*)app->cmd_context; Models *models = (Models*)app->cmd_context;
View *view = imp_get_view(models, view_id); View *view = imp_get_view(models, view_id);
if (view != 0){ if (view != 0){
for (Query_Slot *slot = view->transient.query_set.used_slot; for (Query_Slot *slot = view->query_set.used_slot;
slot != 0 && (result < max_result_count); slot != 0 && (result < max_result_count);
slot = slot->next){ slot = slot->next){
if (slot->query_bar != 0){ if (slot->query_bar != 0){
@ -3075,7 +3075,7 @@ only use for this call is in an interactive command that makes calls to get_user
Models *models = (Models*)app->cmd_context; Models *models = (Models*)app->cmd_context;
Panel *active_panel = layout_get_active_panel(&models->layout); Panel *active_panel = layout_get_active_panel(&models->layout);
View *active_view = active_panel->view; View *active_view = active_panel->view;
Query_Slot *slot = alloc_query_slot(&active_view->transient.query_set); Query_Slot *slot = alloc_query_slot(&active_view->query_set);
bool32 result = (slot != 0); bool32 result = (slot != 0);
if (result){ if (result){
slot->query_bar = bar; slot->query_bar = bar;
@ -3093,7 +3093,7 @@ DOC(Stops showing the particular query bar specified by the bar parameter.)
Models *models = (Models*)app->cmd_context; Models *models = (Models*)app->cmd_context;
Panel *active_panel = layout_get_active_panel(&models->layout); Panel *active_panel = layout_get_active_panel(&models->layout);
View *active_view = active_panel->view; View *active_view = active_panel->view;
free_query_slot(&active_view->transient.query_set, bar); free_query_slot(&active_view->query_set, bar);
} }
API_EXPORT void API_EXPORT void
@ -4073,7 +4073,7 @@ Get_Default_Font_For_View(Application_Links *app, View_ID view_id)
{ {
Models *models = (Models*)app->cmd_context; Models *models = (Models*)app->cmd_context;
View *view = imp_get_view(models, view_id); View *view = imp_get_view(models, view_id);
Editing_File *file = view->transient.file_data.file; Editing_File *file = view->file_data.file;
Assert(file != 0); Assert(file != 0);
Face_ID face_id = file->settings.font_id; Face_ID face_id = file->settings.font_id;
return(face_id); return(face_id);

View File

@ -28,11 +28,11 @@ edit_pre_state_change(System_Functions *system, Heap *heap, Models *models, Edit
panel != 0; panel != 0;
panel = layout_get_next_open_panel(layout, panel)){ panel = layout_get_next_open_panel(layout, panel)){
View *view = panel->view; View *view = panel->view;
if (view->transient.file_data.file == file){ if (view->file_data.file == file){
Full_Cursor render_cursor = view_get_render_cursor(system, view); Full_Cursor render_cursor = view_get_render_cursor(system, view);
Full_Cursor target_cursor = view_get_render_cursor_target(system, view); Full_Cursor target_cursor = view_get_render_cursor_target(system, view);
view->transient.temp_view_top_left_pos = render_cursor.pos; view->temp_view_top_left_pos = render_cursor.pos;
view->transient.temp_view_top_left_target_pos = target_cursor.pos; view->temp_view_top_left_target_pos = target_cursor.pos;
} }
} }
} }
@ -135,12 +135,12 @@ edit_fix_markers(System_Functions *system, Models *models, Editing_File *file, E
panel != 0; panel != 0;
panel = layout_get_next_open_panel(layout, panel)){ panel = layout_get_next_open_panel(layout, panel)){
View *view = panel->view; View *view = panel->view;
if (view->transient.file_data.file == file){ if (view->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, view->transient.mark); write_cursor_with_index(cursors, &cursor_count, view->mark);
write_cursor_with_index(cursors, &cursor_count, view->transient.temp_view_top_left_pos); write_cursor_with_index(cursors, &cursor_count, view->temp_view_top_left_pos);
write_cursor_with_index(cursors, &cursor_count, view->transient.temp_view_top_left_target_pos); write_cursor_with_index(cursors, &cursor_count, view->temp_view_top_left_target_pos);
} }
} }
@ -180,19 +180,19 @@ edit_fix_markers(System_Functions *system, Models *models, Editing_File *file, E
panel != 0; panel != 0;
panel = layout_get_next_open_panel(layout, panel)){ panel = layout_get_next_open_panel(layout, panel)){
View *view = panel->view; View *view = panel->view;
if (view->transient.file_data.file == file){ if (view->file_data.file == file){
i32 cursor_pos = cursors[cursor_count++].pos; i32 cursor_pos = cursors[cursor_count++].pos;
Full_Cursor new_cursor = file_compute_cursor(system, file, seek_pos(cursor_pos)); Full_Cursor new_cursor = file_compute_cursor(system, file, seek_pos(cursor_pos));
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;
view->transient.mark = cursors[cursor_count++].pos; view->mark = cursors[cursor_count++].pos;
i32 line_height = view->transient.line_height; i32 line_height = view->line_height;
i32 top_left_pos = cursors[cursor_count++].pos; i32 top_left_pos = cursors[cursor_count++].pos;
i32 top_left_target_pos = cursors[cursor_count++].pos; i32 top_left_target_pos = cursors[cursor_count++].pos;
f32 new_y_val_aligned = 0; f32 new_y_val_aligned = 0;
if (view->transient.temp_view_top_left_pos != top_left_pos){ if (view->temp_view_top_left_pos != top_left_pos){
Full_Cursor new_position_cursor = file_compute_cursor(system, file, seek_pos(top_left_pos)); Full_Cursor new_position_cursor = file_compute_cursor(system, file, seek_pos(top_left_pos));
if (file->settings.unwrapped_lines){ if (file->settings.unwrapped_lines){
new_y_val_aligned = new_position_cursor.unwrapped_y; new_y_val_aligned = new_position_cursor.unwrapped_y;
@ -202,7 +202,7 @@ edit_fix_markers(System_Functions *system, Models *models, Editing_File *file, E
} }
scroll.scroll_y = edit_fix_markers__compute_scroll_y(line_height, scroll.scroll_y, new_y_val_aligned); scroll.scroll_y = edit_fix_markers__compute_scroll_y(line_height, scroll.scroll_y, new_y_val_aligned);
} }
if (view->transient.temp_view_top_left_target_pos != top_left_target_pos){ if (view->temp_view_top_left_target_pos != top_left_target_pos){
if (top_left_target_pos != top_left_pos){ if (top_left_target_pos != top_left_pos){
Full_Cursor new_position_cursor = file_compute_cursor(system, file, seek_pos(top_left_target_pos)); Full_Cursor new_position_cursor = file_compute_cursor(system, file, seek_pos(top_left_target_pos));
if (file->settings.unwrapped_lines){ if (file->settings.unwrapped_lines){
@ -215,7 +215,7 @@ edit_fix_markers(System_Functions *system, Models *models, Editing_File *file, E
scroll.target_y = edit_fix_markers__compute_scroll_y(line_height, scroll.target_y, new_y_val_aligned); scroll.target_y = edit_fix_markers__compute_scroll_y(line_height, scroll.target_y, new_y_val_aligned);
} }
view_set_cursor_and_scroll(view, new_cursor, true, view->transient.file_data.file->settings.unwrapped_lines, scroll); view_set_cursor_and_scroll(view, new_cursor, true, scroll);
} }
} }
@ -461,12 +461,12 @@ edit_clear(System_Functions *system, Models *models, Editing_File *file){
panel != 0; panel != 0;
panel = layout_get_next_open_panel(layout, panel)){ panel = layout_get_next_open_panel(layout, panel)){
View *view = panel->view; View *view = panel->view;
if (view->transient.file_data.file == file){ if (view->file_data.file == file){
Full_Cursor cursor = {}; Full_Cursor cursor = {};
cursor.line = 1; cursor.line = 1;
cursor.character = 1; cursor.character = 1;
cursor.wrap_line = 1; cursor.wrap_line = 1;
view_set_cursor(system, view, cursor, true, file->settings.unwrapped_lines); view_set_cursor(system, view, cursor, true);
no_views_see_file = false; no_views_see_file = false;
} }
} }

View File

@ -19,16 +19,8 @@ to_file_id(i32 id){
//////////////////////////////// ////////////////////////////////
internal void internal void
file_edit_positions_set_cursor(File_Edit_Positions *edit_pos, Full_Cursor cursor, b32 set_preferred_x, b32 unwrapped_lines){ file_edit_positions_set_cursor(File_Edit_Positions *edit_pos, i32 pos){
edit_pos->cursor_pos = cursor.pos; edit_pos->cursor_pos = pos;
if (set_preferred_x){
if (unwrapped_lines){
edit_pos->preferred_x = cursor.unwrapped_x;
}
else{
edit_pos->preferred_x = cursor.wrapped_x;
}
}
edit_pos->last_set_type = EditPos_CursorSet; edit_pos->last_set_type = EditPos_CursorSet;
} }

View File

@ -22,7 +22,6 @@ struct File_Edit_Positions{
Edit_Pos_Set_Type last_set_type; Edit_Pos_Set_Type last_set_type;
GUI_Scroll_Vars scroll; GUI_Scroll_Vars scroll;
i32 cursor_pos; i32 cursor_pos;
f32 preferred_x;
}; };
// TODO(NAME): do(replace Text_Effect with markers over time) // TODO(NAME): do(replace Text_Effect with markers over time)

View File

@ -11,29 +11,37 @@
internal i32 internal i32
view_get_map(View *view){ view_get_map(View *view){
if (view->transient.ui_mode){ if (view->ui_mode){
return(view->transient.ui_map_id); return(view->ui_map_id);
} }
else{ else{
return(view->transient.file_data.file->settings.base_map_id); return(view->file_data.file->settings.base_map_id);
} }
} }
internal i32
view_get_index(Live_Views *live_set, View *view){
return((i32)(view - live_set->views));
}
internal i32
view_get_id(Live_Views *live_set, View *view){
return((i32)(view - live_set->views) + 1);
}
internal View* internal View*
live_set_alloc_view(Heap *heap, Lifetime_Allocator *lifetime_allocator, Live_Views *live_set){ live_set_alloc_view(Heap *heap, Lifetime_Allocator *lifetime_allocator, Live_Views *live_set){
Assert(live_set->count < live_set->max); Assert(live_set->count < live_set->max);
++live_set->count; ++live_set->count;
View *result = live_set->free_sentinel.transient.next; View *result = live_set->free_sentinel.next;
Assert((i32)(result - live_set->views) == result->persistent.id); result->next->prev = result->prev;
result->prev->next = result->next;
block_zero_struct(result);
result->transient.next->transient.prev = result->transient.prev; result->in_use = true;
result->transient.prev->transient.next = result->transient.next; init_query_set(&result->query_set);
block_zero_struct(&result->transient); result->lifetime_object = lifetime_alloc_object(heap, lifetime_allocator, DynamicWorkspace_View, result);
result->transient.in_use = true;
init_query_set(&result->transient.query_set);
result->transient.lifetime_object = lifetime_alloc_object(heap, lifetime_allocator, DynamicWorkspace_View, result);
return(result); return(result);
} }
@ -43,50 +51,50 @@ live_set_free_view(Heap *heap, Lifetime_Allocator *lifetime_allocator, Live_View
Assert(live_set->count > 0); Assert(live_set->count > 0);
--live_set->count; --live_set->count;
if (view->transient.ui_control.items != 0){ if (view->ui_control.items != 0){
heap_free(heap, view->transient.ui_control.items); heap_free(heap, view->ui_control.items);
} }
view->transient.next = live_set->free_sentinel.transient.next; view->next = live_set->free_sentinel.next;
view->transient.prev = &live_set->free_sentinel; view->prev = &live_set->free_sentinel;
live_set->free_sentinel.transient.next = view; live_set->free_sentinel.next = view;
view->transient.next->transient.prev = view; view->next->prev = view;
view->transient.in_use = false; view->in_use = false;
lifetime_free_object(heap, lifetime_allocator, view->transient.lifetime_object); lifetime_free_object(heap, lifetime_allocator, view->lifetime_object);
} }
//////////////////////////////// ////////////////////////////////
internal File_Edit_Positions internal File_Edit_Positions
view_get_edit_pos(View *view){ view_get_edit_pos(View *view){
return(view->transient.edit_pos_); return(view->edit_pos_);
} }
internal void internal void
view_set_edit_pos(View *view, File_Edit_Positions edit_pos){ view_set_edit_pos(View *view, File_Edit_Positions edit_pos){
view->transient.edit_pos_ = edit_pos; view->edit_pos_ = edit_pos;
view->transient.file_data.file->state.edit_pos_most_recent = edit_pos; view->file_data.file->state.edit_pos_most_recent = edit_pos;
} }
//////////////////////////////// ////////////////////////////////
internal i32 internal i32
view_width(View *view){ view_width(View *view){
return(rect_width(view->transient.file_region)); return(rect_width(view->file_region));
} }
internal i32 internal i32
view_height(View *view){ view_height(View *view){
return(rect_height(view->transient.file_region)); return(rect_height(view->file_region));
} }
internal Vec2_i32 internal Vec2_i32
view_get_cursor_xy(System_Functions *system, View *view){ view_get_cursor_xy(System_Functions *system, View *view){
File_Edit_Positions edit_pos = view_get_edit_pos(view); 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)); Full_Cursor cursor = file_compute_cursor(system, view->file_data.file, seek_pos(edit_pos.cursor_pos));
Vec2_i32 result = {}; Vec2_i32 result = {};
if (view->transient.file_data.file->settings.unwrapped_lines){ if (view->file_data.file->settings.unwrapped_lines){
result = V2i32((i32)cursor.unwrapped_x, (i32)cursor.unwrapped_y); result = V2i32((i32)cursor.unwrapped_x, (i32)cursor.unwrapped_y);
} }
else{ else{
@ -97,7 +105,7 @@ view_get_cursor_xy(System_Functions *system, View *view){
internal Cursor_Limits internal Cursor_Limits
view_cursor_limits(View *view){ view_cursor_limits(View *view){
i32 line_height = view->transient.line_height; i32 line_height = view->line_height;
i32 visible_height = view_height(view); i32 visible_height = view_height(view);
Cursor_Limits limits = {}; Cursor_Limits limits = {};
limits.max = visible_height - line_height*3; limits.max = visible_height - line_height*3;
@ -119,7 +127,7 @@ view_cursor_limits(View *view){
internal i32 internal i32
view_compute_max_target_y_from_bottom_y(View *view, f32 max_item_y){ view_compute_max_target_y_from_bottom_y(View *view, f32 max_item_y){
i32 line_height = view->transient.line_height; i32 line_height = view->line_height;
f32 height = clamp_bottom((f32)line_height, view_height(view)); f32 height = clamp_bottom((f32)line_height, view_height(view));
f32 max_target_y = clamp_bottom(0.f, max_item_y - height*0.5f); f32 max_target_y = clamp_bottom(0.f, max_item_y - height*0.5f);
return(ceil32(max_target_y)); return(ceil32(max_target_y));
@ -127,8 +135,8 @@ view_compute_max_target_y_from_bottom_y(View *view, f32 max_item_y){
internal i32 internal i32
view_compute_max_target_y(View *view){ view_compute_max_target_y(View *view){
i32 line_height = view->transient.line_height; i32 line_height = view->line_height;
Editing_File *file = view->transient.file_data.file; Editing_File *file = view->file_data.file;
Gap_Buffer *buffer = &file->state.buffer; Gap_Buffer *buffer = &file->state.buffer;
i32 lowest_line = buffer->line_count; i32 lowest_line = buffer->line_count;
if (!file->settings.unwrapped_lines){ if (!file->settings.unwrapped_lines){
@ -140,8 +148,8 @@ view_compute_max_target_y(View *view){
internal u32 internal u32
view_lock_flags(View *view){ view_lock_flags(View *view){
u32 result = AccessOpen; u32 result = AccessOpen;
File_Viewing_Data *data = &view->transient.file_data; File_Viewing_Data *data = &view->file_data;
if (view->transient.ui_mode){ if (view->ui_mode){
result |= AccessHidden; result |= AccessHidden;
} }
if (data->file_locked || (data->file && data->file->settings.read_only)){ if (data->file_locked || (data->file && data->file->settings.read_only)){
@ -192,10 +200,10 @@ view_move_view_to_cursor(System_Functions *system, View *view, GUI_Scroll_Vars *
internal b32 internal b32
view_move_cursor_to_view(System_Functions *system, View *view, GUI_Scroll_Vars scroll, i32 *pos_in_out, f32 preferred_x){ 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; Editing_File *file = view->file_data.file;
Full_Cursor cursor = file_compute_cursor(system, file, seek_pos(*pos_in_out)); Full_Cursor cursor = file_compute_cursor(system, file, seek_pos(*pos_in_out));
i32 line_height = view->transient.line_height; i32 line_height = view->line_height;
f32 old_cursor_y = 0.f; f32 old_cursor_y = 0.f;
if (file->settings.unwrapped_lines){ if (file->settings.unwrapped_lines){
old_cursor_y = cursor.unwrapped_y; old_cursor_y = cursor.unwrapped_y;
@ -204,7 +212,7 @@ view_move_cursor_to_view(System_Functions *system, View *view, GUI_Scroll_Vars s
old_cursor_y = cursor.wrapped_y; old_cursor_y = cursor.wrapped_y;
} }
f32 cursor_y = old_cursor_y; f32 cursor_y = old_cursor_y;
f32 target_y = scroll.target_y + view->transient.widget_height; f32 target_y = scroll.target_y + view->widget_height;
Cursor_Limits limits = view_cursor_limits(view); Cursor_Limits limits = view_cursor_limits(view);
@ -232,10 +240,35 @@ view_move_cursor_to_view(System_Functions *system, View *view, GUI_Scroll_Vars s
return(result); return(result);
} }
internal b32
view_has_unwrapped_lines(View *view){
return(view->file_data.file->settings.unwrapped_lines);
}
internal void internal void
view_set_cursor(System_Functions *system, View *view, Full_Cursor cursor, b32 set_preferred_x, b32 unwrapped_lines){ view_set_preferred_x(View *view, Full_Cursor cursor){
if (view_has_unwrapped_lines(view)){
view->preferred_x = cursor.unwrapped_x;
}
else{
view->preferred_x = cursor.wrapped_x;
}
}
internal void
view_set_preferred_x_to_current_position(System_Functions *system, View *view){
File_Edit_Positions edit_pos = view_get_edit_pos(view); File_Edit_Positions edit_pos = view_get_edit_pos(view);
file_edit_positions_set_cursor(&edit_pos, cursor, set_preferred_x, unwrapped_lines); Full_Cursor cursor = file_compute_cursor(system, view->file_data.file, seek_pos(edit_pos.cursor_pos));
view_set_preferred_x(view, cursor);
}
internal void
view_set_cursor(System_Functions *system, View *view, Full_Cursor cursor, b32 set_preferred_x){
File_Edit_Positions edit_pos = view_get_edit_pos(view);
file_edit_positions_set_cursor(&edit_pos, cursor.pos);
if (set_preferred_x){
view_set_preferred_x(view, cursor);
}
view_set_edit_pos(view, edit_pos); view_set_edit_pos(view, edit_pos);
GUI_Scroll_Vars scroll = edit_pos.scroll; GUI_Scroll_Vars scroll = edit_pos.scroll;
if (view_move_view_to_cursor(system, view, &scroll)){ if (view_move_view_to_cursor(system, view, &scroll)){
@ -250,17 +283,20 @@ view_set_scroll(System_Functions *system, View *view, GUI_Scroll_Vars scroll){
file_edit_positions_set_scroll(&edit_pos, scroll); file_edit_positions_set_scroll(&edit_pos, scroll);
view_set_edit_pos(view, edit_pos); view_set_edit_pos(view, edit_pos);
i32 pos = edit_pos.cursor_pos; i32 pos = edit_pos.cursor_pos;
if (view_move_cursor_to_view(system, view, edit_pos.scroll, &pos, edit_pos.preferred_x)){ if (view_move_cursor_to_view(system, view, edit_pos.scroll, &pos, view->preferred_x)){
Full_Cursor cursor = file_compute_cursor(system, view->transient.file_data.file, seek_pos(pos)); Full_Cursor cursor = file_compute_cursor(system, view->file_data.file, seek_pos(pos));
edit_pos.cursor_pos = cursor.pos; edit_pos.cursor_pos = cursor.pos;
view_set_edit_pos(view, edit_pos); view_set_edit_pos(view, edit_pos);
} }
} }
internal void internal void
view_set_cursor_and_scroll(View *view, Full_Cursor cursor, b32 set_preferred_x, b32 unwrapped_lines, GUI_Scroll_Vars scroll){ view_set_cursor_and_scroll(View *view, Full_Cursor cursor, b32 set_preferred_x, GUI_Scroll_Vars scroll){
File_Edit_Positions edit_pos = view_get_edit_pos(view); File_Edit_Positions edit_pos = view_get_edit_pos(view);
file_edit_positions_set_cursor(&edit_pos, cursor, set_preferred_x, unwrapped_lines); file_edit_positions_set_cursor(&edit_pos, cursor.pos);
if (set_preferred_x){
view_set_preferred_x(view, cursor);
}
file_edit_positions_set_scroll(&edit_pos, scroll); file_edit_positions_set_scroll(&edit_pos, scroll);
edit_pos.last_set_type = EditPos_None; edit_pos.last_set_type = EditPos_None;
view_set_edit_pos(view, edit_pos); view_set_edit_pos(view, edit_pos);
@ -268,15 +304,15 @@ view_set_cursor_and_scroll(View *view, Full_Cursor cursor, b32 set_preferred_x,
internal void internal void
view_cursor_move(System_Functions *system, View *view, i32 pos){ view_cursor_move(System_Functions *system, View *view, i32 pos){
Editing_File *file = view->transient.file_data.file; Editing_File *file = view->file_data.file;
Assert(file != 0); Assert(file != 0);
Full_Cursor cursor = file_compute_cursor(system, file, seek_pos(pos)); Full_Cursor cursor = file_compute_cursor(system, file, seek_pos(pos));
view_set_cursor(system, view, cursor, true, file->settings.unwrapped_lines); view_set_cursor(system, view, cursor, true);
} }
internal void internal void
view_post_paste_effect(View *view, f32 seconds, i32 start, i32 size, u32 color){ view_post_paste_effect(View *view, f32 seconds, i32 start, i32 size, u32 color){
Editing_File *file = view->transient.file_data.file; Editing_File *file = view->file_data.file;
file->state.paste_effect.start = start; file->state.paste_effect.start = start;
file->state.paste_effect.end = start + size; file->state.paste_effect.end = start + size;
file->state.paste_effect.color = color; file->state.paste_effect.color = color;
@ -290,28 +326,22 @@ internal void
view_set_file(System_Functions *system, Models *models, View *view, Editing_File *file){ view_set_file(System_Functions *system, Models *models, View *view, Editing_File *file){
Assert(file != 0); Assert(file != 0);
Editing_File *old_file = view->transient.file_data.file; Editing_File *old_file = view->file_data.file;
if (old_file != 0){ if (old_file != 0){
file_touch(&models->working_set, old_file); file_touch(&models->working_set, old_file);
file_edit_positions_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)); block_zero(&view->file_data, sizeof(view->file_data));
view->transient.file_data.file = file; view->file_data.file = file;
File_Edit_Positions 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_set_edit_pos(view, edit_pos);
view->transient.mark = edit_pos.cursor_pos; view->mark = edit_pos.cursor_pos;
view_set_preferred_x_to_current_position(system, view);
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->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
} }
//////////////////////////////// ////////////////////////////////
@ -323,7 +353,7 @@ file_is_viewed(Layout *layout, Editing_File *file){
panel != 0; panel != 0;
panel = layout_get_next_open_panel(layout, panel)){ panel = layout_get_next_open_panel(layout, panel)){
View *view = panel->view; View *view = panel->view;
if (view->transient.file_data.file == file){ if (view->file_data.file == file){
is_viewed = true; is_viewed = true;
break; break;
} }
@ -338,10 +368,10 @@ adjust_views_looking_at_file_to_new_cursor(System_Functions *system, Models *mod
panel != 0; panel != 0;
panel = layout_get_next_open_panel(layout, panel)){ panel = layout_get_next_open_panel(layout, panel)){
View *view = panel->view; View *view = panel->view;
if (view->transient.file_data.file == file){ if (view->file_data.file == file){
File_Edit_Positions edit_pos = view_get_edit_pos(view); File_Edit_Positions edit_pos = view_get_edit_pos(view);
Full_Cursor cursor = file_compute_cursor(system, file, seek_pos(edit_pos.cursor_pos)); 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); view_set_cursor(system, view, cursor, true);
} }
} }
} }
@ -358,8 +388,8 @@ file_full_remeasure(System_Functions *system, Models *models, Editing_File *file
panel != 0; panel != 0;
panel = layout_get_next_open_panel(layout, panel)){ panel = layout_get_next_open_panel(layout, panel)){
View *view = panel->view; View *view = panel->view;
if (view->transient.file_data.file == file){ if (view->file_data.file == file){
view->transient.line_height = font.metrics->height; view->line_height = font.metrics->height;
} }
} }
} }
@ -744,7 +774,7 @@ internal void
render_loaded_file_in_view__inner(Models *models, Render_Target *target, View *view, render_loaded_file_in_view__inner(Models *models, Render_Target *target, View *view,
i32_Rect rect, Full_Cursor render_cursor, Range on_screen_range, i32_Rect rect, Full_Cursor render_cursor, Range on_screen_range,
Buffer_Render_Item *items, i32 item_count){ Buffer_Render_Item *items, i32 item_count){
Editing_File *file = view->transient.file_data.file; Editing_File *file = view->file_data.file;
Partition *part = &models->mem.part; Partition *part = &models->mem.part;
Style *style = &models->styles.styles[0]; Style *style = &models->styles.styles[0];
@ -763,7 +793,7 @@ render_loaded_file_in_view__inner(Models *models, Render_Target *target, View *v
{ {
Lifetime_Object *lifetime_object = file->lifetime_object; Lifetime_Object *lifetime_object = file->lifetime_object;
Buffer_ID buffer_id = file->id.id; Buffer_ID buffer_id = file->id.id;
i32 view_index = view->persistent.id; i32 view_index = view_get_index(&models->live_set, view);
Theme *theme_data = &style->theme; Theme *theme_data = &style->theme;
get_visual_markers(part, &lifetime_object->workspace, on_screen_range, buffer_id, view_index, theme_data); get_visual_markers(part, &lifetime_object->workspace, on_screen_range, buffer_id, view_index, theme_data);
@ -939,7 +969,7 @@ render_loaded_file_in_view__inner(Models *models, Render_Target *target, View *v
char_color = ghost_color; char_color = ghost_color;
} }
if (view->transient.file_data.show_whitespace && highlight_color == 0 && codepoint_is_whitespace(item->codepoint)){ if (view->file_data.show_whitespace && highlight_color == 0 && codepoint_is_whitespace(item->codepoint)){
highlight_this_color = style->theme.colors[Stag_Highlight_White]; highlight_this_color = style->theme.colors[Stag_Highlight_White];
} }
else{ else{
@ -1145,7 +1175,7 @@ do_core_render(Application_Links *app){
internal Full_Cursor internal Full_Cursor
view_get_render_cursor(System_Functions *system, View *view, f32 scroll_y){ view_get_render_cursor(System_Functions *system, View *view, f32 scroll_y){
Full_Cursor result = {}; Full_Cursor result = {};
Editing_File *file = view->transient.file_data.file; Editing_File *file = view->file_data.file;
if (file->settings.unwrapped_lines){ if (file->settings.unwrapped_lines){
result = file_compute_cursor_hint(system, file, seek_unwrapped_xy(0, scroll_y, false)); result = file_compute_cursor_hint(system, file, seek_unwrapped_xy(0, scroll_y, false));
} }
@ -1162,7 +1192,7 @@ view_get_render_cursor(System_Functions *system, View *view){
// NOTE(allen): For now we will temporarily adjust scroll_y to try // NOTE(allen): For now we will temporarily adjust scroll_y to try
// to prevent the view moving around until floating sections are added // to prevent the view moving around until floating sections are added
// to the gui system. // to the gui system.
scroll_y += view->transient.widget_height; scroll_y += view->widget_height;
return(view_get_render_cursor(system, view, scroll_y)); return(view_get_render_cursor(system, view, scroll_y));
} }
@ -1173,14 +1203,14 @@ view_get_render_cursor_target(System_Functions *system, View *view){
// NOTE(allen): For now we will temporarily adjust scroll_y to try // NOTE(allen): For now we will temporarily adjust scroll_y to try
// to prevent the view moving around until floating sections are added // to prevent the view moving around until floating sections are added
// to the gui system. // to the gui system.
scroll_y += view->transient.widget_height; scroll_y += view->widget_height;
return(view_get_render_cursor(system, view, scroll_y)); return(view_get_render_cursor(system, view, scroll_y));
} }
internal void internal void
render_loaded_file_in_view(System_Functions *system, View *view, Models *models, i32_Rect rect, b32 is_active, Render_Target *target){ render_loaded_file_in_view(System_Functions *system, View *view, Models *models, i32_Rect rect, b32 is_active, Render_Target *target){
Editing_File *file = view->transient.file_data.file; Editing_File *file = view->file_data.file;
i32 line_height = view->transient.line_height; i32 line_height = view->line_height;
f32 max_x = (f32)file->settings.display_width; f32 max_x = (f32)file->settings.display_width;
i32 max_y = rect.y1 - rect.y0 + line_height; i32 max_y = rect.y1 - rect.y0 + line_height;
@ -1210,13 +1240,13 @@ render_loaded_file_in_view(System_Functions *system, View *view, Models *models,
// NOTE(allen): For now we will temporarily adjust scroll_y to try // NOTE(allen): For now we will temporarily adjust scroll_y to try
// to prevent the view moving around until floating sections are added // to prevent the view moving around until floating sections are added
// to the gui system. // to the gui system.
scroll_y += view->transient.widget_height; scroll_y += view->widget_height;
Full_Cursor render_cursor = view_get_render_cursor(system, view); Full_Cursor render_cursor = view_get_render_cursor(system, view);
#if 0 #if 0
// TODO(allen): do(eliminate scroll_i nonsense) // TODO(allen): do(eliminate scroll_i nonsense)
view->transient.edit_pos_.scroll_i = render_cursor.pos; view->edit_pos_.scroll_i = render_cursor.pos;
#endif #endif
i32 item_count = 0; i32 item_count = 0;
@ -1296,13 +1326,14 @@ render_loaded_file_in_view(System_Functions *system, View *view, Models *models,
//////////////////////////////// ////////////////////////////////
if (models->render_caller != 0){ if (models->render_caller != 0){
View_ID view_id = view_get_id(&models->live_set, view);
models->render_view = view; models->render_view = view;
models->render_rect = rect; models->render_rect = rect;
models->render_cursor = render_cursor; models->render_cursor = render_cursor;
models->render_range = on_screen_range; models->render_range = on_screen_range;
models->render_items = items; models->render_items = items;
models->render_item_count = item_count; models->render_item_count = item_count;
models->render_caller(&models->app_links, view->persistent.id + 1, on_screen_range, do_core_render); models->render_caller(&models->app_links, view_id, on_screen_range, do_core_render);
models->render_view = 0; models->render_view = 0;
} }
else{ else{

View File

@ -12,18 +12,13 @@
#if !defined(FRED_VIEW_H) #if !defined(FRED_VIEW_H)
#define FRED_VIEW_H #define FRED_VIEW_H
struct View_Persistent{
i32 id;
Coroutine_Head *coroutine;
};
struct File_Viewing_Data{ struct File_Viewing_Data{
Editing_File *file; Editing_File *file;
b32 show_whitespace; b32 show_whitespace;
b32 file_locked; b32 file_locked;
}; };
struct View_Transient{ struct View{
struct View *next; struct View *next;
struct View *prev; struct View *prev;
struct Panel *panel; struct Panel *panel;
@ -38,6 +33,7 @@ struct View_Transient{
i32_Rect scroll_region; i32_Rect scroll_region;
File_Edit_Positions edit_pos_; File_Edit_Positions edit_pos_;
i32 mark; i32 mark;
f32 preferred_x;
i32 temp_view_top_left_pos; i32 temp_view_top_left_pos;
i32 temp_view_top_left_target_pos; i32 temp_view_top_left_target_pos;
@ -52,8 +48,6 @@ struct View_Transient{
b32 hide_scrollbar; b32 hide_scrollbar;
b32 hide_file_bar; b32 hide_file_bar;
b32 changed_context_in_step;
// misc // misc
// TODO(allen): Can we burn line_height to the ground now? // TODO(allen): Can we burn line_height to the ground now?
@ -64,12 +58,6 @@ struct View_Transient{
f32 widget_height; f32 widget_height;
}; };
struct View{
// TODO(allen): Why is this this way?
View_Persistent persistent;
View_Transient transient;
};
struct Live_Views{ struct Live_Views{
View *views; View *views;
View free_sentinel; View free_sentinel;

View File

@ -47,14 +47,14 @@ global_const Style_Color_Edit colors_to_edit[] = {
}; };
internal Input_Process_Result internal Input_Process_Result
do_step_file_view(System_Functions *system, View *view, Models *models, i32_Rect rect, b32 is_active, f32 dt, GUI_Scroll_Vars scroll, i32 max_y){ do_step_file_view(System_Functions *system, Models *models, View *view, i32_Rect rect, b32 is_active, f32 dt, GUI_Scroll_Vars scroll, i32 max_y){
Input_Process_Result result = {}; Input_Process_Result result = {};
scroll.target_y = clamp(0, scroll.target_y, max_y); scroll.target_y = clamp(0, scroll.target_y, max_y);
result.scroll = scroll; result.scroll = scroll;
i32 line_height = view->transient.line_height; i32 line_height = view->line_height;
if (!view->transient.hide_file_bar){ if (!view->hide_file_bar){
i32_Rect top_bar_rect = {}; i32_Rect top_bar_rect = {};
top_bar_rect.x0 = rect.x0; top_bar_rect.x0 = rect.x0;
top_bar_rect.y0 = rect.y0; top_bar_rect.y0 = rect.y0;
@ -62,15 +62,15 @@ do_step_file_view(System_Functions *system, View *view, Models *models, i32_Rect
top_bar_rect.y1 = rect.y0 + line_height + 2; top_bar_rect.y1 = rect.y0 + line_height + 2;
rect.y0 = top_bar_rect.y1; rect.y0 = top_bar_rect.y1;
} }
view->transient.file_region = rect; view->file_region = rect;
i32 bar_count = 0; i32 bar_count = 0;
for (Query_Slot *slot = view->transient.query_set.used_slot; for (Query_Slot *slot = view->query_set.used_slot;
slot != 0; slot != 0;
slot = slot->next, ++bar_count); slot = slot->next, ++bar_count);
view->transient.widget_height = (f32)bar_count*(view->transient.line_height + 2); view->widget_height = (f32)bar_count*(view->line_height + 2);
Editing_File *file = view->transient.file_data.file; Editing_File *file = view->file_data.file;
// TODO(allen): do(eliminate the built in paste_effect) // TODO(allen): do(eliminate the built in paste_effect)
if (!file->is_loading && file->state.paste_effect.seconds_down > 0.f){ if (!file->is_loading && file->state.paste_effect.seconds_down > 0.f){
@ -79,18 +79,19 @@ do_step_file_view(System_Functions *system, View *view, Models *models, i32_Rect
} }
// NOTE(allen): call scroll rule hook // NOTE(allen): call scroll rule hook
b32 is_new_target = (result.scroll.target_x != view->transient.prev_target.x || b32 is_new_target = (result.scroll.target_x != view->prev_target.x ||
result.scroll.target_y != view->transient.prev_target.y); result.scroll.target_y != view->prev_target.y);
f32 target_x = (f32)result.scroll.target_x; f32 target_x = (f32)result.scroll.target_x;
f32 target_y = (f32)result.scroll.target_y; f32 target_y = (f32)result.scroll.target_y;
if (models->scroll_rule(target_x, target_y, &result.scroll.scroll_x, &result.scroll.scroll_y, (view->persistent.id) + 1, is_new_target, dt)){ View_ID view_id = view_get_id(&models->live_set, view);
if (models->scroll_rule(target_x, target_y, &result.scroll.scroll_x, &result.scroll.scroll_y, view_id, is_new_target, dt)){
result.is_animating = true; result.is_animating = true;
} }
view->transient.prev_target.x = result.scroll.target_x; view->prev_target.x = result.scroll.target_x;
view->transient.prev_target.y = result.scroll.target_y; view->prev_target.y = result.scroll.target_y;
return(result); return(result);
} }
@ -149,7 +150,7 @@ draw_file_bar(System_Functions *system, Render_Target *target, View *view, Model
} }
else{ else{
File_Edit_Positions edit_pos = view_get_edit_pos(view); 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)); Full_Cursor cursor = file_compute_cursor(system, view->file_data.file, seek_pos(edit_pos.cursor_pos));
char bar_space[526]; char bar_space[526];
String bar_text = make_fixed_width_string(bar_space); String bar_text = make_fixed_width_string(bar_space);
@ -213,10 +214,10 @@ get_margin_color(Style *style, i32 level){
internal void internal void
do_render_file_view(System_Functions *system, View *view, Models *models, GUI_Scroll_Vars *scroll, View *active, i32_Rect rect, b32 is_active, Render_Target *target){ do_render_file_view(System_Functions *system, View *view, Models *models, GUI_Scroll_Vars *scroll, View *active, i32_Rect rect, b32 is_active, Render_Target *target){
Editing_File *file = view->transient.file_data.file; Editing_File *file = view->file_data.file;
Assert(file != 0); Assert(file != 0);
i32 line_height = view->transient.line_height; i32 line_height = view->line_height;
Style *style = &models->styles.styles[0]; Style *style = &models->styles.styles[0];
Face_ID font_id = file->settings.font_id; Face_ID font_id = file->settings.font_id;
char font_name_space[256]; char font_name_space[256];
@ -224,7 +225,7 @@ do_render_file_view(System_Functions *system, View *view, Models *models, GUI_Sc
font_name.size = system->font.get_name_by_id(font_id, font_name.str, font_name.memory_size); font_name.size = system->font.get_name_by_id(font_id, font_name.str, font_name.memory_size);
Font_Pointers font = system->font.get_pointers_by_id(font_id); Font_Pointers font = system->font.get_pointers_by_id(font_id);
if (!view->transient.hide_file_bar){ if (!view->hide_file_bar){
i32_Rect top_bar_rect = {}; i32_Rect top_bar_rect = {};
top_bar_rect.x0 = rect.x0; top_bar_rect.x0 = rect.x0;
top_bar_rect.y0 = rect.y0; top_bar_rect.y0 = rect.y0;
@ -235,7 +236,7 @@ do_render_file_view(System_Functions *system, View *view, Models *models, GUI_Sc
} }
i32 bar_count = 0; i32 bar_count = 0;
for (Query_Slot *slot = view->transient.query_set.used_slot; for (Query_Slot *slot = view->query_set.used_slot;
slot != 0; slot != 0;
slot = slot->next, ++bar_count){ slot = slot->next, ++bar_count){
i32_Rect query_bar_rect = {}; i32_Rect query_bar_rect = {};
@ -253,10 +254,10 @@ do_render_file_view(System_Functions *system, View *view, Models *models, GUI_Sc
x = ceil32(draw_string(system, target, font_id, slot->query_bar->prompt, x, y, text2_color)); x = ceil32(draw_string(system, target, font_id, slot->query_bar->prompt, x, y, text2_color));
draw_string(system, target, font_id, slot->query_bar->string, x, y, text1_color); draw_string(system, target, font_id, slot->query_bar->string, x, y, text1_color);
} }
view->transient.widget_height = (f32)bar_count*(view->transient.line_height + 2); view->widget_height = (f32)bar_count*(view->line_height + 2);
draw_push_clip(target, rect); draw_push_clip(target, rect);
if (!view->transient.ui_mode){ if (!view->ui_mode){
if (file_is_ready(file)){ if (file_is_ready(file)){
render_loaded_file_in_view(system, view, models, rect, is_active, target); render_loaded_file_in_view(system, view, models, rect, is_active, target);
} }
@ -264,9 +265,9 @@ do_render_file_view(System_Functions *system, View *view, Models *models, GUI_Sc
else{ else{
f32_Rect rect_f32 = f32R(rect); f32_Rect rect_f32 = f32R(rect);
i32 item_count = view->transient.ui_control.count; i32 item_count = view->ui_control.count;
UI_Item *item = view->transient.ui_control.items; UI_Item *item = view->ui_control.items;
GUI_Scroll_Vars ui_scroll = view->transient.ui_scroll; GUI_Scroll_Vars ui_scroll = view->ui_scroll;
for (i32 i = 0; i < item_count; ++i, item += 1){ for (i32 i = 0; i < item_count; ++i, item += 1){
f32_Rect item_rect = f32R(item->rectangle); f32_Rect item_rect = f32R(item->rectangle);