From 1aaf470605ef60af9b130c1094a41872a1eaf065 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Wed, 26 Sep 2018 22:27:25 -0700 Subject: [PATCH] Cursor & mark render through marker system controlled in render caller --- 4coder_default_hooks.cpp | 24 ++++++++++++++++++++++++ 4ed_view.cpp | 38 -------------------------------------- 2 files changed, 24 insertions(+), 38 deletions(-) diff --git a/4coder_default_hooks.cpp b/4coder_default_hooks.cpp index fe42ed58..0ef6629a 100644 --- a/4coder_default_hooks.cpp +++ b/4coder_default_hooks.cpp @@ -60,6 +60,30 @@ RENDER_CALLER_SIG(default_render_caller){ render_scope = create_user_managed_scope(app); } + // NOTE(allen): Cursor and mark + { + Theme_Color colors[2] = {0}; + colors[0].tag = Stag_Cursor; + colors[1].tag = Stag_Mark; + get_theme_colors(app, colors, 2); + uint32_t cursor_color = colors[0].color; + uint32_t mark_color = colors[1].color; + { + Managed_Object o = alloc_buffer_markers_on_buffer(app, buffer.buffer_id, 1, &render_scope); + buffer_markers_set_visuals(app, o, BufferMarkersType_CharacterBlocks, cursor_color, 0, 0); + Marker marker = {0}; + marker.pos = view.cursor.pos; + managed_object_store_data(app, o, 0, 1, &marker); + } + { + Managed_Object o = alloc_buffer_markers_on_buffer(app, buffer.buffer_id, 1, &render_scope); + buffer_markers_set_visuals(app, o, BufferMarkersType_CharacterWireFrames, mark_color, 0, 0); + Marker marker = {0}; + marker.pos = view.mark.pos; + managed_object_store_data(app, o, 0, 1, &marker); + } + } + // NOTE(allen): Line highlight setup if (highlight_line_at_cursor){ Theme_Color color = {0}; diff --git a/4ed_view.cpp b/4ed_view.cpp index 27574973..94bd9c7d 100644 --- a/4ed_view.cpp +++ b/4ed_view.cpp @@ -837,23 +837,6 @@ render_loaded_file_in_view(System_Functions *system, View *view, Models *models, i32 visual_line_markers_scan_index = 0; u32 visual_line_markers_color = 0; - i32 cursor_begin = 0; - i32 cursor_end = 0; - u32 cursor_color = 0; - u32 at_cursor_color = 0; - if (view->transient.file_data.show_temp_highlight){ - cursor_begin = view->transient.file_data.temp_highlight.pos; - cursor_end = view->transient.file_data.temp_highlight_end_pos; - cursor_color = style->main.highlight_color; - at_cursor_color = style->main.at_highlight_color; - } - else{ - cursor_begin = view->transient.edit_pos->cursor.pos; - cursor_end = cursor_begin + 1; - cursor_color = style->main.cursor_color; - at_cursor_color = style->main.at_cursor_color; - } - i32 token_i = 0; u32 main_color = style->main.default_color; u32 special_color = style->main.special_character_color; @@ -864,7 +847,6 @@ render_loaded_file_in_view(System_Functions *system, View *view, Models *models, token_i = result.token_index + 1; } - u32 mark_color = style->main.mark_color; Buffer_Render_Item *item = items; Buffer_Render_Item *item_end = item + count; i32 prev_ind = -1; @@ -1024,26 +1006,6 @@ render_loaded_file_in_view(System_Functions *system, View *view, Models *models, u32 color_wireframe = 0; u32 color_ibar = 0; - if (ind == view->transient.edit_pos->mark && prev_ind != ind){ - if (color_wireframe == 0){ - color_wireframe = mark_color; - } - } - if (cursor_begin <= ind && ind < cursor_end && (ind != prev_ind || cursor_begin < ind)){ - if (is_active){ - if (color_highlight == 0){ - color_highlight = cursor_color; - } - char_color = at_cursor_color; - } - else{ - if (!view->transient.file_data.show_temp_highlight){ - if (color_wireframe == 0){ - color_wireframe = cursor_color; - } - } - } - } if (marker_highlight != 0){ if (color_highlight == 0){ color_highlight = marker_highlight;