Hi Bram,

>>
>> > > > When trying to develop tests for the menu functionality, I realized
>> > > > that there is no function to get information about the menu items.
>> > > > As part of PR #5760, I have added a new menu_getprop() function
>> > > > that returns information about the specified menu item(s).
>> > > > The help text for this new function is below. Let me know if you
>> have
>> > > > any comments/suggestions.
>> > >
>> > > Menus are very much like mappings.  Can we make this work more or less
>> > > like maparg() with the {dict} argument TRUE?
>> > >
>> > >
>> > One difference compared to the maps is that a given menu can have
>> > submenus. So we need to return information about the submenus also.
>> > Otherwise it will be difficult to iterate over all the submenus of a
>> given
>> > menu item.
>>
>> Sure, it won't be exactly the same.
>>
>> I think we always identify menus by their name, or path of names.  Thus
>> the submenus could be returned as a list of names.  You could then get
>> more info by using the function on the root name plus the submenu name.
>> That would need to be supported anyway.  Does that sound right?
>>
>
> Yes. I have updated the PR to add the menu_info() function which is modeled
> after the maparg() function incorporating your comments.
>
>
The updated help text for the menu_info() function is below. I have updated
the PR with this change and the new tests for menu.c. It is now ready for
inclusion.

Regards,
Yegappan

===================================================================
menu_info({name} [, {mode}]) *menu_info()*
Return information about the specified menu {name} in mode {mode}. The menu
name should be specified without the shortcut character ('&').

    {mode} can be one of these strings:
        "n" Normal
        "v" Visual (including Select)
        "o" Operator-pending
        "i" Insert
        "c" Cmd-line
        "s" Select
        "x" Visual
        "t" Terminal-Job
        "" Normal, Visual and Operator-pending
       "!" Insert and Cmd-line

When {mode} is omitted, the modes for "" are used.

Returns a |Dictionary| containing the following items:

    accel menu item accelerator text |menu-text|
    display display name (name without '&')
    enabled v:true if this menu item is enabled
                 Refer to |:menu-enable|
    icon name of the icon file (for toolbar) |toolbar-icon|
    iconidx index of a built-in icon
    modes modes for which the menu is defined. In addition
                to the modes mentioned above, these characters
                will be used:
                       " " Normal, Visual and Operator-pending
    name menu item name.
    noremenu v:true if the {rhs} of the menu item is not
                     remappable else v:false.
    priority menu order priority |menu-priority|
    rhs right-hand-side of the menu item. The returned
          string has special characters translated like
          in the output of the ":menu" command listing.
          When the {rhs} of a menu item is empty, then
          "<Nop>" is returned.
    script v:true if script-local remapping of {rhs} is
             allowed else v:false.  See |:menu-script|.
    shortcut shortcut key (character after '&' in
                 the menu name) |menu-shortcut|
    silent v:true if the menu item is created
             with <silent> argument |:menu-silent|
    submenus |List| containing the names of
                     all the submenus.  Present only if the menu
                     item has submenus.

Returns an empty dictionary if the menu item is not found.

Examples: >
    :echo maparg('Edit.Cut')
    :echo maparg('File.Save', 'n')
<
Can also be used as a |method|: >
    GetMenuName()->maparg('v')

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7np0zu0Wck49P054qBDqByub8wn7Q5JKdZ04tq20MFf%2Bw%40mail.gmail.com.

Raspunde prin e-mail lui