Code

screen: Added screen swap command
authorJeffrey Middleton <jefromi@gmail.com>
Thu, 5 Mar 2009 23:06:42 +0000 (17:06 -0600)
committerJeffrey Middleton <jefromi@gmail.com>
Thu, 5 Mar 2009 19:17:10 +0000 (13:17 -0600)
Screen swap command toggles to the previous (most recently used) screen.
Particularly useful to return from lyrics/info screen.

src/command.c
src/command.h
src/screen.c

index 809f449f07be4c0da30e60e5fb3de6626391c8a3..3c8a405011dc3f28289fb4ca787142b641cac175 100644 (file)
@@ -193,6 +193,8 @@ static command_definition_t cmds[] = {
          N_("Next screen") },
        { { STAB, 0, 0 }, 0, CMD_SCREEN_PREVIOUS, "screen-prev",
          N_("Previous screen") },
+    { { '~', 0, 0 }, 0, CMD_SCREEN_SWAP, "screen-swap",
+         N_("Swap to most recent screen") },
 
 
        /* find */
index 3adc3d2f758e0925511ca1bdbe8f75ea1e5fe2af..a7145822d1a8cff7018759c482a9e03b0c4a8326 100644 (file)
@@ -82,6 +82,7 @@ typedef enum {
        CMD_SCREEN_UPDATE,
        CMD_SCREEN_PREVIOUS,
        CMD_SCREEN_NEXT,
+       CMD_SCREEN_SWAP,
        CMD_SCREEN_PLAY,
        CMD_SCREEN_FILE,
        CMD_SCREEN_ARTIST,
index 924cf4bd8149be56272366f0cdb9fc13734c081b..b53fcf46694f52daa7931f1fc989a9f72d543e99 100644 (file)
@@ -60,6 +60,7 @@ static gboolean welcome = TRUE;
 
 struct screen screen;
 static const struct screen_functions *mode_fn = &screen_playlist;
+static const struct screen_functions *mode_fn_prev = &screen_playlist;
 static int seek_id = -1;
 static int seek_target_time = 0;
 
@@ -77,6 +78,8 @@ screen_switch(const struct screen_functions *sf, struct mpdclient *c)
        if (sf == mode_fn)
                return;
 
+       mode_fn_prev = mode_fn;
+
        /* close the old mode */
        if (mode_fn->close != NULL)
                mode_fn->close();
@@ -857,7 +860,11 @@ screen_cmd(mpdclient_t *c, command_t cmd)
        case CMD_SCREEN_OUTPUTS:
                screen_switch(&screen_outputs, c);
                break;
+       case CMD_SCREEN_SWAP:
+               screen_switch(mode_fn_prev, c);
+               break;
 #endif
+
        default:
                break;
        }