home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume35 / ipick / part04 < prev    next >
Encoding:
Text File  |  1993-03-03  |  60.6 KB  |  2,484 lines

  1. Newsgroups: comp.sources.misc
  2. From: markd@werple.apana.org.au (Mark Delany)
  3. Subject: v35i120:  ipick - an interactive filter to pick lines, Part04/05
  4. Message-ID: <1993Mar4.195049.11822@sparky.imd.sterling.com>
  5. X-Md4-Signature: 84565f428586368be9e3e2080e39ae65
  6. Date: Thu, 4 Mar 1993 19:50:49 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: markd@werple.apana.org.au (Mark Delany)
  10. Posting-number: Volume 35, Issue 120
  11. Archive-name: ipick/part04
  12. Environment: UNIX, Curses
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then feed it
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  19. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  20. # Contents:  ipick/rc.c ipick/ipick.1 ipick/config/TEMPLATE
  21. #   ipick/config/interactive-gcc ipick/config/linux
  22. #   ipick/config/mtxinu ipick/config/sunos4 ipick/config/sunos4-tcap
  23. #   ipick/config/svr3 ipick/config/ultrix ipick/config/vanilla
  24. #   ipick/config/xenix386 ipick/config/xenix386-gcc
  25. #   ipick/examples/README ipick/examples/ikillps
  26. #   ipick/examples/ikillpt ipick/examples/ilprm ipick/examples/imenu
  27. #   ipick/examples/irm ipick/examples/itarx
  28. # Wrapped by markd@bushwire on Sun Feb 28 10:06:38 1993
  29. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  30. echo If this archive is complete, you will see the following message:
  31. echo '          "shar: End of archive 4 (of 5)."'
  32. if test -f 'ipick/rc.c' -a "${1}" != "-c" ; then 
  33.   echo shar: Will not clobber existing file \"'ipick/rc.c'\"
  34. else
  35.   echo shar: Extracting \"'ipick/rc.c'\" \(12303 characters\)
  36.   sed "s/^X//" >'ipick/rc.c' <<'END_OF_FILE'
  37. X/* $Id: rc.c,v 1.1 1993/02/27 21:48:01 markd Exp $
  38. X *
  39. X * Handle the decoding of the rc files.
  40. X *
  41. X *    Copyright (c) 1993, Mark Delany
  42. X *
  43. X *    You may distribute under the terms of either the GNU General Public
  44. X *    License or the Artistic License, as specified in the README file.
  45. X *
  46. X * $Log: rc.c,v $
  47. X * Revision 1.1  1993/02/27  21:48:01  markd
  48. X * Initial revision
  49. X *
  50. X */
  51. X
  52. X#include "ipick.h"
  53. X
  54. X/*
  55. X * Order of load is ~/.ipickrc then SYSTEM_RCFILE.
  56. X *
  57. X * Comments are denoted by the # character. Blank lines are ignored.
  58. X *
  59. X * Valid commands are:
  60. X *
  61. X * bind-key          function    keysequence         [help-text]
  62. X * bind-terminfo    function    terminfo-capability    [help-text]
  63. X * bind-termcap        function    termcap-capability    [help-text]
  64. X * include        includefile
  65. X *
  66. X *
  67. X * Valid functions are those defined cmd_list in keyboard.c
  68. X *
  69. X * The keysequence in bind-key has the following escape characters:
  70. X * 
  71. X *     ^X    Control X
  72. X *    \e    Escape
  73. X *    \n    Linefeed
  74. X *    \r    Return
  75. X *    \t    Tab
  76. X *    \b    Backspace
  77. X *    \f    Formfeed
  78. X *    \\    \
  79. X *    \^    ^
  80. X *    \@    @
  81. X *    \NNN    Octal
  82. X *
  83. X * The includefile can be prefixed by ~ in which case, the tilde will
  84. X * be converted to $HOME. ~name/... is not supported.
  85. X */
  86. X
  87. X
  88. X#define    MAX_TOKENS        4
  89. X#define    MAX_TOKEN_SIZE        50
  90. X
  91. X#define    RC_BAD_TILDE        -2    /* ~[name]/ failed */
  92. X#define    RC_OPEN_FAILED        -1    /* File does not exist */
  93. X#define    RC_PARSE_BAD        0    /* The parse failed in some way */
  94. X#define    RC_PARSE_OK        1    /* All Ok */
  95. X
  96. X
  97. X#define    COMMENT_CHAR        '#'
  98. X#define    SINGLE_QUOTE        '\''
  99. X#define    DOUBLE_QUOTE        '"'
  100. X
  101. X#define    SHELL_CHARS        "!$*`\?[()| "    /* Includes space! */
  102. X
  103. X
  104. X/*
  105. X * An include file can be opened with either popen of fopen. This has
  106. X * to be tracked so that it can be closed correctly with pclose or
  107. X * fclose respectively.
  108. X */
  109. X
  110. Xtypedef    struct    my_file_s {
  111. X    FILE    *fp;
  112. X    int        use_pclose;
  113. X} MY_FILE;
  114. X
  115. X
  116. Xstatic    int    tokenize();
  117. Xstatic    MY_FILE    *my_fopen();
  118. Xstatic    int    my_fclose();
  119. X
  120. Xstatic    int    load_tilde_file();
  121. Xstatic    int    load_normal_file();
  122. Xstatic    int    parse_file();
  123. Xstatic    char    *bind_key();
  124. Xstatic    char    *bind_termcap();
  125. Xstatic    char    *bind_terminfo();
  126. Xstatic    char    *include();
  127. X
  128. Xtypedef struct    {
  129. X    char    *name;
  130. X    int        min_args;
  131. X    int        max_args;
  132. X    char    *(*handler)();
  133. X} CMD_MAP;
  134. X
  135. Xstatic    CMD_MAP    cmd_map[] = {
  136. X
  137. X"bind-key", 3, 4, bind_key,
  138. X"bind-termcap", 3, 4, bind_termcap,
  139. X"bind-terminfo", 3, 4, bind_terminfo,
  140. X"include", 2, 2, include,
  141. X
  142. XNULL };
  143. X
  144. X
  145. Xextern    int
  146. Xrc_init()
  147. X
  148. X{
  149. X
  150. X/* Order is [internal bindings, termcap, terminfo,] system rc then local rc */
  151. X
  152. X#ifdef    SYSTEM_RCFILE
  153. X
  154. X    if (*SYSTEM_RCFILE) {
  155. X    if (load_normal_file(SYSTEM_RCFILE) == 0) return FALSE;
  156. X    }
  157. X
  158. X#endif
  159. X
  160. X    if (load_tilde_file(RC_NAME) == 0) return FALSE;
  161. X
  162. X    return TRUE;
  163. X}
  164. X
  165. X
  166. X
  167. X/*
  168. X * Load a file that is preceded with ~[logname]/path.
  169. X *
  170. X * If ~/ then use $HOME else getpwname() on logname.
  171. X */
  172. Xstatic    int
  173. Xload_tilde_file(tilde_name)
  174. X
  175. X    char    *tilde_name;
  176. X
  177. X{
  178. X
  179. X    int        res;
  180. X    int        logname_len;
  181. X    char    *local_name;
  182. X    char    *logname;
  183. X    char    *logdir;
  184. X    char    *filename;
  185. X    struct    passwd        *pwp;
  186. X
  187. X/* Determine the size of [logname] if any */
  188. X
  189. X    for(logname_len=0, filename=tilde_name + 1;
  190. X    *filename && (*filename != '/');
  191. X    logname_len++, filename++)     /* EMPTY LOOP */ ;
  192. X
  193. X/* filename points to the "/" in ~[logname]/filename */
  194. X
  195. X    if (!*filename) return RC_BAD_TILDE;    /* no "/" after logname */
  196. X
  197. X    if (!logname_len) {            /* If ~/, then use $HOME */
  198. X    logdir = getenv("HOME");
  199. X    if (!logdir || !*logdir) logdir = ".";
  200. X    local_name = xmalloc(strlen(logdir) + strlen(filename) + 1,
  201. X                 "rc:$HOME");
  202. X    strcpy(local_name, logdir);
  203. X    }
  204. X    else {
  205. X
  206. X/* There is a logname. Malloc to copy as tilde_name cannot be modified. */
  207. X
  208. X    logname = tilde_name + 1;
  209. X    local_name = xmalloc(logname_len + 1, "rc:~logname");
  210. X    strncpy(local_name, logname, logname_len);
  211. X    local_name[logname_len] = '\0';
  212. X    pwp = getpwnam(local_name);
  213. X    if (!pwp) {
  214. X        xfree(local_name, "rc:tilde");
  215. X        return RC_BAD_TILDE;
  216. X    }
  217. X
  218. X    local_name = xrealloc(local_name,
  219. X                  strlen(filename) + strlen(pwp->pw_dir) + 1,
  220. X                  "rc:~logname");
  221. X    strcpy(local_name, pwp->pw_dir);
  222. X    }
  223. X
  224. X/* local_name now has whatever ~[logname] expanded to */
  225. X
  226. X    strcat(local_name, filename);
  227. X    res = load_normal_file(local_name);
  228. X    xfree(local_name, "rc:tilde");
  229. X
  230. X    return res;
  231. X}
  232. X
  233. X
  234. X/* Load and parse a "normal" filename. */
  235. X
  236. Xstatic    int
  237. Xload_normal_file(filename)
  238. X
  239. X    char    *filename;
  240. X
  241. X{
  242. X    MY_FILE    *mfp;
  243. X    int        res;
  244. X
  245. X    mfp = my_fopen(filename);
  246. X    if (!mfp) return RC_OPEN_FAILED;
  247. X
  248. X    res = parse_file(mfp, filename);
  249. X    my_fclose(mfp);
  250. X
  251. X    return res;
  252. X}
  253. X
  254. X
  255. X
  256. Xstatic    int
  257. Xparse_file(mfp, filename)
  258. X
  259. X    MY_FILE    *mfp;
  260. X    char    *filename;
  261. X
  262. X{
  263. X
  264. X    int        line_number;
  265. X    int        token_count;
  266. X    int        tix;
  267. X    char    lbuf[MAX_TOKEN_SIZE * 6];
  268. X    char    *tokens[MAX_TOKENS + 1];
  269. X    CMD_MAP    *cmdp;
  270. X    char    *err_msg;
  271. X    char    *cp;
  272. X
  273. X    line_number = 0;
  274. X    while (fgets(lbuf, sizeof(lbuf), mfp->fp)) {
  275. X
  276. X    line_number++;
  277. X
  278. X/* Check for a blank line prior to tokenizing */
  279. X
  280. X    for (cp=lbuf; *cp && isspace(*cp); cp++) /* Empty loop */    ;
  281. X
  282. X    if (!*cp || *cp == COMMENT_CHAR) continue;    /* Line is empty */
  283. X
  284. X/* Line has something on it */
  285. X
  286. X    token_count = tokenize(filename, line_number, cp, tokens);
  287. X
  288. X    if (token_count <= 0) return RC_PARSE_BAD;    /* Error */
  289. X
  290. X/* Search for matching function name */
  291. X
  292. X    for (cmdp = cmd_map; cmdp->name; cmdp++) {
  293. X        if (strcmp(tokens[0], cmdp->name) == 0) break;
  294. X    }
  295. X
  296. X    if (!cmdp->name) {
  297. X        fprintf(stderr, msg_rc[0], filename, line_number);
  298. X        fprintf(stderr, msg_rc[1], tokens[0]);
  299. X        return RC_PARSE_BAD;
  300. X    }
  301. X
  302. X/* Check for incorrect number of args */
  303. X
  304. X    if (token_count < cmdp->min_args) {
  305. X        fprintf(stderr, msg_rc[0], filename, line_number);
  306. X        fprintf(stderr, msg_rc[2], tokens[0], cmdp->min_args);
  307. X        return RC_PARSE_BAD;
  308. X    }
  309. X
  310. X    if (token_count > cmdp->max_args) {
  311. X        fprintf(stderr, msg_rc[0], filename, line_number);
  312. X        fprintf(stderr, msg_rc[3], tokens[0], cmdp->max_args);
  313. X        return RC_PARSE_BAD;
  314. X    }
  315. X
  316. X/* Check for unexpected empty args */
  317. X
  318. X    for (tix=0; tix < cmdp->min_args; tix++) {
  319. X        if (!*tokens[tix]) {
  320. X        fprintf(stderr, msg_rc[0], filename, line_number);
  321. X        fprintf(stderr, msg_rc[4], tix, tokens[0]);
  322. X        return RC_PARSE_BAD;
  323. X        }
  324. X    }
  325. X
  326. X/* Syntaxtically looks ok, dispatch to handler */
  327. X
  328. X    err_msg = (*cmdp->handler)(tokens[1], tokens[2], tokens[3], tokens[4]);
  329. X    if (err_msg) {
  330. X        fprintf(stderr, msg_rc[0], filename, line_number);
  331. X        fprintf(stderr, msg_rc[5], tokens[0], err_msg);
  332. X        return RC_PARSE_BAD;
  333. X    }
  334. X    }
  335. X
  336. X    return RC_PARSE_OK;
  337. X}
  338. X
  339. X
  340. X/*
  341. X * Split the .rc line into separate tokens. A token is whitespace
  342. X * separated and can be quoted. Max number of tokens and max size of
  343. X * tokens are checked in this routine. The only real reason for the
  344. X * max size is for the decode routine - sigh.
  345. X *
  346. X * Return zero if tokenizing failed (error message already generated),
  347. X * otherwise thenumberof tokens found is returned with the tokens[]
  348. X * array filled in.
  349. X *
  350. X * The tokens[] array has NULL if the token was not present, otherwise
  351. X * a pointer to a \0 terminated string.
  352. X */
  353. X
  354. Xstatic    int
  355. Xtokenize(filename, line_number, cp, tokens)
  356. X
  357. X    char    *filename;
  358. X    int        line_number;
  359. X    char    *cp;
  360. X    char    *tokens[];
  361. X
  362. X{
  363. X    int        tix;
  364. X    char    quote_char;
  365. X
  366. X    for (tix=0; tix < (MAX_TOKENS + 1); tix++) tokens[tix] = NULL;
  367. X
  368. X
  369. X    for (tix=0; tix < (MAX_TOKENS + 1); tix++) {
  370. X
  371. X/* Skip whitespace */
  372. X
  373. X    while (*cp && isspace(*cp)) cp++;
  374. X    if (*cp == COMMENT_CHAR) *cp = '\0';
  375. X
  376. X    if (!*cp) break;    /* End of string */
  377. X
  378. X
  379. X/* Have start of token. If token starts with a quote skip over and note. */
  380. X
  381. X    if ((*cp == SINGLE_QUOTE) || (*cp == DOUBLE_QUOTE)) {
  382. X        quote_char = *cp++;
  383. X    }
  384. X    else {
  385. X        quote_char = '\0';
  386. X    }
  387. X
  388. X    tokens[tix] = cp;    /* Point to start of token */
  389. X
  390. X/* Skip over text of token */
  391. X
  392. X    if (quote_char) {
  393. X        while (*cp && (*cp != quote_char) && (*cp != '\n')) cp++;
  394. X
  395. X        if (*cp != quote_char) {    /* Terminated by quote ? */
  396. X        fprintf(stderr, msg_rc[0], filename, line_number);
  397. X        fprintf(stderr, msg_rc[6], tokens[tix]-1);
  398. X        return 0;
  399. X        }
  400. X
  401. X/* A trailing quote must be followed by whitespace */
  402. X
  403. X        if (cp[1] && !isspace(cp[1])) {
  404. X        fprintf(stderr, msg_rc[0], filename, line_number);
  405. X        fprintf(stderr, msg_rc[7], tokens[tix]-1);
  406. X        return 0;
  407. X        }
  408. X
  409. X        *cp++ = '\0';    /* Terminate token string */
  410. X    }
  411. X    else {
  412. X        while (*cp && !isspace(*cp) && (*cp != COMMENT_CHAR)) cp++;
  413. X        if (*cp) *cp++ = '\0';    /* Terminate if necessary */
  414. X    }
  415. X
  416. X/* Check that length of the token doesn't exceed the max */
  417. X
  418. X    if ((int) strlen(tokens[tix]) >= MAX_TOKEN_SIZE) {
  419. X        fprintf(stderr, msg_rc[0], filename, line_number);
  420. X        fprintf(stderr, msg_rc[8], tokens[tix]);
  421. X        return 0;
  422. X    }
  423. X
  424. X    }
  425. X
  426. X    return tix;
  427. X}
  428. X
  429. X
  430. X
  431. X/*
  432. X * bind-key   function-name  key-sequence   [Help-text]
  433. X */
  434. X
  435. Xstatic    char    *
  436. Xbind_key(func, keyseq, help)
  437. X
  438. X    char    *func;
  439. X    char    *keyseq;
  440. X    char    *help;
  441. X
  442. X{
  443. X    char    buf[MAX_TOKEN_SIZE * 2];
  444. X    char    *msg;
  445. X    FUNC_CODE    fc;
  446. X
  447. X/* Convert string for ^C \t etc to real stuff */
  448. X
  449. X    msg = decode(keyseq, buf);
  450. X    if (msg) return msg;
  451. X
  452. X/* Find the function code corresponding to the name */
  453. X
  454. X    fc = kb_findfunc(func);
  455. X    if (fc == INVALID_COMMAND) return msg_rc[12];    /* Unknown function */
  456. X
  457. X    kb_addcode((unsigned char *) buf, fc, help ? help : keyseq);
  458. X
  459. X    return NULL;
  460. X}
  461. X
  462. X
  463. X/*
  464. X * bind-termcap function-name  capname [Help-text]
  465. X */
  466. X
  467. Xstatic    char    *
  468. Xbind_termcap(func, termseq, help)
  469. X
  470. X    char    *func;
  471. X    char    *termseq;
  472. X    char    *help;
  473. X
  474. X{
  475. X    FUNC_CODE    fc;
  476. X
  477. X    fc = kb_findfunc(func);
  478. X    if (fc == INVALID_COMMAND) return msg_rc[12];    /* unknown function */
  479. X
  480. X#ifndef    NO_TGETSTR
  481. X    if (kb_addtcap(termseq, fc, help ? help : termseq) == -1) {
  482. X    return msg_rc[13];    /* Invalid capability */
  483. X    }
  484. X
  485. X#endif
  486. X
  487. X    return NULL;
  488. X}
  489. X
  490. X
  491. X
  492. X/*
  493. X * bind-terminfo function-name    termcapname [Help-text]
  494. X */
  495. X
  496. Xstatic    char    *
  497. Xbind_terminfo(func, termseq, help)
  498. X
  499. X    char    *func;
  500. X    char    *termseq;
  501. X    char    *help;
  502. X
  503. X{
  504. X    FUNC_CODE    fc;
  505. X
  506. X    fc = kb_findfunc(func);
  507. X    if (fc == INVALID_COMMAND) return msg_rc[12];    /* unknown function */
  508. X
  509. X#ifdef    USE_TIGETSTR
  510. X    if (kb_addtinfo(termseq, fc, help ? help : termseq) == -1) {
  511. X    return msg_rc[14];    /* invalid terminfo capability */
  512. X    }
  513. X#endif
  514. X
  515. X    return NULL;
  516. X}
  517. X
  518. X
  519. Xstatic    char    *
  520. Xinclude(filename)
  521. X
  522. X    char    *filename;
  523. X{
  524. X    int        res;
  525. X
  526. X    res = (filename[0] == '~')     ? load_tilde_file(filename)
  527. X                : load_normal_file(filename);
  528. X
  529. X    switch (res) {
  530. X      case RC_PARSE_BAD:    return msg_rc[9];    /* Previous error */
  531. X      case RC_OPEN_FAILED:    return msg_rc[10];    /* Open failed */
  532. X      case RC_BAD_TILDE:    return msg_rc[11];    /* ~expansion failed */
  533. X    }
  534. X
  535. X    return NULL;
  536. X}
  537. X
  538. X/*
  539. X * To expand the flexibility of the include directive, the filename
  540. X * can be potentially opened as a pipeline via popen. This means that
  541. X * the filename can be of the form of:
  542. X *
  543. X *    include        "/usr/local/lib/${EDITOR}_ipickrc"
  544. X *
  545. X * The file is opened as a pipeline if there are any shell characters
  546. X * in the filename. If the trailing character is NOT the pipeline
  547. X * character then the pipeline is constructed with a preceeding "cat"
  548. X * command.
  549. X *
  550. X * If the filename contains no shell characters then it is simply
  551. X * opened with fopen.
  552. X *
  553. X * Examples:
  554. X *
  555. X *    "./fred"            fopen("./fred");
  556. X *    "${EDITOR}_ipick"        popen("cat ${EDITOR}_ipick");
  557. X *
  558. X */
  559. X
  560. Xstatic    MY_FILE    *
  561. Xmy_fopen(filename)
  562. X
  563. X    char    *filename;
  564. X
  565. X{
  566. X    MY_FILE    *mfp;
  567. X    char    *popen_filename;
  568. X
  569. X    mfp = (MY_FILE *) xmalloc(sizeof(MY_FILE), "rc:MY_FILE");
  570. X    mfp->use_pclose = FALSE;
  571. X
  572. X/* If no shell characters then use the normal fopen */
  573. X
  574. X    if (!strpbrk(filename, SHELL_CHARS)) {
  575. X    mfp->fp = fopen(filename, "r");
  576. X    }
  577. X    else {
  578. X    mfp->use_pclose = TRUE;
  579. X
  580. X/* no trailing pipe character means use cat */
  581. X
  582. X    popen_filename = xmalloc(strlen(filename) + 6, "rc:popen_filename");
  583. X
  584. X    if (filename[strlen(filename)-1] != '|') {    /* Use cat filename? */
  585. X        strcpy(popen_filename, "cat ");
  586. X        strcat(popen_filename, filename);
  587. X    }
  588. X    else {
  589. X        strcpy(popen_filename, filename);
  590. X        popen_filename[strlen(popen_filename)-1] = '\0';    /* kill | */
  591. X    }
  592. X    mfp->fp = popen(popen_filename, "r");
  593. X    xfree(popen_filename, "rc:popen_filename");
  594. X    }
  595. X
  596. X/* Did the open fail? */
  597. X
  598. X    if (!mfp->fp) {
  599. X    xfree((char *) mfp, "rc:MY_FILE");
  600. X    mfp = NULL;
  601. X    }
  602. X
  603. X    return mfp;
  604. X}
  605. X
  606. X
  607. X
  608. X/* Corresponding close to my_fopen */
  609. X
  610. Xstatic    int
  611. Xmy_fclose(mfp)
  612. X
  613. X    MY_FILE    *mfp;
  614. X
  615. X{
  616. X    int        res;
  617. X
  618. X    res = mfp->use_pclose ? pclose(mfp->fp) : fclose(mfp->fp);
  619. X    xfree((char *) mfp, "rc:MY_FILE");
  620. X
  621. X    return res;
  622. X}
  623. END_OF_FILE
  624.   if test 12303 -ne `wc -c <'ipick/rc.c'`; then
  625.     echo shar: \"'ipick/rc.c'\" unpacked with wrong size!
  626.   fi
  627.   # end of 'ipick/rc.c'
  628. fi
  629. if test -f 'ipick/ipick.1' -a "${1}" != "-c" ; then 
  630.   echo shar: Will not clobber existing file \"'ipick/ipick.1'\"
  631. else
  632.   echo shar: Extracting \"'ipick/ipick.1'\" \(24269 characters\)
  633.   sed "s/^X//" >'ipick/ipick.1' <<'END_OF_FILE'
  634. X.\ " $Id: ipick.1,v 1.1 1993/02/27 21:53:58 markd Exp $
  635. X.\ "
  636. X.TH IPICK 1 "28 February 1993"
  637. X.\ "
  638. X.\ " $Log: ipick.1,v $
  639. X.\ " Revision 1.1  1993/02/27  21:53:58  markd
  640. X.\ " Initial revision
  641. X.\ "
  642. X.\" Had to fix examples using -i to use -v (new invert option)
  643. X.\" I have no *roff manual so this manpage may well be faulty.
  644. X.\" Having said that, the good bits of this manpage come care of
  645. X.\" DaviD W. Sanderson <dws@ssec.wisc.edu>
  646. X.SH NAME
  647. Xipick \- A screen-based filter to
  648. X.IR i nteractively
  649. X.I pick
  650. Xlines
  651. X.SH SYNTAX
  652. X.B ipick
  653. X.RB [ \-abdhrRvV ]
  654. X.RB [ \-m
  655. X.IR minimum ]
  656. X.RB [ \-M
  657. X.IR maximum ]
  658. X.if n .ti +.6i
  659. X.RB [ \-t
  660. X.IR fixed-title-text ]
  661. X.RB [ \-T
  662. X.IR stdin-title-lines ]
  663. X.if n .ti +.6i
  664. X.RB [ \-X
  665. X.IR xterm-name-substring ]
  666. X.RI [ filename ]
  667. X.SH DESCRIPTION
  668. X.PP
  669. X.I ipick
  670. Xreads lines of text from the standard input or the optional
  671. X.I filename
  672. Xand uses
  673. X.IR curses (3)
  674. Xto present them as a full-screen selection list.
  675. X.I ipick
  676. Xprovides numerous commands
  677. Xto select, navigate, scroll and search
  678. Xthrough this list.
  679. XOn quitting,
  680. X.I ipick
  681. Xwrites the selected lines to the standard output.
  682. X.PP
  683. XTypically you would use
  684. X.I ipick
  685. Xas a final-filter to glue your neat, pre-stored
  686. Xpipelines and scripts together in a friendly way
  687. Xso that people other than Unix-o-philes can use them.
  688. X.\"
  689. X.\" Make the description brief so that the OPTIONS show up early.
  690. X.\" For those interested, there is a more details MOTIVATION section.
  691. X.\"
  692. X.PP
  693. XSee
  694. X.BR MOTIVATION ,
  695. Xtowards the end, for a more detailed discussion.
  696. X.SH OPTIONS
  697. X.PP
  698. XOptions can appear in any order so long as they
  699. X.I precede
  700. Xthe
  701. X.IR filename .
  702. X.TP
  703. X.B \-a
  704. XAutomatically exit when the number of lines selected is within the
  705. Xminimum and maximum values allowed
  706. X(see
  707. X.B \-m
  708. Xand
  709. X.B \-M
  710. Xoptions).
  711. X.TP
  712. X.B \-b
  713. XActivate the audible alarm on invalid keystroke commands.
  714. XNot normally needed as
  715. X.I ipick
  716. Xalways generates an error message.
  717. XNormally you would set this option only for inexperienced users.
  718. X.TP
  719. X.B \-d
  720. XDrain the standard input on exit.
  721. XThis avoids the possibility of upstream processes
  722. Xreceiving a SIGPIPE.
  723. XThis is more a nicety than a necessity.
  724. XFurthermore,
  725. Xusing this option could prove expensive if the upstream process
  726. Xis a long way from finishing!
  727. X.TP
  728. X.BR \-h , " \-?"
  729. XPrint an extended help message describing these options.
  730. X.TP
  731. X.B \-m
  732. XMinimum number of lines that the user must select before
  733. X.I ipick
  734. Xwill exit.
  735. X.TP
  736. X.B \-M
  737. Xmaximum number of lines that the user may select select before
  738. X.I ipick
  739. Xwill exit.
  740. X.TP
  741. X\&
  742. XYou would typically use the minimum and maximum settings
  743. Xin conjunction with the
  744. X.B \-a
  745. Xand/or
  746. X.B \-r
  747. Xoptions to ensure an orderly and
  748. Xpredictable outcome of the picking process.
  749. X.TP
  750. X.B \-r
  751. XRestricted mode.
  752. XIn this mode the user cannot escape the clutches of
  753. X.I ipick
  754. Xexcept as defined by the other command-line options.
  755. XThis disables the shell and pipe commands.
  756. XAdditionally, this disables keyboard signals by
  757. Xsetting the terminal to raw mode instead of cbreak mode.
  758. XNote that raw mode has other side-effects; see
  759. X.IR stty (1)
  760. Xfor more details.
  761. X.TP
  762. X.B \-R
  763. XDo not set terminal input to raw mode.
  764. XThe main effects of this option
  765. Xis that the
  766. X.IR stty (1)
  767. Xcontrol character sequences remain active and are thus capable of
  768. Xgenerating
  769. Xkeyboard signals such as SIGINT and SIGQUIT.
  770. XNote that
  771. X.I ipick
  772. Xhas an abort command that can be bound to your normal ``intr'' or
  773. X``quit'' characters; see
  774. X.IR stty (1)
  775. Xfor more details on raw mode.
  776. X.TP
  777. X.BI \-t " fixed-title-text"
  778. XText to use as a title on the screen.
  779. X.I ipick
  780. Xcreates a ``fixed title'' containing the given text
  781. Xstarting at the top line of the screen.
  782. X.I ipick
  783. Xdoes not scroll this part of the title horizontally with the data.
  784. XIf the
  785. X.I fixed-title-text
  786. Xcontains embedded newlines,
  787. X.I ipick
  788. Xhandles them correctly.
  789. X.TP
  790. X.BI \-T " stdin-title-lines"
  791. X.I ipick
  792. Xwill read
  793. X.I stdin-title-lines
  794. Xlines from the standard input and use these
  795. Xas the ``variable title'' which follows the ``fixed title''.
  796. XThis option is especially useful when the upstream process
  797. Xgenerates a title line,
  798. Xsuch as
  799. X.IR ps (1),
  800. Xor
  801. X.IR w (1).
  802. X.I ipick
  803. Xscrolls this part of the title horizontally with the data.
  804. X.TP
  805. X\&
  806. XIf the standard input is less than
  807. X.I stdin-title-lines
  808. Xlong, then
  809. X.I ipick
  810. Xterminates silently.
  811. X.TP
  812. X\&
  813. XIf you define a title with either
  814. X.B \-t
  815. Xor
  816. X.BR \-T ,
  817. Xthen
  818. X.I ipick
  819. Xseparates the title from the data with a line of hyphens.
  820. X.TP
  821. X.B \-v
  822. XInvert the selections.
  823. XWith this option,
  824. X.I ipick
  825. Xwrites the lines the user
  826. X.I did not
  827. Xselect to stdout.
  828. X.TP
  829. X.B \-V
  830. XPrint a message containing the version,
  831. Xcompilation options, location of the system-wide
  832. Xcustomization file and the obligatory copyright message.
  833. X.TP
  834. X.BI \-X " xterm-name-substring"
  835. X.I ipick
  836. Xcompares the
  837. X.I xterm-name-substring
  838. Xwith the terminal type defined in $TERM.
  839. XIf it matches,
  840. X.I ipick
  841. Xsends the escape sequences needed to enable and disable mouse-tracking.
  842. XThe default
  843. X.I xterm-name-substring
  844. Xis ``xterm'', so real
  845. X.IR xterm (1)
  846. Xusers need do nothing.
  847. XThe comparison is case-sensitive.
  848. XSee
  849. X.B "XTERM MOUSE TRACKING"
  850. Xfor more information.
  851. X.PP
  852. XThe
  853. X.BR \-m ,
  854. X.B \-M
  855. Xand
  856. X.B \-r
  857. Xoptions allow you to carefully control the actions
  858. Xand predict the results of a user.
  859. XFor example, if you use
  860. X.TP
  861. X\&
  862. Xipick \-m 1 \-M 1 \-r
  863. X.PP
  864. Xthen you can write the rest of the pipeline assuming that
  865. X.I ipick
  866. Xwill produce one and only one line of output.
  867. X.SH "KEYBOARD COMMANDS"
  868. X.PP
  869. X.I ipick
  870. Xaccepts numerous keyboard commands,
  871. Xperhaps the most important being
  872. X.I ?
  873. Xwhich provides online help.
  874. X.PP
  875. X.I ipick
  876. Xis ecumenical regarding keybindings
  877. Xas it implements a reasonable set of
  878. X.IR emacs ,
  879. X.I vi
  880. Xand
  881. X.I more
  882. Xkeybindings concurrently!
  883. XAdditionally,
  884. X.I ipick
  885. Xbinds all of the commonly used commands to function keys as defined
  886. Xin the TERMINFO (or the corresponding termcap) definition file.
  887. XThis means that users can avoid learning the idiosyncratic nature of
  888. X.I vi
  889. Xand
  890. X.I emacs
  891. Xkeystrokes.
  892. X.PP
  893. XFinally,
  894. X.I ipick
  895. Xcan be customized
  896. Xwith both a system wide startup file and
  897. Xand a user startup file.
  898. XSee
  899. X.BR CUSTOMIZATION ,
  900. Xfor a detailed discussion of these files.
  901. XFor the purposes of this section it is assumed that
  902. Xno customization is in effect.
  903. X.PP
  904. XThe list of keyboard commands uses the following symbols:
  905. X.nr n \w'^V, <Space>, K_npage, K_index\0\0'+1n-1/1n
  906. X.TP \nn
  907. X^A \(em control-A
  908. XPress Control and ``A'' together
  909. XE-A \(em Escape-A
  910. XPress Escape followed by ``A''
  911. X.TP
  912. X.RI K_ tttt
  913. Xidentifies
  914. Xthe TERMINFO (or termcap)
  915. X.RI key_ tttt
  916. Xused.
  917. XThis is the ``Variable name'',
  918. X.I not
  919. Xthe ``Capname'' in the man page.
  920. X.PP
  921. X.I Selection Commands
  922. X.TP \nn
  923. X<CR>, K_ent
  924. XToggle the selection state of the
  925. Xcurrent line, then move to the next line if present
  926. X.PD 0
  927. X.TP
  928. X0\-9
  929. XSelect the specific line number
  930. X.TP
  931. XS
  932. XSelect all lines
  933. X.TP
  934. XC
  935. XClear all lines
  936. X.TP
  937. X+
  938. XToggle the state of unread lines
  939. X.TP
  940. Xs, K_select
  941. XSelect the ``line-range'' nominated
  942. X.TP
  943. Xc, K_clear
  944. XClear the ``line-range'' nominated
  945. X.TP
  946. Xt
  947. XToggle the selection state of the ``line-range'' nominated
  948. X.PD
  949. X.PP
  950. XThe ``line-range'' given to the ``s'', ``c'' and ``t'' commands may
  951. Xconsist of any one of:
  952. X.PD
  953. X.TP 4
  954. X\(bu
  955. XA number, series of numbers or range of numbers
  956. X.nf
  957. X(e.g. 1 5 7\-14 21\-19)
  958. X.fi
  959. X.TP
  960. X\(bu
  961. XThe string ``visible'' meaning all lines currently visible on the
  962. Xscreen.
  963. X.TP
  964. X\(bu
  965. XThe string ``all'' meaning all lines.
  966. X.PD
  967. X.PP
  968. XYou may shorten both ``visible'' and ``all'' to just ``v'' and ``a''
  969. Xrespectively.
  970. X.I ipick
  971. Xignores the case of these strings.
  972. X.PD
  973. X.PP
  974. X.I Positioning commands
  975. X.TP \nn
  976. X.PD 0
  977. XT, K_beg
  978. XTop of File
  979. X.TP
  980. XB, K_end
  981. XBottom of File
  982. X.TP
  983. XH, K_home
  984. XTop of screen
  985. X.TP
  986. XL, K_ll
  987. XBottom of screen
  988. X.TP
  989. X^N, j, K_down
  990. XNext line
  991. X.TP
  992. X^P, k, K_up
  993. XPrevious line
  994. X.PD
  995. X.PP
  996. X.I Vertical scrolling
  997. X.TP \nn
  998. X^U
  999. XUp half the screen
  1000. X.PD 0
  1001. X.TP
  1002. X^D
  1003. XDown half the screen
  1004. X.TP
  1005. XE-v, b, K_ppage, K_rindex
  1006. XUp full screen
  1007. X.TP
  1008. X^V, <Space>, K_npage, K_index
  1009. XDown full screen
  1010. X.PD
  1011. X.PP
  1012. X.I Horizontal scrolling
  1013. X.TP \nn
  1014. X^B, h, K_left
  1015. XScroll left one character
  1016. X.PD 0
  1017. X.TP
  1018. X^F, l, K_right
  1019. XScroll right one character
  1020. X.TP
  1021. X^I (TAB)
  1022. XScroll right one tabstop
  1023. X.TP
  1024. XE-i, K_cbt
  1025. XScroll left one tabstop
  1026. X.TP
  1027. X^A, ^ (circumflex)
  1028. XScroll to beginning of line
  1029. X.TP
  1030. X^E, $
  1031. XScroll to end of line
  1032. X.TP
  1033. X<
  1034. XScroll left half screen
  1035. X.TP
  1036. X>
  1037. XScroll right half screen
  1038. X.PD
  1039. X.PP
  1040. X.I Searching
  1041. X.TP \nn
  1042. X^S, E-s, /, K_find
  1043. XForward search
  1044. X.PD 0
  1045. X.TP
  1046. X^R, E-r, \e
  1047. XReverse search
  1048. X.TP
  1049. Xn
  1050. XRedo forward search
  1051. X.TP
  1052. XN
  1053. XRedo reverse search
  1054. X.TP
  1055. X*, K_next
  1056. XFind next selected line
  1057. X.TP
  1058. X&, K_prev
  1059. XFind previous selected line
  1060. X.PD
  1061. X.PP
  1062. X.I Miscellaneous
  1063. X.TP \nn
  1064. X\&., K_redo
  1065. XRedo last command
  1066. X.PD 0
  1067. X.TP
  1068. Xg, K_move
  1069. XGo to line
  1070. X.TP
  1071. Xq, Q, ^X^C, ZZ, K_exit
  1072. XQuit
  1073. X.TP
  1074. X^C
  1075. XAbort
  1076. X.TP
  1077. X^L, K_refresh
  1078. XRefresh
  1079. X.TP
  1080. X?, K_help
  1081. XProvide online help
  1082. X.TP
  1083. X!
  1084. XShell command
  1085. X.TP
  1086. X|
  1087. XPipe command.
  1088. XPipe the current line into the command
  1089. X.PD
  1090. X.SH CUSTOMIZATION
  1091. X.PP
  1092. XWhen
  1093. X.I ipick
  1094. Xis invoked, it reads initialization commands from the
  1095. Xsite customization
  1096. Xfile (normally /usr/local/lib/ipickrc but see the
  1097. X.B \-V
  1098. Xoption)
  1099. Xand
  1100. Xthen the user's customization file .ipickrc in the
  1101. Xuser's home directory.
  1102. XBoth files are optional.
  1103. XThe file can contain blank lines and comments where comments are
  1104. Xdenoted by the first occurence of the ``#'' character.
  1105. X.PP
  1106. XA command must be completely contained on a single
  1107. Xline as there is no continuation character.
  1108. XEach token can be separated by one or more
  1109. Xwhite-space characters.
  1110. XA token can be quoted if it requires embedded spaces with either a
  1111. Xsingle or double quote.
  1112. X.PP
  1113. X.PD
  1114. X.I Substitution sequences
  1115. X.PP
  1116. XThe following special substitution sequences are recognized:
  1117. X.ft I
  1118. X.nr n \w'^char\0\0\0'+1n/1n
  1119. X.ft
  1120. X.TP \nn
  1121. X.B \eb
  1122. XA backspace character
  1123. X.TP
  1124. X.B \ef
  1125. XA form-feed
  1126. X.TP
  1127. X.B \ee
  1128. XAn escape
  1129. X.TP
  1130. X.B \en
  1131. XThe newline character
  1132. X.TP
  1133. X.B \er
  1134. XA carriage-return
  1135. X.TP
  1136. X.B \es
  1137. XA space
  1138. X.TP
  1139. X.B \et
  1140. XA TAB
  1141. X.TP
  1142. X.B \e\e
  1143. XThe back-slash character
  1144. X.TP
  1145. X.B \eNNN
  1146. XThe character represented by the  octal value of
  1147. X.I NNN
  1148. X.TP
  1149. X.B ^char
  1150. XA control character.
  1151. X.I char
  1152. Xcan be ``A-Z'' or ``@''.
  1153. X.PP
  1154. X.I Customization commands
  1155. X.\" .nr n \w'bind-terminfo'+1n/1n
  1156. X.\" .TP \nn
  1157. X.PP
  1158. X.B bind-key
  1159. X.I function
  1160. X.I keysequence
  1161. X.RI [ helptext ]
  1162. X.TP
  1163. X\&
  1164. XBind a set of keystrokes to a specific function.
  1165. X.PP
  1166. X.B bind-terminfo
  1167. X.I function
  1168. X.I terminfo-capability
  1169. X.RI [ helptext ]
  1170. X.TP
  1171. X\&
  1172. XBind a terminfo capability to a specific
  1173. Xfunction.
  1174. XIf the terminfo functionality has not been built into
  1175. X.I ipick
  1176. Xthen this effectively becomes a no-op.
  1177. X.PP
  1178. X.B bind-termcap
  1179. X.I function
  1180. X.I termcap-capability
  1181. X.RI [ helptext ]
  1182. X.TP
  1183. X\&
  1184. XBind a termcap capability to a specific
  1185. Xfunction.
  1186. XIf the termcap functionality has not been
  1187. Xbuilt into
  1188. X.I ipick
  1189. Xthen this effectively becomes a no-op.
  1190. X.PP
  1191. X.B include
  1192. X.I includefile
  1193. X.PP
  1194. XWhere:
  1195. X.PP
  1196. X.ft I
  1197. X.nr n \w'terminfo-capability\0\0\0'+1n/1n
  1198. X.ft
  1199. X.TP \nn
  1200. X.I function
  1201. Xis a valid
  1202. X.I ipick
  1203. Xfunction; see
  1204. X.BR FUNCTIONS ,
  1205. Xfor a complete list.
  1206. X.TP
  1207. X.I keysequence
  1208. Xis any sequence of keystrokes.
  1209. XThe
  1210. X.I substitution
  1211. Xcharacter will typically be useful for this parameter.
  1212. X.TP
  1213. X.I helptext
  1214. Xis an optional text string that will be displayed as part of the online
  1215. Xhelp screen.
  1216. XIf not present then the keysequence or capability name will be used.
  1217. X.TP
  1218. X.I terminfo-capability
  1219. XA valid terminfo keystroke capability name; see
  1220. X.IR terminfo (5)
  1221. Xfor more details.
  1222. X.TP
  1223. X.I termcap-capability
  1224. XA valid termcap keystroke capability name; see
  1225. X.IR termcap (5)
  1226. Xfor more details.
  1227. X.TP
  1228. X.I includefile
  1229. Xa path of the file to include.
  1230. X.TP
  1231. X\&
  1232. XIf
  1233. X.I includefile
  1234. Xhas a leading tilde ``~'' then
  1235. X.I ipick
  1236. Xperforms the usual tilde expansion.
  1237. XThat is the string between
  1238. Xthe tilde and the first ``/'' character
  1239. Xis treated as a login name whose home directory is substituted.
  1240. XAn empty login name implies $HOME.
  1241. X.TP
  1242. X\&
  1243. XIf
  1244. X.I includefile
  1245. Xcontains any shell characters then
  1246. X.I ipick
  1247. Xassumes that it's a pipeline command
  1248. Xand uses
  1249. X.IR popen (3S)
  1250. Xrather than
  1251. X.IR fopen (3V)
  1252. Xto open the command.
  1253. X.TP
  1254. X\&
  1255. XIf
  1256. X.I includefile
  1257. Xis treated as a pipeline command and there is no trailing pipe character ``|''
  1258. Xthen
  1259. X.I ipick
  1260. Xpreceeds the pipeline string with
  1261. Xthe
  1262. X.IR cat (1)
  1263. Xcommand.
  1264. X.PD
  1265. X.PP
  1266. XThe follow sample
  1267. X.I .ipickrc
  1268. Xfile demostrates most of the functionality
  1269. Xdiscuss in this section.
  1270. X.PP
  1271. X.nf
  1272. X#
  1273. X# This file has some comments in it
  1274. X#
  1275. X
  1276. Xinclude "~fred/.ipickrc"         # Fred has a cool startup file
  1277. Xinclude '/usr/local/lib/ipick_${EDITOR:-EMACS}'
  1278. X
  1279. Xinclude "grep terminfo /usr/local/lib/ipick_wyse |"
  1280. X
  1281. Xinclude "$HOME/env/test_bindings"
  1282. X
  1283. Xbind-key QUIT "\ee\es\e023" "NT250 Exit key"
  1284. X
  1285. X# Bind the begining of line terminal definition
  1286. X
  1287. Xbind-terminfo beginning-of-line kbeg
  1288. Xbind-termcap beginning-of-line @1
  1289. X.fi
  1290. X.SH FUNCTIONS
  1291. XThe follow is a list of available functions.
  1292. X.PP
  1293. X.ft I
  1294. X.nr n \w'scroll-right-screen\0\0\0'+1n/1n
  1295. X.ft
  1296. X.TP \nn
  1297. X.I select-range
  1298. XEnter a range of line numbers to pick
  1299. X.TP
  1300. X.I select-all
  1301. XMark all lines as picked
  1302. X.TP
  1303. X.I clear-range
  1304. XEnter a range of line numbers which are
  1305. Xto have their pick state cleared
  1306. X.TP
  1307. X.I clear-all
  1308. XMark all lines as not picked
  1309. X.TP
  1310. X.I toggle-current
  1311. XToggle the picked state of the current
  1312. Xline and move the cursor to the next line
  1313. X.TP
  1314. X.I toggle-range
  1315. XEnter a range of line numbers which are
  1316. Xto have their pick state toggled
  1317. X.TP
  1318. X.I toggle-unread
  1319. XToggle the picked state of all unread lines
  1320. X.TP
  1321. X.I top-of-screen
  1322. XMove the cursor to the top of the screen
  1323. X.TP
  1324. X.I bottom-of-screen
  1325. XMove the cursor to the bottom of the screen
  1326. X.TP
  1327. X.I previous-line
  1328. XMove the cursor up one line
  1329. X.TP
  1330. X.I next-line
  1331. XMove the cursor down one line
  1332. X.TP
  1333. X.I quit
  1334. XExit and write the pick lines to stdout
  1335. X.TP
  1336. X.I abort
  1337. XExit without writing anything to stdout
  1338. X.TP
  1339. X.I help
  1340. XDisplay the online help screen
  1341. X.TP
  1342. X.I refresh
  1343. XClear and re-display the current screen
  1344. X.TP
  1345. X.I scroll-left-char
  1346. XMove the cursor left one position
  1347. X.TP
  1348. X.I scroll-right-char
  1349. XMove the cursor right one position
  1350. X.TP
  1351. X.I beginning-of-line
  1352. XMove the cursor to the first character position
  1353. X.TP
  1354. X.I end-of-line
  1355. XMove the cursor to the last character position of the current line
  1356. X.TP
  1357. X.I scroll-tab
  1358. XMove the cursor forward one tabstop
  1359. X.TP
  1360. X.I scroll-backtab
  1361. XMove the cursor back one tabstop
  1362. X.TP
  1363. X.I scroll-left-screen
  1364. XMove the cursor left by one half the width of the screen
  1365. X.TP
  1366. X.I scroll-right-screen
  1367. XMove the cursor right by one half the width of the screen
  1368. X.TP
  1369. X.I scroll-up-half
  1370. XMove the cursor up by one half of the height of the screen
  1371. X.TP
  1372. X.I scroll-down-half
  1373. XMove the cursor down by one half of the height of the screen
  1374. X.TP
  1375. X.I scroll-up-full
  1376. XMove the cursor up a full screen
  1377. X.TP
  1378. X.I scroll-down-full
  1379. XMove the cursor down a full screen
  1380. X.TP
  1381. X.I beginning-of-file
  1382. XMove the cursor to the first line
  1383. X.TP
  1384. X.I end-of-file
  1385. XMove the cursor to the end of all
  1386. Xthe input lines.
  1387. XIf data is from an upstream process, ipick will read until
  1388. Xthis process writes end of file
  1389. X.TP
  1390. X.I search-forward
  1391. XEnter the search forward string
  1392. X.TP
  1393. X.I search-backward
  1394. XEnter the reverse search string
  1395. X.TP
  1396. X.I re-search-forward
  1397. XContinue the search forwards
  1398. X.TP
  1399. X.I re-search-backward
  1400. XContinue the search backwards
  1401. X.TP
  1402. X.I next-selected
  1403. XMove the cursor to the next line selected
  1404. X.TP
  1405. X.I previous-selected
  1406. XMove the cursor to the previous line selected
  1407. X.TP
  1408. X.I goto-line
  1409. XEnter a line number to position to
  1410. X.TP
  1411. X.I shell
  1412. XEnter a shell command
  1413. X.TP
  1414. X.I pipe
  1415. XEnter a  command which will have the
  1416. Xcurrent line written to it's stdin
  1417. X.TP
  1418. X.I redo-command
  1419. XRedo the last command
  1420. X.TP
  1421. X.I xterm-mouse
  1422. XDefine the xterm escape prefix.
  1423. XOnly to be used if you really know what you're
  1424. Xdoing (Which I don't when it comes to
  1425. X.IR nroff (1))
  1426. X.TP
  1427. X.I invalid-command
  1428. XTreat as an invalid command and generate an error message
  1429. X.SH "XTERM MOUSE TRACKING"
  1430. X.PP
  1431. X.I ipick
  1432. Xhas limited support for
  1433. X.IR xterm 's
  1434. X``mouse tracking'' capability (the X11
  1435. X``normal tracking mode'' not the X10 compatibility mode).
  1436. X.PP
  1437. XTo enable this facility in a particular
  1438. X.I xterm
  1439. Xyou have to send it a special escape sequence.
  1440. XTo quote from
  1441. X.IR xterm (1),
  1442. X``[mouse tracking] is enabled
  1443. Xby specifying parameter 1000 to DECSET''.
  1444. X.I ipick
  1445. Xdoes this automatically when it detects a terminal type of
  1446. X.IR xterm .
  1447. XIf your
  1448. X.I xterm
  1449. Xclone uses a different name, you can use the
  1450. X.B \-X
  1451. Xoption to tell ipick what it is.
  1452. X.PP
  1453. XWhen you enable this facility, your
  1454. X.I xterm
  1455. Xwill pass any mouse events to
  1456. X.I ipick
  1457. Xin a form that
  1458. X.I ipick
  1459. Xrecognizes.
  1460. XIn all cases, the down event defines the start of a range of lines and
  1461. Xthe up event defines the end of the range \(em so dragging is useful.
  1462. X.PP
  1463. XEach mouse button has the following function:
  1464. X.nr n \w'Button\0\0\0'+1n-1/1n
  1465. X.TP \nn
  1466. X.B Button
  1467. X.B Description
  1468. X.TP
  1469. X1
  1470. XSet the selected status of the range
  1471. X.PD 0
  1472. X.TP
  1473. X2
  1474. XToggle the selected status of the range
  1475. X.TP
  1476. X3
  1477. XClear the selected status of the range
  1478. X.PD
  1479. X.PP
  1480. XNote that
  1481. X.I ipick
  1482. Xignores augmentation of mouse events
  1483. Xwith the Shift, Control and Meta keys.
  1484. X.PP
  1485. XThe
  1486. X.I xterm
  1487. Xfacility is limited in that chording the mouse buttons seems
  1488. Xto be undefined.
  1489. XFurthermore, the release (or mouse-up) doesn't specify the button.
  1490. XAccordingly
  1491. X.I ipick
  1492. Xtakes a conservative approach to mouse-events and tends to discard
  1493. Xanything unexpected.
  1494. X.ne 11
  1495. X.SH DIAGNOSTICS
  1496. XAll error messages should be self-explanatory.
  1497. X.PP
  1498. X.I Exit codes.
  1499. X.TP
  1500. X0
  1501. XNormal termination \(em at least one line selected
  1502. X.TP
  1503. X1
  1504. XNormal termination \(em no lines selected
  1505. X.TP
  1506. X2
  1507. XAbnormal termination
  1508. X.SH NOTES
  1509. X.PP
  1510. XIf no input exists, or if the
  1511. X.B \-T
  1512. Xoption causes
  1513. X.I ipick
  1514. Xto consume all its input, then
  1515. X.I ipick
  1516. Xterminates silently with an exit code of 1.
  1517. X.PP
  1518. XEach Newline terminated string in
  1519. X.I fixed-title-text
  1520. X(see the
  1521. X.B \-t
  1522. Xoption)
  1523. Xbecomes a separate line on the fixed-title section of the screen.
  1524. X.PP
  1525. X.I ipick
  1526. Xonly reads lines from the standard input as needed
  1527. X(and after each keyboard command)
  1528. Xrather than reading all input lines on starting.
  1529. XThis is especially useful if the upstream process generates output lines
  1530. Xslowly as
  1531. X.I ipick
  1532. Xis able to display lines as soon as they become available \(em within
  1533. Xthe constraints of any buffering.
  1534. XIt is also useful if the upstream process has the potential to generate
  1535. Xan enormous number of lines of output prior to completion.
  1536. X.PP
  1537. X.I ipick
  1538. Xprocesses binary files correctly, but it's hard to imagine that
  1539. Xthis capability is especially useful.
  1540. X.PP
  1541. XWhen constructing pipelines, be aware of the fact that many
  1542. Xcommands don't take multiple parameters.
  1543. XIn these cases, use xargs \-l1 if your system has it.
  1544. X.SH RESTRICTIONS
  1545. X.PP
  1546. X.I ipick
  1547. Xis designed to process modest amounts of data.
  1548. XThe data is held in memory and all functions are coded simplistically.
  1549. XIf you ask
  1550. X.I ipick
  1551. Xto handle large amounts of data, it does so sluggishly and
  1552. Xconsumes excessive system resources.
  1553. X.PP
  1554. X.I ipick
  1555. Xtakes a passive approach to ambiguous function key
  1556. Xdefinitions \(em later definitions override earlier definitions.
  1557. X.PP
  1558. XThe search function does not handle regular expressions.
  1559. X.PP
  1560. XBecause of the way in which
  1561. X.I ipick
  1562. Xreads the standard input, using
  1563. X.I ipick
  1564. Xwith data from the keyboard does not work
  1565. Xas you would want (In fact
  1566. X.I ipick
  1567. Xshould probably insist on a pipe or a file as input,
  1568. Xjust as
  1569. X.I more
  1570. Xdoes).
  1571. XThe workaround is to use the ``here document'' capability
  1572. Xof the shell (the ``<<'' redirection).
  1573. X.PP
  1574. X.I ipick
  1575. Xarbitrarily expands tab characters to 8-column tabstops.
  1576. X.SH BUGS
  1577. X.PP
  1578. XThe online help does not display properly if the screen is less than 80
  1579. Xcolumns wide.
  1580. X.PP
  1581. XDirections implied by movement and scrolling commands apply to
  1582. Xthe cursor, not the data.
  1583. X.PP
  1584. X.I ipick
  1585. Xdoes not know when include files opened with
  1586. X.IR popen (1)
  1587. Xfail.
  1588. XThis can sometimes cause
  1589. X.I ipick
  1590. Xto wait for ever depending on the state of the child process.
  1591. X.SH MOTIVATION
  1592. X.PP
  1593. XIt is the very essence of Unix to make useful
  1594. Xcommands with the generic construct:
  1595. X.IP
  1596. Xgenerate_listing |
  1597. X.I FILTER
  1598. X| do_something
  1599. X.PD 0
  1600. X.PP
  1601. Xor
  1602. X.IP
  1603. Xdo_something `generate_listing |
  1604. X.IR FILTER `
  1605. X.PD
  1606. X.PP
  1607. XThe problem is
  1608. X.IR FILTER .
  1609. XGetting it correct for the simplistic case is easy,
  1610. Xmaking it perfect and bullet-proof is not.
  1611. XThis is especially true if the pipeline is being
  1612. Xdeveloped for the user community.
  1613. X.PP
  1614. XThink about how you typically build a pipeline for
  1615. Xthe following requests:
  1616. X.IP
  1617. X``Kill my awk process, it's hung my terminal.''
  1618. X.br
  1619. X``Remove my print job, I've run the wrong report.''
  1620. X.br
  1621. X``Remove that message queue, then re-run the daemon.''
  1622. X.PP
  1623. XEither you construct a nice obscure
  1624. X.I FILTER
  1625. Xusing some
  1626. Xcombination of
  1627. X.IR grep (1),
  1628. X.IR awk (1),
  1629. X.IR perl (1),
  1630. Xor
  1631. X.IR sed (1)
  1632. X\(em usually
  1633. Xafter
  1634. Xyou've had a look at the
  1635. X.I generate_listing
  1636. Xoutput a couple of times to make sure
  1637. Xyou don't zap the wrong thing!
  1638. XAlternatively you run the
  1639. X.I generate_listing
  1640. Xprogram a couple of times until you've memorized the
  1641. Xrelevant identifier (such as pid, job number, queue id), then you
  1642. Xrun the
  1643. X.I do_something
  1644. Xprogram and re-type the relevant identifier
  1645. Xtrying as best you can to avoid mis-typing and mis-remembering.
  1646. X.PP
  1647. XIn other words, tedious and error-prone.
  1648. X.PP
  1649. XOf course, when the
  1650. Xtime comes to give your neat pipeline or script
  1651. Xto the user community, how do you give it an
  1652. Xeasy to use, safe, bullet-proof interface?
  1653. XDo you knock up a quick shell wrapper with
  1654. Xtoken prompts, perfunctory checking and an
  1655. Xinterface that's
  1656. X.I almost
  1657. Xthe same as your last shell wrapper?
  1658. X.PP
  1659. XIf any of these situations sound familiar then
  1660. X.I ipick
  1661. Xmay well be your pipeline panacea!
  1662. X(Well, at least marginally useful.)
  1663. X.PP
  1664. XThis is because
  1665. X.I ipick
  1666. Xmakes the user the final part of the
  1667. X.I FILTER
  1668. Xin a safe, friendly manner, often obviating the need for
  1669. Xshell wrappers and such.
  1670. X.PP
  1671. XThe example of selecting and removing a set of print jobs
  1672. Xis the easiest way to demonstrate
  1673. X.IR ipick .
  1674. XWith the pipeline:
  1675. X.nf
  1676. X.IP
  1677. Xlpq | grep `whoami` | ipick | awk '{ print $3 }' | xargs lprm
  1678. X.fi
  1679. X.PP
  1680. XYou use
  1681. X.I ipick
  1682. Xto select the print jobs to be removed and the
  1683. Xpipeline does the rest, removing only those print jobs
  1684. Xselected with
  1685. X.IR ipick .
  1686. XAnother example:
  1687. X.nf
  1688. X.IP
  1689. Xkill \-9 `ps | ipick \-T1 | awk '{ print $1 }'`
  1690. X.fi
  1691. X.PP
  1692. Xyou simply select the lines with the relevant pids then
  1693. Xexit from
  1694. X.I ipick
  1695. X\(em the pipeline does the rest by killing only those processes
  1696. Xyou selected with
  1697. X.IR ipick .
  1698. X.SH EXAMPLES
  1699. X.PP
  1700. XA few more examples to get you started.
  1701. XNormally you would define each of these
  1702. Xas a function or alias in your shell.
  1703. X(Of course, I present these examples as ideas.
  1704. XThey are not complete, bullet-proof functions.)
  1705. X.PP
  1706. X.I "Pick source files to edit."
  1707. X.nf
  1708. X.IP
  1709. Xvi `ls \-1 *.c | ipick \-m1`
  1710. X.fi
  1711. X.PP
  1712. X.I "Pick a directory to cd to."
  1713. X.nf
  1714. X.IP
  1715. Xcd `ls \-l | grep '^d' | ipick \-m1 \-M1 \-a | cut \-c46\-`
  1716. X.fi
  1717. X.PP
  1718. X.ne 6
  1719. X.I "Pick files to extract from a tar file in the default tape drive."
  1720. X.nf
  1721. X.IP
  1722. Xtar t | ipick | xargs tar xv
  1723. X.fi
  1724. X.PP
  1725. XI find this especially useful when the archive
  1726. Xcontains l-o-o-o-ng filenames.
  1727. X.PP
  1728. XActually, in its current form
  1729. Xthe above example has a number of limitations, so a more complete
  1730. Xsolution to an interactive tar is:
  1731. X.nf
  1732. X.IP
  1733. X.ta \w'\0\0\0\0\0\0\0\0'u
  1734. Xtar tvf ${1:\-/dev/rmt8} | sed \-e 's./$..' | ipick |
  1735. X.br
  1736. X    cut \-c42\- | xargs \-v \-t tar xvf ${1:\-/dev/rmt8} {}
  1737. X.fi
  1738. X.DT
  1739. X.PP
  1740. X.I "Clean up a directory containing many junk files."
  1741. X.PP
  1742. XThe following pipeline does this by letting you select
  1743. Xthe files you want to keep, and deleting the rest.
  1744. X.nf
  1745. X.IP
  1746. X.ta \w'\0\0\0\0\0\0\0\0'u
  1747. Xrm `ls \-l | grep '^\-' | ipick \-v \-t "Which files to keep ?" |
  1748. X.br
  1749. X    cut \-c46\-`
  1750. X.fi
  1751. X.DT
  1752. X.PP
  1753. X.ne 19
  1754. X.I "Part of the login script to set the terminal type"
  1755. X.nf
  1756. X.IP
  1757. X.ta \w'xterm\0\0\0\0'u
  1758. X#! /bin/sh
  1759. X.sp
  1760. X\&...
  1761. X.sp
  1762. Xexport TERM
  1763. XTERM=`ipick \-m1 \-M1 \-r \-a \-T3 <<EOD | cut \-f1 \-d' '
  1764. X.sp
  1765. X    Pick the terminal type that you are logged into
  1766. X.sp
  1767. Xvt100    The old grey terminals in the conference room
  1768. Xxterm    The new fancy terminals in the bosses office
  1769. Xsun    One of the workstations in the sysadmin's office!
  1770. XEOD`
  1771. X.sp
  1772. X\&...
  1773. X.fi
  1774. X.DT
  1775. X.PP
  1776. X.I "Site conventions for predefined files"
  1777. X.PP
  1778. XIf you get really keen, you can have a site convention for
  1779. Xall pre-defined
  1780. X.I ipick
  1781. Xfiles, such as:
  1782. X.TP
  1783. X\(bu
  1784. Xfirst two lines are always header
  1785. X.TP
  1786. X\(bu
  1787. Xfirst space separated field is always the output
  1788. Xselection value
  1789. X.PP
  1790. XThen you can define a generic function or script
  1791. X(let's call it ipickf) such as:
  1792. X.nf
  1793. X.IP
  1794. Xipick \-a \-m1 \-M1 \-r \-T2 $HOME/pickfiles/$1 | cut \-f1 \-d' '
  1795. X.fi
  1796. X.PP
  1797. Xthen use it around the traps as:
  1798. X.nf
  1799. X.IP
  1800. XTERM=`ipickf TERM`
  1801. X.fi
  1802. X.PP
  1803. X.SH VERSION
  1804. X.PP
  1805. X.I ipick
  1806. Xversion 1.1, dated 28 February, 1993.
  1807. X.SH AUTHOR
  1808. X.PP
  1809. XCopyright (c) 1993, Mark Delany <markd@werple.apana.org.au>
  1810. XAll rights reserved.
  1811. X.PP
  1812. XSubstantial man page improvements by DaviD W. Sanderson <dws@ssec.wisc.edu>
  1813. X.PP
  1814. X.I ipick
  1815. Xmay only be copied under the terms of either the Artistic License
  1816. Xor
  1817. Xthe GNU General Public Licence,
  1818. Xwhich may be found in the ipick source kit.
  1819. X.SH "SEE ALSO"
  1820. X.IR stty (1),
  1821. X.IR xargs (1V),
  1822. X.IR xterm (1L),
  1823. X.IR curses (3V),
  1824. X.IR terminfo (5),
  1825. X.IR termcap (5)
  1826. END_OF_FILE
  1827.   if test 24269 -ne `wc -c <'ipick/ipick.1'`; then
  1828.     echo shar: \"'ipick/ipick.1'\" unpacked with wrong size!
  1829.   fi
  1830.   # end of 'ipick/ipick.1'
  1831. fi
  1832. if test -f 'ipick/config/TEMPLATE' -a "${1}" != "-c" ; then 
  1833.   echo shar: Will not clobber existing file \"'ipick/config/TEMPLATE'\"
  1834. else
  1835.   echo shar: Extracting \"'ipick/config/TEMPLATE'\" \(3166 characters\)
  1836.   sed "s/^X//" >'ipick/config/TEMPLATE' <<'END_OF_FILE'
  1837. X# This is the template file for ipick. Use this to create a new
  1838. X# template file as needed and send it back to the author with a
  1839. X# precise definition of your system so that others may benefit
  1840. X# from your effort.
  1841. X
  1842. X# The template file becomes part of the makefile so make sure that
  1843. X# the syntax is consistant with what your make expects.
  1844. X
  1845. X# CC        Nominate your C compiler if cc is inappropriate
  1846. X#
  1847. X# Example:    CC = gcc
  1848. X
  1849. X
  1850. X
  1851. X# P_INCLUDE    Define #include search directories, typically with -I
  1852. X#
  1853. X# Example:    P_INCLUDE = -I/usr/5include
  1854. X
  1855. XP_INCLUDE    =
  1856. X
  1857. X
  1858. X
  1859. X# P_LIBS    Define libraries that need to be included to get
  1860. X#        the relevant system libraries. Mostly likely candidates
  1861. X#        are malloc, curses and terminfo/termcap.
  1862. X
  1863. XP_LIBS         = -lcurses
  1864. X
  1865. X
  1866. X
  1867. X# P_CFLAGS    Flags to give to the C compiler.
  1868. X
  1869. XP_CFLAGS     = -O
  1870. X
  1871. X
  1872. X
  1873. X# P_LDFLAGS    Flag to give to ld the linker.
  1874. X#
  1875. X# Example:    P_LDFLAGS = -g
  1876. X
  1877. XP_LDFLAGS    =
  1878. X
  1879. X
  1880. X
  1881. X# P_NO_FLAGS    Define the NO_ variables that identify which of the
  1882. X#        following list of system calls, externals and #includes
  1883. X#        which are missing from your particular system.
  1884. X#
  1885. X#
  1886. X# Variable        Why
  1887. X# --------        --------------------------------------------
  1888. X#
  1889. X# NO_BEEP        Your curses hasn't got beep() Use port.c
  1890. X#
  1891. X# NO_NEWTERM        Your curses hasn't got newterm() Use port.c
  1892. X#
  1893. X# NO_PROTOTYPES        Your C compiler doesn't grok prototypes
  1894. X#
  1895. X# NO_SIGWINCH        Your system hasn't got SIGWINCH, or
  1896. X#            ipick doesn't handle it properly...
  1897. X#
  1898. X# NO_STANDOUT        Your curses is so old that it doesn't even
  1899. X#            have standout and standend. This is not
  1900. X#            very important and port.c has null functions.
  1901. X#            Use port.c
  1902. X#
  1903. X# NO_STRDUP        Your C library hasn't got strdup() Use port.c
  1904. X#
  1905. X# NO_STRPBRK        Your C library hasn't got strpbrk() Use port.c
  1906. X#
  1907. X# NO_STRSTR        Your C library hasn't got strstr() Use port.c
  1908. X#
  1909. X# NO_TGETSTR        Your curses hasn't got tgetstr(). Very rare!
  1910. X#            See USE_TIGETSTR.
  1911. X#
  1912. X# --------------------
  1913. X#
  1914. X# Define the include files that are missing from you system. In most
  1915. X# cases, the config.h file simple defines the prototypes for the
  1916. X# relevant missing entries.
  1917. X#
  1918. X# NO_LIMITS_H        No limits.h for CHAR_BIT (defaults to 8)
  1919. X#
  1920. X# NO_MALLOC_H        No malloc.h for malloc() and realloc()
  1921. X#
  1922. X# NO_MEMORY_H        No memory.h with memcpy
  1923. X#
  1924. X# NO_STDLIB_H        stdlib.h pulls in getenv() prototype
  1925. X#
  1926. X# NO_STRING_H        No string.h for strcpy() et al proto's
  1927. X#
  1928. X#
  1929. X#
  1930. X# --------------------
  1931. X#
  1932. X# Define the external variables that are missing from your systems
  1933. X# libraries:
  1934. X#
  1935. X# NO_ERRNO        #include <errno.h> doesn't define errno.
  1936. X#
  1937. X# NO_OPTOPT        Your getopt() doesn't define/use optopt.
  1938. X#
  1939. X#
  1940. X# Example:    P_NO_FLAGS = -DNO_STRDUP -DNO_MALLOC_H -DNO_ERRNO
  1941. X
  1942. X
  1943. X
  1944. X# P_USE_FLAGS    Define the USE_ variables when your system has
  1945. X#        alternatives to the system calls and #includes
  1946. X#        normally used by ipick.
  1947. X#
  1948. X# Variable        Why
  1949. X# --------        --------------------------------------------
  1950. X#
  1951. X# USE_TIGETSTR        If your curses has tigetstr() irregardless of
  1952. X#            of the existance of tgetstr(). If this isn't
  1953. X#            defined and NO_TGETSTR is defined then ipick
  1954. X#            will not look at the terminal definition for
  1955. X#            keybindings.
  1956. X#
  1957. X#
  1958. X# USE_CURSESX_H        Use #include <cursesX.h> rather than <curses.h>
  1959. X#            Decstations need this, maybe others...
  1960. X
  1961. X# Example:    P_USE_FLAGS    = -DUSE_CURSESX_H
  1962. END_OF_FILE
  1963.   if test 3166 -ne `wc -c <'ipick/config/TEMPLATE'`; then
  1964.     echo shar: \"'ipick/config/TEMPLATE'\" unpacked with wrong size!
  1965.   fi
  1966.   # end of 'ipick/config/TEMPLATE'
  1967. fi
  1968. if test -f 'ipick/config/interactive-gcc' -a "${1}" != "-c" ; then 
  1969.   echo shar: Will not clobber existing file \"'ipick/config/interactive-gcc'\"
  1970. else
  1971.   echo shar: Extracting \"'ipick/config/interactive-gcc'\" \(202 characters\)
  1972.   sed "s/^X//" >'ipick/config/interactive-gcc' <<'END_OF_FILE'
  1973. X#    For:    Interactive SysVr3 2.2 with gcc.
  1974. X#    From:    Philip Copeland <p_copela@csd.bristol-poly.ac.uk>
  1975. X
  1976. XCC         = gcc
  1977. XP_CFLAGS    = -O -traditional 
  1978. XP_LIBS        = -lcurses -lcposix
  1979. X
  1980. X# Maybe? P_NO_FLAGS    = -DNO_STRPBRK
  1981. END_OF_FILE
  1982.   if test 202 -ne `wc -c <'ipick/config/interactive-gcc'`; then
  1983.     echo shar: \"'ipick/config/interactive-gcc'\" unpacked with wrong size!
  1984.   fi
  1985.   # end of 'ipick/config/interactive-gcc'
  1986. fi
  1987. if test -f 'ipick/config/linux' -a "${1}" != "-c" ; then 
  1988.   echo shar: Will not clobber existing file \"'ipick/config/linux'\"
  1989. else
  1990.   echo shar: Extracting \"'ipick/config/linux'\" \(224 characters\)
  1991.   sed "s/^X//" >'ipick/config/linux' <<'END_OF_FILE'
  1992. X#    For:    Linux 0.96c
  1993. X#    From:    Matthew Jackson <M.Jackson@unsw.edu.au>
  1994. X
  1995. XCC        = gcc
  1996. XP_LIBS        = -lcurses -ltermcap
  1997. XP_CFLAGS    = -O -g
  1998. XP_LDFLAGS    = -g
  1999. XP_NO_FLAGS    = -DNO_BEEP -DNO_NEWTERM -DNO_LIMITS_H -DNO_OPTOPT
  2000. X
  2001. X# Maybe? -DNO_STRPBRK
  2002. END_OF_FILE
  2003.   if test 224 -ne `wc -c <'ipick/config/linux'`; then
  2004.     echo shar: \"'ipick/config/linux'\" unpacked with wrong size!
  2005.   fi
  2006.   # end of 'ipick/config/linux'
  2007. fi
  2008. if test -f 'ipick/config/mtxinu' -a "${1}" != "-c" ; then 
  2009.   echo shar: Will not clobber existing file \"'ipick/config/mtxinu'\"
  2010. else
  2011.   echo shar: Extracting \"'ipick/config/mtxinu'\" \(273 characters\)
  2012.   sed "s/^X//" >'ipick/config/mtxinu' <<'END_OF_FILE'
  2013. X#    For:    mt xinu MORE/bsd
  2014. X#    From:    Marty Olevitch <marty@wuphys.wustl.edu>
  2015. X
  2016. XP_NO_FLAGS    = -DNO_STDLIB_H -DNO_MALLOC_H -DNO_LIMITS_H \
  2017. X-DNO_BEEP -DNO_STRSTR -DNO_STRDUP -DNO_NEWTERM \
  2018. X-DNO_ERRNO -DNO_PROTOTYPES
  2019. X
  2020. X# Maybe? -DNO_STRPBRK
  2021. X
  2022. XP_CFLAGS    = -O
  2023. XP_LIBS        = -lcurses -ltermcap
  2024. END_OF_FILE
  2025.   if test 273 -ne `wc -c <'ipick/config/mtxinu'`; then
  2026.     echo shar: \"'ipick/config/mtxinu'\" unpacked with wrong size!
  2027.   fi
  2028.   # end of 'ipick/config/mtxinu'
  2029. fi
  2030. if test -f 'ipick/config/sunos4' -a "${1}" != "-c" ; then 
  2031.   echo shar: Will not clobber existing file \"'ipick/config/sunos4'\"
  2032. else
  2033.   echo shar: Extracting \"'ipick/config/sunos4'\" \(246 characters\)
  2034.   sed "s/^X//" >'ipick/config/sunos4' <<'END_OF_FILE'
  2035. X# SunOS 4.1 and greater. This is the terminfo version. If you prefer
  2036. X# termcap (which is smaller!) try sunos4_tc
  2037. X
  2038. XCC        = /usr/5bin/cc
  2039. XP_CFLAGS    = -O
  2040. XP_LIBS        = -lcurses
  2041. XP_NO_FLAGS    = -DNO_PROTOTYPES -DUSE_TIGETSTR -DNO_TGETSTR
  2042. XLINT        = /usr/5bin/lint
  2043. END_OF_FILE
  2044.   if test 246 -ne `wc -c <'ipick/config/sunos4'`; then
  2045.     echo shar: \"'ipick/config/sunos4'\" unpacked with wrong size!
  2046.   fi
  2047.   # end of 'ipick/config/sunos4'
  2048. fi
  2049. if test -f 'ipick/config/sunos4-tcap' -a "${1}" != "-c" ; then 
  2050.   echo shar: Will not clobber existing file \"'ipick/config/sunos4-tcap'\"
  2051. else
  2052.   echo shar: Extracting \"'ipick/config/sunos4-tcap'\" \(138 characters\)
  2053.   sed "s/^X//" >'ipick/config/sunos4-tcap' <<'END_OF_FILE'
  2054. X# SunOS 4.1>= with termcap
  2055. X
  2056. XP_LIBS        = -lcurses -ltermcap
  2057. XP_NO_FLAGS    = -DNO_PROTOTYPES -DNO_BEEP -DNO_NEWTERM
  2058. XP_CFLAGS    = -g
  2059. XP_LDLFAGS    = -g
  2060. END_OF_FILE
  2061.   if test 138 -ne `wc -c <'ipick/config/sunos4-tcap'`; then
  2062.     echo shar: \"'ipick/config/sunos4-tcap'\" unpacked with wrong size!
  2063.   fi
  2064.   # end of 'ipick/config/sunos4-tcap'
  2065. fi
  2066. if test -f 'ipick/config/svr3' -a "${1}" != "-c" ; then 
  2067.   echo shar: Will not clobber existing file \"'ipick/config/svr3'\"
  2068. else
  2069.   echo shar: Extracting \"'ipick/config/svr3'\" \(343 characters\)
  2070.   sed "s/^X//" >'ipick/config/svr3' <<'END_OF_FILE'
  2071. X#
  2072. X# System            Thanks to
  2073. X# ----------------        ---------------------------------------
  2074. X# Encore Multimax UMAX V 2.4m    Kevin Stock <kstock@encore.com>
  2075. X# NCR Tower V.3            John Alsop <jalsop@seachg.com>
  2076. X# AT&T Unix Sys V 3.1 (Prime EXL 325)
  2077. X#
  2078. X
  2079. XP_CFLAGS    =
  2080. XP_LIBS        = -lcurses
  2081. XP_NO_FLAGS    = -DNO_STDLIB_H -DNO_PROTOTYPES -DNO_STRSTR
  2082. X
  2083. X# Maybe? -DNO_STRPBRK
  2084. END_OF_FILE
  2085.   if test 343 -ne `wc -c <'ipick/config/svr3'`; then
  2086.     echo shar: \"'ipick/config/svr3'\" unpacked with wrong size!
  2087.   fi
  2088.   # end of 'ipick/config/svr3'
  2089. fi
  2090. if test -f 'ipick/config/ultrix' -a "${1}" != "-c" ; then 
  2091.   echo shar: Will not clobber existing file \"'ipick/config/ultrix'\"
  2092. else
  2093.   echo shar: Extracting \"'ipick/config/ultrix'\" \(177 characters\)
  2094.   sed "s/^X//" >'ipick/config/ultrix' <<'END_OF_FILE'
  2095. X#    For:    ULTRIX 4.2 on a Decstation
  2096. X#    From:    David Raz <draz@ee.technion.ac.il>
  2097. X
  2098. XP_LIBS        = -lcursesX
  2099. XP_USE_FLAGS    = -DUSE_CURSESX_H
  2100. X
  2101. XP_NO_FLAGS    = -DNO_STRDUP
  2102. X
  2103. X# Maybe? -DNO_STRPBRK
  2104. END_OF_FILE
  2105.   if test 177 -ne `wc -c <'ipick/config/ultrix'`; then
  2106.     echo shar: \"'ipick/config/ultrix'\" unpacked with wrong size!
  2107.   fi
  2108.   # end of 'ipick/config/ultrix'
  2109. fi
  2110. if test -f 'ipick/config/vanilla' -a "${1}" != "-c" ; then 
  2111.   echo shar: Will not clobber existing file \"'ipick/config/vanilla'\"
  2112. else
  2113.   echo shar: Extracting \"'ipick/config/vanilla'\" \(879 characters\)
  2114.   sed "s/^X//" >'ipick/config/vanilla' <<'END_OF_FILE'
  2115. X# This file should work on many modern breeds of Unix that have a
  2116. X# prototype compiler and includes, etc. If you have an "older" vanilla
  2117. X# Unix, have a look at ./config/svr3 as this works on the standard
  2118. X# AT&T SVR3.
  2119. X
  2120. X# System            Thanks to
  2121. X# ----------------        ---------------------------------------
  2122. X# AIX 3.1            Joseph M DeAngelo <wrkgrp!tardis!jmd@uunet.uu.net>
  2123. X# AIX 3.1.5            DaviD W. Sanderson <dws@ssec.wisc.edu>
  2124. X# DG/UX 5.4.1 (Aviion)        Jo Stockley <jo@88open.org>
  2125. X# Motorolla 88k R32V3 (SVR3.2)    Jo Stockley <jo@88open.org>
  2126. X# Motorolla 88k R40V2 (SVR4)    Jo Stockley <jo@88open.org>
  2127. X# OSF/1, Version 1.0.4        Rich Salz <rich@osf.org>
  2128. X# SCO Unix SystemV/386 3.2r2.0
  2129. X#    DevSys: 3.2.0        Petri Wessman <petri@cerebus.inter.fi>
  2130. X# SVR4                UHC 4.0 Version 2.0
  2131. X# ----------------        ---------------------------------------
  2132. X
  2133. XP_CFLAGS    = -O
  2134. XP_LIBS        = -lcurses
  2135. X
  2136. X# Maybe? P_NO_FLAGS = -DNO_STRPBRK
  2137. END_OF_FILE
  2138.   if test 879 -ne `wc -c <'ipick/config/vanilla'`; then
  2139.     echo shar: \"'ipick/config/vanilla'\" unpacked with wrong size!
  2140.   fi
  2141.   # end of 'ipick/config/vanilla'
  2142. fi
  2143. if test -f 'ipick/config/xenix386' -a "${1}" != "-c" ; then 
  2144.   echo shar: Will not clobber existing file \"'ipick/config/xenix386'\"
  2145. else
  2146.   echo shar: Extracting \"'ipick/config/xenix386'\" \(1765 characters\)
  2147.   sed "s/^X//" >'ipick/config/xenix386' <<'END_OF_FILE'
  2148. X#  For:      SCO XENIX 386 (without GNU-CC)
  2149. X#  From:  Peter Funk <pf@artcom0.north.de>
  2150. X
  2151. X#if you have gcc1.40 :
  2152. X#CC        = gcc
  2153. X#P_CFLAGS    = -g -O
  2154. X#else 
  2155. XCC        = cc
  2156. XP_CFLAGS    = -Zi 
  2157. X#endif
  2158. X
  2159. XP_LIBS        = -lcurses -ltinfo
  2160. XP_NO_FLAGS    = -DNO_STDLIB_H -DNO_PROTOTYPES -DNO_STRSTR -DNO_LIMITS_H
  2161. X
  2162. X#  Notes: I will strongly encourage you to use the GNU-C-Compiler because
  2163. X#         the Microsoft-C-Compiler delivered from SCO must be considered
  2164. X#      absolutely broken under several serious ways.  You may use `cc'
  2165. X#         to compile 'ipick', but it will complain about language.c :
  2166. X#        warning C4009: string too big, trailing chars truncated 
  2167. X#         There is a complete binary (and of course source too) distribution
  2168. X#         of 'gcc1.40', 'gdb3.5' and 'gas1.38' available for XENIX 386,
  2169. X#         which installs out of box (using /etc/custom) and which 
  2170. X#      is of production quality and robustness.  This compiler generates
  2171. X#      OMF-object files, so you are able to use your OMF-XENIX-libs.
  2172. X#  to german inhabitant's only: 
  2173. X#         Ich schicke gcc-Kopien, wenn man mir 4 formatierte 5.25
  2174. X#      HD-Disketten inclusive Rueck-Adress-Aufkleber und Rueck-Porto
  2175. X#      zuschickt.  Adresse siehe unten.
  2176. X#  to others: 
  2177. X#         The XENIX-Patches for gcc-1.40, gdb-3.5 and gas-1.38 were 
  2178. X#      developed by Steve Bleazard (steve@robokar.co.uk), who has
  2179. X#      has also composed the SCO XENIX GCC binary distribution. 
  2180. X#      May be, that this stuff is available on a ftp-server in UK.
  2181. X#      If you can't get it anywhere else, I will make copies on 4 
  2182. X#      preformated 5.25 HD-floppys, if you are willing to make further 
  2183. X#      copies for other interested people from your country.
  2184. X#      Please inlcude a adhesive label with your return-address.
  2185. X#  Peter Funk, Oldenburger Str.86, W-2875 Ganderkesee, Germany
  2186. END_OF_FILE
  2187.   if test 1765 -ne `wc -c <'ipick/config/xenix386'`; then
  2188.     echo shar: \"'ipick/config/xenix386'\" unpacked with wrong size!
  2189.   fi
  2190.   # end of 'ipick/config/xenix386'
  2191. fi
  2192. if test -f 'ipick/config/xenix386-gcc' -a "${1}" != "-c" ; then 
  2193.   echo shar: Will not clobber existing file \"'ipick/config/xenix386-gcc'\"
  2194. else
  2195.   echo shar: Extracting \"'ipick/config/xenix386-gcc'\" \(1764 characters\)
  2196.   sed "s/^X//" >'ipick/config/xenix386-gcc' <<'END_OF_FILE'
  2197. X#  For:      SCO XENIX 386 (with GNU-CC)
  2198. X#  From:  Peter Funk <pf@artcom0.north.de>
  2199. X
  2200. X#if you have gcc1.40 :
  2201. XCC        = gcc
  2202. XP_CFLAGS    = -g -O
  2203. X#else 
  2204. X# CC        = cc
  2205. X# P_CFLAGS    = -Zi 
  2206. X#endif
  2207. X
  2208. XP_LIBS        = -lcurses -ltinfo
  2209. XP_NO_FLAGS    = -DNO_STDLIB_H -DNO_PROTOTYPES -DNO_STRSTR -DNO_LIMITS_H
  2210. X
  2211. X#  Notes: I will strongly encourage you to use the GNU-C-Compiler because
  2212. X#         the Microsoft-C-Compiler delivered from SCO must be considered
  2213. X#      absolutely broken under several serious ways.  You may use `cc'
  2214. X#         to compile 'ipick', but it will complain about language.c :
  2215. X#        warning C4009: string too big, trailing chars truncated 
  2216. X#         There is a complete binary (and of course source too) distribution
  2217. X#         of 'gcc1.40', 'gdb3.5' and 'gas1.38' available for XENIX 386,
  2218. X#         which installs out of box (using /etc/custom) and which 
  2219. X#      is of production quality and robustness.  This compiler generates
  2220. X#      OMF-object files, so you are able to use your OMF-XENIX-libs.
  2221. X#  to german inhabitant's only: 
  2222. X#         Ich schicke gcc-Kopien, wenn man mir 4 formatierte 5.25
  2223. X#      HD-Disketten inclusive Rueck-Adress-Aufkleber und Rueck-Porto
  2224. X#      zuschickt.  Adresse siehe unten.
  2225. X#  to others: 
  2226. X#         The XENIX-Patches for gcc-1.40, gdb-3.5 and gas-1.38 were 
  2227. X#      developed by Steve Bleazard (steve@robokar.co.uk), who has
  2228. X#      has also composed the SCO XENIX GCC binary distribution. 
  2229. X#      May be, that this stuff is available on a ftp-server in UK.
  2230. X#      If you can't get it anywhere else, I will make copies on 4 
  2231. X#      preformated 5.25 HD-floppys, if you are willing to make further 
  2232. X#      copies for other interested people from your country.
  2233. X#      Please inlcude a adhesive label with your return-address.
  2234. X#  Peter Funk, Oldenburger Str.86, W-2875 Ganderkesee, Germany
  2235. END_OF_FILE
  2236.   if test 1764 -ne `wc -c <'ipick/config/xenix386-gcc'`; then
  2237.     echo shar: \"'ipick/config/xenix386-gcc'\" unpacked with wrong size!
  2238.   fi
  2239.   # end of 'ipick/config/xenix386-gcc'
  2240. fi
  2241. if test -f 'ipick/examples/README' -a "${1}" != "-c" ; then 
  2242.   echo shar: Will not clobber existing file \"'ipick/examples/README'\"
  2243. else
  2244.   echo shar: Extracting \"'ipick/examples/README'\" \(868 characters\)
  2245.   sed "s/^X//" >'ipick/examples/README' <<'END_OF_FILE'
  2246. XThis directory contains a number of pre-defined bourne shell
  2247. Xfunctions that show ways in which you can use ipick.
  2248. X
  2249. XIn many cases these functions can be used straight "out-of-the-box" in
  2250. Xother cases you may wish to make modifications to suit your needs.
  2251. X
  2252. XAs per usual, if you create new and interesting functions, send them
  2253. Xback to the author and they will be added to the next posting.
  2254. X
  2255. XIn all cases you can define the functions with the bourne shell by
  2256. Xsimply going:
  2257. X
  2258. X. ./*examplename*
  2259. X
  2260. XThis also works for bash and probably for a number of the other newer
  2261. Xshells.
  2262. X
  2263. XThese functions fundamentally rely on the following commands:
  2264. X
  2265. X    o    cut
  2266. X    o    tail
  2267. X    o    awk (as rarely as possible)
  2268. X
  2269. XI prefer cut to awk mainly because on my system cut is 1/10th the size
  2270. Xof awk. However, I have a complaint regarding cut: it doesn't have a
  2271. Xwhitespace delimiter which makes it a bore to use.
  2272. END_OF_FILE
  2273.   if test 868 -ne `wc -c <'ipick/examples/README'`; then
  2274.     echo shar: \"'ipick/examples/README'\" unpacked with wrong size!
  2275.   fi
  2276.   # end of 'ipick/examples/README'
  2277. fi
  2278. if test -f 'ipick/examples/ikillps' -a "${1}" != "-c" ; then 
  2279.   echo shar: Will not clobber existing file \"'ipick/examples/ikillps'\"
  2280. else
  2281.   echo shar: Extracting \"'ipick/examples/ikillps'\" \(287 characters\)
  2282.   sed "s/^X//" >'ipick/examples/ikillps' <<'END_OF_FILE'
  2283. X
  2284. X# Kill processes based on ps output
  2285. X# Usage: ikillps [-SIG]
  2286. X
  2287. X# Assumption:    PID is in columns 1-6 (including a trailing space)
  2288. X
  2289. X
  2290. Xikillps()
  2291. X{
  2292. X    pidlist=`ps | ipick -T1 -t"\\t\\tSelect pids to kill $1" | cut -c1-6`
  2293. X    if [ "$pidlist" ]; then
  2294. X        cmd="kill $1 $pidlist"
  2295. X        echo $cmd
  2296. X        $cmd
  2297. X    fi
  2298. X}
  2299. END_OF_FILE
  2300.   if test 287 -ne `wc -c <'ipick/examples/ikillps'`; then
  2301.     echo shar: \"'ipick/examples/ikillps'\" unpacked with wrong size!
  2302.   fi
  2303.   chmod +x 'ipick/examples/ikillps'
  2304.   # end of 'ipick/examples/ikillps'
  2305. fi
  2306. if test -f 'ipick/examples/ikillpt' -a "${1}" != "-c" ; then 
  2307.   echo shar: Will not clobber existing file \"'ipick/examples/ikillpt'\"
  2308. else
  2309.   echo shar: Extracting \"'ipick/examples/ikillpt'\" \(395 characters\)
  2310.   sed "s/^X//" >'ipick/examples/ikillpt' <<'END_OF_FILE'
  2311. X
  2312. X# If you have Tom Christiansen's <tchrist@convex.com> perl script 'pt',
  2313. X# then this is the kill for you.
  2314. X
  2315. X# Kill processes based on pt output
  2316. X# Usage: ikillpt [-SIG]
  2317. X
  2318. X# Assumption:    PID is in colums 10-15 (including a trailing space)
  2319. X
  2320. Xikillpt()
  2321. X{
  2322. X    pidlist=`pt | ipick -T1 -t"\\t\\tSelect pids to kill $1" | cut -c10-15`
  2323. X    if [ "$pidlist" ]; then
  2324. X        cmd="kill $1 $pidlist"
  2325. X        echo $cmd
  2326. X        $cmd
  2327. X    fi
  2328. X}
  2329. END_OF_FILE
  2330.   if test 395 -ne `wc -c <'ipick/examples/ikillpt'`; then
  2331.     echo shar: \"'ipick/examples/ikillpt'\" unpacked with wrong size!
  2332.   fi
  2333.   chmod +x 'ipick/examples/ikillpt'
  2334.   # end of 'ipick/examples/ikillpt'
  2335. fi
  2336. if test -f 'ipick/examples/ilprm' -a "${1}" != "-c" ; then 
  2337.   echo shar: Will not clobber existing file \"'ipick/examples/ilprm'\"
  2338. else
  2339.   echo shar: Extracting \"'ipick/examples/ilprm'\" \(339 characters\)
  2340.   sed "s/^X//" >'ipick/examples/ilprm' <<'END_OF_FILE'
  2341. X
  2342. X# Remove print jobs from lpd's print queue
  2343. X# Usage: ilprm [lpq-options]
  2344. X
  2345. X# Assumption:    job id is in columns 16-21
  2346. X
  2347. Xilprm()
  2348. X{
  2349. X    jobids=`lpq $1 | grep \`whoami\` | ipick -t"Pick Print jobs to remove"| cut -c16-21`
  2350. X    if [ "$jobids" ]; then
  2351. X        cmd="lprm $jobids"
  2352. X        echo $cmd
  2353. X        $cmd
  2354. X    else
  2355. X        echo There are no print jobs queued for `whoami`
  2356. X    fi
  2357. X}
  2358. END_OF_FILE
  2359.   if test 339 -ne `wc -c <'ipick/examples/ilprm'`; then
  2360.     echo shar: \"'ipick/examples/ilprm'\" unpacked with wrong size!
  2361.   fi
  2362.   chmod +x 'ipick/examples/ilprm'
  2363.   # end of 'ipick/examples/ilprm'
  2364. fi
  2365. if test -f 'ipick/examples/imenu' -a "${1}" != "-c" ; then 
  2366.   echo shar: Will not clobber existing file \"'ipick/examples/imenu'\"
  2367. else
  2368.   echo shar: Extracting \"'ipick/examples/imenu'\" \(555 characters\)
  2369.   sed "s/^X//" >'ipick/examples/imenu' <<'END_OF_FILE'
  2370. X
  2371. X# Return a selection from a menu list
  2372. X#
  2373. X# The menu list comes from a file nominated on the command line.
  2374. X
  2375. X# The format is that the first line is the title and each subsequent
  2376. X# line has a whitespace delimited field as field one which is returned
  2377. X# as the choice. Eg:
  2378. X#
  2379. X# TITLE
  2380. X# 1    Run prog x
  2381. X# 2    Run prog y
  2382. X# Q    Quit
  2383. X
  2384. X# Exactly one and only one selection is allowed.
  2385. X
  2386. X# Usage:    next=`imenu Menu_Filename`
  2387. X
  2388. Ximenu()
  2389. X
  2390. X{
  2391. X    if [ "$1" = "" ]; then
  2392. X        echo '**ERROR: ichoice requires a filename'
  2393. X        return 1
  2394. X    fi
  2395. X
  2396. X    ipick -a -m 1 -M 1 -r -T1 $1 | awk '{ print $1 }'
  2397. X}
  2398. END_OF_FILE
  2399.   if test 555 -ne `wc -c <'ipick/examples/imenu'`; then
  2400.     echo shar: \"'ipick/examples/imenu'\" unpacked with wrong size!
  2401.   fi
  2402.   chmod +x 'ipick/examples/imenu'
  2403.   # end of 'ipick/examples/imenu'
  2404. fi
  2405. if test -f 'ipick/examples/irm' -a "${1}" != "-c" ; then 
  2406.   echo shar: Will not clobber existing file \"'ipick/examples/irm'\"
  2407. else
  2408.   echo shar: Extracting \"'ipick/examples/irm'\" \(349 characters\)
  2409.   sed "s/^X//" >'ipick/examples/irm' <<'END_OF_FILE'
  2410. X
  2411. X# Remove files in the current directory
  2412. X
  2413. X# Usage:    irm    [directory]
  2414. X
  2415. X# Assumption:    ls -l produces filenames starting in column 46
  2416. X#         ls -a generates  the lines: "totals", "." and ".." first
  2417. X
  2418. Xirm()
  2419. X{
  2420. X    files=`ls -la $1 | tail +4 | ipick -t'\t\tSelect files to rm -rf' | cut -c45-`
  2421. X    if [ "$files" ]; then
  2422. X        cmd="rm -rf $files"
  2423. X        echo $cmd
  2424. X        $cmd
  2425. X    fi
  2426. X}
  2427. END_OF_FILE
  2428.   if test 349 -ne `wc -c <'ipick/examples/irm'`; then
  2429.     echo shar: \"'ipick/examples/irm'\" unpacked with wrong size!
  2430.   fi
  2431.   chmod +x 'ipick/examples/irm'
  2432.   # end of 'ipick/examples/irm'
  2433. fi
  2434. if test -f 'ipick/examples/itarx' -a "${1}" != "-c" ; then 
  2435.   echo shar: Will not clobber existing file \"'ipick/examples/itarx'\"
  2436. else
  2437.   echo shar: Extracting \"'ipick/examples/itarx'\" \(420 characters\)
  2438.   sed "s/^X//" >'ipick/examples/itarx' <<'END_OF_FILE'
  2439. X
  2440. X# Extract files from a tar file. Change /dev/rst8 to be your default
  2441. X# primary tape/floppy drive. Works well with .tar files on disk.
  2442. X
  2443. X# Usage: itar [tarfile]
  2444. X
  2445. X# Assumption:    tar tf places filenames as column 43 and beyond
  2446. X
  2447. Xitarx()
  2448. X{
  2449. X    tarfile=${1:-/dev/rst8}
  2450. X    files=`tar tvf $tarfile|tail +3|ipick -t'\t\tSelect files to extract'|cut -c42-`
  2451. X    if [ "$files" ]; then
  2452. X        cmd="tar xf $tarfile $files"
  2453. X        echo $cmd
  2454. X        $cmd
  2455. X    fi
  2456. X}
  2457. END_OF_FILE
  2458.   if test 420 -ne `wc -c <'ipick/examples/itarx'`; then
  2459.     echo shar: \"'ipick/examples/itarx'\" unpacked with wrong size!
  2460.   fi
  2461.   chmod +x 'ipick/examples/itarx'
  2462.   # end of 'ipick/examples/itarx'
  2463. fi
  2464. echo shar: End of archive 4 \(of 5\).
  2465. cp /dev/null ark4isdone
  2466. MISSING=""
  2467. for I in 1 2 3 4 5 ; do
  2468.     if test ! -f ark${I}isdone ; then
  2469.     MISSING="${MISSING} ${I}"
  2470.     fi
  2471. done
  2472. if test "${MISSING}" = "" ; then
  2473.     echo You have unpacked all 5 archives.
  2474.     echo "Check Makefile then run 'make'"
  2475.     rm -f ark[1-9]isdone
  2476. else
  2477.     echo You still must unpack the following archives:
  2478.     echo "        " ${MISSING}
  2479. fi
  2480. exit 0
  2481.  
  2482. exit 0 # Just in case...
  2483.