Ejemplo n.º 1
0
int main()
{
        WINDOW *my_wins[3];
        PANEL *my_panels[3];
        int lines = 10, cols = 40, y = 2, x = 4, i;

        initscr();
        cbreak();
        noecho();

        my_wins[0] = newwin(lines, cols, y, x);
        my_wins[1] = newwin(lines, cols, y + 1, x + 5);
        my_wins[2] = newwin(lines, cols, y + 2, x + 10);

        for(i = 0; i < 3; i++)
                box(my_wins[i], 0, 0);

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

        update_panels();
        doupdate();

        getch();
        endwin();
        return 0;
}
Ejemplo n.º 2
0
//Screen ctor constructs a space with a box around it
Screen::Screen(int h, int w)
{
  //First, call initialization functions
  initscr();  // Start curses mode
  start_color(); // We'll use color
  cbreak();// Line buffering disabled, Pass everything to me
  noecho();// Don't echo characters user types
  curs_set(0); //make cursor invisible
  keypad(stdscr, TRUE); //enable keypad arrows

  //set up color schemes
  init_pair(c_error, COLOR_WHITE, COLOR_RED);
  init_pair(c_gold, COLOR_BLACK, COLOR_YELLOW);

  // Interrogate our (physical) window's dimensions
  int maxlen,maxwid;
  std::pair<int,int> maxes=_getScreenSize();
  screenHeight=maxes.first;
  screenWidth=maxes.second;
  // Abort if physical window is smaller than requested
  // we subtract 2 because of border we need to draw
  if(h > screenHeight-2 || w > screenWidth-2)
  {
    _two_second_error("WINDOW NOT LARGE ENOUGH!");
    endwin();
    std::exit(1);
  }
  //outerWindow is +2 because it boxes L*W inner contents
  WINDOW* outerWindow=newwin(h+2,w+2,0,0);;
  new_panel(outerWindow);
  box(outerWindow, 0, 0); //put frame around window (zeros mean use default chars)
  innerWindow=newwin(h, w, 1, 1); //note it's offset by one to miss the outer box
  panel=new_panel(innerWindow);
}
Ejemplo n.º 3
0
MENUPAN*
menu_pan_create(MENU *menu, int y, int x, int id)
{
    MENUPAN *menupan;


    assert(menu);

    menupan=(MENUPAN *)malloc(sizeof(MENUPAN));
    if(!menupan) {
        set_error(ERR_NOMEM);
        lpr_error("menu_pan_create");
    }

    menupan->id=id;
    menupan->menu=menu;
    menupan->win=new_panel(newwin(item_count(menu)+2, MSIZE, y, x));
    menupan->sub=new_panel(derwin(menupan->win->win,
                                  item_count(menu), MSIZE-2, 1, 1));
    wcolor_set(menupan->win->win, 1, NULL);
    set_menu_fore(menu, COLOR_PAIR(1) | A_REVERSE);
    set_menu_back(menu, COLOR_PAIR(1));
    set_menu_grey(menu, COLOR_PAIR(1));
    set_menu_win(menu, menupan->win->win);
    set_menu_sub(menu, menupan->sub->win);


    box(menupan->win->win, 0, 0);
    menupan_hide(menupan);

    return menupan;
}
Ejemplo n.º 4
0
static void render_ui(ui_t *ui) {
  chat_tab = COLS-12;
  log_tab = COLS-6;
  render_tab_bar(ACTIVE_CHAT);

  ui->screen = newwin(LINES - 6, COLS - 1, 1, 1);
  scrollok(ui->screen, TRUE);
  box(ui->screen, 0, 0);
  ui->next_line = 1;
  CHAT = new_panel(ui->screen);
  chat_history = ui_history_create();

  ui->log = newwin(LINES - 6, COLS - 1, 1, 1);
  scrollok(ui->log, TRUE);
  box(ui->log, 0, 0);
  ui->next_log_line = 1;
  LOG = new_panel(ui->log);
  log_history = ui_history_create();

  ui->alert = newwin(3, COLS, 1, 0);
  ALERT = new_panel(ui->alert);

  set_panel_userptr(CHAT, LOG);
  set_panel_userptr(LOG, ALERT);
  set_panel_userptr(ALERT, CHAT);

  top_panel(CHAT);
  hide_panel(LOG);
  hide_panel(ALERT);
  update_panels();
  doupdate();

  ui->prompt = newwin(4, COLS - 1, LINES - 5, 1);
  show_prompt(ui, NULL);
}
Ejemplo n.º 5
0
void init_othp_table(struct othptable *table)
{
	unsigned int winht;
	unsigned int wintop;
	unsigned int obmaxx __unused;

	winht = LINES - (LINES * 0.6) - 2;
	wintop = (LINES * 0.6) + 1;

	table->count = 0;
	table->lastpos = 0;
	table->strindex = 0;
	table->htstat = NOHTIND;
	table->head = table->tail = NULL;
	table->firstvisible = table->lastvisible = NULL;
	table->borderwin = newwin(winht, COLS, wintop, 0);
	table->borderpanel = new_panel(table->borderwin);
	wattrset(table->borderwin, BOXATTR);
	tx_box(table->borderwin, ACS_VLINE, ACS_HLINE);

	table->head = table->tail = NULL;
	table->othpwin = newwin(winht - 2, COLS - 2, wintop + 1, 1);
	table->othppanel = new_panel(table->othpwin);
	wattrset(table->othpwin, STDATTR);
	tx_colorwin(table->othpwin);
	update_panels();
	doupdate();

	tx_stdwinset(table->othpwin);
	getmaxyx(table->borderwin, table->obmaxy, obmaxx);
	table->oimaxy = table->obmaxy - 2;
}
Ejemplo n.º 6
0
int main_window_open(void)
{
	int w, h;

	getmaxyx(stdscr, h, w);
	h -= 2;

	messagelist_wnd = newwin(h, w - folders_width, 0, folders_width);
	messagelist_panel = new_panel(messagelist_wnd);
	folders_wnd = newwin(h, folders_width, 0, 0);
	folders_panel = new_panel(folders_wnd);
	status_wnd = newwin(1, w, h, 0);
	refresh();

	wrefresh(messagelist_wnd);
	wrefresh(folders_wnd);
	wrefresh(status_wnd);

	gui_add_key_listener(&next_folder_listener, 'n', _("Next folder"), main_folder_next);
	gui_add_key_listener(&prev_folder_listener, 'p', _("Prev folder"), main_folder_prev);
	gui_add_key_listener(&fetch_mail_listener, 'f', _("Fetch"), callback_fetch_mails);
	gui_add_key_listener(&next_mail_listener, NCURSES_DOWN, NULL, main_next_mail);
	gui_add_key_listener(&prev_mail_listener, NCURSES_UP, NULL, main_prev_mail);
	gui_add_key_listener(&read_mail_listener, '\n', NULL, main_read_mail);

	return 1;
}
Ejemplo n.º 7
0
void tx_init_listbox(struct scroll_list *list, int width, int height,
                      int startx, int starty,
                      int mainattr, int borderattr, int selectattr,
                      int keyattr)
{
    bzero(list, sizeof(struct scroll_list));
    list->borderwin = newwin(height, width, starty, startx);
    list->borderpanel = new_panel(list->borderwin);
    wattrset(list->borderwin, borderattr);
    tx_box(list->borderwin, ACS_VLINE, ACS_HLINE);
    
    list->win = newwin(height - 2, width - 2, starty + 1, startx + 1);
    list->panel = new_panel(list->win);
    wattrset(list->win, mainattr);
    tx_colorwin(list->win);
    
    list->mainattr = mainattr;
    list->selectattr = selectattr;
    list->height = height;
    list->width = width;
    list->keyattr = keyattr;
    
    tx_stdwinset(list->win);
    scrollok(list->win, 0);
}
Ejemplo n.º 8
0
void init_windows()
{
  win_inventory = newwin(25, 29, 0, 0);
  win_map       = newwin(25, 90, 0, 30);
  win_input     = newwin(3, 120, 25, 0);
  win_status    = newwin(7, 120, 28, 0);

  pan_inventory = new_panel(win_inventory);
  pan_map       = new_panel(win_map);
  pan_input     = new_panel(win_input);
  pan_status    = new_panel(win_status);

  // input panel needs to be at the top of the stack initially!
  show_panel(pan_input);

  box(win_inventory,  0, 0);
  box(win_map,        0, 0);
  box(win_input,      0, 0);
  box(win_status,     0, 0);

  // make getch() non-blocking
  nodelay(win_map, true);

  // store the height and width of the displayable win_map
  map_y_size = 25;
  map_x_size = 90;

  // store the height and width of the displayable win_input
  input_y_size = 3;
  input_x_size = 120;

  // initialize input window
  Input = (void *)malloc(360);
  for (int i=0;i<360;i++) {
    Input[i] = ' ';
  }

  // starting x-coord and y-coord
  // temporary, not sticking around
  x = 1 + map_x_size / 2;
  y = 1 + map_y_size / 2;

  // set up signal handling for quitting
  memset(&action, 0, sizeof(struct sigaction));
  action.sa_handler = handle_end_signal;
  sigaction(SIGINT, &action, NULL);
  sigaction(SIGQUIT, &action, NULL);
  sigaction(SIGTERM, &action, NULL);

  // set the game mode
  GameMode = MODE_NORMAL;

  // I'm still running!
  should_quit = FALSE;

  // while initializing the game, I currently need to refresh the screen
  needs_refresh = TRUE;
}
Ejemplo n.º 9
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.º 10
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.º 11
0
void init_tcp_table(struct tcptable *table)
{
	int i;

	table->bmaxy = LINES * 0.6;	/* 60% of total screen */
	table->imaxy = table->bmaxy - 2;

	table->borderwin = newwin(table->bmaxy, COLS, 1, 0);
	table->borderpanel = new_panel(table->borderwin);

	wattrset(table->borderwin, BOXATTR);
	tx_box(table->borderwin, ACS_VLINE, ACS_HLINE);
	mvwprintw(table->borderwin, 0, 1, " TCP Connections (Source Host:Port) ");

	setlabels(table->borderwin, 0);	/* initially use mode 0 */

	mvwprintw(table->borderwin, 0, 65 * COLS / 80, " Flag ");
	mvwprintw(table->borderwin, 0, 70 * COLS / 80, " Iface ");
	update_panels();
	doupdate();
	table->ifnamew = COLS - (70 * COLS / 80) - 3;
	if (table->ifnamew < 7)
		table->ifnamew = 7;
	if (table->ifnamew > IFNAMSIZ)
		table->ifnamew = IFNAMSIZ;

	table->head = table->tail = NULL;
	table->firstvisible = table->lastvisible = NULL;
	table->tcpscreen = newwin(table->imaxy, COLS - 2, 2, 1);
	table->tcppanel = new_panel(table->tcpscreen);
	table->closedentries = table->closedtail = NULL;
	wattrset(table->tcpscreen, BOXATTR);
	tx_colorwin(table->tcpscreen);
	table->lastpos = 0;
	table->count = 0;

	wtimeout(table->tcpscreen, -1);
	tx_stdwinset(table->tcpscreen);
	print_tcp_num_entries(table);

	/* 
	 * Initialize hash table to nulls
	 */

	for (i = 0; i <= ENTRIES_IN_HASH_TABLE - 1; i++) {
		table->hash_table[i] = NULL;
		table->hash_tails[i] = NULL;
	}
	table->barptr = NULL;
	table->baridx = 0;
}
Ejemplo n.º 12
0
int main(void) {
	int flag=0;

	initscr();
	atexit(quit);
	clear();
	noecho();
	curs_set(0);
	cbreak();
	keypad(stdscr, 1);

	start_color();
	init_pair(1, COLOR_YELLOW, COLOR_BLUE);
	init_pair(2, COLOR_BLACK, COLOR_WHITE);
	init_pair(3, COLOR_BLACK, COLOR_YELLOW);

	win1 = newwin(10, 25, 5, 10);
	win2 = newwin(10, 25, 10, 15);
	box(win1, ACS_VLINE, ACS_HLINE);
	box(win2, ACS_VLINE, ACS_HLINE);
	pan1 = new_panel(win1);
	pan2 = new_panel(win2);
  
	bkgd(COLOR_PAIR(1));
	wbkgd(win1, COLOR_PAIR(2));
	wbkgd(win2, COLOR_PAIR(3));

	mvaddstr(2,4, "F9 beendet das Programm");
	mvwaddstr(win1, 2, 3, "Druecke eine Taste");
	mvwaddstr(win2, 7, 3, "Druecke eine Taste");
	
	update_panels();
	doupdate();

	while(getch() != KEY_F(9)) {
		if (flag==0) {
			top_panel(pan1);
			flag = 1; 
		} else {
			top_panel(pan2);
			flag = 0;
		}

		update_panels();
		doupdate();
	} 

	return (0);  
}
Ejemplo n.º 13
0
void uiinit() {
    initscr();
    cbreak();
    keypad(stdscr, TRUE);

    wstatus = newwin(1, COLS, LINES-1, 0);
    pstatus = new_panel(wstatus);

    wmain = newwin(LINES-1, COLS, 0, 0);
    pmain = new_panel(wmain);
    scrollok(wmain, TRUE);

    update_panels();
    doupdate();
}
Ejemplo n.º 14
0
void tx_infobox(char *text, char *prompt)
{
	WINDOW *win;
	PANEL *panel;
	int ch;

	win = newwin(4, 50, (LINES - 4) / 2, (COLS - 50) / 2);
	panel = new_panel(win);
	wattrset(win, INFO_BORDER_ATTR);
	tx_colorwin(win);
	tx_box(win, ACS_VLINE, ACS_HLINE);
	wattrset(win, INFO_TEXT_ATTR);
	mvwprintw(win, 1, 2, text);
	wattrset(win, INFO_PROMPT_ATTR);
	mvwprintw(win, 2, 2, prompt);
	update_panels();
	doupdate();

	do {
		ch = wgetch(win);
		if (ch == 12)
			tx_refresh_screen();
	} while (ch == 12);

	del_panel(panel);
	delwin(win);

	update_panels();
	doupdate();
}
Ejemplo n.º 15
0
void map_cursor_init(void)
{
        cursor = new_cursor(frame_h, frame_w, 0, 0, LINES-1, COLS, 0, 0, HJKL);
        nav_win = newwin(nav_h, nav_w, LINES-nav_h, CENT_X-(nav_w/2));
        nav_pan = new_panel(nav_win);
        wbkgrnd(nav_win, &PURPLE[2]);
}
Ejemplo n.º 16
0
static bool init_globalstat(WINDOW *parent, struct globalstat *gs, int type) {
 
    if(!top_prefs_get_logging_mode()) {
	gs->window = newwin(1, 1, 0, 0);
	
	if(NULL == gs->window)
	    return true;

	gs->panel = new_panel(gs->window);
	
	if(NULL == gs->panel) {
	    delwin(gs->window);
	    return true;
	}
    }

    gs->type = type;
    gs->length = 0;
    gs->x = 0;
    gs->y = 0;
    gs->size.width = 0;
    gs->size.height = 0;
    gs->max_width = 0;

    return false;
};
Ejemplo n.º 17
0
void InitResizeMOSAIC () {
	resizeWindow = CreateCenteredBoxedTitledWindow (RESIZE_height,
			RESIZE_width, "RESIZE");
	resizePanel = new_panel (resizeWindow);

	mvwaddstr (resizeWindow, 1, 1, "New height");
	mvwaddstr (resizeWindow, 2, 1, "New width");

	/* MAKING OF FORM */
	FIELD **fields = (FIELD **) malloc (3 * sizeof (FIELD *));
	fields[0] = new_field (1, 3, 0, 0, 0, 0);
	set_field_back (fields[0], A_BOLD);
	field_opts_off (fields[0], O_PASSOK);
	set_field_just (fields[0], JUSTIFY_LEFT);
	set_field_type (fields[0], TYPE_INTEGER, 0, 1, 999);

	fields[1] = new_field (1, 3, 1, 0, 0, 0);
	set_field_back (fields[1], A_BOLD);
	field_opts_off (fields[1], O_PASSOK);
	set_field_just (fields[1], JUSTIFY_LEFT);
	set_field_type (fields[1], TYPE_INTEGER, 0, 1, 999);

	fields[2] = NULL;

	// the FORM itself, WINDOW and post it!
	resize_form = new_form (fields);
	// subwindow: inside the box
	WINDOW *subwindow = derwin (resizeWindow, 2, 3, 1, 12);
	set_form_win (resize_form, subwindow);
	set_form_sub (resize_form, subwindow);
	post_form (resize_form);

	touchwin (resizeWindow);
}
Ejemplo n.º 18
0
void errbox(char *message, char *prompt, int *response)
{
    WINDOW *win;
    PANEL *panel;

    win = newwin(4, 70, (LINES - 4) / 2, (COLS - 70) / 2);
    panel = new_panel(win);

    wattrset(win, ERRBOXATTR);
    colorwin(win);
    box(win, ACS_VLINE, ACS_HLINE);
    wmove(win, 2, 2);
    wprintw(win, "%s", prompt);
    wattrset(win, ERRTXTATTR);
    wmove(win, 1, 2);
    wprintw(win, "%s", message);
    update_panels();
    doupdate();

    do {
	*response = wgetch(win);
	if (*response == 12)
	    refresh_screen();
    } while (*response == 12);

    del_panel(panel);
    delwin(win);
    update_panels();
    doupdate();
}
Ejemplo n.º 19
0
/**
 * print_tcp_stat_screen()
 * -------------------
 * displays the main background screen
 **/
