make taglib optional + more colors to define + other improvements

This commit is contained in:
unknown
2008-08-07 08:30:03 +02:00
parent c7672f1779
commit 12946d6bdd
12 changed files with 155 additions and 60 deletions

View File

@@ -1,14 +1,14 @@
AC_INIT(configure.in) AC_INIT(configure.in)
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(ncmpcpp, 0.1) AM_INIT_AUTOMAKE(ncmpcpp, 0.1.1)
AC_LANG_CPLUSPLUS AC_LANG_CPLUSPLUS
AC_PROG_CXX AC_PROG_CXX
AM_PROG_LIBTOOL AM_PROG_LIBTOOL
AC_ARG_ENABLE(unicode,[ --enable-unicode Enable utf8 support ], [unicode=$enableval], [unicode=yes]) AC_ARG_ENABLE(unicode, AS_HELP_STRING([--enable-unicode], [Enable utf8 support]), [unicode=$enableval], [unicode=yes])
AC_ARG_WITH(taglib, AS_HELP_STRING([--with-taglib], [Enable tag editor]), [taglib=$withval], [taglib=yes])
dnl ======================== dnl ========================
dnl = checking for ncurses = dnl = checking for ncurses =
@@ -49,13 +49,15 @@ AC_CHECK_HEADERS([libmpd/libmpd.h], , AC_MSG_ERROR([missing libmpd.h header]))
dnl ======================= dnl =======================
dnl = checking for taglib = dnl = checking for taglib =
dnl ======================= dnl =======================
AC_PATH_PROG(TAGLIB_CONFIG, taglib-config) if test "$taglib" = "yes" ; then
if test "$TAGLIB_CONFIG" != "" ; then AC_PATH_PROG(TAGLIB_CONFIG, taglib-config)
CPPFLAGS="$CPPFLAGS `$TAGLIB_CONFIG --cflags`" if test "$TAGLIB_CONFIG" != "" ; then
PKG_CHECK_MODULES([taglib], taglib, LDFLAGS="$LDFLAGS `$TAGLIB_CONFIG --libs`", AC_MSG_ERROR([taglib library is required])) CPPFLAGS="$CPPFLAGS `$TAGLIB_CONFIG --cflags`"
AC_CHECK_HEADERS([taglib.h], , AC_MSG_ERROR([missing taglib.h header])) PKG_CHECK_MODULES([taglib], taglib, LDFLAGS="$LDFLAGS `$TAGLIB_CONFIG --libs`", AC_MSG_ERROR([taglib library is required]))
else AC_CHECK_HEADERS([taglib.h], , AC_MSG_ERROR([missing taglib.h header]))
AC_MSG_ERROR([taglib-config executable is missing]) else
AC_MSG_ERROR([taglib-config executable is missing])
fi
fi fi

View File

@@ -1,4 +1,9 @@
### ncmpc++ config file ### ###########################################################
## this is example configuration file, copy it to your ##
## home folder as .ncmpcpprc and set up your preferences ##
###########################################################
#
##### connection settings #####
# #
## set it in order to make tag editor work ## set it in order to make tag editor work
# #
@@ -8,6 +13,8 @@
# #
#mpd_crossfade_time = "5" #mpd_crossfade_time = "5"
# #
##### delays #####
#
## delay after playlist highlighting will be disabled (0 = don't disable) ## delay after playlist highlighting will be disabled (0 = don't disable)
# #
#playlist_disable_highlight_delay = "5" #playlist_disable_highlight_delay = "5"
@@ -16,6 +23,8 @@
# #
#message_delay_time = "4" #message_delay_time = "4"
# #
##### song format #####
##
## for song format you can use: ## for song format you can use:
## ##
## %l - length ## %l - length
@@ -52,21 +61,27 @@
# #
#song_status_format = "(%l) {%a - }{%t}|{%f}" #song_status_format = "(%l) {%a - }{%t}|{%f}"
# #
## window title settings ##### window title settings #####
# #
#enable_window_title = "yes" #enable_window_title = "yes"
# #
#song_window_title_format = "{%a - }{%t}|{%f}" #song_window_title_format = "{%a - }{%t}|{%f}"
# #
## colors definitions ##### colors definitions #####
# #
#empty_tag_color = "cyan" #empty_tag_color = "cyan"
# #
#header_window_color = "default" #header_window_color = "default"
# #
#volume_color = "default"
#
#state_line_color = "default"
#
#state_flags_color = "default"
#
#main_window_color = "yellow" #main_window_color = "yellow"
# #
#progressbar_color = "default" #progressbar_color = "default"
# #
#statusbar_color = "default" #statusbar_color = "default"
#

