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

📄 minicom.c

📁 minicom2.0源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
	   * Take care of the search key: Caseless	   */	  case '\\':	  case 'S':	    case_matters=0; /* case-importance, ie. none :-) */	  /* 	   * fmg 8/22/97	   * Take care of the search key: Exact Match	   */	  case '/':	  case 's':  		if (!us->histlines)		{ wbell(); werror(_("History buffer Disabled!")); break; }  		if (!us->histline)		{ wbell(); werror(_("History buffer empty!")); break; }		if (citemode) break;				/* we need this for the case-importance-toggle to work.. */		if (c == '/' || c == 's')			case_matters=1; /* case-importance, ie. DOES */		/* open up new search window... */		searchhist(us, b_us, 0, look_for);		/* must redraw status line... */  		wlocate(b_st, 0, 0); /* move back to column 0! */  		wprintf(b_st, hline); /* and show the above-defined hline */  		wredraw(b_st, 1); /* again... */		/* highlight any matches */  		if (strlen(look_for)>1)		{  			hit = find_next(us, b_us, y, look_for, case_matters);			if (hit == -1) { wbell(); wflush(); hit=0; break; }  			drawhist_look(b_us, hit, 1, look_for, case_matters);  			y = hit;		}  		else		{ wbell(); break; }  		wflush();		break;	  /* 	   * fmg 8/22/97	   * Take care of the Next Hit key...	   * Popup an error window if no previous... why not start a new	   * search? How do we know which case-importance they wanted?	   */	  case 'n':	  case 'N':		/* highlight NEXT match */		if (citemode) break;  		if (strlen(look_for)>1)		{		  hit = find_next(us, b_us, y, look_for, case_matters);		  if (hit == -1) { wbell(); wflush(); hit=0; break; }		  drawhist_look(b_us, hit, 1, look_for, case_matters);		  y = hit;		}		else	/* no search pattern... */		  {		    wbell();		    werror(_("No previous search!\n  Please 's' or 'S' first!"));		}		wflush();		break;#endif /*_SEARCH_HISTORY*/	  case 'u':	  case 'U':	  case K_UP:		if (citemode && cite_y) {			cite_y--;			if (cite_ystart != 1000000) {			  cite_yend = y + cite_y;			  drawcite(b_us, cite_y+1, y, cite_ystart, cite_yend);			  drawcite(b_us, cite_y, y, cite_ystart, cite_yend);			}			wlocate(b_us, 0, cite_y);			break;		}		if (y <= 0) break;		y--; if (cite_ystart != 1000000) cite_yend = y + cite_y;		wscroll(b_us, S_DOWN);#if _SEARCH_HISTORY		/*		 * fmg 8/20/97		 * This is needed so that the movement in window will HIGHLIGHT		 * the lines that have the pattern we wanted... it's just nice.		 * This almost beggs for a function :-)		 */		if (citemode) {			inverse =			  (y+cite_y >= cite_ystart && y+cite_y <= cite_yend);		} else {        		tmp_e = getline(b_us, y);			if (strlen(look_for) > 1)			{			  /* quick scan for pattern match */			  wdrawelm_var(b_us, 0, tmp_e, tmp_line);			  inverse = (strlen(tmp_line)>1 &&			    StrStr(tmp_line, look_for, case_matters));			}        		else				inverse = 0;		}#else		if (citemode) {			inverse =			  (y+cite_y >= cite_ystart && y+cite_y <= cite_yend);		} else {			inverse = 0;		}#endif /*_SEARCH_HISTORY*/		if (inverse) wdrawelm_inverse(b_us, 0, getline(b_us, y));		else wdrawelm(b_us, 0, getline(b_us, y));		if (citemode) wlocate(b_us, 0, cite_y);		wflush();		break;	  case 'd':	  case 'D':	  case K_DN:		if (citemode && cite_y < b_us->ys-1) {			cite_y++;			if (cite_ystart != 1000000) {			  cite_yend = y + cite_y;			  drawcite(b_us, cite_y-1, y, cite_ystart, cite_yend);			  drawcite(b_us, cite_y, y, cite_ystart, cite_yend);			}			wlocate(b_us, 0, cite_y);			break;		}					if (y >= us->histlines) break;		y++; if (cite_ystart != 1000000) cite_yend = y + cite_y;		wscroll(b_us, S_UP);#if _SEARCH_HISTORY		/*		 * fmg 8/20/97		 * This is needed so that the movement in window will HIGHLIGHT		 * the lines that have the pattern we wanted... it's just nice.		 * This almost beggs for a function :-)		 */		if (citemode) {			inverse =			  (y+cite_y >= cite_ystart && y+cite_y <= cite_yend);		} else {        		tmp_e = getline(b_us, y + b_us->ys - 1);			if (strlen(look_for) > 1)			{				/* quick scan for pattern match */        			wdrawelm_var(b_us, 0, tmp_e, tmp_line);				inverse = (strlen(tmp_line)>1 &&				  StrStr(tmp_line, look_for, case_matters));			}        		else				inverse = 0;		}#else		if (citemode) {			inverse =			  (y+cite_y >= cite_ystart && y+cite_y <= cite_yend);		} else {			inverse = 0;		}#endif /*_SEARCH_HISTORY*/		if (inverse)			wdrawelm_inverse(b_us, b_us->ys - 1, 			  getline(b_us, y + b_us->ys - 1));		else			wdrawelm(b_us, b_us->ys - 1, 			  getline(b_us, y + b_us->ys - 1));		if (citemode) wlocate(b_us, 0, cite_y);		wflush();		break;	  case 'b':	  case 'B':	  case K_PGUP:		if (y <= 0) break;		y -= b_us->ys;		if (y < 0) y = 0;		if (cite_ystart != 1000000) cite_yend = y + cite_y;#if _SEARCH_HISTORY		/*		 * fmg 8/20/97		 * This is needed so that the movement in window will HIGHLIGHT		 * the lines that have the pattern we wanted... it's just nice.		 * Highlight any matches		 */  		if (strlen(look_for)>1 && us->histline)			drawhist_look(b_us, y, 1, look_for, case_matters);  		else			drawhist(b_us, y, 1);#else			drawhist(b_us, y, 1);#endif /*_SEARCH_HISTORY*/		if (citemode) wlocate(b_us, 0, cite_y);		break;	  case 'f':	  case 'F':	  case ' ': /* filipg: space bar will go page-down... pager-like */	  case K_PGDN:		if (y >= us->histlines) break;		y += b_us->ys;		if (y > us->histlines) y=us->histlines;		if (cite_ystart != 1000000) cite_yend = y + cite_y;#if _SEARCH_HISTORY		/*		 * fmg 8/20/97		 * This is needed so that the movement in window will HIGHLIGHT		 * the lines that have the pattern we wanted... it's just nice.		 * Highlight any matches		 */  		if (strlen(look_for)>1 && us->histline)			drawhist_look(b_us, y, 1, look_for, case_matters);  		else			drawhist(b_us, y, 1);#else		drawhist(b_us, y, 1);#endif /*_SEARCH_HISTORY*/		if (citemode) wlocate(b_us, 0, cite_y);		break;	  case 'C': case 'c': /* start citation mode */		if (citemode ^= 1) {			cite_y = 0;			cite_ystart = 1000000;			cite_yend = -1;			strcpy(hline1, _("  CITATION: ENTER=select start line ESC=exit                               "));			if (b_st->xs < 127) hline1[b_st->xs]=0;			hline = hline1;		} else {			hline = hline0;		}		wlocate(b_st, 0, 0);		wprintf(b_st, hline);		wredraw(b_st, 1);		if (citemode) wlocate(b_us, 0, cite_y);		break;	  case 10: case 13:		if (!citemode) break;		if (cite_ystart == 1000000) {			cite_yend = cite_ystart = y + cite_y;			strcpy(hline1, _("  CITATION: ENTER=select end line ESC=exit                                 "));			if (b_st->xs < 127) hline1[b_st->xs]=0;		} else {			if (cite_ystart > cite_yend) break;			drawcite_whole(b_us, y, 1000000, -1);			loop = 0;			break;		}		wlocate(b_st, 0, 0);		wprintf(b_st, hline);		wredraw(b_st, 1);		wdrawelm_inverse(b_us, cite_y, getline(b_us, cite_ystart));		wlocate(b_us, 0, cite_y);		break;	  case K_ESC:		if (!citemode) {loop = 0; break;}		if (cite_ystart == 1000000) {			citemode = 0;			hline = hline0;		} else {			cite_ystart = 1000000;			strcpy(hline1, _("  CITATION: ENTER=select start line ESC=exit                               "));		}		drawcite_whole(b_us, y, cite_ystart, cite_yend);		wlocate(b_st, 0, 0);		wprintf(b_st, hline);		wredraw(b_st, 1);		if (citemode) wlocate(b_us, 0, cite_y);		break;	}  }  /* Cleanup. */  if (citemode) do_cite(b_us, cite_ystart, cite_yend);  wclose(b_us, y == us->histlines ? 0 : 1);  wclose(b_st, 1);  wlocate(us, us->curx, us->cury);  wflush();  wredraw(us, 1);}#endif /*HOSTORY*/#ifdef SIGWINCH/* The window size has changed. Re-initialize. */static void change_size(sig)int sig;{  (void)sig;  size_changed = 1;  signal(SIGWINCH, change_size);}#endif /*SIGWINCH*//* * Read a word from strings 's' and advance pointer. */static char *getword(s)char **s;{  char *begin;  /* Skip space */  while(**s == ' ' || **s == '\t') (*s)++;  /* End of line? */  if (**s == '\0' || **s == '\n') return((char *)0);    begin = *s;  /* Skip word */  while(**s != ' ' && **s != '\t' && **s != '\n' && **s) (*s)++;  /* End word with '\0' */  if (**s) {  	**s = 0;  	(*s)++;  }  return(begin);}static void usage(env_args, optind, mc)int env_args, optind;char *mc;{  if (env_args >= optind && mc)	 fprintf(stderr, _("Wrong option in environment MINICOM=\"%s\"\n"), mc);  fprintf(stderr, _("Type \"minicom %s\" for help.\n"), "--help");  exit(1);}/* Give some help information */static void helpthem(){  char *mc = getenv("MINICOM");  printf(_("Usage: %s [OPTION]... [configuration]\n"), PACKAGE);  printf(_("A terminal program for Linux and other unix-like systems.\n\n"));  printf(_("  -s, --setup            : enter setup mode (only as root)\n"));  printf(_("  -o, --noinit           : do not initialize modem & lockfiles at startup\n"));  printf(_("  -m, --metakey          : use meta or alt key for commands\n"));  printf(_("  -M, --metakey8         : use 8bit meta key for commands\n"));  printf(_("  -l, --ansi             : literal; assume screen uses the IBM-PC character set\n"));  printf(_("  -L, --iso              : Ditto, but assume screen uses ISO8859\n"));   printf(_("  -w, --wrap             : Linewrap on\n"));  printf(_("  -z, --statline         : try to use terminal's status line\n"));  printf(_("  -8, --8bit             : 8bit clean mode (for Japanese, etc)\n"));  printf(_("  -c, --color=on/off     : ANSI style color usage on or off\n"));  printf(_("  -a, --attrib=on/off    : use reverse or highlight attributes on or off\n"));  printf(_("  -t, --term=TERM        : override TERM environment variable\n"));  printf(_("  -S, --script=SCRIPT    : run SCRIPT at startup\n"));  printf(_("  -d, --dial=ENTRY       : dial ENTRY from the dialing directory\n"));  printf(_("  -p, --ptty=TTYP        : connect to pseudo terminal\n"));  printf(_("  -C, --capturefile=FILE : start capturing to FILE\n"));  printf(_("  -v, --version          : output version information and exit\n"));  printf(_("  configuration          : configuration file to use\n\n"));  printf(_("These options can also be specified in the MINICOM environment variable.\n"));  printf(_("This variable is currently %s\"%s\".\n"), mc ? _("set to ") : _("unset"),	mc ? mc : "");  printf(_("The LIBDIR to find the configuration files and the access file\n"));  printf(_("minicom.users is compiled as %s.\n\n"), LIBDIR);  printf(_("Report bugs to <minicom-devel@bazar.conectiva.com.br>.\n"));}int main(argc, argv)int argc;char **argv;{  int c;			/* Command character */  int quit = 0;			/* 'q' or 'x' pressed */  char *s, *bufp;		/* Scratch pointers */  int dosetup = 0, doinit = 1;	/* -o and -s options */  char buf[80];			/* Keyboard input buffer */  char capname[128];		/* Name of capture file */  struct passwd *pwd;		/* To look up user name */  int userok = 0;		/* Scratch variables */  FILE *fp;			/* Scratch file pointer */  char userfile[256];		/* Locate user file */  char *use_port;		/* Name of initialization file */  char *args[20];		/* New argv pointer */  int argk = 1;			/* New argc */  extern int getopt(), optind;  extern char *optarg;		/* From getopt (3) package */  extern int use_status;	/* Use status line. */  char *mc;			/* For 'MINICOM' env. variable */  int env_args;			/* Number of args in env. variable */  char *cmd_dial;		/* Entry from the command line. */  int alt_code = 0;		/* Type of alt key */  char pseudo[64];/*  char* console_encoding = getenv ("LC_CTYPE"); */  static struct option long_options[] =  {	  { "setup", no_argument, NULL, 's' },	  { "help", no_argument, NULL, 'h' },	  { "ptty", required_argument, NULL, 'p' },	  { "metakey", no_argument, NULL, 'm' },	  { "metakey8", no_argument, NULL, 'M' },	  { "ansi", no_argument, NULL, 'l' },	  { "iso", no_argument, NULL, 'L' },	  { "term", required_argument, NULL, 't' },	  { "noinit", no_argument, NULL, 'o' },	  { "color", required_argument, NULL, 'c' },	  { "attrib", required_argument, NULL, 'a' },	  { "dial", required_argument, NULL, 'd' },	  { "statline", no_argument, NULL, 'z' },	  { "capturefile", required_argument, NULL, 'C' },	  { "script", required_argument, NULL, 'S' },	  { "8bit", no_argument, NULL, '8' },	  { "version", no_argument, NULL, 'v' },	  { "wrap", no_argument, NULL, 'w' },	  { NULL, 0, NULL, 0 }  };  /* initialize locale support */  setlocale(LC_ALL, "");  bindtextdomain(PACKAGE, LOCALEDIR);  textdomain(PACKAGE);  /* Initialize global variables */  portfd = -1;  capfp = (FILE *)NULL;  docap = 0;  online = -1;  linespd = 0;  stdattr = XA_NORMAL;  us = NIL_WIN;  addlf = 0;  wrapln = 0;#ifdef HAVE_SELECT  local_echo = 0;#endif /*SELECT*/  strcpy(capname, "minicom.cap");  lockfile[0] = 0;  tempst = 0;  st = NIL_WIN;  us = NIL_WIN;  bogus_dcd = 0;  usecolor = 0;  screen_ibmpc = 0;  screen_iso = 0;  useattr = 1;  strncpy(termtype, getenv("TERM") ? getenv("TERM") : "dumb", sizeof(termtype));  stdattr = XA_NORMAL;  use_port = "dfl";  alt_override = 0;  scr_name[0] = 0;  scr_user[0] = 0;  scr_passwd[0] = 0;  dial_name = (char *)NULL;  dial_number = (char *)NULL;  dial_user = (char *)NULL;  dial_pass = (char *)NULL;  size_changed = 0;  escape = 1;  cmd_dial = NULL;  real_uid = getuid();  real_gid = getgid();  eff_uid  = geteuid();  eff_gid  = getegid();/* fmg 1/11/94 colors (set defaults) *//* MARK updated 02/17/95 to be more similiar to TELIX */  mfcolor = YELLOW;  mbcolor = BLUE;  tfcolor = WHITE;  tbcolor = BLACK;  sfcolor = WHITE;  sbcolor = RED;  st_attr = XA_NORMAL;  /* acme@conectiva.com.br 28/02/1998 */  /*  if (console_encoding != NULL)    if (strncmp (console_encoding, "ISO-8859", 8) == 0)    screen_iso++; *//* kubota@debian.or.jp 12/07/1998 */  {	char *lang = getenv("LANG");	if (lang!=NULL && (!strncmp(lang,"ja",2) || !strncmp(lang,"ko",2))) {		args[argk++] = "-8";	}  }/* MARK updated 02/17/95 default history buffer size */  num_hist_lines = 256;/* fmg - but we reset these to F=WHITE, B=BLACK if -b flag found */  /* Before processing the options, first add options   * from the environment variable 'MINICOM'.   */  args[0] = "minicom";  if ((mc = getenv("MINICOM")) != CNULL) { 	strncpy(buf, mc, 80); 	bufp = buf; 	buf[79] = 0; 	while(isspace(*bufp)) bufp++; 	while(*bufp && argk < 19) { 		for(s = bufp; !isspace(*bufp) && *bufp; bufp++) 			; 		args[argk++] = s; 		while(isspace(*bufp)) *bufp++ = 0; 	}

⌨️ 快捷键说明

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