void print_tcp_stat_screen(WINDOW ** statwin, PANEL ** statpanel, int card, char *iface)
{
  if (GUI_DEBUG) fprintf(stderr,"making overall window\n");
  /** make the overall wireless traffic monitor box window **/
  *statwin = newwin(LINES - 2, COLS, 1, 0);
  *statpanel = new_panel(*statwin);
  stdwinset(*statwin);
  wtimeout(*statwin, -1);
  wattrset(*statwin, BOXATTR);
  colorwin(*statwin);
  box(*statwin, ACS_VLINE, ACS_HLINE);
  wmove(*statwin, 0, 1);
  if (card == AIRONET)
    wprintw(*statwin, " TCP Performance Analysis: listening using Cisco Aironet (%s) ", iface);
  else if (card == PRISMII)
    wprintw(*statwin, " TCP Performance Analysis: listening using PrismII-compatible (%s) ", iface);
  else if (card == HOSTAP)
    wprintw(*statwin, " TCP Performance Analysis: listening using HostAP driver (%s) ", iface);
  else if (card == HERMES)
    wprintw(*statwin, " TCP Performance Analysis: listening using Hermes-compatible (%s) ", iface);
  else if (card == WLANNG)
    wprintw(*statwin, " TCP Performance Analysis: listening using Wlan-ng driver (%s) ", iface);
  wattrset(*statwin, STDATTR);
  update_panels();
  doupdate();
}
Ejemplo n.º 20
0
/**
 * Open window
 */
