Exemplo n.º 1
0
WINDOW* vwm_fmod_wndlist(gpointer anything)
{
	const char      *title=" Window List ";
	WINDOW		    *window;
	int			    width = 0,height = 0;
	MENU			*menu;
	ITEM			**item_list;
	gchar			**titles;
	guint			item_count;

	if(viper_window_find_by_class((gpointer)vwm_fmod_wndlist) != NULL)
        return NULL;

	viper_thread_enter();

	titles = viper_deck_get_wndlist();
	item_count = g_strv_length(titles);

	if(item_count == 0)
	{
		viper_thread_leave();
		return NULL;
	}

	menu = viper_menu_create(titles);

	item_list = (ITEM**)g_malloc0(sizeof(ITEM*)*(item_count+1));

	// override the default of 1 column X 16 entries per row
	set_menu_format(menu,20,1);
	// hide character mark on left hand side
	set_menu_mark(menu," ");

	scale_menu(menu,&height,&width);
	width++;
	if((strlen(title) + 10) > width) width = (strlen(title) + 10);

	window = viper_window_create((gchar*)title,0.95,2,width,height,TRUE);
	viper_menu_bind(menu,window,0,0,width,height);

//	set_menu_sub(menu,window);
	set_menu_fore(menu,
		VIPER_COLORS(COLOR_MAGENTA,COLOR_WHITE) | A_REVERSE | A_BOLD);
	set_menu_back(menu,VIPER_COLORS(COLOR_BLACK,COLOR_WHITE));

//	post_menu(menu);

/*	viper_event_set(window,"window-activate",vwm_fmod_wndlist_ON_ACTIVATE,NULL); */
	viper_event_set(window,"window-destroy",vwm_fmod_wndlist_ON_DESTROY,
		(gpointer)menu);
	viper_window_set_key_func(window,vwm_fmod_wndlist_ON_KEYSTROKE);
	viper_window_set_userptr(window,(gpointer)menu);
	viper_window_set_state(window,STATE_EMINENT);

	viper_thread_leave();
	g_strfreev(titles);

	return window;
}
Exemplo n.º 2
0
static void viper_kmio_show_mouse(MEVENT *mouse_event)
{
   extern VIPER      *viper;
   extern WINDOW     *SCREEN_WINDOW;
   WINDOW            *screen_window;
   static chtype     color;
   gshort            fg,bg;

   screen_window=SCREEN_WINDOW;

   if(viper->console_mouse==NULL)
   {
      viper->console_mouse=newwin(1,1,0,0);
      color=mvwinch(screen_window,0,0);
      pair_content(PAIR_NUMBER(color & A_COLOR),&fg,&bg);
      if(bg==COLOR_RED || bg==COLOR_YELLOW || bg==COLOR_MAGENTA)
         color=VIPER_COLORS(COLOR_CYAN,COLOR_CYAN);
      if(bg==COLOR_CYAN || bg==COLOR_BLUE)
         color=VIPER_COLORS(COLOR_YELLOW,COLOR_YELLOW);
   }

   if(mouse_event!=NULL)
   {
      color=mvwinch(screen_window,mouse_event->y,mouse_event->x);
      pair_content(PAIR_NUMBER(color & A_COLOR),&fg,&bg);
      if(bg==COLOR_RED || bg==COLOR_YELLOW || bg==COLOR_MAGENTA) 
         color=VIPER_COLORS(COLOR_CYAN,COLOR_CYAN);
      else
         color=VIPER_COLORS(COLOR_YELLOW,COLOR_YELLOW);
      mvwin(viper->console_mouse,mouse_event->y,mouse_event->x);
   }

   mvwaddch(viper->console_mouse,0,0,' ' | color);

   return;
}
Exemplo n.º 3
0
WINDOW* vwmterm_init(gpointer anything)
{
   extern WINDOW  	*SCREEN_WINDOW;
	extern ps_runq_t	*vwm_runq;
   vterm_t           *vterm;
	WINDOW	      	*window;
	gint		      	width,height;
   int               master_fd;
   int               fflags;

   getmaxyx(SCREEN_WINDOW,height,width);
   if(height>30 && width>84)
   {
      height=25;
      width=80;
   }
   else
   {
      /* calculate scaled window size */
	   window_get_size_scaled(NULL,&width,&height,0.85,0.65);
	   if(width>80) width=80;
	   if(height>25) height=25;
   }

   vterm=vterm_create(width,height,0);
   vterm_set_colors(vterm,COLOR_WHITE,COLOR_BLACK);
   master_fd=vterm_get_pty_fd(vterm);

   // configure SIGIO acceleration
#ifdef SIGPOLL
   vwmterm_sigset(SIGPOLL,vwmterm_SIGIO);
#else
   vwmterm_sigset(SIGIO,vwmterm_SIGIO);
#endif
	fcntl(master_fd,F_SETOWN,getpid());
   fflags=fcntl(master_fd,F_GETFL);
   fcntl(master_fd,F_SETFL,fflags | FASYNC);

   viper_thread_enter();

   // create window
	window=viper_window_create(" VTerm ",0.5,0.5,width,height,TRUE);
   viper_window_set_state(window,STATE_UNSET | STATE_NORESIZE);
	viper_window_set_limits(window,15,2,WSIZE_UNCHANGED,WSIZE_UNCHANGED);

   // libviper set the default bkgd OR to WHITE on BLACK.  undo it.
   wbkgdset(window,0);
	wattron(window,VIPER_COLORS(COLOR_WHITE,COLOR_BLACK));

   // init terminal
   vterm_wnd_set(vterm,window);
   vterm_erase(vterm);

   // attache event handlers
	viper_event_set(window,"window-resized",vwmterm_ON_RESIZE,(gpointer)vterm);
	viper_event_set(window,"window-close",vwmterm_ON_CLOSE,(gpointer)vterm);
	viper_event_set(window,"window-destroy",vwmterm_ON_DESTROY,
		(gpointer)vterm);
	viper_window_set_key_func(window,vwmterm_ON_KEYSTROKE);
	viper_window_set_userptr(window,(gpointer)vterm);

   // push pseudo-thread onto run queue
	psthread_add(vwm_runq,vwmterm_psthread,(gpointer)window);

	viper_thread_leave();

	return window;
}
Exemplo n.º 4
0
WINDOW* vwm_main_menu(void)
{
   extern WINDOW  *SCREEN_WINDOW;
	MENU           *menu=NULL;
	WINDOW 		   *window;
	gint			   width=0,height=0;
   gint           screen_height;

	VWM_MODULE	   *vwm_module;
	GSList		   *category_list=NULL;
	GSList		   *module_list=NULL;
	GSList		   *node1;
	GSList		   *node2;

	gchar			   **item_list;
   gint           idx=0;

   /* allocate storage for 128 menu items    */
   item_list=(gchar**)g_malloc0(sizeof(gchar*)*(MAX_MENU_ITEMS+1));

   item_list[idx]=g_strdup_printf(" ");
   idx++;
	category_list=vwm_modules_list_categories();
   node1=category_list;
   while(node1!=NULL && idx<MAX_MENU_ITEMS)
   {
      /* skip screensavers */
      if(strcmp((gchar*)node1->data,VWM_SCREENSAVER)==0)
      {
         node1=node1->next;
         continue;
      }

      /* add the category  */
      item_list[idx]=g_strdup_printf("%s",(gchar*)node1->data);
      idx++;
      if(idx==MAX_MENU_ITEMS) break;

      module_list=vwm_modules_list((gchar*)node1->data);
      node2=module_list;
      while(node2!=NULL)
      {
         if(idx==MAX_MENU_ITEMS) break;
         vwm_module=(VWM_MODULE*)node2->data;
         item_list[idx]=g_strdup_printf("..%s",vwm_module->title);
         idx++;
         node2=node2->next;
      }

      /* add a space before the next menu category  */
      if(idx<MAX_MENU_ITEMS)
      {
         item_list[idx]=g_strdup_printf(" ");
         idx++;
      }

      if(module_list!=NULL) g_slist_free(module_list);
      node1=node1->next;
   }
   if(category_list!=NULL) g_slist_free(category_list);

   menu=viper_menu_create(item_list);
   while(idx!=-1)
   {
      g_free(item_list[idx]);
      idx--;
   }
   g_free(item_list);

	/* hide character mark on left hand side */
	set_menu_mark(menu," ");

   window_get_size_scaled(SCREEN_WINDOW,NULL,&screen_height,0,0.80);

	scale_menu(menu,&height,&width);
	width++;
	if(width<16) width=16;
 	/* override the default of 1 column X 16 entries per row */
   if(height>(screen_height-4)) height=screen_height-4;
	set_menu_format(menu,height,1);

	viper_thread_enter();
	window=viper_window_create(" Menu ",1,2,width,height,TRUE);
   /* todo:  it would be nice if the user could resize the window (especially
      in the horizonal direction) and add more columns to the display.  right
      now, it's not a priority (but it would be easy to implement).  just need
      a few lines of code for the event window-resized.  for now, just don't
      allow it */
	set_menu_win(menu,window);
	set_menu_fore(menu,VIPER_COLORS(COLOR_WHITE,COLOR_BLUE) | A_BOLD);
	set_menu_back(menu,VIPER_COLORS(COLOR_BLACK,COLOR_WHITE));
	menu_opts_off(menu,O_NONCYCLIC);
	post_menu(menu);
   vwm_menu_marshall(menu,REQ_DOWN_ITEM);

	/* viper_event_set(window,"window-activate",vwm_main_menu_ON_ACTIVATE,NULL); */
	viper_event_set(window,"window-close",vwm_main_menu_ON_CLOSE,
		(gpointer)menu);
	viper_window_set_key_func(window,vwm_main_menu_ON_KEYSTROKE);
	viper_window_set_userptr(window,(gpointer)menu);

	viper_thread_leave();
	return window;
}
Exemplo n.º 5
0
WINDOW* vwm_main_menu(void)
{
    extern WINDOW   *SCREEN_WINDOW;
	MENU            *menu = NULL;
	WINDOW 		    *window;
	int			    width = 0,height = 0;
    int             screen_height;

	vwm_module_t	*vwm_module;
    char            buf[NAME_MAX];

    gchar			**item_list;
    int             idx = 0;
    int             i;

    // allocate storage for a total of MAX_MENU_ITEMS
    item_list = (gchar**)g_malloc0(sizeof(gchar*) * (MAX_MENU_ITEMS + 1));

    item_list[idx] = g_strdup_printf(" ");
    idx++;

    // iterate through the categories defined in modules.def
    for(i = 0;i < VWM_MOD_TYPE_MAX;i++)
    {
        // skip screensaver type modules.  they are a special class.
        if(i == VWM_MOD_TYPE_SCREENSAVER) continue;

        // print the menu category (type) to the window
        item_list[idx] = g_strdup_printf("%s",modtype_desc[i]);
        idx++;

        vwm_module = NULL;

        do
        {
            if(idx == MAX_MENU_ITEMS) break;

            vwm_module = vwm_module_find_by_type(vwm_module,i);
            if(vwm_module == NULL) break;

            vwm_module_get_title(vwm_module,buf,sizeof(buf) - 1);
            item_list[idx] = g_strdup_printf("..%s",buf);
            idx++;
        }
        while(vwm_module != NULL);

        // add a space before the next menu category
        if(idx < MAX_MENU_ITEMS)
        {
            item_list[idx] = g_strdup_printf(" ");
            idx++;
        }
    }

    menu = viper_menu_create(item_list);
    while(idx != -1)
    {
        g_free(item_list[idx]);
        idx--;
    }
    g_free(item_list);

	// hide character mark on left hand side
	set_menu_mark(menu," ");

    window_get_size_scaled(SCREEN_WINDOW,NULL,&screen_height,0,0.80);

	scale_menu(menu,&height,&width);
	width++;
	if(width < 16) width = 16;

 	// override the default of 1 column X 16 entries per row
    if(height>(screen_height-4)) height=screen_height-4;
	set_menu_format(menu,height,1);

	viper_thread_enter();
	window = viper_window_create(" Menu ",1,2,width,height,TRUE);
    /*
        todo:   it would be nice if the user could resize the menu
                (especially in the horizonal direction) and add more
                columns to the display.  right now, it's not a priority
                (but it would be easy to implement).  just need a few
                lines of code for the event window-resized.  for now,
                just don't allow it
    */
	set_menu_win(menu,window);
	set_menu_fore(menu,VIPER_COLORS(COLOR_WHITE,COLOR_BLUE) | A_BOLD);
	set_menu_back(menu,VIPER_COLORS(COLOR_BLACK,COLOR_WHITE));
	menu_opts_off(menu,O_NONCYCLIC);
	post_menu(menu);
    vwm_menu_marshall(menu,REQ_DOWN_ITEM);

	/* viper_event_set(window,"window-activate",vwm_main_menu_ON_ACTIVATE,NULL); */
	viper_event_set(window,"window-close",vwm_main_menu_ON_CLOSE,
		(gpointer)menu);
	viper_window_set_key_func(window,vwm_main_menu_ON_KEYSTROKE);
	viper_window_set_userptr(window,(gpointer)menu);

	viper_thread_leave();
	return window;
}