⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 command.c

📁 tvapp用于播放tv程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/*=========================================================================== Copyright (c) 1998-2000, The Santa Cruz Operation  All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. *Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. *Neither name of The Santa Cruz Operation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  =========================================================================*//*	cscope - interactive C symbol or text cross-reference * *	command functions */#include "global.h"#include "build.h"		/* for rebuild() */#include <stdlib.h>#if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)#include <ncurses.h>#else#include <curses.h>#endif#include <ctype.h>static char const rcsid[] = "$Id: command.c,v 1.19 2002/07/28 15:40:07 broeker Exp $";int	selecting;int   curdispline = 0;BOOL	caseless;		/* ignore letter case when searching */BOOL	*change;		/* change this line */BOOL	changing;		/* changing text */char	newpat[PATLEN + 1];	/* new pattern */char	pattern[PATLEN + 1];	/* symbol or text pattern */static	char	appendprompt[] = "Append to file: ";static	char	pipeprompt[] = "Pipe to shell command: ";static	char	readprompt[] = "Read from file: ";static	char	toprompt[] = "To: ";/* Internal prototypes: */static	BOOL	changestring(void);static	void	clearprompt(void);static	void	mark(int i);static	void	scrollbar(MOUSE *p);static	void	countrefs(void);/* execute the command */BOOLcommand(int commandc){	char	filename[PATHLEN + 1];	/* file path name */	MOUSE *p;			/* mouse data */	int	c, i;	FILE	*file;	struct	cmd	 *curritem, *item;	/* command history */	char	*s;	switch (commandc) {	case ctrl('C'):	/* toggle caseless mode */		if (caseless == NO) {			caseless = YES;			postmsg2("Caseless mode is now ON");		}		else {			caseless = NO;			postmsg2("Caseless mode is now OFF");		}		egrepcaseless(caseless);	/* turn on/off -i flag */		return(NO);	case ctrl('R'):	/* rebuild the cross reference */		if (isuptodate == YES) {			postmsg("The -d option prevents rebuilding the symbol database");			return(NO);		}		exitcurses();		freefilelist();		/* remake the source file list */		makefilelist();		rebuild();		if (errorsfound == YES) {			errorsfound = NO;			askforreturn();		}				entercurses();		postmsg("");		/* clear any previous message */		totallines = 0;		disprefs = 0;			topline = nextline = 1;		selecting = 0;		break;#if UNIXPC	case ESC:	/* possible unixpc mouse selection */#endif	case ctrl('X'):	/* mouse selection */		if ((p = getmouseaction(DUMMYCHAR)) == NULL) {			return(NO);	/* unknown control sequence */		}		/* if the button number is a scrollbar tag */		if (p->button == '0') {			scrollbar(p);			break;		} 		/* ignore a sweep */		if (p->x2 >= 0) {			return(NO);		}		/* if this is a line selection */		if (p->y1 < FLDLINE) {			/* find the selected line */			/* note: the selection is forced into range */			for (i = disprefs - 1; i > 0; --i) {				if (p->y1 >= displine[i]) {					break;				}			}			/* display it in the file with the editor */			editref(i);		}		else {	/* this is an input field selection */			field = p->y1 - FLDLINE;			/* force it into range */			if (field >= FIELDS) {				field = FIELDS - 1;			}			setfield();			resetcmd();			return(NO);		}		break;	case '\t':	/* go to next input field */		if (disprefs)		{			selecting = !selecting;			if (selecting)			{				move(displine[curdispline], 0);				refresh();			}			else			{				atfield();				resetcmd();			}		}		return(NO);#if TERMINFO	case KEY_ENTER:#endif	case '\r':	case '\n':	/* go to reference */		if (selecting)		{			editref(curdispline);			return(YES);		}		/* FALLTHROUGH */	case ctrl('N'):#if TERMINFO	case KEY_DOWN:	case KEY_RIGHT:#endif		if (selecting)		{			if ((curdispline + 1) < disprefs)			{				move(displine[++curdispline], 0);				refresh();			}		}		else		{			field = (field + 1) % FIELDS;			setfield();			atfield();			resetcmd();		}		return(NO);	case ctrl('P'):	/* go to previous input field */#if TERMINFO	case KEY_UP:	case KEY_LEFT:#endif		if (selecting)		{			if (curdispline)			{				move(displine[--curdispline], 0);				refresh();			}		}		else		{			field = (field + (FIELDS - 1)) % FIELDS;			setfield();			atfield();			resetcmd();		}		return(NO);#if TERMINFO	case KEY_HOME:	/* go to first input field */		if (selecting)		{			curdispline = 0;			move(REFLINE, 0);			refresh();		}		else		{			field = 0;			setfield();			atfield();			resetcmd();		}		return(NO);	case KEY_LL:	/* go to last input field */		if (selecting)		{			move(displine[disprefs - 1], 0);			refresh();		}		else		{			field = FIELDS - 1;			setfield();			atfield();			resetcmd();		}		return(NO);#endif	case ' ':	/* display next page */	case '+':	case ctrl('V'):#if TERMINFO	case KEY_NPAGE:#endif		/* don't redisplay if there are no lines */		if (totallines == 0) {			return(NO);		}		/* note: seekline() is not used to move to the next 		 * page because display() leaves the file pointer at		 * the next page to optimize paging forward		 */		curdispline = 0;		break;	case ctrl('H'):	case '-':	/* display previous page */#if TERMINFO	case KEY_PPAGE:#endif		/* don't redisplay if there are no lines */		if (totallines == 0) {			return(NO);		}		curdispline = 0;		/* if there are only two pages, just go to the other one */		if (totallines <= 2 * mdisprefs) {			break;		}		/* if on first page but not at beginning, go to beginning */		nextline -= mdisprefs;	/* already at next page */		if (nextline > 1 && nextline <= mdisprefs) {			nextline = 1;		}		else {			nextline -= mdisprefs;			if (nextline < 1) {				nextline = totallines - mdisprefs + 1;				if (nextline < 1) {					nextline = 1;				}			}		}		seekline(nextline);		break;	case '>':	/* write or append the lines to a file */		if (totallines == 0) {			postmsg("There are no lines to write to a file");		}		else {	/* get the file name */			(void) move(PRLINE, 0);			(void) addstr("Write to file: ");			s = "w";			if ((c = mygetch()) == '>') {				(void) move(PRLINE, 0);				(void) addstr(appendprompt);				c = '\0';				s = "a";			}			if (c != '\r' &&			    getline(newpat, COLS - sizeof(appendprompt), c,			    NO) > 0) {				shellpath(filename, sizeof(filename), newpat);				if ((file = myfopen(filename, s)) == NULL) {					cannotopen(filename);				}				else {					seekline(1);					while ((c = getc(refsfound)) != EOF) {						(void) putc(c, file);					}					seekline(topline);					(void) fclose(file);				}			}			clearprompt();		}		return(NO);	/* return to the previous field */	case '<':	/* read lines from a file */		(void) move(PRLINE, 0);		(void) addstr(readprompt);		if (getline(newpat, COLS - sizeof(readprompt), '\0',		    NO) > 0) {			clearprompt();			shellpath(filename, sizeof(filename), newpat);			if (readrefs(filename) == NO) {				postmsg2("Ignoring an empty file");				return(NO);			}			return(YES);		}		clearprompt();		return(NO);	case '^':	/* pipe the lines through a shell command */	case '|':	/* pipe the lines to a shell command */		if (totallines == 0) {			postmsg("There are no lines to pipe to a shell command");			return(NO);		}		/* get the shell command */		(void) move(PRLINE, 0);		(void) addstr(pipeprompt);		if (getline(newpat, COLS - sizeof(pipeprompt), '\0', NO) == 0) {			clearprompt();			return(NO);		}		/* if the ^ command, redirect output to a temp file */		if (commandc == '^') {			(void) strcat(strcat(newpat, " >"), temp2);			/* HBB 20020708: somebody might have even			 * their non-interactive default shells			 * complain about clobbering			 * redirections... --> delete before			 * overwriting */			remove(temp2);		}		exitcurses();		if ((file = mypopen(newpat, "w")) == NULL) {			(void) fprintf(stderr, "cscope: cannot open pipe to shell command: %s\n", newpat);		}		else {			seekline(1);			while ((c = getc(refsfound)) != EOF) {				(void) putc(c, file);			}			seekline(topline);			(void) mypclose(file);		}		if (commandc == '^') {			if (readrefs(temp2) == NO) {				postmsg("Ignoring empty output of ^ command");			}		}		askforreturn();		entercurses();		break;	case ctrl('L'):	/* redraw screen */#if TERMINFO	case KEY_CLEAR:#endif                (void) clearmsg2();		(void) clearok(curscr, TRUE);		(void) wrefresh(curscr);		drawscrollbar(topline, bottomline);		return(NO);	case '!':	/* shell escape */		(void) execute(shell, shell, NULL);		seekline(topline);		break;	case '?':	/* help */		(void) clear();		help();		(void) clear();		seekline(topline);		break;	case ctrl('E'):	/* edit all lines */		editall();		break;	case ctrl('Y'):	/* repeat last pattern */		if (*pattern != '\0') {			(void) addstr(pattern);			goto repeat;		}		break;	case ctrl('B'):		/* cmd history back */	case ctrl('F'):		/* cmd history fwd */		if (selecting)			return(NO);		curritem = currentcmd();		item = (commandc == ctrl('F')) ? nextcmd() : prevcmd();		clearmsg2();		if (curritem == item) {	/* inform user that we're at history end */			postmsg2("End of input field and search pattern history");		}		if (item) {			field = item->field;			setfield();			atfield();			(void) addstr(item->text);			(void) strcpy(pattern, item->text);			switch (c = mygetch()) {			case '\r':			case '\n':

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -