The context menu in Eddie puts a host of various editing commands at your fingertips. Like other menus in Eddie, the context menu is dynamic, hiding a number of shortcuts behind modifier key shortcut combinations.
The menu is configurable via UserStartup, allowing you to add commands that are part of your daily workflow. To add a menu item, separator item or a submenu to the context menu, use the AddContextUserMenu command:
AddContextUserMenu [-name <name> | -submenu <name>]
[-toSubmenu <name>] [-afterItem <name>]
[-separator | -shellCommand <command> | -toClipboard <string>]
[-shortcut <shortcut>]
-name specifies the name of the added menu item. -submenu inserts a new submenu with a specified name. -toSubmenu specifies a submenu of the parent menu to which to add the item (or submenu). -afterItem specifies after which item to insert the new item or submenu. If unspecified, the new item/submenu is added to the end.
-toClipboard allows you configuring the menu item to insert a specific string, based on your current selection, to the clipboard. The string may contain symbolic values that get evaluated at the time of invoking the menu item:
AddContextUserMenu -name "Copy as breakpoint" -toClipboard "b $DOCUMENT_NAME:$SELECTED_LINE"
If you use "Copy as breakpoint" configured per this example, it will place the text "b ContextMenu.cpp:213" onto the clipboard. This text can be passed directly to lldb or gdb to set the breakpoint in the file/on the line you had selected by evaluating the symbolic values $DOCUMENT_NAME and $SELECTED_LINE, respectively.
For the list of all the symbolic values available, check here. Symbolic values get substituted by the text they represent at the time the respective menu item is invoked.-shellCommand lets you configure the menu item to execute a specified shell command using context from the current selection:
AddContextUserMenu -name "Sort Selection" -shellCommand "sort -f < $_AS > $AS_"
Here $_AS represents a stream that produces the current selection in the active window. This text gets piped through a shell command sort -f and gets written to $AS_, a stream that writes out text into the current selection in the active window. See a full list of Eddie-specific shell environment variables for more details.
If the command string contains any symbolic values, these all get evaluated and replaced by the actual string before the shell command is executed.
AddContextUserMenu -name "Today's date" -shellCommand "/bin/date +%e-%b-%Y" -shortcut Control-D
Note that here the shell command doesn't use $AS_ to redirect the output, a simpler setup with only slightly different results. As the command is invoked, any of it's output is directed into the current selection. Unlike with > $AS_, the output is merely appended after the originally selected text, rather than replacing it.
AddContextUserMenu -name "lowercase" -shellCommand "perl -pe '$_=lc' <$_AS >$AS_"
Perl with it's rich regular expressions is particularly handy when adding user menu items.
Some other useful custom menu item examples:
AddContextUserMenu -name "svn diff" -shellCommand "svn diff `cat $_AS` |tellEddie --noSave"
AddContextUserMenu -name "svn revert" -shellCommand "svn revert `cat $_AS`"
Similar to the way you can configure the Context Menu, you can also add user defined menu commands to the "Commands" submenu in the Edit menu, using the AddEditUserMenu keyword:
AddEditUserMenu [-name <name> | -submenu <name>]
[-toSubmenu <name>] [-afterItem <name>]
[-separator | -shellCommand <command> | -toClipboard <string>]
[-shortcut <shortcut>]