add support for switching between user-defined sequence of screens using Tab
This commit is contained in:
22
doc/config
22
doc/config
@@ -269,10 +269,26 @@
|
|||||||
##
|
##
|
||||||
## How shall key_screen_switcher work?
|
## How shall key_screen_switcher work?
|
||||||
##
|
##
|
||||||
## - yes - always switch between browser and playlist
|
## - "previous" - switch between current and last used screen
|
||||||
## - no - switch between current and last used screen
|
## - "sequence: 2 -> 9 -> 5" - switch between given sequence of screens.
|
||||||
##
|
##
|
||||||
#screen_switcher_browser_only = "yes"
|
## Screen numbers you can use after 'sequence' keyword are:
|
||||||
|
##
|
||||||
|
## - 1 - help
|
||||||
|
## - 2 - playlist
|
||||||
|
## - 3 - browser
|
||||||
|
## - 4 - search engine
|
||||||
|
## - 5 - media library
|
||||||
|
## - 6 - playlist editor
|
||||||
|
## - 7 - tag editor
|
||||||
|
## - 8 - outputs
|
||||||
|
## - 9 - visualizer
|
||||||
|
## - 10 - clock
|
||||||
|
##
|
||||||
|
## As you can see, above example will switch between
|
||||||
|
## playlist, visualizer and media library screens.
|
||||||
|
##
|
||||||
|
#screen_switcher_mode = "sequence: 2 -> 3"
|
||||||
#
|
#
|
||||||
#jump_to_now_playing_song_at_start = "yes"
|
#jump_to_now_playing_song_at_start = "yes"
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -219,8 +219,8 @@ If set to "playlist", Search engine will perform searching in current MPD playli
|
|||||||
.B display_screens_numbers_on_start = yes/no
|
.B display_screens_numbers_on_start = yes/no
|
||||||
If enabled, screens' names and their keybindings will be shown in header window until key is pressed, otherwise they won't be displayed at all.
|
If enabled, screens' names and their keybindings will be shown in header window until key is pressed, otherwise they won't be displayed at all.
|
||||||
.TP
|
.TP
|
||||||
.B screen_switcher_browser_only = yes/no
|
.B screen_switcher_previous = SWITCHER_MODE
|
||||||
If enabled, the "screen_switcher" key (<Tab> by default) will only switch between the playlist and browser screens. If disabled, the last active screen will be remembered, and the "screen_switcher" key will jump back.
|
If set to "previous", key_screen_switcher will switch between current and last used screen. If set to "sequence: user_defined_sequence", it will switch between given sequence of screens. Syntax clarification can be found in example config file.
|
||||||
.TP
|
.TP
|
||||||
.B jump_to_now_playing_song_at_start = yes/no
|
.B jump_to_now_playing_song_at_start = yes/no
|
||||||
If enabled, ncmpcpp will jump at start to now playing song if mpd is playing or paused.
|
If enabled, ncmpcpp will jump at start to now playing song if mpd is playing or paused.
|
||||||
|
|||||||
@@ -138,10 +138,10 @@ void Help::GetKeybindings()
|
|||||||
*w << DisplayKeys(Key.Home) << "Home\n";
|
*w << DisplayKeys(Key.Home) << "Home\n";
|
||||||
*w << DisplayKeys(Key.End) << "End\n";
|
*w << DisplayKeys(Key.End) << "End\n";
|
||||||
*w << "\n";
|
*w << "\n";
|
||||||
if (Config.screen_switcher_browser_only)
|
if (Config.screen_switcher_previous)
|
||||||
*w << DisplayKeys(Key.ScreenSwitcher) << "Switch between playlist and browser\n";
|
|
||||||
else
|
|
||||||
*w << DisplayKeys(Key.ScreenSwitcher) << "Switch between current and last screen\n";
|
*w << DisplayKeys(Key.ScreenSwitcher) << "Switch between current and last screen\n";
|
||||||
|
else
|
||||||
|
*w << DisplayKeys(Key.ScreenSwitcher) << "Switch between given sequence of screens\n";
|
||||||
*w << DisplayKeys(Key.Help) << "Help screen\n";
|
*w << DisplayKeys(Key.Help) << "Help screen\n";
|
||||||
*w << DisplayKeys(Key.Playlist) << "Playlist screen\n";
|
*w << DisplayKeys(Key.Playlist) << "Playlist screen\n";
|
||||||
*w << DisplayKeys(Key.Browser) << "Browse screen\n";
|
*w << DisplayKeys(Key.Browser) << "Browse screen\n";
|
||||||
|
|||||||
@@ -1945,20 +1945,21 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.ScreenSwitcher))
|
else if (Keypressed(input, Key.ScreenSwitcher))
|
||||||
{
|
{
|
||||||
if (Config.screen_switcher_browser_only)
|
if (Config.screen_switcher_previous)
|
||||||
{
|
|
||||||
if (myScreen == myPlaylist)
|
|
||||||
myBrowser->SwitchTo();
|
|
||||||
else
|
|
||||||
myPlaylist->SwitchTo();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (myScreen->isTabbable())
|
if (myScreen->isTabbable())
|
||||||
myPrevScreen->SwitchTo();
|
myPrevScreen->SwitchTo();
|
||||||
else
|
else
|
||||||
myOldScreen->SwitchTo();
|
myOldScreen->SwitchTo();
|
||||||
}
|
}
|
||||||
|
else if (!Config.screens_seq.empty())
|
||||||
|
{
|
||||||
|
std::list<BasicScreen *>::const_iterator screen = std::find(Config.screens_seq.begin(), Config.screens_seq.end(), myScreen);
|
||||||
|
if (++screen == Config.screens_seq.end())
|
||||||
|
(*Config.screens_seq.begin())->SwitchTo();
|
||||||
|
else
|
||||||
|
(*screen)->SwitchTo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.Playlist))
|
else if (Keypressed(input, Key.Playlist))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,10 +26,20 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include "browser.h"
|
||||||
|
#include "clock.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "help.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "lyrics.h"
|
#include "lyrics.h"
|
||||||
|
#include "media_library.h"
|
||||||
|
#include "outputs.h"
|
||||||
|
#include "playlist.h"
|
||||||
|
#include "playlist_editor.h"
|
||||||
|
#include "search_engine.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "tag_editor.h"
|
||||||
|
#include "visualizer.h"
|
||||||
|
|
||||||
#ifdef HAVE_LANGINFO_H
|
#ifdef HAVE_LANGINFO_H
|
||||||
# include <langinfo.h>
|
# include <langinfo.h>
|
||||||
@@ -70,6 +80,43 @@ namespace
|
|||||||
{
|
{
|
||||||
return Border(IntoColor(color));
|
return Border(IntoColor(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BasicScreen *IntoScreen(int n)
|
||||||
|
{
|
||||||
|
switch (n)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
return myHelp;
|
||||||
|
case 2:
|
||||||
|
return myPlaylist;
|
||||||
|
case 3:
|
||||||
|
return myBrowser;
|
||||||
|
case 4:
|
||||||
|
return mySearcher;
|
||||||
|
case 5:
|
||||||
|
return myLibrary;
|
||||||
|
case 6:
|
||||||
|
return myPlaylistEditor;
|
||||||
|
# ifdef HAVE_TAGLIB_H
|
||||||
|
case 7:
|
||||||
|
return myTagEditor;
|
||||||
|
# endif // HAVE_TAGLIB_H
|
||||||
|
# ifdef ENABLE_OUTPUTS
|
||||||
|
case 8:
|
||||||
|
return myOutputs;
|
||||||
|
# endif // ENABLE_OUTPUTS
|
||||||
|
# ifdef ENABLE_VISUALIZER
|
||||||
|
case 9:
|
||||||
|
return myVisualizer;
|
||||||
|
# endif // ENABLE_VISUALIZER
|
||||||
|
# ifdef ENABLE_CLOCK
|
||||||
|
case 10:
|
||||||
|
return myClock;
|
||||||
|
# endif // ENABLE_CLOCK
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateConfigDir()
|
void CreateConfigDir()
|
||||||
@@ -297,7 +344,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
|||||||
conf.header_text_scrolling = true;
|
conf.header_text_scrolling = true;
|
||||||
conf.statusbar_visibility = true;
|
conf.statusbar_visibility = true;
|
||||||
conf.centered_cursor = false;
|
conf.centered_cursor = false;
|
||||||
conf.screen_switcher_browser_only = true;
|
conf.screen_switcher_previous = false;
|
||||||
conf.autocenter_mode = false;
|
conf.autocenter_mode = false;
|
||||||
conf.wrapped_search = true;
|
conf.wrapped_search = true;
|
||||||
conf.space_selects = false;
|
conf.space_selects = false;
|
||||||
@@ -343,6 +390,10 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
|||||||
if (conf.system_encoding == "UTF-8") // mpd uses utf-8 by default so no need to convert
|
if (conf.system_encoding == "UTF-8") // mpd uses utf-8 by default so no need to convert
|
||||||
conf.system_encoding.clear();
|
conf.system_encoding.clear();
|
||||||
# endif // HAVE_LANGINFO_H
|
# endif // HAVE_LANGINFO_H
|
||||||
|
|
||||||
|
// default screens sequence
|
||||||
|
conf.screens_seq.push_back(myPlaylist);
|
||||||
|
conf.screens_seq.push_back(myBrowser);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadKeys(ncmpcpp_keys &keys)
|
void ReadKeys(ncmpcpp_keys &keys)
|
||||||
@@ -768,9 +819,30 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
|||||||
{
|
{
|
||||||
conf.statusbar_visibility = v == "yes";
|
conf.statusbar_visibility = v == "yes";
|
||||||
}
|
}
|
||||||
else if (cl.find("screen_switcher_browser_only") != std::string::npos)
|
else if (cl.find("screen_switcher_mode") != std::string::npos)
|
||||||
{
|
{
|
||||||
conf.screen_switcher_browser_only = v == "yes";
|
if (v.find("previous") != std::string::npos)
|
||||||
|
{
|
||||||
|
conf.screen_switcher_previous = true;
|
||||||
|
}
|
||||||
|
else if (v.find("sequence") != std::string::npos)
|
||||||
|
{
|
||||||
|
conf.screen_switcher_previous = false;
|
||||||
|
conf.screens_seq.clear();
|
||||||
|
for (std::string::const_iterator it = v.begin(); it != v.end(); )
|
||||||
|
{
|
||||||
|
while (it != v.end() && !isdigit(*it))
|
||||||
|
++it;
|
||||||
|
if (it == v.end())
|
||||||
|
break;
|
||||||
|
if (BasicScreen *screen = IntoScreen(atoi(&*it)))
|
||||||
|
conf.screens_seq.push_back(screen);
|
||||||
|
while (it != v.end() && isdigit(*it))
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
// throw away duplicates
|
||||||
|
conf.screens_seq.unique();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (cl.find("autocenter_mode") != std::string::npos)
|
else if (cl.find("autocenter_mode") != std::string::npos)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,6 +38,8 @@
|
|||||||
const std::string config_dir = home_path + HOME_FOLDER;
|
const std::string config_dir = home_path + HOME_FOLDER;
|
||||||
const int null_key = std::numeric_limits<int>::max();
|
const int null_key = std::numeric_limits<int>::max();
|
||||||
|
|
||||||
|
class BasicScreen; // forward declaration for screens sequence
|
||||||
|
|
||||||
struct Column
|
struct Column
|
||||||
{
|
{
|
||||||
Column() : right_alignment(0), display_empty_tag(1) { }
|
Column() : right_alignment(0), display_empty_tag(1) { }
|
||||||
@@ -189,7 +191,7 @@ struct ncmpcpp_config
|
|||||||
bool header_text_scrolling;
|
bool header_text_scrolling;
|
||||||
bool statusbar_visibility;
|
bool statusbar_visibility;
|
||||||
bool centered_cursor;
|
bool centered_cursor;
|
||||||
bool screen_switcher_browser_only;
|
bool screen_switcher_previous;
|
||||||
bool autocenter_mode;
|
bool autocenter_mode;
|
||||||
bool wrapped_search;
|
bool wrapped_search;
|
||||||
bool space_selects;
|
bool space_selects;
|
||||||
@@ -232,6 +234,8 @@ struct ncmpcpp_config
|
|||||||
unsigned search_engine_default_search_mode;
|
unsigned search_engine_default_search_mode;
|
||||||
|
|
||||||
size_t selected_item_suffix_length;
|
size_t selected_item_suffix_length;
|
||||||
|
|
||||||
|
std::list<BasicScreen *> screens_seq;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ncmpcpp_config Config;
|
extern ncmpcpp_config Config;
|
||||||
|
|||||||
Reference in New Issue
Block a user