apps/examples/pdcurses: Bring pdcurses demos and make them conform to the NuttX coding style (not yet hooked into the build system).

This commit is contained in:
Gregory Nutt 2017-11-17 18:23:23 -06:00
parent 25e4f6b57b
commit eb065a756e
45 changed files with 6101 additions and 201 deletions

21
examples/pdcurses/README Normal file

@ -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).

@ -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 <gnutt@nuttx.org>
*
* 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 <sys/types.h>
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
#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;
}

@ -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 <gnutt@nuttx.org>
*
* 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 <stdio.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#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;
}

@ -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 <gnutt@nuttx.org>
*
* 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 <stdlib.h>
#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;
}

@ -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 <gnutt@nuttx.org>
*
* 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 <stdlib.h>
#include <time.h>
#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);
}
}

File diff suppressed because it is too large Load Diff

895
examples/pdcurses/tui.c Normal file

@ -0,0 +1,895 @@
/****************************************************************************
* apps/examples/pdcurses/tui.c
* Textual User Interface
*
* Author : P.J. Kunst <kunst@prl.philips.nl>
* 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 <gnutt@nuttx.org>
*
* 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 <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#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;
}

116
examples/pdcurses/tui.h Normal file

@ -0,0 +1,116 @@
/****************************************************************************
* apps/examples/pdcurses/tui.c
* Textual User Interface
*
* Author : P.J. Kunst <kunst@prl.philips.nl>
* 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 <gnutt@nuttx.org>
*
* 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 */

@ -0,0 +1,288 @@
/****************************************************************************
* apps/examples/pdcurses/tui.c
* Textual User Interface
*
* Author : P.J. Kunst <kunst@prl.philips.nl>
* 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 <gnutt@nuttx.org>
*
* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#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;
}

@ -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 <gnutt@nuttx.org>
*
* 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 <n> set worm length
* -n <n> set number of worms
* -t make worms leave droppings
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdlib.h>
#include <time.h>
#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();
}
}

File diff suppressed because it is too large Load Diff

@ -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));

@ -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));

@ -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"));

@ -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"));

@ -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"));

@ -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"));

@ -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"));

@ -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"));

@ -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"));

@ -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"));

@ -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"));

@ -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"));

@ -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"));

@ -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));

@ -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"));

@ -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"));

@ -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"));

@ -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"));

@ -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"));

@ -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;

@ -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));

@ -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"));

@ -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;

@ -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"));

@ -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;

@ -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"));

@ -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"));

@ -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;

@ -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"));

@ -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"));

@ -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"));

@ -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;

@ -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;

@ -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);
}