Example #1
0
/*
 * Set the selection status of an entry in the list.
 * Input:  list - which list widget
 *         entry - which entry, 0 being the first
 *         status - 1 = selected, 0 = unselected
 */
void LUI_ListSetStatus( LUI_LIST *list, int entry, int status )
{
   if (entry>=0 && entry<list->numstrings) {
      list->select_flags[entry] = status;
      if (entry>=list->topstring && entry<list->topstring+list->rows) {
         draw_entry( list, entry );
      }
   }
}
Example #2
0
/*
 * Redraw whole list.
 */
static void draw_list( LUI_LIST *list )
{
   int i;

   for (i=0;i<list->rows;i++) {
      draw_entry( list, list->topstring+i );
   }

   /* draw the frame */
   LUI_DrawFrame( list->window, 0, 0, list->width, list->height, LUI_Border,1);
}
Example #3
0
/*
 * Set the selection status of all entries in the list.
 * Input:  list - which list widget
 *         status - 1 = selected, 0 = unselected
 */
void LUI_ListSetStatusAll( LUI_LIST *list, int status )
{
   int i;

   for (i=0;i<list->numstrings;i++) {
      list->select_flags[i] = status;
      if (i>=list->topstring && i<list->topstring+list->rows) {
         draw_entry( list, i );
      }
   }
}
Example #4
0
wireless_scan *show_menu() {
	/* Init ncurses */
	initscr(); raw(); noecho(); curs_set(0);
	start_color(); use_default_colors();
	init_pair(1,1,-1); init_pair(2,2,-1); init_pair(3,3,-1);
	init_pair(4,4,-1); init_pair(5,5,-1); init_pair(6,6,-1);
	init_pair(7,7,-1);
	/* Select entry */
	wireless_scan *ws, *ss;
	int running = True;
	int c,i,sel = 0;
	int n = refresh_list();
	while (running) {
		move(0,0);
		attrset(COLOR_PAIR(4)|A_REVERSE|A_BOLD);
		printw(" *  %-*s  %%  \n",IW_ESSID_MAX_SIZE+2,"Network"); 
		for (ws = context.result, i=0; ws; ws = ws->next)
			if ((mode & MODE_HIDDEN) || strlen(ws->b.essid)) {
				if (i == sel) ss = ws;
				draw_entry(ws,((i++)==sel));
			}
		attrset(COLOR_PAIR(4)|A_REVERSE|A_BOLD);
		printw("  %-*s \n",IW_ESSID_MAX_SIZE+8," ");
		refresh();
		c = getchar();
		if (c == 'q') running = False;
		else if (c == 13) break;
		else if (c == 'r') n = refresh_list();
		else if (c == 'j' || c == 66) sel++;
		else if (c == 'k' || c == 65) sel--;
		if (sel >= n) sel = n;
		else if (sel < 0) sel = 0;
	}
	endwin();
	if (!running) {	/* "q" selected */
		iw_sockets_close(skfd);
		exit(0);
	}
	for (i = 0, ws = context.result; i != sel; ws = ws->next)
		if ((mode & MODE_HIDDEN) || strlen(ws->b.essid)) i++;
	/* End ncurses session & return result */
	return ws;
}
Example #5
0
/*
 * When an X event occurs in the list window, this function will be called.
 * Input:  list - which list widget
 *         event - the X event
 */
static int list_process( LUI_LIST *list, XEvent *event )
{
   static int prev_entry = -1;

   switch (event->type) {
      case Expose:
         draw_list( list );
         break;

      case ButtonPress:
         {
            /* main window */
            int row, i;
            row = (event->xbutton.y - LUI_Border) / FONT_HEIGHT;
            i = list->topstring + row;
            if (i<list->numstrings) {
               /* toggle status */
               list->select_flags[i] = !list->select_flags[i];
               prev_entry = i;
               draw_entry( list, i );
               XSync( LUI_Display, 0 );
               if (list->callback) {
                  (*list->callback)( list, i, list->select_flags[i] );
               }
            }
         }
         break;

      case MotionNotify:
         {
            /* main window */
            int row, i;
            row = (event->xmotion.y - LUI_Border) / FONT_HEIGHT;
            if (row>=0 && row<list->rows) {
               i = list->topstring + row;
#ifdef JUNK
            if (row>=list->rows && i<list->numstrings) {
               /* scroll down */
               list->topstring++;
               draw_list(list);
               LUI_ScrollBarSetPos( list->vsb,
                   100.0 * list->topstring / (list->numstrings-list->rows) );
            }
            else if (row<0 && i>0) {
               /* scroll up */
               list->topstring--;
               draw_list(list);
               LUI_ScrollBarSetPos( list->vsb,
                   100.0 * list->topstring / (list->numstrings-list->rows) );
            }
#endif
               if (i>=0 && i<list->numstrings && i!=prev_entry) {
                  int j;
                  if (i>prev_entry) {
                     for (j=prev_entry+1; j<=i; j++) {
                        /* toggle status */
                        list->select_flags[j] = !list->select_flags[j];
                        draw_entry( list, j );
                        if (list->callback) {
                           (*list->callback)( list, j, list->select_flags[j] );
                        }
                     }
                  }
                  else {
                     for (j=prev_entry-1;j>=i;j--) {
                        /* toggle status */
                        list->select_flags[j] = !list->select_flags[j];
                        draw_entry( list, j );
                        if (list->callback) {
                           (*list->callback)( list, j, list->select_flags[j] );
                        }
                     }
                  }
                  prev_entry = i;
               }
            }
         }
         break;

      case ButtonRelease:
         prev_entry = -1;
         break;

      case EnterNotify:
         break;
      case LeaveNotify:
         break;

      default:
         printf("Error in list_process:  unexpected event (%d)\n",
                (int) event->type );
   }
   return 1;
}