Ejemplo n.º 1
0
int
save_raw_to_file(PANEL *panel)
{
    char field_value[48];
    FILE *f;
    sip_msg_t *msg = NULL;

    // Get panel information
    save_raw_info_t *info = (save_raw_info_t*) panel_userptr(panel);

    // Get current field value.
    // We trim spaces with sscanf because and empty field is stored as
    // space characters
    memset(field_value, 0, sizeof(field_value));
    sscanf(field_buffer(info->fields[FLD_SAVE_RAW_FILE], 0), "%[^ ]", field_value);

    if (!(f = fopen(field_value, "w"))) {
        save_raw_error_message(panel, "Unable to open save file for writing");
        return 0;
    }

    // Print the call group messages into the pad
    while ((msg = call_group_get_next_msg(info->group, msg))) {
        fprintf(f, "%s %s %s -> %s\n%s\n\n", msg_get_attribute(msg, SIP_ATTR_DATE),
                msg_get_attribute(msg, SIP_ATTR_TIME), msg_get_attribute(msg, SIP_ATTR_SRC),
                msg_get_attribute(msg, SIP_ATTR_DST), msg->payload);
    }

    fclose(f);
    return 27;
}
Ejemplo n.º 2
0
void pLScreen::save_panel_stack()
{
	// Save all panels for this logical screen
	// Panel user data : object panel_data
	//                   1 int field, screenID

	PANEL * pnl ;

	const void * vptr ;
	const panel_data * pd ;

	while ( !panelList.empty() )
	{
		panelList.pop() ;
	}
	pnl = NULL ;
	while ( true )
	{
		pnl = panel_below( pnl ) ;
		if ( pnl == NULL ) { break ; }
		vptr = panel_userptr( pnl ) ;
		if ( vptr == NULL ) { continue ; }
		pd = static_cast<const panel_data *>(vptr) ;
		if ( pd->screenID != screenID ) { continue ; }
		panelList.push( pnl ) ;
	}
}
Ejemplo n.º 3
0
Archivo: panels.c Proyecto: catfact/kit
int main()
{	WINDOW *my_wins[3];
	PANEL  *my_panels[3];
	PANEL  *top;
	int ch;

	/* Initialize curses */
	initscr();g
	start_color();
	cbreak();
	noecho();
	keypad(stdscr, TRUE);

	/* Initialize all the colors */
	init_pair(1, COLOR_RED, COLOR_BLACK);
	init_pair(2, COLOR_GREEN, COLOR_BLACK);
	init_pair(3, COLOR_BLUE, COLOR_BLACK);
	init_pair(4, COLOR_CYAN, COLOR_BLACK);

	init_wins(my_wins, 3);
	
	/* Attach a panel to each window */ 	/* Order is bottom up */
	my_panels[0] = new_panel(my_wins[0]); 	/* Push 0, order: stdscr-0 */
	my_panels[1] = new_panel(my_wins[1]); 	/* Push 1, order: stdscr-0-1 */
	my_panels[2] = new_panel(my_wins[2]); 	/* Push 2, order: stdscr-0-1-2 */

	/* Set up the user pointers to the next panel */
	set_panel_userptr(my_panels[0], my_panels[1]);
	set_panel_userptr(my_panels[1], my_panels[2]);
	set_panel_userptr(my_panels[2], my_panels[0]);

	/* Update the stacking order. 2nd panel will be on top */
	update_panels();

	/* Show it on the screen */
	attron(COLOR_PAIR(4));
	mvprintw(LINES - 2, 0, "Use tab to browse through the windows (F1 to Exit)");
	attroff(COLOR_PAIR(4));
	doupdate();

	top = my_panels[2];
	while((ch = getch()) != KEY_F(1))
	{	switch(ch)
		{	case 9:
				top = (PANEL *)panel_userptr(top);
				top_panel(top);
				break;
		}
		update_panels();
		doupdate();
	}
	endwin();
	return 0;
}
Ejemplo n.º 4
0
int
main ()
{
  WINDOW *ventanas[3];
  PANEL *paneles[3];
  PANEL *top;
  int ch;
  int n_paneles=4444;
  /* Initialize curses */
  initscr ();
  start_color ();
  cbreak ();
  noecho ();
  keypad (stdscr, TRUE);
  /* Initialize all the colors */
  init_pair (1, COLOR_RED, COLOR_BLACK);
  init_pair (2, COLOR_GREEN, COLOR_BLACK);
  init_pair (3, COLOR_BLUE, COLOR_BLACK);
  init_pair (4, COLOR_CYAN, COLOR_BLACK);
  init_wins (ventanas, 6);
  /* Attach a panel to each window *//* Order is bottom up */
  paneles[0] = new_panel (ventanas[0]);	/* Push 0, order: stdscr-0 */
  paneles[1] = new_panel (ventanas[1]);	/* Push 1, order: stdscr-0-1 */
  paneles[2] = new_panel (ventanas[2]);	/* Push 2, order: stdscr-0-1-2 */
  /* Set up the user pointers to the next panel */
  set_panel_userptr (paneles[0], paneles[1]);
  set_panel_userptr (paneles[1], paneles[2]);
  set_panel_userptr (paneles[2], paneles[0]);
  /* Update the stacking order. 2nd panel will be on top */
  update_panels ();

  /* Show it on the screen */
  attron (COLOR_PAIR (4));
  mvprintw (LINES - 2, 0, "Q->Salir");
  attroff (COLOR_PAIR (4));
  doupdate ();

  top = paneles[2];		/* Store the top panel pointer */
  while ((ch = getch ()) != 'q')
    {
      switch (ch)
	{
	case 9:
	  top = (PANEL *) panel_userptr (top);	/* Find out the next panel in the cycle */
	  top_panel (top);	/* Make it as the top panel */
	  break;
	}
      update_panels ();
      doupdate ();
    }
  endwin ();
  return 0;
}
Ejemplo n.º 5
0
SCM
gucu_panel_userdata (SCM pan)
{
  if (_scm_is_panel (pan))
    {
      PANEL *c_panel = _scm_to_panel (pan);
      return (SCM) (panel_userptr (c_panel));
    }
  else
    scm_wrong_type_arg ("set-panel-userdata", SCM_ARG1, pan);

  /* Never reached */
  return SCM_UNDEFINED;
}
Ejemplo n.º 6
0
static void
fill_unboxed(PANEL * pan)
{
    WINDOW *win = panel_window(pan);
    const char *userptr = (const char *) panel_userptr(pan);
    int num = (userptr && *userptr) ? userptr[1] : '?';
    int y, x;

    for (y = 0; y < getmaxy(win); y++) {
	for (x = 0; x < getmaxx(win); x++) {
	    wmove(win, y, x);
	    waddch(win, UChar(num));
	}
    }
}
Ejemplo n.º 7
0
static void
my_remove_panel(PANEL ** pans, int which)
{
    if (pans[which] != 0) {
	PANEL *pan = pans[which];
	WINDOW *win = panel_window(pan);
	char *user = (char *) panel_userptr(pan);

	free(user);
	del_panel(pan);
	delwin(win);

	pans[which] = 0;
    }
}
Ejemplo n.º 8
0
static void
fill_wide_panel(PANEL * pan)
{
    WINDOW *win = panel_window(pan);
    int num = ((const char *) panel_userptr(pan))[1];
    int y, x;

    wmove(win, 1, 1);
    wprintw(win, "-pan%c-", num);
    wclrtoeol(win);
    box(win, 0, 0);
    for (y = 2; y < getmaxy(win) - 1; y++) {
	for (x = 1; x < getmaxx(win) - 1; x++) {
	    wmove(win, y, x);
	    waddch(win, UChar(num));
	}
    }
}
int main(int argc, char const *argv[]) {
    WINDOW *my_wins[3];
    PANEL *my_panels[3];
    PANEL_DATA panel_datas[3];
    PANEL_DATA *temp;
    int ch;

    initscr();
    start_color();
    cbreak();
    noecho();
    keypad(stdscr, TRUE);

    init_pair(1, COLOR_RED, COLOR_BLACK);
    init_pair(2, COLOR_GREEN, COLOR_BLACK);
    init_pair(3, COLOR_BLUE, COLOR_BLACK);
    init_pair(4, COLOR_CYAN, COLOR_BLACK);

    init_wins(my_wins, 3);

    my_panels[0] = new_panel(my_wins[0]);
    my_panels[1] = new_panel(my_wins[1]);
    my_panels[2] = new_panel(my_wins[2]);

    panel_datas[0].hide = FALSE;
    panel_datas[1].hide = FALSE;
    panel_datas[2].hide = FALSE;

    set_panel_userptr(my_panels[0], &panel_datas[0]);
    set_panel_userptr(my_panels[1], &panel_datas[1]);
    set_panel_userptr(my_panels[2], &panel_datas[2]);

    update_panels();

    attron(COLOR_PAIR(4));
    mvprintw(LINES - 3, 0, "Show or Hide a window with 'a' (first window), 'b' (second window), 'c' (third window)");
    mvprintw(LINES - 2, 0, "F1 to Exit");
    attroff(COLOR_PAIR(4));
    doupdate();

    while ((ch = getch()) != KEY_F(1)) {
        switch (ch) {
        case 'a':
            temp = (PANEL_DATA *) panel_userptr(my_panels[0]);
            if (temp->hide == FALSE) {
                hide_panel(my_panels[0]);
                temp->hide = TRUE;
            } else {
                show_panel(my_panels[0]);
                temp->hide = FALSE;
            }
            break;
        case 'b':
            temp = (PANEL_DATA *) panel_userptr(my_panels[1]);
            if (temp->hide == FALSE) {
                hide_panel(my_panels[1]);
                temp->hide = TRUE;
            } else {
                show_panel(my_panels[1]);
                temp->hide = FALSE;
            }
            break;
        case 'c':
            temp = (PANEL_DATA *) panel_userptr(my_panels[2]);
            if (temp->hide == FALSE) {
                hide_panel(my_panels[2]);
                temp->hide = TRUE;
            } else {
                show_panel(my_panels[2]);
                temp->hide = FALSE;
            }
            break;
        }
        update_panels();
        doupdate();
    }
    endwin();
    return 0;
}
Ejemplo n.º 10
0
void panel_stack_plugin(const PANEL *panel, const struct aug_plugin **plugin) {
	*plugin = panel_userptr(panel);
}
Ejemplo n.º 11
0
int main()
{	WINDOW *my_wins[3];
	PANEL  *my_panels[3];
	PANEL_DATA panel_datas[3];
	PANEL_DATA *temp;
	int ch;

	/* Initialize curses */
	initscr();
	start_color();
	cbreak();
	noecho();
	keypad(stdscr, TRUE);

	/* Initialize all the colors */
	init_pair(1, COLOR_RED, COLOR_BLACK);
	init_pair(2, COLOR_GREEN, COLOR_BLACK);
	init_pair(3, COLOR_BLUE, COLOR_BLACK);
	init_pair(4, COLOR_CYAN, COLOR_BLACK);

	init_wins(my_wins, 3);
	
	/* Attach a panel to each window */ 	/* Order is bottom up */
	my_panels[0] = new_panel(my_wins[0]); 	/* Push 0, order: stdscr-0 */
	my_panels[1] = new_panel(my_wins[1]); 	/* Push 1, order: stdscr-0-1 */
	my_panels[2] = new_panel(my_wins[2]); 	/* Push 2, order: stdscr-0-1-2 */

	/* Initialize panel datas saying that nothing is hidden */
	panel_datas[0].hide = FALSE;
	panel_datas[1].hide = FALSE;
	panel_datas[2].hide = FALSE;

	set_panel_userptr(my_panels[0], &panel_datas[0]);
	set_panel_userptr(my_panels[1], &panel_datas[1]);
	set_panel_userptr(my_panels[2], &panel_datas[2]);

	/* Update the stacking order. 2nd panel will be on top */
	update_panels();

	/* Show it on the screen */
	attron(COLOR_PAIR(4));
	mvprintw(LINES - 3, 0, "Show or Hide a window with 'a'(first window)  'b'(Second Window)  'c'(Third Window)");
	mvprintw(LINES - 2, 0, "q to Exit");

	attroff(COLOR_PAIR(4));
	doupdate();

	while((ch = getch()) != 'q')
	{	switch(ch)
		{	case 'a':			
				temp = (PANEL_DATA *)panel_userptr(my_panels[0]);
				if(temp->hide == FALSE)
				{	hide_panel(my_panels[0]);
					temp->hide = TRUE;
				}
				else
				{	show_panel(my_panels[0]);
					temp->hide = FALSE;
				}
				break;
			case 'b':
				temp = (PANEL_DATA *)panel_userptr(my_panels[1]);
				if(temp->hide == FALSE)
				{	hide_panel(my_panels[1]);
					temp->hide = TRUE;
				}
				else
				{	show_panel(my_panels[1]);
					temp->hide = FALSE;
				}
				break;
			case 'c':
				temp = (PANEL_DATA *)panel_userptr(my_panels[2]);
				if(temp->hide == FALSE)
				{	hide_panel(my_panels[2]);
					temp->hide = TRUE;
				}
				else
				{	show_panel(my_panels[2]);
					temp->hide = FALSE;
				}
				break;
		}
		update_panels();
		doupdate();
	}
	endwin();
	return 0;
}
Ejemplo n.º 12
0
static VALUE rbncurs_c_panel_userptr(VALUE rb_panel)
{ return (VALUE)(panel_userptr(get_panel(rb_panel))); }
Ejemplo n.º 13
0
column_select_info_t *
column_select_info(ui_t *ui)
{
    return (column_select_info_t*) panel_userptr(ui->panel);
}
Ejemplo n.º 14
0
/**
 * Mouse support:
 *  - bring a window on top if you click on its taskbar
 *  - click on the top-bar of the active window and drag+drop to move a window
 *  - click on a window to bring it to focus
 *   - allow scrolling in tree/textview on wheel-scroll event
 *   - click to activate button or select a row in tree
 *  wishlist:
 *   - have a little [X] on the windows, and clicking it will close that window.
 */
