home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume7 / crisp1.9 / part18 < prev    next >
Encoding:
Text File  |  1989-06-18  |  49.6 KB  |  1,913 lines

  1. Newsgroups: comp.sources.misc
  2. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  3. Subject: v07i038: CRISP release 1.9 part 17/32
  4. Organization: Reuters Ltd PLC, Marlow, England
  5. Reply-To: fox@marlow.UUCP (Paul Fox)
  6.  
  7. Posting-number: Volume 7, Issue 38
  8. Submitted-by: fox@marlow.UUCP (Paul Fox)
  9. Archive-name: crisp1.9/part18
  10.  
  11.  
  12.  
  13. #!/bin/sh
  14. # this is part 4 of a multipart archive
  15. # do not concatenate these parts, unpack them in order with /bin/sh
  16. # file src/crisp/makeman.m continued
  17. #
  18. CurArch=4
  19. if test ! -r s2_seq_.tmp
  20. then echo "Please unpack part 1 first!"
  21.      exit 1; fi
  22. ( read Scheck
  23.   if test "$Scheck" != $CurArch
  24.   then echo "Please unpack part $Scheck next!"
  25.        exit 1;
  26.   else exit 0; fi
  27. ) < s2_seq_.tmp || exit 1
  28. echo "x - Continuing file src/crisp/makeman.m"
  29. sed 's/^X//' << 'SHAR_EOF' >> src/crisp/makeman.m
  30. X            (+ " 2 \"Macros to help writing Programs\"\n" END_SECTION))))
  31. X        (process_file "features/Program.hlp")
  32. X        (insert (+ "\n" (+ START_SECTION 
  33. X            (+ " 2 \"Macros for Manipulating Regions\"\n" END_SECTION))))
  34. X        (process_file "features/Region.hlp")
  35. X        (insert (+ "\n" (+ START_SECTION 
  36. X            (+ " 2 \"Macros for accessing sub-shells\"\n" END_SECTION))))
  37. X        (process_file "features/Shell.hlp")
  38. X        (insert (+ "\n" (+ START_SECTION 
  39. X            (+ " 2 \"Macro for Counting Words.\"\n" END_SECTION))))
  40. X        (process_file "features/Wc.hlp")
  41. X        (insert (+ "\n" (+ START_SECTION 
  42. X            (+ " 2 \"Calculator\"\n" END_SECTION))))
  43. X        (process_file "features/Calc.hlp")
  44. X        (insert (+ "\n" (+ START_SECTION 
  45. X            (+ " 2 \"Ascii Wall Chart.\"\n" END_SECTION))))
  46. X        (process_file "features/Ascii.hlp")
  47. X    )
  48. X)
  49. X(macro chapter_5
  50. X    (                
  51. X        (read_file (+ BHELP "roff/Lang.mm"))
  52. X        (insert (+ "\n" (+ START_SECTION 
  53. X            (+ " 2 \"Macros and their Syntax\"\n" END_SECTION))))
  54. X        (process_file "lang/Macros.hlp")
  55. X        (insert (+ "\n" (+ START_SECTION 
  56. X            (+ " 2 \"Language Data Types\"\n" END_SECTION))))
  57. X        (process_file "lang/Vars.hlp")
  58. X        (insert (+ "\n" (+ START_SECTION 
  59. X            (+ " 2 \"The Macro Compiler\"\n" END_SECTION))))
  60. X        (process_file "lang/Compiler.hlp")
  61. X    )
  62. X)
  63. X(macro end_processing
  64. X    (
  65. X        (top_of_buffer)
  66. X        (translate "^.page_size$" PAGE_LENGTH 0)
  67. X        (top_of_buffer)
  68. X        (translate "CRISP" "\\\\fBCRISP\\\\fR" ST_GLOBAL)
  69. X        (top_of_buffer)
  70. X        (translate "BRIEF" "\\\\fBBRIEF\\\\fR" ST_GLOBAL)
  71. X        (top_of_buffer)
  72. X        (while (> (search_fwd "^.H") 0) (
  73. X            (down)
  74. X            (delete_line)
  75. X            (insert ".sp\n")
  76. X            ))
  77. X        (end_of_buffer)
  78. X        (insert "\n.TC\n")
  79. X        (switch MACROS
  80. X            ME            (me_end_processing)
  81. X            MS            (ms_end_processing)
  82. X            )
  83. X    )
  84. X)
  85. X# define    WORDFILE    "/tmp/word-file"
  86. X
  87. X(macro make_index
  88. X    (
  89. X        (int    srcbuf)
  90. X         
  91. X        (if (! INDEXING)
  92. X            (return))
  93. X        (= srcbuf (inq_buffer))
  94. X        
  95. X        (edit_file WORDFILE)
  96. X        (clear_buffer)
  97. X        (message "Inserting index entries...")
  98. X        
  99. X        (read_file (+ BHELP  "/sections/Arith"))
  100. X        (read_file (+ BHELP  "/sections/Buffer"))
  101. X        (read_file (+ BHELP  "/sections/Debug"))
  102. X        (read_file (+ BHELP  "/sections/Env"))
  103. X        (read_file (+ BHELP  "/sections/File"))
  104. X        (read_file (+ BHELP  "/sections/Kbd"))
  105. X        (read_file (+ BHELP  "/sections/List"))
  106. X        (read_file (+ BHELP  "/sections/Macro"))
  107. X        (read_file (+ BHELP  "/sections/Misc"))
  108. X        (read_file (+ BHELP  "/sections/Movement"))
  109. X        (read_file (+ BHELP  "/sections/Proc"))
  110. X        (read_file (+ BHELP  "/sections/Scrap"))
  111. X        (read_file (+ BHELP  "/sections/Screen"))
  112. X        (read_file (+ BHELP  "/sections/Search"))
  113. X        (read_file (+ BHELP  "/sections/String"))
  114. X        (read_file (+ BHELP  "/sections/Var"))
  115. X        (read_file (+ BHELP  "/sections/Window"))
  116. X        (sort_buffer)
  117. X        (uniq)
  118. X        (gen_index srcbuf WORDFILE)
  119. X        (set_buffer srcbuf)
  120. X    )
  121. X)
  122. X(macro gen_index
  123. X    (
  124. X        (string    
  125. X                    wordfile
  126. X                    word
  127. X                    raw_word        /* Word before quote_regexp gets hold of it*/
  128. X                    regexp1        /* Used for fast find of possible match */
  129. X                    regexp2        /* Used to locate exact match.             */
  130. X                    index_string
  131. X                    )
  132. X                    
  133. X        (int        srcbuf
  134. X                    word_line
  135. X                    )
  136. X
  137. X        (get_parm 0 srcbuf)
  138. X        (get_parm 1 wordfile)
  139. X        
  140. X        (edit_file wordfile)
  141. X        (= word_line 1)
  142. X        
  143. X        /*----------------------------------------
  144. X        /*   For each word in the index file,
  145. X        /*   scan the source file and insert .tm
  146. X        /*   requests into the source buffer.
  147. X        /*----------------------------------------*/
  148. X        (while (<= word_line (inq_lines)) (
  149. X            (goto_line word_line)
  150. X            (= raw_word (trim (ltrim (read))))
  151. X            (= word (quote_regexp raw_word))
  152. X            (message "Indexing '%s'..." word)
  153. X            
  154. X            (set_buffer srcbuf)
  155. X            (top_of_buffer)
  156. X
  157. X            (= regexp1 (+ "B" (+ word "\\\\")))
  158. X            (= regexp2 (+ "B" (+ word "\\")))
  159. X            (= index_string (+ ".tm " (+ "(\\f(HB" (+ raw_word "\\fR) \\n%\n"))))
  160. X            (while (> (search_fwd regexp1) 0) (
  161. X                (beginning_of_line)
  162. X                (down)
  163. X                (beginning_of_line)
  164. X                (insert index_string)
  165. X                ))
  166. X            (edit_file wordfile)
  167. X            (++ word_line)
  168. X            ))
  169. X        (set_buffer srcbuf)
  170. X        (attach_buffer srcbuf)
  171. X    )
  172. X)
  173. X(macro uniq
  174. X    (
  175. X        (string str1 str2)
  176. X        /*----------------------------------------
  177. X        /*    Remove all duplicate lines.
  178. X        /*----------------------------------------*/
  179. X        (top_of_buffer)
  180. X        (= str1 (read))
  181. X        (= str2 "xx")
  182. X        (message "Removing duplicates...")
  183. X        (while (!= str2 "\n") (
  184. X            (= str2 (read))
  185. X            (if (== str1 str2)
  186. X                (delete_line)
  187. X            ;else
  188. X                (
  189. X                    (= str1 str2)
  190. X                    (down)
  191. X                ))
  192. X            ))
  193. X    )
  194. X)
  195. X(macro format_index
  196. X    (
  197. X        (string    str1
  198. X                    str2
  199. X                    token1
  200. X                    token2
  201. X                    word
  202. X                    page_list
  203. X                    )
  204. X                    
  205. X        /*----------------------------------------
  206. X        /*    First sort all lines into order.
  207. X        /*    We have to make all single and double
  208. X        /*    digit numbers have leading zero's other
  209. X        /*    wise the sort comes out wrong.
  210. X        /*----------------------------------------*/
  211. X        (top_of_buffer)
  212. X        (translate " {[0-9]}$" " 0\\0" ST_GLOBAL)
  213. X        (top_of_buffer)
  214. X        (translate " {[0-9][0-9]}$" " 0\\0" ST_GLOBAL)
  215. X        (sort_buffer)
  216. X        (uniq)
  217. X        
  218. X        (top_of_buffer)
  219. X        (= str1 (read))
  220. X        (= str2 "xx")
  221. X        (message "Merging duplicates...")
  222. X        (while (!= str2 "\n") (
  223. X            (= str2 (read))
  224. X            (= token1 (substr str1 1 (index str1 " ")))
  225. X            (= token2 (substr str2 1 (index str2 " ")))
  226. X            (if (!= token1 token2) (
  227. X                (= str1 str2)
  228. X                (down)
  229. X                (continue)))
  230. X            (= word token1)
  231. X            (= page_list (trim (substr str1 (+ (index str1 " ") 1))))
  232. X            (+= page_list (+ "," (trim (substr str2 (index str2 " ")))))
  233. X            (= str1 (+ word page_list))
  234. X            (up)
  235. X            (delete_line)
  236. X            (delete_line)
  237. X            (insert (+ str1 "\n"))
  238. X            ))
  239. X        /*----------------------------------------
  240. X        /*   Now remove all leading zeros.
  241. X        /*----------------------------------------*/
  242. X        (top_of_buffer)
  243. X        (translate " 0+" " " ST_GLOBAL)
  244. X        (top_of_buffer)
  245. X        (translate " 0+{[1-9]}" " \\0" ST_GLOBAL -2)
  246. X        (top_of_buffer)
  247. X        (translate ") " ")  . . . " ST_GLOBAL)
  248. X        (top_of_buffer)
  249. X        (translate "^" ".br\n" ST_GLOBAL)
  250. X        (top_of_buffer)
  251. X        (insert ".2C\n")
  252. X        (write_buffer)
  253. X        (message "Index table generated.")
  254. X    )
  255. X)
  256. X
  257. X(macro process_file
  258. X    (
  259. X        (string filename)
  260. X        
  261. X        (get_parm 0 filename)
  262. X        (message "Processing %s..." filename)
  263. X        (= filename (+ BHELP filename))
  264. X        (save_position)
  265. X        (read_file filename)
  266. X        (restore_position)
  267. X        
  268. X        (convert_buffer)
  269. X    )
  270. X)
  271. X(macro convert_buffer
  272. X    (
  273. X        (int    line)
  274. X        (string    str str1)
  275. X        
  276. X        (inq_position line)
  277. X        
  278. X        //
  279. X        //    First make all multiple spaces into single spaces.
  280. X        //    This unformats the justified text.
  281. X        //
  282. X        (translate "   @" " " ST_GLOBAL -1)
  283. X        //
  284. X        //    Make section headings into nroff section headings.
  285. X        //
  286. X        (goto_line line)
  287. X        (translate "^\\> {*$}" ".H 3 \"\\0\"" ST_GLOBAL)
  288. X        //
  289. X        //    Put in paragraph marks.
  290. X        //
  291. X        (goto_line line)
  292. X        (translate "^$" NEW_PARA ST_GLOBAL)
  293. X        //
  294. X        //    Now make indented blocks into lists.
  295. X        //
  296. X        (goto_line line)
  297. X        (do_DL_list)
  298. X        (goto_line line)
  299. X        (do_VL_list)
  300. X        (goto_line line)
  301. X        (do_AL_list)
  302. X        //
  303. X        //    Create fixed displays.
  304. X        //
  305. X        (goto_line line)
  306. X        (while (> (search_fwd "^ ") 0) (
  307. X            (insert NEW_PARA)
  308. X            (insert "\n.in +1i\n")
  309. X            (insert ".ft CW\n")
  310. X            (while 1 (
  311. X                (down)
  312. X                (if (!= (read 1) " ")
  313. X                    (break))
  314. X                (insert ".br\n")
  315. X                ))
  316. X            (insert ".ft R\n")
  317. X            (insert ".in -1i\n")
  318. X            ))
  319. X        //
  320. X        //    Translate all funny characters.
  321. X        //
  322. X        (goto_line line)
  323. X        (translate "\\\\" "\\\\\\\\" ST_GLOBAL)
  324. X        //
  325. X        //    Translate all funny characters.
  326. X        //
  327. X        (goto_line line)
  328. X        (translate "^'" "\\\\'" ST_GLOBAL)
  329. X        (goto_line line)
  330. X        (translate "~" "\\\\~" ST_GLOBAL)
  331. X        //
  332. X        //    Boldify all CRISP macro names.
  333. X        //
  334. X        (translate "({[a-z_]+})" "(\\\\fB\\0\\\\fR)" ST_GLOBAL)
  335. X        (end_of_buffer)
  336. X    )
  337. X)
  338. X(macro do_DL_list
  339. X    (
  340. X        (int    line)
  341. X        
  342. X        (while (> (search_fwd "^\t-[ \t]") 0) (
  343. X            (insert ".DL\n")
  344. X            /*----------------------------------------
  345. X            /*  Mark the region containing the current
  346. X            /*  list.
  347. X            /*----------------------------------------*/
  348. X            (inq_position line)
  349. X            (if (<= (search_fwd "^[A-Z.]") 0) (
  350. X                (end_of_buffer)
  351. X                (next_char)))
  352. X            (insert ".LE\n")
  353. X            (up)
  354. X            (drop_anchor MK_LINE)
  355. X            /*----------------------------------------
  356. X            /*  Now modify the entries.
  357. X            /*----------------------------------------*/
  358. X            (move_abs line 1)
  359. X            (translate "^\t-?" ".LI\n" ST_GLOBAL NULL NULL ST_BLOCK)
  360. X            (move_abs line 1)
  361. X            (translate "^\t\t" "" ST_GLOBAL NULL NULL ST_BLOCK)
  362. X            (raise_anchor)
  363. X            ))
  364. X    )
  365. X)
  366. X(macro do_VL_list
  367. X    (
  368. X        (int    line)
  369. X
  370. X        (while (> (search_fwd "^\t-[^\t ]") 0) (
  371. X            (insert ".VL 10\n")
  372. X            /*----------------------------------------
  373. X            /*  Mark the region containing the current
  374. X            /*  list.
  375. X            /*----------------------------------------*/
  376. X            (inq_position line)
  377. X            (if (<= (search_fwd "^[A-Z]") 0) (
  378. X                (end_of_buffer)
  379. X                (next_char)))
  380. X            (insert ".LE\n")
  381. X            (up)
  382. X            (drop_anchor MK_LINE)
  383. X            /*----------------------------------------
  384. X            /*  Now modify the entries.
  385. X            /*----------------------------------------*/
  386. X            (move_abs line 1)
  387. X            (translate "^\t{-*}\t{*$}" ".LI \\0\n\\1" ST_GLOBAL NULL NULL ST_BLOCK)
  388. X            (move_abs line 1)
  389. X            (translate "^\t\t" "" ST_GLOBAL NULL NULL ST_BLOCK)
  390. X            (raise_anchor)
  391. X            ))
  392. X    )
  393. X)
  394. X(macro do_AL_list
  395. X    (
  396. X        (int    line)
  397. X
  398. X        (while (> (search_fwd "^\t[1-9]") 0) (
  399. X            (insert ".AL\n")
  400. X            /*----------------------------------------
  401. X            /*  Mark the region containing the current
  402. X            /*  list.
  403. X            /*----------------------------------------*/
  404. X            (inq_position line)
  405. X            (if (<= (search_fwd "^[A-Z]") 0) (
  406. X                (end_of_buffer)
  407. X                (next_char)))
  408. X            (insert ".LE\n")
  409. X            (up)
  410. X            (drop_anchor MK_LINE)
  411. X            /*----------------------------------------
  412. X            /*  Now modify the entries.
  413. X            /*----------------------------------------*/
  414. X            (move_abs line 1)
  415. X            (translate "^\t[1-9]+. " ".LI\n" ST_GLOBAL NULL NULL ST_BLOCK)
  416. X            (move_abs line 1)
  417. X            (translate "^\t  @" "" ST_GLOBAL NULL NULL ST_BLOCK)
  418. X            (raise_anchor)
  419. X            ))
  420. X    )
  421. X)
  422. X(macro process_sections
  423. X    (
  424. X        (string section)
  425. X        (int    line)
  426. X        
  427. X        (save_position)
  428. X        (read_file (+ BHELP "roff/Prim.mm"))
  429. X        (restore_position)
  430. X        (while (> (search_fwd "<##") 0) (
  431. X            (= section (substr (trim (read)) 3))
  432. X            (delete_line)
  433. X            (insert ".sp 2\n")
  434. X            (drop_anchor MK_LINE)
  435. X            (read_file (+ BHELP (+ "sections/" section)))
  436. X            (insert "\n")
  437. X            (up)
  438. X            (message (+ BHELP (+ "sections/" section)))
  439. X            (translate "^{?*}$" ".ce\n(\\\\f(HB\\0\\\\fR)" ST_GLOBAL NULL NULL ST_BLOCK)
  440. X            (raise_anchor)
  441. X            (down)
  442. X            ))
  443. X        (end_of_buffer)
  444. X        (down)
  445. X        (beginning_of_line)
  446. X    )
  447. X)
  448. X(macro process_prim
  449. X    (
  450. X        (int    line)
  451. X        (string    str str1)
  452. X        
  453. X        (restore_position)
  454. X        (insert ".in +.5i\n")
  455. X        (insert "\\s-2\n")
  456. X        (inq_position line)
  457. X        
  458. X        //
  459. X        //    Make sections stand out.
  460. X        //
  461. X        (message "Removing multiple spaces.")
  462. X        (goto_line line)
  463. X        (translate "   @" " " ST_GLOBAL -1)
  464. X        (goto_line line)
  465. X        (message "Removing tabs at beginning of lines.")
  466. X        (translate "^\t" "" ST_GLOBAL)
  467. X        (goto_line line)
  468. X        (message "Center macro name.")
  469. X        (while (> (search_fwd "<.HU") 0) (
  470. X            (delete_line)
  471. X            (translate "S*(" "(" 0)
  472. X            (beginning_of_line)
  473. X            (insert ".sp 1\n")
  474. X            (insert ".DS CB\n")
  475. X            (insert "\\s+3\\f(HB\n.ce\n")
  476. X            (insert "___________________________________________________\n\n")
  477. X            (while (!= (= str (read)) "\n") (
  478. X                (insert ".ce\n")
  479. X                (insert (ltrim str))
  480. X                (delete_line)
  481. X                ))
  482. X            (insert "\\s0\\fR\n")
  483. X            (insert ".DE")
  484. X            ))
  485. X        (message "Processing lists.")
  486. X        (goto_line line)
  487. X        (while (> (search_fwd "^\t") 0) (
  488. X            (insert ".in +.5i\n")
  489. X            (insert ".VL 20\n")
  490. X            (while (== (read 1) "\t") (
  491. X                (delete_char)
  492. X                (insert ".LI \"")
  493. X                (search_fwd "\t|$")
  494. X                (if (== (read 1) "\t") (
  495. X                    (delete_char)
  496. X                    (insert "\"\n")
  497. X                    (down)
  498. X                    )
  499. X                ;else
  500. X                    (
  501. X                        (insert "\"")
  502. X                        (next_char)
  503. X                    ))
  504. X                (while (== (read 2) "\t\t") (
  505. X                    (delete_char 2)
  506. X                    (while (== (read 1) "\t")
  507. X                        (delete_char))
  508. X                    (down)))
  509. X                ))
  510. X            (insert ".LE\n")
  511. X            (insert ".in -.5i\n")
  512. X            ))
  513. X        (message "Rearranging descriptions and return.")
  514. X        (goto_line line)
  515. X        (while (> (search_fwd "<RETURN") 0) (
  516. X            (delete_line)
  517. X            (delete_line)
  518. X            
  519. X            (save_position)
  520. X            (drop_anchor MK_LINE)
  521. X            (insert ".sp\n.Fo \"RETURN\\ VALUE\"\n")
  522. X            (search_fwd "<{.sp 1}|{DESC}")
  523. X            (up)
  524. X            (cut)
  525. X            (search_fwd "<{.sp 1}|{EX}")
  526. X            (paste)
  527. X            (restore_position)
  528. X            (delete_line)
  529. X            (insert ".Fo \"DESCRIPTION\"")
  530. X            ))
  531. X        (message "Making examples into Courier.")
  532. X        (goto_line line)
  533. X        (translate "^ {*$}" "\\\\f(CW\\0\\\\fR\n.br" ST_GLOBAL)
  534. X        (goto_line line)
  535. X        (message "Renaming Examples heading.")
  536. X        (translate "EXAMPLES:" ".Fo \"EXAMPLES\"" ST_GLOBAL)
  537. X        (goto_line line)
  538. X        (message "Making macros stand out.")
  539. X        (translate "({[a-z_]+}){?}" "(\\\\fB\\0\\\\fR)\\1" ST_GLOBAL)
  540. X        (goto_line line)
  541. X        (end_of_buffer)
  542. X        (down)
  543. X        (beginning_of_line)
  544. X        (insert ".in -.5i\n")
  545. X        (insert "\\s+2\n")
  546. X    )
  547. X)
  548. SHAR_EOF
  549. echo "File src/crisp/makeman.m is complete"
  550. chmod 0444 src/crisp/makeman.m || echo "restore of src/crisp/makeman.m fails"
  551. mkdir src src/crisp >/dev/null 2>&1
  552. echo "x - extracting src/crisp/misc.m (Text)"
  553. sed 's/^X//' << 'SHAR_EOF' > src/crisp/misc.m &&
  554. X/********************************************************************
  555. X *                                                                  *
  556. X *      CRISP - Custom Reduced Instruction Set Programmers Editor   *
  557. X *                                                                  *
  558. X *      (C) Paul Fox, 1989                                          *
  559. X *      43, Jerome Close                Tel: +44 6284 4222          *
  560. X *          Marlow                                                  *
  561. X *           Bucks.                                                 *
  562. X *              England SL7 1TX                                     *
  563. X *                                                                  *
  564. X *                                                                  *
  565. X *    Please See COPYRIGHT notice.                                  *
  566. X *                                                                  *
  567. X ********************************************************************/
  568. X# include    "crisp.h"
  569. X
  570. X(macro autoindent
  571. X    (
  572. X        (string    arg)
  573. X        
  574. X        (get_parm 0 arg "Turn autoindent on (y/n) ? ")
  575. X        (if (== (upper (substr arg 1 1)) "Y")
  576. X            (assign_to_key "<Enter>" "_indent")
  577. X        ;else
  578. X            (assign_to_key "<Enter>" "self_insert"))
  579. X    )
  580. X)
  581. X(macro _indent
  582. X    (
  583. X        (int col)
  584. X        
  585. X        (if (& (inq_buffer_flags) BF_READONLY) (
  586. X            (down)
  587. X            (beginning_of_line)
  588. X            (return)))
  589. X        (insert "\n")
  590. X        (save_position)
  591. X
  592. X        (if (<= (search_back "[~ \t]") 0) (
  593. X            (restore_position)
  594. X            (return)))
  595. X
  596. X        (beginning_of_line)
  597. X        (search_fwd "[~ \t]")
  598. X        (inq_position NULL col)
  599. X        (restore_position)
  600. X        (tab_to_col col)
  601. X    )
  602. X)
  603. X/*************************************************************
  604. X/*   Macro to move the cursor back to the previous tab stop. *
  605. X/*   This macro will not move the cursor beyond the beginning*
  606. X/*   of the current line.                                                 *
  607. X/*************************************************************/
  608. X(macro previous_tab
  609. X    (
  610. X        (int    
  611. X                col
  612. X                num
  613. X                prev_num)
  614. X        
  615. X        /*----------------------------------------
  616. X        /*   If we are already in column 1, dont go
  617. X        /*   back any further.
  618. X        /*----------------------------------------*/
  619. X        (inq_position NULL col)
  620. X        (if (== col 1)
  621. X            (return))
  622. X        (left)
  623. X        (= prev_num (distance_to_tab))
  624. X        (while 1 (
  625. X            (= num (distance_to_tab))
  626. X            (inq_position NULL col)
  627. X            (if (< num prev_num) (
  628. X                (right)
  629. X                (break)))
  630. X            (if (== col 1)
  631. X                (break))
  632. X            (= prev_num num)
  633. X            (left)
  634. X            ))
  635. X    )
  636. X)
  637. X
  638. X(macro tab_to_col
  639. X    (
  640. X        (int    col curcol hard_tabs)
  641. X        (get_parm 0 col)
  642. X        (beginning_of_line)
  643. X        (= hard_tabs (use_tab_char "y"))
  644. X        (use_tab_char (if hard_tabs "y" "n"))
  645. X        (if (! hard_tabs) (
  646. X            (insert " " (- col 1))
  647. X            (return)
  648. X            ))
  649. X        (while 1 (
  650. X            (inq_position NULL curcol)
  651. X            (if (>= curcol col)
  652. X                (break))
  653. X            (insert "\t")
  654. X            ))
  655. X        (if (> curcol col) (
  656. X            (backspace)
  657. X            (inq_position NULL curcol)
  658. X            (insert " " (- col curcol))))
  659. X    )
  660. X)
  661. X
  662. X(macro display_file_name
  663. X    (
  664. X        (string     filename buf)
  665. X        (int        cols len)
  666. X
  667. X        (inq_names filename)
  668. X        (inq_screen_size NULL cols)
  669. X        (-= cols 43)
  670. X        (= len (strlen filename))
  671. X        (if (> len cols) (
  672. X            (= filename (substr filename (- len cols)))
  673. X            (= filename (+ "..." filename))
  674. X            ))
  675. X        (message "File: %s%s" filename (if (inq_modified) "*" ""))
  676. X    )
  677. X)
  678. X(macro repeat
  679. X    (
  680. X        (int    count
  681. X                ch)
  682. X        (string macro_name)
  683. X
  684. X        (= count 0)
  685. X        (while 1 (
  686. X            (message "Repeat count = %d" count)
  687. X            (while (== (= ch (read_char)) -1)
  688. X                (nothing))
  689. X            (if (&& (>= ch '0') (<= ch '9')) (
  690. X                (= count (+ (* count 10) (- ch '0')))
  691. X                (continue)))
  692. X            (if (== (int_to_key ch) "<Esc>") (
  693. X                (message "Repeat aborted.")
  694. X                (return)))
  695. X            (if (== (int_to_key ch) "<Ctrl-r>") (
  696. X                (if (== count 0)
  697. X                    (= count 1))
  698. X                (*= count 4)
  699. X                (continue)))
  700. X            (break)
  701. X            ))
  702. X        (= macro_name (inq_assignment (int_to_key ch)))
  703. X        (while (> count 0) (
  704. X            (execute_macro macro_name)
  705. X            (-- count)
  706. X            ))
  707. X    )
  708. X)
  709. X(macro home
  710. X    (
  711. X        (int    line col)
  712. X
  713. X        (inq_position line col)
  714. X        (if (|| (!= line click_line) (!= col click_col))
  715. X            (= click_state 1))
  716. X        (switch click_state
  717. X            2        (top_of_window)
  718. X            3        (top_of_buffer)
  719. X            NULL    (
  720. X                        (beginning_of_line)
  721. X                        (= click_state 1)
  722. X                    )
  723. X            )
  724. X        (inq_position click_line click_col)
  725. X        (++ click_state)
  726. X    )
  727. X)
  728. X(macro end
  729. X    (
  730. X        (int    line col)
  731. X
  732. X        (inq_position line col)
  733. X        (if (|| (!= line click_line) (!= col click_col))
  734. X            (= click_state -1))
  735. X        (switch click_state
  736. X            -2        (end_of_window)
  737. X            -3        (end_of_buffer)
  738. X            NULL    (
  739. X                        (end_of_line)
  740. X                        (= click_state -1)
  741. X                    )
  742. X            )
  743. X        (inq_position click_line click_col)
  744. X        (-- click_state)
  745. X    )
  746. X)
  747. X(macro quote
  748. X    (
  749. X        (int    key)
  750. X        (string buf)
  751. X
  752. X        (= key -1)
  753. X        (while (< key 0)
  754. X            (= key (read_char)))
  755. X        (sprintf buf "%c" key)
  756. X        (insert buf)
  757. X    )
  758. X)
  759. X(macro delete_character
  760. X    (
  761. X        (if (|| (!= (inq_called) "") (== (inq_marked) 0))
  762. X            (return (delete_char)))
  763. X        (if (== (inq_marked) MK_COLUMN)
  764. X            (block-delete)
  765. X        ;else
  766. X            (delete_block))
  767. X    )
  768. X)
  769. X(replacement write_buffer
  770. X    (
  771. X        (int    ret 
  772. X                old_msg_level)
  773. X
  774. X        (if (!= (inq_called) "")
  775. X            (return (write_buffer))
  776. X        ;else
  777. X            (
  778. X                (= old_msg_level (inq_msg_level))
  779. X                (if (inq_marked)
  780. X                    (
  781. X                        (set_msg_level 1)
  782. X                        (= ret (write_block))
  783. X                    )
  784. X                ;else
  785. X                    (
  786. X                        (set_msg_level 0)
  787. X                        (= ret (write_buffer))
  788. X                    ))
  789. X                (set_msg_level old_msg_level)
  790. X                (return ret)
  791. X            ))
  792. X    )
  793. X)
  794. X(macro _init
  795. X    (
  796. X        (int        click_line 
  797. X                    click_col 
  798. X                    click_state
  799. X                    search-regexp
  800. X                    search-case
  801. X                    search-block
  802. X                    )
  803. X        (global    click_line 
  804. X                    click_col 
  805. X                    click_state
  806. X                    search-regexp
  807. X                    search-case
  808. X                    search-block
  809. X                    )
  810. X    )
  811. X)
  812. X
  813. SHAR_EOF
  814. chmod 0444 src/crisp/misc.m || echo "restore of src/crisp/misc.m fails"
  815. mkdir src src/crisp >/dev/null 2>&1
  816. echo "x - extracting src/crisp/options.m (Text)"
  817. sed 's/^X//' << 'SHAR_EOF' > src/crisp/options.m &&
  818. X/********************************************************************
  819. X *                                                                  *
  820. X *      CRISP - Custom Reduced Instruction Set Programmers Editor   *
  821. X *                                                                  *
  822. X *      (C) Paul Fox, 1989                                          *
  823. X *      43, Jerome Close                Tel: +44 6284 4222          *
  824. X *          Marlow                                                  *
  825. X *           Bucks.                                                 *
  826. X *              England SL7 1TX                                     *
  827. X *                                                                  *
  828. X *                                                                  *
  829. X *    Please See COPYRIGHT notice.                                  *
  830. X *                                                                  *
  831. X ********************************************************************/
  832. X# include    "crisp.h"
  833. X
  834. X(macro options
  835. X    (
  836. X        (select_list "Options" ""
  837. X            3
  838. X            (quote_list
  839. X                "Autoindenting"    "autoindent"            
  840. X                                        "help_display \"features/Options.hlp\" \"Autoindenting\" \"> Autoindenting\""
  841. X                "Documents"            "wp-options"
  842. X                                        "help_display \"features/Options.hlp\" \"Documents\" \"> The Documents Option\""
  843. X                 "Screen & Status"    "echo_line-options"
  844. X                                        "help_display \"features/Options.hlp\" \"Status Line\" \"> The Status Line Option\""
  845. X                "Searching"         "search-options"
  846. X                                        "help_display \"features/Options.hlp\" \"Searching\" \"> The Searching Option\""
  847. X                "Tabs"                "tab-options"
  848. X                                        "help_display \"features/Options.hlp\" \"Tabs\" \"> The Tabs Option\""
  849. X                ) 1)
  850. X    )
  851. X)
  852. X(macro echo_line-options
  853. X    (
  854. X        (list    r_list s_list)
  855. X        (int    options new_options ega_mode ega_mode1)
  856. X
  857. X        (= options (echo_line))
  858. X        (= ega_mode (if (== 43 (ega)) 1 0))
  859. X        (put_nth 0 r_list ega_mode)
  860. X        (put_nth 1 r_list (if (& options 0x01) 0 1))
  861. X        (put_nth 2 r_list (if (& options 0x02) 0 1))
  862. X        (put_nth 3 r_list (if (& options 0x04) 0 1))
  863. X        (put_nth 4 r_list (if (& options 0x08) 0 1))
  864. X        (= s_list (quote_list
  865. X            "EGA Mode              : " ("25-line" "43-line")
  866. X            "Line prompt           : "    ("On" "Off")
  867. X            "Col prompt            : " ("On" "Off")
  868. X            "Percent thru file     : " ("On" "Off")
  869. X            "Time                  : " ("On" "Off")
  870. X            ))
  871. X        (= r_list (field_list "Echo-Line Options" r_list s_list))
  872. X        (= new_options 0)
  873. X        
  874. X        (= ega_mode1 (if (nth 0 r_list) 1 0))
  875. X        (if (!= ega_mode1 ega_mode) 
  876. X            (ega (if ega_mode1 43 25)))
  877. X        (if (! (nth 1 r_list))
  878. X            (+= new_options 0x01))
  879. X        (if (! (nth 2 r_list))
  880. X            (+= new_options 0x02))
  881. X        (if (! (nth 3 r_list))
  882. X            (+= new_options 0x04))
  883. X        (if (! (nth 4 r_list))
  884. X            (+= new_options 0x08))
  885. X        (if (!= new_options options)
  886. X            (echo_line new_options))
  887. X    )
  888. X)
  889. X(macro tab-options
  890. X    (
  891. X        (list    r_list s_list)
  892. X        (int    fill)
  893. X
  894. X        (= fill (use_tab_char "y"))
  895. X        (use_tab_char (if fill "n" "y"))
  896. X        (put_nth 0 r_list (if fill 0 1))
  897. X        (= s_list (quote_list
  898. X            "Fill with    : " ("SPACES" "TABS")
  899. X         ))
  900. X        (= r_list (field_list "Tab Options" r_list s_list))
  901. X      (use_tab_char (if (== (nth 0 r_list) 0) "n" "y"))
  902. X    )
  903. X)
  904. SHAR_EOF
  905. chmod 0444 src/crisp/options.m || echo "restore of src/crisp/options.m fails"
  906. mkdir src src/crisp >/dev/null 2>&1
  907. echo "x - extracting src/crisp/region.m (Text)"
  908. sed 's/^X//' << 'SHAR_EOF' > src/crisp/region.m &&
  909. X/********************************************************************
  910. X *                                                                  *
  911. X *      CRISP - Custom Reduced Instruction Set Programmers Editor   *
  912. X *                                                                  *
  913. X *      (C) Paul Fox, 1989                                          *
  914. X *      43, Jerome Close                Tel: +44 6284 4222          *
  915. X *          Marlow                                                  *
  916. X *           Bucks.                                                 *
  917. X *              England SL7 1TX                                     *
  918. X *                                                                  *
  919. X *                                                                  *
  920. X *    Please See COPYRIGHT notice.                                  *
  921. X *                                                                  *
  922. X ********************************************************************/
  923. X# include    "crisp.h"
  924. X
  925. X(macro _init
  926. X    (
  927. X        (string block_line)
  928. X        (global block_line)
  929. X    )
  930. X)
  931. X(replacement copy
  932. X    (
  933. X        (int    old_msg_level)
  934. X
  935. X        (if (!= (inq_called) "")
  936. X            (return (copy)))
  937. X        (if (inq_marked) (
  938. X            (= old_msg_level (inq_msg_level))
  939. X            (set_msg_level 0)
  940. X            (copy)
  941. X            (set_msg_level old_msg_level)
  942. X            (return)))
  943. X
  944. X        (drop_anchor MK_LINE)
  945. X        (message "Line copied to scrap.")
  946. X        (return (copy))
  947. X    )
  948. X)
  949. X(replacement cut
  950. X    (
  951. X        (int    old_msg_level)
  952. X
  953. X        (if (!= (inq_called) "")
  954. X            (return (cut)))
  955. X        (if (inq_marked) (
  956. X            (= old_msg_level (inq_msg_level))
  957. X            (set_msg_level 0)
  958. X            (cut)
  959. X            (set_msg_level old_msg_level)
  960. X            (return)))
  961. X
  962. X        (drop_anchor MK_LINE)
  963. X        (message "Line cut to scrap.")
  964. X        (return (cut))
  965. X    )
  966. X)
  967. X;(replacement paste
  968. X;    (
  969. X;    )
  970. X;)
  971. X# define    BLOCK_REPLACE    1
  972. X(macro block-upper_case
  973. X    (
  974. X        (block NULL (
  975. X                        (insert (upper block_line))
  976. X                        BLOCK_REPLACE
  977. X                        ))
  978. X    )
  979. X)
  980. X(macro block-lower_case
  981. X    (
  982. X        (block NULL (
  983. X                        (insert (lower block_line))
  984. X                        BLOCK_REPLACE
  985. X                        ))
  986. X    )
  987. X)
  988. X(macro block-delete
  989. X    (
  990. X        (block NULL (
  991. X                        BLOCK_REPLACE
  992. X                        ))
  993. X    )
  994. X)
  995. X(macro block
  996. X    (
  997. X        (int        type
  998. X                    start_line
  999. X                    start_col
  1000. X                    end_line
  1001. X                    end_col
  1002. X                    col
  1003. X                    result
  1004. X                    size)
  1005. X        (string    macro_name
  1006. X                    )
  1007. X        
  1008. X        (= type (inq_marked start_line start_col end_line end_col))
  1009. X        (if (== type 0) (
  1010. X            (error "No marked region.")
  1011. X            (return)))
  1012. X
  1013. X        (get_parm 0 macro_name)
  1014. X
  1015. X        (= col (if (== type MK_COLUMN) start_col 1))
  1016. X        (raise_anchor)
  1017. X
  1018. X        (move_abs start_line start_col)
  1019. X        (while (<= start_line end_line) (
  1020. X            (drop_anchor MK_NORMAL)
  1021. X            (save_position)
  1022. X            (if (|| (== type MK_COLUMN) (== start_line end_line))
  1023. X                (move_abs 0 end_col)
  1024. X            ;else
  1025. X                (
  1026. X                    (end_of_line)
  1027. X                    (prev_char)
  1028. X                ))
  1029. X            (= size (inq_mark_size))
  1030. X            (raise_anchor)
  1031. X            (restore_position)
  1032. X            (= block_line (read size))
  1033. X            (if (!= macro_name "")
  1034. X                (= result (execute_macro macro_name block_line))
  1035. X            ;else
  1036. X                (get_parm 1 result))
  1037. X            (switch result
  1038. X                BLOCK_REPLACE    (delete_char size)
  1039. X                )
  1040. X            (++ start_line)
  1041. X            (move_abs start_line col) 
  1042. X            ))
  1043. X        (move_abs end_line end_col)
  1044. X    )
  1045. X)
  1046. SHAR_EOF
  1047. chmod 0444 src/crisp/region.m || echo "restore of src/crisp/region.m fails"
  1048. mkdir src src/crisp >/dev/null 2>&1
  1049. echo "x - extracting src/crisp/regress.m (Text)"
  1050. sed 's/^X//' << 'SHAR_EOF' > src/crisp/regress.m &&
  1051. X/********************************************************************
  1052. X *                                                                  *
  1053. X *      CRISP - Custom Reduced Instruction Set Programmers Editor   *
  1054. X *                                                                  *
  1055. X *      (C) Paul Fox, 1989                                          *
  1056. X *      43, Jerome Close                Tel: +44 6284 4222          *
  1057. X *          Marlow                                                  *
  1058. X *           Bucks.                                                 *
  1059. X *              England SL7 1TX                                     *
  1060. X *                                                                  *
  1061. X *                                                                  *
  1062. X *    Please See COPYRIGHT notice.                                  *
  1063. X *                                                                  *
  1064. X ********************************************************************/
  1065. X;*******************************************************************
  1066. X;
  1067. X;    regress.m    - Regression testing file for CRISP.
  1068. X;
  1069. X; Paul Fox, (C) 1988
  1070. X;
  1071. X; Description:
  1072. X;
  1073. X;   This file is used when debugging and fixing CRISP to aid
  1074. X;   in regression testing - catching bugs introduced inadvertently.
  1075. X;
  1076. X;   This script does not attempt to exhaustively test CRISP, but tests
  1077. X;   are added whenever a bug is found, to ensure the bug does not get
  1078. X;   missed in the future.
  1079. X;
  1080. X;   The tests in this file are mainly to do with testing the 
  1081. X;   interpreter and simple aspects of the language. No attempt is
  1082. X;   made to test the correctnesss of the display, or reading/writing
  1083. X;   files.
  1084. X;
  1085. X;   This file can also be run after porting CRISP, to ensure that
  1086. X;   these tests work as expected. If anything doesn't work that should,
  1087. X;   the porter will hae to check for portability problems.
  1088. X;
  1089. X;   These tests attempt to do things in order of complexity.
  1090. X;
  1091. X;*******************************************************************
  1092. X
  1093. X# define    TRUE    1
  1094. X# define    FALSE    0
  1095. X
  1096. X(macro    regress
  1097. X    (
  1098. X        (int    i j k gi gj gk)
  1099. X        (int    num_passed num_failed)
  1100. X        (list    l1 l2 l3)
  1101. X        (declare    d1 d2 d3)
  1102. X        (string s1 s2 s3 gs1 gs2 gs3)
  1103. X        (global gs1 gs2 gs3 gi gj gk)
  1104. X        (int    buf old_buf)
  1105. X
  1106. X        (= old_buf (inq_buffer))
  1107. X        (= buf (create_buffer "Regression-Test" NULL 0))
  1108. X        (set_buffer buf)
  1109. X        (attach_buffer buf)
  1110. X
  1111. X        (top_of_buffer)
  1112. X        (drop_anchor 3)
  1113. X        (end_of_buffer)
  1114. X        (delete_block)
  1115. X        (top_of_buffer)
  1116. X
  1117. X        (= num_passed 0)
  1118. X        (= num_failed 0)
  1119. X
  1120. X        (= i (= j (= k 0)))
  1121. X        (= s1 "String one")
  1122. X        (= s2 "String two")
  1123. X        (= s3 "String three")
  1124. X
  1125. X        (if (!= i 0) (failed 1) (passed))
  1126. X        ;;;;
  1127. X        (= s1 s2)
  1128. X        (if (!= s1 "String two") (failed 2) (passed))
  1129. X        ;;;;
  1130. X        (if (!= s1 (+ "String two" "")) (failed 3) (passed))
  1131. X        ;;;;
  1132. X        (= s1 (+ s2 s3))
  1133. X        (if (!= s1 "String twoString three") (failed 4) (passed))
  1134. X        ;;;;
  1135. X        (= s1 (substr "ABC" -10000 20))
  1136. X        (if (!= s1 "ABC") (failed 5) (passed))
  1137. X        ;;;;
  1138. X        (= s1 (substr "ABC" 10000 20))
  1139. X        (if (!= s1 "") (failed 6) (passed))
  1140. X        ;;;;
  1141. X        (= s2 "HELLO")
  1142. X        (= s2 s2)
  1143. X        (if (!= s2 "HELLO") (failed 7) (passed))
  1144. X        ;;;;
  1145. X        (= s2 "S2")
  1146. X        (= s1 (+ s2 (+ "-second-" s2)))
  1147. X        (if (!= s1 "S2-second-S2") (failed 8) (passed))
  1148. X        ;;;;
  1149. X        (= s1 "variable")
  1150. X        (= k 99)
  1151. X        (if (! (test1_macro "literal-string" 23 s1 k)) (failed 9) (passed))
  1152. X        ;;;;
  1153. X        (test2_macro i j k s1 s2 s3)
  1154. X        (if (!= k 27) (failed 10) (passed))
  1155. X        (if (!= s1 "literal") (failed 11) (passed))
  1156. X        (if (!= s2 "variable") (failed 12) (passed))
  1157. X        ;;;;
  1158. X        (= k (if TRUE 2 3))
  1159. X        (if (!= k 2) (failed 13) (passed))
  1160. X        ;;;;
  1161. X        (= s1 (if TRUE "abc" "def"))
  1162. X        (if (!= s1 "abc") (failed 14) (passed))
  1163. X        ;;;;
  1164. X        (= s1 (if FALSE "abc" "def"))
  1165. X        (if (!= s1 "def") (failed 15) (passed))
  1166. X        ;;;;
  1167. X        (= s2 "variable")
  1168. X        (= k 99)
  1169. X        (sprintf s1 "%s,%d,%s,%d" "literal" 1 s2 k)
  1170. X        (if (!= s1 "literal,1,variable,99") (failed 16) (passed))
  1171. X        ;;;;
  1172. X        (if (!= (test3_macro) "XYZZY") (failed 17) (passed))
  1173. X        ;;;;
  1174. X        (switch 3 1 (= k 101) 2 (= k 102) 3 (= k 103))
  1175. X        (if (!= k 103) (failed 18) (passed))
  1176. X        ;;;;
  1177. X        (sprintf s1 "--%s--" (if 1 "abc" "def"))
  1178. X        (if (!= s1 "--abc--") (failed 19) (passed))        
  1179. X        ;;;;
  1180. X        (if (test4_macro) (failed 20) (passed))
  1181. X        ;;;;
  1182. X        (switch "hello" 
  1183. X                "hello, everybod" (= s1 "first") 
  1184. X                "hello" (= s1 "second")
  1185. X                NULL        (= s1 "default"))
  1186. X        (if (!= s1 "second") (failed 21) (passed))
  1187. X        ;;;;
  1188. X        (= s1 "hello, everybod")
  1189. X        (= s2 "hello")
  1190. X        (switch "hello" 
  1191. X                s1 (= s1 "first") 
  1192. X                s2 (= s1 "second")
  1193. X                NULL        (= s1 "default"))
  1194. X        (if (!= s1 "second") (failed 22) (passed))
  1195. X        ;;;;
  1196. X        (= s1 "")
  1197. X        (= s1 (substr s1 (+ (index s1 ";") 1)) )
  1198. X        (if (!= s1 "") (failed 23) (passed))
  1199. X        ;;;;
  1200. X        (= gs1 "")
  1201. X        (get_parm 2 gs1)
  1202. X        (= gs1 (substr gs1 (+ (index gs1 ";") 1)) )
  1203. X        (if (!= gs1 "") (failed 24) (passed))
  1204. X        ;;;;
  1205. X        (= s1 "xyz")
  1206. X        (+= s1 "abc")
  1207. X        (if (!= s1 "xyzabc") (failed 25) (passed))
  1208. X        ;;;;
  1209. X        (= s1 "xyz")
  1210. X        (= s2 "abc")
  1211. X        (+= s1 s2)
  1212. X        (if (!= s1 "xyzabc") (failed 26) (passed))
  1213. X        ;;;;
  1214. X        (= s1 "xyz")
  1215. X        (= s2 s1)
  1216. X        (+= s1 s2)
  1217. X        (if (!= s1 "xyzxyz") (failed 27) (passed))
  1218. X        ;;;;
  1219. X        (if (!= (test5_macro) "XYZ") (failed 28) (passed))
  1220. X        ;;;;
  1221. X        (= s1 "xyz")
  1222. X        (if (!= (+= s1 "abc") "xyzabc") (failed 29) (passed))
  1223. X        ;;;;
  1224. X        (= s1 "xyz")
  1225. X        (if (!= (+= s1 s1) "xyzxyz") (failed 30) (passed))
  1226. X        ;;;;
  1227. X        (= s1 "xyz")
  1228. X        (if (!= (= s1 s1) "xyz") (failed 31) (passed))
  1229. X        ;;;;
  1230. X        (= l1 (quote_list 123 "xyz" (hello)))
  1231. X        (if (!= (length_of_list l1) 3) (failed 32) (passed))
  1232. X        ;;;;;;;;;;;;;;;;;;;;;;
  1233. X        (= l2 l1)
  1234. X        (if (!= (nth 0 l1) (nth 0 l2))  (failed 33) (passed))
  1235. X        ;;;;;;;;;;;;;;;;;;;;;;
  1236. X        (= d1 (nth 0 l1))
  1237. X        (if (! (is_integer d1))  (failed 34) (passed))
  1238. X        ;;;;;;;;;;;;;;;;;;;;;;
  1239. X        (= d1 (nth 1 l1))
  1240. X        (if (! (is_string d1))  (failed 35) (passed))
  1241. X        ;;;;;;;;;;;;;;;;;;;;;;
  1242. X        (= d1 (nth 2 l1))
  1243. X        (if (! (is_list d1))  (failed 36) (passed))
  1244. X        ;;;;;;;;;;;;;;;;;;;;;;
  1245. X        (= d1 (nth 3 l1))
  1246. X        (if (! (is_null d1))  (failed 37) (passed))
  1247. X        ;;;;;;;;;;;;;;;;;;;;;;
  1248. X        (= l1 (quote_list 1))
  1249. X        (put_nth 0 l1 2)
  1250. X        (if (!= (nth 0 l1) 2)  (failed 38) (passed))
  1251. X        ;;;;;;;;;;;;;;;;;;;;;;
  1252. X        (= l1 (quote_list 1 "abc"))
  1253. X        (put_nth 0 l1 2)
  1254. X        (if (!= (nth 0 l1) 2)  (failed 39) (passed))
  1255. X        ;;;;;;;;;;;;;;;;;;;;;;
  1256. X        (= l1 (quote_list "abc"))
  1257. X        (put_nth 0 l1 2)
  1258. X        (if (!= (nth 0 l1) 2)  (failed 40) (passed))
  1259. X        ;;;;;;;;;;;;;;;;;;;;;;
  1260. X        (= l1 (quote_list "abc" 1))
  1261. X        (put_nth 1 l1 2)
  1262. X        (if (!= (nth 1 l1) 2)  (failed 41) (passed))
  1263. X        ;;;;;;;;;;;;;;;;;;;;;;
  1264. X        (= l1 (quote_list 1 "abc" 3))
  1265. X        (put_nth 1 l1 2)
  1266. X        (if (!= (nth 1 l1) 2)  (failed 42) (passed))
  1267. X        ;;;;;;;;;;;;;;;;;;;;;;
  1268. X        (= l1 (quote_list 1 2 3))
  1269. X        (put_nth 1 l1 "abc")
  1270. X        (if (!= (nth 1 l1) "abc")  (failed 43) (passed))
  1271. X        ;;;;;;;;;;;;;;;;;;;;;;
  1272. X        (= l1 (quote_list 1 2 3))
  1273. X        (put_nth 1 l1 (quote_list (1 2 3)))
  1274. X        (if (!= (length_of_list l1) 3)  (failed 44) (passed))
  1275. X        ;;;;;;;;;;;;;;;;;;;;;;
  1276. X        (= l1 (quote_list 1 2 3))
  1277. X        (put_nth 1 l1 (quote_list (1 2 3)))
  1278. X        (if (!= (nth 2 l1) 3)  (failed 45) (passed))
  1279. X        ;;;;;;;;;;;;;;;;;;;;;;
  1280. X        (= d1 (nth 1 l1))
  1281. X        (if (!= (nth 2 d1) 3) (failed 46) (passed))
  1282. X        ;;;;;;;;;;;;;;;;;;;;;;
  1283. X        (put_nth 3 l1 "end")
  1284. X        (if (!= (nth 3 l1) "end") (failed 47) (passed))
  1285. X        (if (!= (length_of_list l1) 4) (failed 48) (passed))
  1286. X        ;;;;;;;;;;;;;;;;;;;;;;
  1287. X        (= l1 (quote_list ((1 2) (3 4) ("hello" "bye"))))
  1288. X        (= d1 (nth 1 l1))
  1289. X        (if (! (is_list d1)) (failed 49) (passed))
  1290. X        ;;;;;;;;;;;;;;;;;;;;;;
  1291. X        (put_nth 0 l3 0)
  1292. X        (put_nth 1 l3 1)
  1293. X        (put_nth 2 l3 2)
  1294. X        (if (!= (nth 0 l3) 0) (failed 50) (passed))
  1295. X        (if (!= (nth 1 l3) 1) (failed 51) (passed))
  1296. X        (if (!= (nth 2 l3) 2) (failed 52) (passed))
  1297. X        ;;;;;;;;;;;;;;;;;;;;;;
  1298. X        (= l1 NULL)
  1299. X        (if (!= (length_of_list l1) 0) (failed 53) (passed))
  1300. X        ;;;;;;;;;;;;;;;;;;;;;;
  1301. X        (put_nth 0 l1 "hello")
  1302. X        (if (!= (nth 0 l1) "hello") (failed 54) (passed))
  1303. X        ;;;;;;;;;;;;;;;;;;;;;;
  1304. X        (= s1 "abc")
  1305. X        (put_nth 0 l1 s1)
  1306. X        (if (!= (nth 0 l1) "abc") (failed 55) (passed))
  1307. X        ;;;;;;;;;;;;;;;;;;;;;;
  1308. X        (= s1 "abc")
  1309. X        (put_nth 0 l1 s1)
  1310. X        (= s1 "123456789")
  1311. X        (if (!= (nth 0 l1) "abc") (failed 56) (passed))
  1312. X        ;;;;;;;;;;;;;;;;;;;;;;
  1313. X        (declare a57 b57)
  1314. X        (= b57 "hello")
  1315. X        (= a57 b57)
  1316. X        (if (!= a57 "hello") (failed 57) (passed))
  1317. X        ;;;;;;;;;;;;;;;;;;;;;;
  1318. X        (message "Tests passed: %d, failed: %d" num_passed num_failed)
  1319. X    )
  1320. X)
  1321. X(macro passed
  1322. X    (
  1323. X        (++ num_passed)
  1324. X    )
  1325. X)
  1326. X(macro failed
  1327. X    (
  1328. X        (int    num)
  1329. X        (string    buf)
  1330. X
  1331. X        (get_parm 0 num)
  1332. X        (sprintf buf "Test %d:  Failed.\n" num)
  1333. X        (insert buf)
  1334. X        (++ num_failed)
  1335. X    )
  1336. X)
  1337. X(macro test1_macro
  1338. X    (
  1339. X        (string    s1 s2)
  1340. X        (int    i1 i2)
  1341. X        (get_parm 0 s1)
  1342. X        (get_parm 1 i1)
  1343. X        (get_parm 2 s2)
  1344. X        (get_parm 3 i2)
  1345. X        (return (&& (&& (&& (== s1 "literal-string") (== i1 23)) 
  1346. X                    (== s2 "variable")) (== i2 99)) )
  1347. X    )
  1348. X) 
  1349. X(macro test2_macro
  1350. X    (    (string    s1)
  1351. X
  1352. X
  1353. X        (= s1 "variable")
  1354. X        (put_parm 0 25)
  1355. X        (put_parm 1 26)
  1356. X        (put_parm 2 27)
  1357. X        (put_parm 3 "literal")
  1358. X        (put_parm 4 s1)
  1359. X    )
  1360. X)
  1361. X(macro test3_macro
  1362. X    (
  1363. X        (returns "XYZZY")
  1364. X    )
  1365. X)
  1366. X(macro test4_macro
  1367. X    (    
  1368. X        (int    dir re)
  1369. X        (string prompt)
  1370. X
  1371. X        (= dir 0)
  1372. X        (= re 1)    
  1373. X        (sprintf prompt "%c Pattern%s: " (if dir 25 24 ) (if re "" " (RE off)" ))
  1374. X        (return (!= prompt " Pattern: "))
  1375. X    )
  1376. X)
  1377. X(macro test5_macro
  1378. X    (
  1379. X        (string    s1)
  1380. X        (= s1 "XYZ")
  1381. X        (returns (if 1 s1 "def"))
  1382. X    )
  1383. X)
  1384. SHAR_EOF
  1385. chmod 0444 src/crisp/regress.m || echo "restore of src/crisp/regress.m fails"
  1386. mkdir src src/crisp >/dev/null 2>&1
  1387. echo "x - extracting src/crisp/sdb.m (Text)"
  1388. sed 's/^X//' << 'SHAR_EOF' > src/crisp/sdb.m &&
  1389. X/********************************************************************
  1390. X *                                                                  *
  1391. X *      CRISP - Custom Reduced Instruction Set Programmers Editor   *
  1392. X *                                                                  *
  1393. X *      (C) Paul Fox, 1989                                          *
  1394. X *      43, Jerome Close                Tel: +44 6284 4222          *
  1395. X *          Marlow                                                  *
  1396. X *           Bucks.                                                 *
  1397. X *              England SL7 1TX                                     *
  1398. X *                                                                  *
  1399. X *                                                                  *
  1400. X *    Please See COPYRIGHT notice.                                  *
  1401. X *                                                                  *
  1402. X ********************************************************************/
  1403. X(macro sdb
  1404. X    (
  1405. X        (sdb_display_file "main.c" 15)
  1406. X    )
  1407. X)
  1408. X(macro sdb_display_file
  1409. X    (
  1410. X        (int    sdb_buffer sdb_file_window)
  1411. X        (int    line lines current_buffer current_window)
  1412. X        (string    file sdb_file)
  1413. X        (global    sdb_file sdb_buffer sdb_file_window)
  1414. X
  1415. X        (get_parm 0 file)
  1416. X        (get_parm 1 line)
  1417. X
  1418. X        (= current_buffer (inq_buffer))
  1419. X        (= current_window (inq_window))
  1420. X
  1421. X        (if (== sdb_file_window 0) (
  1422. X                (create_edge 2)
  1423. X                (= sdb_file_window (inq_window))
  1424. X                )
  1425. X        ;else
  1426. X                (set_window sdb_file_window)
  1427. X        )
  1428. X
  1429. X        (if sdb_buffer
  1430. X                (set_buffer    sdb_buffer)
  1431. X                (= sdb_buffer (create_buffer "Sdb File" file 1))
  1432. X                )
  1433. X
  1434. X        (attach_buffer sdb_buffer)
  1435. X        (goto_old_line line)
  1436. X        (inq_window_size lines)
  1437. X        (set_top_left (- line (/ lines 2)))
  1438. X        (insert "==> ")
  1439. X
  1440. X        (set_window current_window)
  1441. X    )
  1442. X)
  1443. SHAR_EOF
  1444. chmod 0444 src/crisp/sdb.m || echo "restore of src/crisp/sdb.m fails"
  1445. mkdir src src/crisp >/dev/null 2>&1
  1446. echo "x - extracting src/crisp/search.m (Text)"
  1447. sed 's/^X//' << 'SHAR_EOF' > src/crisp/search.m &&
  1448. X/********************************************************************
  1449. X *                                                                  *
  1450. X *      CRISP - Custom Reduced Instruction Set Programmers Editor   *
  1451. X *                                                                  *
  1452. X *      (C) Paul Fox, 1989                                          *
  1453. X *      43, Jerome Close                Tel: +44 6284 4222          *
  1454. X *          Marlow                                                  *
  1455. X *           Bucks.                                                 *
  1456. X *              England SL7 1TX                                     *
  1457. X *                                                                  *
  1458. X *                                                                  *
  1459. X *    Please See COPYRIGHT notice.                                  *
  1460. X *                                                                  *
  1461. X ********************************************************************/
  1462. X# include    "crisp.h"
  1463. X
  1464. X(macro search-options
  1465. X    (
  1466. X        (list    r_list s_list)
  1467. X        (put_nth 0 r_list search-regexp)
  1468. X        (put_nth 1 r_list search-case)
  1469. X        (put_nth 2 r_list search-block)
  1470. X        (put_nth 3 r_list search-syntax)
  1471. X        (= s_list (quote_list
  1472. X            "Regular Expressions   : "    ("No" "Yes")
  1473. X            "Case sensitive        : " ("No" "Yes")
  1474. X            "Block selection       : " ("Off" "On")
  1475. X            "Syntax mode           : " ("CRISP" "Unix")
  1476. X            ))
  1477. X        (= r_list (field_list "Search Parameters" r_list s_list))
  1478. X        (= search-regexp (nth 0 r_list))
  1479. X        (= search-case (nth 1 r_list))
  1480. X        (= search-block (nth 2 r_list))
  1481. X        (= search-syntax (nth 3 r_list))
  1482. X    )
  1483. X)
  1484. X(macro translate-fwd
  1485. X    (
  1486. X        (int    old_msg_level)
  1487. X
  1488. X        (if (<= (get_parm NULL translate-pattern "Translate: " NULL translate-pattern) 0)
  1489. X            (return))
  1490. X        (if (<= (get_parm NULL translate-replacement "Replacement: " NULL translate-replacement) 0)
  1491. X            (return))
  1492. X        (= old_msg_level (inq_msg_level))
  1493. X        (set_msg_level 0)
  1494. X        (translate translate-pattern translate-replacement NULL 
  1495. X                search-regexp search-case search-block)
  1496. X        (set_msg_level old_msg_level)
  1497. X    )
  1498. X)
  1499. X(macro search-fwd
  1500. X    (
  1501. X        (int    old_msg_level
  1502. X                match_len)
  1503. X        
  1504. X        (if (<= (get_parm NULL search-pattern "Search for: " NULL search-pattern) 0)
  1505. X            (return))
  1506. X        (= old_msg_level (inq_msg_level))
  1507. X        (set_msg_level 0)
  1508. X        (= match_len (search_fwd search-pattern search-regexp search-case search-block))
  1509. X        (set_msg_level old_msg_level)
  1510. X        (return (search-hilite match_len))
  1511. X    )
  1512. X)
  1513. X(macro search-back
  1514. X    (
  1515. X        (int    old_msg_level
  1516. X                match_len)
  1517. X
  1518. X        (if (<= (get_parm NULL search-pattern "Search back: " NULL search-pattern) 0)
  1519. X            (return))
  1520. X        (= old_msg_level (inq_msg_level))
  1521. X        (set_msg_level 0)
  1522. X        (= match_len (search_back search-pattern search-regexp search-case search-block))
  1523. X        (set_msg_level old_msg_level)
  1524. X        (return (search-hilite match_len))
  1525. X    )
  1526. X)
  1527. X
  1528. X(macro search_next
  1529. X    (
  1530. X        (int    old_msg_level
  1531. X                match_len)
  1532. X
  1533. X        (save_position)
  1534. X        (next_char)
  1535. X        (= old_msg_level (inq_msg_level))
  1536. X        (set_msg_level 0)
  1537. X
  1538. X        (= match_len (search_fwd search-pattern search-regexp search-case search-block))
  1539. X        (if (<= match_len 0)
  1540. X            (restore_position)
  1541. X        ;else
  1542. X            (restore_position 0))
  1543. X
  1544. X        (set_msg_level old_msg_level)
  1545. X        (return (search-hilite match_len))
  1546. X    )
  1547. X)
  1548. X(macro search_prev
  1549. X    (
  1550. X        (int    old_msg_level
  1551. X                match_len)
  1552. X
  1553. X        (save_position)
  1554. X        (prev_char)
  1555. X        (= old_msg_level (inq_msg_level))
  1556. X        (set_msg_level 0)
  1557. X
  1558. X        (= match_len (search_back search-pattern search-regexp search-case search-block))
  1559. X        (if (<= match_len 0)
  1560. X            (restore_position)
  1561. X        ;else
  1562. X            (restore_position 0))
  1563. X
  1564. X        (set_msg_level old_msg_level)
  1565. X        (return (search-hilite match_len))
  1566. X    )
  1567. X)
  1568. X
  1569. X/*************************************************************
  1570. X/*   Macro to hilite a group of characters until a key is
  1571. X/*   pressed. Used by search-fwd and search-back macros.
  1572. X/*************************************************************/
  1573. X(macro search-hilite
  1574. X    (
  1575. X        (int    ch)
  1576. X        (int    match_len)
  1577. X        
  1578. X        (get_parm 0 match_len)
  1579. X        
  1580. X        (if (<= match_len 2)
  1581. X            (return match_len))
  1582. X
  1583. X        /*----------------------------------------
  1584. X        /*   If search is successful, hilite the
  1585. X        /*   matched string but only if the matched
  1586. X        /*   string len is at least 2 chars wide,
  1587. X        /*   otherwise we have real problems on
  1588. X        /*   a mono screen. We hilite the
  1589. X        /*   string until the user presses another
  1590. X        /*   key.
  1591. X        /*----------------------------------------*/
  1592. X        (next_char (- match_len 1))
  1593. X        (drop_anchor MK_NONINC)
  1594. X        (prev_char (- match_len 1))
  1595. X        (refresh)
  1596. X        (while (== (= ch (read_char)) -1)
  1597. X            )
  1598. X        (push_back ch)
  1599. X        (raise_anchor)
  1600. X        (return match_len)
  1601. X    )
  1602. X)
  1603. X(macro _init
  1604. X    (
  1605. X        (int        search-regexp
  1606. X                    search-case
  1607. X                    search-block
  1608. X                    search-syntax
  1609. X                    )
  1610. X        (string    search-pattern
  1611. X                    translate-pattern
  1612. X                    translate-replacement)
  1613. X        (global    search-regexp
  1614. X                    search-case
  1615. X                    search-block
  1616. X                    search-pattern
  1617. X                    search-syntax
  1618. X                    translate-pattern
  1619. X                    translate-replacement)
  1620. X
  1621. X        (= search-regexp TRUE)
  1622. X        (= search-case TRUE)
  1623. X        (= search-block FALSE)
  1624. X        (= search-syntax 0)    /* Set to 1 for Unix syntax. */
  1625. X    )
  1626. X)
  1627. X
  1628. SHAR_EOF
  1629. chmod 0444 src/crisp/search.m || echo "restore of src/crisp/search.m fails"
  1630. mkdir src src/crisp >/dev/null 2>&1
  1631. echo "x - extracting src/crisp/select.m (Text)"
  1632. sed 's/^X//' << 'SHAR_EOF' > src/crisp/select.m &&
  1633. X/********************************************************************
  1634. X *                                                                  *
  1635. X *      CRISP - Custom Reduced Instruction Set Programmers Editor   *
  1636. X *                                                                  *
  1637. X *      (C) Paul Fox, 1989                                          *
  1638. X *      43, Jerome Close                Tel: +44 6284 4222          *
  1639. X *          Marlow                                                  *
  1640. X *           Bucks.                                                 *
  1641. X *              England SL7 1TX                                     *
  1642. X *                                                                  *
  1643. X *                                                                  *
  1644. X *    Please See COPYRIGHT notice.                                  *
  1645. X *                                                                  *
  1646. X ********************************************************************/
  1647. X# include    "crisp.h"
  1648. X
  1649. X# define TRUE    1
  1650. X# define FALSE    0
  1651. X# define    TOP_LINE            3
  1652. X# define    WINDOW_OFFSET    6
  1653. X# define    MARGIN            12
  1654. X
  1655. X(macro _init
  1656. X    (
  1657. X        (int        top_line 
  1658. X                    window_offset 
  1659. X                    select_nest_level)
  1660. X        (global     top_line 
  1661. X                    window_offset
  1662. X                    select_nest_level)
  1663. X
  1664. X        (= top_line TOP_LINE)
  1665. X        (= window_offset WINDOW_OFFSET)
  1666. X    )
  1667. X)
  1668. X;*
  1669. X;*  Display list of buffers on screen, and allow user to make a selection.
  1670. X;*
  1671. X;*  First parameter says whether to display in long or short format.
  1672. X;*  Short format is compatible with the BRIEF display; Long mode is
  1673. X;*  adds extra status fields, demonstrating CRISP's enhancements.
  1674. X;*
  1675. X;*  Second parameter says whether to display system buffers as well.
  1676. X;*
  1677. X(macro buffer_list
  1678. X    (
  1679. X        (int    curbuf
  1680. X                curwin)
  1681. X        (int    shortmode)
  1682. X        (int    sysbuffers)
  1683. X        (int    buf_no)
  1684. X        (int    buffer_list)
  1685. X        (int    win)
  1686. X        (int    retval)
  1687. X        (int    this_buf)
  1688. X        (int    position)
  1689. X        (string    file_name)
  1690. X        (string    tmp line modes)
  1691. X
  1692. X        (get_parm 0 shortmode)
  1693. X        (get_parm 1 sysbuffers)
  1694. X
  1695. X        (= shortmode (! shortmode))
  1696. X
  1697. X        (= curbuf (inq_buffer))
  1698. X        (= buffer_list (create_buffer "Buffer List" NULL 1))
  1699. X        (set_buffer buffer_list)
  1700. X
  1701. X        (= buf_no 1)
  1702. X        (set_buffer curbuf)
  1703. X        (set_buffer (next_buffer))
  1704. X        (while (1) (
  1705. X            (inq_names file_name)
  1706. X            (= this_buf (inq_buffer))
  1707. X            (if (|| sysbuffers (! (inq_system))) (
  1708. X                (if shortmode
  1709. X                     (sprintf tmp "%d) %s%s\n" 
  1710. X                                buf_no 
  1711. X                                file_name 
  1712. X                                (if (inq_modified) "*" ""))
  1713. X                ;else
  1714. X                    (
  1715. X                    (inq_position position)
  1716. X                    (= modes "")
  1717. X                    (+= modes (if (& (inq_buffer_flags) BF_CHANGED) "*" " "))
  1718. X                    (+= modes (if (& (inq_buffer_flags) BF_PROCESS) "P" " "))
  1719. X                    (+= modes (if (& (inq_buffer_flags) BF_BACKUP) "B" " "))
  1720. X                    (+= modes (if (& (inq_buffer_flags) BF_READONLY) "R" " "))
  1721. X                    (+= modes (if (inq_system) "S" " "))
  1722. X                    (+= modes (if (& (inq_buffer_flags) BF_BINARY) " <Bin> " "       "))
  1723. X                     (sprintf tmp "%d)  %5d %5d %s %s" 
  1724. X                                buf_no 
  1725. X                                (inq_lines) 
  1726. X                                position
  1727. X                                modes
  1728. X                                file_name)
  1729. X                    )
  1730. X                )
  1731. X                (set_buffer buffer_list)
  1732. X                (if (> buf_no 1)
  1733. X                    (insert "\n"))
  1734. X                (insert tmp)
  1735. X                (++ buf_no)
  1736. X                (set_buffer this_buf)
  1737. X                ))
  1738. X            (if (== (inq_buffer) curbuf)
  1739. X                (break))
  1740. X            (set_buffer (next_buffer sysbuffers))
  1741. X            ))
  1742. X
  1743. X        (message "List created.")
  1744. X
  1745. X        (= win (sized_window buf_no 70 "<Up>, <Down> to move. <Enter> to select, D to delete, W to write"))
  1746. X        (= retval (select_buffer buffer_list win SEL_NORMAL
  1747. X                (
  1748. X                    (assign_to_key "d"    "buf_delete")
  1749. X                    (assign_to_key "D"    "buf_delete")
  1750. X                    (assign_to_key "w"    "buf_write")
  1751. X                    (assign_to_key "W"    "buf_write")
  1752. X                )
  1753. X                NULL
  1754. X                "help_display \"features/Buflist.hlp\" \"List Buffers\""
  1755. X            ))
  1756. X
  1757. X        (if (< retval 0) (
  1758. X            (delete_buffer buffer_list)
  1759. X            (set_buffer curbuf)
  1760. X            (attach_buffer curbuf)
  1761. X            (return)
  1762. X            ))
  1763. X
  1764. X        (set_buffer buffer_list)
  1765. X        (move_abs retval 0)
  1766. X        (= line (trim (read)))
  1767. X        (delete_buffer buffer_list)
  1768. X        (set_buffer curbuf)
  1769. X
  1770. X        (= line (substr line (+ (rindex line " ") 1)))
  1771. X        (if (== (substr line (strlen line)) "*")
  1772. X            (= line (substr line (- (strlen line) 1))))
  1773. X        (edit_file line)
  1774. X    )
  1775. X)
  1776. X(macro buf_delete
  1777. X    (
  1778. X        (string line str)
  1779. X        (int        buf)
  1780. X
  1781. X        (= line (trim (read)))
  1782. X        (= line (substr line (+ (rindex line " ") 1)))
  1783. X        (if (== (substr line (strlen line)) "*")
  1784. X            (= line (substr line (- (strlen line) 1))))
  1785. X
  1786. X        (= buf (inq_file_buffer line))
  1787. X        ;*
  1788. X        ;*   Dont let user delete a buffer which is currently
  1789. X        ;*   being displayed.
  1790. X        ;*
  1791. X        (if (inq_views buf) (
  1792. X            (error "Cannot delete a buffer being displayed.")
  1793. X            (return)))
  1794. X        ;*
  1795. X        ;*   If buffer has been modified, check whether user
  1796. X        ;*   is really sure.
  1797. X        ;*
  1798. X        (if (inq_modified buf) (
  1799. X            (= str "X")
  1800. X            (while (&& (!= str "y") (!= str "Y")) (
  1801. X                (if (! (get_parm NULL str "Buffer has not been saved. Delete [ynw]? " 1))
  1802. X                    (= str "n"))
  1803. X                (if (|| (== str "n") (== str "N")) (
  1804. X                    (message "")
  1805. X                    (return)
  1806. X                    ))
  1807. X                (if (|| (== str "w") (== str "W")) (
  1808. X                    (int curbuf)
  1809. X                    (= curbuf (inq_buffer))
  1810. X                    (set_buffer buf)
  1811. X                    (write_buffer)
  1812. X                    (set_buffer curbuf)
  1813. X                    (break)
  1814. X                    ))
  1815. X                ))
  1816. X            ))
  1817. X        (delete_buffer buf)
  1818. X        (delete_line)
  1819. X    )
  1820. X)
  1821. X(macro buf_write
  1822. X    (
  1823. X        (string line str)
  1824. X        (int        curbuf buf)
  1825. X
  1826. X        (= line (trim (read)))
  1827. X        (= line (substr line (+ (rindex line " ") 1)))
  1828. X        (if (== (substr line (strlen line)) "*")
  1829. X            (= line (substr line (- (strlen line) 1))))
  1830. X
  1831. X        (= buf (inq_file_buffer line))
  1832. X        (if (! (inq_modified buf)) (
  1833. X            (error "Buffer already saved.")
  1834. X            (return)
  1835. X            ))
  1836. X        (= curbuf (inq_buffer))
  1837. X        (set_buffer buf)
  1838. X        (write_buffer)
  1839. X        (set_buffer curbuf)
  1840. X        (translate "*" " " 0 0)
  1841. X        (beginning_of_line)
  1842. X        (message "Buffer saved.")
  1843. X    )
  1844. X)
  1845. X(macro select_file
  1846. X    (
  1847. X        (string file path cwd wild_card title)
  1848. X        (int i)
  1849. X
  1850. X        (getwd NULL cwd)
  1851. X        (get_parm 0 wild_card)
  1852. X        (get_parm 1 title)
  1853. X        (if (== wild_card "")
  1854. X            (= wild_card "*")
  1855. X        ;
  1856. X            (+= wild_card "*")
  1857. X            )
  1858. X        (if (= i (rindex wild_card "/")) (
  1859. X            (= path (substr wild_card 1 (- i 1)))
  1860. X            (cd path)
  1861. X            ))
  1862. X        (while 1 (
  1863. X            (getwd NULL path)
  1864. X            (= file (_select_file path wild_card title))
  1865. X            (if (== file "")
  1866. X                (break))
  1867. X            (if (!= (substr file (strlen file)) "/")
  1868. X                (break))
  1869. X            (cd file)
  1870. X            (= wild_card "*")
  1871. X            ))
  1872. X        (refresh)
  1873. X        (cd cwd)
  1874. X        (return (+ path (+ "/" file)))
  1875. X    )
  1876. X)
  1877. X(macro _select_file
  1878. X    (
  1879. X        (string    name    
  1880. X                    file
  1881. X                    path
  1882. X                    wild-card
  1883. X                    nl
  1884. X                    title
  1885. X                    tmpbuf)
  1886. X        (int        size
  1887. X                    ret
  1888. X                    mtime
  1889. X                    mode
  1890. X                    curbuf
  1891. X                    width
  1892. X                    min_width
  1893. X                    i
  1894. X                    buf
  1895. X                    win)
  1896. X
  1897. X        (= curbuf (inq_buffer))
  1898. X        (get_parm 0 path)
  1899. X        (= min_width (+ (strlen path) 6))
  1900. X        (get_parm 2 title)
  1901. X        (= buf (create_buffer (if (!= title "") title path) NULL 1))
  1902. SHAR_EOF
  1903. echo "End of part 4"
  1904. echo "File src/crisp/select.m is continued in part 5"
  1905. echo "5" > s2_seq_.tmp
  1906. exit 0
  1907. -- 
  1908. =====================            Reuters Ltd PLC, 
  1909. Tel: +44 628 891313 x. 212         Westthorpe House,
  1910. UUCP:     fox%marlow.uucp@idec.stc.co.uk  Little Marlow,
  1911.                        Bucks, England SL7 3RQ
  1912.  
  1913.