Beispiel #1
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);  
}
Beispiel #2
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);
}
static void
canned_panel(PANEL * px[MAX_PANELS + 1], NCURSES_CONST char *cmd)
{
    int which = cmd[1] - '0';

    saywhat(cmd);
    switch (*cmd) {
    case 'h':
	hide_panel(px[which]);
	break;
    case 's':
	show_panel(px[which]);
	break;
    case 't':
	top_panel(px[which]);
	break;
    case 'b':
	bottom_panel(px[which]);
	break;
    case 'd':
	rmpanel(px[which]);
	break;
    }
    pflush();
    wgetch(stdscr);
}
Beispiel #4
0
int ConWindow::readKey()
{
    top_panel(pan);
    update_panels();
    doupdate();

    return wgetch(win);
} // end ConWindow::readKey
Beispiel #5
0
/**
 * Swaps between the 2 panels depending on whether the low or high
 * limit is set.
 */
static void
magic_swap_panels(volatile struct readline_session_context *ctx, bool fwd)
{
    if (panel_state == PANEL1_ACTIVE) {
	ctx->act = panel_window(readline_pan2);
	(void) top_panel(readline_pan2);
	panel_state = PANEL2_ACTIVE;
    } else if (panel_state == PANEL2_ACTIVE) {
	ctx->act = panel_window(readline_pan1);
	(void) top_panel(readline_pan1);
	panel_state = PANEL1_ACTIVE;
    } else {
	sw_assert_not_reached();
    }

    write_cmdprompt(ctx->act, ctx->prompt, ctx->prompt_size);
    compute_new_window_entry(ctx, fwd);
}
Beispiel #6
0
/**
 * map_control -- draw a cursor on the screen and accept control from FSM
 * @ch: the input word from the FSM
 */
int map_control(int ch)
{
        bool dozoom = false;
        struct map_t *tmp;

        if (!nav_win)
                map_cursor_init();

        top_panel(nav_pan);

        switch (ch) 
        {
        case MODE_STARTED:
                map_controls_active = true;
                cursor->Show(cursor);
                show_panel(nav_pan);
                break;
                
        /* Scroll the map in a direction */
        case 'w': case 'a': case 's': case 'd':
        case 'W': case 'A': case 'S': case 'D':
                map_scroll(MAPBOOK->active, ch);
                break;

        /* Move the zoom frame in a direction */
        case 'h': case 'j': case 'k': case 'l':
        case 'H': case 'J': case 'K': case 'L':
                cursor->Move(cursor, ch);
                break;

        /* Select the current zoom frame */
        case '\n':
                dozoom = true;
                break;

        case KEY_ESC:
        case 'm':
                map_controls_active = false;
                show_dock();
                cursor->Hide(cursor);
                hide_panel(nav_pan);
                return MODE_RELEASE;
        }

        /* Adjust for changing y0 or x0 of the map pad */
        y_map = pos_y(cursor->pos) + pos_y(ACTIVE->pos);
        x_map = pos_x(cursor->pos) + pos_x(ACTIVE->pos);
        zoomlevel = MAPBOOK->page;

        print_map_control(y_map, x_map);
        draw_zoom_box(ACTIVE, y_map, x_map);

        if (dozoom)
                set_zoom(MAPBOOK, y_map, x_map);

        return MODE_PERSIST;
}
Beispiel #7
0
void update_map_control(void)
{
        if (!map_controls_active)
                return;

        hide_dock();
        show_panel(nav_pan);
        top_panel(nav_pan);
}
Beispiel #8
0
static inline void
unlock_ncurses(void){
	if(active){
		assert(top_panel(active->p) != ERR);
	}
	screen_update();
	check_consistency();
	assert(pthread_mutex_unlock(&bfl) == 0);
}
Beispiel #9
0
static void
packet_callback(omphalos_packet *op){
	pthread_mutex_lock(&bfl); // don't always want screen_update()
	if(packet_cb_locked(op->i,op,&details)){
		if(active){
			assert(top_panel(active->p) != ERR);
		}
		screen_update();
	}
	pthread_mutex_unlock(&bfl);
}
Beispiel #10
0
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;
}
Beispiel #11
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;
}
Beispiel #12
0
void pLScreen::restore_panel_stack()
{
	// Restore saved panels for this logical screen.
	// Call touchwin() for the associated window, to make sure panels are fully refreshed.

	while ( !panelList.empty() )
	{
		top_panel( panelList.top() ) ;
		touchwin( panel_window( panelList.top() ) ) ;
		panelList.pop() ;
	}
}
Beispiel #13
0
/* This is used with the controller to insert a statistic. */
static void insert_tail(struct statistics_controller *c) {
    int i;

    for(i = 0; i < c->get_total_possible(c); ++i) {
	if(c->state[i].instance && !c->state[i].instance->visible) {
	    c->state[i].instance->visible = true;
	    show_panel(c->state[i].instance->panel);
	    top_panel(c->state[i].instance->panel);
	    c->total_active_statistics++;
	    return;
	}
    }
}
Beispiel #14
0
static void *
neighbor_callback(const interface *i,struct l2host *l2){
	void *ret;

	pthread_mutex_lock(&bfl);
	if( (ret = neighbor_callback_locked(i,l2)) ){
		if(active){
			assert(top_panel(active->p) != ERR);
		}
		screen_update();
	}
	pthread_mutex_unlock(&bfl);
	return ret;
}
Beispiel #15
0
void show_alert(ui_t *ui, char *message) {
  int cols = COLS;
  int x = (COLS - strlen(message)) / 2;
  wattron(ui->alert, COLOR_PAIR(COL_LOGO) | A_BOLD);
  mvwprintw(ui->alert, 0, 0, "%*s", COLS," ");
  mvwprintw(ui->alert, 1, 0, "%*s", COLS," ");
  mvwprintw(ui->alert, 2, 0, "%*s", COLS," ");
  mvwprintw(ui->alert, 1, x, message);
  wattroff(ui->alert, COLOR_PAIR(COL_LOGO) | A_BOLD);
  show_panel(ALERT);
  top_panel(ALERT);
  update_panels();
  doupdate();
}
Beispiel #16
0
/**
 * Recreate the 2 readline panels with respect to the screen size.
 *
 * @param rows Size of the screen in rows
 * @param cols Size of the screen in cols
 * @return Void
 */
