1 USING: accessors ui.gestures help.markup help.syntax strings kernel
2 hashtables quotations words classes sequences namespaces make
7 { $description "A key which may be set in the hashtable passed to " { $link define-command } ". If set to a true value, the command does not take any inputs, and the value passed to " { $link invoke-command } " will be ignored. Otherwise, it takes one input." } ;
10 { $description "A key which may be set in the hashtable passed to " { $link define-command } ". If set to a true value, " { $link invoke-command } " will run the command in the listener. Otherwise it will run in the event loop." } ;
13 { $description "A key which may be set in the hashtable passed to " { $link define-command } ". The value is a string displayed as part of the command's documentation by " { $link $command-map } "." } ;
16 { $values { "target" object } { "command" "a command" } }
17 { $description "Invokes a command on the given target object." } ;
19 { invoke-command +nullary+ } related-words
22 { $values { "command" "a command" } { "str" string } }
23 { $description "Outputs a human-readable name for the command." }
26 "USING: io ui.commands ;"
28 ": com-my-command ( -- ) ;"
29 "\\ com-my-command command-name write"
34 HELP: command-description
35 { $values { "command" "a command" } { "str/f" { $maybe string } } }
36 { $description "Outputs the command's description." } ;
38 { command-description +description+ } related-words
41 { $values { "command" "a command" } { "word" word } }
42 { $description "Outputs the word that will be executed by " { $link invoke-command } ". This is only used for documentation purposes." } ;
45 { $values { "group" string } { "class" "a class word" } { "command-map" { $maybe command-map } } }
46 { $description "Outputs a named command map defined on a class." }
47 { $class-description "A command map stores a group of related commands. The " { $snippet "commands" } " slot stores an association list mapping gestures to commands, and the " { $snippet "blurb" } " slot stores an optional one-line description string of this command map."
49 "Command maps are created by calling " { $link <command-map> } " or " { $link define-command-map } "." } ;
52 { $values { "class" "a class word" } { "hash" hashtable } }
53 { $description "Outputs a hashtable mapping command map names to " { $link command-map } " instances." } ;
55 HELP: define-command-map
56 { $values { "class" "a class word" } { "group" string } { "blurb" { $maybe string } } { "pairs" "a sequence of gesture/word pairs" } }
58 "Defines a command map on the specified gadget class. The " { $snippet "blurb" } " is an optional description. The " { $snippet "pairs" } " parameter is a sequence of pairs " { $snippet "{ gesture word }" } ". The " { $snippet "gesture" } " may be " { $link f } " if you are defining a \"toolbar\" " { $snippet "group" } ". The " { $snippet "word" } "s must be valid commands; see " { $link define-command } "."
60 { $notes "Only one of " { $link define-command-map } " and " { $link set-gestures } " can be used on a given gadget class, since each word will overwrite the other word's definitions." } ;
63 { $values { "element" "a pair " { $snippet "{ class map }" } } }
64 { $description "Prints a command map, where the first element of the pair is a class word and the second is a command map name." } ;
67 { $values { "element" "a triple " { $snippet "{ class map command }" } } }
68 { $description "Prints the keyboard shortcut associated with " { $snippet "command" } " in the command map named " { $snippet "map" } " on the class " { $snippet "class" } "." } ;
71 { $values { "word" word } { "hash" hashtable } }
72 { $description "Defines a command. The hashtable can contain the following keys:"
74 { { $link +nullary+ } " - if set to a true value, the word must have stack effect " { $snippet "( -- )" } "; otherwise it must have stack effect " { $snippet "( target -- )" } }
75 { { $link +listener+ } " - if set to a true value, the command will run in the listener" }
76 { { $link +description+ } " - can be set to a string description of the command" }
80 ARTICLE: "ui-commands" "Commands"
81 "Commands are an abstraction layered on top of gestures. Their main advantage is that they are identified by words and can be organized into " { $emphasis "command maps" } ". This allows easy construction of buttons and tool bars for invoking commands."
82 { $subsections define-command }
83 "Command groups are defined on gadget classes:"
84 { $subsections define-command-map }
85 "Commands can be introspected and invoked:"
91 "Gadgets for invoking commands are documented in " { $link "ui.gadgets.buttons" } "."
93 "When documenting gadgets, command documentation can be automatically generated:"