fix drawing selected_item_{prefix,suffix}

This commit is contained in:
Andrzej Rybczak
2009-12-31 11:30:12 +01:00
parent 455f729bef
commit 444354f860
4 changed files with 6 additions and 2 deletions

View File

@@ -255,7 +255,7 @@ void Display::Songs(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)
String2Buffer(TO_WSTRING(line.substr(it-line.begin()+1)), buf); String2Buffer(TO_WSTRING(line.substr(it-line.begin()+1)), buf);
if (is_now_playing) if (is_now_playing)
buf << Config.now_playing_suffix; buf << Config.now_playing_suffix;
*menu << XY(menu->GetWidth()-buf.Str().length(), menu->Y()) << buf; *menu << XY(menu->GetWidth()-buf.Str().length()-(menu->isSelected(menu->CurrentlyDrawedPosition()) ? Config.selected_item_suffix_length : 0), menu->Y()) << buf;
return; return;
} }
else // not a color nor right align, just a random character else // not a color nor right align, just a random character

View File

@@ -742,9 +742,9 @@ template <typename T> void NCurses::Menu<T>::Refresh()
*this << fmtReverse; *this << fmtReverse;
*this << itsHighlightColor; *this << itsHighlightColor;
} }
mvwhline(itsWindow, line, 0, 32, itsWidth);
if ((*itsOptionsPtr)[i]->isSelected && itsSelectedPrefix) if ((*itsOptionsPtr)[i]->isSelected && itsSelectedPrefix)
*this << *itsSelectedPrefix; *this << *itsSelectedPrefix;
mvwhline(itsWindow, line, 0, 32, itsWidth);
if (itsItemDisplayer) if (itsItemDisplayer)
itsItemDisplayer((*itsOptionsPtr)[i]->Item, itsItemDisplayerUserdata, this); itsItemDisplayer((*itsOptionsPtr)[i]->Item, itsItemDisplayerUserdata, this);
if ((*itsOptionsPtr)[i]->isSelected && itsSelectedSuffix) if ((*itsOptionsPtr)[i]->isSelected && itsSelectedSuffix)

View File

@@ -333,6 +333,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
conf.lyrics_db = 0; conf.lyrics_db = 0;
conf.regex_type = 0; conf.regex_type = 0;
conf.lines_scrolled = 2; conf.lines_scrolled = 2;
conf.selected_item_suffix_length = 0;
# ifdef HAVE_LANGINFO_H # ifdef HAVE_LANGINFO_H
conf.system_encoding = nl_langinfo(CODESET); conf.system_encoding = nl_langinfo(CODESET);
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
@@ -688,6 +689,7 @@ void ReadConfiguration(ncmpcpp_config &conf)
{ {
conf.selected_item_suffix.Clear(); conf.selected_item_suffix.Clear();
String2Buffer(v, conf.selected_item_suffix); String2Buffer(v, conf.selected_item_suffix);
conf.selected_item_suffix_length = Window::Length(conf.selected_item_suffix.Str());
} }
} }
else if (cl.find("now_playing_prefix") != std::string::npos) else if (cl.find("now_playing_prefix") != std::string::npos)

View File

@@ -227,6 +227,8 @@ struct ncmpcpp_config
int regex_type; int regex_type;
unsigned lines_scrolled; unsigned lines_scrolled;
size_t selected_item_suffix_length;
}; };
extern ncmpcpp_config Config; extern ncmpcpp_config Config;