本文整理汇总了C++中current_item函数的典型用法代码示例。如果您正苦于以下问题:C++ current_item函数的具体用法?C++ current_item怎么用?C++ current_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了current_item函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: wdg_file_driver
/*
* sends command to the menu
*/
static int wdg_file_driver(struct wdg_object *wo, int key, struct wdg_mouse_event *mouse)
{
WDG_WO_EXT(struct wdg_file_handle, ww);
int c;
struct stat buf;
c = menu_driver(ww->m, wdg_file_virtualize(key) );
/* skip non selectable items */
if ( !(item_opts(current_item(ww->m)) & O_SELECTABLE) )
c = menu_driver(ww->m, wdg_file_virtualize(key) );
/* one item has been selected */
if (c == E_UNKNOWN_COMMAND) {
/* the item is not selectable (probably selected with mouse) */
if ( !(item_opts(current_item(ww->m)) & O_SELECTABLE) )
return WDG_ESUCCESS;
stat(item_name(current_item(ww->m)), &buf);
/* if it is a directory, change to it */
if (S_ISDIR(buf.st_mode)) {
chdir(item_name(current_item(ww->m)));
return -WDG_ENOTHANDLED;
} else {
/* invoke the callback and return */
wdg_file_callback(wo, ww->curpath, (char *)item_name(current_item(ww->m)));
return WDG_ESUCCESS;
}
}
wnoutrefresh(ww->mwin);
return WDG_ESUCCESS;
}
开发者ID:Aishinjiaolo,项目名称:ettercap,代码行数:38,代码来源:wdg_file.c
示例2: show_chooser_win
void
show_chooser_win(MENU *dirmenu, size_t items, char *buf)
{
int c = 0;
size_t buflen, offset = 0;
char *tmp;
buflen = strlen(buf) - 1;
set_menu_fore(dirmenu, A_REVERSE);
returnval = set_menu_format(dirmenu, LINES, 1);
post_menu(dirmenu);
refresh();
while ((c = getch()) != 'q') {
switch(c) {
case 'j':
case KEY_DOWN:
menu_driver(dirmenu, REQ_DOWN_ITEM);
break;
case 'k':
case KEY_UP:
menu_driver(dirmenu, REQ_UP_ITEM);
break;
case KEY_NPAGE:
menu_driver(dirmenu, REQ_SCR_DPAGE);
break;
case KEY_PPAGE:
menu_driver(dirmenu, REQ_SCR_UPAGE);
break;
case KEY_END:
menu_driver(dirmenu, REQ_LAST_ITEM);
break;
case KEY_HOME:
menu_driver(dirmenu, REQ_FIRST_ITEM);
break;
case 10: /* Enter */
move(20, 0);
clrtoeol();
tmp = (char *)item_name(current_item(dirmenu));
offset = strlcpy(buf, tmp, MAX_CHOICESIZE);
if (offset >= MAX_CHOICESIZE)
goto toolong;
if (strlcpy(buf + offset,
item_description(current_item(dirmenu)),
MAX_CHOICESIZE - offset))
goto toolong;
pos_menu_cursor(dirmenu);
break;
}
}
toolong:
unpost_menu(dirmenu);
fprintf(stdout, "shit happens\n");
fprintf(stdout, "VALUE WAS: %d\n", returnval);
}
开发者ID:weezel,项目名称:fcd,代码行数:59,代码来源:choosewin.c
示例3: load_values
static void load_values(struct regedit *regedit)
{
struct tree_node *node;
node = item_userptr(current_item(regedit->keys->menu));
value_list_load(regedit->vl, node->key);
}
开发者ID:AIdrifter,项目名称:samba,代码行数:7,代码来源:regedit.c
示例4: mainmenu
int mainmenu(int height, int width) {
int ret;
ITEM **menu_items;
MENU *main_menu;
int n_choices, i;
clean_main_menu();
build_main_menu(instance_path);
n_choices = menu_size;
menu_items = (ITEM **) calloc(n_choices + 1, sizeof (ITEM *));
for (i = 0; i < n_choices; ++i) {
menu_items[i] = new_item(menu_values[i], menu_values[i]);
set_item_userptr(menu_items[i], (void *) menu_selected);
}
menu_items[n_choices] = (ITEM *) NULL;
main_menu = new_menu((ITEM **) menu_items);
menu_opts_off(main_menu, O_SHOWDESC);
set_menu_sub(main_menu, derwin(stdscr, 10, 50, 6, 10));
post_menu(main_menu);
attron(A_BOLD);
mvprintw(0, 0, name);
mvprintw(0, width - strlen(vers), vers);
attroff(A_BOLD);
refresh();
pos_menu_cursor(main_menu);
while ((i = getch()) != KEY_F(4)) {
switch (i) {
case KEY_DOWN:
menu_driver(main_menu, REQ_DOWN_ITEM);
break;
case KEY_UP:
menu_driver(main_menu, REQ_UP_ITEM);
break;
case 10:
{
ITEM *cur;
int (*p)(char *);
cur = current_item(main_menu);
p = (int (*)(char *))item_userptr(cur);
ret = p((char *) item_name(cur));
pos_menu_cursor(main_menu);
goto menu_sel;
}
}
}
if (i == KEY_F(4)) {
ret = menu_size - 1;
}
menu_sel:
unpost_menu(main_menu);
free_menu(main_menu);
for (i = 0; i < n_choices; ++i)
free_item(menu_items[i]);
return ret;
}
开发者ID:JonathanFu,项目名称:OpenAM-1,代码行数:59,代码来源:main.c
示例5: set_app_to_run
static void
set_app_to_run(void)
{
ITEM *item = current_item(menu_list);
if (item) {
open_app_later(g_list_nth_data(results, item_index(item)));
}
}
开发者ID:lchsk,项目名称:xstarter,代码行数:9,代码来源:term.c
示例6: displayMenu
void displayMenu(int y, int x, char title[],int numOfOpt, char *options[], void (*p[])(void)){
int i,c;
WINDOW *menuWindow;
MENU *myMenu;
ITEM **myOptions;
ITEM *currentOption;
initscr();
noecho();
cbreak();
keypad(stdscr,TRUE);
init_pair(1,COLOR_CYAN,COLOR_BLACK);
myOptions=(ITEM **)calloc(numOfOpt+1,sizeof(ITEM *));
for(i=0;i<numOfOpt;i++){
myOptions[i]=new_item(options[i]," ");
set_item_userptr(myOptions[i],p[i]);
}
myOptions[numOfOpt]=(ITEM *)NULL;
myMenu=new_menu(myOptions);
menuWindow = newwin(8,20,(LINES-y)/2,(COLS-x)/2);
keypad(menuWindow,TRUE);
set_menu_win(myMenu,menuWindow);
set_menu_sub(myMenu, derwin(menuWindow,y-4,x-2,3,1));
set_menu_format(myMenu,numOfOpt,1);
menu_opts_off(myMenu, O_SHOWDESC);
set_menu_mark(myMenu," * ");
post_menu(myMenu);
wrefresh(menuWindow);
while((c=wgetch(menuWindow))!=KEY_F(2)){
switch(c){
case KEY_UP:
menu_driver(myMenu,REQ_UP_ITEM);
break;
case KEY_DOWN:
menu_driver(myMenu,REQ_DOWN_ITEM);
break;
case 10:{
ITEM *temp;
temp=current_item(myMenu);
void(*pointer)(void);
pointer=item_userptr(temp);
pointer();
pos_menu_cursor(myMenu);
menu_driver(myMenu,REQ_DOWN_ITEM);
break;
}
wrefresh(menuWindow);
}
}
/*unpost_menu(myMenu);*/
/*for(i=0;i<numOfOpt;++i){*/
/*free_item(myOptions[i]);*/
/*}*/
/*free_menu(myMenu);*/
/*free(optionsNumbers);*/
}
开发者ID:nijen1312,项目名称:uczelnia,代码行数:55,代码来源:menufunctons.c
示例7: test_list
const char* test_list() {
gc_list list;
initialize_list(&list);
for(long i = 1; i < 17; ++i)
append_item((os_pointer)i, &list);
gc_list_iterator itr;
begin_list_iteration(&list, &itr);
os_pointer item = 0;
long expected = 1;
while((item = current_item(&itr))) {
if((long)item != expected)
return "append item failed";
if((long)item % 2 == 0 || (long)item < 7)
remove_item(&itr);
advance_item(&itr);
++expected;
}
for(long i = 16; i < 19; ++i)
append_item((os_pointer)i, &list);
long expected2[] = {7, 9, 11, 13, 15, 16, 17, 18};
int expected2_idx = 0;
begin_list_iteration(&list, &itr);
while((item = current_item(&itr))) {
if((long)item != expected2[expected2_idx++])
return "remove item failed";
advance_item(&itr);
}
finalize_list(&list);
return "passed";
}
开发者ID:rayiner,项目名称:portfolio,代码行数:39,代码来源:gc-utility.c
示例8: main
int main()
{ ITEM **my_items;
int c;
MENU *my_menu;
int n_choices, i;
ITEM *cur_item;
initscr();
cbreak();
noecho();
keypad(stdscr, TRUE);
n_choices = ARRAY_SIZE(choices);
my_items = (ITEM **)calloc(n_choices + 1, sizeof(ITEM *));
for(i = 0; i < n_choices; ++i)
my_items[i] = new_item(choices[i], choices[i]);
my_items[n_choices] = (ITEM *)NULL;
my_menu = new_menu((ITEM **)my_items);
post_menu(my_menu);
refresh();
while((c = getch()) != KEY_F(1))
{ switch(c)
{ case KEY_DOWN:
menu_driver(my_menu, REQ_DOWN_ITEM);
break;
case KEY_UP:
menu_driver(my_menu, REQ_UP_ITEM);
break;
case 10: /* Enter */
cur_item = current_item(my_menu);
move(LINES - 2, 0);
clrtoeol();
mvprintw(LINES - 2, 0, "You have chosen %d item with name %s and description %s",
item_index(cur_item) + 1, item_name(cur_item),
item_description(cur_item));
refresh();
pos_menu_cursor(my_menu);
break;
}
}
free_item(my_items[0]);
free_item(my_items[1]);
free_menu(my_menu);
endwin();
}
开发者ID:AmitKrJoshi,项目名称:LDP,代码行数:51,代码来源:menu_item_data.c
示例9: vwm_menu_marshall
/* this function make sure that the user selection is valid--not a category
or white space */
void vwm_menu_marshall(MENU *menu,gint32 key_vector)
{
gchar *item_text;
if(key_vector!=REQ_UP_ITEM && key_vector!=REQ_DOWN_ITEM) return;
do
{
item_text=(gchar*)item_name(current_item(menu));
if(memcmp(item_text,"..",2)==0) break;
menu_driver(menu,key_vector);
}
while(1);
return;
}
开发者ID:notbryant,项目名称:Neckbear-de-,代码行数:18,代码来源:vwm_menu.c
示例10: search_menu_backwards
static ITEM *
search_menu_backwards (MENU * menu)
{
char *search_string = NULL;
ITEM *result_item = NULL;
/* the search string is stored in the menu user pointer */
search_string = (char *) menu_userptr (menu);
if (NULL != search_string)
{
int i = -1;
int current_index = -1;
ITEM **items = NULL;
int found = 0;
bool done = FALSE;
current_index = item_index (current_item (menu));
items = menu_items (menu);
/* start search from the item immediately before the current item */
for (i = current_index - 1; i >= 0 && !found; i--)
{
found = strstr_nocase (item_description (items[i]), search_string);
}
if (!found)
{
int count = -1;
count = item_count (menu);
/* start search from the end (i.e. wrap around) */
for (i = count - 1; i >= current_index && !found; i--)
{
found =
strstr_nocase (item_description (items[i]), search_string);
}
}
if (found)
{
result_item = items[i + 1];
}
}
return result_item;
}
开发者ID:yourealwaysbe,项目名称:rolo,代码行数:46,代码来源:search.c
示例11: main_menu_left
//Update left window logic. If enter key was not pressed
//return NULL. Otherwise return pointer to selected item.
ITEM * main_menu_left(WINDOW * window, MENU * menu){
int c = wgetch(window);
switch(c){
case KEY_DOWN:
menu_driver(menu, REQ_DOWN_ITEM);
wrefresh(window);
break;
case KEY_UP:
menu_driver(menu, REQ_UP_ITEM);
wrefresh(window);
break;
case 10:
return current_item(menu);
break;
}
return NULL;
}
开发者ID:quantumvm,项目名称:AFLDFF,代码行数:21,代码来源:afldff_ncurses.c
示例12: column_select_update_menu
void
column_select_update_menu(ui_t *ui)
{
// Get panel information
column_select_info_t *info = column_select_info(ui);
ITEM *current = current_item(info->menu);
int top_idx = top_row(info->menu);
// Remove the menu from the subwindow
unpost_menu(info->menu);
// Set menu items
set_menu_items(info->menu, info->items);
// Put the menu agin into its subwindow
post_menu(info->menu);
// Move until the current position is set
set_top_row(info->menu, top_idx);
set_current_item(info->menu, current);
}
开发者ID:cruzccl,项目名称:sngrep,代码行数:19,代码来源:ui_column_select.c
示例13: main
int main(int argc, char *argv[]) {
int ch;
initscr();
atexit(quit);
clear();
noecho();
curs_set(0);
nl();
keypad(stdscr, TRUE);
it = (ITEM **)calloc(5, sizeof(ITEM *));
it[0] = new_item("M1", "");
it[1] = new_item("M2", "");
it[2] = new_item("M3", "");
it[3] = new_item("Ende", "");
it[4] = 0;
me = new_menu(it);
post_menu(me);
mvaddstr(7, 3, "Programm mittels Menü oder F2-Funktionstaste beenden");
refresh();
while ((ch = getch()) != KEY_F(2)) {
switch (ch) {
case KEY_DOWN:
menu_driver(me, REQ_DOWN_ITEM);
break;
case KEY_UP:
menu_driver(me, REQ_UP_ITEM);
break;
case 0xA:
if (item_index(current_item(me)) == 3) {
exit(0);
}
break;
}
}
return 0;
}
开发者ID:pwarnimo,项目名称:misc_projects,代码行数:42,代码来源:m1.c
示例14: exec_action_context_services
void exec_action_context_services(int ch)
{
ITEM *item;
switch (ch) {
case KEY_DOWN:
menu_driver(my_menu, REQ_DOWN_ITEM);
break;
case KEY_UP:
menu_driver(my_menu, REQ_UP_ITEM);
break;
case KEY_ENTER:
case 10:
item = current_item(my_menu);
exec_action(item_userptr(item));
break;
}
}
开发者ID:ychaim,项目名称:connman-json-client,代码行数:20,代码来源:main.c
示例15: vwm_fmod_wndlist_ON_KEYSTROKE
gint vwm_fmod_wndlist_ON_KEYSTROKE(gint32 keystroke,WINDOW *window)
{
MENU *menu=NULL;
MEVENT mevent;
ITEM *item;
// guint32 window_state;
menu=(MENU*)viper_window_get_userptr(window);
if(keystroke==KEY_MOUSE)
{
menu_driver(menu,keystroke);
getmouse(&mevent);
if((mevent.bstate & BUTTON1_DOUBLE_CLICKED)==BUTTON1_DOUBLE_CLICKED)
keystroke=KEY_CRLF;
}
viper_thread_enter();
if(keystroke==KEY_UP) menu_driver(menu,REQ_UP_ITEM);
if(keystroke==KEY_DOWN) menu_driver(menu,REQ_DOWN_ITEM);
if(keystroke==KEY_CRLF)
{
item=current_item(menu);
/* viper_wnd=(VIPER_WND*)item_userptr(item); */
viper_window_destroy(window);
/*
if((viper_wnd->window_state & STATE_VISIBLE)==FALSE)
viper_window_unhide(viper_wnd->window);
viper_window_set_top(viper_wnd->window);
viper_window_focus(TOPMOST_WINDOW);
*/
/* viper_screen_redraw(REDRAW_ALL); */
viper_thread_leave();
return 1;
}
viper_window_redraw(window);
viper_thread_leave();
return 1;
}
开发者ID:notbryant,项目名称:Neckbear-de-,代码行数:40,代码来源:vwm_wndlist.c
示例16: getUpgradeResult
int item::getUpgradeResult() const
{
const itemdata& data=itemsbuf[id];
int nextItem=-1;
if((data.flags&ITEM_COMBINE)!=0 && current_item(data.family)==data.fam_type)
{
for(int i=0; i<MAXITEMS; i++)
{
// Find the item in the same family with the least greater fam_type
if(itemsbuf[i].family==data.family &&
itemsbuf[i].fam_type>data.fam_type)
{
if(nextItem==-1 ||
itemsbuf[i].fam_type<=itemsbuf[nextItem].fam_type)
nextItem=i;
}
}
}
return nextItem;
}
开发者ID:arceusplayer11,项目名称:Vanilla-Patch,代码行数:22,代码来源:zc_items.cpp
示例17: menu_handler
/* menu handler */
void menu_handler(void) {
int c;
keypad(sub_window,TRUE); /* enable keypad on the menu */
wtimeout(sub_window,-1); /* wait for input */
while((c=wgetch(sub_window))) {
switch (c) {
case KEY_MOUSE:
menu_driver(menu_ptr,KEY_MOUSE);
break;
case 9: /* TAB */
case 'k':
case KEY_DOWN:
menu_driver(menu_ptr,REQ_DOWN_ITEM);
break;
case 'j':
case KEY_UP:
menu_driver(menu_ptr,REQ_UP_ITEM);
break;
case 27: /* ESC */
case 'q':
delete_menu();
finish(0);
break;
case 13:
case KEY_ENTER:
case KEY_RIGHT:
func_ptr = item_userptr(current_item(menu_ptr));
delete_menu();
return;
default: break;
}
}
return;
}
开发者ID:topgenorth,项目名称:saballistics,代码行数:39,代码来源:menu_handlers.c
示例18: update_info_bar
static void
update_info_bar(void)
{
if (! results_not_found) {
GList *l = g_list_nth(
results,
item_index(current_item(menu_list))
);
char *path = l->data;
clean_info_bar();
char status[100];
snprintf(status, 100, "Results: %d", choices_cnt);
mvwprintw(window, MAX_Y - 1, 0, status);
mvwprintw(window, MAX_Y, 0, path);
} else {
clean_info_bar();
}
}
开发者ID:lchsk,项目名称:xstarter,代码行数:23,代码来源:term.c
示例19: hgd_enter_on_files_menu
/* uh oh, someone hit enter on the files menu! */
int
hgd_enter_on_files_menu(struct ui *u)
{
DPRINTF(HGD_D_INFO, "Selected item on files menu");
char *new_cwd = NULL;
ITEM *item;
struct dirent *dirent;
if ((item = current_item(u->content_menus[HGD_WIN_FILES])) == NULL) {
DPRINTF(HGD_D_WARN, "Could not get current item");
return (HGD_FAIL);
}
dirent = (struct dirent *) item_userptr(item);
switch (dirent->d_type) {
case DT_DIR:
DPRINTF(HGD_D_INFO, "switch cwd: dirent->d_name");
if (strcmp(dirent->d_name, "..") == 0)
new_cwd = xstrdup(dirname(u->cwd));
else
xasprintf(&new_cwd, "%s/%s", u->cwd, dirent->d_name);
free(u->cwd);
u->cwd = new_cwd;
break;
default:
hgd_ui_queue_track(u, dirent->d_name);
break;
};
return (HGD_OK);
}
开发者ID:Eeketh,项目名称:hgd,代码行数:37,代码来源:nchgdc.c
示例20: viewMainMenu
void viewMainMenu() {
const int window_nlines = 10,
window_ncols = 90;
const char *choices[] = {
"Team 1: ",
"Team 2: ",
"Exit",
};
for(;;) {
// Create new window.
WINDOW *window = newwin(window_nlines,
window_ncols,
headerWindow_begin_y + headerWindow_nlines + 1,
0);
// Set new window options.
keypad(window, TRUE);
// Get the teams (used in menu items).
FootBallTeam *team[2];
team[0] = game.getFootBallTeam(FootBallGame::TEAM_ONE);
team[1] = game.getFootBallTeam(FootBallGame::TEAM_TWO);
String teamName[2];
// Create the menu items
int nChoices = ARRAY_SIZE(choices) + 1;
ITEM **items = new ITEM* [nChoices];
for (int i = 0; i < 2; i++ ) {
if (team[i] == NULL)
items[i] = new_item(choices[i], "Empty");
else {
teamName[i] = team[i]->getTeamName();
items[i] = new_item(choices[i], teamName[i].c_str());
}
}
items[2] = new_item(choices[2], NULL);
items[nChoices-1] = NULL;
// Create the menu
MENU *menu = new_menu(items);
// Menu options
set_menu_mark(menu, NULL);
// Attach the menu to the window
set_menu_win(menu, window);
set_menu_sub(menu, derwin(window, 10, 80, 0, 10));
// Make window and menu visible;
post_menu(menu);
wrefresh(window);
refresh();
// Start user interaction loop.
int c;
// The restart variable is used to tell the function to rebuild the
// menu by starting at the top of the for(;;) loop above.
bool restart = false;
while (!restart && (c = wgetch(window))) {
switch (c) {
case KEY_DOWN:
menu_driver(menu, REQ_DOWN_ITEM);
break;
case KEY_UP:
menu_driver(menu, REQ_UP_ITEM);
break;
case 10: // Enter
// When the user hits enter determine the currently selected
// item and do nessary actions.
const ITEM *currentItem = current_item(menu);
const char *itemName = item_name(currentItem);
// Delete allocated data
unpost_menu(menu);
free_menu(menu);
delwin(window);
for (int i = 0; i < nChoices; i++)
free_item(items[i]);
delete[] items;
if (strcmp(itemName, choices[2]) == 0) {
return;
// Edit/View Team 1
} else if (strcmp(itemName, choices[0]) == 0) {
restart = true;
viewTeam(FootBallGame::TEAM_ONE);
// Edit/View Team 2
} else if (strcmp(itemName, choices[1]) == 0) {
restart = true;
viewTeam(FootBallGame::TEAM_TWO);
}
}
}
}
}
开发者ID:cameronbwhite,项目名称:SportsManager,代码行数:93,代码来源:main.cpp
注:本文中的current_item函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论