United States-English |
|
|
HP-UX Reference > Ssoftkeys(4)HP-UX 11i Version 3: February 2007 |
|
NAMEsoftkeys — keysh softkey file format BACKGROUNDkeysh softkey information is stored in the form of a softkey node hierarchy. The top level of this hierarchy represents the softkey commands themselves; lower levels represent various command options and parameters. The softkey labels form a window into this softkey node hierarchy through which the user can view and select eligible nodes. A node is eligible if it was:
When a softkey node is selected, it can enable or disable any of its siblings as appropriate. A new window into the softkey node hierarchy is then computed as follows:
This process of node display and selection continues until the user has entered a complete command. At that point, keysh performs the editrules associated with each of the selected softkey nodes. These editrules create the HP-UX command that is fed to the shell for execution. SOFTKEY FILE FORMATEach softkey file contains one or more softkey definitions, each of which is represented as a sub-hierarchy of softkey nodes. There are two basic types of softkey nodes:
Note that the keyword softkey can be used as a synonym for the keyword option. The basic softkey node definition is composed of the following components: {option|string} softkey attribute . . . ; Where softkey is the softkey node name from which the command-line text and softkey label are derived. If necessary, a single plus sign (+) within softkey can be used to force hyphenation of the softkey label at a syllable boundary. If a softkey node has an associated sub-menu, its trailing ; is replaced with a list of child nodes as follows: { softkey node . . . } Each softkey node can have the following optional attribute fields:
Arguments are as follows:
A typical backup softkey node definition resembles:
where literal is the literal text string to program the terminal function key with (if different than softkey). An unquoted hash-mark character (#) in a softkey file delimits a comment to the end of the line. Softkey Command TranslationTo translate softkey commands into HP-UX commands, keysh executes the editrules associated with each softkey selected by the user. These editrules create a word list via an awk-like editing language. This translated word list is then passed to the shell for execution. For a simple translation, this list might resemble:
Every time an editrule is invoked, the special constants last and next are defined to the index of the last word in the list (``2'' in this example) and the would-be-next word in the list (``3'' in this example), respectively. In addition, the constant argument is set equal to the user input for the softkey (e.g., *.c for the softkey corresponding to the file name in this example). Note that keysh automatically casts numbers and strings back and forth as necessary to carry out editrules. Also, variables are cleared only before the first editrule associated with a softkey command. All assigned variables are available to subsequent editrules. EditrulesAn editrule is a list of edit statements enclosed in curly-braces (i.e., { and }). An edit statement is:
ExpressionsA simple expression can be any of:
Simple expressions can be combined with any of:
The following functions are also supported and return the indicated results:
Assignments can be done with any of:
if StatementThe if statement is similar to the full-block mode if statement in awk, and is structured as follows: if(number) { edit statement . . . } else { edit statement . . . } Where the else part is optional. If number is non-zero, the first block of edit statements is executed. Otherwise, if the second block of edit statements is present, it is executed. Word Allocation StatementsWord allocation statements include the following:
HelptextEach softkey node can have an associated helptext, to be displayed upon a user request for help. This helptext is formatted on-the-fly and presented to the user through the preferred pager. The helptext format is an nroff-like language, supporting a subset of the man(5) macros used to write standard HP-UX manual entries. In particular, this subset includes:
Note that these macros are recognized anywhere in the input helptext, not just at the beginning of a line. Also, all macro arguments must be present, even if they consist of nothing more than a quoted empty string. EXAMPLESFor a custom cd command (see cd(1)): softkey cd editrule { append("cd"); } { softkey keysh-src disable all editrule { append("~/keysh/src"); } ; softkey keysh-test disable all editrule { append("~/keysh/test"); } ; softkey keysh-doc disable all editrule { append("~/keysh/doc"); } ; softkey demo disable all editrule { append("~/demo"); } ; softkey tmp disable all editrule { append("/tmp"); } ; string <dir> disable all editrule { append(argument); } required "Enter the name of the directory to move to." ; } For other examples, refer to the file /usr/lib/keysh/C/softkeys. |
Printable version | ||
|