コード例 #1
0
ファイル: declarewinner.c プロジェクト: Shirish111/files
int declarewinner(chess *q) {
	int n; 
	if(q->state == WHITE) {
		clear();
		init_pair(13, COLOR_WHITE, COLOR_RED); 
		bkgd(COLOR_PAIR(13));
		mvprintw(LINES / 2 - 4, COLS /2 - 4, "BLACK WINS");
		mvprintw(LINES / 2 - 2, COLS /2 - 6, "Want to resume?");
		mvprintw(LINES / 2, COLS /2 - 5,"1. Yes 2. No");
		mvprintw(LINES / 2 + 2, COLS /2 - 5, "Enter choice");
		curs_set(1);
		mvscanw(LINES / 2 + 4, COLS /2, "%d", &n);
		curs_set(0);
		refresh();
		display(stdscr, q);
		if(n == 1) {
			undoredo(q, "undo");
			undoredo(q, "undo");
			display(stdscr, q);
			return 0;
		}
		else {
			savefile(q);
			getch();
			return 1;
		}
	}
	else {
		clear();
		init_pair(13, COLOR_WHITE, COLOR_RED); 
		bkgd(COLOR_PAIR(13));
		mvprintw(LINES / 2 - 4, COLS /2 - 4, "WHITE WINS");
		mvprintw(LINES / 2 - 2, COLS /2 - 6, "Want to resume?");
		mvprintw(LINES / 2, COLS /2 - 5,"1. Yes 2. No");
		mvprintw(LINES / 2 + 2, COLS /2 - 5, "Enter choice");
		/* mvprintw(22, 110, "Want to resume?"); */
		/* mvprintw(24, 110, "1. Yes 2. No"); */
		/* mvprintw(26, 110, "Enter choice"); */
		/* mvwaddch(win, 26, 123, ':'); */
		curs_set(1);
		mvscanw(LINES / 2 + 4, COLS / 2, "%d", &n);
		curs_set(0);
		refresh();
		display(stdscr, q);
		if(n == 1) {
			undoredo(q, "undo");
			undoredo(q, "undo");
			display(stdscr, q);
			return 0;
		}
		else {
			savefile(q);
			getch();
			return 1;
		}
	}
}
コード例 #2
0
void intro() {
	clear();
	init_pair(1, COLOR_CYAN, COLOR_BLACK);			/*Setting backgrnd and foregrnd*/
	bkgd(COLOR_PAIR(1));
	attron(A_BOLD);
	init_pair(2,COLOR_YELLOW,COLOR_BLACK);			/*Setting borders*/
        attron(COLOR_PAIR(2));
        border(0,0,0,0, 0,0,0,0);
        refresh();
        attroff(COLOR_PAIR(2));
        refresh();
	init_pair(3,COLOR_WHITE,COLOR_BLACK);
	attron(COLOR_PAIR(3));
	refresh();
	mvaddstr(2,60," ~*~*~*~*~* WELCOME *~*~*~*~*~");	/*Printing main menu*/
	attroff(COLOR_PAIR(3));
	refresh();
	mvaddstr(5,48,"Please select an option");
	mvaddstr(7,48,"1. Add books");
	mvaddstr(9,48,"2. Display books");
	mvaddstr(11,48,"3. Search a book");
	mvaddstr(13,48,"4. Delete a record");
	mvaddstr(15,48,"5. Edit a record");
	mvaddstr(17,48,"6. Issue a book");
	mvaddstr(19,48,"7. View issued books");
	mvaddstr(21,48,"8. Return a book");
	mvaddstr(23,48,"9. Close application");
	refresh();
}	
コード例 #3
0
ファイル: mainwindow.cpp プロジェクト: HermesYoung/pd2-Taiko
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->menuButton->hide();
    ui->mapList->hide();
