27.2 Command Tables

There are four main styles of interaction: keyboard interaction using a command- line processor, keyboard interaction using keystroke accelerators, mouse interaction via command menus, and mouse interaction via translators. A command table is an object that serves to mediate between an application frame, a set of commands, and the four interaction styles. Command tables contain the following information: [annotate]

[command table, Concept← A Glossary]
[command table, Concept← 27.2 Command Tables, command-table-complete-input]
[command table, Concept← 27.2 Command Tables, command-table-inherit-from]
[command table, Concept← 27.2 Command Tables, command-table-name]
[command table, Concept← 27.2 Command Tables, command-table-p]
[command table, Concept← 23.7.2 Presentation Translator Functions, find-presentation-translators]

We say that a command is present in a command table when it has been added to that command table. We say that a command is accessible in a command table when it is present in that command table or is present in any of the command tables from which that command table inherits. [annotate]

command-table   [Protocol Class]
          

The protocol class that corresponds to command tables. If you want to create a new class that behaves like a command table, it should be a subclass of command-table. All instantiable subclasses of command-table must obey the command table protocol. Members of this class are mutable. [annotate]

[annotate]

command-table-p  object [Protocol Predicate]
          

Returns true if object is a command table, otherwise returns false. [annotate]

[annotate]

standard-command-table   [Class]
          

The instantiable class that implements command tables, a subclass of command-table. make-command-table returns objects that are members of this class. [annotate]

Minor issue: Do we really want to advertise these classes, since all the functions below are vanilla functions instead of generic functions? Or should we make those functions be generic functions? --- SWM [annotate]

[annotate]

command-table-name  command-table [Generic Function]
          

Returns the name of the command table command-table. [annotate]

[annotate]

command-table-inherit-from  command-table [Generic Function]
          

Returns a list of the command tables from which the command table command-table inherits. This function returns objects that reveal CLIM's internal state; do not modify those objects. [annotate]

[annotate]

define-command-table  name &key inherit-from menu inherit-menu [Macro]
          

Defines a command table whose name is the symbol name. The new command table inherits from all of the command tables specified by inherit-from, which is a list of command table designators (that is, either a command table or a symbol that names a command table). The inheritance is done by union with shadowing. If no inheritance is specified, the command table will be made to inherit from CLIM's global command table. (This command table contains such things as the "menu" translator that is associated with the right-hand button on pointers.) [annotate]

If inherit-menu is true, the new command table will inherit the menu items and keystroke accelerators from all of the inherited command tables. If it is false (the default), no menu items or keystroke accelerators will be inherited. [annotate]

Note:

