diff --git a/src/menu.h b/src/menu.h index b4448679..21638aea 100644 --- a/src/menu.h +++ b/src/menu.h @@ -171,11 +171,16 @@ int Menu::count_length(string str) for (int i = 0; i < str2.length(); i++, length++) { - if (str2[i] == '[') + if (str2[i] == '[' && (str2[i+1] == '.' || str2[i+1] == '/')) collect = 1; if (collect) - tmp += str2[i]; + { + if (str2[i] != '[') + tmp += str2[i]; + else + tmp = str2[i]; + } if (str2[i] == ']') collect = 0; @@ -423,17 +428,10 @@ void Menu::Refresh(bool redraw_whole_window) } } -# ifdef UTF8_ENABLED if (itsOptions[*it]->selected) - WriteXY(x, line, itsWidth, ToWString(itsSelectedPrefix + option + itsSelectedSuffix), 0); + WriteXY(x, line, itsWidth, TO_WSTRING(itsSelectedPrefix + option + itsSelectedSuffix), 0); else - WriteXY(x, line, itsWidth, ToWString(option), 0); -# else - if (itsOptions[*it]->selected) - WriteXY(x, line, itsWidth, itsSelectedPrefix + option + itsSelectedSuffix, 0); - else - WriteXY(x, line, itsWidth, option, 0); -# endif + WriteXY(x, line, itsWidth, TO_WSTRING(option), 0); if (!ch && (itsOptions[*it]->location == lCenter || itsOptions[*it]->location == lLeft)) { diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index f24d5b1e..327d7dea 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -173,6 +173,7 @@ int main(int argc, char *argv[]) main_height++; mPlaylist = new Menu(0, main_start_y, COLS, main_height, Config.columns_in_playlist ? DisplayColumns(Config.song_columns_list_format) : "", Config.main_color, brNone); + mPlaylist->AutoRefresh(0); mPlaylist->SetTimeout(ncmpcpp_window_timeout); mPlaylist->HighlightColor(Config.main_highlight_color); mPlaylist->SetSelectPrefix(Config.selected_item_prefix); @@ -368,8 +369,7 @@ int main(int argc, char *argv[]) if (current_screen == csPlaylist && !playlist_stats.empty()) wHeader->WriteXY(title.length(), 0, max_allowed_title_length-title.length(), playlist_stats); - - if (current_screen == csBrowser) + else if (current_screen == csBrowser) { int max_length_without_scroll = wHeader->GetWidth()-volume_state.length()-title.length(); my_string_t wbrowseddir = TO_WSTRING(browsed_dir); @@ -651,10 +651,12 @@ int main(int argc, char *argv[]) } if (redraw_screen && wCurrent == mEditorTagTypes && mEditorTagTypes->GetChoice() < 10) + { mEditorTags->Refresh(1); + redraw_screen = 0; + } else if (mEditorTagTypes->GetChoice() >= 10) mEditorTags->Window::Clear(); - redraw_screen = 0; } # endif // HAVE_TAGLIB_H // album editor end @@ -1277,9 +1279,6 @@ int main(int argc, char *argv[]) # ifdef HAVE_TAGLIB_H case csTagEditor: { - if (mEditorTags->Empty()) - break; - if (wCurrent == mEditorDirs) { TagList test; @@ -1296,6 +1295,9 @@ int main(int argc, char *argv[]) break; } + if (mEditorTags->Empty()) // we need songs to deal with, don't we? + break; + // if there are selected songs, perform operations only on them SongList list; if (mEditorTags->IsAnySelected()) diff --git a/src/status_checker.cpp b/src/status_checker.cpp index 10b5ce3f..41c57410 100644 --- a/src/status_checker.cpp +++ b/src/status_checker.cpp @@ -192,9 +192,6 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da } else { - // mPlaylist->BoldOption(old_playing+1, 0); - // mPlaylist->BoldOption(now_playing+1, 1); - Mpd->GetPlaylistChanges(-1, list); for (int i = 0; i < mPlaylist->Size(); i++) diff --git a/src/window.cpp b/src/window.cpp index bfc2d5bd..cfa0200e 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -629,7 +629,7 @@ char * ToString(const wchar_t *ws) string s; for (int i = 0; i < wcslen(ws); i++) { - char *c = (char *)calloc(MB_CUR_MAX, sizeof(char)); + char *c = new char[MB_CUR_MAX](); wctomb(c, ws[i]); s += c; delete [] c; @@ -640,7 +640,7 @@ char * ToString(const wchar_t *ws) wchar_t * ToWString(const char *s) { - wchar_t *ws = (wchar_t *)calloc(strlen(s)+1, sizeof(wchar_t)); + wchar_t *ws = new wchar_t[strlen(s)+1](); mbstowcs(ws, s, strlen(s)); return ws; } @@ -650,7 +650,7 @@ string ToString(const wstring &ws) string s; for (wstring::const_iterator it = ws.begin(); it != ws.end(); it++) { - char *c = (char *)calloc(MB_CUR_MAX, sizeof(char)); + char *c = new char[MB_CUR_MAX](); wctomb(c, *it); s += c; delete [] c; @@ -660,14 +660,13 @@ string ToString(const wstring &ws) wstring ToWString(const string &s) { - wchar_t *ws = (wchar_t *)calloc(s.length()+1, sizeof(wchar_t)); + wchar_t *ws = new wchar_t[s.length()+1](); mbstowcs(ws, s.c_str(), s.length()); wstring result = ws; delete [] ws; return result; } - string Window::OmitBBCodes(const string &str) { bool collect = false;