import re # Example plugin for EditorFunctions type plugins # # The plugin allows to install new menu items and toolbar items and register a # a function with each that is called. The function must accept one argument which # is the instance of PersonalWikiFrame providing access to the editor and the data store. # # To register a menu item implement the function describeMenuItem to return a # sequence of tuples at least containing the callback function, the item string # and an item tooltip (see below for details). # # To register a toolbar item implement the function describeToolbarItem to return # a tuple at least containing the callback function, item label, tooltip and icon. # # both register functions must accept one argument which is again the # PersonalWikiFrame instance # descriptor for EditorFunctions plugin type WIKIDPAD_PLUGIN = (("MenuFunctions",1),) def describeMenuItems(wiki): """ wiki -- Calling PersonalWikiFrame Returns a sequence of tuples to describe the menu items, where each must contain (in this order): - callback function - menu item string - menu item description (string to show in status bar) It can contain the following additional items (in this order), each of them can be replaced by None: - icon descriptor (see below, if no icon found, it won't show one) - menu item id. The callback function must take 2 parameters: wiki - Calling PersonalWikiFrame evt - wx.CommandEvent An icon descriptor can be one of the following: - a wx.Bitmap object - the filename of a bitmap (if file not found, no icon is used) - a tuple of filenames, first existing file is used """ return ((sortSelection, u"Sort selected text" + u"\tCtrl-Alt-S", u"Sort selected text"),) # # Sort the currently marked/selected/highlighted text alphabetically. # def sortSelection(wiki, evt): import string editor = wiki.getActiveEditor() lines = sorted(editor.GetSelectedText().split("\n")) editor.ReplaceSelection(string.join(lines, "\n"))