Home | History | Annotate | Download | only in cscope-fast
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License, Version 1.0 only
      6  * (the "License").  You may not use this file except in compliance
      7  * with the License.
      8  *
      9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  * or http://www.opensolaris.org/os/licensing.
     11  * See the License for the specific language governing permissions
     12  * and limitations under the License.
     13  *
     14  * When distributing Covered Code, include this CDDL HEADER in each
     15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  * If applicable, add the following below this CDDL HEADER, with the
     17  * fields enclosed by brackets "[]" replaced with your own identifying
     18  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  *
     20  * CDDL HEADER END
     21  */
     22 /*	Copyright (c) 1988 AT&T	*/
     23 /*	  All Rights Reserved  	*/
     24 
     25 
     26 /*
     27  * Copyright (c) 1999 by Sun Microsystems, Inc.
     28  * All rights reserved.
     29  */
     30 
     31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
     32 
     33 /*
     34  *	cscope - interactive C symbol cross-reference
     35  *
     36  *	display help
     37  */
     38 
     39 #include "global.h"
     40 #include <curses.h>	/* LINES */
     41 
     42 #define	MAXHELP	50	/* maximum number of help strings */
     43 
     44 void
     45 help(void)
     46 {
     47 	char	**ep, *s, **tp, *text[MAXHELP];
     48 	int	line;
     49 
     50 	tp = text;
     51 	if (changing == NO) {
     52 		if (mouse) {
     53 			*tp++ = "Point with the mouse and click button 1 to "
     54 			    "move to the desired input field,\n";
     55 			*tp++ = "type the pattern to search for, and then "
     56 			    "press the RETURN key.  For the first 5\n";
     57 			*tp++ = "and last 2 input fields, the pattern can be "
     58 			    "a regcmp(3X) regular expression.\n";
     59 			*tp++ = "If the search is successful, you can edit "
     60 			    "the file containing a displayed line\n";
     61 			*tp++ = "by pointing with the mouse and clicking "
     62 			    "button 1.\n";
     63 			*tp++ = "\nYou can either use the button 2 menu or "
     64 			    "these command characters:\n\n";
     65 		} else {
     66 			*tp++ = "Press the TAB key repeatedly to move to the "
     67 			    "desired input field, type the\n";
     68 			*tp++ = "pattern to search for, and then press the "
     69 			    "RETURN key.  For the first 4 and\n";
     70 			*tp++ = "last 2 input fields, the pattern can be a "
     71 			    "regcmp(3X) regular expression.\n";
     72 			*tp++ = "If the search is successful, you can use "
     73 			    "these command characters:\n\n";
     74 			*tp++ = "1-9\tEdit the file containing the displayed "
     75 			    "line.\n";
     76 		}
     77 		*tp++ = "space\tDisplay next lines.\n";
     78 		*tp++ = "+\tDisplay next lines.\n";
     79 		*tp++ = "-\tDisplay previous lines.\n";
     80 		*tp++ = "^E\tEdit all lines.\n";
     81 		*tp++ = ">\tWrite all lines to a file.\n";
     82 		*tp++ = ">>\tAppend all lines to a file.\n";
     83 		*tp++ = "<\tRead lines from a file.\n";
     84 		*tp++ = "^\tFilter all lines through a shell command.\n";
     85 		*tp++ = "|\tPipe all lines to a shell command.\n";
     86 		*tp++ = "\nAt any time you can use these command "
     87 		    "characters:\n\n";
     88 		if (!mouse) {
     89 			*tp++ = "^P\tMove to the previous input field.\n";
     90 		}
     91 		*tp++ = "^A\tSearch again with the last pattern typed.\n";
     92 		*tp++ = "^B\tRecall previous input field and search pattern.\n";
     93 		*tp++ = "^F\tRecall next input field and search pattern.\n";
     94 		*tp++ = "^C\tToggle ignore/use letter case when searching.\n";
     95 		*tp++ = "^R\tRebuild the symbol database.\n";
     96 		*tp++ = "!\tStart an interactive shell (type ^D to return "
     97 		    "to cscope).\n";
     98 		*tp++ = "^L\tRedraw the screen.\n";
     99 		*tp++ = "?\tDisplay this list of commands.\n";
    100 		*tp++ = "^D\tExit cscope.\n";
    101 		*tp++ = "\nNote: If the first character of the pattern you "
    102 		    "want to search for matches\n";
    103 		*tp++ = "a command, type a \\ character first.\n";
    104 	} else {
    105 		if (mouse) {
    106 			*tp++ = "Point with the mouse and click button 1 "
    107 			    "to mark or unmark the line to be\n";
    108 			*tp++ = "changed.  You can also use the button 2 "
    109 			    "menu or these command characters:\n\n";
    110 		} else {
    111 			*tp++ = "When changing text, you can use these "
    112 			    "command characters:\n\n";
    113 			*tp++ = "1-9\tMark or unmark the line to be changed.\n";
    114 		}
    115 		*tp++ = "*\tMark or unmark all displayed lines to be "
    116 		    "changed.\n";
    117 		*tp++ = "space\tDisplay next lines.\n";
    118 		*tp++ = "+\tDisplay next lines.\n";
    119 		*tp++ = "-\tDisplay previous lines.\n";
    120 		*tp++ = "a\tMark or unmark all lines to be changed.\n";
    121 		*tp++ = "^D\tChange the marked lines and exit.\n";
    122 		*tp++ = "RETURN\tExit without changing the marked lines.\n";
    123 		*tp++ = "!\tStart an interactive shell (type ^D to return "
    124 		    "to cscope).\n";
    125 		*tp++ = "^L\tRedraw the screen.\n";
    126 		*tp++ = "?\tDisplay this list of commands.\n";
    127 	}
    128 	/* print help, a screen at a time */
    129 	ep = tp;
    130 	line = 0;
    131 	for (tp = text; tp < ep; ) {
    132 		if (line < LINES - 1) {
    133 			for (s = *tp; *s != '\0'; ++s) {
    134 				if (*s == '\n') {
    135 					++line;
    136 				}
    137 			}
    138 			(void) addstr(*tp++);
    139 		} else {
    140 			(void) addstr("\n");
    141 			askforchar();
    142 			(void) clear();
    143 			line = 0;
    144 		}
    145 	}
    146 	if (line) {
    147 		(void) addstr("\n");
    148 		askforchar();
    149 	}
    150 }
    151