home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / editors / 1846 < prev    next >
Encoding:
Text File  |  1992-07-29  |  45.8 KB  |  1,802 lines

  1. Newsgroups: comp.editors
  2. Path: sparky!uunet!mcsun!Germany.EU.net!news.netmbx.de!zrz.tu-berlin.de!math.fu-berlin.de!wolff
  3. From: wolff@inf.fu-berlin.de (Thomas Wolff)
  4. Subject: Re: Editor mined (4/4)
  5. Message-ID: <5AK5XXI@math.fu-berlin.de>
  6. Sender: news@math.fu-berlin.de (Math Department)
  7. Organization: Free University of Berlin, Germany
  8. References: <62I5CYD@math.fu-berlin.de>
  9. Date: Wed, 29 Jul 1992 18:03:33 GMT
  10. Lines: 1790
  11.  
  12. #! /bin/sh
  13. : This is a sharchive -- extract the files by running through sh
  14.  
  15. echo ---------------------- extracting posting-errors -----------------
  16. sed 's/^,//' << \EOSED > posting-errors
  17. ,
  18. ,Posting the editor mined lead to some errors which I correct hereby.
  19. ,
  20. ,The last line of the file mined.prj was left out due to a missing line-end.
  21. ,In the files minedio.c and minedmp.c, I had several Escape characters 
  22. ,included literally in control strings. Obviously, they got killed somewhere 
  23. ,in the News system. I have replaced them with the \033 notation now.
  24. ,
  25. ,The mismatches in the files mined.prj and minedio.c only affect the MSDOS 
  26. ,version. Those in minedmp.c disable function key detection.
  27. ,
  28. ,This posting can be taken as a complete replacement of the previous (4/4) 
  29. ,part. It includes all 3 corrupted files.
  30. ,
  31. ,Sorry for the inconvenience. Moreover, there may also be undesirable 
  32. ,results for people who get the postings with bit 8 stripped off since 
  33. ,some characters with that bit set are also included literally.
  34. ,I list the mismatches here:
  35. ,File mined1.c:
  36. ,    char SHIFT_MARK = '╗';
  37. ,               ^    This is the double right-angle '>>'
  38. ,    if (Mark != NIL_PTR) TABchar = (Mark [0] == '\0' ? '╖' : Mark [0]);
  39. ,            That is the bullet or dotcentered   ^
  40. ,File mined2.c:
  41. ,    ((u_char) '\300' <= ch && ch != (u_char) '╫' && ch != (u_char) '≈') ||
  42. ,    (ch == (u_char) '╡')
  43. ,             ^              ^            ^
  44. ,       These are the multiplication and division sign and the Greek mu
  45. ,    Some more >> and << characters are in the comment to search ()
  46. ,File minedio.c:
  47. ,        SHIFT_MARK = '╗';    <- double right-angle '>>'
  48. ,      else    SHIFT_MARK = '>';
  49. ,File minedmp.c:
  50. ,    The 8-bit characters in the generation tables for mined's 
  51. ,    diacritic prefix keys functions. I cannot list them all here.
  52. ,    If there is interest, I can send or post a uuencoded version.
  53. ,
  54. ,8 bit characters are also used in mined.help where referring to themselves, 
  55. ,and of course in the German mined.hilf.
  56. ,
  57. ,I typed the characters in literally since this appeared more natural to me 
  58. ,and also more logical in case the whole files would be translated into an 
  59. ,other character set. Octal notations would not be translated then and thus 
  60. ,incorrectly remain in the original character set.
  61. ,
  62. ,Thomas Wolff
  63. ,Freie Universit:at Berlin
  64. ,wolff@inf.fu-berlin.de
  65. ,
  66. EOSED
  67.  
  68. echo ---------------------- extracting minedio.c -----------------
  69. sed 's/^,//' << \EOSED > minedio.c
  70. ,/*  ==================================================================    *
  71. , *                Editor mined                *
  72. , *            Operating system dependant I/O            *
  73. , *  ==================================================================    */
  74. ,
  75. ,#include "mined.h"
  76. ,#include <errno.h>
  77. ,#include <signal.h>
  78. ,
  79. ,#ifdef CURSES
  80. ,#include <curses.h>
  81. ,#undef FALSE
  82. ,#undef TRUE
  83. ,#undef TERMIO    /* \ must be  */
  84. ,#undef SGTTY    /* / disabled */
  85. ,#endif
  86. ,
  87. ,#ifdef TERMIO
  88. ,#include <termios.h>
  89. ,#endif
  90. ,#ifdef SGTTY
  91. ,#include <sys/ioctl.h>    /* <sgtty.h> ? */
  92. ,#endif
  93. ,
  94. ,#ifdef msdos
  95. ,#include <conio.h>
  96. ,#undef SIGINT    /* signal (SIGINT, catchint) not understood */
  97. ,#define _getch_
  98. ,#endif
  99. ,
  100. ,#ifdef unix
  101. ,#include <sys/time.h>    /* for struct timeval (for select in inputreadyafter) */
  102. ,#define selectread    /* use select () ? */
  103. ,#endif
  104. ,
  105. ,#ifdef vms
  106. ,#undef u_char
  107. ,#include <socket.h>    /* for select () and struct timeval */
  108. ,#ifdef CURSES
  109. ,#define _getch_
  110. ,#endif
  111. ,#endif
  112. ,
  113. ,/*  ==================================================================    *
  114. , *            Unix signalling routines            *
  115. , *  ==================================================================    */
  116. ,
  117. ,catch_signals (catch)
  118. ,  void (* catch) ();
  119. ,{
  120. ,#ifdef SIGHUP
  121. ,  signal (SIGHUP, catch);
  122. ,#endif
  123. ,#ifdef SIGILL
  124. ,  signal (SIGILL, catch);
  125. ,#endif
  126. ,#ifdef SIGTRAP
  127. ,  signal (SIGTRAP, catch);
  128. ,#endif
  129. ,#ifdef SIGABRT
  130. ,  signal (SIGABRT, catch);
  131. ,#endif
  132. ,#ifdef SIGEMT
  133. ,  signal (SIGEMT, catch);
  134. ,#endif
  135. ,#ifdef SIGFPE
  136. ,  signal (SIGFPE, catch);
  137. ,#endif
  138. ,#ifdef SIGBUS
  139. ,  signal (SIGBUS, catch);
  140. ,#endif
  141. ,#ifdef SIGSEGV
  142. ,  signal (SIGSEGV, catch);
  143. ,#endif
  144. ,#ifdef SIGSYS
  145. ,  signal (SIGSYS, catch);
  146. ,#endif
  147. ,#ifdef SIGPIPE
  148. ,  signal (SIGPIPE, catch);
  149. ,#endif
  150. ,#ifdef SIGALRM
  151. ,  signal (SIGALRM, catch);
  152. ,#endif
  153. ,#ifdef SIGTERM
  154. ,  signal (SIGTERM, catch);
  155. ,#endif
  156. ,#ifdef SIGXCPU
  157. ,  signal (SIGXCPU, catch);
  158. ,#endif
  159. ,#ifdef SIGXFSZ
  160. ,  signal (SIGXFSZ, catch);
  161. ,#endif
  162. ,#ifdef SIGVTALRM
  163. ,  signal (SIGVTALRM, catch);
  164. ,#endif
  165. ,#ifdef SIGPROF
  166. ,  signal (SIGPROF, catch);
  167. ,#endif
  168. ,#ifdef SIGLOST
  169. ,  signal (SIGLOST, catch);
  170. ,#endif
  171. ,#ifdef SIGUSR1
  172. ,  signal (SIGUSR1, catch);
  173. ,#endif
  174. ,#ifdef SIGUSR2
  175. ,  signal (SIGUSR2, catch);
  176. ,#endif
  177. ,}
  178. ,
  179. ,#ifdef SIGTSTP
  180. ,suspendmyself ()
  181. ,{
  182. ,  kill (getpid (), SIGTSTP);
  183. ,}
  184. ,FLAG cansuspendmyself = TRUE;
  185. ,#else
  186. ,suspendmyself () {}
  187. ,FLAG cansuspendmyself = FALSE;
  188. ,#endif
  189. ,
  190. ,#ifdef SIGWINCH
  191. ,/*
  192. , * Catch the SIGWINCH signal sent to mined.
  193. , */
  194. ,catchwinch ()
  195. ,{
  196. ,  winchg = TRUE;
  197. ,/*  if (waitingforinput == TRUE) RDwin ();    now done in __readchar () */
  198. ,  signal (SIGWINCH, catchwinch); /* Re-installation of the signal */
  199. ,}
  200. ,#endif
  201. ,
  202. ,#ifdef SIGQUIT
  203. ,/*
  204. , * Catch the SIGQUIT signal (^\) sent to mined. It turns on the quitflag.
  205. , */
  206. ,catchquit ()
  207. ,{
  208. ,#ifdef UNUSED /* Should not be needed with new __readchar () */
  209. ,/* Was previously needed on SUN but showed bad effects on Iris. */
  210. ,  static char quitchar = '\0';
  211. ,  if (waitingforinput == TRUE)
  212. ,    /* simulate input to enable immediate break also during input */
  213. ,    ioctl (input_fd, TIOCSTI, & quitchar);
  214. ,#endif
  215. ,  quit = TRUE;
  216. ,  signal (SIGQUIT, catchquit); /* Re-installation of the signal */
  217. ,}
  218. ,#endif
  219. ,
  220. ,#ifdef SIGINT
  221. ,/*
  222. , * Catch the SIGINT signal (^C) sent if it cannot be ignored by tty driver
  223. , */
  224. ,catchint ()
  225. ,{
  226. ,  intr = TRUE;
  227. ,  signal (SIGINT, catchint); /* Re-installation of the signal */
  228. ,}
  229. ,#endif
  230. ,
  231. ,/*  ==================================================================    *
  232. , *            Terminal mode switcher                *
  233. , *  ==================================================================    */
  234. ,
  235. ,/*
  236. , * Set and reset tty into CBREAK or old mode according to argument `state'.
  237. , * It also sets all signal characters (except for ^\) to UNDEF. ^\ is caught.
  238. , */
  239. ,raw_mode (state)
  240. ,  FLAG state;
  241. ,{
  242. ,#ifdef TERMIO
  243. ,  static struct termios old_termio;
  244. ,     struct termios new_termio;
  245. ,#define gettermio(fd, iopoi)    tcgetattr (fd, iopoi);
  246. ,#define settermio(fd, iopoi)    tcsetattr (fd, TCSADRAIN, iopoi); /**/
  247. ,/* #define gettermio(fd, iopoi)    ioctl (fd, TCGETS, iopoi);
  248. ,   #define settermio(fd, iopoi)    ioctl (fd, TCSETSW, iopoi); /**/
  249. ,#endif
  250. ,#ifdef SGTTY
  251. ,  static struct sgttyb old_tty;
  252. ,     struct sgttyb new_tty;
  253. ,  static int oldlmode;
  254. ,     int lmode;
  255. ,  static struct tchars old_tchars;
  256. ,  static struct ltchars old_ltchars;
  257. ,#define NDEF '\377'
  258. ,  static struct tchars new_tchars = {NDEF, QUITCHAR, NDEF, NDEF, NDEF, NDEF};
  259. ,  static struct ltchars new_ltchars = {NDEF, NDEF, NDEF, NDEF, NDEF, NDEF};
  260. ,/* correspondence between the tchars/ltchars characters of the sgtty 
  261. ,   interface and the c_cc characters of the termios interface (codes vary):
  262. ,    sgtty        termio        sgtty        termio
  263. ,    t_intrc        VINTR        t_suspc        VSUSP
  264. ,    t_quitc        VQUIT        t_dsuspc    VDSUSP
  265. ,    t_startc    VSTART        t_rprntc    VREPRINT
  266. ,    t_stopc        VSTOP        t_flushc    VDISCARD
  267. ,    t_eofc        VEOF (VMIN)    t_werasc    VWERASE
  268. ,    t_brkc        VEOL (VTIME)    t_lnextc    VLNEXT
  269. ,*/
  270. ,#endif
  271. ,
  272. ,  if (state == OFF) {
  273. ,    isscreenmode = FALSE;
  274. ,#ifdef CURSES
  275. ,    endwin ();
  276. ,#ifdef vms
  277. ,    system ("set terminal /ttsync /nopasthru");
  278. ,#endif
  279. ,#else
  280. ,    end_screen_mode ();
  281. ,    flush ();
  282. ,#endif
  283. ,#ifdef TERMIO
  284. ,    settermio (input_fd, & old_termio);
  285. ,#endif
  286. ,#ifdef SGTTY
  287. ,    ioctl (input_fd, TIOCSETP, & old_tty);
  288. ,    ioctl (input_fd, TIOCSETC, & old_tchars);
  289. ,    ioctl (input_fd, TIOCSLTC, & old_ltchars);
  290. ,    ioctl (input_fd, TIOCLSET, & oldlmode);
  291. ,#endif
  292. ,    return;
  293. ,  }
  294. ,
  295. ,  else /* (state == ON) */ {
  296. ,    isscreenmode = TRUE;
  297. ,#ifdef CURSES
  298. ,    refresh ();
  299. ,#else
  300. ,    start_screen_mode ();
  301. ,    flush ();
  302. ,#endif
  303. ,#ifdef TERMIO
  304. ,    gettermio (input_fd, & old_termio);
  305. ,    gettermio (input_fd, & new_termio);
  306. ,
  307. ,    new_termio.c_iflag &= ~(ISTRIP|IXON|IXOFF);
  308. ,    new_termio.c_oflag &= ~OPOST;
  309. ,    new_termio.c_cflag &= ~(PARENB|CSIZE);
  310. ,    new_termio.c_cflag |= CS8;
  311. ,    new_termio.c_lflag &= ~(ICANON|ECHO);
  312. ,#define NDEF '\000'
  313. ,    new_termio.c_cc [VMIN] = 1;
  314. ,    new_termio.c_cc [VTIME] = 0;
  315. ,    new_termio.c_cc [VQUIT] = QUITCHAR;
  316. ,    new_termio.c_cc [VINTR] = NDEF;
  317. ,    new_termio.c_cc [VSUSP] = NDEF;
  318. ,#ifdef VDISCARD
  319. ,    new_termio.c_cc [VDISCARD] = NDEF;
  320. ,#endif
  321. ,    settermio (input_fd, & new_termio);
  322. ,#endif
  323. ,#ifdef SGTTY
  324. ,/* Save old tty settings */
  325. ,    ioctl (input_fd, TIOCGETP, & old_tty);
  326. ,    ioctl (input_fd, TIOCGETC, & old_tchars);
  327. ,    ioctl (input_fd, TIOCGLTC, & old_ltchars);
  328. ,    ioctl (input_fd, TIOCLGET, & oldlmode);
  329. ,/* Set line mode */
  330. ,/* If this feature should not be available on some system, RAW must be used
  331. ,   instead of CBREAK below to enable 8 bit characters on output */
  332. ,    lmode = oldlmode;
  333. ,    lmode |= LPASS8; /* enable 8 bit characters on input in CBREAK mode */
  334. ,    lmode |= LLITOUT; /* enable 8 bit characters on output in CBREAK mode;
  335. ,        this may not be necessary in newer Unixes, e.g. SUN-OS 4;
  336. ,        output handling is slightly complicated by LITOUT */
  337. ,    ioctl (input_fd, TIOCLSET, & lmode);
  338. ,/* Set tty to CBREAK (or RAW) mode */
  339. ,    new_tty = old_tty;
  340. ,    new_tty.sg_flags &= ~ECHO;
  341. ,    new_tty.sg_flags |= CBREAK;
  342. ,    ioctl (input_fd, TIOCSETP, & new_tty);
  343. ,/* Unset signal chars */
  344. ,    ioctl (input_fd, TIOCSETC, & new_tchars);  /* Only leaves QUITCHAR */
  345. ,    ioctl (input_fd, TIOCSLTC, & new_ltchars); /* Leaves nothing */
  346. ,#endif
  347. ,
  348. ,/* Define signal handlers */
  349. ,#ifdef SIGQUIT
  350. ,    signal (SIGQUIT, catchquit);    /* Catch QUITCHAR (^\) */
  351. ,#endif
  352. ,#ifdef SIGINT
  353. ,    signal (SIGINT, catchint);    /* Catch INTR char (^C) */
  354. ,#endif
  355. ,#ifdef SIGWINCH
  356. ,    signal (SIGWINCH, catchwinch);    /* Catch window size changes */
  357. ,#endif
  358. ,  }
  359. ,}
  360. ,
  361. ,/*  ==================================================================    *
  362. , *            Unix I/O routines                *
  363. , *  ==================================================================    */
  364. ,
  365. ,#ifdef CURSES
  366. ,
  367. ,__putchar (c)
  368. ,  register u_char c;
  369. ,{ addch (c); }
  370. ,
  371. ,putstring (str)
  372. ,  register u_char * str;
  373. ,{ addstr (str); }
  374. ,
  375. ,flush ()
  376. ,{ refresh (); }
  377. ,
  378. ,FLAG can_add_line = TRUE, can_delete_line = TRUE, can_clear_eol = TRUE;
  379. ,
  380. ,clear_screen ()
  381. ,{
  382. ,  clear ();
  383. ,}
  384. ,clear_eol ()
  385. ,{
  386. ,  clrtoeol ();
  387. ,}
  388. ,scroll_forward ()
  389. ,{
  390. ,  scroll (stdscr);
  391. ,}
  392. ,scroll_reverse ()
  393. ,{ /* only called if cursor is at top of screen */
  394. ,  insertln ();
  395. ,}
  396. ,add_line (y)
  397. ,  register int y;
  398. ,{
  399. ,  move (y, 0);
  400. ,  insertln ();
  401. ,}
  402. ,delete_line (y)
  403. ,  register int y;
  404. ,{
  405. ,  move (y, 0);
  406. ,  deleteln ();
  407. ,}
  408. ,move_cursor (x, y)
  409. ,  register int x, y;
  410. ,{
  411. ,  move (y, x);
  412. ,}
  413. ,reverse_on ()
  414. ,{
  415. ,  standout ();
  416. ,}
  417. ,reverse_off ()
  418. ,{
  419. ,  standend ();
  420. ,}
  421. ,
  422. ,get_term_cap (TERMname)
  423. ,  char * TERMname;
  424. ,{
  425. ,#ifdef vms
  426. ,  system ("set terminal /pasthru /nottsync");
  427. ,#endif
  428. ,  initscr ();
  429. ,#ifdef vms
  430. ,  crmode ();
  431. ,#else
  432. ,  crmode (); /* cbreak (); */
  433. ,  nonl ();
  434. ,#endif
  435. ,  noecho ();
  436. ,  scrollok (stdscr, TRUE);
  437. ,#ifdef unix
  438. ,#ifndef vax
  439. ,  idlok (stdscr, TRUE);
  440. ,#ifndef sun
  441. ,  typeahead (input_fd);
  442. ,#endif
  443. ,#endif
  444. ,#endif
  445. ,
  446. ,  YMAX = LINES - 1;    /* # of lines */
  447. ,  XMAX = COLS - 1;    /* # of columns */
  448. ,  getwinsize ();
  449. ,}
  450. ,
  451. ,/*------------------------------------------------------------------------*/
  452. ,#else    /* not CURSES */
  453. ,
  454. ,__putchar (c)
  455. ,  register u_char c;
  456. ,{ writechar (output_fd, (c)); }
  457. ,
  458. ,putstring (str)
  459. ,  register u_char * str;
  460. ,{ writestring (output_fd, (str)); }
  461. ,
  462. ,flush ()
  463. ,{ flush_buffer (output_fd); }
  464. ,
  465. ,#ifdef unix
  466. ,
  467. ,/* Storage for the terminal control sequences */
  468. ,char *cCL, *cCE, *cSR, *cAL, *cDL, *cCS, *cSC, *cRC,
  469. ,     *cCM, *cSO, *cSE, *cVS, *cVE, *cTI, *cTE;
  470. ,#define aff1 0
  471. ,#define affmax YMAX
  472. ,
  473. ,FLAG can_add_line = FALSE, can_delete_line = FALSE, can_clear_eol = FALSE;
  474. ,
  475. ,clear_screen ()
  476. ,{
  477. ,  tputs (cCL, affmax, __putchar);
  478. ,}
  479. ,clear_eol ()
  480. ,{
  481. ,  if (cCE) tputs (cCE, aff1, __putchar);
  482. ,  else putstring (blank_line);
  483. ,}
  484. ,scroll_forward ()
  485. ,{
  486. ,  move_cursor (0, YMAX);
  487. ,/*  putchar ('\n');    */
  488. ,  tputs ("\n", affmax, __putchar);
  489. ,}
  490. ,scroll_reverse ()
  491. ,{
  492. ,  tputs (cSR, affmax, __putchar);
  493. ,}
  494. ,add_line (y)
  495. ,  register int y;
  496. ,{
  497. ,  if (cAL) {
  498. ,    move_cursor (0, y);
  499. ,    tputs (cAL, affmax, __putchar);
  500. ,  }
  501. ,  else {
  502. ,    move_cursor (0, y);
  503. ,    tputs (cSC, aff1, __putchar);
  504. ,    tputs (tgoto (cCS, YMAX, y), aff1, __putchar);
  505. ,    tputs (cRC, aff1, __putchar);
  506. ,    tputs (cSR, affmax, __putchar);
  507. ,    tputs (tgoto (cCS, YMAX, 0), aff1, __putchar);
  508. ,    tputs (cRC, aff1, __putchar);
  509. ,  }
  510. ,}
  511. ,delete_line (y)
  512. ,  register int y;
  513. ,{
  514. ,  if (cDL) {
  515. ,    move_cursor (0, y);
  516. ,    tputs (cDL, affmax, __putchar);
  517. ,  }
  518. ,  else {
  519. ,    move_cursor (0, y);
  520. ,    tputs (cSC, aff1, __putchar);
  521. ,    tputs (tgoto (cCS, YMAX, y), aff1, __putchar);
  522. ,    move_cursor (0, YMAX);
  523. ,/*    putchar ('\n');    */
  524. ,    tputs ("\n", affmax, __putchar);
  525. ,    tputs (tgoto (cCS, YMAX, 0), aff1, __putchar);
  526. ,    tputs (cRC, aff1, __putchar);
  527. ,  }
  528. ,}
  529. ,move_cursor (x, y)
  530. ,  register int x, y;
  531. ,{
  532. ,  tputs (tgoto (cCM, x, y), aff1, __putchar);
  533. ,}
  534. ,reverse_on ()
  535. ,{
  536. ,  tputs (cSO, aff1, __putchar);
  537. ,}
  538. ,reverse_off ()
  539. ,{
  540. ,  tputs (cSE, aff1, __putchar);
  541. ,}
  542. ,start_screen_mode ()
  543. ,{
  544. ,  tputs (cTI, affmax, __putchar);
  545. ,  tputs (cVS, affmax, __putchar);
  546. ,/* Install correct scrolling region in case terminal is bigger than assumed */
  547. ,/* (this effect was observed after window size changes of Sun windows): */
  548. ,  if (cCS) tputs (tgoto (cCS, YMAX, 0), aff1, __putchar);
  549. ,}
  550. ,end_screen_mode ()
  551. ,{
  552. ,  tputs (cTE, affmax, __putchar);
  553. ,  tputs (cVE, affmax, __putchar);
  554. ,}
  555. ,
  556. ,get_term_cap (TERMname)
  557. ,  char * TERMname;
  558. ,{
  559. ,#define termbuflen 100
  560. ,  char entry [1024];
  561. ,  static char termbuf [termbuflen];
  562. ,  char * loc = termbuf;
  563. ,  extern char * tgetstr ();
  564. ,
  565. ,  if (tgetent (entry, TERMname) <= 0) {
  566. ,    panic ("Unknown terminal", NIL_PTR);
  567. ,  }
  568. ,
  569. ,  YMAX = tgetnum ("li", & loc) - 1;    /* # of lines */
  570. ,  XMAX = tgetnum ("co", & loc) - 1;    /* # of columns */
  571. ,/* getenv ("LINES"), getenv ("COLUMNS") ?! */
  572. ,  getwinsize ();
  573. ,
  574. ,  cCL = tgetstr ("cl", & loc);    /* clear screen */
  575. ,  cCE = tgetstr ("ce", & loc);    /* clear to end of line */
  576. ,  cSR = tgetstr ("sr", & loc);    /* scroll reverse */
  577. ,  cAL = tgetstr ("al", & loc);    /* add line */
  578. ,  if (!cSR) cSR = cAL;
  579. ,  cDL = tgetstr ("dl", & loc);    /* delete line */
  580. ,  cCS = tgetstr ("cs", & loc);    /* change scrolling region */
  581. ,  cSC = tgetstr ("sc", & loc);    /* save cursor    \ needed with vt100   */
  582. ,  cRC = tgetstr ("rc", & loc);    /* restore cursor / for add/delete line */
  583. ,  cCM = tgetstr ("cm", & loc);    /* cursor motion */
  584. ,  cSO = tgetstr ("so", & loc);    /* stand out mode */
  585. ,  cSE = tgetstr ("se", & loc);    /* end " */
  586. ,  cVS = tgetstr ("vs", & loc);    /* visual mode */
  587. ,  cVE = tgetstr ("ve", & loc);    /* end " */
  588. ,  cTI = tgetstr ("ti", & loc);    /* positioning mode */
  589. ,  cTE = tgetstr ("te", & loc);    /* end " */
  590. ,
  591. ,  if (cAL || (cSR && cCS)) can_add_line = TRUE;
  592. ,  if (cDL || cCS) can_delete_line = TRUE;
  593. ,  if (cCE) can_clear_eol = TRUE;
  594. ,
  595. ,  if (loc > termbuf + termbuflen) {
  596. ,    panic ("Terminal control strings don't fit", NIL_PTR);
  597. ,  }
  598. ,  if (!cCL || !cCM || !cSR || !cCE /* || !cSO || !cSE */ ) {
  599. ,    panic ("Sorry, no mined on this type of terminal", NIL_PTR);
  600. ,  }
  601. ,}
  602. ,
  603. ,/*------------------------------------------------------------------------*/
  604. ,#endif unix
  605. ,
  606. ,#ifdef msdos
  607. ,#ifdef conio
  608. ,#include <conio.h>
  609. ,
  610. ,FLAG can_add_line = TRUE, can_delete_line = TRUE, can_clear_eol = TRUE;
  611. ,
  612. ,clear_screen ()
  613. ,{ clrscr (); }
  614. ,clear_eol ()
  615. ,{ clreol (); }
  616. ,scroll_forward ()
  617. ,{
  618. ,  move_cursor (0, YMAX);
  619. ,  putchar ('\n');
  620. ,}
  621. ,scroll_reverse ()
  622. ,{ /* only called if cursor is at top of screen */
  623. ,  insline ();
  624. ,}
  625. ,add_line (y)
  626. ,  register int y;
  627. ,{
  628. ,  move_cursor (0, y);
  629. ,  insline ();
  630. ,}
  631. ,delete_line (y)
  632. ,  register int y;
  633. ,{
  634. ,  move_cursor (0, y);
  635. ,  delline ();
  636. ,}
  637. ,move_cursor (x, y)
  638. ,{
  639. ,  gotoxy (x + 1, y + 1);
  640. ,}
  641. ,reverse_on ()
  642. ,{ highvideo ();
  643. ,}
  644. ,reverse_off ()
  645. ,{ normvideo ();
  646. ,}
  647. ,start_screen_mode ()
  648. ,{}
  649. ,end_screen_mode ()
  650. ,{}
  651. ,
  652. ,get_term ()
  653. ,{
  654. ,  getwinsize ();
  655. ,}
  656. ,
  657. ,getwinsize ()
  658. ,{
  659. ,/* this has to be extended to request the current screen size */
  660. ,  struct text_info scrinfo;
  661. ,
  662. ,  gettextinfo (& scrinfo);
  663. ,  /* This seems to be a junk procedure since no other information than
  664. ,     25 * 80 comes out in 50 lines mode */
  665. ,  YMAX = scrinfo.screenheight - 1;
  666. ,  XMAX = scrinfo.screenwidth - 1;
  667. ,}
  668. ,
  669. ,#else   # conio
  670. ,
  671. ,/* adjust the following values to the capabilities of your ANSI driver: */
  672. ,FLAG can_add_line = TRUE, can_delete_line = TRUE, can_clear_eol = TRUE;
  673. ,
  674. ,clear_screen ()
  675. ,{ putstring ("\033[2J"); }
  676. ,clear_eol ()
  677. ,{ putstring ("\033[K"); }
  678. ,scroll_forward ()
  679. ,{
  680. ,  move_cursor (0, YMAX);
  681. ,  putchar ('\n');
  682. ,}
  683. ,scroll_reverse ()
  684. ,{ /* only called if cursor is at top of screen */
  685. ,  putstring ("\033[1L");
  686. ,}
  687. ,add_line (y)
  688. ,  register int y;
  689. ,{
  690. ,  move_cursor (0, y);
  691. ,  putstring ("\033[1L");
  692. ,}
  693. ,delete_line (y)
  694. ,  register int y;
  695. ,{
  696. ,  move_cursor (0, y);
  697. ,  putstring ("\033[1M");
  698. ,}
  699. ,move_cursor (x, y)
  700. ,  register int x, y;
  701. ,{ static char s [11];
  702. ,  build_string (s, "\033[%d;%dH", y + 1, x + 1);
  703. ,  putstring (s);
  704. ,}
  705. ,char reverse_on_str [30] = "\033[7m";    /* inverse mode */
  706. ,char reverse_off_str [30] = "\033[27m";    /* inverse off */
  707. ,reverse_on ()
  708. ,{ putstring (reverse_on_str); /* 1m | 7m | 7m    | 7;2m */
  709. ,}
  710. ,reverse_off ()
  711. ,{ putstring (reverse_off_str); /* m  | 0m | 0m 1m | m    */
  712. ,}
  713. ,start_screen_mode ()
  714. ,{}
  715. ,end_screen_mode ()
  716. ,{}
  717. ,
  718. ,get_term ()
  719. ,{
  720. ,  char * colstr = unnull (getenv ("MINEDCOL"));
  721. ,  char * coloff = colstr;
  722. ,  while (* coloff != '\0' && * coloff != ' ') coloff ++;
  723. ,  if (* coloff == ' ') {* coloff = '\0'; coloff ++;}
  724. ,  if (* colstr != '\0') build_string (reverse_on_str, "\033[%sm", colstr);
  725. ,  if (* coloff != '\0') build_string (reverse_off_str, "\033[%sm", coloff);
  726. ,  getwinsize ();
  727. ,}
  728. ,
  729. ,getwinsize ()
  730. ,{
  731. ,  move_cursor (200, 200);
  732. ,  putstring ("\033[6n");
  733. ,  flush ();
  734. ,  (void) readchar (); (void) readchar ();
  735. ,  get_digits (& YMAX); YMAX = YMAX - 1;
  736. ,  get_digits (& XMAX); XMAX = XMAX - 1;
  737. ,  readchar ();    /* NNANSI sends a final return */
  738. ,}
  739. ,
  740. ,#endif else conio
  741. ,#endif msdos
  742. ,
  743. ,#endif else CURSES
  744. ,
  745. ,/*------------------------------------------------------------------------*/
  746. ,
  747. ,/*
  748. , * Read a character from the operating system and handle interrupts.
  749. , * Concerning problems due to the interference of read operations and
  750. , * incoming signals (QUIT, WINCH) see the comments at readchar ().
  751. , */
  752. ,strange (err)
  753. ,  char * err;
  754. ,{
  755. ,  ring_bell ();
  756. ,  error ("Read interrupted: ", err);
  757. ,  sleep (1);
  758. ,  ring_bell ();
  759. ,  return QUITCHAR;
  760. ,}
  761. ,
  762. ,/*
  763. , * Is a character available within msec milliseconds from file no fid?
  764. , */
  765. ,int
  766. ,inputreadyafter (fid, msec)
  767. ,  int fid;
  768. ,  int msec;
  769. ,{
  770. ,#ifdef selectread
  771. ,  int readfds;
  772. ,  static struct timeval timeoutstru = {0, 0};
  773. ,  register int nfds;
  774. ,
  775. ,  readfds = 1 << fid;
  776. ,  timeoutstru.tv_usec = 1000 * msec;
  777. ,  nfds = select (fid + 1, & readfds, 0, 0, & timeoutstru);
  778. ,  return nfds;
  779. ,#else
  780. ,  if (msec < 500)
  781. ,    return 1;
  782. ,  else    return 0;
  783. ,#endif
  784. ,}
  785. ,
  786. ,/*
  787. , * Read a char from operating system, handle interrupts if possible, 
  788. , * handle window size changes if possible.
  789. , */
  790. ,#ifdef selectread
  791. ,__readchar ()
  792. ,{
  793. ,  u_char c;
  794. ,  register int n;
  795. ,  int readfds, exceptfds;
  796. ,
  797. ,  do {
  798. ,    if (winchg == TRUE) RDwin ();
  799. ,    readfds = 1 << input_fd;
  800. ,    exceptfds = readfds;
  801. ,    select (input_fd + 1, & readfds, 0, & exceptfds, 0);
  802. ,    if (exceptfds) {
  803. ,       if (quit == TRUE) return QUITCHAR;
  804. ,       else if (winchg == TRUE) ;
  805. ,       else if (intr == TRUE) {intr = FALSE; return '\003';}
  806. ,       else return strange ("exception");
  807. ,    }
  808. ,    else
  809. ,#ifdef _getch_
  810. ,       return getch ();
  811. ,#else
  812. ,    {
  813. ,       if ((n = read (input_fd, & c, 1)) == 1) return c;
  814. ,       else if ((n == 0) || (geterrno () != EINTR))
  815. ,        panicio ("Error during character input", serror ());
  816. ,       else return strange (serror ());
  817. ,    }
  818. ,#endif
  819. ,  } while (TRUE);
  820. ,}
  821. ,#else
  822. ,__readchar ()
  823. ,{
  824. ,  u_char c;
  825. ,
  826. ,#ifdef _getch_
  827. ,  c = getch ();
  828. ,  if (intr == TRUE) {intr = FALSE; c = '\003';}
  829. ,#else
  830. ,  if (read (input_fd, & c, 1) != 1 && quit == FALSE) {
  831. ,    if (geterrno () == EINTR) return __readchar ();
  832. ,    else panicio ("Error during character input", serror ());
  833. ,  }
  834. ,#endif
  835. ,  if (quit == TRUE) c = QUITCHAR;
  836. ,  return c;
  837. ,}
  838. ,#endif
  839. ,
  840. ,/*------------------------------------------------------------------------*/
  841. ,
  842. ,#ifdef vms
  843. ,
  844. ,get_term ()
  845. ,{
  846. ,  get_term_cap (NIL_PTR);
  847. ,}
  848. ,
  849. ,getwinsize ()
  850. ,{ }
  851. ,
  852. ,#endif vms
  853. ,
  854. ,#ifdef unix
  855. ,
  856. ,/*
  857. , * Get current window size
  858. , */
  859. ,getwinsize ()
  860. ,{
  861. ,  struct winsize winsiz;
  862. ,
  863. ,  ioctl (output_fd, TIOCGWINSZ, & winsiz);
  864. ,  if (winsiz.ws_row != 0) YMAX = winsiz.ws_row - 1;
  865. ,  if (winsiz.ws_col != 0) XMAX = winsiz.ws_col - 1;
  866. ,}
  867. ,
  868. ,/*
  869. , * Get terminal information
  870. , */
  871. ,get_term ()
  872. ,{
  873. ,  char * TERMname = (char *) getenv ("TERM");
  874. ,
  875. ,  if (TERMname == NIL_PTR)
  876. ,    panic ("Terminal not specified", NIL_PTR);
  877. ,
  878. ,/*
  879. ,  if (  (strisprefix ("vt", TERMname) && strlen (TERMname) > 2)
  880. ,     || strisprefix ("sun", TERMname)
  881. ,     || strisprefix ("xterm", TERMname)
  882. ,     )
  883. ,    SHIFT_MARK = '╗';
  884. ,  else    SHIFT_MARK = '>';
  885. ,*/
  886. ,
  887. ,  get_term_cap (TERMname);
  888. ,
  889. ,/* build_string (text_buffer, "Terminal is %s, %d * %d.\n", TERMname, YMAX+1, XMAX+1);
  890. ,  putstring (text_buffer); */
  891. ,}
  892. ,
  893. ,#endif unix
  894. ,
  895. ,/*  ==================================================================    *
  896. , *                End                    *
  897. , *  ==================================================================    */
  898. EOSED
  899.  
  900. echo ---------------------- extracting minedmp.c -----------------
  901. sed 's/^,//' << \EOSED > minedmp.c
  902. ,/*  ==================================================================    *
  903. , *                Editor mined                *
  904. , *            Command and character set mappings        *
  905. , *  ==================================================================    */
  906. ,
  907. ,#include "mined.h"
  908. ,
  909. ,#define iso_latin_1
  910. ,
  911. ,#ifdef msdos
  912. ,#undef iso_latin_1
  913. ,#undef dec_sup
  914. ,#define pc_charset
  915. ,#endif
  916. ,
  917. ,/*  ==================================================================    *
  918. , *            character set coding                *
  919. , *  ==================================================================    */
  920. ,
  921. ,/*
  922. , * Determine a default diacritic character value for _readchar ().
  923. , * The characters are given literally except for the MSDOS version in order
  924. , * not to depend on the function of a character set translator.
  925. , * For all non-MSDOS platforms, ISO-Latin1 or the very similar 
  926. , * DEC-Supplemental are assumed.
  927. , * For MSDOS, characters for the "International Codepage" ("850") are 
  928. , * generated which includes the real letters (not all graphic and Greek 
  929. , * characters) of the old IBM codepage ("437") (which, by the way, some 
  930. , * time ago someone must have designed in an attack of mental sickness).
  931. , */
  932. ,u_char
  933. ,diacritic (c)
  934. ,  u_char c;
  935. ,{
  936. ,  /*    the following characters cannot be inserted by this function:
  937. ,    ⌐¬«║╝╜╛ and MSDOS graphics characters */
  938. ,  switch (c) {
  939. ,#ifdef pc_charset
  940. ,    case 'C' : return 128;
  941. ,    case 'c' : return 135;
  942. ,    case 'N' : return 165;
  943. ,    case 'n' : return 164;
  944. ,    case 's' : return 225;
  945. ,    case '!' : return 173;
  946. ,    case '$' : return 189;
  947. ,    case '/' : return 189;
  948. ,    case 'l' : return 156;
  949. ,    case 'L' : return 156;
  950. ,    case 'Y' : return 190;
  951. ,    case '+' : return 241;
  952. ,    case '?' : return 168;
  953. ,    case '0' : return 248;
  954. ,    case '1' : return 251;
  955. ,    case '2' : return 253;
  956. ,    case '3' : return 252;
  957. ,    case '<' : return 174;
  958. ,    case '>' : return 175;
  959. ,    case ':' : return 246;
  960. ,    case 'x' : return 158;
  961. ,    case 'f' : return 159;
  962. ,    case 'D' : return 209;
  963. ,    case 'd' : return 208;
  964. ,    case 'P' : return 232;
  965. ,    case 'p' : return 231;
  966. ,    case 'i' : return 213;
  967. ,    case '|' : return 221;
  968. ,    case '&' : return 244;
  969. ,    case '\\' : return 170;
  970. ,    case '_' : return 238;
  971. ,    case '-' : return 240;
  972. ,    case 'm' : return 230;
  973. ,    case '=' : return 242;
  974. ,    case '#' : return 245;
  975. ,    case '.' : return 250;
  976. ,    case ',' : return 247;
  977. ,    case '\'' : return 239;
  978. ,    case 'X' : return 207;
  979. ,#else
  980. ,    case 'C' : return '╟';
  981. ,    case 'c' : return 'τ';
  982. ,    case 'N' : return '╤';
  983. ,    case 'n' : return '±';
  984. ,    case 's' : return '▀';
  985. ,    case '!' : return 'í';
  986. ,    case '$' : return 'ó';
  987. ,    case '/' : return 'ó';
  988. ,    case 'l' : return 'ú';
  989. ,    case 'L' : return 'ú';
  990. ,    case 'Y' : return 'Ñ';
  991. ,    case '+' : return '▒';
  992. ,    case '?' : return '┐';
  993. ,    case '0' : return '░';
  994. ,    case '2' : return '▓';
  995. ,    case '<' : return '½';
  996. ,    case '>' : return '╗';
  997. ,    case 'D' : return '╨';
  998. ,    case 'd' : return '≡';
  999. ,    case 'P' : return '▐';
  1000. ,    case 'p' : return '■';
  1001. ,    case '|' : return 'ª';
  1002. ,    case '&' : return 'º';
  1003. ,    case '\\' : return '¼';
  1004. ,    case '_' : return '»';
  1005. ,    case '-' : return '¡';
  1006. ,    case 'm' : return '╡';
  1007. ,    case '#' : return '╢';
  1008. ,    case '.' : return '╖';
  1009. ,    case '*' : return '╖';
  1010. ,    case ',' : return '╕';
  1011. ,    case '\'' : return '┤';
  1012. ,    case '1' : return '╣';
  1013. ,    case '3' : return '│';
  1014. ,#ifdef iso_latin_1
  1015. ,    case 'X' : return 'ñ';
  1016. ,    case '"' : return '¿';
  1017. ,    case 'x' : return '╫';
  1018. ,    case ':' : return '≈';
  1019. ,#endif
  1020. ,#ifdef dec_sup
  1021. ,    case 'X' : return '¿'; /* ñ */
  1022. ,#endif
  1023. ,#endif
  1024. ,    default: return c;
  1025. ,  }
  1026. ,}
  1027. ,
  1028. ,grave (ch)
  1029. ,  u_char ch;
  1030. ,{
  1031. ,    switch (ch) {
  1032. ,#ifdef pc_charset
  1033. ,        case 'A' : return 183;
  1034. ,        case 'E' : return 212;
  1035. ,        case 'I' : return 222;
  1036. ,        case 'O' : return 227;
  1037. ,        case 'U' : return 235;
  1038. ,        case 'a' : return 133;
  1039. ,        case 'e' : return 138;
  1040. ,        case 'i' : return 141;
  1041. ,        case 'o' : return 149;
  1042. ,        case 'u' : return 151;
  1043. ,#else
  1044. ,        case 'A' : return '└';
  1045. ,        case 'E' : return '╚';
  1046. ,        case 'I' : return '╠';
  1047. ,        case 'O' : return '╥';
  1048. ,        case 'U' : return '┘';
  1049. ,        case 'a' : return 'α';
  1050. ,        case 'e' : return 'Φ';
  1051. ,        case 'i' : return '∞';
  1052. ,        case 'o' : return '≥';
  1053. ,        case 'u' : return '∙';
  1054. ,#endif
  1055. ,        default : return diacritic (ch);
  1056. ,    }
  1057. ,}
  1058. ,circumflex (ch)
  1059. ,  u_char ch;
  1060. ,{
  1061. ,    switch (ch) {
  1062. ,#ifdef pc_charset
  1063. ,        case 'A' : return 182;
  1064. ,        case 'E' : return 210;
  1065. ,        case 'I' : return 215;
  1066. ,        case 'O' : return 226;
  1067. ,        case 'U' : return 234;
  1068. ,        case 'a' : return 131;
  1069. ,        case 'e' : return 136;
  1070. ,        case 'i' : return 140;
  1071. ,        case 'o' : return 147;
  1072. ,        case 'u' : return 150;
  1073. ,#else
  1074. ,        case 'A' : return '┬';
  1075. ,        case 'E' : return '╩';
  1076. ,        case 'I' : return '╬';
  1077. ,        case 'O' : return '╘';
  1078. ,        case 'U' : return '█';
  1079. ,        case 'a' : return 'Γ';
  1080. ,        case 'e' : return 'Ω';
  1081. ,        case 'i' : return 'ε';
  1082. ,        case 'o' : return '⌠';
  1083. ,        case 'u' : return '√';
  1084. ,#endif
  1085. ,        default : return diacritic (ch);
  1086. ,    }
  1087. ,}
  1088. ,acute (ch)
  1089. ,  u_char ch;
  1090. ,{
  1091. ,    switch (ch) {
  1092. ,#ifdef pc_charset
  1093. ,        case 'A' : return 181;
  1094. ,        case 'E' : return 144;
  1095. ,        case 'I' : return 214;
  1096. ,        case 'O' : return 224;
  1097. ,        case 'U' : return 233;
  1098. ,        case 'a' : return 160;
  1099. ,        case 'e' : return 130;
  1100. ,        case 'i' : return 161;
  1101. ,        case 'o' : return 162;
  1102. ,        case 'u' : return 163;
  1103. ,        case 'Y' : return 237;
  1104. ,        case 'y' : return 236;
  1105. ,        case ' ' : return 239;
  1106. ,#else
  1107. ,        case 'A' : return '┴';
  1108. ,        case 'E' : return '╔';
  1109. ,        case 'I' : return '═';
  1110. ,        case 'O' : return '╙';
  1111. ,        case 'U' : return '┌';
  1112. ,        case 'a' : return 'ß';
  1113. ,        case 'e' : return 'Θ';
  1114. ,        case 'i' : return 'φ';
  1115. ,        case 'o' : return '≤';
  1116. ,        case 'u' : return '·';
  1117. ,        case ' ' : return '┤';
  1118. ,#ifdef iso_latin_1
  1119. ,        case 'Y' : return '▌';
  1120. ,        case 'y' : return '²';
  1121. ,#endif
  1122. ,#endif
  1123. ,        default : return diacritic (ch);
  1124. ,    }
  1125. ,}
  1126. ,diaeresis (ch)
  1127. ,  u_char ch;
  1128. ,{
  1129. ,    switch (ch) {
  1130. ,#ifdef pc_charset
  1131. ,        case 'A' : return 142;
  1132. ,        case 'E' : return 211;
  1133. ,        case 'I' : return 216;
  1134. ,        case 'O' : return 153;
  1135. ,        case 'U' : return 154;
  1136. ,        case 'a' : return 132;
  1137. ,        case 'e' : return 137;
  1138. ,        case 'i' : return 139;
  1139. ,        case 'o' : return 148;
  1140. ,        case 'u' : return 129;
  1141. ,        case 'y' : return 152;
  1142. ,        case ' ' : return 249;
  1143. ,#else
  1144. ,        case 'A' : return '─';
  1145. ,        case 'E' : return '╦';
  1146. ,        case 'I' : return '╧';
  1147. ,        case 'O' : return '╓';
  1148. ,        case 'U' : return '▄';
  1149. ,        case 'a' : return 'Σ';
  1150. ,        case 'e' : return 'δ';
  1151. ,        case 'i' : return '∩';
  1152. ,        case 'o' : return '÷';
  1153. ,        case 'u' : return 'ⁿ';
  1154. ,#ifdef iso_latin_1
  1155. ,        case ' ' : return '¿';
  1156. ,        case 'y' : return '\377'; /* ' ' aborts sun compiler */
  1157. ,#endif
  1158. ,#ifdef dec_sup
  1159. ,        case 'Y' : return '▌'; /* capital   */
  1160. ,        case 'y' : return '²'; /*   */
  1161. ,#endif
  1162. ,#endif
  1163. ,        default : return diacritic (ch);
  1164. ,    }
  1165. ,}
  1166. ,tilde (ch)
  1167. ,  u_char ch;
  1168. ,{
  1169. ,    switch (ch) {
  1170. ,#ifdef pc_charset
  1171. ,        case 'A' : return 199;
  1172. ,        case 'O' : return 229;
  1173. ,        case 'a' : return 198;
  1174. ,        case 'o' : return 228;
  1175. ,#else
  1176. ,        case 'A' : return '├';
  1177. ,        case 'O' : return '╒';
  1178. ,        case 'a' : return 'π';
  1179. ,        case 'o' : return '⌡';
  1180. ,#ifdef dec_sup
  1181. ,        case 'E' : return '╫'; /* OE */
  1182. ,        case 'e' : return '≈'; /* oe */
  1183. ,#endif
  1184. ,#endif
  1185. ,        default : return diacritic (ch);
  1186. ,    }
  1187. ,}
  1188. ,angstrom (ch)
  1189. ,  u_char ch;
  1190. ,{
  1191. ,    switch (ch) {
  1192. ,#ifdef pc_charset
  1193. ,        case 'A' : return 143;
  1194. ,        case 'E' : return 146;
  1195. ,        case 'O' : return 157;
  1196. ,        case 'a' : return 134;
  1197. ,        case 'e' : return 145;
  1198. ,        case 'o' : return 155;
  1199. ,#else
  1200. ,        case 'A' : return '┼';
  1201. ,        case 'E' : return '╞';
  1202. ,        case 'O' : return '╪';
  1203. ,        case 'a' : return 'σ';
  1204. ,        case 'e' : return 'µ';
  1205. ,        case 'o' : return '°';
  1206. ,#endif
  1207. ,        default : return diacritic (ch);
  1208. ,    }
  1209. ,}
  1210. ,
  1211. ,/*  ==================================================================    *
  1212. , *        key and function key -> command mapping            *
  1213. , *  ==================================================================    */
  1214. ,
  1215. ,/* The mapping between input codes and functions */
  1216. ,
  1217. ,extern MUP (), MDN (), MLF (), MRT (), MNW (), MPW (), GOTO (), GOMA ();
  1218. ,extern SD (), SU (), PD (), PU (), HOME (), EF (), BL (), EL (), HIGH (), LOW ();
  1219. ,extern S (), SNL (), LIB (), DPC (), DCC (), DLN (), DNW (), DPW (), CTRl ();
  1220. ,extern QUED (), WT (), EDIT (), RD (), SH (), I (), FS (), REPT ();
  1221. ,extern SFW (), SRV (), RS (), LR (), GR (), REPL ();
  1222. ,extern MARK (), YA (), DT (), PT (), WB (), INF ();
  1223. ,extern HOP (), CANCEL (), ESCAPE (), HELP (), BAD (), FUNKEY (), DIRECT ();
  1224. ,extern EXED (), VIEW ();
  1225. ,
  1226. ,#ifdef unix
  1227. ,#define NULLcmd BAD
  1228. ,#define BSPcmd MLF
  1229. ,#endif
  1230. ,#ifdef msdos
  1231. ,#define NULLcmd FUNKEY    /* since FUNcmd is 0 */
  1232. ,#define BSPcmd DPC
  1233. ,#endif
  1234. ,#ifdef vms
  1235. ,#define NULLcmd ESCAPE
  1236. ,#define BSPcmd MLF
  1237. ,#endif
  1238. ,
  1239. ,int (* key_map [256]) () =
  1240. ,{    /* characters to functions map */
  1241. ,   /* 000-017 */ NULLcmd, MPW, DCC, PD, MRT, MUP, MNW, GOTO,
  1242. ,         BSPcmd, S, S, DLN, HOP, SNL, RS, LIB,
  1243. ,   /* 020-037 */ PT, HOP, PU, MLF, DNW, DT, CTRl, SU,
  1244. ,         MDN, YA, SD, ESCAPE, CANCEL, MARK, DPW, BAD,
  1245. ,   /* 040-057 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
  1246. ,   /* 060-077 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
  1247. ,   /* 100-117 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
  1248. ,   /* 120-137 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
  1249. ,   /* 140-157 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
  1250. ,   /* 160-177 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, DPC,
  1251. ,#ifdef msdos
  1252. ,   /* 200-217 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
  1253. ,   /* 220-237 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
  1254. ,#else
  1255. ,   /* 200-217 */ FUNKEY, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
  1256. ,   /* 220-237 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
  1257. ,#endif
  1258. ,   /* 240-257 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
  1259. ,   /* 260-277 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
  1260. ,   /* 300-317 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
  1261. ,   /* 320-337 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
  1262. ,   /* 340-357 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
  1263. ,   /* 360-377 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
  1264. ,};
  1265. ,
  1266. ,#ifdef msdos
  1267. ,/*
  1268. ,function keys deliver NUL and the following codes:
  1269. ,Block1: RGISOQHKPM
  1270. ,Block2: GHIKMOPQRS    Pos1 Up PgUp Left Center Right End Down PdDn Ins
  1271. ,Cntrl:    st <-/->
  1272. ,Cntrl:    wu Pos1/End
  1273. ,    Σv PgUp / PgDn
  1274. ,F1-F10: ;<=>?@ABCD
  1275. ,shift:    TUVWXYZ[\]
  1276. ,cntrl:    ^_`abcdefg
  1277. ,alt:    hijklmnopq
  1278. ,*/
  1279. ,
  1280. ,HELPF ()
  1281. ,{ status_msg ("       F2 write  F3 edit  F6 \357  F7 \371  F8 search      F9 next  F10 hop"); }
  1282. ,HELPS ()
  1283. ,{ status_msg ("shift- F2 exit            F6 `  F7 ~  F8 search rev  F9 next  F10 hop"); }
  1284. ,HELPC ()
  1285. ,{ status_msg ("cntrl- F2 write  F3 view  F6 ^  F7 \370  F8 search next          F10 hop"); }
  1286. ,HELPA ()
  1287. ,{ status_msg ("alt-   F2 write buffer                F8 search rev           F10 hop"); }
  1288. ,
  1289. ,int (* pc_key_map [256]) () =
  1290. ,{    /* function characters to functions map */
  1291. ,   /* 000-017 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
  1292. ,   /* 020-037 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
  1293. ,   /* 040-057 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
  1294. ,   /* 060-077 */ I, I, I, I, I, I, I, I, I, I, I, HELPF, WT, EDIT, I, I,
  1295. ,   /* 100-117 */ acute, diaeresis, SFW, RS, GOTO, I, I, MARK, MUP, PU, I, MLF, HOP, MRT, I, YA,
  1296. ,   /* 120-137 */ MDN, PD, PT, DCC, HELPS, EXED, I, I, I, grave, tilde, SRV, RS, GOTO, HELPC, WT,
  1297. ,   /* 140-157 */ VIEW, I, I, circumflex, angstrom, RS, I, GOTO, HELPA, WB, I, I, I, I, I, SRV,
  1298. ,   /* 160-177 */ I, GOTO, I, MPW, MNW, DT, SD, HOP, I, I, I, I, I, I, I, I,
  1299. ,   /* 200-217 */ I, I, I, I, SU, I, I, I, I, I, I, I, I, I, I, I,
  1300. ,   /* 220-237 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
  1301. ,   /* 240-257 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
  1302. ,   /* 260-277 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
  1303. ,   /* 300-317 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
  1304. ,   /* 320-337 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
  1305. ,   /* 340-357 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
  1306. ,   /* 360-377 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I
  1307. ,};
  1308. ,#endif
  1309. ,
  1310. ,#ifndef msdos
  1311. ,
  1312. ,/* The mapping between function key sequences and functions */
  1313. ,
  1314. ,struct {char * fk; int (* fp) ();} keycode [] =
  1315. ,{    /* Escape-key sequences of function keys */
  1316. ,    /* VT100 and SUN */
  1317. ,    "\033[A",    MUP,    /* move cursor up    */
  1318. ,    "\033[B",    MDN,    /* more cursor down    */
  1319. ,    "\033[C",    MRT,    /* more cursor right    */
  1320. ,    "\033[D",    MLF,    /* more cursor left    */
  1321. ,    /* SUN raw keycodes */
  1322. ,    "\033[215z",    MUP,    /* move cursor up    */
  1323. ,    "\033[221z",    MDN,    /* more cursor down    */
  1324. ,    "\033[219z",    MRT,    /* more cursor right    */
  1325. ,    "\033[217z",    MLF,    /* more cursor left    */
  1326. ,    /* VT100 */
  1327. ,    "\033[6~",    PD,    /* Next Screen    */
  1328. ,    "\033[5~",    PU,    /* Prev Screen    */
  1329. ,    "\033[4~",    MARK,    /* Select    */
  1330. ,    "\033[3~",    DT,    /* Remove    */
  1331. ,    "\033[2~",    PT,    /* Insert Here    */
  1332. ,    "\033[1~",    SFW,    /* Find        */
  1333. ,    "\033[29~",    YA,    /* Do        */
  1334. ,    "\033[28~",    HELP,    /* Help        */
  1335. ,    "\033[17~",    diaeresis, /* F6    */
  1336. ,    "\033[18~",    diaeresis, /* F7    */
  1337. ,    "\033[19~",    SFW,    /* F8    */
  1338. ,    "\033[20~",    RS,    /* F9    */
  1339. ,    "\033[21~",    I,    /* F10    */
  1340. ,    "\033[23~",    I,    /* F11    */
  1341. ,    "\033[24~",    I,    /* F12    */
  1342. ,    "\033[25~",    I,    /* F13    */
  1343. ,    "\033[26~",    I,    /* F14    */
  1344. ,    "\033[31~",    I,    /* F17    */
  1345. ,    "\033[32~",    I,    /* F18    */
  1346. ,    "\033[33~",    I,    /* F19    */
  1347. ,    "\033[34~",    I,    /* F20    */
  1348. ,    "\033OP",    HOP,    /* PF1    */
  1349. ,    "\033OQ",    SU,    /* PF2    */
  1350. ,    "\033OR",    SD,    /* PF3    */
  1351. ,    "\033OS",    I,    /* PF4    */
  1352. ,    /* SUN */
  1353. ,    "\033[208z",    grave,        /* R1 */
  1354. ,    "\033[209z",    circumflex,    /* R2 */
  1355. ,    "\033[210z",    acute,        /* R3 */
  1356. ,    "\033[211z",    diaeresis,    /* R4 */
  1357. ,    "\033[212z",    tilde,        /* R5 */
  1358. ,    "\033[213z",    angstrom,    /* R6 */
  1359. ,    "\033[214z",    SU,    /* R7    */
  1360. ,    "\033[216z",    PU,    /* R9    */
  1361. ,    "\033[218z",    HOP,    /* R11    */
  1362. ,    "\033[220z",    SD,    /* R13    */
  1363. ,    "\033[222z",    PD,    /* R15    */
  1364. ,    "\033[254z",    GOMA,    /* - */
  1365. ,    "\033[253z",    MARK,    /* + */
  1366. ,    "\033[250z",    YA,    /* Enter */
  1367. ,    "\033[249z",    DT,    /* Del */
  1368. ,    "\033[247z",    PT,    /* Ins */
  1369. ,    "\033[2z",        PT,    /* Ins (NeWS) */
  1370. ,    "\033[192z",    MARK,    /* Stop */
  1371. ,    "\033[193z",    I,    /* Again */
  1372. ,    "\033[194z",    FS,    /* Props */
  1373. ,    "\033[195z",    I,    /* Undo */
  1374. ,    "\033[197z",    YA,    /* Copy */
  1375. ,    "\033[199z",    PT,    /* Paste */
  1376. ,    "\033[200z",    RS,    /* Find */
  1377. ,    "\033[201z",    DT,    /* Cut */
  1378. ,    "\033[196z",    HELP,    /* Help */
  1379. ,    "\033[225z",    I,    /* F2 */
  1380. ,    "\033[226z",    I,    /* F3 */
  1381. ,    "\033[227z",    I,    /* F4 */
  1382. ,    "\033[228z",    I,    /* F5 */
  1383. ,    "\033[229z",    PU,    /* F6 */
  1384. ,    "\033[230z",    PD,    /* F7 */
  1385. ,    "\033[231z",    SFW,    /* F8 */
  1386. ,    "\033[232z",    RS,    /* F9 */
  1387. ,    "\033[233z",    I,    /* F10 */
  1388. ,    "\033[234z",    I,    /* F11 */
  1389. ,    "\033[235z",    I,    /* F12 */
  1390. ,    /* Iris */
  1391. ,    "\033[209q",    MARK,    /* Print Screen */
  1392. ,    "\033[213q",    YA,    /* Scroll Lock */
  1393. ,/*    "\033[217q",    I,    /* Pause */
  1394. ,    "\033[139q",    PT,    /* Insert, Ins */
  1395. ,    "\033[P",    DT,    /* Del */
  1396. ,    "\033[H",    SU,    /* Home */
  1397. ,    "\033[150q",    PU,    /* PgUp */
  1398. ,    "\033[146q",    SD,    /* End */
  1399. ,    "\033[154q",    PD,    /* PgDn */
  1400. ,    "\033[000q",    HOP,    /* 5 */
  1401. ,    "\033[001q",    I,    /* F1 */
  1402. ,    "\033[002q",    I,    /* F2 */
  1403. ,    "\033[005q",    I,    /* F5 */
  1404. ,    "\033[006q",    I,    /* F6 */
  1405. ,    "\033[007q",    I,    /* F7 */
  1406. ,    "\033[008q",    SFW,    /* F8 */
  1407. ,    "\033[009q",    RS,    /* F9 */
  1408. ,    "\033[022q",    grave,        /* Shift-F10 */
  1409. ,    "\033[023q",    circumflex,    /* Shift-F11 */
  1410. ,    "\033[024q",    acute,        /* Shift-F12 */
  1411. ,    "\033[010q",    diaeresis,    /* F10 */
  1412. ,    "\033[011q",    tilde,        /* F11 */
  1413. ,    "\033[012q",    angstrom,    /* F12 */
  1414. ,    /* VT100 emulator at IBM-PC */
  1415. ,    "\033M",        PU,    /* Pg Up */
  1416. ,    "\033D",        PD,    /* Pg Dn */
  1417. ,/*    "\033[H",        SU,    /* Home    , same at Iris */
  1418. ,    "\033[24;1H",    SD,    /* End    */
  1419. ,    "\0331",        HOP,    /* Ins    */
  1420. ,        /* cursor keys and F1-4 same as VT100 */
  1421. ,    /* crttool */
  1422. ,    "\033m",        DIRECT,    /* direct cursor address */
  1423. ,    NIL_PTR
  1424. ,};
  1425. ,
  1426. ,#define MAXCODELEN 7 /* max. length of function key sequence to be detected, 
  1427. ,            depending on the keycode table => used in mined1.c */
  1428. ,
  1429. ,#endif
  1430. ,
  1431. ,/*  ==================================================================    *
  1432. , *                End                    *
  1433. , *  ==================================================================    */
  1434. EOSED
  1435.  
  1436. echo ---------------------- extracting mined.h -----------------
  1437. sed 's/^,//' << \EOSED > mined.h
  1438. ,/*  ====================================================================  *
  1439. , *                Mined.h                      *
  1440. , *  ====================================================================  */
  1441. ,
  1442. ,#ifndef minedH
  1443. ,#define minedH
  1444. ,
  1445. ,#define msdos
  1446. ,#ifdef unix
  1447. ,#  undef msdos
  1448. ,#endif
  1449. ,#ifdef vms
  1450. ,#  undef msdos
  1451. ,#endif
  1452. ,
  1453. ,#ifdef msdos
  1454. ,/* With Turbo-C, compile with memory model >= Compact */
  1455. ,/* #define conio doesn't work with current combined positioning/output method */
  1456. ,extern far * getenv ();
  1457. ,extern far * getcwd ();
  1458. ,#  define u_char unsigned char
  1459. ,#  include <fcntl.h>
  1460. ,#  define abort()    exit (1)
  1461. ,#  define FUNcmd    '\000'
  1462. ,#endif
  1463. ,
  1464. ,#ifdef vms
  1465. ,#  define u_char unsigned char
  1466. ,#  include <unixio.h>
  1467. ,#  include <file.h>    /* for the O_... attributes to open () */
  1468. ,#  include <unixlib.h>
  1469. ,#  undef putchar
  1470. ,#  undef FALSE
  1471. ,#  undef TRUE
  1472. ,#  define CURSES
  1473. ,#  define FUNcmd    '\200'
  1474. ,#endif
  1475. ,
  1476. ,#ifdef unix
  1477. ,#  include <stdio.h>
  1478. ,#  include <fcntl.h>
  1479. ,#  undef putchar
  1480. ,#  undef NULL
  1481. ,#  undef EOF
  1482. ,#  define FUNcmd    '\200'
  1483. ,#endif
  1484. ,
  1485. ,/*------------------------------------------------------------------------*/
  1486. ,
  1487. ,extern clear_screen ();
  1488. ,extern clear_eol ();
  1489. ,extern scroll_forward ();
  1490. ,extern scroll_reverse ();
  1491. ,extern add_line (/* y */);
  1492. ,extern delete_line (/* y */);
  1493. ,extern move_cursor (/* x, y */);
  1494. ,extern reverse_on ();
  1495. ,extern reverse_off ();
  1496. ,extern start_screen_mode ();
  1497. ,extern end_screen_mode ();
  1498. ,extern get_term ();
  1499. ,extern getwinsize ();
  1500. ,extern inputreadyafter ();
  1501. ,extern __readchar ();
  1502. ,
  1503. ,/*------------------------------------------------------------------------*/
  1504. ,
  1505. ,/* Set cursor at coordinates x, y */
  1506. ,#define set_cursor(nx, ny)    move_cursor(nx, ny)
  1507. ,
  1508. ,/* Screen size and display definitions. Coordinates start at 0, 0 */
  1509. ,#ifdef msdos
  1510. ,#  define maxYMAX        64
  1511. ,#  define maxXMAX        132
  1512. ,#else
  1513. ,#  define maxYMAX        126    /* 73 */
  1514. ,#  define maxXMAX        279    /* 163 */
  1515. ,#endif
  1516. ,
  1517. ,extern short YMAX;
  1518. ,extern short XMAX;
  1519. ,#define SCREENMAX    (YMAX - 1)    /* last line displayed (first is 0) */
  1520. ,#define XBREAK        (XMAX - 1)    /* Shift line display at this column */
  1521. ,#define SHIFT_SIZE    25        /* Number of chars to shift */
  1522. ,#define maxLINE_LEN    (maxXMAX + 1)    /* max screen line length */
  1523. ,#define screen_BUFL    (maxXMAX * maxYMAX)    /* Size of I/O buffering */
  1524. ,
  1525. ,#define MAX_CHARS    1024        /* max chars on one line of text */
  1526. ,        /* LINE_START must be rounded up to the lowest SHIFT_SIZE */
  1527. ,#define LINE_START    (((-MAX_CHARS - 1) / SHIFT_SIZE) * SHIFT_SIZE \
  1528. ,                     - SHIFT_SIZE)
  1529. ,#define LINE_END    (MAX_CHARS + 1)    /* Highest x-coordinate for line */
  1530. ,
  1531. ,#define BLOCK_SIZE    1024
  1532. ,
  1533. ,/* Return values of functions */
  1534. ,#define ERRORS        -1
  1535. ,#define NO_LINE        (ERRORS - 1)    /* Must be < 0 */
  1536. ,#define FINE         (ERRORS + 1)
  1537. ,#define NO_INPUT    (ERRORS + 2)
  1538. ,
  1539. ,#define STD_IN        0        /* Input file # */
  1540. ,#define STD_OUT         1        /* Terminal output file # */
  1541. ,#define STD_ERR        2
  1542. ,
  1543. ,#define REPORT    2        /* Report change of lines on # lines */
  1544. ,
  1545. ,/*
  1546. , * Common enum type for all flags used in mined.
  1547. , */
  1548. ,typedef enum {
  1549. ,/* General flags */
  1550. ,  FALSE,
  1551. ,  TRUE,
  1552. ,  OFF,
  1553. ,  ON,
  1554. ,/* yank_status and other */
  1555. ,  NOT_VALID,
  1556. ,  VALID,
  1557. ,
  1558. ,/* Expression flags */
  1559. ,  FORWARD,
  1560. ,  REVERSE,
  1561. ,
  1562. ,/* Yank flags */
  1563. ,  SMALLER,
  1564. ,  BIGGER,
  1565. ,  SAME,
  1566. ,/*  EMPTY, */
  1567. ,  NO_DELETE,
  1568. ,  DELETE,
  1569. ,  READ,
  1570. ,  WRITE
  1571. ,} FLAG;
  1572. ,
  1573. ,/*
  1574. , * The Line structure. Each line entry contains a pointer to the next line,
  1575. , * a pointer to the previous line, a pointer to the text and an unsigned char
  1576. , * telling at which offset of the line printing should start (usually 0).
  1577. , */
  1578. ,struct Line {
  1579. ,  struct Line * next;
  1580. ,  struct Line * prev;
  1581. ,  char * text;
  1582. ,  unsigned char shift_count;
  1583. ,};
  1584. ,
  1585. ,typedef struct Line LINE;
  1586. ,
  1587. ,/* Dummy line indicator */
  1588. ,#define DUMMY        0x80
  1589. ,#define DUMMY_MASK    0x7F
  1590. ,
  1591. ,/* Expression definitions */
  1592. ,#define NO_MATCH    0
  1593. ,#define MATCH        1
  1594. ,#define REG_ERROR    2
  1595. ,
  1596. ,#define BEGIN_LINE    (2 * REG_ERROR)
  1597. ,#define END_LINE    (2 * BEGIN_LINE)
  1598. ,
  1599. ,/*
  1600. , * The regex structure. Status can be any of 0, BEGIN_LINE or REG_ERROR. In
  1601. , * the last case, the result.err_mess field is assigned. Start_ptr and end_ptr
  1602. , * point to the match found. For more details see the documentation file.
  1603. , */
  1604. ,struct regex {
  1605. ,  union {
  1606. ,      char * err_mess;
  1607. ,      int * expression;
  1608. ,  } result;
  1609. ,  char status;
  1610. ,  char * start_ptr;
  1611. ,  char * end_ptr;
  1612. ,};
  1613. ,
  1614. ,typedef struct regex REGEX;
  1615. ,
  1616. ,/* NULL definitions */
  1617. ,#define NIL_PTR        ((char *) 0)
  1618. ,#define NIL_LINE    ((LINE *) 0)
  1619. ,#define NIL_REG        ((REGEX *) 0)
  1620. ,#define NIL_INT        ((int *) 0)
  1621. ,
  1622. ,/*
  1623. , * Forward declarations
  1624. , */
  1625. ,extern int nlines;        /* Number of lines in file */
  1626. ,extern LINE * header;        /* Head of line list */
  1627. ,extern LINE * tail;        /* Last line in line list */
  1628. ,extern LINE * top_line;        /* First line of screen */
  1629. ,extern LINE * bot_line;        /* Last line of screen */
  1630. ,extern LINE * cur_line;        /* Current line in use */
  1631. ,extern char * cur_text;        /* Pointer to char on current line in use */
  1632. ,extern int last_y;        /* Last y of screen, usually SCREENMAX */
  1633. ,
  1634. ,extern int x, y;        /* x, y coordinates on screen */
  1635. ,extern FLAG modified;        /* Set when file is modified */
  1636. ,extern FLAG viewonly;        /* Set when view only mode is selected */
  1637. ,extern FLAG quit;        /* Set when quit character is typed */
  1638. ,extern FLAG intr;        /* Set when intr character is typed */
  1639. ,extern FLAG winchg;        /* Set when the window size changes */
  1640. ,extern FLAG waitingforinput;    /* Set while waiting for the next command key */
  1641. ,extern FLAG isscreenmode;    /* Set when screen mode is on */
  1642. ,extern int out_count;        /* Index in output buffer */
  1643. ,extern char text_buffer [MAX_CHARS];    /* Buffer for modifying text */
  1644. ,extern int input_fd;        /* File descriptors for terminal dialog */
  1645. ,extern int output_fd;
  1646. ,extern char SHIFT_MARK;
  1647. ,extern char blank_line [];    /* For line clearance, in case terminal cannot do it */
  1648. ,extern int fprot;        /* To be used for all file creatings */
  1649. ,
  1650. ,extern char yank_file [];    /* Temp. file for buffer */
  1651. ,extern char yankie_file [];    /* Temp. file for inter-window buffer */
  1652. ,extern char panic_file [];    /* file for panic-write-back */
  1653. ,extern FLAG yank_status;    /* Status of yank_file */
  1654. ,extern long chars_saved;    /* # of chars saved in buffer */
  1655. ,
  1656. ,extern int hop_flag;        /* set to 2 by HOP key function */
  1657. ,
  1658. ,extern FLAG can_add_line, can_delete_line, can_clear_eol;
  1659. ,extern FLAG cansuspendmyself;
  1660. ,extern char * get_line_err1;
  1661. ,extern char * get_line_err2;
  1662. ,extern char * serror ();
  1663. ,extern char * serrorof ();
  1664. ,extern int geterrno ();
  1665. ,
  1666. ,extern LINE * proceed ();
  1667. ,extern LINE * match ();
  1668. ,extern LINE * line_insert ();
  1669. ,extern char * num_out ();
  1670. ,extern get_digits ();
  1671. ,extern char * basename ();
  1672. ,extern u_char promptyn ();
  1673. ,extern FLAG checkoverwrite ();
  1674. ,extern delete_file ();
  1675. ,extern char * unnull ();
  1676. ,
  1677. ,#define putchar(c)    __putchar (c)
  1678. ,extern __putchar ();    /* do not use _putchar! it may conflict with curses */
  1679. ,extern writechar ();
  1680. ,extern putstring ();
  1681. ,extern writestring ();
  1682. ,extern flush ();
  1683. ,extern flush_buffer ();
  1684. ,
  1685. ,extern char * alloc ();
  1686. ,
  1687. ,/*
  1688. , * String functions
  1689. , */
  1690. ,#define streq(s1, s2)        (strcmp (s1, s2) == 0)
  1691. ,#define strisprefix(s1, s2)    (strncmp (s2, s1, strlen (s1)) == 0)
  1692. ,
  1693. ,/*
  1694. , * Empty output buffer
  1695. , */
  1696. ,#define clear_buffer()        (out_count = 0)
  1697. ,
  1698. ,/*
  1699. , * Ring bell on terminal
  1700. , */
  1701. ,#define ring_bell()        putchar ('\07')
  1702. ,
  1703. ,#ifdef UNUSED    /* putchar, putstring, flush, and #include <curses.h> 
  1704. ,           are now in minedio.c */
  1705. ,/*
  1706. , * Print character on terminal    - obsolete due to new putchar macro
  1707. , */
  1708. ,#ifdef CURSES
  1709. ,#  define putchar(c)        addch (c)
  1710. ,#else
  1711. ,#  define putchar(c)        writechar (output_fd, (c))
  1712. ,#endif
  1713. ,/*
  1714. , * Print string on terminal
  1715. , */
  1716. ,#ifdef CURSES
  1717. ,#  define putstring(str)    addstr (str)
  1718. ,#else
  1719. ,#  define putstring(str)    writestring (output_fd, (str))
  1720. ,#endif
  1721. ,/*
  1722. , * Flush output buffer
  1723. , */
  1724. ,#ifdef CURSES
  1725. ,#  define flush()        refresh ()
  1726. ,#else
  1727. ,#  define flush()        flush_buffer (output_fd)
  1728. ,#endif
  1729. ,
  1730. ,#endif UNUSED
  1731. ,
  1732. ,/*
  1733. , * Print line on terminal at offset 0 and clear tail of line
  1734. , */
  1735. ,#define line_print(line)    put_line (line, 0, TRUE)
  1736. ,
  1737. ,/*
  1738. , * Functions handling status_line. ON means in reverse video.
  1739. , */
  1740. ,#define status_msg(str)        status_line (str, NIL_PTR)
  1741. ,#define status_line(str1, str2)        \
  1742. ,    bottom_line (ON, (str1), (str2), NIL_PTR, FALSE)
  1743. ,#define status_beg(str)            \
  1744. ,    bottom_line (ON, (str), NIL_PTR, NIL_PTR, TRUE)
  1745. ,#define error(str1, str2)        \
  1746. ,    bottom_line (ON, (str1), (str2), NIL_PTR, FALSE)
  1747. ,#define get_string(str1, str2, fl)    \
  1748. ,    bottom_line (ON, (str1), NIL_PTR, (str2), fl)
  1749. ,#define clear_status()            \
  1750. ,    bottom_line (OFF, NIL_PTR, NIL_PTR, NIL_PTR, FALSE)
  1751. ,
  1752. ,/*
  1753. , * Print info about current file and buffer.
  1754. , */
  1755. ,#define fstatus(mess, cnt)    \
  1756. ,    file_status ((mess), (cnt), file_name, nlines, writable, modified, viewonly)
  1757. ,
  1758. ,/*
  1759. , * Build formatted string.
  1760. , * If this definition is left out, a routine will be defined in mined1.c.
  1761. , */
  1762. ,#define build_string sprintf /**/
  1763. ,
  1764. ,/*
  1765. , * Get real shift value.
  1766. , */
  1767. ,#define get_shift(cnt)        ((cnt) & DUMMY_MASK)
  1768. ,
  1769. ,/*
  1770. , * Special character.
  1771. , */
  1772. ,#define QUITCHAR '\034' /* ^\ */
  1773. ,
  1774. ,/*------------------------------------------------------------------------*/
  1775. ,#endif
  1776. ,/*------------------------------------------------------------------------*/
  1777. EOSED
  1778.  
  1779. echo ---------------------- extracting mined.c -----------------
  1780. sed 's/^,//' << \EOSED > mined.c
  1781. ,/* mined single compilation version for my attempts with Turbo-C
  1782. ,   (since I don't know how to compile separately with it)
  1783. , */
  1784. ,
  1785. ,#define single_pass_compilation
  1786. ,#include "minedmp.c"
  1787. ,#include "mined1.c"
  1788. ,#include "mined2.c"
  1789. ,#include "minedio.c"
  1790. EOSED
  1791.  
  1792. echo ---------------------- extracting mined.prj -----------------
  1793. sed 's/^,//' << \EOSED > mined.prj
  1794. ,mined1.c
  1795. ,mined2.c
  1796. ,minedio.c
  1797. ,minedmp.c
  1798. EOSED
  1799.  
  1800. exit 0
  1801.  
  1802.