View File

@@ -116,7 +116,15 @@ string DisplaySong(const Song &s, const string &song_template)
{ {
case 'l': case 'l':
{ {
result += s.GetLength(); if (link_tags)
{
if (s.GetTotalLength() > 0)
result += s.GetLength();
else
tags_present = 0;
}
else
result += s.GetLength();
break; break;
} }
case 'F': case 'F':
@@ -388,23 +396,26 @@ bool GetSongInfo(Song &s)
string path_to_file = Config.mpd_music_dir + "/" + s.GetFile(); string path_to_file = Config.mpd_music_dir + "/" + s.GetFile();
# ifdef HAVE_TAGLIB_H
TagLib::FileRef f(path_to_file.c_str()); TagLib::FileRef f(path_to_file.c_str());
if (f.isNull()) if (f.isNull())
return false; return false;
s.SetComment(f.tag()->comment().to8Bit(UNICODE)); s.SetComment(f.tag()->comment().to8Bit(UNICODE));
# endif
mTagEditor->AddStaticOption("[b][white]Song name: [green][/b]" + s.GetShortFilename()); mTagEditor->AddStaticOption("[b][white]Song name: [green][/b]" + s.GetShortFilename());
mTagEditor->AddStaticOption("[b][white]Location in DB: [green][/b]" + s.GetDirectory()); mTagEditor->AddStaticOption("[b][white]Location in DB: [green][/b]" + s.GetDirectory());
mTagEditor->AddStaticOption(""); mTagEditor->AddStaticOption("");
mTagEditor->AddStaticOption("[b][white]Length: [green][/b]" + s.GetLength()); mTagEditor->AddStaticOption("[b][white]Length: [green][/b]" + s.GetLength() + "[/green]");
# ifdef HAVE_TAGLIB_H
mTagEditor->AddStaticOption("[b][white]Bitrate: [green][/b]" + IntoStr(f.audioProperties()->bitrate()) + " kbps"); mTagEditor->AddStaticOption("[b][white]Bitrate: [green][/b]" + IntoStr(f.audioProperties()->bitrate()) + " kbps");
mTagEditor->AddStaticOption("[b][white]Sample rate: [green][/b]" + IntoStr(f.audioProperties()->sampleRate()) + " Hz"); mTagEditor->AddStaticOption("[b][white]Sample rate: [green][/b]" + IntoStr(f.audioProperties()->sampleRate()) + " Hz");
mTagEditor->AddStaticOption("[b][white]Channels: [green][/b]" + (string)(f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") + "[/green]"); mTagEditor->AddStaticOption("[b][white]Channels: [green][/b]" + (string)(f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") + "[/green]");
# endif
mTagEditor->AddSeparator(); mTagEditor->AddSeparator();
# ifdef HAVE_TAGLIB_H
mTagEditor->AddOption("[b]Title:[/b] " + s.GetTitle()); mTagEditor->AddOption("[b]Title:[/b] " + s.GetTitle());
mTagEditor->AddOption("[b]Artist:[/b] " + s.GetArtist()); mTagEditor->AddOption("[b]Artist:[/b] " + s.GetArtist());
mTagEditor->AddOption("[b]Album:[/b] " + s.GetAlbum()); mTagEditor->AddOption("[b]Album:[/b] " + s.GetAlbum());
@@ -415,6 +426,17 @@ bool GetSongInfo(Song &s)
mTagEditor->AddSeparator(); mTagEditor->AddSeparator();
mTagEditor->AddOption("Save"); mTagEditor->AddOption("Save");
mTagEditor->AddOption("Cancel"); mTagEditor->AddOption("Cancel");
# else
mTagEditor->AddStaticOption("[b]Title:[/b] " + s.GetTitle());
mTagEditor->AddStaticOption("[b]Artist:[/b] " + s.GetArtist());
mTagEditor->AddStaticOption("[b]Album:[/b] " + s.GetAlbum());
mTagEditor->AddStaticOption("[b]Year:[/b] " + s.GetYear());
mTagEditor->AddStaticOption("[b]Track:[/b] " + s.GetTrack());
mTagEditor->AddStaticOption("[b]Genre:[/b] " + s.GetGenre());
mTagEditor->AddStaticOption("[b]Comment:[/b] " + s.GetComment());
mTagEditor->AddSeparator();
mTagEditor->AddOption("Back");
# endif
edited_song = s; edited_song = s;
return true; return true;

View File

@@ -379,8 +379,9 @@ void Menu::Highlight(int which)
{ {
if (which <= itsOptions.size()) if (which <= itsOptions.size())
itsHighlight = which-1; itsHighlight = which-1;
if (which > itsHeight) if (which > itsHeight)
itsBeginning = which-itsHeight; itsBeginning = which-itsHeight/2;
else else
itsBeginning = 0; itsBeginning = 0;
} }

View File

@@ -18,10 +18,6 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "ncmpcpp.h" #include "ncmpcpp.h"
#include "status_checker.h" #include "status_checker.h"
#include "helpers.h" #include "helpers.h"
@@ -32,12 +28,18 @@
#define BLOCK_STATUSBAR_UPDATE \ #define BLOCK_STATUSBAR_UPDATE \
block_statusbar_update = 1; \ block_statusbar_update = 1; \
allow_statusbar_unblock = 0; allow_statusbar_unblock = 0
#define UNBLOCK_STATUSBAR_UPDATE \ #define UNBLOCK_STATUSBAR_UPDATE \
allow_statusbar_unblock = 1; \ allow_statusbar_unblock = 1; \
if (block_statusbar_update_delay < 0) \ if (block_statusbar_update_delay < 0) \
block_statusbar_update = 0; block_statusbar_update = 0
#ifdef HAVE_TAGLIB_H
const string tag_screen_keydesc = "\tE e : Edit song's tags\n";
#else
const string tag_screen_keydesc = "\tE e : Show song's tags\n";
#endif
char *MPD_HOST = getenv("MPD_HOST"); char *MPD_HOST = getenv("MPD_HOST");
int MPD_PORT = getenv("MPD_PORT") ? atoi(getenv("MPD_PORT")) : 6600; int MPD_PORT = getenv("MPD_PORT") ? atoi(getenv("MPD_PORT")) : 6600;
@@ -182,19 +184,19 @@ int main(int argc, char *argv[])
sHelp->Add("\tm : Move song up\n"); sHelp->Add("\tm : Move song up\n");
sHelp->Add("\tn : Move song down\n"); sHelp->Add("\tn : Move song down\n");
sHelp->Add("\tS : Save playlist\n"); sHelp->Add("\tS : Save playlist\n");
sHelp->Add("\tE e : Edit song's tags\n"); sHelp->Add(tag_screen_keydesc);
sHelp->Add("\to : Go to currently playing position\n\n\n"); sHelp->Add("\to : Go to currently playing position\n\n\n");
sHelp->Add(" [b]Keys - Browse screen\n -----------------------------------------[/b]\n"); sHelp->Add(" [b]Keys - Browse screen\n -----------------------------------------[/b]\n");
sHelp->Add("\tEnter : Enter directory/Select and play song\n"); sHelp->Add("\tEnter : Enter directory/Select and play song\n");
sHelp->Add("\tSpace : Add song to playlist\n"); sHelp->Add("\tSpace : Add song to playlist\n");
sHelp->Add("\tDelete : Delete playlist\n"); sHelp->Add("\tDelete : Delete playlist\n");
sHelp->Add("\tE e : Edit song's tags\n\n\n"); sHelp->Add(tag_screen_keydesc + "\n\n");
sHelp->Add(" [b]Keys - Search engine\n -----------------------------------------[/b]\n"); sHelp->Add(" [b]Keys - Search engine\n -----------------------------------------[/b]\n");
sHelp->Add("\tEnter : Change option/Select and play song\n"); sHelp->Add("\tEnter : Change option/Select and play song\n");
sHelp->Add("\tSpace : Add song to playlist\n"); sHelp->Add("\tSpace : Add song to playlist\n");
sHelp->Add("\tE e : Edit song's tags\n\n\n"); sHelp->Add(tag_screen_keydesc + "\n\n");
sHelp->Add(" [b]Keys - Tag Editor\n -----------------------------------------[/b]\n"); sHelp->Add(" [b]Keys - Tag Editor\n -----------------------------------------[/b]\n");
sHelp->Add("\tEnter : Change option\n"); sHelp->Add("\tEnter : Change option\n");
@@ -251,7 +253,11 @@ int main(int argc, char *argv[])
title = "Browse: "; title = "Browse: ";
break; break;
case csTagEditor: case csTagEditor:
# ifdef HAVE_TAGLIB_H
title = "Tag editor"; title = "Tag editor";
# else
title = "Tag info";
# endif
break; break;
case csSearcher: case csSearcher:
title = "Search engine"; title = "Search engine";
@@ -266,7 +272,9 @@ int main(int argc, char *argv[])
else else
wHeader->WriteXY(0, 0, "[b]1:[/b]Help [b]2:[/b]Playlist [b]3:[/b]Browse [b]4:[/b]Search", 1); wHeader->WriteXY(0, 0, "[b]1:[/b]Help [b]2:[/b]Playlist [b]3:[/b]Browse [b]4:[/b]Search", 1);
wHeader->SetColor(Config.volume_color);
wHeader->WriteXY(max_allowed_title_length, 0, volume_state); wHeader->WriteXY(max_allowed_title_length, 0, volume_state);
wHeader->SetColor(Config.header_color);
if (current_screen == csBrowser) if (current_screen == csBrowser)
{ {
@@ -446,9 +454,10 @@ int main(int argc, char *argv[])
} }
case csTagEditor: case csTagEditor:
{ {
# ifdef HAVE_TAGLIB_H
int id = mTagEditor->GetRealChoice(); int id = mTagEditor->GetRealChoice();
int option = mTagEditor->GetChoice(); int option = mTagEditor->GetChoice();
BLOCK_STATUSBAR_UPDATE BLOCK_STATUSBAR_UPDATE;
Song &s = edited_song; Song &s = edited_song;
switch (id) switch (id)
@@ -558,14 +567,19 @@ int main(int argc, char *argv[])
break; break;
} }
} }
UNBLOCK_STATUSBAR_UPDATE UNBLOCK_STATUSBAR_UPDATE;
# else
wCurrent->Clear();
wCurrent = wPrev;
current_screen = prev_screen;
# endif // HAVE_TAGLIB_H
break; break;
} }
case csSearcher: case csSearcher:
{ {
int id = mSearcher->GetChoice(); int id = mSearcher->GetChoice();
int option = mSearcher->GetChoice(); int option = mSearcher->GetChoice();
BLOCK_STATUSBAR_UPDATE BLOCK_STATUSBAR_UPDATE;
Song &s = searched_song; Song &s = searched_song;
switch (id) switch (id)
@@ -718,7 +732,7 @@ int main(int argc, char *argv[])
break; break;
} }
} }
UNBLOCK_STATUSBAR_UPDATE UNBLOCK_STATUSBAR_UPDATE;
break; break;
} }
} }
@@ -832,7 +846,7 @@ int main(int argc, char *argv[])
} }
if (current_screen == csBrowser) if (current_screen == csBrowser)
{ {
BLOCK_STATUSBAR_UPDATE BLOCK_STATUSBAR_UPDATE;
int id = mBrowser->GetChoice()-1; int id = mBrowser->GetChoice()-1;
if (vFileType[id] == MPD_DATA_TYPE_PLAYLIST) if (vFileType[id] == MPD_DATA_TYPE_PLAYLIST)
{ {
@@ -856,7 +870,7 @@ int main(int argc, char *argv[])
else else
ShowMessage("Aborted!"); ShowMessage("Aborted!");
curs_set(0); curs_set(0);
UNBLOCK_STATUSBAR_UPDATE UNBLOCK_STATUSBAR_UPDATE;
} }
} }
break; break;
@@ -879,10 +893,10 @@ int main(int argc, char *argv[])
case 'S': // save playlist case 'S': // save playlist
{ {
string playlist_name; string playlist_name;
BLOCK_STATUSBAR_UPDATE BLOCK_STATUSBAR_UPDATE;
wFooter->WriteXY(0, 1, "Save playlist as: ", 1); wFooter->WriteXY(0, 1, "Save playlist as: ", 1);
playlist_name = wFooter->GetString("", TraceMpdStatus); playlist_name = wFooter->GetString("", TraceMpdStatus);
UNBLOCK_STATUSBAR_UPDATE UNBLOCK_STATUSBAR_UPDATE;
if (playlist_name.find("/") != string::npos) if (playlist_name.find("/") != string::npos)
{ {
ShowMessage("Playlist name cannot contain slashes!"); ShowMessage("Playlist name cannot contain slashes!");
@@ -935,7 +949,7 @@ int main(int argc, char *argv[])
break; break;
block_progressbar_update = 1; block_progressbar_update = 1;
BLOCK_STATUSBAR_UPDATE BLOCK_STATUSBAR_UPDATE;
int songpos, in; int songpos, in;
@@ -974,7 +988,7 @@ int main(int argc, char *argv[])
mpd_player_seek(conn, songpos); mpd_player_seek(conn, songpos);
block_progressbar_update = 0; block_progressbar_update = 0;
UNBLOCK_STATUSBAR_UPDATE UNBLOCK_STATUSBAR_UPDATE;
break; break;
} }
@@ -1074,13 +1088,13 @@ int main(int argc, char *argv[])
break; break;
int newpos = 0; int newpos = 0;
string position; string position;
BLOCK_STATUSBAR_UPDATE BLOCK_STATUSBAR_UPDATE;
wFooter->WriteXY(0, 1, "Position to go (in %): ", 1); wFooter->WriteXY(0, 1, "Position to go (in %): ", 1);
position = wFooter->GetString(3, TraceMpdStatus); position = wFooter->GetString(3, TraceMpdStatus);
newpos = atoi(position.c_str()); newpos = atoi(position.c_str());
if (newpos > 0 && newpos < 100 && !position.empty()) if (newpos > 0 && newpos < 100 && !position.empty())
mpd_player_seek(conn, vPlaylist[now_playing].GetTotalLength()*newpos/100.0); mpd_player_seek(conn, vPlaylist[now_playing].GetTotalLength()*newpos/100.0);
UNBLOCK_STATUSBAR_UPDATE UNBLOCK_STATUSBAR_UPDATE;
break; break;
} }
case 'c': // clear playlist case 'c': // clear playlist

