arbitrary wrap positions with commands for adjusting and horizontal navigation
This commit is contained in:
parent
1b03a6a2be
commit
1e8bea250e
File diff suppressed because one or more lines are too long
|
@ -26,6 +26,7 @@
|
||||||
#define OPEN_VIEW_SIG(n) View_Summary n(Application_Links *app, View_Summary *view_location, View_Split_Position position)
|
#define OPEN_VIEW_SIG(n) View_Summary n(Application_Links *app, View_Summary *view_location, View_Split_Position position)
|
||||||
#define CLOSE_VIEW_SIG(n) bool32 n(Application_Links *app, View_Summary *view)
|
#define CLOSE_VIEW_SIG(n) bool32 n(Application_Links *app, View_Summary *view)
|
||||||
#define SET_ACTIVE_VIEW_SIG(n) bool32 n(Application_Links *app, View_Summary *view)
|
#define SET_ACTIVE_VIEW_SIG(n) bool32 n(Application_Links *app, View_Summary *view)
|
||||||
|
#define VIEW_GET_SETTING_SIG(n) int32_t n(Application_Links *app, View_Summary *view, View_Setting_ID setting)
|
||||||
#define VIEW_SET_SETTING_SIG(n) bool32 n(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value)
|
#define VIEW_SET_SETTING_SIG(n) bool32 n(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value)
|
||||||
#define VIEW_SET_SPLIT_PROPORTION_SIG(n) bool32 n(Application_Links *app, View_Summary *view, float t)
|
#define VIEW_SET_SPLIT_PROPORTION_SIG(n) bool32 n(Application_Links *app, View_Summary *view, float t)
|
||||||
#define VIEW_COMPUTE_CURSOR_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out)
|
#define VIEW_COMPUTE_CURSOR_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out)
|
||||||
|
@ -87,6 +88,7 @@ typedef GET_ACTIVE_VIEW_SIG(Get_Active_View_Function);
|
||||||
typedef OPEN_VIEW_SIG(Open_View_Function);
|
typedef OPEN_VIEW_SIG(Open_View_Function);
|
||||||
typedef CLOSE_VIEW_SIG(Close_View_Function);
|
typedef CLOSE_VIEW_SIG(Close_View_Function);
|
||||||
typedef SET_ACTIVE_VIEW_SIG(Set_Active_View_Function);
|
typedef SET_ACTIVE_VIEW_SIG(Set_Active_View_Function);
|
||||||
|
typedef VIEW_GET_SETTING_SIG(View_Get_Setting_Function);
|
||||||
typedef VIEW_SET_SETTING_SIG(View_Set_Setting_Function);
|
typedef VIEW_SET_SETTING_SIG(View_Set_Setting_Function);
|
||||||
typedef VIEW_SET_SPLIT_PROPORTION_SIG(View_Set_Split_Proportion_Function);
|
typedef VIEW_SET_SPLIT_PROPORTION_SIG(View_Set_Split_Proportion_Function);
|
||||||
typedef VIEW_COMPUTE_CURSOR_SIG(View_Compute_Cursor_Function);
|
typedef VIEW_COMPUTE_CURSOR_SIG(View_Compute_Cursor_Function);
|
||||||
|
@ -150,6 +152,7 @@ Get_Active_View_Function *get_active_view;
|
||||||
Open_View_Function *open_view;
|
Open_View_Function *open_view;
|
||||||
Close_View_Function *close_view;
|
Close_View_Function *close_view;
|
||||||
Set_Active_View_Function *set_active_view;
|
Set_Active_View_Function *set_active_view;
|
||||||
|
View_Get_Setting_Function *view_get_setting;
|
||||||
View_Set_Setting_Function *view_set_setting;
|
View_Set_Setting_Function *view_set_setting;
|
||||||
View_Set_Split_Proportion_Function *view_set_split_proportion;
|
View_Set_Split_Proportion_Function *view_set_split_proportion;
|
||||||
View_Compute_Cursor_Function *view_compute_cursor;
|
View_Compute_Cursor_Function *view_compute_cursor;
|
||||||
|
@ -212,6 +215,7 @@ Get_Active_View_Function *get_active_view_;
|
||||||
Open_View_Function *open_view_;
|
Open_View_Function *open_view_;
|
||||||
Close_View_Function *close_view_;
|
Close_View_Function *close_view_;
|
||||||
Set_Active_View_Function *set_active_view_;
|
Set_Active_View_Function *set_active_view_;
|
||||||
|
View_Get_Setting_Function *view_get_setting_;
|
||||||
View_Set_Setting_Function *view_set_setting_;
|
View_Set_Setting_Function *view_set_setting_;
|
||||||
View_Set_Split_Proportion_Function *view_set_split_proportion_;
|
View_Set_Split_Proportion_Function *view_set_split_proportion_;
|
||||||
View_Compute_Cursor_Function *view_compute_cursor_;
|
View_Compute_Cursor_Function *view_compute_cursor_;
|
||||||
|
@ -282,6 +286,7 @@ app_links->get_active_view_ = Get_Active_View;\
|
||||||
app_links->open_view_ = Open_View;\
|
app_links->open_view_ = Open_View;\
|
||||||
app_links->close_view_ = Close_View;\
|
app_links->close_view_ = Close_View;\
|
||||||
app_links->set_active_view_ = Set_Active_View;\
|
app_links->set_active_view_ = Set_Active_View;\
|
||||||
|
app_links->view_get_setting_ = View_Get_Setting;\
|
||||||
app_links->view_set_setting_ = View_Set_Setting;\
|
app_links->view_set_setting_ = View_Set_Setting;\
|
||||||
app_links->view_set_split_proportion_ = View_Set_Split_Proportion;\
|
app_links->view_set_split_proportion_ = View_Set_Split_Proportion;\
|
||||||
app_links->view_compute_cursor_ = View_Compute_Cursor;\
|
app_links->view_compute_cursor_ = View_Compute_Cursor;\
|
||||||
|
@ -344,6 +349,7 @@ static inline View_Summary get_active_view(Application_Links *app, Access_Flag a
|
||||||
static inline View_Summary open_view(Application_Links *app, View_Summary *view_location, View_Split_Position position){return(app->open_view(app, view_location, position));}
|
static inline View_Summary open_view(Application_Links *app, View_Summary *view_location, View_Split_Position position){return(app->open_view(app, view_location, position));}
|
||||||
static inline bool32 close_view(Application_Links *app, View_Summary *view){return(app->close_view(app, view));}
|
static inline bool32 close_view(Application_Links *app, View_Summary *view){return(app->close_view(app, view));}
|
||||||
static inline bool32 set_active_view(Application_Links *app, View_Summary *view){return(app->set_active_view(app, view));}
|
static inline bool32 set_active_view(Application_Links *app, View_Summary *view){return(app->set_active_view(app, view));}
|
||||||
|
static inline int32_t view_get_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting){return(app->view_get_setting(app, view, setting));}
|
||||||
static inline bool32 view_set_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value){return(app->view_set_setting(app, view, setting, value));}
|
static inline bool32 view_set_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value){return(app->view_set_setting(app, view, setting, value));}
|
||||||
static inline bool32 view_set_split_proportion(Application_Links *app, View_Summary *view, float t){return(app->view_set_split_proportion(app, view, t));}
|
static inline bool32 view_set_split_proportion(Application_Links *app, View_Summary *view, float t){return(app->view_set_split_proportion(app, view, t));}
|
||||||
static inline bool32 view_compute_cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out){return(app->view_compute_cursor(app, view, seek, cursor_out));}
|
static inline bool32 view_compute_cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out){return(app->view_compute_cursor(app, view, seek, cursor_out));}
|
||||||
|
@ -406,6 +412,7 @@ static inline View_Summary get_active_view(Application_Links *app, Access_Flag a
|
||||||
static inline View_Summary open_view(Application_Links *app, View_Summary *view_location, View_Split_Position position){return(app->open_view_(app, view_location, position));}
|
static inline View_Summary open_view(Application_Links *app, View_Summary *view_location, View_Split_Position position){return(app->open_view_(app, view_location, position));}
|
||||||
static inline bool32 close_view(Application_Links *app, View_Summary *view){return(app->close_view_(app, view));}
|
static inline bool32 close_view(Application_Links *app, View_Summary *view){return(app->close_view_(app, view));}
|
||||||
static inline bool32 set_active_view(Application_Links *app, View_Summary *view){return(app->set_active_view_(app, view));}
|
static inline bool32 set_active_view(Application_Links *app, View_Summary *view){return(app->set_active_view_(app, view));}
|
||||||
|
static inline int32_t view_get_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting){return(app->view_get_setting_(app, view, setting));}
|
||||||
static inline bool32 view_set_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value){return(app->view_set_setting_(app, view, setting, value));}
|
static inline bool32 view_set_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value){return(app->view_set_setting_(app, view, setting, value));}
|
||||||
static inline bool32 view_set_split_proportion(Application_Links *app, View_Summary *view, float t){return(app->view_set_split_proportion_(app, view, t));}
|
static inline bool32 view_set_split_proportion(Application_Links *app, View_Summary *view, float t){return(app->view_set_split_proportion_(app, view, t));}
|
||||||
static inline bool32 view_compute_cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out){return(app->view_compute_cursor_(app, view, seek, cursor_out));}
|
static inline bool32 view_compute_cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out){return(app->view_compute_cursor_(app, view, seek, cursor_out));}
|
||||||
|
|
|
@ -401,6 +401,9 @@ default_keys(Bind_Helper *context){
|
||||||
bind(context, '1', MDFR_CTRL, eol_dosify);
|
bind(context, '1', MDFR_CTRL, eol_dosify);
|
||||||
bind(context, '!', MDFR_CTRL, eol_nixify);
|
bind(context, '!', MDFR_CTRL, eol_nixify);
|
||||||
|
|
||||||
|
bind(context, '2', MDFR_CTRL, decrease_line_wrap);
|
||||||
|
bind(context, '3', MDFR_CTRL, increase_line_wrap);
|
||||||
|
|
||||||
bind(context, '?', MDFR_CTRL, toggle_show_whitespace);
|
bind(context, '?', MDFR_CTRL, toggle_show_whitespace);
|
||||||
bind(context, '~', MDFR_CTRL, clean_all_lines);
|
bind(context, '~', MDFR_CTRL, clean_all_lines);
|
||||||
bind(context, '\n', MDFR_NONE, newline_or_goto_position);
|
bind(context, '\n', MDFR_NONE, newline_or_goto_position);
|
||||||
|
|
|
@ -2662,6 +2662,18 @@ CUSTOM_COMMAND_SIG(toggle_line_wrap){
|
||||||
buffer_set_setting(app, &buffer, BufferSetting_WrapLine, unwrapped);
|
buffer_set_setting(app, &buffer, BufferSetting_WrapLine, unwrapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CUSTOM_COMMAND_SIG(increase_line_wrap){
|
||||||
|
View_Summary view = get_active_view(app, AccessProtected);
|
||||||
|
int32_t wrap = view_get_setting(app, &view, ViewSetting_WrapPosition);
|
||||||
|
view_set_setting(app, &view, ViewSetting_WrapPosition, wrap + 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
CUSTOM_COMMAND_SIG(decrease_line_wrap){
|
||||||
|
View_Summary view = get_active_view(app, AccessProtected);
|
||||||
|
int32_t wrap = view_get_setting(app, &view, ViewSetting_WrapPosition);
|
||||||
|
view_set_setting(app, &view, ViewSetting_WrapPosition, wrap - 10);
|
||||||
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(toggle_show_whitespace){
|
CUSTOM_COMMAND_SIG(toggle_show_whitespace){
|
||||||
View_Summary view = get_active_view(app, AccessProtected);
|
View_Summary view = get_active_view(app, AccessProtected);
|
||||||
view_set_setting(app, &view, ViewSetting_ShowWhitespace, !view.show_whitespace);
|
view_set_setting(app, &view, ViewSetting_ShowWhitespace, !view.show_whitespace);
|
||||||
|
|
|
@ -155,7 +155,7 @@ ENUM(int32_t, Buffer_Setting_ID){
|
||||||
BufferSetting_ReadOnly,
|
BufferSetting_ReadOnly,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* DOC(A View_Setting_ID names a setting in a view.) */
|
/* DOC(A View_Setting_ID names an adjustable setting in a view.) */
|
||||||
ENUM(int32_t, View_Setting_ID){
|
ENUM(int32_t, View_Setting_ID){
|
||||||
/* DOC(ViewSetting_Null is not a valid setting, it is reserved to detect errors.) */
|
/* DOC(ViewSetting_Null is not a valid setting, it is reserved to detect errors.) */
|
||||||
ViewSetting_Null,
|
ViewSetting_Null,
|
||||||
|
@ -165,6 +165,15 @@ ENUM(int32_t, View_Setting_ID){
|
||||||
will reset this setting to match the 'preferred' line wrapping setting of the buffer.) */
|
will reset this setting to match the 'preferred' line wrapping setting of the buffer.) */
|
||||||
ViewSetting_WrapLine,
|
ViewSetting_WrapLine,
|
||||||
|
|
||||||
|
/* DOC(The ViewSetting_WrapPosition setting determines after how many pixels
|
||||||
|
a line will wrap. A view set's this value from the global default value
|
||||||
|
when the view is created. The global default can be changed at startup with
|
||||||
|
a flag (TODO). This value cannot be set to less than 48, any value passed
|
||||||
|
below 48 will cause the position to be set to 48. This is a potentially expensive
|
||||||
|
operation because the wrap positions of the file have to be reindexed, for
|
||||||
|
best behavior try to only set this setting once per frame, if possible.) */
|
||||||
|
ViewSetting_WrapPosition,
|
||||||
|
|
||||||
/* DOC(The ViewSetting_ShowWhitespace setting determines whether the view highlights
|
/* DOC(The ViewSetting_ShowWhitespace setting determines whether the view highlights
|
||||||
whitespace in a file. Whenever the view switches to a new buffer this setting is turned off.) */
|
whitespace in a file. Whenever the view switches to a new buffer this setting is turned off.) */
|
||||||
ViewSetting_ShowWhitespace,
|
ViewSetting_ShowWhitespace,
|
||||||
|
@ -172,6 +181,7 @@ ENUM(int32_t, View_Setting_ID){
|
||||||
/* DOC(The ViewSetting_ShowScrollbar setting determines whether a scroll bar is
|
/* DOC(The ViewSetting_ShowScrollbar setting determines whether a scroll bar is
|
||||||
attached to a view in it's scrollable section.) */
|
attached to a view in it's scrollable section.) */
|
||||||
ViewSetting_ShowScrollbar,
|
ViewSetting_ShowScrollbar,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* DOC(A Buffer_Create_Flag field specifies how a buffer should be created.) */
|
/* DOC(A Buffer_Create_Flag field specifies how a buffer should be created.) */
|
||||||
|
|
52
4ed.cpp
52
4ed.cpp
|
@ -39,6 +39,7 @@ typedef struct Command_Data{
|
||||||
System_Functions *system;
|
System_Functions *system;
|
||||||
Live_Views *live_set;
|
Live_Views *live_set;
|
||||||
|
|
||||||
|
// TODO(allen): eliminate this shit yo!
|
||||||
Panel *panel;
|
Panel *panel;
|
||||||
View *view;
|
View *view;
|
||||||
|
|
||||||
|
@ -1121,7 +1122,7 @@ enum Command_Line_Action{
|
||||||
CLAct_WindowFullscreen,
|
CLAct_WindowFullscreen,
|
||||||
CLAct_WindowStreamMode,
|
CLAct_WindowStreamMode,
|
||||||
CLAct_FontSize,
|
CLAct_FontSize,
|
||||||
CLAct_FontStopHinting,
|
CLAct_FontStartHinting,
|
||||||
CLAct_Count
|
CLAct_Count
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1167,11 +1168,11 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
||||||
if (arg[0] == '-'){
|
if (arg[0] == '-'){
|
||||||
action = CLAct_Ignore;
|
action = CLAct_Ignore;
|
||||||
switch (arg[1]){
|
switch (arg[1]){
|
||||||
case 'u': action = CLAct_UserFile; strict = false; break;
|
case 'u': action = CLAct_UserFile; strict = 0; break;
|
||||||
case 'U': action = CLAct_UserFile; strict = true; break;
|
case 'U': action = CLAct_UserFile; strict = 1; break;
|
||||||
|
|
||||||
case 'd': action = CLAct_CustomDLL; strict = false; break;
|
case 'd': action = CLAct_CustomDLL; strict = 0; break;
|
||||||
case 'D': action = CLAct_CustomDLL; strict = true; break;
|
case 'D': action = CLAct_CustomDLL; strict = 1; break;
|
||||||
|
|
||||||
case 'i': action = CLAct_InitialFilePosition; break;
|
case 'i': action = CLAct_InitialFilePosition; break;
|
||||||
|
|
||||||
|
@ -1182,7 +1183,7 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
||||||
case 'S': action = CLAct_WindowStreamMode; break;
|
case 'S': action = CLAct_WindowStreamMode; break;
|
||||||
|
|
||||||
case 'f': action = CLAct_FontSize; break;
|
case 'f': action = CLAct_FontSize; break;
|
||||||
case 'h': action = CLAct_FontStopHinting; --i; break;
|
case 'h': action = CLAct_FontStartHinting; --i; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (arg[0] != 0){
|
else if (arg[0] != 0){
|
||||||
|
@ -1222,7 +1223,7 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
||||||
case CLAct_WindowSize:
|
case CLAct_WindowSize:
|
||||||
{
|
{
|
||||||
if (i + 1 < clparams.argc){
|
if (i + 1 < clparams.argc){
|
||||||
plat_settings->set_window_size = true;
|
plat_settings->set_window_size = 1;
|
||||||
plat_settings->window_w = str_to_int_c(clparams.argv[i]);
|
plat_settings->window_w = str_to_int_c(clparams.argv[i]);
|
||||||
plat_settings->window_h = str_to_int_c(clparams.argv[i+1]);
|
plat_settings->window_h = str_to_int_c(clparams.argv[i+1]);
|
||||||
|
|
||||||
|
@ -1234,14 +1235,14 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
||||||
case CLAct_WindowMaximize:
|
case CLAct_WindowMaximize:
|
||||||
{
|
{
|
||||||
--i;
|
--i;
|
||||||
plat_settings->maximize_window = true;
|
plat_settings->maximize_window = 1;
|
||||||
action = CLAct_Nothing;
|
action = CLAct_Nothing;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case CLAct_WindowPosition:
|
case CLAct_WindowPosition:
|
||||||
{
|
{
|
||||||
if (i + 1 < clparams.argc){
|
if (i + 1 < clparams.argc){
|
||||||
plat_settings->set_window_pos = true;
|
plat_settings->set_window_pos = 1;
|
||||||
plat_settings->window_x = str_to_int_c(clparams.argv[i]);
|
plat_settings->window_x = str_to_int_c(clparams.argv[i]);
|
||||||
plat_settings->window_y = str_to_int_c(clparams.argv[i+1]);
|
plat_settings->window_y = str_to_int_c(clparams.argv[i+1]);
|
||||||
|
|
||||||
|
@ -1253,15 +1254,15 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
||||||
case CLAct_WindowFullscreen:
|
case CLAct_WindowFullscreen:
|
||||||
{
|
{
|
||||||
--i;
|
--i;
|
||||||
plat_settings->fullscreen_window = true;
|
plat_settings->fullscreen_window = 1;
|
||||||
plat_settings->stream_mode = true;
|
plat_settings->stream_mode = 1;
|
||||||
action = CLAct_Nothing;
|
action = CLAct_Nothing;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case CLAct_WindowStreamMode:
|
case CLAct_WindowStreamMode:
|
||||||
{
|
{
|
||||||
--i;
|
--i;
|
||||||
plat_settings->stream_mode = true;
|
plat_settings->stream_mode = 1;
|
||||||
action = CLAct_Nothing;
|
action = CLAct_Nothing;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
@ -1273,9 +1274,9 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
||||||
action = CLAct_Nothing;
|
action = CLAct_Nothing;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case CLAct_FontStopHinting:
|
case CLAct_FontStartHinting:
|
||||||
{
|
{
|
||||||
plat_settings->use_hinting = true;
|
plat_settings->use_hinting = 1;
|
||||||
action = CLAct_Nothing;
|
action = CLAct_Nothing;
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
|
@ -1348,17 +1349,16 @@ extern "C" SCROLL_RULE_SIG(fallback_scroll_rule){
|
||||||
}
|
}
|
||||||
|
|
||||||
App_Init_Sig(app_init){
|
App_Init_Sig(app_init){
|
||||||
App_Vars *vars;
|
|
||||||
Models *models;
|
|
||||||
Partition *partition;
|
Partition *partition;
|
||||||
Panel *panels, *panel;
|
Panel *panels, *panel;
|
||||||
Panel_Divider *dividers, *div;
|
Panel_Divider *dividers, *div;
|
||||||
i32 panel_max_count;
|
i32 panel_max_count;
|
||||||
i32 divider_max_count;
|
i32 divider_max_count;
|
||||||
|
|
||||||
vars = (App_Vars*)memory->vars_memory;
|
App_Vars *vars = (App_Vars*)memory->vars_memory;
|
||||||
models = &vars->models;
|
Models *models = &vars->models;
|
||||||
models->keep_playing = 1;
|
models->keep_playing = 1;
|
||||||
|
models->default_display_width = 672;
|
||||||
|
|
||||||
app_links_init(system, &models->app_links, memory->user_memory, memory->user_memory_size);
|
app_links_init(system, &models->app_links, memory->user_memory, memory->user_memory_size);
|
||||||
|
|
||||||
|
@ -2746,22 +2746,6 @@ App_Step_Sig(app_step){
|
||||||
|
|
||||||
end_temp_memory(param_stack_temp);
|
end_temp_memory(param_stack_temp);
|
||||||
|
|
||||||
// NOTE(allen): send resize messages to panels that have changed size
|
|
||||||
{
|
|
||||||
Panel *panel = 0, *used_panels = 0;
|
|
||||||
|
|
||||||
used_panels = &models->layout.used_sentinel;
|
|
||||||
for (dll_items(panel, used_panels)){
|
|
||||||
View *view = panel->view;
|
|
||||||
i32_Rect prev = view->file_region_prev;
|
|
||||||
i32_Rect region = view->file_region;
|
|
||||||
if (!rect_equal(prev, region)){
|
|
||||||
remeasure_file_view(system, panel->view);
|
|
||||||
}
|
|
||||||
view->file_region_prev = region;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE(allen): on the first frame there should be no scrolling
|
// NOTE(allen): on the first frame there should be no scrolling
|
||||||
if (input->first_step){
|
if (input->first_step){
|
||||||
Panel *panel = 0, *used_panels = &models->layout.used_sentinel;
|
Panel *panel = 0, *used_panels = &models->layout.used_sentinel;
|
||||||
|
|
|
@ -1377,6 +1377,25 @@ DOC_SEE(get_active_view)
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
API_EXPORT int32_t
|
||||||
|
View_Get_Setting(Application_Links *app, View_Summary *view, View_Setting_ID setting){
|
||||||
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
|
System_Functions *system = cmd->system;
|
||||||
|
View *vptr = imp_get_view(cmd, view);
|
||||||
|
int32_t result = -1;
|
||||||
|
|
||||||
|
if (vptr){
|
||||||
|
switch (setting){
|
||||||
|
case ViewSetting_WrapLine: result = !vptr->file_data.unwrapped_lines; break;
|
||||||
|
case ViewSetting_WrapPosition: result = vptr->display_width; break;
|
||||||
|
case ViewSetting_ShowWhitespace: result = vptr->file_data.show_whitespace; break;
|
||||||
|
case ViewSetting_ShowScrollbar: result = !vptr->hide_scrollbar; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
API_EXPORT bool32
|
API_EXPORT bool32
|
||||||
View_Set_Setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value)/*
|
View_Set_Setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value)/*
|
||||||
DOC_PARAM(view, The view parameter specifies the view on which to set a setting.)
|
DOC_PARAM(view, The view parameter specifies the view on which to set a setting.)
|
||||||
|
@ -1386,6 +1405,7 @@ DOC_RETURN(This call returns non-zero on success.)
|
||||||
DOC_SEE(View_Setting_ID)
|
DOC_SEE(View_Setting_ID)
|
||||||
*/{
|
*/{
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
|
System_Functions *system = cmd->system;
|
||||||
View *vptr = imp_get_view(cmd, view);
|
View *vptr = imp_get_view(cmd, view);
|
||||||
bool32 result = false;
|
bool32 result = false;
|
||||||
|
|
||||||
|
@ -1412,6 +1432,18 @@ DOC_SEE(View_Setting_ID)
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
case ViewSetting_WrapPosition:
|
||||||
|
{
|
||||||
|
if (value < 48){
|
||||||
|
value = 48;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value != vptr->display_width){
|
||||||
|
vptr->display_width = value;
|
||||||
|
remeasure_file_view(system, vptr);
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
|
||||||
case ViewSetting_ShowWhitespace:
|
case ViewSetting_ShowWhitespace:
|
||||||
{
|
{
|
||||||
vptr->file_data.show_whitespace = value;
|
vptr->file_data.show_whitespace = value;
|
||||||
|
|
|
@ -80,6 +80,7 @@ struct Models{
|
||||||
struct Live_Views *live_set;
|
struct Live_Views *live_set;
|
||||||
Editing_File *message_buffer;
|
Editing_File *message_buffer;
|
||||||
Editing_File *scratch_buffer;
|
Editing_File *scratch_buffer;
|
||||||
|
f32 default_display_width;
|
||||||
|
|
||||||
char hot_dir_base_[256];
|
char hot_dir_base_[256];
|
||||||
Hot_Directory hot_directory;
|
Hot_Directory hot_directory;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* Mr. 4th Dimention - Allen Webster
|
* Mr. 4th Dimention - Allen Webster
|
||||||
*
|
*
|
||||||
* 19.08.2015
|
* 19.08.2015
|
||||||
*
|
*
|
||||||
* File editing view for 4coder
|
* File editing view for 4coder
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TOP
|
// TOP
|
||||||
|
|
||||||
|
@ -252,6 +252,7 @@ struct View{
|
||||||
// misc
|
// misc
|
||||||
i32 line_height;
|
i32 line_height;
|
||||||
|
|
||||||
|
// TODO(allen): Do I still use mode?
|
||||||
View_Mode mode, next_mode;
|
View_Mode mode, next_mode;
|
||||||
Query_Set query_set;
|
Query_Set query_set;
|
||||||
f32 widget_height;
|
f32 widget_height;
|
||||||
|
@ -259,7 +260,10 @@ struct View{
|
||||||
b32 reinit_scrolling;
|
b32 reinit_scrolling;
|
||||||
|
|
||||||
Debug_Vars debug_vars;
|
Debug_Vars debug_vars;
|
||||||
|
|
||||||
|
i32 display_width;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void*
|
inline void*
|
||||||
get_view_body(View *view){
|
get_view_body(View *view){
|
||||||
char *result = (char*)view;
|
char *result = (char*)view;
|
||||||
|
@ -271,15 +275,20 @@ get_view_size(){
|
||||||
return(sizeof(View) - sizeof(View_Persistent));
|
return(sizeof(View) - sizeof(View_Persistent));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(allen): Switch over to using an i32 instead of
|
// TODO(past-allen): Switch over to using an i32 for these.
|
||||||
// an f32 for these.
|
|
||||||
inline f32
|
inline f32
|
||||||
view_file_width(View *view){
|
view_width(View *view){
|
||||||
i32_Rect file_rect = view->file_region;
|
i32_Rect file_rect = view->file_region;
|
||||||
f32 result = (f32)(file_rect.x1 - file_rect.x0);
|
f32 result = (f32)(file_rect.x1 - file_rect.x0);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline f32
|
||||||
|
view_file_display_width(View *view){
|
||||||
|
f32 result = view->display_width;
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
inline f32
|
inline f32
|
||||||
view_file_height(View *view){
|
view_file_height(View *view){
|
||||||
i32_Rect file_rect = view->file_region;
|
i32_Rect file_rect = view->file_region;
|
||||||
|
@ -391,7 +400,7 @@ file_compute_cursor_from_line_character(Editing_File *file, i32 line, i32 charac
|
||||||
|
|
||||||
inline b32
|
inline b32
|
||||||
file_compute_cursor(Editing_File *file, Buffer_Seek seek, Partial_Cursor *cursor){
|
file_compute_cursor(Editing_File *file, Buffer_Seek seek, Partial_Cursor *cursor){
|
||||||
b32 result = true;
|
b32 result = 1;
|
||||||
switch (seek.type){
|
switch (seek.type){
|
||||||
case buffer_seek_pos:
|
case buffer_seek_pos:
|
||||||
{
|
{
|
||||||
|
@ -405,7 +414,7 @@ file_compute_cursor(Editing_File *file, Buffer_Seek seek, Partial_Cursor *cursor
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
result = false;
|
result = 0;
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
|
@ -419,7 +428,7 @@ view_compute_cursor_from_pos(View *view, i32 pos){
|
||||||
|
|
||||||
Full_Cursor result = {};
|
Full_Cursor result = {};
|
||||||
if (font){
|
if (font){
|
||||||
f32 max_width = view_file_width(view);
|
f32 max_width = view_file_display_width(view);
|
||||||
result = buffer_cursor_from_pos(&file->state.buffer, pos, view->file_data.line_wrap_y,
|
result = buffer_cursor_from_pos(&file->state.buffer, pos, view->file_data.line_wrap_y,
|
||||||
max_width, (f32)view->line_height, font->advance_data);
|
max_width, (f32)view->line_height, font->advance_data);
|
||||||
}
|
}
|
||||||
|
@ -434,7 +443,7 @@ view_compute_cursor_from_unwrapped_xy(View *view, f32 seek_x, f32 seek_y, b32 ro
|
||||||
|
|
||||||
Full_Cursor result = {};
|
Full_Cursor result = {};
|
||||||
if (font){
|
if (font){
|
||||||
f32 max_width = view_file_width(view);
|
f32 max_width = view_file_display_width(view);
|
||||||
result = buffer_cursor_from_unwrapped_xy(&file->state.buffer, seek_x, seek_y,
|
result = buffer_cursor_from_unwrapped_xy(&file->state.buffer, seek_x, seek_y,
|
||||||
round_down, view->file_data.line_wrap_y, max_width, (f32)view->line_height, font->advance_data);
|
round_down, view->file_data.line_wrap_y, max_width, (f32)view->line_height, font->advance_data);
|
||||||
}
|
}
|
||||||
|
@ -450,7 +459,7 @@ view_compute_cursor_from_wrapped_xy(View *view, f32 seek_x, f32 seek_y, b32 roun
|
||||||
|
|
||||||
Full_Cursor result = {};
|
Full_Cursor result = {};
|
||||||
if (font){
|
if (font){
|
||||||
f32 max_width = view_file_width(view);
|
f32 max_width = view_file_display_width(view);
|
||||||
result = buffer_cursor_from_wrapped_xy(&file->state.buffer, seek_x, seek_y,
|
result = buffer_cursor_from_wrapped_xy(&file->state.buffer, seek_x, seek_y,
|
||||||
round_down, view->file_data.line_wrap_y,
|
round_down, view->file_data.line_wrap_y,
|
||||||
max_width, (f32)view->line_height, font->advance_data);
|
max_width, (f32)view->line_height, font->advance_data);
|
||||||
|
@ -467,7 +476,7 @@ view_compute_cursor_from_line_pos(View *view, i32 line, i32 pos){
|
||||||
|
|
||||||
Full_Cursor result = {};
|
Full_Cursor result = {};
|
||||||
if (font){
|
if (font){
|
||||||
f32 max_width = view_file_width(view);
|
f32 max_width = view_file_display_width(view);
|
||||||
result = buffer_cursor_from_line_character(&file->state.buffer, line, pos,
|
result = buffer_cursor_from_line_character(&file->state.buffer, line, pos,
|
||||||
view->file_data.line_wrap_y, max_width, (f32)view->line_height, font->advance_data);
|
view->file_data.line_wrap_y, max_width, (f32)view->line_height, font->advance_data);
|
||||||
}
|
}
|
||||||
|
@ -503,8 +512,12 @@ view_compute_cursor(View *view, Buffer_Seek seek){
|
||||||
inline Full_Cursor
|
inline Full_Cursor
|
||||||
view_compute_cursor_from_xy(View *view, f32 seek_x, f32 seek_y){
|
view_compute_cursor_from_xy(View *view, f32 seek_x, f32 seek_y){
|
||||||
Full_Cursor result;
|
Full_Cursor result;
|
||||||
if (view->file_data.unwrapped_lines) result = view_compute_cursor_from_unwrapped_xy(view, seek_x, seek_y);
|
if (view->file_data.unwrapped_lines){
|
||||||
else result = view_compute_cursor_from_wrapped_xy(view, seek_x, seek_y);
|
result = view_compute_cursor_from_unwrapped_xy(view, seek_x, seek_y);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
result = view_compute_cursor_from_wrapped_xy(view, seek_x, seek_y);
|
||||||
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,7 +539,7 @@ view_compute_lowest_line(View *view){
|
||||||
else{
|
else{
|
||||||
f32 wrap_y = view->file_data.line_wrap_y[last_line];
|
f32 wrap_y = view->file_data.line_wrap_y[last_line];
|
||||||
lowest_line = FLOOR32(wrap_y / view->line_height);
|
lowest_line = FLOOR32(wrap_y / view->line_height);
|
||||||
f32 max_width = view_file_width(view);
|
f32 max_width = view_file_display_width(view);
|
||||||
|
|
||||||
Editing_File *file = view->file_data.file;
|
Editing_File *file = view->file_data.file;
|
||||||
Assert(!file->is_dummy);
|
Assert(!file->is_dummy);
|
||||||
|
@ -556,8 +569,8 @@ view_compute_max_target_y(View *view){
|
||||||
|
|
||||||
internal b32
|
internal b32
|
||||||
view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll, b32 center_view){
|
view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll, b32 center_view){
|
||||||
b32 result = false;
|
b32 result = 0;
|
||||||
f32 max_x = view_file_width(view);
|
f32 max_x = view_width(view);
|
||||||
i32 max_y = view_compute_max_target_y(view);
|
i32 max_y = view_compute_max_target_y(view);
|
||||||
|
|
||||||
f32 cursor_y = view_get_cursor_y(view);
|
f32 cursor_y = view_get_cursor_y(view);
|
||||||
|
@ -598,7 +611,7 @@ view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll, b32 center_view){
|
||||||
if (target_x != scroll_vars.target_x || target_y != scroll_vars.target_y){
|
if (target_x != scroll_vars.target_x || target_y != scroll_vars.target_y){
|
||||||
scroll->target_x = target_x;
|
scroll->target_x = target_x;
|
||||||
scroll->target_y = target_y;
|
scroll->target_y = target_y;
|
||||||
result = true;
|
result = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
|
@ -607,7 +620,7 @@ view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll, b32 center_view){
|
||||||
internal b32
|
internal b32
|
||||||
view_move_cursor_to_view(View *view, GUI_Scroll_Vars scroll,
|
view_move_cursor_to_view(View *view, GUI_Scroll_Vars scroll,
|
||||||
Full_Cursor *cursor, f32 preferred_x){
|
Full_Cursor *cursor, f32 preferred_x){
|
||||||
b32 result = false;
|
b32 result = 0;
|
||||||
|
|
||||||
if (view->edit_pos){
|
if (view->edit_pos){
|
||||||
i32 line_height = view->line_height;
|
i32 line_height = view->line_height;
|
||||||
|
@ -638,7 +651,7 @@ view_move_cursor_to_view(View *view, GUI_Scroll_Vars scroll,
|
||||||
*cursor = view_compute_cursor_from_xy(
|
*cursor = view_compute_cursor_from_xy(
|
||||||
view, preferred_x, cursor_y);
|
view, preferred_x, cursor_y);
|
||||||
|
|
||||||
result = true;
|
result = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,7 +665,7 @@ view_set_cursor(View *view, Full_Cursor cursor,
|
||||||
edit_pos_set_cursor_(view->edit_pos, cursor, set_preferred_x, unwrapped_lines);
|
edit_pos_set_cursor_(view->edit_pos, cursor, set_preferred_x, unwrapped_lines);
|
||||||
|
|
||||||
GUI_Scroll_Vars scroll = view->edit_pos->scroll;
|
GUI_Scroll_Vars scroll = view->edit_pos->scroll;
|
||||||
if (view_move_view_to_cursor(view, &scroll, false)){
|
if (view_move_view_to_cursor(view, &scroll, 0)){
|
||||||
view->edit_pos->scroll = scroll;
|
view->edit_pos->scroll = scroll;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -997,7 +1010,7 @@ view_measure_wraps(General_Memory *general, View *view){
|
||||||
}
|
}
|
||||||
|
|
||||||
f32 line_height = (f32)view->line_height;
|
f32 line_height = (f32)view->line_height;
|
||||||
f32 max_width = view_file_width(view);
|
f32 max_width = view_file_display_width(view);
|
||||||
buffer_measure_wrap_y(buffer, view->file_data.line_wrap_y, line_height, max_width);
|
buffer_measure_wrap_y(buffer, view->file_data.line_wrap_y, line_height, max_width);
|
||||||
|
|
||||||
view->file_data.line_count = line_count;
|
view->file_data.line_count = line_count;
|
||||||
|
@ -1266,10 +1279,10 @@ file_relex_parallel(System_Functions *system,
|
||||||
|
|
||||||
if (file->state.token_array.tokens == 0){
|
if (file->state.token_array.tokens == 0){
|
||||||
file_first_lex_parallel(system, general, file);
|
file_first_lex_parallel(system, general, file);
|
||||||
return(false);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
b32 result = true;
|
b32 result = 1;
|
||||||
b32 inline_lex = !file->state.still_lexing;
|
b32 inline_lex = !file->state.still_lexing;
|
||||||
if (inline_lex){
|
if (inline_lex){
|
||||||
Buffer_Type *buffer = &file->state.buffer;
|
Buffer_Type *buffer = &file->state.buffer;
|
||||||
|
@ -1384,7 +1397,7 @@ file_relex_parallel(System_Functions *system,
|
||||||
job.data[0] = file;
|
job.data[0] = file;
|
||||||
job.data[1] = general;
|
job.data[1] = general;
|
||||||
file->state.lex_job = system->post_job(BACKGROUND_THREADS, job);
|
file->state.lex_job = system->post_job(BACKGROUND_THREADS, job);
|
||||||
result = false;
|
result = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
|
@ -1670,7 +1683,7 @@ view_set_temp_highlight(View *view, i32 pos, i32 end_pos){
|
||||||
view->file_data.show_temp_highlight = 1;
|
view->file_data.show_temp_highlight = 1;
|
||||||
|
|
||||||
view_set_cursor(view, view->file_data.temp_highlight,
|
view_set_cursor(view, view->file_data.temp_highlight,
|
||||||
false, view->file_data.unwrapped_lines);
|
0, view->file_data.unwrapped_lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
|
@ -1751,7 +1764,7 @@ view_set_relative_scrolling(View *view, Relative_Scrolling scrolling){
|
||||||
inline void
|
inline void
|
||||||
view_cursor_move(View *view, Full_Cursor cursor){
|
view_cursor_move(View *view, Full_Cursor cursor){
|
||||||
view_set_cursor(view, cursor,
|
view_set_cursor(view, cursor,
|
||||||
true, view->file_data.unwrapped_lines);
|
1, view->file_data.unwrapped_lines);
|
||||||
view->file_data.show_temp_highlight = 0;
|
view->file_data.show_temp_highlight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2061,7 +2074,7 @@ file_edit_cursor_fix(System_Functions *system,
|
||||||
}
|
}
|
||||||
|
|
||||||
view_set_cursor_and_scroll(view, new_cursor,
|
view_set_cursor_and_scroll(view, new_cursor,
|
||||||
true, view->file_data.unwrapped_lines,
|
1, view->file_data.unwrapped_lines,
|
||||||
scroll);
|
scroll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2707,7 +2720,7 @@ view_show_file(View *view){
|
||||||
|
|
||||||
if (view->showing_ui != VUI_None){
|
if (view->showing_ui != VUI_None){
|
||||||
view->showing_ui = VUI_None;
|
view->showing_ui = VUI_None;
|
||||||
view->changed_context_in_step = true;
|
view->changed_context_in_step = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2946,7 +2959,7 @@ interactive_try_kill_file(System_Functions *system, Models *models, View *view,
|
||||||
|
|
||||||
internal b32
|
internal b32
|
||||||
interactive_try_kill_file_by_name(System_Functions *system, Models *models, View *view, String name){
|
interactive_try_kill_file_by_name(System_Functions *system, Models *models, View *view, String name){
|
||||||
b32 kill_dialogue = false;
|
b32 kill_dialogue = 0;
|
||||||
|
|
||||||
Editing_File *file = working_set_name_contains(&models->working_set, name);
|
Editing_File *file = working_set_name_contains(&models->working_set, name);
|
||||||
if (file){
|
if (file){
|
||||||
|
@ -3144,11 +3157,11 @@ view_reinit_scrolling(View *view){
|
||||||
cursor_x = view_get_cursor_x(view);
|
cursor_x = view_get_cursor_x(view);
|
||||||
cursor_y = view_get_cursor_y(view);
|
cursor_y = view_get_cursor_y(view);
|
||||||
|
|
||||||
w = view_file_width(view);
|
w = view_width(view);
|
||||||
h = view_file_height(view);
|
h = view_file_height(view);
|
||||||
|
|
||||||
if (cursor_x >= target_x + w){
|
if (cursor_x >= target_x + w){
|
||||||
target_x = ROUND32(cursor_x - w*.5f);
|
target_x = ROUND32(cursor_x - w*.35f);
|
||||||
}
|
}
|
||||||
|
|
||||||
target_y = clamp_bottom(0, FLOOR32(cursor_y - h*.5f));
|
target_y = clamp_bottom(0, FLOOR32(cursor_y - h*.5f));
|
||||||
|
@ -3950,10 +3963,10 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
|
|
||||||
gui_do_text_field(target, message, hdir->string);
|
gui_do_text_field(target, message, hdir->string);
|
||||||
|
|
||||||
b32 snap_into_view = false;
|
b32 snap_into_view = 0;
|
||||||
scroll_context.id[0] = (u64)(hdir);
|
scroll_context.id[0] = (u64)(hdir);
|
||||||
if (gui_scroll_was_activated(target, scroll_context)){
|
if (gui_scroll_was_activated(target, scroll_context)){
|
||||||
snap_into_view = true;
|
snap_into_view = 1;
|
||||||
}
|
}
|
||||||
gui_begin_scrollable(target, scroll_context, view->gui_scroll,
|
gui_begin_scrollable(target, scroll_context, view->gui_scroll,
|
||||||
9 * view->line_height, show_scrollbar);
|
9 * view->line_height, show_scrollbar);
|
||||||
|
@ -4041,10 +4054,10 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
|
|
||||||
gui_do_text_field(target, message, view->dest);
|
gui_do_text_field(target, message, view->dest);
|
||||||
|
|
||||||
b32 snap_into_view = false;
|
b32 snap_into_view = 0;
|
||||||
scroll_context.id[0] = (u64)(working_set);
|
scroll_context.id[0] = (u64)(working_set);
|
||||||
if (gui_scroll_was_activated(target, scroll_context)){
|
if (gui_scroll_was_activated(target, scroll_context)){
|
||||||
snap_into_view = true;
|
snap_into_view = 1;
|
||||||
}
|
}
|
||||||
gui_begin_scrollable(target, scroll_context, view->gui_scroll,
|
gui_begin_scrollable(target, scroll_context, view->gui_scroll,
|
||||||
9 * view->line_height, show_scrollbar);
|
9 * view->line_height, show_scrollbar);
|
||||||
|
@ -4394,7 +4407,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
i32 inspecting_id = view->debug_vars.inspecting_view_id;
|
i32 inspecting_id = view->debug_vars.inspecting_view_id;
|
||||||
View *views_to_inspect[16];
|
View *views_to_inspect[16];
|
||||||
i32 view_count = 0;
|
i32 view_count = 0;
|
||||||
b32 low_detail = true;
|
b32 low_detail = 1;
|
||||||
|
|
||||||
if (inspecting_id == 0){
|
if (inspecting_id == 0){
|
||||||
Editing_Layout *layout = &models->layout;
|
Editing_Layout *layout = &models->layout;
|
||||||
|
@ -4410,7 +4423,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
Live_Views *live_set = models->live_set;
|
Live_Views *live_set = models->live_set;
|
||||||
View *view_ptr = live_set->views + inspecting_id - 1;
|
View *view_ptr = live_set->views + inspecting_id - 1;
|
||||||
views_to_inspect[view_count++] = view_ptr;
|
views_to_inspect[view_count++] = view_ptr;
|
||||||
low_detail = false;
|
low_detail = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i32 i = 0; i < view_count; ++i){
|
for (i32 i = 0; i < view_count; ++i){
|
||||||
|
@ -4458,7 +4471,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
#define SHOW_GUI_ID(n, h, str, v) show_gui_id(target, &string, n, h, " " str, v)
|
#define SHOW_GUI_ID(n, h, str, v) show_gui_id(target, &string, n, h, " " str, v)
|
||||||
#define SHOW_GUI_FLOAT(n, h, str, v) show_gui_float(target, &string, n, h, " " str " ", v)
|
#define SHOW_GUI_FLOAT(n, h, str, v) show_gui_float(target, &string, n, h, " " str " ", v)
|
||||||
#define SHOW_GUI_BOOL(n, h, str, v) do { if (v) { show_gui_line(target, &string, n, h, " " str " ", "true"); }\
|
#define SHOW_GUI_BOOL(n, h, str, v) do { if (v) { show_gui_line(target, &string, n, h, " " str " ", "true"); }\
|
||||||
else { show_gui_line(target, &string, n, h, " " str " ", "false"); } } while(false)
|
else { show_gui_line(target, &string, n, h, " " str " ", "false"); } } while(0)
|
||||||
|
|
||||||
#define SHOW_GUI_SCROLL(n, h, str, v) show_gui_scroll(target, &string, n, h, " " str, v)
|
#define SHOW_GUI_SCROLL(n, h, str, v) show_gui_scroll(target, &string, n, h, " " str, v)
|
||||||
#define SHOW_GUI_CURSOR(n, h, str, v) show_gui_cursor(target, &string, n, h, " " str, v)
|
#define SHOW_GUI_CURSOR(n, h, str, v) show_gui_cursor(target, &string, n, h, " " str, v)
|
||||||
|
@ -4684,12 +4697,12 @@ do_step_file_view(System_Functions *system,
|
||||||
if (interpret_result.auto_activate){
|
if (interpret_result.auto_activate){
|
||||||
target->auto_hot = gui_id_zero();
|
target->auto_hot = gui_id_zero();
|
||||||
target->active = b->id;
|
target->active = b->id;
|
||||||
result.is_animating = true;
|
result.is_animating = 1;
|
||||||
}
|
}
|
||||||
else if (interpret_result.auto_hot){
|
else if (interpret_result.auto_hot){
|
||||||
if (!gui_id_eq(target->auto_hot, b->id)){
|
if (!gui_id_eq(target->auto_hot, b->id)){
|
||||||
target->auto_hot = b->id;
|
target->auto_hot = b->id;
|
||||||
result.is_animating = true;
|
result.is_animating = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
@ -4707,11 +4720,11 @@ do_step_file_view(System_Functions *system,
|
||||||
|
|
||||||
if (view->reinit_scrolling){
|
if (view->reinit_scrolling){
|
||||||
result.vars = view_reinit_scrolling(view);
|
result.vars = view_reinit_scrolling(view);
|
||||||
result.is_animating = true;
|
result.is_animating = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_step(view, gui_session.rect, user_input, is_active, &result.consumed_l)){
|
if (file_step(view, gui_session.rect, user_input, is_active, &result.consumed_l)){
|
||||||
result.is_animating = true;
|
result.is_animating = 1;
|
||||||
}
|
}
|
||||||
is_file_scroll = 1;
|
is_file_scroll = 1;
|
||||||
}break;
|
}break;
|
||||||
|
@ -4726,7 +4739,7 @@ do_step_file_view(System_Functions *system,
|
||||||
|
|
||||||
if (click_button_input(target, &gui_session, user_input,
|
if (click_button_input(target, &gui_session, user_input,
|
||||||
b, &result.is_animating)){
|
b, &result.is_animating)){
|
||||||
result.consumed_l = true;
|
result.consumed_l = 1;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
@ -4737,7 +4750,7 @@ do_step_file_view(System_Functions *system,
|
||||||
|
|
||||||
if (click_button_input(target, &gui_session, user_input,
|
if (click_button_input(target, &gui_session, user_input,
|
||||||
b, &result.is_animating)){
|
b, &result.is_animating)){
|
||||||
result.consumed_l = true;
|
result.consumed_l = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -4760,7 +4773,7 @@ do_step_file_view(System_Functions *system,
|
||||||
key = get_single_key(keys, i);
|
key = get_single_key(keys, i);
|
||||||
if (char_to_upper(key.character) == activation_key){
|
if (char_to_upper(key.character) == activation_key){
|
||||||
target->active = b->id;
|
target->active = b->id;
|
||||||
result.is_animating = true;
|
result.is_animating = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4779,8 +4792,8 @@ do_step_file_view(System_Functions *system,
|
||||||
target->hover = id;
|
target->hover = id;
|
||||||
if (user_input->mouse.press_l){
|
if (user_input->mouse.press_l){
|
||||||
target->mouse_hot = id;
|
target->mouse_hot = id;
|
||||||
result.is_animating = true;
|
result.is_animating = 1;
|
||||||
result.consumed_l = true;
|
result.consumed_l = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (gui_id_eq(target->hover, id)){
|
else if (gui_id_eq(target->hover, id)){
|
||||||
|
@ -4794,7 +4807,7 @@ do_step_file_view(System_Functions *system,
|
||||||
result.vars.target_y = ROUND32(lerp(0.f, v, (f32)max_y));
|
result.vars.target_y = ROUND32(lerp(0.f, v, (f32)max_y));
|
||||||
|
|
||||||
gui_activate_scrolling(target);
|
gui_activate_scrolling(target);
|
||||||
result.is_animating = true;
|
result.is_animating = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// NOTE(allen): NO BREAK HERE!!
|
// NOTE(allen): NO BREAK HERE!!
|
||||||
|
@ -4807,7 +4820,7 @@ do_step_file_view(System_Functions *system,
|
||||||
result.vars.target_y =
|
result.vars.target_y =
|
||||||
clamp(0, result.vars.target_y, max_y);
|
clamp(0, result.vars.target_y, max_y);
|
||||||
gui_activate_scrolling(target);
|
gui_activate_scrolling(target);
|
||||||
result.is_animating = true;
|
result.is_animating = 1;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
@ -4818,7 +4831,7 @@ do_step_file_view(System_Functions *system,
|
||||||
if (scroll_button_input(target, &gui_session, user_input, id, &result.is_animating)){
|
if (scroll_button_input(target, &gui_session, user_input, id, &result.is_animating)){
|
||||||
result.vars.target_y -= clamp_bottom(1, target->delta >> 2);
|
result.vars.target_y -= clamp_bottom(1, target->delta >> 2);
|
||||||
result.vars.target_y = clamp_bottom(0, result.vars.target_y);
|
result.vars.target_y = clamp_bottom(0, result.vars.target_y);
|
||||||
result.consumed_l = true;
|
result.consumed_l = 1;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
@ -4829,14 +4842,14 @@ do_step_file_view(System_Functions *system,
|
||||||
if (scroll_button_input(target, &gui_session, user_input, id, &result.is_animating)){
|
if (scroll_button_input(target, &gui_session, user_input, id, &result.is_animating)){
|
||||||
result.vars.target_y += clamp_bottom(1, target->delta >> 2);
|
result.vars.target_y += clamp_bottom(1, target->delta >> 2);
|
||||||
result.vars.target_y = clamp_top(result.vars.target_y, max_y);
|
result.vars.target_y = clamp_top(result.vars.target_y, max_y);
|
||||||
result.consumed_l = true;
|
result.consumed_l = 1;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case guicom_end_scrollable_section:
|
case guicom_end_scrollable_section:
|
||||||
{
|
{
|
||||||
if (!is_file_scroll){
|
if (!is_file_scroll){
|
||||||
result.has_max_y_suggestion = true;
|
result.has_max_y_suggestion = 1;
|
||||||
result.max_y = gui_session.suggested_max_y;
|
result.max_y = gui_session.suggested_max_y;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
@ -4847,15 +4860,17 @@ do_step_file_view(System_Functions *system,
|
||||||
if (!user_input->mouse.l){
|
if (!user_input->mouse.l){
|
||||||
if (!gui_id_is_null(target->mouse_hot)){
|
if (!gui_id_is_null(target->mouse_hot)){
|
||||||
target->mouse_hot = gui_id_zero();
|
target->mouse_hot = gui_id_zero();
|
||||||
result.is_animating = true;
|
result.is_animating = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
GUI_Scroll_Vars scroll_vars = result.vars;
|
GUI_Scroll_Vars scroll_vars = result.vars;
|
||||||
b32 is_new_target = false;
|
b32 is_new_target = 0;
|
||||||
if (scroll_vars.target_x != scroll_vars.prev_target_x) is_new_target = true;
|
if (scroll_vars.target_x != scroll_vars.prev_target_x ||
|
||||||
if (scroll_vars.target_y != scroll_vars.prev_target_y) is_new_target = true;
|
scroll_vars.target_y != scroll_vars.prev_target_y){
|
||||||
|
is_new_target = 1;
|
||||||
|
}
|
||||||
|
|
||||||
f32 target_x = (f32)scroll_vars.target_x;
|
f32 target_x = (f32)scroll_vars.target_x;
|
||||||
f32 target_y = (f32)scroll_vars.target_y;
|
f32 target_y = (f32)scroll_vars.target_y;
|
||||||
|
@ -4863,7 +4878,7 @@ do_step_file_view(System_Functions *system,
|
||||||
if (view->persistent.models->scroll_rule(target_x, target_y,
|
if (view->persistent.models->scroll_rule(target_x, target_y,
|
||||||
&scroll_vars.scroll_x, &scroll_vars.scroll_y,
|
&scroll_vars.scroll_x, &scroll_vars.scroll_y,
|
||||||
(view->persistent.id) + 1, is_new_target, user_input->dt)){
|
(view->persistent.id) + 1, is_new_target, user_input->dt)){
|
||||||
result.is_animating = true;
|
result.is_animating = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
scroll_vars.prev_target_x = scroll_vars.target_x;
|
scroll_vars.prev_target_x = scroll_vars.target_x;
|
||||||
|
@ -4883,7 +4898,7 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
|
||||||
Style *style = main_style(models);
|
Style *style = main_style(models);
|
||||||
i32 line_height = view->line_height;
|
i32 line_height = view->line_height;
|
||||||
|
|
||||||
i32 max_x = rect.x1 - rect.x0;
|
f32 max_x = view_file_display_width(view);
|
||||||
i32 max_y = rect.y1 - rect.y0 + line_height;
|
i32 max_y = rect.y1 - rect.y0 + line_height;
|
||||||
|
|
||||||
Assert(file && !file->is_dummy && buffer_good(&file->state.buffer));
|
Assert(file && !file->is_dummy && buffer_good(&file->state.buffer));
|
||||||
|
@ -4897,7 +4912,6 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
|
||||||
}
|
}
|
||||||
|
|
||||||
Partition *part = &models->mem.part;
|
Partition *part = &models->mem.part;
|
||||||
|
|
||||||
Temp_Memory temp = begin_temp_memory(part);
|
Temp_Memory temp = begin_temp_memory(part);
|
||||||
|
|
||||||
partition_align(part, 4);
|
partition_align(part, 4);
|
||||||
|
@ -4907,17 +4921,17 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
|
||||||
i16 font_id = file->settings.font_id;
|
i16 font_id = file->settings.font_id;
|
||||||
Render_Font *font = get_font_info(models->font_set, font_id)->font;
|
Render_Font *font = get_font_info(models->font_set, font_id)->font;
|
||||||
float *advance_data = 0;
|
float *advance_data = 0;
|
||||||
if (font) advance_data = font->advance_data;
|
// TODO(allen): Why isn't this "Assert(font);"?
|
||||||
|
if (font){
|
||||||
|
advance_data = font->advance_data;
|
||||||
|
}
|
||||||
|
|
||||||
i32 count = 0;
|
i32 count = 0;
|
||||||
Full_Cursor render_cursor = {0};
|
Full_Cursor render_cursor = {0};
|
||||||
|
|
||||||
f32 *wraps = view->file_data.line_wrap_y;
|
f32 *wraps = view->file_data.line_wrap_y;
|
||||||
f32 scroll_x = 0;
|
f32 scroll_x = view->edit_pos->scroll.scroll_x;
|
||||||
f32 scroll_y = 0;
|
f32 scroll_y = view->edit_pos->scroll.scroll_y;
|
||||||
|
|
||||||
scroll_x = view->edit_pos->scroll.scroll_x;
|
|
||||||
scroll_y = view->edit_pos->scroll.scroll_y;
|
|
||||||
|
|
||||||
// NOTE(allen): For now we will temporarily adjust scroll_y to try
|
// NOTE(allen): For now we will temporarily adjust scroll_y to try
|
||||||
// to prevent the view moving around until floating sections are added
|
// to prevent the view moving around until floating sections are added
|
||||||
|
@ -4927,16 +4941,14 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
|
||||||
{
|
{
|
||||||
render_cursor = buffer_get_start_cursor(&file->state.buffer, wraps, scroll_y,
|
render_cursor = buffer_get_start_cursor(&file->state.buffer, wraps, scroll_y,
|
||||||
!view->file_data.unwrapped_lines,
|
!view->file_data.unwrapped_lines,
|
||||||
(f32)max_x,
|
max_x, advance_data, (f32)line_height);
|
||||||
advance_data, (f32)line_height);
|
|
||||||
|
|
||||||
view->edit_pos->scroll_i = render_cursor.pos;
|
view->edit_pos->scroll_i = render_cursor.pos;
|
||||||
|
|
||||||
buffer_get_render_data(&file->state.buffer, items, max, &count,
|
buffer_get_render_data(&file->state.buffer, items, max, &count,
|
||||||
(f32)rect.x0, (f32)rect.y0,
|
(f32)rect.x0, (f32)rect.y0, max_x, (f32)max_y,
|
||||||
scroll_x, scroll_y, render_cursor,
|
scroll_x, scroll_y,
|
||||||
!view->file_data.unwrapped_lines,
|
render_cursor, !view->file_data.unwrapped_lines,
|
||||||
(f32)max_x, (f32)max_y,
|
|
||||||
advance_data, (f32)line_height);
|
advance_data, (f32)line_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5237,12 +5249,12 @@ draw_font_button(GUI_Target *gui_target, Render_Target *target, View *view,
|
||||||
|
|
||||||
i32 active_level = gui_active_level(gui_target, id);
|
i32 active_level = gui_active_level(gui_target, id);
|
||||||
|
|
||||||
u32 margin = get_margin_color(active_level, style);
|
u32 margin_color = get_margin_color(active_level, style);
|
||||||
u32 back = style->main.back_color;
|
u32 back_color = style->main.back_color;
|
||||||
u32 text_color = style->main.default_color;
|
u32 text_color = style->main.default_color;
|
||||||
|
|
||||||
draw_rectangle(target, rect, back);
|
draw_rectangle(target, rect, back_color);
|
||||||
draw_rectangle_outline(target, rect, margin);
|
draw_rectangle_outline(target, rect, margin_color);
|
||||||
draw_string(target, font_id, text, rect.x0, rect.y0 + 1, text_color);
|
draw_string(target, font_id, text, rect.x0, rect.y0 + 1, text_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5594,8 +5606,7 @@ view_change_size(General_Memory *general, View *view){
|
||||||
view_measure_wraps(general, view);
|
view_measure_wraps(general, view);
|
||||||
Full_Cursor cursor =
|
Full_Cursor cursor =
|
||||||
view_compute_cursor_from_pos(view, view->edit_pos->cursor.pos);
|
view_compute_cursor_from_pos(view, view->edit_pos->cursor.pos);
|
||||||
view_set_cursor(view, cursor,
|
view_set_cursor(view, cursor, 0, view->file_data.unwrapped_lines);
|
||||||
false, view->file_data.unwrapped_lines);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5627,6 +5638,7 @@ live_set_alloc_view(Live_Views *live_set, Panel *panel, Models *models){
|
||||||
result.view->gui_mem = gui_mem;
|
result.view->gui_mem = gui_mem;
|
||||||
gui_mem = advance_to_alignment(gui_mem);
|
gui_mem = advance_to_alignment(gui_mem);
|
||||||
result.view->gui_target.push = make_part(gui_mem, gui_mem_size);
|
result.view->gui_target.push = make_part(gui_mem, gui_mem_size);
|
||||||
|
result.view->display_width = models->default_display_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
|
|
12
TODO.txt
12
TODO.txt
|
@ -141,7 +141,14 @@
|
||||||
; [] switch to line classification system
|
; [] switch to line classification system
|
||||||
; [] more built in options for auto indenting
|
; [] more built in options for auto indenting
|
||||||
;
|
;
|
||||||
; [] eliminate the need for the lexer state's spare array.
|
; [X] eliminate the need for the lexer state's spare array.
|
||||||
|
|
||||||
|
; Arbitrary wrap positions
|
||||||
|
; [X] allow for arbitrary wrap positions independent of view width
|
||||||
|
; [X] command for adjusting wrap positions in views
|
||||||
|
; [X] get horizontal scrolling to work in line wrap mode
|
||||||
|
; [] command for setting wrap positions in views directly
|
||||||
|
; [] ability to see the wrap position as a number/line and adjust graphically
|
||||||
|
|
||||||
; [] miblo's various number editors
|
; [] miblo's various number editors
|
||||||
; [] user file bar string
|
; [] user file bar string
|
||||||
|
@ -156,13 +163,12 @@
|
||||||
; [] option to break buffer name ties by adding parent directories instead of <#>
|
; [] option to break buffer name ties by adding parent directories instead of <#>
|
||||||
; [] undo groups
|
; [] undo groups
|
||||||
; [] cursor/scroll groups
|
; [] cursor/scroll groups
|
||||||
; [] allow for arbitrary wrap positions independent of view width
|
|
||||||
; [] word level wrapping ~ temporary measure really want to have totally formatted code presentation
|
; [] word level wrapping ~ temporary measure really want to have totally formatted code presentation
|
||||||
; [] double binding warnings
|
; [] double binding warnings
|
||||||
;
|
;
|
||||||
;
|
;
|
||||||
; [] the "main_4coder" experiment
|
; [] the "main_4coder" experiment
|
||||||
; [] multi-line editing
|
; [] real multi-line editing
|
||||||
; [] multi-cursor editing
|
; [] multi-cursor editing
|
||||||
|
|
||||||
; [] API docs have duplicate ids?
|
; [] API docs have duplicate ids?
|
||||||
|
|
|
@ -302,11 +302,14 @@ buffer_remeasure_widths(Buffer_Type *buffer, f32 *advance_data,
|
||||||
i = line_start;
|
i = line_start;
|
||||||
j = starts[i];
|
j = starts[i];
|
||||||
|
|
||||||
if (line_end == line_count) size = buffer_size(buffer);
|
if (line_end == line_count){
|
||||||
else size = starts[line_end];
|
size = buffer_size(buffer);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
size = starts[line_end];
|
||||||
|
}
|
||||||
|
|
||||||
width = 0;
|
width = 0;
|
||||||
|
|
||||||
for (loop = buffer_stringify_loop(buffer, j, size);
|
for (loop = buffer_stringify_loop(buffer, j, size);
|
||||||
buffer_stringify_good(&loop);
|
buffer_stringify_good(&loop);
|
||||||
buffer_stringify_next(&loop)){
|
buffer_stringify_next(&loop)){
|
||||||
|
@ -333,58 +336,53 @@ buffer_remeasure_widths(Buffer_Type *buffer, f32 *advance_data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
inline_4tech void
|
|
||||||
buffer_measure_widths(Buffer_Type *buffer, void *advance_data){
|
|
||||||
assert_4tech(buffer->line_count >= 1);
|
|
||||||
buffer_remeasure_widths(buffer, advance_data, 0, buffer->line_count-1, 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
internal_4tech void
|
internal_4tech void
|
||||||
buffer_measure_wrap_y(Buffer_Type *buffer, f32 *wraps,
|
buffer_measure_wrap_y(Buffer_Type *buffer, f32 *wraps,
|
||||||
f32 font_height, f32 max_width){
|
f32 font_height, f32 max_width){
|
||||||
f32 *widths;
|
f32 *widths = buffer->line_widths;
|
||||||
f32 y_pos;
|
f32 y_pos = 0;
|
||||||
i32 i, line_count;
|
i32 line_count = buffer->line_count;
|
||||||
|
i32 i = 0;
|
||||||
|
|
||||||
line_count = buffer->line_count;
|
for (; i < line_count; ++i){
|
||||||
widths = buffer->line_widths;
|
|
||||||
y_pos = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < line_count; ++i){
|
|
||||||
wraps[i] = y_pos;
|
wraps[i] = y_pos;
|
||||||
if (widths[i] == 0) y_pos += font_height;
|
if (widths[i] == 0){
|
||||||
else y_pos += font_height*ceil_4tech(widths[i]/max_width);
|
y_pos += font_height;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
y_pos += font_height*ceil_4tech(widths[i]/max_width);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal_4tech i32
|
internal_4tech i32
|
||||||
buffer_get_line_index_range(Buffer_Type *buffer, i32 pos, i32 l_bound, i32 u_bound){
|
buffer_get_line_index_range(Buffer_Type *buffer, i32 pos, i32 l_bound, i32 u_bound){
|
||||||
i32 *lines;
|
i32 *lines = buffer->line_starts;
|
||||||
i32 start, end;
|
i32 start = l_bound, end = u_bound;
|
||||||
i32 i;
|
i32 i = 0;
|
||||||
|
|
||||||
assert_4tech(0 <= l_bound);
|
assert_4tech(0 <= l_bound);
|
||||||
assert_4tech(l_bound <= u_bound);
|
assert_4tech(l_bound <= u_bound);
|
||||||
assert_4tech(u_bound <= buffer->line_count);
|
assert_4tech(u_bound <= buffer->line_count);
|
||||||
|
|
||||||
lines = buffer->line_starts;
|
|
||||||
|
|
||||||
assert_4tech(lines != 0);
|
assert_4tech(lines != 0);
|
||||||
|
|
||||||
start = l_bound;
|
|
||||||
end = u_bound;
|
|
||||||
for (;;){
|
for (;;){
|
||||||
i = (start + end) >> 1;
|
i = (start + end) >> 1;
|
||||||
if (lines[i] < pos) start = i;
|
if (lines[i] < pos){
|
||||||
else if (lines[i] > pos) end = i;
|
start = i;
|
||||||
|
}
|
||||||
|
else if (lines[i] > pos){
|
||||||
|
end = i;
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
start = i;
|
start = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
assert_4tech(start < end);
|
assert_4tech(start < end);
|
||||||
if (start == end - 1) break;
|
if (start == end - 1){
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(start);
|
return(start);
|
||||||
|
@ -816,11 +814,10 @@ write_render_item(Render_Item_Write write, i32 index, u16 glyphid, u16 flags){
|
||||||
|
|
||||||
internal_4tech void
|
internal_4tech void
|
||||||
buffer_get_render_data(Buffer_Type *buffer, Buffer_Render_Item *items, i32 max, i32 *count,
|
buffer_get_render_data(Buffer_Type *buffer, Buffer_Render_Item *items, i32 max, i32 *count,
|
||||||
f32 port_x, f32 port_y,
|
f32 port_x, f32 port_y, f32 width, f32 height,
|
||||||
f32 scroll_x, f32 scroll_y, Full_Cursor start_cursor,
|
f32 scroll_x, f32 scroll_y,
|
||||||
i32 wrapped,
|
Full_Cursor start_cursor,
|
||||||
f32 width, f32 height,
|
i32 wrapped, f32 *adv, f32 font_height){
|
||||||
f32 *adv, f32 font_height){
|
|
||||||
|
|
||||||
Buffer_Stringify_Type loop = {0};
|
Buffer_Stringify_Type loop = {0};
|
||||||
char *data = 0;
|
char *data = 0;
|
||||||
|
@ -858,7 +855,7 @@ buffer_get_render_data(Buffer_Type *buffer, Buffer_Render_Item *items, i32 max,
|
||||||
data = loop.data - loop.absolute_pos;
|
data = loop.data - loop.absolute_pos;
|
||||||
|
|
||||||
for (i32 i = loop.absolute_pos; i < end; ++i){
|
for (i32 i = loop.absolute_pos; i < end; ++i){
|
||||||
uint8_t ch = (uint8_t)data[i];
|
u8 ch = (uint8_t)data[i];
|
||||||
f32 ch_width = measure_character(adv, ch);
|
f32 ch_width = measure_character(adv, ch);
|
||||||
|
|
||||||
if (ch_width + write.x > width + shift_x && wrapped && ch != '\n'){
|
if (ch_width + write.x > width + shift_x && wrapped && ch != '\n'){
|
||||||
|
|
Loading…
Reference in New Issue