From: Kalle Wallin Date: Mon, 12 Jul 2004 20:40:02 +0000 (+0000) Subject: Support SIGSTOP, SIGCONT in raw mode X-Git-Tag: v0.12_alpha1~464 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a054f129e4e4eb6baac21c192c1cf49bd6343fc4;p=ncmpc.git Support SIGSTOP, SIGCONT in raw mode git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1858 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- diff --git a/src/command.c b/src/command.c index 1d77d0d..6cf3bf1 100644 --- a/src/command.c +++ b/src/command.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "config.h" @@ -391,12 +392,17 @@ get_keyboard_command_with_timeout(int ms) if( key==KEY_RESIZE ) screen_resize(); +#ifdef ENABLE_RAW_MODE + if( key==KEY_SIGSTOP ) + sigstop(); +#endif + if( key==ERR ) return CMD_NONE; #ifdef HAVE_GETMOUSE - if( key==KEY_MOUSE ) - return CMD_MOUSE_EVENT; + // if( key==KEY_MOUSE ) + // return CMD_MOUSE_EVENT; #endif return get_key_command(key); diff --git a/src/main.c b/src/main.c index 9497e3b..19dad29 100644 --- a/src/main.c +++ b/src/main.c @@ -137,7 +137,19 @@ void catch_sigcont( int sig ) { D("catch_sigcont()\n"); - screen_resize(); +#ifdef ENABLE_RAW_MODE + reset_prog_mode(); /* restore tty modes */ + refresh(); +#endif + screen_resize(); +} + +void +sigstop(void) +{ + def_prog_mode(); /* save the tty modes */ + endwin(); /* end curses mode temporarily */ + kill(0, SIGSTOP); /* issue SIGSTOP */ } #ifdef DEBUG diff --git a/src/ncmpc.h b/src/ncmpc.h index 4118456..dec530d 100644 --- a/src/ncmpc.h +++ b/src/ncmpc.h @@ -46,4 +46,10 @@ void D(char *format, ...); #define DEFAULT_STATUS_FORMAT "[%artist% - ]%title%|%shortfile%" #define STATUS_FORMAT (options.status_format ? options.status_format : DEFAULT_STATUS_FORMAT) +/* sigstop key (Ctrl-Z) */ +#define KEY_SIGSTOP 26 + +/* send SIGSTOP */ +void sigstop(void); + #endif /* NCMPC_H */ diff --git a/src/screen_utils.c b/src/screen_utils.c index 7e2ba14..cd3fc1e 100644 --- a/src/screen_utils.c +++ b/src/screen_utils.c @@ -66,6 +66,11 @@ screen_getch(WINDOW *w, char *prompt) while( (key=wgetch(w)) == ERR ) ; +#ifdef ENABLE_RAW_MODE + if( key==KEY_SIGSTOP ) + sigstop(); +#endif + #ifdef HAVE_GETMOUSE /* ignore mouse events */ if( key==KEY_MOUSE ) diff --git a/src/wreadln.c b/src/wreadln.c index 3ebba7f..d020432 100644 --- a/src/wreadln.c +++ b/src/wreadln.c @@ -44,6 +44,7 @@ wrln_gcmp_pre_cb_t wrln_pre_completion_callback = NULL; wrln_gcmp_post_cb_t wrln_post_completion_callback = NULL; extern void screen_bell(void); +extern void sigstop(void); char * wreadln(WINDOW *w, @@ -169,6 +170,11 @@ wreadln(WINDOW *w, case ERR: /* ingnore errors */ break; +#ifdef ENABLE_RAW_MODE + case 26: + sigstop(); + break; +#endif case KEY_RESIZE: /* a resize event -> call an external callback function */ if( wrln_resize_callback )