struct panelw *openWindow(int x, int y, int width, int height, int color, const char *title, const char *help, t_EventHandler handler, t_ActivateHandler ahandler)
{
    struct panelw *p;
    p = malloc(sizeof(struct panelw));
    if (p)
    {
        strncpy(p->title, title, 100);
        snprintf(p->help, 512, "%s\n\tTAB\tswitch to next window\n\tF10\tto quit", help);
        p->col = 0;
        p->row = 0;
        p->x = x;
        p->y = y;
        p->width = width + 2;
        p->height = height + 2;
        p->handler = handler;
        p->ahandler = ahandler;
        p->next = NULL;
        p->prev = NULL;
        p->win = newwin(p->height, p->width, p->y, p->x);
        wattron(p->win, color);
        wbkgd(p->win, color);
        keypad(p->win, TRUE);
        p->panel = new_panel(p->win);
        wattron(p->win, COLOR_PAIR(2));
        box(p->win, 0, 0);
        mvwprintw(p->win, 0, ((p->width - strlen(p->title)) / 2), p->title);
        wattroff(p->win, COLOR_PAIR(2));
        update_panels();
        doupdate();
        wmove(p->win, 1, 1);
        refresh();
    }
    return p;
}
Ejemplo n.º 21
0
static PANEL *
mkpanel(short color, int rows, int cols, int tly, int tlx)
{
    WINDOW *win;
    PANEL *pan = 0;
    char *userdata = typeMalloc(char, 3);

    if ((win = newwin(rows, cols, tly, tlx)) != 0) {
	keypad(win, TRUE);
	if ((pan = new_panel(win)) == 0) {
	    delwin(win);
	} else if (use_colors) {
	    short fg = (short) ((color == COLOR_BLUE)
				? COLOR_WHITE
				: COLOR_BLACK);
	    short bg = color;

	    init_pair(color, fg, bg);
	    wbkgdset(win, (chtype) (COLOR_PAIR(color) | ' '));
	} else if (!unboxed) {
	    wbkgdset(win, A_BOLD | ' ');
	}
    }
    sprintf(userdata, "p%d", color % 8);
    set_panel_userptr(pan, (NCURSES_CONST void *) userdata);
    return pan;
}
Ejemplo n.º 22
0
void tui_error_va(const char *prompt, const char *err, va_list vararg)
{
	WINDOW *win = newwin(4, 70, (LINES - 4) / 2, (COLS - 70) / 2);
	PANEL *panel = new_panel(win);

	wattrset(win, ERR_BORDER_ATTR);
	tx_colorwin(win);
	tx_box(win, ACS_VLINE, ACS_HLINE);
	wattrset(win, ERR_PROMPT_ATTR);
	mvwprintw(win, 2, 2, "%s", prompt);

	wattrset(win, ERR_TEXT_ATTR);
	wmove(win, 1, 2);

	vw_printw(win, err, vararg);

	update_panels();
	doupdate();

	int response;

	do {
		response = wgetch(win);
		if (response == 12)
			tx_refresh_screen();
	} while (response == 12);

	del_panel(panel);
	delwin(win);
	update_panels();
	doupdate();
}
Ejemplo n.º 23
0
bool InputForm::Init()
{
  field = (FIELD **)calloc(choices*2+1, sizeof(FIELD *));
  for (int i = 0; i < choices; ++i)
  {
    field[2*i] = new_field(1, 30, 4+i*2, 2, 02, 02);
    field[2*i+1] = new_field(1, 20, 4+i*2, 30, 02, 02);
    set_field_back(field[2*i+1], A_UNDERLINE);
    field_opts_off(field[2*i+1], O_AUTOSKIP);
    set_field_buffer(field[2*i], 0, itemNames[i].c_str());
    set_field_back(field[2*i], O_EDIT);
  }
  field[choices*2] = NULL;
  form = new_form(field);
  scale_form(form, &formRows, &formCols);
  win = newwin(formRows+8, formCols+20, LINES/2-formRows/2 -6, COLS/2-10-formCols/2);
  keypad(win, TRUE);
  set_form_win(form, win);
  set_form_sub(form, derwin(win, formRows, formCols, 2, 2));
  box(win, 0, 0);
  wattron(win, COLOR_PAIR(1));
  
  mvwprintw(win, 0, formCols/2+8-title.size()/2, "%s", title.c_str());
  wattroff(win, COLOR_PAIR(1));
  post_form(form);
  panel = new_panel(win);
  switchOkCancle();
  
  update_panels();
  doupdate();
  form_driver(form, REQ_NEXT_FIELD);
  return true;
}
Ejemplo n.º 24
0
void    setUpPanel(PANEL **my_panels, WINDOW **my_wins)
{
    /* 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();
    doupdate();
}
Ejemplo n.º 25
0
void pbstart(const char* filename, const char* url) {
    progressinfo.progwin = newwin(8, 52, (LINES-8)/2, (COLS-52)/2);
    progressinfo.pprogwin = new_panel(progressinfo.progwin);
    progressinfo.filename = filename;
    progressinfo.url = url;
    progressinfo.tstart = time(NULL);
}
Ejemplo n.º 26
0
/*
  Create a new window
  Window()
*/
int		lui_new_window(lua_State *L)
{
    int width	= luaL_checkint(L, 1);
    int height	= luaL_checkint(L, 2);
    int begin_x	= luaL_checkint(L, 3);
    int begin_y	= luaL_checkint(L, 4);
    WINDOW	*win;
    PANEL		*pan;

    win = newwin(height, width, begin_y, begin_x);
    wrefresh(win);
    pan = new_panel(win);

    update_panels();
    wnoutrefresh(win);
    doupdate();

    *((PANEL **) lua_newuserdata(L, sizeof(pan))) = pan;

    /* set instance metatable to registered methods */
    luaL_getmetatable(L, WINDOW_CLASS);
    lua_setmetatable(L, -2);

    return 1;
}
Ejemplo n.º 27
0
static void show_hostsort_keywin(WINDOW ** win, PANEL ** panel)
{
	*win = newwin(13, 35, (LINES - 10) / 2, COLS - 40);
	*panel = new_panel(*win);

	wattrset(*win, DLGBOXATTR);
	tx_colorwin(*win);
	tx_box(*win, ACS_VLINE, ACS_HLINE);

	wattrset(*win, DLGTEXTATTR);
	mvwprintw(*win, 2, 2, "Select sort criterion");
	wmove(*win, 4, 2);
	tx_printkeyhelp("P", " - total packets in", *win, DLGHIGHATTR,
			DLGTEXTATTR);
	wmove(*win, 5, 2);
	tx_printkeyhelp("I", " - IP packets in", *win, DLGHIGHATTR,
			DLGTEXTATTR);
	wmove(*win, 6, 2);
	tx_printkeyhelp("B", " - total bytes in", *win, DLGHIGHATTR,
			DLGTEXTATTR);
	wmove(*win, 7, 2);
	tx_printkeyhelp("K", " - total packets out", *win, DLGHIGHATTR,
			DLGTEXTATTR);
	wmove(*win, 8, 2);
	tx_printkeyhelp("O", " - IP packets out", *win, DLGHIGHATTR,
			DLGTEXTATTR);
	wmove(*win, 9, 2);
	tx_printkeyhelp("Y", " - total bytes out", *win, DLGHIGHATTR,
			DLGTEXTATTR);
	wmove(*win, 10, 2);
	tx_printkeyhelp("Any other key", " - cancel sort", *win, DLGHIGHATTR,
			DLGTEXTATTR);
	update_panels();
	doupdate();
}
Ejemplo n.º 28
0
/**
 * print_tcp_activity_overview_labels()
 * --------------------------------
 * displays the Activity Overview window, and prints the labels
 * associated with it.
 **/
void print_tcp_activity_overview_labels(WINDOW ** scanwin, PANEL ** scanpanel, int highlight)
{
  *scanwin = newwin(LINES - 5, 30, 3, 1);
  *scanpanel = new_panel(*scanwin);
  wattrset(*scanwin, BOXATTR);
  colorwin(*scanwin);
  box(*scanwin, ACS_VLINE, ACS_HLINE);
  mvwprintw(*scanwin, 0, 2, " Activity Overview ");

  wattrset(*scanwin, ACTIVEATTR);
  mvwprintw(*scanwin, 2, 2, "Access Point Information");
  wattrset(*scanwin, STDATTR);
  mvwprintw(*scanwin, 4, 3, "SSID:             ");
  mvwprintw(*scanwin, 5, 3, "BSSID: ");
  mvwprintw(*scanwin, 6, 3, "WEP: ");
  mvwprintw(*scanwin, 7, 3, "Channel:");
  mvwprintw(*scanwin, 8, 3, "Total # Nodes:");

  wattrset(*scanwin, BOXATTR);
  wmove(*scanwin, 10, 6);
  whline(*scanwin, ACS_HLINE, 15);
  
  wattrset(*scanwin, ACTIVEATTR);
  mvwprintw(*scanwin, 12, 2, "Selected Wireless Node");
  wattrset(*scanwin, STDATTR);
  mvwprintw(*scanwin, 14, 3, "MAC: ");
  mvwprintw(*scanwin, 15, 3, "IP Addr: ");

  wattrset(*scanwin, BOXATTR);
  mvwprintw(*scanwin, 17, 2, "TCP Related-Info");
  wattrset(*scanwin, STDATTR);  
  mvwprintw(*scanwin, 19, 3, "Total # Conns: ");
  mvwprintw(*scanwin, 20, 3, "Total pkts:    ");
  mvwprintw(*scanwin, 21, 3, "Total bytes: ");
  mvwprintw(*scanwin, 22, 3, "Existing pkts: ");
  mvwprintw(*scanwin, 23, 3, "Existing bytes: ");
  mvwprintw(*scanwin, 24, 3, "Retran pkts: ");
  mvwprintw(*scanwin, 25, 3, "Retran bytes: ");

  mvwprintw(*scanwin, 27, 3, "Waste (%%): ");

  wattrset(*scanwin, ACTIVEATTR);
  mvwprintw(*scanwin, 30, 2, "Data Setting");
  wattrset(*scanwin, STDATTR);
  mvwprintw(*scanwin, 32, 3, "Current View: ");
  
  wattrset(*scanwin, BOXATTR);
  wmove(*scanwin, 34, 6);
  whline(*scanwin, ACS_HLINE, 15);
 
  mvwprintw(*scanwin, 35, 3, "Press 'V' to view other");
  mvwprintw(*scanwin, 36, 3, "types of data");

  wattrset(*scanwin, STDATTR);
  mvwprintw(*scanwin, LINES - 7, 2, "Elapsed: "); 
  
  update_panels();
  doupdate();
}
Ejemplo n.º 29
0
WINDOW* prep_game(WINDOW *w_game, WINDOW *w_gamefrm, PANEL *p_game, PANEL *p_gamefrm, frame *game, frame *term, int *xPos, int *yPos, snake *snake){
    if(term->lines > MAX_Y)
        game->lines = MAX_Y; //consider border!
    else
        game->lines = term->lines; //leave space for messages
    if(term->cols > MAX_X)
        game->cols = MAX_X; //consider border!
    else
        game->cols = term->cols;
	//calc center
    game->centerY = (game->lines)/2;
	game->centerX = (game->cols)/2;
	//create window in center
    w_game = newwin(game->lines, game->cols, //size
                    (term->centerY)-(game->centerY), //posY
                    (term->centerX)-game->centerX); //posX

    w_gamefrm = newwin((game->lines)+2, (game->cols)+2,
                    (term->centerY)-(game->centerY)-1,
                    (term->centerX)-(game->centerX)-1);
    draw_border(w_gamefrm);

    /* Stack Panels on top of each other w/p_game is on top*/
    p_gamefrm = new_panel(w_gamefrm);
    p_game = new_panel(w_game);

	update_panels(); // update order of panels | IMPORTANT: only after all wins are inited
    doupdate(); //show updated panels
	
    //move cursor to center
    *xPos=game->centerX;
    *yPos=game->centerY;

	//invalidate lastPos
	snake->lastPos_h[0] = -1;
	snake->lastPos_h[1] = -1;
	snake->lastPos_t[0] = -1;
	snake->lastPos_t[1] = -1;
    do_refresh(w_game, xPos, yPos, NULL, snake);
	/* :::::WARNING:::::
	 * dragons ahead: the panel functions change the pointing destination of w_game
	 * you have to reset it in main, else you'll spend many hours of debugging not noticing that
	 * all stuff gets written in foreign address space!
	 */
	return w_game;
}
Ejemplo n.º 30
0
void print_tcp_breakdown_labels(WINDOW ** breakwin, PANEL ** breakpanel, int view)
{
  *breakwin = newwin(LINES / 2 - 2, COLS - 32, 3, 31);
  *breakpanel = new_panel(*breakwin);
  wattrset(*breakwin, BOXATTR);
  colorwin(*breakwin);
  box(*breakwin, ACS_VLINE, ACS_HLINE);
  mvwprintw(*breakwin, 0, 2, " TCP Performance Breakdown for Selected Node");

  wattrset(*breakwin, BOXATTR);
  mvwprintw(*breakwin, 3, 3, "Connections:");
  mvwprintw(*breakwin, 2, 24, "Service");
  mvwprintw(*breakwin, 3, 24, "   Port");

  wattrset(*breakwin, STDATTR);
  switch (view)
    {
    case CONNECTIONS:
      mvwprintw(*breakwin, 2, 37, "-Connections-");
      mvwprintw(*breakwin, 3, 34, "Total|Open|Closed");
      mvwprintw(*breakwin, 2, 54, "Reset");
      mvwprintw(*breakwin, 3, 54, "Count");
      mvwprintw(*breakwin, 2, 61, "  Total");
      mvwprintw(*breakwin, 3, 61, "Packets");
      mvwprintw(*breakwin, 2, 72, "Total");
      mvwprintw(*breakwin, 3, 72, "Bytes");
      wattrset(*breakwin, BOXATTR);
      mvwprintw(*breakwin, 3, 80, "STATUS");    
      break;
    case STATISTICS:
      mvwprintw(*breakwin, 2, 36, " -Incoming-");
      mvwprintw(*breakwin, 3, 35, "Count | Bytes");
      mvwprintw(*breakwin, 2, 53, " -Outgoing-");
      mvwprintw(*breakwin, 3, 52, "Count | Bytes");
      mvwprintw(*breakwin, 2, 69, " -Retransmit-");
      mvwprintw(*breakwin, 3, 69, "Count | Bytes");
      break;
    case PERF_LATENCY:
      mvwprintw(*breakwin, 2, 35, "  Incoming (ms)");
      mvwprintw(*breakwin, 3, 35, "Observed|Actual");
      mvwprintw(*breakwin, 2, 53, "  Outgoing (ms)");
      mvwprintw(*breakwin, 3, 53, "Observed|Actual");
      mvwprintw(*breakwin, 2, 72, "Round-trip");
      mvwprintw(*breakwin, 3, 72, " time (ms)");
      break;
    case PERF_BANDWIDTH:
      mvwprintw(*breakwin, 2, 35, "Incoming (Kbps)");
      mvwprintw(*breakwin, 3, 35, "Current|Highest");
      mvwprintw(*breakwin, 2, 52, "Outgoing (Kbps)");
      mvwprintw(*breakwin, 3, 52, "Current|Highest");
      mvwprintw(*breakwin, 2, 72, "Total (Kbps)");
      mvwprintw(*breakwin, 3, 69, "Current|Highest");
      break;
    }

  update_panels();
  doupdate();
}