home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / the25.zip / thesrc251.zip / demo.the < prev    next >
Text File  |  1997-11-10  |  13KB  |  351 lines

  1. /**/
  2. 'rexxout file 5000'
  3. Call Initialise
  4. Do Forever
  5.    'reserved * off'
  6.    'reserved' midline-2 Centre('Select the category of demonstration',numcols)
  7.    'reserved' midline-1
  8.    prefix = (numcols-25) % 2
  9.    'reserved' midline   Copies(" ",prefix)||'1.  THE concepts'
  10.    'reserved' midline+1 Copies(" ",prefix)||'2.  Configuration of THE'
  11.    'reserved' midline+2 Copies(" ",prefix)||'3.  Some THE commands'
  12.    'reserved' midline+3 Copies(" ",prefix)||'4.  Navigating through THE'
  13.    'reserved' midline+4 Copies(" ",prefix)||'Q.  Quits the demo'
  14.    rc = menuopt()
  15.    Select
  16.      When rc = 1 Then Call concepts numlines
  17.      When rc = 2 Then Call config numlines, reserved_colour
  18.      When rc = 3 Then Call commands numlines
  19.      When rc = 4 Then Call navigating numlines
  20.      Otherwise Nop
  21.    End
  22.    Call Restart
  23. End
  24. 'reserved * off'
  25. 'curline' save_curline
  26. Return
  27.  
  28. /*---------------------------------------------------------------------------*/
  29. concepts: Procedure Expose monitor.
  30. /*---------------------------------------------------------------------------*/
  31. Parse Arg numlines .
  32. If monitor.1 = 'MONO' Then
  33.   Do
  34.     norm. = 'normal'
  35.     high = 'reverse'
  36.     'color prefix normal bold'
  37.     'color idline normal bold'
  38.     'color statarea normal bold'
  39.     highlight_text = 'in reverse video'
  40.   End
  41. Else
  42.   Do
  43.     norm.1 = 'grey blue'
  44.     norm.2 = 'black cyan'
  45.     norm.3 = 'blue white'
  46.     norm.4 = 'blue white'
  47.     norm.5 = 'white blue'
  48.     norm.6 = 'black cyan'
  49.     high = 'white black'
  50.     highlight_text = 'with white writing on black background'
  51.   End
  52.  
  53. precmd.   = ''
  54. precmd.2  = "colour filearea" high
  55. precmd.3  = "colour prefix" high
  56. precmd.4  = "colour statarea" high
  57. precmd.5  = "colour idline" high
  58. precmd.6  = "colour curline" high
  59. precmd.7  = "colour cmdline" high
  60. precmd.8  = ""
  61.  
  62. command.1  = "0"
  63. command.2  = "0 colour filearea" norm.1
  64. command.3  = "0 colour prefix" norm.2
  65. command.4  = "0 colour statarea" norm.3
  66. command.5  = "0 colour idline" norm.4
  67. command.6  = "0 colour curline" norm.5
  68. command.7  = "0 colour cmdline" norm.6
  69. command.8  = "0"
  70. command.0  = 8
  71.  
  72. rsrvd_start.  = -5
  73. rsrvd_start.8 = -4
  74.  
  75. rsrvd.1  = " The lines displayed here are reserved lines which can contain any text that\n",
  76.            "the user desires. They can appear anywhere within the window and can be\n",
  77.            "turned on or off with the SET RESERVED command.\n\n"
  78. rsrvd.2  = " The area of the screen that is displayed" highlight_text "\n",
  79.            "is the FILEAREA.  This is where the contents of the file being edited is\n",
  80.            "displayed.\n\n"
  81. rsrvd.3  = " The area of the screen that is displayed" highlight_text "\n",
  82.            "is the PREFIX AREA.  This is used to display the line number associated with\n",
  83.            "each line.  Editing commands can also be entered here.\n\n"
  84. rsrvd.4  = " The area of the screen that is displayed" highlight_text "\n",
  85.            "is the STATUS AREA.  This is used to display information about the current\n",
  86.            "editing session.\n\n"
  87. rsrvd.5  = " The area of the screen that is displayed" highlight_text "\n",
  88.            "is the IDLINE. The information in this area relates to the file currently\n",
  89.            "being edited.\n\n"
  90. rsrvd.6  = " The area of the screen that is displayed" highlight_text "\n",
  91.            "is the CURRENT LINE. All commands issued from the command line take effect\n",
  92.            "from this line.\n\n"
  93. rsrvd.7  = "off\nThe area of the screen that is displayed" highlight_text "\n",
  94.            "is the COMMAND LINE. THE commands can be entered in this area.\n\n"
  95. rsrvd.8  = "off\nThis completes the tour of the concepts and definitions of THE.\n"
  96.  
  97. 'reserved * off'
  98.  
  99. Call doit numlines
  100.  
  101. If monitor.1 = 'MONO' Then
  102.   Do
  103.     'color prefix reverse'
  104.     'color idline reverse'
  105.     'color statarea reverse'
  106.   End
  107. Return
  108.  
  109. /*---------------------------------------------------------------------------*/
  110. config: Procedure 
  111. /*---------------------------------------------------------------------------*/
  112. Parse Arg numlines, reserved_colour
  113. 'reserved * off'
  114.  
  115. command.1  = "0 'prefix off#cmdline off#idline off#statusline off#reserved * off'"
  116. command.2  = "0 'prefix on left#cmdline bot#idline on#statusline bot#cursor cmdline'"
  117. command.3  = "0 'prefix on right'"
  118. command.4  = "0 'cmdline top'"
  119. command.5  = "0 'prefix on left#cmdline bot'"
  120. command.6  = "0 'set compat xedit#msgline on -2 1'"
  121. command.7  = "0 'set compat kedit#msgline on -2 1'"
  122. command.8  = "0 'compat the#msgline on -2 1#colour reserved'" reserved_colour
  123. command.9  = "1"
  124. command.0  = 9
  125.  
  126. precmd. = ''
  127.  
  128. rsrvd_start.  = -7
  129. rsrvd_start.4 = -4
  130. rsrvd_start.5 = -3
  131. rsrvd_start.6 = -5
  132. rsrvd_start.7 = -5
  133. rsrvd_start.8 = -3
  134. rsrvd_start.9 = -3
  135.  
  136. rsrvd.1  = " One of THE's most powerful features is that it lets you change\n",
  137.            "the way the editor looks.  In it's default mode, THE has several\n",
  138.            "portions of the screen set aside for displaying useful information.\n",
  139.            "You may not want all of these areas displayed, or displayed in their\n",
  140.            "default areas. For example, lets hide all areas except for the FILEAREA.\n\n"
  141. rsrvd.2  = ''
  142. rsrvd.3  = "off\noff\noff\n",
  143.            "Now that we have everything back the way it was, lets move them around.\n\n",
  144.            "Lets move the PREFIX AREA to the right...\n\n"
  145. rsrvd.4  = 'off\n',
  146.            "... the COMMAND LINE to the top...\n\n"
  147. rsrvd.5  = " Now we'll put everything back the way it was...\n\n"
  148. rsrvd.6  = " THE makes it easy to set up your editing session to look like other editors\n",
  149.            "of its ilk; XEDIT and Kedit, with the SET COMPAT command...\n\n",
  150.            "First, lets look at SET COMPAT XEDIT...\n\n"
  151. rsrvd.7  = 'off\noff\n',
  152.            "... now Kedit's default look...\n\n"
  153. rsrvd.8  = " Now we'll put everything back the way it was...\n\n"
  154. rsrvd.9  = " This completes the section on configuring THE.\n\n"
  155.  
  156. Call doit numlines
  157.  
  158. Return
  159.  
  160. /*---------------------------------------------------------------------------*/
  161. commands: Procedure
  162. /*---------------------------------------------------------------------------*/
  163. Parse Arg numlines .
  164.  
  165. command.1  = "1 'all /the/ | /and/'"
  166. command.2  = "1 'set shadow off'"
  167. command.3  = "1 'all'"
  168. command.4  = '1'
  169. command.0  = 4
  170.  
  171. precmd. = ''
  172.  
  173. rsrvd_start. = -7
  174.  
  175. rsrvd.1  = " Lets look at some of the powerful features of THE...\n",
  176.            "The ALL command lets you edit a selected group of lines based on a target.\n",
  177.            'Assume we want to look at only those lines that contain the string "the"\n',
  178.            'or "and"\n',
  179.            'The command to do this is displayed on the COMMAND LINE.\n\n'
  180. rsrvd.2  = ' All lines that contain either "the" or "and" are now displayed.  Those lines\n',
  181.            'not displayed are replaced with SHADOW lines, indicating the number of lines\n',
  182.            'NOT matching the requested target.  These shadow lines can be made to not\n',
  183.            'appear by changing the setting of SHADOW.\n',
  184.            'The command to do this is displayed on the COMMAND LINE.\n\n'
  185. rsrvd.3  = 'off\noff\noff\n',
  186.            "To restore the display of all lines in the file issue the ALL command without\n",
  187.            "any arguments as displayed on the COMMAND LINE.\n\n"
  188. rsrvd.4  = 'off\noff\noff\noff\n',
  189.            "This completes the tour of the some of THE's most powerful and useful commands.\n\n"
  190.  
  191. Call doit numlines
  192.  
  193. 'set shadow on'
  194. 'cursor cmdline'
  195. Return
  196.  
  197. /*---------------------------------------------------------------------------*/
  198. navigating: Procedure
  199. /*---------------------------------------------------------------------------*/
  200. Parse Arg numlines .
  201.  
  202. command.1  = '1 cursor home'
  203. command.2  = "1 'cursor down#cursor down'"
  204. command.3  = "1 'text the'"
  205. command.4  = '1 sos undo'
  206. command.5  = '1 sos tabwordf'
  207. command.6  = '1 sos tabwordb'
  208. command.7  = '1 sos prefix'
  209. command.8  = '1 sos marginl'
  210. command.9  = '1 sos endchar'
  211. command.10 = '1 sos startendchar'
  212. command.11 = '1 bottom'
  213. command.12 = '1 top'
  214. command.13 = '1 forward'
  215. command.14 = '1 cursor screen 10 20'
  216. command.15 = '1 cursor 10 20'
  217. command.16 = '1'
  218. command.0  = 16
  219.  
  220. precmd. = ''
  221.  
  222. rsrvd_start. = -3
  223. rsrvd_start.13 = -4
  224. rsrvd_start.14 = -5
  225. rsrvd_start.15 = -5
  226. rsrvd_start.16 = -5
  227.  
  228. rsrvd.1  = " First, we'll move the cursor into the FILEAREA...\n\n"
  229. rsrvd.2  = " ...move the cursor down 2 lines...\n\n"
  230. rsrvd.3  = ' ...type the word "the"...\n\n'
  231. rsrvd.4  = " ...oops, we didn't want to do that, let's undo the change...\n\n"
  232. rsrvd.5  = " Move the cursor to the start of the next word...\n\n"
  233. rsrvd.6  = " Move the cursor to the start of the previous word...\n\n"
  234. rsrvd.7  = " Move the cursor into the PREFIX area...\n\n"
  235. rsrvd.8  = " ...and back to the FILEAREA.\n\n"
  236. rsrvd.9  = " Move to the end of the line...\n\n"
  237. rsrvd.10 = " ...and back to the start of the line.\n\n"
  238. rsrvd.11 = " Scroll to the bottom of the file...\n\n"
  239. rsrvd.12 = " ...and back to the top of file.\n\n"
  240. rsrvd.13 = " Scrolling backwards and forwards by a screen at a time is also available.\n",
  241.            "We'll go forward now\n\n"
  242. rsrvd.14 = "The cursor can be positioned at particular positions in the FILEAREA\n",
  243.            "by using the CURSOR SCREEN command The following positions the cursor at\n",
  244.            "row 10, column 20 relative to the top left corner of the FILEAREA.\n\n"
  245. rsrvd.15 = " The cursor can also be positioned at particular positions relative to\n",
  246.            "the top left corner of the physical window, provided the resulting position\n",
  247.            "is a valid position to be placed.\n\n"
  248. rsrvd.16 = "off\noff\nThis completes the examples of some of THE's cursor navigation.\n\n"
  249.  
  250. Call doit numlines
  251.  
  252. 'cursor cmdline'
  253. Return
  254.  
  255. /*---------------------------------------------------------------------------*/
  256. show_reserved: Procedure
  257. /*---------------------------------------------------------------------------*/
  258. Parse Arg numlines,start_line,rsrvd
  259. 'msgmode off'
  260. Do i = 0
  261.    Parse Var rsrvd line '\n' rsrvd
  262.    'reserved' start_line+i line
  263.    If rsrvd = '' Then Leave
  264. End
  265. 'msgmode on'
  266. Return
  267.  
  268. /*---------------------------------------------------------------------------*/
  269. doit: Procedure Expose command. precmd. rsrvd_start. rsrvd.
  270. /*---------------------------------------------------------------------------*/
  271. Parse Arg numlines .
  272. 'reserved * off'
  273. Do i = 1 To command.0
  274.   Call show_reserved numlines,rsrvd_start.i,rsrvd.i
  275.   If precmd.i \= '' Then
  276.     Do
  277.       cmd = precmd.i
  278.       Interpret cmd
  279.     End
  280.   If Word(command.i,1) = 1 Then
  281.     Do
  282.       'set linend off'
  283.       'cmsg' Strip(Subword(command.i,2),'B',"'");
  284.     End
  285.   Call getkey
  286.   'set linend on #'
  287.   cmd = Subword(command.i,2)
  288.   Interpret cmd
  289. End
  290. Return
  291.  
  292. /*---------------------------------------------------------------------------*/
  293. getkey: Procedure 
  294. /*---------------------------------------------------------------------------*/
  295. 'msg' Centre('Hit any key to continue...',74)
  296. 'refresh'
  297. 'readv key'
  298. If readv.1 = 'S-Q' Then 
  299.   Do
  300.     'reserved * off'
  301.     Exit
  302.   End
  303. Return
  304.  
  305. /*---------------------------------------------------------------------------*/
  306. menuopt: Procedure
  307. /*---------------------------------------------------------------------------*/
  308. 'refresh'
  309. 'readv key'
  310. If readv.1 = 'S-Q' Then
  311.   Do
  312.     'reserved * off'
  313.     Exit
  314.   End
  315. trace i
  316. If readv.1 >= 1 & readv.1 <= 4 Then Return readv.1
  317. 'msg' Centre('Please enter 1,2,3 or 4.',74)
  318. Return 0
  319.  
  320. /*---------------------------------------------------------------------------*/
  321. Restart:
  322. /*---------------------------------------------------------------------------*/
  323. 'cmsg'
  324. 'msgline on -2 1'
  325. ':2'
  326. 'cursor screen 10 15'
  327. 'cursor cmdline'
  328. 'extract /lscreen/version/monitor/fname/fpath/curline/'
  329. If monitor.1 = 'MONO' Then reserved_colour = 'bold'
  330. Else reserved_colour = 'blue white'
  331. 'colour reserved' reserved_colour
  332. numlines = lscreen.1
  333. numcols = lscreen.2
  334. midline = numlines % 2
  335. save_curline = curline.1
  336. 'curline 6'
  337. Return
  338.  
  339. /*---------------------------------------------------------------------------*/
  340. Initialise:
  341. /*---------------------------------------------------------------------------*/
  342. Call Restart
  343. 'reserved' numlines-8 ' This is an interactive demo of THE. The demo is simply a THE macro written in'
  344. 'reserved' numlines-7 " THE's macro language, REXX. All commands and statements used are valid THE or"
  345. 'reserved' numlines-6 " REXX commands. This demonstration will give you an idea of THE's power and"
  346. 'reserved' numlines-5 ' versatility.'
  347. 'reserved' numlines-4 ' To run the demonstration, just follow the instructions that are displayed'
  348. 'reserved' numlines-3 ' in this portion of the screen.'
  349. Call getkey
  350. Return
  351.