File: macros

package info (click to toggle)
trn4 4.0-test76-15
  • links: PTS
  • area: non-free
  • in suites: lenny
  • size: 3,048 kB
  • ctags: 2,964
  • sloc: ansic: 48,338; sh: 6,770; tcl: 1,696; yacc: 660; perl: 108; makefile: 73
file content (62 lines) | stat: -rw-r--r-- 2,702 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
AUTOMATIC MACROS

On startup trn attempts to build a set of macros that map your keypad
arrow keys to useful functions.  These default actions are mentioned in
the prior description of each level's commands.  If you don't like this
(or trn gets it wrong), you can disable the automatic macros by using the
-A option.

CUSTOM MACROS

When trn starts up it looks for a file containing macro definitions (see
environment variables TRNMACRO and RNMACRO).  Any sequence of commands
may be bound to any sequence of keys, so you could re-map your entire
keyboard if you desire.  Blank lines or lines beginning with # in the
macro file are considered comments; otherwise trn looks for two fields
separated by white space.  The first field gives the sequence of
keystrokes that trigger the macro, and the second field gives the
sequence of commands to execute.  Both fields are subject to %
interpolation, which will also translate backslash and caret sequences.
(The keystroke field is interpreted at startup time, but the command
field is interpreted at macro execution time so that you may refer to %
values in a macro.)  For example, if you want to reverse the roles of
carriage return and space in trn

     ^J   \040
     ^M   \040
     \040 ^J

will do just that.  By default, all characters in the command field are
interpreted as the canonical trn characters, i.e. no macro expansion is
done.  Otherwise the above pair of macros would cause an infinite loop.
To force macro expansion in the command field, enclose the macro call
with ^( ... ^) thusly:

     @s   |mysavescript
     @w   w^(@s^)

You can use the %() conditional construct to construct macros that work
differently under different circumstances.  In particular, the current
mode (%m) of trn could be used to make a command that only works at a
particular level.  This is particularly vital for the selector which uses
most of the lower-case letters to select the associated item in its
display.  For example,

     a    %(%m=t?a:s art.hold\n)

will return the original letter (a) in the selector, and the command "s
art.hold\n" everywhere else.

     %(%{TERM}=vt100?^[[O)    /^J

will do the binding only if the terminal type is vt100, though if you
have many of these it would be better to have separate files for each
terminal.

If you want to bind a macro to a function key that puts a common garbage
character after the sequence (such as the carriage return on the end of
Televideo 920 function sequences), DO NOT put the carriage return into
all the sequences or you will waste a CONSIDERABLE amount of internal
storage.  Instead of "^AF^M", put "^AF+1", which indicates to trn that it
should gobble up one character after the F.