Cleanup and experiments with line layout
parent
8a11860fc3
commit
a831f55444
|
@ -636,8 +636,32 @@ buffer_set_dirty_state(Application_Links *app, Buffer_ID buffer_id, Dirty_State
|
|||
Editing_File *file = imp_get_file(models, buffer_id);
|
||||
b32 result = false;
|
||||
if (api_check_buffer(file)){
|
||||
file->state.dirty = dirty_state;
|
||||
result = true;
|
||||
file->state.dirty = dirty_state;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
api(custom) function b32
|
||||
buffer_set_layout(Application_Links *app, Buffer_ID buffer_id,
|
||||
Layout_Function *layout_func){
|
||||
Models *models = (Models*)app->cmd_context;
|
||||
Editing_File *file = imp_get_file(models, buffer_id);
|
||||
b32 result = false;
|
||||
if (api_check_buffer(file)){
|
||||
result = true;
|
||||
file->settings.layout_func = layout_func;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
api(custom) function Layout_Function*
|
||||
buffer_get_layout(Application_Links *app, Buffer_ID buffer_id){
|
||||
Models *models = (Models*)app->cmd_context;
|
||||
Editing_File *file = imp_get_file(models, buffer_id);
|
||||
Layout_Function *result = 0;
|
||||
if (api_check_buffer(file)){
|
||||
result = file->settings.layout_func;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
|
|
@ -208,6 +208,11 @@ file_compute_cursor(Editing_File *file, Buffer_Seek seek){
|
|||
|
||||
////////////////////////////////
|
||||
|
||||
function Layout_Function*
|
||||
file_get_layout_func(Editing_File *file){
|
||||
return(file->settings.layout_func);
|
||||
}
|
||||
|
||||
internal void
|
||||
file_create_from_string(Thread_Context *tctx, Models *models, Editing_File *file, String_Const_u8 val, File_Attributes attributes){
|
||||
Scratch_Block scratch(tctx, Scratch_Share);
|
||||
|
@ -222,6 +227,7 @@ file_create_from_string(Thread_Context *tctx, Models *models, Editing_File *file
|
|||
file_clear_dirty_flags(file);
|
||||
file->attributes = attributes;
|
||||
|
||||
file->settings.layout_func = models->layout_func;
|
||||
file->settings.face_id = models->global_face_id;
|
||||
|
||||
buffer_measure_starts(scratch, &file->state.buffer);
|
||||
|
|
|
@ -34,7 +34,7 @@ struct Text_Effect{
|
|||
};
|
||||
|
||||
struct Editing_File_Settings{
|
||||
Command_Map_ID base_map_id;
|
||||
Layout_Function *layout_func;
|
||||
Face_ID face_id;
|
||||
b8 dos_write_mode;
|
||||
b8 is_initialized;
|
||||
|
|
37
4ed_view.cpp
37
4ed_view.cpp
|
@ -72,11 +72,6 @@ free_all_queries(Query_Set *set){
|
|||
|
||||
////////////////////////////////
|
||||
|
||||
internal Command_Map_ID
|
||||
view_get_map(View *view){
|
||||
return(view->file->settings.base_map_id);
|
||||
}
|
||||
|
||||
internal Access_Flag
|
||||
view_get_access_flags(View *view){
|
||||
Access_Flag result = file_get_access_flags(view->file);
|
||||
|
@ -177,11 +172,6 @@ view_height(Thread_Context *tctx, Models *models, View *view){
|
|||
return(rect_height(view_get_buffer_rect(tctx, models, view)));
|
||||
}
|
||||
|
||||
function Layout_Function*
|
||||
view_get_layout_func(View *view){
|
||||
return(view->layout_func);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
internal Layout_Item_List
|
||||
|
@ -189,7 +179,7 @@ view_get_line_layout(Thread_Context *tctx, Models *models, View *view, i64 line_
|
|||
Editing_File *file = view->file;
|
||||
Face *face = file_get_face(models, file);
|
||||
f32 width = view_width(tctx, models, view);
|
||||
Layout_Function *layout_func = view_get_layout_func(view);
|
||||
Layout_Function *layout_func = file_get_layout_func(file);
|
||||
return(file_get_line_layout(tctx, models, file, layout_func, width, face, line_number));
|
||||
}
|
||||
|
||||
|
@ -199,7 +189,7 @@ view_line_shift_y(Thread_Context *tctx, Models *models, View *view,
|
|||
Editing_File *file = view->file;
|
||||
Face *face = file_get_face(models, file);
|
||||
f32 width = view_width(tctx, models, view);
|
||||
Layout_Function *layout_func = view_get_layout_func(view);
|
||||
Layout_Function *layout_func = file_get_layout_func(file);
|
||||
return(file_line_shift_y(tctx, models, file, layout_func, width, face,
|
||||
line_number, y_delta));
|
||||
}
|
||||
|
@ -210,7 +200,7 @@ view_line_y_difference(Thread_Context *tctx, Models *models, View *view,
|
|||
Editing_File *file = view->file;
|
||||
Face *face = file_get_face(models, file);
|
||||
f32 width = view_width(tctx, models, view);
|
||||
Layout_Function *layout_func = view_get_layout_func(view);
|
||||
Layout_Function *layout_func = file_get_layout_func(file);
|
||||
return(file_line_y_difference(tctx, models, file,
|
||||
layout_func, width, face, line_a, line_b));
|
||||
}
|
||||
|
@ -221,7 +211,7 @@ view_pos_at_relative_xy(Thread_Context *tctx, Models *models, View *view,
|
|||
Editing_File *file = view->file;
|
||||
Face *face = file_get_face(models, file);
|
||||
f32 width = view_width(tctx, models, view);
|
||||
Layout_Function *layout_func = view_get_layout_func(view);
|
||||
Layout_Function *layout_func = file_get_layout_func(file);
|
||||
return(file_pos_at_relative_xy(tctx, models, file,
|
||||
layout_func, width, face, base_line, relative_xy));
|
||||
}
|
||||
|
@ -232,7 +222,7 @@ view_relative_box_of_pos(Thread_Context *tctx, Models *models, View *view,
|
|||
Editing_File *file = view->file;
|
||||
Face *face = file_get_face(models, file);
|
||||
f32 width = view_width(tctx, models, view);
|
||||
Layout_Function *layout_func = view_get_layout_func(view);
|
||||
Layout_Function *layout_func = file_get_layout_func(file);
|
||||
return(file_relative_box_of_pos(tctx, models, file,
|
||||
layout_func, width, face, base_line, pos));
|
||||
}
|
||||
|
@ -250,7 +240,7 @@ view_normalize_buffer_point(Thread_Context *tctx, Models *models, View *view,
|
|||
Editing_File *file = view->file;
|
||||
Face *face = file_get_face(models, file);
|
||||
f32 width = view_width(tctx, models, view);
|
||||
Layout_Function *layout_func = view_get_layout_func(view);
|
||||
Layout_Function *layout_func = file_get_layout_func(file);
|
||||
return(file_normalize_buffer_point(tctx, models, file,
|
||||
layout_func, width, face, point));
|
||||
}
|
||||
|
@ -261,7 +251,7 @@ view_buffer_point_difference(Thread_Context *tctx, Models *models, View *view,
|
|||
Editing_File *file = view->file;
|
||||
Face *face = file_get_face(models, file);
|
||||
f32 width = view_width(tctx, models, view);
|
||||
Layout_Function *layout_func = view_get_layout_func(view);
|
||||
Layout_Function *layout_func = file_get_layout_func(file);
|
||||
return(file_buffer_point_difference(tctx, models, file,
|
||||
layout_func, width, face, a, b));
|
||||
}
|
||||
|
@ -282,7 +272,7 @@ view_line_shift_characters(Thread_Context *tctx, Models *models, View *view,
|
|||
Editing_File *file = view->file;
|
||||
Face *face = file_get_face(models, file);
|
||||
f32 width = view_width(tctx, models, view);
|
||||
Layout_Function *layout_func = view_get_layout_func(view);
|
||||
Layout_Function *layout_func = file_get_layout_func(file);
|
||||
return(file_line_shift_characters(tctx, models, file,
|
||||
layout_func, width, face, line_number, character_delta));
|
||||
}
|
||||
|
@ -293,7 +283,7 @@ view_line_character_difference(Thread_Context *tctx, Models *models, View *view,
|
|||
Editing_File *file = view->file;
|
||||
Face *face = file_get_face(models, file);
|
||||
f32 width = view_width(tctx, models, view);
|
||||
Layout_Function *layout_func = view_get_layout_func(view);
|
||||
Layout_Function *layout_func = file_get_layout_func(file);
|
||||
return(file_line_character_difference(tctx, models, file, layout_func, width, face,
|
||||
line_a, line_b));
|
||||
}
|
||||
|
@ -304,7 +294,7 @@ view_pos_from_relative_character(Thread_Context *tctx, Models *models, View *vie
|
|||
Editing_File *file = view->file;
|
||||
Face *face = file_get_face(models, file);
|
||||
f32 width = view_width(tctx, models, view);
|
||||
Layout_Function *layout_func = view_get_layout_func(view);
|
||||
Layout_Function *layout_func = file_get_layout_func(file);
|
||||
return(file_pos_from_relative_character(tctx, models, file, layout_func, width, face,
|
||||
base_line, relative_character));
|
||||
}
|
||||
|
@ -315,7 +305,7 @@ view_relative_character_from_pos(Thread_Context *tctx, Models *models, View *vie
|
|||
Editing_File *file = view->file;
|
||||
Face *face = file_get_face(models, file);
|
||||
f32 width = view_width(tctx, models, view);
|
||||
Layout_Function *layout_func = view_get_layout_func(view);
|
||||
Layout_Function *layout_func = file_get_layout_func(file);
|
||||
return(file_relative_character_from_pos(tctx, models, file,
|
||||
layout_func, width, face, base_line, pos));
|
||||
}
|
||||
|
@ -335,7 +325,7 @@ view_move_view_to_cursor(Thread_Context *tctx, Models *models, View *view, Buffe
|
|||
Rect_f32 rect = view_get_buffer_rect(tctx, models, view);
|
||||
Vec2_f32 view_dim = rect_dim(rect);
|
||||
|
||||
Layout_Function *layout_func = view_get_layout_func(view);
|
||||
Layout_Function *layout_func = file_get_layout_func(file);
|
||||
|
||||
File_Edit_Positions edit_pos = view_get_edit_pos(view);
|
||||
Vec2_f32 p = file_relative_xy_of_pos(tctx, models, file,
|
||||
|
@ -374,7 +364,7 @@ view_move_cursor_to_view(Thread_Context *tctx, Models *models, View *view, Buffe
|
|||
Rect_f32 rect = view_get_buffer_rect(tctx, models, view);
|
||||
Vec2_f32 view_dim = rect_dim(rect);
|
||||
|
||||
Layout_Function *layout_func = view_get_layout_func(view);
|
||||
Layout_Function *layout_func = file_get_layout_func(file);
|
||||
|
||||
Vec2_f32 p = file_relative_xy_of_pos(tctx, models, file,
|
||||
layout_func, view_dim.x, face,
|
||||
|
@ -568,7 +558,6 @@ view_event_context_base__inner(Coroutine *coroutine){
|
|||
function void
|
||||
view_init(Thread_Context *tctx, Models *models, View *view, Editing_File *initial_buffer,
|
||||
Custom_Command_Function *event_context_base){
|
||||
view->layout_func = models->layout_func;
|
||||
view_set_file(tctx, models, view, initial_buffer);
|
||||
|
||||
view->node_arena = reserve_arena(tctx);
|
||||
|
|
|
@ -75,7 +75,6 @@ struct View{
|
|||
File_Edit_Positions edit_pos_;
|
||||
i64 mark;
|
||||
f32 preferred_x;
|
||||
Layout_Function *layout_func;
|
||||
|
||||
b8 new_scroll_target;
|
||||
|
||||
|
|
|
@ -764,6 +764,23 @@ BUFFER_HOOK_SIG(default_begin_buffer){
|
|||
*lex_task_ptr = async_task_no_dep(&global_async_system, do_full_lex_async, make_data_struct(&buffer_id));
|
||||
}
|
||||
|
||||
if (wrap_lines){
|
||||
if (use_virtual_whitespace){
|
||||
buffer_set_layout(app, buffer_id, layout_virt_indent_unwrapped);
|
||||
}
|
||||
else{
|
||||
buffer_set_layout(app, buffer_id, layout_wrap_whitespace);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (use_virtual_whitespace){
|
||||
buffer_set_layout(app, buffer_id, layout_virt_indent_unwrapped);
|
||||
}
|
||||
else{
|
||||
buffer_set_layout(app, buffer_id, layout_unwrapped);
|
||||
}
|
||||
}
|
||||
|
||||
// no meaning for return
|
||||
return(0);
|
||||
}
|
||||
|
@ -937,10 +954,10 @@ set_all_default_hooks(Application_Links *app){
|
|||
set_custom_hook(app, HookID_BufferEditRange, default_buffer_edit_range);
|
||||
set_custom_hook(app, HookID_BufferRegion, default_buffer_region);
|
||||
|
||||
//set_custom_hook(app, HookID_Layout, layout_unwrapped);
|
||||
set_custom_hook(app, HookID_Layout, layout_unwrapped);
|
||||
//set_custom_hook(app, HookID_Layout, layout_wrap_anywhere);
|
||||
//set_custom_hook(app, HookID_Layout, layout_wrap_whitespace);
|
||||
set_custom_hook(app, HookID_Layout, layout_generic_virtual_whitespace);
|
||||
//set_custom_hook(app, HookID_Layout, layout_virt_indent_unwrapped);
|
||||
//set_custom_hook(app, HookID_Layout, layout_unwrapped_small_blank_lines);
|
||||
}
|
||||
|
||||
|
|
|
@ -106,16 +106,6 @@ newline_layout_consume_finish(Newline_Layout_Vars *vars){
|
|||
|
||||
////
|
||||
|
||||
#if 0
|
||||
function void
|
||||
lr_tb_write_blank(LefRig_TopBot_Layout_Vars *vars,
|
||||
Arena *arena, Layout_Item_List *list, i64 index){
|
||||
f32 advance = vars->metrics->space_advance;
|
||||
lr_tb_write_blank_dim(vars, V2f32(advance, vars->metrics->text_height),
|
||||
arena, list, index);
|
||||
}
|
||||
#endif
|
||||
|
||||
function LefRig_TopBot_Layout_Vars
|
||||
get_lr_tb_layout_vars(Face_Advance_Map *advance_map, Face_Metrics *metrics, f32 width){
|
||||
f32 text_height = metrics->text_height;
|
||||
|
@ -612,9 +602,9 @@ layout_wrap_whitespace(Application_Links *app, Arena *arena, Buffer_ID buffer,
|
|||
}
|
||||
|
||||
function Layout_Item_List
|
||||
layout_generic_virtual_whitespace(Application_Links *app, Arena *arena,
|
||||
Buffer_ID buffer, Range_i64 range, Face_ID face,
|
||||
f32 width){
|
||||
layout_virt_indent_unwrapped(Application_Links *app, Arena *arena,
|
||||
Buffer_ID buffer, Range_i64 range, Face_ID face,
|
||||
f32 width){
|
||||
Scratch_Block scratch(app);
|
||||
|
||||
Layout_Item_List list = get_empty_item_list(range);
|
||||
|
|
|
@ -42,6 +42,8 @@ vtable->push_buffer_unique_name = push_buffer_unique_name;
|
|||
vtable->push_buffer_file_name = push_buffer_file_name;
|
||||
vtable->buffer_get_dirty_state = buffer_get_dirty_state;
|
||||
vtable->buffer_set_dirty_state = buffer_set_dirty_state;
|
||||
vtable->buffer_set_layout = buffer_set_layout;
|
||||
vtable->buffer_get_layout = buffer_get_layout;
|
||||
vtable->buffer_get_setting = buffer_get_setting;
|
||||
vtable->buffer_set_setting = buffer_set_setting;
|
||||
vtable->buffer_get_managed_scope = buffer_get_managed_scope;
|
||||
|
@ -219,6 +221,8 @@ push_buffer_unique_name = vtable->push_buffer_unique_name;
|
|||
push_buffer_file_name = vtable->push_buffer_file_name;
|
||||
buffer_get_dirty_state = vtable->buffer_get_dirty_state;
|
||||
buffer_set_dirty_state = vtable->buffer_set_dirty_state;
|
||||
buffer_set_layout = vtable->buffer_set_layout;
|
||||
buffer_get_layout = vtable->buffer_get_layout;
|
||||
buffer_get_setting = vtable->buffer_get_setting;
|
||||
buffer_set_setting = vtable->buffer_set_setting;
|
||||
buffer_get_managed_scope = vtable->buffer_get_managed_scope;
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#define custom_push_buffer_file_name_sig() String_Const_u8 custom_push_buffer_file_name(Application_Links* app, Arena* arena, Buffer_ID buffer_id)
|
||||
#define custom_buffer_get_dirty_state_sig() Dirty_State custom_buffer_get_dirty_state(Application_Links* app, Buffer_ID buffer_id)
|
||||
#define custom_buffer_set_dirty_state_sig() b32 custom_buffer_set_dirty_state(Application_Links* app, Buffer_ID buffer_id, Dirty_State dirty_state)
|
||||
#define custom_buffer_set_layout_sig() b32 custom_buffer_set_layout(Application_Links* app, Buffer_ID buffer, Layout_Function* layout_func)
|
||||
#define custom_buffer_get_layout_sig() Layout_Function* custom_buffer_get_layout(Application_Links* app, Buffer_ID buffer)
|
||||
#define custom_buffer_get_setting_sig() b32 custom_buffer_get_setting(Application_Links* app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i64* value_out)
|
||||
#define custom_buffer_set_setting_sig() b32 custom_buffer_set_setting(Application_Links* app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i64 value)
|
||||
#define custom_buffer_get_managed_scope_sig() Managed_Scope custom_buffer_get_managed_scope(Application_Links* app, Buffer_ID buffer_id)
|
||||
|
@ -213,6 +215,8 @@ typedef String_Const_u8 custom_push_buffer_unique_name_type(Application_Links* a
|
|||
typedef String_Const_u8 custom_push_buffer_file_name_type(Application_Links* app, Arena* arena, Buffer_ID buffer_id);
|
||||
typedef Dirty_State custom_buffer_get_dirty_state_type(Application_Links* app, Buffer_ID buffer_id);
|
||||
typedef b32 custom_buffer_set_dirty_state_type(Application_Links* app, Buffer_ID buffer_id, Dirty_State dirty_state);
|
||||
typedef b32 custom_buffer_set_layout_type(Application_Links* app, Buffer_ID buffer, Layout_Function* layout_func);
|
||||
typedef Layout_Function* custom_buffer_get_layout_type(Application_Links* app, Buffer_ID buffer);
|
||||
typedef b32 custom_buffer_get_setting_type(Application_Links* app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i64* value_out);
|
||||
typedef b32 custom_buffer_set_setting_type(Application_Links* app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i64 value);
|
||||
typedef Managed_Scope custom_buffer_get_managed_scope_type(Application_Links* app, Buffer_ID buffer_id);
|
||||
|
@ -387,6 +391,8 @@ custom_push_buffer_unique_name_type *push_buffer_unique_name;
|
|||
custom_push_buffer_file_name_type *push_buffer_file_name;
|
||||
custom_buffer_get_dirty_state_type *buffer_get_dirty_state;
|
||||
custom_buffer_set_dirty_state_type *buffer_set_dirty_state;
|
||||
custom_buffer_set_layout_type *buffer_set_layout;
|
||||
custom_buffer_get_layout_type *buffer_get_layout;
|
||||
custom_buffer_get_setting_type *buffer_get_setting;
|
||||
custom_buffer_set_setting_type *buffer_set_setting;
|
||||
custom_buffer_get_managed_scope_type *buffer_get_managed_scope;
|
||||
|
@ -562,6 +568,8 @@ internal String_Const_u8 push_buffer_unique_name(Application_Links* app, Arena*
|
|||
internal String_Const_u8 push_buffer_file_name(Application_Links* app, Arena* arena, Buffer_ID buffer_id);
|
||||
internal Dirty_State buffer_get_dirty_state(Application_Links* app, Buffer_ID buffer_id);
|
||||
internal b32 buffer_set_dirty_state(Application_Links* app, Buffer_ID buffer_id, Dirty_State dirty_state);
|
||||
internal b32 buffer_set_layout(Application_Links* app, Buffer_ID buffer, Layout_Function* layout_func);
|
||||
internal Layout_Function* buffer_get_layout(Application_Links* app, Buffer_ID buffer);
|
||||
internal b32 buffer_get_setting(Application_Links* app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i64* value_out);
|
||||
internal b32 buffer_set_setting(Application_Links* app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i64 value);
|
||||
internal Managed_Scope buffer_get_managed_scope(Application_Links* app, Buffer_ID buffer_id);
|
||||
|
@ -737,6 +745,8 @@ global custom_push_buffer_unique_name_type *push_buffer_unique_name = 0;
|
|||
global custom_push_buffer_file_name_type *push_buffer_file_name = 0;
|
||||
global custom_buffer_get_dirty_state_type *buffer_get_dirty_state = 0;
|
||||
global custom_buffer_set_dirty_state_type *buffer_set_dirty_state = 0;
|
||||
global custom_buffer_set_layout_type *buffer_set_layout = 0;
|
||||
global custom_buffer_get_layout_type *buffer_get_layout = 0;
|
||||
global custom_buffer_get_setting_type *buffer_get_setting = 0;
|
||||
global custom_buffer_set_setting_type *buffer_set_setting = 0;
|
||||
global custom_buffer_get_managed_scope_type *buffer_get_managed_scope = 0;
|
||||
|
|
|
@ -40,6 +40,8 @@ api(custom) function String_Const_u8 push_buffer_unique_name(Application_Links*
|
|||
api(custom) function String_Const_u8 push_buffer_file_name(Application_Links* app, Arena* arena, Buffer_ID buffer_id);
|
||||
api(custom) function Dirty_State buffer_get_dirty_state(Application_Links* app, Buffer_ID buffer_id);
|
||||
api(custom) function b32 buffer_set_dirty_state(Application_Links* app, Buffer_ID buffer_id, Dirty_State dirty_state);
|
||||
api(custom) function b32 buffer_set_layout(Application_Links* app, Buffer_ID buffer, Layout_Function* layout_func);
|
||||
api(custom) function Layout_Function* buffer_get_layout(Application_Links* app, Buffer_ID buffer);
|
||||
api(custom) function b32 buffer_get_setting(Application_Links* app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i64* value_out);
|
||||
api(custom) function b32 buffer_set_setting(Application_Links* app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i64 value);
|
||||
api(custom) function Managed_Scope buffer_get_managed_scope(Application_Links* app, Buffer_ID buffer_id);
|
||||
|
|
Loading…
Reference in New Issue