home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume20 / scan / part03 < prev    next >
Encoding:
Text File  |  1991-05-21  |  53.9 KB  |  2,018 lines

  1. Newsgroups: comp.sources.misc
  2. From: Patrick J. Wolfe <pat@kai.com>
  3. Subject:  v20i003:  scan - A directory menu program, Part03/03
  4. Message-ID: <1991May21.054323.16466@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 56b1d6be032e9c0a207a0c2484ebf6bb
  6. Date: Tue, 21 May 1991 05:43:23 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Patrick J. Wolfe <pat@kai.com>
  10. Posting-number: Volume 20, Issue 3
  11. Archive-name: scan/part03
  12.  
  13. #! /bin/sh
  14. # into a shell via "sh file" or similar.  To overwrite existing files,
  15. # type "sh file -c".
  16. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  17. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  18. # Contents:  Makefile Todo funcmenu.c getch.c getch.h main.c readrc.h
  19. #   runcmd.c scan.1 setupmenu.c
  20. # Wrapped by kent@sparky on Tue May 21 00:34:20 1991
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. echo If this archive is complete, you will see the following message:
  23. echo '          "shar: End of archive 3 (of 3)."'
  24. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'Makefile'\"
  26. else
  27.   echo shar: Extracting \"'Makefile'\" \(2974 characters\)
  28.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  29. X#    Scan directory menu program
  30. X#    edit config.h to make sure your system type and signal values are okay
  31. X#
  32. X
  33. X#    for SGI Irix 3.3
  34. X#LIBS = -lsun -lcurses
  35. X
  36. X#    for BSD 4.2 (Dynix 3, Concentrix 5.5)
  37. XLIBS = -lcurses -ltermcap
  38. X
  39. X#    for Esix (AT&T Unix) System V/386 Release 3.2
  40. X#CC = gcc -traditional
  41. X#LIBS = -lcurses -lbsd -lc_s
  42. X
  43. X#    for HP/UX 7.0 or later
  44. X#LIBS = -lcurses -lBSD
  45. X
  46. XCFLAGS = -O
  47. XLDFLAGS = $(CFLAGS)
  48. XLINTFLAGS = -vx -DLINT
  49. X
  50. X# where to install things
  51. XPGM = scan
  52. XBIN = /usr/local/bin
  53. XMANSECT = l
  54. XMANPAGE = /usr/man/man$(MANSECT)/scan.$(MANSECT)
  55. X
  56. XSHELL = /bin/sh
  57. XOBJS = filemenu.o fileops.o funcmenu.o getch.o keymenu.o main.o optionmenu.o readrc.o runcmd.o setupmenu.o userfuncs.o
  58. XSRCS = filemenu.c fileops.c funcmenu.c getch.c keymenu.c main.c optionmenu.c readrc.c runcmd.c setupmenu.c userfuncs.c
  59. X
  60. XFILES1 = README scan.1 Makefile Todo config.h defkeys.h getch.h readrc.h userfuncs.c
  61. XFILES2 = filemenu.c fileops.c funcmenu.c getch.c keymenu.c main.c optionmenu.c readrc.c runcmd.c setupmenu.c
  62. X
  63. Xscan:$& $(OBJS)
  64. X    rm -f scan.new
  65. X    $(CC) -o scan.new $(LDFLAGS) $(OBJS) $(LIBS)
  66. X    rm -f scan.old
  67. X    test ! -f scan || mv scan scan.old
  68. X    mv scan.new scan
  69. X
  70. Xinstall: scan
  71. X    rm -f $(BIN)/$(PGM)
  72. X    cp scan $(BIN)/$(PGM)
  73. X    strip $(BIN)/$(PGM)
  74. X    chmod 755 $(BIN)/$(PGM)
  75. X    ls -l $(BIN)/$(PGM)
  76. X
  77. Xmanpage: scan.1
  78. X    rm -f $(MANPAGE)
  79. X    cp scan.1 $(MANPAGE)
  80. X    chmod 644 $(MANPAGE)
  81. X    ls -l $(MANPAGE)
  82. X
  83. Xlint:
  84. X    lint $(LINTFLAGS) $(SRCS)
  85. X
  86. Xclean:
  87. X    rm -f a.out core mklog scan scan.old scan.shar* *.o
  88. X
  89. Xshar: $(FILES1) $(FILES2)
  90. X    shar $(FILES1) > scan.shar1
  91. X    shar $(FILES2) > scan.shar2
  92. X    ls -l scan.shar1 scan.shar2
  93. X
  94. Xfileops.o: config.h
  95. Xfilemenu.o: config.h getch.h
  96. Xfuncmenu.o: config.h getch.h
  97. Xgetch.o: config.h getch.h
  98. Xmain.o: config.h getch.h defkeys.h
  99. Xkeymenu.o: config.h getch.h
  100. Xoptionmenu.o: config.h getch.h
  101. Xreadrc.o: config.h getch.h readrc.h
  102. Xruncmd.o: config.h
  103. Xsetupmenu.o: config.h getch.h
  104. Xuserfuncs.o: config.h
  105. X
  106. X#
  107. X# This software is Copyright (c) 1989, 1990, 1991 by Patrick J. Wolfe.
  108. X#
  109. X# Permission is hereby granted to copy, distribute or otherwise 
  110. X# use any part of this package as long as you do not try to make 
  111. X# money from it or pretend that you wrote it.  This copyright 
  112. X# notice must be maintained in any copy made.
  113. X#
  114. X# Use of this software constitutes acceptance for use in an AS IS 
  115. X# condition. There are NO warranties with regard to this software.  
  116. X# In no event shall the author be liable for any damages whatsoever 
  117. X# arising out of or in connection with the use or performance of this 
  118. X# software.  Any use of this software is at the user's own risk.
  119. X#
  120. X# If you make modifications to this software that you feel 
  121. X# increases it usefulness for the rest of the community, please 
  122. X# email the changes, enhancements, bug fixes as well as any and 
  123. X# all ideas to me. This software is going to be maintained and 
  124. X# enhanced as deemed necessary by the community.
  125. X#              
  126. X#              Patrick J. Wolfe
  127. X#              uunet!uiucuxc!kailand!pwolfe
  128. X#              pwolfe@kailand.kai.com
  129. X#
  130. END_OF_FILE
  131.   if test 2974 -ne `wc -c <'Makefile'`; then
  132.     echo shar: \"'Makefile'\" unpacked with wrong size!
  133.   fi
  134.   # end of 'Makefile'
  135. fi
  136. if test -f 'Todo' -a "${1}" != "-c" ; then 
  137.   echo shar: Will not clobber existing file \"'Todo'\"
  138. else
  139.   echo shar: Extracting \"'Todo'\" \(1830 characters\)
  140.   sed "s/^X//" >'Todo' <<'END_OF_FILE'
  141. X*** FIX BUGS ***
  142. X
  143. X- there are currently none that I am aware of
  144. X
  145. X*** ENHANCE CURRENT FEATURES ***
  146. X
  147. X- handle SIGWINCH window size changes correctly.
  148. X
  149. X- update the manpage.  Double check the real default bindings, and add a
  150. X  table of builtin functions.
  151. X
  152. X- need improved rm_tagged function which deletes files properly with "rm -f",
  153. X  and directories with "rmdir", to prevent accidentally deleting all
  154. X  subdirectories and their contents.
  155. X
  156. X- check if the directory itself has been updated (files added or deleted) and
  157. X  display something to let the user know to "re-read current directory" (or
  158. X  remember the current file and do it automatically).
  159. X
  160. X- the "help screen" function only describes the default key bindings, which
  161. X  a user may change at any time.  It should describe the current bindings.
  162. X  Maybe a table of descriptions for each function, and a scrollable menu
  163. X  showing keys and their bindings.
  164. X
  165. X- find a way to get curses to use the "deleteln" and "insertln" routines
  166. X  correctly, so the menu scrolls better.  SVR3 curses does, BSD doesn't.
  167. X  Maybe on SVR3, allow down arrow to scroll the menu one line at a time,
  168. X  which looks smoother than jumping a half of a screen at a time.
  169. X
  170. X
  171. X*** ADD NEW FEATURES ***
  172. X
  173. X- A "File Operations Menu" would be nice.  This would have options to delete,
  174. X  rename, copy, tar, etc... current or tagged files.  Also, create file and
  175. X  subdirectory.
  176. X
  177. X- permissions menu, for assisting secretary types with modifying a file's
  178. X  access permissions.
  179. X
  180. X- search function, for tagging files whose name matches some wildcard string
  181. X  bind to "/".  Also, "n", "N", "?".
  182. X
  183. X- grep function, for tagging files which contain some wildcard string
  184. X  bind to "g". "G" could untag files with match, or it could tag files
  185. X  with DON'T match.  This could be confusing.  Maybe a submenu is called
  186. X  for here.
  187. X
  188. END_OF_FILE
  189.   if test 1830 -ne `wc -c <'Todo'`; then
  190.     echo shar: \"'Todo'\" unpacked with wrong size!
  191.   fi
  192.   # end of 'Todo'
  193. fi
  194. if test -f 'funcmenu.c' -a "${1}" != "-c" ; then 
  195.   echo shar: Will not clobber existing file \"'funcmenu.c'\"
  196. else
  197.   echo shar: Extracting \"'funcmenu.c'\" \(4919 characters\)
  198.   sed "s/^X//" >'funcmenu.c' <<'END_OF_FILE'
  199. X
  200. X/*
  201. X * This software is Copyright (c) 1989, 1990, 1991 by Patrick J. Wolfe.
  202. X *
  203. X * Permission is hereby granted to copy, distribute or otherwise 
  204. X * use any part of this package as long as you do not try to make 
  205. X * money from it or pretend that you wrote it.  This copyright 
  206. X * notice must be maintained in any copy made.
  207. X *
  208. X * Use of this software constitutes acceptance for use in an AS IS 
  209. X * condition. There are NO warranties with regard to this software.  
  210. X * In no event shall the author be liable for any damages whatsoever 
  211. X * arising out of or in connection with the use or performance of this 
  212. X * software.  Any use of this software is at the user's own risk.
  213. X *
  214. X * If you make modifications to this software that you feel 
  215. X * increases it usefulness for the rest of the community, please 
  216. X * email the changes, enhancements, bug fixes as well as any and 
  217. X * all ideas to me. This software is going to be maintained and 
  218. X * enhanced as deemed necessary by the community.
  219. X *              
  220. X *              Patrick J. Wolfe
  221. X *              uunet!uiucuxc!kailand!pwolfe
  222. X *              pwolfe@kailand.kai.com
  223. X */
  224. X
  225. X#include "config.h"
  226. Xextern struct funcname_entry funcname_table[];
  227. X
  228. Xstatic void redraw_data();
  229. Xstatic WINDOW *header_window, *data_window, *help_window;
  230. Xstatic int top = 0, current = 0, last;
  231. X
  232. X
  233. Xstatic
  234. Xdown_one_line ()
  235. X{
  236. Xif (current < last) {
  237. X    current++;
  238. X    if (current > (top + 14)) {
  239. X        top += 14;
  240. X        if (top >= (last - 14)) {
  241. X            top = last - 14;
  242. X            if (top < 0) {
  243. X                top = 0;
  244. X                }
  245. X            }
  246. X        }
  247. X    redraw_data ();
  248. X    }
  249. Xelse    {
  250. X    beep();
  251. X    }
  252. X}
  253. X
  254. X
  255. Xstatic
  256. Xup_one_line ()
  257. X{
  258. Xif (current > 0) {
  259. X    current--;
  260. X    if (current < top) {
  261. X        top -= 14;
  262. X        if (top < 0) {
  263. X            top = 0;
  264. X            }
  265. X        }
  266. X    redraw_data ();
  267. X    }
  268. Xelse    {
  269. X    beep();
  270. X    }
  271. X}
  272. X
  273. X
  274. Xstatic
  275. Xdown_one_screen ()
  276. X{
  277. Xif (top < (last - 14)) {
  278. X    top += 15;
  279. X    if (top >= (last - 14)) {
  280. X        top = last - 14;
  281. X        if (top < 0) {
  282. X            top = 0;
  283. X            }
  284. X        }
  285. X    current = top;
  286. X    redraw_data ();
  287. X    }
  288. Xelse if (current < last) {
  289. X    current = last;
  290. X    redraw_data ();
  291. X    }
  292. Xelse    {
  293. X    beep();
  294. X    }
  295. X}
  296. X
  297. X
  298. Xstatic
  299. Xup_one_screen ()
  300. X{
  301. Xif (top > 0) {
  302. X    top -= 15;
  303. X    if (top < 0) {
  304. X        top = 0;
  305. X        }
  306. X    current = top + 14;
  307. X    if (current > last) {
  308. X        current = last;
  309. X        }
  310. X    redraw_data ();
  311. X    }
  312. Xelse if (current > 0) {
  313. X    current = 0;
  314. X    redraw_data ();
  315. X    }
  316. Xelse    {
  317. X    beep();
  318. X    }
  319. X}
  320. X
  321. X
  322. Xstatic void
  323. Xredraw_data ()
  324. X{
  325. Xint row, ptr;
  326. X
  327. Xwmove (data_window, 0, 0);
  328. Xwclrtobot (data_window);
  329. Xfor (row = 0, ptr = top; (ptr <= last) && (row < 15); ptr++, row++) {
  330. X    if (ptr == current) {
  331. X        wstandout (data_window);
  332. X        }
  333. X    
  334. X    mvwaddstr (data_window, row, 0, (char *) funcname_table[ptr].name);
  335. X
  336. X    if (ptr == current) {
  337. X        wstandend (data_window);
  338. X        }
  339. X    }
  340. Xwrefresh (data_window);
  341. X}
  342. X
  343. X
  344. Xstatic
  345. Xredraw_all ()
  346. X{
  347. Xwmove (header_window, 0, 0);
  348. Xwclrtobot (header_window);
  349. Xwmove (header_window, 1, 10);
  350. Xwstandout (header_window);
  351. Xwaddstr (header_window, PGM_VERSION);
  352. Xwaddstr (header_window, " Builtin Function Selection Menu");
  353. Xwstandend (header_window);
  354. Xwmove (header_window, 3, 3);
  355. Xwaddstr (header_window, "function name");
  356. Xwmove (header_window, 4, 0);
  357. Xwaddstr (header_window, "-------------");
  358. Xwrefresh (header_window);
  359. X
  360. Xredraw_data ();
  361. X
  362. Xwmove (help_window, 0, 0);
  363. Xwclrtobot (help_window);
  364. Xwmove (help_window, 0, 0);
  365. Xwaddstr (help_window, "+----------------------------------------------------------------------------+");
  366. Xwmove (help_window, 1, 0);
  367. Xwaddstr (help_window, "|     use ^F, ^B, j, k and/or the arrow keys to move around the display      |");
  368. Xwmove (help_window, 2, 0);
  369. Xwaddstr (help_window, "|     Return selects the highlighted function, Q cancels the key definition  |");
  370. Xwmove (help_window, 3, 0);
  371. Xwaddstr (help_window, "+----------------------------------------------------------------------------+");
  372. Xwrefresh (help_window);
  373. X}
  374. X
  375. X
  376. Xvoidptr
  377. Xfunction_menu ()
  378. X{
  379. Xint c;
  380. X
  381. X/* find last function in table */
  382. Xfor (last = 0; funcname_table[last].kfunc != NULL; last++);
  383. X
  384. Xheader_window = newwin (5, 80, 0, 0);
  385. Xdata_window = newwin (15, 80, 5, 0);
  386. Xhelp_window = newwin (4, 80, 20, 0);
  387. X#ifdef SYSVcurses
  388. Xidlok (data_window, TRUE);
  389. X#endif
  390. Xredraw_all ();
  391. X
  392. Xwhile (1) {
  393. X    c = my_getch (header_window);
  394. X    switch (c) {
  395. X
  396. X    case ControlB:
  397. X    case KEY_PPAGE:
  398. X    case KEY_PrevScreen:
  399. X        up_one_screen ();
  400. X        break;
  401. X
  402. X    case ControlF:
  403. X    case KEY_NPAGE:
  404. X    case KEY_NextScreen:
  405. X        down_one_screen ();
  406. X        break;
  407. X
  408. X    case 'k':
  409. X    case KEY_UP:
  410. X    case ControlP:
  411. X        up_one_line ();
  412. X        break;
  413. X
  414. X    case 'j':
  415. X    case KEY_DOWN:
  416. X    case ControlN:
  417. X        down_one_line ();
  418. X        break;
  419. X    
  420. X    case 'q':
  421. X    case 'Q':
  422. X    case ControlM:
  423. X        wmove (header_window, 0, 0);
  424. X        wclrtobot (header_window);
  425. X        wrefresh (header_window);
  426. X        delwin (header_window);
  427. X        wmove (data_window, 0, 0);
  428. X        wclrtobot (data_window);
  429. X        wrefresh (data_window);
  430. X        delwin (data_window);
  431. X        wmove (help_window, 0, 0);
  432. X        wclrtobot (help_window);
  433. X        wrefresh (help_window);
  434. X        delwin (help_window);
  435. X        if (c == ControlM)
  436. X            return ((voidptr) funcname_table[current].kfunc);
  437. X        return ((voidptr) NULL);
  438. X
  439. X    case ControlL:
  440. X    case ControlR:
  441. X        redraw_all ();
  442. X        break;
  443. X
  444. X    default:
  445. X        beep();
  446. X        }
  447. X    }
  448. X}
  449. END_OF_FILE
  450.   if test 4919 -ne `wc -c <'funcmenu.c'`; then
  451.     echo shar: \"'funcmenu.c'\" unpacked with wrong size!
  452.   fi
  453.   # end of 'funcmenu.c'
  454. fi
  455. if test -f 'getch.c' -a "${1}" != "-c" ; then 
  456.   echo shar: Will not clobber existing file \"'getch.c'\"
  457. else
  458.   echo shar: Extracting \"'getch.c'\" \(3184 characters\)
  459.   sed "s/^X//" >'getch.c' <<'END_OF_FILE'
  460. X
  461. X/*
  462. X * This software is Copyright (c) 1989, 1990, 1991 by Patrick J. Wolfe.
  463. X *
  464. X * Permission is hereby granted to copy, distribute or otherwise 
  465. X * use any part of this package as long as you do not try to make 
  466. X * money from it or pretend that you wrote it.  This copyright 
  467. X * notice must be maintained in any copy made.
  468. X *
  469. X * Use of this software constitutes acceptance for use in an AS IS 
  470. X * condition. There are NO warranties with regard to this software.  
  471. X * In no event shall the author be liable for any damages whatsoever 
  472. X * arising out of or in connection with the use or performance of this 
  473. X * software.  Any use of this software is at the user's own risk.
  474. X *
  475. X * If you make modifications to this software that you feel 
  476. X * increases it usefulness for the rest of the community, please 
  477. X * email the changes, enhancements, bug fixes as well as any and 
  478. X * all ideas to me. This software is going to be maintained and 
  479. X * enhanced as deemed necessary by the community.
  480. X *              
  481. X *              Patrick J. Wolfe
  482. X *              uunet!uiucuxc!kailand!pwolfe
  483. X *              pwolfe@kailand.kai.com
  484. X */
  485. X
  486. X#include "config.h"
  487. X
  488. X#define NORMAL    100
  489. X#define ESCAPE    200
  490. X#define FKEY    300
  491. X
  492. X
  493. Xint
  494. Xmy_getch (winptr)
  495. XWINDOW *winptr;
  496. X{
  497. Xchar c;
  498. Xint state = NORMAL;
  499. Xint fkeycount = 0;
  500. X
  501. Xwhile (1) {
  502. X    c = wgetch (winptr);    /* call the real getch() to return a single character */
  503. X    switch (state) {
  504. X
  505. X    case FKEY:
  506. X        switch (c) {
  507. X
  508. X        /* numeric function keys */
  509. X        case '0': case '1': case '2': case '3': case '4':
  510. X        case '5': case '6': case '7': case '8': case '9':
  511. X            fkeycount = (fkeycount * 10) + (c - '0');
  512. X            break;
  513. X        
  514. X        case '~':
  515. X            switch (fkeycount) {
  516. X
  517. X            /* Find, Insert Here, Remove, Select, Prev Screen, Next Screen */
  518. X            case 1: case 2: case 3: case 4: case 5: case 6:
  519. X                return KEY_Find + (fkeycount - 1);
  520. X
  521. X            /* unshifted vt220 function keys */
  522. X            case 17: case 18: case 19: case 20: case 21:
  523. X            case 22: case 23: case 24: case 25: case 26:
  524. X            case 27: case 28: case 29: case 30: case 31:
  525. X                return KEY_F6 + (fkeycount - 17);
  526. X
  527. X            /* shifted tvs922 function keys */
  528. X            case 37: case 38: case 39: case 40: case 41:
  529. X            case 42: case 43: case 44: case 45: case 46:
  530. X            case 47: case 48: case 49: case 50: case 51:
  531. X                return KEY_SF6 + (fkeycount - 37);
  532. X
  533. X            default:
  534. X                beep();
  535. X                state = NORMAL;
  536. X                }
  537. X            break;
  538. X
  539. X        case 'A':    return KEY_UP;
  540. X        case 'B':    return KEY_DOWN;
  541. X        case 'C':    return KEY_RIGHT;
  542. X        case 'D':    return KEY_LEFT;
  543. X        case 'M':    return KEY_PadEnter;
  544. X        case 'Z':    return KEY_BackTab;
  545. X
  546. X        /* VT[12]00 PF keys */
  547. X        case 'P': case 'Q': case 'R': case 'S':
  548. X            return KEY_PF1 + (c - 'P');
  549. X
  550. X        /* VT[12]00 keypad */
  551. X        case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
  552. X        case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y':
  553. X            return KEY_PadComma + (c - 'l');
  554. X
  555. X        default:
  556. X            beep();
  557. X            state = NORMAL;
  558. X            }
  559. X        break;
  560. X
  561. X    case ESCAPE:
  562. X        switch (c) {
  563. X        case 'O':
  564. X        case '[':
  565. X            state = FKEY;
  566. X            fkeycount = 0;
  567. X            break;
  568. X
  569. X        default:
  570. X            state = NORMAL;
  571. X            beep();
  572. X            }
  573. X        break;
  574. X
  575. X    default:
  576. X        switch (c) {
  577. X        case Escape:
  578. X            state = ESCAPE;
  579. X            break;
  580. X
  581. X        case CSI:
  582. X            state = FKEY;
  583. X            fkeycount = 0;
  584. X            break;
  585. X
  586. X        default:
  587. X            return (c);
  588. X            }
  589. X        }
  590. X    }
  591. X}
  592. END_OF_FILE
  593.   if test 3184 -ne `wc -c <'getch.c'`; then
  594.     echo shar: \"'getch.c'\" unpacked with wrong size!
  595.   fi
  596.   # end of 'getch.c'
  597. fi
  598. if test -f 'getch.h' -a "${1}" != "-c" ; then 
  599.   echo shar: Will not clobber existing file \"'getch.h'\"
  600. else
  601.   echo shar: Extracting \"'getch.h'\" \(4869 characters\)
  602.   sed "s/^X//" >'getch.h' <<'END_OF_FILE'
  603. X
  604. X/*
  605. X * This software is Copyright (c) 1989, 1990, 1991 by Patrick J. Wolfe.
  606. X *
  607. X * Permission is hereby granted to copy, distribute or otherwise 
  608. X * use any part of this package as long as you do not try to make 
  609. X * money from it or pretend that you wrote it.  This copyright 
  610. X * notice must be maintained in any copy made.
  611. X *
  612. X * Use of this software constitutes acceptance for use in an AS IS 
  613. X * condition. There are NO warranties with regard to this software.  
  614. X * In no event shall the author be liable for any damages whatsoever 
  615. X * arising out of or in connection with the use or performance of this 
  616. X * software.  Any use of this software is at the user's own risk.
  617. X *
  618. X * If you make modifications to this software that you feel 
  619. X * increases it usefulness for the rest of the community, please 
  620. X * email the changes, enhancements, bug fixes as well as any and 
  621. X * all ideas to me. This software is going to be maintained and 
  622. X * enhanced as deemed necessary by the community.
  623. X *              
  624. X *              Patrick J. Wolfe
  625. X *              uunet!uiucuxc!kailand!pwolfe
  626. X *              pwolfe@kailand.kai.com
  627. X */
  628. X
  629. X#ifndef SYSVcurses
  630. X/* System V curses key names and codes returned by getch */
  631. X#define KEY_BREAK    0401
  632. X#define KEY_DOWN    0402
  633. X#define KEY_UP        0403
  634. X#define KEY_LEFT    0404
  635. X#define KEY_RIGHT    0405
  636. X#define KEY_HOME    0406
  637. X#define KEY_BACKSPACE    0407
  638. X#define KEY_F0        0410    /* function keys */
  639. X#define KEY_F(x)    (KEY_F0 + (x))    /* space for 64 function keys is reserved */
  640. X#define KEY_DL        0510    /* delete line */
  641. X#define KEY_IL        0511    /* insert line */
  642. X#define KEY_DC        0512    /* delete char */
  643. X#define KEY_IC        0513    /* insert char or enter insert mode */
  644. X#define KEY_EIC        0514    /* exit insert mode */
  645. X#define KEY_CLEAR    0515    /* clear screen */
  646. X#define KEY_EOS        0516    /* clear to end of screen */
  647. X#define KEY_EOL        0517    /* clear to end of line */
  648. X#define KEY_SF        0520    /* scroll 1 line forward */
  649. X#define KEY_SR        0521    /* scroll 1 line backward (reverse) */
  650. X#define KEY_NPAGE    0522    /* next page */
  651. X#define KEY_PPAGE    0523    /* previous page */
  652. X#define KEY_STAB    0524    /* set tab */
  653. X#define KEY_CTAB    0525    /* clear tab */
  654. X#define KEY_CATAB    0526    /* clear all tabs */
  655. X#define KEY_ENTER    0527    /* Enter or send (unreliable) */
  656. X#define KEY_SRESET    0530    /* soft (partial) reset (unreliable) */
  657. X#define KEY_RESET    0531    /* reset or hard reset (unreliable) */
  658. X#define KEY_PRINT    0532    /* print or copy */
  659. X#define KEY_LL        0533    /* home down or bottom (lower left) */
  660. X#endif /* NOT SYSVcurses */
  661. X
  662. X/* vt220 special keys */
  663. X
  664. X#define KEY_F1        0411
  665. X#define KEY_F2        0412
  666. X#define KEY_F3        0413
  667. X#define KEY_F4        0414
  668. X#define KEY_F5        0415
  669. X#define KEY_F6        0416
  670. X#define KEY_F7        0417
  671. X#define KEY_F8        0420
  672. X#define KEY_F9        0421
  673. X#define KEY_F10        0422
  674. X#define KEY_F11        0423
  675. X#define KEY_F12        0424
  676. X#define KEY_F13        0425
  677. X#define KEY_F14        0426
  678. X#define KEY_F15        0427
  679. X#define KEY_Help    0427
  680. X#define KEY_F16        0430
  681. X#define KEY_Do        0430
  682. X#define KEY_F17        0431
  683. X#define KEY_F18        0432
  684. X#define KEY_F19        0433
  685. X#define KEY_F20        0434
  686. X#define KEY_PF1        0534
  687. X#define KEY_PF2        0535
  688. X#define KEY_PF3        0536
  689. X#define KEY_PF4        0537
  690. X#define KEY_Pad0    0540
  691. X#define KEY_Pad1    0541
  692. X#define KEY_Pad2    0542
  693. X#define KEY_Pad3    0543
  694. X#define KEY_Pad4    0544
  695. X#define KEY_Pad5    0545
  696. X#define KEY_Pad6    0546
  697. X#define KEY_Pad7    0547
  698. X#define KEY_Pad8    0550
  699. X#define KEY_Pad9    0551
  700. X#define KEY_PadEnter    0552
  701. X#define KEY_PadMinus    0553
  702. X#define KEY_PadPeriod    0554
  703. X#define KEY_PadComma    0555
  704. X#define KEY_Pad00    0556
  705. X#define KEY_BackTab    0557
  706. X#define KEY_Find    0560
  707. X#define KEY_InsertHere    0561
  708. X#define KEY_Remove    0562
  709. X#define KEY_Select    0563
  710. X#define KEY_PrevScreen    0564
  711. X#define KEY_PrevScrn    0564
  712. X#define KEY_NextScreen    0565
  713. X#define KEY_NextScrn    0565
  714. X#define KEY_SF1        0611
  715. X#define KEY_SF2        0612
  716. X#define KEY_SF3        0613
  717. X#define KEY_SF4        0614
  718. X#define KEY_SF5        0615
  719. X#define KEY_SF6        0616
  720. X#define KEY_SF7        0617
  721. X#define KEY_SF8        0620
  722. X#define KEY_SF9        0621
  723. X#define KEY_SF10    0622
  724. X#define KEY_SF11    0623
  725. X#define KEY_SF12    0624
  726. X#define KEY_SF13    0625
  727. X#define KEY_SF14    0626
  728. X#define KEY_SF15    0627
  729. X#define KEY_SHelp    0627
  730. X#define KEY_SF16    0630
  731. X#define KEY_SDo        0630
  732. X#define KEY_SF17    0631
  733. X#define KEY_SF18    0632
  734. X#define KEY_SF19    0633
  735. X#define KEY_SF20    0634
  736. X
  737. X/* ascii control codes */
  738. X#define ControlA    001
  739. X#define ControlB    002
  740. X#define ControlC    003
  741. X#define ControlD    004
  742. X#define ControlE    005
  743. X#define ControlF    006
  744. X#define ControlG    007
  745. X#define ControlH    010
  746. X#define BackSpace    010
  747. X#define ControlI    011
  748. X#define Tab        011
  749. X#define ControlJ    012
  750. X#define LineFeed    012
  751. X#define ControlK    013
  752. X#define ControlL    014
  753. X#define ControlM    015
  754. X#define Return        015
  755. X#define ControlN    016
  756. X#define ControlO    017
  757. X#define ControlP    020
  758. X#define ControlQ    021
  759. X#define ControlR    022
  760. X#define ControlS    023
  761. X#define ControlT    024
  762. X#define ControlU    025
  763. X#define ControlV    026
  764. X#define ControlW    027
  765. X#define ControlX    030
  766. X#define ControlY    031
  767. X#define ControlZ    032
  768. X#define Escape        033
  769. X#define Control[    033
  770. X#define Delete        0177
  771. X#define Del        0177
  772. X#define CSI        0233
  773. END_OF_FILE
  774.   if test 4869 -ne `wc -c <'getch.h'`; then
  775.     echo shar: \"'getch.h'\" unpacked with wrong size!
  776.   fi
  777.   # end of 'getch.h'
  778. fi
  779. if test -f 'main.c' -a "${1}" != "-c" ; then 
  780.   echo shar: Will not clobber existing file \"'main.c'\"
  781. else
  782.   echo shar: Extracting \"'main.c'\" \(4197 characters\)
  783.   sed "s/^X//" >'main.c' <<'END_OF_FILE'
  784. X/*
  785. X *    scan - file menu program
  786. X *
  787. X * This software is Copyright (c) 1989, 1990, 1991 by Patrick J. Wolfe.
  788. X *
  789. X * Permission is hereby granted to copy, distribute or otherwise 
  790. X * use any part of this package as long as you do not try to make 
  791. X * money from it or pretend that you wrote it.  This copyright 
  792. X * notice must be maintained in any copy made.
  793. X *
  794. X * Use of this software constitutes acceptance for use in an AS IS 
  795. X * condition. There are NO warranties with regard to this software.  
  796. X * In no event shall the author be liable for any damages whatsoever 
  797. X * arising out of or in connection with the use or performance of this 
  798. X * software.  Any use of this software is at the user's own risk.
  799. X *
  800. X * If you make modifications to this software that you feel 
  801. X * increases it usefulness for the rest of the community, please 
  802. X * email the changes, enhancements, bug fixes as well as any and 
  803. X * all ideas to me. This software is going to be maintained and 
  804. X * enhanced as deemed necessary by the community.
  805. X *              
  806. X *              Patrick J. Wolfe
  807. X *              uunet!uiucuxc!kailand!pwolfe
  808. X *              pwolfe@kailand.kai.com
  809. X */
  810. X
  811. X
  812. X#include "config.h"
  813. X#include "defkeys.h"
  814. X
  815. Xextern char *getenv();
  816. Xextern struct option_entry option_table[];
  817. Xextern char currdir[];
  818. X
  819. Xstruct key_entry keytab[SIZEKEYTAB];
  820. Xint opt_auto_untag, opt_dir_order, opt_dot_order, opt_dotdir_order, opt_hide_dotdot,
  821. X    opt_pager_pause, opt_rm_prompt, opt_show_filetype, opt_show_symlinks;
  822. Xchar *editor = DEFAULT_EDITOR, *pager = DEFAULT_PAGER, *loginid, *shellpgm, *homedir;
  823. Xchar rcfilename[MAXPATHLEN];
  824. Xint namebufleft = BUFSIZE;
  825. Xint PAGESIZE = 0;
  826. Xchar *namebuf;
  827. X
  828. X
  829. X/*
  830. X * initialize key definition and option tables
  831. X */
  832. Xinit_defaults ()
  833. X{
  834. Xint ctr;
  835. X
  836. Xbcopy ((char *) default_keytab, (char *) keytab, (sizeof(struct key_entry) * SIZEKEYTAB));
  837. X/*
  838. Xfor (ctr = 0; ctr < SIZEKEYTAB; ctr++) {
  839. X    keytab[ctr].type = default_keytab[ctr].type;
  840. X    keytab[ctr].options = default_keytab[ctr].options;
  841. X    keytab[ctr].pntr = default_keytab[ctr].pntr;
  842. X    }
  843. X*/
  844. X
  845. Xfor (ctr = 0; option_table[ctr].name != NULL; ctr++) {
  846. X    *option_table[ctr].variable = option_table[ctr].default_value;
  847. X    }
  848. X}
  849. X
  850. X
  851. XSIGTYPE
  852. Xdie ()
  853. X{
  854. Xmove (LINES, 0);
  855. Xrefresh ();
  856. Xendwin();
  857. Xexit (0);
  858. X}
  859. X
  860. X
  861. Xmain (argc, argv)
  862. Xint    argc;
  863. Xchar    **argv;
  864. X{
  865. Xstruct    passwd    *pb;
  866. Xchar *fieldval;
  867. X
  868. X#ifdef SYSVgetcwd
  869. Xgetcwd (currdir, MAXPATHLEN);
  870. X#else
  871. Xgetwd (currdir);
  872. X#endif /* SYSVgetcwd */
  873. X
  874. Xif ((argc > 1) && (chdir (argv[1]) == -1)) {
  875. X    perror ("chdir");
  876. X    fprintf (stderr, "scan:  cannot cd to directory %s\n", argv[1]);
  877. X    exit (1);
  878. X    }
  879. X
  880. Xif ((pb = getpwuid (getuid())) == NULL) {
  881. X    perror ("getpwuid");
  882. X    fprintf (stderr, "scan:  you do not have an account on this system\n");
  883. X    exit (1);
  884. X    }
  885. X
  886. X/* get some environment variables */
  887. Xif (((fieldval = getenv("USER")) != NULL) || ((fieldval = getenv("LOGNAME")) != NULL)) {
  888. X    loginid = (char *) malloc (strlen(fieldval)+1);
  889. X    strcpy (loginid, fieldval);
  890. X    }
  891. Xelse if ((fieldval = (char *) getlogin()) != NULL) {
  892. X    loginid = (char *) malloc (strlen(fieldval)+1);
  893. X    strcpy (loginid, fieldval);
  894. X    }
  895. Xelse    {
  896. X    loginid = (char *) malloc (strlen(pb->pw_name)+1);
  897. X    strcpy (loginid, pb->pw_name);
  898. X    }
  899. X
  900. Xif ((fieldval = getenv("EDITOR")) != NULL) {
  901. X    editor = (char *) malloc (strlen(fieldval)+1);
  902. X    strcpy (editor, fieldval);
  903. X    }
  904. X
  905. Xif ((fieldval = getenv("PAGER")) != NULL) {
  906. X    pager = (char *) malloc (strlen(fieldval)+1);
  907. X    strcpy (pager, fieldval);
  908. X    }
  909. X
  910. Xif ((fieldval = getenv("SHELL")) != NULL) {
  911. X    shellpgm = (char *) malloc (strlen(fieldval)+1);
  912. X    strcpy (shellpgm, fieldval);
  913. X    }
  914. Xelse    {
  915. X    shellpgm = (char *) malloc (strlen(pb->pw_shell)+1);
  916. X    strcpy (shellpgm, pb->pw_shell);
  917. X    }
  918. X
  919. Xif ((fieldval = getenv("HOME")) != NULL) {
  920. X    homedir = (char *) malloc (strlen(fieldval)+1);
  921. X    strcpy (homedir, fieldval);
  922. X    }
  923. Xelse    {
  924. X    homedir = (char *) malloc (strlen(pb->pw_dir)+1);
  925. X    strcpy (homedir, pb->pw_dir);
  926. X    }
  927. X
  928. Xif ((namebuf = (char *) malloc (BUFSIZE)) == NULL) {
  929. X    perror ("malloc");
  930. X    exit (1);
  931. X    }
  932. X
  933. Xinit_defaults ();        /* initialize key and option tables */
  934. Xreadrc (SYSTEM_RCFILE);        /* read system init file */
  935. Xstrcpy (rcfilename, homedir);
  936. Xstrcat (rcfilename, "/.scanrc");
  937. Xreadrc (rcfilename);        /* read user init file */
  938. X
  939. Xmain_loop ();            /* the program's main routine */
  940. X/* NOTREACHED */
  941. X}
  942. END_OF_FILE
  943.   if test 4197 -ne `wc -c <'main.c'`; then
  944.     echo shar: \"'main.c'\" unpacked with wrong size!
  945.   fi
  946.   # end of 'main.c'
  947. fi
  948. if test -f 'readrc.h' -a "${1}" != "-c" ; then 
  949.   echo shar: Will not clobber existing file \"'readrc.h'\"
  950. else
  951.   echo shar: Extracting \"'readrc.h'\" \(7455 characters\)
  952.   sed "s/^X//" >'readrc.h' <<'END_OF_FILE'
  953. X
  954. X/*
  955. X * This software is Copyright (c) 1989, 1990, 1991 by Patrick J. Wolfe.
  956. X *
  957. X * Permission is hereby granted to copy, distribute or otherwise 
  958. X * use any part of this package as long as you do not try to make 
  959. X * money from it or pretend that you wrote it.  This copyright 
  960. X * notice must be maintained in any copy made.
  961. X *
  962. X * Use of this software constitutes acceptance for use in an AS IS 
  963. X * condition. There are NO warranties with regard to this software.  
  964. X * In no event shall the author be liable for any damages whatsoever 
  965. X * arising out of or in connection with the use or performance of this 
  966. X * software.  Any use of this software is at the user's own risk.
  967. X *
  968. X * If you make modifications to this software that you feel 
  969. X * increases it usefulness for the rest of the community, please 
  970. X * email the changes, enhancements, bug fixes as well as any and 
  971. X * all ideas to me. This software is going to be maintained and 
  972. X * enhanced as deemed necessary by the community.
  973. X *              
  974. X *              Patrick J. Wolfe
  975. X *              uunet!uiucuxc!kailand!pwolfe
  976. X *              pwolfe@kailand.kai.com
  977. X */
  978. X
  979. X
  980. Xextern int opt_auto_untag, opt_dir_order, opt_dot_order, opt_dotdir_order, opt_hide_dotdot,
  981. X    opt_pager_pause, opt_rm_prompt, opt_show_filetype, opt_show_symlinks;
  982. X
  983. X/* option value tables */
  984. Xchar *true_false[] = { "false", "true", NULL };
  985. Xchar *dot_order[] = { "first", "last", "hide", NULL };
  986. Xchar *dir_order[] = { "first", "last", "sort", NULL };
  987. Xchar *dotdir_order[] = { "withdot", "withdir", NULL };
  988. X
  989. X/* info about options used in init files and options menu */ 
  990. Xstruct option_entry option_table[] = {
  991. X    { "auto-untag",        &opt_auto_untag,    true_false,    OPT_TRUE },
  992. X    { "dir-order",        &opt_dir_order,        dir_order,    DIR_FIRST },
  993. X    { "dot-order",        &opt_dot_order,        dot_order,    DOT_LAST },
  994. X    { "dotdir-order",    &opt_dotdir_order,    dotdir_order,    WITH_DOT },
  995. X    { "hide-dotdot",    &opt_hide_dotdot,    true_false,    OPT_FALSE },
  996. X    { "pager-pause",    &opt_pager_pause,    true_false,    OPT_TRUE },
  997. X    { "rm-prompt",        &opt_rm_prompt,        true_false,    OPT_TRUE },
  998. X    { "show-filetype",    &opt_show_filetype,    true_false,    OPT_TRUE },
  999. X    { "show-symlinks",    &opt_show_symlinks,    true_false,    OPT_TRUE },
  1000. X    { NULL,            NULL,            NULL,        0 }
  1001. X    };
  1002. X
  1003. X/* info about built-in functions used in init files and keydef menu */
  1004. Xstruct funcname_entry funcname_table[] = {
  1005. X    { "bottom_line",        bottom_line },
  1006. X    { "cd_back",            cd_back },
  1007. X    { "cd_dot",            cd_dot },
  1008. X    { "cd_dotdot",            cd_dotdot },
  1009. X    { "cd_file",            cd_file },
  1010. X    { "cd_home",             cd_home },
  1011. X    { "cd_prompt",             cd_prompt },
  1012. X    { "cd_root",             cd_root },
  1013. X    { "cd_or_edit",             cd_or_edit },
  1014. X    { "cd_or_view",             cd_or_view },
  1015. X    { "command_file",        command_file },
  1016. X    { "command_tagged",        command_tagged },
  1017. X    { "edit_file",            edit_file },
  1018. X    { "edit_tagged",        edit_tagged },
  1019. X    { "execute_file",        execute_file },
  1020. X    { "exec_file",            exec_file },
  1021. X    { "exit_pgm",            exit_pgm },
  1022. X    { "first_page",            first_page },
  1023. X    { "fork_shell",            fork_shell },
  1024. X    { "help_screen",        help_screen },
  1025. X    { "last_page",            last_page },
  1026. X    { "middle_line",        middle_line },
  1027. X    { "next_halfpage",        next_halfpage },
  1028. X    { "next_line",            next_line },
  1029. X    { "next_page",            next_page },
  1030. X    { "prev_halfpage",        prev_halfpage },
  1031. X    { "prev_line",            prev_line },
  1032. X    { "prev_page",            prev_page },
  1033. X    { "redraw_menu",        redraw_menu },
  1034. X    { "rm_file",            rm_file },
  1035. X    { "rm_tagged",            rm_tagged },
  1036. X    { "setup_menu",            setup_menu },
  1037. X    { "tag_all",             tag_all },
  1038. X    { "toggle_tag",            toggle_tag },
  1039. X    { "top_line",             top_line },
  1040. X    { "untag_all",            untag_all },
  1041. X    { "view_file",             view_file },
  1042. X    { "view_tagged",         view_tagged },
  1043. X    { "",                NULL }
  1044. X    };
  1045. X
  1046. X/* names of keys used in init files and keydef menu */
  1047. Xstruct keydef_entry keydef_table[] = {
  1048. X    { "AndSign",    '&' },
  1049. X    { "Asterisk",    '*' },
  1050. X    { "AtSign",    '@' },
  1051. X    { "BackQuote",    '`' },
  1052. X    { "BackSpace",    ControlH },
  1053. X    { "BackTab",    KEY_BackTab },
  1054. X    { "BackTick",    '`' },
  1055. X    { "Backslash",    '\\' },
  1056. X    { "Bang",    '!' },
  1057. X    { "Colon",    ':' },
  1058. X    { "Comma",    ',' },
  1059. X    { "ControlA",    ControlA },
  1060. X    { "ControlB",    ControlB },
  1061. X    { "ControlC",    ControlC },
  1062. X    { "ControlD",    ControlD },
  1063. X    { "ControlE",    ControlE },
  1064. X    { "ControlF",    ControlF },
  1065. X    { "ControlG",    ControlG },
  1066. X    { "ControlH",    ControlH },
  1067. X    { "ControlI",    ControlI },
  1068. X    { "ControlJ",    ControlJ },
  1069. X    { "ControlK",    ControlK },
  1070. X    { "ControlL",    ControlL },
  1071. X    { "ControlM",    ControlM },
  1072. X    { "ControlN",    ControlN },
  1073. X    { "ControlO",    ControlO },
  1074. X    { "ControlP",    ControlP },
  1075. X    { "ControlQ",    ControlQ },
  1076. X    { "ControlR",    ControlR },
  1077. X    { "ControlS",    ControlS },
  1078. X    { "ControlT",    ControlT },
  1079. X    { "ControlU",    ControlU },
  1080. X    { "ControlV",    ControlV },
  1081. X    { "ControlW",    ControlW },
  1082. X    { "ControlX",    ControlX },
  1083. X    { "ControlY",    ControlY },
  1084. X    { "ControlZ",    ControlZ },
  1085. X    { "Dash",    '-' },
  1086. X    { "Delete",    Delete },
  1087. X    { "Do",        KEY_F16 },
  1088. X    { "DollarSign",    '$' },
  1089. X    { "DoubleQuote",    '"' },
  1090. X    { "DownArrow",    KEY_DOWN },
  1091. X    { "Enter",    ControlM },
  1092. X    { "Equals",    '=' },
  1093. X    { "Exclamation",    '!' },
  1094. X    { "ExclamationPoint",    '!' },
  1095. X    { "F10",    KEY_F10 },
  1096. X    { "F11",    KEY_F11 },
  1097. X    { "F12",    KEY_F12 },
  1098. X    { "F13",    KEY_F13 },
  1099. X    { "F14",    KEY_F14 },
  1100. X    { "F15",    KEY_F15 },
  1101. X    { "F16",    KEY_F16 },
  1102. X    { "F17",    KEY_F17 },
  1103. X    { "F18",    KEY_F18 },
  1104. X    { "F19",    KEY_F19 },
  1105. X    { "F20",    KEY_F20 },
  1106. X    { "F6",        KEY_F6 },
  1107. X    { "F7",        KEY_F7 },
  1108. X    { "F8",        KEY_F8 },
  1109. X    { "F9",        KEY_F9 },
  1110. X    { "Find",    KEY_Find },
  1111. X    { "GreaterThan",    '>' },
  1112. X    { "HatSign",    '^' },
  1113. X    { "Help",    KEY_F15 },
  1114. X    { "InsertHere",    KEY_InsertHere },
  1115. X    { "KP0",    KEY_Pad0 },
  1116. X    { "KP00",    KEY_Pad00 },
  1117. X    { "KP1",    KEY_Pad1 },
  1118. X    { "KP2",    KEY_Pad2 },
  1119. X    { "KP3",    KEY_Pad3 },
  1120. X    { "KP4",    KEY_Pad4 },
  1121. X    { "KP5",    KEY_Pad5 },
  1122. X    { "KP6",    KEY_Pad6 },
  1123. X    { "KP7",    KEY_Pad7 },
  1124. X    { "KP8",    KEY_Pad8 },
  1125. X    { "KP9",    KEY_Pad9 },
  1126. X    { "KPComma",    KEY_PadComma },
  1127. X    { "KPEnter",    KEY_PadEnter },
  1128. X    { "KPMinus",    KEY_PadMinus },
  1129. X    { "KPPeriod",    KEY_PadPeriod },
  1130. X    { "LeftArrow",    KEY_LEFT },
  1131. X    { "LeftBrace",    '{' },
  1132. X    { "LeftBracket",    '[' },
  1133. X    { "LeftParen",    '(' },
  1134. X    { "LessThan",    '<' },
  1135. X    { "LineFeed",    ControlJ },
  1136. X    { "Minus",    '-' },
  1137. X    { "NextScreen",    KEY_NextScreen },
  1138. X    { "PF1",    KEY_PF1 },
  1139. X    { "PF2",    KEY_PF2 },
  1140. X    { "PF3",    KEY_PF3 },
  1141. X    { "PF4",    KEY_PF4 },
  1142. X    { "Paren",    '(' },
  1143. X    { "PercentSign",    '%' },
  1144. X    { "Period",    '.' },
  1145. X    { "Pipe",    '|' },
  1146. X    { "Plus",    '+' },
  1147. X    { "PrevScreen",    KEY_PrevScreen },
  1148. X    { "Question",    '?' },
  1149. X    { "QuestionMark",    '?' },
  1150. X    { "Quote",    '\'' },
  1151. X    { "Remove",    KEY_Remove },
  1152. X    { "Return",    ControlM },
  1153. X    { "RightArrow",    KEY_RIGHT },
  1154. X    { "RightBrace",    '}' },
  1155. X    { "RightBracket",    ']' },
  1156. X    { "RightParen",    ')' },
  1157. X    { "SDo",    KEY_SF16 },
  1158. X    { "SF10",    KEY_SF10 },
  1159. X    { "SF11",    KEY_SF11 },
  1160. X    { "SF12",    KEY_SF12 },
  1161. X    { "SF13",    KEY_SF13 },
  1162. X    { "SF14",    KEY_SF14 },
  1163. X    { "SF15",    KEY_SF15 },
  1164. X    { "SF16",    KEY_SF16 },
  1165. X    { "SF17",    KEY_SF17 },
  1166. X    { "SF18",    KEY_SF18 },
  1167. X    { "SF19",    KEY_SF19 },
  1168. X    { "SF20",    KEY_SF20 },
  1169. X    { "SF6",    KEY_SF6 },
  1170. X    { "SF7",    KEY_SF7 },
  1171. X    { "SF8",    KEY_SF8 },
  1172. X    { "SF9",    KEY_SF9 },
  1173. X    { "SHelp",    KEY_SF15 },
  1174. X    { "Select",    KEY_Select },
  1175. X    { "SemiColon",    ';' },
  1176. X    { "Sharp",    '#' },
  1177. X    { "Slash",    '/' },
  1178. X    { "Tab",    ControlI },
  1179. X    { "Tilde",    '~' },
  1180. X    { "UnParen",    ')' },
  1181. X    { "Underline",    '_' },
  1182. X    { "UpArrow",    KEY_UP },
  1183. X    { "^A",        ControlA },
  1184. X    { "^B",        ControlB },
  1185. X    { "^C",        ControlC },
  1186. X    { "^D",        ControlD },
  1187. X    { "^E",        ControlE },
  1188. X    { "^F",        ControlF },
  1189. X    { "^G",        ControlG },
  1190. X    { "^H",        ControlH },
  1191. X    { "^I",        ControlI },
  1192. X    { "^J",        ControlJ },
  1193. X    { "^K",        ControlK },
  1194. X    { "^L",        ControlL },
  1195. X    { "^M",        ControlM },
  1196. X    { "^N",        ControlN },
  1197. X    { "^O",        ControlO },
  1198. X    { "^P",        ControlP },
  1199. X    { "^Q",        ControlQ },
  1200. X    { "^R",        ControlR },
  1201. X    { "^S",        ControlS },
  1202. X    { "^T",        ControlT },
  1203. X    { "^U",        ControlU },
  1204. X    { "^V",        ControlV },
  1205. X    { "^W",        ControlW },
  1206. X    { "^X",        ControlX },
  1207. X    { "^Y",        ControlY },
  1208. X    { "^Z",        ControlZ },
  1209. X    { "",        0 }
  1210. X    };
  1211. END_OF_FILE
  1212.   if test 7455 -ne `wc -c <'readrc.h'`; then
  1213.     echo shar: \"'readrc.h'\" unpacked with wrong size!
  1214.   fi
  1215.   # end of 'readrc.h'
  1216. fi
  1217. if test -f 'runcmd.c' -a "${1}" != "-c" ; then 
  1218.   echo shar: Will not clobber existing file \"'runcmd.c'\"
  1219. else
  1220.   echo shar: Extracting \"'runcmd.c'\" \(7729 characters\)
  1221.   sed "s/^X//" >'runcmd.c' <<'END_OF_FILE'
  1222. X/*
  1223. X *    runcmd.c - parse and execute commands (both builting and external)
  1224. X *
  1225. X * This software is Copyright (c) 1989, 1990, 1991 by Patrick J. Wolfe.
  1226. X *
  1227. X * Permission is hereby granted to copy, distribute or otherwise 
  1228. X * use any part of this package as long as you do not try to make 
  1229. X * money from it or pretend that you wrote it.  This copyright 
  1230. X * notice must be maintained in any copy made.
  1231. X *
  1232. X * Use of this software constitutes acceptance for use in an AS IS 
  1233. X * condition. There are NO warranties with regard to this software.  
  1234. X * In no event shall the author be liable for any damages whatsoever 
  1235. X * arising out of or in connection with the use or performance of this 
  1236. X * software.  Any use of this software is at the user's own risk.
  1237. X *
  1238. X * If you make modifications to this software that you feel 
  1239. X * increases it usefulness for the rest of the community, please 
  1240. X * email the changes, enhancements, bug fixes as well as any and 
  1241. X * all ideas to me. This software is going to be maintained and 
  1242. X * enhanced as deemed necessary by the community.
  1243. X *              
  1244. X *              Patrick J. Wolfe
  1245. X *              uunet!uiucuxc!kailand!pwolfe
  1246. X *              pwolfe@kailand.kai.com
  1247. X */
  1248. X
  1249. X
  1250. X#include "config.h"
  1251. X
  1252. Xextern SIGTYPE die();
  1253. X#ifdef NEED_TSTP
  1254. X#define TSTP_RTN _tstp
  1255. X#else
  1256. X#define TSTP_RTN tstp
  1257. X#endif
  1258. Xextern SIGTYPE TSTP_RTN();
  1259. Xextern struct dblock cwd[];
  1260. Xextern WINDOW *headwin, *datawin, *helpwin;
  1261. Xextern int lastptr, curptr, opt_auto_untag;
  1262. X
  1263. X
  1264. X/*
  1265. X *    1.  Break command line into arguments
  1266. X *        Copies command to "command_line", placing null's between arguments,
  1267. X *        and adding pointers to "arglist" to the beginning of each argument.
  1268. X *        Counts the number of arguments found.
  1269. X *
  1270. X *    2.  Append filenames to the command
  1271. X *        Depending on the options specified, add the current filename, all
  1272. X *        tagged filenames, or no filenames to the end of the built command.
  1273. X *
  1274. X *    3.  Run the passed command.
  1275. X */
  1276. Xvoid
  1277. Xdo_cmd (command, options)
  1278. Xchar    *command;
  1279. Xint    options;
  1280. X{
  1281. Xunion    wait    status;
  1282. Xint    argc, ctr1, ctr2, row = 2, cpid, dpid;
  1283. Xint c;
  1284. Xchar    *ptr1, *ptr2, *arglist[MAXARGS],
  1285. X    command_line[10240];
  1286. X
  1287. Xmvcur (0, COLS-1, LINES-1, 0);
  1288. Xrefresh ();
  1289. Xargc = 0;
  1290. Xptr1 = command;
  1291. Xptr2 = command_line;
  1292. X
  1293. Xwhile (1) {
  1294. X    /* skip over white space */
  1295. X    for (; (*ptr1 != '\0') && isspace(*ptr1); ptr1++);
  1296. X    if (*ptr1 == '\0') {
  1297. X        break;
  1298. X        }
  1299. X
  1300. X    /* mark beginning of argument */
  1301. X    arglist[argc] = ptr2;
  1302. X#ifdef DEBUG
  1303. X    fprintf (stderr, "starting argument %d at %s\n", argc, ptr1);
  1304. X#endif
  1305. X
  1306. X    /* find end of current argument */
  1307. X    for (ctr1 = ctr2 = 0; *ptr1 != '\0'; ptr1++, ptr2++) {
  1308. X        if (isspace (*ptr1) && (ctr1 == 0) && (ctr2 == 0)) {
  1309. X            break;        /* stop at first whitespace outsite quotes */
  1310. X            }
  1311. X        if (*ptr1 == '\\') {
  1312. X            ptr1++;
  1313. X            if (*ptr1 == '\0') {
  1314. X                break;    /* the line ends in a bad old backslash */
  1315. X                }
  1316. X            }
  1317. X        else if ((*ptr1 == '"') && (ctr2 == 0)) {    /* keep track of double quotes */
  1318. X            ctr1 = (ctr1 * -1) + 1;
  1319. X            }
  1320. X        else if ((*ptr1 == '\'') && (ctr1 == 0)) {    /* keep track of single quotes */
  1321. X            ctr2 = (ctr2 * -1) + 1;
  1322. X            }
  1323. X        *ptr2 = *ptr1;
  1324. X        }
  1325. X
  1326. X    /* mark end of current argument, and advance to next char */
  1327. X    *ptr2 = '\0';
  1328. X    ptr2++;
  1329. X
  1330. X#ifdef DEBUG
  1331. X    fprintf (stderr, "arg %d length=%d bytes, value = \"%s\"\n", argc, strlen(arglist[argc]), arglist[argc]);
  1332. X    sleep (2);
  1333. X#endif
  1334. X
  1335. X    /* check to see if this is the special argument of a pair of curly or hard braces */
  1336. X    if ((strlen(arglist[argc]) == 2) && (((arglist[argc][0] == '{') && (arglist[argc][1] == '}'))
  1337. X        || ((arglist[argc][0] == '[') && (arglist[argc][1] == ']')))) {
  1338. X        options &= OPT_TAGALL;    /* turn off tag all and tag current options */
  1339. X        options &= OPT_TAGCUR;
  1340. X        /* replace this argument with the list of all tagged files */
  1341. X        for (ctr1 = 0; (ctr1 <= lastptr) && (argc < MAXARGS); ctr1++) {
  1342. X            if (cwd[ctr1].selected) {
  1343. X                arglist[argc++] = cwd[ctr1].name;
  1344. X                if (opt_auto_untag) {
  1345. X                    cwd[ctr1].selected = 0;
  1346. X                    }
  1347. X                }
  1348. X            }
  1349. X        }
  1350. X    else    {
  1351. X        argc++;
  1352. X        }
  1353. X
  1354. X    /* if at end of input command, stop here */
  1355. X    if (*ptr1 == '\0') {
  1356. X        break;
  1357. X        }
  1358. X    }
  1359. X
  1360. Xif (argc == 0) {
  1361. X    return;        /* no command to execute */
  1362. X    }
  1363. X
  1364. Xif (options & OPT_TAGCUR) {        /* append filename currently being pointed at to the command */
  1365. X    arglist[argc++] = cwd[curptr].name;
  1366. X    cwd[curptr].size = -1;            /* set flag so this file gets re-stat'd */
  1367. X    }
  1368. X
  1369. Xelse if (options & OPT_TAGALL) {    /* append names of all tagged files to the command */
  1370. X    for (ctr2 = 0; (ctr2 <= lastptr) && (argc < MAXARGS); ctr2++) {
  1371. X        if (cwd[ctr2].selected) {
  1372. X            arglist[argc++] = cwd[ctr2].name;
  1373. X            if (opt_auto_untag) {
  1374. X                cwd[ctr2].selected = 0;
  1375. X                }
  1376. X            cwd[ctr2].size = -1;    /* set flag so these files get re-stat'd */
  1377. X            }
  1378. X        }
  1379. X    }
  1380. X
  1381. Xarglist[argc] = 0;
  1382. X
  1383. X/* clear the screen, reset the terminal to normal mode, and run the command */
  1384. Xwmove (helpwin, 0, 0);
  1385. Xwclrtobot (helpwin);
  1386. Xwrefresh (helpwin);
  1387. Xwmove (datawin, 0, 0);
  1388. Xwclrtobot (datawin);
  1389. Xwrefresh (datawin);
  1390. Xwmove (headwin, row, 0);
  1391. Xwclrtobot (headwin);
  1392. Xwmove (headwin, row, 0);
  1393. X
  1394. X/* let the user know what we are doing */
  1395. Xwaddstr (headwin, "Running the command: ");
  1396. Xfor (ctr1 = 0, ctr2 = 0; (row <= 3) && (arglist[ctr1] != 0); ctr1++) {
  1397. X    ctr2 += 1 + strlen (arglist[ctr1]);
  1398. X    if (ctr2 > 79) {
  1399. X        row++;
  1400. X        wmove (headwin, row, 4);
  1401. X        ctr2 = 4 + strlen (arglist[ctr1]);
  1402. X        }
  1403. X    else    {
  1404. X        waddch (headwin, ' ');
  1405. X        }
  1406. X    waddstr (headwin, arglist[ctr1]);
  1407. X    }
  1408. X
  1409. Xif (options & OPT_VERIFY) {
  1410. X    c = 'a';
  1411. X    while ((c != 'y') && (c != 'Y') && (c != 'N') && (c != 'n')) {
  1412. X        wmove (headwin, 4, 0);
  1413. X        waddstr (headwin, "Are you sure? ");
  1414. X        wrefresh (headwin);
  1415. X        c = my_getch (headwin);
  1416. X        }
  1417. X    if ((c != 'y') && (c != 'Y')) {
  1418. X        redraw_menu ();
  1419. X        return;
  1420. X        }
  1421. X    }
  1422. Xelse
  1423. X    wrefresh (headwin);
  1424. X
  1425. Xwmove (datawin, 0, 0);
  1426. Xwrefresh (datawin);
  1427. X#ifdef SYSVcurses
  1428. Xdelwin (datawin);
  1429. Xdelwin (helpwin);
  1430. Xdelwin (helpwin);
  1431. Xendwin();        /* terminate curses */
  1432. X#else /* ! SYSVcurses */
  1433. Xecho ();        /* echo keys as they are typed */
  1434. Xnl ();            /* enable cr/lf mapping */
  1435. Xnocrmode ();        /* turn off cbreak mode */
  1436. X#endif /* SYSVcurses */
  1437. Xsignal (SIGHUP, SIG_DFL);            /* trap signal 1, hangup */
  1438. Xsignal (SIGINT, SIG_DFL);            /* trap signal 2, interrupt */
  1439. Xsignal (SIGQUIT, SIG_DFL);            /* trap signal 3, quit */
  1440. Xsignal (SIGTERM, SIG_DFL);            /* trap signal 15, software termination */
  1441. Xsignal (SIGTSTP, SIG_IGN);            /* trap signal 15, software termination */
  1442. X
  1443. Xif ((cpid = fork()) == 0) {
  1444. X    execvp (arglist[0], arglist);
  1445. X    perror ("execvp");
  1446. X    fprintf (stderr, "scan:  cannot execute %s\r\n", arglist[0]);
  1447. X    exit (-1);
  1448. X    }
  1449. Xif (cpid == -1) {
  1450. X    perror ("fork");
  1451. X    exit (-1);
  1452. X    }
  1453. Xsignal (SIGINT, SIG_IGN);            /* restore signal 2, interrupt */
  1454. Xsignal (SIGQUIT, SIG_IGN);            /* restore signal 3, quit */
  1455. X
  1456. X/* wait until our baby dies */
  1457. Xdo    {
  1458. X    dpid = wait (&status);
  1459. X    } while ((dpid != cpid) && (dpid != -1));
  1460. X
  1461. Xif (status.w_T.w_Termsig != 0) {
  1462. X    fprintf (stderr, "\r\ncommand was killed by signal #%d ", status.w_T.w_Termsig);
  1463. X    }
  1464. Xelse if (status.w_T.w_Retcode != 0) {
  1465. X    fprintf (stderr, "\r\ncommand returned error status code %d", status.w_T.w_Retcode);
  1466. X    }
  1467. X
  1468. X#ifdef SYSVcurses
  1469. Xinitscr ();            /* initialize curses */
  1470. X#endif
  1471. Xsignal (SIGHUP, die);        /* trap signal 1, hangup */
  1472. Xsignal (SIGINT, die);        /* trap signal 2, interrupt */
  1473. Xsignal (SIGQUIT, die);        /* trap signal 3, quit */
  1474. Xsignal (SIGTERM, die);        /* trap signal 15, software termination */
  1475. Xsignal (SIGTSTP, TSTP_RTN);    /* trap tstp signal */
  1476. Xnoecho ();            /* curses should not echo keys as they are typed */
  1477. Xnonl ();            /* disable cr/lf mapping */
  1478. Xcrmode ();            /* turn on cbreak mode */
  1479. X#ifdef SYSVcurses
  1480. Xheadwin = newwin (5, COLS, 0, 0);
  1481. Xdatawin = newwin (PAGESIZE, COLS, 5, 0);
  1482. Xhelpwin = newwin (1, COLS, PAGESIZE + 5, 0);
  1483. Xidlok (datawin, TRUE);
  1484. X#endif
  1485. X
  1486. Xif ( (options & OPT_WAIT) || ((options & OPT_WAITERR) && (status.w_T.w_Retcode != 0)) ) {
  1487. X    fprintf (stderr, " -- press Return to continue");
  1488. X    my_getch (headwin);
  1489. X    }
  1490. X
  1491. Xredraw_menu ();
  1492. X}
  1493. END_OF_FILE
  1494.   if test 7729 -ne `wc -c <'runcmd.c'`; then
  1495.     echo shar: \"'runcmd.c'\" unpacked with wrong size!
  1496.   fi
  1497.   # end of 'runcmd.c'
  1498. fi
  1499. if test -f 'scan.1' -a "${1}" != "-c" ; then 
  1500.   echo shar: Will not clobber existing file \"'scan.1'\"
  1501. else
  1502.   echo shar: Extracting \"'scan.1'\" \(8428 characters\)
  1503.   sed "s/^X//" >'scan.1' <<'END_OF_FILE'
  1504. X...
  1505. X.TH SCAN 1 "4.0" "Usenet software" "Usenet software"
  1506. X
  1507. X.SH NAME
  1508. Xscan - directory menu
  1509. X
  1510. X.SH SYNOPSIS
  1511. Xscan [directory]
  1512. X
  1513. X.SH DESCRIPTION
  1514. X.I Scan
  1515. Xdisplays a menu containing information about all the files contained in
  1516. Xa directory, and lets you perform common operations on them.
  1517. X
  1518. XYou may optionally specify a directory name to begin with.
  1519. XWith no directory names on the command line,
  1520. X.I scan
  1521. Xwill begin in the current directory.
  1522. X
  1523. X.SH "WHAT'S ON THE SCREEN"
  1524. XThe screen that
  1525. X.I Scan
  1526. Xdisplays can be broken into to three areas.
  1527. X
  1528. XThe top few lines display the program's
  1529. Xname and version number, your login id, the date and time, and
  1530. Xthe occational error message.  Also shown is
  1531. Xthe name of current directory, the total
  1532. Xnumber of files in the directory, and the number of hidden files (if any).
  1533. XHidden files are "dot files" which aren't currently being shown (see the
  1534. XOPTIONS section later).
  1535. X
  1536. XThe last line of the display is used to display some help.
  1537. X
  1538. XThe rest of the screen is used by the file menu.
  1539. X
  1540. X.SH "USING THE FILE MENU"
  1541. XThe file menu resembles the output of an "ls -l" command.  Displayed are
  1542. Xthe file's permissions, owner and group name, size (in bytes),
  1543. Xthe date of the most recent modification, and filename.  If the name
  1544. Xis too long, it may be truncated in the display.  If the "show-filetype"
  1545. Xoption is turned on, a slash will be appended to subdirectory names,
  1546. Xand an asterisk to executable files.  If the "show-symlinks"
  1547. Xoption is turned on, symbolic links will display the file the link points to
  1548. Xafter the file name.
  1549. X
  1550. XSome functions of Scan operate on the current file.
  1551. XThe "current file" is what we call the file which has the little arrow ("=>") pointing to
  1552. Xit's name.  The up and down arrow keys (also the "j" and "k" keys) move the current file
  1553. Xpointer up and down on the file menu.
  1554. X
  1555. XFiles may also be "tagged".
  1556. XWhen a file is "tagged", it's line on the screen is highlighted.
  1557. XSome functions of Scan operate on all tagged files at once.
  1558. XThe "m" key toggles the "tagged" status of any file.
  1559. XTagged files are discussed more fully in the section "USING THE TAG FEATURE".
  1560. X
  1561. XThere are a number of ways to move around the file menu display:
  1562. X
  1563. X.br
  1564. Xcontrol-F
  1565. X.br
  1566. X.in +10
  1567. Xscroll forward (down) one screen
  1568. X.in -10
  1569. X.br
  1570. Xcontrol-B
  1571. X.br
  1572. X.in +10
  1573. Xscroll backward (up) one screen
  1574. X.in -10
  1575. X.br
  1576. Xcontrol-D
  1577. X.br
  1578. X.in +10
  1579. Xscroll down one half screen
  1580. X.in -10
  1581. X.br
  1582. Xcontrol-U
  1583. X.br
  1584. X.in +10
  1585. Xscroll up one half screen
  1586. X.in -10
  1587. X.br
  1588. X"down-arrow" or "j"
  1589. X.br
  1590. X.in +10
  1591. Xmoves down one file on the menu
  1592. X.in -10
  1593. X.br
  1594. X"up-arrow" or "k"
  1595. X.br
  1596. X.in +10
  1597. Xmoves up one file on the menu
  1598. X.in -10
  1599. X.br
  1600. X"g"
  1601. X.br
  1602. X.in +10
  1603. X(top) moves to the first page of the menu
  1604. X.in -10
  1605. X.br
  1606. X"G"
  1607. X.br
  1608. X.in +10
  1609. X(bottom) moves to the last page of the menu
  1610. X.in -10
  1611. X.br
  1612. X"H"
  1613. X.br
  1614. X.in +10
  1615. X(high) moves to the first line of the current page
  1616. X.in -10
  1617. X.br
  1618. X"M"
  1619. X.br
  1620. X.in +10
  1621. X(middle) moves to the middle line of the current page
  1622. X.in -10
  1623. X.br
  1624. X"L"
  1625. X.br
  1626. X.in +10
  1627. X(low) moves to the last line of the current page
  1628. X.in -10
  1629. X.br
  1630. X
  1631. X
  1632. XThere are also several commands to change which directory you are "scanning":
  1633. X
  1634. X.br
  1635. X"d" or Return
  1636. X.br
  1637. X.in +10
  1638. X(down) change directory to the current file (the file the "==>" is pointing to)
  1639. X.in -10
  1640. X.br
  1641. X"u"
  1642. X.br
  1643. X.in +10
  1644. X(up) change directory to the parent of the current directory
  1645. X.in -10
  1646. X.br
  1647. X"b"
  1648. X.br
  1649. X.in +10
  1650. X(back) change directory to the last directory you "scanned"
  1651. X.in -10
  1652. X.br
  1653. X"c"
  1654. X.br
  1655. X.in +10
  1656. X(cd) prompts for a directory path to cd to.
  1657. X.in -10
  1658. X.br
  1659. X"/"
  1660. X.br
  1661. X.in +10
  1662. Xchange directory to the root directory
  1663. X.in -10
  1664. X.br
  1665. X"~"
  1666. X.br
  1667. X.in +10
  1668. Xchange directory to your home directory
  1669. X.in -10
  1670. X.br
  1671. X"."
  1672. X.br
  1673. X.in +10
  1674. Xre-scans the current directory (useful if some files where added or deleted)
  1675. X.in -10
  1676. X
  1677. XHere are a few common actions that you can do to a file, without using the command line.
  1678. XThe "tag" feature is described in more detail in the section "USING THE TAG FEATURE".
  1679. X
  1680. X.br
  1681. X"e" or Return
  1682. X.br
  1683. X.in +10
  1684. Xedits the current file.  It will use the value of the "EDITOR"
  1685. Xenvironment variable, if this is set, and defaults to "vi".
  1686. X.in -10
  1687. X.br
  1688. X"v"
  1689. X.br
  1690. X.in +10
  1691. Xview the current file.  It will use the value of the "PAGER"
  1692. Xenvironment variable, if this is set, and defaults to "more".
  1693. X.in -10
  1694. X.br
  1695. X"r"
  1696. X.br
  1697. X.in +10
  1698. Xremoves the current file, after verifying with you that this is okay.
  1699. X.in -10
  1700. X.br
  1701. X"x"
  1702. X.br
  1703. X.in +10
  1704. Xprompts for a command, and executes it appending the current filename
  1705. X.in -10
  1706. X.br
  1707. X"E", "V", "R" and "X"
  1708. X.br
  1709. X.in +10
  1710. Xare the same as "e", "v", "r" and "x", except that they work
  1711. Xon all the tagged files, instead of just the current file.
  1712. X.in -10
  1713. X.br
  1714. X"m" or LineFeed
  1715. X.br
  1716. X.in +10
  1717. Xtoggles the "tagged" status of the current file.
  1718. X.in -10
  1719. X.br
  1720. X"T"
  1721. X.br
  1722. X.in +10
  1723. Xtags every file.
  1724. X.in -10
  1725. X.br
  1726. X"U"
  1727. X.br
  1728. X.in +10
  1729. Xuntags every file.
  1730. X.in -10
  1731. X.br
  1732. X
  1733. X
  1734. XThe rest of the commands perform miscellaneous tasks:
  1735. X
  1736. X.br
  1737. X"S"
  1738. X.br
  1739. X.in +10
  1740. XEnter the SETUP mode, used to change key definitions or option values
  1741. X.in -10
  1742. X.br
  1743. X"q" or "Q"
  1744. X.br
  1745. X.in +10
  1746. Xquit the Scan program.
  1747. X.in -10
  1748. X.br
  1749. X"!" or "%"
  1750. X.br
  1751. X.in +10
  1752. Xforks a shell (using your SHELL)
  1753. X.in -10
  1754. X.br
  1755. X"control-L" or "control-R"
  1756. X.br
  1757. X.in +10
  1758. Xredraws the screen
  1759. X.in -10
  1760. X.br
  1761. X
  1762. X.SH "USING THE TAG FEATURE"
  1763. XTagging files is an easy way to operate on multiple files at one time.
  1764. X
  1765. XYou can tag files by moving the current file pointer and pressing the "m"
  1766. Xkey.  Tagged files are highlighted on the screen.  The "m" key toggles the tagged status
  1767. Xof a file, so to un-tag a file, just press "m" again.  The "T" key tags all files (except hidden files) in the
  1768. Xcurrent directory, and "U" untags all files.
  1769. X
  1770. XSome of the file menu commands (C,E,R,V) operate on all tagged files at once.
  1771. X
  1772. XFor example, you can edit a whole range of files by moving up and down the file menu, tagging all
  1773. Xthe files you want to edit, and then pressing "E".
  1774. X
  1775. XAfter a commands which uses tagged files is executed, all files are un-tagged automatically, unless
  1776. Xthe "auto-untag" option is turned off.
  1777. X
  1778. X.SH SETUP
  1779. XThe "setup_menu" lets you choose between defining keys and changing values of options.  Once you
  1780. Xhave customized options and keys to your desire, remember to save your changes.  A ".scanrc" file
  1781. Xwill be written for you.
  1782. X
  1783. XThere are several options which you may want to change:
  1784. X
  1785. X.br
  1786. X    option        valid values (*=default value)
  1787. X.br
  1788. X    ------        ------------------------------
  1789. X.br
  1790. X    auto_untag    *true, false
  1791. X.br
  1792. X                        If true, operations on tagged files cause the files to be untagged.
  1793. X.br
  1794. X    dir_order    first, last, *sort
  1795. X.br
  1796. X                        Where to put the directory names in the file menu, top, bottom, or sorted (like ls)
  1797. X.br
  1798. X    dot_order    first, *last, hide
  1799. X.br
  1800. X                        Where to put the dot files, at top of list, bottom of list, or hide them
  1801. X.br
  1802. X    dotdir_order    *withdot, withdir
  1803. X.br
  1804. X                        Where to put dot-directory names, with dot files or with other directories
  1805. X.br
  1806. X    hide_dotdot    *true, false
  1807. X.br
  1808. X                        If true, "." and ".." are not shown
  1809. X.br
  1810. X    pause_pager    *true, false
  1811. X.br
  1812. X                        If true, pauses after your "PAGER" is executed
  1813. X.br
  1814. X    rm_prompt    *true, false
  1815. X.br
  1816. X                        If true, verifies before removing files or directories
  1817. X.br
  1818. X    show_filetype    *true, false
  1819. X.br
  1820. X                        If true, appends "/" to directory names and "*" to executable files
  1821. X.br
  1822. X    show_symlinks    *true, false
  1823. X.br
  1824. X                        If true, shows files that symbolic links point to
  1825. X
  1826. X.SH ORIGIN
  1827. XThe first Unix version of
  1828. X.I scan
  1829. Xwas written in 1989 in the C language by Patrick Wolfe (pat@kai.com,
  1830. Xkailand!pat).
  1831. XVersion 4 was updated in April 1991 and release to the Usenet
  1832. Xcommunity in May 1991.
  1833. X
  1834. X.SH COPYRIGHT
  1835. X.I Scan
  1836. Xis Copyright (c) 1989, 1990, 1991 by Patrick J. Wolfe.
  1837. X
  1838. XPermission is hereby granted to copy, distribute or otherwise 
  1839. Xuse any part of this package as long as you do not try to make 
  1840. Xmoney from it or pretend that you wrote it.  This copyright 
  1841. Xnotice must be maintained in any copy made.
  1842. X
  1843. XUse of this software constitutes acceptance for use in an AS IS 
  1844. Xcondition. There are NO warranties with regard to this software.  
  1845. XIn no event shall the author be liable for any damages whatsoever 
  1846. Xarising out of or in connection with the use or performance of this 
  1847. Xsoftware.  Any use of this software is at the user's own risk.
  1848. X
  1849. XIf you make modifications to this software that you feel 
  1850. Xincreases it usefulness for the rest of the community, please 
  1851. Xemail the changes, enhancements, bug fixes as well as any and 
  1852. Xall ideas to me. This software is going to be maintained and 
  1853. Xenhanced as deemed necessary by the community.
  1854. X
  1855. END_OF_FILE
  1856.   if test 8428 -ne `wc -c <'scan.1'`; then
  1857.     echo shar: \"'scan.1'\" unpacked with wrong size!
  1858.   fi
  1859.   # end of 'scan.1'
  1860. fi
  1861. if test -f 'setupmenu.c' -a "${1}" != "-c" ; then 
  1862.   echo shar: Will not clobber existing file \"'setupmenu.c'\"
  1863. else
  1864.   echo shar: Extracting \"'setupmenu.c'\" \(2599 characters\)
  1865.   sed "s/^X//" >'setupmenu.c' <<'END_OF_FILE'
  1866. X
  1867. X/*
  1868. X * This software is Copyright (c) 1989, 1990, 1991 by Patrick J. Wolfe.
  1869. X *
  1870. X * Permission is hereby granted to copy, distribute or otherwise 
  1871. X * use any part of this package as long as you do not try to make 
  1872. X * money from it or pretend that you wrote it.  This copyright 
  1873. X * notice must be maintained in any copy made.
  1874. X *
  1875. X * Use of this software constitutes acceptance for use in an AS IS 
  1876. X * condition. There are NO warranties with regard to this software.  
  1877. X * In no event shall the author be liable for any damages whatsoever 
  1878. X * arising out of or in connection with the use or performance of this 
  1879. X * software.  Any use of this software is at the user's own risk.
  1880. X *
  1881. X * If you make modifications to this software that you feel 
  1882. X * increases it usefulness for the rest of the community, please 
  1883. X * email the changes, enhancements, bug fixes as well as any and 
  1884. X * all ideas to me. This software is going to be maintained and 
  1885. X * enhanced as deemed necessary by the community.
  1886. X *              
  1887. X *              Patrick J. Wolfe
  1888. X *              uunet!uiucuxc!kailand!pwolfe
  1889. X *              pwolfe@kailand.kai.com
  1890. X */
  1891. X
  1892. X#include "config.h"
  1893. X
  1894. Xextern int redraw_menu();
  1895. Xextern int init_defaults();
  1896. Xextern int options_changed, keydef_changed;
  1897. Xextern char rcfilename[];
  1898. X
  1899. X
  1900. Xstatic void
  1901. Xsetup_redraw ()
  1902. X{
  1903. Xint row = 5;
  1904. X
  1905. Xclear();
  1906. Xmvaddstr (1, 30, PGM_VERSION);
  1907. Xaddstr (" Setup Menu");
  1908. Xmvaddstr (row++, 30, "K - key definition menu");
  1909. Xmvaddstr (row++, 30, "O - options menu");
  1910. Xmvaddstr (row++, 30, "S - save changes to setup");
  1911. Xmvaddstr (row++, 30, "D - restore default setup");
  1912. Xmvaddstr (row++, 30, "Q - save changes and exit setup");
  1913. Xmvaddstr (row, 30, "X - exit setup without saving changes");
  1914. Xrefresh ();
  1915. X}
  1916. X
  1917. X
  1918. Xsave_setup ()
  1919. X{
  1920. Xmvaddstr (3, 10, "saving setup ... please wait");
  1921. Xrefresh ();
  1922. X
  1923. Xwriterc ();
  1924. Xoptions_changed = keydef_changed = 0;
  1925. X
  1926. Xmove (3, 10);
  1927. Xclrtoeol ();
  1928. Xmvprintw (3, 10, "Your setup has been saved");
  1929. Xrefresh ();
  1930. X}
  1931. X
  1932. X
  1933. Xsetup_menu ()
  1934. X{
  1935. Xint c;
  1936. X
  1937. Xsetup_redraw ();
  1938. Xwhile (1) {
  1939. X    c = my_getch (stdscr);
  1940. X    switch (c) {
  1941. X    case 'D':
  1942. X    case 'd':
  1943. X        init_defaults ();
  1944. X        break;
  1945. X
  1946. X    case 'K':
  1947. X    case 'k':
  1948. X        clear ();
  1949. X        refresh ();
  1950. X        keydef_menu ();
  1951. X        setup_redraw ();
  1952. X        break;
  1953. X
  1954. X    case 'O':
  1955. X    case 'o':
  1956. X        clear ();
  1957. X        refresh ();
  1958. X        options_menu ();
  1959. X        setup_redraw ();
  1960. X        break;
  1961. X
  1962. X    case 'S':
  1963. X    case 's':
  1964. X        save_setup ();
  1965. X        break;
  1966. X
  1967. X    case 'Q':
  1968. X    case 'q':
  1969. X        if (options_changed || keydef_changed) {
  1970. X            save_setup ();
  1971. X            do_chdir (".");
  1972. X            }
  1973. X        else
  1974. X            redraw_menu();
  1975. X        return;
  1976. X        
  1977. X    case 'X':
  1978. X    case 'x':
  1979. X        if (options_changed)
  1980. X            do_chdir (".");
  1981. X        else
  1982. X            redraw_menu();
  1983. X        return;
  1984. X
  1985. X    default:
  1986. X        fprintf (stderr, "\007");
  1987. X        }
  1988. X    }
  1989. X}
  1990. END_OF_FILE
  1991.   if test 2599 -ne `wc -c <'setupmenu.c'`; then
  1992.     echo shar: \"'setupmenu.c'\" unpacked with wrong size!
  1993.   fi
  1994.   # end of 'setupmenu.c'
  1995. fi
  1996. echo shar: End of archive 3 \(of 3\).
  1997. cp /dev/null ark3isdone
  1998. MISSING=""
  1999. for I in 1 2 3 ; do
  2000.     if test ! -f ark${I}isdone ; then
  2001.     MISSING="${MISSING} ${I}"
  2002.     fi
  2003. done
  2004. if test "${MISSING}" = "" ; then
  2005.     echo You have unpacked all 3 archives.
  2006.     rm -f ark[1-9]isdone
  2007. else
  2008.     echo You still must unpack the following archives:
  2009.     echo "        " ${MISSING}
  2010. fi
  2011. exit 0
  2012. exit 0 # Just in case...
  2013. -- 
  2014. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  2015. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  2016. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  2017. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  2018.