Added get_view_visible_range

Add get_view_visible_range so you don't have to be in the render_caller to find out what can be seen in a view.  Ideally these two paths would be merged eventually...

Also added mirror buffer support to Buffer_Insertion
master
Casey Muratori 2019-03-24 00:17:21 -07:00
parent 7ee448c7f5
commit fb55121c00
3 changed files with 39 additions and 1 deletions

View File

@ -40,6 +40,8 @@ insertf(Buffer_Insertion *insertion, char *format, ...){
va_list args; va_list args;
va_start(args, format); va_start(args, format);
// 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.
i32 result = vsprintf(temp, format, args); i32 result = vsprintf(temp, format, args);
va_end(args); va_end(args);
@ -97,5 +99,16 @@ insert_line_from_buffer(Buffer_Insertion *insertion, Buffer_ID buffer_id, i32 li
return(insert_line_from_buffer(insertion, buffer_id, line, 0)); 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 // BOTTOM

View File

@ -597,6 +597,9 @@ mirror_buffer_insert_range(Application_Links *app, Buffer_ID mirror, Buffer_ID s
if (mode == MirrorMode_Constructing){ if (mode == MirrorMode_Constructing){
b32 did_insert = false; 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)); Arena arena = make_arena(app, (8 << 10));
char *buffer = push_array(&arena, char, length); char *buffer = push_array(&arena, char, length);
if (buffer_read_range(app, source, source_first, source_first + length, buffer)){ if (buffer_read_range(app, source, source_first, source_first + length, buffer)){

View File

@ -4758,9 +4758,31 @@ Get_Process_State(Application_Links *app, Buffer_ID buffer_id)
result.is_updating = file->is_updating; result.is_updating = file->is_updating;
result.return_code = file->return_code; result.return_code = file->return_code;
} }
*/
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 && view->panel)
{
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); return(result);
} }
*/
// BOTTOM // BOTTOM