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

📄 bind.vtc

📁 Unix下的MUD客户端程序
💻 VTC
字号:
// bind.vtc: key bindings and keyboard history// Editing keysbind(ctrl("^[[A") , K_CUP     );bind(ctrl("^[[B") , K_CDOWN   );bind(ctrl("^B")	  , K_CLEFT   );bind(ctrl("^[[D") , K_CLEFT   );bind(ctrl("^F")	  , K_CRIGHT  );bind(ctrl("^[[C") , K_CRIGHT  );bind(ctrl("^A")	  , K_CHOME   );bind(ctrl("^[[H") , K_CHOME   );bind(ctrl("^E")	  , K_CEND    );bind(ctrl("^[[K") , K_CEND    );bind(ctrl("^[B")  , K_CWLEFT  );bind(ctrl("^[F")  , K_CWRIGHT );bind("\b"	  , K_BSPC    );bind(ctrl("^?")	  , K_BSPC    );bind(ctrl("^W")	  , K_BWORD   );bind(ctrl("^[^?") , K_BWORD   );bind(ctrl("^[K")  , K_BHOME   );bind(ctrl("^U")	  , K_DBUF    );bind(ctrl("^D")	  , K_DCH     );bind(ctrl("^[W")  , K_DWORD   );bind(ctrl("^K")	  , K_DEND    );bind(ctrl("^R")	  , K_REFRESH );bind(ctrl("^L")	  , .redraw_hook);bind(ctrl("^[^[") , K_MODE    );bind("\t"	  , .reset_pager);bind(ctrl("^[Q")  , .discard_pager_buffer);// Window switchingfunc prev_win() { active = prev(active) ? : tail(T_WIN); reset_prompt(); }func next_win() { active = next(active) ? : head(T_WIN); reset_prompt(); }bind(ctrl("^XO"), .next_win);// Remote switchingfunc cycle_rmt(c, s) [rmt, orig] {	if (!head(T_RMT))		return;	orig = rmt = (cur_rmt && (*c)(cur_rmt)) ? (*c)(cur_rmt) : head(T_RMT);	do {		if (!rmt_win(rmt))			return std_display(cur_win, rmt);		rmt = (*c)(rmt) ? : (*s)(T_RMT);	} while (rmt != orig);}func prev_rmt() { cycle_rmt(.prev, .tail); }func next_rmt() { cycle_rmt(.next, .head); }bind(ctrl("^[P"), .prev_rmt);bind(ctrl("^[N"), .next_rmt);// Keyboard historyKBHSIZE ?:= 100;kbhist ?:= alloc(KBHSIZE);kbhpos ?:= 0;kbhsize ?:= 0;kbhback ?:= 0;func add_kbhist(line) {	kbhist[kbhpos] = line;	kbhpos = (kbhpos + 1) % KBHSIZE;	if (kbhsize < KBHSIZE)		kbhsize++;}func accept() {	add_kbhist(kbuf);	kbhback = 0;	edfunc(K_PROCESS);	reset_prompt();}func prevline() [p, l] {	if (!kbhback && strlen(kbuf)) {		add_kbhist(kbuf);		kbhback = 1;	}	if (kbhback >= kbhsize)		return;	l = kbhist[(kbhpos - ++kbhback + KBHSIZE) % KBHSIZE];	kbuf = l;	kpos = strlen(l);}func nextline() [l] {	if (!kbhback)		return;	l = --kbhback ? kbhist[(kbhpos - kbhback + KBHSIZE) % KBHSIZE] : "";	kbuf = l;	kpos = strlen(l);}func kbpush() {	add_kbhist(kbuf);	kbhback = 0;	edfunc(K_DBUF);}bind("\n", .accept);bind(ctrl("^P"), .prevline);bind(ctrl("^N"), .nextline);bind(ctrl("^XP"), .kbpush);kfnames = table("Cursor up", "Cursor down", "Cursor left", "Cursor right", \		"Cursor end", "Cursor word left", "Cursor word right", \		"Backspace", "Delete word left", "Delete to beginning", \		"Delete buffer", "Delete character", "Delete word right", \		"Delete to end", "Refresh buffer", "Redraw screen", \		"Switch modes", "Process buffer");func List_keys() [k, f] {	for (k = head(T_KEY); k; k = next(k)) {		f = key_func(k);		printf("%10s %s\n", dispstr(key_seq(k)),		       (type(f) == T_FPTR) ? func_name(f) : kfnames[f]);	}}add_cmd("list_keys", 0, .List_keys, "/list_keys");

⌨️ 快捷键说明

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