xref: /illumos-gate/usr/src/tools/cscope-fast/help.c (revision bbf215553c7233fbab8a0afdf1fac74c44781867)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
237c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
277c478bd9Sstevel@tonic-gate  * Copyright (c) 1999 by Sun Microsystems, Inc.
287c478bd9Sstevel@tonic-gate  * All rights reserved.
297c478bd9Sstevel@tonic-gate  */
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  *	cscope - interactive C symbol cross-reference
337c478bd9Sstevel@tonic-gate  *
347c478bd9Sstevel@tonic-gate  *	display help
357c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include "global.h"
387c478bd9Sstevel@tonic-gate #include <curses.h>	/* LINES */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #define	MAXHELP	50	/* maximum number of help strings */
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate void
help(void)437c478bd9Sstevel@tonic-gate help(void)
447c478bd9Sstevel@tonic-gate {
457c478bd9Sstevel@tonic-gate 	char	**ep, *s, **tp, *text[MAXHELP];
467c478bd9Sstevel@tonic-gate 	int	line;
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate 	tp = text;
497c478bd9Sstevel@tonic-gate 	if (changing == NO) {
507c478bd9Sstevel@tonic-gate 		if (mouse) {
517c478bd9Sstevel@tonic-gate 			*tp++ = "Point with the mouse and click button 1 to "
527c478bd9Sstevel@tonic-gate 			    "move to the desired input field,\n";
537c478bd9Sstevel@tonic-gate 			*tp++ = "type the pattern to search for, and then "
547c478bd9Sstevel@tonic-gate 			    "press the RETURN key.  For the first 5\n";
557c478bd9Sstevel@tonic-gate 			*tp++ = "and last 2 input fields, the pattern can be "
56*bbf21555SRichard Lowe 			    "a regcmp(3C) regular expression.\n";
577c478bd9Sstevel@tonic-gate 			*tp++ = "If the search is successful, you can edit "
587c478bd9Sstevel@tonic-gate 			    "the file containing a displayed line\n";
597c478bd9Sstevel@tonic-gate 			*tp++ = "by pointing with the mouse and clicking "
607c478bd9Sstevel@tonic-gate 			    "button 1.\n";
617c478bd9Sstevel@tonic-gate 			*tp++ = "\nYou can either use the button 2 menu or "
627c478bd9Sstevel@tonic-gate 			    "these command characters:\n\n";
637c478bd9Sstevel@tonic-gate 		} else {
647c478bd9Sstevel@tonic-gate 			*tp++ = "Press the TAB key repeatedly to move to the "
657c478bd9Sstevel@tonic-gate 			    "desired input field, type the\n";
667c478bd9Sstevel@tonic-gate 			*tp++ = "pattern to search for, and then press the "
677c478bd9Sstevel@tonic-gate 			    "RETURN key.  For the first 4 and\n";
687c478bd9Sstevel@tonic-gate 			*tp++ = "last 2 input fields, the pattern can be a "
69*bbf21555SRichard Lowe 			    "regcmp(3C) regular expression.\n";
707c478bd9Sstevel@tonic-gate 			*tp++ = "If the search is successful, you can use "
717c478bd9Sstevel@tonic-gate 			    "these command characters:\n\n";
727c478bd9Sstevel@tonic-gate 			*tp++ = "1-9\tEdit the file containing the displayed "
737c478bd9Sstevel@tonic-gate 			    "line.\n";
747c478bd9Sstevel@tonic-gate 		}
757c478bd9Sstevel@tonic-gate 		*tp++ = "space\tDisplay next lines.\n";
767c478bd9Sstevel@tonic-gate 		*tp++ = "+\tDisplay next lines.\n";
777c478bd9Sstevel@tonic-gate 		*tp++ = "-\tDisplay previous lines.\n";
787c478bd9Sstevel@tonic-gate 		*tp++ = "^E\tEdit all lines.\n";
797c478bd9Sstevel@tonic-gate 		*tp++ = ">\tWrite all lines to a file.\n";
807c478bd9Sstevel@tonic-gate 		*tp++ = ">>\tAppend all lines to a file.\n";
817c478bd9Sstevel@tonic-gate 		*tp++ = "<\tRead lines from a file.\n";
827c478bd9Sstevel@tonic-gate 		*tp++ = "^\tFilter all lines through a shell command.\n";
837c478bd9Sstevel@tonic-gate 		*tp++ = "|\tPipe all lines to a shell command.\n";
847c478bd9Sstevel@tonic-gate 		*tp++ = "\nAt any time you can use these command "
857c478bd9Sstevel@tonic-gate 		    "characters:\n\n";
867c478bd9Sstevel@tonic-gate 		if (!mouse) {
877c478bd9Sstevel@tonic-gate 			*tp++ = "^P\tMove to the previous input field.\n";
887c478bd9Sstevel@tonic-gate 		}
897c478bd9Sstevel@tonic-gate 		*tp++ = "^A\tSearch again with the last pattern typed.\n";
907c478bd9Sstevel@tonic-gate 		*tp++ = "^B\tRecall previous input field and search pattern.\n";
917c478bd9Sstevel@tonic-gate 		*tp++ = "^F\tRecall next input field and search pattern.\n";
927c478bd9Sstevel@tonic-gate 		*tp++ = "^C\tToggle ignore/use letter case when searching.\n";
937c478bd9Sstevel@tonic-gate 		*tp++ = "^R\tRebuild the symbol database.\n";
947c478bd9Sstevel@tonic-gate 		*tp++ = "!\tStart an interactive shell (type ^D to return "
957c478bd9Sstevel@tonic-gate 		    "to cscope).\n";
967c478bd9Sstevel@tonic-gate 		*tp++ = "^L\tRedraw the screen.\n";
977c478bd9Sstevel@tonic-gate 		*tp++ = "?\tDisplay this list of commands.\n";
987c478bd9Sstevel@tonic-gate 		*tp++ = "^D\tExit cscope.\n";
997c478bd9Sstevel@tonic-gate 		*tp++ = "\nNote: If the first character of the pattern you "
1007c478bd9Sstevel@tonic-gate 		    "want to search for matches\n";
1017c478bd9Sstevel@tonic-gate 		*tp++ = "a command, type a \\ character first.\n";
1027c478bd9Sstevel@tonic-gate 	} else {
1037c478bd9Sstevel@tonic-gate 		if (mouse) {
1047c478bd9Sstevel@tonic-gate 			*tp++ = "Point with the mouse and click button 1 "
1057c478bd9Sstevel@tonic-gate 			    "to mark or unmark the line to be\n";
1067c478bd9Sstevel@tonic-gate 			*tp++ = "changed.  You can also use the button 2 "
1077c478bd9Sstevel@tonic-gate 			    "menu or these command characters:\n\n";
1087c478bd9Sstevel@tonic-gate 		} else {
1097c478bd9Sstevel@tonic-gate 			*tp++ = "When changing text, you can use these "
1107c478bd9Sstevel@tonic-gate 			    "command characters:\n\n";
1117c478bd9Sstevel@tonic-gate 			*tp++ = "1-9\tMark or unmark the line to be changed.\n";
1127c478bd9Sstevel@tonic-gate 		}
1137c478bd9Sstevel@tonic-gate 		*tp++ = "*\tMark or unmark all displayed lines to be "
1147c478bd9Sstevel@tonic-gate 		    "changed.\n";
1157c478bd9Sstevel@tonic-gate 		*tp++ = "space\tDisplay next lines.\n";
1167c478bd9Sstevel@tonic-gate 		*tp++ = "+\tDisplay next lines.\n";
1177c478bd9Sstevel@tonic-gate 		*tp++ = "-\tDisplay previous lines.\n";
1187c478bd9Sstevel@tonic-gate 		*tp++ = "a\tMark or unmark all lines to be changed.\n";
1197c478bd9Sstevel@tonic-gate 		*tp++ = "^D\tChange the marked lines and exit.\n";
1207c478bd9Sstevel@tonic-gate 		*tp++ = "RETURN\tExit without changing the marked lines.\n";
1217c478bd9Sstevel@tonic-gate 		*tp++ = "!\tStart an interactive shell (type ^D to return "
1227c478bd9Sstevel@tonic-gate 		    "to cscope).\n";
1237c478bd9Sstevel@tonic-gate 		*tp++ = "^L\tRedraw the screen.\n";
1247c478bd9Sstevel@tonic-gate 		*tp++ = "?\tDisplay this list of commands.\n";
1257c478bd9Sstevel@tonic-gate 	}
1267c478bd9Sstevel@tonic-gate 	/* print help, a screen at a time */
1277c478bd9Sstevel@tonic-gate 	ep = tp;
1287c478bd9Sstevel@tonic-gate 	line = 0;
1297c478bd9Sstevel@tonic-gate 	for (tp = text; tp < ep; ) {
1307c478bd9Sstevel@tonic-gate 		if (line < LINES - 1) {
1317c478bd9Sstevel@tonic-gate 			for (s = *tp; *s != '\0'; ++s) {
1327c478bd9Sstevel@tonic-gate 				if (*s == '\n') {
1337c478bd9Sstevel@tonic-gate 					++line;
1347c478bd9Sstevel@tonic-gate 				}
1357c478bd9Sstevel@tonic-gate 			}
1367c478bd9Sstevel@tonic-gate 			(void) addstr(*tp++);
1377c478bd9Sstevel@tonic-gate 		} else {
1387c478bd9Sstevel@tonic-gate 			(void) addstr("\n");
1397c478bd9Sstevel@tonic-gate 			askforchar();
1407c478bd9Sstevel@tonic-gate 			(void) clear();
1417c478bd9Sstevel@tonic-gate 			line = 0;
1427c478bd9Sstevel@tonic-gate 		}
1437c478bd9Sstevel@tonic-gate 	}
1447c478bd9Sstevel@tonic-gate 	if (line) {
1457c478bd9Sstevel@tonic-gate 		(void) addstr("\n");
1467c478bd9Sstevel@tonic-gate 		askforchar();
1477c478bd9Sstevel@tonic-gate 	}
1487c478bd9Sstevel@tonic-gate }
149