void
readline_recreate(int rows, int cols)
{
    struct term_window_size newsize = {
	.rows      = 1,
	.cols      = cols,
	.start_row = rows - 1,
	.start_col = 0,
    };

    readline_pan1 = term_resize_panel(readline_pan1, &newsize);
    readline_pan2 = term_resize_panel(readline_pan2, &newsize);

    apply_readline_options(panel_window(readline_pan1));
    apply_readline_options(panel_window(readline_pan2));
}

/**
 * Puts the currently active readline panel on the top of all panels
 * in the stack.
 */
void
readline_top_panel(void)
{
    if (panel_state == PANEL1_ACTIVE) {
	if (readline_pan1)
	    (void) top_panel(readline_pan1);
    } else if (panel_state == PANEL2_ACTIVE) {
	if (readline_pan2)
	    (void) top_panel(readline_pan2);
    } else {
	sw_assert_not_reached();
    }

    update_panels();
    (void) doupdate();
}
Beispiel #17
0
static void *
service_callback(const interface *i,struct l2host *l2,struct l3host *l3,
				struct l4srv *l4){
	void *ret;

	pthread_mutex_lock(&bfl);
	if( (ret = service_callback_locked(i,l2,l3,l4)) ){
		if(active){
			assert(top_panel(active->p) != ERR);
		}
		screen_update();
	}
	pthread_mutex_unlock(&bfl);
	return ret;
}
Beispiel #18
0
void CSeparatorWidget::update(int c)
{
	if(_visible && _changed)
	{
		move_panel(_panel, _pos.y(), _pos.x());
		top_panel(_panel);
		wclear(_window);

		uint tw = _size.width() - _leftMargin - _rightMargin;

		mvwhline(_window, _topMargin, _leftMargin, 0, tw);

		_changed = false;
	}
}
Beispiel #19
0
void show_chat(ui_t *ui) {
  chat_tab = COLS-12;
  log_tab = COLS-6;
  render_tab_bar(ACTIVE_CHAT);

  hide_panel(ALERT);
  reset_borders(ui);
  wclear(ui->screen);
  wresize(ui->screen, LINES - 6, COLS - 1);
  restore_history(ui->screen, chat_history, &ui->next_line);
  box(ui->screen, 0, 0);
  hide_panel(LOG);
  top_panel(CHAT);
  update_panels();
  doupdate();
}
Beispiel #20
0
void show_log(ui_t *ui) {
  chat_tab = COLS-12;
  log_tab = COLS-6;
  render_tab_bar(ACTIVE_LOG);

  hide_panel(ALERT);
  reset_borders(ui);
  wclear(ui->log);
  wresize(ui->log, LINES - 6, COLS - 1);
  mvwin(ui->log, 1, 1);
  restore_history(ui->log, log_history, &ui->next_log_line);
  box(ui->log, 0, 0);
  hide_panel(CHAT);
  top_panel(LOG);
  update_panels();
  doupdate();
}
Beispiel #21
0
void CLabel::update(int c)
{
	if(_visible && _changed)
	{
		move_panel(_panel, _pos.y(), _pos.x());
		top_panel(_panel);
		wclear(_window);

		uint tw = _size.width() - _leftMargin - _rightMargin;

		if(_centered)
			mvwaddnstr(_window, _topMargin, _leftMargin + (_text.size() < tw ? ( tw - _text.size() ) / 2 : 0), _text.c_str(), tw);
		else
			mvwaddnstr(_window, _topMargin, _leftMargin, _text.c_str(), tw);

		_changed = false;
	}
}
Beispiel #22
0
/**
 * dest should have enough space (at least len) to hold the string.
 */