View File

@@ -21,6 +21,10 @@
#ifndef HAVE_NCMPCPP_H #ifndef HAVE_NCMPCPP_H
#define HAVE_NCMPCPP_H #define HAVE_NCMPCPP_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef UTF8_ENABLED #ifdef UTF8_ENABLED
const bool UNICODE = 1; const bool UNICODE = 1;
# define ncmpcpp_string_t wstring # define ncmpcpp_string_t wstring
@@ -31,13 +35,14 @@ const bool UNICODE = 0;
# define NCMPCPP_TO_WSTRING(x) (x) # define NCMPCPP_TO_WSTRING(x) (x)
#endif #endif
#define NCMPCPP_VERSION "0.1"
#define ENTER 10 #define ENTER 10
#define KEY_SPACE 32 #define KEY_SPACE 32
#include "fileref.h" #ifdef HAVE_TAGLIB_H
#include "tag.h" # include "fileref.h"
# include "tag.h"
#endif
#include "libmpd/libmpd.h" #include "libmpd/libmpd.h"
#include <clocale> #include <clocale>

View File

@@ -39,12 +39,6 @@ void Scrollpad::Add(string str)
int space_pos = 0; int space_pos = 0;
bool collect = 0; bool collect = 0;
// no idea why does it work, but it prevents text from going out of the window
// ugly hack, but i didn't come up with anything better
/*if (!itsContent.empty())
for (int i = itsContent.length()-1; itsContent[i] != '\0' && i >= 0; i--)
x++;*/
for (size_t i = 0; i <= s.length(); i++, itsXPos++) for (size_t i = 0; i <= s.length(); i++, itsXPos++)
{ {
if (BBEnabled) if (BBEnabled)

View File

@@ -28,10 +28,13 @@ void DefaultConfiguration(ncmpcpp_config &conf)
{ {
conf.mpd_music_dir = "/var/lib/mpd/music"; conf.mpd_music_dir = "/var/lib/mpd/music";
conf.song_list_format = "[green](%l)[/green] {%a - }{%t}|{[white]%f[/white]}"; conf.song_list_format = "[green](%l)[/green] {%a - }{%t}|{[white]%f[/white]}";
conf.song_status_format = conf.song_list_format; conf.song_status_format = "(%l) {%a - }{%t}|{%f}";
conf.song_window_title_format = "{%a - }{%t}|{%f}"; conf.song_window_title_format = "{%a - }{%t}|{%f}";
conf.empty_tags_color = clCyan; conf.empty_tags_color = clCyan;
conf.header_color = clDefault; conf.header_color = clDefault;
conf.volume_color = clDefault;
conf.state_line_color = clDefault;
conf.state_flags_color = clDefault;
conf.main_color = clYellow; conf.main_color = clYellow;
conf.progressbar_color = clDefault; conf.progressbar_color = clDefault;
conf.statusbar_color = clDefault; conf.statusbar_color = clDefault;
@@ -173,6 +176,18 @@ void ReadConfiguration(ncmpcpp_config &conf)
if (!v.empty()) if (!v.empty())
conf.header_color = IntoColor(v); conf.header_color = IntoColor(v);
if (it->find("volume_color") != string::npos)
if (!v.empty())
conf.volume_color = IntoColor(v);
if (it->find("state_line_color") != string::npos)
if (!v.empty())
conf.state_line_color = IntoColor(v);
if (it->find("state_flags_color") != string::npos)
if (!v.empty())
conf.state_flags_color = IntoColor(v);
if (it->find("main_window_color") != string::npos) if (it->find("main_window_color") != string::npos)
if (!v.empty()) if (!v.empty())
conf.main_color = IntoColor(v); conf.main_color = IntoColor(v);
@@ -185,6 +200,7 @@ void ReadConfiguration(ncmpcpp_config &conf)
if (!v.empty()) if (!v.empty())
conf.statusbar_color = IntoColor(v); conf.statusbar_color = IntoColor(v);
} }
f.close();
} }
} }

