Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add comments for bind commands [#809] #926

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Commits on Jul 26, 2019

  1. Improve argv_to_string_alloc()

    1. Fix bug in argv_to_string_alloc(),
       which did not increase buffer size to account for number of separators.
    
    2. Improve coding
       a. Initialize buffer size to one to account for terminator,
          which avoids the need to later increment by one.
       b. Call concat_argv() directly, instead of calling argv_to_string(),
          which is a wrapper.
    
    3. Add similar function argv_to_string_alloc_prefix(),
       which preloads string buffer with a prefix string.
    stevenyvr987 committed Jul 26, 2019
    Configuration menu
    Copy the full SHA
    5088ad7 View commit details
    Browse the repository at this point in the history
  2. Ability to add comments into help view [jonas#809]

    1. keys.h
    
       Add a run_request.help field, analogous to the req_info.help field.
    
    2. options.h
    
       Add a parameter to set_option() for passing any comment text.
    
    3. options.c
    
       a. read_option()
    
          Identify any #comment text string that may have accompanied an option command,
          and pass it into set_option(). The #comment text string is trimmed of any white space.
    
       b. set_option()
    
          set_option() dispatches to specific bind commands.
          Pass any given comment text into the option_bind_command(),
          and ignore comment text for the other bind commands.
    
       c. option_bind_command()
    
          Pass comment text into add_run_request().
    
       d. read_repo_config_option()
    
          Specify the option command to use with "color", "bind", or "set" names
          instead of specific function names.
    
       e. set_repo_config_option()
    
          Refactor to call set_option(), the dispatcher for specific bind commands,
          and call with comment text pointer set to NULL,
          because comment text is never available from a repo configuration file.
    
    4. prompt.c
    
       a. run_prompt_command()
    
          Call set_option() with comment text pointer set to NULL,
          because comment text is not parsed on a prompt line.
    
    5. keys.c
    
       a. add_run_request()
    
          Duplicate comment text into the new run_request.help field.
    
    6. help.c
    
       a. help_draw()
    
          Draw the run_request.help text using draw_text(), analogous to drawing req_info.help.
    stevenyvr987 committed Jul 26, 2019
    Configuration menu
    Copy the full SHA
    b8751cb View commit details
    Browse the repository at this point in the history
  3. Draw comment text in help view in alignment

    Add code to align comment text when shown in the help screen. Comment text are drawn on the right-hand side of an 'action' field.
    
    Change the calculation of field width: only key bindings with comment text will participate in calculating the field width. Consequently, key bindings with no comments but with unusually long action names are allowed to overflow the field.
    
    1. keys.h
    
       Add a name field to struct run_request, analogous to the name field in struct req_info.
    
    2. keys.c
    
       a. add_run_request()
    
          * Load run_request.name with a displayable version of **argv, using new function argv_to_string_alloc_prefix().
          * Include run_request.flags as a string prefix.
    
    3. help.c
    
       a. help_keys_visitor()
    
          * If run_request.help text is present, update help_state.name_width with strlen(run_request.name), so that drawing run_request.help will be aligned.
          * We can also do the same for req_info.help text: calculate the maximum field width only if req_info.help text is available.
    
       b. help_draw()
    
          * Analogous to drawing req_info.name as a LINE_HELP_ACTION, draw run_request.name using draw_field(), which replaces the current method of drawing **argv using draw_formatted(). We do this only if run_request.help text is present, otherwise, we draw run_request.name as free-form text.
          * Do the same for req_info.name. In this way, the code for drawing both types of requests are more similar.
    stevenyvr987 committed Jul 26, 2019
    Configuration menu
    Copy the full SHA
    ddae6be View commit details
    Browse the repository at this point in the history
  4. Update tests

    1. help/default-test
    
       The action name field is wider causing re-alignment of help text.
    
    2. tigrc/parse-test
    
       Comment for a key binding is now exposed as help text.
    
    3. help/user-command-comment-test
    
       Add a new test for defining user comments for user commands.
    stevenyvr987 committed Jul 26, 2019
    Configuration menu
    Copy the full SHA
    54db1af View commit details
    Browse the repository at this point in the history
  5. Ensure that comment text in all keybindings is searchable

    1. help.c
    
       a. help_grep()
    
          For keybinding for each run request, include any help text in the text line so that it can participate in grep operations.
    stevenyvr987 committed Jul 26, 2019
    Configuration menu
    Copy the full SHA
    852192d View commit details
    Browse the repository at this point in the history
  6. Cache key strings calculated during help_open() so that help_draw() d…

    …oes not need to recalculate them
    
    1. help.c
    
       a. struct help
    
          Add a key field to cache key strings calculated during help_open() so that help_draw() does not need to recalculate.
    
       b. help_keys_visitor()
    
          Cache the available key string in help.key.
    
       c. help_draw(), help_grep()
    
          Use cached help.key string instead of recalculating the key string.
    
       d. help_open()
    
          Free any key strings that have been cached in the help struct to prevent memory leak during a refresh of help screen.
    stevenyvr987 committed Jul 26, 2019
    Configuration menu
    Copy the full SHA
    dcfe1fd View commit details
    Browse the repository at this point in the history