Exemple #1
0
static void
draw_object_cb(struct gol *g, void *data, int y, int x) {
    const cchar_t wc = g->table[y][x].alive_this_round ?
        g->ncurses_alive_character : g->ncurses_not_alive_character;
    add_wch(&wc);
    if (x == g->columns - 1)
        move(y + 1, 0);
}
// taken from David X at StackOverflow
// needed to display unicode
int add_wchar(int c)
{
    cchar_t t = {
        0 , // .attr
        {c,0} // not sure how .chars works, so best guess
        };
    return add_wch(&t);
}
Exemple #3
0
int CmdOutput(const byte *pData, int iDataLen, bool bSingleChar, bool bUTF8)
{
#ifdef BUILDWIDE
   int iDataPos = 0, iDataMove = 0;
   unsigned int iUCS = 0;
   bool bValid = false;
   unsigned char *szChars = NULL;
   cchar_t *pChars = NULL;
#endif

   if(bSingleChar == true)
   {
#ifdef BUILDWIDE
      if(bUTF8 == true)
      {
         pChars = new cchar_t;
         pChars->attr = A_NORMAL;
         pChars->chars[4] = 0;

         for(iDataPos = 0; iDataPos < iDataLen; iDataPos++)
         {
            iUCS = CmdDecode((byte *)pData + iDataPos, &iDataMove, &bValid);
            iDataPos += iDataMove;

            if(bValid == true)
            {
               szChars = CmdEncode(iUCS);

               pChars->chars[0] = szChars[0];
               pChars->chars[1] = szChars[1];
               pChars->chars[2] = szChars[2];
               pChars->chars[3] = szChars[3];

               add_wch(pChars);

               delete[] szChars;
            }
         }

         delete pChars;
      }
      else
#endif
      {
         addch(168);
      }
   }
   else
   {
      addnstr((char *)pData, iDataLen);
   }

   return iDataLen;
}
Exemple #4
0
static int
AddCh(chtype ch)
{
    int code;
    cchar_t tmp_cchar;

    if (ConvertCh(ch, &tmp_cchar)) {
	code = add_wch(&tmp_cchar);
    } else {
	code = addch(ch);
    }
    return code;
}
Exemple #5
0
static void
init_wide_panel(void)
{
    int digit;
    cchar_t temp[10];

    for (digit = 0; digit < 10; ++digit)
	make_fullwidth_digit(&temp[digit], digit);

    do {
	int y, x;
	getyx(stdscr, y, x);
	digit = (y + x / 2) % 10;
    } while (add_wch(&temp[digit]) != ERR);
}
int addch_unicode(int c) {
   wchar_t wch;
   cchar_t cch;

   if (unicode_mode) {
      // We can do this because we've already verified
      // that __STDC_ISO_10646__ is set.
      wch = c;

      setcchar(&cch, &wch, 0, 0, NULL);
      return add_wch(&cch);
   } else {
      return addch(lookup_unicode_hack(c));
   }
}
Exemple #7
0
void acsTest(WINDOW *win)
{
    static const char *acs_names[] =
    {
        "ACS_ULCORNER", "ACS_URCORNER", "ACS_LLCORNER", "ACS_LRCORNER",
        "ACS_LTEE", "ACS_RTEE", "ACS_TTEE", "ACS_BTEE", "ACS_HLINE",
        "ACS_VLINE", "ACS_PLUS",

#ifdef ACS_D_ULCORNER
        "ACS_D_ULCORNER", "ACS_D_URCORNER", "ACS_D_LLCORNER", "ACS_D_LRCORNER",
        "ACS_D_LTEE", "ACS_D_RTEE", "ACS_D_TTEE", "ACS_D_BTEE", "ACS_D_HLINE",
        "ACS_D_VLINE", "ACS_D_PLUS",
        "ACS_SD_ULCORNER", "ACS_SD_URCORNER", "ACS_SD_LLCORNER",
        "ACS_SD_LRCORNER", "ACS_SD_LTEE",
        "ACS_SD_RTEE", "ACS_SD_TTEE", "ACS_SD_BTEE", "ACS_SD_PLUS",
        "ACS_DS_ULCORNER", "ACS_DS_URCORNER", "ACS_DS_LLCORNER",
        "ACS_DS_LRCORNER", "ACS_DS_LTEE", "ACS_DS_RTEE", "ACS_DS_TTEE",
        "ACS_DS_BTEE", "ACS_DS_PLUS",
#endif
        "ACS_S1",
#ifdef ACS_S3
        "ACS_S3", "ACS_S7",
#endif
        "ACS_S9", "ACS_DIAMOND",
#ifdef ACS_CLUB
        "ACS_CLUB", "ACS_SPADE", "ACS_HEART",
        "ACS_LTBOARD",
#endif
        "ACS_BOARD", "ACS_CKBOARD", "ACS_DEGREE", "ACS_PLMINUS",
        "ACS_BULLET",
#ifdef ACS_SM_BULLET
        "ACS_SM_BULLET", "ACS_MED_BULLET", "ACS_WHITE_BULLET",
        "ACS_PILCROW", "ACS_SECTION", "ACS_SMILE", "ACS_REV_SMILE",
#endif
        "ACS_LARROW", "ACS_RARROW", "ACS_UARROW", "ACS_DARROW",
        "ACS_LANTERN", "ACS_BLOCK",
#ifdef ACS_LEQUAL
        "ACS_LEQUAL", "ACS_GEQUAL", "ACS_NEQUAL",
        "ACS_PI",  "ACS_STERLING",
#endif
#ifdef ACS_CENT
        "ACS_CENT", "ACS_YEN", "ACS_PESETA",
        "ACS_ALPHA", "ACS_BETA", "ACS_GAMMA", "ACS_UP_SIGMA",
        "ACS_LO_SIGMA", "ACS_MU", "ACS_TAU", "ACS_UP_PHI", "ACS_LO_PHI",
        "ACS_OMEGA", "ACS_DELTA", "ACS_INFINITY", "ACS_THETA", "ACS_EPSILON",
        "ACS_INTERSECT", "ACS_SUP2", "ACS_SUP_N", "ACS_TRIPLE_BAR",
        "ACS_APPROX_EQ", "ACS_SQUARE_ROOT", "ACS_NOT", "ACS_REV_NOT",
        "ACS_HALF", "ACS_QUARTER", "ACS_DIVISION",
        "ACS_UP_INTEGRAL", "ACS_LO_INTEGRAL",
        "ACS_UBLOCK", "ACS_BBLOCK",
        "ACS_LBLOCK", "ACS_RBLOCK",
        "ACS_A_ORDINAL", "ACS_O_ORDINAL",
        "ACS_INV_BANG", "ACS_INV_QUERY",
        "ACS_LEFT_ANG_QU", "ACS_RIGHT_ANG_QU",
        "ACS_CENTER_SQU", "ACS_F_WITH_HOOK",
#endif
    };

    const chtype acs_values[] =
    {
        ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER,
        ACS_LTEE, ACS_RTEE, ACS_TTEE, ACS_BTEE, ACS_HLINE,
        ACS_VLINE, ACS_PLUS,

#ifdef ACS_D_ULCORNER
        ACS_D_ULCORNER, ACS_D_URCORNER, ACS_D_LLCORNER, ACS_D_LRCORNER,
        ACS_D_LTEE, ACS_D_RTEE, ACS_D_TTEE, ACS_D_BTEE, ACS_D_HLINE,
        ACS_D_VLINE, ACS_D_PLUS,
        ACS_SD_ULCORNER, ACS_SD_URCORNER, ACS_SD_LLCORNER,
        ACS_SD_LRCORNER, ACS_SD_LTEE,
        ACS_SD_RTEE, ACS_SD_TTEE, ACS_SD_BTEE, ACS_SD_PLUS,
        ACS_DS_ULCORNER, ACS_DS_URCORNER, ACS_DS_LLCORNER,
        ACS_DS_LRCORNER, ACS_DS_LTEE, ACS_DS_RTEE, ACS_DS_TTEE,
        ACS_DS_BTEE, ACS_DS_PLUS,
#endif
        ACS_S1,
#ifdef ACS_S3
        ACS_S3, ACS_S7,
#endif
        ACS_S9, ACS_DIAMOND,
#ifdef ACS_CLUB
        ACS_CLUB, ACS_SPADE, ACS_HEART, ACS_LTBOARD,
#endif
        ACS_BOARD, ACS_CKBOARD, ACS_DEGREE, ACS_PLMINUS, ACS_BULLET,
#ifdef ACS_SM_BULLET
        ACS_SM_BULLET, ACS_MED_BULLET, ACS_WHITE_BULLET,
        ACS_PILCROW, ACS_SECTION, ACS_SMILE, ACS_REV_SMILE,
#endif
        ACS_LARROW, ACS_RARROW, ACS_UARROW, ACS_DARROW,
        ACS_LANTERN, ACS_BLOCK,
#ifdef ACS_LEQUAL
        ACS_LEQUAL, ACS_GEQUAL, ACS_NEQUAL,
        ACS_PI,  ACS_STERLING,
#endif
#ifdef ACS_CENT
        ACS_CENT, ACS_YEN, ACS_PESETA,
        ACS_ALPHA, ACS_BETA, ACS_GAMMA, ACS_UP_SIGMA,
        ACS_LO_SIGMA, ACS_MU, ACS_TAU, ACS_UP_PHI, ACS_LO_PHI,
        ACS_OMEGA, ACS_DELTA, ACS_INFINITY, ACS_THETA, ACS_EPSILON,
        ACS_INTERSECT, ACS_SUP2, ACS_SUP_N, ACS_TRIPLE_BAR,
        ACS_APPROX_EQ, ACS_SQUARE_ROOT, ACS_NOT, ACS_REV_NOT,
        ACS_HALF, ACS_QUARTER, ACS_DIVISION,
        ACS_UP_INTEGRAL, ACS_LO_INTEGRAL,
        ACS_UBLOCK, ACS_BBLOCK,
        ACS_LBLOCK, ACS_RBLOCK,
        ACS_A_ORDINAL, ACS_O_ORDINAL,
        ACS_INV_BANG, ACS_INV_QUERY,
        ACS_LEFT_ANG_QU, ACS_RIGHT_ANG_QU,
        ACS_CENTER_SQU, ACS_F_WITH_HOOK,
#endif
    };

#if HAVE_WIDE
    const cchar_t *wacs_values[] =
    {
        WACS_ULCORNER, WACS_URCORNER, WACS_LLCORNER, WACS_LRCORNER,
        WACS_LTEE, WACS_RTEE, WACS_TTEE, WACS_BTEE, WACS_HLINE,
        WACS_VLINE, WACS_PLUS,

#ifdef WACS_D_ULCORNER
        WACS_D_ULCORNER, WACS_D_URCORNER, WACS_D_LLCORNER, WACS_D_LRCORNER,
        WACS_D_LTEE, WACS_D_RTEE, WACS_D_TTEE, WACS_D_BTEE, WACS_D_HLINE,
        WACS_D_VLINE, WACS_D_PLUS,
        WACS_SD_ULCORNER, WACS_SD_URCORNER, WACS_SD_LLCORNER,
        WACS_SD_LRCORNER, WACS_SD_LTEE,
        WACS_SD_RTEE, WACS_SD_TTEE, WACS_SD_BTEE, WACS_SD_PLUS,
        WACS_DS_ULCORNER, WACS_DS_URCORNER, WACS_DS_LLCORNER,
        WACS_DS_LRCORNER, WACS_DS_LTEE, WACS_DS_RTEE, WACS_DS_TTEE,
        WACS_DS_BTEE, WACS_DS_PLUS,
#endif
        WACS_S1,
#ifdef WACS_S3
        WACS_S3, WACS_S7,
#endif
        WACS_S9, WACS_DIAMOND,
#ifdef WACS_CLUB
        WACS_CLUB, WACS_SPADE, WACS_HEART, WACS_LTBOARD,
#endif
        WACS_BOARD, WACS_CKBOARD, WACS_DEGREE, WACS_PLMINUS, WACS_BULLET,
#ifdef WACS_SM_BULLET
        WACS_SM_BULLET, WACS_MED_BULLET, WACS_WHITE_BULLET,
        WACS_PILCROW, WACS_SECTION, WACS_SMILE, WACS_REV_SMILE,
#endif
        WACS_LARROW, WACS_RARROW, WACS_UARROW, WACS_DARROW,
        WACS_LANTERN, WACS_BLOCK,
#ifdef WACS_LEQUAL
        WACS_LEQUAL, WACS_GEQUAL, WACS_NEQUAL,
        WACS_PI,  WACS_STERLING,
#endif
#ifdef WACS_CENT
        WACS_CENT, WACS_YEN, WACS_PESETA,
        WACS_ALPHA, WACS_BETA, WACS_GAMMA, WACS_UP_SIGMA,
        WACS_LO_SIGMA, WACS_MU, WACS_TAU, WACS_UP_PHI, WACS_LO_PHI,
        WACS_OMEGA, WACS_DELTA, WACS_INFINITY, WACS_THETA, WACS_EPSILON,
        WACS_INTERSECT, WACS_SUP2, WACS_SUP_N, WACS_TRIPLE_BAR,
        WACS_APPROX_EQ, WACS_SQUARE_ROOT, WACS_NOT, WACS_REV_NOT,
        WACS_HALF, WACS_QUARTER, WACS_DIVISION,
        WACS_UP_INTEGRAL, WACS_LO_INTEGRAL,
        WACS_UBLOCK, WACS_BBLOCK,
        WACS_LBLOCK, WACS_RBLOCK,
        WACS_A_ORDINAL, WACS_O_ORDINAL,
        WACS_INV_BANG, WACS_INV_QUERY,
        WACS_LEFT_ANG_QU, WACS_RIGHT_ANG_QU,
        WACS_CENTER_SQU, WACS_F_WITH_HOOK,
#endif
    };

    static const wchar_t russian[] = {0x0420, 0x0443, 0x0441, 0x0441,
        0x043a, 0x0438, 0x0439, L' ', 0x044f, 0x0437, 0x044b, 0x043a, 0};

    static const wchar_t greek[] = {0x0395, 0x03bb, 0x03bb, 0x03b7,
        0x03bd, 0x03b9, 0x03ba, 0x03ac, 0};

    static const wchar_t georgian[] = {0x10e5, 0x10d0, 0x10e0, 0x10d7,
        0x10e3, 0x10da, 0x10d8, L' ', 0x10d4, 0x10dc, 0x10d0, 0};

    static const wchar_t fullwidth[] = { 0xff26, 0xff55, 0xff4c, 0xff4c,
        0xff57, 0xff49, 0xff44, 0xff54, 0xff48, 0 };  /* "Fullwidth" */
#endif

    int i, tmarg = 1, ncols = COLS / 19;
    int n_items = sizeof( acs_names) / sizeof( acs_names[0]);
    int n_rows = (n_items + ncols - 1) / ncols;
    int col_size = COLS / ncols;

    i = 0;
    if( n_rows > LINES / 2 - 4)
        n_rows = LINES / 2 - 4;
    while( i < n_items)
    {
        int j;

        attrset(A_BOLD);
        mvaddstr( 1, (COLS - 23) / 2, "Alternate Character Set");
        attrset(A_NORMAL);
        tmarg = 4;
        for( j = 0; i + j < n_items && j < n_rows * ncols; j++)
        {
            move((j % n_rows) * 2 + tmarg,
                  (j / n_rows) * col_size + col_size / 2 - 7);
            addch(acs_values[i + j]);
            printw(" %s", acs_names[i + j]);
        }

        mvaddstr(tmarg + n_rows * 2 + 2, 3, "Press any key to continue");
        getch();
        i += j;
        clear( );
    }

#if HAVE_WIDE
    i = 0;
    while( i < n_items)
    {
        int j;

        attrset(A_BOLD);
        mvaddstr( 1, (COLS - 28) / 2, "Wide Alternate Character Set");
        attrset(A_NORMAL);
        tmarg = 4;
        for( j = 0; i + j < n_items && j < n_rows * ncols; j++)
        {
            move((j % n_rows) * 2 + tmarg,
                  (j / n_rows) * col_size + col_size / 2 - 7);
            add_wch(wacs_values[i + j]);
            printw(" W%s", acs_names[i + j]);
        }
    /* Spanish, Russian, Greek, Georgian, fullwidth */

        tmarg += n_rows * 2;
        mvaddwstr(tmarg, COLS / 8 - 5, L"Espa\xf1ol");
        mvaddwstr(tmarg, 3 * (COLS / 8) - 5, russian);
        mvaddwstr(tmarg, 5 * (COLS / 8) - 5, greek);
        mvaddwstr(tmarg, 7 * (COLS / 8) - 5, georgian);
        mvaddwstr(tmarg + 1, COLS / 8 - 5, fullwidth);

#if(CHTYPE_LONG >= 2)       /* "non-standard" 64-bit chtypes     */
        mvaddch( tmarg + 1, 7 * (COLS / 8) - 5, (chtype)0x1d11e);
#endif            /* U+1D11E = musical symbol G clef */

        mvaddstr(tmarg + 2, 3, "Press any key to continue");
        getch();
        i += j;
        clear( );
    }
#endif
}
Exemple #8
0
int
main(int argc, char *argv[])
{
	int optc;
	int option_differences = 0,
	    option_differences_cumulative = 0,
	    option_help = 0, option_version = 0;
	double interval = 2;
	char *command;
	int command_length = 0;	/* not including final \0 */

	setlocale(LC_ALL, "");
	progname = argv[0];

	while ((optc = getopt_long(argc, argv, "+d::hn:vt", longopts, (int *) 0))
	       != EOF) {
		switch (optc) {
		case 'd':
			option_differences = 1;
			if (optarg)
				option_differences_cumulative = 1;
			break;
		case 'h':
			option_help = 1;
			break;
		case 't':
			show_title = 0;
			break;
		case 'n':
			{
				char *str;
				interval = strtod(optarg, &str);
				if (!*optarg || *str)
					do_usage();
				if(interval < 0.1)
					interval = 0.1;
				if(interval > ~0u/1000000)
					interval = ~0u/1000000;
			}
			break;
		case 'v':
			option_version = 1;
			break;
		default:
			do_usage();
			break;
		}
	}

	if (option_version) {
		fprintf(stderr, "%s\n", VERSION);
		if (!option_help)
			exit(0);
	}

	if (option_help) {
		fprintf(stderr, usage, progname);
		fputs("  -d, --differences[=cumulative]\thighlight changes between updates\n", stderr);
		fputs("\t\t(cumulative means highlighting is cumulative)\n", stderr);
		fputs("  -h, --help\t\t\t\tprint a summary of the options\n", stderr);
		fputs("  -n, --interval=<seconds>\t\tseconds to wait between updates\n", stderr);
		fputs("  -v, --version\t\t\t\tprint the version number\n", stderr);
		fputs("  -t, --no-title\t\t\tturns off showing the header\n", stderr);
		exit(0);
	}

	if (optind >= argc)
		do_usage();

	command = strdup(argv[optind++]);
	command_length = strlen(command);
	for (; optind < argc; optind++) {
		char *endp;
		int s = strlen(argv[optind]);
		command = realloc(command, command_length + s + 2);	/* space and \0 */
		endp = command + command_length;
		*endp = ' ';
		memcpy(endp + 1, argv[optind], s);
		command_length += 1 + s;	/* space then string length */
		command[command_length] = '\0';
	}

	get_terminal_size();

	/* Catch keyboard interrupts so we can put tty back in a sane state.  */
	signal(SIGINT, die);
	signal(SIGTERM, die);
	signal(SIGHUP, die);
	signal(SIGWINCH, winch_handler);

	/* Set up tty for curses use.  */
	curses_started = 1;
	initscr();
	nonl();
	noecho();
	cbreak();

	for (;;) {
		time_t t = time(NULL);
		char *ts = ctime(&t);
		int tsl = strlen(ts);
		char *header;
		FILE *p;
		int x, y;
		int oldeolseen = 1;
		mbstate_t mbs;

		if (screen_size_changed) {
			get_terminal_size();
			resizeterm(height, width);
			clear();
			/* redrawwin(stdscr); */
			screen_size_changed = 0;
			first_screen = 1;
		}

		if (show_title) {
			// left justify interval and command,
			// right justify time, clipping all to fit window width
			asprintf(&header, "Every %.1fs: %.*s",
				interval, min(width - 1, command_length), command);
			mvaddstr(0, 0, header);
			if (strlen(header) > (size_t) (width - tsl - 1))
				mvaddstr(0, width - tsl - 4, "...  ");
			mvaddstr(0, width - tsl + 1, ts);
			free(header);
		}

		if (!(p = popen(command, "r"))) {
			perror("popen");
			do_exit(2);
		}

		memset(&mbs, 0, sizeof(mbs));
		for (y = show_title; y < height; y++) {
			int eolseen = 0, tabpending = 0;
			for (x = 0; x < width; x++) {
				wint_t c = L' ';
				int attr = 0, c_width;
				cchar_t cc;
				wchar_t wstr[2];

				if (!eolseen) {
					/* if there is a tab pending, just spit spaces until the
					   next stop instead of reading characters */
					if (!tabpending)
						do
							c = readwc(p, &mbs);
						while (c != WEOF && !iswprint(c)
						       && c != L'\n'
						       && c != L'\t');
					if (c == L'\n')
						if (!oldeolseen && x == 0) {
							x = -1;
							continue;
						} else
							eolseen = 1;
					else if (c == L'\t')
						tabpending = 1;
					if (c == WEOF || c == L'\n' || c == L'\t')
						c = L' ';
					if (tabpending && (((x + 1) % 8) == 0))
						tabpending = 0;
				}
				wstr[0] = c;
				wstr[1] = 0;
				setcchar (&cc, wstr, 0, 0, NULL);
				move(y, x);
				if (option_differences) {
					cchar_t oldc;
					wchar_t oldwstr[2];
					attr_t attrs;
					short colors;

					in_wch(&oldc);
					getcchar(&oldc, oldwstr, &attrs, &colors, NULL);
					attr = !first_screen
					    && (wstr[0] != oldwstr[0]
						||
						(option_differences_cumulative
						 && attrs));
				}
				if (attr)
					standout();
				add_wch(&cc);

				if (attr)
					standend();
				c_width = wcwidth(c);
				if (c_width > 1)
					x += c_width - 1;

			}
			oldeolseen = eolseen;
		}

		pclose(p);

		first_screen = 0;
		refresh();
		usleep(interval * 1000000);
	}

	endwin();

	return 0;
}
Exemple #9
0
void acsTest(WINDOW *win)
{
#ifdef ACS_S3
# define ACSNUM 32
#else
# define ACSNUM 25
#endif
    static const char *acs_names[] =
    {
        "ACS_ULCORNER", "ACS_URCORNER", "ACS_LLCORNER", "ACS_LRCORNER",
        "ACS_LTEE", "ACS_RTEE", "ACS_TTEE", "ACS_BTEE", "ACS_HLINE",
        "ACS_VLINE", "ACS_PLUS",

        "ACS_S1", "ACS_S9", "ACS_DIAMOND", "ACS_CKBOARD", "ACS_DEGREE",
        "ACS_PLMINUS", "ACS_BULLET",

        "ACS_LARROW", "ACS_RARROW", "ACS_UARROW", "ACS_DARROW",
        "ACS_BOARD", "ACS_LANTERN", "ACS_BLOCK"
#ifdef ACS_S3
        , "ACS_S3", "ACS_S7", "ACS_LEQUAL", "ACS_GEQUAL",
        "ACS_PI", "ACS_NEQUAL", "ACS_STERLING"
#endif
    };

    chtype acs_values[ACSNUM];

#if HAVE_WIDE
    cchar_t *wacs_values[] =
    {
        WACS_ULCORNER, WACS_URCORNER, WACS_LLCORNER, WACS_LRCORNER,
        WACS_LTEE, WACS_RTEE, WACS_TTEE, WACS_BTEE, WACS_HLINE,
        WACS_VLINE, WACS_PLUS,

        WACS_S1, WACS_S9, WACS_DIAMOND, WACS_CKBOARD, WACS_DEGREE,
        WACS_PLMINUS, WACS_BULLET,

        WACS_LARROW, WACS_RARROW, WACS_UARROW, WACS_DARROW, WACS_BOARD,
        WACS_LANTERN, WACS_BLOCK
# ifdef WACS_S3
        , WACS_S3, WACS_S7, WACS_LEQUAL, WACS_GEQUAL, WACS_PI,
        WACS_NEQUAL, WACS_STERLING
# endif
    };

    static const wchar_t russian[] = {0x0420, 0x0443, 0x0441, 0x0441,
                                      0x043a, 0x0438, 0x0439, L' ', 0x044f, 0x0437, 0x044b, 0x043a, 0
                                     };

    static const wchar_t greek[] = {0x0395, 0x03bb, 0x03bb, 0x03b7,
                                    0x03bd, 0x03b9, 0x03ba, 0x03ac, 0
                                   };

    static const wchar_t georgian[] = {0x10e5, 0x10d0, 0x10e0, 0x10d7,
                                       0x10e3, 0x10da, 0x10d8, L' ', 0x10d4, 0x10dc, 0x10d0, 0
                                      };
#endif

    int i, tmarg = (LINES - 22) / 2;

    attrset(A_BOLD);
    mvaddstr(tmarg, (COLS - 23) / 2, "Alternate Character Set");
    attrset(A_NORMAL);

    tmarg += 3;

#define A(b,c) acs_values[b] = ACS_##c

    A(0,ULCORNER);
    A(1,URCORNER);
    A(2,LLCORNER);
    A(3,LRCORNER);
    A(4,LTEE);
    A(5,RTEE);
    A(6,TTEE);
    A(7,BTEE);
    A(8,HLINE);
    A(9,VLINE);
    A(10,PLUS);
    A(11,S1);
    A(12,S9);
    A(13,DIAMOND);
    A(14,CKBOARD);
    A(15,DEGREE);

    A(16,PLMINUS);
    A(17,BULLET);
    A(18,LARROW);
    A(19,RARROW);
    A(20,UARROW);
    A(21,DARROW);
    A(22,BOARD);
    A(23,LANTERN);
    A(24,BLOCK);
#ifdef ACS_S3
    A(25,S3);
    A(26,S7);
    A(27,LEQUAL);
    A(28,GEQUAL);
    A(29,PI);
    A(30,NEQUAL);
    A(31,STERLING);
#endif

#undef A

    for (i = 0; i < ACSNUM; i++)
    {
        move((i % 8) * 2 + tmarg, (i / 8) * (COLS / 4) + (COLS / 8 - 7));
        addch(acs_values[i]);
        printw(" %s", acs_names[i]);
    }

    mvaddstr(tmarg + 18, 3, "Press any key to continue");
    getch();

#if HAVE_WIDE
    clear();

    attrset(A_BOLD);
    mvaddstr(tmarg - 3, (COLS - 28) / 2, "Wide Alternate Character Set");
    attrset(A_NORMAL);

    for (i = 0; i < ACSNUM; i++)
    {
        move((i % 8) * 2 + tmarg, (i / 8) * (COLS / 4) + (COLS / 8 - 7));
        add_wch(wacs_values[i]);
        printw(" W%s", acs_names[i]);
    }

    /* Spanish, Russian, Greek, Georgian */

    mvaddwstr(tmarg + 16, COLS / 8 - 5, L"Espa\xf1ol");
    mvaddwstr(tmarg + 16, 3 * (COLS / 8) - 5, russian);
    mvaddwstr(tmarg + 16, 5 * (COLS / 8) - 5, greek);
    mvaddwstr(tmarg + 16, 7 * (COLS / 8) - 5, georgian);

    mvaddstr(tmarg + 18, 3, "Press any key to continue");
    getch();
#endif
}
Exemple #10
0
static void print_enriched_string (int attr, unsigned char *s, int do_color)
{
  wchar_t wc;
  size_t k;
  size_t n = mutt_strlen ((char *)s);
  mbstate_t mbstate;

  memset (&mbstate, 0, sizeof (mbstate));
  while (*s)
  {
    if (*s < M_TREE_MAX)
    {
      if (do_color)
	SETCOLOR (MT_COLOR_TREE);
      while (*s && *s < M_TREE_MAX)
      {
	switch (*s)
	{
	  case M_TREE_LLCORNER:
	    if (option (OPTASCIICHARS))
	      addch ('`');
#ifdef WACS_LLCORNER
	    else
	      add_wch(WACS_LLCORNER);
#else
	    else if (Charset_is_utf8)
	      addstr ("\342\224\224"); /* WACS_LLCORNER */
	    else
	      addch (ACS_LLCORNER);
#endif
	    break;
	  case M_TREE_ULCORNER:
	    if (option (OPTASCIICHARS))
	      addch (',');
#ifdef WACS_ULCORNER
	    else
	      add_wch(WACS_ULCORNER);
#else
	    else if (Charset_is_utf8)
	      addstr ("\342\224\214"); /* WACS_ULCORNER */
	    else
	      addch (ACS_ULCORNER);
#endif
	    break;
	  case M_TREE_LTEE:
	    if (option (OPTASCIICHARS))
	      addch ('|');
#ifdef WACS_LTEE
	    else
	      add_wch(WACS_LTEE);
#else
	    else if (Charset_is_utf8)
	      addstr ("\342\224\234"); /* WACS_LTEE */
	    else
	      addch (ACS_LTEE);
#endif
	    break;
	  case M_TREE_HLINE:
	    if (option (OPTASCIICHARS))
	      addch ('-');
#ifdef WACS_HLINE
	    else
	      add_wch(WACS_HLINE);
#else
	    else if (Charset_is_utf8)
	      addstr ("\342\224\200"); /* WACS_HLINE */
	    else
	      addch (ACS_HLINE);
#endif
	    break;
	  case M_TREE_VLINE:
	    if (option (OPTASCIICHARS))
	      addch ('|');
#ifdef WACS_VLINE
	    else
	      add_wch(WACS_VLINE);
#else
	    else if (Charset_is_utf8)