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;
|
||||||
|
|
11302
4ed_file_view.cpp
11302
4ed_file_view.cpp
File diff suppressed because it is too large
Load Diff
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