2017-07-17 23:35:13 +00:00
|
|
|
/*
|
|
|
|
* Mr. 4th Dimention - Allen Webster
|
|
|
|
*
|
2018-03-24 10:06:45 +00:00
|
|
|
* 19.08.2015
|
2017-07-17 23:35:13 +00:00
|
|
|
*
|
2018-03-24 21:43:57 +00:00
|
|
|
* Viewing
|
2017-07-17 23:35:13 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
2018-08-04 02:41:38 +00:00
|
|
|
internal i32
|
|
|
|
view_get_map(View *view){
|
2019-02-10 09:18:34 +00:00
|
|
|
if (view->ui_mode){
|
|
|
|
return(view->ui_map_id);
|
2018-08-04 02:41:38 +00:00
|
|
|
}
|
|
|
|
else{
|
2019-02-27 05:49:35 +00:00
|
|
|
return(view->file->settings.base_map_id);
|
2018-08-04 02:41:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-13 22:14:27 +00:00
|
|
|
internal u32
|
|
|
|
view_get_access_flags(View *view){
|
|
|
|
u32 result = AccessOpen;
|
|
|
|
if (view->ui_mode){
|
|
|
|
result |= AccessHidden;
|
|
|
|
}
|
2019-02-27 05:49:35 +00:00
|
|
|
result |= file_get_access_flags(view->file);
|
2019-02-13 22:14:27 +00:00
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2019-02-10 09:18:34 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-02-05 09:13:38 +00:00
|
|
|
internal View*
|
2019-02-27 05:49:35 +00:00
|
|
|
live_set_alloc_view(Heap *heap, Lifetime_Allocator *lifetime_allocator, Live_Views *live_set, Panel *panel){
|
2018-03-26 05:19:08 +00:00
|
|
|
Assert(live_set->count < live_set->max);
|
|
|
|
++live_set->count;
|
|
|
|
|
2019-02-10 09:18:34 +00:00
|
|
|
View *result = live_set->free_sentinel.next;
|
2019-02-27 05:49:35 +00:00
|
|
|
dll_remove(result);
|
2019-02-10 09:18:34 +00:00
|
|
|
block_zero_struct(result);
|
2018-03-26 05:19:08 +00:00
|
|
|
|
2019-02-10 09:18:34 +00:00
|
|
|
result->in_use = true;
|
|
|
|
init_query_set(&result->query_set);
|
|
|
|
result->lifetime_object = lifetime_alloc_object(heap, lifetime_allocator, DynamicWorkspace_View, result);
|
2019-02-27 05:49:35 +00:00
|
|
|
panel->view = result;
|
|
|
|
result->panel = panel;
|
2018-06-23 03:03:58 +00:00
|
|
|
|
2018-03-26 05:19:08 +00:00
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2019-01-31 13:06:42 +00:00
|
|
|
internal void
|
2018-08-18 08:16:52 +00:00
|
|
|
live_set_free_view(Heap *heap, Lifetime_Allocator *lifetime_allocator, Live_Views *live_set, View *view){
|
2018-03-26 05:19:08 +00:00
|
|
|
Assert(live_set->count > 0);
|
|
|
|
--live_set->count;
|
|
|
|
|
2019-02-10 09:18:34 +00:00
|
|
|
view->next = live_set->free_sentinel.next;
|
|
|
|
view->prev = &live_set->free_sentinel;
|
|
|
|
live_set->free_sentinel.next = view;
|
|
|
|
view->next->prev = view;
|
|
|
|
view->in_use = false;
|
2018-06-23 03:03:58 +00:00
|
|
|
|
2019-02-10 09:18:34 +00:00
|
|
|
lifetime_free_object(heap, lifetime_allocator, view->lifetime_object);
|
2018-03-26 05:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
2019-02-09 22:48:53 +00:00
|
|
|
internal File_Edit_Positions
|
|
|
|
view_get_edit_pos(View *view){
|
2019-02-10 09:18:34 +00:00
|
|
|
return(view->edit_pos_);
|
2019-02-09 22:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
internal void
|
|
|
|
view_set_edit_pos(View *view, File_Edit_Positions edit_pos){
|
2019-02-10 09:18:34 +00:00
|
|
|
view->edit_pos_ = edit_pos;
|
2019-02-27 05:49:35 +00:00
|
|
|
view->file->state.edit_pos_most_recent = edit_pos;
|
2019-02-09 22:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
2019-06-19 02:31:59 +00:00
|
|
|
internal Rect_f32
|
2019-03-31 18:55:26 +00:00
|
|
|
view_get_buffer_rect(Models *models, View *view){
|
2019-06-19 02:31:59 +00:00
|
|
|
Rect_f32 region = {};
|
2019-02-27 05:49:35 +00:00
|
|
|
if (models->get_view_buffer_region != 0){
|
2019-06-19 02:31:59 +00:00
|
|
|
Rect_f32 rect = Rf32(view->panel->rect_inner);
|
|
|
|
Rect_f32 sub_region = Rf32(V2(0, 0), rect_dim(rect));
|
2019-02-27 05:49:35 +00:00
|
|
|
sub_region = models->get_view_buffer_region(&models->app_links, view_get_id(&models->live_set, view), sub_region);
|
|
|
|
region.p0 = rect.p0 + sub_region.p0;
|
|
|
|
region.p1 = rect.p0 + sub_region.p1;
|
|
|
|
region.x1 = clamp_top(region.x1, rect.x1);
|
|
|
|
region.y1 = clamp_top(region.y1, rect.y1);
|
|
|
|
region.x0 = clamp_top(region.x0, region.x1);
|
|
|
|
region.y0 = clamp_top(region.y0, region.y1);
|
|
|
|
}
|
|
|
|
else{
|
2019-06-19 02:31:59 +00:00
|
|
|
region = Rf32(view->panel->rect_inner);
|
2019-02-27 05:49:35 +00:00
|
|
|
}
|
|
|
|
return(region);
|
|
|
|
}
|
|
|
|
|
2019-06-19 02:31:59 +00:00
|
|
|
internal f32
|
2019-02-27 05:49:35 +00:00
|
|
|
view_width(Models *models, View *view){
|
2019-03-31 18:55:26 +00:00
|
|
|
return(rect_width(view_get_buffer_rect(models, view)));
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
|
2019-06-19 02:31:59 +00:00
|
|
|
internal f32
|
2019-02-27 05:49:35 +00:00
|
|
|
view_height(Models *models, View *view){
|
2019-03-31 18:55:26 +00:00
|
|
|
return(rect_height(view_get_buffer_rect(models, view)));
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
|
2019-02-10 07:48:07 +00:00
|
|
|
internal Vec2_i32
|
2019-07-24 07:41:40 +00:00
|
|
|
view_get_cursor_xy(Models *models, View *view){
|
2019-02-10 00:20:55 +00:00
|
|
|
File_Edit_Positions edit_pos = view_get_edit_pos(view);
|
2019-07-24 07:41:40 +00:00
|
|
|
Full_Cursor cursor = file_compute_cursor(models, view->file, seek_pos(edit_pos.cursor_pos));
|
2019-02-10 07:48:07 +00:00
|
|
|
Vec2_i32 result = {};
|
2019-02-27 05:49:35 +00:00
|
|
|
if (view->file->settings.unwrapped_lines){
|
2019-02-10 07:48:07 +00:00
|
|
|
result = V2i32((i32)cursor.unwrapped_x, (i32)cursor.unwrapped_y);
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
2019-02-04 03:51:43 +00:00
|
|
|
else{
|
2019-02-10 07:48:07 +00:00
|
|
|
result = V2i32((i32)cursor.wrapped_x, (i32)cursor.wrapped_y);
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2019-01-31 13:06:42 +00:00
|
|
|
internal Cursor_Limits
|
2019-02-27 05:49:35 +00:00
|
|
|
view_cursor_limits(Models *models, View *view){
|
2019-07-31 20:43:27 +00:00
|
|
|
Editing_File *file = view->file;
|
|
|
|
Face *face = font_set_face_from_id(&models->font_set, file->settings.font_id);
|
|
|
|
i32 line_height = (i32)face->height;
|
2019-06-19 02:31:59 +00:00
|
|
|
i32 visible_height = (i32)view_height(models, view);
|
2018-11-20 08:18:54 +00:00
|
|
|
Cursor_Limits limits = {};
|
2019-02-10 07:48:07 +00:00
|
|
|
limits.min = line_height*2;
|
2019-08-01 02:13:36 +00:00
|
|
|
limits.max = visible_height - line_height*3;
|
2018-03-24 10:06:45 +00:00
|
|
|
if (limits.max - limits.min <= line_height){
|
|
|
|
if (visible_height >= line_height){
|
|
|
|
limits.max = visible_height - line_height;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
limits.max = visible_height;
|
|
|
|
}
|
2019-02-10 07:48:07 +00:00
|
|
|
limits.min = 0;
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
2019-02-10 07:48:07 +00:00
|
|
|
limits.min = clamp(0, limits.min, limits.max);
|
2019-08-01 02:13:36 +00:00
|
|
|
limits.max = clamp_bot(0, limits.max);
|
2019-02-10 07:48:07 +00:00
|
|
|
limits.delta = clamp_top(line_height*5, (limits.max - limits.min + 1)/2);
|
2018-03-24 10:06:45 +00:00
|
|
|
return(limits);
|
|
|
|
}
|
|
|
|
|
2019-01-31 13:06:42 +00:00
|
|
|
internal i32
|
2019-07-31 20:43:27 +00:00
|
|
|
view_compute_max_target_y_from_bottom_y(Models *models, View *view, f32 max_item_y, f32 line_height){
|
|
|
|
f32 height = clamp_bot(line_height, view_height(models, view));
|
2019-06-01 23:58:28 +00:00
|
|
|
f32 max_target_y = clamp_bot(0.f, max_item_y - height*0.5f);
|
2018-07-17 03:21:22 +00:00
|
|
|
return(ceil32(max_target_y));
|
|
|
|
}
|
|
|
|
|
2019-01-31 13:06:42 +00:00
|
|
|
internal i32
|
2019-02-27 05:49:35 +00:00
|
|
|
view_compute_max_target_y(Models *models, View *view){
|
|
|
|
Editing_File *file = view->file;
|
2019-07-31 20:43:27 +00:00
|
|
|
Face *face = font_set_face_from_id(&models->font_set, file->settings.font_id);
|
|
|
|
f32 line_height = face->height;
|
2018-03-24 10:06:45 +00:00
|
|
|
Gap_Buffer *buffer = &file->state.buffer;
|
|
|
|
i32 lowest_line = buffer->line_count;
|
|
|
|
if (!file->settings.unwrapped_lines){
|
|
|
|
lowest_line = file->state.wrap_line_index[buffer->line_count];
|
|
|
|
}
|
2019-07-31 20:43:27 +00:00
|
|
|
return(view_compute_max_target_y_from_bottom_y(models, view, (lowest_line + 0.5f)*line_height, line_height));
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
|
2018-03-25 06:43:56 +00:00
|
|
|
////////////////////////////////
|
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
internal b32
|
2019-07-24 07:41:40 +00:00
|
|
|
view_move_view_to_cursor(Models *models, View *view, GUI_Scroll_Vars *scroll){
|
|
|
|
System_Functions *system = models->system;
|
2019-02-10 07:48:07 +00:00
|
|
|
b32 result = false;
|
2019-06-19 02:31:59 +00:00
|
|
|
i32 max_x = (i32)view_width(models, view);
|
2019-02-27 05:49:35 +00:00
|
|
|
i32 max_y = view_compute_max_target_y(models, view);
|
2018-03-24 10:06:45 +00:00
|
|
|
|
2019-07-24 07:41:40 +00:00
|
|
|
Vec2_i32 cursor = view_get_cursor_xy(models, view);
|
2018-03-24 10:06:45 +00:00
|
|
|
|
|
|
|
GUI_Scroll_Vars scroll_vars = *scroll;
|
|
|
|
i32 target_x = scroll_vars.target_x;
|
|
|
|
i32 target_y = scroll_vars.target_y;
|
|
|
|
|
2019-02-27 05:49:35 +00:00
|
|
|
Cursor_Limits limits = view_cursor_limits(models, view);
|
2019-07-31 20:43:27 +00:00
|
|
|
if (target_y < cursor.y - limits.max){
|
2019-02-10 07:48:07 +00:00
|
|
|
target_y = cursor.y - limits.max + limits.delta;
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
2019-07-31 20:43:27 +00:00
|
|
|
if (target_y > cursor.y - limits.min){
|
|
|
|
target_y = cursor.y - limits.min - limits.delta;
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
target_y = clamp(0, target_y, max_y);
|
|
|
|
|
|
|
|
if (cursor.x >= target_x + max_x){
|
2019-02-10 07:48:07 +00:00
|
|
|
target_x = cursor.x - max_x/2;
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
else if (cursor.x < target_x){
|
2019-06-01 23:58:28 +00:00
|
|
|
target_x = clamp_bot(0, cursor.x - max_x/2);
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (target_x != scroll_vars.target_x || target_y != scroll_vars.target_y){
|
|
|
|
scroll->target_x = target_x;
|
|
|
|
scroll->target_y = target_y;
|
2019-02-10 07:48:07 +00:00
|
|
|
result = true;
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
internal b32
|
2019-07-24 07:41:40 +00:00
|
|
|
view_move_cursor_to_view(Models *models, View *view, GUI_Scroll_Vars scroll, i32 *pos_in_out, f32 preferred_x){
|
|
|
|
System_Functions *system = models->system;
|
2019-02-27 05:49:35 +00:00
|
|
|
Editing_File *file = view->file;
|
2019-07-24 07:41:40 +00:00
|
|
|
Full_Cursor cursor = file_compute_cursor(models, file, seek_pos(*pos_in_out));
|
2019-07-31 20:43:27 +00:00
|
|
|
Face *face = font_set_face_from_id(&models->font_set, file->settings.font_id);
|
|
|
|
f32 line_height = face->height;
|
2019-02-10 00:20:55 +00:00
|
|
|
f32 old_cursor_y = 0.f;
|
2019-02-04 03:51:43 +00:00
|
|
|
if (file->settings.unwrapped_lines){
|
2019-02-10 00:20:55 +00:00
|
|
|
old_cursor_y = cursor.unwrapped_y;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
old_cursor_y = cursor.wrapped_y;
|
2019-02-04 03:51:43 +00:00
|
|
|
}
|
|
|
|
f32 cursor_y = old_cursor_y;
|
2019-02-27 05:49:35 +00:00
|
|
|
f32 target_y = (f32)scroll.target_y;
|
2018-03-24 10:06:45 +00:00
|
|
|
|
2019-02-27 05:49:35 +00:00
|
|
|
Cursor_Limits limits = view_cursor_limits(models, view);
|
2019-02-04 03:51:43 +00:00
|
|
|
|
|
|
|
if (cursor_y > target_y + limits.max){
|
|
|
|
cursor_y = target_y + limits.max;
|
|
|
|
}
|
|
|
|
if (target_y != 0 && cursor_y < target_y + limits.min){
|
|
|
|
cursor_y = target_y + limits.min;
|
|
|
|
}
|
|
|
|
|
|
|
|
b32 result = false;
|
|
|
|
if (cursor_y != old_cursor_y){
|
|
|
|
if (cursor_y > old_cursor_y){
|
|
|
|
cursor_y += line_height;
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
2019-02-04 03:51:43 +00:00
|
|
|
else{
|
|
|
|
cursor_y -= line_height;
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
2019-02-04 03:51:43 +00:00
|
|
|
Buffer_Seek seek = seek_xy(preferred_x, cursor_y, false, file->settings.unwrapped_lines);
|
2019-07-24 07:41:40 +00:00
|
|
|
cursor = file_compute_cursor(models, file, seek);
|
2019-06-20 23:43:27 +00:00
|
|
|
*pos_in_out = (i32)cursor.pos;
|
2019-02-04 03:51:43 +00:00
|
|
|
result = true;
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
2018-03-24 21:43:57 +00:00
|
|
|
|
|
|
|
return(result);
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
|
2019-02-10 09:18:34 +00:00
|
|
|
internal b32
|
|
|
|
view_has_unwrapped_lines(View *view){
|
2019-02-27 05:49:35 +00:00
|
|
|
return(view->file->settings.unwrapped_lines);
|
2019-02-10 09:18:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
internal void
|
|
|
|
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
|
2019-07-24 07:41:40 +00:00
|
|
|
view_set_preferred_x_to_current_position(Models *models, View *view){
|
2019-02-10 09:18:34 +00:00
|
|
|
File_Edit_Positions edit_pos = view_get_edit_pos(view);
|
2019-07-24 07:41:40 +00:00
|
|
|
Full_Cursor cursor = file_compute_cursor(models, view->file, seek_pos(edit_pos.cursor_pos));
|
2019-02-10 09:18:34 +00:00
|
|
|
view_set_preferred_x(view, cursor);
|
|
|
|
}
|
|
|
|
|
2018-03-24 21:43:57 +00:00
|
|
|
internal void
|
2019-02-27 05:49:35 +00:00
|
|
|
view_set_cursor(System_Functions *system, Models *models, View *view, Full_Cursor cursor, b32 set_preferred_x){
|
2019-02-09 22:48:53 +00:00
|
|
|
File_Edit_Positions edit_pos = view_get_edit_pos(view);
|
2019-06-20 23:43:27 +00:00
|
|
|
file_edit_positions_set_cursor(&edit_pos, (i32)cursor.pos);
|
2019-02-10 09:18:34 +00:00
|
|
|
if (set_preferred_x){
|
|
|
|
view_set_preferred_x(view, cursor);
|
|
|
|
}
|
2019-02-10 00:20:55 +00:00
|
|
|
view_set_edit_pos(view, edit_pos);
|
2019-02-09 22:48:53 +00:00
|
|
|
GUI_Scroll_Vars scroll = edit_pos.scroll;
|
2019-07-24 07:41:40 +00:00
|
|
|
if (view_move_view_to_cursor(models, view, &scroll)){
|
2019-02-09 22:48:53 +00:00
|
|
|
edit_pos.scroll = scroll;
|
2019-02-10 00:20:55 +00:00
|
|
|
view_set_edit_pos(view, edit_pos);
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
internal void
|
2019-02-27 05:49:35 +00:00
|
|
|
view_set_scroll(System_Functions *system, Models *models, View *view, GUI_Scroll_Vars scroll){
|
2019-02-09 22:48:53 +00:00
|
|
|
File_Edit_Positions edit_pos = view_get_edit_pos(view);
|
2019-02-27 05:49:35 +00:00
|
|
|
file_edit_positions_set_scroll(&edit_pos, scroll, view_compute_max_target_y(models, view));
|
2019-02-09 22:48:53 +00:00
|
|
|
view_set_edit_pos(view, edit_pos);
|
2019-06-20 23:43:27 +00:00
|
|
|
i32 pos = (i32)edit_pos.cursor_pos;
|
2019-07-24 07:41:40 +00:00
|
|
|
if (view_move_cursor_to_view(models, view, edit_pos.scroll, &pos, view->preferred_x)){
|
|
|
|
Full_Cursor cursor = file_compute_cursor(models, view->file, seek_pos(pos));
|
2019-02-10 00:20:55 +00:00
|
|
|
edit_pos.cursor_pos = cursor.pos;
|
|
|
|
view_set_edit_pos(view, edit_pos);
|
|
|
|
}
|
2018-03-24 21:43:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
internal void
|
2019-02-27 05:49:35 +00:00
|
|
|
view_set_cursor_and_scroll(Models *models, View *view, Full_Cursor cursor, b32 set_preferred_x, GUI_Scroll_Vars scroll){
|
2019-02-09 22:48:53 +00:00
|
|
|
File_Edit_Positions edit_pos = view_get_edit_pos(view);
|
2019-06-20 23:43:27 +00:00
|
|
|
file_edit_positions_set_cursor(&edit_pos, (i32)cursor.pos);
|
2019-02-10 09:18:34 +00:00
|
|
|
if (set_preferred_x){
|
|
|
|
view_set_preferred_x(view, cursor);
|
|
|
|
}
|
2019-02-27 05:49:35 +00:00
|
|
|
file_edit_positions_set_scroll(&edit_pos, scroll, view_compute_max_target_y(models, view));
|
2019-02-09 22:48:53 +00:00
|
|
|
edit_pos.last_set_type = EditPos_None;
|
|
|
|
view_set_edit_pos(view, edit_pos);
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
|
2019-01-31 13:06:42 +00:00
|
|
|
internal void
|
2018-03-25 06:43:56 +00:00
|
|
|
view_post_paste_effect(View *view, f32 seconds, i32 start, i32 size, u32 color){
|
2019-02-27 05:49:35 +00:00
|
|
|
Editing_File *file = view->file;
|
2018-03-25 06:43:56 +00:00
|
|
|
file->state.paste_effect.start = start;
|
|
|
|
file->state.paste_effect.end = start + size;
|
|
|
|
file->state.paste_effect.color = color;
|
|
|
|
file->state.paste_effect.seconds_down = seconds;
|
|
|
|
file->state.paste_effect.seconds_max = seconds;
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
|
2018-03-25 06:43:56 +00:00
|
|
|
////////////////////////////////
|
|
|
|
|
2018-03-26 05:19:08 +00:00
|
|
|
internal void
|
|
|
|
view_set_file(System_Functions *system, Models *models, View *view, Editing_File *file){
|
|
|
|
Assert(file != 0);
|
|
|
|
|
2019-02-27 05:49:35 +00:00
|
|
|
Editing_File *old_file = view->file;
|
2019-02-04 03:51:43 +00:00
|
|
|
if (old_file != 0){
|
|
|
|
file_touch(&models->working_set, old_file);
|
2019-02-10 00:20:55 +00:00
|
|
|
file_edit_positions_push(old_file, view_get_edit_pos(view));
|
2018-03-26 05:19:08 +00:00
|
|
|
}
|
|
|
|
|
2019-02-27 05:49:35 +00:00
|
|
|
view->file = file;
|
2018-03-26 05:19:08 +00:00
|
|
|
|
2019-02-10 00:35:47 +00:00
|
|
|
File_Edit_Positions edit_pos = file_edit_positions_pop(file);
|
|
|
|
view_set_edit_pos(view, edit_pos);
|
2019-02-10 09:18:34 +00:00
|
|
|
view->mark = edit_pos.cursor_pos;
|
2019-07-24 07:41:40 +00:00
|
|
|
view_set_preferred_x_to_current_position(models, view);
|
2018-03-26 05:19:08 +00:00
|
|
|
|
2019-07-24 07:41:40 +00:00
|
|
|
Face *face = font_set_face_from_id(&models->font_set, file->settings.font_id);
|
2019-07-21 18:16:34 +00:00
|
|
|
Assert(face != 0);
|
|
|
|
|
2019-02-24 07:22:16 +00:00
|
|
|
models->layout.panel_state_dirty = true;
|
2018-03-26 05:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
2018-03-24 21:43:57 +00:00
|
|
|
internal b32
|
2019-02-05 09:13:38 +00:00
|
|
|
file_is_viewed(Layout *layout, Editing_File *file){
|
2018-03-24 21:43:57 +00:00
|
|
|
b32 is_viewed = false;
|
2019-02-05 09:13:38 +00:00
|
|
|
for (Panel *panel = layout_get_first_open_panel(layout);
|
|
|
|
panel != 0;
|
|
|
|
panel = layout_get_next_open_panel(layout, panel)){
|
2018-03-24 21:43:57 +00:00
|
|
|
View *view = panel->view;
|
2019-02-27 05:49:35 +00:00
|
|
|
if (view->file == file){
|
2018-03-24 21:43:57 +00:00
|
|
|
is_viewed = true;
|
|
|
|
break;
|
|
|
|
}
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
2018-03-24 21:43:57 +00:00
|
|
|
return(is_viewed);
|
|
|
|
}
|
|
|
|
|
|
|
|
internal void
|
2018-03-25 06:43:56 +00:00
|
|
|
adjust_views_looking_at_file_to_new_cursor(System_Functions *system, Models *models, Editing_File *file){
|
2019-02-05 09:13:38 +00:00
|
|
|
Layout *layout = &models->layout;
|
|
|
|
for (Panel *panel = layout_get_first_open_panel(layout);
|
|
|
|
panel != 0;
|
|
|
|
panel = layout_get_next_open_panel(layout, panel)){
|
2018-03-24 21:43:57 +00:00
|
|
|
View *view = panel->view;
|
2019-02-27 05:49:35 +00:00
|
|
|
if (view->file == file){
|
2019-02-10 00:20:55 +00:00
|
|
|
File_Edit_Positions edit_pos = view_get_edit_pos(view);
|
2019-07-24 07:41:40 +00:00
|
|
|
Full_Cursor cursor = file_compute_cursor(models, file, seek_pos(edit_pos.cursor_pos));
|
2019-02-27 05:49:35 +00:00
|
|
|
view_set_cursor(system, models, view, cursor, true);
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
internal void
|
2018-03-25 06:43:56 +00:00
|
|
|
file_full_remeasure(System_Functions *system, Models *models, Editing_File *file){
|
|
|
|
Face_ID font_id = file->settings.font_id;
|
2019-07-24 07:41:40 +00:00
|
|
|
Face *face = font_set_face_from_id(&models->font_set, font_id);
|
2019-07-21 18:16:34 +00:00
|
|
|
file_measure_wraps(system, &models->mem, file, face);
|
2018-03-25 06:43:56 +00:00
|
|
|
adjust_views_looking_at_file_to_new_cursor(system, models, file);
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
|
2018-03-25 06:43:56 +00:00
|
|
|
internal void
|
|
|
|
file_set_font(System_Functions *system, Models *models, Editing_File *file, Face_ID font_id){
|
|
|
|
file->settings.font_id = font_id;
|
|
|
|
file_full_remeasure(system, models, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
internal void
|
|
|
|
global_set_font_and_update_files(System_Functions *system, Models *models, Face_ID font_id){
|
2019-01-31 12:38:24 +00:00
|
|
|
for (Node *node = models->working_set.used_sentinel.next;
|
2018-03-25 06:43:56 +00:00
|
|
|
node != &models->working_set.used_sentinel;
|
|
|
|
node = node->next){
|
2019-01-31 12:38:24 +00:00
|
|
|
Editing_File *file = CastFromMember(Editing_File, main_chain_node, node);
|
2018-03-25 06:43:56 +00:00
|
|
|
file_set_font(system, models, file, font_id);
|
|
|
|
}
|
|
|
|
models->global_font_id = font_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
internal b32
|
2019-07-24 07:41:40 +00:00
|
|
|
alter_font_and_update_files(System_Functions *system, Models *models, Face_ID face_id, Face_Description *new_description){
|
2018-03-25 06:43:56 +00:00
|
|
|
b32 success = false;
|
2019-07-24 07:41:40 +00:00
|
|
|
if (font_set_modify_face(&models->font_set, face_id, new_description)){
|
2018-03-25 06:43:56 +00:00
|
|
|
success = true;
|
2019-01-31 12:38:24 +00:00
|
|
|
for (Node *node = models->working_set.used_sentinel.next;
|
2018-03-25 06:43:56 +00:00
|
|
|
node != &models->working_set.used_sentinel;
|
|
|
|
node = node->next){
|
2019-01-31 12:38:24 +00:00
|
|
|
Editing_File *file = CastFromMember(Editing_File, main_chain_node, node);
|
2019-07-24 07:41:40 +00:00
|
|
|
if (file->settings.font_id == face_id){
|
2018-03-25 06:43:56 +00:00
|
|
|
file_full_remeasure(system, models, file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(success);
|
|
|
|
}
|
|
|
|
|
|
|
|
internal b32
|
|
|
|
release_font_and_update_files(System_Functions *system, Models *models, Face_ID font_id, Face_ID replacement_id){
|
|
|
|
b32 success = false;
|
2019-07-24 07:41:40 +00:00
|
|
|
if (font_set_release_face(&models->font_set, font_id)){
|
|
|
|
Face *face = font_set_face_from_id(&models->font_set, replacement_id);
|
|
|
|
if (face == 0){
|
|
|
|
replacement_id = font_set_get_fallback_face(&models->font_set);
|
|
|
|
Assert(font_set_face_from_id(&models->font_set, replacement_id) != 0);
|
2018-03-25 06:43:56 +00:00
|
|
|
}
|
2019-01-31 12:38:24 +00:00
|
|
|
for (Node *node = models->working_set.used_sentinel.next;
|
2018-03-25 06:43:56 +00:00
|
|
|
node != &models->working_set.used_sentinel;
|
|
|
|
node = node->next){
|
2019-01-31 12:38:24 +00:00
|
|
|
Editing_File *file = CastFromMember(Editing_File, main_chain_node, node);
|
2018-03-25 06:43:56 +00:00
|
|
|
if (file->settings.font_id == font_id){
|
|
|
|
file_set_font(system, models, file, replacement_id);
|
|
|
|
}
|
|
|
|
}
|
2019-07-24 07:41:40 +00:00
|
|
|
success = true;
|
2018-03-25 06:43:56 +00:00
|
|
|
}
|
|
|
|
return(success);
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
|
2018-03-26 05:19:08 +00:00
|
|
|
////////////////////////////////
|
|
|
|
|
2019-02-25 23:42:13 +00:00
|
|
|
internal argb_color
|
|
|
|
finalize_color(Color_Table color_table, int_color color){
|
|
|
|
argb_color color_argb = color;
|
|
|
|
if ((color & 0xFF000000) == 0){
|
|
|
|
color_argb = color_table.vals[color % color_table.count];
|
2019-01-25 21:03:52 +00:00
|
|
|
}
|
2019-02-25 23:42:13 +00:00
|
|
|
return(color_argb);
|
2019-01-25 21:03:52 +00:00
|
|
|
}
|
|
|
|
|
2018-11-27 15:21:10 +00:00
|
|
|
internal u32
|
2019-02-25 23:42:13 +00:00
|
|
|
get_token_color(Color_Table color_table, Cpp_Token token){
|
2018-11-27 15:21:10 +00:00
|
|
|
u32 result = 0;
|
|
|
|
if ((token.flags & CPP_TFLAG_IS_KEYWORD) != 0){
|
2019-02-05 01:06:48 +00:00
|
|
|
if (cpp_token_category_from_type(token.type) == CPP_TOKEN_CAT_BOOLEAN_CONSTANT){
|
2019-02-25 23:42:13 +00:00
|
|
|
result = color_table.vals[Stag_Bool_Constant];
|
2018-11-27 15:21:10 +00:00
|
|
|
}
|
|
|
|
else{
|
2019-02-25 23:42:13 +00:00
|
|
|
result = color_table.vals[Stag_Keyword];
|
2018-11-27 15:21:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((token.flags & CPP_TFLAG_PP_DIRECTIVE) != 0){
|
2019-02-25 23:42:13 +00:00
|
|
|
result = color_table.vals[Stag_Preproc];
|
2018-11-27 15:21:10 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
switch (token.type){
|
|
|
|
case CPP_TOKEN_COMMENT:
|
|
|
|
{
|
2019-02-25 23:42:13 +00:00
|
|
|
result = color_table.vals[Stag_Comment];
|
2018-11-27 15:21:10 +00:00
|
|
|
}break;
|
|
|
|
case CPP_TOKEN_STRING_CONSTANT:
|
|
|
|
{
|
2019-02-25 23:42:13 +00:00
|
|
|
result = color_table.vals[Stag_Str_Constant];
|
2018-11-27 15:21:10 +00:00
|
|
|
}break;
|
|
|
|
case CPP_TOKEN_CHARACTER_CONSTANT:
|
|
|
|
{
|
2019-02-25 23:42:13 +00:00
|
|
|
result = color_table.vals[Stag_Char_Constant];
|
2018-11-27 15:21:10 +00:00
|
|
|
}break;
|
|
|
|
case CPP_TOKEN_INTEGER_CONSTANT:
|
|
|
|
{
|
2019-02-25 23:42:13 +00:00
|
|
|
result = color_table.vals[Stag_Int_Constant];
|
2018-11-27 15:21:10 +00:00
|
|
|
}break;
|
|
|
|
case CPP_TOKEN_FLOATING_CONSTANT:
|
|
|
|
{
|
2019-02-25 23:42:13 +00:00
|
|
|
result = color_table.vals[Stag_Float_Constant];
|
2018-11-27 15:21:10 +00:00
|
|
|
}break;
|
|
|
|
case CPP_PP_INCLUDE_FILE:
|
|
|
|
{
|
2019-02-25 23:42:13 +00:00
|
|
|
result = color_table.vals[Stag_Include];
|
2018-11-27 15:21:10 +00:00
|
|
|
}break;
|
|
|
|
default:
|
|
|
|
{
|
2019-02-25 23:42:13 +00:00
|
|
|
result = color_table.vals[Stag_Default];
|
2018-11-27 15:21:10 +00:00
|
|
|
}break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2018-09-22 23:45:24 +00:00
|
|
|
internal void
|
2018-09-30 12:14:47 +00:00
|
|
|
render_loaded_file_in_view__inner(Models *models, Render_Target *target, View *view,
|
2019-08-01 03:16:53 +00:00
|
|
|
Rect_i32 rect, Full_Cursor render_cursor, Range on_screen_range,
|
|
|
|
Buffer_Render_Item *items, int_color *item_colors, i32 item_count){
|
2019-02-27 05:49:35 +00:00
|
|
|
Editing_File *file = view->file;
|
2019-06-01 23:58:28 +00:00
|
|
|
Arena *scratch = &models->mem.arena;
|
2019-02-25 23:42:13 +00:00
|
|
|
Color_Table color_table = models->color_table;
|
2019-07-25 07:17:01 +00:00
|
|
|
Font_Set *font_set = &models->font_set;
|
2018-03-25 06:43:56 +00:00
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
Assert(file != 0);
|
2018-03-26 05:19:08 +00:00
|
|
|
Assert(!file->is_dummy);
|
|
|
|
Assert(buffer_good(&file->state.buffer));
|
2018-03-24 10:06:45 +00:00
|
|
|
|
2018-09-30 12:14:47 +00:00
|
|
|
b32 tokens_use = file->state.tokens_complete && (file->state.token_array.count > 0);
|
|
|
|
Cpp_Token_Array token_array = file->state.token_array;
|
2018-09-24 23:33:26 +00:00
|
|
|
b32 wrapped = !file->settings.unwrapped_lines;
|
2018-09-30 12:14:47 +00:00
|
|
|
Face_ID font_id = file->settings.font_id;
|
2018-09-22 00:29:32 +00:00
|
|
|
|
2018-09-22 23:45:24 +00:00
|
|
|
i32 *line_starts = file->state.buffer.line_starts;
|
|
|
|
i32 line_count = file->state.buffer.line_count;
|
2019-06-20 23:43:27 +00:00
|
|
|
i32 line_scan_index = (i32)render_cursor.line - 1;
|
2018-09-22 23:45:24 +00:00
|
|
|
i32 first_byte_index_of_next_line = 0;
|
|
|
|
if (line_scan_index + 1 < line_count){
|
|
|
|
first_byte_index_of_next_line = line_starts[line_scan_index + 1];
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
first_byte_index_of_next_line = max_i32;
|
|
|
|
}
|
|
|
|
|
|
|
|
i32 *wrap_starts = file->state.wrap_positions;
|
|
|
|
i32 wrap_count = file->state.wrap_position_count;
|
2018-09-25 04:33:26 +00:00
|
|
|
if (wrap_count > 0 && wrap_starts[wrap_count - 1] == buffer_size(&file->state.buffer)){
|
|
|
|
wrap_count -= 1;
|
|
|
|
}
|
2019-06-20 23:43:27 +00:00
|
|
|
i32 wrap_scan_index = (i32)render_cursor.wrap_line - (i32)render_cursor.line;
|
2018-09-22 23:45:24 +00:00
|
|
|
i32 first_byte_index_of_next_wrap = 0;
|
|
|
|
if (wrap_scan_index + 1 < wrap_count){
|
|
|
|
first_byte_index_of_next_wrap = wrap_starts[wrap_scan_index + 1];
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
first_byte_index_of_next_wrap = max_i32;
|
|
|
|
}
|
|
|
|
|
2018-09-22 00:29:32 +00:00
|
|
|
i32 visual_markers_scan_index = 0;
|
|
|
|
|
2018-09-22 23:45:24 +00:00
|
|
|
i32 visual_line_markers_scan_index = 0;
|
|
|
|
u32 visual_line_markers_color = 0;
|
|
|
|
|
2018-09-30 12:14:47 +00:00
|
|
|
i32 visual_range_markers_scan_index = 0;
|
|
|
|
i32 visual_line_range_markers_scan_index = 0;
|
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
i32 token_i = 0;
|
2019-02-25 23:42:13 +00:00
|
|
|
u32 main_color = color_table.vals[Stag_Default];
|
|
|
|
u32 special_color = color_table.vals[Stag_Special_Character];
|
|
|
|
u32 ghost_color = color_table.vals[Stag_Ghost_Character];
|
2018-03-24 10:06:45 +00:00
|
|
|
if (tokens_use){
|
|
|
|
Cpp_Get_Token_Result result = cpp_get_token(token_array, items->index);
|
2019-02-25 23:42:13 +00:00
|
|
|
main_color = get_token_color(color_table, token_array.tokens[result.token_index]);
|
2018-03-24 10:06:45 +00:00
|
|
|
token_i = result.token_index + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Buffer_Render_Item *item = items;
|
2018-09-30 12:14:47 +00:00
|
|
|
Buffer_Render_Item *item_end = item + item_count;
|
2018-03-24 10:06:45 +00:00
|
|
|
i32 prev_ind = -1;
|
|
|
|
u32 highlight_color = 0;
|
|
|
|
|
2019-08-01 03:16:53 +00:00
|
|
|
for (i32 i = 0; item < item_end; item += 1, i += 1){
|
2018-03-24 10:06:45 +00:00
|
|
|
i32 ind = item->index;
|
2018-09-22 23:45:24 +00:00
|
|
|
|
|
|
|
// NOTE(allen): Line scanning
|
|
|
|
b32 is_new_line = false;
|
|
|
|
for (; line_scan_index < line_count;){
|
|
|
|
if (ind < first_byte_index_of_next_line){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
line_scan_index += 1;
|
|
|
|
is_new_line = true;
|
|
|
|
if (line_scan_index + 1 < line_count){
|
|
|
|
first_byte_index_of_next_line = line_starts[line_scan_index + 1];
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
first_byte_index_of_next_line = max_i32;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (item == items){
|
|
|
|
is_new_line = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE(allen): Wrap scanning
|
|
|
|
b32 is_new_wrap = false;
|
2018-09-24 23:33:26 +00:00
|
|
|
if (wrapped){
|
|
|
|
for (; wrap_scan_index < wrap_count;){
|
|
|
|
if (ind < first_byte_index_of_next_wrap){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
wrap_scan_index += 1;
|
|
|
|
is_new_wrap = true;
|
|
|
|
if (wrap_scan_index + 1 < wrap_count){
|
|
|
|
first_byte_index_of_next_wrap = wrap_starts[wrap_scan_index + 1];
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
first_byte_index_of_next_wrap = max_i32;
|
|
|
|
}
|
2018-09-22 23:45:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE(allen): Token scanning
|
2018-09-22 00:29:32 +00:00
|
|
|
u32 highlight_this_color = 0;
|
2018-03-24 10:06:45 +00:00
|
|
|
if (tokens_use && ind != prev_ind){
|
|
|
|
Cpp_Token current_token = token_array.tokens[token_i-1];
|
|
|
|
|
|
|
|
if (token_i < token_array.count){
|
|
|
|
if (ind >= token_array.tokens[token_i].start){
|
|
|
|
for (;token_i < token_array.count && ind >= token_array.tokens[token_i].start; ++token_i){
|
2019-02-25 23:42:13 +00:00
|
|
|
main_color = get_token_color(color_table, token_array.tokens[token_i]);
|
2018-03-24 10:06:45 +00:00
|
|
|
current_token = token_array.tokens[token_i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ind >= current_token.start + current_token.size){
|
2019-02-25 23:42:13 +00:00
|
|
|
main_color = color_table.vals[Stag_Default];
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (current_token.type == CPP_TOKEN_JUNK && ind >= current_token.start && ind < current_token.start + current_token.size){
|
2019-02-25 23:42:13 +00:00
|
|
|
highlight_color = color_table.vals[Stag_Highlight_Junk];
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
highlight_color = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-17 04:31:04 +00:00
|
|
|
if (item->y1 > 0){
|
2019-08-01 02:13:36 +00:00
|
|
|
Rect_f32 char_rect = f32R(item->x0, item->y0, item->x1, item->y1);
|
2018-12-17 04:31:04 +00:00
|
|
|
|
|
|
|
u32 char_color = main_color;
|
2019-08-01 03:16:53 +00:00
|
|
|
if (on_screen_range.min <= ind && ind < on_screen_range.max){
|
|
|
|
i32 index_shifted = ind - on_screen_range.min;
|
|
|
|
if (item_colors[index_shifted] != 0){
|
|
|
|
char_color = finalize_color(color_table, item_colors[index_shifted]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (HasFlag(item->flags, BRFlag_Special_Character)){
|
2018-12-17 04:31:04 +00:00
|
|
|
char_color = special_color;
|
|
|
|
}
|
2019-08-01 03:16:53 +00:00
|
|
|
else if (HasFlag(item->flags, BRFlag_Ghost_Character)){
|
2018-12-17 04:31:04 +00:00
|
|
|
char_color = ghost_color;
|
|
|
|
}
|
|
|
|
|
2019-02-27 05:49:35 +00:00
|
|
|
if (view->show_whitespace && highlight_color == 0 && codepoint_is_whitespace(item->codepoint)){
|
2019-02-25 23:42:13 +00:00
|
|
|
highlight_this_color = color_table.vals[Stag_Highlight_White];
|
2018-12-17 04:31:04 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
highlight_this_color = highlight_color;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE(allen): Perform highlight, wireframe, and ibar renders
|
|
|
|
u32 color_highlight = 0;
|
|
|
|
u32 color_wireframe = 0;
|
|
|
|
u32 color_ibar = 0;
|
|
|
|
|
|
|
|
if (highlight_this_color != 0){
|
|
|
|
if (color_highlight == 0){
|
|
|
|
color_highlight = highlight_this_color;
|
|
|
|
}
|
2018-09-22 00:29:32 +00:00
|
|
|
}
|
2018-12-17 04:31:04 +00:00
|
|
|
|
|
|
|
if (color_highlight != 0){
|
|
|
|
draw_rectangle(target, char_rect, color_highlight);
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 fade_color = 0xFFFF00FF;
|
|
|
|
f32 fade_amount = 0.f;
|
|
|
|
if (file->state.paste_effect.seconds_down > 0.f &&
|
|
|
|
file->state.paste_effect.start <= ind &&
|
|
|
|
ind < file->state.paste_effect.end){
|
|
|
|
fade_color = file->state.paste_effect.color;
|
|
|
|
fade_amount = file->state.paste_effect.seconds_down;
|
|
|
|
fade_amount /= file->state.paste_effect.seconds_max;
|
|
|
|
}
|
|
|
|
char_color = color_blend(char_color, fade_amount, fade_color);
|
|
|
|
if (item->codepoint != 0){
|
2019-07-25 07:17:01 +00:00
|
|
|
draw_font_glyph(target, font_set, font_id, item->codepoint, item->x0, item->y0, char_color, GlyphFlag_None);
|
2018-12-17 04:31:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (color_wireframe != 0){
|
|
|
|
draw_rectangle_outline(target, char_rect, color_wireframe);
|
|
|
|
}
|
2018-09-22 00:29:32 +00:00
|
|
|
}
|
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
prev_ind = ind;
|
|
|
|
}
|
2018-09-30 12:14:47 +00:00
|
|
|
}
|
|
|
|
|
2019-02-10 02:56:29 +00:00
|
|
|
internal Full_Cursor
|
2019-07-24 07:41:40 +00:00
|
|
|
file_get_render_cursor(Models *models, Editing_File *file, f32 scroll_y){
|
2019-02-10 02:56:29 +00:00
|
|
|
Full_Cursor result = {};
|
|
|
|
if (file->settings.unwrapped_lines){
|
2019-07-24 07:41:40 +00:00
|
|
|
result = file_compute_cursor_hint(models, file, seek_unwrapped_xy(0, scroll_y, false));
|
2019-02-10 02:56:29 +00:00
|
|
|
}
|
|
|
|
else{
|
2019-07-24 07:41:40 +00:00
|
|
|
result = file_compute_cursor(models, file, seek_wrapped_xy(0, scroll_y, false));
|
2019-02-10 02:56:29 +00:00
|
|
|
}
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2019-04-02 16:23:07 +00:00
|
|
|
internal Full_Cursor
|
2019-07-24 07:41:40 +00:00
|
|
|
view_get_render_cursor(Models *models, View *view, f32 scroll_y){
|
|
|
|
return(file_get_render_cursor(models, view->file, scroll_y));
|
2019-04-02 16:23:07 +00:00
|
|
|
}
|
|
|
|
|
2019-02-10 02:56:29 +00:00
|
|
|
internal Full_Cursor
|
2019-07-24 07:41:40 +00:00
|
|
|
view_get_render_cursor(Models *models, View *view){
|
2019-02-10 02:56:29 +00:00
|
|
|
File_Edit_Positions edit_pos = view_get_edit_pos(view);
|
|
|
|
f32 scroll_y = edit_pos.scroll.scroll_y;
|
2019-02-27 05:49:35 +00:00
|
|
|
//scroll_y += view->widget_height;
|
2019-07-24 07:41:40 +00:00
|
|
|
return(view_get_render_cursor(models, view, scroll_y));
|
2019-02-10 02:56:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
internal Full_Cursor
|
2019-07-24 07:41:40 +00:00
|
|
|
view_get_render_cursor_target(Models *models, View *view){
|
2019-02-10 02:56:29 +00:00
|
|
|
File_Edit_Positions edit_pos = view_get_edit_pos(view);
|
|
|
|
f32 scroll_y = (f32)edit_pos.scroll.target_y;
|
2019-02-27 05:49:35 +00:00
|
|
|
//scroll_y += view->widget_height;
|
2019-07-24 07:41:40 +00:00
|
|
|
return(view_get_render_cursor(models, view, scroll_y));
|
2019-02-10 02:56:29 +00:00
|
|
|
}
|
|
|
|
|
2019-02-26 19:59:57 +00:00
|
|
|
internal void
|
2019-04-05 23:30:24 +00:00
|
|
|
view_quit_ui(System_Functions *system, Models *models, View *view){
|
|
|
|
Assert(view != 0);
|
|
|
|
view->ui_mode = false;
|
|
|
|
if (view->ui_quit != 0){
|
|
|
|
view->ui_quit(&models->app_links, view_get_id(&models->live_set, view));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
internal View*
|
|
|
|
imp_get_view(Models *models, View_ID view_id){
|
|
|
|
Live_Views *live_set = &models->live_set;
|
|
|
|
View *view = 0;
|
|
|
|
view_id -= 1;
|
|
|
|
if (0 <= view_id && view_id < live_set->max){
|
|
|
|
view = live_set->views + view_id;
|
|
|
|
if (!view->in_use){
|
|
|
|
view = 0;
|
|
|
|
}
|
2019-02-26 19:59:57 +00:00
|
|
|
}
|
2019-04-05 23:30:24 +00:00
|
|
|
return(view);
|
2019-02-26 19:59:57 +00:00
|
|
|
}
|
2017-07-17 23:35:13 +00:00
|
|
|
|
|
|
|
// BOTTOM
|
|
|
|
|