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

  1. Newsgroups: comp.sources.misc
  2. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  3. Subject: v07i036: CRISP release 1.9 part 15/32
  4. Organization: Reuters Ltd PLC, Marlow, England
  5. Reply-To: fox@marlow.UUCP (Paul Fox)
  6.  
  7. Posting-number: Volume 7, Issue 36
  8. Submitted-by: fox@marlow.UUCP (Paul Fox)
  9. Archive-name: crisp1.9/part16
  10.  
  11.  
  12.  
  13. #!/bin/sh
  14. # this is part 2 of a multipart archive
  15. # do not concatenate these parts, unpack them in order with /bin/sh
  16. # file src/crisp/core.m continued
  17. #
  18. CurArch=2
  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/core.m"
  29. sed 's/^X//' << 'SHAR_EOF' >> src/crisp/core.m
  30. X *           Bucks.                                                 *
  31. X *              England SL7 1TX                                     *
  32. X *                                                                  *
  33. X *                                                                  *
  34. X *    Please See COPYRIGHT notice.                                  *
  35. X *                                                                  *
  36. X ********************************************************************/
  37. X
  38. X# include    "crisp.h"
  39. X
  40. X# define    FILENAME    "BUFFER"
  41. X
  42. X(macro _fatal_error
  43. X    (
  44. X        (int    win
  45. X                buf
  46. X                file_no
  47. X                this_buf)
  48. X        (string    prompt tmp file_name buf_name)
  49. X
  50. X        (= buf (create_buffer "*** CRISP Internal Error ***" NULL 1))
  51. X        (set_buffer buf)
  52. X        (insert "A fatal error has been detected with the software.\n")
  53. X        (insert "CRISP  will attempt to save your modified buffers.\n")
  54. X        (insert "\n")
  55. X        (insert "It will  write  the  buffers  away to files called\n")
  56. X        (insert "BUFFER.1, BUFFER.2, etc.\n")
  57. X        (insert "\n")
  58. X        (insert "It will not  overwrite the  original files in case\n")
  59. X        (insert "the buffers have  been corrupted or it dies during\n")
  60. X        (insert "the attempted salvage.\n")
  61. X        (insert "\n")
  62. X        (insert "You will be prompted to save each file.")
  63. X        (top_of_buffer)
  64. X        (= win (sized_window (inq_lines) (inq_line_length) ""))
  65. X        (set_window win)
  66. X        (attach_buffer buf)
  67. X        (refresh)
  68. X        (message "")        
  69. X        /*----------------------------------------
  70. X        /*   Now attempt to save the files.
  71. X        /*----------------------------------------*/
  72. X        (= this_buf (next_buffer 1))
  73. X        (= file_no 1)
  74. X        
  75. X        (while (!= this_buf buf) (
  76. X            (set_buffer this_buf)
  77. X            
  78. X            (if (&& (! (inq_system)) (inq_modified)) (
  79. X                (inq_names file_name NULL buf_name)
  80. X                
  81. X                (if (> (strlen file_name) 20)
  82. X                    (= file_name buf_name))
  83. X                    
  84. X                (sprintf tmp "Save %s as %s.%d ? (y/n) " file_name FILENAME file_no)
  85. X                (= prompt "x")
  86. X                
  87. X                (while (== (index "NnYy" prompt) 0) (
  88. X                    (get_parm NULL prompt tmp 1)
  89. X                    ))
  90. X                (if (index "yY" prompt) (
  91. X                    (sprintf file_name "%s.%d" FILENAME file_no)
  92. X                    (write_buffer file_name)
  93. X                    (++ file_no)))
  94. X                ))
  95. X            (= this_buf (next_buffer 1))
  96. X            ))
  97. X    )
  98. X)
  99. SHAR_EOF
  100. echo "File src/crisp/core.m is complete"
  101. chmod 0644 src/crisp/core.m || echo "restore of src/crisp/core.m fails"
  102. mkdir src src/crisp >/dev/null 2>&1
  103. echo "x - extracting src/crisp/crisp.m (Text)"
  104. sed 's/^X//' << 'SHAR_EOF' > src/crisp/crisp.m &&
  105. X/********************************************************************
  106. X *                                                                  *
  107. X *      CRISP - Custom Reduced Instruction Set Programmers Editor   *
  108. X *                                                                  *
  109. X *      (C) Paul Fox, 1989                                          *
  110. X *      43, Jerome Close                Tel: +44 6284 4222          *
  111. X *          Marlow                                                  *
  112. X *           Bucks.                                                 *
  113. X *              England SL7 1TX                                     *
  114. X *                                                                  *
  115. X *                                                                  *
  116. X *    Please See COPYRIGHT notice.                                  *
  117. X *                                                                  *
  118. X ********************************************************************/
  119. X# include    "crisp.h"
  120. X
  121. X
  122. X/*----------------------------------------
  123. X/*   The following macro is used to convert
  124. X/*   a PC keyboard key description into
  125. X/*   a keyboard dependent string, so that
  126. X/*   messages appearing at the bottom of
  127. X/*   windows dont necessarily say things like
  128. X/*   <Alt-H> on a keyboard which doesnt have
  129. X/*   an Alt-H key.
  130. X/*----------------------------------------*/
  131. X(macro key_label
  132. X    (
  133. X        (string key)
  134. X        (int len keyval)
  135. X        
  136. X        (get_parm 0 key)
  137. X        (= keyval (- (key_to_int key) 128))
  138. X        
  139. X        (= len (length_of_list kbd_labels))
  140. X        (if (< len keyval)
  141. X            (return key))
  142. X        (return (nth keyval kbd_labels))
  143. X        
  144. X    )
  145. X)
  146. X/*----------------------------------------
  147. X/*   Macro to perform a redo after an undo.
  148. X/*----------------------------------------*/
  149. X(macro redo
  150. X    (undo 0 0 0)
  151. X)
  152. X(macro edit_next_buffer
  153. X    (
  154. X        (int    curbuf
  155. X                nextbuf)
  156. X        (string filename)
  157. X
  158. X        (= curbuf (inq_buffer))
  159. X        (= nextbuf (next_buffer))
  160. X
  161. X        (if (== curbuf nextbuf) (
  162. X            (error "No more buffers.")
  163. X            (return)))
  164. X
  165. X        (set_buffer nextbuf)
  166. X        (inq_names filename)
  167. X        (edit_file filename)
  168. X        (display_file_name)
  169. X    )
  170. X)
  171. X(macro edit_prev_buffer
  172. X    (
  173. X        (int    curbuf
  174. X                nextbuf)
  175. X        (string    filename)
  176. X
  177. X        (= curbuf (inq_buffer))
  178. X        (= nextbuf (next_buffer))
  179. X
  180. X        (if (== curbuf nextbuf) (
  181. X            (error "No more buffers.")
  182. X            (return)))
  183. X
  184. X        (while 1 (
  185. X            (set_buffer nextbuf)
  186. X            (if (== (next_buffer) curbuf)
  187. X                (break))
  188. X            (= nextbuf (next_buffer))
  189. X            ))
  190. X        (set_buffer nextbuf)
  191. X        (inq_names filename)
  192. X        (edit_file filename)
  193. X        (display_file_name)
  194. X    )
  195. X)
  196. X(macro redit
  197. X    (
  198. X        (string file_name)
  199. X        (int    tmpbuf curbuf line)
  200. X
  201. X        (inq_names NULL NULL file_name)
  202. X        (inq_position line)
  203. X
  204. X        (= curbuf (inq_buffer))
  205. X        (delete_buffer curbuf)
  206. X
  207. X        (edit_file "Non-existant")
  208. X        (= tmpbuf (inq_buffer))
  209. X
  210. X        (shell_pop (+ "exec sccs edit " file_name))
  211. X        (edit_file file_name)
  212. X        (delete_buffer tmpbuf)
  213. X        (goto_line line)
  214. X    )
  215. X)
  216. X(macro shell_pop
  217. X    (
  218. X        (string command
  219. X                    space)
  220. X        (int    curwin
  221. X                curbuf
  222. X                win
  223. X                buf
  224. X                line col)
  225. X
  226. X        (get_parm 0 command)
  227. X        (= curwin (inq_window))
  228. X        (= curbuf (inq_buffer))
  229. X        (= buf (create_buffer "Shell Pop-Up" NULL 1))
  230. X        (= win (create_window 55 8 77 2))
  231. X        (attach_buffer buf)
  232. X        (connect)
  233. X        (insert (+ command "\n"))
  234. X        (inq_position line col)
  235. X        (set_process_position line col)
  236. X        (insert_process (+ command "\n"))
  237. X        (refresh)
  238. X        ;*
  239. X        ;*   Wait for process to exit.
  240. X        ;*
  241. X        (wait)
  242. X        (delete_buffer buf)
  243. X        (delete_window)
  244. X        (set_buffer curbuf)
  245. X        (set_window curwin)
  246. X    )
  247. X)
  248. X(macro    clear_buffer
  249. X    (
  250. X        (top_of_buffer)
  251. X        (drop_anchor)
  252. X        (end_of_buffer)
  253. X        (delete_block)
  254. X    )
  255. X)
  256. X;**************************************************
  257. X;** ALT-!:  Pipe output from shell into buffer.  **
  258. X;**************************************************
  259. X(macro _pipe     
  260. X    (    (string    command)
  261. X
  262. X        (get_parm NULL command "!")
  263. X        (sprintf command "%s >&bpipe.tmp" command)
  264. X        (dos command)
  265. X        (read_file "bpipe.tmp")
  266. X        (del "bpipe.tmp")
  267. X    )
  268. X)
  269. X
  270. X;**************************************************
  271. X;** .log:   Extension handler for .log files.    **
  272. X;**************************************************
  273. X(macro    .log
  274. X    (
  275. X        (set_backup)
  276. X    )
  277. X)
  278. X(macro    .m
  279. X    (tabs 4 7)
  280. X)
  281. X(macro    .c
  282. X    (tabs 9 17)
  283. X)
  284. X(macro    default
  285. X    (tabs 9 17)
  286. X)
  287. X//
  288. X//    The following macro is called on startup and is responsible
  289. X// for setting up the initial environment. In addition, it sets
  290. X// up the following global variables which are used by the other
  291. X// macros to try and ensure some form of portability between
  292. X// operating systems.
  293. X//
  294. X//    string     CRISP_OPSYS
  295. X//        This contains the string:
  296. X//            VMS    - if running under VMS
  297. X//            UNIX    - if running under any Unix variant.
  298. X//
  299. X//    string    CRISP_DELIM
  300. X//        This contains a string which can be used to concatenate a
  301. X//        directory name and a filename. This string can be used
  302. X//        for constructing filenames.
  303. X//        Under VMS this is null; under Unix it is "/".
  304. X//
  305. X// string    CRISP_SLASH
  306. X//        This contains the character used to delimit a directory
  307. X//        name and a file name. This string can be used for breaking
  308. X//        apart file-names.
  309. X//        Under VMS this is "]"; under Unix it is "/".
  310. X//
  311. X(macro crisp
  312. X    (
  313. X        (int    win suflen kbd_normal)
  314. X        (list    kbd_labels)
  315. X        (global    kbd_normal
  316. X                    kbd_labels)
  317. X        (string    kbd term suffix 
  318. X                    suffices 
  319. X                    CRISP_OPSYS
  320. X                    CRISP_DELIM
  321. X                    CRISP_SLASH
  322. X                    )
  323. X        (global     win 
  324. X                    CRISP_OPSYS
  325. X                    CRISP_DELIM
  326. X                    CRISP_SLASH
  327. X                    )
  328. X
  329. X        (= kbd_normal (inq_keyboard))
  330. X        (assign_to_key "<Shift-Tab>"    "previous_tab")
  331. X        (assign_to_key "<Shift-F5>"    "search_next")
  332. X        (assign_to_key "<Shift-F6>"    "search_prev")
  333. X        (assign_to_key "<Shift-F10>"    "cm")
  334. X        (assign_to_key "<Home>"    "home")
  335. X        (assign_to_key    "<End>"    "end")
  336. X        (assign_to_key "<Ctrl-Left-Arrow>" "objects word_left")
  337. X        (assign_to_key "<Ctrl-Right-Arrow>" "objects word_right")
  338. X        (assign_to_key    "<Alt-1>"    "drop_bookmark 1")
  339. X        (assign_to_key    "<Alt-2>"    "drop_bookmark 2")
  340. X        (assign_to_key    "<Alt-3>"    "drop_bookmark 3")
  341. X        (assign_to_key    "<Alt-4>"    "drop_bookmark 4")
  342. X        (assign_to_key    "<Alt-5>"    "drop_bookmark 5")
  343. X        (assign_to_key    "<Alt-6>"    "drop_bookmark 6")
  344. X        (assign_to_key    "<Alt-7>"    "drop_bookmark 7")
  345. X        (assign_to_key    "<Alt-8>"    "drop_bookmark 8")
  346. X        (assign_to_key    "<Alt-9>"    "drop_bookmark 9")
  347. X        (assign_to_key    "<Alt-0>"    "drop_bookmark 0")
  348. X        (assign_to_key    "<Alt-B>"    "buffer_list 1")
  349. X        (assign_to_key    "<Alt-F>"    "features")
  350. X        (assign_to_key    "<Alt-H>"    "help")
  351. X        (assign_to_key    "<Alt-P>"    "edit_prev_buffer")
  352. X        (assign_to_key    "<Alt-N>"    "edit_next_buffer")
  353. X        (assign_to_key    "<Alt-Q>"    "quote")
  354. X        (assign_to_key    "<Alt-S>"    "search-fwd")
  355. X        (assign_to_key    "<Alt-T>"    "translate-fwd")
  356. X        (assign_to_key    "<Alt-Y>"    "search-back")
  357. X        (assign_to_key    "#127"    "delete_character")
  358. X        (assign_to_key    "^B"    "set_bottom_of_window")
  359. X        (assign_to_key    "^C"    "set_center_of_window")
  360. X        (assign_to_key    "^F"    "objects format_block")
  361. X        (assign_to_key    "^G"    "objects routines")
  362. X        (assign_to_key    "^H"    "backspace")
  363. X        (assign_to_key    "^K"    "objects delete_word_left")
  364. X        (assign_to_key    "^L"    "objects delete_word_right")
  365. X        (assign_to_key    "^O"    "options")
  366. X        (assign_to_key    "^R"    "repeat")
  367. X        (assign_to_key    "^T"    "set_top_of_window")
  368. X        (assign_to_key    "^U"    "redo")
  369. X        (assign_to_key    "^^"    "brace")
  370. X        (assign_to_key    "^]"    "tag_function")
  371. X        /*-------------------------------------------------------
  372. X        /*
  373. X        /*    Find  out  what  operating system we are on. We do
  374. X        /*    this  by  testing  for the existence of files that
  375. X        /*    are  peculiar  to  the  operating  systems.  These
  376. X        /*    tests  may  get  the wrong files in which case you
  377. X        /*    may  need  to  tinker  with  them for best effect.
  378. X        /*    The  purpose  here  is  to  have a global variable
  379. X        /*    that  can  be  tested  in  the  macros  for system
  380. X        /*    dependent    actions.   For   example,   VMS   has
  381. X        /*    different  file  naming  conventions to unix which
  382. X        /*    can cause the macros to fail.
  383. X        /*-------------------------------------------------------*/
  384. X        
  385. X        (if (exist "sys$input") (
  386. X                (= CRISP_OPSYS "VMS")
  387. X                (= CRISP_DELIM "")
  388. X                (= CRISP_SLASH "]")
  389. X                )
  390. X        ;else
  391. X            (if (exist "/") (
  392. X                (= CRISP_OPSYS "UNIX")
  393. X                (= CRISP_DELIM "/")
  394. X                (= CRISP_SLASH "/")
  395. X                )))
  396. X        
  397. X        /*---------------------------------------------------------*/
  398. X        /*    Find   out   what   terminal   type  we  are,  and      *
  399. X        /*    initialise   the   terminal   characteristics  for      *
  400. X        /*    CRISP.  We  do  this  by  first seeing if BTERM is      *
  401. X        /*    set.  If  it  is, then we load tty/$BTERM; if not,      *
  402. X        /*    we   use   TERM,  and  see  if  tty/$TERM  exists.      *
  403. X        /*    Otherwise,  we  default  to  tty.m  If  the  BTERM      *
  404. X        /*    environment    variable    is    of    the   form:      *
  405. X        /*    type-type1-type2,  then  we  load  tty/type.m  and      *
  406. X        /*    execute  macros  'type1',  'type2', ... This is to      *
  407. X        /*    avoid  exceeding  the  14 character filename limit      *
  408. X        /*    on  Sys  V,  and also to keep terminal definitions      *
  409. X        /*    which are similar in the same tty file.                  *
  410. X        /*---------------------------------------------------------*/
  411. X        
  412. X        (= term (inq_environment "BTERM"))
  413. X        (if (== term "")
  414. X            (= term (lower (inq_environment "TERM"))))
  415. X        (= suflen (index term "-"))
  416. X        (if suflen (
  417. X                (= suffices (substr term (+ suflen 1)))
  418. X                (= term (substr term 1 (- suflen 1)))
  419. X                ))
  420. X        (if (|| (== term "") (! (load_macro (+ "tty/" term)))) 
  421. X            (load_macro "tty/tty")
  422. X            )
  423. X        /*----------------------------------------
  424. X        /*  Now scan suffix list.
  425. X        /*----------------------------------------*/
  426. X        (while (!= suffices "") (
  427. X            (= suflen (index suffices "-"))
  428. X            (if suflen (
  429. X                (= suffix (substr suffices 1 (- suflen 1)))
  430. X                (= suffices (substr suffices (+ suflen 1)))
  431. X                )
  432. X            ;else
  433. X                (
  434. X                    (= suffix suffices)
  435. X                    (= suffices "")
  436. X                )
  437. X            )
  438. X            (execute_macro suffix)
  439. X            ))
  440. X        /*----------------------------------------
  441. X        /*  See if this guy has a keyboard description
  442. X        /*  environment variable.
  443. X        /*----------------------------------------*/
  444. X        (= kbd (lower (inq_environment "BKBD")))
  445. X        (load_macro (+ "kbd/" kbd))
  446. X        ;*
  447. X        ;*  We enable CRISP to update the screen, and tell it to
  448. X        ;*  refresh it.
  449. X        ;*
  450. X        (enable_display 1)
  451. X        (redraw)
  452. X        ;*
  453. X        ;*  Autoload definitions.
  454. X        ;*
  455. X        (autoload "compile"     
  456. X                                    "cm"
  457. X                                    "make" 
  458. X                                    "lint"
  459. X                                    "default-next_error" "default-previous_error")
  460. X        (autoload "core"         "_fatal_error")
  461. X        (autoload "g_macros" 
  462. X                                    "objects" 
  463. X                                    "<<"
  464. X                                    ">>"
  465. X                                    "c-routines" 
  466. X                                    "h-routines" 
  467. X                                    "m-routines"
  468. X                                    "mm-routines"
  469. X                                    "select_routine")
  470. X        (autoload "help"
  471. X                                    "help"
  472. X                                    "help_display"
  473. X                                    "explain")
  474. X        (autoload "history" 
  475. X                                    "_prompt_begin"
  476. X                                    "_prompt_end")
  477. X        (autoload "misc"
  478. X                                    "autoindent"
  479. X                                    "display_file_name"
  480. X                                    "end"
  481. X                                    "home"
  482. X                                    "previous_tab"
  483. X                                    "quote"
  484. X                                    "repeat"
  485. X                                    "delete_character"
  486. X                                    "write_buffer"
  487. X                                    )
  488. X        (autoload "options" 
  489. X                                    "options"
  490. X                                    "echo_line-options")
  491. X        (autoload "region"
  492. X                                    "copy"
  493. X                                    "cut"
  494. X;                                    "paste"
  495. X                                    )
  496. X        (autoload "search"
  497. X                                    "translate-fwd"
  498. X                                    "search-fwd"
  499. X                                    "search-back"
  500. X                                    "search_next"
  501. X                                    "search_prev"
  502. X                                    "search-options")
  503. X        (autoload "select" 
  504. X                                    "field_list"
  505. X                                    "sized_window" 
  506. X                                    "select_list" 
  507. X                                    "select_file" 
  508. X                                    "select_buffer" 
  509. X                                    "buffer_list")
  510. X        (autoload "shell"     
  511. X                                    "sh" 
  512. X                                    "csh" 
  513. X                                    "ksh" 
  514. X                                    "create_shell")
  515. X        (autoload     "tags"
  516. X                                    "mtags"
  517. X                                    "tag"
  518. X                                    "tags"
  519. X                                    "tag_function")
  520. X        (autoload     "telnet"
  521. X                                    "rlogin")
  522. X        (autoload     "text"        
  523. X                                    "grep"
  524. X                                    "spell"
  525. X                                    "wc")
  526. X        (autoload     "unix"        
  527. X                                    "perform_unix_command")
  528. X        (autoload    "window"
  529. X                                    "set_top_of_window"
  530. X                                    "set_bottom_of_window"
  531. X                                    "set_center_of_window")
  532. X        (autoload    "wp"
  533. X                                    "wp-options"
  534. X                                    "h-format_block"
  535. X                                    "c-format_block"
  536. X                                    "default-format_block"
  537. X                                    "margin")
  538. X        ;*
  539. X        ;*   Tell user about any latest news.
  540. X        ;*
  541. X        ;* (welcome)
  542. X    )
  543. X)
  544. X
  545. SHAR_EOF
  546. chmod 0444 src/crisp/crisp.m || echo "restore of src/crisp/crisp.m fails"
  547. mkdir src src/crisp >/dev/null 2>&1
  548. echo "x - extracting src/crisp/dial.m (Text)"
  549. sed 's/^X//' << 'SHAR_EOF' > src/crisp/dial.m &&
  550. X/********************************************************************
  551. X *                                                                  *
  552. X *      CRISP - Custom Reduced Instruction Set Programmers Editor   *
  553. X *                                                                  *
  554. X *      (C) Paul Fox, 1989                                          *
  555. X *      43, Jerome Close                Tel: +44 6284 4222          *
  556. X *          Marlow                                                  *
  557. X *           Bucks.                                                 *
  558. X *              England SL7 1TX                                     *
  559. X *                                                                  *
  560. X *                                                                  *
  561. X *    Please See COPYRIGHT notice.                                  *
  562. X *                                                                  *
  563. X ********************************************************************/
  564. X# include    "crisp.h"
  565. X
  566. X
  567. X# define    TIMEOUT    60
  568. X# define    TRUE        1
  569. X# define    PREFIX    "\rATDT9"
  570. X
  571. X;***
  572. X;*** Initialise modem description table.
  573. X;***
  574. X(macro    _init
  575. X    (
  576. X        (list    modem_strings)
  577. X        (global modem_strings)
  578. X        (int modem_active)
  579. X        (global modem_active)
  580. X
  581. X        (unregister_macro 5 "dial_hangup")
  582. X        (register_macro 5 "dial_hangup")
  583. X
  584. X        (= modem_strings (quote_list 
  585. X            (300                "1\r")
  586. X            (1200                "5\r")
  587. X            (2400                "10\r")
  588. X;            (4800                "3\r")
  589. X;            (9600                "??")    ; Not defined at present.
  590. X;            (19200            "??") ;  "       "
  591. X            ("NO CARRIER"     "3\r")
  592. X            ("BUSY"            "7\r")
  593. X            ("NO ANSWER"    "8\r")
  594. X            ("RING"            "2\r")
  595. X            ("BLACKLISTED" "26\r")
  596. X            ))
  597. X    )
  598. X)
  599. X;***
  600. X;*** Example dial macro for calling BIX. Note that this macro
  601. X;*** is censored before being distributed world-wide. So you'll
  602. X;*** have to fill in your own telephone number / passwords etc.
  603. X;***
  604. X;*** This macro dials an X.25 PAD in England and calls BIX.
  605. X;*** Please tailor to your own needs, but please keep copy
  606. X;*** safe otherwise future installations of CRISP may destroy
  607. X;*** your private copy.
  608. X;***
  609. X(macro bix
  610. X    (
  611. X        (echo_line 9)  // Just Line number and time. Reduces load
  612. X                            // on display if we dont have to keep updating
  613. X                            // column and percentage.
  614. X        (dial "BIX" "01-200-1353" 1200                                     ;*** PRIVATE
  615. X                (                                 (insert_process "\r\rd1\r\r")        ;*** PRIVATE
  616. X                 (wait_for 20 "NUI?")    (insert_process "npssdem033WHU\r") ;*** PRIVATE
  617. X                 (wait_for 20 "ADD?")    (insert_process    "a931060015787\r");*** PRIVATE
  618. X                 (wait_for 20 "ame? ")    (insert_process    "foxy\r")            ;*** PRIVATE
  619. X                ))
  620. X    )
  621. X)
  622. X;***
  623. X;*** (dial system-name number speed (waitfor transmit waitfor transmit ..))
  624. X;***
  625. X(macro dial
  626. X    (
  627. X        (int    dial_buf)
  628. X        (global dial_buf)
  629. X        (string    system-name number)
  630. X        (int    speed line col)
  631. X        (int    cmds retval)
  632. X        (declare    d)
  633. X
  634. X        (dial_hangup)
  635. X
  636. X        (if (! (get_parm 0 system-name "System to dial : "))
  637. X            (return))
  638. X        (if (! (get_parm 1 number "Number to dial : "))
  639. X            (return))
  640. X        (if (! (get_parm 2 speed "Speed : " NULL 1200))
  641. X            (return))
  642. X
  643. X        (= dial_buf (create_shell    "/bin/sh" 
  644. X                                            (+ system-name "-Window") 
  645. X                                            (| PF_ECHO PF_WAIT)
  646. X                        ))
  647. X        (assign_to_key "<Ctrl-S>" "dial_send")
  648. X        (assign_to_key "<Ctrl-R>" "dial_recv")
  649. X        (strip_cr 0)
  650. X        (wait_for 10 "\$")
  651. X        (insert "cu -l /dev/cua0 -t -s 1200\n")
  652. X        (inq_position line col)
  653. X        (set_process_position line col)
  654. X        (insert_process "cu -l /dev/cua0 -t -s 1200\n")
  655. X        (wait_for 10 "onnected\r")
  656. X        (= modem_active TRUE)
  657. X
  658. X        (= retval (dial_dial modem_strings (+ (+ PREFIX number) "\r")))
  659. X        (if (< retval 0) (
  660. X            (error "Dialup failed.")
  661. X            (return)))
  662. X
  663. X        (= d (nth 0 (nth retval modem_strings)))
  664. X        (if (is_string d) (
  665. X            (error d)
  666. X            (return)))
  667. X        (if (!= d speed) (
  668. X            (error "Connected at wrong speed - %d." d)
  669. X            (return)
  670. X            ))
  671. X        (message "Connected at %d baud" speed)
  672. X
  673. X        (end_of_buffer)
  674. X        (inq_position line col)
  675. X        (set_process_position line col)
  676. X
  677. X        (get_parm 3 cmds)
  678. X        (connect 0)
  679. X        (sh_line_mode)
  680. X    )
  681. X)
  682. X(macro    dial_hangup
  683. X    (
  684. X        (if (! modem_active)
  685. X            (return))
  686. X
  687. X        (sh_char_mode)
  688. X        (message "Saying goodbye to modem.")
  689. X        (attach_buffer dial_buf)
  690. X        (set_buffer dial_buf)
  691. X        (insert_process "\r~.\r")
  692. X        (refresh)
  693. X        (wait_for 5 "\\[EOT]")
  694. X        (= modem_active FALSE)
  695. X    )
  696. X)
  697. X(macro dial_dial
  698. X    (
  699. X        (list    l)
  700. X        (list    wlist)
  701. X        (int    n)
  702. X        (int    retval)
  703. X        (declare    atom)
  704. X        (string    number)
  705. X        (int    line col)
  706. X
  707. X        (if (! (get_parm 0 l))
  708. X            (return -1))
  709. X        (if (! (get_parm 1 number))
  710. X            (return -1))
  711. X
  712. X        (while TRUE (
  713. X            (= atom (nth n l))
  714. X            (if (is_null atom)
  715. X                (break))
  716. X            (put_nth n wlist (nth 1 atom))
  717. X            (++ n)            
  718. X            ))
  719. X        (insert number)
  720. X        (refresh)
  721. X        (inq_position line col)
  722. X        (set_process_position line col)
  723. X        (insert_process number)
  724. X        (connect PF_WAIT)
  725. X        (= retval (wait_for TIMEOUT wlist))
  726. X        (return retval)
  727. X    )
  728. X)
  729. X(macro dial_send
  730. X    (
  731. X        (string    filename)
  732. X
  733. X        (get_parm 0 filename)
  734. X        (if (== filename "")
  735. X            (= filename (select_file "*" "Send File")))
  736. X        (if (== filename "")
  737. X            (return))
  738. X;        (get_parm 0 filename "File to send: ")
  739. X        (insert_process (+ (+ "\r~Csx -bkvv " filename) "\n\n"))
  740. X        (refresh)
  741. X    )
  742. X)
  743. X(macro dial_recv
  744. X    (
  745. X        (string    filename)
  746. X;        (get_parm 0 filename "File to receive: ")
  747. X        (insert_process "\r~Crz -bvv\n")
  748. X        (refresh)
  749. X    )
  750. X)
  751. X
  752. SHAR_EOF
  753. chmod 0444 src/crisp/dial.m || echo "restore of src/crisp/dial.m fails"
  754. mkdir src src/crisp >/dev/null 2>&1
  755. echo "x - extracting src/crisp/edt.m (Text)"
  756. sed 's/^X//' << 'SHAR_EOF' > src/crisp/edt.m &&
  757. X/********************************************************************
  758. X *                                                                  *
  759. X *      CRISP - Custom Reduced Instruction Set Programmers Editor   *
  760. X *                                                                  *
  761. X *      (C) Paul Fox, 1989                                          *
  762. X *      43, Jerome Close                Tel: +44 6284 4222          *
  763. X *          Marlow                                                  *
  764. X *           Bucks.                                                 *
  765. X *              England SL7 1TX                                     *
  766. X *                                                                  *
  767. X *                                                                  *
  768. X *    Please See COPYRIGHT notice.                                  *
  769. X *                                                                  *
  770. X *  Set of macros to emulate an EDT interface.                              *
  771. X ********************************************************************/
  772. X# include    "crisp.h"
  773. X# define    GOLD "OP"
  774. X
  775. X/*----------------------------------------
  776. X/*   Definitions for current direction.
  777. X/*----------------------------------------*/
  778. X# define    ADVANCE    1
  779. X# define    BACKUP    -1
  780. X
  781. X(macro _init
  782. X    (
  783. X        (string    edt_undo_line
  784. X                    edt_undo_word
  785. X                    edt_undo_char)
  786. X        (int        edt_direction edt_col)
  787. X        (global    edt_undo_line
  788. X                    edt_undo_word
  789. X                    edt_undo_char
  790. X                    edt_direction edt_col)
  791. X        (= edt_direction ADVANCE)
  792. X        /*----------------------------------------
  793. X        /*   Make control characters display as
  794. X        /*   they do in EDT.
  795. X        /*----------------------------------------*/
  796. X        (display_mode 0)
  797. X        (set_display_chars 
  798. X            "<NUL>" "<SOH>" "<STX>" "<ETX>" "<EOT>" "<ENQ>" "<ACK>" "<BEL>" 
  799. X            "<BS>"  "<HT>"  "<NL>"  "<VT>"  "<FF>"  "<CR>"  "<SO>"  "<SI>" 
  800. X            "<DLE>" "<DC1>" "<DC2>" "<DC3>" "<DC4>" "<NAK>" "<SYN>" "<ETB>" 
  801. X            "<CAN>" "<EM>"  "<SUB>" "<ESC>" "<FS>"  "<GS>"  "<RS>"  "<US>")
  802. X    )
  803. X)
  804. X(macro edt
  805. X    (
  806. X        (ansi)
  807. X        (assign_to_key (+ GOLD "OD") "<<")
  808. X        (assign_to_key (+ GOLD "OC") ">>")
  809. X        
  810. X        (assign_to_key "OQ" "help")             /* PF2 */
  811. X        (assign_to_key (+ GOLD "OQ") "help")             /* PF2 */
  812. X
  813. X        (assign_to_key "OR" "search_next")    /* PF3 */
  814. X        (assign_to_key (+ GOLD "OR") "search-fwd")    /* PF3 */
  815. X
  816. X        (assign_to_key "OS" (quote_list 
  817. X                                        (
  818. X                                            (= edt_undo_line (read))
  819. X                                            (delete_to_eol)
  820. X                                            (delete_char)
  821. X                                        ))) /* PF 4 */
  822. X
  823. X        (assign_to_key (+ GOLD "OS") (quote_list
  824. X                                    (
  825. X                                        (insert edt_undo_line)
  826. X                                    )))    /* PF4 */
  827. X
  828. X        (assign_to_key "Ow" "search_fwd \"\x0c\"")    /* 7 */
  829. X        (assign_to_key (+ GOLD "Ow") "execute_macro")    /* 7 */
  830. X
  831. X        (assign_to_key "Ox" (quote_list                /* 8 */
  832. X                                        (
  833. X                                            (if (== edt_direction ADVANCE)
  834. X                                                (page_down)
  835. X                                            ;else
  836. X                                                (page_up)
  837. X                                                )
  838. X                                        )))
  839. X
  840. X        (assign_to_key (+ GOLD "Ox") "page_direction")            /* 8 */
  841. X        (assign_to_key "Oy" "message \"Sorry, not supported\"") /* 9 */
  842. X        (assign_to_key "Om" "objects delete_word_right")        /* - */
  843. X        (assign_to_key (+ GOLD "Om") (quote_list    /* - */
  844. X                                    (
  845. X                                        (insert edt_undo_word)
  846. X                                    )))    /* PF4 */
  847. X
  848. X        (assign_to_key "Ot" (quote_list                /* 4 */
  849. X                                        (
  850. X                                            (message "Advance.")
  851. X                                            (= edt_direction ADVANCE)
  852. X                                        )))
  853. X        (assign_to_key (+ GOLD "Ot") "end_of_buffer")            /* 4 */
  854. X        (assign_to_key "Ou" (quote_list                /* 5 */
  855. X                                        (
  856. X                                            (message "Backup.")
  857. X                                            (= edt_direction BACKUP)
  858. X        (assign_to_key (+ GOLD "Ou") "top_of_buffer")            /* 5 */
  859. X                                        )))
  860. X        (assign_to_key "Ov" "cut")                    /* 6 */
  861. X        (assign_to_key (+ GOLD "Ov") "paste")                    /* 6 */
  862. X        (assign_to_key "Ol" (quote_list            /* , */
  863. X                                        (
  864. X                                        (= edt_undo_char (read 1))
  865. X                                        (delete_char)
  866. X                                        )))
  867. X        (assign_to_key (+ GOLD "Ol") (quote_list    /* , */ 
  868. X                                                    (insert edt_undo_char)
  869. X                                                ))
  870. X
  871. X
  872. X        (assign_to_key "Oq" (quote_list        /* 1 */
  873. X                                        (
  874. X                                            (if (== edt_direction ADVANCE)
  875. X                                                (objects "word_right")
  876. X                                            ;else
  877. X                                                (objects "word_left"))
  878. X                                        )))
  879. X
  880. X        (assign_to_key "Or" "end_of_line")            /*  2 */
  881. X        (assign_to_key "Os" (quote_list        /* 3 */
  882. X                                        (
  883. X                                            (if (== edt_direction ADVANCE)
  884. X                                                (right)
  885. X                                            ;else
  886. X                                                (left))
  887. X                                        )))
  888. X        (assign_to_key "OM" "copy")                    /* Enter */
  889. X
  890. X        (assign_to_key "Op" (quote_list        /* 0 */
  891. X                                        (
  892. X                                            (if (== edt_direction ADVANCE)
  893. X                                                (down)
  894. X                                            ;else
  895. X                                                (up))
  896. X                                        )))
  897. X        (assign_to_key (+ GOLD "Op") (quote_list        /* 0 */
  898. X                                        (
  899. X                                            (save_position)
  900. X                                            (beginning_of_line)
  901. X                                            (insert "\n")
  902. X                                            (restore_position)
  903. X                                        )))
  904. X        (assign_to_key "On" (quote_list
  905. X                                        (
  906. X                                            (message "Anchor dropped.")
  907. X                                            (mark)
  908. X                                        )
  909. X                                    ))                    /* . */
  910. X
  911. X
  912. X        (assign_to_key "^E" "edit_file")
  913. X        (assign_to_key "#127" "backspace")
  914. X        (assign_to_key "^H" (quote_list
  915. X                                    (
  916. X                                    (inq_position NULL edt_col)
  917. X                                    (if (== edt_col 1)
  918. X                                        (up)
  919. X                                    ;else
  920. X                                        (beginning_of_line))
  921. X                                    )))
  922. X        (assign_to_key "^L" "self_insert")
  923. X        (assign_to_key "^W" "write_buffer")
  924. X        (assign_to_key "^U" "undo")
  925. X        (autoindent "y")
  926. X
  927. X    )
  928. X)
  929. SHAR_EOF
  930. chmod 0644 src/crisp/edt.m || echo "restore of src/crisp/edt.m fails"
  931. mkdir src src/crisp >/dev/null 2>&1
  932. echo "x - extracting src/crisp/features.m (Text)"
  933. sed 's/^X//' << 'SHAR_EOF' > src/crisp/features.m &&
  934. X/********************************************************************
  935. X *                                                                  *
  936. X *      CRISP - Custom Reduced Instruction Set Programmers Editor   *
  937. X *                                                                  *
  938. X *      (C) Paul Fox, 1989                                          *
  939. X *      43, Jerome Close                Tel: +44 6284 4222          *
  940. X *          Marlow                                                  *
  941. X *           Bucks.                                                 *
  942. X *              England SL7 1TX                                     *
  943. X *                                                                  *
  944. X *                                                                  *
  945. X *    Please See COPYRIGHT notice.                                  *
  946. X *                                                                  *
  947. X ********************************************************************/
  948. X(macro features
  949. X    (
  950. X        (int    result result1)
  951. X
  952. X        (= result  -1)
  953. X        (= result1 -1)
  954. X
  955. X        (select_list "CRISP Features" "" 3 (quote_list
  956. X            "ASCII Chart"                "feature_select"
  957. X                                            "help_display \"features/Ascii.hlp\" \"ASCII\""
  958. X            "Calculator"                "feature_select" 
  959. X                                            "help_display \"features/Calc.hlp\" \"Calculator\""
  960. X            "Compilation"                "feature_compile" 
  961. X                                            "help_display \"features/Compile.hlp\" \"Compiling\""
  962. X            "Current Filename"        "feature_select"     
  963. X                                            "help_display \"features/Filename.hlp\" \"Current Filename\""
  964. X            "GREP"                        "feature_select"    
  965. X                                            "help_display \"features/Grep.hlp\" \"GREP\""
  966. X            "List Buffers"                "feature_select"    
  967. X                                            "help_display \"features/Buflist.hlp\" \"List Buffers\""
  968. X            "Mail"                        "feature_select"
  969. X                                            "help_display \"features/Mail.hlp\" \"Mail\""
  970. X            "Options"                    "feature_select"    
  971. X                                            "help_display \"features/Options.hlp\" \"Options\""
  972. X            "Programming Features"     "feature_programming"    
  973. X                                            "help_display \"features/Program.hlp\" \"Compiling\""
  974. X            "Region Manipulation"      "feature_region"    
  975. X                                            "help_display \"features/Region.hlp\" \"Regions\""
  976. X            "Spell"                        "feature_select"    
  977. X                                            "help_display \"features/Spell.hlp\" \"Spelling\""
  978. X            "Start a Sub-shell"        "feature_select"    
  979. X                                            "help_display \"features/Shell.hlp\" \"Shells\""
  980. X            "Word Count"                  "feature_select"    
  981. X                                            "help_display \"features/Wc.hlp\" \"Word Count\""
  982. X            ) 2)
  983. X        (refresh)
  984. X        (switch result 
  985. X            1    (ascii)
  986. X            2    (calc)
  987. X            3    (switch result1
  988. X                    1    (lint)
  989. X                    2    (make)
  990. X                    )
  991. X            4    (display_file_name)
  992. X            5    (grep)
  993. X            6    (buffer_list)
  994. X            7    (mail)
  995. X            8    (options)
  996. X            9    (switch result1
  997. X                    1    (brace)
  998. X                    2    (tag)
  999. X                    3    (objects "routines")
  1000. X                    )
  1001. X            10 (switch result1
  1002. X                    1    (objects "format_block")
  1003. X                    2    (block-lower_case)
  1004. X                    3    (>>)
  1005. X                    4    (<<)
  1006. X                    5    (block-upper_case)
  1007. X                    )
  1008. X            11 (spell)
  1009. X            12    (csh)
  1010. X            13    (wc)
  1011. X            )
  1012. X    )
  1013. X)
  1014. X(macro feature_select
  1015. X    (
  1016. X        (inq_position result)
  1017. X        (push_back (key_to_int "<Esc>"))
  1018. X    )
  1019. X)
  1020. X(macro feature_compile
  1021. X    (
  1022. X        (inq_position result)
  1023. X        (= result1 (select_list "Compile" "" 3 (quote_list
  1024. X            "Lint"            ""
  1025. X                                "help_display \"features/Compile.hlp\" \"Lint\" \"> The (lint) Macro\""
  1026. X            "Execute Make" ""
  1027. X                                "help_display \"features/Compile.hlp\" \"Make\" \"> The (make) Macro\""
  1028. X            ) 2))
  1029. X        (push_back (key_to_int "<Esc>"))
  1030. X    )
  1031. X)
  1032. X(macro feature_programming
  1033. X    (
  1034. X
  1035. X        (inq_position result)
  1036. X        (= result1 (select_list "Programming" "" 3 (quote_list
  1037. X            "Match brackets"    ""
  1038. X                                    "help_display \"features/Program.hlp\" \"Bracket Matching\" \"> The Match Brackets Macro\""
  1039. X            "Find function"    ""
  1040. X                                    "help_display \"features/Program.hlp\" \"Finding Functions\" \"> The Find Function Macro\""
  1041. X            "List functions"    ""
  1042. X                                    "help_display \"features/Program.hlp\" \"Function List\" \"> The List Functions Macro\""
  1043. X            ) 2))
  1044. X        (push_back (key_to_int "<Esc>"))
  1045. X    )
  1046. X)
  1047. X(macro feature_region
  1048. X    (
  1049. X        (inq_position result)
  1050. X        (= result1 (select_list "Regions" "" 1 (quote_list
  1051. X            "Justify Text"
  1052. X            "Lower case text"
  1053. X            "Indent Block"
  1054. X            "Unindent Block"
  1055. X            "Upper case text"
  1056. X            ) 2))
  1057. X        (push_back (key_to_int "<Esc>"))
  1058. X    )
  1059. X)
  1060. SHAR_EOF
  1061. chmod 0444 src/crisp/features.m || echo "restore of src/crisp/features.m fails"
  1062. mkdir src src/crisp >/dev/null 2>&1
  1063. echo "x - extracting src/crisp/g_macros.m (Text)"
  1064. sed 's/^X//' << 'SHAR_EOF' > src/crisp/g_macros.m &&
  1065. X/********************************************************************
  1066. X *                                                                  *
  1067. X *      CRISP - Custom Reduced Instruction Set Programmers Editor   *
  1068. X *                                                                  *
  1069. X *      (C) Paul Fox, 1989                                          *
  1070. X *      43, Jerome Close                Tel: +44 6284 4222          *
  1071. X *          Marlow                                                  *
  1072. X *           Bucks.                                                 *
  1073. X *              England SL7 1TX                                     *
  1074. X *                                                                  *
  1075. X *                                                                  *
  1076. X *    Please See COPYRIGHT notice.                                  *
  1077. X *                                                                  *
  1078. X ********************************************************************/
  1079. X# include    "crisp.h"
  1080. X
  1081. X(macro objects
  1082. X    (
  1083. X        (string    ext            ;* Extension of current buffer.
  1084. X                    function        ;* Function to call.
  1085. X                    macro_name    ;* Name of macro to call.
  1086. X                    )
  1087. X        (int        arg1)
  1088. X
  1089. X        (get_parm 0 function)
  1090. X        (get_parm 1 arg1)
  1091. X        (inq_names NULL ext NULL)
  1092. X        (assign_to_key    "^N"    "objects next_error")
  1093. X        (assign_to_key    "^P"    "objects previous_error")
  1094. X        (= macro_name (+ ext (+ "-" function)))
  1095. X        (if (! (inq_macro macro_name))
  1096. X            (= macro_name (+ "default-" function)))
  1097. X        (execute_macro macro_name arg1)
  1098. X    )
  1099. X)
  1100. X;*
  1101. X;*   Macros to shift left & shift right the currently marked
  1102. X;*   block.
  1103. X;*
  1104. X(macro >>
  1105. X    (
  1106. X        (objects ">>")
  1107. X    )
  1108. X)
  1109. X(macro <<
  1110. X    (
  1111. X        (objects "<<")
  1112. X    )
  1113. X)
  1114. X(macro default->>
  1115. X    (
  1116. X        (int marked)
  1117. X
  1118. X        (= marked (inq_marked))
  1119. X        (if (== marked 0)
  1120. X            (drop_anchor MK_LINE))
  1121. X        (beginning_of_line)
  1122. X        (translate "<" "\t" ST_GLOBAL ST_REGEXP NULL ST_BLOCK)
  1123. X        (if (== marked 0)
  1124. X            (raise_anchor))
  1125. X    )
  1126. X)
  1127. X(macro default-<<
  1128. X    (
  1129. X        (int marked)
  1130. X
  1131. X        (= marked (inq_marked))
  1132. X        (if (== marked 0)
  1133. X            (drop_anchor MK_LINE))
  1134. X        (beginning_of_line)
  1135. X        (translate "<\t" "" ST_GLOBAL ST_REGEXP NULL ST_BLOCK)
  1136. X        (if (== marked 0)
  1137. X            (raise_anchor))
  1138. X    )
  1139. X)
  1140. X;*
  1141. X;*   Delete word left/right macros.
  1142. X;*   Uses the word_left/word_right macros.
  1143. X;*
  1144. X(macro default-delete_word_right
  1145. X    (
  1146. X        (delete_word (default-word_right))
  1147. X    )
  1148. X)
  1149. X(macro default-delete_word_left
  1150. X    (
  1151. X        (delete_word (default-word_left))
  1152. X    )
  1153. X)
  1154. X(macro delete_word
  1155. X    (
  1156. X        (int    i)
  1157. X
  1158. X        (drop_anchor 4)
  1159. X        (get_parm 0 i)
  1160. X        (delete_block)
  1161. X        
  1162. X    )
  1163. X)
  1164. X;*
  1165. X;*    word_left macros.
  1166. X;*
  1167. X(macro default-word_left
  1168. X    (
  1169. X        (return (word_left "<|[ .()/\t]\\c[~ .()/\t]"))
  1170. X    )
  1171. X)
  1172. X(macro word_left
  1173. X    (    (int line col line1 col1)
  1174. X        (string    pat)
  1175. X
  1176. X        (get_parm 0 pat)
  1177. X        (inq_position line col)
  1178. X        (search_back pat -3)
  1179. X        (inq_position line1 col1)
  1180. X        (if (&& (== line line1) (== col col1)) (
  1181. X            (prev_char)
  1182. X            (return (search_back pat -3))))
  1183. X        (return 0)
  1184. X    )
  1185. X)
  1186. X;*
  1187. X;*    word_right macros.
  1188. X;* 
  1189. X(macro default-word_right
  1190. X        (return (word_right "<|[ .()/\t]\\c[~ .()/\t]"))
  1191. X)
  1192. X(macro word_right
  1193. X    (
  1194. X        (string    pat)
  1195. X
  1196. X        (get_parm 0 pat)
  1197. X        (next_char)
  1198. X        (return (search_fwd pat))
  1199. X    )
  1200. X)
  1201. X(macro default-routines
  1202. X    (
  1203. X        (error "No routines macro defined for this file.")
  1204. X    )
  1205. X)
  1206. X/* Routines for Intel assembler files */
  1207. X(macro asm-routines
  1208. X        (select_routine "<*{PROC}|{proc}"
  1209. X                "Assembler Subroutines" "asm-routines_trim")
  1210. X)
  1211. X(macro asm-routines_trim
  1212. X    (
  1213. X        (string    routine_name)
  1214. X
  1215. X        (get_parm 0 routine_name)
  1216. X        (return routine_name)
  1217. X    )
  1218. X)
  1219. X/* Routines for PostScript files. */
  1220. X(macro ps-routines
  1221. X        (select_routine "</"
  1222. X                "PostScript Definitions" "ps-routines_trim")
  1223. X)
  1224. X(macro ps-routines_trim
  1225. X    (
  1226. X        (string    routine_name)
  1227. X
  1228. X        (get_parm 0 routine_name)
  1229. X        (return routine_name)
  1230. X    )
  1231. X)
  1232. X/* Routines for Yacc source files. */
  1233. X(macro y-routines
  1234. X        (select_routine "<[_a-zA-Z0-9]+[ \t]@:"
  1235. X                "Yacc Rules" "y-routines_trim")
  1236. X)
  1237. X(macro y-routines_trim
  1238. X    (
  1239. X        (int        spos)
  1240. X        (string    routine_name)
  1241. X
  1242. X        (get_parm 0 routine_name)
  1243. X
  1244. X        (= spos (search_string ":" routine_name))
  1245. X        (if (> spos 0)
  1246. X                (= routine_name (substr routine_name 1 (- spos 1))))
  1247. X        (return (trim routine_name))
  1248. X
  1249. X    )
  1250. X)
  1251. X(macro c-routines
  1252. X        (select_routine "<[_a-zA-Z0-9]+[ \t]@*([^)\"]@)[^,;]@>"
  1253. X                "Functions" "c-routines_trim")
  1254. X)
  1255. X(macro c-routines_trim
  1256. X    (
  1257. X        (int        spos)
  1258. X        (string    routine_name)
  1259. X
  1260. X        (get_parm 0 routine_name)
  1261. X
  1262. X        (= spos (search_string "[;/{]" routine_name))
  1263. X        (if (> spos 0)
  1264. X                (= routine_name (substr routine_name 1 (- spos 1))))
  1265. X        (return (trim routine_name))
  1266. X
  1267. X    )
  1268. X)
  1269. X(macro h-routines
  1270. X        (select_routine "<{typedef}|{struct}\\c" "Structures" "h-routines_trim")
  1271. X)
  1272. X(macro h-routines_trim
  1273. X    (
  1274. X        (int        spos)
  1275. X        (string    routine_name)
  1276. X
  1277. X        (get_parm 0 routine_name)
  1278. X
  1279. X        (= spos (search_string "[;/{]" routine_name))
  1280. X        (if (> spos 0)
  1281. X                (= routine_name (substr routine_name 1 (- spos 1))))
  1282. X        (return (trim routine_name))
  1283. X
  1284. X    )
  1285. X)
  1286. X(macro hlp-routines
  1287. X        (select_routine "<\\> " "Sections" "hlp-routines_trim")
  1288. X)
  1289. X(macro hlp-routines_trim
  1290. X    (
  1291. X        (string    routine_name)
  1292. X
  1293. X        (get_parm 0 routine_name)
  1294. X        (return (substr routine_name 3))
  1295. X    )
  1296. X)
  1297. X(macro m-routines
  1298. X        (select_routine "<({macro}|{replacement}\\c" "Macros" "m-routines_trim")
  1299. X)
  1300. X(macro m-routines_trim
  1301. X    (
  1302. X        (int        spos)
  1303. X        (string    routine_name)
  1304. X
  1305. X        (get_parm 0 routine_name)
  1306. X
  1307. X        (= spos (search_string "[ \t;]" routine_name))
  1308. X        (if (> spos 0)
  1309. X                (return (substr routine_name 1 (- spos 1))))
  1310. X        (return routine_name)
  1311. X
  1312. X    )
  1313. X)
  1314. X(macro mm-routines
  1315. X        (select_routine "<\.{TH}|{H}|{SH}" "Sections" "mm-routines_trim")
  1316. X)
  1317. X(macro mm-routines_trim
  1318. X    (
  1319. X        (int        spos)
  1320. X        (string    routine_name)
  1321. X
  1322. X        (get_parm 0 routine_name)
  1323. X
  1324. X        (return routine_name)
  1325. X
  1326. X    )
  1327. X)
  1328. X;*
  1329. X;*   Routine to select language sepecific entities from a buffer.
  1330. X;*
  1331. X;*    (macro select_routine
  1332. X;*            sstr        search-string to find matching line.
  1333. X;*            name        name of things we are looking for.
  1334. X;*            )
  1335. X        
  1336. X(macro select_routine
  1337. X    (
  1338. X        (list        line_no_list)    ;* List of line-numbers so we know
  1339. X                                        ;* where to go to when the user makes
  1340. X                                        ;* a selection.
  1341. X        (int        curbuf            ;* Current buffer.
  1342. X                    macbuf            ;* Buffer to put macro names in.
  1343. X                    mac_cnt            ;* Count of macros encountered so far.
  1344. X                    line                ;* Temporary to contain line number of
  1345. X                                        ;* of matched macro-name.
  1346. X                    display_win        ;* Window to display macros in.
  1347. X                    spos                ;* Search position.
  1348. X                    selection        ;* Users selection.
  1349. X                    width                ;* Maximum width so far.
  1350. X                    )
  1351. X        (string    routine_name    ;* Name of currently matched macro.
  1352. X                    sstr                ;* Search-string for matching lines.
  1353. X                    name                ;* Name of things we are looking for.
  1354. X                    trim_func        ;* Function to trim matched line.
  1355. X                    msg
  1356. X                    )
  1357. X
  1358. X        (get_parm 0 sstr)
  1359. X        (get_parm 1 name)
  1360. X        (get_parm 2 trim_func)
  1361. X        (= curbuf (inq_buffer))
  1362. X        (save_position)
  1363. X        (= macbuf (create_buffer name NULL 1))
  1364. X        (top_of_buffer)
  1365. X        (message "Scanning for %s..." (lower name))
  1366. X        (= mac_cnt 0)
  1367. X        (= width 10)
  1368. X
  1369. X        (while (search_fwd sstr) (
  1370. X                (= routine_name (ltrim (trim (compress (read)))))
  1371. X                (= routine_name (execute_macro trim_func routine_name))
  1372. X                (inq_position line)
  1373. X                (put_nth mac_cnt line_no_list line)
  1374. X                (set_buffer macbuf)
  1375. X                (if mac_cnt
  1376. X                    (insert "\n"))
  1377. X                (insert routine_name)
  1378. X                (++ mac_cnt)
  1379. X;                (message "Scanning for %s [#%d]..." (lower name) mac_cnt)
  1380. X                (if (> (strlen routine_name) width)
  1381. X                    (= width (strlen routine_name)))
  1382. X                (set_buffer curbuf)
  1383. X                (next_char)
  1384. X                )
  1385. X        )
  1386. X        (message "%d %s found." mac_cnt (lower name))
  1387. X        (restore_position)
  1388. X
  1389. X        ;*
  1390. X        ;*   If no macros found just tell the user and exit.
  1391. X        ;*
  1392. X        (if (== mac_cnt 0) (
  1393. X                (message "No %s found." (lower name))
  1394. X                (delete_buffer macbuf)
  1395. X                (return)
  1396. X                ))
  1397. X        ;*
  1398. X        ;*   We found some macros -- display them.
  1399. X        ;*
  1400. X        (++ width)
  1401. X        (if (< width 26)
  1402. X            (= width 26))
  1403. X        (= msg (+ (key_label "<Alt-C>") " - copy to scrap. "))
  1404. X        (= display_win (sized_window (+ mac_cnt 1) width msg))
  1405. X        (message "Use arrow keys to make a selection.")
  1406. X        (= selection (select_buffer macbuf display_win SEL_NORMAL
  1407. X                                (
  1408. X                                    (assign_to_key "<Ctrl-C>" "routines_copy")
  1409. X                                    (assign_to_key "<Alt-C>" "routines_copy")
  1410. X                                )
  1411. X                                NULL
  1412. X                                "help_display \"features/Program.hlp\" \"Function List\" \"> The List Functions Macro\""
  1413. X                            ))
  1414. X        (delete_buffer macbuf)
  1415. X        (message "")
  1416. X        (if (< selection 0)
  1417. X            (return)
  1418. X            )
  1419. X        (goto_line (nth (- selection 1) line_no_list))
  1420. X     )
  1421. X)
  1422. X(macro routines_copy
  1423. X    (
  1424. X        (save_position)
  1425. X        (top_of_buffer)
  1426. X        (drop_anchor MK_LINE)
  1427. X        (end_of_buffer)
  1428. X        (copy)
  1429. X        (restore_position)
  1430. X        (message "Routines copied to scrap.")
  1431. X    )
  1432. X)
  1433. SHAR_EOF
  1434. chmod 0444 src/crisp/g_macros.m || echo "restore of src/crisp/g_macros.m fails"
  1435. mkdir src src/crisp >/dev/null 2>&1
  1436. echo "x - extracting src/crisp/g_vi.m (Text)"
  1437. sed 's/^X//' << 'SHAR_EOF' > src/crisp/g_vi.m &&
  1438. X/********************************************************************
  1439. X *                                                                  *
  1440. X *      CRISP - Custom Reduced Instruction Set Programmers Editor   *
  1441. X *                                                                  *
  1442. X *      (C) Paul Fox, 1989                                          *
  1443. X *      43, Jerome Close                Tel: +44 6284 4222          *
  1444. X *          Marlow                                                  *
  1445. X *           Bucks.                                                 *
  1446. X *              England SL7 1TX                                     *
  1447. X *                                                                  *
  1448. X *                                                                  *
  1449. X *    Please See COPYRIGHT notice.                                  *
  1450. X *                                                                  *
  1451. X ********************************************************************/
  1452. X(macro _init
  1453. X    (
  1454. X        (int    _command_keymap _insert_keymap)
  1455. X        (string last_command)
  1456. X        (global    _command_keymap _insert_keymap last_command)
  1457. X
  1458. X        (keyboard_push)
  1459. X        (assign_to_key "<Left Arrow>" "left")
  1460. X        (assign_to_key "<Right Arrow>" "right")
  1461. X        (assign_to_key "<Up Arrow>" "up")
  1462. X        (assign_to_key "<Down Arrow>" "down")
  1463. X        (assign_to_key    "<PgUp>"    "page_up")
  1464. X        (assign_to_key    "<PgDn>"    "page_down")
  1465. X        (assign_to_key " " "right")
  1466. X        (assign_to_key    "."    "dot")
  1467. X        (assign_to_key "$" "end_of_line")
  1468. X        (assign_to_key "/" "search_fwd")
  1469. X        (assign_to_key "?" "search_back")
  1470. X        (assign_to_key "\^" "beginning_of_line")
  1471. X        (assign_to_key "^B" "page_up")
  1472. X        (assign_to_key "^F" "page_down")
  1473. X        (assign_to_key "^G" "display_file_name")
  1474. X        (assign_to_key    "^L"    "redraw")
  1475. X        (assign_to_key    "^M"    "down")
  1476. X        (assign_to_key "0"    "beginning_of_line")
  1477. X        (assign_to_key "A" "vi_Add")
  1478. X        (assign_to_key "B" "search_back \"[ \\t\\n]\"")
  1479. X        (assign_to_key "C"    "change")
  1480. X        (assign_to_key "D"    "delete_to_eol")
  1481. X        (assign_to_key "G" "end_of_buffer")
  1482. X        (assign_to_key "H" "top_of_window")
  1483. X        (assign_to_key "I"     "i_command")
  1484. X        (assign_to_key "J" "join_line")
  1485. X        (assign_to_key "L" "end_of_window")
  1486. X        (assign_to_key    "O"    "vi_Open")
  1487. X        (assign_to_key "W" "search_fwd \"[ \t\n]\\\\c[~ \t\n]\"")
  1488. X        (assign_to_key "X" "backspace")
  1489. X        (assign_to_key    "ZZ"    "x")
  1490. X        (assign_to_key "a" "vi_add")
  1491. X        (assign_to_key "b" "search_back \"[ \t\n]\"")
  1492. X        (assign_to_key    "db"    "db_cmd")
  1493. X        (assign_to_key    "dw"    "dw_cmd")
  1494. X        (assign_to_key "h" "left")
  1495. X        (assign_to_key "i" "vi_insert_mode 0")
  1496. X        (assign_to_key "j" "down")
  1497. X        (assign_to_key "k" "up")
  1498. X        (assign_to_key "l" "right")
  1499. X        (assign_to_key    "n"    "search_again")
  1500. X        (assign_to_key    "o"    "vi_open")
  1501. X        (assign_to_key    "p"    "paste")
  1502. X        (assign_to_key "u" "undo")
  1503. X        (assign_to_key "w" "search_fwd \"[.:;[\\\\]/ \t\n]\\\\c[~ \t\n]\"")
  1504. X        (assign_to_key "x"    "delete_char")
  1505. X        (assign_to_key ":" "execute_macro")
  1506. X        (= _command_keymap (inq_keyboard))
  1507. X        (keyboard_pop 1)
  1508. X
  1509. X        (keyboard_push)
  1510. X        (keyboard_typeables)
  1511. X        (assign_to_key    "<Esc>"    "vi_command_mode")
  1512. X        (assign_to_key "^H" "backspace")
  1513. X        (assign_to_key "#127" "backspace")
  1514. X        (= _insert_keymap (inq_keyboard))
  1515. X        (keyboard_pop 1)
  1516. X
  1517. X    )
  1518. X)
  1519. X(macro vi
  1520. X    (
  1521. X        (keyboard_push _command_keymap)
  1522. X        (process)
  1523. X        (keyboard_pop 1)
  1524. X    )
  1525. X)
  1526. X(macro vi_insert_mode
  1527. X    (
  1528. X        (int    arg)
  1529. X        (get_parm 0 arg)
  1530. X        (keyboard_pop 1)
  1531. X        (keyboard_push _insert_keymap)
  1532. X    )
  1533. X)
  1534. X(macro vi_command_mode
  1535. X    (
  1536. X        (keyboard_pop 1)
  1537. X        (keyboard_push _command_keymap)
  1538. X    )
  1539. X)
  1540. X(macro vi_open
  1541. X    (
  1542. X        (end_of_line)
  1543. X        (insert "\n")
  1544. X        (vi_insert_mode)
  1545. X    )
  1546. X)
  1547. X(macro vi_Open
  1548. X    (
  1549. X        (beginning_of_line)
  1550. X        (insert "\n")
  1551. X        (up)
  1552. X        (vi_insert_mode)
  1553. X    )
  1554. X)
  1555. X(macro vi_add
  1556. X    (
  1557. X        (right)
  1558. X        (vi_insert_mode)
  1559. X    )
  1560. X)
  1561. X(macro vi_Add
  1562. X    (
  1563. X        (end_of_line)
  1564. X        (vi_insert_mode)
  1565. X    )
  1566. X)
  1567. X(macro    db_cmd
  1568. X    (
  1569. X        (= last_command "db_cmd")
  1570. X        (delete_previous_word)
  1571. X    )
  1572. X)
  1573. X(macro    dw_cmd
  1574. X    (
  1575. X        (= last_command "dw_cmd")
  1576. X        (delete_next_word)
  1577. X    )
  1578. X)
  1579. X(macro e
  1580. X    (
  1581. X        (string    file)
  1582. X        (get_parm 0 file)
  1583. X        (edit_file file)
  1584. X    )
  1585. X)
  1586. X(macro r
  1587. X    (
  1588. X        (string    file)
  1589. X        (get_parm 0 file)
  1590. X        (read_file file)
  1591. X    )
  1592. X)
  1593. X(macro w        (write_buffer))
  1594. X(macro n        (next_buffer))
  1595. X(macro    x
  1596. X    (
  1597. X        (exit)
  1598. X        (exit)
  1599. X        (exit)
  1600. X    )
  1601. X)
  1602. X(macro join_line
  1603. X    (
  1604. X        (= last_command "join_line")
  1605. X        (end_of_line)
  1606. X        (delete_char)
  1607. X        (insert " ")
  1608. X    )
  1609. X)
  1610. X
  1611. X(macro change
  1612. X    (
  1613. X        (= last_command "change")
  1614. X        (delete_to_eol)
  1615. X        (vi_insert_mode)
  1616. X    )
  1617. X)
  1618. X(macro    i_command
  1619. X    (
  1620. X        (beginning_of_line)
  1621. X        (vi_insert_mode)
  1622. X    )
  1623. X)
  1624. X(macro    dot
  1625. X    (
  1626. X        (last_command)
  1627. X    )
  1628. X)
  1629. SHAR_EOF
  1630. chmod 0444 src/crisp/g_vi.m || echo "restore of src/crisp/g_vi.m fails"
  1631. mkdir src src/crisp >/dev/null 2>&1
  1632. echo "x - extracting src/crisp/hanoi.m (Text)"
  1633. sed 's/^X//' << 'SHAR_EOF' > src/crisp/hanoi.m &&
  1634. X/********************************************************************
  1635. X *                                                                  *
  1636. X *      CRISP - Custom Reduced Instruction Set Programmers Editor   *
  1637. X *                                                                  *
  1638. X *      (C) Paul Fox, 1989                                          *
  1639. X *      43, Jerome Close                Tel: +44 6284 4222          *
  1640. X *          Marlow                                                  *
  1641. X *           Bucks.                                                 *
  1642. X *              England SL7 1TX                                     *
  1643. X *                                                                  *
  1644. X *                                                                  *
  1645. X *    Please See COPYRIGHT notice.                                  *
  1646. X *                                                                  *
  1647. X ********************************************************************/
  1648. X# define    WIDTH    24
  1649. X
  1650. X(macro hanoi
  1651. X    (
  1652. X        (int discs i)
  1653. X        (int buf new_buf)
  1654. X        
  1655. X        (= discs 3)
  1656. X        (if (|| (<= (get_parm 0 discs "Number of discs: ") 0) (< discs 0))
  1657. X            (= discs 3)
  1658. X            )
  1659. X        (if (> discs 9)
  1660. X                (= discs 9)
  1661. X            )
  1662. X        (= buf (inq_buffer))
  1663. X        (= new_buf (create_buffer "Tower of Hanoi" NULL 1))
  1664. X        (set_buffer new_buf)
  1665. X        (attach_buffer new_buf)
  1666. X        (clear_buffer)
  1667. X        (insert "                                                                      \n")
  1668. X        (insert "                                                                      \n")
  1669. X        (insert "                                                                      \n")
  1670. X        (insert "            !                       !                       !             \n")
  1671. X        (insert "           xxx                      !                       !                 \n")
  1672. X        (if (> discs 1)
  1673. X        (insert "          xxxxx                     !                       !                 \n"))
  1674. X        (if (> discs 2)
  1675. X        (insert "         xxxxxxx                    !                       !                 \n"))
  1676. X        (if (> discs 3)
  1677. X        (insert "        xxxxxxxxx                   !                       !                   \n"))
  1678. X        (if (> discs 4)
  1679. X        (insert "       xxxxxxxxxxx                  !                       !                 \n"))
  1680. X        (if (> discs 5)
  1681. X        (insert "      xxxxxxxxxxxxx                 !                       !                \n"))
  1682. X        (if (> discs 6)
  1683. X        (insert "     xxxxxxxxxxxxxxx                !                       !                \n"))
  1684. X        (if (> discs 7)
  1685. X        (insert "    xxxxxxxxxxxxxxxxx               !                       !                \n"))
  1686. X        (if (> discs 8)
  1687. X        (insert "   xxxxxxxxxxxxxxxxxxx              !                       !                \n"))
  1688. X        (if (> discs 9)
  1689. X        (insert "  xxxxxxxxxxxxxxxxxxxxx             !                       !                \n"))
  1690. X        (insert "====================================================================    \n")
  1691. X        (hanoi0 discs 1 3 2)
  1692. X        (if (inq_kbd_char) (
  1693. X                (read_char)
  1694. X                (message "I've had enough of this!")
  1695. X                )
  1696. X        )
  1697. X        (set_buffer buf)
  1698. X    )
  1699. X)
  1700. X(macro hanoi0
  1701. X    (
  1702. X        (int    n sn dn hn)
  1703. X        (if (inq_kbd_char)
  1704. X            (return)
  1705. X            )
  1706. X        (get_parm 0 n)
  1707. X        (get_parm 1 sn)
  1708. X        (get_parm 2 dn)
  1709. X        (get_parm 3 hn)
  1710. X        (if (> n 0)
  1711. X                (
  1712. X                    (hanoi0 (- n 1) sn hn dn)
  1713. X                    (if (inq_kbd_char)
  1714. X                            (return)
  1715. X                            )
  1716. X                    (move_piece sn dn)
  1717. X                    (hanoi0 (- n 1) hn dn sn)
  1718. X                )
  1719. X            )
  1720. X    )
  1721. X)                                                                           
  1722. X(macro move_piece
  1723. X    (
  1724. X        (int    width i j from to col col1 col2 lines)
  1725. X        (string blanks disc)
  1726. X
  1727. X        (get_parm 0 from)
  1728. X        (get_parm 1 to)
  1729. X        (top_of_buffer)
  1730. X        (= i from)
  1731. X        (while (> i 0) (
  1732. X                (search_fwd "!")
  1733. X                (right)
  1734. X                (-- i)
  1735. X                )
  1736. X            )
  1737. X        (left)
  1738. X        (inq_position NULL col)
  1739. X        (while (== (read 1) "!")
  1740. X            (
  1741. X                (++ lines)
  1742. X                (down)
  1743. X            )
  1744. X        )
  1745. X        (search_back " \\c")
  1746. X        (inq_position NULL col1)
  1747. X        (search_fwd "x@\\c" -2)
  1748. X        (inq_position NULL col2)
  1749. X        (refresh)
  1750. X        (move_abs 0 col1)
  1751. X        (= width (- col2 col1))
  1752. X        (= disc (read width))
  1753. X        (up)
  1754. X        (move_abs 0 col1)
  1755. X        (= blanks (read width))
  1756. X        (down)
  1757. X        (= j lines)
  1758. X        (while (>= j 0) (
  1759. X                (replace_string blanks)
  1760. X                (up)
  1761. X                (replace_string disc)
  1762. X                (display_disc)
  1763. X                (-- j)
  1764. X                )
  1765. X            )
  1766. X        (if (> to from)
  1767. X                (= j (* (- to from) WIDTH))
  1768. X            ;else
  1769. X                (= j (* (- from to) WIDTH))
  1770. X            )
  1771. X        (/= j 2)
  1772. X        (while (> j 0) (
  1773. X            (if (> to from) (
  1774. X                    (insert "  ")
  1775. X                    (inq_position NULL col)
  1776. X                    (end_of_line)
  1777. X                    (left 2)
  1778. X                    (delete_char 2)
  1779. X                    (move_abs 0 col)
  1780. X                    )
  1781. X            ;else
  1782. X                (
  1783. X                    (left 2)
  1784. X                    (inq_position NULL col)
  1785. X                    (delete_char 2)
  1786. X                    (end_of_line)
  1787. X                    (insert "  ")
  1788. X                    (move_abs 0 col)
  1789. X                )
  1790. X            )
  1791. X            (-- j)
  1792. X            (display_disc)
  1793. X            )
  1794. X        )                
  1795. X        (save_position)
  1796. X        (replace_string blanks)
  1797. X        (search_fwd "!")
  1798. X        (delete_char)
  1799. X        (insert " ")
  1800. X        (restore_position)
  1801. X        (down)
  1802. X        (replace_string disc)
  1803. X        (display_disc)
  1804. X        (while 1 (
  1805. X                (replace_string blanks)
  1806. X                (down)
  1807. X                (replace_string disc)
  1808. X                (display_disc)
  1809. X                (down)
  1810. X                (if (!= (read 1) " ")
  1811. X                    (break)
  1812. X                    )
  1813. X                (up)
  1814. X                )
  1815. X            )
  1816. X                
  1817. X                        
  1818. X    )
  1819. X)
  1820. X(macro display_disc
  1821. X    (
  1822. X;            (drop_anchor 4)
  1823. X            (move_rel 0 width)
  1824. X            (refresh)
  1825. X            (move_rel 0 (- 0 width))
  1826. X;            (raise_anchor)
  1827. X    )
  1828. X)
  1829. X(macro replace_string
  1830. X    (
  1831. X        (string    str)
  1832. X        (int    col)
  1833. X
  1834. X        (get_parm 0 str)
  1835. X        (inq_position NULL col)
  1836. X        (delete_char (strlen str))
  1837. SHAR_EOF
  1838. echo "End of part 2"
  1839. echo "File src/crisp/hanoi.m is continued in part 3"
  1840. echo "3" > s2_seq_.tmp
  1841. exit 0
  1842. -- 
  1843. =====================            Reuters Ltd PLC, 
  1844. Tel: +44 628 891313 x. 212         Westthorpe House,
  1845. UUCP:     fox%marlow.uucp@idec.stc.co.uk  Little Marlow,
  1846.                        Bucks, England SL7 3RQ
  1847.  
  1848.