⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmas.c

📁 ncurses-5.4 需要的就来下把 一定会有用的哦
💻 C
📖 第 1 页 / 共 3 页
字号:
/******************************************************************************//* asciixmas                                                                  *//* December 1989             Larry Bartz           Indianapolis, IN           *//*                                                                            *//*                                                                            *//* I'm dreaming of an ascii character-based monochrome Christmas,             *//* Just like the one's I used to know!                                        *//* Via a full duplex communications channel,                                  *//* At 9600 bits per second,                                                   *//* Even though it's kinda slow.                                               *//*                                                                            *//* I'm dreaming of an ascii character-based monochrome Christmas,             *//* With ev'ry C program I write!                                              *//* May your screen be merry and bright!                                       *//* And may all your Christmases be amber or green,                            *//* (for reduced eyestrain and improved visibility)!                           *//*                                                                            *//*                                                                            *//*                                                                            *//*                                                                            *//*                                                                            *//* IMPLEMENTATION                                                             *//*                                                                            *//* Feel free to modify the defined string FROMWHO to reflect you, your        *//* organization, your site, whatever.                                         *//*                                                                            *//* This really looks a lot better if you can turn off your cursor before      *//* execution. I wanted to do that here but very few termcap entries or        *//* terminfo definitions have the appropriate string defined. If you know      *//* the string(s) for the terminal(s) you use or which your site supports,     *//* you could call asciixmas from within a shell in which you issue the        *//* string to the terminal. The cursor is distracting but it doesn't really    *//* ruin the show.                                                             *//*                                                                            *//* At our site, we invoke this for our users just after login and the         *//* determination of terminal type.                                            *//*                                                                            *//*                                                                            *//* PORTABILITY                                                                *//*                                                                            *//* I wrote this using only the very simplest curses functions so that it      *//* might be the most portable. I was personally able to test on five          *//* different cpu/UNIX combinations.                                           *//*                                                                            *//*                                                                            *//* COMPILE                                                                    *//*                                                                            *//* usually this:                                                              *//*                                                                            *//* cc -O asciixmas.c -lcurses -o asciixmas -s                                 *//*                                                                            *//*                                                                            *//* Zilog S8000 models 11, 21, 31, etc with ZEUS variant of SYSTEM III         *//* maybe other SYSTEM III also:                                               *//*                                                                            *//* cc asciixmas.c -lcurses -ltermlib -o asciixmas -s                          *//*                                                                            *//* as above with optional "peephole optimizer" installed:                     *//*                                                                            *//* cc -O asciixmas.c -lcurses -ltermlib -o asciixmas -s                       *//*                                                                            *//*                                                                            *//* Zilog S8000 models 32, 130 with WE32100 chip and SYS V, REL2               *//* maybe 3B2 also?                                                            *//*                                                                            *//* cc -f -O -K sd asciixmas.c -lcurses -o asciixmas -s                        *//*                                                                            *//*                                                                            *//* Pyramid, Sequent, any other "dual universe" types compile and execute      *//* under either universe. The compile line for the ucb universe (as you       *//* might expect) is the same as for SYS III UNIX:                             *//*                                                                            *//* cc -O asciixmas.c -lcurses -ltermlib -o asciixmas -s                       *//*                                                                            *//* The above compile will also hold true for other BSD systems. (I hope)      *//*                                                                            *//*                                                                            *//*                                                                            *//*                                                                            *//* For the Scrooges out there among you who don't want this thing to loop     *//* forever (or until the user hits a key), insert this into your compile      *//* line just after "cc" :                                                     *//*                                                                            *//* -DNOLOOP                                                                   *//*                                                                            *//* like so:                                                                   *//*                                                                            *//* cc -DNOLOOP -O asciixmas.c -lcurses -o asciixmas -s                        *//*                                                                            *//*                                                                            *//*                                                                            *//******************************************************************************//* * $Id: xmas.c,v 1.19 2002/06/29 23:32:18 tom Exp $ */#include <test.priv.h>#define FROMWHO "Mark Hessling - (M.Hessling@gu.edu.au)"static int my_bg = COLOR_BLACK;static int y_pos, x_pos;static WINDOW *treescrn;static WINDOW *treescrn2;static WINDOW *treescrn3;static WINDOW *treescrn4;static WINDOW *treescrn5;static WINDOW *treescrn6;static WINDOW *treescrn7;static WINDOW *treescrn8;static WINDOW *dotdeer0;static WINDOW *stardeer0;static WINDOW *lildeer0;static WINDOW *lildeer1;static WINDOW *lildeer2;static WINDOW *lildeer3;static WINDOW *middeer0;static WINDOW *middeer1;static WINDOW *middeer2;static WINDOW *middeer3;static WINDOW *bigdeer0;static WINDOW *bigdeer1;static WINDOW *bigdeer2;static WINDOW *bigdeer3;static WINDOW *bigdeer4;static WINDOW *lookdeer0;static WINDOW *lookdeer1;static WINDOW *lookdeer2;static WINDOW *lookdeer3;static WINDOW *lookdeer4;static WINDOW *w_holiday;static WINDOW *w_del_msg;static int boxit(void);static int seas(void);static int greet(void);static int fromwho(void);static int tree(void);static int balls(void);static int star(void);static int strng1(void);static int strng2(void);static int strng3(void);static int strng4(void);static int strng5(void);static int reindeer(void);static int blinkit(void);static RETSIGTYPE done(int sig) GCC_NORETURN;static voidset_color(WINDOW *win, chtype color){    if (has_colors()) {	static bool *pairs;	int n = (color + 1);	if (pairs == 0)	    pairs = (bool *) calloc(COLORS + 1, sizeof(bool));	if (!pairs[n]) {	    init_pair(n, color, my_bg);	    pairs[n] = TRUE;	}	wattroff(win, A_COLOR);	wattron(win, COLOR_PAIR(n));    }}static voidunset_color(WINDOW *win){    if (has_colors())	wattrset(win, COLOR_PAIR(0));}static voidlook_out(int msecs){    napms(msecs);    if (getch() != ERR) {	beep();	done(0);    }}intmain(int argc GCC_UNUSED, char **argv GCC_UNUSED){    int loopy;    setlocale(LC_ALL, "");    initscr();    noecho();    nonl();    refresh();    signal(SIGINT, done);    signal(SIGTERM, done);#if !defined	DOS && !defined OS2    signal(SIGHUP, done);    signal(SIGQUIT, done);#endif    if (has_colors()) {	start_color();#if HAVE_USE_DEFAULT_COLORS	if (use_default_colors() == OK)	    my_bg = -1;#endif    }    curs_set(0);    treescrn = newwin(16, 27, 3, 53);    treescrn2 = newwin(16, 27, 3, 53);    treescrn3 = newwin(16, 27, 3, 53);    treescrn4 = newwin(16, 27, 3, 53);    treescrn5 = newwin(16, 27, 3, 53);    treescrn6 = newwin(16, 27, 3, 53);    treescrn7 = newwin(16, 27, 3, 53);    treescrn8 = newwin(16, 27, 3, 53);    dotdeer0 = newwin(3, 71, 0, 8);    stardeer0 = newwin(4, 56, 0, 8);    lildeer0 = newwin(7, 53, 0, 8);    lildeer1 = newwin(2, 4, 0, 0);    lildeer2 = newwin(2, 4, 0, 0);    lildeer3 = newwin(2, 4, 0, 0);    middeer0 = newwin(15, 42, 0, 8);    middeer1 = newwin(3, 7, 0, 0);    middeer2 = newwin(3, 7, 0, 0);    middeer3 = newwin(3, 7, 0, 0);    bigdeer0 = newwin(10, 23, 0, 0);    bigdeer1 = newwin(10, 23, 0, 0);    bigdeer2 = newwin(10, 23, 0, 0);    bigdeer3 = newwin(10, 23, 0, 0);    bigdeer4 = newwin(10, 23, 0, 0);    lookdeer0 = newwin(10, 25, 0, 0);    lookdeer1 = newwin(10, 25, 0, 0);    lookdeer2 = newwin(10, 25, 0, 0);    lookdeer3 = newwin(10, 25, 0, 0);    lookdeer4 = newwin(10, 25, 0, 0);    w_holiday = newwin(1, 26, 3, 27);    w_del_msg = newwin(1, 19, 23, 60);    mvwaddstr(w_del_msg, 0, 0, "Hit any key to quit");    mvwaddstr(w_holiday, 0, 0, "H A P P Y  H O L I D A Y S");    /* set up the windows for our various reindeer */    /* lildeer1 */    mvwaddch(lildeer1, 0, 0, (chtype) 'V');    mvwaddch(lildeer1, 1, 0, (chtype) '@');    mvwaddch(lildeer1, 1, 1, (chtype) '<');    mvwaddch(lildeer1, 1, 2, (chtype) '>');    mvwaddch(lildeer1, 1, 3, (chtype) '~');    /* lildeer2 */    mvwaddch(lildeer2, 0, 0, (chtype) 'V');    mvwaddch(lildeer2, 1, 0, (chtype) '@');    mvwaddch(lildeer2, 1, 1, (chtype) '|');    mvwaddch(lildeer2, 1, 2, (chtype) '|');    mvwaddch(lildeer2, 1, 3, (chtype) '~');    /* lildeer3 */    mvwaddch(lildeer3, 0, 0, (chtype) 'V');    mvwaddch(lildeer3, 1, 0, (chtype) '@');    mvwaddch(lildeer3, 1, 1, (chtype) '>');    mvwaddch(lildeer3, 1, 2, (chtype) '<');    mvwaddch(lildeer2, 1, 3, (chtype) '~');    /* middeer1 */    mvwaddch(middeer1, 0, 2, (chtype) 'y');    mvwaddch(middeer1, 0, 3, (chtype) 'y');    mvwaddch(middeer1, 1, 2, (chtype) '0');    mvwaddch(middeer1, 1, 3, (chtype) '(');    mvwaddch(middeer1, 1, 4, (chtype) '=');    mvwaddch(middeer1, 1, 5, (chtype) ')');    mvwaddch(middeer1, 1, 6, (chtype) '~');    mvwaddch(middeer1, 2, 3, (chtype) '\\');    mvwaddch(middeer1, 2, 4, (chtype) '/');    /* middeer2 */    mvwaddch(middeer2, 0, 2, (chtype) 'y');    mvwaddch(middeer2, 0, 3, (chtype) 'y');    mvwaddch(middeer2, 1, 2, (chtype) '0');    mvwaddch(middeer2, 1, 3, (chtype) '(');    mvwaddch(middeer2, 1, 4, (chtype) '=');    mvwaddch(middeer2, 1, 5, (chtype) ')');    mvwaddch(middeer2, 1, 6, (chtype) '~');    mvwaddch(middeer2, 2, 3, (chtype) '|');    mvwaddch(middeer2, 2, 5, (chtype) '|');    /* middeer3 */    mvwaddch(middeer3, 0, 2, (chtype) 'y');    mvwaddch(middeer3, 0, 3, (chtype) 'y');    mvwaddch(middeer3, 1, 2, (chtype) '0');    mvwaddch(middeer3, 1, 3, (chtype) '(');    mvwaddch(middeer3, 1, 4, (chtype) '=');    mvwaddch(middeer3, 1, 5, (chtype) ')');    mvwaddch(middeer3, 1, 6, (chtype) '~');    mvwaddch(middeer3, 2, 2, (chtype) '/');    mvwaddch(middeer3, 2, 6, (chtype) '\\');    /* bigdeer1 */    mvwaddch(bigdeer1, 0, 17, (chtype) '\\');    mvwaddch(bigdeer1, 0, 18, (chtype) '/');    mvwaddch(bigdeer1, 0, 20, (chtype) '\\');    mvwaddch(bigdeer1, 0, 21, (chtype) '/');    mvwaddch(bigdeer1, 1, 18, (chtype) '\\');    mvwaddch(bigdeer1, 1, 20, (chtype) '/');    mvwaddch(bigdeer1, 2, 19, (chtype) '|');    mvwaddch(bigdeer1, 2, 20, (chtype) '_');    mvwaddch(bigdeer1, 3, 18, (chtype) '/');    mvwaddch(bigdeer1, 3, 19, (chtype) '^');    mvwaddch(bigdeer1, 3, 20, (chtype) '0');    mvwaddch(bigdeer1, 3, 21, (chtype) '\\');    mvwaddch(bigdeer1, 4, 17, (chtype) '/');    mvwaddch(bigdeer1, 4, 18, (chtype) '/');    mvwaddch(bigdeer1, 4, 19, (chtype) '\\');    mvwaddch(bigdeer1, 4, 22, (chtype) '\\');    mvwaddstr(bigdeer1, 5, 7, "^~~~~~~~~//  ~~U");    mvwaddstr(bigdeer1, 6, 7, "( \\_____( /");    mvwaddstr(bigdeer1, 7, 8, "( )    /");    mvwaddstr(bigdeer1, 8, 9, "\\\\   /");    mvwaddstr(bigdeer1, 9, 11, "\\>/>");    /* bigdeer2 */    mvwaddch(bigdeer2, 0, 17, (chtype) '\\');    mvwaddch(bigdeer2, 0, 18, (chtype) '/');    mvwaddch(bigdeer2, 0, 20, (chtype) '\\');    mvwaddch(bigdeer2, 0, 21, (chtype) '/');    mvwaddch(bigdeer2, 1, 18, (chtype) '\\');    mvwaddch(bigdeer2, 1, 20, (chtype) '/');    mvwaddch(bigdeer2, 2, 19, (chtype) '|');    mvwaddch(bigdeer2, 2, 20, (chtype) '_');    mvwaddch(bigdeer2, 3, 18, (chtype) '/');    mvwaddch(bigdeer2, 3, 19, (chtype) '^');    mvwaddch(bigdeer2, 3, 20, (chtype) '0');    mvwaddch(bigdeer2, 3, 21, (chtype) '\\');    mvwaddch(bigdeer2, 4, 17, (chtype) '/');    mvwaddch(bigdeer2, 4, 18, (chtype) '/');    mvwaddch(bigdeer2, 4, 19, (chtype) '\\');    mvwaddch(bigdeer2, 4, 22, (chtype) '\\');    mvwaddstr(bigdeer2, 5, 7, "^~~~~~~~~//  ~~U");    mvwaddstr(bigdeer2, 6, 7, "(( )____( /");    mvwaddstr(bigdeer2, 7, 7, "( /      |");    mvwaddstr(bigdeer2, 8, 8, "\\/      |");    mvwaddstr(bigdeer2, 9, 9, "|>     |>");    /* bigdeer3 */    mvwaddch(bigdeer3, 0, 17, (chtype) '\\');    mvwaddch(bigdeer3, 0, 18, (chtype) '/');    mvwaddch(bigdeer3, 0, 20, (chtype) '\\');    mvwaddch(bigdeer3, 0, 21, (chtype) '/');    mvwaddch(bigdeer3, 1, 18, (chtype) '\\');    mvwaddch(bigdeer3, 1, 20, (chtype) '/');    mvwaddch(bigdeer3, 2, 19, (chtype) '|');    mvwaddch(bigdeer3, 2, 20, (chtype) '_');    mvwaddch(bigdeer3, 3, 18, (chtype) '/');    mvwaddch(bigdeer3, 3, 19, (chtype) '^');    mvwaddch(bigdeer3, 3, 20, (chtype) '0');    mvwaddch(bigdeer3, 3, 21, (chtype) '\\');    mvwaddch(bigdeer3, 4, 17, (chtype) '/');    mvwaddch(bigdeer3, 4, 18, (chtype) '/');    mvwaddch(bigdeer3, 4, 19, (chtype) '\\');    mvwaddch(bigdeer3, 4, 22, (chtype) '\\');    mvwaddstr(bigdeer3, 5, 7, "^~~~~~~~~//  ~~U");    mvwaddstr(bigdeer3, 6, 6, "( ()_____( /");    mvwaddstr(bigdeer3, 7, 6, "/ /       /");    mvwaddstr(bigdeer3, 8, 5, "|/          \\");    mvwaddstr(bigdeer3, 9, 5, "/>           \\>");    /* bigdeer4 */    mvwaddch(bigdeer4, 0, 17, (chtype) '\\');    mvwaddch(bigdeer4, 0, 18, (chtype) '/');    mvwaddch(bigdeer4, 0, 20, (chtype) '\\');    mvwaddch(bigdeer4, 0, 21, (chtype) '/');    mvwaddch(bigdeer4, 1, 18, (chtype) '\\');    mvwaddch(bigdeer4, 1, 20, (chtype) '/');    mvwaddch(bigdeer4, 2, 19, (chtype) '|');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -