Simplify fade range code; make it update with buffer edits
This commit is contained in:
parent
6dd43762c4
commit
886c70100d
|
@ -251,7 +251,7 @@ CUSTOM_DOC("Paste multiple entries from the clipboard at once")
|
|||
view_set_cursor_and_preferred_x(app, view, seek_pos(range.max + insert_string.size));
|
||||
|
||||
ARGB_Color argb = fcolor_resolve(fcolor_id(defcolor_paste));
|
||||
view_post_fade(app, buffer, 0.667f, Ii64(range.max + 1, range.max + insert_string.size), argb);
|
||||
buffer_post_fade(app, buffer, 0.667f, Ii64(range.max + 1, range.max + insert_string.size), argb);
|
||||
}
|
||||
else{
|
||||
paste(app);
|
||||
|
|
|
@ -717,15 +717,20 @@ buffer_post_fade(Application_Links *app, Buffer_ID buffer_id, f32 seconds, Range
|
|||
}
|
||||
|
||||
function void
|
||||
view_post_fade(Application_Links *app, View_ID view_id, f32 seconds, Range_i64 range, ARGB_Color color){
|
||||
Fade_Range *fade_range = alloc_fade_range();
|
||||
sll_queue_push(view_fade_ranges.first, view_fade_ranges.last, fade_range);
|
||||
view_fade_ranges.count += 1;
|
||||
fade_range->view_id = view_id;
|
||||
fade_range->t = seconds;
|
||||
fade_range->full_t = seconds;
|
||||
fade_range->range = range;
|
||||
fade_range->color= color;
|
||||
buffer_shift_fade_ranges(Buffer_ID buffer_id, i64 shift_after_p, i64 shift_amount){
|
||||
for (Fade_Range *node = buffer_fade_ranges.first;
|
||||
node != 0;
|
||||
node = node->next){
|
||||
if (node->buffer_id == buffer_id){
|
||||
if (node->range.min >= shift_after_p){
|
||||
node->range.min += shift_amount;
|
||||
node->range.max += shift_amount;
|
||||
}
|
||||
else if (node->range.max >= shift_after_p){
|
||||
node->range.max += shift_amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function b32
|
||||
|
@ -742,29 +747,14 @@ tick_all_fade_ranges(f32 t){
|
|||
}
|
||||
else{
|
||||
prev_next = &node->next;
|
||||
buffer_fade_ranges.last = node;
|
||||
}
|
||||
}
|
||||
|
||||
prev_next = &view_fade_ranges.first;
|
||||
for (Fade_Range *node = view_fade_ranges.first, *next = 0;
|
||||
node != 0;
|
||||
node = next){
|
||||
next = node->next;
|
||||
node->t -= t;
|
||||
if (node->t <= 0.f){
|
||||
*prev_next = next;
|
||||
view_fade_ranges.count -= 1;
|
||||
}
|
||||
else{
|
||||
prev_next = &node->next;
|
||||
}
|
||||
}
|
||||
|
||||
return(buffer_fade_ranges.count > 0 || view_fade_ranges.count > 0);
|
||||
}
|
||||
|
||||
function void
|
||||
paint_fade_ranges(Application_Links *app, Text_Layout_ID layout, Buffer_ID buffer, View_ID view){
|
||||
paint_fade_ranges(Application_Links *app, Text_Layout_ID layout, Buffer_ID buffer){
|
||||
for (Fade_Range *node = buffer_fade_ranges.first;
|
||||
node != 0;
|
||||
node = node->next){
|
||||
|
@ -772,14 +762,6 @@ paint_fade_ranges(Application_Links *app, Text_Layout_ID layout, Buffer_ID buffe
|
|||
paint_text_color_blend(app, layout, node->range, node->color, node->t/node->full_t);
|
||||
}
|
||||
}
|
||||
|
||||
for (Fade_Range *node = view_fade_ranges.first;
|
||||
node != 0;
|
||||
node = node->next){
|
||||
if (node->view_id == view){
|
||||
paint_text_color_blend(app, layout, node->range, node->color, node->t/node->full_t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
|
|
|
@ -98,10 +98,7 @@ struct Buffer_Modified_Set{
|
|||
|
||||
struct Fade_Range{
|
||||
Fade_Range *next;
|
||||
union{
|
||||
Buffer_ID buffer_id;
|
||||
View_ID view_id;
|
||||
};
|
||||
f32 t;
|
||||
f32 full_t;
|
||||
Range_i64 range;
|
||||
|
|
|
@ -378,7 +378,7 @@ default_render_buffer(Application_Links *app, View_ID view_id, Face_ID face_id,
|
|||
}
|
||||
|
||||
// NOTE(allen): Fade ranges
|
||||
paint_fade_ranges(app, text_layout_id, buffer, view_id);
|
||||
paint_fade_ranges(app, text_layout_id, buffer);
|
||||
|
||||
// NOTE(allen): put the actual text on the actual screen
|
||||
draw_text_layout_default(app, text_layout_id);
|
||||
|
@ -919,6 +919,8 @@ BUFFER_EDIT_RANGE_SIG(default_buffer_edit_range){
|
|||
|
||||
Range_i64 old_range = Ii64(new_range.first, new_range.first + original_size);
|
||||
|
||||
buffer_shift_fade_ranges(buffer_id, old_range.max, (new_range.max - old_range.max));
|
||||
|
||||
{
|
||||
code_index_lock();
|
||||
Code_Index_File *file = code_index_get_file(buffer_id);
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
+ Fix: no crash when a project file .cmd is not the right type
|
||||
+ Fix: windows layer now generates layout independent key stroke events
|
||||
+ Fix: notepad like mode scrolling does not snap mark to cursor
|
||||
+ Fix: special case colors from the theme override general case colors
|
||||
+ Fix: Paste fade range is updated with buffer edits
|
||||
|
||||
4.1.4
|
||||
+ MAJOR: The clipboard history is now a fully custom layer implemented system. Users maintaining a customization layer should try to update their call sites to the old clipboard API. #define FCODER_TRANSITION_TO 4001004 to disable the transitional function wrappers when you are ready to make the transition.
|
||||
|
|
|
@ -18,7 +18,7 @@ defcolor_comment_pop = {0xFF00C030, 0xFFF00000};
|
|||
defcolor_keyword = 0xFF002255;
|
||||
defcolor_str_constant = 0xFFE820E0;
|
||||
defcolor_char_constant = defcolor_str_constant;
|
||||
defcolor_int_constant = 0xFF20E8E0;
|
||||
defcolor_int_constant = 0xFF109810;
|
||||
defcolor_float_constant = defcolor_int_constant;
|
||||
defcolor_bool_constant = defcolor_int_constant;
|
||||
defcolor_include = 0xFFF010F0;
|
||||
|
|
Loading…
Reference in New Issue