示例#1
0
文件: lib.c 项目: KWMalik/adom-tas
int play_key(WINDOW * const win) {
	if (record.current == NULL) {
		wtimeout(win, 0);
		return KEY_EOF;
	}
	int key;
	if (record.current->duration == 0) {//seed frame
		cfg_timestamp += record.current->value;
		arc4_inject((unsigned long int )cfg_timestamp, exec_arc4_calls_automatic_load);
		(*exec_saves)++;
		key = KEY_NULL;
	}
	else {//key frame
		const int delay = record.current->duration * NAP_RESOLUTION / frame_rate;
		wtimeout(win, delay);
		const int some_key = orig_wgetch(win);
		if (some_key == cfg_play_key) {
			wtimeout(win, 0);
			int some_other_key;
			do {
				some_other_key = orig_wgetch(win);
			} while (some_other_key != cfg_play_key);
		}
		else if (some_key == cfg_stop_key) {
			record.current = NULL;
		}
		key = record.current->value;
	}
	record.current = record.current->next;
	return key;
}
示例#2
0
int
get_map_key(int place_cursor)
{
    int key = ERR;

    if (settings.blink)
        wtimeout(mapwin, 666);  /* wait 2/3 of a second before switching */

    if (player.x && place_cursor) {     /* x == 0 is not a valid coordinate */
        wmove(mapwin, player.y, player.x - 1);
        curs_set(1);
    }

    while (1) {
        key = nh_wgetch(mapwin);
        draw_map(player.x, player.y);
        doupdate();
        if (key != ERR)
            break;

    };
    wtimeout(mapwin, -1);

    return key;
}
示例#3
0
/* Ensures that terminal is in proper state for a loop iteration.  Returns
 * non-zero if so, otherwise zero is returned. */
static int
ensure_term_is_ready(void)
{
	ui_update_term_state();

	update_terminal_settings();

	if(curr_stats.term_state == TS_TOO_SMALL)
	{
		ui_display_too_small_term_msg();
		wait_for_signal();
		return 0;
	}

	if(curr_stats.term_state == TS_BACK_TO_NORMAL)
	{
		wint_t c;

		wtimeout(status_bar, 0);
		while(compat_wget_wch(status_bar, &c) != ERR);
		curr_stats.term_state = TS_NORMAL;
		modes_redraw();
		wtimeout(status_bar, cfg.timeout_len);

		curr_stats.save_msg = 0;
		status_bar_message("");
	}

	return 1;
}
示例#4
0
文件: tasknc.c 项目: skn/tasknc
void set_curses_mode(const ncurses_mode mode) /* {{{ */
{
	/* set curses settings for various common modes */
	switch (mode)
	{
		case NCURSES_MODE_STD:
			keypad(statusbar, TRUE);/* enable keyboard mapping */
			nonl();                 /* tell curses not to do NL->CR/NL on output */
			cbreak();               /* take input chars one at a time, no wait for \n */
			noecho();               /* dont echo input */
			curs_set(0);            /* set cursor invisible */
			wtimeout(statusbar, cfg.nc_timeout);/* timeout getch */
			break;
		case NCURSES_MODE_STD_BLOCKING:
			keypad(statusbar, TRUE);/* enable keyboard mapping */
			nonl();                 /* tell curses not to do NL->CR/NL on output */
			cbreak();               /* take input chars one at a time, no wait for \n */
			noecho();               /* dont echo input */
			curs_set(0);            /* set cursor invisible */
			wtimeout(statusbar, -1);/* no timeout on getch */
			break;
		case NCURSES_MODE_STRING:
			curs_set(1);            /* set cursor visible */
			nocbreak();             /* wait for \n */
			echo();                 /* echo input */
			wtimeout(statusbar, -1);/* no timeout on getch */
			break;
		default:
			break;
	}
} /* }}} */
示例#5
0
int get_key() {
     wtimeout(input_win, -1);
     int c; 
     move(0, rescol + inputline_pos + 1);
     c = wgetch(input_win);
     wtimeout(input_win, TIMEOUT_CURSES);
     if ( c != OKEY_ESC ) return c;
     return -1;
}
示例#6
0
void Terminal::SetBlocking(bool blocking)
{
	this->blocking = blocking;
	if (blocking)
	{
		wtimeout(input_window, -1);
	}
	else
	{
		wtimeout(input_window, GETCH_TIMEOUT);
	}
}
/**
 * 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();
}
示例#8
0
文件: screen.c 项目: rubenerd/sc-im
void start_screen() {
    initscr();

    main_win = newwin(LINES - RESROW, COLS, RESROW, 0);
    input_win = newwin(RESROW, COLS, 0, 0); // just 2 rows (RESROW = 2)

    #ifdef USECOLORS
    if (has_colors()) {
        start_color();

        if (get_d_colors_param() == NULL) {
            start_default_ucolors();

            // in case we decide to change colors
            // esto crea un diccionario y guarda en el 
            // la equivalencia entre las macros y los valores
            // de las claves que se definen en los archivos .sc
            set_colors_param_dict();
        }
        //wbkgd(input_win, COLOR_PAIR(DEFAULT));
        //wbkgd(main_win, COLOR_PAIR(DEFAULT));
    }
    #endif

    wtimeout(input_win, TIMEOUT_CURSES);
    noecho();
    curs_set(0);

    #ifndef NETBSD
    if ((char *) getenv ("ESCDELAY") == NULL) set_escdelay(ESC_DELAY);
    #endif
    cbreak();
    keypad(input_win, 1);
}
示例#9
0
文件: snake.c 项目: ga2arch/Snake
static int screen_init()
{
	initscr();
	start_color();
	init_pair(1, COLOR_RED, COLOR_BLACK);
	init_pair(2, COLOR_GREEN, COLOR_BLACK);
	init_pair(3, COLOR_YELLOW, COLOR_BLACK);
	init_pair(4, COLOR_BLUE, COLOR_BLACK);
	init_pair(5, COLOR_MAGENTA, COLOR_BLACK);
	init_pair(6, COLOR_CYAN, COLOR_BLACK);
	raw();
	noecho();
	getmaxyx(stdscr, ps.rowtot, ps.coltot);
/* check terminal size */
	if ((ps.rowtot < ROWS + 6) || (ps.coltot < COLS + 2)) {
		clear();
		endwin();
		printf("This screen has %d rows and %d columns. Enlarge it.\n", ps.rowtot, ps.coltot);
		printf("You need at least %d rows and %d columns.\n", ROWS + 6, COLS + 2);
		return 1;
	}
