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_Insertionmaster
parent
7ee448c7f5
commit
fb55121c00
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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)){
|
||||||
|
|
|
@ -4759,8 +4759,30 @@ Get_Process_State(Application_Links *app, Buffer_ID buffer_id)
|
||||||
result.return_code = file->return_code;
|
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 && 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);
|
||||||
|
}
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
Loading…
Reference in New Issue