It produces a garbled mess but also does print the correct information.
It also doesn’t seem to output all of the files. If I specify a smaller directory with less files all files are included, however when I do my entire Music directory, around 2000 files it only shows a menu with 3 items. I know it successfully scans the files, it seems to be a problem with my ncurses code.
void init_song_menu(vector<Song>& songs){
int nsongs = (int) songs.size();
printw("%d",nsongs);
ITEM **items;
items = (ITEM **)calloc(nsongs,sizeof(ITEM *));
for(int i = 0; i < nsongs; ++i){
//printw(choice.c_str());
string* choice = new string;
choices.push_back(choice);
//*choice += songs.at(i).get_path();
*choice += songs.at(i).get_ID3().title;
items[i] = new_item(choice->c_str()," ");
}
WINDOW *mw = newwin(30,90,4,4);
LSTWINDOW* menu_win = (LSTWINDOW*) mw;
menu_opts_off(menu_win->menu,O_SHOWDESC);
menu_win->menu = new_menu((ITEM **)items);
set_menu_win(menu_win->menu,mw);
set_menu_sub(menu_win->menu,derwin(menu_win,26,88,3,1));
set_menu_format(menu_win->menu,10,1);
set_menu_mark(menu_win->menu,"*");
wlist.push_back(menu_win);
focused = menu_win;
}
The list of items must be NULL terminated. That is, you must allocate nsongs+1 and then set the last item to NULL: