add support for binding actions to multibyte characters
This commit is contained in:
@@ -58,6 +58,35 @@ size_t Action::FooterHeight;
|
||||
size_t Action::FooterStartY;
|
||||
|
||||
std::map<ActionType, Action *> Action::Actions;
|
||||
Action::Key Action::NoOp = Action::Key(ERR, ctNCurses);
|
||||
|
||||
Action::Key Action::ReadKey(Window &w)
|
||||
{
|
||||
std::string tmp;
|
||||
int input;
|
||||
while (true)
|
||||
{
|
||||
w.ReadKey(input);
|
||||
if (input == ERR)
|
||||
return NoOp;
|
||||
if (input > 255)
|
||||
return Key(input, ctNCurses);
|
||||
else
|
||||
{
|
||||
wchar_t wc;
|
||||
tmp += input;
|
||||
size_t conv_res = mbrtowc(&wc, tmp.c_str(), MB_CUR_MAX, 0);
|
||||
if (conv_res == size_t(-1)) // incomplete multibyte character
|
||||
continue;
|
||||
else if (conv_res == size_t(-2)) // garbage character sequence
|
||||
return NoOp;
|
||||
else // character complete
|
||||
return Key(wc, ctStandard);
|
||||
}
|
||||
}
|
||||
// not reachable
|
||||
assert(false);
|
||||
}
|
||||
|
||||
void Action::ValidateScreenSize()
|
||||
{
|
||||
@@ -215,7 +244,6 @@ void Action::Seek()
|
||||
LockProgressbar();
|
||||
LockStatusbar();
|
||||
|
||||
int input;
|
||||
int songpos = Mpd.GetElapsedTime();
|
||||
time_t t = time(0);
|
||||
|
||||
@@ -227,11 +255,11 @@ void Action::Seek()
|
||||
{
|
||||
TraceMpdStatus();
|
||||
myPlaylist->UpdateTimer();
|
||||
wFooter->ReadKey(input);
|
||||
|
||||
int howmuch = Config.incremental_seeking ? (myPlaylist->Timer()-t)/2+Config.seek_time : Config.seek_time;
|
||||
|
||||
NcmpcppKeys::Binding k = Key.Bindings.equal_range(input);
|
||||
Key input = ReadKey(*wFooter);
|
||||
KeyConfiguration::Binding k = Keys.Bindings.equal_range(input);
|
||||
// no action?
|
||||
if (k.first == k.second)
|
||||
break;
|
||||
|
||||
@@ -49,8 +49,41 @@ enum ActionType
|
||||
aShowVisualizer, aShowClock, aShowServerInfo
|
||||
};
|
||||
|
||||
enum CharType { ctStandard, ctNCurses };
|
||||
|
||||
struct Action
|
||||
{
|
||||
/// Key for binding actions to it. Supports non-ascii characters.
|
||||
struct Key
|
||||
{
|
||||
Key(wchar_t ch, CharType ct) : Char(ch), Type(ct) { }
|
||||
|
||||
wchar_t getChar() const { return Char; }
|
||||
CharType getType() const { return Type; }
|
||||
|
||||
# define INEQUALITY_OPERATOR(CMP) \
|
||||
bool operator CMP (const Key &k) const \
|
||||
{ \
|
||||
if (Char CMP k.Char) \
|
||||
return true; \
|
||||
if (Char != k.Char) \
|
||||
return false; \
|
||||
return Type CMP k.Type; \
|
||||
}
|
||||
INEQUALITY_OPERATOR(<);
|
||||
INEQUALITY_OPERATOR(<=);
|
||||
INEQUALITY_OPERATOR(>);
|
||||
INEQUALITY_OPERATOR(>=);
|
||||
# undef INEQUALITY_OPERATOR
|
||||
|
||||
bool operator==(const Key &k) const { return Char == k.Char && Type == k.Type; }
|
||||
bool operator!=(const Key &k) const { return !(*this == k); }
|
||||
|
||||
private:
|
||||
wchar_t Char;
|
||||
CharType Type;
|
||||
};
|
||||
|
||||
enum FindDirection { fdForward, fdBackward };
|
||||
|
||||
Action(ActionType type, const char *name) : itsType(type), itsName(name) { }
|
||||
@@ -68,6 +101,8 @@ struct Action
|
||||
return false;
|
||||
}
|
||||
|
||||
static Key ReadKey(Window &w);
|
||||
|
||||
static void ValidateScreenSize();
|
||||
static void SetResizeFlags();
|
||||
static void ResizeScreen();
|
||||
@@ -87,6 +122,8 @@ struct Action
|
||||
static size_t FooterHeight;
|
||||
static size_t FooterStartY;
|
||||
|
||||
static Key NoOp;
|
||||
|
||||
protected:
|
||||
virtual bool canBeRun() const { return true; }
|
||||
virtual void Run() = 0;
|
||||
|
||||
56
src/conv.cpp
56
src/conv.cpp
@@ -97,6 +97,62 @@ std::string IntoStr(NCurses::Color color)
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string IntoStr(const Action::Key &key, bool *print_backspace)
|
||||
{
|
||||
std::string result;
|
||||
if (key == Action::Key(KEY_UP, ctNCurses))
|
||||
result += "Up";
|
||||
else if (key == Action::Key(KEY_DOWN, ctNCurses))
|
||||
result += "Down";
|
||||
else if (key == Action::Key(KEY_PPAGE, ctNCurses))
|
||||
result += "PageUp";
|
||||
else if (key == Action::Key(KEY_NPAGE, ctNCurses))
|
||||
result += "PageDown";
|
||||
else if (key == Action::Key(KEY_HOME, ctNCurses))
|
||||
result += "Home";
|
||||
else if (key == Action::Key(KEY_END, ctNCurses))
|
||||
result += "End";
|
||||
else if (key == Action::Key(KEY_SPACE, ctStandard))
|
||||
result += "Space";
|
||||
else if (key == Action::Key(KEY_ENTER, ctStandard))
|
||||
result += "Enter";
|
||||
else if (key == Action::Key(KEY_DC, ctNCurses))
|
||||
result += "Delete";
|
||||
else if (key == Action::Key(KEY_RIGHT, ctNCurses))
|
||||
result += "Right";
|
||||
else if (key == Action::Key(KEY_LEFT, ctNCurses))
|
||||
result += "Left";
|
||||
else if (key == Action::Key(KEY_TAB, ctStandard))
|
||||
result += "Tab";
|
||||
else if (key == Action::Key(KEY_SHIFT_TAB, ctNCurses))
|
||||
result += "Shift-Tab";
|
||||
else if (key >= Action::Key(KEY_CTRL_A, ctStandard) && key <= Action::Key(KEY_CTRL_Z, ctStandard))
|
||||
{
|
||||
result += "Ctrl-";
|
||||
result += key.getChar()+64;
|
||||
}
|
||||
else if (key >= Action::Key(KEY_F1, ctNCurses) && key <= Action::Key(KEY_F12, ctNCurses))
|
||||
{
|
||||
result += "F";
|
||||
result += IntoStr(key.getChar()-264);
|
||||
}
|
||||
else if ((key == Action::Key(KEY_BACKSPACE, ctNCurses) || key == Action::Key(KEY_BACKSPACE_2, ctStandard)))
|
||||
{
|
||||
// since some terminals interpret KEY_BACKSPACE as backspace and other need KEY_BACKSPACE_2,
|
||||
// actions have to be bound to either of them, but we want to display "Backspace" only once,
|
||||
// hance this 'print_backspace' switch.
|
||||
if (!print_backspace || *print_backspace)
|
||||
{
|
||||
result += "Backspace";
|
||||
if (print_backspace)
|
||||
*print_backspace = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
result += ToString(std::wstring(1, key.getChar()));
|
||||
return result;
|
||||
}
|
||||
|
||||
NCurses::Color IntoColor(const std::string &color)
|
||||
{
|
||||
NCurses::Color result = NCurses::clDefault;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
#include "actions.h"
|
||||
#include "window.h"
|
||||
#include "song.h"
|
||||
|
||||
@@ -43,10 +44,9 @@ int StrToInt(const std::string &);
|
||||
long StrToLong(const std::string &);
|
||||
|
||||
std::string IntoStr(int);
|
||||
|
||||
std::string IntoStr(mpd_tag_type);
|
||||
|
||||
std::string IntoStr(NCurses::Color);
|
||||
std::string IntoStr(const Action::Key &key, bool *print_backspace = 0);
|
||||
|
||||
NCurses::Color IntoColor(const std::string &);
|
||||
|
||||
|
||||
51
src/help.cpp
51
src/help.cpp
@@ -78,58 +78,13 @@ std::basic_string<my_char_t> Help::Title()
|
||||
|
||||
std::string Help::DisplayKeys(const ActionType at)
|
||||
{
|
||||
bool backspace = true;
|
||||
bool print_backspace = true;
|
||||
std::string result;
|
||||
for (std::multimap<int, Action *>::const_iterator it = Key.Bindings.begin(); it != Key.Bindings.end(); ++it)
|
||||
for (std::multimap<Action::Key, Action *>::const_iterator it = Keys.Bindings.begin(); it != Keys.Bindings.end(); ++it)
|
||||
{
|
||||
if (it->second->Type() == at)
|
||||
{
|
||||
int key = it->first;
|
||||
|
||||
if (key == 259)
|
||||
result += "Up";
|
||||
else if (key == 258)
|
||||
result += "Down";
|
||||
else if (key == 339)
|
||||
result += "PageUp";
|
||||
else if (key == 338)
|
||||
result += "PageDown";
|
||||
else if (key == 262)
|
||||
result += "Home";
|
||||
else if (key == 360)
|
||||
result += "End";
|
||||
else if (key == 32)
|
||||
result += "Space";
|
||||
else if (key == 10)
|
||||
result += "Enter";
|
||||
else if (key == 330)
|
||||
result += "Delete";
|
||||
else if (key == 261)
|
||||
result += "Right";
|
||||
else if (key == 260)
|
||||
result += "Left";
|
||||
else if (key == 9)
|
||||
result += "Tab";
|
||||
else if (key == 353)
|
||||
result += "Shift-Tab";
|
||||
else if (key >= 1 && key <= 26)
|
||||
{
|
||||
result += "Ctrl-";
|
||||
result += key+64;
|
||||
}
|
||||
else if (key >= 265 && key <= 276)
|
||||
{
|
||||
result += "F";
|
||||
result += IntoStr(key-264);
|
||||
}
|
||||
else if ((key == 263 || key == 127) && !backspace);
|
||||
else if ((key == 263 || key == 127) && backspace)
|
||||
{
|
||||
result += "Backspace";
|
||||
backspace = false;
|
||||
}
|
||||
else if (isprint(key))
|
||||
result += key;
|
||||
result += IntoStr(it->first, &print_backspace);
|
||||
result += " ";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ void ParseArgv(int argc, char **argv)
|
||||
}
|
||||
else if (!strcmp(argv[i], "-c") || !strcmp(argv[i], "--config"))
|
||||
{
|
||||
// this is used in NcmpcppConfig::CheckForCommandLineConfigFilePath, ignoring here.
|
||||
// this is used in Configuration::CheckForCommandLineConfigFilePath, ignoring here.
|
||||
++i;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -103,7 +103,7 @@ int main(int argc, char **argv)
|
||||
Config.Read();
|
||||
|
||||
Config.GenerateColumns();
|
||||
Key.GenerateKeybindings();
|
||||
Keys.GenerateBindings();
|
||||
|
||||
if (getenv("MPD_HOST"))
|
||||
Mpd.SetHostname(getenv("MPD_HOST"));
|
||||
@@ -175,8 +175,7 @@ int main(int argc, char **argv)
|
||||
Mpd.SetErrorHandler(NcmpcppErrorCallback, 0);
|
||||
|
||||
// local variables
|
||||
int input = 0;
|
||||
|
||||
Action::Key input(Action::NoOp);
|
||||
timeval past = { 0, 0 };
|
||||
// local variables end
|
||||
|
||||
@@ -263,14 +262,14 @@ int main(int argc, char **argv)
|
||||
}
|
||||
// header stuff end
|
||||
|
||||
if (input != ERR)
|
||||
if (input != Action::NoOp)
|
||||
myScreen->RefreshWindow();
|
||||
wFooter->ReadKey(input);
|
||||
input = Action::ReadKey(*wFooter);
|
||||
|
||||
if (input == ERR)
|
||||
if (input == Action::NoOp)
|
||||
continue;
|
||||
|
||||
NcmpcppKeys::Binding k = Key.Bindings.equal_range(input);
|
||||
KeyConfiguration::Binding k = Keys.Bindings.equal_range(input);
|
||||
for (; k.first != k.second; ++k.first)
|
||||
if (k.first->second->Execute())
|
||||
break;
|
||||
|
||||
284
src/settings.cpp
284
src/settings.cpp
@@ -51,8 +51,8 @@
|
||||
# include <langinfo.h>
|
||||
#endif
|
||||
|
||||
NcmpcppConfig Config;
|
||||
NcmpcppKeys Key;
|
||||
Configuration Config;
|
||||
KeyConfiguration Keys;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -131,147 +131,147 @@ void CreateDir(const std::string &dir)
|
||||
);
|
||||
}
|
||||
|
||||
void NcmpcppKeys::GenerateKeybindings()
|
||||
void KeyConfiguration::GenerateBindings()
|
||||
{
|
||||
# define BIND(key, action) Bindings.insert(std::make_pair(key, Action::Get(action)))
|
||||
# define BIND(key, type, action) Bindings.insert(std::make_pair(Action::Key(key, type), Action::Get(action)))
|
||||
|
||||
BIND(KEY_MOUSE, aMouseEvent);
|
||||
BIND(KEY_UP, aScrollUp);
|
||||
BIND(KEY_DOWN, aScrollDown);
|
||||
BIND('[', aScrollUpAlbum);
|
||||
BIND(']', aScrollDownAlbum);
|
||||
BIND('{', aScrollUpArtist);
|
||||
BIND('}', aScrollDownArtist);
|
||||
BIND(KEY_PPAGE, aPageUp);
|
||||
BIND(KEY_NPAGE, aPageDown);
|
||||
BIND(KEY_HOME, aMoveHome);
|
||||
BIND(KEY_END, aMoveEnd);
|
||||
BIND(' ', aPressSpace);
|
||||
BIND(KEY_ENTER, aPressEnter);
|
||||
BIND(KEY_DC, aDelete);
|
||||
BIND(KEY_RIGHT, aNextColumn);
|
||||
BIND(KEY_RIGHT, aSlaveScreen);
|
||||
BIND(KEY_RIGHT, aVolumeUp);
|
||||
BIND(KEY_LEFT, aPreviousColumn);
|
||||
BIND(KEY_LEFT, aMasterScreen);
|
||||
BIND(KEY_LEFT, aVolumeDown);
|
||||
BIND(KEY_TAB, aNextScreen);
|
||||
BIND(KEY_SHIFT_TAB, aPreviousScreen);
|
||||
BIND('1', aShowHelp);
|
||||
BIND('2', aShowPlaylist);
|
||||
BIND('3', aShowBrowser);
|
||||
BIND('4', aShowSearchEngine);
|
||||
BIND('5', aShowMediaLibrary);
|
||||
BIND('6', aShowPlaylistEditor);
|
||||
BIND('7', aShowTagEditor);
|
||||
BIND('8', aShowOutputs);
|
||||
BIND('9', aShowVisualizer);
|
||||
BIND('0', aShowClock);
|
||||
BIND('@', aShowServerInfo);
|
||||
BIND('s', aStop);
|
||||
BIND('P', aPause);
|
||||
BIND('>', aNextSong);
|
||||
BIND('<', aPreviousSong);
|
||||
BIND(KEY_CTRL_H, aJumpToParentDir);
|
||||
BIND(KEY_CTRL_H, aReplaySong);
|
||||
BIND(KEY_BACKSPACE, aJumpToParentDir);
|
||||
BIND(KEY_BACKSPACE, aReplaySong);
|
||||
BIND(KEY_BACKSPACE_2, aJumpToParentDir);
|
||||
BIND(KEY_BACKSPACE_2, aReplaySong);
|
||||
BIND('f', aSeekForward);
|
||||
BIND('b', aSeekBackward);
|
||||
BIND('r', aToggleRepeat);
|
||||
BIND('z', aToggleRandom);
|
||||
BIND('y', aSaveTagChanges);
|
||||
BIND('y', aStartSearching);
|
||||
BIND('y', aToggleSingle);
|
||||
BIND('R', aToggleConsume);
|
||||
BIND('Y', aToggleReplayGainMode);
|
||||
BIND('t', aToggleSpaceMode);
|
||||
BIND('T', aToggleAddMode);
|
||||
BIND('|', aToggleMouse);
|
||||
BIND('#', aToggleBitrateVisibility);
|
||||
BIND('Z', aShuffle);
|
||||
BIND('x', aToggleCrossfade);
|
||||
BIND('X', aSetCrossfade);
|
||||
BIND('u', aUpdateDatabase);
|
||||
BIND(KEY_CTRL_V, aSortPlaylist);
|
||||
BIND(KEY_CTRL_R, aReversePlaylist);
|
||||
BIND(KEY_CTRL_F, aApplyFilter);
|
||||
BIND(KEY_CTRL_G, aDisableFilter);
|
||||
BIND('/', aFind);
|
||||
BIND('/', aFindItemForward);
|
||||
BIND('?', aFind);
|
||||
BIND('?', aFindItemBackward);
|
||||
BIND('.', aNextFoundItem);
|
||||
BIND(',', aPreviousFoundItem);
|
||||
BIND('w', aToggleFindMode);
|
||||
BIND('e', aEditSong);
|
||||
BIND('e', aEditLibraryTag);
|
||||
BIND('e', aEditLibraryAlbum);
|
||||
BIND('e', aEditDirectoryName);
|
||||
BIND('e', aEditPlaylistName);
|
||||
BIND('e', aEditLyrics);
|
||||
BIND('i', aShowSongInfo);
|
||||
BIND('I', aShowArtistInfo);
|
||||
BIND('g', aJumpToPositionInSong);
|
||||
BIND('l', aShowLyrics);
|
||||
BIND('v', aReverseSelection);
|
||||
BIND('V', aDeselectItems);
|
||||
BIND('B', aSelectAlbum);
|
||||
BIND('a', aAddSelectedItems);
|
||||
BIND('c', aClearPlaylist);
|
||||
BIND('c', aClearMainPlaylist);
|
||||
BIND('C', aCropPlaylist);
|
||||
BIND('C', aCropMainPlaylist);
|
||||
BIND('m', aMoveSortOrderUp);
|
||||
BIND('m', aMoveSelectedItemsUp);
|
||||
BIND('n', aMoveSortOrderDown);
|
||||
BIND('n', aMoveSelectedItemsDown);
|
||||
BIND('M', aMoveSelectedItemsTo);
|
||||
BIND('A', aAdd);
|
||||
BIND('S', aSavePlaylist);
|
||||
BIND('o', aJumpToPlayingSong);
|
||||
BIND('G', aJumpToBrowser);
|
||||
BIND('G', aJumpToPlaylistEditor);
|
||||
BIND('~', aJumpToMediaLibrary);
|
||||
BIND('E', aJumpToTagEditor);
|
||||
BIND('U', aToggleAutoCenter);
|
||||
BIND('p', aToggleDisplayMode);
|
||||
BIND('\\', aToggleInterface);
|
||||
BIND('!', aToggleSeparatorsInPlaylist);
|
||||
BIND('L', aToggleLyricsFetcher);
|
||||
BIND('F', aToggleFetchingLyricsInBackground);
|
||||
BIND(KEY_CTRL_L, aToggleScreenLock);
|
||||
BIND('`', aToggleBrowserSortMode);
|
||||
BIND('`', aToggleLibraryTagType);
|
||||
BIND('`', aRefetchLyrics);
|
||||
BIND('`', aRefetchArtistInfo);
|
||||
BIND('`', aAddRandomItems);
|
||||
BIND(KEY_CTRL_P, aSetSelectedItemsPriority);
|
||||
BIND('q', aQuit);
|
||||
BIND(KEY_MOUSE, ctNCurses, aMouseEvent);
|
||||
BIND(KEY_UP, ctNCurses, aScrollUp);
|
||||
BIND(KEY_DOWN, ctNCurses, aScrollDown);
|
||||
BIND('[', ctStandard, aScrollUpAlbum);
|
||||
BIND(']', ctStandard, aScrollDownAlbum);
|
||||
BIND('{', ctStandard, aScrollUpArtist);
|
||||
BIND('}', ctStandard, aScrollDownArtist);
|
||||
BIND(KEY_PPAGE, ctNCurses, aPageUp);
|
||||
BIND(KEY_NPAGE, ctNCurses, aPageDown);
|
||||
BIND(KEY_HOME, ctNCurses, aMoveHome);
|
||||
BIND(KEY_END, ctNCurses, aMoveEnd);
|
||||
BIND(KEY_SPACE, ctStandard, aPressSpace);
|
||||
BIND(KEY_ENTER, ctStandard, aPressEnter);
|
||||
BIND(KEY_DC, ctNCurses, aDelete);
|
||||
BIND(KEY_RIGHT, ctNCurses, aNextColumn);
|
||||
BIND(KEY_RIGHT, ctNCurses, aSlaveScreen);
|
||||
BIND(KEY_RIGHT, ctNCurses, aVolumeUp);
|
||||
BIND(KEY_LEFT, ctNCurses, aPreviousColumn);
|
||||
BIND(KEY_LEFT, ctNCurses, aMasterScreen);
|
||||
BIND(KEY_LEFT, ctNCurses, aVolumeDown);
|
||||
BIND(KEY_TAB, ctStandard, aNextScreen);
|
||||
BIND(KEY_SHIFT_TAB, ctNCurses, aPreviousScreen);
|
||||
BIND('1', ctStandard, aShowHelp);
|
||||
BIND('2', ctStandard, aShowPlaylist);
|
||||
BIND('3', ctStandard, aShowBrowser);
|
||||
BIND('4', ctStandard, aShowSearchEngine);
|
||||
BIND('5', ctStandard, aShowMediaLibrary);
|
||||
BIND('6', ctStandard, aShowPlaylistEditor);
|
||||
BIND('7', ctStandard, aShowTagEditor);
|
||||
BIND('8', ctStandard, aShowOutputs);
|
||||
BIND('9', ctStandard, aShowVisualizer);
|
||||
BIND('0', ctStandard, aShowClock);
|
||||
BIND('@', ctStandard, aShowServerInfo);
|
||||
BIND('s', ctStandard, aStop);
|
||||
BIND('P', ctStandard, aPause);
|
||||
BIND('>', ctStandard, aNextSong);
|
||||
BIND('<', ctStandard, aPreviousSong);
|
||||
BIND(KEY_CTRL_H, ctStandard, aJumpToParentDir);
|
||||
BIND(KEY_CTRL_H, ctStandard, aReplaySong);
|
||||
BIND(KEY_BACKSPACE, ctNCurses, aJumpToParentDir);
|
||||
BIND(KEY_BACKSPACE, ctNCurses, aReplaySong);
|
||||
BIND(KEY_BACKSPACE_2, ctStandard, aJumpToParentDir);
|
||||
BIND(KEY_BACKSPACE_2, ctStandard, aReplaySong);
|
||||
BIND('f', ctStandard, aSeekForward);
|
||||
BIND('b', ctStandard, aSeekBackward);
|
||||
BIND('r', ctStandard, aToggleRepeat);
|
||||
BIND('z', ctStandard, aToggleRandom);
|
||||
BIND('y', ctStandard, aSaveTagChanges);
|
||||
BIND('y', ctStandard, aStartSearching);
|
||||
BIND('y', ctStandard, aToggleSingle);
|
||||
BIND('R', ctStandard, aToggleConsume);
|
||||
BIND('Y', ctStandard, aToggleReplayGainMode);
|
||||
BIND('t', ctStandard, aToggleSpaceMode);
|
||||
BIND('T', ctStandard, aToggleAddMode);
|
||||
BIND('|', ctStandard, aToggleMouse);
|
||||
BIND('#', ctStandard, aToggleBitrateVisibility);
|
||||
BIND('Z', ctStandard, aShuffle);
|
||||
BIND('x', ctStandard, aToggleCrossfade);
|
||||
BIND('X', ctStandard, aSetCrossfade);
|
||||
BIND('u', ctStandard, aUpdateDatabase);
|
||||
BIND(KEY_CTRL_V, ctStandard, aSortPlaylist);
|
||||
BIND(KEY_CTRL_R, ctStandard, aReversePlaylist);
|
||||
BIND(KEY_CTRL_F, ctStandard, aApplyFilter);
|
||||
BIND(KEY_CTRL_G, ctStandard, aDisableFilter);
|
||||
BIND('/', ctStandard, aFind);
|
||||
BIND('/', ctStandard, aFindItemForward);
|
||||
BIND('?', ctStandard, aFind);
|
||||
BIND('?', ctStandard, aFindItemBackward);
|
||||
BIND('.', ctStandard, aNextFoundItem);
|
||||
BIND(',', ctStandard, aPreviousFoundItem);
|
||||
BIND('w', ctStandard, aToggleFindMode);
|
||||
BIND('e', ctStandard, aEditSong);
|
||||
BIND('e', ctStandard, aEditLibraryTag);
|
||||
BIND('e', ctStandard, aEditLibraryAlbum);
|
||||
BIND('e', ctStandard, aEditDirectoryName);
|
||||
BIND('e', ctStandard, aEditPlaylistName);
|
||||
BIND('e', ctStandard, aEditLyrics);
|
||||
BIND('i', ctStandard, aShowSongInfo);
|
||||
BIND('I', ctStandard, aShowArtistInfo);
|
||||
BIND('g', ctStandard, aJumpToPositionInSong);
|
||||
BIND('l', ctStandard, aShowLyrics);
|
||||
BIND('v', ctStandard, aReverseSelection);
|
||||
BIND('V', ctStandard, aDeselectItems);
|
||||
BIND('B', ctStandard, aSelectAlbum);
|
||||
BIND('a', ctStandard, aAddSelectedItems);
|
||||
BIND('c', ctStandard, aClearPlaylist);
|
||||
BIND('c', ctStandard, aClearMainPlaylist);
|
||||
BIND('C', ctStandard, aCropPlaylist);
|
||||
BIND('C', ctStandard, aCropMainPlaylist);
|
||||
BIND('m', ctStandard, aMoveSortOrderUp);
|
||||
BIND('m', ctStandard, aMoveSelectedItemsUp);
|
||||
BIND('n', ctStandard, aMoveSortOrderDown);
|
||||
BIND('n', ctStandard, aMoveSelectedItemsDown);
|
||||
BIND('M', ctStandard, aMoveSelectedItemsTo);
|
||||
BIND('A', ctStandard, aAdd);
|
||||
BIND('S', ctStandard, aSavePlaylist);
|
||||
BIND('o', ctStandard, aJumpToPlayingSong);
|
||||
BIND('G', ctStandard, aJumpToBrowser);
|
||||
BIND('G', ctStandard, aJumpToPlaylistEditor);
|
||||
BIND('~', ctStandard, aJumpToMediaLibrary);
|
||||
BIND('E', ctStandard, aJumpToTagEditor);
|
||||
BIND('U', ctStandard, aToggleAutoCenter);
|
||||
BIND('p', ctStandard, aToggleDisplayMode);
|
||||
BIND('\\', ctStandard, aToggleInterface);
|
||||
BIND('!', ctStandard, aToggleSeparatorsInPlaylist);
|
||||
BIND('L', ctStandard, aToggleLyricsFetcher);
|
||||
BIND('F', ctStandard, aToggleFetchingLyricsInBackground);
|
||||
BIND(KEY_CTRL_L, ctStandard, aToggleScreenLock);
|
||||
BIND('`', ctStandard, aToggleBrowserSortMode);
|
||||
BIND('`', ctStandard, aToggleLibraryTagType);
|
||||
BIND('`', ctStandard, aRefetchLyrics);
|
||||
BIND('`', ctStandard, aRefetchArtistInfo);
|
||||
BIND('`', ctStandard, aAddRandomItems);
|
||||
BIND(KEY_CTRL_P, ctStandard, aSetSelectedItemsPriority);
|
||||
BIND('q', ctStandard, aQuit);
|
||||
|
||||
BIND('k', aScrollUp);
|
||||
BIND('j', aScrollDown);
|
||||
BIND('d', aDelete);
|
||||
BIND('+', aVolumeUp);
|
||||
BIND('-', aVolumeDown);
|
||||
BIND(KEY_F1, aShowHelp);
|
||||
BIND(KEY_F2, aShowPlaylist);
|
||||
BIND(KEY_F3, aShowBrowser);
|
||||
BIND(KEY_F4, aShowSearchEngine);
|
||||
BIND(KEY_F5, aShowMediaLibrary);
|
||||
BIND(KEY_F6, aShowPlaylistEditor);
|
||||
BIND(KEY_F7, aShowTagEditor);
|
||||
BIND(KEY_F8, aShowOutputs);
|
||||
BIND(KEY_F9, aShowVisualizer);
|
||||
BIND(KEY_F10, aShowClock);
|
||||
BIND('Q', aQuit);
|
||||
BIND('k', ctStandard, aScrollUp);
|
||||
BIND('j', ctStandard, aScrollDown);
|
||||
BIND('d', ctStandard, aDelete);
|
||||
BIND('+', ctStandard, aVolumeUp);
|
||||
BIND('-', ctStandard, aVolumeDown);
|
||||
BIND(KEY_F1, ctNCurses, aShowHelp);
|
||||
BIND(KEY_F2, ctNCurses, aShowPlaylist);
|
||||
BIND(KEY_F3, ctNCurses, aShowBrowser);
|
||||
BIND(KEY_F4, ctNCurses, aShowSearchEngine);
|
||||
BIND(KEY_F5, ctNCurses, aShowMediaLibrary);
|
||||
BIND(KEY_F6, ctNCurses, aShowPlaylistEditor);
|
||||
BIND(KEY_F7, ctNCurses, aShowTagEditor);
|
||||
BIND(KEY_F8, ctNCurses, aShowOutputs);
|
||||
BIND(KEY_F9, ctNCurses, aShowVisualizer);
|
||||
BIND(KEY_F10, ctNCurses, aShowClock);
|
||||
BIND('Q', ctStandard, aQuit);
|
||||
|
||||
# undef BIND
|
||||
}
|
||||
|
||||
void NcmpcppConfig::SetDefaults()
|
||||
void Configuration::SetDefaults()
|
||||
{
|
||||
mpd_host = "localhost";
|
||||
empty_tag = "<empty>";
|
||||
@@ -389,7 +389,7 @@ void NcmpcppConfig::SetDefaults()
|
||||
screens_seq.push_back(myBrowser);
|
||||
}
|
||||
|
||||
NcmpcppConfig::NcmpcppConfig()
|
||||
Configuration::Configuration()
|
||||
{
|
||||
# ifdef WIN32
|
||||
ncmpcpp_directory = GetHomeDirectory() + "ncmpcpp/";
|
||||
@@ -401,7 +401,7 @@ NcmpcppConfig::NcmpcppConfig()
|
||||
config_file_path = ncmpcpp_directory + "config";
|
||||
}
|
||||
|
||||
const std::string &NcmpcppConfig::GetHomeDirectory()
|
||||
const std::string &Configuration::GetHomeDirectory()
|
||||
{
|
||||
if (!home_directory.empty())
|
||||
return home_directory;
|
||||
@@ -419,7 +419,7 @@ const std::string &NcmpcppConfig::GetHomeDirectory()
|
||||
return home_directory;
|
||||
}
|
||||
|
||||
void NcmpcppConfig::CheckForCommandLineConfigFilePath(char **argv, int argc)
|
||||
void Configuration::CheckForCommandLineConfigFilePath(char **argv, int argc)
|
||||
{
|
||||
if (argc < 3)
|
||||
return;
|
||||
@@ -434,7 +434,7 @@ void NcmpcppConfig::CheckForCommandLineConfigFilePath(char **argv, int argc)
|
||||
}
|
||||
}
|
||||
|
||||
void NcmpcppConfig::Read()
|
||||
void Configuration::Read()
|
||||
{
|
||||
std::ifstream f(config_file_path.c_str());
|
||||
std::string cl, v, name;
|
||||
@@ -1075,7 +1075,7 @@ void NcmpcppConfig::Read()
|
||||
f.close();
|
||||
}
|
||||
|
||||
void NcmpcppConfig::GenerateColumns()
|
||||
void Configuration::GenerateColumns()
|
||||
{
|
||||
columns.clear();
|
||||
std::string width;
|
||||
@@ -1143,7 +1143,7 @@ void NcmpcppConfig::GenerateColumns()
|
||||
*song_in_columns_to_string_format.rbegin() = '}';
|
||||
}
|
||||
|
||||
void NcmpcppConfig::MakeProperPath(std::string &dir)
|
||||
void Configuration::MakeProperPath(std::string &dir)
|
||||
{
|
||||
if (dir.empty())
|
||||
return;
|
||||
|
||||
@@ -45,21 +45,21 @@ struct Column
|
||||
bool display_empty_tag;
|
||||
};
|
||||
|
||||
struct NcmpcppKeys
|
||||
struct KeyConfiguration
|
||||
{
|
||||
typedef std::pair<
|
||||
std::multimap<int, Action *>::iterator
|
||||
, std::multimap<int, Action *>::iterator
|
||||
std::multimap<Action::Key, Action *>::iterator
|
||||
, std::multimap<Action::Key, Action *>::iterator
|
||||
> Binding;
|
||||
|
||||
void GenerateKeybindings();
|
||||
void GenerateBindings();
|
||||
|
||||
std::multimap<int, Action *> Bindings;
|
||||
std::multimap<Action::Key, Action *> Bindings;
|
||||
};
|
||||
|
||||
struct NcmpcppConfig
|
||||
struct Configuration
|
||||
{
|
||||
NcmpcppConfig();
|
||||
Configuration();
|
||||
|
||||
const std::string &GetHomeDirectory();
|
||||
void CheckForCommandLineConfigFilePath(char **argv, int argc);
|
||||
@@ -208,8 +208,8 @@ struct NcmpcppConfig
|
||||
std::string config_file_path;
|
||||
};
|
||||
|
||||
extern NcmpcppKeys Key;
|
||||
extern NcmpcppConfig Config;
|
||||
extern KeyConfiguration Keys;
|
||||
extern Configuration Config;
|
||||
|
||||
void CreateDir(const std::string &dir);
|
||||
|
||||
|
||||
@@ -80,8 +80,9 @@
|
||||
#define KEY_F12 276
|
||||
|
||||
// other handy keys
|
||||
#define KEY_TAB 9
|
||||
#define KEY_SHIFT_TAB 353
|
||||
#define KEY_SPACE 32
|
||||
#define KEY_TAB 9
|
||||
|
||||
// define alternative KEY_BACKSPACE (used in some terminal emulators)
|
||||
#define KEY_BACKSPACE_2 127
|
||||
|
||||
Reference in New Issue
Block a user