/****************************************************************************
- * Copyright (c) 2009 Free Software Foundation, Inc. *
+ * Copyright (c) 2009-2014,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* authorization. *
****************************************************************************/
/*
- * $Id: test_addwstr.c,v 1.2 2009/09/12 22:55:23 tom Exp $
+ * $Id: test_addwstr.c,v 1.13 2016/09/10 21:27:59 tom Exp $
*
* Demonstrate the waddwstr() and wadd_wch functions.
* Thomas Dickey - 2009/9/12
#define WIDE_LINEDATA
#include <linedata.h>
+#undef MvAddCh
+#undef MvAddStr
+#undef MvWAddCh
+#undef MvWAddStr
+
/* definitions to make it simpler to compare with inserts.c */
#define AddNStr addnwstr
#define AddStr addwstr
-#define MvAddNStr mvaddnwstr
-#define MvAddStr mvaddwstr
-#define MvWAddNStr mvwaddnwstr
-#define MvWAddStr mvwaddwstr
+#define MvAddNStr (void) mvaddnwstr
+#define MvAddStr (void) mvaddwstr
+#define MvWAddNStr (void) mvwaddnwstr
+#define MvWAddStr (void) mvwaddwstr
#define WAddNStr waddnwstr
#define WAddStr waddwstr
static void
legend(WINDOW *win, int level, Options state, wchar_t *buffer, int length)
{
- NCURSES_CONST char *showstate;
+ const char *showstate;
switch (state) {
default:
wprintw(win,
"The Strings/Chars displays should match. Enter any characters, except:\n");
wprintw(win,
- "down-arrow or ^N to repeat on next line, 'w' for inner window, 'q' to exit.\n");
+ "down-arrow or ^N to repeat on next line, ^W for inner window, ESC to exit.\n");
wclrtoeol(win);
wprintw(win, "Level %d,%s inserted %d characters <", level,
showstate, length);
result += 2;
break;
default:
- result += wcwidth(ch);
+ result += wcwidth((wchar_t) ch);
if (ch < 32)
++result;
break;
{
wchar_t tmp_wchar[2];
- tmp_wchar[0] = source;
+ tmp_wchar[0] = (wchar_t) source;
tmp_wchar[1] = 0;
if (setcchar(target, tmp_wchar, A_NORMAL, 0, (void *) 0) == ERR) {
beep();
WINDOW *work = 0;
WINDOW *show = 0;
int margin = (2 * MY_TABSIZE) - 1;
- Options option = ((m_opt ? oMove : oDefault)
- | ((w_opt || (level > 0)) ? oWindow : oDefault));
+ Options option = (Options) ((int) (m_opt ? oMove : oDefault)
+ | (int) ((w_opt || (level > 0))
+ ? oWindow : oDefault));
if (first) {
static char cmd[80];
setlocale(LC_ALL, "");
- putenv(strcpy(cmd, "TABSIZE=8"));
+ _nc_STRCPY(cmd, "TABSIZE=8", sizeof(cmd));
+ putenv(cmd);
initscr();
(void) cbreak(); /* take input chars one at a time, no wait for \n */
(void) noecho(); /* don't echo input */
keypad(stdscr, TRUE);
+
+ /*
+ * Show the characters inserted in color, to distinguish from those that
+ * are shifted.
+ */
+ if (has_colors()) {
+ start_color();
+ init_pair(1, COLOR_WHITE, COLOR_BLUE);
+ }
}
limit = LINES - 5;
keypad(work, TRUE);
for (col = margin + 1; col < COLS; col += MY_TABSIZE)
- mvwvline(work, row, col, '.', limit - 2);
+ MvWVLine(work, row, col, '.', limit - 2);
- mvwvline(work, row, margin, ACS_VLINE, limit - 2);
- mvwvline(work, row, margin + 1, ACS_VLINE, limit - 2);
+ MvWVLine(work, row, margin, ACS_VLINE, limit - 2);
+ MvWVLine(work, row, margin + 1, ACS_VLINE, limit - 2);
limit /= 2;
- mvwaddstr(work, 1, 2, "String");
- mvwaddstr(work, limit + 1, 2, "Chars");
+ (void) mvwaddstr(work, 1, 2, "String");
+ (void) mvwaddstr(work, limit + 1, 2, "Chars");
wnoutrefresh(work);
buffer[length = 0] = '\0';
doupdate();
- /*
- * Show the characters inserted in color, to distinguish from those that
- * are shifted.
- */
if (has_colors()) {
- start_color();
- init_pair(1, COLOR_WHITE, COLOR_BLUE);
- wbkgdset(work, COLOR_PAIR(1) | ' ');
+ wbkgdset(work, (chtype) (COLOR_PAIR(1) | ' '));
}
while ((ch = read_linedata(work)) != ERR && !isQUIT(ch)) {
case key_RECUR:
test_inserts(level + 1);
- touchwin(look);
+ if (look)
+ touchwin(look);
touchwin(work);
touchwin(show);
- wnoutrefresh(look);
+ if (look)
+ wnoutrefresh(look);
wnoutrefresh(work);
wnoutrefresh(show);
ch = '\b';
/* FALLTHRU */
default:
- buffer[length++] = ch;
+ buffer[length++] = (wchar_t) ch;
buffer[length] = '\0';
/* put the string in, one character at a time */
switch (option) {
case oDefault:
if (move(limit + row, col) != ERR) {
- AddCh(ch);
+ AddCh((chtype) ch);
}
break;
case oMove:
- MvAddCh(limit + row, col, ch);
+ MvAddCh(limit + row, col, (chtype) ch);
break;
case oWindow:
if (wmove(work, limit + row, col) != ERR) {
- WAddCh(work, ch);
+ WAddCh(work, (chtype) ch);
}
break;
case oMoveWindow:
- MvWAddCh(work, limit + row, col, ch);
+ MvWAddCh(work, limit + row, col, (chtype) ch);
break;
}
break;
}
}
+ delwin(show);
if (level > 0) {
- delwin(show);
delwin(work);
delwin(look);
}