diff --git a/4coder_API/4coder_types.h b/4coder_API/4coder_types.h index b50efd2e..e2f5be45 100644 --- a/4coder_API/4coder_types.h +++ b/4coder_API/4coder_types.h @@ -1133,39 +1133,12 @@ STRUCT Binding_Unit{ typedef i32 _Get_Version_Function(i32 maj, i32 min, i32 patch); #define _GET_VERSION_SIG(n) i32 n(i32 maj, i32 min, i32 patch) -STRUCT color_picker{ +STRUCT Color_Picker{ String_Const_u8 title; argb_color *dest; b32 *finished; }; -// TODO(allen): Remove these vvvvv ? -enum Found_String_Flag{ - FoundString_Sensitive = 0x1, - FoundString_Insensitive = 0x2, - FoundString_CleanEdges = 0x4, - - FoundString_Straddled = 0x10, -}; - -STRUCT Found_String{ - Found_String *next; - Buffer_ID buffer_id; - - u32 flags; - i32 string_id; - - Range location; -}; - -// TODO(casey): If this sticks around, there should be a way to export add/remove/merge as inlines that are shared -STRUCT Found_String_List{ - Found_String *first; - Found_String *last; - i32 count; -}; -// TODO(allen): Remove these ^^^^^ ? - ENUM(u32, String_Match_Flag){ StringMatch_CaseSensitive = 1, StringMatch_LeftSideSloppy = 2, @@ -1176,8 +1149,9 @@ ENUM(u32, String_Match_Flag){ STRUCT String_Match{ String_Match *next; Buffer_ID buffer; + i32 string_id; String_Match_Flag flags; - u64 index; + Range_u64 range; }; STRUCT String_Match_List{ diff --git a/4coder_api_transition_30_31_helpers.cpp b/4coder_api_transition_30_31_helpers.cpp index 74020d06..bf76edd5 100644 --- a/4coder_api_transition_30_31_helpers.cpp +++ b/4coder_api_transition_30_31_helpers.cpp @@ -678,7 +678,7 @@ execute_standard_build(Application_Links *app, View_Summary *view, Buffer_ID act static b32 post_buffer_range_to_clipboard(Application_Links *app, i32 clipboard_index, Buffer_Summary *buffer, i32 first, i32 one_past_last){ - return(post_buffer_range_to_clipboard(app, clipboard_index, buffer==0?0:buffer->buffer_id, first, one_past_last)); + return(post_buffer_range_to_clipboard(app, clipboard_index, buffer==0?0:buffer->buffer_id, first, one_past_last)); } static void @@ -995,7 +995,7 @@ scratch_read(Application_Links *app, Arena *arena, Buffer_ID buffer, Range range } static String_Const_u8 -scratch_read(Application_Links *app, Arena *arena, Buffer_ID buffer, Range_umem range){ +scratch_read(Application_Links *app, Arena *arena, Buffer_ID buffer, Range_u64 range){ return(push_buffer_range(app, arena, buffer, range)); } diff --git a/4coder_base_commands.cpp b/4coder_base_commands.cpp index 37274319..a238ef96 100644 --- a/4coder_base_commands.cpp +++ b/4coder_base_commands.cpp @@ -701,16 +701,11 @@ CUSTOM_DOC("Converts all ascii text in the range between the cursor and the mark Buffer_ID buffer = 0; view_get_buffer(app, view, AccessOpen, &buffer); Range range = get_view_range(app, view); - i32 size = get_width(range); - if (size <= app->memory_size){ - char *mem = (char*)app->memory; - buffer_read_range(app, buffer, range.min, range.max, mem); - for (i32 i = 0; i < size; ++i){ - mem[i] = character_to_upper(mem[i]); - } - buffer_replace_range(app, buffer, range, SCu8(mem, size)); - view_set_cursor(app, view, seek_pos(range.max), true); - } + Scratch_Block scratch(app); + String_Const_u8 string = push_buffer_range(app, scratch, buffer, range); + string = string_mod_upper(string); + buffer_replace_range(app, buffer, range, string); + view_set_cursor(app, view, seek_pos(range.max), true); } CUSTOM_COMMAND_SIG(to_lowercase) @@ -721,16 +716,11 @@ CUSTOM_DOC("Converts all ascii text in the range between the cursor and the mark Buffer_ID buffer = 0; view_get_buffer(app, view, AccessOpen, &buffer); Range range = get_view_range(app, view); - i32 size = get_width(range); - if (size <= app->memory_size){ - char *mem = (char*)app->memory; - buffer_read_range(app, buffer, range.min, range.max, mem); - for (i32 i = 0; i < size; ++i){ - mem[i] = character_to_lower(mem[i]); - } - buffer_replace_range(app, buffer, range, SCu8(mem, size)); - view_set_cursor(app, view, seek_pos(range.max), true); - } + Scratch_Block scratch(app); + String_Const_u8 string = push_buffer_range(app, scratch, buffer, range); + string = string_mod_lower(string); + buffer_replace_range(app, buffer, range, string); + view_set_cursor(app, view, seek_pos(range.max), true); } CUSTOM_COMMAND_SIG(clean_all_lines) diff --git a/4coder_base_types.cpp b/4coder_base_types.cpp index 4bacb9f7..52737721 100644 --- a/4coder_base_types.cpp +++ b/4coder_base_types.cpp @@ -1575,25 +1575,7 @@ hsla_to_rgba(Vec4 hsla){ //////////////////////////////// -static Interval_i8 -Ii8(i8 a, i8 b){ - Interval_i8 interval = {a, b}; - if (b < a){ - interval.min = b; - interval.max = a; - } - return(interval); -} -static Interval_i16 -Ii16(i16 a, i16 b){ - Interval_i16 interval = {a, b}; - if (b < a){ - interval.min = b; - interval.max = a; - } - return(interval); -} -static Interval_i32 +internal Interval_i32 Ii32(i32 a, i32 b){ Interval_i32 interval = {a, b}; if (b < a){ @@ -1602,7 +1584,25 @@ Ii32(i32 a, i32 b){ } return(interval); } -static Interval_f32 +internal Interval_i64 +Ii64(i64 a, i64 b){ + Interval_i64 interval = {a, b}; + if (b < a){ + interval.min = b; + interval.max = a; + } + return(interval); +} +internal Interval_u64 +Iu64(u64 a, u64 b){ + Interval_u64 interval = {a, b}; + if (b < a){ + interval.min = b; + interval.max = a; + } + return(interval); +} +internal Interval_f32 If32(f32 a, f32 b){ Interval_f32 interval = {a, b}; if (b < a){ @@ -1612,390 +1612,402 @@ If32(f32 a, f32 b){ return(interval); } -static Interval_i8 -range_margin(Interval_i8 range, i8 margin){ - range.min += margin; - range.max -= margin; - return(range); +internal Interval_i32 +Ii32(i32 a){ + Interval_i32 interval = {a, a}; + return(interval); } -static Interval_i16 -range_margin(Interval_i16 range, i16 margin){ - range.min += margin; - range.max -= margin; - return(range); +internal Interval_i64 +Ii64(i64 a){ + Interval_i64 interval = {a, a}; + return(interval); } -static Interval_i32 +internal Interval_u64 +Iu64(u64 a){ + Interval_u64 interval = {a, a}; + return(interval); +} +internal Interval_f32 +If32(f32 a){ + Interval_f32 interval = {a, a}; + return(interval); +} + +#define make_range Ii32 +#define make_range_i32 Ii32 +#define make_range_i64 Ii64 +#define make_range_u64 Iu64 +#define make_range_f32 If32 + +internal Interval_i32 range_margin(Interval_i32 range, i32 margin){ range.min += margin; - range.max -= margin; + range.max += margin; return(range); } -static Interval_f32 +internal Interval_i64 +range_margin(Interval_i64 range, i64 margin){ + range.min += margin; + range.max += margin; + return(range); +} +internal Interval_u64 +range_margin(Interval_u64 range, u64 margin){ + range.min += margin; + range.max += margin; + return(range); +} +internal Interval_f32 range_margin(Interval_f32 range, f32 margin){ range.min += margin; - range.max -= margin; + range.max += margin; return(range); } -static i8 -range_size(Interval_i8 range){ - return(range.max - range.min); +internal b32 +range_overlap(Interval_i32 a, Interval_i32 b){ + return(a.min < b.max && b.min < a.max); } -static i16 -range_size(Interval_i16 range){ - return(range.max - range.min); +internal b32 +range_overlap(Interval_i64 a, Interval_i64 b){ + return(a.min < b.max && b.min < a.max); } -static i32 -range_size(Interval_i32 range){ - return(range.max - range.min); +internal b32 +range_overlap(Interval_u64 a, Interval_u64 b){ + return(a.min < b.max && b.min < a.max); } -static f32 -range_size(Interval_f32 range){ - return(range.max - range.min); +internal b32 +range_overlap(Interval_f32 a, Interval_f32 b){ + return(a.min < b.max && b.min < a.max); } -static i32 -get_width(Range range){ - i32 result = range.end - range.start; - if (result < 0){ - result = 0; - } - return(result); +internal b32 +range_contains(Interval_i32 a, i32 p){ + return(a.min <= p && p < a.max); +} +internal b32 +range_contains(Interval_i64 a, i64 p){ + return(a.min <= p && p < a.max); +} +internal b32 +range_contains(Interval_u64 a, u64 p){ + return(a.min <= p && p < a.max); +} +internal b32 +range_contains(Interval_f32 a, f32 p){ + return(a.min <= p && p < a.max); } -static Range_i8 -make_range_i8(i8 p1, i8 p2){ - Range_i8 range; - if (p1 < p2){ - range.min = p1; - range.max = p2; - } - else{ - range.min = p2; - range.max = p1; - } - return(range); +internal i32 +range_size(Interval_i32 a){ + i32 size = a.max - a.min; + size = clamp_bot(0, size); + return(size); } -static Range_i16 -make_range_i16(i16 p1, i16 p2){ - Range_i16 range; - if (p1 < p2){ - range.min = p1; - range.max = p2; - } - else{ - range.min = p2; - range.max = p1; - } - return(range); +internal i64 +range_size(Interval_i64 a){ + i64 size = a.max - a.min; + size = clamp_bot(0, size); + return(size); } -static Range_i32 -make_range_i32(i32 p1, i32 p2){ - Range_i32 range; - if (p1 < p2){ - range.min = p1; - range.max = p2; - } - else{ - range.min = p2; - range.max = p1; - } - return(range); +internal u64 +range_size(Interval_u64 a){ + u64 size = a.max - a.min; + size = clamp_bot(0, size); + return(size); } -static Range_f32 -make_range_f32(f32 p1, f32 p2){ - Range_f32 range; - if (p1 < p2){ - range.min = p1; - range.max = p2; - } - else{ - range.min = p2; - range.max = p1; - } - return(range); -} -static Range_umem -make_range_umem(umem p1, umem p2){ - Range_umem range; - if (p1 < p2){ - range.min = p1; - range.max = p2; - } - else{ - range.min = p2; - range.max = p1; - } - return(range); +internal f32 +range_size(Interval_f32 a){ + f32 size = a.max - a.min; + size = clamp_bot(0, size); + return(size); } -static Range_i8 -make_range_i8(i8 p){ - Range_i8 range = {p, p}; - return(range); +internal Interval_i32 +rectify(Interval_i32 a){ + return(Ii32(a.min, a.max)); } -static Range_i16 -make_range_i16(i16 p){ - Range_i16 range = {p, p}; - return(range); +internal Interval_i64 +rectify(Interval_i64 a){ + return(Ii64(a.min, a.max)); } -static Range_i32 -make_range_i32(i32 p){ - Range_i32 range = {p, p}; - return(range); +internal Interval_u64 +rectify(Interval_u64 a){ + return(Iu64(a.min, a.max)); } -static Range_f32 -make_range_f32(f32 p){ - Range_f32 range = {p, p}; - return(range); -} -static Range_umem -make_range_umem(umem p){ - Range_umem range = {p, p}; - return(range); +internal Interval_f32 +rectify(Interval_f32 a){ + return(If32(a.min, a.max)); } -#define make_range make_range_i32 - -static Range -rectify(Range range) { - return(make_range(range.min, range.max)); +internal Interval_i32 +range_clamp_size(Interval_i32 a, i32 max_size){ + i32 max = a.min + max_size; + a.max = clamp_top(a.max, max); + return(a); +} +internal Interval_i64 +range_clamp_size(Interval_i64 a, i64 max_size){ + i64 max = a.min + max_size; + a.max = clamp_top(a.max, max); + return(a); +} +internal Interval_u64 +range_clamp_size(Interval_u64 a, u64 max_size){ + u64 max = a.min + max_size; + a.max = clamp_top(a.max, max); + return(a); +} +internal Interval_f32 +range_clamp_size(Interval_f32 a, f32 max_size){ + f32 max = a.min + max_size; + a.max = clamp_top(a.max, max); + return(a); } -static b32 -interval_overlap(i32 a0, i32 a1, i32 b0, i32 b1){ - return(a0 < b1 && b0 < a1); +internal b32 +range_is_valid(Interval_i32 a){ + return(a.min <= a.max); } - -static b32 -interval_overlap(Range a, Range b){ - return(interval_overlap(a.first, a.one_past_last, b.first, b.one_past_last)); +internal b32 +range_is_valid(Interval_i64 a){ + return(a.min <= a.max); } - -static i32 -interval_overlap(f32 a0, f32 a1, f32 b0, f32 b1){ - return(a0 < b1 && b0 < a1); +internal b32 +range_is_valid(Interval_u64 a){ + return(a.min <= a.max); } - -static b32 -interval_contains(i32 a0, i32 a1, i32 b){ - return((a0 <= b) && (b < a1)); -} - -static b32 -interval_contains(Range range, i32 b){ - return(interval_contains(range.start, range.one_past_last, b)); -} - -static Range -clip_range_to_width(Range range, i32 max_width) { - i32 top = range.first + max_width; - range.end = clamp_top(range.end, top); - return(range); -} - -static b32 -interval_is_valid(Range range){ - return(range.start <= range.one_past_last); -} - -static i32 -replace_range_compute_shift(i32 replace_length, i32 insert_length){ - return(insert_length - replace_length); -} - -static i32 -replace_range_compute_shift(i32 replace_start, i32 replace_end, i32 insert_length){ - return(insert_length - (replace_end - replace_start)); -} - -static i32 -replace_range_compute_shift(Range range, i32 insert_length){ - return(replace_range_compute_shift(range.first, range.one_past_last, insert_length)); +internal b32 +range_is_valid(Interval_f32 a){ + return(a.min <= a.max); } //////////////////////////////// -static i32_Rect -i32R(i32 l, i32 t, i32 r, i32 b){ - i32_Rect rect = {}; - rect.x0 = l; - rect.y0 = t; - rect.x1 = r; - rect.y1 = b; +internal i32 +replace_range_compute_shift(i32 replace_length, i32 insert_length){ + return(insert_length - replace_length); +} +internal i32 +replace_range_compute_shift(i32 start, i32 end, i32 insert_length){ + return(insert_length - (end - start)); +} +internal i32 +replace_range_compute_shift(Interval_i32 range, i32 insert_length){ + return(insert_length - (range.end - range.start)); +} +internal i64 +replace_range_compute_shift(i64 replace_length, i64 insert_length){ + return(insert_length - replace_length); +} +internal i64 +replace_range_compute_shift(i64 start, i64 end, i64 insert_length){ + return(insert_length - (end - start)); +} +internal i64 +replace_range_compute_shift(Interval_i64 range, i64 insert_length){ + return(insert_length - (range.end - range.start)); +} + +//////////////////////////////// + +internal Rect_i32 +Ri32(i32 x0, i32 y0, i32 x1, i32 y1){ + Rect_i32 rect = {x0, y0, x1, y1}; + return(rect); +} +internal Rect_f32 +Rf32(f32 x0, f32 y0, f32 x1, f32 y1){ + Rect_f32 rect = {x0, y0, x1, y1}; return(rect); } -static i32_Rect -i32R_xy_wh(i32 x, i32 y, i32 w, i32 h){ - return(i32R(x, y, x + w, y + h)); +internal Rect_i32 +Ri32(Vec2_i32 p0, Vec2_i32 p1){ + Rect_i32 rect = {p0.x, p0.y, p1.x, p1.y}; + return(rect); } - -static i32_Rect -i32R(f32_Rect r){ - i32_Rect rect = {}; - rect.x0 = (i32)r.x0; - rect.y0 = (i32)r.y0; - rect.x1 = (i32)r.x1; - rect.y1 = (i32)r.y1; +internal Rect_f32 +Rf32(Vec2_f32 p0, Vec2_f32 p1){ + Rect_f32 rect = {p0.x, p0.y, p1.x, p1.y}; return(rect); } -static f32_Rect -f32R(f32 l, f32 t, f32 r, f32 b){ - f32_Rect rect = {}; - rect.x0 = l; - rect.y0 = t; - rect.x1 = r; - rect.y1 = b; +internal Rect_i32 +Ri32(Rect_f32 o){ + Rect_i32 rect = {(i32)(o.x0), (i32)(o.y0), (i32)(o.x0), (i32)(o.y1)}; + return(rect); +} +internal Rect_f32 +Rf32(Rect_i32 o){ + Rect_f32 rect = {(f32)(o.x0), (f32)(o.y0), (f32)(o.x0), (f32)(o.y1)}; return(rect); } -static f32_Rect -f32R(Vec2 p0, Vec2 p1){ - f32_Rect rect = {}; - rect.p0 = p0; - rect.p1 = p1; +#define i32R Ri32 +#define f32R Rf32 + +internal Rect_i32 +Ri32_xy_wh(i32 x0, i32 y0, i32 w, i32 h){ + Rect_i32 rect = {x0, y0, x0 + w, y0 + h}; + return(rect); +} +internal Rect_f32 +Rf32_xy_wh(f32 x0, f32 y0, f32 w, f32 h){ + Rect_f32 rect = {x0, y0, x0 + w, y0 + h}; return(rect); } -static f32_Rect -f32R(i32_Rect r){ - f32_Rect rect = {}; - rect.x0 = (f32)r.x0; - rect.y0 = (f32)r.y0; - rect.x1 = (f32)r.x1; - rect.y1 = (f32)r.y1; +internal Rect_i32 +Ri32_xy_wh(Vec2_i32 p0, Vec2_i32 d){ + Rect_i32 rect = {p0.x, p0.y, p0.x + d.x, p0.y + d.y}; + return(rect); +} +internal Rect_f32 +Rf32_xy_wh(Vec2_f32 p0, Vec2_f32 d){ + Rect_f32 rect = {p0.x, p0.y, p0.x + d.x, p0.y + d.y}; return(rect); } -static i32 -rect_equal(i32_Rect r1, i32_Rect r2){ - return(r1.x0 == r2.x0 && r1.y0 == r2.y0 && r1.x1 == r2.x1 && r1.y1 == r2.y1); +#define i32R_xy_wh +#define f32R_xy_wh + +internal b32 +rect_equals(Rect_i32 a, Rect_i32 b){ + return(a.x0 == b.x0 && a.y0 == b.y0 && a.x1 == b.x1 && a.y1 == b.y1); +} +internal b32 +rect_equals(Rect_f32 a, Rect_f32 b){ + return(a.x0 == b.x0 && a.y0 == b.y0 && a.x1 == b.x1 && a.y1 == b.y1); } -static b32 -rect_contains_point(b32 BLAH, f32 x0, f32 y0, f32 x1, f32 y1, f32 x, f32 y){ - return(x0 <= x && x < x1 && y0 <= y && y < y1); +internal b32 +rect_contains_point(Rect_i32 a, Vec2_i32 b){ + return(a.x0 <= b.x && b.x < a.x1 && a.y0 <= b.y && b.y < a.y1); +} +internal b32 +rect_contains_point(Rect_f32 a, Vec2_f32 b){ + return(a.x0 <= b.x && b.x < a.x1 && a.y0 <= b.y && b.y < a.y1); } -static b32 -rect_contains_point(b32 BLAH, i32 x0, i32 y0, i32 x1, i32 y1, i32 x, i32 y){ - return(x0 <= x && x < x1 && y0 <= y && y < y1); +internal Rect_i32 +rect_inner(Rect_i32 r, i32 m){ + r.x0 += m; + r.y0 += m; + r.x1 -= m; + r.y1 -= m; + return(r); } - -static b32 -rect_contains_point(Rect_f32 rect, Vec2_f32 p){ - return(rect_contains_point(false, rect.x0, rect.y0, rect.x1, rect.y1, p.x, p.y)); -} - -static b32 -rect_contains_point(Rect_i32 rect, Vec2_i32 p){ - return(rect_contains_point(false, rect.x0, rect.y0, rect.x1, rect.y1, p.x, p.y)); -} - -static i32_Rect -get_inner_rect(i32_Rect outer, i32 margin){ - i32_Rect r = {}; - r.x0 = outer.x0 + margin; - r.y0 = outer.y0 + margin; - r.x1 = outer.x1 - margin; - r.y1 = outer.y1 - margin; +internal Rect_f32 +rect_inner(Rect_f32 r, f32 m){ + r.x0 += m; + r.y0 += m; + r.x1 -= m; + r.y1 -= m; return(r); } -static f32_Rect -get_inner_rect(f32_Rect outer, f32 margin){ - f32_Rect r = {}; - r.x0 = outer.x0 + margin; - r.y0 = outer.y0 + margin; - r.x1 = outer.x1 - margin; - r.y1 = outer.y1 - margin; - return(r); +internal Vec2_i32 +rect_dim(Rect_i32 r){ + Vec2_i32 v = {r.x1 - r.x0, r.y1 - r.y0}; + return(v); +} +internal i32 +rect_width(Rect_i32 r){ + return(r.x1 - r.x0); +} +internal i32 +rect_height(Rect_i32 r){ + return(r.y1 - r.y0); +} +internal Vec2_f32 +rect_dim(Rect_f32 r){ + Vec2_f32 v = {r.x1 - r.x0, r.y1 - r.y0}; + return(v); +} +internal f32 +rect_width(Rect_f32 r){ + return(r.x1 - r.x0); +} +internal f32 +rect_height(Rect_f32 r){ + return(r.y1 - r.y0); } -static i32 -rect_height(i32_Rect rect){ - return(rect.y1 - rect.y0); +internal Interval_i32 +rect_range_x(Rect_i32 r){ + return(Ii32(r.x0, r.x1)); +} +internal Interval_i32 +rect_range_y(Rect_i32 r){ + return(Ii32(r.y0, r.y1)); +} +internal Interval_f32 +rect_range_x(Rect_f32 r){ + return(If32(r.x0, r.x1)); +} +internal Interval_f32 +rect_range_y(Rect_f32 r){ + return(If32(r.y0, r.y1)); } -static i32 -rect_width(i32_Rect rect){ - return(rect.x1 - rect.x0); +internal b32 +rect_overlap(Rect_i32 a, Rect_i32 b){ + return(range_overlap(rect_range_x(a), rect_range_x(b)) && + range_overlap(rect_range_y(a), rect_range_y(b))); +} +internal b32 +rect_overlap(Rect_f32 a, Rect_f32 b){ + return(range_overlap(rect_range_x(a), rect_range_x(b)) && + range_overlap(rect_range_y(a), rect_range_y(b))); } -static i32 -fits_inside(i32_Rect rect, i32_Rect outer){ - return(rect.x0 >= outer.x0 && rect.x1 <= outer.x1 && rect.y0 >= outer.y0 && rect.y1 <= outer.y1); +internal Vec2_i32 +rect_center(Rect_i32 r){ + return(rect_dim(r)/2); } - -static i32 -rect_overlap(f32_Rect a, f32_Rect b){ - return(interval_overlap(a.x0, a.x1, b.x0, b.x1) && - interval_overlap(a.y0, a.y1, b.y0, b.y1)); -} - -static f32 -rect_height(f32_Rect rect){ - return(rect.y1 - rect.y0); -} - -static f32 -rect_width(f32_Rect rect){ - return(rect.x1 - rect.x0); -} - -static Vec2 -rect_dim(f32_Rect rect){ - return(V2(rect.x1 - rect.x0, rect.y1 - rect.y0)); -} - -static Vec2 -rect_center(f32_Rect rect){ - return(V2(0.5f*(rect.x0 + rect.x1), 0.5f*(rect.y0 + rect.y1))); +internal Vec2_f32 +rect_center(Rect_f32 r){ + return(rect_dim(r)/2); } #define center_of rect_center -static i32_Rect -intersection_of(i32_Rect a, i32_Rect b){ - i32_Rect result; - result.x0 = Max(a.x0, b.x0); - result.y0 = Max(a.y0, b.y0); - result.x1 = Min(a.x1, b.x1); - result.y1 = Min(a.y1, b.y1); - return(result); +internal Rect_i32 +rect_intersect(Rect_i32 a, Rect_i32 b){ + a.x0 = Max(a.x0, b.x0); + a.y0 = Max(a.y0, b.y0); + a.x1 = Min(a.x1, b.x1); + a.y1 = Min(a.y1, b.y1); + return(a); +} +internal Rect_i32 +rect_union(Rect_i32 a, Rect_i32 b){ + a.x0 = Min(a.x0, b.x0); + a.y0 = Min(a.y0, b.y0); + a.x1 = Max(a.x1, b.x1); + a.y1 = Max(a.y1, b.y1); + return(a); +} +internal Rect_f32 +rect_intersect(Rect_f32 a, Rect_f32 b){ + a.x0 = Max(a.x0, b.x0); + a.y0 = Max(a.y0, b.y0); + a.x1 = Min(a.x1, b.x1); + a.y1 = Min(a.y1, b.y1); + return(a); +} +internal Rect_f32 +rect_union(Rect_f32 a, Rect_f32 b){ + a.x0 = Min(a.x0, b.x0); + a.y0 = Min(a.y0, b.y0); + a.x1 = Max(a.x1, b.x1); + a.y1 = Max(a.y1, b.y1); + return(a); } -static i32_Rect -union_of(i32_Rect a, i32_Rect b){ - i32_Rect result; - result.x0 = Max(a.x0, b.x0); - result.y0 = Max(a.y0, b.y0); - result.x1 = Min(a.x1, b.x1); - result.y1 = Min(a.y1, b.y1); - return(result); -} - -static f32_Rect -intersection_of(f32_Rect a, f32_Rect b){ - f32_Rect result; - result.x0 = Max(a.x0, b.x0); - result.y0 = Max(a.y0, b.y0); - result.x1 = Min(a.x1, b.x1); - result.y1 = Min(a.y1, b.y1); - return(result); -} - -static f32_Rect -union_of(f32_Rect a, f32_Rect b){ - f32_Rect result; - result.x0 = Max(a.x0, b.x0); - result.y0 = Max(a.y0, b.y0); - result.x1 = Min(a.x1, b.x1); - result.y1 = Min(a.y1, b.y1); - return(result); -} +#define intersection_of rect_intersect +#define union_of rect_union //////////////////////////////// @@ -3299,7 +3311,7 @@ static umem string_find_first_slash(String_Const_u16 str){ umem i = 0; for (;i < str.size && !character_is_slash(str.str[i]); i += 1); - return(i); + return(i); } static umem string_find_first_slash(String_Const_u32 str){ diff --git a/4coder_base_types.h b/4coder_base_types.h index 7971c1eb..3d924b7f 100644 --- a/4coder_base_types.h +++ b/4coder_base_types.h @@ -628,34 +628,6 @@ union Vec4_f32{ f32 v[4]; }; -union Range_i8{ - struct{ - i8 min; - i8 max; - }; - struct{ - i8 start; - i8 end; - }; - struct{ - i8 first; - i8 one_past_last; - }; -}; -union Range_i16{ - struct{ - i16 min; - i16 max; - }; - struct{ - i16 start; - i16 end; - }; - struct{ - i16 first; - i16 one_past_last; - }; -}; union Range_i32{ struct{ i32 min; @@ -670,6 +642,34 @@ union Range_i32{ i32 one_past_last; }; }; +union Range_i64{ + struct{ + i64 min; + i64 max; + }; + struct{ + i64 start; + i64 end; + }; + struct{ + i64 first; + i64 one_past_last; + }; +}; +union Range_u64{ + struct{ + u64 min; + u64 max; + }; + struct{ + u64 start; + u64 end; + }; + struct{ + u64 first; + u64 one_past_last; + }; +}; union Range_f32{ struct{ f32 min; @@ -684,54 +684,13 @@ union Range_f32{ f32 one_past_last; }; }; -union Range_umem{ - struct{ - umem min; - umem max; - }; - struct{ - umem start; - umem end; - }; - struct{ - umem first; - umem one_past_last; - }; -}; -typedef Range_i8 Interval_i8; -typedef Range_i16 Interval_i16; -typedef Range_i32 Interval_i32; -typedef Range_f32 Interval_f32; -typedef Range_umem Interval_umem; +typedef Range_i32 Interval_i32; +typedef Range_i64 Interval_i64; +typedef Range_u64 Interval_u64; +typedef Range_f32 Interval_f32; typedef Range_i32 Range; -union Rect_i8{ - struct{ - i8 x0; - i8 y0; - i8 x1; - i8 y1; - }; - struct{ - Vec2_i8 p0; - Vec2_i8 p1; - }; - Vec2_i8 p[2]; -}; -union Rect_i16{ - struct{ - i16 x0; - i16 y0; - i16 x1; - i16 y1; - }; - struct{ - Vec2_i16 p0; - Vec2_i16 p1; - }; - Vec2_i16 p[2]; -}; union Rect_i32{ struct{ i32 x0; diff --git a/4coder_default_hooks.cpp b/4coder_default_hooks.cpp index 90c71fce..9295879a 100644 --- a/4coder_default_hooks.cpp +++ b/4coder_default_hooks.cpp @@ -849,21 +849,21 @@ default_ui_render_caller(Application_Links *app, View_ID view_id, Rect_f32 rect_ } if (rect_overlap(item_rect, rect_f32)){ - Rect_f32 inner_rect = get_inner_rect(item_rect, (f32)item->inner_margin); + Rect_f32 inner = rect_inner(item_rect, (f32)item->inner_margin); Face_Metrics metrics = {}; get_face_metrics(app, face_id, &metrics); f32 line_height = metrics.line_height; f32 info_height = (f32)item->line_count*line_height; - draw_rectangle(app, inner_rect, Stag_Back); - Vec2 p = V2(inner_rect.x0 + 3.f, (f32)(round32((inner_rect.y0 + inner_rect.y1 - info_height)*0.5f))); + draw_rectangle(app, inner, Stag_Back); + Vec2 p = V2(inner.x0 + 3.f, (f32)(round32((inner.y0 + inner.y1 - info_height)*0.5f))); for (i32 i = 0; i < item->line_count; i += 1){ draw_fancy_string(app, face_id, item->lines[i].first, p, Stag_Default, 0, 0, V2(1.f, 0)); p.y += line_height; } if (item->inner_margin > 0){ - draw_margin(app, item_rect, inner_rect, get_margin_color(item->activation_level)); + draw_margin(app, item_rect, inner, get_margin_color(item->activation_level)); } } } @@ -902,7 +902,7 @@ static void default_render_view(Application_Links *app, Frame_Info frame_info, View_ID view_id, b32 is_active){ Rect_i32 view_rect = {}; view_get_region(app, view_id, &view_rect); - Rect_i32 inner = get_inner_rect(view_rect, 3); + Rect_i32 inner = rect_inner(view_rect, 3); draw_rectangle(app, f32R(view_rect), get_margin_color(is_active?UIActivation_Active:UIActivation_None)); draw_rectangle(app, f32R(inner), Stag_Back); draw_clip_push(app, f32R(inner)); diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index dec28964..6962210b 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -37,6 +37,7 @@ #include "4coder_api_transition_30_31.h" +#include "4coder_string_match.cpp" #include "4coder_helper.h" #include "4coder_insertion.h" #include "4coder_fancy.h" diff --git a/4coder_generated/app_functions.h b/4coder_generated/app_functions.h index 81d30268..3fd2ee31 100644 --- a/4coder_generated/app_functions.h +++ b/4coder_generated/app_functions.h @@ -180,9 +180,9 @@ struct Application_Links; #define TEXT_LAYOUT_FREE_SIG(n) b32 n(Application_Links *app, Text_Layout_ID text_layout_id) #define COMPUTE_RENDER_LAYOUT_SIG(n) b32 n(Application_Links *app, View_ID view_id, Buffer_ID buffer_id, Vec2 screen_p, Vec2 layout_dim, Buffer_Point buffer_point, i32 one_past_last, Text_Layout_ID *text_layout_id_out) #define DRAW_RENDER_LAYOUT_SIG(n) void n(Application_Links *app, View_ID view_id) -#define OPEN_COLOR_PICKER_SIG(n) void n(Application_Links *app, color_picker *picker) +#define OPEN_COLOR_PICKER_SIG(n) void n(Application_Links *app, Color_Picker *picker) #define ANIMATE_IN_N_MILLISECONDS_SIG(n) void n(Application_Links *app, u32 n) -#define FIND_ALL_MATCHES_BUFFER_RANGE_SIG(n) String_Match_List n(Application_Links *app, Arena *arena, Buffer_ID buffer, Range range, String_Const_u8 needle, Character_Predicate *predicate, Scan_Direction direction) +#define FIND_ALL_MATCHES_BUFFER_RANGE_SIG(n) String_Match_List n(Application_Links *app, Arena *arena, Buffer_ID buffer, i32 string_id, Range range, String_Const_u8 needle, Character_Predicate *predicate, Scan_Direction direction) #define GET_VIEW_VISIBLE_RANGE_SIG(n) Range n(Application_Links *app, View_ID view_id) typedef GLOBAL_SET_SETTING_SIG(Global_Set_Setting_Function); typedef GLOBAL_SET_MAPPING_SIG(Global_Set_Mapping_Function); @@ -1118,9 +1118,9 @@ static b32 text_layout_get_height(Application_Links *app, Text_Layout_ID text_la static b32 text_layout_free(Application_Links *app, Text_Layout_ID text_layout_id){return(app->text_layout_free(app, text_layout_id));} static b32 compute_render_layout(Application_Links *app, View_ID view_id, Buffer_ID buffer_id, Vec2 screen_p, Vec2 layout_dim, Buffer_Point buffer_point, i32 one_past_last, Text_Layout_ID *text_layout_id_out){return(app->compute_render_layout(app, view_id, buffer_id, screen_p, layout_dim, buffer_point, one_past_last, text_layout_id_out));} static void draw_render_layout(Application_Links *app, View_ID view_id){(app->draw_render_layout(app, view_id));} -static void open_color_picker(Application_Links *app, color_picker *picker){(app->open_color_picker(app, picker));} +static void open_color_picker(Application_Links *app, Color_Picker *picker){(app->open_color_picker(app, picker));} static void animate_in_n_milliseconds(Application_Links *app, u32 n){(app->animate_in_n_milliseconds(app, n));} -static String_Match_List find_all_matches_buffer_range(Application_Links *app, Arena *arena, Buffer_ID buffer, Range range, String_Const_u8 needle, Character_Predicate *predicate, Scan_Direction direction){return(app->find_all_matches_buffer_range(app, arena, buffer, range, needle, predicate, direction));} +static String_Match_List find_all_matches_buffer_range(Application_Links *app, Arena *arena, Buffer_ID buffer, i32 string_id, Range range, String_Const_u8 needle, Character_Predicate *predicate, Scan_Direction direction){return(app->find_all_matches_buffer_range(app, arena, buffer, string_id, range, needle, predicate, direction));} static Range get_view_visible_range(Application_Links *app, View_ID view_id){return(app->get_view_visible_range(app, view_id));} #else static b32 global_set_setting(Application_Links *app, Global_Setting_ID setting, i32 value){return(app->global_set_setting_(app, setting, value));} @@ -1304,8 +1304,8 @@ static b32 text_layout_get_height(Application_Links *app, Text_Layout_ID text_la static b32 text_layout_free(Application_Links *app, Text_Layout_ID text_layout_id){return(app->text_layout_free_(app, text_layout_id));} static b32 compute_render_layout(Application_Links *app, View_ID view_id, Buffer_ID buffer_id, Vec2 screen_p, Vec2 layout_dim, Buffer_Point buffer_point, i32 one_past_last, Text_Layout_ID *text_layout_id_out){return(app->compute_render_layout_(app, view_id, buffer_id, screen_p, layout_dim, buffer_point, one_past_last, text_layout_id_out));} static void draw_render_layout(Application_Links *app, View_ID view_id){(app->draw_render_layout_(app, view_id));} -static void open_color_picker(Application_Links *app, color_picker *picker){(app->open_color_picker_(app, picker));} +static void open_color_picker(Application_Links *app, Color_Picker *picker){(app->open_color_picker_(app, picker));} static void animate_in_n_milliseconds(Application_Links *app, u32 n){(app->animate_in_n_milliseconds_(app, n));} -static String_Match_List find_all_matches_buffer_range(Application_Links *app, Arena *arena, Buffer_ID buffer, Range range, String_Const_u8 needle, Character_Predicate *predicate, Scan_Direction direction){return(app->find_all_matches_buffer_range_(app, arena, buffer, range, needle, predicate, direction));} +static String_Match_List find_all_matches_buffer_range(Application_Links *app, Arena *arena, Buffer_ID buffer, i32 string_id, Range range, String_Const_u8 needle, Character_Predicate *predicate, Scan_Direction direction){return(app->find_all_matches_buffer_range_(app, arena, buffer, string_id, range, needle, predicate, direction));} static Range get_view_visible_range(Application_Links *app, View_ID view_id){return(app->get_view_visible_range_(app, view_id));} #endif diff --git a/4coder_generated/command_metadata.h b/4coder_generated/command_metadata.h index b2dc57a0..258db328 100644 --- a/4coder_generated/command_metadata.h +++ b/4coder_generated/command_metadata.h @@ -323,58 +323,58 @@ static Command_Metadata fcoder_metacmd_table[236] = { { PROC_LINKS(move_left_alpha_numeric_or_camel_boundary, 0), "move_left_alpha_numeric_or_camel_boundary", 41, "Seek left for boundary between alphanumeric characters or camel case word and non-alphanumeric characters.", 106, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 659 }, { PROC_LINKS(select_all, 0), "select_all", 10, "Puts the cursor at the top of the file, and the mark at the bottom of the file.", 79, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 680 }, { PROC_LINKS(to_uppercase, 0), "to_uppercase", 12, "Converts all ascii text in the range between the cursor and the mark to uppercase.", 82, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 696 }, -{ PROC_LINKS(to_lowercase, 0), "to_lowercase", 12, "Converts all ascii text in the range between the cursor and the mark to lowercase.", 82, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 716 }, -{ PROC_LINKS(clean_all_lines, 0), "clean_all_lines", 15, "Removes trailing whitespace from all lines in the current buffer.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 736 }, -{ 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, 777 }, -{ PROC_LINKS(close_panel, 0), "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 786 }, -{ PROC_LINKS(show_scrollbar, 0), "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 796 }, -{ PROC_LINKS(hide_scrollbar, 0), "hide_scrollbar", 14, "Sets the current view to hide it's scrollbar.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 804 }, -{ PROC_LINKS(show_filebar, 0), "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 812 }, -{ PROC_LINKS(hide_filebar, 0), "hide_filebar", 12, "Sets the current view to hide it's filebar.", 43, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 820 }, -{ PROC_LINKS(toggle_filebar, 0), "toggle_filebar", 14, "Toggles the visibility status of the current view's filebar.", 60, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 828 }, -{ PROC_LINKS(toggle_line_wrap, 0), "toggle_line_wrap", 16, "Toggles the current buffer's line wrapping status.", 50, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 838 }, -{ PROC_LINKS(toggle_fps_meter, 0), "toggle_fps_meter", 16, "Toggles the visibility of the FPS performance meter", 51, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 850 }, -{ PROC_LINKS(increase_line_wrap, 0), "increase_line_wrap", 18, "Increases the current buffer's width for line wrapping.", 55, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 856 }, -{ PROC_LINKS(decrease_line_wrap, 0), "decrease_line_wrap", 18, "Decrases the current buffer's width for line wrapping.", 54, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 868 }, -{ PROC_LINKS(increase_face_size, 0), "increase_face_size", 18, "Increase the size of the face used by the current buffer.", 57, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 880 }, -{ PROC_LINKS(decrease_face_size, 0), "decrease_face_size", 18, "Decrease the size of the face used by the current buffer.", 57, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 894 }, -{ PROC_LINKS(mouse_wheel_change_face_size, 0), "mouse_wheel_change_face_size", 28, "Reads the state of the mouse wheel and uses it to either increase or decrease the face size.", 92, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 908 }, -{ PROC_LINKS(toggle_virtual_whitespace, 0), "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 925 }, -{ PROC_LINKS(toggle_show_whitespace, 0), "toggle_show_whitespace", 22, "Toggles the current buffer's whitespace visibility status.", 58, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 937 }, -{ PROC_LINKS(toggle_line_numbers, 0), "toggle_line_numbers", 19, "Toggles the left margin line numbers.", 37, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 947 }, -{ PROC_LINKS(eol_dosify, 0), "eol_dosify", 10, "Puts the buffer in DOS line ending mode.", 40, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 953 }, -{ PROC_LINKS(eol_nixify, 0), "eol_nixify", 10, "Puts the buffer in NIX line ending mode.", 40, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 963 }, -{ PROC_LINKS(exit_4coder, 0), "exit_4coder", 11, "Attempts to close 4coder.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 973 }, -{ PROC_LINKS(goto_line, 0), "goto_line", 9, "Queries the user for a number, and jumps the cursor to the corresponding line.", 78, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 981 }, -{ PROC_LINKS(search, 0), "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1209 }, -{ PROC_LINKS(reverse_search, 0), "reverse_search", 14, "Begins an incremental search up through the current buffer for a user specified string.", 87, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1215 }, -{ PROC_LINKS(search_identifier, 0), "search_identifier", 17, "Begins an incremental search down through the current buffer for the word or token under the cursor.", 100, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1221 }, -{ PROC_LINKS(reverse_search_identifier, 0), "reverse_search_identifier", 25, "Begins an incremental search up through the current buffer for the word or token under the cursor.", 98, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1236 }, -{ PROC_LINKS(replace_in_range, 0), "replace_in_range", 16, "Queries the user for two strings, and replaces all occurences of the first string in the range between the cursor and the mark with the second string.", 150, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1251 }, -{ PROC_LINKS(query_replace, 0), "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1360 }, -{ PROC_LINKS(query_replace_identifier, 0), "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1383 }, -{ PROC_LINKS(query_replace_selection, 0), "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1402 }, -{ PROC_LINKS(save_all_dirty_buffers, 0), "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1446 }, -{ PROC_LINKS(delete_file_query, 0), "delete_file_query", 17, "Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.", 125, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1471 }, -{ PROC_LINKS(save_to_query, 0), "save_to_query", 13, "Queries the user for a file name and saves the contents of the current buffer, altering the buffer's name too.", 110, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1511 }, -{ PROC_LINKS(rename_file_query, 0), "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1549 }, -{ PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1592 }, -{ PROC_LINKS(move_line_up, 0), "move_line_up", 12, "Swaps the line under the cursor with the line above it, and moves the cursor up with it.", 88, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1628 }, -{ PROC_LINKS(move_line_down, 0), "move_line_down", 14, "Swaps the line under the cursor with the line below it, and moves the cursor down with it.", 90, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1634 }, -{ PROC_LINKS(duplicate_line, 0), "duplicate_line", 14, "Create a copy of the line on which the cursor sits.", 51, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1640 }, -{ PROC_LINKS(delete_line, 0), "delete_line", 11, "Delete the line the on which the cursor sits.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1657 }, -{ PROC_LINKS(open_file_in_quotes, 0), "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1726 }, -{ PROC_LINKS(open_matching_file_cpp, 0), "open_matching_file_cpp", 22, "If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.", 110, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1764 }, -{ 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, 1779 }, -{ PROC_LINKS(swap_buffers_between_panels, 0), "swap_buffers_between_panels", 27, "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, 1794 }, -{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1839 }, -{ PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1849 }, -{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1863 }, -{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history of the current buffer.", 66, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1927 }, -{ PROC_LINKS(redo, 0), "redo", 4, "Advances forwards through the undo history of the current buffer.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1943 }, -{ PROC_LINKS(undo_all_buffers, 0), "undo_all_buffers", 16, "Advances backward through the undo history in the buffer containing the most recent regular edit.", 97, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1961 }, -{ PROC_LINKS(redo_all_buffers, 0), "redo_all_buffers", 16, "Advances forward through the undo history in the buffer containing the most recent regular edit.", 96, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 2040 }, -{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 2150 }, +{ PROC_LINKS(to_lowercase, 0), "to_lowercase", 12, "Converts all ascii text in the range between the cursor and the mark to lowercase.", 82, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 711 }, +{ PROC_LINKS(clean_all_lines, 0), "clean_all_lines", 15, "Removes trailing whitespace from all lines in the current buffer.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 726 }, +{ 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, 767 }, +{ PROC_LINKS(close_panel, 0), "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 776 }, +{ PROC_LINKS(show_scrollbar, 0), "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 786 }, +{ PROC_LINKS(hide_scrollbar, 0), "hide_scrollbar", 14, "Sets the current view to hide it's scrollbar.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 794 }, +{ PROC_LINKS(show_filebar, 0), "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 802 }, +{ PROC_LINKS(hide_filebar, 0), "hide_filebar", 12, "Sets the current view to hide it's filebar.", 43, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 810 }, +{ PROC_LINKS(toggle_filebar, 0), "toggle_filebar", 14, "Toggles the visibility status of the current view's filebar.", 60, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 818 }, +{ PROC_LINKS(toggle_line_wrap, 0), "toggle_line_wrap", 16, "Toggles the current buffer's line wrapping status.", 50, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 828 }, +{ PROC_LINKS(toggle_fps_meter, 0), "toggle_fps_meter", 16, "Toggles the visibility of the FPS performance meter", 51, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 840 }, +{ PROC_LINKS(increase_line_wrap, 0), "increase_line_wrap", 18, "Increases the current buffer's width for line wrapping.", 55, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 846 }, +{ PROC_LINKS(decrease_line_wrap, 0), "decrease_line_wrap", 18, "Decrases the current buffer's width for line wrapping.", 54, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 858 }, +{ PROC_LINKS(increase_face_size, 0), "increase_face_size", 18, "Increase the size of the face used by the current buffer.", 57, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 870 }, +{ PROC_LINKS(decrease_face_size, 0), "decrease_face_size", 18, "Decrease the size of the face used by the current buffer.", 57, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 884 }, +{ PROC_LINKS(mouse_wheel_change_face_size, 0), "mouse_wheel_change_face_size", 28, "Reads the state of the mouse wheel and uses it to either increase or decrease the face size.", 92, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 898 }, +{ PROC_LINKS(toggle_virtual_whitespace, 0), "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 915 }, +{ PROC_LINKS(toggle_show_whitespace, 0), "toggle_show_whitespace", 22, "Toggles the current buffer's whitespace visibility status.", 58, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 927 }, +{ PROC_LINKS(toggle_line_numbers, 0), "toggle_line_numbers", 19, "Toggles the left margin line numbers.", 37, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 937 }, +{ PROC_LINKS(eol_dosify, 0), "eol_dosify", 10, "Puts the buffer in DOS line ending mode.", 40, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 943 }, +{ PROC_LINKS(eol_nixify, 0), "eol_nixify", 10, "Puts the buffer in NIX line ending mode.", 40, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 953 }, +{ PROC_LINKS(exit_4coder, 0), "exit_4coder", 11, "Attempts to close 4coder.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 963 }, +{ PROC_LINKS(goto_line, 0), "goto_line", 9, "Queries the user for a number, and jumps the cursor to the corresponding line.", 78, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 971 }, +{ PROC_LINKS(search, 0), "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1199 }, +{ PROC_LINKS(reverse_search, 0), "reverse_search", 14, "Begins an incremental search up through the current buffer for a user specified string.", 87, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1205 }, +{ PROC_LINKS(search_identifier, 0), "search_identifier", 17, "Begins an incremental search down through the current buffer for the word or token under the cursor.", 100, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1211 }, +{ PROC_LINKS(reverse_search_identifier, 0), "reverse_search_identifier", 25, "Begins an incremental search up through the current buffer for the word or token under the cursor.", 98, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1226 }, +{ PROC_LINKS(replace_in_range, 0), "replace_in_range", 16, "Queries the user for two strings, and replaces all occurences of the first string in the range between the cursor and the mark with the second string.", 150, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1241 }, +{ PROC_LINKS(query_replace, 0), "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1350 }, +{ PROC_LINKS(query_replace_identifier, 0), "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1373 }, +{ PROC_LINKS(query_replace_selection, 0), "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1392 }, +{ PROC_LINKS(save_all_dirty_buffers, 0), "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1436 }, +{ PROC_LINKS(delete_file_query, 0), "delete_file_query", 17, "Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.", 125, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1461 }, +{ PROC_LINKS(save_to_query, 0), "save_to_query", 13, "Queries the user for a file name and saves the contents of the current buffer, altering the buffer's name too.", 110, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1501 }, +{ PROC_LINKS(rename_file_query, 0), "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1539 }, +{ PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1582 }, +{ PROC_LINKS(move_line_up, 0), "move_line_up", 12, "Swaps the line under the cursor with the line above it, and moves the cursor up with it.", 88, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1618 }, +{ PROC_LINKS(move_line_down, 0), "move_line_down", 14, "Swaps the line under the cursor with the line below it, and moves the cursor down with it.", 90, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1624 }, +{ PROC_LINKS(duplicate_line, 0), "duplicate_line", 14, "Create a copy of the line on which the cursor sits.", 51, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1630 }, +{ PROC_LINKS(delete_line, 0), "delete_line", 11, "Delete the line the on which the cursor sits.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1647 }, +{ PROC_LINKS(open_file_in_quotes, 0), "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1716 }, +{ PROC_LINKS(open_matching_file_cpp, 0), "open_matching_file_cpp", 22, "If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.", 110, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1754 }, +{ 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, 1769 }, +{ PROC_LINKS(swap_buffers_between_panels, 0), "swap_buffers_between_panels", 27, "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, 1784 }, +{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1829 }, +{ PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1839 }, +{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1853 }, +{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history of the current buffer.", 66, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1917 }, +{ PROC_LINKS(redo, 0), "redo", 4, "Advances forwards through the undo history of the current buffer.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1933 }, +{ PROC_LINKS(undo_all_buffers, 0), "undo_all_buffers", 16, "Advances backward through the undo history in the buffer containing the most recent regular edit.", 97, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1951 }, +{ PROC_LINKS(redo_all_buffers, 0), "redo_all_buffers", 16, "Advances forward through the undo history in the buffer containing the most recent regular edit.", 96, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 2030 }, +{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 2140 }, { PROC_LINKS(lister__quit, 0), "lister__quit", 12, "A lister mode command that quits the list without executing any actions.", 72, "w:\\4ed\\code\\4coder_lists.cpp", 28, 8 }, { PROC_LINKS(lister__activate, 0), "lister__activate", 16, "A lister mode command that activates the list's action on the highlighted item.", 79, "w:\\4ed\\code\\4coder_lists.cpp", 28, 16 }, { PROC_LINKS(lister__write_character, 0), "lister__write_character", 23, "A lister mode command that dispatches to the lister's write character handler.", 78, "w:\\4ed\\code\\4coder_lists.cpp", 28, 32 }, diff --git a/4coder_helper.cpp b/4coder_helper.cpp index a52290d4..d05c1759 100644 --- a/4coder_helper.cpp +++ b/4coder_helper.cpp @@ -1096,7 +1096,7 @@ push_buffer_range(Application_Links *app, Arena *arena, Buffer_ID buffer, Range } static String_Const_u8 -push_buffer_range(Application_Links *app, Arena *arena, Buffer_ID buffer, Range_umem range){ +push_buffer_range(Application_Links *app, Arena *arena, Buffer_ID buffer, Range_u64 range){ return(push_buffer_range(app, arena, buffer, range.first, range.one_past_last)); } diff --git a/4coder_string_match.cpp b/4coder_string_match.cpp new file mode 100644 index 00000000..9abcfb16 --- /dev/null +++ b/4coder_string_match.cpp @@ -0,0 +1,43 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 17.06.2019 + * + * Routines for operating on the String_Match and String_Match_List types. + * + */ + +// TOP + +internal void +string_match_list_push(Arena *arena, String_Match_List *list, + Buffer_ID buffer, i32 string_id, String_Match_Flag flags, Range_u64 range){ + String_Match *match = push_array(arena, String_Match, 1); + sll_queue_push(list->first, list->last, match); + list->count += 1; + match->buffer = buffer; + match->string_id = string_id; + match->flags = flags; + match->range = range; +} + +internal void +string_match_list_push(Arena *arena, String_Match_List *list, + Buffer_ID buffer, i32 string_id, String_Match_Flag flags, u64 start, u64 length){ + string_match_list_push(arena, list, buffer, string_id, flags, + make_range_u64(start, start + length)); +} + +internal void +string_match_list_join(String_Match_List *dst, String_Match_List *src){ + if (dst->last != 0){ + dst->last->next = src->first; + } + if (src->last != 0){ + dst->last = src->last; + } + dst->count += src->count; + block_zero_struct(src); +} + +// BOTTOM \ No newline at end of file diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 2df2328e..dafcfe02 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -487,10 +487,10 @@ Buffer_Seek_String(Application_Links *app, Buffer_ID buffer, String_Const_u8 nee Character_Predicate dummy = {}; String_Match_List list = find_all_matches(scratch, 1, chunks, needle, jump_table, &dummy, direction, - range.min, 0); + range.min, 0, 0); if (list.count == 1){ result = true; - *pos_out = (i32)list.first->index; + *pos_out = (i32)list.first->range.first; *case_sensitive_out = (HasFlag(list.first->flags, StringMatch_CaseSensitive)); } } @@ -4257,13 +4257,11 @@ Draw_Render_Layout(Application_Links *app, View_ID view_id){ } API_EXPORT void -Open_Color_Picker(Application_Links *app, color_picker *picker) +Open_Color_Picker(Application_Links *app, Color_Picker *picker) { Models *models = (Models*)app->cmd_context; System_Functions *system = models->system; - - if(picker->finished) - { + if (picker->finished){ *picker->finished = false; } system->open_color_picker(picker); @@ -4282,7 +4280,7 @@ Animate_In_N_Milliseconds(Application_Links *app, u32 n) } API_EXPORT String_Match_List -Find_All_Matches_Buffer_Range(Application_Links *app, Arena *arena, Buffer_ID buffer, Range range, String_Const_u8 needle, Character_Predicate *predicate, Scan_Direction direction) +Find_All_Matches_Buffer_Range(Application_Links *app, Arena *arena, Buffer_ID buffer, i32 string_id, Range range, String_Const_u8 needle, Character_Predicate *predicate, Scan_Direction direction) { Models *models = (Models*)app->cmd_context; Editing_File *file = imp_get_file(models, buffer); @@ -4301,7 +4299,7 @@ Find_All_Matches_Buffer_Range(Application_Links *app, Arena *arena, Buffer_ID bu } list = find_all_matches(arena, max_i32, chunks, needle, jump_table, predicate, direction, - range.min, buffer); + range.min, buffer, string_id); } } } diff --git a/4ed_app_target.cpp b/4ed_app_target.cpp index 742d86d8..8214ebaf 100644 --- a/4ed_app_target.cpp +++ b/4ed_app_target.cpp @@ -21,6 +21,7 @@ #include "4ed_system.h" #include "4coder_base_types.cpp" +#include "4coder_string_match.cpp" #include "4coder_stringf.cpp" #include "4coder_app_links_allocator.cpp" diff --git a/4ed_layout.cpp b/4ed_layout.cpp index 7038e1e3..05d966b4 100644 --- a/4ed_layout.cpp +++ b/4ed_layout.cpp @@ -53,7 +53,7 @@ layout__free_panel(Layout *layout, Panel *panel){ internal void layout__set_panel_rectangle(Layout *layout, Panel *panel, i32_Rect rect){ panel->rect_full = rect; - panel->rect_inner = get_inner_rect(rect, layout->margin); + panel->rect_inner = rect_inner(rect, layout->margin); } internal i32 diff --git a/4ed_render_format.cpp b/4ed_render_format.cpp index 43a48127..67341bc6 100644 --- a/4ed_render_format.cpp +++ b/4ed_render_format.cpp @@ -94,7 +94,7 @@ draw_margin(Render_Target *target, f32_Rect outer, f32_Rect inner, u32 color){ internal void draw_margin(Render_Target *target, f32_Rect outer, f32 width, u32 color){ - f32_Rect inner = get_inner_rect(outer, width); + f32_Rect inner = rect_inner(outer, width); draw_margin(target, outer, inner, color); } @@ -109,7 +109,7 @@ draw_margin(Render_Target *target, i32_Rect outer, i32_Rect inner, u32 color){ internal void draw_margin(Render_Target *target, i32_Rect outer, i32 width, u32 color){ - i32_Rect inner = get_inner_rect(outer, width); + i32_Rect inner = rect_inner(outer, width); draw_margin(target, outer, inner, color); } diff --git a/4ed_render_target.cpp b/4ed_render_target.cpp index 853593e0..0370cfa2 100644 --- a/4ed_render_target.cpp +++ b/4ed_render_target.cpp @@ -82,11 +82,7 @@ Render_Change_Clip_Sig(render_change_clip, t, clip_box){ internal Render_Push_Clip_Sig(render_push_clip, t, clip_box){ - // NOTE(casey): Allen, I nerfed this assertion because really people should be able to push any clip region they want, it - // should just be "restricted" to the previous clip regions, right? -// Assert(t->clip_top == -1 || fits_inside(clip_box, t->clip_boxes[t->clip_top])); - if(t->clip_top != -1) - { + if (t->clip_top != -1){ clip_box = intersection_of(clip_box, t->clip_boxes[t->clip_top]); } Assert(t->clip_top + 1 < ArrayCount(t->clip_boxes)); diff --git a/4ed_string_matching.cpp b/4ed_string_matching.cpp index 288b3d1d..aef1f344 100644 --- a/4ed_string_matching.cpp +++ b/4ed_string_matching.cpp @@ -63,24 +63,13 @@ string_compute_needle_jump_table(Arena *arena, String_Const_u8 needle, Scan_Dire return(string_compute_needle_jump_table(arena, prefix_table)); } -internal void -string_match_list_push(Arena *arena, String_Match_List *list, - u64 index, String_Match_Flag flags, Buffer_ID buffer){ - String_Match *match = push_array(arena, String_Match, 1); - sll_queue_push(list->first, list->last, match); - list->count += 1; - match->buffer = buffer; - match->flags = flags; - match->index = index; -} - #define character_predicate_check_character(p, c) (((p).b[(c)/8] & (1 << ((c)%8))) != 0) internal String_Match_List find_all_matches_forward(Arena *arena, i32 maximum_output_count, String_Const_u8_Array chunks, String_Const_u8 needle, u64_Array jump_table, Character_Predicate *predicate, - u64 base_index, Buffer_ID buffer){ + u64 base_index, Buffer_ID buffer, i32 string_id){ String_Match_List list = {}; if (chunks.count > 0){ @@ -155,7 +144,8 @@ find_all_matches_forward(Arena *arena, i32 maximum_output_count, if (current_l){ AddFlag(flags, StringMatch_LeftSideSloppy); } - string_match_list_push(arena, &list, base_index + j, flags, buffer); + string_match_list_push(arena, &list, buffer, string_id, flags, + base_index + j, needle.size); if (list.count >= maximum_output_count){ break; } @@ -192,7 +182,7 @@ internal String_Match_List find_all_matches_backward(Arena *arena, i32 maximum_output_count, String_Const_u8_Array chunks, String_Const_u8 needle, u64_Array jump_table, Character_Predicate *predicate, - u64 base_index, Buffer_ID buffer){ + u64 base_index, Buffer_ID buffer, i32 string_id){ String_Match_List list = {}; if (chunks.count > 0){ @@ -272,8 +262,8 @@ find_all_matches_backward(Arena *arena, i32 maximum_output_count, if (current_r){ AddFlag(flags, StringMatch_RightSideSloppy); } - string_match_list_push(arena, &list, - base_index + (j - (needle.size - 1)), flags, buffer); + string_match_list_push(arena, &list, buffer, string_id, flags, + base_index + (j - (needle.size - 1)), needle.size); if (list.count >= maximum_output_count){ break; } @@ -314,21 +304,21 @@ find_all_matches(Arena *arena, i32 maximum_output_count, String_Const_u8_Array chunks, String_Const_u8 needle, u64_Array jump_table, Character_Predicate *predicate, Scan_Direction direction, - u64 base_index, Buffer_ID buffer){ + u64 base_index, Buffer_ID buffer, i32 string_id){ String_Match_List list = {}; switch (direction){ case Scan_Forward: { list = find_all_matches_forward(arena, maximum_output_count, chunks, needle, jump_table, predicate, - base_index, buffer); + base_index, buffer, string_id); }break; case Scan_Backward: { list = find_all_matches_backward(arena, maximum_output_count, chunks, needle, jump_table, predicate, - base_index, buffer); + base_index, buffer, string_id); }break; } return(list); diff --git a/4ed_system.h b/4ed_system.h index 4a850f8c..7c738e3a 100644 --- a/4ed_system.h +++ b/4ed_system.h @@ -128,7 +128,7 @@ typedef Sys_Yield_Coroutine_Sig(System_Yield_Coroutine); // -#define Sys_Open_Color_Picker_Sig(name) void name(color_picker *picker) +#define Sys_Open_Color_Picker_Sig(name) void name(Color_Picker *picker) typedef Sys_Open_Color_Picker_Sig(System_Open_Color_Picker); // thread diff --git a/opengl/4ed_opengl_render.cpp b/opengl/4ed_opengl_render.cpp index 137e483d..4e959e5b 100644 --- a/opengl/4ed_opengl_render.cpp +++ b/opengl/4ed_opengl_render.cpp @@ -140,7 +140,7 @@ interpret_render_buffer(Render_Target *t, Arena *scratch){ case RenCom_Outline: { Render_Command_Rectangle *rectangle = (Render_Command_Rectangle*)header; - f32_Rect r = get_inner_rect(rectangle->rect, .5f); + f32_Rect r = rect_inner(rectangle->rect, .5f); private_draw_set_color(t, rectangle->color); private_draw_bind_texture(t, 0); glBegin(GL_LINE_STRIP); diff --git a/platform_win32/win32_4ed_functions.cpp b/platform_win32/win32_4ed_functions.cpp index 77fc850f..c201f8e4 100644 --- a/platform_win32/win32_4ed_functions.cpp +++ b/platform_win32/win32_4ed_functions.cpp @@ -475,10 +475,11 @@ color_picker_hook(HWND Window, UINT Message, WPARAM WParam, LPARAM LParam){ UINT_PTR result = 0; switch(Message) { + // TODO(allen): review case WM_INITDIALOG: { CHOOSECOLORW *win32_params = (CHOOSECOLORW *)LParam; - color_picker *picker = (color_picker *)win32_params->lCustData; + Color_Picker *picker = (Color_Picker*)win32_params->lCustData; SetWindowLongPtr(Window, GWLP_USERDATA, (LONG_PTR)LParam); u16 Temp[256]; @@ -509,7 +510,7 @@ color_picker_hook(HWND Window, UINT Message, WPARAM WParam, LPARAM LParam){ CHOOSECOLORW *win32_params = (CHOOSECOLORW *)GetWindowLongPtr(Window, GWLP_USERDATA); if(win32_params) { - color_picker *picker = (color_picker *)win32_params->lCustData; + Color_Picker *picker = (Color_Picker*)win32_params->lCustData; RECT rect; GetClientRect(swatch_window, &rect); @@ -540,10 +541,11 @@ color_picker_hook(HWND Window, UINT Message, WPARAM WParam, LPARAM LParam){ return(result); } +// TODO(allen): review internal DWORD WINAPI color_picker_thread(LPVOID Param) { - color_picker *picker = (color_picker *)Param; + Color_Picker *picker = (Color_Picker*)Param; int_color color = 0; if(picker->dest) @@ -585,11 +587,11 @@ color_picker_thread(LPVOID Param) internal Sys_Open_Color_Picker_Sig(system_open_color_picker){ - + // TODO(allen): review // NOTE(casey): Because this is going to be used by a semi-permanent thread, we need to copy // it to system memory where it can live as long as it wants, no matter what we do over here // on the 4coder threads. - color_picker *perm = (color_picker *)system_memory_allocate_extended(0, sizeof(color_picker)); + Color_Picker *perm = (Color_Picker*)system_memory_allocate_extended(0, sizeof(Color_Picker)); *perm = *picker; HANDLE ThreadHandle = CreateThread(0, 0, color_picker_thread, perm, 0, 0);