/****************************************************************************
- * Copyright (c) 2007-2011,2015 Free Software Foundation, Inc. *
+ * Copyright (c) 2007-2015,2017 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: savescreen.c,v 1.27 2015/03/28 23:21:28 tom Exp $
+ * $Id: savescreen.c,v 1.32 2017/04/15 17:33:50 tom Exp $
*
* Demonstrate save/restore functions from the curses library.
* Thomas Dickey - 2007/7/14
*/
#include <test.priv.h>
+#include <popup_msg.h>
#if HAVE_SCR_DUMP
# endif
#endif
+#if defined(__hpux)
+#define MyMarker 'X'
+#else
+#define MyMarker ACS_DIAMOND
+#endif
+
static bool use_init = FALSE;
static bool keep_dumps = FALSE;
+#if USE_WIDEC_SUPPORT
+/* In HPUX curses, cchar_t is opaque; other implementations are not */
+static wchar_t
+BaseChar(cchar_t data)
+{
+ wchar_t my_wchar[sizeof(cchar_t)];
+ attr_t my_attr;
+ short my_pair;
+ getcchar(&data, my_wchar, &my_attr, &my_pair, NULL);
+ return my_wchar[0];
+}
+#endif
+
static int
fexists(const char *name)
{
return ch;
}
-static void
-show_help(const char **help)
-{
- WINDOW *mywin = newwin(LINES, COLS, 0, 0);
- int n;
-
- box(mywin, 0, 0);
- wmove(mywin, 1, 1);
- for (n = 0; help[n] != 0; ++n) {
- wmove(mywin, 1 + n, 2);
- wprintw(mywin, "%.*s", COLS - 4, help[n]);
- }
- wgetch(mywin);
- delwin(mywin);
- touchwin(stdscr);
- refresh();
-}
-
static void
editor_help(void)
{
" a toggle between '#' and graphic symbol for drawing",
" c change color drawn by line to next in palette",
" h,j,k,l or arrows to move around the screen, drawing",
+ 0
};
- show_help(msgs);
+ popup_msg(stdscr, msgs);
}
static void
" q quit",
" <space> load the next screen",
" <backspace> load the previous screen",
+ 0
};
- show_help(msgs);
+ popup_msg(stdscr, msgs);
}
static void
if (++which > last)
which = 0;
break;
- case '?':
+ case HELP_KEY_1:
replay_help();
break;
default:
wmove(stdscr, cy, cx);
#if USE_WIDEC_SUPPORT
if (win_wch(curscr, &mycc) != ERR) {
- myxx = wcwidth(mycc.chars[0]);
+ myxx = wcwidth(BaseChar(mycc));
if (myxx > 0) {
wadd_wchnstr(stdscr, &mycc, 1);
cx += (myxx - 1);
case 'c':
color = (color + 1) % COLORS;
break;
- case '?':
+ case HELP_KEY_1:
editor_help();
break;
default:
continue;
}
if (!done) {
- attr_t attr = (A_REVERSE | COLOR_PAIR(color * COLORS));
- chtype ch2 = (altchars ? ACS_DIAMOND : '#');
+ attr_t attr = (A_REVERSE | (attr_t) COLOR_PAIR(color * COLORS));
+ chtype ch2 = (altchars ? MyMarker : '#');
move(y, x);
- addch(ch2 | attr);
+ AddCh(ch2 | attr);
move(y, x);
}
}