我想在我的 ncurses 菜单中将字符串链接到以下内容:
/bin
/hello
/home
...
而且我有命名的组件向量,这些组件w_files
具有变量name
(bin,hello,home,...),当我这样做时:
chdir(w_actDir.c_str());
this->selected = 0;
unsigned int n_choices = w_files.size();
my_items = (ITEM **)calloc(n_choices+1, sizeof(ITEM *));
for(unsigned int i = 0; i < n_choices; ++i){
string toShow = w_files[i]->getName();
my_items[i] = new_item(toShow.c_str(), "");
}
my_menu = new_menu((ITEM**)my_items);
set_menu_mark(my_menu, "");
set_menu_win(my_menu, this->w_window);
set_menu_format(my_menu, LINES-5, 1);
int center = COLS/2;
set_menu_sub(my_menu, derwin(this->w_window, LINES-5, center-5, 3, 1));
post_menu(my_menu);
wrefresh(this->w_window);
没关系,结果看起来:
bin
hello
home
...
string toShow = w_files[i]->getName();
但是当换行时string toShow = "/" + w_files[i]->getName();
结果是:
有人可以帮我吗?谢谢你。