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); }
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; }
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; }
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(); }
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; }
void msg_diff_create(ui_t *ui) { int hwidth; msg_diff_info_t *info; // Create a new panel to fill all the screen ui_panel_create(ui, LINES, COLS); // Initialize panel specific data info = sng_malloc(sizeof(msg_diff_info_t)); // Store it into panel userptr set_panel_userptr(ui->panel, (void*) info); // Calculate subwindows width hwidth = ui->width / 2 - 1; // Create 2 subwindows, one for each message info->one_win = subwin(ui->win, ui->height - 2, hwidth, 1, 0); info->two_win = subwin(ui->win, ui->height - 2, hwidth, 1, hwidth + 1); // Header - Footer - Address // Draw a vertical line to separe both subwindows mvwvline(ui->win, 0, hwidth, ACS_VLINE, ui->height); // Draw title ui_set_title(ui, "sngrep - SIP messages flow viewer"); // Draw keybindings msg_diff_draw_footer(ui); }
/* Set the PANEL_DATA structures for individual panels */ void set_user_ptrs(PANEL **panels, int n) { PANEL_DATA *ptrs; WINDOW *win; int x, y, w, h, i; char temp[80]; ptrs = (PANEL_DATA *)calloc(n, sizeof(PANEL_DATA)); for(i = 0;i < n; ++i) { win = panel_window(panels[i]); getbegyx(win, y, x); getmaxyx(win, h, w); ptrs[i].x = x; ptrs[i].y = y; ptrs[i].w = w; ptrs[i].h = h; sprintf(temp, "Window Number %d", i + 1); strcpy(ptrs[i].label, temp); ptrs[i].label_color = i + 1; if(i + 1 == n) ptrs[i].next = panels[0]; else ptrs[i].next = panels[i + 1]; set_panel_userptr(panels[i], &ptrs[i]); } }
SCM gucu_set_panel_userdata (SCM pan, SCM data) { if (_scm_is_panel (pan)) { set_panel_userptr (_scm_to_panel (pan), (void *) data); } else scm_wrong_type_arg ("set-panel-userdata", SCM_ARG1, pan); return SCM_UNDEFINED; }
void panel_stack_push(struct aug_plugin *plugin, int nlines, int ncols, int begin_y, int begin_x) { WINDOW *win; PANEL *panel; win = newwin(nlines, ncols, begin_y, begin_x); if(win == NULL) err_exit(0, "newwin failed!"); panel = new_panel(win); if(panel == NULL) err_exit(0, "new_panel failed!"); if(set_panel_userptr(panel, plugin) == ERR) err_exit(0, "set_panel_userptr failed!"); }
PANEL * call_raw_create() { PANEL *panel; call_raw_info_t *info; // Create a new panel to fill all the screen panel = new_panel(newwin(LINES, COLS, 0, 0)); // Initialize Call List specific data info = sng_malloc(sizeof(call_raw_info_t)); // Store it into panel userptr set_panel_userptr(panel, (void*) info); // Create a initial pad of 1000 lines info->pad = newpad(500, COLS); info->padline = 0; info->scroll = 0; return panel; }
void setup_windows(void) { int y_begin = 1; if (tui_disabled) return; getmaxyx(stdscr, maxy, maxx); resizeterm(maxy, maxx); title_bar_window = subwin(stdscr, TITLE_BAR_HIGHT, maxx, 0, 0); y_begin += TITLE_BAR_HIGHT; tz_sensor_window = subwin(stdscr, SENSOR_WIN_HIGHT, maxx, y_begin, 0); y_begin += SENSOR_WIN_HIGHT; cooling_device_window = subwin(stdscr, ptdata.nr_cooling_dev + 3, maxx, y_begin, 0); y_begin += ptdata.nr_cooling_dev + 3; /* 2 lines for border */ /* two lines to show borders, one line per tz show trip point position * and value. * dialogue window is a pop-up, when needed it lays on top of cdev win */ dialogue_window = subwin(stdscr, ptdata.nr_cooling_dev+5, maxx-50, DIAG_Y, DIAG_X); thermal_data_window = subwin(stdscr, ptdata.nr_tz_sensor * NR_LINES_TZDATA + 3, maxx, y_begin, 0); y_begin += ptdata.nr_tz_sensor * NR_LINES_TZDATA + 3; control_window = subwin(stdscr, 4, maxx, y_begin, 0); scrollok(cooling_device_window, TRUE); maxwidth = maxx - 18; status_bar_window = subwin(stdscr, 1, maxx, maxy-1, 0); strcpy(status_bar_slots[0], " Ctrl-c - Quit "); strcpy(status_bar_slots[1], " TAB - Tuning "); wmove(status_bar_window, 1, 30); /* prepare panels for dialogue, if panel already created then we must * be doing resizing, so just replace windows with new ones, old ones * should have been deleted by close_window */ data_panel = new_panel(cooling_device_window); if (!data_panel) syslog(LOG_DEBUG, "No data panel\n"); else { if (dialogue_window) { dialogue_panel = new_panel(dialogue_window); if (!dialogue_panel) syslog(LOG_DEBUG, "No dialogue panel\n"); else { /* Set up the user pointer to the next panel*/ set_panel_userptr(data_panel, dialogue_panel); set_panel_userptr(dialogue_panel, data_panel); top = data_panel; } } else syslog(LOG_INFO, "no dialogue win, term too small\n"); } doupdate(); werase(stdscr); refresh(); }
static VALUE rbncurs_c_set_panel_userptr(VALUE rb_panel, VALUE userptr) { return INT2NUM(set_panel_userptr(get_panel(rb_panel), (void*)(userptr))); }
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; }
void column_select_create(ui_t *ui) { int attr_id, column; MENU *menu; column_select_info_t *info; // Cerate a new indow for the panel and form ui_panel_create(ui, 20, 60); // Initialize Filter panel specific data info = sng_malloc(sizeof(column_select_info_t)); // Store it into panel userptr set_panel_userptr(ui->panel, (void*) info); // Initialize the fields info->fields[FLD_COLUMNS_ACCEPT] = new_field(1, 10, ui->height - 2, 13, 0, 0); info->fields[FLD_COLUMNS_SAVE] = new_field(1, 10, ui->height - 2, 25, 0, 0); info->fields[FLD_COLUMNS_CANCEL] = new_field(1, 10, ui->height - 2, 37, 0, 0); info->fields[FLD_COLUMNS_COUNT] = NULL; // Field Labels set_field_buffer(info->fields[FLD_COLUMNS_ACCEPT], 0, "[ Accept ]"); set_field_buffer(info->fields[FLD_COLUMNS_SAVE], 0, "[ Save ]"); set_field_buffer(info->fields[FLD_COLUMNS_CANCEL], 0, "[ Cancel ]"); // Create the form and post it info->form = new_form(info->fields); set_form_sub(info->form, ui->win); post_form(info->form); // Create a subwin for the menu area info->menu_win = derwin(ui->win, 10, ui->width - 2, 7, 0); // Initialize one field for each attribute for (attr_id = 0; attr_id < SIP_ATTR_COUNT; attr_id++) { // Create a new field for this column info->items[attr_id] = new_item("[ ]", sip_attr_get_description(attr_id)); set_item_userptr(info->items[attr_id], (void*) sip_attr_get_name(attr_id)); } info->items[SIP_ATTR_COUNT] = NULL; // Create the columns menu and post it info->menu = menu = new_menu(info->items); // Set current enabled fields // FIXME Stealing Call list columns :/ call_list_info_t *list_info = call_list_info(ui_find_by_type(PANEL_CALL_LIST)); // Enable current enabled fields and move them to the top for (column = 0; column < list_info->columncnt; column++) { const char *attr = list_info->columns[column].attr; for (attr_id = 0; attr_id < item_count(menu); attr_id++) { if (!strcmp(item_userptr(info->items[attr_id]), attr)) { column_select_toggle_item(ui, info->items[attr_id]); column_select_move_item(ui, info->items[attr_id], column); break; } } } // Set main window and sub window set_menu_win(menu, ui->win); set_menu_sub(menu, derwin(ui->win, 10, ui->width - 5, 7, 2)); set_menu_format(menu, 10, 1); set_menu_mark(menu, ""); set_menu_fore(menu, COLOR_PAIR(CP_DEF_ON_BLUE)); menu_opts_off(menu, O_ONEVALUE); post_menu(menu); // Draw a scrollbar to the right info->scroll = ui_set_scrollbar(info->menu_win, SB_VERTICAL, SB_RIGHT); info->scroll.max = item_count(menu) - 1; ui_scrollbar_draw(info->scroll); // Set the window title and boxes mvwprintw(ui->win, 1, ui->width / 2 - 14, "Call List columns selection"); wattron(ui->win, COLOR_PAIR(CP_BLUE_ON_DEF)); title_foot_box(ui->panel); mvwhline(ui->win, 6, 1, ACS_HLINE, ui->width - 1); mvwaddch(ui->win, 6, 0, ACS_LTEE); mvwaddch(ui->win, 6, ui->width - 1, ACS_RTEE); wattroff(ui->win, COLOR_PAIR(CP_BLUE_ON_DEF)); // Some brief explanation abotu what window shows wattron(ui->win, COLOR_PAIR(CP_CYAN_ON_DEF)); mvwprintw(ui->win, 3, 2, "This windows show the list of columns displayed on Call"); mvwprintw(ui->win, 4, 2, "List. You can enable/disable using Space Bar and reorder"); mvwprintw(ui->win, 5, 2, "them using + and - keys."); wattroff(ui->win, COLOR_PAIR(CP_CYAN_ON_DEF)); info->form_active = 0; }
void save_create(ui_t *ui) { save_info_t *info; char savepath[128]; // Pause the capture while saving capture_set_paused(1); // Cerate a new indow for the panel and form ui_panel_create(ui, 15, 68); // Initialize save panel specific data info = sng_malloc(sizeof(save_info_t)); // Store it into panel userptr set_panel_userptr(ui->panel, (void*) info); // Initialize the fields int total, displayed; info->fields[FLD_SAVE_PATH] = new_field(1, 52, 3, 13, 0, 0); info->fields[FLD_SAVE_FILE] = new_field(1, 47, 4, 13, 0, 0); info->fields[FLD_SAVE_ALL] = new_field(1, 1, 7, 4, 0, 0); info->fields[FLD_SAVE_SELECTED] = new_field(1, 1, 8, 4, 0, 0); info->fields[FLD_SAVE_DISPLAYED] = new_field(1, 1, 9, 4, 0, 0); info->fields[FLD_SAVE_MESSAGE] = new_field(1, 1, 10, 4, 0, 0); info->fields[FLD_SAVE_PCAP] = new_field(1, 1, 7, 36, 0, 0); info->fields[FLD_SAVE_PCAP_RTP] = new_field(1, 1, 8, 36, 0, 0); info->fields[FLD_SAVE_TXT] = new_field(1, 1, 9, 36, 0, 0); info->fields[FLD_SAVE_SAVE] = new_field(1, 10, ui->height - 2, 20, 0, 0); info->fields[FLD_SAVE_CANCEL] = new_field(1, 10, ui->height - 2, 40, 0, 0); info->fields[FLD_SAVE_COUNT] = NULL; // Set fields options field_opts_off(info->fields[FLD_SAVE_PATH], O_AUTOSKIP); field_opts_off(info->fields[FLD_SAVE_FILE], O_AUTOSKIP); field_opts_off(info->fields[FLD_SAVE_ALL], O_AUTOSKIP); field_opts_off(info->fields[FLD_SAVE_SELECTED], O_AUTOSKIP); field_opts_off(info->fields[FLD_SAVE_DISPLAYED], O_AUTOSKIP); field_opts_off(info->fields[FLD_SAVE_MESSAGE], O_VISIBLE); // Change background of input fields set_field_back(info->fields[FLD_SAVE_PATH], A_UNDERLINE); set_field_back(info->fields[FLD_SAVE_FILE], A_UNDERLINE); // Disable Save RTP if RTP packets are not being captured if (!setting_enabled(SETTING_CAPTURE_RTP)) field_opts_off(info->fields[FLD_SAVE_PCAP_RTP], O_ACTIVE); // Create the form and post it info->form = new_form(info->fields); set_form_sub(info->form, ui->win); post_form(info->form); form_opts_off(info->form, O_BS_OVERLOAD); // Set Default field values sprintf(savepath, "%s", setting_get_value(SETTING_SAVEPATH)); set_field_buffer(info->fields[FLD_SAVE_PATH], 0, savepath); set_field_buffer(info->fields[FLD_SAVE_SAVE], 0, "[ Save ]"); set_field_buffer(info->fields[FLD_SAVE_CANCEL], 0, "[ Cancel ]"); // Set window boxes wattron(ui->win, COLOR_PAIR(CP_BLUE_ON_DEF)); // Window border title_foot_box(ui->panel); // Header and footer lines mvwhline(ui->win, ui->height - 3, 1, ACS_HLINE, ui->width - 1); mvwaddch(ui->win, ui->height - 3, 0, ACS_LTEE); mvwaddch(ui->win, ui->height - 3, ui->width - 1, ACS_RTEE); // Save mode box mvwaddch(ui->win, 6, 2, ACS_ULCORNER); mvwhline(ui->win, 6, 3, ACS_HLINE, 30); mvwaddch(ui->win, 6, 32, ACS_URCORNER); mvwvline(ui->win, 7, 2, ACS_VLINE, 4); mvwvline(ui->win, 7, 32, ACS_VLINE, 4); mvwaddch(ui->win, 11, 2, ACS_LLCORNER); mvwhline(ui->win, 11, 3, ACS_HLINE, 30); mvwaddch(ui->win, 11, 32, ACS_LRCORNER); // Save mode box mvwaddch(ui->win, 6, 34, ACS_ULCORNER); mvwhline(ui->win, 6, 35, ACS_HLINE, 30); mvwaddch(ui->win, 6, 64, ACS_URCORNER); mvwvline(ui->win, 7, 34, ACS_VLINE, 3); mvwvline(ui->win, 7, 64, ACS_VLINE, 3); mvwaddch(ui->win, 10, 34, ACS_LLCORNER); mvwhline(ui->win, 10, 35, ACS_HLINE, 30); mvwaddch(ui->win, 10, 64, ACS_LRCORNER); wattroff(ui->win, COLOR_PAIR(CP_BLUE_ON_DEF)); // Set screen labels mvwprintw(ui->win, 1, 27, "Save capture"); mvwprintw(ui->win, 3, 3, "Path:"); mvwprintw(ui->win, 4, 3, "Filename:"); wattron(ui->win, COLOR_PAIR(CP_BLUE_ON_DEF)); mvwprintw(ui->win, 6, 4, " Dialogs "); mvwprintw(ui->win, 6, 36, " Format "); wattroff(ui->win, COLOR_PAIR(CP_BLUE_ON_DEF)); // Set default cursor position set_current_field(info->form, info->fields[FLD_SAVE_FILE]); form_driver(info->form, REQ_END_LINE); curs_set(1); // Get filter stats sip_stats_t stats = sip_calls_stats(); // Set default save modes info->savemode = (stats.displayed == stats.total) ? SAVE_ALL : SAVE_DISPLAYED; info->saveformat = (setting_enabled(SETTING_CAPTURE_RTP))? SAVE_PCAP_RTP : SAVE_PCAP; }
PANEL * filter_create() { PANEL *panel; WINDOW *win; int height, width; filter_info_t *info; const char *method; // Calculate window dimensions height = 16; width = 50; // Cerate a new indow for the panel and form win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2); // Create a new panel panel = new_panel(win); // Initialize Filter panel specific data info = sng_malloc(sizeof(filter_info_t)); // Store it into panel userptr set_panel_userptr(panel, (void*) info); // Initialize the fields info->fields[FLD_FILTER_SIPFROM] = new_field(1, 28, 3, 18, 0, 0); info->fields[FLD_FILTER_SIPTO] = new_field(1, 28, 4, 18, 0, 0); info->fields[FLD_FILTER_SRC] = new_field(1, 18, 5, 18, 0, 0); info->fields[FLD_FILTER_DST] = new_field(1, 18, 6, 18, 0, 0); info->fields[FLD_FILTER_PAYLOAD] = new_field(1, 28, 7, 18, 0, 0); info->fields[FLD_FILTER_REGISTER] = new_field(1, 1, 9, 15, 0, 0); info->fields[FLD_FILTER_INVITE] = new_field(1, 1, 10, 15, 0, 0); info->fields[FLD_FILTER_SUBSCRIBE] = new_field(1, 1, 11, 15, 0, 0); info->fields[FLD_FILTER_NOTIFY] = new_field(1, 1, 12, 15, 0, 0); info->fields[FLD_FILTER_OPTIONS] = new_field(1, 1, 9, 37, 0, 0); info->fields[FLD_FILTER_PUBLISH] = new_field(1, 1, 10, 37, 0, 0); info->fields[FLD_FILTER_MESSAGE] = new_field(1, 1, 11, 37, 0, 0); info->fields[FLD_FILTER_FILTER] = new_field(1, 10, height - 2, 11, 0, 0); info->fields[FLD_FILTER_CANCEL] = new_field(1, 10, height - 2, 30, 0, 0); info->fields[FLD_FILTER_COUNT] = NULL; // Set fields options field_opts_off(info->fields[FLD_FILTER_SIPFROM], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_SIPTO], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_SRC], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_DST], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_PAYLOAD], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_REGISTER], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_INVITE], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_SUBSCRIBE], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_NOTIFY], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_OPTIONS], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_PUBLISH], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_MESSAGE], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_FILTER], O_EDIT); field_opts_off(info->fields[FLD_FILTER_CANCEL], O_EDIT); // Change background of input fields set_field_back(info->fields[FLD_FILTER_SIPFROM], A_UNDERLINE); set_field_back(info->fields[FLD_FILTER_SIPTO], A_UNDERLINE); set_field_back(info->fields[FLD_FILTER_SRC], A_UNDERLINE); set_field_back(info->fields[FLD_FILTER_DST], A_UNDERLINE); set_field_back(info->fields[FLD_FILTER_PAYLOAD], A_UNDERLINE); // Create the form and post it info->form = new_form(info->fields); set_form_sub(info->form, win); post_form(info->form); // Fields labels mvwprintw(win, 3, 3, "SIP From:"); mvwprintw(win, 4, 3, "SIP To:"); mvwprintw(win, 5, 3, "Source:"); mvwprintw(win, 6, 3, "Destination:"); mvwprintw(win, 7, 3, "Payload:"); mvwprintw(win, 9, 3, "REGISTER [ ]"); mvwprintw(win, 10, 3, "INVITE [ ]"); mvwprintw(win, 11, 3, "SUBSCRIBE [ ]"); mvwprintw(win, 12, 3, "NOTIFY [ ]"); mvwprintw(win, 9, 25, "OPTIONS [ ]"); mvwprintw(win, 10, 25, "PUBLISH [ ]"); mvwprintw(win, 11, 25, "MESSAGE [ ]"); // Get Method filter if (!(method = filter_get(FILTER_METHOD))) method = setting_get_value(SETTING_FILTER_METHODS); // Set Default field values set_field_buffer(info->fields[FLD_FILTER_SIPFROM], 0, filter_get(FILTER_SIPFROM)); set_field_buffer(info->fields[FLD_FILTER_SIPTO], 0, filter_get(FILTER_SIPTO)); set_field_buffer(info->fields[FLD_FILTER_SRC], 0, filter_get(FILTER_SOURCE)); set_field_buffer(info->fields[FLD_FILTER_DST], 0, filter_get(FILTER_DESTINATION)); set_field_buffer(info->fields[FLD_FILTER_PAYLOAD], 0, filter_get(FILTER_PAYLOAD)); set_field_buffer(info->fields[FLD_FILTER_REGISTER], 0, strcasestr(method, sip_method_str(SIP_METHOD_REGISTER)) ? "*" : ""); set_field_buffer(info->fields[FLD_FILTER_INVITE], 0, strcasestr(method, sip_method_str(SIP_METHOD_INVITE)) ? "*" : ""); set_field_buffer(info->fields[FLD_FILTER_SUBSCRIBE], 0, strcasestr(method,sip_method_str(SIP_METHOD_SUBSCRIBE)) ? "*" : ""); set_field_buffer(info->fields[FLD_FILTER_NOTIFY], 0, strcasestr(method, sip_method_str(SIP_METHOD_NOTIFY)) ? "*" : ""); set_field_buffer(info->fields[FLD_FILTER_OPTIONS], 0, strcasestr(method, sip_method_str(SIP_METHOD_OPTIONS)) ? "*" : ""); set_field_buffer(info->fields[FLD_FILTER_PUBLISH], 0, strcasestr(method, sip_method_str(SIP_METHOD_PUBLISH)) ? "*" : ""); set_field_buffer(info->fields[FLD_FILTER_MESSAGE], 0, strcasestr(method, sip_method_str(SIP_METHOD_MESSAGE)) ? "*" : ""); set_field_buffer(info->fields[FLD_FILTER_FILTER], 0, "[ Filter ]"); set_field_buffer(info->fields[FLD_FILTER_CANCEL], 0, "[ Cancel ]"); // Set the window title and boxes mvwprintw(win, 1, 18, "Filter options"); wattron(win, COLOR_PAIR(CP_BLUE_ON_DEF)); title_foot_box(panel); mvwhline(win, 8, 1, ACS_HLINE, 49); mvwaddch(win, 8, 0, ACS_LTEE); mvwaddch(win, 8, 49, ACS_RTEE); wattroff(win, COLOR_PAIR(CP_BLUE_ON_DEF)); // Set default cursor position set_current_field(info->form, info->fields[FLD_FILTER_SIPFROM]); wmove(win, 3, 18); curs_set(1); return panel; }
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, <ab->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(); }
PANEL * call_list_create() { PANEL *panel; WINDOW *win; int height, width, i, attrid, collen; call_list_info_t *info; char option[80]; const char *field, *title; // Create a new panel that fill all the screen panel = new_panel(newwin(LINES, COLS, 0, 0)); // Initialize Call List specific data info = sng_malloc(sizeof(call_list_info_t)); // Store it into panel userptr set_panel_userptr(panel, (void*) info); // Add configured columns for (i = 0; i < SIP_ATTR_COUNT; i++) { // Get column attribute name from options sprintf(option, "cl.column%d", i); if ((field = get_option_value(option))) { if ((attrid = sip_attr_from_name(field)) == -1) continue; // Get column width from options sprintf(option, "cl.column%d.width", i); if ((collen = get_option_int_value(option)) == -1) collen = sip_attr_get_width(attrid); // Get column title title = sip_attr_get_title(attrid); // Add column to the list call_list_add_column(panel, attrid, field, title, collen); } } // Let's draw the fixed elements of the screen win = panel_window(panel); getmaxyx(win, height, width); // Initialize the fields info->fields[FLD_LIST_FILTER] = new_field(1, width - 19, 2, 18, 0, 0); info->fields[FLD_LIST_COUNT] = NULL; // Create the form and post it info->form = new_form(info->fields); set_form_sub(info->form, win); // Form starts inactive call_list_form_activate(panel, 0); // Calculate available printable area info->list_win = subwin(win, height - 5, width, 4, 0); info->group = call_group_create(); // Get current call list info->calls = sip_calls_iterator(); vector_iterator_set_filter(&info->calls, filter_check_call); info->cur_call = info->first_call = -1; // Set autoscroll default status info->autoscroll = setting_enabled(SETTING_CL_AUTOSCROLL); // Apply initial configured method filters filter_method_from_setting(setting_get_value(SETTING_FILTER_METHODS)); // Return the created panel return panel; }
int main(int argc, char **argv) { int itmp, y; if (argc > 1 && atol(argv[1])) nap_msec = atol(argv[1]); #ifdef XCURSES Xinitscr(argc, argv); #else initscr(); #endif backfill(); for (y = 0; y < 5; y++) { p1 = mkpanel(10, 10, 0, 0); set_panel_userptr(p1, "p1"); p2 = mkpanel(14, 14, 5, 5); set_panel_userptr(p2, "p2"); p3 = mkpanel(6, 8, 12, 12); set_panel_userptr(p3, "p3"); p4 = mkpanel(10, 10, 10, 30); w4 = panel_window(p4); set_panel_userptr(p4, "p4"); p5 = mkpanel(10, 10, 13, 37); w5 = panel_window(p5); set_panel_userptr(p5, "p5"); fill_panel(p1); fill_panel(p2); fill_panel(p3); fill_panel(p4); fill_panel(p5); hide_panel(p4); hide_panel(p5); pflush(); wait_a_while(nap_msec); saywhat("h3 s1 s2 s4 s5;"); move_panel(p1, 0, 0); hide_panel(p3); show_panel(p1); show_panel(p2); show_panel(p4); show_panel(p5); pflush(); wait_a_while(nap_msec); saywhat("s1;"); show_panel(p1); pflush(); wait_a_while(nap_msec); saywhat("s2;"); show_panel(p2); pflush(); wait_a_while(nap_msec); saywhat("m2;"); move_panel(p2, 10, 10); pflush(); wait_a_while(nap_msec); saywhat("s3;"); show_panel(p3); pflush(); wait_a_while(nap_msec); saywhat("m3;"); move_panel(p3, 5, 5); pflush(); wait_a_while(nap_msec); saywhat("b3;"); bottom_panel(p3); pflush(); wait_a_while(nap_msec); saywhat("s4;"); show_panel(p4); pflush(); wait_a_while(nap_msec); saywhat("s5;"); show_panel(p5); pflush(); wait_a_while(nap_msec); saywhat("t3;"); top_panel(p3); pflush(); wait_a_while(nap_msec); saywhat("t1;"); top_panel(p1); pflush(); wait_a_while(nap_msec); saywhat("t2;"); top_panel(p2); pflush(); wait_a_while(nap_msec); saywhat("t3;"); top_panel(p3); pflush(); wait_a_while(nap_msec); saywhat("t4;"); top_panel(p4); pflush(); wait_a_while(nap_msec); for (itmp = 0; itmp < 6; itmp++) { saywhat("m4;"); mvwaddstr(w4, 3, 1, mod[itmp]); move_panel(p4, 4, itmp * 10); mvwaddstr(w5, 4, 1, mod[itmp]); pflush(); wait_a_while(nap_msec); saywhat("m5;"); mvwaddstr(w4, 4, 1, mod[itmp]); move_panel(p5, 7, itmp * 10 + 6); mvwaddstr(w5, 3, 1, mod[itmp]); pflush(); wait_a_while(nap_msec); } saywhat("m4;"); move_panel(p4, 4, itmp * 10); pflush(); wait_a_while(nap_msec); saywhat("t5;"); top_panel(p5); pflush(); wait_a_while(nap_msec); saywhat("t2;"); top_panel(p2); pflush(); wait_a_while(nap_msec); saywhat("t1;"); top_panel(p1); pflush(); wait_a_while(nap_msec); saywhat("d2;"); rmpanel(p2); pflush(); wait_a_while(nap_msec); saywhat("h3;"); hide_panel(p3); pflush(); wait_a_while(nap_msec); saywhat("d1;"); rmpanel(p1); pflush(); wait_a_while(nap_msec); saywhat("d4; "); rmpanel(p4); pflush(); wait_a_while(nap_msec); saywhat("d5; "); rmpanel(p5); pflush(); wait_a_while(nap_msec); if (nap_msec == 1) break; nap_msec = 100L; } endwin(); return 0; } /* end of main */
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; }
/** * Join panels into double linked list */ void joinWindows(struct panelw *current, struct panelw *next) { current->next = next; next->prev = current; set_panel_userptr(current->panel, next->panel); }
PANEL * save_raw_create() { PANEL *panel; WINDOW *win; int height, width; save_raw_info_t *info; char savefile[128]; // Calculate window dimensions height = 10; width = 90; // Cerate a new indow for the panel and form win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2); // Create a new panel panel = new_panel(win); // Initialize save panel specific data info = malloc(sizeof(save_raw_info_t)); memset(info, 0, sizeof(save_raw_info_t)); // Store it into panel userptr set_panel_userptr(panel, (void*) info); // Initialize the fields info->fields[FLD_SAVE_RAW_FILE] = new_field(1, 68, 3, 15, 0, 0); info->fields[FLD_SAVE_RAW_SELECTED] = new_field(1, 1, 4, 5, 0, 0); info->fields[FLD_SAVE_RAW_SAVE] = new_field(1, 10, height - 2, 30, 0, 0); info->fields[FLD_SAVE_RAW_CANCEL] = new_field(1, 10, height - 2, 50, 0, 0); info->fields[FLD_SAVE_RAW_COUNT] = NULL; // Set fields options field_opts_off(info->fields[FLD_SAVE_RAW_FILE], O_AUTOSKIP); // Change background of input fields set_field_back(info->fields[FLD_SAVE_RAW_FILE], A_UNDERLINE); // Create the form and post it info->form = new_form(info->fields); set_form_sub(info->form, win); post_form(info->form); // Fields labels mvwprintw(win, 3, 3, "Save file:"); mvwprintw(win, 4, 4, "[ ] Only save selected calls"); // Set Default field values sprintf(savefile, "%s/sngrep-raw-%u.txt", get_option_value("sngrep.savepath"), (unsigned) time(NULL)); set_field_buffer(info->fields[FLD_SAVE_RAW_FILE], 0, savefile); set_field_buffer(info->fields[FLD_SAVE_RAW_SELECTED], 0, is_option_enabled("sngrep.saveselected") ? "*" : ""); set_field_buffer(info->fields[FLD_SAVE_RAW_SAVE], 0, "[ Save ]"); set_field_buffer(info->fields[FLD_SAVE_RAW_CANCEL], 0, "[ Cancel ]"); // Set the window title and boxes mvwprintw(win, 1, 28, "Save raw data to file"); wattron(win, COLOR_PAIR(CP_BLUE_ON_DEF)); title_foot_box(panel_window(panel)); mvwhline(win, height - 3, 1, ACS_HLINE, width - 1); mvwaddch(win, height - 3, 0, ACS_LTEE); mvwaddch(win, height - 3, width - 1, ACS_RTEE); wattroff(win, COLOR_PAIR(CP_BLUE_ON_DEF)); // Set default cursor position set_current_field(info->form, info->fields[FLD_SAVE_RAW_FILE]); wmove(win, 3, 15); curs_set(1); return panel; }