home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / drdobbs / 1988 / 12 / twp.asc < prev   
Text File  |  1988-12-31  |  19KB  |  746 lines

  1. _C PROGRAMMING COLUMN_
  2. by Al Stevens
  3.  
  4. [LISTING 1]
  5.  
  6. /* ------------ help.h -------------- */
  7.  
  8. void load_help(char *);
  9. void display_help(void);
  10.  
  11. extern char *help_window;
  12. #define set_help(s) help_window=s
  13.  
  14.  
  15. [LISTING 2]
  16.  
  17. /* --------- help.c ----------- */
  18.  
  19. #include <stdio.h>
  20. #include <string.h>
  21. #include <stdlib.h>
  22. #include <conio.h>
  23. #include "window.h"
  24. #include "menu.h"
  25. #include "entry.h"
  26. #include "help.h"
  27.  
  28. #define MAXHELPS 25
  29.  
  30. static struct helps {
  31.     char hname [9];
  32.     int h, w;
  33.     long hptr;
  34. } hps [MAXHELPS+1];
  35.  
  36. extern FIELD *fld;
  37. extern MENU *mn;
  38.  
  39. static int hp = 0;
  40. static FILE *helpfp;
  41. static char hline [80];
  42. char *help_window;
  43.  
  44. /* ----------- load the HELP! definition file ------------ */
  45. void load_help(char *hn)
  46. {
  47.     extern void (*helpfunc)(void);
  48.     extern int helpkey;
  49.     char *cp;
  50.  
  51.     helpfunc = display_help;
  52.     helpkey = F1;
  53.     hp = 0;
  54.     if ((helpfp = fopen(hn, "r")) == NULL)
  55.         return;
  56.     if ((fgets(hline, 80, helpfp)) == NULL)
  57.         return;
  58.     while (1)   {
  59.         if (hp == MAXHELPS)
  60.             break;
  61.         if (strncmp(hline, "<end>", 5) == 0)
  62.             break;
  63.         if (*hline != '<')
  64.             continue;
  65.         hps[hp].h = 2;
  66.         hps[hp].w = 23;
  67.         strncpy(hps[hp].hname, hline+1, 8);
  68.         hps[hp].hname[8] = '\0';
  69.         cp = strchr(hps[hp].hname, '>');
  70.         if (cp)
  71.             *cp = '\0';
  72.         hps[hp].hptr = ftell(helpfp);
  73.         if (fgets(hline, 80, helpfp) == NULL)
  74.             strcpy(hline, "<end>");
  75.         while (hline[0] != '<') {
  76.             hps[hp].h++;
  77.             hps[hp].w = max(hps[hp].w, strlen(hline)+2);
  78.         if (fgets(hline, 80, helpfp) == NULL)
  79.             strcpy(hline, "<end>");
  80.         }
  81.         hp++;
  82.     }
  83. }
  84.  
  85. /* ---------- display the current help window ----------- */
  86. void display_help()
  87. {
  88.     int hx, hy, i, xx, yy, ch;
  89.     extern int helpkey, hsel;
  90.     char *save_help;
  91.     static int inhelp = 0;
  92.     extern struct wn wkw;
  93.  
  94.     if (inhelp)
  95.         return;
  96.     inhelp++;
  97.     save_help = help_window;
  98.     if (fld != NULL)
  99.         help_window = fld->fhelp;
  100.     else if (mn != NULL)
  101.         help_window = (mn+hsel-1)->mshelp [wkw.wy-1];
  102.     if (help_window != NULL)    {
  103.         for (ch = 0; ch < hp; ch++)
  104.             if (strcmp(help_window, hps[ch].hname) == 0)
  105.                 break;
  106.         if (ch < hp)    {
  107.             xx = wherex();
  108.             yy = wherey();
  109.             hidecursor();
  110.             hx = ((80-hps[ch].w) / 2)+1;
  111.             hy = ((25-hps[ch].h) / 2)+1;
  112.             establish_window(hx, hy,
  113.                     hx+hps[ch].w-1, hy+hps[ch].h,
  114.                     HELPFG, HELPBG, TRUE);
  115.             fseek(helpfp, hps[ch].hptr, 0);
  116.             for (i = 0; i < hps[ch].h-2; i++)   {
  117.                 gotoxy(2,2+i);
  118.                 fgets(hline, 80, helpfp);
  119.                 cprintf(hline);
  120.             }
  121.             gotoxy(2,2+i);
  122.             cprintf(" [Any key to return]");
  123.             hidecursor();
  124.             getkey();
  125.             delete_window();
  126.             if (mn == NULL || fld != NULL)    {
  127.                 textcolor(FIELDFG);
  128.                 textbackground(FIELDBG);
  129.                 gotoxy(xx, yy);
  130.             }
  131.         }
  132.     }
  133.     help_window = save_help;
  134.     --inhelp;
  135. }
  136.  
  137.  
  138. [LISTING 3]
  139.  
  140. <editor>
  141.               TINY WORD PROCESSOR (TWP) COMMANDS
  142. -------Cursor Movement------   ---------Page Movement--------
  143. arrows    = move text cursor   Ctrl-Home = Beginning of File
  144. Ctrl-T    = Top of Window      Ctrl-End  = End of File
  145. Ctrl-B    = Bottom of Window   PgUp      = Previous Page
  146. Ctrl ->   = Next Word          PgDn      = Next Page
  147. Ctrl <-   = Previous Word
  148. Home      = Beginning of Line  ---------Editor Control-------
  149. End       = End of Line        Alt-A  = Auto Paragraph Reform
  150. Shift-Tab = Back tab           
  151.  
  152. --------Block Controls------   ---------Edit Commands--------
  153. F2  = Form Paragraph           Alt-Q or Esc = Done
  154. F5  = Mark Block Beginning     Ins          = Insert Mode 
  155. F6  = Mark Block End           Del          = Delete Char
  156. F3  = Move Block               <--          = Rubout
  157. F4  = Copy Block               Ctrl-D       = Delete Word
  158. F8  = Delete Block             Alt-D        = Delete Line
  159. F9  = Unmark Block             F7           = Find
  160.                                Alt-F7       = Find again
  161. <load>
  162. Load a new file into TWP,
  163. replacing the existing file.
  164. <save>
  165. Save the file from the
  166. edit buffer.
  167. <merge>
  168. Merge a file into the
  169. edit buffer at the
  170. line where the cursor
  171. is pointed.
  172. <new>
  173. Clear the edit buffer
  174. and create a new file.
  175. <quit>
  176. Exit from TWP, returning to DOS
  177. <move>
  178. Move the block to the
  179. line where the cursor
  180. points. This is an
  181. insert move.
  182. <copy>
  183. Copy the block to the
  184. line where the cursor
  185. points. This is an
  186. insert copy.
  187. <delete>
  188. Delete the block closing
  189. the space it occupies.
  190. <hide>
  191. Turn off the block
  192. markers.
  193. <formpara>
  194. Form a paragraph.
  195. This makes a paragraph from
  196. a marked block, or, if no
  197. block is marked, to the next
  198. blank or indented line.
  199. <markbeg>
  200. Mark the beginning line
  201. of a block for move, copy,
  202. delete, or paragraph.
  203. <markend>
  204. Mark the ending line
  205. of a block for move, copy,
  206. delete, or paragraph.
  207. <find>
  208. Find a specified string
  209. in the edit buffer.
  210. Move the cursor to the
  211. location where the string
  212. was found.
  213. <findagn>
  214. Find the next occurrence
  215. of the string most recently
  216. specified.
  217. <auto>
  218. Turn on/off the automatic
  219. paragraph forming feature.
  220. <insert>
  221. Turn on/off the
  222. character insert mode.
  223. (insert/overstrike toggle)
  224. <filename>
  225. Enter the path and file name.
  226. The path is optional but must
  227. be fully qualified if entered.
  228. <findstr>
  229. Enter the string to be searched
  230. by the Find command.
  231. <end>
  232.  
  233.  
  234. [LISTING 4]
  235.  
  236. /* --------- editshel.c ------------ */
  237. #include <stdio.h>
  238. #include <string.h>
  239. #include <conio.h>
  240. #include <stdlib.h>
  241. #include <mem.h>
  242. #include <alloc.h>
  243. #include <ctype.h>
  244. #include "window.h"
  245. #include "menu.h"
  246. #include "entry.h"
  247. #include "editor.h"
  248. #include "help.h"
  249.  
  250. int MAXLINES;           /* maximum number of editor lines */
  251. #define EDITWIDTH  78   /* length of an editor line       */
  252. #define BUFLEN (EDITWIDTH*MAXLINES)
  253.  
  254. /* --------- alt keys returned by getkey() --------- */
  255. #define ALT_A 158
  256. #define ALT_L 166
  257. #define ALT_M 178
  258. #define ALT_N 177
  259.  
  260. /* -------- configured advanced editor commands --------- */
  261. #define FIND            F7
  262. #define FIND_AGAIN      ALT_F7
  263. #define LOAD_FILE       ALT_L
  264. #define SAVE_FILE       ALT_S
  265. #define MERGE_FILE      ALT_M
  266. #define NEW_FILE        ALT_N
  267. #define EDITOR_MENU     F10
  268. #define REFORM          ALT_A
  269.  
  270. /* ---------- editor menu tables --------- */
  271. static char *fselcs[] = {
  272.     "Load   [Alt-L]",
  273.     "Save   [Alt-S]",
  274.     "Merge  [Alt-M]",
  275.     "New    [Alt-N]",
  276.     "Quit   [Alt-Q]",
  277.     NULL
  278. };
  279.  
  280. static char *filehelp[] = {
  281.     "load",
  282.     "save",
  283.     "merge",
  284.     "new",
  285.     "quit"
  286. };
  287.  
  288. static char *eselcs[] = {
  289.     "Move         [F3]",
  290.     "Copy         [F4]",
  291.     "Delete       [F8]",
  292.     "Hide         [F9]",
  293.     "Paragraph    [F2]",
  294.     "Mark Beg     [F5]",
  295.     "Mark End     [F6]",
  296.     "Find         [F7]",
  297.     "Find Again   [Alt-F7]",
  298.     NULL
  299. };
  300.  
  301. static char *edithelp[] = {
  302.     "move",
  303.     "copy",
  304.     "delete",
  305.     "hide",
  306.     "formpara",
  307.     "markbeg",
  308.     "markend",
  309.     "find",
  310.     "findagn",
  311. };
  312.  
  313. static char *oselcs[] = {
  314.     "Auto Paragraph Reformat   [Alt-A]",
  315.     "Insert                    [Ins]",
  316.     NULL
  317. };
  318.  
  319. static char *opthelp[] = {
  320.     "auto",
  321.     "insert"
  322. };
  323.  
  324. void fileedit(char *);
  325. static int  edit(int,int);
  326. static void editmenu(int);
  327. static int  get_filename(char *, int);
  328. static int  write_file(void);
  329. static int  load_file(int,int);
  330. static int  save_file(int,int);
  331. static int  merge_file(int,int);
  332. static int  new_file(int,int);
  333. static void editkeys(int);
  334. static void statusline(void);
  335. static int  findstring(void);
  336. static char *find(char *, unsigned);
  337. static int  read_file(char *, char *, int, int, int);
  338. static int  bufferok(char *);
  339. static void notice(char *);
  340. void (*edit_extend)(void);
  341.  
  342. static char fkeys[] =   {LOAD_FILE,SAVE_FILE,
  343.                          MERGE_FILE,NEW_FILE,QUIT};
  344. static char forced[] =  {MOVE_BLOCK,COPY_BLOCK,
  345.                          DELETE_BLOCK,HIDE_BLOCK,
  346.                          PARAGRAPH,BEGIN_BLOCK,
  347.                          END_BLOCK,FIND,FIND_AGAIN};
  348. static char options[] = {REFORM,INS};
  349.  
  350. static int (*ffuncs[])() =
  351.     {load_file,save_file,merge_file,new_file,edit};
  352. static int (*efuncs[])() =
  353.     {edit,edit,edit,edit,edit,edit,edit,edit,edit};
  354. static int (*ofuncs[])() =
  355.     {edit,edit,edit};
  356.  
  357. MENU emn [] = {
  358.     {"File",    NULL, fselcs, filehelp, fkeys,   ffuncs, 0},
  359.     {"Edit",    NULL, eselcs, edithelp, forced,  efuncs, 0},
  360.     {"Options", NULL, oselcs, opthelp,  options, ofuncs, 0},
  361.     {NULL}
  362. };
  363.  
  364. /* ------ filename data entry template and buffer ------- */
  365. static char filename[65];
  366. static char savefn [65];
  367. static char filemask[65];
  368.  
  369. FIELD fn_template[] = {
  370.     {2,14,1,filename,filemask,"filename"},
  371.     {0}
  372. };
  373.  
  374. /* ------- text find data entry template and buffer ------ */
  375. static char findstr[71];
  376. static char findmask[71];
  377.  
  378. FIELD find_template[] = {
  379.     { 2,8,1,findstr,findmask,"findstr"},
  380.     {0}
  381. };
  382.  
  383. extern int forcechar;
  384. extern struct edit_env ev;
  385.  
  386. static void editkeys(int c)
  387. {
  388.     switch(c)   {
  389.         case REFORM:
  390.             ev.reforming ^= TRUE;
  391.             break;
  392.         case NEW_FILE:
  393.             new_file(1,1);
  394.             break;
  395.         case LOAD_FILE:
  396.             load_file(1,1);
  397.             break;
  398.         case SAVE_FILE:
  399.             save_file(1,1);
  400.             break;
  401.         case MERGE_FILE:
  402.             merge_file(1,1);
  403.             break;
  404.         case FIND:
  405.             if (!findstring())
  406.                 break;
  407.         case FIND_AGAIN:
  408.             ev.nowptr++;
  409.             ev.nowptr = find(ev.nowptr, ev.lstptr-ev.nowptr);
  410.             if (ev.nowptr != NULL)  {
  411.                 ev.curr_x = (ev.nowptr-ev.topptr) % ev.wwd;
  412.                 if (ev.nowptr >= ev.bfptr+ev.wwd*ev.wdo->ht)
  413.                     ev.bfptr = ev.nowptr - ev.curr_x;
  414.                 ev.curr_y = (ev.nowptr - ev.bfptr) / ev.wwd;
  415.             }
  416.             else
  417.                 error_message("Not found ...");
  418.             break;
  419.         case ALT_F:
  420.             editmenu(1);
  421.             break;
  422.         case ALT_E:
  423.             editmenu(2);
  424.             break;
  425.         case ALT_O:
  426.             editmenu(3);
  427.             break;
  428.         case EDITOR_MENU:
  429.             editmenu(0);
  430.             break;
  431.         default:
  432.             if (edit_extend)
  433.                 (*edit_extend)();
  434.             else
  435.                 putch(BELL);
  436.             break;
  437.     }
  438. }
  439.  
  440. static void editmenu(n)
  441. {
  442.     menu_select(emn, n);
  443. }
  444.  
  445. static int edit(hs,vs)
  446. {
  447.     forcechar = emn[hs-1].mskeys[vs-1] & 255;
  448.     return TRUE;
  449. }
  450.  
  451. /* ---------- edit a file -------------- */
  452. void fileedit(char *file)
  453. {
  454.     char *bf, *mb;
  455.     extern void (*editfunc)();
  456.     extern void (*status_line)();
  457.  
  458.     setmem(filename, 64, ' ');
  459.     setmem(filemask, 64, '_');
  460.     setmem(findmask, 70, '_');
  461.     setmem(findstr, 70, ' ');
  462.     establish_window(1,2,80,24,TEXTFG,TEXTBG,TRUE);
  463.     editfunc = editkeys;
  464.     status_line = statusline;
  465.     mb = display_menubar(emn);
  466.     statusline();
  467.     if ((bf = malloc(BUFLEN)) != NULL)  {
  468.         setmem(bf, BUFLEN, ' ');
  469.         strcpy(filename, file);
  470.         filename[strlen(filename)] = ' ';
  471.         if (*file)
  472.             read_file(" Loading ... ",bf,0,FALSE,FALSE);
  473.         while (TRUE)    {
  474.             text_editor(bf, MAXLINES, EDITWIDTH);
  475.             if (bufferok("quit"))
  476.                 break;
  477.         }
  478.         free(bf);
  479.     }
  480.     restore_menubar(mb);
  481.     delete_window();
  482. }
  483.  
  484. /* ---------- load a file --------------- */
  485. static int load_file(hs,vs)
  486. {
  487.     if (bufferok("reload"))
  488.         strcpy(savefn, filename);
  489.         if (get_filename(" Load what file? ", TRUE) != ESC) {
  490.             setmem(ev.topptr, BUFLEN, ' ');
  491.             read_file(" Loading ... ",ev.topptr,0,FALSE,TRUE);
  492.             forcechar = BEGIN_BUFFER;
  493.             ev.text_changed = FALSE;
  494.         }
  495.         else
  496.             strcpy(filename, savefn);
  497.     return TRUE;
  498. }
  499.  
  500. /* ---------- merge a file into the edit buffer -------- */
  501. static int merge_file(hs,vs)
  502. {
  503.     strcpy(savefn, filename);
  504.     if (get_filename(" Merge what file? ", TRUE) != ESC)    {
  505.         if (read_file(" Merging ... ",
  506.                 curr(0, ev.curr_y),
  507.                 lineno(ev.curr_y), TRUE, TRUE)) {
  508.             forcechar = REPAINT;
  509.             ev.text_changed = TRUE;
  510.         }
  511.     }
  512.     strcpy(filename, savefn);
  513.     return TRUE;
  514. }
  515.  
  516. /* --------- save the file -------------- */
  517. static int save_file(hs,vs)
  518. {
  519.     if (get_filename(" Save as what file? ", FALSE) != ESC)
  520.         if (write_file())
  521.             ev.text_changed = FALSE;
  522.     return TRUE;
  523. }
  524.  
  525. /* ---------- start a new file ------------- */
  526. static int new_file(hs,vs)
  527. {
  528.     if (bufferok("erase"))
  529.         if (get_filename(" Build as what file? ",TRUE)!=ESC){
  530.             setmem(ev.topptr, BUFLEN, ' ');
  531.             forcechar = BEGIN_BUFFER;
  532.             ev.text_changed = FALSE;
  533.         }
  534.     return TRUE;
  535. }
  536.  
  537. /* -------- read a file name ------------- */
  538. static int get_filename(char *ttl, int clear)
  539. {
  540.     int rtn;
  541.  
  542.     establish_window(1,23,80,25,ENTRYFG,ENTRYBG,TRUE);
  543.     window_title(ttl);
  544.     gotoxy(3,2);
  545.     cputs("File name:");
  546.     rtn = data_entry(fn_template, clear, 1);
  547.     delete_window();
  548.     return rtn;
  549. }
  550.  
  551. /* --------- write a file ------------ */
  552. static int write_file()
  553. {
  554.     FILE *fp;
  555.     int ln, i, ln1;
  556.     char *cp, buf[EDITWIDTH+1];
  557.  
  558.     if ((fp = fopen(filename, "w")) == NULL)    {
  559.         error_message(" Can't write that file! ");
  560.         return FALSE;
  561.     }
  562.     notice(" Writing file ... ");
  563.     /* ----- find the last significant line ----- */
  564.     for (ln = MAXLINES-1; ln > -1; --ln)    {
  565.         cp = ev.topptr + ln * EDITWIDTH;
  566.         for (i = 0; i < EDITWIDTH; i++)
  567.             if (*(cp + i) != ' ')
  568.                 break;
  569.         if (i < EDITWIDTH)
  570.             break;
  571.     }
  572.     for (ln1 = 0; ln1 <= ln; ln1++) {
  573.         movmem(ev.topptr + ln1 * EDITWIDTH, buf, EDITWIDTH);
  574.         i = EDITWIDTH-1;
  575.         cp = buf;
  576.         while (i >= 0 && *(cp + i) == ' ')
  577.             --i;
  578.         if (i == -1 || *(cp + i) != ' ')
  579.             i++;
  580.         *(cp + i) = '\n';
  581.         *(cp + i + 1) = '\0';
  582.         fputs(cp, fp);
  583.     }
  584.     fclose(fp);
  585.     delete_window();
  586.     return TRUE;
  587. }
  588.  
  589. /* -------------- read (load or merge) a file ----------- */
  590. static int
  591. read_file(char *nt,char *ln,int lines,int merging,int needed)
  592. {
  593.     FILE *fp;
  594.     char ibf[120];
  595.     char *cp;
  596.     int x;
  597.  
  598.     if ((fp = fopen(filename, "r")) != NULL)    {
  599.         notice(nt);
  600.         while (fgets(ibf, 120, fp) && lines < MAXLINES) {
  601.             lines++;
  602.             if (merging)    {
  603.                 movmem(ln,ln+EDITWIDTH,
  604.                     BUFLEN-lines*EDITWIDTH);
  605.                 setmem(ln,EDITWIDTH,' ');
  606.             }
  607.             cp = ibf, x = 0;
  608.             while (*cp && *cp != '\n')  {
  609.                 if (*cp == '\t')
  610.                     x += TAB-(x%TAB);
  611.                 else
  612.                     *(ln+x++) = *cp;
  613.                 cp++;
  614.             }
  615.             ln += EDITWIDTH;
  616.         }
  617.         fclose(fp);
  618.         delete_window();
  619.         return TRUE;
  620.     }
  621.     else if (needed)
  622.         error_message("No such file can be found");
  623.     return FALSE;
  624. }
  625.  
  626. /* ----------- display a status line ----------- */
  627. static void statusline()
  628. {
  629.     char stat[81], *st;
  630.     int cl[81], *cp;
  631.     static char msk[] =
  632. "Line:%3d   Column:%2d   %-9.9s   %-21.21s   F1:Help    \
  633. F10:Menu  ";
  634.     unsigned y = 1;
  635.     unsigned x = 1;
  636.     unsigned attr = ((MENUFG | (MENUBG << 4)) << 8);
  637.  
  638.     if (ev.wwd) {
  639.         y = (unsigned) (ev.nowptr-ev.topptr) / ev.wwd + 1;
  640.         x = (unsigned) (ev.nowptr-ev.topptr) % ev.wwd + 1;
  641.     }
  642.     sprintf(stat,msk,y,x,
  643.         (ev.edinsert ? "Insert" : "Overwrite"),
  644.         (ev.reforming ? "Auto Paragraph Reform" : " "));
  645.     for (st = stat, cp = cl; *st; st++)
  646.         *cp++ = (*st & 255) | attr;
  647.     __vram(__vptr(1,25),cl,80);
  648.     set_help("editor");
  649. }
  650.  
  651. /* -------- get a string to find --------- */
  652. static int findstring()
  653. {
  654.     char *cp = findstr+60;
  655.     int ans;
  656.  
  657.     establish_window(1,23,80,25,ENTRYFG,ENTRYBG,TRUE);
  658.     gotoxy(2,2);
  659.     cputs("Find?");
  660.     ans = data_entry(find_template, TRUE, 1);
  661.     delete_window();
  662.     if (ans == ESC)
  663.         return FALSE;
  664.     while (*--cp == ' ')
  665.         ;
  666.     if (*cp)
  667.         *(cp+1) = '\0';
  668.     return TRUE;
  669. }
  670.  
  671. /* -------- find a string in the buffer -------------- */
  672. static char *find(char *bf, unsigned len)
  673. {
  674.     char *cp;
  675.  
  676.     for (cp = bf; cp < bf+len-strlen(findstr); cp++)
  677.         if (strncmp(cp, findstr, strlen(findstr)) == 0)
  678.             return cp;
  679.     return NULL;
  680. }
  681.  
  682. /* ---------- test for buffer changed ----------- */
  683. static int bufferok(char *s)
  684. {
  685.     int c = 'Y';
  686.     if (ev.text_changed)    {
  687.         establish_window(23,11,56,13,ERRORFG,ERRORBG,TRUE);
  688.         gotoxy(2,2);
  689.         cprintf("Text has changed, %s? (y/n)", s);
  690.         hidecursor();
  691.         do
  692.             putch(BELL), c = getkey();
  693.         while (toupper(c) != 'Y' && toupper(c) != 'N');
  694.         delete_window();
  695.     }
  696.     return toupper(c) == 'Y';
  697. }
  698.  
  699. /* -------- small message ------------ */
  700. static void notice(char *s)
  701. {
  702.     int lf = (80-strlen(s))/2-1;
  703.     int rt = lf+strlen(s)+2;
  704.     establish_window(lf,11,rt,13,HELPFG,HELPBG,TRUE);
  705.     gotoxy(2,2);
  706.     cputs(s);
  707. }
  708.  
  709.  
  710. [LISTING 5]
  711.  
  712. /* ----------- twrp.c ------------ */
  713. #include <conio.h>
  714. #include "window.h"
  715. #include "editor.h"
  716. #include "help.h"
  717.  
  718. void main(int, char **);
  719. void fileedit(char *);
  720.  
  721. void main(int argc, char **argv)
  722. {
  723.     extern int inserting, MAXLINES;
  724.  
  725.     MAXLINES = 800;
  726.     load_help("twrp.hlp");
  727.     clear_screen();
  728.     fileedit(argc > 1 ? argv[1] : "");
  729.     clear_screen();
  730.     inserting = FALSE;
  731.     insert_line();
  732. }
  733.  
  734. [LISTING 6]
  735.  
  736. trwp (window.h, editor.h, help.h)
  737. editshel (editor.h, menu.h, entry.h, help.h, window.h)
  738. editor (editor.h, window.h)
  739. entry (entry.h, window.h)
  740. menu (menu.h, window.h)
  741. help (help.h, window.h)
  742. window (window.h)
  743.  
  744.  
  745.  
  746.