example _tasks.py
The complete grammar (called with show tasks):
--- grammar: #commands for switching tasks: exported = (task)({taskcount}|{application}|Back); exported = ( | (task))({taskaction}); #commands for positioning (moving) and resizing tasks: exported = (|(task)) position []; exported = ( | (task)) move (|) [||||]; exported = ( | (task)) (stretch|shrink) (|) [||||]; #directional specifications: = {degrees} degrees; = {directionplus}; # size specifications: = {pixelcount} [pixels]; = {sizecount} centimeters; = {sizecount} millimeters; = {sizecount} inches; = {percentcount} percent; #commands for recording taskbar and clock positions: exported = ('get task position') ({taskcount}|clock); # here are the older commands: # icon (system tray) commands: exported = (icon) ({iconcount} |{character}|( [{iconcount}])) [{iconaction}]; exported = (icon) {iconaction}; = {direction}; # windows inside an application: exported = (Window) ({windowcount}|Back|Previous|Next); # miscelaneous: exported = ('switch file to') {switchapp}; exported = 'remove cursor'; exported = convert file to (windows|dos|unix);
A lot of the functions are DocstringGrammar style rule or subrule functions:
def rule_taskswitch(self, words): """#commands for switching tasks: (task)({taskcount}|{application}|Back) """ ...
or
def subrule_directionplus(self, words): '{directionplus}' # just defining the directionplus list
or
def subrule_pixels(self, words): """ # size specifications: {pixelcount} [pixels] """ # giving an optional word and also comment in the specification
But part of the rules are defined as:
gramSpec = """ # here are the older commands: # icon (system tray) commands: exported = (icon) ({iconcount} |{character}|( [{iconcount}])) [{iconaction}]; exported = (icon) {iconaction}; = {direction}; # windows inside an application: exported = (Window) ({windowcount}|Back|Previous|Next); ... """
with functions like:
def gotResults_thisicon(self, words, fullResults): """do actions on active icon""" ... |