The handling of keystroke accelerators described here is inconsistent with the text earlier on this page, where it says "The keystroke accelerator table does not contain any items inherited from superior command tables". Which is it to be? (I would rather have optional inheritance rather than no inheritance, but I don't know what classic clim does)

[edit]-- Daniel Barlow 2005-06-28 14:18Z
 

menu can be used to specify a menu for the command table. The value of menu is a list of clauses. Each clause is a list with the syntax (string type value &key keystroke documentation text-style), where string, type, value, keystroke, documentation, and text-style are as for add-menu-item-to-command-table. [annotate]

If the command table named by name already exists, define-command-table will modify the existing command table to have the new value for inherit-from and menu, and leaves the other attributes for the existing command table alone. [annotate]

Note: What about the inherit-menu value? [edit]-- DK 2020-10-22 13:23Z
 

None of define-command-table's arguments are evaluated. [annotate]

[annotate]

make-command-table  name &key inherit-from menu inherit-menu (errorp t) [Function]
          

Creates a command table named name. inherit-from, menu, and inherit-menu are the same as for define-command-table. make-command-table does not implicitly include CLIM's global command table in the inheritance list for the new command table. If the command table already exists and errorp is true, the command-table-already-exists error will be signalled. If the command table already exists and errorp is false, then the old command table will be discarded. The returned value is the command table. [annotate]

[annotate]

find-command-table  name &key (errorp t) [Function]
          

Returns the command table named by name. If name is itself a command table, it is returned. If the command table is not found and errorp is true, the command-table-not-found error will be signalled. [annotate]

[annotate]

command-table-error   [Error Condition]
          

The class that is the superclass of the following four conditions. This class is a subclass of error. [annotate]

Note: It probably means "...superclass of the following five conditions." [edit]-- Christophe Rhodes 2006-04-21 12:13Z
 

command-table-error and its subclasses must handle the :format-string and :format-arguments initargs, which are used to specify a control string and arguments for a call to format. [annotate]

[annotate]

command-table-not-found   [Error Condition]
          

The error that is signalled by such functions as find-command-table when a command table is not found. [annotate]

[annotate]

command-table-already-exists   [Error Condition]
          

The error that is signalled when the programmer tries to create a command table that already exists. [annotate]

[annotate]

command-not-present   [Error Condition]
command-not-accessible   [Error Condition]
command-already-present   [Error Condition]
add-command-to-command-table  command-name command-table &key name menu keystroke (errorp t) [Function]
          

Adds the command named by command-name to the command table specified by the command table designator command-table. [annotate]

name is the command-line name for the command, and can be nil, t, or a string. When it is nil, the command will not be available via command-line interactions. When it is a string, that string is the command-line name for the command. When it is t, the command-line name is generated automatically by calling command-name-from-symbol on command-name. For the purposes of command-line name lookup, the character case of name is ignored. [annotate]

menu is a menu item for the command, and can be nil, t, a string, or a cons. When it is nil, the command will not be available via menus. When it is a string, the string will be used as the menu name. When menu is t and name is a string, then name will be used as the menu name. When menu is t and name is not a string, an automatically generated menu name will be used. When menu is a cons of the form (string . menu-options), string is the menu name and menu-options consists of keyword-value pairs. The valid keywords are :after, :documentation, and :text-style, which are interpreted as for add-menu-item-to-command-table. [annotate]

The value for keystroke is either keyboard gesture name or nil. When it is a gesture name, it is the keystroke accelerator for the command; otherwise the command will not be available via keystroke accelerators. [annotate]

If the command is already present in the command table and errorp is true, the command-already-present error will be signalled. When the command is already present in the command table and errorp is false, then the old command-line name, menu, and keystroke accelerator will first be removed from the command table. [annotate]

[annotate]

remove-command-from-command-table  command-name command-table &key (errorp t) [Function]
          

Removes the command named by command-name from the command table specified by the command table designator command-table. [annotate]

If the command is not present in the command table and errorp is true, the command-not-present error will be signalled. [annotate]

[annotate]

command-name-from-symbol  symbol [Function]
          

Generates a string suitable for use as a command-line name from the symbol symbol. The string consists the symbol name with the hyphens replaced by spaces, and the words capitalized. If the symbol name is prefixed by "COM-", the prefix is removed. For example, if the symbol is com-show-file, the result string will be "Show File". [annotate]

[annotate]

do-command-table-inheritance  (command-table-var command-table) &body body [Macro]
          

Successively executes body with command-table-var bound first to the command table specified by the command table designator command-table, and then (recursively) to all of the command tables from which command-table inherits. [annotate]

The command-table-var argument is not evaluated. body may have zero or more declarations as its first forms. [annotate]

[annotate]

map-over-command-table-commands  function command-table &key (inherited t) [Function]
          

Applies function to all of the commands accessible in the command table specified by the command table designator command-table. function must be a function that takes a single argument, the command name; it has dynamic extent. [annotate]

If inherited is false, this applies function only to those commands present in command-table, that is, it does not map over any inherited command tables. If inherited is true, then the inherited command tables are traversed in the same order as for do-command-table-inheritance. [annotate]

[annotate]

map-over-command-table-names  function command-table &key (inherited t) [Function]
          

Applies function to all of the command-line name accessible in the command table specified by the command table designator command-table. function must be a function of two arguments, the command-line name and the command name; it has dynamic extent. [annotate]

If inherited is false, this applies function only to those command-line names present in command-table, that is, it does not map over any inherited command tables. If inherited is true, then the inherited command tables are traversed in the same order as for do-command-table-inheritance. [annotate]

[annotate]

command-present-in-command-table-p  command-name command-table [Function]
          

Returns true if the command named by command-name is present in the command table specified by the command table designator command-table, otherwise returns false. [annotate]

[annotate]

command-accessible-in-command-table-p  command-name command-table [Function]
          

If the command named by command-name is not accessible in the command table specified by the command table designator command-table, then this function returns nil. Otherwise, it returns the command table in which the command was found. [annotate]

[annotate]

find-command-from-command-line-name  name command-table &key (errorp t) [Function]
          

Given a command-line name name and a command table, returns two values, the command name and the command table in which the command was found. If the command is not accessible in command-table and errorp is true, the command-not-accessible error will be signalled. command-table is a command table designator. [annotate]

find-command-from-command-line-name ignores character case. [annotate]

[annotate]

command-line-name-for-command  command-name command-table &key (errorp t) [Function]
          

Returns the command-line name for command-name as it is installed in command-table. command-table is a command table designator. [annotate]

If the command is not accessible in command-table or has no command-line name, then there are three possible results. If errorp is nil, then the returned value will be nil. If errorp is :create, then a command-line name will be generated, as described in add-command-to-command-table. Otherwise, if errorp is t, then the command-not-accessible error will be signalled. The returned command-line name should not be modified. [annotate]

This is the inverse of find-command-from-command-line-name. It should be implemented in such as way that it is fast, since it may be used by presentation translators to produce pointer documentation. [annotate]

[annotate]

command-table-complete-input  command-table string action &key frame [Function]
          

A function that can be used as in conjunction with complete-input in order to complete over all of the command lines names accessible in the command table command-table. string is the input string to complete over, and action is as for complete-from-possibilities. [annotate]

frame is either an application frame, or nil. If frame is supplied, no disabled commands should be offered as valid completions. [annotate]

command-table-complete-input could be implemented by collecting all of the command line names accessible in the command table and then calling complete-from-possibilities, or it could be implemented more efficiently than that (such as by caching a sorted list of command line names and using a binary search). [annotate]

[annotate]

global-command-table   [Command Table]
          

The command table from which all other command tables inherit by default. Programmers should not explicitly add anything to or remove anything from this command table. CLIM can use this command to store internals or system-wide commands and translators (for example, the translator that implements the "identity" translation from a type to itself). Programmers should not casually install any commands or translators into this command table. [annotate]

[annotate]

user-command-table   [Command Table]
          

A command table that can be used by the programmer for any purpose. CLIM does not use it for anything, and its contents are completely undefined. [annotate]

[annotate]