ui->menuBar->hide();
ui->offset_box->hide();
ui->label->hide();
ui->delay->hide();
ui->label_2->hide();
    QDir setting(QDir::currentPath());
    setting.mkdir("songs");
    QPixmap bkgd(":/images/images/title.png");
    bkgd=bkgd.scaled(this->size(),Qt::IgnoreAspectRatio);
    QPalette palette;
    palette.setBrush(QPalette::Background,bkgd);
   this->setPalette(palette);
    QDir dir_map;
    QString map_path=dir_map.currentPath()+"/songs";


dir_map.setPath(map_path);
 ui->mapList->addItems(dir_map.entryList(QDir::Dirs|QDir::NoDotAndDotDot));
 if(ui->mapList->count()>0)
     ui->mapList->setCurrentItem(ui->mapList->item(0));
}
コード例 #4
0
//ncursesで色を使う初期化
void init_mycolor()
{
	/* start_colorは色属性を使用するときは最初に必ず実行する.
	 *      initscrの直後に実行するのがよい習慣らしい. */
	if(has_colors() == FALSE || start_color() == ERR){
		endwin();
		fprintf(stderr, "has_colors or start_color failure\n");
		exit(EXIT_FAILURE);
	}
	/* 色のペアを作る */
	// 黒
	init_pair(PRINT_BLACK, COLOR_BLACK, COLOR_WHITE);
	// 赤
	init_pair(PRINT_RED, COLOR_RED, COLOR_WHITE);
	// 黄色
	init_pair(PRINT_MAGENTA, COLOR_MAGENTA, COLOR_WHITE);
	// 緑
	init_pair(PRINT_GREEN, COLOR_GREEN, COLOR_WHITE);
	// 青
	init_pair(PRINT_BLUE, COLOR_BLUE, COLOR_WHITE);
	// シアン
	init_pair(PRINT_CYAN, COLOR_CYAN, COLOR_WHITE);

	// 背景赤、文字黒
	init_pair(BACK_RED, COLOR_WHITE, COLOR_RED);

	// デフォルト色設定
	bkgd(COLOR_PAIR(PRINT_BLACK));
}
コード例 #5
0
ファイル: declaredraw.c プロジェクト: Shirish111/files
int declaredraw(chess *q, char *str) {
	int n;
	mvprintw(23, 110, "%s", str);
	getch();
	clear();
	init_pair(13, COLOR_WHITE, COLOR_RED); 
	bkgd(COLOR_PAIR(13));
	mvprintw(LINES / 2 - 4, COLS /2 - 1, "DRAW");
	mvprintw(LINES / 2 - 2, COLS /2 - 6, "Want to resume?");
	mvprintw(LINES / 2, COLS /2 - 5,"1. Yes 2. No");
	mvprintw(LINES / 2 + 2, COLS /2 - 5, "Enter choice");
	curs_set(1);
	mvscanw(LINES / 2 + 4, COLS /2, "%d", &n);
	curs_set(0);
	refresh();
	if(n == 1) {
		undoredo(q, "undo");
		undoredo(q, "undo");
		display(stdscr, q);
		return 0;
	}
	else {
		q->enable = DISABLE;
		savefile(q);
		return 1;
	}
}
コード例 #6
0
ファイル: main.c プロジェクト: sdlu1992/clims
int main(int argc, char **argv)
{
	initScreen();       //初始化屏幕
	initColor();        //初始化颜色
	bkgd(COLOR_PAIR(1));//给背景设定颜色
	box(stdscr, 0, 0);  //画边框
	editWin = newwin(LINES-4, COLS-4, 3, 2);
	wbkgd(editWin, COLOR_PAIR(2));
	wattron(editWin, COLOR_PAIR(3));    //当前使用该色彩
	box(editWin, 0, 0);
	wattroff(editWin, COLOR_PAIR(3));   //不使用该色彩了
    wattron(editWin,COLOR_PAIR(7));
	initMenu(); //初始化菜单
	draw_main_menu(stdscr); //画菜单
	initList(); //初始化链表
	while(isOn){
		wnoutrefresh(stdscr);
		wnoutrefresh(editWin);
		doupdate();
		drawMenuList(0, 0);
		touchwin(editWin);
		wrefresh(editWin);
	}
	exitScreen();   //退出函数
	return 0;
}
コード例 #7
0
ファイル: kid1.c プロジェクト: ajpaulson/learning-ncurses
int main(int argc, char *argv[])
{
        WINDOW *sonny;

        initscr();
        refresh();

        start_color();          // remember to check for errors
        init_pair(1, COLOR_WHITE, COLOR_BLUE);
        init_pair(2, COLOR_RED, COLOR_YELLOW);

        /* create subwindow */
        sonny = subwin(stdscr, 5, 20, 10, 30);
        if(sonny == NULL)
        {
                addstr("Unable to create subwindow\n");
                endwin();
                return 1;
        }

        /* colour windows and splash some text */
        bkgd(COLOR_PAIR(1));
        addstr("Hello, son.");
        wbkgd(sonny, COLOR_PAIR(2));
        waddstr(sonny, "Hello, Dad.");
        refresh();
        getch();

        endwin();
        return 0;
}
コード例 #8
0
void Controller::draw() {
	int max_y, max_x;
	getmaxyx(stdscr, max_y, max_x);
	clear();
	std::string blank_line = String::get_padded_string("", max_x, ' ');

	bkgd(COLOR_PAIR(0));

	attron(COLOR_PAIR(HEADING_PAIR));
	if (!timer.is_stopped() && !timer.is_done()) {
		mvprintw(max_y - 2, 0, blank_line.c_str());
		std::string song_heading = current_song.name + " Time: " + std::to_string(static_cast<int>(timer.get_time_remaining()));
		mvprintw(max_y - 2, 0, song_heading.c_str());
	}
	mvprintw(0, 0, blank_line.c_str());
	std::string heading = !playlist.name.empty() ? "In room " + playlist.name : "OpenPlugServer";
	mvprintw(0, 0, heading.c_str());
	attroff(COLOR_PAIR(HEADING_PAIR));

	attron(COLOR_PAIR(TEXT_PAIR));
	messages.draw(1, 0, max_y - 2, max_x);
	attroff(COLOR_PAIR(HEADING_PAIR));

	mvprintw(max_y - 1, 0, current_line.c_str());

	refresh();
}
コード例 #9
0
ファイル: bib_game.c プロジェクト: angeloperpa/flappybrick
void help() {             //Print da tela de ajuda ao jogador.
    FILE *help_file;
    char *line;
    int i;
    int op;

    line = (char*) malloc (COLUNAS * sizeof(char));
    help_file = fopen("help.sprite", "r");
    i = 0;
    clear();
    init_pair(1, COLOR_RED, COLOR_YELLOW);
    bkgd(COLOR_PAIR(1));
    fgets(line, COLUNAS, help_file);

    while(!feof(help_file)) {
        mvprintw(i, 0, line);
        refresh();
	i++;
	fgets(line, COLUNAS, help_file);
    }
    while(1) {
	op = getch();
        if(op == 104 || op == 112) {
	      break;
   	}
    }
}
コード例 #10
0
ファイル: test.c プロジェクト: erich0929/boardwidget
int main()
{
		WINDOW *menubar, *statusbar, *about;
		int key;
		init_scr();
		bkgd(COLOR_PAIR(1));
		menubar = subwin(stdscr, 1, 80, 0, 0);
		statusbar = subwin(stdscr, 1, 79, 23, 1);
		make_menubar(menubar);
		move(2, 1);
		printw("Press 'a' or 'h' to open the menus. ");
		printw("ESC or 'q' quits.");
		refresh();    
		while(1)
		{
				WINDOW **menu_items;            
				int selected_item;

				key = getch();
				werase(statusbar);
				wrefresh(statusbar);

				if (key == 'a')
				{
						menu_items=file_menu_list(0);
						selected_item = scroll_menu(menu_items, 4, 20, 0); 
						delete_menu(menu_items, 5);
						if (selected_item < 0)
								wprintw(statusbar, "You haven't selected any item");
						else
								wprintw(statusbar, "You have selected menu item %d.", selected_item);
						touchwin(stdscr);
						refresh();    
				}
				if (key == 'h')
				{
						menu_items=help_menu_list(20);
						selected_item = scroll_menu(menu_items, 2, 0, 1); 
						delete_menu(menu_items, 3);
						if (selected_item == 1)
						{
								about_window();
						}
						if (selected_item < 0)
								wprintw(statusbar, "You haven't selected any item");

				}
				if (key == ESCAPE || key == 'q')
				{
						if (check_quit() == 1)
								break;
				}
				touchwin(stdscr);
				refresh();    
		}
		endwin();
}
コード例 #11
0
ファイル: demo_forms.c プロジェクト: geho/android_ncurses
int
main(int argc, char *argv[])
{
    int ch;

    setlocale(LC_ALL, "");

    while ((ch = getopt(argc, argv, "dj:m:o:t:")) != -1) {
	switch (ch) {
	case 'd':
	    d_option = TRUE;
	    break;
	case 'j':
	    j_value = atoi(optarg);
	    if (j_value < NO_JUSTIFICATION
		|| j_value > JUSTIFY_RIGHT)
		usage();
	    break;
	case 'm':
	    m_value = atoi(optarg);
	    break;
	case 'o':
	    o_value = atoi(optarg);
	    break;
	case 't':
	    t_value = optarg;
	    break;
	default:
	    usage();

	}
    }

    initscr();
    cbreak();
    noecho();
    raw();
    nonl();			/* lets us read ^M's */
    intrflush(stdscr, FALSE);
    keypad(stdscr, TRUE);

    if (has_colors()) {
	start_color();
	init_pair(1, COLOR_WHITE, COLOR_BLUE);
	init_pair(2, COLOR_GREEN, COLOR_BLACK);
	init_pair(3, COLOR_CYAN, COLOR_BLACK);
	bkgd((chtype) COLOR_PAIR(1));
	refresh();
    }

    demo_forms();

    endwin();
    ExitProgram(EXIT_SUCCESS);
}
コード例 #12
0
ファイル: awesomebanner.c プロジェクト: jclulow/miscutils
void setupscreen() {
	bkgd(COLOR_PAIR(1));
	clear();
	// poke the display so that it doesn't assume black bg...
	attron(COLOR_PAIR(4));
	move(0, 0);
	addch(' ');
	// reset to 'normal'
	attron(COLOR_PAIR(1));
	refresh();
}
コード例 #13
0
ファイル: mainwindow.cpp プロジェクト: HermesYoung/pd2-Taiko
void MainWindow::setbg()
{
    QPixmap bkgd(":/images/images/title.png");
    bkgd=bkgd.scaled(this->size(),Qt::IgnoreAspectRatio);
    QPalette palette;
    palette.setBrush(QPalette::Background,bkgd);
   this->setPalette(palette);
    ui->label->show();
    ui->label_2->show();
    ui->offset_box->show();
    ui->delay->show();
}
コード例 #14
0
ファイル: render.c プロジェクト: michalbe/say-the-magic-word
void render_init(void)
{
    initscr();

    cbreak();
    noecho();
    curs_set(FALSE);

    start_color();
    init_pair(1, COLOR_WHITE, COLOR_BLACK);

    bkgd(COLOR_PAIR(1));
}
コード例 #15
0
int init_terminal_ncurses(char *color, char *bcolor, int predefcol, int predefbgcol) {
	struct cols col, bgcol;
	initscr();
	curs_set(0);
	timeout(0);
	noecho();
	start_color();
	use_default_colors();

	double magic = 1000 / 255.0;
	int colp = 0, bgcolp = 0;

	col = parse_color(color);
	bgcol = parse_color(bcolor);
	if (col.col == -2) {
		init_color(1, (int)(col.R * magic), (int)(col.G * magic), (int)(col.B * magic));
	}
	if (bgcol.col == -2) {
		init_color(2, (int)(bgcol.R * magic), (int)(bgcol.G * magic), (int)(bgcol.B * magic));
	}

	switch (col.col) {
		case -2:
			colp = 1;
			break;
		case -1:
			colp = DEFAULTCOL;
			break;
		default:
			colp = predefcol;
	}

	switch (bgcol.col) {
		case -2:
			bgcolp = 2;
			break;
		case -1:
			bgcolp = DEFAULTBGCOL;
			break;
		default:
			bgcolp = predefbgcol;
	}

	init_pair(1, colp, bgcolp);
	if (bgcolp != -1)
		bkgd(COLOR_PAIR(1));
	attron(COLOR_PAIR(1));
//	attron(A_BOLD);
	return 0;
}
コード例 #16
0
ファイル: ncurses_panel_test.c プロジェクト: bakkertj/6502
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);  
}
コード例 #17
0
ファイル: main.cpp プロジェクト: chris-vdop/twitch-cursed
int main(void)
{
    int ch;
    initscr();
    atexit(quit);
    start_color();
    clear();
    noecho();
    curs_set(0);
    cbreak();
    nl();
    keypad(stdscr, TRUE);

    //set stdscr red
    init_pair(1, COLOR_BLACK, COLOR_RED);
    bkgd(COLOR_PAIR(1));
//
    refresh();
    loadConfig("config.cfg");
    clear();
    getmaxyx(stdscr,y,x);

    box(stdscr,0,0);
    if (y > 30 && configFile::getInstance()->getContents("printLogo") != "false")
    {
        titleWin = newwin(7,x-2,1,1);
        pluginWin = newwin(y-2-7,x-2,8,1);
        box(titleWin,0,0);
        printTitle();
    }
    else
        pluginWin = stdscr;

    box(pluginWin,0,0);



    refresh();
    if (titleWin != NULL)
        wrefresh(titleWin);

    wrefresh(pluginWin);


    listModules();


    return (0);
}
コード例 #18
0
ファイル: terminal_ncurses.c プロジェクト: nrhine1/cava
int init_terminal_ncurses(int col, int bgcol) {

	initscr();
	curs_set(0);
	timeout(0);
	noecho();
	start_color();
	use_default_colors();
	init_pair(1, col, bgcol);
	if(bgcol != -1)
		bkgd(COLOR_PAIR(1));
	attron(COLOR_PAIR(1));
//	attron(A_BOLD);
	return 0;
}
コード例 #19
0
ファイル: getbkgd.c プロジェクト: wkoszek/ncurses_guide
int main(void)
{
    chtype ch,a;
    char bgchar;
    int bgcolor,x;
    short fore,back;
    char colors[8][8] = { "Black", "Red", "Green", "Yellow",
                          "Blue", "Magenta", "Cyan", "White"
                        };
    char attribs[15][11] = { "Standout", "Underline", "Reverse",
                             "Blink", "Dim", "Bold",
                             "AltChar", "Invis", "Protect",
                             "Horizontal", "Left", "Low",
                             "Right", "Top", "Vertical"
                           };

    a = 0x10000;

    initscr();
    start_color();
    init_pair(1,COLOR_WHITE,COLOR_BLUE);
    bkgd(COLOR_PAIR(1) | A_BOLD);

    ch = getbkgd(stdscr);

    bgchar = (ch & A_CHARTEXT);			/* Read character */
    bgcolor = (ch & A_COLOR) >> 8;		/* Read color pair */
    pair_content(bgcolor,&fore,&back);	/* Read colors */

    printw("Background chtype is 0x%04x\n",ch);
    printw("Background character is 0x%02x or '%c'\n",\
           bgchar,bgchar);
    printw("Background color pair is %d\n",bgcolor);
    printw("\tForeground color is %s\n",colors[fore]);
    printw("\tBackground color is %s\n",colors[back]);
    addstr("Other attributes found:\n");
    for(x=0; x<15; x++)
    {
        if(a & ch)
            printw("%s\n",attribs[x]);
        a <<= 1;
    }
    refresh();
    getch();

    endwin();
    return 0;
}
コード例 #20
0
ファイル: readfromfile.c プロジェクト: Shirish111/files
void readfromfile(chess *q) {
	int fdr;
	int i = 1, x, n;
	int j = 0;
	char c = '\t';
	clear();
	init_pair(11, COLOR_BLACK, COLOR_WHITE); 
	bkgd(COLOR_PAIR(11));
	if(i == 1) {
		fdr = open("MovesList1.txt", O_RDONLY, S_IRWXU);
		if(fdr == -1) {
			printw("Error opening the file MovesList.txt\n");
			exit(1);
		}
	}
	while(1) {
		x = read(fdr, &n, sizeof(int));
		if(x == 0 || x == -1) {
			break;
		}
		printw("%d", n);
		x = read(fdr, &c, 1);
		if(x == 0 || x == -1) {
			break;
		}
		printw("%c", c);
		x = read(fdr, &c, 1);
		if(x == 0 || x == -1) {
			break;
		}
		while(c != '\0') {
			printw("%c", c);
			x = read(fdr, &c, 1);
		}
		x = read(fdr, &c, 1);
		if(x == 0 || x == -1) {
			break;
		}
		printw("%c", c);
		if(c == '+') {
			printw(" ");
		}
	}
	refresh();
	getch();
	display(stdscr, q);
}
コード例 #21
0
ファイル: curses.c プロジェクト: ThomasDickey/add-snapshots
/*
 * Setup and run the interactive portion of the program.
 */
