aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorKalle Wallin <kaw@linux.se>2004-07-13 15:28:43 +0000
committerKalle Wallin <kaw@linux.se>2004-07-13 15:28:43 +0000
commitf674c3f262a6bf2542debd29c4aa61281a976cbc (patch)
tree54226e05acccdf1bad118b4dadde4c4d4f8b7e10 /src/command.c
parent2c6af7312cf617f40ab407323fd07a9fa5579495 (diff)
downloadmpd-f674c3f262a6bf2542debd29c4aa61281a976cbc.tar.gz
mpd-f674c3f262a6bf2542debd29c4aa61281a976cbc.tar.xz
mpd-f674c3f262a6bf2542debd29c4aa61281a976cbc.zip
Use my_wgetch() instead of wgetch(), added --[no-]mouse option
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1864 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/command.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/src/command.c b/src/command.c
index c8d43d99d..c256d0c5c 100644
--- a/src/command.c
+++ b/src/command.c
@@ -39,6 +39,7 @@
#define DK(x)
#endif
+extern void sigstop(void);
extern void screen_resize(void);
#define BS KEY_BACKSPACE
@@ -378,6 +379,29 @@ get_key_command(int key)
return find_key_command(key, cmds);
}
+int
+my_wgetch(WINDOW *w)
+{
+ int c;
+
+ c = wgetch(w);
+
+ /* handle resize event */
+ if( c==KEY_RESIZE )
+ screen_resize();
+
+#ifdef ENABLE_RAW_MODE
+ /* handle SIGSTOP (Ctrl-Z) */
+ if( c==26 || c==407 )
+ sigstop();
+ /* handle SIGINT (Ctrl-C) */
+ if( c==3 )
+ exit(EXIT_SUCCESS);
+#endif
+
+ return c;
+}
+
command_t
get_keyboard_command_with_timeout(int ms)
{
@@ -385,18 +409,10 @@ get_keyboard_command_with_timeout(int ms)
if( ms != SCREEN_TIMEOUT)
timeout(ms);
- key = wgetch(stdscr);
+ key = my_wgetch(stdscr);
if( ms != SCREEN_TIMEOUT)
timeout(SCREEN_TIMEOUT);
- if( key==KEY_RESIZE )
- screen_resize();
-
-#ifdef ENABLE_RAW_MODE
- if( key==KEY_SIGSTOP )
- sigstop();
-#endif
-
if( key==ERR )
return CMD_NONE;
@@ -490,18 +506,21 @@ check_key_bindings(command_definition_t *cp, char *buf, size_t bufsize)
}
int
-write_key_bindings(FILE *f)
+write_key_bindings(FILE *f, int flags)
{
int i,j;
- fprintf(f, "# Key bindings for ncmpc (generated by ncmpc)\n\n");
+ if( flags & KEYDEF_WRITE_HEADER )
+ fprintf(f, "## Key bindings for ncmpc (generated by ncmpc)\n\n");
i=0;
while( cmds[i].name && !ferror(f) )
{
- if( cmds[i].flags & COMMAND_KEY_MODIFIED )
+ if( cmds[i].flags & COMMAND_KEY_MODIFIED || flags & KEYDEF_WRITE_ALL)
{
- fprintf(f, "# %s\n", cmds[i].description);
+ fprintf(f, "## %s\n", cmds[i].description);
+ if( flags & KEYDEF_COMMENT_ALL )
+ fprintf(f, "#");
fprintf(f, "key %s = ", cmds[i].name);
for(j=0; j<MAX_COMMAND_KEYS; j++)
{