home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / DevTools / eText5 / Source / eText.subproj / eText.XText.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-01  |  7.4 KB  |  338 lines

  1. {\rtf0\ansi{\fonttbl\f0\fmodern Courier;\f1\ftech Symbol;\f2\fmodern Ohlfs;}
  2. \paperw11640
  3. \paperh18320
  4. \margl120
  5. \margr120
  6. {\colortbl;\red0\green0\blue0;}
  7. \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\f0\b0\i0\ulnone\fs24\fc0\cf0 //—————————————————————————————————————————————————————————————————————————————\
  8. //
  9. \i     
  10. \b FILENAME
  11. \b0 :    
  12. \b\i0 eText.XText.h \
  13.  
  14. \b0 //
  15. \i     
  16. \b SUMMARY
  17. \b0 :    
  18. \b\i0 Interface for the XText keybinding subsystem of eText
  19. \b0 \
  20. //    
  21. \b\i CATEGORY
  22. \b0 :
  23. \i0     
  24. \b XText
  25. \b0 \
  26. //    
  27. \b\i PROTOCOLS
  28. \b0 :
  29. \i0     
  30. \b Uses XTActions
  31. \b0 \
  32. //    
  33. \b\i INTERFACE
  34. \b0 :
  35. \i0     
  36. \b None
  37. \b0 \
  38. //    
  39. \b\i AUTHOR
  40. \b0 :        
  41. \b\i0 Rohit Khare, portions by Mike Dixon
  42. \b0 \
  43. //    
  44. \b\i COPYRIGHT
  45. \b0 :    
  46. \f1\i0 ½
  47. \f0\b 1993,94 California Institure of Technology, eText Project\
  48.  
  49. \b0 //—————————————————————————————————————————————————————————————————————————————\
  50. //    
  51. \b\i Description
  52. \b0\i0 \
  53. //        These methods deal with Mike Dixon's XText and XTActions.\
  54. //—————————————————————————————————————————————————————————————————————————————\
  55. //    
  56. \b\i History
  57. \b0\i0 \
  58. //    10/18/94:    
  59. \b Cleaned up for eText5.
  60. \b0 \
  61. //    08/05/94:    
  62. \b Completely Rearchitected for 5.0. RK
  63. \b0 \
  64. //—————————————————————————————————————————————————————————————————————————————\
  65. //    
  66. \b Imported Interfaces
  67. \b0 \
  68. //\
  69.     #import "
  70. \b eText.Class.h
  71. \b0 "\
  72.     #import "
  73. \b Kludges
  74. \b0 .subproj/
  75. \b ErrorStream.h
  76. \b0 "\
  77.     #import "
  78. \b XTAction.h
  79. \b0 "\
  80. \
  81. extern void 
  82. \b initbase_emacs
  83. \b0 (
  84. \b actionTbl
  85. \b0  actions, 
  86. \b NXZone
  87. \b0  *zone);\
  88. #define 
  89. \b BOF
  90. \b0  255 
  91. \i // begining of file (new in 0.9b2)
  92. \i0 \
  93. \
  94.  
  95. \i @interface eText(XText)\
  96.  
  97. \i0 //—————————————————————————————————————————————————————————————————————————————\
  98. //    
  99. \b XText0 Management
  100. \b0 \
  101. //\
  102.     - 
  103. \b setErrorStream
  104. \b0 :errs;\
  105.     - 
  106. \b errorStream
  107. \b0 ;\
  108.     \
  109.     - 
  110. \b setInitialAction
  111. \b0 :action;\
  112.     - 
  113. \b initialAction
  114. \b0 ;\
  115.     - 
  116. \b setNextAction
  117. \b0 :action;\
  118.     \
  119.     - 
  120. \b unboundKey
  121. \b0 ;\
  122.     - 
  123. \b keyDown
  124. \b0 :(
  125. \b NXEvent
  126. \b0  *) event;\
  127.     \
  128. //—————————————————————————————————————————————————————————————————————————————\
  129. //    
  130. \b XText Operations (emacs)
  131. \b0 \
  132. //\
  133.     - 
  134. \b goto
  135. \b0 :(int)pos 
  136. \b end
  137. \b0 :(int)end 
  138. \b mode
  139. \b0 :(int)mode;\
  140.     - 
  141. \b moveWord
  142. \b0 :(int)cnt 
  143. \b mode
  144. \b0 :(int)mode;\
  145.     - 
  146. \b moveChar
  147. \b0 :(int)cnt 
  148. \b mode
  149. \b0 :(int)mode;\
  150.     - 
  151. \b moveLine
  152. \b0 :(int)cnt 
  153. \b mode
  154. \b0 :(int)mode;\
  155.     - 
  156. \b lineBegin
  157. \b0 :(int)mode;\
  158.     - 
  159. \b lineEnd
  160. \b0 :(int)mode;\
  161.     - 
  162. \b docBegin
  163. \b0 :(int)mode;\
  164.     - 
  165. \b docEnd
  166. \b0 :(int)mode;\
  167.     - 
  168. \b collapseSel
  169. \b0 :(int)dir;\
  170.     - 
  171. \b transChars
  172. \b0 ;\
  173.     - 
  174. \b openLine
  175. \b0 ;\
  176.     - 
  177. \b scroll
  178. \b0 :(int)
  179. \b pages
  180. \b0  :(int)
  181. \b lines
  182. \b0 ;\
  183.     - 
  184. \b scrollIfRO
  185. \b0 :(int)
  186. \b pages
  187. \b0  :(int)
  188. \b lines
  189. \b0 ;\
  190.     - 
  191. \b insertChar
  192. \b0 :(
  193. \b NXEvent
  194. \b0  *)event;\
  195.     - 
  196. \b insertNextChar
  197. \b0 ;\
  198.  
  199. \i\fc1\cf1     // new to XText 0.9b2\
  200.  
  201. \i0     - 
  202. \b autoIndent
  203. \b0 ;\
  204.     - 
  205. \b match
  206. \b0 :(unsigned char *)
  207. \b LR
  208. \b0 ;\
  209.  
  210. \i     // useful methods to display character codes\
  211.  
  212. \i0     - 
  213. \b insertKeyCombination
  214. \b0 :(
  215. \b NXEvent
  216. \b0  *)event;\
  217.     - 
  218. \b insertKeyCombOfNextKey
  219. \b0 ;\
  220.  
  221. \i\fc0\cf0 \
  222. @end\
  223.  
  224. \i0 \
  225. //—————————————————————————————————————————————————————————————————————————————\
  226. // 
  227. \b Original Header Comments Follow
  228. \b0 \
  229. //\
  230. \
  231.  
  232. \i /*    This file is part of XText (version 0.9)\
  233.     Paul Griffin July 1995 No copyright.  Use at your own discretion. \
  234.     \
  235.     Based on XText 0.8\
  236.     Mike Dixon, April 1992    \
  237.     Copyright (c) 1992 Xerox Corporation.  All rights reserved.\
  238. \
  239. */\
  240. /*    This file is part of the XText package (version 0.8)\
  241.     Mike Dixon, April 1992\
  242.     \
  243.     Copyright (c) 1992 Xerox Corporation.  All rights reserved.\
  244. \
  245.     Use and copying of this software and preparation of derivative works based\
  246.     upon this software are permitted.  This software is made available AS IS,\
  247.     and Xerox Corporation makes no warranty about the software or its\
  248.     performance.\
  249. */\
  250. \
  251. #import <appkit/Text.h>\
  252. \
  253. /*    XText0 is the 'bare' extensible Text class; it provides the support for\
  254.     key bindings, but doesn't provide any of the useful methods you're likely\
  255.     to want to bind them to.\
  256. \
  257.     The instance variables are\
  258.         nextAction        the action that will interpret the next key\
  259.         initialAction    the basic action used to interpret keys (generally\
  260.                         an XTDispatchAction)\
  261.         errorStream        used to report errors\
  262. \
  263.     In normal operation nextAction == initialAction, but an action may\
  264.     change nextAction to cause the next key to be interpreted specially.\
  265.     For example, this is used to implement ctrl-q (quote next char), and\
  266.     could also be used to implement emacs-style prefix maps.\
  267. \
  268.     Most of the methods are all self-explanatory;  the ones that might not\
  269.     be are\
  270.         newFieldEditorFor:initialAction:estream:\
  271.                                 should be called from a window's delegate's\
  272.                                 getFieldEditor:for: method; returns an XText\
  273.                                 for editing the window's fields\
  274.         unboundKey                just beeps\
  275.         disableAutodisplay        like setAutodisplay:NO, except that it does\
  276.                                 nothing if this is a field editor (to work\
  277.                                 around a bug in text fields)\
  278. \
  279.     The default initialAction is nil, which just causes all key events to\
  280.     be handled by the superclass (i.e. Text).\
  281. */\
  282. /*    XText augments XText0 with a bunch of useful methods for emacs-like\
  283.     key bindings.\
  284. \
  285.     All of the cursor-movement methods take a 'mode' argument, which may\
  286.     be\
  287.         0        just move the point to new location\
  288.         1        delete to new location\
  289.         2        cut to new location\
  290.         3        extend selection to new location\
  291.     \
  292.     The methods are\
  293.         goto:end:mode:        implements all movement; second argument specifies\
  294.                             the other end of the selection when mode != 0\
  295.         moveWord:mode:        move n words forward from point (back if n<0)\
  296.         moveChar:mode:        move n chars forward from point (back if n<0)\
  297.         moveLine:mode:        move n lines down from point (up if n<0)\
  298.         lineBegin:            move to beginning of current line\
  299.         lineEnd:            move to end of current line\
  300.         docBegin:            move to beginning of document\
  301.         docEnd:                move to end of document\
  302.         collapseSel:        move to beginning of selection (dir<0), end of\
  303.                             selection (dir>0), or active end of sel (dir=0)\
  304.         transChars            transpose characters around point\
  305.         openLine            insert new line after point\
  306.         scroll::            scroll window n pages + m lines\
  307.         scrollIfRO::        scroll window n pages + m lines if doc is\
  308.                             read-only; returns nil if doc is editable\
  309.         insertChar:            inserts the character associated with a key event\
  310.         insertNextChar        sets nextAction so that the next key event will be\
  311.                             interpreted as a character\
  312. \
  313.         autoIndent            creates a new line with space and tab indentation\
  314.                             equal to the current line        \
  315.         match:"LR"            Finds previous correctly nested matched character\
  316.                              L and briefly displays it; then prints R.  \
  317.                             Useful for "()" "\{\}" and "[]".   \
  318.     \
  319. \
  320. \
  321.     When there is a non-empty selection, we keep track of which end is active\
  322.     (further movement commands will be relative to that end).  When we move\
  323.     up or down lines, we keep track of which column we started in and try to\
  324.     stick to it.  XText's instance variables are used to implement this\
  325.     behavior:\
  326.         posHint        the cp of the point; if this doesn't correspond to either\
  327.                     end of the selection, we put the point after the selection\
  328.         xHint        the column we're trying to keep the point in during\
  329.                     vertical movement\
  330.         xHintPos    xHint is only valid if this is the cp of the point\
  331.     ("cp" == character position)\
  332. \
  333.     This file also includes initbase_emacs, called by XTDispatchAction's\
  334.     initBase:estream: method when base == "emacs" to set up the default\
  335.     key bindings.\
  336. */
  337. }
  338.