From: Max Kellermann Date: Wed, 17 Sep 2008 23:14:00 +0000 (+0200) Subject: screen: moved code to screen_client_cmd() X-Git-Tag: v0.12_alpha1~250 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9de9dfc3a6a8061089eebcc6271b2f13ac43e20b;p=ncmpc.git screen: moved code to screen_client_cmd() Move all command handlers which need a connection to the MPD server to screen_client_cmd(). This will allow us to unify error handling later. --- diff --git a/src/screen.c b/src/screen.c index b6e2b7b..14ffffe 100644 --- a/src/screen.c +++ b/src/screen.c @@ -795,16 +795,9 @@ screen_get_mouse_event(mpdclient_t *c, } #endif -void -screen_cmd(mpdclient_t *c, command_t cmd) +static int +screen_client_cmd(mpdclient_t *c, command_t cmd) { - screen.input_timestamp = time(NULL); - screen.last_cmd = cmd; - welcome = FALSE; - - if (mode_fn->cmd != NULL && mode_fn->cmd(&screen, c, cmd)) - return; - switch(cmd) { case CMD_PLAY: mpdclient_cmd_play(c, MPD_PLAY_AT_BEGINNING); @@ -883,6 +876,28 @@ screen_cmd(mpdclient_t *c, command_t cmd) if( c->status->volume!=MPD_STATUS_NO_VOLUME && c->status->volume>0 ) mpdclient_cmd_volume(c, --c->status->volume); break; + + default: + return 0; + } + + return 1; +} + +void +screen_cmd(mpdclient_t *c, command_t cmd) +{ + screen.input_timestamp = time(NULL); + screen.last_cmd = cmd; + welcome = FALSE; + + if (mode_fn->cmd != NULL && mode_fn->cmd(&screen, c, cmd)) + return; + + if (screen_client_cmd(c, cmd)) + return; + + switch(cmd) { case CMD_TOGGLE_FIND_WRAP: options.find_wrap = !options.find_wrap; screen_status_printf(options.find_wrap ?