void get_text_string_from_centered_panel(char const *const prompt, char *dest, int len)
{
  WINDOW *panel_win;
  PANEL *the_panel;
  int panel_height=6,panel_width;
  /* char *dest = malloc(100); */

  int promptlen = strlen(prompt);
  panel_width = MAX(30, promptlen+5);

  /* Create the window to hold the panel */
  panel_win = newwin(panel_height,
                     panel_width,
                     (LINES-panel_height)/2,
                     (COLS-panel_width)/2);
  box(panel_win, 0, 0);
  print_in_middle(panel_win, 1,
          0, panel_width,
          prompt, COLOR_PAIR(6));
  wattron(panel_win, COLOR_PAIR(5));
  mvwhline(panel_win, 3, 2, ' ', panel_width-4);
  curs_set(1); // make cursor visible
  echo();
  mvwgetnstr(panel_win, 3, 2, dest, len);
  noecho();
  curs_set(0); // make cursor invisible
  wattroff(panel_win, COLOR_PAIR(5));
  
  /* create the panel from our window */
  the_panel = new_panel(panel_win);
  top_panel(the_panel);
  update_panels();
  doupdate();

  del_panel(the_panel);
  update_panels();
  delwin(panel_win);
  doupdate();
}
static VALUE rbncurs_c_top_panel(VALUE rb_panel)
{ return INT2NUM(top_panel(get_panel(rb_panel))); }
Beispiel #24
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();
}
Beispiel #25
0
int eq_run (kr_client_t *client, char *sysname) {

	WINDOW *eq_win,*tmpw;
	PANEL  *eq_mainpan,*eq_subpan,*ctrl_subp;
	FORM *eq_form;
	FIELD **field;
	FIELD **ctrl_field;
	FORM *ctrl_form;


  /* Panels Structs */
  ctrls_show_t *ctrls;
  eq_port_t *eqport;

  db_show_t *db;
  hz_show_t *hz;
  bw_show_t *bw;

  eq_saved_val_t *vals;

	int i;
	int max_co,subx,suby,gap;
	int offs = 0;
	int field_idx;
	int in_ctrl = 0;
  int nbands = KRAD_EQ_MAX_BANDS;
  int showed_bands = 1;
  int idx;
  char num[3];

	int ch;
	int res;
  int bandn;

	clear ();

	char *fieldname[3] = {"Power","Frequency","Bandwidth"}; 
  int nctrls = 3;

	eq_win = newwin (0,0,0,0);

	field = calloc (nbands+1,sizeof (FIELD*));

  ctrl_field = calloc (nctrls+1,sizeof (FIELD*));

	max_co = getmaxx (eq_win);

	gap = floor ((max_co) / nbands);

  vals = NULL;
  bandn = 0;
  ch = 0;


  for (i=0;i<nbands;i++) {

    field[i] = new_field (1,2,1, offs, 0, 0);
    set_field_just (field[i], JUSTIFY_CENTER);
    itoa (i,num,digits (i) + 1 );
    set_field_buffer (field[i], 0, num);
    field_opts_off (field[i], O_AUTOSKIP | O_EDIT); 
    offs += gap;

  }

  field[nbands] = NULL;

  offs = 0;
  gap = floor ((max_co ) / nctrls);

  for (i=0;i<nctrls;i++) {

    ctrl_field[i] = new_field (1,strlen (fieldname[i]),1, offs, 0, 0);
    set_field_just (ctrl_field[i], JUSTIFY_CENTER);
    set_field_buffer (ctrl_field[i], 0, fieldname[i]);
    field_opts_off (ctrl_field[i], O_AUTOSKIP | O_EDIT); 
    offs += gap;

  }


  /* Controls generation */
  ctrls = eq_ctrls_gen (eq_win,showed_bands);

  vals = calloc (1,sizeof (eq_saved_val_t));

  eqport = calloc (1,sizeof (eq_port_t));

  db = ctrls->db;
  hz = ctrls->hz;
  bw = ctrls->bw;

  eqport->name = sysname;
  eqport->vals = vals;
  eqport->ctrls = ctrls;


  /* Eq form init */
  eq_form = new_form (field);

  wattron (eq_win,COLOR_PAIR (2) | A_BOLD);
  mvwprintw (eq_win,getmaxy (eq_win) * 0.05,floor ((max_co/2)-((strlen (sysname)+14)/2)),"Equalizer for %s",sysname); 
  wattroff (eq_win,COLOR_PAIR (2) | A_BOLD);

  set_form_win (eq_form, eq_win);
  scale_form (eq_form, &suby, &subx);
  set_form_sub (eq_form, derwin (eq_win,suby, subx , getmaxy (eq_win) * 0.10 , (max_co - subx) / 2 ));

  eq_mainpan = new_panel (eq_win);
  eq_subpan = new_panel (form_sub (eq_form));

  top_panel (eq_mainpan);
  top_panel (eq_subpan);

  post_form (eq_form);

  keypad (eq_win, TRUE);

  set_current_field (eq_form,field[0]);
  set_field_fore (current_field (eq_form),A_BOLD | COLOR_PAIR (3)); 


  /* Eq ctrls form init */

  ctrl_form = new_form (ctrl_field);

  set_form_win (ctrl_form, eq_win);
  scale_form (ctrl_form, &suby, &subx);
  set_form_sub (ctrl_form, derwin (eq_win,suby, subx , getmaxy (eq_win) * 0.90 , (max_co - subx) / 2 ));

  ctrl_subp = new_panel (form_sub (ctrl_form));

  top_panel (ctrl_subp);

  post_form (ctrl_form);


  field_idx = field_index (current_field (eq_form));


  /* Let's show controls! */
  kr_mixer_portgroups (client);
  show_all_panels (ctrls,showed_bands);


	update_panels ();
	doupdate ();

	while (ch != 'q') { 


    res = krm_poll (client,-1); 

    switch (res) {
      case 0:
        continue;
      case 1:
        ch = getch ();
        break;
      case 2:
        eqport->band = bandn;
        kr_delivery_recv (client);
        eq_delivery_handler (client,eqport);
        continue;
      case -1:
        continue;
    }

    switch (ch) { 

      case KEY_LEFT:

      	if (in_ctrl) {
          set_field_fore (current_field (ctrl_form),A_NORMAL); 
          form_driver (ctrl_form, REQ_PREV_FIELD);
          set_field_fore (current_field (ctrl_form),A_BOLD | COLOR_PAIR (1)); 
          idx = field_index (current_field (ctrl_form));
      	}
      	else {
      		set_field_fore (current_field (eq_form),A_NORMAL); 
      		form_driver (eq_form, REQ_PREV_FIELD);
      		set_field_fore (current_field (eq_form),A_BOLD | COLOR_PAIR (3)); 
          bandn = field_index (current_field (eq_form));
          kr_mixer_portgroups (client); 
      	}
        break;
      case KEY_RIGHT:
      	if (in_ctrl) {
          set_field_fore (current_field (ctrl_form),A_NORMAL); 
          form_driver (ctrl_form, REQ_NEXT_FIELD);
          set_field_fore (current_field (ctrl_form),A_BOLD | COLOR_PAIR (1)); 
          idx = field_index (current_field (ctrl_form));
          
        }
      	else {
          set_field_fore (current_field (eq_form),A_NORMAL); 
          form_driver (eq_form, REQ_NEXT_FIELD);
          set_field_fore (current_field (eq_form),A_BOLD | COLOR_PAIR (3));
          bandn = field_index (current_field (eq_form));
          kr_mixer_portgroups (client); 
      	}
        break;
      case KEY_UP:
        if (in_ctrl) {
          switch (idx) {
            case 0:
              vals->db += 0.50;
              kr_mixer_set_effect_control (client, sysname, 0, bandn, "db", vals->db, 0, 0);
              break;
            case 1:
              vals->hz += 5;
              kr_mixer_set_effect_control (client, sysname, 0, bandn, "hz", vals->hz, 0, 0);
              break;
            case 2:
              vals->bw += 0.10;
              kr_mixer_set_effect_control (client, sysname, 0, bandn, "bw", vals->bw, 0, 0);
              break;
          }

        }
        break;
      case KEY_DOWN:
        if (in_ctrl) {
          switch (idx) {
            case 0:
              vals->db -= 0.5;
              kr_mixer_set_effect_control (client, sysname, 0, bandn, "db", vals->db, 0, 0);
              break;
            case 1:
              vals->hz -= 5;
              kr_mixer_set_effect_control (client, sysname, 0, bandn, "hz", vals->hz, 0, 0);
              break;
            case 2:
              vals->bw -= 0.10;
              kr_mixer_set_effect_control (client, sysname, 0, bandn, "bw", vals->bw, 0, 0);
              break;

          }
   
        }
        break;
      case 'w':
        if (in_ctrl) {
          switch (idx) {
            case 0:
              vals->db += 0.10;
              kr_mixer_set_effect_control (client, sysname, 0, bandn, "db", vals->db, 0, 0);
              break;
            case 1:
              vals->hz += 1;
              kr_mixer_set_effect_control (client, sysname, 0, bandn, "hz", vals->hz, 0, 0);
              break;
            case 2:
              break;

          }

        }
        break;
      case 's':
        if (in_ctrl) {
          switch (idx) {
            case 0:
              vals->db -= 0.10;
              kr_mixer_set_effect_control (client, sysname, 0, bandn, "db", vals->db, 0, 0);
              break;
            case 1:
              vals->hz -= 1;
              kr_mixer_set_effect_control (client, sysname, 0, bandn, "hz", vals->hz, 0, 0);
              break;
            case 2:
              break;

          }
   
        }
        break;
      case 9:
        if (in_ctrl) {
          idx = field_index (current_field (ctrl_form));
          set_field_fore (ctrl_field[idx],A_NORMAL);
          /* ncurses bug I suppose */
          form_driver (ctrl_form, REQ_NEXT_FIELD);
          form_driver (ctrl_form, REQ_PREV_FIELD);
          set_current_field (eq_form,field[field_idx]); 
          in_ctrl = 0;
        }
        else {
          field_idx = field_index (current_field (eq_form));
          set_current_field (ctrl_form,ctrl_field[0]); 
          set_field_fore (ctrl_field[0],A_BOLD | COLOR_PAIR (1));  
          /* ncurses bug I suppose */
          form_driver (ctrl_form, REQ_NEXT_FIELD);
          form_driver (ctrl_form, REQ_PREV_FIELD);
          idx = 0;
          in_ctrl = 1;
        }
        break;
      default:
        break;
    }

    update_panels ();
    doupdate ();
  }
 	

  /* CLEANUP */


  for (i=0;i<showed_bands;i++) {

    tmpw = panel_window (db->slider_p[i]);
    del_panel (db->slider_p[i]);
    delwin (tmpw);

    tmpw = panel_window (db->bar_p[i]);
    del_panel (db->bar_p[i]);
    delwin (tmpw);    

    tmpw = panel_window (hz->cell_p[i]);
    del_panel (hz->cell_p[i]);
    delwin (tmpw);

    tmpw = panel_window (bw->bar_p[i]);
    del_panel (bw->bar_p[i]);
    delwin (tmpw);

    tmpw = panel_window (bw->slider_p[i]);
    del_panel (bw->slider_p[i]);
    delwin (tmpw);

    tmpw = panel_window (bw->cell_p[i]);
    del_panel (bw->cell_p[i]);
    delwin (tmpw);

  }


  free (db->bar_w);
  free (db->slider_w);
  free (hz->cell_w);
  free (bw->bar_w);
  free (bw->slider_w);
  free (bw->cell_w);
  free (db->bar_p);
  free (db->slider_p);
  free (hz->cell_p);
  free (bw->bar_p);
  free (bw->slider_p);
  free (bw->cell_p);

  tmpw = panel_window (db->pan);
  del_panel (db->pan);
  delwin (tmpw);

  tmpw = panel_window (hz->pan);
  del_panel (hz->pan);
  delwin (tmpw);

  tmpw = panel_window (bw->pan);
  del_panel (bw->pan);
  delwin (tmpw);

  free (ctrls);
  free (db);
  free (hz);
  free (bw);
  free (vals);
  free (eqport);


  tmpw = form_sub (ctrl_form);

  unpost_form (ctrl_form);
  free_form (ctrl_form);

  for (i=0;i<nctrls;i++) {
    free_field (ctrl_field[i]);
  }

  free (ctrl_field);

  del_panel (ctrl_subp);
  delwin (tmpw);

  tmpw = form_sub (eq_form);

  unpost_form (eq_form);
  free_form (eq_form);

  
  for (i=0;i<nbands;i++) {
    free_field (field[i]);
  }

  free (field);


  del_panel (eq_subpan);
  del_panel (eq_mainpan);

  delwin (tmpw);
  delwin (eq_win);




	return 0;
}
Beispiel #26
0
/**
 * Shows a message box in specific window the middle of the
 * screen. You should make sure you're always passing in the same
 * reference to last_box_width and last_box_height associated with
 * this window.
 */