/* print grid centered */
	ps.field = subwin(stdscr, ROWS + 2, COLS + 2, (ps.rowtot - 6 - ROWS) / 2, (ps.coltot - COLS - 2) / 2);
	ps.score = subwin(stdscr, 2 + 2, ps.coltot, ps.rowtot - 4, 0);
	keypad(ps.field, TRUE);
	wtimeout(ps.field, 30);
	wborder(ps.field, '|', '|', '-', '-', '+', '+', '+', '+');
	wborder(ps.score, '|', '|', '-', '-', '+', '+', '+', '+');
	mvwprintw(ps.score, 2, 1, "F2 anytime to *rage* quit. Arrow keys to move.");
	mvwprintw(ps.score, 1, 1, "%d points.", ps.points);
	mvwprintw(ps.field, 0, 0, "Snake");
	mvwprintw(ps.score, 0, 0, "Score");
	wrefresh(ps.score);
	return 0;
}
示例#10
0
void parser (void)
{
	char command_line [80];
	int quit=0;

	noecho();
	cbreak();
	wtimeout(command_win, 100);
	keypad(command_win, 1);

	while (!quit) {
		/* Terminal screen size has changed */
		if (redraw_request) {
			redraw_all();
			redraw_request=0;
		}

		wmove (command_win,0,0);wclrtoeol (command_win);

		wmove(command_win, 0, 0);
		wprintw(command_win, "ext2ed > ");
		read_line(command_line);

		/* If only enter was pressed, recall the last command */
 		if (*command_line==0)
 			strcpy (command_line,last_command_line);

		mvcur (-1,-1,LINES-COMMAND_WIN_LINES + 1,0);	

 		strcpy (last_command_line,command_line);	/* Save this command in our tiny cache */
		
		/* And call dispatch to do the actual job */
		quit=dispatch (command_line);
	}		
}
示例#11
0
void
dlg_add_callback(DIALOG_CALLBACK * p)
{
    p->next = dialog_state.getc_callbacks;
    dialog_state.getc_callbacks = p;
    wtimeout(p->win, WTIMEOUT_VAL);
}
示例#12
0
static void
more(void)
{
    int key, attr = A_NORMAL;
    int cursx, cursy;

    draw_msgwin();

    if (settings.standout)
        attr = A_STANDOUT;

    if (getmaxy(msgwin) == 1) {
        wmove(msgwin, getmaxy(msgwin) - 1, COLNO - 8);
        wattron(msgwin, attr);
        waddstr(msgwin, "--More--");
        wattroff(msgwin, attr);
        wrefresh(msgwin);
    } else {
        newline();
        draw_msgwin();
        wmove(msgwin, getmaxy(msgwin) - 1, COLNO / 2 - 4);
        wattron(msgwin, attr);
        waddstr(msgwin, "--More--");
        wattroff(msgwin, attr);
        wrefresh(msgwin);
    }

    getyx(msgwin, cursy, cursx);
    wtimeout(msgwin, 666);      /* enable blinking */
    do {
        key = nh_wgetch(msgwin);
        draw_map(player.x, player.y);
        wmove(msgwin, cursy, cursx);
        doupdate();
    } while (key != '\n' && key != '\r' && key != ' ' && key != KEY_ESC);
    wtimeout(msgwin, -1);

    if (getmaxy(msgwin) == 1)
        newline();
    draw_msgwin();

    if (key == KEY_ESC)
        stopprint = TRUE;

    /* we want to --more-- by screenfuls, not lines */
    last_redraw_curline = curline;
}
示例#13
0
static bool simulator_view(WINDOW *out, WINDOW *state, struct program *program,
                           enum STATE *current_state)
{
        int input;
        static int timeout = 0;