View File

@@ -36,6 +36,9 @@ struct ncmpcpp_config
COLOR empty_tags_color; COLOR empty_tags_color;
COLOR header_color; COLOR header_color;
COLOR volume_color;
COLOR state_line_color;
COLOR state_flags_color;
COLOR main_color; COLOR main_color;
COLOR progressbar_color; COLOR progressbar_color;
COLOR statusbar_color; COLOR statusbar_color;

View File

@@ -116,6 +116,7 @@ void NcmpcppStatusChanged(MpdObj *conn, ChangedStatusType what)
{ {
int sx, sy; int sx, sy;
wFooter->DisableBB(); wFooter->DisableBB();
wFooter->AutoRefresh(0);
wFooter->Bold(1); wFooter->Bold(1);
wFooter->GetXY(sx, sy); wFooter->GetXY(sx, sy);
@@ -242,7 +243,7 @@ void NcmpcppStatusChanged(MpdObj *conn, ChangedStatusType what)
} }
case MPD_PLAYER_STOP: case MPD_PLAYER_STOP:
{ {
WindowTitle("ncmpc++ ver. "NCMPCPP_VERSION); WindowTitle("ncmpc++ ver. "VERSION);
wFooter->SetColor(Config.progressbar_color); wFooter->SetColor(Config.progressbar_color);
mvwhline(wFooter->RawWin(), 0, 0, 0, wFooter->GetWidth()); mvwhline(wFooter->RawWin(), 0, 0, 0, wFooter->GetWidth());
wFooter->SetColor(Config.statusbar_color); wFooter->SetColor(Config.statusbar_color);
@@ -266,7 +267,11 @@ void NcmpcppStatusChanged(MpdObj *conn, ChangedStatusType what)
if (!block_statusbar_update) if (!block_statusbar_update)
{ {
string tracklength = " [" + ShowTime(elapsed) + "/" + s.GetLength() + "]"; string tracklength;
if (s.GetTotalLength() > 0)
tracklength = " [" + ShowTime(elapsed) + "/" + s.GetLength() + "]";
else
tracklength = " [" + ShowTime(elapsed) + "]";
ncmpcpp_string_t playing_song = NCMPCPP_TO_WSTRING(OmitBBCodes(DisplaySong(s, Config.song_status_format))); ncmpcpp_string_t playing_song = NCMPCPP_TO_WSTRING(OmitBBCodes(DisplaySong(s, Config.song_status_format)));
int max_length_without_scroll = wFooter->GetWidth()-player_state.length()-tracklength.length(); int max_length_without_scroll = wFooter->GetWidth()-player_state.length()-tracklength.length();
@@ -343,10 +348,18 @@ void NcmpcppStatusChanged(MpdObj *conn, ChangedStatusType what)
wHeader->DisableBB(); wHeader->DisableBB();
wHeader->Bold(1); wHeader->Bold(1);
wHeader->SetColor(Config.state_line_color);
mvwhline(wHeader->RawWin(), 1, 0, 0, wHeader->GetWidth()); mvwhline(wHeader->RawWin(), 1, 0, 0, wHeader->GetWidth());
if (!switch_state.empty()) if (!switch_state.empty())
wHeader->WriteXY(wHeader->GetWidth()-switch_state.length()-3, 1, "[" + switch_state + "]"); {
wHeader->WriteXY(wHeader->GetWidth()-switch_state.length()-3, 1, "[");
wHeader->SetColor(Config.state_flags_color);
wHeader->WriteXY(wHeader->GetWidth()-switch_state.length()-2, 1, switch_state);
wHeader->SetColor(Config.state_line_color);
wHeader->WriteXY(wHeader->GetWidth()-2, 1, "]");
}
wHeader->Refresh(); wHeader->Refresh();
wHeader->SetColor(Config.header_color);
wHeader->Bold(0); wHeader->Bold(0);
wHeader->EnableBB(); wHeader->EnableBB();
header_update_status = 0; header_update_status = 0;
@@ -372,11 +385,14 @@ void NcmpcppStatusChanged(MpdObj *conn, ChangedStatusType what)
{ {
int vol = mpd_status_get_volume(conn); int vol = mpd_status_get_volume(conn);
volume_state = " Volume: " + IntoStr(vol) + "%"; volume_state = " Volume: " + IntoStr(vol) + "%";
wHeader->SetColor(Config.volume_color);
wHeader->WriteXY(wHeader->GetWidth()-volume_state.length(), 0, volume_state); wHeader->WriteXY(wHeader->GetWidth()-volume_state.length(), 0, volume_state);
wHeader->SetColor(Config.header_color);
} }
wFooter->Bold(0); wFooter->Bold(0);
wFooter->GotoXY(sx, sy); wFooter->GotoXY(sx, sy);
wFooter->Refresh(); wFooter->Refresh();
wFooter->AutoRefresh(1);
wFooter->EnableBB(); wFooter->EnableBB();
} }

View File

@@ -20,7 +20,7 @@
#include "window.h" #include "window.h"
Window::Window(int startx, int starty, int width, int height, string title, COLOR color, BORDER border) : itsWindow(0), itsWinBorder(0), itsStartX(startx), itsStartY(starty), itsWidth(width), itsHeight(height), BBEnabled(1), itsTitle(title), itsColor(color), itsBaseColor(color), itsBgColor(clDefault), itsBaseBgColor(clDefault), itsBorder(border) Window::Window(int startx, int starty, int width, int height, string title, COLOR color, BORDER border) : itsWindow(0), itsWinBorder(0), itsStartX(startx), itsStartY(starty), itsWidth(width), itsHeight(height), BBEnabled(1), AutoRefreshEnabled(1), itsTitle(title), itsColor(color), itsBaseColor(color), itsBgColor(clDefault), itsBaseBgColor(clDefault), itsBorder(border)
{ {
if (itsStartX < 0) itsStartX = 0; if (itsStartX < 0) itsStartX = 0;
if (itsStartY < 0) itsStartY = 0; if (itsStartY < 0) itsStartY = 0;
@@ -308,8 +308,10 @@ void Window::Write(const string &str, CLEAR_TO_EOL clrtoeol)
else else
waddstr(itsWindow,str.c_str()); waddstr(itsWindow,str.c_str());
if (clrtoeol) wclrtoeol(itsWindow); if (clrtoeol)
wrefresh(itsWindow); wclrtoeol(itsWindow);
if (AutoRefreshEnabled)
wrefresh(itsWindow);
} }
#ifdef UTF8_ENABLED #ifdef UTF8_ENABLED
@@ -359,8 +361,11 @@ void Window::Write(const wstring &str, CLEAR_TO_EOL clrtoeol)
} }
else else
waddwstr(itsWindow,str.c_str()); waddwstr(itsWindow,str.c_str());
if (clrtoeol) wclrtoeol(itsWindow);
wrefresh(itsWindow); if (clrtoeol)
wclrtoeol(itsWindow);
if (AutoRefreshEnabled)
wrefresh(itsWindow);
} }
void Window::WriteXY(int x, int y, const wstring &str, CLEAR_TO_EOL cleartoeol) void Window::WriteXY(int x, int y, const wstring &str, CLEAR_TO_EOL cleartoeol)

View File

@@ -77,6 +77,7 @@ class Window
virtual void AltCharset(bool) const; virtual void AltCharset(bool) const;
virtual void Delay(bool) const; virtual void Delay(bool) const;
virtual void Timeout(int) const; virtual void Timeout(int) const;
virtual void AutoRefresh(bool val) { AutoRefreshEnabled = val; }
virtual void ReadKey(int &) const; virtual void ReadKey(int &) const;
virtual void ReadKey() const; virtual void ReadKey() const;
virtual void Write(const string &, CLEAR_TO_EOL = 1); virtual void Write(const string &, CLEAR_TO_EOL = 1);
@@ -117,6 +118,7 @@ class Window
int itsWidth; int itsWidth;
int itsHeight; int itsHeight;
bool BBEnabled; bool BBEnabled;
bool AutoRefreshEnabled;
string itsTitle; string itsTitle;
COLOR itsColor; COLOR itsColor;
COLOR itsBaseColor; COLOR itsBaseColor;