?? signal.c
字號:
/* signal.c: Handle signals in an intelligent manner */
/* $Id: signal.c 2.2 1995/10/27 20:03:47 tsurace Release $ */
#include "vt.h"
#include <signal.h>
#ifndef __WIN32__
# include <sys/ioctl.h>
#endif /* __WIN32__ */
int break_pending = 0, console_pending = 0, winresize_pending = 0;
int stop_pending = 0;
extern int console_mode, rows, cols, debug;
#ifndef __WIN32__ /* Handle ctrl-c from main event loop instead */
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;
}
}
}
#endif /* __WIN32_ */
#ifdef SIGSTOP /* Windows NT doesn't understand STOPping */
static void sigtstp_handler()
{
signal(SIGTSTP, sigtstp_handler);
stop_pending = 1;
}
#endif /* SIGSTOP */
void stop() {
#ifdef SIGSTOP
scroll(0, rows - 1);
cmove(0, rows - 1);
bflushfunc();
tty_mode(0);
kill(getpid(), SIGSTOP);
tty_mode(1);
auto_redraw();
#endif /* SIGSTOP */
stop_pending = 0;
}
#ifdef SIGWINCH
static 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()
{
#ifndef __WIN32__
signal(SIGINT , sigint_handler );
#endif /* __WIN32__ */
#ifdef SIGSTOP
signal(SIGTSTP , sigtstp_handler );
#endif /* SIGSTOP */
#ifdef SIGWINCH
signal(SIGWINCH, sigwinch_handler );
#endif
#ifdef SIGPIPE
signal(SIGPIPE , SIG_IGN );
#endif /* SIGPIPE */
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -