示例#1
0
MainWindow::MainWindow(QString torrent, QString downloadPath, QString mountPath, QString rate, bool gui, QObject *parent): QObject(parent) {
    initSession(rate);
    initscr();
    nodelay(stdscr, true);
    noecho();
    main = NULL;
    if (!gui)
        realAddTorrent(torrent, downloadPath, mountPath);
    else {
        fake = new QMainWindow;
        if (QFile(torrent).exists() || isMagnet(torrent))
            findPaths(torrent);
        else
            addTorrent();
    }
}
示例#2
0
文件: main.c 项目: NicolasC27/Dante
static void	init_ncurses()
{
  int		i;

  i = 0;
  nodelay(initscr(), TRUE);
  start_color();
  while (i < COLORS && i < COLOR_PAIRS)
    {
      init_pair(i, COLOR_BLACK, i);
      i += 1;
    }
  cbreak();
  curs_set(0);
  noecho();
}
示例#3
0
void init ()
{
    int c;
    srand (time(NULL));
    keypad(initscr(),1);
    raw ();
    nodelay(stdscr,0);
    noecho();
    curs_set(0);
    nonl();
    start_color();   // init color
    for (c=0; c<=8; c++)   // init color pairs
    {
        init_pair(c,c,COLOR_WHITE);
    }
}
示例#4
0
static void curses_setup(void)
{
    int i, colour_default[8] = {
        COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN,
        COLOR_RED, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE,
    };

    /* input as raw as possible, let everything be interpreted
     * by the guest system */
    initscr(); noecho(); intrflush(stdscr, FALSE);
    nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE);
    start_color(); raw(); scrollok(stdscr, FALSE);

    for (i = 0; i < 64; i ++)
        init_pair(i, colour_default[i & 7], colour_default[i >> 3]);
}
void TerminalChatConsole::initOfCurses()
{
	initscr();
	cbreak(); //raw();
	noecho();
	keypad(stdscr, TRUE);
	nodelay(stdscr, TRUE);
	timeout(100);

	// To make esc not delay up to one second. According to the internet,
	// this is the value vim uses, too.
	set_escdelay(25);

	getmaxyx(stdscr, m_rows, m_cols);
	m_can_draw_text = reformat_backend(&m_chat_backend, m_rows, m_cols);
}
示例#6
0
void open_dialog(Vector2i pos, color_t color_index)
{
	size_t height = (color_index == CIDX_DEFAULT)  ? left_pos.y+2
		          : (color_index == CIDX_NEWCOLOR) ? delete_pos.y
		          : DIALOG_WINDOW_HEIGHT;
	cidx = color_index;

	if (pos.x + DIALOG_WINDOW_WIDTH >= MENU_WINDOW_WIDTH) {
		pos.x += DIALOG_WINDOW_WIDTH - MENU_WINDOW_WIDTH - 2;
	}
	dialog_pos = rel2abs(pos, menu_pos);

	dialogw = newwin(height, DIALOG_WINDOW_WIDTH, dialog_pos.y, dialog_pos.x);
	keypad(dialogw, TRUE);
	nodelay(dialogw, TRUE);
}
示例#7
0
WDL_CursesEditor::WDL_CursesEditor(void *cursesCtx)
{ 
  m_max_undo_states = 500;
  m_indent_size=2;
  m_cursesCtx = cursesCtx;

  m_color_bottomline = COLOR_PAIR(1);
  m_color_statustext = COLOR_PAIR(1);
  m_color_selection = COLOR_PAIR(2);
  m_color_message = COLOR_PAIR(2);

  m_top_margin=0;
  m_bottom_margin=2;

  m_selecting=0;
  m_select_x1=m_select_y1=m_select_x2=m_select_y2=0;
  m_state=0;
  m_offs_x=m_offs_y=0;
  m_curs_x=m_curs_y=0;
  m_want_x=-1;
  m_undoStack_pos=-1;
  m_clean_undopos=0;


#ifdef WDL_IS_FAKE_CURSES
  if (m_cursesCtx)
  {
    CURSES_INSTANCE->user_data = this;
    CURSES_INSTANCE->onMouseMessage = _onMouseMessage;
  }
#endif

  initscr();
  cbreak();
  noecho();
  nonl();
  intrflush(stdscr,FALSE);
  keypad(stdscr,TRUE);
  nodelay(stdscr,TRUE);
  raw(); // disable ctrl+C etc. no way to kill if allow quit isn't defined, yay.
  start_color();
  init_pair(1, COLOR_WHITE, COLOR_BLUE); // normal status lines
  init_pair(2, COLOR_BLACK, COLOR_CYAN); // value

  erase();
  refresh();
}
示例#8
0
void cli_init(void)
{
    uint32_t row;
	initscr();			/* Start curses mode 		  */
    erase();
    clear();
    cbreak();
    noecho();
    nodelay(stdscr,TRUE);
    curs_set(0);
    start_color();          /* Start color          */
    init_pair(1, COLOR_GREEN, COLOR_BLACK);
    init_pair(2, COLOR_BLACK, COLOR_GREEN);
    init_pair(3, COLOR_RED, COLOR_BLACK);

    row = 0;
    move(row + 0, 20); printw(DOOR_NAME);

    row = 5;
    move(row + 0,15); printw("Press 'D' to toggle the open button.");
    move(row + 1,15); printw("Press 'B' to ring the bell (Default: > 400 ms).");

    row = 8;
    move(row + 0,0); printw("Desired State: ");

    row = 10;
    move(row + 0,0); printw("Press C to toggle DOOR_DOOR_CLOSED: ");
    move(row + 1,0); printw("Press L to toggle DOOR_LOCK_LOCKED: ");
    move(row + 2,0); printw("Press U to toggle DOOR_LOCK_UNLOCKED: ");
    move(row + 3,0); printw("Press O to toggle DOOR_LOCK_LOCKING: ");
    move(row + 4,0); printw("Press N to toggle DOOR_LOCK_UNLOCKING: ");
    move(row + 5,0); printw("Press M to toggle DOOR_LOCK_MANUAL_UNLOCKED: ");
    move(row + 6,0); printw("Press H to toggle DOOR_HANDLE_PRESSED: ");
    
    move(row + 8,0); printw("Press R to reset the device");

    pressed_buttons = 0;
    door_state = DOOR_DOOR_CLOSED | DOOR_LOCK_LOCKED;
    cli_update_screen();
    uint32_t led;
    for(led = 0; led < 32; led++) {
        leds[led] = false;
    }

    cli_device_reset = false;
    cli_exit_simulation = false;
}
示例#9
0
int main(int argc, const char *argv[])
{
	initscr();
	noecho();
	cbreak();
	curs_set(0);
	nodelay(stdscr, TRUE); // 若沒有nodelay,getch就會卡住等輸入,有開啟nodelay,則沒有輸入就會返回ERR

	int pos_x = 0, pos_y = 0;
	int dic_x = 1, dic_y = 0;
	while (1) {
		// 清除上次位置
		mvaddstr(pos_y, pos_x, " ");
		refresh();

		if (kbhit()) {
			int c;
			switch (c = getch()) {
				case 'w':
					dic_x = 0;
					dic_y = -1;
					break;
				case 's':
					dic_x = 0;
					dic_y = 1;
					break;
				case 'a':
					dic_x = -1;
					dic_y = 0;
					break;
				case 'd':
					dic_x = 1;
					dic_y = 0;
					break;
			}
		}
		pos_x += dic_x;
		pos_y += dic_y;

		mvaddstr(pos_y, pos_x, "O");
		refresh();
		sleep(1);
	}
	endwin();

	return 0;
}
示例#10
0
文件: ncurses_demo.c 项目: fhict/el32
int 
main(void)
{
    int     ch;
    unsigned int     i = 0;
    char    x[] = "|/-\\";

    initscr();              /* Start curses mode        */
    raw();                  /* Line buffering disabled  */
    nodelay(stdscr, TRUE);  /* getch() returns immediately      */
    noecho();               /* no cursor */
    curs_set(0);			/* no cursor */

	DrawBox();
	GetSetTime();
    mvprintw(3,5,"press a key ('q' to quit)");
    
    ch = getch();           /* If raw() hadn't been called
                             * we have to press 'enter' before it
                             * gets to the program      
                             */
	
    while (ch != 'q')
    {
		usleep(9000);	// wait a while
        ch = getch();
        if (ch == ERR)
        {
            // no key pressed: show that the while-loop is busy
            i++;
            if (i > strlen (x))
            {
                i = 0;
            }
            mvprintw(7,11,"%c %12lld", x[i], GetMilli());
        }
        else
        {
            // show pressed key
            mvprintw(5,13,"%c (%02x)     ", ch, ch);
        }
    }
    
    endwin();           /* End curses mode        */

    return (0);
}
示例#11
0
/*  Initializes PDCurses and game startup */
int initGame(int argc, char *argv[]) {
    int c;

    srand (time(NULL));
	initscr();
    raw();
    nodelay(stdscr,1);
    noecho();
    curs_set(0);
    nonl();

	if (has_colors()) start_color();

    for (c = 0; c < COLORS; c++) {
        if (c == COLOR_WHITE) init_pair(c,COLOR_BLACK,c);
        else init_pair(c,COLOR_WHITE,c);
    }

    /* Special color pair used for drawing player */
    init_pair(10,COLOR_YELLOW,COLOR_BLACK);
    init_pair(11,COLOR_GREEN,COLOR_BLACK);

	width  = 80;
	height = 20;

    clear();
    refresh();

    /* Resize the terminal window */
    resize_term(height,width);

	win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2);
	helpwindow = newwin(0,0,0,0);
	stats = newwin(20,20,0,60); /* create the character stats window */
	encounterwin = newwin(3,19,10,20);

	if (win == NULL || stats == NULL || helpwindow == NULL) {
		endwin();
		return 1;
	}

    savetty();
    resize_term(0,0);
    game_state = GAME_MENU;
	return 0;
}
示例#12
0
文件: tui.c 项目: oetherington/Yaw
void t_unset_flags(int flags)
{
	if (flags & TUI_KEYPAD)
		keypad(stdscr, FALSE);

	if (flags & TUI_NO_DELAY)
		nodelay(stdscr, FALSE);

	if (flags & TUI_ECHO)
		noecho();

	if (flags & TUI_RAW)
		noraw();

	if (flags & TUI_COOKED)
		cbreak();
}
示例#13
0
void start_ncurses(struct display_t *display)
{
    initscr();
    cbreak();
    noecho();
    keypad(stdscr, TRUE);
    nodelay(stdscr, TRUE);
    start_color();
    use_default_colors();
    init_pair(1, -1, -1);
    curs_set(0);

    struct theme_t *theme;
    theme = read_theme();
    apply_theme(theme);
    destroy_theme(theme);
}
示例#14
0
void			Env::_initCurses(void) {
	initscr();
	cbreak();
	noecho();
	nodelay(stdscr, TRUE);
	keypad(stdscr, TRUE);
	curs_set(FALSE);
	srand(time(NULL));
	// Colors
	start_color();
	init_pair(1, 0, COLOR_WHITE);
	init_pair(2, COLOR_MAGENTA, 0);
	init_pair(3, COLOR_RED, 0);
	init_pair(4, 0, COLOR_WHITE);
	init_pair(5, 0, COLOR_RED);
	init_pair(6, COLOR_GREEN, 0);
}
示例#15
0
文件: CursesOut.cpp 项目: schmied/swf
WINDOW* CursesOut::initWindow() {
    WINDOW *w = initscr();
    start_color();
    use_default_colors();
    nodelay(w, TRUE); // do not block on getch()
    cbreak();
    noecho();
    nonl();
    intrflush(w, FALSE);
    keypad(w, TRUE);
    meta(w, TRUE);
    raw();
    scrollok(w, FALSE);
    erase();
    refresh();
    return w;
}
示例#16
0
文件: snake.c 项目: cbasix/fhk-work
//Drawing helper methods -------------------------------------------------------
void initNcurses() {
    initscr();			/* Start curses mode 		*/
    raw();				/* Line buffering disabled	*/
    keypad(stdscr, TRUE);		/* We get F1, F2 etc..		*/
    noecho();	/* Don't echo() while we do getch */
    nodelay(stdscr ,TRUE);
    curs_set(0);

    start_color();			/* Start color 			*/
    init_pair(COLOR_PAIR_BLACK, COLOR_BLACK, COLOR_WHITE);//WALLS
    init_pair(COLOR_PAIR_GREEN, COLOR_GREEN, COLOR_WHITE); //FRUIT
    init_pair(COLOR_PAIR_YELLOW, COLOR_YELLOW, COLOR_WHITE); //Enemy
    init_pair(COLOR_PAIR_WALL, COLOR_BLUE, COLOR_BLACK); //WALLS
    init_pair(COLOR_PAIR_RED, COLOR_RED, COLOR_WHITE); //P1
    init_pair(COLOR_PAIR_BLUE, COLOR_BLUE, COLOR_WHITE); //P2

}
int main()
{
	bcm_host_init();
 	initscr();
	keypad(stdscr, TRUE);
	cbreak();
	noecho();
	nodelay(stdscr, TRUE);
	Game game;
	game.setWindowProvider(new EGLWindowProvider());
	game.setGameContext(new GameContextDemo());

	std::cout << "Finish setting up Game loop, starting ..." << std::endl;
	game.init();
	endwin();
	bcm_host_deinit();
}
示例#18
0
void curses_init(void)
{
    initscr();

    noecho();
    cbreak();

    int h, w;
    getmaxyx(stdscr, h, w);

    win = newwin(h - 6, w, 5, 0);
    win_info = newwin(5, w, 0, 0);
    win_input = newwin(1, w, h - 1, 0);

    scrollok(win, TRUE);
    nodelay(win_input, TRUE);
}
示例#19
0
static inline void init()
{
    // Don't show cursor
    curs_set(0);

    // Read arrow keys
    keypad(stdscr, true);

    // Read chars directly but allow interrupts
    cbreak();

    // Don't echo typed characters
    noecho();

    // Don't wait for characters, error if nothing typed
    nodelay(stdscr, true);
}
int main (int argc, char **argv)
{
  FILE *output;
  int file, row, col;
  Triplet bias;
  FTriplet scale;

  initscr ();
  nodelay (stdscr, 1);
  noecho ();
  cbreak ();
  curs_set (0);
  getmaxyx (stdscr, row, col);
  (void)row;

  file = init_device (I2C_DEV_NAME);
  if (file == 0)
    return 1;

  init_mag (file, MAG_SCALE_2GS);

  output = fopen(BIAS_FILENAME, "w");
  if (!output){
    printf("Error opening '"BIAS_FILENAME"' for output.\n");
    return 1;
  }
  mvprintw (0, 0, "Calibrating: Turn the Edison around all axes.");
  mvprintw (1, 0, "Try to find the absolute furthest limits of each axis.");
  mvaddch (3, 0, 'X');
  mvaddch (4, 0, 'Y');
  mvaddch (5, 0, 'Z');

  mvprintw (7, 0, "Press any key when done.");

  calibrate (file, col, &bias, &scale);

  endwin ();

  fprintf(output, "m_bias %d %d %d\n", bias.x, bias.y, bias.z);
  fprintf(output, "m_scale %f %f %f\n", scale.x, scale.y, scale.z);
  fclose (output);

  printf ("Calibration succesful, wrote '"BIAS_FILENAME"'.\n");
  return 0;
}
示例#21
0
文件: global.c 项目: davidben/barnowl
static void _owl_global_init_windows(owl_global *g)
{
  /* Create the main window */
  owl_mainpanel_init(&(g->mainpanel));

  /* Create the widgets */
  g->mw = owl_mainwin_new(g->mainpanel.recwin);
  owl_msgwin_init(&(g->msgwin), g->mainpanel.msgwin);
  owl_sepbar_init(g->mainpanel.sepwin);

  owl_window_set_default_cursor(g->mainpanel.sepwin);

  /* set up a pad for input */
  g->input_pad = newpad(1, 1);
  nodelay(g->input_pad, 1);
  keypad(g->input_pad, 1);
  meta(g->input_pad, 1);
}
示例#22
0
void engine_start(void){
  // start ncurses screen
  initscr();
  start_color();

  // customizations
  raw();
  nodelay(stdscr, TRUE);
  noecho();
  nonl();
  curs_set(0);
  keypad(stdscr, TRUE);
  refresh();

  // render game
  draw_border();
  print_welcome_message();
}
示例#23
0
static int searchA(char **string, int *sizea, char *tmp, int tmp_size)
{
  char *msg = hexOrAscii ? "Hexa string to search: " : "Ascii string to search: ";
  char **last = hexOrAscii ? &lastAskHexString : &lastAskAsciiString;

  if (!ask_about_save_and_redisplay()) return FALSE;
  if (!displayMessageAndGetString(msg, last, tmp, tmp_size)) return FALSE;

  *sizea = strlen(tmp);
  if (hexOrAscii) if (!hexStringToBinString(tmp, sizea)) return FALSE;

  *string = malloc(*sizea);
  memcpy(*string, tmp, *sizea);

  nodelay(stdscr, TRUE);
  displayTwoLineMessage("searching...", "(press any key to cancel)");
  return TRUE;
}
示例#24
0
文件: nCurse.C 项目: chandl34/public
bool nCurse::Activate() {
    if (running) refresh();
    else {
        s = newterm((char *) 0,stdout,stdin);
        if (s != NULL) {
            set_term(s);
            width = COLS;
            height = LINES;
            curs_set(0); //uncomment it to get rid of the cursor
            noecho();
            cbreak();// Line buffering disabled. pass on everything
            nodelay(stdscr,1);
            keypad(stdscr, TRUE);
            running = true;
        }
    }
    return running;
}
示例#25
0
文件: curses.cpp 项目: drakargx/ADWIF
 void reset(int code)
 {
   endwin();
   initscr();
   nonl();
   cbreak();
   noecho();
   keypad(stdscr, TRUE);
   nodelay(stdscr, TRUE);
   curs_set(FALSE);
   set_escdelay(10);
   start_color();
   use_default_colors();
   assume_default_colors(COLOR_WHITE, COLOR_BLACK);
   idlok(stdscr, TRUE);
   clear();
   refresh();
 }
示例#26
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);
}
示例#27
0
Window::Window(void) : _color(0)
{
	initscr();
	m_win = stdscr;
	noecho();
	curs_set(FALSE);
	raw();
	keypad(stdscr, TRUE);
	getmaxyx(m_win, m_sizey, m_sizex);
	nodelay(stdscr, TRUE);
	if (has_colors() == FALSE)
	{
		endwin();
		std::cout << "Color are not eneable in this term." << std::endl;
		exit(1);
	}
	return;
}
示例#28
0
void                     NcursesDisplay::init(void)
{
    initscr();
    cbreak();
    noecho();
    curs_set(0);
    keypad(stdscr, TRUE);
    nodelay(stdscr, TRUE);

    start_color();
    init_pair(DISP_WHITE, COLOR_WHITE, COLOR_BLACK);
    init_pair(DISP_RED, COLOR_RED, COLOR_BLACK);
    init_pair(DISP_GREEN, COLOR_GREEN, COLOR_BLACK);
    init_pair(DISP_BLUE, COLOR_BLUE, COLOR_BLACK);
    init_pair(DISP_CYAN, COLOR_CYAN, COLOR_BLACK);
    init_pair(DISP_YELLOW, COLOR_YELLOW, COLOR_BLACK);
    init_pair(DISP_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
}
示例#29
0
文件: popwin.c 项目: arlynap/barnowl
int owl_popwin_up(owl_popwin *pw)
{
  int glines, gcols, startcol, startline;

  /* calculate the size of the popwin */
  glines=owl_global_get_lines(&g);
  gcols=owl_global_get_cols(&g);

  pw->lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2;
  startline = (glines-pw->lines)/2;

  pw->cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2;
  startcol = (gcols-pw->cols)/2;

  pw->borderwin=newwin(pw->lines, pw->cols, startline, startcol);
  pw->popwin=newwin(pw->lines-2, pw->cols-2, startline+1, startcol+1);
  pw->needsfirstrefresh=1;
  
  meta(pw->popwin,TRUE);
  nodelay(pw->popwin, 1);
  keypad(pw->popwin, TRUE);

  werase(pw->popwin);
  werase(pw->borderwin);
  if (owl_global_is_fancylines(&g)) {
    box(pw->borderwin, 0, 0);
  } else {
    box(pw->borderwin, '|', '-');
    wmove(pw->borderwin, 0, 0);
    waddch(pw->borderwin, '+');
    wmove(pw->borderwin, pw->lines-1, 0);
    waddch(pw->borderwin, '+');
    wmove(pw->borderwin, pw->lines-1, pw->cols-1);
    waddch(pw->borderwin, '+');
    wmove(pw->borderwin, 0, pw->cols-1);
    waddch(pw->borderwin, '+');
  }
    
  wnoutrefresh(pw->popwin);
  wnoutrefresh(pw->borderwin);
  owl_global_set_needrefresh(&g);
  pw->active=1;
  return(0);
}
示例#30
0
int InputManager::startUp(){
    GraphicsManager& graphics_manager = GraphicsManager::getInstance();
    LogManager& log_manager = LogManager::getInstance();
    if(!graphics_manager.isStarted()){
        log_manager.writeLog("InputManager::startUp(): GraphicsManager is not started. ");
        return -1;
    }
    
    // Error checking
    int* flag = new int[7]();
    
    // enable keypad
    *(flag++) = keypad(stdscr, TRUE);

    // disable line buffering
    *(flag++) = cbreak();

    // turn off newline so can detect 'enter' key
    *(flag++) = nonl();

    // disable character echo
    *(flag++) = noecho();

    // turn off the cursor
    *(flag++) = curs_set(0);

    // no delay for input
    *(flag++) = nodelay(stdscr, TRUE);

    // enable mouse event
    *flag = mousemask(BUTTON1_CLICKED, NULL);

    flag -= 6;
    for(int i = 0; i != 7; i++){
        if(*(flag+i) == ERR){
            log_manager.writeLog("InputManager::startUp(): curse input start fails. ");
            delete[] flag;
            return -1;
        }
    }
    Manager::startUp();
    delete[] flag;
    return 0;
}