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

📄 signal.c

📁 Unix下的MUD客户端程序
💻 C
字号:
/* signal.c: Handle signals in an intelligent manner */#include "vt.h"#include <signal.h>#include <sys/ioctl.h>int break_pending = 0, console_pending = 0, winresize_pending = 0;int stop_pending = 0;extern int console_mode, rows, cols, debug;static void sigint_handler(){	char c;	signal(SIGINT, sigint_handler);	coutput("[Q]uit [R]esume [B]reak [C]onsole [D]ebug: ");	do		c = lcase(getch());	while (!strchr("qbrcd\033", c));	switch(c) {	    case 'q':		coutput("Quit\n");		cleanup();		exit(0);	    Case 'r':	    case '\033':		coutput("Resume\n");	    Case 'b':		coutput("Break\n");		break_pending = 1;	    Case 'c':		coutput("Console\n");		console_pending = !console_mode;	    Case 'd':		coutput("Debug\n[+] On [-] Off: ");		while (!strchr("+-\033", c = getch()));		switch(c) {		    case '+':			coutput("On\n");			debug = 1;		    Case '-':			coutput("Off\n");			debug = 0;		}	}}static void sigtstp_handler(){	signal(SIGTSTP, sigtstp_handler);	stop_pending = 1;}void stop() {	scroll(0, rows - 1);	cmove(0, rows - 1);	bflushfunc();	tty_mode(0);	kill(getpid(), SIGSTOP);	tty_mode(1);	auto_redraw();	stop_pending = 0;}#ifdef SIGWINCHstatic void sigwinch_handler(){	signal(SIGWINCH, sigwinch_handler);	winresize_pending = 1;}#endif /* SIGWINCH */void winresize() {#ifdef TIOCGWINSZ	struct winsize size;	ioctl(0, TIOCGWINSZ, &size);	if (size.ws_row && size.ws_col) {		if (size.ws_row != rows)			resize_screen((int) size.ws_row, (int) size.ws_col);		else if (size.ws_col != cols) {			cols = size.ws_col;			auto_redraw();		}	}#endif /* TIOCGWINSZ */	winresize_pending = 0;}void init_signals(){	signal(SIGINT  , sigint_handler	  );	signal(SIGTSTP , sigtstp_handler  );#ifdef SIGWINCH	signal(SIGWINCH, sigwinch_handler );#endif	signal(SIGPIPE , SIG_IGN	  );}

⌨️ 快捷键说明

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