        set_state(current_state);

        while (1) {
                wtimeout(state, timeout);
                input = wgetch(status);

                if (program->simulator.memory[program->simulator.PC].isBreakpoint) {
                        popup_window("Breakpoint hit!", 0, true);
                        program->simulator.isPaused = true;
                        program->simulator.memory[program->simulator.PC]
                                .isBreakpoint = false;
                }

                if (QUIT == input) {
                        return false;
                } else if (GOBACK == input) {
                        *current_state = MAIN;
                        program->simulator.isPaused = true;
                        return true;
                } else if (PAUSE == input) {
                        program->simulator.isPaused = !program->simulator.isPaused;
                } else if (START == input || RUN == input) {
                        program->simulator.isPaused = program->simulator.isHalted;
                } else if (RESTART == input) {
                        memPopulated = -1;
                        init_machine(program);
                        wclear(out);
                        wrefresh(out);
                } else if (STEP_NEXT == input) {
                        executeNext(&(program->simulator), output);
                        program->simulator.isPaused = true;
                        printState(&(program->simulator), state);
                } else if (CONTINUE == input) {
                        memPopulated = -1;
                        init_machine(program);
                } else if (CONTINUE_RUN == input) {
                        memPopulated = -1;
                        init_machine(program);
                        program->simulator.isPaused = false;
                }

                if (!program->simulator.isPaused && !program->simulator.isHalted) {
                        executeNext(&(program->simulator), out);
                        timeout = 0;
                } else {
                        set_state(current_state);
                        printState(&(program->simulator), state);
                        timeout = -1;
                        generateContext(context, program, 0, program->simulator.PC);
                }
        }
}
示例#14
0
文件: niii.c 项目: c00kiemon5ter/niii
static void updatewinp(void) {
    char *prompt = NULL;
    prompt = strrchr(ircdir, '/') + 1;
    delwin(winp);
    winp = newwin(1, wincols, winrows - 1, 0);
    wtimeout(winp, 1000); // FIXME not so good idea - input is lost if enter is not pressed and timeout expires
    if (has_colors() == TRUE) wattron(winp, COLOR_PAIR(WINP)|A_BOLD);
    wprintw(winp, "[%s] ", prompt);
    if (has_colors() == TRUE) wattroff(winp, COLOR_PAIR(WINP)|A_BOLD);
    wrefresh(winp);
}
示例#15
0
void initfields(struct FIELDLIST *list, int leny, int lenx, int begy, int begx)
{
    list->list = NULL;
    list->fieldwin = newwin(leny, lenx, begy, begx);
    list->fieldpanel = new_panel(list->fieldwin);
    stdwinset(list->fieldwin);
    wtimeout(list->fieldwin, -1);
    wattrset(list->fieldwin, STDATTR);
    colorwin(list->fieldwin);
    update_panels();
    doupdate();
}
示例#16
0
文件: ship_battle.c 项目: kidaa/aur
void change_refresh_time() {
    if(points >= 800) {
        wtimeout(stdscr, 50);
        return;
    }
    if(points >= 600) {
        wtimeout(stdscr, 75);
        return;
    }
    if(points >= 400) {
        wtimeout(stdscr, 100);
        return;
    }
    if(points >= 250) {
        wtimeout(stdscr, 160);
        return;
    }
    if(points >= 100) {
        wtimeout(stdscr,200);
        return;
    }
    if(points == 0) {
        wtimeout(stdscr, 250);
        return;
    }
}
示例#17
0
文件: wfc.cpp 项目: TellarHK/wwiv
void ControlCenter::Run() {
  Initialize();
  bool need_refresh = false;
  for (bool done = false; !done;) {
    if (need_refresh) {
      // refresh the window since we call endwin before invoking bbs code.
      RefreshAll();
      need_refresh = false;
    }

    wtimeout(commands_->window(), 500);
    int key = commands_->GetChar();
    if (key == ERR) {
      // we have a timeout. process other events
      need_refresh = false;
      UpdateLog();
      UpdateStatus(status_.get());
      CleanNetIfNeeded();
      RunEventsIfNeeded();
      continue;
    }
    need_refresh = true;
    session()->SetWfcStatus(2);
    // Call endwin since we'll be out of curses IO
    endwin();
    switch (toupper(key)) {
    case 'B': wfc_command(INST_LOC_BOARDEDIT, boardedit, cleanup_net); log_->Put("Ran BoardEdit"); break;
    case 'C': wfc_command(INST_LOC_CHAINEDIT, chainedit); log_->Put("Ran ChainEdit"); break;
    case 'D': wfc_command(INST_LOC_DIREDIT, dlboardedit); log_->Put("Ran DirEdit"); break;
    case 'E': wfc_command(INST_LOC_EMAIL, send_email_f, cleanup_net); break;
    case 'G': wfc_command(INST_LOC_GFILEEDIT, gfileedit); break;
    case 'H': wfc_command(INST_LOC_EVENTEDIT, eventedit); break;
    case 'I': wfc_command(INST_LOC_VOTEEDIT, ivotes); break;
    case 'J': wfc_command(INST_LOC_CONFEDIT, edit_confs); break;
    case 'L': wfc_command(INST_LOC_WFC, view_sysop_log_f); break;
    case 'M': wfc_command(INST_LOC_EMAIL, read_mail_f, cleanup_net); break;
    case 'N': wfc_command(INST_LOC_WFC, []() { print_local_file("net.log"); }); break;
    case 'P': wfc_command(INST_LOC_WFC, print_pending_list); break;
    case 'R': wfc_command(INST_LOC_MAILR, mailr); break;
    case 'S': wfc_command(INST_LOC_WFC, prstatus, getkey_f); break;
    case 'U': wfc_command(INST_LOC_UEDIT, []() { uedit(1, UEDIT_NONE); } ); break;
    case 'Y': wfc_command(INST_LOC_WFC, view_yesterday_sysop_log_f); break;
    case 'Z': wfc_command(INST_LOC_WFC, zlog, getkey_f); break;
    case 'Q': done=true; break;
    // ansicallout doesn't work due to arrow keys and other drawing problems with it under curses.
    // case '/': wfc_command(INST_LOC_NET, []() { force_callout(0); }); log_->Put("Ran Network Callout"); break;
    case ' ': log_->Put("Not Implemented Yet"); break; 
    }
    TouchAll();
  }
}
示例#18
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;
}
示例#19
0
int kbhit(void) {
    int temp;
    if (!screen_initialized) init_screen();

    wtimeout(stdscr, 0);
    if ((temp = wgetch(stdscr)) != EOF) {
        ungetch(temp);
        nodelay(stdscr, FALSE);
        return TRUE;
    } else {
        nodelay(stdscr, FALSE);
        return FALSE;
    }
}
示例#20
0
static int
read_char(WINDOW *win, wint_t *c, int timeout)
{
	static const int T = 150;
	static const int IPC_F = 10;

	int i;
	int result = ERR;

	for(i = 0; i <= timeout/T; i++)
	{
		int j;

		if(is_redraw_scheduled())
		{
			modes_redraw();
		}

		if(!is_status_bar_multiline() && !is_in_menu_like_mode() &&
				get_mode() != CMDLINE_MODE)
		{
			check_if_filelists_have_changed(curr_view);
			if(curr_stats.number_of_windows != 1 && !curr_stats.view)
				check_if_filelists_have_changed(other_view);
		}

		check_background_jobs();

		for(j = 0; j < IPC_F; j++)
		{
			ipc_check();
			wtimeout(win, MIN(T, timeout)/IPC_F);

			if((result = wget_wch(win, c)) != ERR)
				break;

			if(is_redraw_scheduled())
			{
				modes_redraw();
			}
		}
		if(result != ERR)
			break;

		timeout -= T;
	}
	return result;
}
示例#21
0
文件: deskman.c 项目: ebichu/dd-wrt
void about(void)
{
	WINDOW *win;
	PANEL *panel;
	int ch;

	win = newwin(18, 62, (LINES - 17) / 2, (COLS - 62) / 2);

	panel = new_panel(win);

	tx_stdwinset(win);
	wtimeout(win, -1);
	wattrset(win, BOXATTR);
	tx_colorwin(win);
	tx_box(win, ACS_VLINE, ACS_HLINE);
	wattrset(win, STDATTR);
	mvwprintw(win, 1, 2, IPTRAF_NAME);
	mvwprintw(win, 2, 2, "An IP Network Statistics Utility");
	mvwprintw(win, 3, 2, "Version %s", IPTRAF_VERSION);
	mvwprintw(win, 5, 2, "Written by Gerard Paul Java");
	mvwprintw(win, 6, 2, "Copyright (c) Gerard Paul Java 1997-2004");
	mvwprintw(win, 8, 2, "This program is open-source software released");
	mvwprintw(win, 9, 2, "under the terms of the GNU General Public");
	mvwprintw(win, 10, 2, "Public License Version 2 or any later version.");
	mvwprintw(win, 11, 2, "See the included LICENSE file for details.");
	mvwprintw(win, 13, 2,
		  "IPv6 support by Markus Ullmann <*****@*****.**>");
	mvwprintw(win, 14, 2,
		  "inspired by 2.7.0 diff by Guy Martin <*****@*****.**>");

	wattrset(win, HIGHATTR);

	mvwprintw(win, 16, 2, ANYKEY_MSG);

	update_panels();
	doupdate();

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

	del_panel(panel);
	delwin(win);
	update_panels();
	doupdate();
}
示例#22
0
int
sc_nextEvent (int blockingMillisecs)
{
  int ch;

  wtimeout(stdscr, blockingMillisecs);
  ch = wgetch(stdscr);
  if (ch == ERR)
  {
    if (blockingMillisecs < 0)
      error("Error reading console?!");
    else
      return -1;
  }
  return ch;
}
示例#23
0
文件: ship_battle.c 项目: kidaa/aur
void screen_end() {
    char exitmsg[] = "Leaving...bye! See you later :)";
    wtimeout(stdscr, -1);
    clear();
    attron(COLOR_PAIR(rand()%6 + 1));
    attron(A_BOLD);
    if(!victory)
        mvprintw(rowtot / 2,(coltot - strlen("You scored %d points!")) / 2, "You scored %d points!", points);
    else
        mvprintw(rowtot / 2,(coltot - strlen(exitmsg)) / 2, "%s", exitmsg);
    refresh();
    sleep(1);
    attroff(COLOR_PAIR);
    attroff(A_BOLD);
    endwin();
}
示例#24
0
int kbhit(void)
{
    int c;

    nodelay(win, TRUE);
    wtimeout(win, 0);
    c = wgetch(win);
    nodelay(win, FALSE);

    if (c == -1)
        c = 0;
    else
        ungetch(c);

    return c;
}
示例#25
0
void tx_initfields(struct FIELDLIST *list, int leny, int lenx, int begy,
		   int begx, int dlgtextattr, int fieldattr)
{
	list->list = NULL;
	list->fieldwin = newwin(leny, lenx, begy, begx);
	list->fieldpanel = new_panel(list->fieldwin);
	tx_stdwinset(list->fieldwin);
	wtimeout(list->fieldwin, -1);
	wattrset(list->fieldwin, dlgtextattr);
	tx_colorwin(list->fieldwin);
	update_panels();
	doupdate();

	list->dlgtextattr = dlgtextattr;
	list->fieldattr = fieldattr;
}
示例#26
0
int
sc_hasEvent ()
{
  int ch;

  wtimeout(stdscr, 0);
  ch = wgetch(stdscr);
  if (ch == ERR)
  {
    return FALSE;
  }
  else
  {
    ungetch(ch);
    return TRUE;
  }
}
示例#27
0
文件: hostmon.c 项目: rogerhu/dd-wrt
static void initethtab(struct ethtab *table)
{
	table->head = table->tail = NULL;
	table->firstvisible = table->lastvisible = NULL;
	table->count = table->entcount = 0;

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

	table->tabwin = newwin(LINES - 4, COLS - 2, 2, 1);
	table->tabpanel = new_panel(table->tabwin);

	wattrset(table->borderwin, BOXATTR);
	tx_box(table->borderwin, ACS_VLINE, ACS_HLINE);
	wmove(table->borderwin, 0, 5 * COLS / 80);
	wprintw(table->borderwin, " PktsIn ");
	wmove(table->borderwin, 0, 16 * COLS / 80);
	wprintw(table->borderwin, " IP In ");
	wmove(table->borderwin, 0, 24 * COLS / 80);
	wprintw(table->borderwin, " BytesIn ");
	wmove(table->borderwin, 0, 34 * COLS / 80);
	wprintw(table->borderwin, " InRate ");

	wmove(table->borderwin, 0, 42 * COLS / 80);
	wprintw(table->borderwin, " PktsOut ");
	wmove(table->borderwin, 0, 53 * COLS / 80);
	wprintw(table->borderwin, " IP Out ");
	wmove(table->borderwin, 0, 61 * COLS / 80);
	wprintw(table->borderwin, " BytesOut ");
	wmove(table->borderwin, 0, 70 * COLS / 80);
	wprintw(table->borderwin, " OutRate ");

	wmove(table->borderwin, LINES - 3, 40);

	wprintw(table->borderwin, " InRate and OutRate are in %s ",
		dispmode(options.actmode));

	wattrset(table->tabwin, STDATTR);
	tx_colorwin(table->tabwin);
	tx_stdwinset(table->tabwin);
	wtimeout(table->tabwin, -1);

	update_panels();
	doupdate();
}
示例#28
0
void init() {
    setlocale(LC_CTYPE, "");
    initscr();
    noecho();
    raw();
    nodelay(stdscr, true);
    wtimeout(stdscr, 200);
    keypad(stdscr, true);
    use_default_colors();
    start_color();
    init_pair(225, -1, -1);
    init_pair(1, 1, 1);
    init_pair(2, 10, 10);
    init_pair(3, 3, 3);
    init_pair(4, 4, 4);
    init_pair(5, 5, 5);
    curs_set(0);
}
示例#29
0
void		Snake::displaySnake(std::vector<t_snake>& snakeTrace, const int &xApple, const int &yApple, const int &fruit , const int &speed)
{
  std::vector<t_snake>::const_iterator	it;

  usleep(speed * 1000);
  wtimeout(_win, 0);
  _key = getch();
  wclear(_win);
  drawBackground();
  for (it = snakeTrace.begin(); it != snakeTrace.end(); ++it)
    {
      wattron(_win, A_REVERSE);
      mvwprintw(_win, (*it).y / 32, (*it).x / 32, " ");
      wattroff(_win, A_REVERSE);
    }
  mvwprintw(_win, yApple / 32, xApple / 32, "0");
  wrefresh(_win);
}
示例#30
0
static void help_draw(void *tinst, struct user_input_state *s, WINDOW *win,
		       int row, int column) {
    int c;

    do {
	help.yoffset = 0;
	help.window = newwin(LINES, COLS, 0, 0);
	
	if(NULL == help.window) {
	    user_input_set_state(NULL);
	    return;
	}
	
	help.panel = new_panel(help.window);
	
	if(NULL == help.panel) {
	    help_cleanup();
	    user_input_set_state(NULL);
	    return;
	}
        
	help.state = derwin(help.window, LINES - 1, 10, /*y*/ 0, /*x*/ 0);
	help.command = derwin(help.window, LINES - 1, 15, /*y*/ 0, 
			      /*x*/ 10);
	help.description = derwin(help.window, LINES - 1, COLS - 25, /*y*/ 0,
				  /*x*/ 25);
    
	if(NULL == help.state || NULL == help.command || NULL == help.description) {
	    help_cleanup();
	    user_input_set_state(NULL);
	    return;
	}
	
	help_draw_text();
	
	/* Wait for a key press. */
	wtimeout(help.window, -1);
	c = wgetch(help.window);

	help_cleanup();
    } while(KEY_RESIZE == c);

    user_input_set_state(NULL);
 }