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

📄 vi.c

📁 这是一个SIGMA方案的PMP播放器的UCLINUX程序,可播放DVD,VCD,CD MP3...有很好的参考价值.
💻 C
📖 第 1 页 / 共 5 页
字号:
key_cmd_mode:	switch (c) {		//case 0x01:	// soh		//case 0x09:	// ht		//case 0x0b:	// vt		//case 0x0e:	// so		//case 0x0f:	// si		//case 0x10:	// dle		//case 0x11:	// dc1		//case 0x13:	// dc3#ifdef CONFIG_FEATURE_VI_CRASHME	case 0x14:			// dc4  ctrl-T		crashme = (crashme == 0) ? 1 : 0;		break;#endif							/* CONFIG_FEATURE_VI_CRASHME */		//case 0x16:	// syn		//case 0x17:	// etb		//case 0x18:	// can		//case 0x1c:	// fs		//case 0x1d:	// gs		//case 0x1e:	// rs		//case 0x1f:	// us		//case '!':	// !- 		//case '#':	// #- 		//case '&':	// &- 		//case '(':	// (- 		//case ')':	// )- 		//case '*':	// *- 		//case ',':	// ,- 		//case '=':	// =- 		//case '@':	// @- 		//case 'F':	// F- 		//case 'K':	// K- 		//case 'Q':	// Q- 		//case 'S':	// S- 		//case 'T':	// T- 		//case 'V':	// V- 		//case '[':	// [- 		//case '\\':	// \- 		//case ']':	// ]- 		//case '_':	// _- 		//case '`':	// `- 		//case 'g':	// g- 		//case 'u':	// u- FIXME- there is no undo		//case 'v':	// v- 	default:			// unrecognised command		buf[0] = c;		buf[1] = '\0';		if (c <= ' ') {			buf[0] = '^';			buf[1] = c + '@';			buf[2] = '\0';		}		ni((Byte *) buf);		end_cmd_q();	// stop adding to q	case 0x00:			// nul- ignore		break;	case 2:			// ctrl-B  scroll up   full screen	case VI_K_PAGEUP:	// Cursor Key Page Up		dot_scroll(rows - 2, -1);		break;#ifdef CONFIG_FEATURE_VI_USE_SIGNALS	case 0x03:			// ctrl-C   interrupt		longjmp(restart, 1);		break;	case 26:			// ctrl-Z suspend		suspend_sig(SIGTSTP);		break;#endif							/* CONFIG_FEATURE_VI_USE_SIGNALS */	case 4:			// ctrl-D  scroll down half screen		dot_scroll((rows - 2) / 2, 1);		break;	case 5:			// ctrl-E  scroll down one line		dot_scroll(1, 1);		break;	case 6:			// ctrl-F  scroll down full screen	case VI_K_PAGEDOWN:	// Cursor Key Page Down		dot_scroll(rows - 2, 1);		break;	case 7:			// ctrl-G  show current status		edit_status();		break;	case 'h':			// h- move left	case VI_K_LEFT:	// cursor key Left	case 8:			// ctrl-H- move left    (This may be ERASE char)	case 127:			// DEL- move left   (This may be ERASE char)		if (cmdcnt-- > 1) {			do_cmd(c);		}				// repeat cnt		dot_left();		break;	case 10:			// Newline ^J	case 'j':			// j- goto next line, same col	case VI_K_DOWN:	// cursor key Down		if (cmdcnt-- > 1) {			do_cmd(c);		}				// repeat cnt		dot_next();		// go to next B-o-l		dot = move_to_col(dot, ccol + offset);	// try stay in same col		break;	case 12:			// ctrl-L  force redraw whole screen	case 18:			// ctrl-R  force redraw		place_cursor(0, 0, FALSE);	// put cursor in correct place		clear_to_eos();	// tel terminal to erase display		(void) mysleep(10);		screen_erase();	// erase the internal screen buffer		refresh(TRUE);	// this will redraw the entire display		break;	case 13:			// Carriage Return ^M	case '+':			// +- goto next line		if (cmdcnt-- > 1) {			do_cmd(c);		}				// repeat cnt		dot_next();		dot_skip_over_ws();		break;	case 21:			// ctrl-U  scroll up   half screen		dot_scroll((rows - 2) / 2, -1);		break;	case 25:			// ctrl-Y  scroll up one line		dot_scroll(1, -1);		break;	case 27:			// esc		if (cmd_mode == 0)			indicate_error(c);		cmd_mode = 0;	// stop insrting		end_cmd_q();		*status_buffer = '\0';	// clear status buffer		break;	case ' ':			// move right	case 'l':			// move right	case VI_K_RIGHT:	// Cursor Key Right		if (cmdcnt-- > 1) {			do_cmd(c);		}				// repeat cnt		dot_right();		break;#ifdef CONFIG_FEATURE_VI_YANKMARK	case '"':			// "- name a register to use for Delete/Yank		c1 = get_one_char();		c1 = tolower(c1);		if (islower(c1)) {			YDreg = c1 - 'a';		} else {			indicate_error(c);		}		break;	case '\'':			// '- goto a specific mark		c1 = get_one_char();		c1 = tolower(c1);		if (islower(c1)) {			c1 = c1 - 'a';			// get the b-o-l			q = mark[(int) c1];			if (text <= q && q < end) {				dot = q;				dot_begin();	// go to B-o-l				dot_skip_over_ws();			}		} else if (c1 == '\'') {	// goto previous context			dot = swap_context(dot);	// swap current and previous context			dot_begin();	// go to B-o-l			dot_skip_over_ws();		} else {			indicate_error(c);		}		break;	case 'm':			// m- Mark a line		// this is really stupid.  If there are any inserts or deletes		// between text[0] and dot then this mark will not point to the		// correct location! It could be off by many lines!		// Well..., at least its quick and dirty.		c1 = get_one_char();		c1 = tolower(c1);		if (islower(c1)) {			c1 = c1 - 'a';			// remember the line			mark[(int) c1] = dot;		} else {			indicate_error(c);		}		break;	case 'P':			// P- Put register before	case 'p':			// p- put register after		p = reg[YDreg];		if (p == 0) {			psbs("Nothing in register %c", what_reg());			break;		}		// are we putting whole lines or strings		if (strchr((char *) p, '\n') != NULL) {			if (c == 'P') {				dot_begin();	// putting lines- Put above			}			if (c == 'p') {				// are we putting after very last line?				if (end_line(dot) == (end - 1)) {					dot = end;	// force dot to end of text[]				} else {					dot_next();	// next line, then put before				}			}		} else {			if (c == 'p')				dot_right();	// move to right, can move to NL		}		dot = string_insert(dot, p);	// insert the string		end_cmd_q();	// stop adding to q		break;	case 'U':			// U- Undo; replace current line with original version		if (reg[Ureg] != 0) {			p = begin_line(dot);			q = end_line(dot);			p = text_hole_delete(p, q);	// delete cur line			p = string_insert(p, reg[Ureg]);	// insert orig line			dot = p;			dot_skip_over_ws();		}		break;#endif							/* CONFIG_FEATURE_VI_YANKMARK */	case '$':			// $- goto end of line	case VI_K_END:		// Cursor Key End		if (cmdcnt-- > 1) {			do_cmd(c);		}				// repeat cnt		dot = end_line(dot + 1);		break;	case '%':			// %- find matching char of pair () [] {}		for (q = dot; q < end && *q != '\n'; q++) {			if (strchr("()[]{}", *q) != NULL) {				// we found half of a pair				p = find_pair(q, *q);				if (p == NULL) {					indicate_error(c);				} else {					dot = p;				}				break;			}		}		if (*q == '\n')			indicate_error(c);		break;	case 'f':			// f- forward to a user specified char		last_forward_char = get_one_char();	// get the search char		//		// dont seperate these two commands. 'f' depends on ';'		//		//**** fall thru to ... 'i'	case ';':			// ;- look at rest of line for last forward char		if (cmdcnt-- > 1) {			do_cmd(';');		}				// repeat cnt		if (last_forward_char == 0) break;		q = dot + 1;		while (q < end - 1 && *q != '\n' && *q != last_forward_char) {			q++;		}		if (*q == last_forward_char)			dot = q;		break;	case '-':			// -- goto prev line		if (cmdcnt-- > 1) {			do_cmd(c);		}				// repeat cnt		dot_prev();		dot_skip_over_ws();		break;#ifdef CONFIG_FEATURE_VI_DOT_CMD	case '.':			// .- repeat the last modifying command		// Stuff the last_modifying_cmd back into stdin		// and let it be re-executed.		if (last_modifying_cmd != 0) {			ioq = ioq_start = (Byte *) xstrdup((char *) last_modifying_cmd);		}		break;#endif							/* CONFIG_FEATURE_VI_DOT_CMD */#ifdef CONFIG_FEATURE_VI_SEARCH	case '?':			// /- search for a pattern	case '/':			// /- search for a pattern		buf[0] = c;		buf[1] = '\0';		q = get_input_line(buf);	// get input line- use "status line"		if (strlen((char *) q) == 1)			goto dc3;	// if no pat re-use old pat		if (strlen((char *) q) > 1) {	// new pat- save it and find			// there is a new pat			if (last_search_pattern != 0) {				free(last_search_pattern);			}			last_search_pattern = (Byte *) xstrdup((char *) q);			goto dc3;	// now find the pattern		}		// user changed mind and erased the "/"-  do nothing		break;	case 'N':			// N- backward search for last pattern		if (cmdcnt-- > 1) {			do_cmd(c);		}				// repeat cnt		dir = BACK;		// assume BACKWARD search		p = dot - 1;		if (last_search_pattern[0] == '?') {			dir = FORWARD;			p = dot + 1;		}		goto dc4;		// now search for pattern		break;	case 'n':			// n- repeat search for last pattern		// search rest of text[] starting at next char		// if search fails return orignal "p" not the "p+1" address		if (cmdcnt-- > 1) {			do_cmd(c);		}				// repeat cnt	  dc3:		if (last_search_pattern == 0) {			msg = (Byte *) "No previous regular expression";			goto dc2;		}		if (last_search_pattern[0] == '/') {			dir = FORWARD;	// assume FORWARD search			p = dot + 1;		}		if (last_search_pattern[0] == '?') {			dir = BACK;			p = dot - 1;		}	  dc4:		q = char_search(p, last_search_pattern + 1, dir, FULL);		if (q != NULL) {			dot = q;	// good search, update "dot"			msg = (Byte *) "";			goto dc2;		}		// no pattern found between "dot" and "end"- continue at top		p = text;		if (dir == BACK) {			p = end - 1;		}		q = char_search(p, last_search_pattern + 1, dir, FULL);		if (q != NULL) {	// found something			dot = q;	// found new pattern- goto it			msg = (Byte *) "search hit BOTTOM, continuing at TOP";			if (dir == BACK) {				msg = (Byte *) "search hit TOP, continuing at BOTTOM";			}		} else {			msg = (Byte *) "Pattern not found";		}	  dc2:		psbs("%s", msg);		break;	case '{':			// {- move backward paragraph		q = char_search(dot, (Byte *) "\n\n", BACK, FULL);		if (q != NULL) {	// found blank line			dot = next_line(q);	// move to next blank line		}		break;	case '}':			// }- move forward paragraph		q = char_search(dot, (Byte *) "\n\n", FORWARD, FULL);		if (q != NULL) {	// found blank line			dot = next_line(q);	// move to next blank line		}		break;#endif							/* CONFIG_FEATURE_VI_SEARCH */	case '0':			// 0- goto begining of line	case '1':			// 1- 	case '2':			// 2- 	case '3':			// 3- 	case '4':			// 4- 	case '5':			// 5- 	case '6':			// 6- 	case '7':			// 7- 	case '8':			// 8- 	case '9':			// 9- 		if (c == '0' && cmdcnt < 1) {			dot_begin();	// this was a standalone zero		} else {			cmdcnt = cmdcnt * 10 + (c - '0');	// this 0 is part of a number		}		break;	case ':':			// :- the colon mode commands		p = get_input_line((Byte *) ":");	// get input line- use "status line"#ifdef CONFIG_FEATURE_VI_COLON		colon(p);		// execute the command#else							/* CONFIG_FEATURE_VI_COLON */		if (*p == ':')			p++;				// move past the ':'		cnt = strlen((char *) p);		if (cnt <= 0)			break;		if (strncasecmp((char *) p, "quit", cnt) == 0 ||			strncasecmp((char *) p, "q!", cnt) == 0) {	// delete lines			if (file_modified && p[1] != '!') {				psbs("No write since last change (:quit! overrides)");			} else {				editing = 0;			}		} else if (strncasecmp((char *) p, "write", cnt) == 0 ||				   strncasecmp((char *) p, "wq", cnt) == 0) {			cnt = file_write(cfn, text, end - 1);			file_modified = FALSE;			psb("\"%s\" %dL, %dC", cfn, count_lines(text, end - 1), cnt);			if (p[1] == 'q') {				editing = 0;			}		} else if (strncasecmp((char *) p, "file", cnt) == 0 ) {			edit_status();			// show current file status		} else if (sscanf((char *) p, "%d", &j) > 0) {			dot = find_line(j);		// go to line # j			dot_skip_over_ws();		} else {		// unrecognised cmd			ni((Byte *) p);		}

⌨️ 快捷键说明

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