From cb6d1d8953467b53efaebc42052deea2160960d2 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Wed, 29 Jun 2016 14:38:58 -0400 Subject: [PATCH] moved cmdid_show_scrollbar/cmdid_hide_scrollbar to custom side --- 4coder_API.html | 73 ++++++++++++++++++++----------- 4coder_custom.h | 8 ++-- 4coder_custom_api.h | 4 ++ 4coder_default_bindings.cpp | 8 ++-- 4coder_default_include.cpp | 14 ++++++ 4ed.cpp | 13 ------ 4ed_api_implementation.cpp | 32 ++++++++++++-- power/4coder_default_building.cpp | 1 + 8 files changed, 104 insertions(+), 49 deletions(-) diff --git a/4coder_API.html b/4coder_API.html index 09f6f2d3..04f1c9e5 100644 --- a/4coder_API.html +++ b/4coder_API.html @@ -93,6 +93,9 @@ This is the documentation for alpha 4.0.9 super! The documentation has been made set_active_view
  • +view_set_setting +
  • +
  • view_set_split_proportion
  • @@ -420,15 +423,15 @@ range is not within the bounds of the buffer.
    Parameters
    buffer
    -
    the buffer to set a setting on
    +
    The buffer on which to set a setting.
    setting
    -
    one of the Buffer_Setting_ID enum values that identifies the setting to set
    +
    One of the Buffer_Setting_ID enum values that identifies the setting to set.
    value
    -
    the value to set the specified setting to
    +
    The value to set the specified setting to.
    See Also
    Buffer_Setting_ID

    @@ -592,8 +595,26 @@ Views should not be closed or opened durring a view loop.
    Return
    returns non-zero on success
    Description
    If the given view is a currently open view, it is set as the active view, and takes subsequent commands and is returned from get_active_view.
    See Also
    get_active_view

    +
    +

    §2.2.22: view_set_setting

    +
    int app->view_set_setting( +
    Application_Links *app,
    View_Summary *view,
    int setting,
    int value
    ) +
    +
    Parameters
    +
    view
    +
    The view on which to set a setting.
    +
    +
    +
    setting
    +
    One of the View_Setting_ID enum values that identifies the setting to set.
    +
    +
    +
    value
    +
    The value to set the specified setting to.
    +
    +
    See Also
    View_Setting_ID

    -

    §2.2.22: view_set_split_proportion

    +

    §2.2.23: view_set_split_proportion

    int app->view_set_split_proportion(
    Application_Links *app,
    View_Summary *view,
    float t
    )
    @@ -607,7 +628,7 @@ from get_active_view.
    Return
    Returns non-zero on success.

    -

    §2.2.23: view_compute_cursor

    +

    §2.2.24: view_compute_cursor

    int app->view_compute_cursor(
    Application_Links *app,
    View_Summary *view,
    Buffer_Seek seek,
    Full_Cursor *cursor_out
    )
    @@ -625,7 +646,7 @@ from get_active_view.
    Return
    Returns non-zero on success.
    Description
    Computes a full cursor for the given seek position.
    See Also
    Buffer_Seek

    -

    §2.2.24: view_set_cursor

    +

    §2.2.25: view_set_cursor

    int app->view_set_cursor(
    Application_Links *app,
    View_Summary *view,
    Buffer_Seek seek,
    int set_preferred_x
    )
    @@ -644,7 +665,7 @@ from get_active_view.
    Return
    returns non-zero on success
    Description
    Sets the the view's cursor position. set_preferred_x should usually be true unless the change in cursor position is is a vertical motion that tries to keep the cursor in the same column or x position.
    See Also
    Buffer_Seek

    -

    §2.2.25: view_set_mark

    +

    §2.2.26: view_set_mark

    int app->view_set_mark(
    Application_Links *app,
    View_Summary *view,
    Buffer_Seek seek
    )
    @@ -658,7 +679,7 @@ cursor position is is a vertical motion that tries to keep the cursor in the sam
    Return
    returns non-zero on success
    Description
    Sets the the view's mark position.
    See Also
    Buffer_Seek

    -

    §2.2.26: view_set_highlight

    +

    §2.2.27: view_set_highlight

    int app->view_set_highlight(
    Application_Links *app,
    View_Summary *view,
    int start,
    int end,
    int turn_on
    )
    @@ -683,7 +704,7 @@ is set to true the highlight will be shown and the cursor will be hidden. After that either setting the with view_set_cursor or calling view_set_highlight and the turn_on set to false, will switch back to showing the cursor.

    -

    §2.2.27: view_set_buffer

    +

    §2.2.28: view_set_buffer

    int app->view_set_buffer(
    Application_Links *app,
    View_Summary *view,
    int buffer_id,
    unsigned int flags
    )
    @@ -702,7 +723,7 @@ the turn_on set to false, will switch back to showing the cursor.

    Return
    returns non-zero on success
    Description
    On success view_set_buffer sets the specified view's current buffer and cancels and dialogue shown in the view and displays the file.
    See Also
    Set_Buffer_Flag

    -

    §2.2.28: view_post_fade

    +

    §2.2.29: view_post_fade

    int app->view_post_fade(
    Application_Links *app,
    View_Summary *view,
    float seconds,
    int start,
    int end,
    unsigned int color
    )
    @@ -728,7 +749,7 @@ cancels and dialogue shown in the view and displays the file.
    -

    §2.2.29: get_user_input

    +

    §2.2.30: get_user_input

    User_Input app->get_user_input(
    Application_Links *app,
    unsigned int get_type,
    unsigned int abort_type
    )
    @@ -746,19 +767,19 @@ command is executed an abort signal is returned. If an abort signal is ever ret command should finish execution without any more calls that preempt the command. If a get condition is met the user input is returned
    See Also
    Input_Type_Flag
    User_Input

    -

    §2.2.30: get_command_input

    +

    §2.2.31: get_command_input

    User_Input app->get_command_input(
    Application_Links *app
    )
    Return
    returns the input that triggered the command in execution.
    See Also
    User_Input

    -

    §2.2.31: get_mouse_state

    +

    §2.2.32: get_mouse_state

    Mouse_State app->get_mouse_state(
    Application_Links *app
    )
    Return
    returns the current mouse state
    See Also
    Mouse_State

    -

    §2.2.32: start_query_bar

    +

    §2.2.33: start_query_bar

    int app->start_query_bar(
    Application_Links *app,
    Query_Bar *bar,
    unsigned int flags
    )
    @@ -773,7 +794,7 @@ If a get condition is met the user input is returned
    Return
    returns non-zero on success
    Description
    The memory pointed to by bar must remain valid until a call to end_query_bar or until the command returns.

    -

    §2.2.33: end_query_bar

    +

    §2.2.34: end_query_bar

    void app->end_query_bar(
    Application_Links *app,
    Query_Bar *bar,
    unsigned int flags
    )
    @@ -787,7 +808,7 @@ until the command returns.

    Description
    bar must be a pointer previously passed to start_query_bar previously in the same command.



    -

    §2.2.35: change_theme

    +

    §2.2.36: change_theme

    void app->change_theme(
    Application_Links *app,
    char *name,
    int len
    )
    @@ -815,7 +836,7 @@ until the command returns.


    -

    §2.2.36: change_font

    +

    §2.2.37: change_font

    void app->change_font(
    Application_Links *app,
    char *name,
    int len
    )
    @@ -829,7 +850,7 @@ until the command returns.


    -

    §2.2.37: set_theme_colors

    +

    §2.2.38: set_theme_colors

    void app->set_theme_colors(
    Application_Links *app,
    Theme_Color *colors,
    int count
    )
    @@ -844,7 +865,7 @@ until the command returns.

    Description
    For each color struct in the array, the color in the style pallet is set to the color code paired with the tag.

    -

    §2.2.38: get_theme_colors

    +

    §2.2.39: get_theme_colors

    void app->get_theme_colors(
    Application_Links *app,
    Theme_Color *colors,
    int count
    )
    @@ -859,7 +880,7 @@ code paired with the tag.

    Description
    For each color struct in the array, the color field of the struct is filled with the color from the specified color in the pallet.

    -

    §2.2.39: directory_get_hot

    +

    §2.2.40: directory_get_hot

    int app->directory_get_hot(
    Application_Links *app,
    char *out,
    int capacity
    )
    @@ -877,7 +898,7 @@ accessed in the GUI. Whenever the GUI is opened it shows the hot directory. In the future this will be deprecated and eliminated in favor of more flexible directories controlled by the custom side.

    -

    §2.2.40: get_file_list

    +

    §2.2.41: get_file_list

    File_List app->get_file_list(
    Application_Links *app,
    char *dir,
    int len
    )
    @@ -893,7 +914,7 @@ directories controlled by the custom side.

    the specified directory. The File_List returned should be passed to free_file_list when it is no longer in use.
    -

    §2.2.41: free_file_list

    +

    §2.2.42: free_file_list

    void app->free_file_list(
    Application_Links *app,
    File_List list
    )
    @@ -903,7 +924,7 @@ when it is no longer in use.

    Description
    after this call the file list passed in should not be read or written to

    -

    §2.2.42: file_exists

    +

    §2.2.43: file_exists

    int app->file_exists(
    Application_Links *app,
    char *filename,
    int len
    )
    @@ -917,7 +938,7 @@ when it is no longer in use.

    Return
    returns non-zero if the file exists, returns zero if the file does not exist

    -

    §2.2.43: directory_cd

    +

    §2.2.44: directory_cd

    int app->directory_cd(
    Application_Links *app,
    char *dir,
    int *len,
    int capacity,
    char *rel_path,
    int rel_len
    )
    @@ -949,7 +970,7 @@ For instance if dir contains "C:/Users/MySelf" and rel is "Documents" the buffer "C:/Users/MySelf/Documents" and len will contain the length of that string. This call can also be used with rel set to ".." to traverse to parent folders.

    -

    §2.2.44: get_4ed_path

    +

    §2.2.45: get_4ed_path

    int app->get_4ed_path(
    Application_Links *app,
    char *out,
    int capacity
    )
    diff --git a/4coder_custom.h b/4coder_custom.h index 77d99ae4..1ff2e008 100644 --- a/4coder_custom.h +++ b/4coder_custom.h @@ -140,9 +140,6 @@ enum{ cmdid_eol_dosify, cmdid_eol_nixify, - cmdid_hide_scrollbar, - cmdid_show_scrollbar, - cmdid_interactive_new, cmdid_interactive_open, cmdid_reopen, @@ -280,6 +277,11 @@ enum Buffer_Setting_ID{ BufferSetting_MapID, }; +enum View_Setting_ID{ + ViewSetting_Null, + ViewSetting_ShowScrollbar, +}; + enum Buffer_Kill_Flag{ BufferKill_Background = 0x1, BufferKill_AlwaysKill = 0x2, diff --git a/4coder_custom_api.h b/4coder_custom_api.h index 685fc712..4fda4445 100644 --- a/4coder_custom_api.h +++ b/4coder_custom_api.h @@ -20,6 +20,7 @@ #define GET_VIEW_SIG(n) View_Summary n(Application_Links *app, int view_id, unsigned int access) #define GET_ACTIVE_VIEW_SIG(n) View_Summary n(Application_Links *app, unsigned int access) #define SET_ACTIVE_VIEW_SIG(n) int n(Application_Links *app, View_Summary *view) +#define VIEW_SET_SETTING_SIG(n) int n(Application_Links *app, View_Summary *view, int setting, int value) #define VIEW_SET_SPLIT_PROPORTION_SIG(n) int n(Application_Links *app, View_Summary *view, float t) #define VIEW_COMPUTE_CURSOR_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out) #define VIEW_SET_CURSOR_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x) @@ -66,6 +67,7 @@ extern "C"{ typedef GET_VIEW_SIG(Get_View_Function); typedef GET_ACTIVE_VIEW_SIG(Get_Active_View_Function); typedef SET_ACTIVE_VIEW_SIG(Set_Active_View_Function); + typedef VIEW_SET_SETTING_SIG(View_Set_Setting_Function); typedef VIEW_SET_SPLIT_PROPORTION_SIG(View_Set_Split_Proportion_Function); typedef VIEW_COMPUTE_CURSOR_SIG(View_Compute_Cursor_Function); typedef VIEW_SET_CURSOR_SIG(View_Set_Cursor_Function); @@ -115,6 +117,7 @@ struct Application_Links{ Get_View_Function *get_view; Get_Active_View_Function *get_active_view; Set_Active_View_Function *set_active_view; + View_Set_Setting_Function *view_set_setting; View_Set_Split_Proportion_Function *view_set_split_proportion; View_Compute_Cursor_Function *view_compute_cursor; View_Set_Cursor_Function *view_set_cursor; @@ -166,6 +169,7 @@ app_links->get_view_next = Get_View_Next;\ app_links->get_view = Get_View;\ app_links->get_active_view = Get_Active_View;\ app_links->set_active_view = Set_Active_View;\ +app_links->view_set_setting = View_Set_Setting;\ app_links->view_set_split_proportion = View_Set_Split_Proportion;\ app_links->view_compute_cursor = View_Compute_Cursor;\ app_links->view_set_cursor = View_Set_Cursor;\ diff --git a/4coder_default_bindings.cpp b/4coder_default_bindings.cpp index 132f6d53..706cf08f 100644 --- a/4coder_default_bindings.cpp +++ b/4coder_default_bindings.cpp @@ -122,9 +122,9 @@ CUSTOM_COMMAND_SIG(seek_whitespace_down_end_line){ HOOK_SIG(my_start){ exec_command(app, cmdid_open_panel_vsplit); - exec_command(app, cmdid_hide_scrollbar); + exec_command(app, hide_scrollbar); exec_command(app, cmdid_change_active_panel); - exec_command(app, cmdid_hide_scrollbar); + exec_command(app, hide_scrollbar); app->change_theme(app, literal("4coder")); app->change_font(app, literal("Liberation Sans")); @@ -318,13 +318,13 @@ default_keys(Bind_Helper *context){ bind(context, 'O', MDFR_CTRL, cmdid_reopen); bind(context, 'q', MDFR_CTRL, query_replace); bind(context, 'r', MDFR_CTRL, reverse_search); - bind(context, 's', MDFR_ALT, cmdid_show_scrollbar); + bind(context, 's', MDFR_ALT, show_scrollbar); bind(context, 's', MDFR_CTRL, cmdid_save); bind(context, 'u', MDFR_CTRL, cmdid_to_uppercase); bind(context, 'U', MDFR_CTRL, rewrite_as_single_caps); bind(context, 'v', MDFR_CTRL, paste); bind(context, 'V', MDFR_CTRL, paste_next); - bind(context, 'w', MDFR_ALT, cmdid_hide_scrollbar); + bind(context, 'w', MDFR_ALT, hide_scrollbar); bind(context, 'x', MDFR_CTRL, cut); bind(context, 'y', MDFR_CTRL, cmdid_redo); bind(context, 'z', MDFR_CTRL, cmdid_undo); diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index 6c6e22d1..af89aac7 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -811,6 +811,20 @@ CUSTOM_COMMAND_SIG(snipe_token_or_word){ app->buffer_replace_range(app, &buffer, range.start, range.end, 0, 0); } +// +// Scroll Bar Controlling +// + +CUSTOM_COMMAND_SIG(show_scrollbar){ + View_Summary view = app->get_active_view(app, AccessProtected); + app->view_set_setting(app, &view, ViewSetting_ShowScrollbar, true); +} + +CUSTOM_COMMAND_SIG(hide_scrollbar){ + View_Summary view = app->get_active_view(app, AccessProtected); + app->view_set_setting(app, &view, ViewSetting_ShowScrollbar, false); +} + // // // diff --git a/4ed.cpp b/4ed.cpp index b4b29089..f17dfdf4 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -976,16 +976,6 @@ COMMAND_DECL(user_callback){ if (binding.custom) binding.custom(&models->app_links); } -COMMAND_DECL(hide_scrollbar){ - USE_VIEW(view); - view->hide_scrollbar = 1; -} - -COMMAND_DECL(show_scrollbar){ - USE_VIEW(view); - view->hide_scrollbar = 0; -} - internal void update_command_data(App_Vars *vars, Command_Data *cmd){ cmd->panel = cmd->models->layout.panels + cmd->models->layout.active_panel; @@ -1122,9 +1112,6 @@ setup_command_table(){ SET(open_menu); SET(open_debug); - SET(hide_scrollbar); - SET(show_scrollbar); - #undef SET } diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 75ac0276..f14f64e3 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -688,9 +688,9 @@ range is not within the bounds of the buffer. API_EXPORT int Buffer_Set_Setting(Application_Links *app, Buffer_Summary *buffer, int setting, int value)/* -DOC_PARAM(buffer, the buffer to set a setting on) -DOC_PARAM(setting, one of the Buffer_Setting_ID enum values that identifies the setting to set) -DOC_PARAM(value, the value to set the specified setting to) +DOC_PARAM(buffer, The buffer on which to set a setting.) +DOC_PARAM(setting, One of the Buffer_Setting_ID enum values that identifies the setting to set.) +DOC_PARAM(value, The value to set the specified setting to.) DOC_SEE(Buffer_Setting_ID) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; @@ -1107,6 +1107,32 @@ DOC_SEE(get_active_view) return(result); } +API_EXPORT int +View_Set_Setting(Application_Links *app, View_Summary *view, int setting, int value)/* +DOC_PARAM(view, The view on which to set a setting.) +DOC_PARAM(setting, One of the View_Setting_ID enum values that identifies the setting to set.) +DOC_PARAM(value, The value to set the specified setting to.) +DOC_SEE(View_Setting_ID) +*/{ + Command_Data *cmd = (Command_Data*)app->cmd_context; + View *vptr = imp_get_view(cmd, view); + int result = false; + + if (vptr){ + switch (setting){ + case ViewSetting_ShowScrollbar: + { + result = true; + vptr->hide_scrollbar = !value; + }break; + } + + fill_view_summary(view, vptr, cmd); + } + + return(result); +} + API_EXPORT int View_Set_Split_Proportion(Application_Links *app, View_Summary *view, float t)/* DOC_PARAM(view, The view on which to adjust size.) diff --git a/power/4coder_default_building.cpp b/power/4coder_default_building.cpp index 4d4de339..b05a27bd 100644 --- a/power/4coder_default_building.cpp +++ b/power/4coder_default_building.cpp @@ -32,6 +32,7 @@ CUSTOM_COMMAND_SIG(build_in_build_panel){ if (!build_view.exists){ exec_command(app, cmdid_open_panel_hsplit); + exec_command(app, hide_scrollbar); build_view = app->get_active_view(app, AccessAll); app->view_set_split_proportion(app, &build_view, .2f); }