From eb065a756e9fd75ce543ba9c7034f46cb31bc426 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 17 Nov 2017 18:23:23 -0600 Subject: [PATCH] apps/examples/pdcurses: Bring pdcurses demos and make them conform to the NuttX coding style (not yet hooked into the build system). --- examples/pdcurses/README | 21 + examples/pdcurses/firework_main.c | 214 ++++ examples/pdcurses/newdemo_main.c | 516 ++++++++ examples/pdcurses/panel_main.c | 358 ++++++ examples/pdcurses/rain_main.c | 185 +++ examples/pdcurses/testcurs_main.c | 1295 +++++++++++++++++++++ examples/pdcurses/tui.c | 895 ++++++++++++++ examples/pdcurses/tui.h | 116 ++ examples/pdcurses/tui_main.c | 288 +++++ examples/pdcurses/worm_main.c | 929 +++++++++++++++ examples/pdcurses/xmas_main.c | 1083 +++++++++++++++++ graphics/pdcurs34/pdcurses/pdc_addch.c | 20 +- graphics/pdcurs34/pdcurses/pdc_addchstr.c | 16 +- graphics/pdcurs34/pdcurses/pdc_addstr.c | 16 +- graphics/pdcurs34/pdcurses/pdc_attr.c | 4 +- graphics/pdcurs34/pdcurses/pdc_bkgd.c | 18 +- graphics/pdcurs34/pdcurses/pdc_border.c | 44 +- graphics/pdcurs34/pdcurses/pdc_clear.c | 8 +- graphics/pdcurs34/pdcurses/pdc_delch.c | 4 +- graphics/pdcurs34/pdcurses/pdc_deleteln.c | 10 +- graphics/pdcurs34/pdcurses/pdc_getch.c | 14 +- graphics/pdcurs34/pdcurses/pdc_getstr.c | 24 +- graphics/pdcurs34/pdcurses/pdc_getyx.c | 16 +- graphics/pdcurs34/pdcurses/pdc_inch.c | 12 +- graphics/pdcurs34/pdcurses/pdc_inchstr.c | 32 +- graphics/pdcurs34/pdcurses/pdc_initscr.c | 2 +- graphics/pdcurs34/pdcurses/pdc_inopts.c | 12 +- graphics/pdcurs34/pdcurses/pdc_insch.c | 16 +- graphics/pdcurs34/pdcurses/pdc_insstr.c | 16 +- graphics/pdcurs34/pdcurses/pdc_instr.c | 16 +- graphics/pdcurs34/pdcurses/pdc_mouse.c | 6 +- graphics/pdcurs34/pdcurses/pdc_move.c | 2 +- graphics/pdcurs34/pdcurses/pdc_outopts.c | 14 +- graphics/pdcurs34/pdcurses/pdc_overlay.c | 8 +- graphics/pdcurs34/pdcurses/pdc_pad.c | 10 +- graphics/pdcurs34/pdcurses/pdc_panel.c | 4 +- graphics/pdcurs34/pdcurses/pdc_printw.c | 8 +- graphics/pdcurs34/pdcurses/pdc_scanw.c | 8 +- graphics/pdcurs34/pdcurses/pdc_scrdump.c | 2 +- graphics/pdcurs34/pdcurses/pdc_scroll.c | 4 +- graphics/pdcurs34/pdcurses/pdc_slk.c | 2 +- graphics/pdcurs34/pdcurses/pdc_termattr.c | 4 +- graphics/pdcurs34/pdcurses/pdc_touch.c | 12 +- graphics/pdcurs34/pdcurses/pdc_util.c | 12 +- graphics/pdcurs34/pdcurses/pdc_window.c | 6 +- 45 files changed, 6101 insertions(+), 201 deletions(-) create mode 100644 examples/pdcurses/README create mode 100644 examples/pdcurses/firework_main.c create mode 100644 examples/pdcurses/newdemo_main.c create mode 100644 examples/pdcurses/panel_main.c create mode 100644 examples/pdcurses/rain_main.c create mode 100644 examples/pdcurses/testcurs_main.c create mode 100644 examples/pdcurses/tui.c create mode 100644 examples/pdcurses/tui.h create mode 100644 examples/pdcurses/tui_main.c create mode 100644 examples/pdcurses/worm_main.c create mode 100644 examples/pdcurses/xmas_main.c diff --git a/examples/pdcurses/README b/examples/pdcurses/README new file mode 100644 index 000000000..b7dd0e4c6 --- /dev/null +++ b/examples/pdcurses/README @@ -0,0 +1,21 @@ +PDCurses Demos +============== + +This directory contains demonstration programs to show and test the +capabilities of pdcurses libraries. Some of them predate PDCurses, +PCcurses or even pcurses/ncurses. Although some PDCurses-specific code +has been added, all programs remain portable to other implementations +(at a minimum, to ncurses). + +Building +-------- + +The demos are built by the platform-specific makefiles, in the platform +directories. There are no dependencies besides curses and the standard +C library, and no configuration is needed. + +Distribution Status +------------------- + +Public Domain, except for rain_main.c and worm_main.c, which are under +the ncurses license (MIT-like). diff --git a/examples/pdcurses/firework_main.c b/examples/pdcurses/firework_main.c new file mode 100644 index 000000000..b2a4adeef --- /dev/null +++ b/examples/pdcurses/firework_main.c @@ -0,0 +1,214 @@ +/**************************************************************************** + * apps/examples/pdcurses/firework_main.c + * $Id: firework.c,v 1.25 2008/07/13 16:08:17 wmcbrine Exp $ + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Adapted by: Gregory Nutt + * + * Adapted from the original public domain pdcurses by Gregory Nutt and + * released as part of NuttX under the 3-clause BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "graphics/curses.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define DELAYSIZE 200 + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static void myrefresh(void); +static void get_color(void); +static void explode(int, int); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static short color_table[] = +{ + COLOR_RED, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, + COLOR_RED, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static void myrefresh(void) +{ + napms(DELAYSIZE); + move(LINES - 1, COLS - 1); + refresh(); +} + +static void get_color(void) +{ + chtype bold = (rand() % 2) ? A_BOLD : A_NORMAL; + attrset(COLOR_PAIR(rand() % 8) | bold); +} + +static void explode(int row, int col) +{ + erase(); + mvaddstr(row, col, "-"); + myrefresh(); + + --col; + + get_color(); + mvaddstr(row - 1, col, " - "); + mvaddstr(row, col, "-+-"); + mvaddstr(row + 1, col, " - "); + myrefresh(); + + --col; + + get_color(); + mvaddstr(row - 2, col, " --- "); + mvaddstr(row - 1, col, "-+++-"); + mvaddstr(row, col, "-+#+-"); + mvaddstr(row + 1, col, "-+++-"); + mvaddstr(row + 2, col, " --- "); + myrefresh(); + + get_color(); + mvaddstr(row - 2, col, " +++ "); + mvaddstr(row - 1, col, "++#++"); + mvaddstr(row, col, "+# #+"); + mvaddstr(row + 1, col, "++#++"); + mvaddstr(row + 2, col, " +++ "); + myrefresh(); + + get_color(); + mvaddstr(row - 2, col, " # "); + mvaddstr(row - 1, col, "## ##"); + mvaddstr(row, col, "# #"); + mvaddstr(row + 1, col, "## ##"); + mvaddstr(row + 2, col, " # "); + myrefresh(); + + get_color(); + mvaddstr(row - 2, col, " # # "); + mvaddstr(row - 1, col, "# #"); + mvaddstr(row, col, " "); + mvaddstr(row + 1, col, "# #"); + mvaddstr(row + 2, col, " # # "); + myrefresh(); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int firework_main(int argc, char *argv[]) +#endif +{ + int i, start, end, row, diff, flag, direction, seed; + + initscr(); + nodelay(stdscr, true); + noecho(); + + if (has_colors()) + { + start_color(); + } + + for (i = 0; i < 8; i++) + { + init_pair(i, color_table[i], COLOR_BLACK); + } + + seed = time((time_t *) 0); + srand(seed); + flag = 0; + + while (getch() == ERR) /* loop until a key is hit */ + { + do + { + start = rand() % (COLS - 3); + end = rand() % (COLS - 3); + start = (start < 2) ? 2 : start; + end = (end < 2) ? 2 : end; + direction = (start > end) ? -1 : 1; + diff = abs(start - end); + } + while (diff < 2 || diff >= LINES - 2); + + attrset(A_NORMAL); + + for (row = 0; row < diff; row++) + { + mvaddstr(LINES - row, row * direction + start, + (direction < 0) ? "\\" : "/"); + + if (flag++) + { + myrefresh(); + erase(); + flag = 0; + } + } + + if (flag++) + { + myrefresh(); + flag = 0; + } + + explode(LINES - row, diff * direction + start); + erase(); + myrefresh(); + } + + endwin(); + return 0; +} diff --git a/examples/pdcurses/newdemo_main.c b/examples/pdcurses/newdemo_main.c new file mode 100644 index 000000000..0e58fa6d5 --- /dev/null +++ b/examples/pdcurses/newdemo_main.c @@ -0,0 +1,516 @@ +/**************************************************************************** + * apps/examples/pdcurses/newdemo_main.c + * A demo program using PDCurses. The program illustrates the use of colors + * for text output. + * Hacks by jbuhler@cs.washington.edu on 12/29/96 + * $Id: newdemo.c,v 1.39 2008/07/13 16:08:17 wmcbrine Exp $ + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Adapted by: Gregory Nutt + * + * Adapted from the original public domain pdcurses by Gregory Nutt and + * released as part of NuttX under the 3-clause BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include + +#include "graphics/curses.h" + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static int wait_for_user(void); +static int subwin_test(WINDOW *); +static int bouncing_balls(WINDOW *); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* An ASCII map of Australia */ + +static char *AusMap[17] = +{ + " A ", + " AA AA ", + " N.T. AAAAA AAAA ", + " AAAAAAAAAAA AAAAAAAA ", + " AAAAAAAAAAAAAAAAAAAAAAAAA Qld.", + " AAAAAAAAAAAAAAAAAAAAAAAAAAAA ", + " AAAAAAAAAAAAAAAAAAAAAAAAAAAAA ", + " AAAAAAAAAAAAAAAAAAAAAAAAAAAA ", + " AAAAAAAAAAAAAAAAAAAAAAAAA N.S.W.", + "W.A. AAAAAAAAA AAAAAA Vic.", + " AAA S.A. AA", + " A Tas.", + "" +}; + +/* Funny messages for the scroller */ + +static char *messages[] = +{ + "Hello from the Land Down Under", + "The Land of crocs, and a big Red Rock", + "Where the sunflower runs along the highways", + "The dusty red roads lead one to loneliness", + "Blue sky in the morning and", + "Freezing nights and twinkling stars", + NULL +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static int wait_for_user(void) +{ + chtype ch; + + nodelay(stdscr, true); + halfdelay(50); + + ch = getch(); + + nodelay(stdscr, false); + nocbreak(); /* Reset the halfdelay() value */ + cbreak(); + + return (ch == '\033') ? ch : 0; +} + +static int subwin_test(WIDNOW *win) +{ + WINDOW *swin1; + WINDOW *swin2; + WINDOW *swin3; + int w; + int h; + int sw; + int sh; + int bx; + int by; + + wattrset(win, 0); + getmaxyx(win, h, w); + getbegyx(win, by, bx); + + sw = w / 3; + sh = h / 3; + + if ((swin1 = derwin(win, sh, sw, 3, 5)) == NULL) + { + return 1; + } + + if ((swin2 = subwin(win, sh, sw, by + 4, bx + 8)) == NULL) + { + return 1; + } + + if ((swin3 = subwin(win, sh, sw, by + 5, bx + 11)) == NULL) + { + return 1; + } + + init_pair(8, COLOR_RED, COLOR_BLUE); + wbkgd(swin1, COLOR_PAIR(8)); + werase(swin1); + mvwaddstr(swin1, 0, 3, "Sub-window 1"); + wrefresh(swin1); + + init_pair(9, COLOR_CYAN, COLOR_MAGENTA); + wbkgd(swin2, COLOR_PAIR(9)); + werase(swin2); + mvwaddstr(swin2, 0, 3, "Sub-window 2"); + wrefresh(swin2); + + init_pair(10, COLOR_YELLOW, COLOR_GREEN); + wbkgd(swin3, COLOR_PAIR(10)); + werase(swin3); + mvwaddstr(swin3, 0, 3, "Sub-window 3"); + wrefresh(swin3); + + delwin(swin1); + delwin(swin2); + delwin(swin3); + wait_for_user(); + + return 0; +} + +static int bouncing_balls(WIDNOW *win) +{ + chtype c1; + chtype c2; + chtype c3; + chtype ball1; + chtype ball2; + chtype ball3; + int w; + int h; + int x1; + int y1; + int xd1; + int yd1; + int x2; + int y2; + int xd2; + int yd2; + int x3; + int y3; + int xd3; + int yd3; + int c; + + curs_set(0); + + wbkgd(win, COLOR_PAIR(1)); + wrefresh(win); + wattrset(win, 0); + + init_pair(11, COLOR_RED, COLOR_GREEN); + init_pair(12, COLOR_BLUE, COLOR_RED); + init_pair(13, COLOR_YELLOW, COLOR_WHITE); + + ball1 = 'O' | COLOR_PAIR(11); + ball2 = '*' | COLOR_PAIR(12); + ball3 = '@' | COLOR_PAIR(13); + + getmaxyx(win, h, w); + + x1 = 2 + rand() % (w - 4); + y1 = 2 + rand() % (h - 4); + x2 = 2 + rand() % (w - 4); + y2 = 2 + rand() % (h - 4); + x3 = 2 + rand() % (w - 4); + y3 = 2 + rand() % (h - 4); + + xd1 = 1; + yd1 = 1; + xd2 = 1; + yd2 = -1; + xd3 = -1; + yd3 = 1; + + nodelay(stdscr, true); + + while ((c = getch()) == ERR) + { + x1 += xd1; + if (x1 <= 1 || x1 >= w - 2) + { + xd1 *= -1; + } + + y1 += yd1; + if (y1 <= 1 || y1 >= h - 2) + { + yd1 *= -1; + } + + x2 += xd2; + if (x2 <= 1 || x2 >= w - 2) + { + xd2 *= -1; + } + + y2 += yd2; + if (y2 <= 1 || y2 >= h - 2) + { + yd2 *= -1; + } + + x3 += xd3; + if (x3 <= 1 || x3 >= w - 2) + { + xd3 *= -1; + } + + y3 += yd3; + if (y3 <= 1 || y3 >= h - 2) + { + yd3 *= -1; + } + + c1 = mvwinch(win, y1, x1); + c2 = mvwinch(win, y2, x2); + c3 = mvwinch(win, y3, x3); + + mvwaddch(win, y1, x1, ball1); + mvwaddch(win, y2, x2, ball2); + mvwaddch(win, y3, x3, ball3); + + wmove(win, 0, 0); + wrefresh(win); + + mvwaddch(win, y1, x1, c1); + mvwaddch(win, y2, x2, c2); + mvwaddch(win, y3, x3, c3); + + napms(150); + } + + nodelay(stdscr, false); + ungetch(c); + return 0; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int newdemo_main(int argc, char *argv[]) +#endif +{ + WINDOW *win; + chtype save[80], ch; + int width, height, w, x, y, i, j, seed; + + initscr(); + seed = time((time_t *) 0); + srand(seed); + + start_color(); +#if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000) + use_default_colors(); +#endif + cbreak(); + noecho(); + + curs_set(0); + noecho(); + + /* Refresh stdscr so that reading from it will not cause it to overwrite the + * other windows that are being created. + */ + + refresh(); + + /* Create a drawing window */ + + width = 48; + height = 15; + + win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2); + + if (win == NULL) + { + endwin(); + return 1; + } + + for (;;) + { + init_pair(1, COLOR_WHITE, COLOR_BLUE); + wbkgd(win, COLOR_PAIR(1)); + werase(win); + + init_pair(2, COLOR_RED, COLOR_RED); + wattrset(win, COLOR_PAIR(2)); + box(win, ' ', ' '); + wrefresh(win); + + wattrset(win, 0); + + /* Do random output of a character */ + + ch = 'a'; + + nodelay(stdscr, true); + + for (i = 0; i < 5000; ++i) + { + x = rand() % (width - 2) + 1; + y = rand() % (height - 2) + 1; + + mvwaddch(win, y, x, ch); + wrefresh(win); + + if (getch() != ERR) + { + break; + } + + if (i == 2000) + { + ch = 'b'; + init_pair(3, COLOR_CYAN, COLOR_YELLOW); + wattrset(win, COLOR_PAIR(3)); + } + } + + nodelay(stdscr, false); + + subwin_test(win); + + /* Erase and draw green window */ + + init_pair(4, COLOR_YELLOW, COLOR_GREEN); + wbkgd(win, COLOR_PAIR(4)); + wattrset(win, A_BOLD); + werase(win); + wrefresh(win); + + /* Draw RED bounding box */ + + wattrset(win, COLOR_PAIR(2)); + box(win, ' ', ' '); + wrefresh(win); + + /* Display Australia map */ + + wattrset(win, A_BOLD); + i = 0; + + while (*AusMap[i]) + { + mvwaddstr(win, i + 1, 8, AusMap[i]); + wrefresh(win); + napms(100); + ++i; + } + + init_pair(5, COLOR_BLUE, COLOR_WHITE); + wattrset(win, COLOR_PAIR(5) | A_BLINK); + mvwaddstr(win, height - 2, 3, + " PDCurses 3.4 - DOS, OS/2, Win32, X11, SDL"); + wrefresh(win); + + /* Draw running messages */ + + init_pair(6, COLOR_BLACK, COLOR_WHITE); + wattrset(win, COLOR_PAIR(6)); + w = width - 2; + nodelay(win, true); + + /* jbuhler's re-hacked scrolling messages */ + + for (j = 0; messages[j] != NULL; j++) + { + char *message = messages[j]; + int msg_len = strlen(message); + int scroll_len = w + 2 * msg_len; + char *scrollbuf = malloc(scroll_len); + char *visbuf = scrollbuf + msg_len; + int stop = 0; + int i; + + for (i = w + msg_len; i > 0; i--) + { + memset(visbuf, ' ', w); + strncpy(scrollbuf + i, message, msg_len); + mvwaddnstr(win, height / 2, 1, visbuf, w); + wrefresh(win); + + if (wgetch(win) != ERR) + { + flushinp(); + stop = 1; + break; + } + + napms(100); + } + + free(scrollbuf); + + if (stop) + { + break; + } + } + + j = 0; + + /* Draw running 'A's across in RED */ + + init_pair(7, COLOR_RED, COLOR_GREEN); + wattron(win, COLOR_PAIR(7)); + + for (i = 2; i < width - 4; ++i) + { + ch = mvwinch(win, 5, i); + save[j++] = ch; + ch = ch & 0x7f; + mvwaddch(win, 5, i, ch); + } + + wrefresh(win); + + /* Put a message up; wait for a key */ + + i = height - 2; + wattrset(win, COLOR_PAIR(5)); + mvwaddstr(win, i, 3, " Type a key to continue or ESC to quit "); + wrefresh(win); + + if (wait_for_user() == '\033') + { + break; + } + + /* Restore the old line */ + + wattrset(win, 0); + + for (i = 2, j = 0; i < width - 4; ++i) + { + mvwaddch(win, 5, i, save[j++]); + } + + wrefresh(win); + + bouncing_balls(win); + + /* bouncing_balls() leaves a keystroke in the queue */ + + if (wait_for_user() == '\033') + { + break; + } + } + + endwin(); + return 0; +} diff --git a/examples/pdcurses/panel_main.c b/examples/pdcurses/panel_main.c new file mode 100644 index 000000000..2bcfa287e --- /dev/null +++ b/examples/pdcurses/panel_main.c @@ -0,0 +1,358 @@ +/**************************************************************************** + * apps/examples/pdcurses/panel_main.c + * $Id: ptest.c,v 1.24 2008/07/13 16:08:17 wmcbrine Exp $ + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Adapted by: Gregory Nutt + * + * Adapted from the original public domain pdcurses by Gregory Nutt and + * released as part of NuttX under the 3-clause BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include "graphics/curses.h" +#include "graphics/panel.h" + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static PANEL *p1; +static PANEL *p2; +static PANEL *p3; +static PANEL *p4; +static PANEL *p5; +static WINDOW *w4; +static WINDOW *w5; + +static long nap_msec = 1; + +static char *mod[] = +{ + "test ", "TEST ", "(**) ", "*()* ", "<--> ", "LAST " +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static void pflush(void) +{ + update_panels(); + doupdate(); +} + +static void backfill(void) +{ + int x; + int y; + + erase(); + + for (y = 0; y < LINES - 1; y++) + { + for (x = 0; x < COLS; x++) + { + printw("%d", (y + x) % 10); + } + } +} + +static void wait_a_while(long msec) +{ + int c; + + if (msec != 1) + { + timeout(msec); + } + + c = getch(); + if (c == 'q') + { + endwin(); + exit(1); + } +} + +static void saywhat(const char *text) +{ + mvprintw(LINES - 1, 0, "%-20.20s", text); +} + +/* mkpanel - alloc a win and panel and associate them */ + +static PANEL *mkpanel(int rows, int cols, int tly, int tlx) +{ + WINDOW *win = newwin(rows, cols, tly, tlx); + PANEL *pan = (PANEL *) 0; + + if (win) + { + pan = new_panel(win); + + if (!pan) + { + delwin(win); + } + } + + return pan; +} + +static void rmpanel(PANEL *pan) +{ + WINDOW *win = pan->win; + + del_panel(pan); + delwin(win); +} + +static void fill_panel(PANEL *pan) +{ + WINDOW *win = pan->win; + char num = *((char *)pan->user + 1); + int x; + int y; + int maxx; + int maxy; + + box(win, 0, 0); + mvwprintw(win, 1, 1, "-pan%c-", num); + getmaxyx(win, maxy, maxx); + + for (y = 2; y < maxy - 1; y++) + { + for (x = 1; x < maxx - 1; x++) + { + mvwaddch(win, y, x, num); + } + } +} + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int panel_main(int argc, char *argv[]) +#endif +{ + int itmp, y; + + if (argc > 1 && atol(argv[1])) + { + nap_msec = atol(argv[1]); + } + + initscr(); + backfill(); + + for (y = 0; y < 5; y++) + { + p1 = mkpanel(10, 10, 0, 0); + set_panel_userptr(p1, "p1"); + + p2 = mkpanel(14, 14, 5, 5); + set_panel_userptr(p2, "p2"); + + p3 = mkpanel(6, 8, 12, 12); + set_panel_userptr(p3, "p3"); + + p4 = mkpanel(10, 10, 10, 30); + w4 = panel_window(p4); + set_panel_userptr(p4, "p4"); + + p5 = mkpanel(10, 10, 13, 37); + w5 = panel_window(p5); + set_panel_userptr(p5, "p5"); + + fill_panel(p1); + fill_panel(p2); + fill_panel(p3); + fill_panel(p4); + fill_panel(p5); + hide_panel(p4); + hide_panel(p5); + pflush(); + wait_a_while(nap_msec); + + saywhat("h3 s1 s2 s4 s5;"); + move_panel(p1, 0, 0); + hide_panel(p3); + show_panel(p1); + show_panel(p2); + show_panel(p4); + show_panel(p5); + pflush(); + wait_a_while(nap_msec); + + saywhat("s1;"); + show_panel(p1); + pflush(); + wait_a_while(nap_msec); + + saywhat("s2;"); + show_panel(p2); + pflush(); + wait_a_while(nap_msec); + + saywhat("m2;"); + move_panel(p2, 10, 10); + pflush(); + wait_a_while(nap_msec); + + saywhat("s3;"); + show_panel(p3); + pflush(); + wait_a_while(nap_msec); + + saywhat("m3;"); + move_panel(p3, 5, 5); + pflush(); + wait_a_while(nap_msec); + + saywhat("b3;"); + bottom_panel(p3); + pflush(); + wait_a_while(nap_msec); + + saywhat("s4;"); + show_panel(p4); + pflush(); + wait_a_while(nap_msec); + + saywhat("s5;"); + show_panel(p5); + pflush(); + wait_a_while(nap_msec); + + saywhat("t3;"); + top_panel(p3); + pflush(); + wait_a_while(nap_msec); + + saywhat("t1;"); + top_panel(p1); + pflush(); + wait_a_while(nap_msec); + + saywhat("t2;"); + top_panel(p2); + pflush(); + wait_a_while(nap_msec); + + saywhat("t3;"); + top_panel(p3); + pflush(); + wait_a_while(nap_msec); + + saywhat("t4;"); + top_panel(p4); + pflush(); + wait_a_while(nap_msec); + + for (itmp = 0; itmp < 6; itmp++) + { + saywhat("m4;"); + mvwaddstr(w4, 3, 1, mod[itmp]); + move_panel(p4, 4, itmp * 10); + mvwaddstr(w5, 4, 1, mod[itmp]); + pflush(); + wait_a_while(nap_msec); + + saywhat("m5;"); + mvwaddstr(w4, 4, 1, mod[itmp]); + move_panel(p5, 7, itmp * 10 + 6); + mvwaddstr(w5, 3, 1, mod[itmp]); + pflush(); + wait_a_while(nap_msec); + } + + saywhat("m4;"); + move_panel(p4, 4, itmp * 10); + pflush(); + wait_a_while(nap_msec); + + saywhat("t5;"); + top_panel(p5); + pflush(); + wait_a_while(nap_msec); + + saywhat("t2;"); + top_panel(p2); + pflush(); + wait_a_while(nap_msec); + + saywhat("t1;"); + top_panel(p1); + pflush(); + wait_a_while(nap_msec); + + saywhat("d2;"); + rmpanel(p2); + pflush(); + wait_a_while(nap_msec); + + saywhat("h3;"); + hide_panel(p3); + pflush(); + wait_a_while(nap_msec); + + saywhat("d1;"); + rmpanel(p1); + pflush(); + wait_a_while(nap_msec); + + saywhat("d4; "); + rmpanel(p4); + pflush(); + wait_a_while(nap_msec); + + saywhat("d5; "); + rmpanel(p5); + pflush(); + wait_a_while(nap_msec); + + if (nap_msec == 1) + { + break; + } + + nap_msec = 100L; + } + + endwin(); + return 0; +} diff --git a/examples/pdcurses/rain_main.c b/examples/pdcurses/rain_main.c new file mode 100644 index 000000000..feb591844 --- /dev/null +++ b/examples/pdcurses/rain_main.c @@ -0,0 +1,185 @@ +/**************************************************************************** + * apps/examples/pdcurses/rain_main.c + * $Id: rain.c,v 1.11 2008/07/13 16:08:17 wmcbrine Exp $ + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Copyright (c) 2002 Free Software Foundation, Inc + * Adapted by: Gregory Nutt + * + * Adapted from the original public domain pdcurses by Gregory Nutt and + * released as part of NuttX under the origin ncurses license: + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, distribute with modifications, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name(s) of the above copyright + * holders shall not be used in advertising or otherwise to promote the + * sale, use or other dealings in this Software without prior written + * authorization. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include "graphics/curses.h" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static int next_j(int j) +{ + if (j == 0) + { + j = 4; + } + else + { + --j; + } + + if (has_colors()) + { + int z = rand() % 3; + chtype color = COLOR_PAIR(z); + + if (z) + { + color |= A_BOLD; + } + + attrset(color); + } + + return j; +} + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int rain_main(int argc, char *argv[]) +#endif +{ + int x, y, j, r, c, seed; + static int xpos[5], ypos[5]; + + initscr(); + seed = time((time_t *) 0); + srand(seed); + + if (has_colors()) + { + int bg = COLOR_BLACK; + + start_color(); + +#if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000) + if (use_default_colors() == OK) + { + bg = -1; + } +#endif + + init_pair(1, COLOR_BLUE, bg); + init_pair(2, COLOR_CYAN, bg); + } + + nl(); + noecho(); + curs_set(0); + timeout(0); + keypad(stdscr, true); + + r = LINES - 4; + c = COLS - 4; + + for (j = 5; --j >= 0;) + { + xpos[j] = rand() % c + 2; + ypos[j] = rand() % r + 2; + } + + for (j = 0;;) + { + x = rand() % c + 2; + y = rand() % r + 2; + + mvaddch(y, x, '.'); + + mvaddch(ypos[j], xpos[j], 'o'); + + j = next_j(j); + mvaddch(ypos[j], xpos[j], 'O'); + + j = next_j(j); + mvaddch(ypos[j] - 1, xpos[j], '-'); + mvaddstr(ypos[j], xpos[j] - 1, "|.|"); + mvaddch(ypos[j] + 1, xpos[j], '-'); + + j = next_j(j); + mvaddch(ypos[j] - 2, xpos[j], '-'); + mvaddstr(ypos[j] - 1, xpos[j] - 1, "/ \\"); + mvaddstr(ypos[j], xpos[j] - 2, "| O |"); + mvaddstr(ypos[j] + 1, xpos[j] - 1, "\\ /"); + mvaddch(ypos[j] + 2, xpos[j], '-'); + + j = next_j(j); + mvaddch(ypos[j] - 2, xpos[j], ' '); + mvaddstr(ypos[j] - 1, xpos[j] - 1, " "); + mvaddstr(ypos[j], xpos[j] - 2, " "); + mvaddstr(ypos[j] + 1, xpos[j] - 1, " "); + mvaddch(ypos[j] + 2, xpos[j], ' '); + + xpos[j] = x; + ypos[j] = y; + + switch (getch()) + { + case 'q': + case 'Q': + curs_set(1); + endwin(); + return EXIT_SUCCESS; + + case 's': + nodelay(stdscr, false); + break; + + case ' ': + nodelay(stdscr, true); +#ifdef KEY_RESIZE + break; + + case KEY_RESIZE: + resize_term(0, 0); + erase(); + r = LINES - 4; + c = COLS - 4; + break; +#endif + } + + napms(50); + } +} diff --git a/examples/pdcurses/testcurs_main.c b/examples/pdcurses/testcurs_main.c new file mode 100644 index 000000000..942cd5030 --- /dev/null +++ b/examples/pdcurses/testcurs_main.c @@ -0,0 +1,1295 @@ +/**************************************************************************** + * apps/examples/pdcurses/testcurs_main.c + * This is a test program for PDCurses. Originally by + * John Burnell + * wrs(5/28/93) -- modified to be consistent (perform identically) + * with either PDCurses or under Unix System V, R4 + * $Id: testcurs.c,v 1.85 2008/07/14 12:35:23 wmcbrine Exp $ + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Adapted by: Gregory Nutt + * + * Adapted from the original public domain pdcurses by Gregory Nutt and + * released as part of NuttX under the 3-clause BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +#include "graphics/curses.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef WACS_S1 +# define HAVE_WIDE 1 +#else +# define HAVE_WIDE 0 +#endif + +#include + +#if HAVE_WIDE +# include +#endif + +#ifdef A_COLOR +# define HAVE_COLOR 1 +#else +# define HAVE_COLOR 0 +#endif + +/* Set to non-zero if you want to test the PDCurses clipboard */ + +#define HAVE_CLIPBOARD 0 + +#define MAX_OPTIONS (6 + HAVE_COLOR + HAVE_CLIPBOARD + HAVE_WIDE) + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct commands +{ + const char *text; + void (*function) (WINDOW *); +}; + +typedef struct commands COMMAND; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static void continue1(WIDNOW *win); +static void continue2(void); + +static void input_test(WINDOW *); +static void scroll_test(WINDOW *); +static void intro_test(WINDOW *); +static int init_test(WINDOW **, int, char **); +static void output_test(WINDOW *); +static void pad_test(WINDOW *); +static void acs_test(WINDOW *); + +#if HAVE_COLOR +static void color_test(WINDOW *); +#endif + +static void resize_test(WINDOW *); + +#if HAVE_CLIPBOARD +static void clipboard_test(WINDOW *); +#endif + +#if HAVE_WIDE +static void wide_test(WINDOW *); +#endif + +static void display_menu(int, int); + +static const COMMAND command[MAX_OPTIONS] = +{ + {"Intro Test", intro_test}, + {"Pad Test", pad_test}, + {"Resize Test", resize_test}, + {"Scroll Test", scroll_test}, + {"Input Test", input_test}, + {"Output Test", output_test}, + {"ACS Test", acs_test}, +#if HAVE_COLOR + {"Color Test", color_test}, +#endif +#if HAVE_CLIPBOARD + {"Clipboard Test", clipboard_test}, +#endif +#if HAVE_WIDE + {"Wide Input", wide_test} +#endif +}; + +static int height; +static int width; + +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 +}; + +#ifdef ACS_S3 +# define ACSNUM 32 +#else +# define ACSNUM 25 +#endif + +#if HAVE_WIDE +static 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, + + 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 + +#if HAVE_COLOR +static const short colors[] = +{ + COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_BLUE, + COLOR_CYAN, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE +}; + +static const char *colornames[] = +{ + "COLOR_BLACK", "COLOR_RED", "COLOR_GREEN", "COLOR_BLUE", + "COLOR_CYAN", "COLOR_MAGENTA", "COLOR_YELLOW", "COLOR_WHITE" +}; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static void continue1(WIDNOW *win) +{ + mvwaddstr(win, 10, 1, " Press any key to continue"); + wrefresh(win); + raw(); + wgetch(win); +} + +static void continue2(void) +{ + move(LINES - 1, 1); + clrtoeol(); + mvaddstr(LINES - 2, 1, " Press any key to continue"); + refresh(); + raw(); + getch(); +} + +static int init_test(WINDOW ** win, int argc, char *argv[]) +{ + initscr(); +#ifdef A_COLOR + if (has_colors()) + { + start_color(); + } +#endif + /* Create a drawing window */ + + width = 60; + height = 13; + + *win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2); + if (*win == NULL) + { + endwin(); + return 1; + } + + return 0; +} + +static void intro_test(WIDNOW *win) +{ + werase(win); + wmove(win, height / 2 - 5, width / 2); + wvline(win, ACS_VLINE, 10); + wmove(win, height / 2, width / 2 - 10); + whline(win, ACS_HLINE, 20); + continue1(win); + + beep(); + werase(win); + + box(win, ACS_VLINE, ACS_HLINE); + wrefresh(win); + + cbreak(); + mvwaddstr(win, 1, 1, + "You should have a rectangle in the middle of the screen"); + mvwaddstr(win, 2, 1, "You should have heard a beep"); + continue1(win); + + flash(); + mvwaddstr(win, 3, 1, "You should have seen a flash"); + continue1(win); +} + +static void scroll_test(WIDNOW *win) +{ + int oldy; + int i; + + werase(win); + mvwaddstr(win, height - 2, 1, "The window will now scroll slowly"); + box(win, ACS_VLINE, ACS_HLINE); + wrefresh(win); + scrollok(win, true); + napms(500); + + for (i = 1; i <= height; i++) + { + napms(150); + scroll(win); + wrefresh(win); + }; + + oldy = getmaxy(win); + mvwaddstr(win, 6, 1, "The top of the window will scroll"); + wmove(win, 1, 1); + wsetscrreg(win, 0, 4); + box(win, ACS_VLINE, ACS_HLINE); + wrefresh(win); + + for (i = 1; i <= 5; i++) + { + napms(500); + scroll(win); + wrefresh(win); + } + + mvwaddstr(win, 3, 1, "The bottom of the window will scroll"); + wmove(win, 8, 1); + wsetscrreg(win, 5, --oldy); + box(win, ACS_VLINE, ACS_HLINE); + wrefresh(win); + + for (i = 5; i <= oldy; i++) + { + napms(300); + wscrl(win, -1); + wrefresh(win); + } + + wsetscrreg(win, 0, oldy); +} + +static void input_test(WIDNOW *win) +{ + int w; + int h; + int bx; + int by; + int sw; + int sh; + int i; + int c; + int num = 0; + char buffer[80]; + WINDOW *subWin; + static const char spinner[4] = "/-\\|"; + int spinner_count = 0; + + wclear(win); + + getmaxyx(win, h, w); + getbegyx(win, by, bx); + + sw = w / 3; + sh = h / 3; + + if ((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2)) == NULL) + { + return; + } + +#ifdef A_COLOR + if (has_colors()) + { + init_pair(2, COLOR_WHITE, COLOR_RED); + wbkgd(subWin, COLOR_PAIR(2) | A_BOLD); + } + else +#endif + { + wbkgd(subWin, A_BOLD); + } + + box(subWin, ACS_VLINE, ACS_HLINE); + wrefresh(win); + + nocbreak(); + + wclear(win); + mvwaddstr(win, 1, 1, "Press keys (or mouse buttons) to show their names"); + mvwaddstr(win, 2, 1, "Press spacebar to finish"); + wrefresh(win); + + keypad(win, true); + raw(); + noecho(); + + wtimeout(win, 200); + + mouse_set(ALL_MOUSE_EVENTS); + PDC_save_key_modifiers(true); + PDC_return_key_modifiers(true); + curs_set(0); /* turn cursor off */ + + while (1) + { + while (1) + { + c = wgetch(win); + + if (c == ERR) + { + spinner_count++; + if (spinner_count == 4) + { + spinner_count = 0; + } + + mvwaddch(win, 3, 3, spinner[spinner_count]); + wrefresh(win); + } + else + { + break; + } + } + + wmove(win, 4, 18); + wclrtoeol(win); + mvwaddstr(win, 3, 5, "Key Pressed: "); + wclrtoeol(win); + + if (c >= KEY_MIN) + { + wprintw(win, "%s", keyname(c)); + } + else if (isprint(c)) + { + wprintw(win, "%c", c); + } + else + { + wprintw(win, "%s", unctrl(c)); + } + + if (c == KEY_MOUSE) + { + int button = 0; + request_mouse_pos(); + + if (BUTTON_CHANGED(1)) + { + button = 1; + } + else if (BUTTON_CHANGED(2)) + { + button = 2; + } + else if (BUTTON_CHANGED(3)) + { + button = 3; + } + + if (button && (BUTTON_STATUS(button) & BUTTON_MODIFIER_MASK)) + { + waddstr(win, " Modifier(s):"); + + if (BUTTON_STATUS(button) & BUTTON_SHIFT) + { + waddstr(win, " SHIFT"); + } + + if (BUTTON_STATUS(button) & BUTTON_CONTROL) + { + waddstr(win, " CONTROL"); + } + + if (BUTTON_STATUS(button) & BUTTON_ALT) + { + waddstr(win, " ALT"); + } + } + + wmove(win, 4, 18); + wclrtoeol(win); + wprintw(win, "Button %d: ", button); + + if (MOUSE_MOVED) + { + waddstr(win, "moved: "); + } + else if (MOUSE_WHEEL_UP) + { + waddstr(win, "wheel up: "); + } + else if (MOUSE_WHEEL_DOWN) + { + waddstr(win, "wheel dn: "); + } + else if ((BUTTON_STATUS(button) & + BUTTON_ACTION_MASK) == BUTTON_PRESSED) + { + waddstr(win, "pressed: "); + } + else if ((BUTTON_STATUS(button) & + BUTTON_ACTION_MASK) == BUTTON_CLICKED) + { + waddstr(win, "clicked: "); + } + else if ((BUTTON_STATUS(button) & + BUTTON_ACTION_MASK) == BUTTON_DOUBLE_CLICKED) + { + waddstr(win, "double: "); + } + else + { + waddstr(win, "released: "); + } + + wprintw(win, "Position: Y: %d X: %d", MOUSE_Y_POS, MOUSE_X_POS); + } + else if (PDC_get_key_modifiers()) + { + waddstr(win, " Modifier(s):"); + if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_SHIFT) + { + waddstr(win, " SHIFT"); + } + + if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_CONTROL) + { + waddstr(win, " CONTROL"); + } + + if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_ALT) + { + waddstr(win, " ALT"); + } + + if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_NUMLOCK) + { + waddstr(win, " NUMLOCK"); + } + } + + wrefresh(win); + + if (c == ' ') + { + break; + } + } + + wtimeout(win, -1); /* turn off timeout() */ + curs_set(1); /* turn cursor back on */ + + mouse_set(0L); + PDC_save_key_modifiers(false); + PDC_return_key_modifiers(false); + wclear(win); + mvwaddstr(win, 2, 1, "Press some keys for 5 seconds"); + mvwaddstr(win, 1, 1, "Pressing ^C should do nothing"); + wrefresh(win); + + werase(subWin); + box(subWin, ACS_VLINE, ACS_HLINE); + + for (i = 0; i < 5; i++) + { + mvwprintw(subWin, 1, 1, "Time = %d", i); + wrefresh(subWin); + napms(1000); + flushinp(); + } + + delwin(subWin); + werase(win); + flash(); + wrefresh(win); + napms(500); + flushinp(); + + mvwaddstr(win, 2, 1, "Press a key, followed by ENTER"); + wmove(win, 9, 10); + wrefresh(win); + echo(); + + keypad(win, true); + raw(); + wgetnstr(win, buffer, 3); + flushinp(); + + wmove(win, 9, 10); + wdelch(win); + mvwaddstr(win, 4, 1, "The character should now have been deleted"); + continue1(win); + + refresh(); + wclear(win); + echo(); + buffer[0] = '\0'; + mvwaddstr(win, 3, 2, "The window should have moved"); + mvwaddstr(win, 4, 2, + "This text should have appeared without you pressing a key"); + mvwaddstr(win, 6, 2, "Enter a number then a string seperated by space"); + mvwin(win, 2, 1); + wrefresh(win); + mvwscanw(win, 7, 6, "%d %s", &num, buffer); + mvwprintw(win, 8, 6, "String: %s Number: %d", buffer, num); + continue1(win); + + refresh(); + wclear(win); + echo(); + mvwaddstr(win, 3, 2, "Enter a 5 character string: "); + wgetnstr(win, buffer, 5); + mvwprintw(win, 4, 2, "String: %s", buffer); + continue1(win); +} + +static void output_test(WIDNOW *win) +{ + WINDOW *win1; + char Buffer[80]; + chtype ch; + int bx; + int by; + + nl(); + wclear(win); + mvwaddstr(win, 1, 1, "You should now have a screen in the upper " + "left corner, and this text should have wrapped"); + waddstr(win, "\nThis text should be down\n"); + waddstr(win, "and broken into two here ^"); + continue1(win); + + wclear(win); + wattron(win, A_BOLD); + mvwaddstr(win, 1, 1, "A new window will appear with this text in it"); + mvwaddstr(win, 8, 1, "Press any key to continue"); + wrefresh(win); + wgetch(win); + + getbegyx(win, by, bx); + + if (LINES < 24 || COLS < 75) + { + mvwaddstr(win, 5, 1, "Some tests have been skipped as they require a"); + mvwaddstr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS"); + continue1(win); + } + else + { + win1 = newwin(10, 50, 14, 25); + + if (win1 == NULL) + { + endwin(); + return; + } + +#ifdef A_COLOR + if (has_colors()) + { + init_pair(3, COLOR_BLUE, COLOR_WHITE); + wbkgd(win1, COLOR_PAIR(3)); + } + else +#endif + { + wbkgd(win1, A_NORMAL); + } + + wclear(win1); + mvwaddstr(win1, 5, 1, "This text should appear; using overlay option"); + copywin(win, win1, 0, 0, 0, 0, 9, 49, true); + box(win1, ACS_VLINE, ACS_HLINE); + wmove(win1, 8, 26); + wrefresh(win1); + wgetch(win1); + + wclear(win1); + + wattron(win1, A_BLINK); + mvwaddstr(win1, 4, 1, + "This blinking text should appear in only the second window"); + wattroff(win1, A_BLINK); + + mvwin(win1, by, bx); + overlay(win, win1); + mvwin(win1, 14, 25); + wmove(win1, 8, 26); + wrefresh(win1); + wgetch(win1); + + delwin(win1); + } + + clear(); + wclear(win); + wrefresh(win); + mvwaddstr(win, 6, 2, "This line shouldn't appear"); + mvwaddstr(win, 4, 2, "Only half of the next line is visible"); + mvwaddstr(win, 5, 2, "Only half of the next line is visible"); + wmove(win, 6, 1); + wclrtobot(win); + wmove(win, 5, 20); + wclrtoeol(win); + mvwaddstr(win, 8, 2, "This line also shouldn't appear"); + wmove(win, 8, 1); + winsdelln(win, -1); + continue1(win); + + wmove(win, 5, 9); + ch = winch(win); + + wclear(win); + wmove(win, 6, 2); + waddstr(win, "The next char should be l: "); + winsch(win, ch); + continue1(win); + + mvwinsstr(win, 6, 2, "A1B2C3D4E5"); + continue1(win); + + wmove(win, 5, 1); + winsdelln(win, 1); + mvwaddstr(win, 5, 2, "The lines below should have moved down"); + continue1(win); + + wclear(win); + wmove(win, 2, 2); + wprintw(win, "This is a formatted string in a window: %d %s\n", 42, "is it"); + mvwaddstr(win, 10, 1, "Enter a string: "); + wrefresh(win); + echo(); + wscanw(win, "%s", Buffer); + + printw("This is a formatted string in stdscr: %d %s\n", 42, "is it"); + mvaddstr(10, 1, "Enter a string: "); + scanw("%s", Buffer); + + wclear(win); + curs_set(2); + mvwaddstr(win, 1, 1, "The cursor should be in high-visibility mode"); + continue1(win); + + wclear(win); + curs_set(0); + mvwaddstr(win, 1, 1, "The cursor should have disappeared"); + continue1(win); + + wclear(win); + curs_set(1); + mvwaddstr(win, 1, 1, "The cursor should be normal"); + continue1(win); + +#ifdef A_COLOR + if (has_colors()) + { + wclear(win); + mvwaddstr(win, 1, 1, "Colors should change after you press a key"); + continue1(win); + + init_pair(1, COLOR_RED, COLOR_WHITE); + wrefresh(win); + } +#endif + + werase(win); + mvwaddstr(win, 1, 1, "Information About Your Terminal"); + mvwaddstr(win, 3, 1, termname()); + mvwaddstr(win, 4, 1, longname()); + + if (termattrs() & A_BLINK) + { + mvwaddstr(win, 5, 1, "This terminal claims to support blinking."); + } + else + { + mvwaddstr(win, 5, 1, "This terminal does NOT support blinking."); + } + + mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16); + wrefresh(win); + + mvwinnstr(win, 7, 5, Buffer, 18); + mvaddstr(LINES - 2, 10, Buffer); + refresh(); + continue1(win); +} + +static void resize_test(WIDNOW *dummy) +{ + WINDOW *win1; + int nwidth = 135, nheight = 52; + int owidth = COLS, oheight = LINES; + + savetty(); + + resize_term(nheight, nwidth); + + clear(); + refresh(); + + win1 = newwin(10, 50, 14, 25); + + if (win1 == NULL) + { + endwin(); + return; + } + +#ifdef A_COLOR + if (has_colors()) + { + init_pair(3, COLOR_BLUE, COLOR_WHITE); + wattrset(win1, COLOR_PAIR(3)); + } + + wclear(win1); +#endif + mvwaddstr(win1, 0, 0, "The screen may now be resized"); + mvwprintw(win1, 1, 4, "Given size: %d by %d", nwidth, nheight); + mvwprintw(win1, 2, 4, "Actual size: %d by %d", COLS, LINES); + continue1(win1); + + wclear(win1); + resetty(); + + mvwaddstr(win1, 0, 0, "The screen should now be reset"); + mvwprintw(win1, 1, 6, "Old size: %d by %d", owidth, oheight); + mvwprintw(win1, 2, 6, "Size now: %d by %d", COLS, LINES); + continue1(win1); + + delwin(win1); + + clear(); + refresh(); +} + +static void pad_test(WIDNOW *dummy) +{ + WINDOW *pad, *spad; + + pad = newpad(50, 100); + wattron(pad, A_REVERSE); + mvwaddstr(pad, 5, 2, "This is a new pad"); + wattrset(pad, 0); + mvwaddstr(pad, 8, 0, + "The end of this line should be truncated here:except now"); + mvwaddstr(pad, 11, 1, "This line should not appear.It will now"); + wmove(pad, 10, 1); + wclrtoeol(pad); + mvwaddstr(pad, 10, 1, " Press any key to continue"); + prefresh(pad, 0, 0, 0, 0, 10, 45); + keypad(pad, true); + raw(); + wgetch(pad); + + spad = subpad(pad, 12, 25, 7, 52); + mvwaddstr(spad, 2, 2, "This is a new subpad"); + box(spad, 0, 0); + prefresh(pad, 0, 0, 0, 0, 15, 75); + keypad(pad, true); + raw(); + wgetch(pad); + + mvwaddstr(pad, 35, 2, "This is displayed at line 35 in the pad"); + mvwaddstr(pad, 40, 1, " Press any key to continue"); + prefresh(pad, 30, 0, 0, 0, 10, 45); + keypad(pad, true); + raw(); + wgetch(pad); + + delwin(pad); +} + +#if HAVE_CLIPBOARD +static void clipboard_test(WIDNOW *win) +{ + static const char *text = + "This string placed in clipboard by PDCurses test program, testcurs."; + char *ptr = NULL; + long i, length = 0; + + mvaddstr(1, 1, "This test will display the contents of the system clipboard"); + + continue2(); + + scrollok(stdscr, true); + i = PDC_getclipboard(&ptr, &length); + + switch (i) + { + case PDC_CLIP_ACCESS_ERROR: + mvaddstr(3, 1, "There was an error accessing the clipboard"); + refresh(); + break; + + case PDC_CLIP_MEMORY_ERROR: + mvaddstr(3, 1, "Unable to allocate memory for clipboard contents"); + break; + + case PDC_CLIP_EMPTY: + mvaddstr(3, 1, "There was no text in the clipboard"); + break; + + default: + wsetscrreg(stdscr, 0, LINES - 1); + clear(); + mvaddstr(1, 1, "Clipboard contents..."); + mvprintw(2, 1, "%s\n", ptr); + } + + continue2(); + + clear(); + mvaddstr(1, 1, + "This test will place the following string in the system clipboard:"); + mvaddstr(2, 1, text); + + i = PDC_setclipboard(text, strlen(text)); + + switch (i) + { + case PDC_CLIP_ACCESS_ERROR: + mvaddstr(3, 1, "There was an error accessing the clipboard"); + break; + + case PDC_CLIP_MEMORY_ERROR: + mvaddstr(3, 1, "Unable to allocate memory for clipboard contents"); + break; + + default: + mvaddstr(3, 1, "The string was placed in the clipboard successfully"); + } + + continue2(); +} +#endif /* HAVE_CLIPBOARD */ + +static void acs_test(WIDNOW *win) +{ + chtype acs_values[ACSNUM]; + int tmarg = (LINES - 22) / 2; + int i; + + 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 +} + +#if HAVE_COLOR +static void color_test(WIDNOW *win) +{ + chtype fill = ACS_BLOCK; + int tmarg; + int col1; + int col2; + int col3; + int i; + int j; + + if (!has_colors()) + { + return; + } + + tmarg = (LINES - 19) / 2; + col1 = (COLS - 60) / 2; + col2 = col1 + 20; + col3 = col2 + 20; + + attrset(A_BOLD); + mvaddstr(tmarg, (COLS - 22) / 2, "Color Attribute Macros"); + attrset(A_NORMAL); + + mvaddstr(tmarg + 3, col2 + 4, "A_NORMAL"); + mvaddstr(tmarg + 3, col3 + 5, "A_BOLD"); + + for (i = 0; i < 8; i++) + { + init_pair(i + 4, colors[i], COLOR_BLACK); + + mvaddstr(tmarg + i + 5, col1, colornames[i]); + + for (j = 0; j < 16; j++) + { + mvaddch(tmarg + i + 5, col2 + j, fill | COLOR_PAIR(i + 4)); + mvaddch(tmarg + i + 5, col3 + j, fill | COLOR_PAIR(i + 4) | A_BOLD); + } + } + + mvprintw(tmarg + 15, col1, "COLORS = %d", COLORS); + mvprintw(tmarg + 16, col1, "COLOR_PAIRS = %d", COLOR_PAIRS); + + mvaddstr(tmarg + 19, 3, "Press any key to continue"); + getch(); + + if (can_change_color()) + { + struct + { + short red; + short green; + short blue; + } orgcolors[16]; + + int MAXCOL = (COLORS >= 16) ? 16 : 8; + + if (MAXCOL < 8) + { + return; + } + + for (i = 0; i < MAXCOL; i++) + { + color_content(i, &(orgcolors[i].red), + &(orgcolors[i].green), &(orgcolors[i].blue)); + } + + attrset(A_BOLD); + mvaddstr(tmarg, (COLS - 22) / 2, " init_color() Example "); + attrset(A_NORMAL); + + refresh(); + + for (i = 0; i < 8; i++) + { + init_color(colors[i], i * 125, 0, i * 125); + + if (MAXCOL == 16) + { + init_color(colors[i] + 8, 0, i * 125, 0); + } + } + + mvaddstr(tmarg + 19, 3, "Press any key to continue"); + getch(); + + for (i = 0; i < MAXCOL; i++) + { + init_color(i, orgcolors[i].red, orgcolors[i].green, orgcolors[i].blue); + } + } +} +#endif + +#if HAVE_WIDE +static void wide_test(WIDNOW *win) +{ + wchar_t tmp[513]; + size_t i; + + attrset(A_BOLD); + mvaddstr(1, (COLS - 25) / 2, "Wide Character Input Test"); + attrset(A_NORMAL); + + mvaddstr(4, 1, "Enter a string: "); + + echo(); + + get_wstr((wint_t *) tmp); + addstr("\n\n String:\n\n "); + addwstr(tmp); + addstr("\n\n\n Hex:\n\n "); + + for (i = 0; i < wcslen(tmp); i++) + { + printw("%04x ", tmp[i]); + addnwstr(tmp + i, 1); + addstr(" "); + } + + noecho(); + continue2(); +} +#endif + +void display_menu(int old_option, int new_option) +{ + int lmarg = (COLS - 14) / 2, tmarg = (LINES - (MAX_OPTIONS + 2)) / 2; + + if (old_option == -1) + { + int i; + + attrset(A_BOLD); + mvaddstr(tmarg - 3, lmarg - 5, "PDCurses Test Program"); + attrset(A_NORMAL); + + for (i = 0; i < MAX_OPTIONS; i++) + { + mvaddstr(tmarg + i, lmarg, command[i].text); + } + } + else + { + mvaddstr(tmarg + old_option, lmarg, command[old_option].text); + } + + attrset(A_REVERSE); + mvaddstr(tmarg + new_option, lmarg, command[new_option].text); + attrset(A_NORMAL); + + mvaddstr(tmarg + MAX_OPTIONS + 2, lmarg - 23, + "Use Up and Down Arrows to select - Enter to run - Q to quit"); + refresh(); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int testcurs_main(int argc, char *argv[]) +#endif +{ + WINDOW *win; + int key, old_option = -1, new_option = 0; + bool quit = false; + + setlocale(LC_ALL, ""); + + if (init_test(&win, argc, argv)) + { + return 1; + } + +#ifdef A_COLOR + if (has_colors()) + { + init_pair(1, COLOR_WHITE, COLOR_BLUE); + wbkgd(win, COLOR_PAIR(1)); + } + else +#endif + { + wbkgd(win, A_REVERSE); + } + + erase(); + display_menu(old_option, new_option); + + while (1) + { + noecho(); + keypad(stdscr, true); + raw(); + + key = getch(); + + switch (key) + { + case 10: + case 13: + case KEY_ENTER: + old_option = -1; + erase(); + refresh(); + (*command[new_option].function) (win); + erase(); + display_menu(old_option, new_option); + break; + + case KEY_PPAGE: + case KEY_HOME: + old_option = new_option; + new_option = 0; + display_menu(old_option, new_option); + break; + + case KEY_NPAGE: + case KEY_END: + old_option = new_option; + new_option = MAX_OPTIONS - 1; + display_menu(old_option, new_option); + break; + + case KEY_UP: + old_option = new_option; + new_option = (new_option == 0) ? new_option : new_option - 1; + display_menu(old_option, new_option); + break; + + case KEY_DOWN: + old_option = new_option; + new_option = (new_option == MAX_OPTIONS - 1) ? + new_option : new_option + 1; + display_menu(old_option, new_option); + break; + +#ifdef KEY_RESIZE + case KEY_RESIZE: + resize_term(0, 0); + old_option = -1; + erase(); + display_menu(old_option, new_option); + break; +#endif + case 'Q': + case 'q': + quit = true; + break; + } + + if (quit == true) + { + break; + } + } + + delwin(win); + endwin(); + return 0; +} diff --git a/examples/pdcurses/tui.c b/examples/pdcurses/tui.c new file mode 100644 index 000000000..64d20b497 --- /dev/null +++ b/examples/pdcurses/tui.c @@ -0,0 +1,895 @@ +/**************************************************************************** + * apps/examples/pdcurses/tui.c + * Textual User Interface + * + * Author : P.J. Kunst + * Date : 25-02-93 + * + * $Id: tui.c,v 1.34 2008/07/14 12:35:23 wmcbrine Exp $ + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Adapted by: Gregory Nutt + * + * Adapted from the original public domain pdcurses by Gregory Nutt and + * released as part of NuttX under the 3-clause BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "graphics/curses.h" +#include "tui.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef A_COLOR +# define TITLECOLOR 1 /* color pair indices */ +# define MAINMENUCOLOR (2 | A_BOLD) +# define MAINMENUREVCOLOR (3 | A_BOLD | A_REVERSE) +# define SUBMENUCOLOR (4 | A_BOLD) +# define SUBMENUREVCOLOR (5 | A_BOLD | A_REVERSE) +# define BODYCOLOR 6 +# define STATUSCOLOR (7 | A_BOLD) +# define INPUTBOXCOLOR 8 +# define EDITBOXCOLOR (9 | A_BOLD | A_REVERSE) +#else +# define TITLECOLOR 0 /* color pair indices */ +# define MAINMENUCOLOR (A_BOLD) +# define MAINMENUREVCOLOR (A_BOLD | A_REVERSE) +# define SUBMENUCOLOR (A_BOLD) +# define SUBMENUREVCOLOR (A_BOLD | A_REVERSE) +# define BODYCOLOR 0 +# define STATUSCOLOR (A_BOLD) +# define INPUTBOXCOLOR 0 +# define EDITBOXCOLOR (A_BOLD | A_REVERSE) +#endif + +#define th 1 /* title window height */ +#define mh 1 /* main menu height */ +#define sh 2 /* status window height */ +#define bh (LINES - th - mh - sh) /* body window height */ +#define bw COLS /* body window width */ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static WINDOW *wtitl; +static WINDOW *wmain; +static WINDOW *wbody; +static WINDOW *wstat; +static int nextx; +static int nexty; +static int key = ERR; +static int ch = ERR; +static bool quit = false; +static bool incurses = false; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static char *padstr(char *s, int length) +{ + static char buf[MAXSTRLEN]; + char fmt[10]; + + sprintf(fmt, (int)strlen(s) > length ? "%%.%ds" : "%%-%ds", length); + sprintf(buf, fmt, s); + + return buf; +} + +static char *prepad(char *s, int length) +{ + int i; + char *p = s; + + if (length > 0) + { + memmove((void *)(s + length), (const void *)s, strlen(s) + 1); + + for (i = 0; i < length; i++) + { + *p++ = ' '; + } + } + + return s; +} + +static void rmline(WIDNOW *win, int nr) /* keeps box lines intact */ +{ + mvwaddstr(win, nr, 1, padstr(" ", bw - 2)); + wrefresh(win); +} + +static void initcolor(void) +{ +#ifdef A_COLOR + if (has_colors()) + { + start_color(); + } + + /* foreground, background */ + + init_pair(TITLECOLOR & ~A_ATTR, COLOR_BLACK, COLOR_CYAN); + init_pair(MAINMENUCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_CYAN); + init_pair(MAINMENUREVCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLACK); + init_pair(SUBMENUCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_CYAN); + init_pair(SUBMENUREVCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLACK); + init_pair(BODYCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLUE); + init_pair(STATUSCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_CYAN); + init_pair(INPUTBOXCOLOR & ~A_ATTR, COLOR_BLACK, COLOR_CYAN); + init_pair(EDITBOXCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLACK); +#endif +} + +static void setcolor(WIDNOW *win, chtype color) +{ + chtype attr = color & A_ATTR; /* extract Bold, Reverse, Blink bits */ + +#ifdef A_COLOR + attr &= ~A_REVERSE; /* ignore reverse, use colors instead! */ + wattrset(win, COLOR_PAIR(color & A_CHARTEXT) | attr); +#else + attr &= ~A_BOLD; /* ignore bold, gives messy display on HP-UX */ + wattrset(win, attr); +#endif +} + +static void colorbox(WIDNOW *win, chtype color, int hasbox) +{ + int maxy; + chtype attr = color & A_ATTR; /* extract Bold, Reverse, Blink bits */ + + setcolor(win, color); + +#ifdef A_COLOR + if (has_colors()) + { + wbkgd(win, COLOR_PAIR(color & A_CHARTEXT) | (attr & ~A_REVERSE)); + } + else +#endif + { + wbkgd(win, attr); + } + + werase(win); + + maxy = getmaxy(win); + if (hasbox && (maxy > 2)) + { + box(win, 0, 0); + } + + touchwin(win); + wrefresh(win); +} + +static void idle(void) +{ + char buf[MAXSTRLEN]; + time_t t; + struct tm *tp; + + if (time(&t) == -1) + { + return; /* time not available */ + } + + tp = localtime(&t); + sprintf(buf, " %.2d-%.2d-%.4d %.2d:%.2d:%.2d", + tp->tm_mday, tp->tm_mon + 1, tp->tm_year + 1900, + tp->tm_hour, tp->tm_min, tp->tm_sec); + + mvwaddstr(wtitl, 0, bw - strlen(buf) - 2, buf); + wrefresh(wtitl); +} + +static void menudim(menu *mp, int *lines, int *columns) +{ + int n; + int l; + int mmax = 0; + + for (n = 0; mp->func; n++, mp++) + { + if ((l = strlen(mp->name)) > mmax) + { + mmax = l; + } + } + + *lines = n; + *columns = mmax + 2; +} + +static void setmenupos(int y, int x) +{ + nexty = y; + nextx = x; +} + +static void getmenupos(int *y, int *x) +{ + *y = nexty; + *x = nextx; +} + +static int hotkey(const char *s) +{ + int c0 = *s; /* if no upper case found, return first char */ + + for (; *s; s++) + { + if (isupper((unsigned char)*s)) + { + break; + } + } + + return *s ? *s : c0; +} + +static void repaintmenu(WIDNOW *wmenu, menu *mp) +{ + int i; + menu *p = mp; + + for (i = 0; p->func; i++, p++) + { + mvwaddstr(wmenu, i + 1, 2, p->name); + } + + touchwin(wmenu); + wrefresh(wmenu); +} + +static void repaintmainmenu(int width, menu *mp) +{ + int i; + menu *p = mp; + + for (i = 0; p->func; i++, p++) + { + mvwaddstr(wmain, 0, i * width, prepad(padstr(p->name, width - 1), 1)); + } + + touchwin(wmain); + wrefresh(wmain); +} + +static void mainhelp(void) +{ +#ifdef ALT_X + statusmsg("Use arrow keys and Enter to select (Alt-X to quit)"); +#else + statusmsg("Use arrow keys and Enter to select"); +#endif +} + +static void mainmenu(menu *mp) +{ + int nitems, barlen, old = -1, cur = 0, c, cur0; + + menudim(mp, &nitems, &barlen); + repaintmainmenu(barlen, mp); + + while (!quit) + { + if (cur != old) + { + if (old != -1) + { + mvwaddstr(wmain, 0, old * barlen, + prepad(padstr(mp[old].name, barlen - 1), 1)); + + statusmsg(mp[cur].desc); + } + else + { + mainhelp(); + } + + setcolor(wmain, MAINMENUREVCOLOR); + + mvwaddstr(wmain, 0, cur * barlen, + prepad(padstr(mp[cur].name, barlen - 1), 1)); + + setcolor(wmain, MAINMENUCOLOR); + old = cur; + wrefresh(wmain); + } + + switch (c = (key != ERR ? key : waitforkey())) + { + case KEY_DOWN: + case '\n': /* menu item selected */ + touchwin(wbody); + wrefresh(wbody); + rmerror(); + setmenupos(th + mh, cur * barlen); + curs_set(1); + (mp[cur].func) (); /* perform function */ + curs_set(0); + + switch (key) + { + case KEY_LEFT: + cur = (cur + nitems - 1) % nitems; + key = '\n'; + break; + + case KEY_RIGHT: + cur = (cur + 1) % nitems; + key = '\n'; + break; + + default: + key = ERR; + } + + repaintmainmenu(barlen, mp); + old = -1; + break; + + case KEY_LEFT: + cur = (cur + nitems - 1) % nitems; + break; + + case KEY_RIGHT: + cur = (cur + 1) % nitems; + break; + + case KEY_ESC: + mainhelp(); + break; + + default: + cur0 = cur; + + do + { + cur = (cur + 1) % nitems; + } + while ((cur != cur0) && (hotkey(mp[cur].name) != toupper(c))); + + if (hotkey(mp[cur].name) == toupper(c)) + { + key = '\n'; + } + } + } + + rmerror(); + touchwin(wbody); + wrefresh(wbody); +} + +static void cleanup(void) /* cleanup curses settings */ +{ + if (incurses) + { + delwin(wtitl); + delwin(wmain); + delwin(wbody); + delwin(wstat); + curs_set(1); + endwin(); + incurses = false; + } +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void clsbody(void) +{ + werase(wbody); + wmove(wbody, 0, 0); +} + +int bodylen(void) +{ + return getmaxy(wbody); +} + +WINDOW *bodywin(void) +{ + return wbody; +} + +void rmerror(void) +{ + rmline(wstat, 0); +} + +void rmstatus(void) +{ + rmline(wstat, 1); +} + +void titlemsg(char *msg) +{ + mvwaddstr(wtitl, 0, 2, padstr(msg, bw - 3)); + wrefresh(wtitl); +} + +void bodymsg(char *msg) +{ + waddstr(wbody, msg); + wrefresh(wbody); +} + +void errormsg(char *msg) +{ + beep(); + mvwaddstr(wstat, 0, 2, padstr(msg, bw - 3)); + wrefresh(wstat); +} + +void statusmsg(char *msg) +{ + mvwaddstr(wstat, 1, 2, padstr(msg, bw - 3)); + wrefresh(wstat); +} + +bool keypressed(void) +{ + ch = wgetch(wbody); + + return ch != ERR; +} + +int getkey(void) +{ + int c = ch; + + ch = ERR; +#ifdef ALT_X + quit = (c == ALT_X); /* PC only ! */ +#endif + return c; +} + +int waitforkey(void) +{ + do + { + idle(); + } + while (!keypressed()); + + return getkey(); +} + +void tui_exit(void) /* terminate program */ +{ + quit = true; +} + +void domenu(menu *mp) +{ + int x; + int y; + int nitems; + int barlen; + int mheight; + int mw; + int old = -1; + int cur = 0; + int cur0; + bool stop = false; + WINDOW *wmenu; + + curs_set(0); + getmenupos(&y, &x); + menudim(mp, &nitems, &barlen); + mheight = nitems + 2; + mw = barlen + 2; + wmenu = newwin(mheight, mw, y, x); + colorbox(wmenu, SUBMENUCOLOR, 1); + repaintmenu(wmenu, mp); + + key = ERR; + + while (!stop && !quit) + { + if (cur != old) + { + if (old != -1) + { + mvwaddstr(wmenu, old + 1, 1, + prepad(padstr(mp[old].name, barlen - 1), 1)); + } + + setcolor(wmenu, SUBMENUREVCOLOR); + mvwaddstr(wmenu, cur + 1, 1, + prepad(padstr(mp[cur].name, barlen - 1), 1)); + + setcolor(wmenu, SUBMENUCOLOR); + statusmsg(mp[cur].desc); + + old = cur; + wrefresh(wmenu); + } + + switch (key = ((key != ERR) ? key : waitforkey())) + { + case '\n': /* menu item selected */ + touchwin(wbody); + wrefresh(wbody); + setmenupos(y + 1, x + 1); + rmerror(); + + key = ERR; + curs_set(1); + (mp[cur].func) (); /* perform function */ + curs_set(0); + + repaintmenu(wmenu, mp); + old = -1; + break; + + case KEY_UP: + cur = (cur + nitems - 1) % nitems; + key = ERR; + break; + + case KEY_DOWN: + cur = (cur + 1) % nitems; + key = ERR; + break; + + case KEY_ESC: + case KEY_LEFT: + case KEY_RIGHT: + if (key == KEY_ESC) + { + key = ERR; /* return to prev submenu */ + } + + stop = true; + break; + + default: + cur0 = cur; + + do + { + cur = (cur + 1) % nitems; + + } + while ((cur != cur0) && (hotkey(mp[cur].name) != toupper((int)key))); + + key = (hotkey(mp[cur].name) == toupper((int)key)) ? '\n' : ERR; + } + + } + + rmerror(); + delwin(wmenu); + touchwin(wbody); + wrefresh(wbody); +} + +void startmenu(menu *mp, char *mtitle) +{ + initscr(); + incurses = true; + initcolor(); + + wtitl = subwin(stdscr, th, bw, 0, 0); + wmain = subwin(stdscr, mh, bw, th, 0); + wbody = subwin(stdscr, bh, bw, th + mh, 0); + wstat = subwin(stdscr, sh, bw, th + mh + bh, 0); + + colorbox(wtitl, TITLECOLOR, 0); + colorbox(wmain, MAINMENUCOLOR, 0); + colorbox(wbody, BODYCOLOR, 0); + colorbox(wstat, STATUSCOLOR, 0); + + if (mtitle) + { + titlemsg(mtitle); + } + + cbreak(); /* direct input (no newline required)... */ + noecho(); /* ... without echoing */ + curs_set(0); /* hide cursor (if possible) */ + nodelay(wbody, true); /* don't wait for input... */ + halfdelay(10); /* ...well, no more than a second, anyway */ + keypad(wbody, true); /* enable cursor keys */ + scrollok(wbody, true); /* enable scrolling in main window */ + + leaveok(stdscr, true); + leaveok(wtitl, true); + leaveok(wmain, true); + leaveok(wstat, true); + + mainmenu(mp); + cleanup(); +} + +static void repainteditbox(WIDNOW *win, int x, char *buf) +{ + int maxx; + + maxx = getmaxx(win); + werase(win); + mvwprintw(win, 0, 0, "%s", padstr(buf, maxx)); + wmove(win, 0, x); + wrefresh(win); +} + +/* weditstr() - edit string + * + * Description: + * The initial value of 'str' with a maximum length of 'field' - 1, + * which is supplied by the calling routine, is editted. The user's + * erase (^H), kill (^U) and delete word (^W) chars are interpreted. + * The PC insert or Tab keys toggle between insert and edit mode. + * Escape aborts the edit session, leaving 'str' unchanged. + * Enter, Up or Down Arrow are used to accept the changes to 'str'. + * NOTE: editstr(), mveditstr(), and mvweditstr() are macros. + * + * Return Value: + * Returns the input terminating character on success (Escape, + * Enter, Up or Down Arrow) and ERR on error. + * + * Errors: + * It is an error to call this function with a NULL window pointer. + * The length of the initial 'str' must not exceed 'field' - 1. + * + */ + +int weditstr(WIDNOW *win, char *buf, int field) +{ + char org[MAXSTRLEN], *tp, *bp = buf; + bool defdisp = true, stop = false, insert = false; + int cury, curx, begy, begx, oldattr; + WINDOW *wedit; + int c = 0; + + if ((field >= MAXSTRLEN) || (buf == NULL) || ((int)strlen(buf) > field - 1)) + { + return ERR; + } + + strcpy(org, buf); /* save original */ + + wrefresh(win); + getyx(win, cury, curx); + getbegyx(win, begy, begx); + + wedit = subwin(win, 1, field, begy + cury, begx + curx); + oldattr = wedit->_attrs; + colorbox(wedit, EDITBOXCOLOR, 0); + + keypad(wedit, true); + curs_set(1); + + while (!stop) + { + idle(); + repainteditbox(wedit, bp - buf, buf); + + switch (c = wgetch(wedit)) + { + case ERR: + break; + + case KEY_ESC: + strcpy(buf, org); /* restore original */ + stop = true; + break; + + case '\n': + case KEY_UP: + case KEY_DOWN: + stop = true; + break; + + case KEY_LEFT: + if (bp > buf) + bp--; + break; + + case KEY_RIGHT: + defdisp = false; + if (bp - buf < (int)strlen(buf)) + bp++; + break; + + case '\t': /* TAB -- because insert is broken on HPUX */ + case KEY_IC: /* enter insert mode */ + case KEY_EIC: /* exit insert mode */ + defdisp = false; + insert = !insert; + + curs_set(insert ? 2 : 1); + break; + + default: + if (c == erasechar()) /* backspace, ^H */ + { + if (bp > buf) + { + memmove((void *)(bp - 1), (const void *)bp, strlen(bp) + 1); + bp--; + } + } + else if (c == killchar()) /* ^U */ + { + bp = buf; + *bp = '\0'; + } + else if (c == wordchar()) /* ^W */ + { + tp = bp; + + while ((bp > buf) && (*(bp - 1) == ' ')) + bp--; + while ((bp > buf) && (*(bp - 1) != ' ')) + bp--; + + memmove((void *)bp, (const void *)tp, strlen(tp) + 1); + } + else if (isprint(c)) + { + if (defdisp) + { + bp = buf; + *bp = '\0'; + defdisp = false; + } + + if (insert) + { + if ((int)strlen(buf) < field - 1) + { + memmove((void *)(bp + 1), (const void *)bp, + strlen(bp) + 1); + + *bp++ = c; + } + } + else if (bp - buf < field - 1) + { + /* append new string terminator */ + + if (!*bp) + bp[1] = '\0'; + + *bp++ = c; + } + } + + break; + } + } + + curs_set(0); + + wattrset(wedit, oldattr); + repainteditbox(wedit, bp - buf, buf); + delwin(wedit); + return c; +} + +WINDOW *winputbox(WIDNOW *win, int nlines, int ncols) +{ + WINDOW *winp; + int cury, curx, begy, begx; + + getyx(win, cury, curx); + getbegyx(win, begy, begx); + + winp = newwin(nlines, ncols, begy + cury, begx + curx); + colorbox(winp, INPUTBOXCOLOR, 1); + + return winp; +} + +int getstrings(char *desc[], char *buf[], int field) +{ + WINDOW *winput; + int oldy, oldx, maxy, maxx, nlines, ncols, i, n, l, mmax = 0; + int c = 0; + bool stop = false; + + for (n = 0; desc[n]; n++) + { + if ((l = strlen(desc[n])) > mmax) + { + mmax = l; + } + } + + nlines = n + 2; + ncols = mmax + field + 4; + getyx(wbody, oldy, oldx); + getmaxyx(wbody, maxy, maxx); + + winput = mvwinputbox(wbody, (maxy - nlines) / 2, (maxx - ncols) / 2, + nlines, ncols); + + for (i = 0; i < n; i++) + { + mvwprintw(winput, i + 1, 2, "%s", desc[i]); + } + + i = 0; + + while (!stop) + { + switch (c = mvweditstr(winput, i + 1, mmax + 3, buf[i], field)) + { + case KEY_ESC: + stop = true; + break; + + case KEY_UP: + i = (i + n - 1) % n; + break; + + case '\n': + case '\t': + case KEY_DOWN: + if (++i == n) + { + stop = true; /* all passed? */ + } + + break; + } + } + + delwin(winput); + touchwin(wbody); + wmove(wbody, oldy, oldx); + wrefresh(wbody); + return c; +} diff --git a/examples/pdcurses/tui.h b/examples/pdcurses/tui.h new file mode 100644 index 000000000..061b7de5b --- /dev/null +++ b/examples/pdcurses/tui.h @@ -0,0 +1,116 @@ +/**************************************************************************** + * apps/examples/pdcurses/tui.c + * Textual User Interface + * + * Author : P.J. Kunst + * Date : 25-02-93 + * + * $Id: tui.h,v 1.11 2008/07/14 12:35:23 wmcbrine Exp $ + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Adapted by: Gregory Nutt + * + * Adapted from the original public domain pdcurses by Gregory Nutt and + * released as part of NuttX under the 3-clause BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __APPS_EXAMPLES_PDCURSES_TUI_H +#define __APPS_EXAMPLES_PDCURSES_TUI_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "graphics/curses.h" + +/**************************************************************************** + * Pre-processor Defintiions + ****************************************************************************/ + +#ifdef A_COLOR +# define A_ATTR (A_ATTRIBUTES ^ A_COLOR) /* A_BLINK, A_REVERSE, A_BOLD */ +#else +# define A_ATTR (A_ATTRIBUTES) /* standard UNIX attributes */ +#endif + +#define MAXSTRLEN 256 +#define KEY_ESC 0x1b /* Escape */ + +#define editstr(s,f) (weditstr(stdscr,s,f)) +#define mveditstr(y,x,s,f) (move(y,x)==ERR?ERR:editstr(s,f)) +#define mvweditstr(w,y,x,s,f) (wmove(w,y,x)==ERR?ERR:weditstr(w,s,f)) + +#define inputbox(l,c) (winputbox(stdscr,l,c)) +#define mvinputbox(y,x,l,c) (move(y,x)==ERR?w:inputbox(l,c)) +#define mvwinputbox(w,y,x,l,c) (wmove(w,y,x)==ERR?w:winputbox(w,l,c)) + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +typedef void (*FUNC)(void); + +typedef struct +{ + char *name; /* item label */ + FUNC func; /* (pointer to) function */ + char *desc; /* function description */ +} menu; + +/**************************************************************************** + * Public Functin Prototypes + ****************************************************************************/ + +void clsbody(void); +int bodylen(void); +WINDOW *bodywin(void); + +void rmerror(void); +void rmstatus(void); + +void titlemsg(char *msg); +void bodymsg(char *msg); +void errormsg(char *msg); +void statusmsg(char *msg); + +bool keypressed(void); +int getkey(void); +int waitforkey(void); + +void tui_exit(void); +void startmenu(menu *mp, char *title); +void domenu(menu *mp); + +int weditstr(WINDOW *win, char *buf, int field); +WINDOW *winputbox(WINDOW *win, int nlines, int ncols); +int getstrings(char *desc[], char *buf[], int field); + +#endif /* __APPS_EXAMPLES_PDCURSES_TUI_H */ diff --git a/examples/pdcurses/tui_main.c b/examples/pdcurses/tui_main.c new file mode 100644 index 000000000..933d80553 --- /dev/null +++ b/examples/pdcurses/tui_main.c @@ -0,0 +1,288 @@ +/**************************************************************************** + * apps/examples/pdcurses/tui.c + * Textual User Interface + * + * Author : P.J. Kunst + * Date : 25-02-93 + * + * Purpose: This program demonstrates the use of the 'curses' library + * for the creation of (simple) menu-operated programs. + * In the PDCurses version, use is made of colors for the + * highlighting of subwindows (title bar, status bar etc). + * + * Acknowledgement: some ideas were borrowed from Mark Hessling's + * version of the 'testcurs' program. + * + * $Id: tuidemo.c,v 1.22 2008/07/14 12:35:23 wmcbrine Exp $ + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Adapted by: Gregory Nutt + * + * Adapted from the original public domain pdcurses by Gregory Nutt and + * released as part of NuttX under the 3-clause BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include + +#include "tui.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Change this if source at other location */ + +#define FNAME "../demos/tui.c" + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static void sub0(void), sub1(void), sub2(void), sub3(void); +static void func1(void), func2(void); +static void subfunc1(void), subfunc2(void); +static void subsub(void); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const char *g_fieldname[6] = +{ + "Name", "Street", "City", "State", "Country", (char *)0 +}; + +menu g_mainmenu[] = +{ + {"Asub", sub0, "Go inside first submenu"}, + {"Bsub", sub1, "Go inside second submenu"}, + {"Csub", sub2, "Go inside third submenu"}, + {"Dsub", sub3, "Go inside fourth submenu"}, + {"", (FUNC)0, ""} /* always add this as the last item! */ +}; + +static const menu g_submenu0[] = +{ + {"Exit", tui_exit, "Terminate program"}, + {"", (FUNC)0, ""} +}; + +static const menu g_submenu1[] = +{ + {"OneBeep", func1, "Sound one beep"}, + {"TwoBeeps", func2, "Sound two beeps"}, + {"", (FUNC)0, ""} +}; + +static const menu g_submenu2[] = +{ + {"Browse", subfunc1, "Source file lister"}, + {"Input", subfunc2, "Interactive file lister"}, + {"Address", address, "Get address data"}, + {"", (FUNC)0, ""} +}; + +static const menu g_submenu3[] = +{ + {"SubSub", subsub, "Go inside sub-submenu"}, + {"", (FUNC)0, ""} +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static void address(void) +{ + char *fieldbuf[5]; + WINDOW *wbody = bodywin(); + int field = 50; + int i; + + for (i = 0; i < 5; i++) + { + fieldbuf[i] = calloc(1, field + 1); + } + + if (getstrings(g_fieldname, fieldbuf, field) != KEY_ESC) + { + for (i = 0; g_fieldname[i]; i++) + { + wprintw(wbody, "%10s : %s\n", g_fieldname[i], fieldbuf[i]); + } + + wrefresh(wbody); + } + + for (i = 0; i < 5; i++) + { + free(fieldbuf[i]); + } +} + +static char *getfname(char *desc, char *fname, int field) +{ + char *g_fieldname[2]; + char *fieldbuf[1]; + + g_fieldname[0] = desc; + g_fieldname[1] = 0; + fieldbuf[0] = fname; + + return (getstrings(g_fieldname, fieldbuf, field) == KEY_ESC) ? NULL : fname; +} + +static void showfile(char *fname) +{ + FILE *fp; + char buf[MAXSTRLEN]; + bool ateof = false; + int bh = bodylen(); + int i; + + statusmsg("FileBrowser: Hit key to continue, Q to quit"); + + if ((fp = fopen(fname, "r")) != NULL) /* file available? */ + { + while (!ateof) + { + clsbody(); + + for (i = 0; i < bh - 1 && !ateof; i++) + { + buf[0] = '\0'; + fgets(buf, MAXSTRLEN, fp); + + if (strlen(buf)) + { + bodymsg(buf); + } + else + { + ateof = true; + } + } + + switch (waitforkey()) + { + case 'Q': + case 'q': + case 0x1b: + ateof = true; + break; + } + } + + fclose(fp); + } + else + { + sprintf(buf, "ERROR: file '%s' not found", fname); + errormsg(buf); + } +} + +static void sub0(void) +{ + domenu(g_submenu0); +} + +static void sub1(void) +{ + domenu(g_submenu1); +} + +static void sub2(void) +{ + domenu(g_submenu2); +} + +static void sub3(void) +{ + domenu(g_submenu3); +} + +static void func1(void) +{ + beep(); + bodymsg("One beep! "); +} + +static void func2(void) +{ + beep(); + bodymsg("Two beeps! "); + beep(); +} + +static void subfunc1(void) +{ + showfile(FNAME); +} + +static void subfunc2(void) +{ + char fname[MAXSTRLEN]; + + strcpy(fname, FNAME); + if (getfname("File to browse:", fname, 50)) + { + showfile(fname); + } +} + +static void subsub(void) +{ + domenu(g_submenu2); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int tui_main(int argc, char *argv[]) +#endif +{ + setlocale(LC_ALL, ""); + + startmenu(g_mainmenu, "TUI - 'textual user interface' demonstration program"); + return 0; +} diff --git a/examples/pdcurses/worm_main.c b/examples/pdcurses/worm_main.c new file mode 100644 index 000000000..4fb971b60 --- /dev/null +++ b/examples/pdcurses/worm_main.c @@ -0,0 +1,929 @@ +/**************************************************************************** + * apps/examples/pdcurses/rain_main.c + * $Id: worm.c,v 1.16 2008/07/13 16:08:17 wmcbrine Exp $ + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Copyright (c) 2005 Free Software Foundation, Inc. + * Adapted by: Gregory Nutt + * + * Adapted from the original public domain pdcurses by Gregory Nutt and + * released as part of NuttX under the origin ncurses license: + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, distribute with modifications, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name(s) of the above copyright + * holders shall not be used in advertising or otherwise to promote the + * sale, use or other dealings in this Software without prior written + * authorization. + * + ****************************************************************************/ + +/* + * @@@ @@@ @@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@ + * @@@ @@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@ + * @@@ @@@ @@@@ @@@@ @@@@ @@@@ @@@ @@@@ + * @@@ @@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ + * @@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ + * @@@@ @@@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@ + * @@@@@@@@@@@@ @@@@ @@@@ @@@ @@@ @@@ @@@ + * @@@@ @@@@ @@@@@@@@@@@@ @@@ @@@ @@@ @@@ + * @@ @@ @@@@@@@@@@ @@@ @@@ @@@ @@@ + * + * Eric P. Scott + * Caltech High Energy Physics + * October, 1980 + * + * Color by Eric S. Raymond + * July, 1995 + * + * Options: + * -f fill screen with copies of 'WORM' at start. + * -l set worm length + * -n set number of worms + * -t make worms leave droppings + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include "graphics/curses.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define FLAVORS 7 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct worm +{ + int orientation, head; + short *xpos, *ypos; +}; + +struct options +{ + int nopts; + int opts[3]; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const chtype flavor[FLAVORS] = +{ + 'O', '*', '#', '$', '%', '0', '@' +}; + +static const short xinc[] = +{ + 1, 1, 1, 0, -1, -1, -1, 0 +}; + +static const short yinc[] = +{ + -1, 0, 1, 1, 1, 0, -1, -1 +}; + +static struct worm worm[40]; +static const char *field; +static int length = 16; +static int number = 3; +static chtype trail = ' '; + +static const struct options normal[8] = +{ + { + 3, + { + 7, 0, 1 + } + }, + { + 3, + { + 0, 1, 2 + } + }, + { + 3, + { + 1, 2, 3 + } + }, + { + 3, + { + 2, 3, 4 + } + }, + { + 3, + { + 3, 4, 5 + } + }, + { + 3, + { + 4, 5, 6 + } + }, + { + 3, + { + 5, 6, 7 + } + }, + { + 3, + { + 6, 7, 0 + } + } +}; + +static const struct options upper[8] = +{ + { + 1, + { + 1, 0, 0 + } + }, + { + 2, + { + 1, 2, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 2, + { + 4, 5, 0 + } + }, + { + 1, + { + 5, 0, 0 + } + }, + { + 2, + { + 1, 5, 0 + } + } +}; + +static const struct options left[8] = +{ + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 2, + { + 2, 3, 0 + } + }, + { + 1, + { + 3, 0, 0 + } + }, + { + 2, + { + 3, 7, 0 + } + }, + { + 1, + { + 7, 0, 0 + } + }, + { + 2, + { + 7, 0, 0 + } + } +}; + +static const struct options right[8] = +{ + { + 1, + { + 7, 0, 0 + } + }, + { + 2, + { + 3, 7, 0 + } + }, + { + 1, + { + 3, 0, 0 + } + }, + { + 2, + { + 3, 4, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 2, + { + 6, 7, 0 + } + } +}; + +static const struct options lower[8] = +{ + { + 0, + { + 0, 0, 0 + } + }, + { + 2, + { + 0, 1, 0 + } + }, + { + 1, + { + 1, 0, 0 + } + }, + { + 2, + { + 1, 5, 0 + } + }, + { + 1, + { + 5, 0, 0 + } + }, + { + 2, + { + 5, 6, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + } +}; + +static const struct options upleft[8] = +{ + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 1, + { + 3, 0, 0 + } + }, + { + 2, + { + 1, 3, 0 + } + }, + { + 1, + { + 1, 0, 0 + } + } +}; + +static const struct options upright[8] = +{ + { + 2, + { + 3, 5, 0 + } + }, + { + 1, + { + 3, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 1, + { + 5, 0, 0 + } + } +}; + +static const struct options lowleft[8] = +{ + { + 3, + { + 7, 0, 1 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 1, + { + 1, 0, 0 + } + }, + { + 2, + { + 1, 7, 0 + } + }, + { + 1, + { + 7, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + } +}; + +static const struct options lowright[8] = +{ + { + 0, + { + 0, 0, 0 + } + }, + { + 1, + { + 7, 0, 0 + } + }, + { + 2, + { + 5, 7, 0 + } + }, + { + 1, + { + 5, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + }, + { + 0, + { + 0, 0, 0 + } + } +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static void cleanup(void) +{ + standend(); + refresh(); + curs_set(1); + endwin(); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int worm_main(int argc, char *argv[]) +#endif +{ + const struct options *op; + struct worm *w; + short **ref, *ip; + int x, y, n, h, last, bottom, seed; + + for (x = 1; x < argc; x++) + { + char *p = argv[x]; + + if (*p == '-') + { + p++; + } + + switch (*p) + { + case 'f': + field = "WORM"; + break; + + case 'l': + if (++x == argc) + { + goto usage; + } + + if ((length = atoi(argv[x])) < 2 || length > 1024) + { + fprintf(stderr, "%s: Invalid length\n", *argv); + return EXIT_FAILURE; + } + + break; + + case 'n': + if (++x == argc) + { + goto usage; + } + + if ((number = atoi(argv[x])) < 1 || number > 40) + { + fprintf(stderr, "%s: Invalid number of worms\n", *argv); + return EXIT_FAILURE; + } + + break; + + case 't': + trail = '.'; + break; + + default: + usage: + fprintf(stderr, "usage: %s [-field] [-length #] " + "[-number #] [-trail]\n", *argv); + return EXIT_FAILURE; + } + } + + initscr(); + seed = time((time_t *) 0); + srand(seed); + + noecho(); + cbreak(); + nonl(); + keypad(stdscr, true); + + curs_set(0); + + bottom = LINES - 1; + last = COLS - 1; + +#ifdef A_COLOR + if (has_colors()) + { + int bg = COLOR_BLACK; + start_color(); + +# if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000) + if (use_default_colors() == OK) + { + bg = -1; + } +# endif + +# define SET_COLOR(num, fg) \ + init_pair(num + 1, fg, bg); \ + flavor[num] |= COLOR_PAIR(num + 1) | A_BOLD + + SET_COLOR(0, COLOR_GREEN); + SET_COLOR(1, COLOR_RED); + SET_COLOR(2, COLOR_CYAN); + SET_COLOR(3, COLOR_WHITE); + SET_COLOR(4, COLOR_MAGENTA); + SET_COLOR(5, COLOR_BLUE); + SET_COLOR(6, COLOR_YELLOW); + } +#endif + + ref = malloc(sizeof(short *) * LINES); + + for (y = 0; y < LINES; y++) + { + ref[y] = malloc(sizeof(short) * COLS); + + for (x = 0; x < COLS; x++) + { + ref[y][x] = 0; + } + } + +#ifdef BADCORNER + /* if addressing the lower right corner doesn't work in your curses */ + + ref[bottom][last] = 1; +#endif + + for (n = number, w = &worm[0]; --n >= 0; w++) + { + w->orientation = w->head = 0; + + if ((ip = malloc(sizeof(short) * (length + 1))) == NULL) + { + fprintf(stderr, "%s: out of memory\n", *argv); + return EXIT_FAILURE; + } + + w->xpos = ip; + + for (x = length; --x >= 0;) + { + *ip++ = -1; + } + + if ((ip = malloc(sizeof(short) * (length + 1))) == NULL) + { + fprintf(stderr, "%s: out of memory\n", *argv); + return EXIT_FAILURE; + } + + w->ypos = ip; + + for (y = length; --y >= 0;) + { + *ip++ = -1; + } + } + + if (field) + { + const char *p = field; + + for (y = bottom; --y >= 0;) + { + for (x = COLS; --x >= 0;) + { + addch((chtype) (*p++)); + + if (!*p) + { + p = field; + } + } + } + } + + napms(12); + refresh(); + nodelay(stdscr, true); + + for (;;) + { + int ch; + + if ((ch = getch()) > 0) + { +#ifdef KEY_RESIZE + if (ch == KEY_RESIZE) + { + resize_term(0, 0); + erase(); + + if (last != COLS - 1) + { + for (y = 0; y <= bottom; y++) + { + ref[y] = realloc(ref[y], sizeof(short) * COLS); + + for (x = last + 1; x < COLS; x++) + { + ref[y][x] = 0; + } + } + + last = COLS - 1; + } + + if (bottom != LINES - 1) + { + for (y = LINES; y <= bottom; y++) + { + free(ref[y]); + } + + ref = realloc(ref, sizeof(short *) * LINES); + + for (y = bottom + 1; y < LINES; y++) + { + ref[y] = malloc(sizeof(short) * COLS); + + for (x = 0; x < COLS; x++) + { + ref[y][x] = 0; + } + } + + bottom = LINES - 1; + } + } + +#endif /* KEY_RESIZE */ + + /* Make it simple to put this into single-step mode, or resume normal + * operation - T. Dickey + */ + + if (ch == 'q') + { + cleanup(); + return EXIT_SUCCESS; + } + else if (ch == 's') + { + nodelay(stdscr, false); + } + else if (ch == ' ') + { + nodelay(stdscr, true); + } + } + + for (n = 0, w = &worm[0]; n < number; n++, w++) + { + if ((x = w->xpos[h = w->head]) < 0) + { + move(y = w->ypos[h] = bottom, x = w->xpos[h] = 0); + addch(flavor[n % FLAVORS]); + ref[y][x]++; + } + else + { + y = w->ypos[h]; + } + + if (x > last) + { + x = last; + } + + if (y > bottom) + { + y = bottom; + } + + + if (++h == length) + { + h = 0; + } + + if (w->xpos[w->head = h] >= 0) + { + int x1 = w->xpos[h]; + int y1 = w->ypos[h]; + + if (y1 < LINES && x1 < COLS && --ref[y1][x1] == 0) + { + move(y1, x1); + addch(trail); + } + } + + op = &(x == 0 ? (y == 0 ? upleft : + (y == bottom ? lowleft : left)) : + (x == last ? (y == 0 ? upright : + (y == bottom ? lowright : right)) : + (y == 0 ? upper : + (y == bottom ? lower : normal))))[w->orientation]; + + switch (op->nopts) + { + case 0: + cleanup(); + return EXIT_SUCCESS; + + case 1: + w->orientation = op->opts[0]; + break; + + default: + w->orientation = op->opts[rand() % op->nopts]; + break; + } + + move(y += yinc[w->orientation], x += xinc[w->orientation]); + + if (y < 0) + { + y = 0; + } + + addch(flavor[n % FLAVORS]); + ref[w->ypos[h] = y][w->xpos[h] = x]++; + } + + napms(12); + refresh(); + } +} diff --git a/examples/pdcurses/xmas_main.c b/examples/pdcurses/xmas_main.c new file mode 100644 index 000000000..b53019c26 --- /dev/null +++ b/examples/pdcurses/xmas_main.c @@ -0,0 +1,1083 @@ +/**************************************************************************** + * apps/examples/pdcurses/tui.c + * December 1989, Larry Bartz, Indianapolis, IN + * $Id: xmas.c,v 1.29 2008/07/13 16:08:17 wmcbrine Exp $ + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Adapted by: Gregory Nutt + * + * Adapted from the original public domain pdcurses by Gregory Nutt and + * released as part of NuttX under the 3-clause BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/* 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)! + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include "graphics/curses.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define FROMWHO "From Larry Bartz, Mark Hessling and William McBrine" + +#define TSHOW(win, pause) touchwin(win); wrefresh(win); \ + wrefresh(w_del_msg); napms(pause) + +#define SHOW(win, pause) mvwin(win, y_pos, x_pos); wrefresh(win); \ + wrefresh(w_del_msg); napms(pause) + + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static void lil(WINDOW *); +static void midtop(WINDOW *); +static void bigtop(WINDOW *); +static void bigface(WINDOW *, chtype); +static void legs1(WINDOW *); +static void legs2(WINDOW *); +static void legs3(WINDOW *); +static void legs4(WINDOW *); +static void initdeer(void); +static void boxit(void); +static void seas(void); +static void greet(void); +static void fromwho(void); +static void del_msg(void); +static void tree(void); +static void balls(void); +static void star(void); +static void strng1(void); +static void strng2(void); +static void strng3(void); +static void strng4(void); +static void strng5(void); +static void blinkit(void); +static void reindeer(void); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static int x_pos; +static int y_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; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static void lil(WIDNOW *win) +{ + mvwaddch(win, 0, 0, (chtype) 'V'); + mvwaddch(win, 1, 0, (chtype) '@'); + mvwaddch(win, 1, 3, (chtype) '~'); +} + +static void midtop(WIDNOW *win) +{ + mvwaddstr(win, 0, 2, "yy"); + mvwaddstr(win, 1, 2, "0(=)~"); +} + +static void bigtop(WIDNOW *win) +{ + mvwaddstr(win, 0, 17, "\\/"); + mvwaddstr(win, 0, 20, "\\/"); + mvwaddch(win, 1, 18, (chtype) '\\'); + mvwaddch(win, 1, 20, (chtype) '/'); + mvwaddstr(win, 2, 19, "|_"); + mvwaddstr(win, 3, 18, "/^0\\"); + mvwaddstr(win, 4, 17, "//\\"); + mvwaddch(win, 4, 22, (chtype) '\\'); + mvwaddstr(win, 5, 7, "^~~~~~~~~// ~~U"); +} + +static void bigface(WIDNOW *win, chtype noseattr) +{ + mvwaddstr(win, 0, 16, "\\/ \\/"); + mvwaddstr(win, 1, 17, "\\Y/ \\Y/"); + mvwaddstr(win, 2, 19, "\\=/"); + mvwaddstr(win, 3, 17, "^\\o o/^"); + mvwaddstr(win, 4, 17, "//( )"); + mvwaddstr(win, 5, 7, "^~~~~~~~~// \\"); + waddch(win, 'O' | noseattr); + waddstr(win, "/"); +} + +static void legs1(WIDNOW *win) +{ + mvwaddstr(win, 6, 7, "( \\_____( /"); + mvwaddstr(win, 7, 8, "( ) /"); + mvwaddstr(win, 8, 9, "\\\\ /"); + mvwaddstr(win, 9, 11, "\\>/>"); +} + +static void legs2(WIDNOW *win) +{ + mvwaddstr(win, 6, 7, "(( )____( /"); + mvwaddstr(win, 7, 7, "( / |"); + mvwaddstr(win, 8, 8, "\\/ |"); + mvwaddstr(win, 9, 9, "|> |>"); +} + +static void legs3(WIDNOW *win) +{ + mvwaddstr(win, 6, 6, "( ()_____( /"); + mvwaddstr(win, 7, 6, "/ / /"); + mvwaddstr(win, 8, 5, "|/ \\"); + mvwaddstr(win, 9, 5, "/> \\>"); +} + +static void legs4(WIDNOW *win) +{ + mvwaddstr(win, 6, 6, "( )______( /"); + mvwaddstr(win, 7, 5, "(/ \\"); + mvwaddstr(win, 8, 0, "v___= ----^"); +} + +static void initdeer(void) +{ + chtype noseattr; + +#ifdef A_COLOR + if (has_colors()) + { + init_pair(31, COLOR_RED, COLOR_BLACK); + noseattr = COLOR_PAIR(31); + } + else +#endif + { + noseattr = A_NORMAL; + } + + /* set up the windows for our various reindeer */ + + dotdeer0 = newwin(3, 71, 0, 8); + stardeer0 = newwin(4, 56, 0, 8); + lildeer0 = newwin(7, 54, 0, 8); + middeer0 = newwin(15, 42, 0, 8); + bigdeer0 = newwin(10, 23, 0, 0); + lookdeer0 = newwin(10, 25, 0, 0); + + /* lildeer1 */ + + lildeer1 = newwin(2, 4, 0, 0); + lil(lildeer1); + mvwaddstr(lildeer1, 1, 1, "<>"); + + /* lildeer2 */ + + lildeer2 = newwin(2, 4, 0, 0); + lil(lildeer2); + mvwaddstr(lildeer2, 1, 1, "||"); + + /* lildeer3 */ + + lildeer3 = newwin(2, 4, 0, 0); + lil(lildeer3); + mvwaddstr(lildeer3, 1, 1, "><"); + + /* middeer1 */ + + middeer1 = newwin(3, 7, 0, 0); + midtop(middeer1); + mvwaddstr(middeer1, 2, 3, "\\/"); + + /* middeer2 */ + + middeer2 = newwin(3, 7, 0, 0); + midtop(middeer2); + mvwaddch(middeer2, 2, 3, (chtype) '|'); + mvwaddch(middeer2, 2, 5, (chtype) '|'); + + /* middeer3 */ + + middeer3 = newwin(3, 7, 0, 0); + midtop(middeer3); + mvwaddch(middeer3, 2, 2, (chtype) '/'); + mvwaddch(middeer3, 2, 6, (chtype) '\\'); + + /* bigdeer1 */ + + bigdeer1 = newwin(10, 23, 0, 0); + bigtop(bigdeer1); + legs1(bigdeer1); + + /* bigdeer2 */ + + bigdeer2 = newwin(10, 23, 0, 0); + bigtop(bigdeer2); + legs2(bigdeer2); + + /* bigdeer3 */ + + bigdeer3 = newwin(10, 23, 0, 0); + bigtop(bigdeer3); + legs3(bigdeer3); + + /* bigdeer4 */ + + bigdeer4 = newwin(10, 23, 0, 0); + bigtop(bigdeer4); + legs4(bigdeer4); + + /* lookdeer1 */ + + lookdeer1 = newwin(10, 25, 0, 0); + bigface(lookdeer1, noseattr); + legs1(lookdeer1); + + /* lookdeer2 */ + + lookdeer2 = newwin(10, 25, 0, 0); + bigface(lookdeer2, noseattr); + legs2(lookdeer2); + + /* lookdeer3 */ + + lookdeer3 = newwin(10, 25, 0, 0); + bigface(lookdeer3, noseattr); + legs3(lookdeer3); + + /* lookdeer4 */ + + lookdeer4 = newwin(10, 25, 0, 0); + bigface(lookdeer4, noseattr); + legs4(lookdeer4); +} + +static void boxit(void) +{ + int x; + + for (x = 0; x < 20; ++x) + { + mvaddch(x, 7, '|'); + } + + for (x = 0; x < 80; ++x) + { + if (x > 7) + { + mvaddch(19, x, '_'); + } + + mvaddch(22, x, '_'); + } +} + +static void seas(void) +{ + mvaddch(4, 1, 'S'); + mvaddch(6, 1, 'E'); + mvaddch(8, 1, 'A'); + mvaddch(10, 1, 'S'); + mvaddch(12, 1, 'O'); + mvaddch(14, 1, 'N'); + mvaddch(16, 1, '`'); + mvaddch(18, 1, 'S'); +} + +static void greet(void) +{ + mvaddch(3, 5, 'G'); + mvaddch(5, 5, 'R'); + mvaddch(7, 5, 'E'); + mvaddch(9, 5, 'E'); + mvaddch(11, 5, 'T'); + mvaddch(13, 5, 'I'); + mvaddch(15, 5, 'N'); + mvaddch(17, 5, 'G'); + mvaddch(19, 5, 'S'); +} + +static void fromwho(void) +{ + mvaddstr(21, 13, FROMWHO); +} + +static void del_msg(void) +{ + refresh(); +} + +static void tree(void) +{ +#ifdef A_COLOR + if (has_colors()) + { + init_pair(30, COLOR_GREEN, COLOR_BLACK); + wattrset(treescrn, COLOR_PAIR(30)); + } +#endif + + mvwaddch(treescrn, 1, 11, (chtype) '/'); + mvwaddch(treescrn, 2, 11, (chtype) '/'); + mvwaddch(treescrn, 3, 10, (chtype) '/'); + mvwaddch(treescrn, 4, 9, (chtype) '/'); + mvwaddch(treescrn, 5, 9, (chtype) '/'); + mvwaddch(treescrn, 6, 8, (chtype) '/'); + mvwaddch(treescrn, 7, 7, (chtype) '/'); + mvwaddch(treescrn, 8, 6, (chtype) '/'); + mvwaddch(treescrn, 9, 6, (chtype) '/'); + mvwaddch(treescrn, 10, 5, (chtype) '/'); + mvwaddch(treescrn, 11, 3, (chtype) '/'); + mvwaddch(treescrn, 12, 2, (chtype) '/'); + + mvwaddch(treescrn, 1, 13, (chtype) '\\'); + mvwaddch(treescrn, 2, 13, (chtype) '\\'); + mvwaddch(treescrn, 3, 14, (chtype) '\\'); + mvwaddch(treescrn, 4, 15, (chtype) '\\'); + mvwaddch(treescrn, 5, 15, (chtype) '\\'); + mvwaddch(treescrn, 6, 16, (chtype) '\\'); + mvwaddch(treescrn, 7, 17, (chtype) '\\'); + mvwaddch(treescrn, 8, 18, (chtype) '\\'); + mvwaddch(treescrn, 9, 18, (chtype) '\\'); + mvwaddch(treescrn, 10, 19, (chtype) '\\'); + mvwaddch(treescrn, 11, 21, (chtype) '\\'); + mvwaddch(treescrn, 12, 22, (chtype) '\\'); + + mvwaddch(treescrn, 4, 10, (chtype) '_'); + mvwaddch(treescrn, 4, 14, (chtype) '_'); + mvwaddch(treescrn, 8, 7, (chtype) '_'); + mvwaddch(treescrn, 8, 17, (chtype) '_'); + + mvwaddstr(treescrn, 13, 0, "//////////// \\\\\\\\\\\\\\\\\\\\\\\\"); + +#ifdef A_COLOR + if (has_colors()) + { + init_pair(20, COLOR_YELLOW, COLOR_BLACK); + wattrset(treescrn, COLOR_PAIR(20)); + } +#endif + + mvwaddstr(treescrn, 14, 11, "| |"); + mvwaddstr(treescrn, 15, 11, "|_|"); + + wrefresh(treescrn); + wrefresh(w_del_msg); +} + +static void balls(void) +{ + chtype ball1, ball2, ball3, ball4, ball5, ball6; + + overlay(treescrn, treescrn2); + +#ifdef A_COLOR + if (has_colors()) + { + init_pair(1, COLOR_BLUE, COLOR_BLACK); + init_pair(2, COLOR_RED, COLOR_BLACK); + init_pair(3, COLOR_MAGENTA, COLOR_BLACK); + init_pair(4, COLOR_CYAN, COLOR_BLACK); + init_pair(5, COLOR_YELLOW, COLOR_BLACK); + init_pair(6, COLOR_WHITE, COLOR_BLACK); + ball1 = COLOR_PAIR(1) | '@'; + ball2 = COLOR_PAIR(2) | '@'; + ball3 = COLOR_PAIR(3) | '@'; + ball4 = COLOR_PAIR(4) | '@'; + ball5 = COLOR_PAIR(5) | '@'; + ball6 = COLOR_PAIR(6) | '@'; + } + else +#endif + { + ball1 = ball2 = ball3 = ball4 = ball5 = ball6 = '@'; + } + + mvwaddch(treescrn2, 3, 9, ball1); + mvwaddch(treescrn2, 3, 15, ball2); + mvwaddch(treescrn2, 4, 8, ball3); + mvwaddch(treescrn2, 4, 16, ball4); + mvwaddch(treescrn2, 5, 7, ball5); + mvwaddch(treescrn2, 5, 17, ball6); + mvwaddch(treescrn2, 7, 6, ball1 | A_BOLD); + mvwaddch(treescrn2, 7, 18, ball2 | A_BOLD); + mvwaddch(treescrn2, 8, 5, ball3 | A_BOLD); + mvwaddch(treescrn2, 8, 19, ball4 | A_BOLD); + mvwaddch(treescrn2, 10, 4, ball5 | A_BOLD); + mvwaddch(treescrn2, 10, 20, ball6 | A_BOLD); + mvwaddch(treescrn2, 11, 2, ball1); + mvwaddch(treescrn2, 11, 22, ball2); + mvwaddch(treescrn2, 12, 1, ball3); + mvwaddch(treescrn2, 12, 23, ball4); + + wrefresh(treescrn2); + wrefresh(w_del_msg); +} + +static void star(void) +{ + mvwaddch(treescrn2, 0, 12, (chtype) '*' | A_STANDOUT); + + wrefresh(treescrn2); + wrefresh(w_del_msg); +} + +static void strng1(void) +{ +#ifdef A_COLOR + if (has_colors()) + { + init_pair(10, COLOR_YELLOW, COLOR_BLACK); + wattrset(treescrn2, COLOR_PAIR(10) | A_BOLD); + } +#endif + + mvwaddstr(treescrn2, 3, 11, ".:'"); + wrefresh(treescrn2); + wrefresh(w_del_msg); +} + +static void strng2(void) +{ +#ifdef A_COLOR + if (has_colors()) + { + init_pair(11, COLOR_RED, COLOR_BLACK); + wattrset(treescrn2, COLOR_PAIR(11) | A_BOLD); + } +#endif + + mvwaddstr(treescrn2, 5, 11, ",.:'"); + mvwaddstr(treescrn2, 6, 9, ":'"); + + wrefresh(treescrn2); + wrefresh(w_del_msg); +} + +static void strng3(void) +{ +#ifdef A_COLOR + if (has_colors()) + { + init_pair(12, COLOR_GREEN, COLOR_BLACK); + wattrset(treescrn2, COLOR_PAIR(12) | A_BOLD); + } +#endif + + mvwaddstr(treescrn2, 7, 13, ",.:'"); + mvwaddstr(treescrn2, 8, 9, ",.:'"); + + wrefresh(treescrn2); + wrefresh(w_del_msg); +} + +static void strng4(void) +{ +#ifdef A_COLOR + if (has_colors()) + { + init_pair(13, COLOR_WHITE, COLOR_BLACK); + wattrset(treescrn2, COLOR_PAIR(13) | A_BOLD); + } +#endif + + mvwaddstr(treescrn2, 9, 14, ",.:'"); + mvwaddstr(treescrn2, 10, 10, ",.:'"); + mvwaddstr(treescrn2, 11, 6, ",.:'"); + mvwaddch(treescrn2, 12, 5, (chtype) '\''); + + wrefresh(treescrn2); + wrefresh(w_del_msg); +} + +static void strng5(void) +{ +#ifdef A_COLOR + if (has_colors()) + { + init_pair(14, COLOR_CYAN, COLOR_BLACK); + wattrset(treescrn2, COLOR_PAIR(14) | A_BOLD); + } +#endif + + mvwaddstr(treescrn2, 11, 16, ",.:'"); + mvwaddstr(treescrn2, 12, 12, ",.:'"); + + /* Save a fully lit tree */ + + overlay(treescrn2, treescrn); + + wrefresh(treescrn2); + wrefresh(w_del_msg); +} + +static void blinkit(void) +{ + static int cycle; + + if (cycle > 4) + { + cycle = 0; + } + + touchwin(treescrn8); + + switch (cycle) + { + case 0: + overlay(treescrn3, treescrn8); + break; + + case 1: + overlay(treescrn4, treescrn8); + break; + + case 2: + overlay(treescrn5, treescrn8); + break; + + case 3: + overlay(treescrn6, treescrn8); + break; + + case 4: + overlay(treescrn7, treescrn8); + break; + } + + wrefresh(treescrn8); + wrefresh(w_del_msg); + + napms(50); + touchwin(treescrn8); + + /* ALL ON ************************************************** */ + + overlay(treescrn, treescrn8); + wrefresh(treescrn8); + wrefresh(w_del_msg); + + ++cycle; +} + +static void reindeer(void) +{ + int looper; + + y_pos = 0; + + for (x_pos = 70; x_pos > 62; x_pos--) + { + if (x_pos < 62) + { + y_pos = 1; + } + + for (looper = 0; looper < 4; looper++) + { + mvwaddch(dotdeer0, y_pos, x_pos, (chtype) '.'); + wrefresh(dotdeer0); + wrefresh(w_del_msg); + werase(dotdeer0); + wrefresh(dotdeer0); + wrefresh(w_del_msg); + } + } + + y_pos = 2; + + for (; x_pos > 50; x_pos--) + { + for (looper = 0; looper < 4; looper++) + { + if (x_pos < 56) + { + y_pos = 3; + + mvwaddch(stardeer0, y_pos, x_pos, (chtype) '*'); + wrefresh(stardeer0); + wrefresh(w_del_msg); + werase(stardeer0); + wrefresh(stardeer0); + } + else + { + mvwaddch(dotdeer0, y_pos, x_pos, (chtype) '*'); + wrefresh(dotdeer0); + wrefresh(w_del_msg); + werase(dotdeer0); + wrefresh(dotdeer0); + } + + wrefresh(w_del_msg); + } + } + + x_pos = 58; + + for (y_pos = 2; y_pos < 5; y_pos++) + { + TSHOW(lildeer0, 50); + + for (looper = 0; looper < 4; looper++) + { + SHOW(lildeer3, 50); + SHOW(lildeer2, 50); + SHOW(lildeer1, 50); + SHOW(lildeer2, 50); + SHOW(lildeer3, 50); + + TSHOW(lildeer0, 50); + + x_pos -= 2; + } + } + + x_pos = 35; + + for (y_pos = 5; y_pos < 10; y_pos++) + { + touchwin(middeer0); + wrefresh(middeer0); + wrefresh(w_del_msg); + + for (looper = 0; looper < 2; looper++) + { + SHOW(middeer3, 50); + SHOW(middeer2, 50); + SHOW(middeer1, 50); + SHOW(middeer2, 50); + SHOW(middeer3, 50); + + TSHOW(middeer0, 50); + + x_pos -= 3; + } + } + + napms(2000); + + y_pos = 1; + + for (x_pos = 8; x_pos < 16; x_pos++) + { + SHOW(bigdeer4, 30); + SHOW(bigdeer3, 30); + SHOW(bigdeer2, 30); + SHOW(bigdeer1, 30); + SHOW(bigdeer2, 30); + SHOW(bigdeer3, 30); + SHOW(bigdeer4, 30); + SHOW(bigdeer0, 30); + } + + --x_pos; + + for (looper = 0; looper < 6; looper++) + { + SHOW(lookdeer4, 40); + SHOW(lookdeer3, 40); + SHOW(lookdeer2, 40); + SHOW(lookdeer1, 40); + SHOW(lookdeer2, 40); + SHOW(lookdeer3, 40); + SHOW(lookdeer4, 40); + } + + SHOW(lookdeer0, 40); + + for (; y_pos < 10; y_pos++) + { + for (looper = 0; looper < 2; looper++) + { + SHOW(bigdeer4, 30); + SHOW(bigdeer3, 30); + SHOW(bigdeer2, 30); + SHOW(bigdeer1, 30); + SHOW(bigdeer2, 30); + SHOW(bigdeer3, 30); + SHOW(bigdeer4, 30); + } + + SHOW(bigdeer0, 30); + } + + --y_pos; + + mvwin(lookdeer3, y_pos, x_pos); + wrefresh(lookdeer3); + wrefresh(w_del_msg); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int xmas_main(int argc, char *argv[]) +#endif +{ + int loopy; + + initscr(); + nodelay(stdscr, true); + noecho(); + nonl(); + refresh(); + +#ifdef A_COLOR + if (has_colors()) + { + start_color(); + } +#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); + + w_holiday = newwin(1, 26, 3, 27); + + w_del_msg = newwin(1, 12, 23, 60); + + mvwaddstr(w_holiday, 0, 0, "H A P P Y H O L I D A Y S"); + + initdeer(); + + clear(); + werase(treescrn); + touchwin(treescrn); + werase(treescrn2); + touchwin(treescrn2); + werase(treescrn8); + touchwin(treescrn8); + refresh(); + napms(1000); + + boxit(); + del_msg(); + napms(1000); + + seas(); + del_msg(); + napms(1000); + + greet(); + del_msg(); + napms(1000); + + fromwho(); + del_msg(); + napms(1000); + + tree(); + napms(1000); + + balls(); + napms(1000); + + star(); + napms(1000); + + strng1(); + strng2(); + strng3(); + strng4(); + strng5(); + + /* set up the windows for our blinking trees */ + /* treescrn3 */ + + overlay(treescrn, treescrn3); + + /* balls */ + + mvwaddch(treescrn3, 4, 18, ' '); + mvwaddch(treescrn3, 7, 6, ' '); + mvwaddch(treescrn3, 8, 19, ' '); + mvwaddch(treescrn3, 11, 22, ' '); + + /* star */ + + mvwaddch(treescrn3, 0, 12, '*'); + + /* strng1 */ + + mvwaddch(treescrn3, 3, 11, ' '); + + /* strng2 */ + + mvwaddch(treescrn3, 5, 13, ' '); + mvwaddch(treescrn3, 6, 10, ' '); + + /* strng3 */ + + mvwaddch(treescrn3, 7, 16, ' '); + mvwaddch(treescrn3, 7, 14, ' '); + + /* strng4 */ + + mvwaddch(treescrn3, 10, 13, ' '); + mvwaddch(treescrn3, 10, 10, ' '); + mvwaddch(treescrn3, 11, 8, ' '); + + /* strng5 */ + + mvwaddch(treescrn3, 11, 18, ' '); + mvwaddch(treescrn3, 12, 13, ' '); + + /* treescrn4 */ + + overlay(treescrn, treescrn4); + + /* balls */ + + mvwaddch(treescrn4, 3, 9, ' '); + mvwaddch(treescrn4, 4, 16, ' '); + mvwaddch(treescrn4, 7, 6, ' '); + mvwaddch(treescrn4, 8, 19, ' '); + mvwaddch(treescrn4, 11, 2, ' '); + mvwaddch(treescrn4, 12, 23, ' '); + + /* star */ + + mvwaddch(treescrn4, 0, 12, '*' | A_STANDOUT); + + /* strng1 */ + + mvwaddch(treescrn4, 3, 13, ' '); + + /* strng2 */ + + /* strng3 */ + + mvwaddch(treescrn4, 7, 15, ' '); + mvwaddch(treescrn4, 8, 11, ' '); + + /* strng4 */ + + mvwaddch(treescrn4, 9, 16, ' '); + mvwaddch(treescrn4, 10, 12, ' '); + mvwaddch(treescrn4, 11, 8, ' '); + + /* strng5 */ + + mvwaddch(treescrn4, 11, 18, ' '); + mvwaddch(treescrn4, 12, 14, ' '); + + /* treescrn5 */ + + overlay(treescrn, treescrn5); + + /* balls */ + + mvwaddch(treescrn5, 3, 15, ' '); + mvwaddch(treescrn5, 10, 20, ' '); + mvwaddch(treescrn5, 12, 1, ' '); + + /* star */ + + mvwaddch(treescrn5, 0, 12, '*'); + + /* strng1 */ + + mvwaddch(treescrn5, 3, 11, ' '); + + /* strng2 */ + + mvwaddch(treescrn5, 5, 12, ' '); + + /* strng3 */ + + mvwaddch(treescrn5, 7, 14, ' '); + mvwaddch(treescrn5, 8, 10, ' '); + + /* strng4 */ + + mvwaddch(treescrn5, 9, 15, ' '); + mvwaddch(treescrn5, 10, 11, ' '); + mvwaddch(treescrn5, 11, 7, ' '); + + /* strng5 */ + + mvwaddch(treescrn5, 11, 17, ' '); + mvwaddch(treescrn5, 12, 13, ' '); + + /* treescrn6 */ + + overlay(treescrn, treescrn6); + + /* balls */ + + mvwaddch(treescrn6, 6, 7, ' '); + mvwaddch(treescrn6, 7, 18, ' '); + mvwaddch(treescrn6, 10, 4, ' '); + mvwaddch(treescrn6, 11, 23, ' '); + + /* star */ + + mvwaddch(treescrn6, 0, 12, '*' | A_STANDOUT); + + /* strng1 */ + + /* strng2 */ + + mvwaddch(treescrn6, 5, 11, ' '); + + /* strng3 */ + + mvwaddch(treescrn6, 7, 13, ' '); + mvwaddch(treescrn6, 8, 9, ' '); + + /* strng4 */ + + mvwaddch(treescrn6, 9, 14, ' '); + mvwaddch(treescrn6, 10, 10, ' '); + mvwaddch(treescrn6, 11, 6, ' '); + + /* strng5 */ + + mvwaddch(treescrn6, 11, 16, ' '); + mvwaddch(treescrn6, 12, 12, ' '); + + /* treescrn7 */ + + overlay(treescrn, treescrn7); + + /* balls */ + + mvwaddch(treescrn7, 3, 15, ' '); + mvwaddch(treescrn7, 6, 7, ' '); + mvwaddch(treescrn7, 7, 18, ' '); + mvwaddch(treescrn7, 10, 4, ' '); + mvwaddch(treescrn7, 11, 22, ' '); + + /* star */ + + mvwaddch(treescrn7, 0, 12, '*'); + + /* strng1 */ + + mvwaddch(treescrn7, 3, 12, ' '); + + /* strng2 */ + + mvwaddch(treescrn7, 5, 13, ' '); + mvwaddch(treescrn7, 6, 9, ' '); + + /* strng3 */ + + mvwaddch(treescrn7, 7, 15, ' '); + mvwaddch(treescrn7, 8, 11, ' '); + + /* strng4 */ + + mvwaddch(treescrn7, 9, 16, ' '); + mvwaddch(treescrn7, 10, 12, ' '); + mvwaddch(treescrn7, 11, 8, ' '); + + /* strng5 */ + + mvwaddch(treescrn7, 11, 18, ' '); + mvwaddch(treescrn7, 12, 14, ' '); + + napms(1000); + reindeer(); + + touchwin(w_holiday); + wrefresh(w_holiday); + wrefresh(w_del_msg); + + napms(1000); + + for (loopy = 0; loopy < 50; loopy++) + { + blinkit(); + } + + clear(); + refresh(); + endwin(); + return 0; +} diff --git a/graphics/pdcurs34/pdcurses/pdc_addch.c b/graphics/pdcurs34/pdcurses/pdc_addch.c index 76c5c2de4..e067cb5a8 100644 --- a/graphics/pdcurs34/pdcurses/pdc_addch.c +++ b/graphics/pdcurs34/pdcurses/pdc_addch.c @@ -373,7 +373,7 @@ int mvaddch(int y, int x, const chtype ch) return waddch(stdscr, ch); } -int mvwaddch(WINDOW * win, int y, int x, const chtype ch) +int mvwaddch(WINDOW *win, int y, int x, const chtype ch) { PDC_LOG(("mvwaddch() - called: win=%p y=%d x=%d ch=%d\n", win, y, x, ch)); @@ -392,7 +392,7 @@ int echochar(const chtype ch) return wechochar(stdscr, ch); } -int wechochar(WINDOW * win, const chtype ch) +int wechochar(WINDOW *win, const chtype ch) { PDC_LOG(("wechochar() - called: win=%p ch=%x\n", win, ch)); @@ -404,7 +404,7 @@ int wechochar(WINDOW * win, const chtype ch) return wrefresh(win); } -int waddrawch(WINDOW * win, chtype ch) +int waddrawch(WINDOW *win, chtype ch) { PDC_LOG(("waddrawch() - called: win=%p ch=%x (text=%c attr=0x%x)\n", win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES)); @@ -436,7 +436,7 @@ int mvaddrawch(int y, int x, chtype ch) return waddrawch(stdscr, ch); } -int mvwaddrawch(WINDOW * win, int y, int x, chtype ch) +int mvwaddrawch(WINDOW *win, int y, int x, chtype ch) { PDC_LOG(("mvwaddrawch() - called: win=%p y=%d x=%d ch=%d\n", win, y, x, ch)); @@ -449,21 +449,21 @@ int mvwaddrawch(WINDOW * win, int y, int x, chtype ch) } #ifdef CONFIG_PDCURSES_WIDE -int wadd_wch(WINDOW * win, const cchar_t * wch) +int wadd_wch(WINDOW *win, const cchar_t *wch) { PDC_LOG(("wadd_wch() - called: win=%p wch=%x\n", win, *wch)); return wch ? waddch(win, *wch) : ERR; } -int add_wch(const cchar_t * wch) +int add_wch(const cchar_t *wch) { PDC_LOG(("add_wch() - called: wch=%x\n", *wch)); return wadd_wch(stdscr, wch); } -int mvadd_wch(int y, int x, const cchar_t * wch) +int mvadd_wch(int y, int x, const cchar_t *wch) { PDC_LOG(("mvaddch() - called: y=%d x=%d wch=%x\n", y, x, *wch)); @@ -475,7 +475,7 @@ int mvadd_wch(int y, int x, const cchar_t * wch) return wadd_wch(stdscr, wch); } -int mvwadd_wch(WINDOW * win, int y, int x, const cchar_t * wch) +int mvwadd_wch(WINDOW *win, int y, int x, const cchar_t *wch) { PDC_LOG(("mvwaddch() - called: win=%p y=%d x=%d wch=%d\n", win, y, x, *wch)); @@ -488,14 +488,14 @@ int mvwadd_wch(WINDOW * win, int y, int x, const cchar_t * wch) return wadd_wch(win, wch); } -int echo_wchar(const cchar_t * wch) +int echo_wchar(const cchar_t *wch) { PDC_LOG(("echo_wchar() - called: wch=%x\n", *wch)); return wecho_wchar(stdscr, wch); } -int wecho_wchar(WINDOW * win, const cchar_t * wch) +int wecho_wchar(WINDOW *win, const cchar_t *wch) { PDC_LOG(("wecho_wchar() - called: win=%p wch=%x\n", win, *wch)); diff --git a/graphics/pdcurs34/pdcurses/pdc_addchstr.c b/graphics/pdcurs34/pdcurses/pdc_addchstr.c index 919f64c7b..d0a0445f2 100644 --- a/graphics/pdcurs34/pdcurses/pdc_addchstr.c +++ b/graphics/pdcurs34/pdcurses/pdc_addchstr.c @@ -106,7 +106,7 @@ * Public Functions ****************************************************************************/ -int waddchnstr(WINDOW *win, const chtype * ch, int n) +int waddchnstr(WINDOW *win, const chtype *ch, int n) { int x; int y; @@ -162,28 +162,28 @@ int waddchnstr(WINDOW *win, const chtype * ch, int n) return OK; } -int addchstr(const chtype * ch) +int addchstr(const chtype *ch) { PDC_LOG(("addchstr() - called\n")); return waddchnstr(stdscr, ch, -1); } -int addchnstr(const chtype * ch, int n) +int addchnstr(const chtype *ch, int n) { PDC_LOG(("addchnstr() - called\n")); return waddchnstr(stdscr, ch, n); } -int waddchstr(WINDOW *win, const chtype * ch) +int waddchstr(WINDOW *win, const chtype *ch) { PDC_LOG(("waddchstr() - called: win=%p\n", win)); return waddchnstr(win, ch, -1); } -int mvaddchstr(int y, int x, const chtype * ch) +int mvaddchstr(int y, int x, const chtype *ch) { PDC_LOG(("mvaddchstr() - called: y %d x %d\n", y, x)); @@ -195,7 +195,7 @@ int mvaddchstr(int y, int x, const chtype * ch) return waddchnstr(stdscr, ch, -1); } -int mvaddchnstr(int y, int x, const chtype * ch, int n) +int mvaddchnstr(int y, int x, const chtype *ch, int n) { PDC_LOG(("mvaddchnstr() - called: y %d x %d n %d\n", y, x, n)); @@ -207,7 +207,7 @@ int mvaddchnstr(int y, int x, const chtype * ch, int n) return waddchnstr(stdscr, ch, n); } -int mvwaddchstr(WINDOW *win, int y, int x, const chtype * ch) +int mvwaddchstr(WINDOW *win, int y, int x, const chtype *ch) { PDC_LOG(("mvwaddchstr() - called:\n")); @@ -219,7 +219,7 @@ int mvwaddchstr(WINDOW *win, int y, int x, const chtype * ch) return waddchnstr(win, ch, -1); } -int mvwaddchnstr(WINDOW *win, int y, int x, const chtype * ch, int n) +int mvwaddchnstr(WINDOW *win, int y, int x, const chtype *ch, int n) { PDC_LOG(("mvwaddchnstr() - called: y %d x %d n %d \n", y, x, n)); diff --git a/graphics/pdcurs34/pdcurses/pdc_addstr.c b/graphics/pdcurs34/pdcurses/pdc_addstr.c index e97d33aa9..c1bfe549b 100644 --- a/graphics/pdcurs34/pdcurses/pdc_addstr.c +++ b/graphics/pdcurs34/pdcurses/pdc_addstr.c @@ -205,7 +205,7 @@ int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n) } #ifdef CONFIG_PDCURSES_WIDE -int waddnwstr(WINDOW *win, const wchar_t * wstr, int n) +int waddnwstr(WINDOW *win, const wchar_t *wstr, int n) { int i = 0; @@ -229,28 +229,28 @@ int waddnwstr(WINDOW *win, const wchar_t * wstr, int n) return OK; } -int addwstr(const wchar_t * wstr) +int addwstr(const wchar_t *wstr) { PDC_LOG(("addwstr() - called\n")); return waddnwstr(stdscr, wstr, -1); } -int addnwstr(const wchar_t * wstr, int n) +int addnwstr(const wchar_t *wstr, int n) { PDC_LOG(("addnwstr() - called\n")); return waddnwstr(stdscr, wstr, n); } -int waddwstr(WINDOW *win, const wchar_t * wstr) +int waddwstr(WINDOW *win, const wchar_t *wstr) { PDC_LOG(("waddwstr() - called\n")); return waddnwstr(win, wstr, -1); } -int mvaddwstr(int y, int x, const wchar_t * wstr) +int mvaddwstr(int y, int x, const wchar_t *wstr) { PDC_LOG(("mvaddstr() - called\n")); @@ -262,7 +262,7 @@ int mvaddwstr(int y, int x, const wchar_t * wstr) return waddnwstr(stdscr, wstr, -1); } -int mvaddnwstr(int y, int x, const wchar_t * wstr, int n) +int mvaddnwstr(int y, int x, const wchar_t *wstr, int n) { PDC_LOG(("mvaddnstr() - called\n")); @@ -274,7 +274,7 @@ int mvaddnwstr(int y, int x, const wchar_t * wstr, int n) return waddnwstr(stdscr, wstr, n); } -int mvwaddwstr(WINDOW *win, int y, int x, const wchar_t * wstr) +int mvwaddwstr(WINDOW *win, int y, int x, const wchar_t *wstr) { PDC_LOG(("mvwaddstr() - called\n")); @@ -286,7 +286,7 @@ int mvwaddwstr(WINDOW *win, int y, int x, const wchar_t * wstr) return waddnwstr(win, wstr, -1); } -int mvwaddnwstr(WINDOW *win, int y, int x, const wchar_t * wstr, int n) +int mvwaddnwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n) { PDC_LOG(("mvwaddnstr() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_attr.c b/graphics/pdcurs34/pdcurses/pdc_attr.c index dbfd4ada3..d472f98b5 100644 --- a/graphics/pdcurs34/pdcurses/pdc_attr.c +++ b/graphics/pdcurs34/pdcurses/pdc_attr.c @@ -272,7 +272,7 @@ int color_set(short color_pair, void *opts) return wcolor_set(stdscr, color_pair, opts); } -int wattr_get(WINDOW *win, attr_t * attrs, short *color_pair, void *opts) +int wattr_get(WINDOW *win, attr_t *attrs, short *color_pair, void *opts) { PDC_LOG(("wattr_get() - called\n")); @@ -294,7 +294,7 @@ int wattr_get(WINDOW *win, attr_t * attrs, short *color_pair, void *opts) return OK; } -int attr_get(attr_t * attrs, short *color_pair, void *opts) +int attr_get(attr_t *attrs, short *color_pair, void *opts) { PDC_LOG(("attr_get() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_bkgd.c b/graphics/pdcurs34/pdcurses/pdc_bkgd.c index a01a4eb87..ffd0d6639 100644 --- a/graphics/pdcurs34/pdcurses/pdc_bkgd.c +++ b/graphics/pdcurs34/pdcurses/pdc_bkgd.c @@ -94,7 +94,7 @@ #include "curspriv.h" -int wbkgd(WINDOW * win, chtype ch) +int wbkgd(WINDOW *win, chtype ch) { int x; int y; @@ -201,7 +201,7 @@ int bkgd(chtype ch) return wbkgd(stdscr, ch); } -void wbkgdset(WINDOW * win, chtype ch) +void wbkgdset(WINDOW *win, chtype ch) { PDC_LOG(("wbkgdset() - called\n")); @@ -223,7 +223,7 @@ void bkgdset(chtype ch) wbkgdset(stdscr, ch); } -chtype getbkgd(WINDOW * win) +chtype getbkgd(WINDOW *win) { PDC_LOG(("getbkgd() - called\n")); @@ -231,21 +231,21 @@ chtype getbkgd(WINDOW * win) } #ifdef CONFIG_PDCURSES_WIDE -int wbkgrnd(WINDOW * win, const cchar_t * wch) +int wbkgrnd(WINDOW *win, const cchar_t *wch) { PDC_LOG(("wbkgrnd() - called\n")); return wch ? wbkgd(win, *wch) : ERR; } -int bkgrnd(const cchar_t * wch) +int bkgrnd(const cchar_t *wch) { PDC_LOG(("bkgrnd() - called\n")); return wbkgrnd(stdscr, wch); } -void wbkgrndset(WINDOW * win, const cchar_t * wch) +void wbkgrndset(WINDOW *win, const cchar_t *wch) { PDC_LOG(("wbkgdset() - called\n")); @@ -255,14 +255,14 @@ void wbkgrndset(WINDOW * win, const cchar_t * wch) } } -void bkgrndset(const cchar_t * wch) +void bkgrndset(const cchar_t *wch) { PDC_LOG(("bkgrndset() - called\n")); wbkgrndset(stdscr, wch); } -int wgetbkgrnd(WINDOW * win, cchar_t * wch) +int wgetbkgrnd(WINDOW *win, cchar_t *wch) { PDC_LOG(("wgetbkgrnd() - called\n")); @@ -276,7 +276,7 @@ int wgetbkgrnd(WINDOW * win, cchar_t * wch) return OK; } -int getbkgrnd(cchar_t * wch) +int getbkgrnd(cchar_t *wch) { PDC_LOG(("getbkgrnd() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_border.c b/graphics/pdcurs34/pdcurses/pdc_border.c index 71ea7ef3d..faa84b064 100644 --- a/graphics/pdcurs34/pdcurses/pdc_border.c +++ b/graphics/pdcurs34/pdcurses/pdc_border.c @@ -141,7 +141,7 @@ * it. Attributes set explicitly in ch take precedence. */ -static chtype _attr_passthru(WINDOW * win, chtype ch) +static chtype _attr_passthru(WINDOW *win, chtype ch) { chtype attr; @@ -180,7 +180,7 @@ static chtype _attr_passthru(WINDOW * win, chtype ch) * Public Functions ****************************************************************************/ -int wborder(WINDOW * win, chtype ls, chtype rs, chtype ts, chtype bs, +int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br) { int xmax; @@ -242,14 +242,14 @@ int border(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, return wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br); } -int box(WINDOW * win, chtype verch, chtype horch) +int box(WINDOW *win, chtype verch, chtype horch) { PDC_LOG(("box() - called\n")); return wborder(win, verch, verch, horch, horch, 0, 0, 0, 0); } -int whline(WINDOW * win, chtype ch, int n) +int whline(WINDOW *win, chtype ch, int n) { chtype *dest; int startpos, endpos; @@ -307,7 +307,7 @@ int mvhline(int y, int x, chtype ch, int n) return whline(stdscr, ch, n); } -int mvwhline(WINDOW * win, int y, int x, chtype ch, int n) +int mvwhline(WINDOW *win, int y, int x, chtype ch, int n) { PDC_LOG(("mvwhline() - called\n")); @@ -319,7 +319,7 @@ int mvwhline(WINDOW * win, int y, int x, chtype ch, int n) return whline(win, ch, n); } -int wvline(WINDOW * win, chtype ch, int n) +int wvline(WINDOW *win, chtype ch, int n) { int endpos; int x; @@ -375,7 +375,7 @@ int mvvline(int y, int x, chtype ch, int n) return wvline(stdscr, ch, n); } -int mvwvline(WINDOW * win, int y, int x, chtype ch, int n) +int mvwvline(WINDOW *win, int y, int x, chtype ch, int n) { PDC_LOG(("mvwvline() - called\n")); @@ -388,9 +388,9 @@ int mvwvline(WINDOW * win, int y, int x, chtype ch, int n) } #ifdef CONFIG_PDCURSES_WIDE -int wborder_set(WINDOW * win, const cchar_t * ls, const cchar_t * rs, - const cchar_t * ts, const cchar_t * bs, const cchar_t * tl, - const cchar_t * tr, const cchar_t * bl, const cchar_t * br) +int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs, + const cchar_t *ts, const cchar_t *bs, const cchar_t *tl, + const cchar_t *tr, const cchar_t *bl, const cchar_t *br) { PDC_LOG(("wborder_set() - called\n")); @@ -399,16 +399,16 @@ int wborder_set(WINDOW * win, const cchar_t * ls, const cchar_t * rs, bl ? *bl : 0, br ? *br : 0); } -int border_set(const cchar_t * ls, const cchar_t * rs, const cchar_t * ts, - const cchar_t * bs, const cchar_t * tl, const cchar_t * tr, - const cchar_t * bl, const cchar_t * br) +int border_set(const cchar_t *ls, const cchar_t *rs, const cchar_t *ts, + const cchar_t *bs, const cchar_t *tl, const cchar_t *tr, + const cchar_t *bl, const cchar_t *br) { PDC_LOG(("border_set() - called\n")); return wborder_set(stdscr, ls, rs, ts, bs, tl, tr, bl, br); } -int box_set(WINDOW * win, const cchar_t * verch, const cchar_t * horch) +int box_set(WINDOW *win, const cchar_t *verch, const cchar_t *horch) { PDC_LOG(("box_set() - called\n")); @@ -417,21 +417,21 @@ int box_set(WINDOW * win, const cchar_t * verch, const cchar_t * horch) (const cchar_t *)NULL, (const cchar_t *)NULL); } -int whline_set(WINDOW * win, const cchar_t * wch, int n) +int whline_set(WINDOW *win, const cchar_t *wch, int n) { PDC_LOG(("whline_set() - called\n")); return wch ? whline(win, *wch, n) : ERR; } -int hline_set(const cchar_t * wch, int n) +int hline_set(const cchar_t *wch, int n) { PDC_LOG(("hline_set() - called\n")); return whline_set(stdscr, wch, n); } -int mvhline_set(int y, int x, const cchar_t * wch, int n) +int mvhline_set(int y, int x, const cchar_t *wch, int n) { PDC_LOG(("mvhline_set() - called\n")); @@ -443,7 +443,7 @@ int mvhline_set(int y, int x, const cchar_t * wch, int n) return whline_set(stdscr, wch, n); } -int mvwhline_set(WINDOW * win, int y, int x, const cchar_t * wch, int n) +int mvwhline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n) { PDC_LOG(("mvwhline_set() - called\n")); @@ -455,21 +455,21 @@ int mvwhline_set(WINDOW * win, int y, int x, const cchar_t * wch, int n) return whline_set(win, wch, n); } -int wvline_set(WINDOW * win, const cchar_t * wch, int n) +int wvline_set(WINDOW *win, const cchar_t *wch, int n) { PDC_LOG(("wvline_set() - called\n")); return wch ? wvline(win, *wch, n) : ERR; } -int vline_set(const cchar_t * wch, int n) +int vline_set(const cchar_t *wch, int n) { PDC_LOG(("vline_set() - called\n")); return wvline_set(stdscr, wch, n); } -int mvvline_set(int y, int x, const cchar_t * wch, int n) +int mvvline_set(int y, int x, const cchar_t *wch, int n) { PDC_LOG(("mvvline_set() - called\n")); @@ -481,7 +481,7 @@ int mvvline_set(int y, int x, const cchar_t * wch, int n) return wvline_set(stdscr, wch, n); } -int mvwvline_set(WINDOW * win, int y, int x, const cchar_t * wch, int n) +int mvwvline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n) { PDC_LOG(("mvwvline_set() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_clear.c b/graphics/pdcurs34/pdcurses/pdc_clear.c index 3ad22dd35..9f5d93f34 100644 --- a/graphics/pdcurs34/pdcurses/pdc_clear.c +++ b/graphics/pdcurs34/pdcurses/pdc_clear.c @@ -88,7 +88,7 @@ * Public Functions ****************************************************************************/ -int wclrtoeol(WINDOW * win) +int wclrtoeol(WINDOW *win) { chtype blank; chtype *ptr; @@ -133,7 +133,7 @@ int clrtoeol(void) return wclrtoeol(stdscr); } -int wclrtobot(WINDOW * win) +int wclrtobot(WINDOW *win) { int savey = win->_cury; int savex = win->_curx; @@ -174,7 +174,7 @@ int clrtobot(void) return wclrtobot(stdscr); } -int werase(WINDOW * win) +int werase(WINDOW *win) { PDC_LOG(("werase() - called\n")); @@ -193,7 +193,7 @@ int erase(void) return werase(stdscr); } -int wclear(WINDOW * win) +int wclear(WINDOW *win) { PDC_LOG(("wclear() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_delch.c b/graphics/pdcurs34/pdcurses/pdc_delch.c index 735c5702e..eb95e9edb 100644 --- a/graphics/pdcurs34/pdcurses/pdc_delch.c +++ b/graphics/pdcurs34/pdcurses/pdc_delch.c @@ -75,7 +75,7 @@ * Public Functions ****************************************************************************/ -int wdelch(WINDOW * win) +int wdelch(WINDOW *win) { int x; int y; @@ -131,7 +131,7 @@ int mvdelch(int y, int x) return wdelch(stdscr); } -int mvwdelch(WINDOW * win, int y, int x) +int mvwdelch(WINDOW *win, int y, int x) { PDC_LOG(("mvwdelch() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_deleteln.c b/graphics/pdcurs34/pdcurses/pdc_deleteln.c index f5aab0870..5213d051b 100644 --- a/graphics/pdcurs34/pdcurses/pdc_deleteln.c +++ b/graphics/pdcurs34/pdcurses/pdc_deleteln.c @@ -91,7 +91,7 @@ * Public Functions ****************************************************************************/ -int wdeleteln(WINDOW * win) +int wdeleteln(WINDOW *win) { chtype blank; chtype *temp; @@ -152,7 +152,7 @@ int mvdeleteln(int y, int x) return wdeleteln(stdscr); } -int mvwdeleteln(WINDOW * win, int y, int x) +int mvwdeleteln(WINDOW *win, int y, int x) { PDC_LOG(("mvwdeleteln() - called\n")); @@ -164,7 +164,7 @@ int mvwdeleteln(WINDOW * win, int y, int x) return wdeleteln(win); } -int winsdelln(WINDOW * win, int n) +int winsdelln(WINDOW *win, int n) { int i; @@ -207,7 +207,7 @@ int insdelln(int n) return winsdelln(stdscr, n); } -int winsertln(WINDOW * win) +int winsertln(WINDOW *win) { chtype blank, *temp, *end; int y; @@ -264,7 +264,7 @@ int mvinsertln(int y, int x) return winsertln(stdscr); } -int mvwinsertln(WINDOW * win, int y, int x) +int mvwinsertln(WINDOW *win, int y, int x) { PDC_LOG(("mvwinsertln() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_getch.c b/graphics/pdcurs34/pdcurses/pdc_getch.c index 9cc01c257..3dba30d77 100644 --- a/graphics/pdcurs34/pdcurses/pdc_getch.c +++ b/graphics/pdcurs34/pdcurses/pdc_getch.c @@ -138,7 +138,7 @@ static int c_ungch[NUNGETCH]; /* array of ungotten chars */ * Private Functions ****************************************************************************/ -static int _mouse_key(WINDOW * win) +static int _mouse_key(WINDOW *win) { unsigned long mbe = SP->_trap_mbe; int key = KEY_MOUSE; @@ -214,7 +214,7 @@ static int _mouse_key(WINDOW * win) * Public Functions ****************************************************************************/ -int wgetch(WINDOW * win) +int wgetch(WINDOW *win) { static int buffer[_INBUFSIZ]; /* character buffer */ int key, waitcount; @@ -394,7 +394,7 @@ int mvgetch(int y, int x) return wgetch(stdscr); } -int mvwgetch(WINDOW * win, int y, int x) +int mvwgetch(WINDOW *win, int y, int x) { PDC_LOG(("mvwgetch() - called\n")); @@ -457,7 +457,7 @@ int PDC_return_key_modifiers(bool flag) } #ifdef CONFIG_PDCURSES_WIDE -int wget_wch(WINDOW * win, wint_t * wch) +int wget_wch(WINDOW *win, wint_t *wch) { int key; @@ -480,14 +480,14 @@ int wget_wch(WINDOW * win, wint_t * wch) return SP->key_code ? KEY_CODE_YES : OK; } -int get_wch(wint_t * wch) +int get_wch(wint_t *wch) { PDC_LOG(("get_wch() - called\n")); return wget_wch(stdscr, wch); } -int mvget_wch(int y, int x, wint_t * wch) +int mvget_wch(int y, int x, wint_t *wch) { PDC_LOG(("mvget_wch() - called\n")); @@ -499,7 +499,7 @@ int mvget_wch(int y, int x, wint_t * wch) return wget_wch(stdscr, wch); } -int mvwget_wch(WINDOW * win, int y, int x, wint_t * wch) +int mvwget_wch(WINDOW *win, int y, int x, wint_t *wch) { PDC_LOG(("mvwget_wch() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_getstr.c b/graphics/pdcurs34/pdcurses/pdc_getstr.c index 93a77ab47..f1fa71705 100644 --- a/graphics/pdcurs34/pdcurses/pdc_getstr.c +++ b/graphics/pdcurs34/pdcurses/pdc_getstr.c @@ -111,7 +111,7 @@ * Public Functions ****************************************************************************/ -int wgetnstr(WINDOW * win, char *str, int n) +int wgetnstr(WINDOW *win, char *str, int n) { #ifdef CONFIG_PDCURSES_WIDE wchar_t wstr[MAXLINE + 1]; @@ -307,7 +307,7 @@ int getstr(char *str) return wgetnstr(stdscr, str, MAXLINE); } -int wgetstr(WINDOW * win, char *str) +int wgetstr(WINDOW *win, char *str) { PDC_LOG(("wgetstr() - called\n")); @@ -326,7 +326,7 @@ int mvgetstr(int y, int x, char *str) return wgetnstr(stdscr, str, MAXLINE); } -int mvwgetstr(WINDOW * win, int y, int x, char *str) +int mvwgetstr(WINDOW *win, int y, int x, char *str) { PDC_LOG(("mvwgetstr() - called\n")); @@ -357,7 +357,7 @@ int mvgetnstr(int y, int x, char *str, int n) return wgetnstr(stdscr, str, n); } -int mvwgetnstr(WINDOW * win, int y, int x, char *str, int n) +int mvwgetnstr(WINDOW *win, int y, int x, char *str, int n) { PDC_LOG(("mvwgetnstr() - called\n")); @@ -370,7 +370,7 @@ int mvwgetnstr(WINDOW * win, int y, int x, char *str, int n) } #ifdef CONFIG_PDCURSES_WIDE -int wgetn_wstr(WINDOW * win, wint_t * wstr, int n) +int wgetn_wstr(WINDOW *win, wint_t *wstr, int n) { int ch; int i; @@ -541,21 +541,21 @@ int wgetn_wstr(WINDOW * win, wint_t * wstr, int n) return OK; } -int get_wstr(wint_t * wstr) +int get_wstr(wint_t *wstr) { PDC_LOG(("get_wstr() - called\n")); return wgetn_wstr(stdscr, wstr, MAXLINE); } -int wget_wstr(WINDOW * win, wint_t * wstr) +int wget_wstr(WINDOW *win, wint_t *wstr) { PDC_LOG(("wget_wstr() - called\n")); return wgetn_wstr(win, wstr, MAXLINE); } -int mvget_wstr(int y, int x, wint_t * wstr) +int mvget_wstr(int y, int x, wint_t *wstr) { PDC_LOG(("mvget_wstr() - called\n")); @@ -567,7 +567,7 @@ int mvget_wstr(int y, int x, wint_t * wstr) return wgetn_wstr(stdscr, wstr, MAXLINE); } -int mvwget_wstr(WINDOW * win, int y, int x, wint_t * wstr) +int mvwget_wstr(WINDOW *win, int y, int x, wint_t *wstr) { PDC_LOG(("mvwget_wstr() - called\n")); @@ -579,14 +579,14 @@ int mvwget_wstr(WINDOW * win, int y, int x, wint_t * wstr) return wgetn_wstr(win, wstr, MAXLINE); } -int getn_wstr(wint_t * wstr, int n) +int getn_wstr(wint_t *wstr, int n) { PDC_LOG(("getn_wstr() - called\n")); return wgetn_wstr(stdscr, wstr, n); } -int mvgetn_wstr(int y, int x, wint_t * wstr, int n) +int mvgetn_wstr(int y, int x, wint_t *wstr, int n) { PDC_LOG(("mvgetn_wstr() - called\n")); @@ -598,7 +598,7 @@ int mvgetn_wstr(int y, int x, wint_t * wstr, int n) return wgetn_wstr(stdscr, wstr, n); } -int mvwgetn_wstr(WINDOW * win, int y, int x, wint_t * wstr, int n) +int mvwgetn_wstr(WINDOW *win, int y, int x, wint_t *wstr, int n) { PDC_LOG(("mvwgetn_wstr() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_getyx.c b/graphics/pdcurs34/pdcurses/pdc_getyx.c index ae97eec6e..6045f5601 100644 --- a/graphics/pdcurs34/pdcurses/pdc_getyx.c +++ b/graphics/pdcurs34/pdcurses/pdc_getyx.c @@ -111,56 +111,56 @@ * Publid Functions ****************************************************************************/ -int getbegy(WINDOW * win) +int getbegy(WINDOW *win) { PDC_LOG(("getbegy() - called\n")); return win ? win->_begy : ERR; } -int getbegx(WINDOW * win) +int getbegx(WINDOW *win) { PDC_LOG(("getbegx() - called\n")); return win ? win->_begx : ERR; } -int getcury(WINDOW * win) +int getcury(WINDOW *win) { PDC_LOG(("getcury() - called\n")); return win ? win->_cury : ERR; } -int getcurx(WINDOW * win) +int getcurx(WINDOW *win) { PDC_LOG(("getcurx() - called\n")); return win ? win->_curx : ERR; } -int getpary(WINDOW * win) +int getpary(WINDOW *win) { PDC_LOG(("getpary() - called\n")); return win ? win->_pary : ERR; } -int getparx(WINDOW * win) +int getparx(WINDOW *win) { PDC_LOG(("getparx() - called\n")); return win ? win->_parx : ERR; } -int getmaxy(WINDOW * win) +int getmaxy(WINDOW *win) { PDC_LOG(("getmaxy() - called\n")); return win ? win->_maxy : ERR; } -int getmaxx(WINDOW * win) +int getmaxx(WINDOW *win) { PDC_LOG(("getmaxx() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_inch.c b/graphics/pdcurs34/pdcurses/pdc_inch.c index d6a5ce157..3a9adec0e 100644 --- a/graphics/pdcurs34/pdcurses/pdc_inch.c +++ b/graphics/pdcurs34/pdcurses/pdc_inch.c @@ -83,7 +83,7 @@ * Public Functions ****************************************************************************/ -chtype winch(WINDOW * win) +chtype winch(WINDOW *win) { PDC_LOG(("winch() - called\n")); @@ -114,7 +114,7 @@ chtype mvinch(int y, int x) return stdscr->_y[stdscr->_cury][stdscr->_curx]; } -chtype mvwinch(WINDOW * win, int y, int x) +chtype mvwinch(WINDOW *win, int y, int x) { PDC_LOG(("mvwinch() - called\n")); @@ -127,7 +127,7 @@ chtype mvwinch(WINDOW * win, int y, int x) } #ifdef CONFIG_PDCURSES_WIDE -int win_wch(WINDOW * win, cchar_t * wcval) +int win_wch(WINDOW *win, cchar_t *wcval) { PDC_LOG(("win_wch() - called\n")); @@ -141,14 +141,14 @@ int win_wch(WINDOW * win, cchar_t * wcval) return OK; } -int in_wch(cchar_t * wcval) +int in_wch(cchar_t *wcval) { PDC_LOG(("in_wch() - called\n")); return win_wch(stdscr, wcval); } -int mvin_wch(int y, int x, cchar_t * wcval) +int mvin_wch(int y, int x, cchar_t *wcval) { PDC_LOG(("mvin_wch() - called\n")); @@ -161,7 +161,7 @@ int mvin_wch(int y, int x, cchar_t * wcval) return OK; } -int mvwin_wch(WINDOW * win, int y, int x, cchar_t * wcval) +int mvwin_wch(WINDOW *win, int y, int x, cchar_t *wcval) { PDC_LOG(("mvwin_wch() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_inchstr.c b/graphics/pdcurs34/pdcurses/pdc_inchstr.c index c360fe899..d4cc0bb64 100644 --- a/graphics/pdcurs34/pdcurses/pdc_inchstr.c +++ b/graphics/pdcurs34/pdcurses/pdc_inchstr.c @@ -97,7 +97,7 @@ * Public Functions ****************************************************************************/ -int winchnstr(WINDOW * win, chtype * ch, int n) +int winchnstr(WINDOW *win, chtype *ch, int n) { chtype *src; int i; @@ -125,21 +125,21 @@ int winchnstr(WINDOW * win, chtype * ch, int n) return OK; } -int inchstr(chtype * ch) +int inchstr(chtype *ch) { PDC_LOG(("inchstr() - called\n")); return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx); } -int winchstr(WINDOW * win, chtype * ch) +int winchstr(WINDOW *win, chtype *ch) { PDC_LOG(("winchstr() - called\n")); return winchnstr(win, ch, win->_maxx - win->_curx); } -int mvinchstr(int y, int x, chtype * ch) +int mvinchstr(int y, int x, chtype *ch) { PDC_LOG(("mvinchstr() - called: y %d x %d\n", y, x)); @@ -151,7 +151,7 @@ int mvinchstr(int y, int x, chtype * ch) return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx); } -int mvwinchstr(WINDOW * win, int y, int x, chtype * ch) +int mvwinchstr(WINDOW *win, int y, int x, chtype *ch) { PDC_LOG(("mvwinchstr() - called:\n")); @@ -163,14 +163,14 @@ int mvwinchstr(WINDOW * win, int y, int x, chtype * ch) return winchnstr(win, ch, win->_maxx - win->_curx); } -int inchnstr(chtype * ch, int n) +int inchnstr(chtype *ch, int n) { PDC_LOG(("inchnstr() - called\n")); return winchnstr(stdscr, ch, n); } -int mvinchnstr(int y, int x, chtype * ch, int n) +int mvinchnstr(int y, int x, chtype *ch, int n) { PDC_LOG(("mvinchnstr() - called: y %d x %d n %d\n", y, x, n)); @@ -182,7 +182,7 @@ int mvinchnstr(int y, int x, chtype * ch, int n) return winchnstr(stdscr, ch, n); } -int mvwinchnstr(WINDOW * win, int y, int x, chtype * ch, int n) +int mvwinchnstr(WINDOW *win, int y, int x, chtype *ch, int n) { PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n)); @@ -195,28 +195,28 @@ int mvwinchnstr(WINDOW * win, int y, int x, chtype * ch, int n) } #ifdef CONFIG_PDCURSES_WIDE -int win_wchnstr(WINDOW * win, cchar_t * wch, int n) +int win_wchnstr(WINDOW *win, cchar_t *wch, int n) { PDC_LOG(("win_wchnstr() - called\n")); return winchnstr(win, wch, n); } -int in_wchstr(cchar_t * wch) +int in_wchstr(cchar_t *wch) { PDC_LOG(("in_wchstr() - called\n")); return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx); } -int win_wchstr(WINDOW * win, cchar_t * wch) +int win_wchstr(WINDOW *win, cchar_t *wch) { PDC_LOG(("win_wchstr() - called\n")); return win_wchnstr(win, wch, win->_maxx - win->_curx); } -int mvin_wchstr(int y, int x, cchar_t * wch) +int mvin_wchstr(int y, int x, cchar_t *wch) { PDC_LOG(("mvin_wchstr() - called: y %d x %d\n", y, x)); @@ -228,7 +228,7 @@ int mvin_wchstr(int y, int x, cchar_t * wch) return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx); } -int mvwin_wchstr(WINDOW * win, int y, int x, cchar_t * wch) +int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wch) { PDC_LOG(("mvwin_wchstr() - called:\n")); @@ -240,14 +240,14 @@ int mvwin_wchstr(WINDOW * win, int y, int x, cchar_t * wch) return win_wchnstr(win, wch, win->_maxx - win->_curx); } -int in_wchnstr(cchar_t * wch, int n) +int in_wchnstr(cchar_t *wch, int n) { PDC_LOG(("in_wchnstr() - called\n")); return win_wchnstr(stdscr, wch, n); } -int mvin_wchnstr(int y, int x, cchar_t * wch, int n) +int mvin_wchnstr(int y, int x, cchar_t *wch, int n) { PDC_LOG(("mvin_wchnstr() - called: y %d x %d n %d\n", y, x, n)); @@ -259,7 +259,7 @@ int mvin_wchnstr(int y, int x, cchar_t * wch, int n) return win_wchnstr(stdscr, wch, n); } -int mvwin_wchnstr(WINDOW * win, int y, int x, cchar_t * wch, int n) +int mvwin_wchnstr(WINDOW *win, int y, int x, cchar_t *wch, int n) { PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n)); diff --git a/graphics/pdcurs34/pdcurses/pdc_initscr.c b/graphics/pdcurs34/pdcurses/pdc_initscr.c index ef95c11c2..8d1ea0c06 100644 --- a/graphics/pdcurs34/pdcurses/pdc_initscr.c +++ b/graphics/pdcurs34/pdcurses/pdc_initscr.c @@ -303,7 +303,7 @@ bool isendwin(void) return SP ? !(SP->alive) : false; } -SCREEN *newterm(const char *type, FILE * outfd, FILE * infd) +SCREEN *newterm(const char *type, FILE *outfd, FILE *infd) { PDC_LOG(("newterm() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_inopts.c b/graphics/pdcurs34/pdcurses/pdc_inopts.c index 34a3a9a02..09d50d3d4 100644 --- a/graphics/pdcurs34/pdcurses/pdc_inopts.c +++ b/graphics/pdcurs34/pdcurses/pdc_inopts.c @@ -202,14 +202,14 @@ int halfdelay(int tenths) return OK; } -int intrflush(WINDOW * win, bool bf) +int intrflush(WINDOW *win, bool bf) { PDC_LOG(("intrflush() - called\n")); return OK; } -int keypad(WINDOW * win, bool bf) +int keypad(WINDOW *win, bool bf) { PDC_LOG(("keypad() - called\n")); @@ -222,7 +222,7 @@ int keypad(WINDOW * win, bool bf) return OK; } -int meta(WINDOW * win, bool bf) +int meta(WINDOW *win, bool bf) { PDC_LOG(("meta() - called\n")); @@ -246,7 +246,7 @@ int nonl(void) return OK; } -int nodelay(WINDOW * win, bool flag) +int nodelay(WINDOW *win, bool flag) { PDC_LOG(("nodelay() - called\n")); @@ -259,7 +259,7 @@ int nodelay(WINDOW * win, bool flag) return OK; } -int notimeout(WINDOW * win, bool flag) +int notimeout(WINDOW *win, bool flag) { PDC_LOG(("notimeout() - called\n")); @@ -301,7 +301,7 @@ int typeahead(int fildes) return OK; } -void wtimeout(WINDOW * win, int delay) +void wtimeout(WINDOW *win, int delay) { PDC_LOG(("wtimeout() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_insch.c b/graphics/pdcurs34/pdcurses/pdc_insch.c index 8a0dcd84c..c50e422a1 100644 --- a/graphics/pdcurs34/pdcurses/pdc_insch.c +++ b/graphics/pdcurs34/pdcurses/pdc_insch.c @@ -101,7 +101,7 @@ * Public Functions ****************************************************************************/ -int winsch(WINDOW * win, chtype ch) +int winsch(WINDOW *win, chtype ch) { chtype attr; bool xlat; @@ -244,7 +244,7 @@ int mvinsch(int y, int x, chtype ch) return winsch(stdscr, ch); } -int mvwinsch(WINDOW * win, int y, int x, chtype ch) +int mvwinsch(WINDOW *win, int y, int x, chtype ch) { PDC_LOG(("mvwinsch() - called\n")); @@ -256,7 +256,7 @@ int mvwinsch(WINDOW * win, int y, int x, chtype ch) return winsch(win, ch); } -int winsrawch(WINDOW * win, chtype ch) +int winsrawch(WINDOW *win, chtype ch) { PDC_LOG(("winsrawch() - called: win=%p ch=%x " "(char=%c attr=0x%x)\n", win, ch, @@ -289,7 +289,7 @@ int mvinsrawch(int y, int x, chtype ch) return winsrawch(stdscr, ch); } -int mvwinsrawch(WINDOW * win, int y, int x, chtype ch) +int mvwinsrawch(WINDOW *win, int y, int x, chtype ch) { PDC_LOG(("mvwinsrawch() - called\n")); @@ -302,21 +302,21 @@ int mvwinsrawch(WINDOW * win, int y, int x, chtype ch) } #ifdef CONFIG_PDCURSES_WIDE -int wins_wch(WINDOW * win, const cchar_t * wch) +int wins_wch(WINDOW *win, const cchar_t *wch) { PDC_LOG(("wins_wch() - called\n")); return wch ? winsch(win, *wch) : ERR; } -int ins_wch(const cchar_t * wch) +int ins_wch(const cchar_t *wch) { PDC_LOG(("ins_wch() - called\n")); return wins_wch(stdscr, wch); } -int mvins_wch(int y, int x, const cchar_t * wch) +int mvins_wch(int y, int x, const cchar_t *wch) { PDC_LOG(("mvins_wch() - called\n")); @@ -328,7 +328,7 @@ int mvins_wch(int y, int x, const cchar_t * wch) return wins_wch(stdscr, wch); } -int mvwins_wch(WINDOW * win, int y, int x, const cchar_t * wch) +int mvwins_wch(WINDOW *win, int y, int x, const cchar_t *wch) { PDC_LOG(("mvwins_wch() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_insstr.c b/graphics/pdcurs34/pdcurses/pdc_insstr.c index 232f4c856..be5c8933b 100644 --- a/graphics/pdcurs34/pdcurses/pdc_insstr.c +++ b/graphics/pdcurs34/pdcurses/pdc_insstr.c @@ -242,7 +242,7 @@ int mvwinsnstr(WINDOW *win, int y, int x, const char *str, int n) } #ifdef CONFIG_PDCURSES_WIDE -int wins_nwstr(WINDOW *win, const wchar_t * wstr, int n) +int wins_nwstr(WINDOW *win, const wchar_t *wstr, int n) { const wchar_t *p; int len; @@ -275,21 +275,21 @@ int wins_nwstr(WINDOW *win, const wchar_t * wstr, int n) return OK; } -int ins_wstr(const wchar_t * wstr) +int ins_wstr(const wchar_t *wstr) { PDC_LOG(("ins_wstr() - called\n")); return wins_nwstr(stdscr, wstr, -1); } -int wins_wstr(WINDOW *win, const wchar_t * wstr) +int wins_wstr(WINDOW *win, const wchar_t *wstr) { PDC_LOG(("wins_wstr() - called\n")); return wins_nwstr(win, wstr, -1); } -int mvins_wstr(int y, int x, const wchar_t * wstr) +int mvins_wstr(int y, int x, const wchar_t *wstr) { PDC_LOG(("mvins_wstr() - called\n")); @@ -301,7 +301,7 @@ int mvins_wstr(int y, int x, const wchar_t * wstr) return wins_nwstr(stdscr, wstr, -1); } -int mvwins_wstr(WINDOW *win, int y, int x, const wchar_t * wstr) +int mvwins_wstr(WINDOW *win, int y, int x, const wchar_t *wstr) { PDC_LOG(("mvwinsstr() - called\n")); @@ -313,14 +313,14 @@ int mvwins_wstr(WINDOW *win, int y, int x, const wchar_t * wstr) return wins_nwstr(win, wstr, -1); } -int ins_nwstr(const wchar_t * wstr, int n) +int ins_nwstr(const wchar_t *wstr, int n) { PDC_LOG(("ins_nwstr() - called\n")); return wins_nwstr(stdscr, wstr, n); } -int mvins_nwstr(int y, int x, const wchar_t * wstr, int n) +int mvins_nwstr(int y, int x, const wchar_t *wstr, int n) { PDC_LOG(("mvinsnstr() - called\n")); @@ -332,7 +332,7 @@ int mvins_nwstr(int y, int x, const wchar_t * wstr, int n) return wins_nwstr(stdscr, wstr, n); } -int mvwins_nwstr(WINDOW *win, int y, int x, const wchar_t * wstr, int n) +int mvwins_nwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n) { PDC_LOG(("mvwinsnstr() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_instr.c b/graphics/pdcurs34/pdcurses/pdc_instr.c index dfad78a90..76b397498 100644 --- a/graphics/pdcurs34/pdcurses/pdc_instr.c +++ b/graphics/pdcurs34/pdcurses/pdc_instr.c @@ -215,7 +215,7 @@ int mvwinnstr(WINDOW *win, int y, int x, char *str, int n) } #ifdef CONFIG_PDCURSES_WIDE -int winnwstr(WINDOW *win, wchar_t * wstr, int n) +int winnwstr(WINDOW *win, wchar_t *wstr, int n) { chtype *src; int i; @@ -243,21 +243,21 @@ int winnwstr(WINDOW *win, wchar_t * wstr, int n) return i; } -int inwstr(wchar_t * wstr) +int inwstr(wchar_t *wstr) { PDC_LOG(("inwstr() - called\n")); return (ERR == winnwstr(stdscr, wstr, stdscr->_maxx)) ? ERR : OK; } -int winwstr(WINDOW *win, wchar_t * wstr) +int winwstr(WINDOW *win, wchar_t *wstr) { PDC_LOG(("winwstr() - called\n")); return (ERR == winnwstr(win, wstr, win->_maxx)) ? ERR : OK; } -int mvinwstr(int y, int x, wchar_t * wstr) +int mvinwstr(int y, int x, wchar_t *wstr) { PDC_LOG(("mvinwstr() - called\n")); @@ -269,7 +269,7 @@ int mvinwstr(int y, int x, wchar_t * wstr) return (ERR == winnwstr(stdscr, wstr, stdscr->_maxx)) ? ERR : OK; } -int mvwinwstr(WINDOW *win, int y, int x, wchar_t * wstr) +int mvwinwstr(WINDOW *win, int y, int x, wchar_t *wstr) { PDC_LOG(("mvwinstr() - called\n")); @@ -281,14 +281,14 @@ int mvwinwstr(WINDOW *win, int y, int x, wchar_t * wstr) return (ERR == winnwstr(win, wstr, win->_maxx)) ? ERR : OK; } -int innwstr(wchar_t * wstr, int n) +int innwstr(wchar_t *wstr, int n) { PDC_LOG(("innwstr() - called\n")); return winnwstr(stdscr, wstr, n); } -int mvinnwstr(int y, int x, wchar_t * wstr, int n) +int mvinnwstr(int y, int x, wchar_t *wstr, int n) { PDC_LOG(("mvinnstr() - called\n")); @@ -300,7 +300,7 @@ int mvinnwstr(int y, int x, wchar_t * wstr, int n) return winnwstr(stdscr, wstr, n); } -int mvwinnwstr(WINDOW *win, int y, int x, wchar_t * wstr, int n) +int mvwinnwstr(WINDOW *win, int y, int x, wchar_t *wstr, int n) { PDC_LOG(("mvwinnwstr() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_mouse.c b/graphics/pdcurs34/pdcurses/pdc_mouse.c index 2abffb250..7d614b563 100644 --- a/graphics/pdcurs34/pdcurses/pdc_mouse.c +++ b/graphics/pdcurs34/pdcurses/pdc_mouse.c @@ -240,7 +240,7 @@ int request_mouse_pos(void) return OK; } -void wmouse_position(WINDOW * win, int *y, int *x) +void wmouse_position(WINDOW *win, int *y, int *x) { PDC_LOG(("wmouse_position() - called\n")); @@ -302,7 +302,7 @@ int mouseinterval(int wait) return old_wait; } -bool wenclose(const WINDOW * win, int y, int x) +bool wenclose(const WINDOW *win, int y, int x) { PDC_LOG(("wenclose() - called: %p %d %d\n", win, y, x)); @@ -310,7 +310,7 @@ bool wenclose(const WINDOW * win, int y, int x) x >= win->_begx && x < win->_begx + win->_maxx); } -bool wmouse_trafo(const WINDOW * win, int *y, int *x, bool to_screen) +bool wmouse_trafo(const WINDOW *win, int *y, int *x, bool to_screen) { int newy, newx; diff --git a/graphics/pdcurs34/pdcurses/pdc_move.c b/graphics/pdcurs34/pdcurses/pdc_move.c index 6994fcf21..735bde73d 100644 --- a/graphics/pdcurs34/pdcurses/pdc_move.c +++ b/graphics/pdcurs34/pdcurses/pdc_move.c @@ -82,7 +82,7 @@ int move(int y, int x) return OK; } -int wmove(WINDOW * win, int y, int x) +int wmove(WINDOW *win, int y, int x) { PDC_LOG(("wmove() - called: y=%d x=%d\n", y, x)); diff --git a/graphics/pdcurs34/pdcurses/pdc_outopts.c b/graphics/pdcurs34/pdcurses/pdc_outopts.c index 1dea1bbc4..35fe9d21a 100644 --- a/graphics/pdcurs34/pdcurses/pdc_outopts.c +++ b/graphics/pdcurs34/pdcurses/pdc_outopts.c @@ -106,7 +106,7 @@ * Public Functions ****************************************************************************/ -int clearok(WINDOW * win, bool bf) +int clearok(WINDOW *win, bool bf) { PDC_LOG(("clearok() - called\n")); @@ -119,19 +119,19 @@ int clearok(WINDOW * win, bool bf) return OK; } -int idlok(WINDOW * win, bool bf) +int idlok(WINDOW *win, bool bf) { PDC_LOG(("idlok() - called\n")); return OK; } -void idcok(WINDOW * win, bool bf) +void idcok(WINDOW *win, bool bf) { PDC_LOG(("idcok() - called\n")); } -void immedok(WINDOW * win, bool bf) +void immedok(WINDOW *win, bool bf) { PDC_LOG(("immedok() - called\n")); @@ -141,7 +141,7 @@ void immedok(WINDOW * win, bool bf) } } -int leaveok(WINDOW * win, bool bf) +int leaveok(WINDOW *win, bool bf) { PDC_LOG(("leaveok() - called\n")); @@ -162,7 +162,7 @@ int setscrreg(int top, int bottom) return wsetscrreg(stdscr, top, bottom); } -int wsetscrreg(WINDOW * win, int top, int bottom) +int wsetscrreg(WINDOW *win, int top, int bottom) { PDC_LOG(("wsetscrreg() - called: top %d bottom %d\n", top, bottom)); @@ -180,7 +180,7 @@ int wsetscrreg(WINDOW * win, int top, int bottom) } } -int scrollok(WINDOW * win, bool bf) +int scrollok(WINDOW *win, bool bf) { PDC_LOG(("scrollok() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_overlay.c b/graphics/pdcurs34/pdcurses/pdc_overlay.c index 3c3de6771..9af589767 100644 --- a/graphics/pdcurs34/pdcurses/pdc_overlay.c +++ b/graphics/pdcurs34/pdcurses/pdc_overlay.c @@ -88,7 +88,7 @@ * Private Functions ****************************************************************************/ -static int _copy_win(const WINDOW * src_w, WINDOW * dst_w, int src_tr, +static int _copy_win(const WINDOW *src_w, WINDOW *dst_w, int src_tr, int src_tc, int src_br, int src_bc, int dst_tr, int dst_tc, bool overlay) { @@ -174,7 +174,7 @@ static int _copy_win(const WINDOW * src_w, WINDOW * dst_w, int src_tr, * Public Functions ****************************************************************************/ -int overlay(const WINDOW * src_w, WINDOW * dst_w) +int overlay(const WINDOW *src_w, WINDOW *dst_w) { int first_line; int first_col; @@ -241,7 +241,7 @@ int overlay(const WINDOW * src_w, WINDOW * dst_w) dst_start_y, dst_start_x, true); } -int overwrite(const WINDOW * src_w, WINDOW * dst_w) +int overwrite(const WINDOW *src_w, WINDOW *dst_w) { int first_line; int first_col; @@ -308,7 +308,7 @@ int overwrite(const WINDOW * src_w, WINDOW * dst_w) dst_start_y, dst_start_x, false); } -int copywin(const WINDOW * src_w, WINDOW * dst_w, int src_tr, int src_tc, +int copywin(const WINDOW *src_w, WINDOW *dst_w, int src_tr, int src_tc, int dst_tr, int dst_tc, int dst_br, int dst_bc, int overlay) { int src_end_x; diff --git a/graphics/pdcurs34/pdcurses/pdc_pad.c b/graphics/pdcurs34/pdcurses/pdc_pad.c index 19de198bb..70c3885af 100644 --- a/graphics/pdcurs34/pdcurses/pdc_pad.c +++ b/graphics/pdcurs34/pdcurses/pdc_pad.c @@ -149,7 +149,7 @@ WINDOW *newpad(int nlines, int ncols) return win; } -WINDOW *subpad(WINDOW * orig, int nlines, int ncols, int begy, int begx) +WINDOW *subpad(WINDOW *orig, int nlines, int ncols, int begy, int begx) { WINDOW *win; int i; @@ -218,7 +218,7 @@ WINDOW *subpad(WINDOW * orig, int nlines, int ncols, int begy, int begx) return win; } -int prefresh(WINDOW * win, int py, int px, int sy1, int sx1, int sy2, +int prefresh(WINDOW *win, int py, int px, int sy1, int sx1, int sy2, int sx2) { PDC_LOG(("prefresh() - called\n")); @@ -232,7 +232,7 @@ int prefresh(WINDOW * win, int py, int px, int sy1, int sx1, int sy2, return OK; } -int pnoutrefresh(WINDOW * w, int py, int px, int sy1, int sx1, int sy2, +int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1, int sy2, int sx2) { int num_cols; @@ -320,7 +320,7 @@ int pnoutrefresh(WINDOW * w, int py, int px, int sy1, int sx1, int sy2, return OK; } -int pechochar(WINDOW * pad, chtype ch) +int pechochar(WINDOW *pad, chtype ch) { PDC_LOG(("pechochar() - called\n")); @@ -334,7 +334,7 @@ int pechochar(WINDOW * pad, chtype ch) } #ifdef CONFIG_PDCURSES_WIDE -int pecho_wchar(WINDOW * pad, const cchar_t * wch) +int pecho_wchar(WINDOW *pad, const cchar_t *wch) { PDC_LOG(("pecho_wchar() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_panel.c b/graphics/pdcurs34/pdcurses/pdc_panel.c index 102d4e43c..1206d8f04 100644 --- a/graphics/pdcurs34/pdcurses/pdc_panel.c +++ b/graphics/pdcurs34/pdcurses/pdc_panel.c @@ -584,7 +584,7 @@ int move_panel(PANEL *pan, int starty, int startx) return OK; } -PANEL *new_panel(WINDOW * win) +PANEL *new_panel(WINDOW *win) { PANEL *pan = malloc(sizeof(PANEL)); @@ -655,7 +655,7 @@ WINDOW *panel_window(const PANEL *pan) return pan->win; } -int replace_panel(PANEL *pan, WINDOW * win) +int replace_panel(PANEL *pan, WINDOW *win) { int maxy, maxx; diff --git a/graphics/pdcurs34/pdcurses/pdc_printw.c b/graphics/pdcurs34/pdcurses/pdc_printw.c index 0c5a04d38..0d8065bdc 100644 --- a/graphics/pdcurs34/pdcurses/pdc_printw.c +++ b/graphics/pdcurs34/pdcurses/pdc_printw.c @@ -79,7 +79,7 @@ * Public Functions ****************************************************************************/ -int vwprintw(WINDOW * win, const char *fmt, va_list varglist) +int vwprintw(WINDOW *win, const char *fmt, va_list varglist) { char printbuf[513]; int len; @@ -104,7 +104,7 @@ int printw(const char *fmt, ...) return retval; } -int wprintw(WINDOW * win, const char *fmt, ...) +int wprintw(WINDOW *win, const char *fmt, ...) { va_list args; int retval; @@ -137,7 +137,7 @@ int mvprintw(int y, int x, const char *fmt, ...) return retval; } -int mvwprintw(WINDOW * win, int y, int x, const char *fmt, ...) +int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...) { va_list args; int retval; @@ -156,7 +156,7 @@ int mvwprintw(WINDOW * win, int y, int x, const char *fmt, ...) return retval; } -int vw_printw(WINDOW * win, const char *fmt, va_list varglist) +int vw_printw(WINDOW *win, const char *fmt, va_list varglist) { PDC_LOG(("vw_printw() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_scanw.c b/graphics/pdcurs34/pdcurses/pdc_scanw.c index 138e40b76..749e9ca87 100644 --- a/graphics/pdcurs34/pdcurses/pdc_scanw.c +++ b/graphics/pdcurs34/pdcurses/pdc_scanw.c @@ -78,7 +78,7 @@ * Public Functions ****************************************************************************/ -int vwscanw(WINDOW * win, const char *fmt, va_list varglist) +int vwscanw(WINDOW *win, const char *fmt, va_list varglist) { char scanbuf[256]; @@ -106,7 +106,7 @@ int scanw(const char *fmt, ...) return retval; } -int wscanw(WINDOW * win, const char *fmt, ...) +int wscanw(WINDOW *win, const char *fmt, ...) { va_list args; int retval; @@ -139,7 +139,7 @@ int mvscanw(int y, int x, const char *fmt, ...) return retval; } -int mvwscanw(WINDOW * win, int y, int x, const char *fmt, ...) +int mvwscanw(WINDOW *win, int y, int x, const char *fmt, ...) { va_list args; int retval; @@ -158,7 +158,7 @@ int mvwscanw(WINDOW * win, int y, int x, const char *fmt, ...) return retval; } -int vw_scanw(WINDOW * win, const char *fmt, va_list varglist) +int vw_scanw(WINDOW *win, const char *fmt, va_list varglist) { PDC_LOG(("vw_scanw() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_scrdump.c b/graphics/pdcurs34/pdcurses/pdc_scrdump.c index 1a974e368..b68111f8c 100644 --- a/graphics/pdcurs34/pdcurses/pdc_scrdump.c +++ b/graphics/pdcurs34/pdcurses/pdc_scrdump.c @@ -106,7 +106,7 @@ * Public Functions ****************************************************************************/ -int putwin(WINDOW * win, FILE *filep) +int putwin(WINDOW *win, FILE *filep) { static const char *marker = "PDC"; static const unsigned char version = DUMPVER; diff --git a/graphics/pdcurs34/pdcurses/pdc_scroll.c b/graphics/pdcurs34/pdcurses/pdc_scroll.c index fd0c77dfd..27f017267 100644 --- a/graphics/pdcurs34/pdcurses/pdc_scroll.c +++ b/graphics/pdcurs34/pdcurses/pdc_scroll.c @@ -76,7 +76,7 @@ * Public Functions ****************************************************************************/ -int wscrl(WINDOW * win, int n) +int wscrl(WINDOW *win, int n) { chtype blank; chtype *temp; @@ -142,7 +142,7 @@ int scrl(int n) return wscrl(stdscr, n); } -int scroll(WINDOW * win) +int scroll(WINDOW *win) { PDC_LOG(("scroll() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_slk.c b/graphics/pdcurs34/pdcurses/pdc_slk.c index 43cc35655..f28fae8e5 100644 --- a/graphics/pdcurs34/pdcurses/pdc_slk.c +++ b/graphics/pdcurs34/pdcurses/pdc_slk.c @@ -667,7 +667,7 @@ int PDC_mouse_in_slk(int y, int x) } #ifdef CONFIG_PDCURSES_WIDE -int slk_wset(int labnum, const wchar_t * label, int justify) +int slk_wset(int labnum, const wchar_t *label, int justify) { PDC_LOG(("slk_wset() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_termattr.c b/graphics/pdcurs34/pdcurses/pdc_termattr.c index e29bd54b1..466fe1925 100644 --- a/graphics/pdcurs34/pdcurses/pdc_termattr.c +++ b/graphics/pdcurs34/pdcurses/pdc_termattr.c @@ -193,7 +193,7 @@ char wordchar(void) } #ifdef CONFIG_PDCURSES_WIDE -int erasewchar(wchar_t * ch) +int erasewchar(wchar_t *ch) { PDC_LOG(("erasewchar() - called\n")); @@ -206,7 +206,7 @@ int erasewchar(wchar_t * ch) return OK; } -int killwchar(wchar_t * ch) +int killwchar(wchar_t *ch) { PDC_LOG(("killwchar() - called\n")); diff --git a/graphics/pdcurs34/pdcurses/pdc_touch.c b/graphics/pdcurs34/pdcurses/pdc_touch.c index c491897c8..24b9ffa8c 100644 --- a/graphics/pdcurs34/pdcurses/pdc_touch.c +++ b/graphics/pdcurs34/pdcurses/pdc_touch.c @@ -94,7 +94,7 @@ * Public Functions ****************************************************************************/ -int touchwin(WINDOW * win) +int touchwin(WINDOW *win) { int i; @@ -114,7 +114,7 @@ int touchwin(WINDOW * win) return OK; } -int touchline(WINDOW * win, int start, int count) +int touchline(WINDOW *win, int start, int count) { int i; @@ -135,7 +135,7 @@ int touchline(WINDOW * win, int start, int count) return OK; } -int untouchwin(WINDOW * win) +int untouchwin(WINDOW *win) { int i; @@ -155,7 +155,7 @@ int untouchwin(WINDOW * win) return OK; } -int wtouchln(WINDOW * win, int y, int n, int changed) +int wtouchln(WINDOW *win, int y, int n, int changed) { int i; @@ -184,7 +184,7 @@ int wtouchln(WINDOW * win, int y, int n, int changed) return OK; } -bool is_linetouched(WINDOW * win, int line) +bool is_linetouched(WINDOW *win, int line) { PDC_LOG(("is_linetouched() - called: win=%p line=%d\n", win, line)); @@ -196,7 +196,7 @@ bool is_linetouched(WINDOW * win, int line) return (win->_firstch[line] != _NO_CHANGE) ? true : false; } -bool is_wintouched(WINDOW * win) +bool is_wintouched(WINDOW *win) { int i; diff --git a/graphics/pdcurs34/pdcurses/pdc_util.c b/graphics/pdcurs34/pdcurses/pdc_util.c index 538eaed1f..6d34f1386 100644 --- a/graphics/pdcurs34/pdcurses/pdc_util.c +++ b/graphics/pdcurs34/pdcurses/pdc_util.c @@ -172,7 +172,7 @@ int delay_output(int ms) } #ifdef CONFIG_PDCURSES_WIDE -int getcchar(const cchar_t * wcval, wchar_t * wch, attr_t * attrs, +int getcchar(const cchar_t *wcval, wchar_t *wch, attr_t *attrs, short *color_pair, void *opts) { if (!wcval) @@ -204,7 +204,7 @@ int getcchar(const cchar_t * wcval, wchar_t * wch, attr_t * attrs, } } -int setcchar(cchar_t * wcval, const wchar_t * wch, const attr_t attrs, +int setcchar(cchar_t *wcval, const wchar_t *wch, const attr_t attrs, short color_pair, const void *opts) { if (!wcval || !wch) @@ -216,7 +216,7 @@ int setcchar(cchar_t * wcval, const wchar_t * wch, const attr_t attrs, return OK; } -wchar_t *wunctrl(cchar_t * wc) +wchar_t *wunctrl(cchar_t *wc) { static wchar_t strbuf[3] = { 0, 0, 0 }; @@ -247,7 +247,7 @@ wchar_t *wunctrl(cchar_t * wc) return strbuf; } -int PDC_mbtowc(wchar_t * pwc, const char *s, size_t n) +int PDC_mbtowc(wchar_t *pwc, const char *s, size_t n) { #ifdef CONFIG_PDCURSES_FORCE_UTF8 wchar_t key; @@ -306,7 +306,7 @@ int PDC_mbtowc(wchar_t * pwc, const char *s, size_t n) #endif } -size_t PDC_mbstowcs(wchar_t * dest, const char *src, size_t n) +size_t PDC_mbstowcs(wchar_t *dest, const char *src, size_t n) { #ifdef CONFIG_PDCURSES_FORCE_UTF8 size_t len; @@ -340,7 +340,7 @@ size_t PDC_mbstowcs(wchar_t * dest, const char *src, size_t n) return i; } -size_t PDC_wcstombs(char *dest, const wchar_t * src, size_t n) +size_t PDC_wcstombs(char *dest, const wchar_t *src, size_t n) { #ifdef CONFIG_PDCURSES_FORCE_UTF8 size_t i = 0; diff --git a/graphics/pdcurs34/pdcurses/pdc_window.c b/graphics/pdcurs34/pdcurses/pdc_window.c index bca47ba4c..49de1c283 100644 --- a/graphics/pdcurs34/pdcurses/pdc_window.c +++ b/graphics/pdcurs34/pdcurses/pdc_window.c @@ -118,7 +118,7 @@ * the window. (However, you still can call it _on_ subwindows.) It * returns OK or ERR. * - * PDC_makenew() allocates all data for a new WINDOW * except the + * PDC_makenew() allocates all data for a new WINDOW *except the * actual lines themselves. If it's unable to allocate memory for * the window structure, it will free all allocated memory and * return a NULL pointer. @@ -360,7 +360,7 @@ int mvwin(WINDOW *win, int y, int x) return OK; } -WINDOW *subwin(WINDOW * orig, int nlines, int ncols, int begy, int begx) +WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begy, int begx) { WINDOW *win; int i; @@ -417,7 +417,7 @@ WINDOW *subwin(WINDOW * orig, int nlines, int ncols, int begy, int begx) return win; } -WINDOW *derwin(WINDOW * orig, int nlines, int ncols, int begy, int begx) +WINDOW *derwin(WINDOW *orig, int nlines, int ncols, int begy, int begx) { return subwin(orig, nlines, ncols, begy + orig->_begy, begx + orig->_begx); }