void
screen_start(void)
{
    if (initscr() == 0)		/* should return a "WINDOW *" */
	exit(EXIT_FAILURE);
#if HAVE_KEYPAD
    keypad(stdscr, TRUE);
#endif
#if HAVE_DEFINE_KEY
    define_key("\033Ok", '+');
    define_key("\033Ol", ',');
    define_key("\033Om", '-');
    define_key("\033On", '.');
    define_key("\033Op", '0');
    define_key("\033Oq", '1');
    define_key("\033Or", '2');
    define_key("\033Os", '3');
    define_key("\033Ot", '4');
    define_key("\033Ou", '5');
    define_key("\033Ov", '6');
    define_key("\033Ow", '7');
    define_key("\033Ox", '8');
    define_key("\033Oy", '9');
    define_key("\033OM", '\n');
#endif
#if defined(COLOR_BLUE) && defined(COLOR_WHITE) && HAVE_COLOR_PAIR
    if (has_colors()) {
	start_color();
	init_pair(1, COLOR_WHITE, COLOR_BLUE);	/* normal */
	SetColors(1);
#if HAVE_BKGD
	bkgd(CURRENT_COLOR);
#endif
    }
#endif
#if HAVE_TYPEAHEAD
    typeahead(-1);		/* disable typeahead */
#endif
#if SYS_MSDOS && defined(F_GRAY) && defined(B_BLUE)
    wattrset(stdscr, F_GRAY | B_BLUE);	/* patch for old PD-Curses */
#endif
    raw();
    nonl();
    noecho();
    set_screensize();
}
コード例 #22
0
void printgen() {				/*Prints genre menu*/
	int y, x;
	clear();
	init_pair(1, COLOR_CYAN, COLOR_BLACK);
	bkgd(COLOR_PAIR(1));
	attron(A_BOLD);
	for(x = 44; x < 100; x++) {
		attron(COLOR_PAIR(1));
		printw("*");
		move(0, x);
		attroff(COLOR_PAIR(1));
	}
	for(y = 0; y < 11; y++) {
		attron(COLOR_PAIR(1));
		printw("*");
		move(y, 44);
		attroff(COLOR_PAIR(1));
	}
	for(x = 44; x < 100; x++) {
		attron(COLOR_PAIR(1));
		printw("*");
		move(11, x);
		attroff(COLOR_PAIR(1));
	}
	for(y = 0; y < 11; y++) {
		attron(COLOR_PAIR(1));
		printw("*");
		move(y, 100);
		attroff(COLOR_PAIR(1));
	}
	init_pair(2,COLOR_YELLOW,COLOR_BLACK);
        attron(COLOR_PAIR(2));
        border(0,0,0,0, 0,0,0,0);
        refresh();
        attroff(COLOR_PAIR(2));
        refresh();	
	mvaddstr(2,60," ----- SELECT GENRES -----");
	mvaddstr(4,48,"1. Fiction");
	mvaddstr(5,48,"2. Non-fiction");
	mvaddstr(6,48,"3. Reference");
	mvaddstr(7,48,"4. Self-help");
	mvaddstr(8,48,"5. Back to main menu");
	mvaddstr(9,48,"Enter your choice:");
   	refresh();
}
コード例 #23
0
ファイル: notif.c プロジェクト: maxux/easynotif
void *reset(void *dummy) {
	while(1) {
		// waiting user input
		getchar();
		split();

		// reset black color
		bkgd(COLOR_PAIR(2));
		refresh();

		newmessage = 0;
		
		// mark all as read
		db_query(db, "UPDATE notifications SET read = 1");
	}
	
	return dummy;
}
コード例 #24
0
ファイル: main.c プロジェクト: vdaviot/2048
static void	init(t_game *game)
{
	game->menubar = NULL;
	game->win = NULL;
	game->msgbar = NULL;
	game->menulist = NULL;
	game->scorelist = NULL;
	init_array(game);
	start_color();
	curs_set(0);
	init_pair(1, COLOR_CYAN, COLOR_BLACK);
	init_pair(2, COLOR_RED, COLOR_BLACK);
	init_pair(3, COLOR_BLUE, COLOR_BLACK);
	init_pair(4, COLOR_GREEN, COLOR_BLACK);
	noecho();
	keypad(stdscr, TRUE);
	bkgd(COLOR_PAIR(1));
	refresh();
}
コード例 #25
0
ファイル: jeu_2048_curse.c プロジェクト: isputra/jeu2048
int main (void) {
    int tab[DIM_JEU][DIM_JEU], key, int_jeu_2048, score=0;
    char continuer='y';
    srand(time(NULL));
    
    init_curses();
    bkgd(COLOR_PAIR(1));
    affiche_menu();    
    key=getch();    
   
    while(key!=ESCAPE)
    {
	if(key == KEY_F(2)) 
	{
	  clear();
	  affiche_menu();
	  InitJeu(tab, &score);
	  do
	  {
	    int_jeu_2048 = jeu_2048(tab, &score);
	    if(int_jeu_2048 == 3)
	    {
		move(4,0);
		printw(" Vous avez atteint l'objectif ! \n");
		printw(" Vous voulez continuer? (y/n) ");
		continuer = SaisieOuiNon();
	    }
	  }
	  while (continuer == 'y' && int_jeu_2048 > 1);
	  
	  if(int_jeu_2048 == 0)
	      printw(" Vouz avez perdu. \n");
	  if(int_jeu_2048 == 1)
	      printw(" Vouz ne pouvez plus retasser. \n");
	}
	key=getch();
    }
    
    endwin();
    
    return 0;
}
コード例 #26
0
ファイル: touchwin.c プロジェクト: wkoszek/ncurses_guide
int main(void)
{
    WINDOW *bob;

    initscr();
    start_color();
    init_pair(1,COLOR_WHITE,COLOR_BLUE);
    init_pair(2,COLOR_RED,COLOR_WHITE);

    bob = newwin(0,0,0,0);
    wbkgd(bob,COLOR_PAIR(2));
    bkgd(COLOR_PAIR(1));

    waddstr(bob,"Hello from the window bob!\n");
    waddstr(bob,"I like long walks and romantic candlelit dinners.\n");
    waddstr(bob,"Press Enter to return to the standard screen.\n");
    addstr("This is the standard screen.\n");
    addstr("To see the window bob, press the Enter key:\n");
    refresh();
    getch();

    wrefresh(bob);
    getch();

    addstr("Welcome back to the standard screen (kinda).\n");
    addstr("To see the whole window bob, press Enter.\n");
    refresh();
    getch();

    waddstr(bob,"Thanks!\n");
    waddstr(bob,"Press Enter to see the whole standard screen.\n");
    touchwin(bob);
    wrefresh(bob);
    getch();

    touchwin(stdscr);
    refresh();
    getch();

    endwin();
    return 0;
}
コード例 #27
0
ファイル: bib_game.c プロジェクト: angeloperpa/flappybrick
void start_page() {           //Inicio da pagina do game.
    FILE *start_game;
    char *line;
    int i;

    char load_start_game[] = "start_game.sprite";
    line = (char*) malloc (COLUNAS * sizeof(char));
    start_game = fopen(load_start_game, "r");
    i = 0;
    init_pair(1, COLOR_RED, COLOR_YELLOW);
    bkgd(COLOR_PAIR(1));
    fgets(line, COLUNAS, start_game);
    while(!feof(start_game)) {
        mvwprintw(stdscr, i, 0, line);
        wrefresh(stdscr);
        i++;
        fgets(line, COLUNAS, start_game);
    }
    fclose(start_game);
    wgetch(stdscr);
}
コード例 #28
0
ファイル: leaveok.c プロジェクト: wkoszek/ncurses_guide
int main(void)
{
	initscr();
	start_color();
	init_pair(1,COLOR_WHITE,COLOR_BLUE);

	addstr("This is the standard screen as it normally appears.\n");
	addstr("The cursor is synchronized ->");
	refresh();
	getch();

	leaveok(stdscr,TRUE);
	bkgd(COLOR_PAIR(1));
	addstr("\n\nThe cursor is now not being updated.\n");
	addstr("This means that it's position could be anywhere.\n");
	refresh();
	getch();

	endwin();
	return 0;
}
コード例 #29
0
ファイル: interface.c プロジェクト: albertoCaroM/cgdb
/* init_curses: Initializes curses and sets up the terminal properly.
 * ------------
 *
 * Return Value: Zero on success, non-zero on failure.
 */
