当前位置: 首页>>代码示例>>C++>>正文


C++ current_item函数代码示例

本文整理汇总了C++中current_item函数的典型用法代码示例。如果您正苦于以下问题:C++ current_item函数的具体用法?C++ current_item怎么用?C++ current_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了current_item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的current_item函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。