static gboolean
detect_mouse_action(const char *buffer)
{
	int x, y;
	static enum {
		MOUSE_NONE,
		MOUSE_LEFT,
		MOUSE_RIGHT,
		MOUSE_MIDDLE
	} button = MOUSE_NONE;
	static GntWidget *remember = NULL;
	static int offset = 0;
	GntMouseEvent event;
	GntWidget *widget = NULL;
	PANEL *p = NULL;

	if (!wm->cws->ordered || buffer[0] != 27)
		return FALSE;

	buffer++;
	if (strlen(buffer) < 5)
		return FALSE;

	x = buffer[3];
	y = buffer[4];
	if (x < 0)	x += 256;
	if (y < 0)	y += 256;
	x -= 33;
	y -= 33;

	while ((p = panel_below(p)) != NULL) {
		const GntNode *node = panel_userptr(p);
		GntWidget *wid;
		if (!node)
			continue;
		wid = node->me;
		if (x >= wid->priv.x && x < wid->priv.x + wid->priv.width) {
			if (y >= wid->priv.y && y < wid->priv.y + wid->priv.height) {
				widget = wid;
				break;
			}
		}
	}

	if (strncmp(buffer, "[M ", 3) == 0) {
		/* left button down */
		/* Bring the window you clicked on to front */
		/* If you click on the topbar, then you can drag to move the window */
		event = GNT_LEFT_MOUSE_DOWN;
	} else if (strncmp(buffer, "[M\"", 3) == 0) {
		/* right button down */
		event = GNT_RIGHT_MOUSE_DOWN;
	} else if (strncmp(buffer, "[M!", 3) == 0) {
		/* middle button down */
		event = GNT_MIDDLE_MOUSE_DOWN;
	} else if (strncmp(buffer, "[M`", 3) == 0) {
		/* wheel up*/
		event = GNT_MOUSE_SCROLL_UP;
	} else if (strncmp(buffer, "[Ma", 3) == 0) {
		/* wheel down */
		event = GNT_MOUSE_SCROLL_DOWN;
	} else if (strncmp(buffer, "[M#", 3) == 0) {
		/* button up */
		event = GNT_MOUSE_UP;
	} else
		return FALSE;

	if (widget && gnt_wm_process_click(wm, event, x, y, widget))
		return TRUE;

	if (event == GNT_LEFT_MOUSE_DOWN && widget && widget != wm->_list.window &&
			!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) {
		if (widget != wm->cws->ordered->data) {
			gnt_wm_raise_window(wm, widget);
		}
		if (y == widget->priv.y) {
			offset = x - widget->priv.x;
			remember = widget;
			button = MOUSE_LEFT;
		}
	} else if (event == GNT_MOUSE_UP) {
		if (button == MOUSE_NONE && y == getmaxy(stdscr) - 1) {
			/* Clicked on the taskbar */
			int n = g_list_length(wm->cws->list);
			if (n) {
				int width = getmaxx(stdscr) / n;
				gnt_bindable_perform_action_named(GNT_BINDABLE(wm), "switch-window-n", x/width, NULL);
			}
		} else if (button == MOUSE_LEFT && remember) {
			x -= offset;
			if (x < 0)	x = 0;
			if (y < 0)	y = 0;
			gnt_screen_move_widget(remember, x, y);
		}
		button = MOUSE_NONE;
		remember = NULL;
		offset = 0;
	}

	if (widget)
		gnt_widget_clicked(widget, event, x, y);
	return TRUE;
}
Ejemplo n.º 15
0
save_info_t *
save_info(ui_t *ui)
{
    return (save_info_t*) panel_userptr(ui->panel);
}
Ejemplo n.º 16
0
void
save_raw_set_group(PANEL *panel, sip_call_group_t *group)
{
    save_raw_info_t *info = (save_raw_info_t*) panel_userptr(panel);
    info->group = group;
}
Ejemplo n.º 17
0
int
save_raw_handle_key(PANEL *panel, int key)
{
    int field_idx;
    char field_value[48];
    int action = -1;

    // Get panel information
    save_raw_info_t *info = (save_raw_info_t*) panel_userptr(panel);

    // Get current field id
    field_idx = field_index(current_field(info->form));

    // Get current field value.
    // We trim spaces with sscanf because and empty field is stored as
    // space characters
    memset(field_value, 0, sizeof(field_value));
    sscanf(field_buffer(current_field(info->form), 0), "%[^ ]", field_value);

    // Check actions for this key
    while ((action = key_find_action(key, action)) != ERR) {
        // Check if we handle this action
        switch (action) {
            case ACTION_PRINTABLE:
                if (field_idx == FLD_SAVE_RAW_SAVE)
                    form_driver(info->form, key);
                break;
            case ACTION_NEXT_FIELD:
                form_driver(info->form, REQ_NEXT_FIELD);
                form_driver(info->form, REQ_END_LINE);
                break;
            case ACTION_PREV_FIELD:
                form_driver(info->form, REQ_PREV_FIELD);
                form_driver(info->form, REQ_END_LINE);
                break;
            case ACTION_RIGHT:
                form_driver(info->form, REQ_RIGHT_CHAR);
                break;
            case ACTION_LEFT:
                form_driver(info->form, REQ_LEFT_CHAR);
                break;
            case ACTION_BEGIN:
                form_driver(info->form, REQ_BEG_LINE);
                break;
            case ACTION_END:
                form_driver(info->form, REQ_END_LINE);
                break;
            case ACTION_DELETE:
                form_driver(info->form, REQ_DEL_CHAR);
                break;
            case ACTION_BACKSPACE:
                if (strlen(field_value) > 0)
                    form_driver(info->form, REQ_DEL_PREV);
                break;
            case ACTION_CLEAR:
                form_driver(info->form, REQ_CLR_FIELD);
                break;
            case ACTION_CONFIRM:
                if (field_idx != FLD_SAVE_RAW_CANCEL) {
                    if (!strcasecmp(field_value, "")) {
                        save_raw_error_message(panel, "Invalid filename");
                        return 0;
                    }
                    return save_raw_to_file(panel);
                }
                return 27;
            default:
                // Parse next action
                continue;
        }

        // We've handled this key, stop checking actions
        break;
    }

    // Validate all input data
    form_driver(info->form, REQ_VALIDATION);

    // Change background and cursor of "button fields"
    set_field_back(info->fields[FLD_SAVE_RAW_SAVE], A_NORMAL);
    set_field_back(info->fields[FLD_SAVE_RAW_CANCEL], A_NORMAL);
    curs_set(1);

    // Change current field background
    field_idx = field_index(current_field(info->form));
    if (field_idx == FLD_SAVE_RAW_SAVE || field_idx == FLD_SAVE_RAW_CANCEL) {
        set_field_back(info->fields[field_idx], A_REVERSE);
        curs_set(0);
    }

    // Return if this panel has handled or not the key
    return (action == ERR) ? key : 0;
}
Ejemplo n.º 18
0
filter_info_t *
filter_info(PANEL *panel)
{
    return (filter_info_t*) panel_userptr(panel);
}
Ejemplo n.º 19
0
int main(void)
{
    tui_init();

    tab_window *ltab = malloc(sizeof *ltab);
    tab_window *rtab = malloc(sizeof *ltab);
    int ch;
    void (*p)(tab_window *, const char *);
    tab_window *active_tab;
    ltab->win = tui_new_win(0, 0, LINES, COLS / 2 , 2);
    rtab->win = tui_new_win(0, COLS / 2, LINES, COLS / 2, 2);

    mvwprintw(ltab->win->decoration, 1,1, "/");
    mvwprintw(rtab->win->decoration, 1,1, "/");

    set_panel_userptr(ltab->win->panel, rtab);
    set_panel_userptr(rtab->win->panel, ltab);

    top_panel(ltab->win->panel);

    active_tab = ltab;

    strncpy(ltab->path, "/", PATH_MAX - 1);
    strncpy(rtab->path, "/", PATH_MAX - 1);
    ltab->items_num = scan_dir(ltab->path, &ltab->files, dirsortbyname);
    rtab->items_num = scan_dir(rtab->path, &rtab->files, dirsortbyname);

    tui_make_menu(ltab, event_handler);
    tui_make_menu(rtab, event_handler);

    touchwin(panel_window(active_tab->win->panel));
    update_panels();
    doupdate();

    while ((ch = getch()) != KEY_F(12))
    {
        p = (void (*)(tab_window *, const char *))(uintptr_t)item_userptr(current_item(active_tab->menu));
        switch (ch)
        {
            case '\t':
                active_tab = (tab_window *) panel_userptr(active_tab->win->panel);
                top_panel(active_tab->win->panel);
                break;
            case KEY_DOWN:
                menu_driver(active_tab->menu, REQ_DOWN_ITEM);
                break;
            case KEY_UP:
                menu_driver(active_tab->menu, REQ_UP_ITEM);
                break;
            case KEY_NPAGE:
                menu_driver(active_tab->menu, REQ_SCR_DPAGE);
                break;
            case KEY_PPAGE:
                menu_driver(active_tab->menu, REQ_SCR_UPAGE);
                break;
            case KEY_HOME:
                menu_driver(active_tab->menu, REQ_FIRST_ITEM);
                break;
            case KEY_END:
                menu_driver(active_tab->menu, REQ_LAST_ITEM);
                break;
            case 13: // enter
                p(active_tab, "select");
                break;
            case KEY_F(2):
                p(active_tab, "remove");
                break;
            case KEY_F(3):
                p(active_tab, "rename");
                break;
            default:break;
        }
        touchwin(panel_window(active_tab->win->panel));
        update_panels();
        doupdate();
    }
    for(int i = 0; i < ltab->items_num ; ++i)
    {
        free(ltab->files[i]);
    }
    free(ltab->files);
    for(int i = 0; i < rtab->items_num; ++i)
    {
        free(rtab->files[i]);
    }
    free(rtab->files);
    tui_destroy_menu(rtab);
    tui_destroy_menu(ltab);
    tui_del_win(ltab);
    tui_del_win(rtab);
    free(ltab);
    free(rtab);
    endwin();
}
Ejemplo n.º 20
0
msg_diff_info_t *
msg_diff_info(ui_t *ui)
{
    return (msg_diff_info_t*) panel_userptr(ui->panel);
}
Ejemplo n.º 21
0
void    eventManager(MenuLeft *menu_left, MenuRight *menu_right, WINDOW *menu_bottom, PANEL **my_panels)
{
    PANEL   *top;
    int     ch;

    top = my_panels[0];
    wattron(stdscr, COLOR_PAIR(2) | A_BLINK);
    mvwaddch(stdscr, 3, COLS / 2 - 2, ACS_DIAMOND);
    wattroff(stdscr, COLOR_PAIR(2) | A_BLINK);
    while((ch = getch()) != 27) {
        if (ch == 9)
        {
            top = (PANEL *) panel_userptr(top);
            top_panel(top);
            if (top == my_panels[0])
            {
                wattron(menu_bottom, COLOR_PAIR(5));
                mvwprintw(menu_bottom, 0, COLS - 15, "PRESS ENTER");
                mvwprintw(menu_bottom, 1, COLS - 15, "TO VALIDATE");
                wattroff(menu_bottom, COLOR_PAIR(5));
                wattron(stdscr, COLOR_PAIR(2) | A_BLINK);
                mvwaddch(stdscr, 3, COLS / 2 - 2, ACS_DIAMOND);
                wattroff(stdscr, COLOR_PAIR(2) | A_BLINK);
            }
            else if (top == my_panels[1])
            {
                if (!menu_left->getExp()->getSelectedItems().size())
                {
                    top = (PANEL *) panel_userptr(top);
                    top_panel(top);
                }
                else
                {
                    wattron(stdscr, COLOR_PAIR(2));
                    mvwaddch(stdscr, 3, COLS / 2 - 2, ' ');
                    wattroff(stdscr, COLOR_PAIR(2));
                    wattron(stdscr, COLOR_PAIR(2) | A_BLINK);
                    mvwaddch(stdscr, 3, COLS - 3, ACS_DIAMOND);
                    wattroff(stdscr, COLOR_PAIR(2) | A_BLINK);
                }
            }
            if (top == my_panels[2])
            {
                wattron(stdscr, COLOR_PAIR(2));
                mvwaddch(stdscr, 3, COLS / 2 - 2, ' ');
                mvwaddch(stdscr, 3, COLS - 3, ' ');
                wattroff(stdscr, COLOR_PAIR(2));
                wattron(menu_bottom, COLOR_PAIR(5) | A_REVERSE | A_BLINK);
                mvwprintw(menu_bottom, 0, COLS - 15, "PRESS ENTER");
                mvwprintw(menu_bottom, 1, COLS - 15, "TO VALIDATE");
                wattroff(menu_bottom, COLOR_PAIR(5) | A_REVERSE | A_BLINK);
            }
        }
        if (top == my_panels[0])
            menu_left->eventManager(menu_right, ch);
        else if (top == my_panels[1])
            menu_right->eventManager(ch);
        else if (top == my_panels[2] && ch == 10)
            break;
        update_panels();
        doupdate();
    }
}
Ejemplo n.º 22
0
int main()
{   WINDOW *my_wins[3];
    PANEL  *my_panels[3];
    PANEL_DATA  *top;
    PANEL *stack_top;
    WINDOW *temp_win, *old_win;
    int ch;
    int newx, newy, neww, newh;
    int size = FALSE, move = FALSE;

    /* Initialize curses */
    initscr();
    start_color();
    cbreak();
    noecho();
    keypad(stdscr, TRUE);

    /* Initialize all the colors */
    init_pair(1, COLOR_RED, COLOR_BLACK);
    init_pair(2, COLOR_GREEN, COLOR_BLACK);
    init_pair(3, COLOR_BLUE, COLOR_BLACK);
    init_pair(4, COLOR_CYAN, COLOR_BLACK);

    init_wins(my_wins, 3);
 
    /* Attach a panel to each window */     /* Order is bottom up */
    my_panels[0] = new_panel(my_wins[0]);   /* Push 0, order: stdscr-0 */
    my_panels[1] = new_panel(my_wins[1]);   /* Push 1, order: stdscr-0-1 */
    my_panels[2] = new_panel(my_wins[2]);   /* Push 2, order: stdscr-0-1-2 */

    set_user_ptrs(my_panels, 3);
    /* Update the stacking order. 2nd panel will be on top */
    update_panels();

    /* Show it on the screen */
    attron(COLOR_PAIR(4));
    mvprintw(LINES - 3, 0, "Use 'm' for moving, 'r' for resizing");
    mvprintw(LINES - 2, 0, "Use tab to browse through the windows (F1 to Exit)");
    attroff(COLOR_PAIR(4));
    doupdate();

    stack_top = my_panels[2];
    top = (PANEL_DATA *)panel_userptr(stack_top);
    newx = top->x;
    newy = top->y;
    neww = top->w;
    newh = top->h;
    while((ch = getch()) != KEY_F(1))
    {   switch(ch)
        {   case 9:     /* Tab */
                top = (PANEL_DATA *)panel_userptr(stack_top);
                top_panel(top->next);
                stack_top = top->next;
                top = (PANEL_DATA *)panel_userptr(stack_top);
                newx = top->x;
                newy = top->y;
                neww = top->w;
                newh = top->h;
                break;
            case 'r':   /* Re-Size*/
                size = TRUE;
                attron(COLOR_PAIR(4));
                mvprintw(LINES - 4, 0, "Entered Resizing :Use Arrow Keys to resize and press <ENTER> to end resizing");
                refresh();
                attroff(COLOR_PAIR(4));
                break;
            case 'm':   /* Move */
                attron(COLOR_PAIR(4));
                mvprintw(LINES - 4, 0, "Entered Moving: Use Arrow Keys to Move and press <ENTER> to end moving");
                refresh();
                attroff(COLOR_PAIR(4));
                move = TRUE;
                break;
            case KEY_LEFT:
                if(size == TRUE)
                {   --newx;
                    ++neww;
                }
                if(move == TRUE)
                    --newx;
                break;
            case KEY_RIGHT:
                if(size == TRUE)
                {   ++newx;
                    --neww;
                }
                if(move == TRUE)
                    ++newx;
                break;
            case KEY_UP:
                if(size == TRUE)
                {   --newy;
                    ++newh;
                }
                if(move == TRUE)
                    --newy;
                break;
            case KEY_DOWN:
                if(size == TRUE)
                {   ++newy;
                    --newh;
                }
                if(move == TRUE)
                    ++newy;
                break;
            case 10:    /* Enter */
                move(LINES - 4, 0);
                clrtoeol();
                refresh();
                if(size == TRUE)
                {   old_win = panel_window(stack_top);
                    temp_win = newwin(newh, neww, newy, newx);
                    replace_panel(stack_top, temp_win);
                    win_show(temp_win, top->label, top->label_color); 
                    delwin(old_win);
                    size = FALSE;
                }
                if(move == TRUE)
                {   move_panel(stack_top, newy, newx);
                    move = FALSE;
                }
                break;
            
        }
        attron(COLOR_PAIR(4));
        mvprintw(LINES - 3, 0, "Use 'm' for moving, 'r' for resizing");
            mvprintw(LINES - 2, 0, "Use tab to browse through the windows (F1 to Exit)");
            attroff(COLOR_PAIR(4));
            refresh();  
        update_panels();
        doupdate();
    }
    endwin();
    return 0;
}
Ejemplo n.º 23
0
column_select_info_t *
column_select_info(PANEL *panel)
{
    return (column_select_info_t*) panel_userptr(panel);
}
Ejemplo n.º 24
0
call_raw_info_t *
call_raw_info(PANEL *panel)
{
    return (call_raw_info_t*) panel_userptr(panel);
}
Ejemplo n.º 25
0
filter_info_t *
filter_info(ui_t *ui)
{
    return (filter_info_t*) panel_userptr(ui->panel);
}