static int init_curses()
{
    if (putenv("ESCDELAY=0") == -1)
        fprintf(stderr, "(%s:%d) putenv failed\r\n", __FILE__, __LINE__);

    initscr();                  /* Start curses mode */

    if ((curses_colors = has_colors())) {
        start_color();
#ifdef NCURSES_VERSION
        use_default_colors();
#else
        bkgdset(0);
        bkgd(COLOR_WHITE);
#endif
    }

    refresh();                  /* Refresh the initial window once */
    curses_initialized = 1;

    return 0;
}
コード例 #30
0
ファイル: bib_game.c プロジェクト: angeloperpa/flappybrick
void gameover(char **tela, int score_global) {        ///Finaliza o jogo mostrando o score.
    int op, i, count;
    FILE *score_file;
    char line[30];
    score_t score;

    write_screen(tela, score_global);
    clear();
    show_score(score_global);
    count = 0;
    init_pair(1, COLOR_RED, COLOR_YELLOW);
    bkgd(COLOR_PAIR(1));
    score_file = fopen("score.sprite", "r");
    while(!feof(score_file)) {
		fgets(line, COLUNAS, score_file);
		mvprintw(count, 0, "%s", line);
		count++;
	}
	fclose(score_file);
    score_file = fopen("score.txt", "r");

  for(i = 0; i < 5; i++)
  {
		fgets(line, 30, score_file);
    sscanf(line, "%s %d %d %d %d", score.nome, &score.dia, &score.mes, &score.ano, &score.score);
		mvprintw(i + (count + 2), 0, "%d. %s        %d/%d/%d     %d ", (i + 1), score.nome, score.dia, score.mes, score.ano, score.score);
	}
	fclose(score_file);
	refresh();

    while (1) {
        op = getch();
        if(op == KEY_UP) {
            score_global = 0;
            tela = init_screen(COLUNAS, LINHAS);
            game_init(tela);
        }
    }
}