diff --git a/4coder_generated/app_functions.h b/4coder_generated/app_functions.h index 296cb008..675e13b1 100644 --- a/4coder_generated/app_functions.h +++ b/4coder_generated/app_functions.h @@ -155,6 +155,7 @@ struct Application_Links; #define OPEN_COLOR_PICKER_SIG(n) void n(Application_Links *app, color_picker *picker) #define ANIMATE_SIG(n) void n(Application_Links *app) #define FIND_ALL_IN_RANGE_INSENSITIVE_SIG(n) Found_String_List n(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 end, String key, Partition *memory) +#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); typedef CREATE_CHILD_PROCESS_SIG(Create_Child_Process_Function); @@ -311,6 +312,7 @@ typedef GET_DEFAULT_FONT_FOR_VIEW_SIG(Get_Default_Font_For_View_Function); typedef OPEN_COLOR_PICKER_SIG(Open_Color_Picker_Function); typedef ANIMATE_SIG(Animate_Function); typedef FIND_ALL_IN_RANGE_INSENSITIVE_SIG(Find_All_In_Range_Insensitive_Function); +typedef GET_VIEW_VISIBLE_RANGE_SIG(Get_View_Visible_Range_Function); struct Application_Links{ #if defined(ALLOW_DEP_4CODER) Global_Set_Setting_Function *global_set_setting; @@ -469,6 +471,7 @@ Get_Default_Font_For_View_Function *get_default_font_for_view; Open_Color_Picker_Function *open_color_picker; Animate_Function *animate; Find_All_In_Range_Insensitive_Function *find_all_in_range_insensitive; +Get_View_Visible_Range_Function *get_view_visible_range; #else Global_Set_Setting_Function *global_set_setting_; Global_Set_Mapping_Function *global_set_mapping_; @@ -626,6 +629,7 @@ Get_Default_Font_For_View_Function *get_default_font_for_view_; Open_Color_Picker_Function *open_color_picker_; Animate_Function *animate_; Find_All_In_Range_Insensitive_Function *find_all_in_range_insensitive_; +Get_View_Visible_Range_Function *get_view_visible_range_; #endif void *memory; int32_t memory_size; @@ -790,7 +794,8 @@ app_links->draw_clip_pop_ = Draw_Clip_Pop;\ app_links->get_default_font_for_view_ = Get_Default_Font_For_View;\ app_links->open_color_picker_ = Open_Color_Picker;\ app_links->animate_ = Animate;\ -app_links->find_all_in_range_insensitive_ = Find_All_In_Range_Insensitive;} while(false) +app_links->find_all_in_range_insensitive_ = Find_All_In_Range_Insensitive;\ +app_links->get_view_visible_range_ = Get_View_Visible_Range;} while(false) #if defined(ALLOW_DEP_4CODER) static b32 global_set_setting(Application_Links *app, Global_Setting_ID setting, i32 value){return(app->global_set_setting(app, setting, value));} static b32 global_set_mapping(Application_Links *app, void *data, i32 size){return(app->global_set_mapping(app, data, size));} @@ -948,6 +953,7 @@ static Face_ID get_default_font_for_view(Application_Links *app, View_ID view_id static void open_color_picker(Application_Links *app, color_picker *picker){(app->open_color_picker(app, picker));} static void animate(Application_Links *app){(app->animate(app));} static Found_String_List find_all_in_range_insensitive(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 end, String key, Partition *memory){return(app->find_all_in_range_insensitive(app, buffer_id, start, end, key, memory));} +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));} static b32 global_set_mapping(Application_Links *app, void *data, i32 size){return(app->global_set_mapping_(app, data, size));} @@ -1105,4 +1111,5 @@ static Face_ID get_default_font_for_view(Application_Links *app, View_ID view_id static void open_color_picker(Application_Links *app, color_picker *picker){(app->open_color_picker_(app, picker));} static void animate(Application_Links *app){(app->animate_(app));} static Found_String_List find_all_in_range_insensitive(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 end, String key, Partition *memory){return(app->find_all_in_range_insensitive_(app, buffer_id, start, end, key, memory));} +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_insertion.cpp b/4coder_insertion.cpp index b214e250..de4e84de 100644 --- a/4coder_insertion.cpp +++ b/4coder_insertion.cpp @@ -39,6 +39,8 @@ insertf(Buffer_Insertion *insertion, char *format, ...){ char temp[1024]; va_list args; + // TODO(casey): Allen, ideally we would have our own formatted here that could handle our string type, via %S or something, so + // we don't have to keep doing %.*s and passing two parameters and all that garbage. va_start(args, format); i32 result = vsprintf(temp, format, args); va_end(args); @@ -97,5 +99,14 @@ insert_line_from_buffer(Buffer_Insertion *insertion, Buffer_ID buffer_id, i32 li return(insert_line_from_buffer(insertion, buffer_id, line, 0)); } +static b32 +insert_mirror_range(Buffer_Insertion *insertion, Buffer_ID source, i32 source_first, i32 length){ + b32 result = mirror_buffer_insert_range(insertion->app, insertion->buffer, source, insertion->at, source_first, length); + if (result){ + insertion->at += length; + } + return(result); +} + // BOTTOM diff --git a/4coder_mirror.cpp b/4coder_mirror.cpp index 580bb1d5..bf195502 100644 --- a/4coder_mirror.cpp +++ b/4coder_mirror.cpp @@ -597,6 +597,9 @@ mirror_buffer_insert_range(Application_Links *app, Buffer_ID mirror, Buffer_ID s if (mode == MirrorMode_Constructing){ b32 did_insert = false; { + // TODO(casey): Allen, this is going to be suuuuuper slow - it has to do a whole memory block + // reserve just to get the temporary space. This is the kind of thing that would be super simple and + // very efficient with a stack off the app pointer. Arena arena = make_arena(app, (8 << 10)); char *buffer = push_array(&arena, char, length); if (buffer_read_range(app, source, source_first, source_first + length, buffer)){ diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 9eb4ade3..160b9f47 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -4684,9 +4684,26 @@ Get_Process_State(Application_Links *app, Buffer_ID buffer_id) result.is_updating = file->is_updating; result.return_code = file->return_code; } - return(result); } */ +API_EXPORT Range +Get_View_Visible_Range(Application_Links *app, View_ID view_id){ + Range result = {}; + // TODO(casey): Allen, I leave it to you to actually compute this the way you want. Hopefully all + // this sort of thing will get sorted out as the render/layout stuff becomes more disentangled. + Models *models = (Models*)app->cmd_context; + View *view = imp_get_view(models, view_id); + if (view_api_check_view(view)){ + i32 view_height = rect_height(view->panel->rect_inner); + Full_Cursor min_cursor = view_get_render_cursor(models->system, view); + Full_Cursor max_cursor; + view_compute_cursor(app, view_id, seek_xy(min_cursor.wrapped_x, min_cursor.wrapped_y + view_height, false, false), &max_cursor); + result.min = min_cursor.pos; + result.max = max_cursor.pos; + } + return(result); +} + // BOTTOM