dispatch.doc 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. Notes on Defining Commands and Modes
  2. Cris Perdue
  3. 8/9/82
  4. File: pe:dispatch.doc
  5. These notes should be of use to anyone wishing to customize EMODE
  6. by defining commands (keystrokes) or new modes. Most of the
  7. current mode and keystroke definitions are contained in
  8. PE:DISPCH.SL. Read it for examples and the keystroke-function
  9. associations.
  10. define_prefix_character(char, prompt)
  11. Char must be a single character, possibly with Control and/or
  12. Meta turned on. This is used for "true prefix characters" such
  13. as CTRL-X and META-X, not prefixes for obtaining control or meta
  14. through multiple keystrokes. Those are defined using
  15. AddToKeyList and EstablishCurrentMode.
  16. AddToKeyList(listname, char, opr)
  17. Adds a keystroke-operation association to a "key list", whose
  18. name, an atom, is passed in. The value of the atom must be the
  19. actual list. See the information on CharSequence, below, for the
  20. format of the chr parameter. The opr must be a function of no
  21. arguments. Its value is ignored. AddToKeyList may also be used
  22. to change an association in a keylist. Three existing lists are
  23. BasicDispatchList, ReadOnlyTextDispatchList, and
  24. TextDispatchList.
  25. BasicDispatchList includes commands that do not modify the buffer
  26. and do not have to do with manipulating text in any way.
  27. ReadOnlyTextDispatchList contains the commands that have to do
  28. with manipulating text, but that do not modify the buffer.
  29. This list is for support of read-only buffers.
  30. TextDispatchList contains commands that modify the buffer.
  31. CharSequence([char])
  32. This is a macro analogous to "char". Where char takes a single
  33. "character specification", CharSequence takes a sequence. Both
  34. char and CharSequence forms may be used in the specification of
  35. KeyLists. At present two characters is the maximum sequence, due
  36. to the implementation of the actual dispatcher used when the user
  37. types commands to EMODE.
  38. SetKey(char opr)
  39. It is generally a mistake to use this function directly, but it
  40. is used internally be EstablishCurrentMode to activate a keylist.
  41. Takes a character as produced by "char" or a character sequence
  42. as produced by "CharSequence" and installs it in the (global)
  43. command key lookup tables. The first character of any character
  44. sequence must be defined as a prefix character. If the specified
  45. character is upper case, the corresponding lower case character
  46. is also defined.
  47. Does not add the definition to any mode, nor permanently to the
  48. buffer, so use things like AddToKeyList at user level.
  49. MODES
  50. AlterBufferEnv(BufferName, 'ModeEstablishExpressions, Exprs)
  51. Every buffer carries around an environment, which includes a list
  52. of PSL expressions that set up its current mode. To change
  53. modes, alter the ModeEstblishExpressions part of the buffer's
  54. environment as shown. The expressions will be evaluated in
  55. reverse order (first one last) immediately and then whenever the
  56. mode is "established" with EstablishCurrentMode. See
  57. PE:DISPCH.SL for examples of modes, including FundamentalTextMode.
  58. Expressions of the form (SetKeys <variable>) set up the
  59. keystroke-operation associations in a keylist.
  60. EstablishCurrentMode()
  61. Activates the current mode with its keylists. Key definitions
  62. made by AddToKeyList don't take effect until this is performed
  63. even if the keylist changed is part of the current mode.