void show_message_box_win(WINDOW **win, PANEL **pan, char const *const string,
              int *last_box_width, int *last_box_height)
{
  int width;
  int height = 5;
  int leftoffset = 1;
  int largest_line_length = 0, prev_newline_index = 0;
  char msg[500];
  (void)msg; /*compiler warnings*/

  /* Count the newlines to determine any extra height we'll need to add */
  for (int i=0; i<strlen(string)+1; ++i) {
    if (string[i] == '\n' || string[i] == '\0') {
      largest_line_length = i-prev_newline_index > largest_line_length
    ? i-prev_newline_index
    : largest_line_length;
      prev_newline_index = i;
      if (string[i] == '\n')
    height++;
      /* sprintf(msg, "found newline or null at %d. now height is %d largest line is %d\n", i, height, largest_line_length); */
      /* write_to_log(msg); */
    }
  }
  largest_line_length = largest_line_length == 0
    ? strlen(string)
    : largest_line_length;
  /* sprintf(msg, "At the end, now height is %d largest line is %d\n", height, largest_line_length); */
  /* write_to_log(msg); */

  width = largest_line_length + 6;


  /* if there's an existing message box up and this string is a
     different length than the last one, we need to recompute the
     width, so we just hide the message box. */
  if (*last_box_width != width || *last_box_height != height) {
    sprintf(msg, "implicit hide of the message box because %d != %d || %d != %d\n",
        *last_box_width, width, *last_box_height, height);
    write_to_log(msg);
    hide_message_box_win(win, pan);
  }

  if (*win == NULL) {
    *win = newwin(height, width,
                 (LINES-height)/2,
                 (COLS-width)/2);
    sprintf(msg, "created new win at *win %p\n", *win);
    write_to_log(msg);
  }
  if (*pan == NULL) {
    *pan = new_panel(*win);
    sprintf(msg, "created new *pan at %p\n", *pan);
    write_to_log(msg);
  }
  wattron(*win, BLUE_ON_BLACK);
  box(*win, 0, 0);
  wattroff(*win, BLUE_ON_BLACK);
  /* border(186, 186, 205, 205, */
  /*     201, 187, 200, 188); */
  /* border(ls, rs, chtype ts, chtype bs, */
  /*     chtype tl, chtype tr, chtype bl, chtype br); */

  int current_y = 1;
  wattron(*win, WHITE_ON_RED);
  for (int i=0; i<width-2; ++i)
    mvwprintw(*win, current_y, i+1, "-"); /* fill above the text */
  current_y++;


  /* Now for the printing. We need to split the string on newlines (if
     any) and print each of those separately */
  char *our_string = (char *) malloc(strlen(string)+1);
  KINDLY_DIE_IF_NULL(our_string);
  strcpy(our_string, string);
  if (strchr(string, '\n') != NULL) { /* we have newlines */
    for (char *next_tok = strtok(our_string, "\n");
     next_tok != NULL;
     next_tok = strtok(NULL, "\n")) {
      wattron(*win, WHITE_ON_RED);
      mvwhline(*win, current_y, 1, ' ', width-2);
      print_in_middle(*win, current_y,
              leftoffset, width-1, next_tok,
              WHITE_ON_RED);
      current_y++;
    }
  } else {
    wattron(*win, WHITE_ON_RED);
    mvwhline(*win, current_y, 1, ' ', width-2);
    print_in_middle(*win, current_y, leftoffset, width-1, string, WHITE_ON_RED);
    current_y++;
  }

  wattron(*win, WHITE_ON_RED);
  for (int i=0; i<width-2; ++i)
    mvwprintw(*win, current_y, i+1, "-"); /* fill below the text */

  wattroff(*win, WHITE_ON_RED);

  free(our_string);

  top_panel(*pan);
  update_panels();
  doupdate();

  *last_box_width = width;
  *last_box_height = height;
}
Beispiel #27
0
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 */
Beispiel #28
0
void CListWidget::update(int c)
{
	if(_visible)
	{
		uint tw = _size.width();
		uint th = _size.height();

		if(focused())
		{		
#ifdef __PDCURSES__
			// Mouse wheel scrolling
			if(c == KEY_MOUSE && _count > th)
			{
				if(Mouse_status.changes == MOUSE_WHEEL_DOWN)
				{
					_scroll += 4;
					_changed = true;
				}
				else if(Mouse_status.changes == MOUSE_WHEEL_UP && _scroll >= 4)
				{
					_scroll -= 4;
					_changed = true;
				}
			}
#endif
		}

		if((_listenKeys || focused()) && _count > th)
		{
			if(c == KEY_NPAGE)	// PAGE DOWN
			{
				_scroll += 4;
				_changed = true;
			}
			else if(c == KEY_PPAGE && _scroll >= 4)	// PAGE UP
			{
				_scroll -= 4;
				_changed = true;
			}
		}

		if(_changed)
		{
			move_panel(_panel, _pos.y(), _pos.x());
			top_panel(_panel);
			wclear(_window);

			if((_count < th && _scroll < _count) || (_count > th && _scroll > _count)) _scroll = _count;
			if(_count > th && _scroll < th) _scroll = th;

			uint b = 0, n = 0;

			for(uint i = 0; i < _items.size() && i < _scroll + b; ++i)
			{
				if(_items[i]->nocrlf()) b++;

				if(!_items[i]->nocrlf())
					n = 0;

				const string &message = _items[i]->text();

				for(uint j = 0; j < _leftMargin; ++j)
					waddch(_window, ' ');

				attr_t a = attribute(_items[i]->backgroundColor(), _items[i]->foregroundColor(), _items[i]->bold());
				wattr_on(_window, a, 0);

				n++;

				for(uint j = 0; j < message.size(); ++j, n++)
				{
					if(n >= tw - _leftMargin - _rightMargin)
					{
						n = 0;
						wattr_off(_window, a, 0);
						waddch(_window, '\n');
						for(uint j = 0; j < _leftMargin; ++j)
							waddch(_window, ' ');
						wattr_on(_window, a, 0);
					}

					waddch(_window, toULong(message[j]));
				}

				wattr_off(_window, a, 0);

				if(i < _scroll + b - 1 && i != _items.size() - 1 && !_items[i]->nocrlf())
					waddch(_window, '\n');
			}

			_changed = false;
		}
	}
}
Beispiel #29
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;
}
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();
    }
}