Moved from ports with several enhancements
This commit is contained in:
parent
d456d8f48d
commit
c0e33523c8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/zmbenhal/; revision=3410
18
lib/libncurses/COPYRIGHT.NEW
Normal file
18
lib/libncurses/COPYRIGHT.NEW
Normal file
@ -0,0 +1,18 @@
|
||||
/***************************************************************************
|
||||
* COPYRIGHT NOTICE *
|
||||
****************************************************************************
|
||||
* ncurses is copyright (C) 1992, 1993, 1994 *
|
||||
* by Zeyd M. Ben-Halim *
|
||||
* zmbenhal@netcom.com *
|
||||
* *
|
||||
* Permission is hereby granted to reproduce and distribute ncurses *
|
||||
* by any means and for any fee, whether alone or as part of a *
|
||||
* larger distribution, in source or in binary form, PROVIDED *
|
||||
* this notice remains in the sources and is reproduced in any *
|
||||
* documentation accompanying it or the applications linked with it. *
|
||||
* Any other use of ncurses, including incorporating it in another *
|
||||
* product is subject to written permission. *
|
||||
* *
|
||||
* ncurses comes AS IS with no warranty, implied or expressed. *
|
||||
* *
|
||||
***************************************************************************/
|
5
lib/libncurses/COPYRIGHT.OLD
Normal file
5
lib/libncurses/COPYRIGHT.OLD
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
Pavel Curtis has given up his copyright to the public domain. This mean
|
||||
his ORIGINAL sources are in the public domain, not this current release.
|
||||
This current release IS copyrighted, see COPYRIGHT.NEW.
|
||||
|
30
lib/libncurses/MKkeyname.awk
Normal file
30
lib/libncurses/MKkeyname.awk
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
BEGIN {
|
||||
print ""
|
||||
print "#include <stdlib.h>"
|
||||
print "#include <ncurses.h>"
|
||||
print ""
|
||||
print "struct kn {"
|
||||
print "\tchar *name;"
|
||||
print "\tint code;"
|
||||
print "};"
|
||||
print ""
|
||||
print "struct kn key_names[] = {"
|
||||
}
|
||||
|
||||
{printf "\t{\"%s\", %s,},\n", $1, $2;}
|
||||
|
||||
END {
|
||||
print "};"
|
||||
print ""
|
||||
print "char *keyname(int c)"
|
||||
print "{"
|
||||
print "int i, size = sizeof(key_names)/sizeof(struct kn);"
|
||||
print ""
|
||||
print "\tfor (i = 0; i < size; i++) {"
|
||||
print "\t\tif (key_names[i].code == c) return key_names[i].name;"
|
||||
print "\t}"
|
||||
print "\treturn NULL;"
|
||||
print "}"
|
||||
print ""
|
||||
}
|
1
lib/libncurses/MKkeys.awk
Normal file
1
lib/libncurses/MKkeys.awk
Normal file
@ -0,0 +1 @@
|
||||
{printf "\tadd_to_try(%s, %s);\n", $1, $2;}
|
73
lib/libncurses/Makefile
Normal file
73
lib/libncurses/Makefile
Normal file
@ -0,0 +1,73 @@
|
||||
LIB= ncurses
|
||||
INCDIR= /usr/include
|
||||
CFLAGS+= -Wall -DMYTINFO -DTERMIOS -DGOOD_SELECT -DBSDTABS
|
||||
SHARED_LDADD+= -lmytinfo
|
||||
SRCS= lib_kernel.c lib_pad.c\
|
||||
lib_unctrl.c lib_raw.c lib_vidattr.c lib_trace.c lib_beep.c \
|
||||
lib_doupdate.c lib_refresh.c lib_initscr.c lib_newwin.c lib_addch.c \
|
||||
lib_addstr.c lib_scroll.c lib_clreol.c lib_touch.c lib_mvcur.c lib_keyname.c\
|
||||
lib_delwin.c lib_endwin.c lib_clrbot.c lib_move.c lib_printw.c \
|
||||
lib_scanw.c lib_erase.c lib_getch.c lib_options.c lib_acs.c lib_slk.c\
|
||||
lib_box.c lib_clear.c lib_delch.c lib_deleteln.c lib_insch.c \
|
||||
lib_insertln.c lib_getstr.c lib_mvwin.c lib_longname.c lib_tstp.c \
|
||||
lib_newterm.c lib_set_term.c lib_overlay.c lib_scrreg.c lib_color.c \
|
||||
lib_insstr.c lib_insdel.c lib_twait.c
|
||||
CLEANFILES+= lib_keyname.c ${.CURDIR}/keys.tries
|
||||
|
||||
beforedepend: ${.CURDIR}/keys.tries
|
||||
|
||||
beforeinstall:
|
||||
@cd ${.CURDIR}; for i in ncurses.h nterm.h unctrl.h termcap.h; do \
|
||||
cmp -s $$i ${DESTDIR}${INCDIR}/$$i || \
|
||||
$(INSTALL) $(COPY) -m 444 -o $(BINOWN) -g $(BINGRP) $$i ${DESTDIR}$(INCDIR); done
|
||||
|
||||
${.CURDIR}/keys.tries: keys.list MKkeys.awk
|
||||
awk -f ${.CURDIR}/MKkeys.awk ${.CURDIR}/keys.list > ${.CURDIR}/keys.tries
|
||||
|
||||
# in case you don't run make depend
|
||||
lib_options.o: ${.CURDIR}/keys.tries
|
||||
|
||||
lib_keyname.c: keys.list MKkeyname.awk
|
||||
awk -f ${.CURDIR}/MKkeyname.awk ${.CURDIR}/keys.list > lib_keyname.c
|
||||
|
||||
MAN3 = curs_addch.3 \
|
||||
curs_addchst.3 \
|
||||
curs_addstr.3 \
|
||||
curs_attr.3 \
|
||||
curs_beep.3 \
|
||||
curs_bkgd.3 \
|
||||
curs_border.3 \
|
||||
curs_clear.3 \
|
||||
curs_color.3 \
|
||||
curs_delch.3 \
|
||||
curs_delln.3 \
|
||||
curs_getch.3 \
|
||||
curs_getstr.3 \
|
||||
curs_getyx.3 \
|
||||
curs_inch.3 \
|
||||
curs_inchstr.3 \
|
||||
curs_initscr.3 \
|
||||
curs_inopts.3 \
|
||||
curs_insch.3 \
|
||||
curs_insstr.3 \
|
||||
curs_instr.3 \
|
||||
curs_kernel.3 \
|
||||
curs_move.3 \
|
||||
curs_outopts.3 \
|
||||
curs_overlay.3 \
|
||||
curs_pad.3 \
|
||||
curs_printw.3 \
|
||||
curs_refresh.3 \
|
||||
curs_scanw.3 \
|
||||
curs_scr_dmp.3 \
|
||||
curs_scroll.3 \
|
||||
curs_slk.3 \
|
||||
curs_termatt.3 \
|
||||
curs_touch.3 \
|
||||
curs_util.3 \
|
||||
curs_window.3 \
|
||||
ncurses.3
|
||||
|
||||
MAN5 = term.5 terminfo.5
|
||||
|
||||
.include <bsd.lib.mk>
|
39
lib/libncurses/README
Normal file
39
lib/libncurses/README
Normal file
@ -0,0 +1,39 @@
|
||||
This file is intended to help people interested in working
|
||||
on fixing ncurses, enhancing it, or porting it to other
|
||||
platforms.
|
||||
|
||||
PORTABILITY:
|
||||
The file matrix is an attempt and centralizing all portability
|
||||
information. The top line contains the different options, down
|
||||
the leftside are the operating systems supported. If an option
|
||||
is not needed then it should have an entry of NONE. Note the
|
||||
use of ':' to terminate each field. If somebody knows awk better
|
||||
than me, get in touch.
|
||||
|
||||
OS: name of operating system
|
||||
ISPOSIX: -DNONPOSIX if <unistd.h> is missing
|
||||
POSIX: -DSTRICTPOSIX if _POSIX_SOURCE turns off non-POSIX features.
|
||||
-DSVR4_ACTION if like svr4 you need _POSIX_SOURCE to have sigaction
|
||||
TERMINAL: -DNOTERMIOS if you don't have <termios.h> but have <sgtty.h>
|
||||
HEADERS: -DBRAINDEAD if system headers don't declare external variables
|
||||
TABS: -DBSDTABS if you don't have TABS3 but have OXTABS
|
||||
OPT: -DOPT_MVCUR if you want mvcur() to cost its actions or you have a
|
||||
terminal that doesn't have direct cursor addressing.
|
||||
SRCDIR: the directory where the terminfo database lives
|
||||
CC: ANSI C compiler
|
||||
FLAGS: standard compiler flags
|
||||
EXTRA: extra flags needed by individual systems
|
||||
Linux: -DBROKEN_TCDRAIN tcdrain() is broken on Linux
|
||||
Sun: -DSUNIOCTL <sys/ioctl.h> conflicts with <termios.h>
|
||||
HP-UX: -D_HPUX_SOURCE so that we get POSIX and XOPEN features.
|
||||
SVR4: -DBROKEN_TIOCGETWINSZ guess what?
|
||||
BASE: The directory under which headers and libraries will
|
||||
be installed.
|
||||
INSTALL: The name of an intelligent install program. GNU install works.
|
||||
|
||||
The awk script in script.src reads matrix and generates all the Config.*
|
||||
files.
|
||||
|
||||
There are several problems with strict POSIX systems so extra flags
|
||||
or #define's maybe needed.
|
||||
|
37
lib/libncurses/TESTS/Makefile
Normal file
37
lib/libncurses/TESTS/Makefile
Normal file
@ -0,0 +1,37 @@
|
||||
TESTS = test corner ensor getch ncurses bs gdc hanoi knight rain worm \
|
||||
over scroll2 battle newdemo scroll3 xmas copy firework testcurs \
|
||||
scroll
|
||||
|
||||
CLEANFILES += $(TESTS)
|
||||
|
||||
LIBS += -lncurses -lmytinfo
|
||||
|
||||
all: $(TESTS)
|
||||
|
||||
$(TESTS):
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) ${.CURDIR}/$@.c -o $@ $(LIBS)
|
||||
|
||||
test: test.c
|
||||
corner: corner.c
|
||||
ensor: ensor.c
|
||||
getch: getch.c
|
||||
ncurses: ncurses.c
|
||||
bs: bs.c
|
||||
gdc: gdc.c
|
||||
hanoi: hanoi.c
|
||||
knight: knight.c
|
||||
rain: rain.c
|
||||
worm: worm.c
|
||||
over: over.c
|
||||
scroll2: scroll2.c
|
||||
battle: battle.c
|
||||
newdemo: newdemo.c
|
||||
scroll3: scroll3.c
|
||||
xmas: xmas.c
|
||||
copy: copy.c
|
||||
firework: firework.c
|
||||
testcurs: testcurs.c
|
||||
scroll: scroll.c
|
||||
|
||||
.include "bsd.prog.mk"
|
||||
|
22
lib/libncurses/TESTS/README
Normal file
22
lib/libncurses/TESTS/README
Normal file
@ -0,0 +1,22 @@
|
||||
The programs in this directory are designed to test your newest toy :-)
|
||||
Check the sources for any further details.
|
||||
|
||||
asc.c - tests the line drawing functions
|
||||
attr.c - display attributes available on the terminal
|
||||
bs.c - the game of battleship
|
||||
battle.c - older version of battleship with different interface
|
||||
caps.c - output a list of all capabilites to stderr (redirect to a file
|
||||
or it will screw up the terminal)
|
||||
copy.c - test overlay
|
||||
gdc.c - Great Digital Clock, gives an example of usng color
|
||||
getch.c - tests ketpad() and getch()
|
||||
hanoi.c - the game of hanoi, also an example of using color
|
||||
knight.c - the game of Knight's Tour
|
||||
rain.c - rain drops are falling on my head..
|
||||
scroll.c - test scrolling region
|
||||
slk.c - test soft labels
|
||||
worm.c - worms run all over your screen
|
||||
firework.c - multi-colored fireworks
|
||||
newdemo.c - a demo from the PDCurses people
|
||||
testcurs.c - a test from the PDCurses people
|
||||
This will fail to link on machines that don't have vsscanf().
|
705
lib/libncurses/TESTS/battle.c
Normal file
705
lib/libncurses/TESTS/battle.c
Normal file
@ -0,0 +1,705 @@
|
||||
/*
|
||||
* battle.c - original author: Bruce Holloway
|
||||
* mods by: Chuck A DeGaul
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
#include <ncurses.h>
|
||||
|
||||
#define OTHER 1-turn
|
||||
|
||||
char numbers[] = " 0 1 2 3 4 5 6 7 8 9";
|
||||
|
||||
char carrier[] = "Aircraft Carrier";
|
||||
char battle[] = "Battleship";
|
||||
char sub[] = "Submarine";
|
||||
char destroy[] = "Destroyer";
|
||||
char ptboat[] = "PT Boat";
|
||||
|
||||
char name[40];
|
||||
char dftname[] = "Stranger";
|
||||
|
||||
struct _ships {
|
||||
char *name;
|
||||
char symbol;
|
||||
char length;
|
||||
char start; /* Coordinates - 0,0=0; 10,10=100. */
|
||||
char dir; /* Direction - 0 = right; 1 = down. */
|
||||
char hits; /* How many times has this ship been hit? (-1==sunk) */
|
||||
};
|
||||
|
||||
struct _ships plyship[] = {
|
||||
{ carrier,'A',5,0,0,0 },
|
||||
{ battle,'B',4,0,0,0 },
|
||||
{ destroy,'D',3,0,0,0 },
|
||||
{ sub,'S',3,0,0,0 },
|
||||
{ ptboat,'P',2,0,0,0 },
|
||||
};
|
||||
|
||||
struct _ships cpuship[] = {
|
||||
{ carrier,'A',5,0,0,0 },
|
||||
{ battle,'B',4,0,0,0 },
|
||||
{ destroy,'D',3,0,0,0 },
|
||||
{ sub,'S',3,0,0,0 },
|
||||
{ ptboat,'P',2,0,0,0 },
|
||||
};
|
||||
|
||||
char hits[2][100], board[2][100]; /* "Hits" board, and main board. */
|
||||
|
||||
int srchstep;
|
||||
int cpuhits;
|
||||
int cstart, cdir;
|
||||
int plywon=0, cpuwon=0; /* How many games has each won? */
|
||||
int turn; /* 0=player, 1=computer */
|
||||
int huntoffs; /* Offset on search strategy */
|
||||
|
||||
int salvo, blitz, ask, seemiss; /* options */
|
||||
|
||||
void intro(void);
|
||||
void initgame(void);
|
||||
int rnd(int);
|
||||
void plyplace(struct _ships *);
|
||||
int getdir(void);
|
||||
void placeship(struct _ships *, int, int);
|
||||
int checkplace(struct _ships *, int, int);
|
||||
void error(char *);
|
||||
void prompt(void);
|
||||
char getcoord(void);
|
||||
void cpuplace(struct _ships *);
|
||||
int awinna(void);
|
||||
int plyturn(void);
|
||||
int hitship(int);
|
||||
int cputurn(void);
|
||||
int playagain(void);
|
||||
void uninitgame();
|
||||
int sgetc(char *);
|
||||
int do_options(int, char *[]);
|
||||
int scount(int);
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
do_options(argc, argv);
|
||||
|
||||
intro();
|
||||
do {
|
||||
initgame();
|
||||
while(awinna() == -1) {
|
||||
if (!blitz) {
|
||||
if (!salvo) {
|
||||
if (turn)
|
||||
cputurn();
|
||||
else plyturn();
|
||||
} else {
|
||||
register int i;
|
||||
|
||||
i = scount(turn);
|
||||
while (i--) {
|
||||
if (turn)
|
||||
if (cputurn())
|
||||
if (awinna() != -1)
|
||||
i = 0;
|
||||
else
|
||||
if(plyturn())
|
||||
if (awinna() != -1)
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while((turn) ? cputurn() : plyturn());
|
||||
}
|
||||
turn = OTHER;
|
||||
}
|
||||
} while(playagain());
|
||||
uninitgame();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#define PR addstr
|
||||
|
||||
void
|
||||
intro()
|
||||
{
|
||||
char *tmpname;
|
||||
|
||||
srand(time(0L)); /* Kick the random number generator */
|
||||
|
||||
signal(SIGINT,uninitgame);
|
||||
if(signal(SIGQUIT,SIG_IGN) != SIG_IGN) signal(SIGQUIT,uninitgame);
|
||||
#if 1
|
||||
/* for some bizzare reason, getlogin or cuserid cause havoc with the terminal */
|
||||
if ((tmpname = getlogin()) != NULL) {
|
||||
strcpy(name, tmpname);
|
||||
} else
|
||||
#endif
|
||||
strcpy(name,dftname);
|
||||
name[0] = toupper(name[0]);
|
||||
|
||||
initscr();
|
||||
savetty();
|
||||
nonl();
|
||||
cbreak();
|
||||
noecho();
|
||||
clear();
|
||||
mvaddstr(4,29,"Welcome to Battleship!");
|
||||
move(8,0);
|
||||
PR(" \\\n");
|
||||
PR(" \\ \\ \\\n");
|
||||
PR(" \\ \\ \\ \\ \\_____________\n");
|
||||
PR(" \\ \\ \\_____________ \\ \\/ |\n");
|
||||
PR(" \\ \\/ \\ \\/ |\n");
|
||||
PR(" \\/ \\_____/ |__\n");
|
||||
PR(" ________________/ |\n");
|
||||
PR(" \\ S.S. Penguin |\n");
|
||||
PR(" \\ /\n");
|
||||
PR(" \\___________________________________________________/\n");
|
||||
mvaddstr(20,27,"Hit any key to continue..."); refresh();
|
||||
getch();
|
||||
}
|
||||
|
||||
void
|
||||
initgame()
|
||||
{
|
||||
int i;
|
||||
|
||||
clear();
|
||||
mvaddstr(0,35,"BATTLESHIP");
|
||||
mvaddstr(4,12,"Main Board");
|
||||
mvaddstr(6,0,numbers);
|
||||
move(7,0);
|
||||
for(i=0; i<10; ++i){
|
||||
printw("%c . . . . . . . . . . %c\n",i+'A',i+'A');
|
||||
}
|
||||
mvaddstr(17,0,numbers);
|
||||
mvaddstr(4,55,"Hit/Miss Board");
|
||||
mvaddstr(6,45,numbers);
|
||||
for(i=0; i<10; ++i){
|
||||
mvprintw(7+i,45,"%c . . . . . . . . . . %c",i+'A',i+'A');
|
||||
}
|
||||
mvaddstr(17,45,numbers);
|
||||
for(turn=0; turn<2; ++turn)
|
||||
for(i=0; i<100; ++i){
|
||||
hits[turn][i] = board[turn][i] = 0;
|
||||
}
|
||||
for(turn=0; turn<2; ++turn){
|
||||
for(i=0; i<5; ++i)
|
||||
if (!turn)
|
||||
plyplace(&plyship[i]);
|
||||
else
|
||||
cpuplace(&cpuship[i]);
|
||||
}
|
||||
turn = rnd(2);
|
||||
cstart = cdir = -1;
|
||||
cpuhits = 0;
|
||||
srchstep = 3;
|
||||
huntoffs = rnd(srchstep);
|
||||
}
|
||||
|
||||
int
|
||||
rnd(int n)
|
||||
{
|
||||
return(((rand() & 0x7FFF) % n));
|
||||
}
|
||||
|
||||
void
|
||||
plyplace(ss)
|
||||
struct _ships *ss;
|
||||
{
|
||||
int c, d;
|
||||
|
||||
do {
|
||||
prompt();
|
||||
printw("Place your %s (ex.%c%d) ? ",ss->name,rnd(10)+'A',rnd(10));
|
||||
c = getcoord();
|
||||
d = getdir();
|
||||
} while(!checkplace(ss,c,d));
|
||||
placeship(ss,c,d);
|
||||
}
|
||||
|
||||
int
|
||||
getdir()
|
||||
{
|
||||
|
||||
prompt();
|
||||
addstr("What direction (0=right, 1=down) ? ");
|
||||
return(sgetc("01")-'0');
|
||||
}
|
||||
|
||||
void
|
||||
placeship(ss,c,d)
|
||||
struct _ships *ss;
|
||||
int c, d;
|
||||
{
|
||||
int x, y, l, i;
|
||||
|
||||
for(l=0; l<ss->length; ++l){
|
||||
i = c + l * ((d) ? 10 : 1);
|
||||
board[turn][i] = ss->symbol;
|
||||
x = (i % 10) * 3 + 3;
|
||||
y = (i / 10) + 7;
|
||||
if(!turn) mvaddch(y,x,ss->symbol);
|
||||
}
|
||||
ss->start = c;
|
||||
ss->dir = d;
|
||||
ss->hits = 0;
|
||||
}
|
||||
|
||||
int
|
||||
checkplace(ss,c,d)
|
||||
struct _ships *ss;
|
||||
int c, d;
|
||||
{
|
||||
int x, y, l;
|
||||
|
||||
x = c%10; y = c/10;
|
||||
if(((x+ss->length) > 10 && !d) || ((y+ss->length) > 10 && d==1)){
|
||||
if(!turn)
|
||||
switch(rnd(3)){
|
||||
case 0:
|
||||
error("Ship is hanging from the edge of the world");
|
||||
break;
|
||||
case 1:
|
||||
error("Try fitting it on the board");
|
||||
break;
|
||||
case 2:
|
||||
error("Figure I won't find it if you put it there?");
|
||||
break;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
for(l=0; l<ss->length; ++l){
|
||||
x = c + l * ((d) ? 10 : 1);
|
||||
if(board[turn][x]){
|
||||
if(!turn)
|
||||
switch(rnd(3)){
|
||||
case 0:
|
||||
error("There's already a ship there");
|
||||
break;
|
||||
case 1:
|
||||
error("Collision alert! Aaaaaagh!");
|
||||
break;
|
||||
case 2:
|
||||
error("Er, Admiral, what about the other ship?");
|
||||
break;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
void
|
||||
error(s)
|
||||
char *s;
|
||||
{
|
||||
prompt();
|
||||
beep();
|
||||
printw("%s -- hit any key to continue --",s);
|
||||
refresh();
|
||||
getch();
|
||||
}
|
||||
|
||||
void
|
||||
prompt(){
|
||||
move(22,0);
|
||||
clrtoeol();
|
||||
}
|
||||
|
||||
char
|
||||
getcoord()
|
||||
{
|
||||
int ch, x, y;
|
||||
|
||||
redo:
|
||||
y = sgetc("ABCDEFGHIJ");
|
||||
do {
|
||||
ch = getch();
|
||||
if (ch == 0x7F || ch == 8) {
|
||||
addstr("\b \b");
|
||||
refresh();
|
||||
goto redo;
|
||||
}
|
||||
} while(ch < '0' || ch > '9');
|
||||
addch(x = ch);
|
||||
refresh();
|
||||
return((y-'A')*10+x-'0');
|
||||
}
|
||||
|
||||
void
|
||||
cpuplace(ss)
|
||||
struct _ships *ss;
|
||||
{
|
||||
int c, d;
|
||||
|
||||
do{
|
||||
c = rnd(100);
|
||||
d = rnd(2);
|
||||
} while(!checkplace(ss,c,d));
|
||||
placeship(ss,c,d);
|
||||
}
|
||||
|
||||
int
|
||||
awinna()
|
||||
{
|
||||
int i, j;
|
||||
struct _ships *ss;
|
||||
|
||||
for (i = 0; i < 2; ++i) {
|
||||
ss = (i) ? cpuship : plyship;
|
||||
for(j=0; j<5; ++j, ++ss)
|
||||
if(ss->length != ss->hits)
|
||||
break;
|
||||
if(j == 5) return(OTHER);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int
|
||||
plyturn()
|
||||
{
|
||||
int c, res;
|
||||
char *m;
|
||||
|
||||
prompt();
|
||||
addstr("Where do you want to shoot? ");
|
||||
c = getcoord();
|
||||
if(!(res = hits[turn][c])){
|
||||
hits[turn][c] = res = (board[OTHER][c]) ? 'H' : 'M';
|
||||
mvaddch(7+c/10,48+3*(c%10),(res=='H') ? 'H' : 'o');
|
||||
if(c = hitship(c)){
|
||||
prompt();
|
||||
switch(rnd(3)){
|
||||
case 0:
|
||||
m = "You sank my %s!";
|
||||
break;
|
||||
case 1:
|
||||
m = "I have this sinking feeling about my %s....";
|
||||
break;
|
||||
case 2:
|
||||
m = "Have some mercy for my %s!";
|
||||
break;
|
||||
}
|
||||
move(23,0);
|
||||
clrtoeol();
|
||||
beep();
|
||||
printw(m,cpuship[c-1].name); refresh();
|
||||
return(awinna() == -1);
|
||||
}
|
||||
}
|
||||
prompt();
|
||||
move(23,0); clrtoeol();
|
||||
printw("You %s.",(res=='M')?"missed":"scored a hit"); refresh();
|
||||
return(res == 'H');
|
||||
}
|
||||
|
||||
int
|
||||
hitship(c)
|
||||
int c;
|
||||
{
|
||||
struct _ships *ss;
|
||||
int sym, i, j;
|
||||
|
||||
ss = (turn) ? plyship : cpuship;
|
||||
if (!(sym = board[OTHER][c])) return(0);
|
||||
for (i = 0; i < 5; ++i, ++ss)
|
||||
if (ss->symbol == sym) {
|
||||
j = ss->hits;
|
||||
++j;
|
||||
ss->hits = j;
|
||||
if (j == ss->length)
|
||||
return(i+1);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
cputurn()
|
||||
{
|
||||
int c, res, x, y, i, d;
|
||||
|
||||
redo:
|
||||
if (cstart == -1){
|
||||
if (cpuhits){
|
||||
for(i=0, c=rnd(100); i<100; ++i, c = (c+1) % 100)
|
||||
if(hits[turn][c] == 'H')
|
||||
break;
|
||||
if(i != 100){
|
||||
cstart = c;
|
||||
cdir = -1;
|
||||
goto fndir;
|
||||
}
|
||||
}
|
||||
do {
|
||||
i = 0;
|
||||
do{
|
||||
while(hits[turn][c=rnd(100)]);
|
||||
x = c % 10; y = c / 10;
|
||||
if(++i == 1000) break;
|
||||
} while(((x+huntoffs) % srchstep) != (y % srchstep));
|
||||
if(i == 1000) --srchstep;
|
||||
} while(i == 1000);
|
||||
}
|
||||
else if(cdir == -1){
|
||||
fndir: for(i=0, d=rnd(4); i++ < 4; d = (d+1) % 4){
|
||||
x = cstart%10; y = cstart/10;
|
||||
switch(d){
|
||||
case 0: ++x; break;
|
||||
case 1: ++y; break;
|
||||
case 2: --x; break;
|
||||
case 3: --y; break;
|
||||
}
|
||||
if(x<0 || x>9 || y<0 || y>9) continue;
|
||||
if(hits[turn][c=y*10+x]) continue;
|
||||
cdir = -2;
|
||||
break;
|
||||
}
|
||||
if(i == 4){
|
||||
cstart = -1;
|
||||
goto redo;
|
||||
}
|
||||
}
|
||||
else{
|
||||
x = cstart%10; y = cstart/10;
|
||||
switch(cdir){
|
||||
case 0: ++x; break;
|
||||
case 1: ++y; break;
|
||||
case 2: --x; break;
|
||||
case 3: --y; break;
|
||||
}
|
||||
if(x<0 || x>9 || y<0 || y>9 || hits[turn][y*10+x]){
|
||||
cdir = (cdir+2) % 4;
|
||||
for(;;){
|
||||
switch(cdir){
|
||||
case 0: ++x; break;
|
||||
case 1: ++y; break;
|
||||
case 2: --x; break;
|
||||
case 3: --y; break;
|
||||
}
|
||||
if(x<0 || x>9 || y<0 || y>9){ cstart = -1;
|
||||
goto redo;
|
||||
}
|
||||
if(!hits[turn][y*10+x]) break;
|
||||
}
|
||||
}
|
||||
c = y*10 + x;
|
||||
}
|
||||
|
||||
if (!ask) {
|
||||
res = (board[OTHER][c]) ? 'H' : 'M';
|
||||
move(21,0); clrtoeol();
|
||||
printw("I shoot at %c%d. I %s!",c/10+'A',c%10,(res=='H')?"hit":"miss");
|
||||
} else {
|
||||
for(;;){
|
||||
prompt();
|
||||
printw("I shoot at %c%d. Do I (H)it or (M)iss? ",c/10+'A',c%10);
|
||||
res = sgetc("HM");
|
||||
if((res=='H' && !board[OTHER][c]) || (res=='M' && board[OTHER][c])){
|
||||
error("You lie!");
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
addch(res);
|
||||
}
|
||||
hits[turn][c] = res;
|
||||
if(res == 'H') {
|
||||
++cpuhits;
|
||||
if(cstart == -1) cdir = -1;
|
||||
cstart = c;
|
||||
if(cdir == -2) cdir = d;
|
||||
mvaddch(7+(c/10),3+3*(c%10),'*');
|
||||
if (blitz && !ask) {
|
||||
refresh();
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (seemiss) {
|
||||
mvaddch(7+(c/10),3+3*(c%10),' ');
|
||||
} else {
|
||||
if(cdir == -2) cdir = -1;
|
||||
}
|
||||
}
|
||||
if(c=hitship(c)){
|
||||
cstart = -1;
|
||||
cpuhits -= plyship[c-1].length;
|
||||
x = plyship[c-1].start;
|
||||
d = plyship[c-1].dir;
|
||||
y = plyship[c-1].length;
|
||||
for(i=0; i<y; ++i){
|
||||
hits[turn][x] = '*';
|
||||
x += (d) ? 10 : 1;
|
||||
}
|
||||
}
|
||||
if (salvo && !ask) {
|
||||
refresh();
|
||||
sleep(1);
|
||||
}
|
||||
if(awinna() != -1) return(0);
|
||||
return(res == 'H');
|
||||
}
|
||||
|
||||
int
|
||||
playagain()
|
||||
{
|
||||
int i, x, y, dx, dy, j;
|
||||
|
||||
for(i=0; i<5; ++i){
|
||||
x = cpuship[i].start; y = x/10+7; x = (x % 10) * 3 + 48;
|
||||
dx = (cpuship[i].dir) ? 0 : 3;
|
||||
dy = (cpuship[i].dir) ? 1 : 0;
|
||||
for(j=0; j < cpuship[i].length; ++j){
|
||||
mvaddch(y,x,cpuship[i].symbol);
|
||||
x += dx; y += dy;
|
||||
}
|
||||
}
|
||||
|
||||
if(awinna()) ++cpuwon; else ++plywon;
|
||||
i = 18 + strlen(name);
|
||||
if(plywon >= 10) ++i;
|
||||
if(cpuwon >= 10) ++i;
|
||||
mvprintw(2,(80-i)/2,"%s: %d Computer: %d",name,plywon,cpuwon);
|
||||
|
||||
prompt();
|
||||
printw((awinna()) ? "Want to be humiliated again, %s? "
|
||||
: "Going to give me a chance for revenge, %s? ",name);
|
||||
return(sgetc("YN") == 'Y');
|
||||
}
|
||||
|
||||
void
|
||||
uninitgame(int sig)
|
||||
{
|
||||
refresh();
|
||||
endwin();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int
|
||||
sgetc(s)
|
||||
char *s;
|
||||
{
|
||||
char *s1;
|
||||
int ch;
|
||||
|
||||
refresh();
|
||||
for (;;) {
|
||||
ch = toupper(getch());
|
||||
for (s1 = s; *s1 && ch != *s1; ++s1);
|
||||
if (*s1) {
|
||||
addch(ch);
|
||||
refresh();
|
||||
return(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* I should use getopts() from libc.a, but I'm leary that other UNIX
|
||||
* systems might not have it, although I'd love to use it.
|
||||
*/
|
||||
|
||||
int
|
||||
do_options(c,op)
|
||||
int c;
|
||||
char *op[];
|
||||
{
|
||||
register int i;
|
||||
|
||||
if (c > 1) {
|
||||
for (i=1; i<c; i++) {
|
||||
switch(op[i][0]) {
|
||||
default:
|
||||
case '?':
|
||||
fprintf(stderr, "Usage: battle [ -s | -b ] [ -a ] [ -m ]\n");
|
||||
fprintf(stderr, "\tWhere the options are:\n");
|
||||
fprintf(stderr, "\t-s : play a salvo game (mutex with -b)\n");
|
||||
fprintf(stderr, "\t-b : play a blitz game (mutex with -s)\n");
|
||||
fprintf(stderr, "\t-a : computer asks you for hit/miss\n");
|
||||
fprintf(stderr, "\t-m : computer misses are displayed\n");
|
||||
exit(1);
|
||||
break;
|
||||
case '-':
|
||||
switch(op[i][1]) {
|
||||
case 'b':
|
||||
blitz = 1;
|
||||
if (salvo == 1) {
|
||||
fprintf(stderr,
|
||||
"Bad Arg: -b and -s are mutually exclusive\n");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
salvo = 1;
|
||||
if (blitz == 1) {
|
||||
fprintf(stderr,
|
||||
"Bad Arg: -s and -b are mutually exclusive\n");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'a':
|
||||
ask = 1;
|
||||
break;
|
||||
case 'm':
|
||||
seemiss = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"Bad Arg: type \"%s ?\" for usage message\n", op[0]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(stdout, "Playing optional game (");
|
||||
if (salvo)
|
||||
fprintf(stdout, "salvo, noblitz, ");
|
||||
else if (blitz)
|
||||
fprintf(stdout, "blitz, nosalvo, ");
|
||||
else
|
||||
fprintf(stdout, "noblitz, nosalvo, ");
|
||||
|
||||
if (ask)
|
||||
fprintf(stdout, "ask, ");
|
||||
else
|
||||
fprintf(stdout, "noask, ");
|
||||
|
||||
if (seemiss)
|
||||
fprintf(stdout, "seemiss)\n");
|
||||
else
|
||||
fprintf(stdout, "noseemiss)\n");
|
||||
}
|
||||
else
|
||||
fprintf(stdout,
|
||||
"Playing standard game (no blitz, no slavo, no ask, no seemiss)\n");
|
||||
sleep(2);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
scount(who)
|
||||
int who;
|
||||
{
|
||||
int i, shots;
|
||||
struct _ships *sp;
|
||||
|
||||
if (who) {
|
||||
/* count cpu shots */
|
||||
sp = cpuship;
|
||||
} else {
|
||||
/* count player shots */
|
||||
sp = plyship;
|
||||
}
|
||||
for (i=0, shots = 0; i<5; i++, sp++) {
|
||||
/* extra test for machines with unsigned chars! */
|
||||
if (sp->hits == (char) -1 || sp->hits >= sp->length) {
|
||||
continue; /* dead ship */
|
||||
} else {
|
||||
shots++;
|
||||
}
|
||||
}
|
||||
return(shots);
|
||||
}
|
||||
|
42
lib/libncurses/TESTS/bs.6
Normal file
42
lib/libncurses/TESTS/bs.6
Normal file
@ -0,0 +1,42 @@
|
||||
.TH BATTLESHIPS 6 "Aug 23, 1989"
|
||||
.SH NAME
|
||||
bs \- battleships game
|
||||
.SH SYNOPSIS
|
||||
battle [ -b | -s ] [ -c ]
|
||||
.SH DESCRIPTION
|
||||
This program allows you to play the familiar Battleships game against the
|
||||
computer on a 10x10 board. The interface is visual and largely
|
||||
self-explanatory; you place your ships and pick your shots by moving the
|
||||
cursor around the `sea' with the rogue/hack motion keys hjklyubn.
|
||||
.PP
|
||||
Note that when selecting a ship to place, you must type the capital letter
|
||||
(these are, after all, capital ships). During ship placement, the `r' command
|
||||
may be used to ignore the current position and randomly place your currently
|
||||
selected ship. The `R' command will place all remaining ships randomly. The ^L
|
||||
command (form feed, ASCII 12) will force a screen redraw).
|
||||
.PP
|
||||
The command-line arguments control game modes.
|
||||
|
||||
.nf
|
||||
-b selects a `blitz' variant
|
||||
-s selects a `salvo' variant
|
||||
-c permits ships to be placed adjacently
|
||||
.fi
|
||||
|
||||
The `blitz' variant allows a side to shoot for as long as it continues to
|
||||
score hits.
|
||||
.PP
|
||||
The `salvo' game allows a player one shot per turn for each of his/her ships
|
||||
still afloat. This puts a premium scoring hits early and knocking out some
|
||||
ships and also makes much harder the situation where you face a superior force
|
||||
with only your PT-boat.
|
||||
.PP
|
||||
Normally, ships must be separated by at least one square of open water. The
|
||||
-c option disables this check and allows them to close-pack.
|
||||
.PP
|
||||
The algorithm the computer uses once it has found a ship to sink is provably
|
||||
optimal. The dispersion criterion for the random-fire algorithm may not be.
|
||||
.SH AUTHORS
|
||||
Originally written by one Bruce Holloway in 1986. Salvo mode added by Chuck A.
|
||||
DeGaul (cbosgd!cad). Visual user interface, `closepack' option, code rewrite
|
||||
and manual page by Eric S. Raymond <esr@snark.thyrsus.com> August 1989.
|
1119
lib/libncurses/TESTS/bs.c
Normal file
1119
lib/libncurses/TESTS/bs.c
Normal file
File diff suppressed because it is too large
Load Diff
39
lib/libncurses/TESTS/copy.c
Normal file
39
lib/libncurses/TESTS/copy.c
Normal file
@ -0,0 +1,39 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
main()
|
||||
{
|
||||
WINDOW *win1, *win2;
|
||||
int h, i;
|
||||
|
||||
initscr();
|
||||
cbreak();
|
||||
noecho();
|
||||
win1 = newwin(20, 50, 0, 20);
|
||||
for (h = 0; h < 20; h++)
|
||||
for (i = 0; i < 50; i++)
|
||||
mvwaddch(win1, h, i, 'X');
|
||||
wrefresh(win1);
|
||||
getch();
|
||||
|
||||
win2 = newwin(20, 50, 3, 30);
|
||||
for (h = 0; h < 20; h++)
|
||||
for (i = 0; i < 50; i++)
|
||||
mvwaddch(win2, h, i, 'Y');
|
||||
wnoutrefresh(win1);
|
||||
wnoutrefresh(win2);
|
||||
doupdate();
|
||||
getch();
|
||||
|
||||
/* now, remove window 2 and restore the contents of window 1 */
|
||||
i = copywin(win1, win2, 5, 10, 0, 0, 14, 39, 0);
|
||||
wnoutrefresh(win1);
|
||||
wnoutrefresh(win2);
|
||||
printw("copywin returns %d\n", i);
|
||||
wnoutrefresh(stdscr);
|
||||
doupdate();
|
||||
|
||||
getch();
|
||||
|
||||
endwin();
|
||||
}
|
||||
|
16
lib/libncurses/TESTS/corner.c
Normal file
16
lib/libncurses/TESTS/corner.c
Normal file
@ -0,0 +1,16 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int i, j;
|
||||
|
||||
initscr();
|
||||
|
||||
for (i = 0; i < LINES; i++) {
|
||||
j = mvaddch(i, COLS - 1, 'A' + i);
|
||||
}
|
||||
refresh();
|
||||
endwin();
|
||||
exit(0);
|
||||
}
|
||||
|
52
lib/libncurses/TESTS/ensor.c
Normal file
52
lib/libncurses/TESTS/ensor.c
Normal file
@ -0,0 +1,52 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
main()
|
||||
{
|
||||
int i;
|
||||
WINDOW *win;
|
||||
|
||||
initscr();
|
||||
noecho();
|
||||
nonl();
|
||||
cbreak();
|
||||
|
||||
scrollok(stdscr, TRUE);
|
||||
|
||||
for (i=0; i<25; i++)
|
||||
printw("This is in the background, this should be left alone!\n");
|
||||
|
||||
refresh();
|
||||
win=newwin(10,50,6,20);
|
||||
scrollok(win,TRUE);
|
||||
wmove(win,0,0);
|
||||
whline(win,0,49);
|
||||
wmove(win,9,0);
|
||||
whline(win,0,49);
|
||||
wrefresh(win);
|
||||
wattrset(win,A_STANDOUT);
|
||||
mvwprintw(win, 0, 14, " Scrolling Demo! ");
|
||||
mvwprintw(win, 9, 14, " Scrolling Demo! ");
|
||||
wattroff(win,A_STANDOUT);
|
||||
wsetscrreg(win, 1,8);
|
||||
|
||||
mvwprintw(win, 0, 5, " DOWN ");
|
||||
wmove(win,1,0);
|
||||
wrefresh(win);
|
||||
|
||||
getch();
|
||||
for (i=0; i<25; i++){ wprintw(win, "This is window line test (%d).\n", i);
|
||||
if (i%2) wattrset(win,A_BOLD); else wattroff(win,A_BOLD);
|
||||
wrefresh(win); }
|
||||
|
||||
mvwprintw(win, 0, 5, " UP ");
|
||||
wrefresh(win);
|
||||
getch();
|
||||
for (i=0; i<25; i++) { wmove(win,1,0); winsertln(win);
|
||||
if (i%2) wattrset(win,A_BOLD); else wattroff(win,A_BOLD);
|
||||
wprintw(win, "Scrolling backwards! (%d)\n", i); wrefresh(win); }
|
||||
|
||||
mvwprintw(win, 0, 5, " DONE "); wrefresh(win);
|
||||
|
||||
endwin();
|
||||
}
|
||||
|
113
lib/libncurses/TESTS/firework.c
Normal file
113
lib/libncurses/TESTS/firework.c
Normal file
@ -0,0 +1,113 @@
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <ncurses.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
void explode();
|
||||
|
||||
int main()
|
||||
{
|
||||
int start,end,row,diff,flag,direction,seed;
|
||||
|
||||
initscr();
|
||||
if (has_colors())
|
||||
start_color();
|
||||
seed = time((time_t *)0);
|
||||
srand(seed);
|
||||
cbreak();
|
||||
for (;;) {
|
||||
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++) {
|
||||
mvprintw(LINES - row,start + (row * direction),
|
||||
(direction < 0) ? "\\" : "/");
|
||||
if (flag++) {
|
||||
refresh();
|
||||
erase();
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
if (flag++) {
|
||||
refresh();
|
||||
flag = 0;
|
||||
}
|
||||
seed = time((time_t *)0);
|
||||
srand(seed);
|
||||
explode(LINES-row,start+(diff*direction));
|
||||
erase();
|
||||
refresh();
|
||||
}
|
||||
endwin();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void explode(int row, int col)
|
||||
{
|
||||
erase();
|
||||
mvprintw(row,col,"-");
|
||||
refresh();
|
||||
|
||||
init_pair(1,get_colour(),COLOR_BLACK);
|
||||
attrset(COLOR_PAIR(1));
|
||||
mvprintw(row-1,col-1," - ");
|
||||
mvprintw(row,col-1,"-+-");
|
||||
mvprintw(row+1,col-1," - ");
|
||||
refresh();
|
||||
|
||||
init_pair(1,get_colour(),COLOR_BLACK);
|
||||
attrset(COLOR_PAIR(1));
|
||||
mvprintw(row-2,col-2," --- ");
|
||||
mvprintw(row-1,col-2,"-+++-");
|
||||
mvprintw(row, col-2,"-+#+-");
|
||||
mvprintw(row+1,col-2,"-+++-");
|
||||
mvprintw(row+2,col-2," --- ");
|
||||
refresh();
|
||||
|
||||
init_pair(1,get_colour(),COLOR_BLACK);
|
||||
attrset(COLOR_PAIR(1));
|
||||
mvprintw(row-2,col-2," +++ ");
|
||||
mvprintw(row-1,col-2,"++#++");
|
||||
mvprintw(row, col-2,"+# #+");
|
||||
mvprintw(row+1,col-2,"++#++");
|
||||
mvprintw(row+2,col-2," +++ ");
|
||||
refresh();
|
||||
|
||||
init_pair(1,get_colour(),COLOR_BLACK);
|
||||
attrset(COLOR_PAIR(1));
|
||||
mvprintw(row-2,col-2," # ");
|
||||
mvprintw(row-1,col-2,"## ##");
|
||||
mvprintw(row, col-2,"# #");
|
||||
mvprintw(row+1,col-2,"## ##");
|
||||
mvprintw(row+2,col-2," # ");
|
||||
refresh();
|
||||
|
||||
init_pair(1,get_colour(),COLOR_BLACK);
|
||||
attrset(COLOR_PAIR(1));
|
||||
mvprintw(row-2,col-2," # # ");
|
||||
mvprintw(row-1,col-2,"# #");
|
||||
mvprintw(row, col-2," ");
|
||||
mvprintw(row+1,col-2,"# #");
|
||||
mvprintw(row+2,col-2," # # ");
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
int get_colour()
|
||||
{
|
||||
int attr;
|
||||
attr = (rand() % 16)+1;
|
||||
if (attr == 1 || attr == 9)
|
||||
attr = COLOR_RED;
|
||||
if (attr > 8)
|
||||
attr |= A_BOLD;
|
||||
return(attr);
|
||||
}
|
22
lib/libncurses/TESTS/gdc.6
Normal file
22
lib/libncurses/TESTS/gdc.6
Normal file
@ -0,0 +1,22 @@
|
||||
.TH GDC 6
|
||||
.SH NAME
|
||||
gdc \- grand digital clock (curses)
|
||||
.SH SYNOPSIS
|
||||
.B gdc
|
||||
[-s] [
|
||||
.I n
|
||||
]
|
||||
.SH DESCRIPTION
|
||||
.I Gdc
|
||||
runs a digital clock made of reverse-video blanks on a curses
|
||||
compatible VDU screen. With an optional numeric argument
|
||||
.I n
|
||||
it stops after
|
||||
.I n
|
||||
seconds (default never).
|
||||
The optional
|
||||
.B -s
|
||||
flag makes digits scroll as they change. In this curses mode implementation,
|
||||
the scrolling option has trouble keeping up.
|
||||
.SH AUTHOR
|
||||
Amos Shapir, modified for curses by John Lupien.
|
174
lib/libncurses/TESTS/gdc.c
Normal file
174
lib/libncurses/TESTS/gdc.c
Normal file
@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Grand digital clock for curses compatible terminals
|
||||
* Usage: gdc [-s] [n] -- run for n seconds (default infinity)
|
||||
* Flags: -s: scroll
|
||||
*
|
||||
* modified 10-18-89 for curses (jrl)
|
||||
* 10-18-89 added signal handling
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
#include <ncurses.h>
|
||||
#include <stdlib.h>
|
||||
#ifndef NONPOSIX
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* it won't be */
|
||||
long now; /* yeah! */
|
||||
struct tm *tm;
|
||||
|
||||
short disp[11] = {
|
||||
075557, 011111, 071747, 071717, 055711,
|
||||
074717, 074757, 071111, 075757, 075717, 002020
|
||||
};
|
||||
long old[6], next[6], new[6], mask;
|
||||
char scrol;
|
||||
|
||||
int sigtermed=0;
|
||||
|
||||
int hascolor = 0;
|
||||
|
||||
void set(int, int);
|
||||
void standt(int);
|
||||
void movto(int, int);
|
||||
|
||||
void sighndl(signo)
|
||||
int signo;
|
||||
{
|
||||
signal(signo, sighndl);
|
||||
sigtermed=signo;
|
||||
}
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
long t, a;
|
||||
int i, j, s, k;
|
||||
int n = 0;
|
||||
|
||||
signal(SIGINT,sighndl);
|
||||
signal(SIGTERM,sighndl);
|
||||
signal(SIGKILL,sighndl);
|
||||
|
||||
initscr();
|
||||
cbreak();
|
||||
noecho();
|
||||
|
||||
hascolor = has_colors();
|
||||
|
||||
if(hascolor) {
|
||||
start_color();
|
||||
init_pair(1, COLOR_BLACK, COLOR_RED);
|
||||
init_pair(2, COLOR_RED, COLOR_BLACK);
|
||||
attrset(COLOR_PAIR(2));
|
||||
}
|
||||
|
||||
clear();
|
||||
refresh();
|
||||
while(--argc > 0) {
|
||||
if(**++argv == '-')
|
||||
scrol = 1;
|
||||
else
|
||||
n = atoi(*argv);
|
||||
}
|
||||
do {
|
||||
mask = 0;
|
||||
time(&now);
|
||||
tm = localtime(&now);
|
||||
set(tm->tm_sec%10, 0);
|
||||
set(tm->tm_sec/10, 4);
|
||||
set(tm->tm_min%10, 10);
|
||||
set(tm->tm_min/10, 14);
|
||||
set(tm->tm_hour%10, 20);
|
||||
set(tm->tm_hour/10, 24);
|
||||
set(10, 7);
|
||||
set(10, 17);
|
||||
for(k=0; k<6; k++) {
|
||||
if(scrol) {
|
||||
for(i=0; i<5; i++)
|
||||
new[i] = (new[i]&~mask) | (new[i+1]&mask);
|
||||
new[5] = (new[5]&~mask) | (next[k]&mask);
|
||||
} else
|
||||
new[k] = (new[k]&~mask) | (next[k]&mask);
|
||||
next[k] = 0;
|
||||
for(s=1; s>=0; s--) {
|
||||
standt(s);
|
||||
for(i=0; i<6; i++) {
|
||||
if((a = (new[i]^old[i])&(s ? new : old)[i]) != 0) {
|
||||
for(j=0,t=1<<26; t; t>>=1,j++) {
|
||||
if(a&t) {
|
||||
if(!(a&(t<<1))) {
|
||||
movto(i, 2*j);
|
||||
}
|
||||
addstr(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!s) {
|
||||
old[i] = new[i];
|
||||
}
|
||||
}
|
||||
if(!s) {
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
movto(6, 0);
|
||||
refresh();
|
||||
sleep(1);
|
||||
if (sigtermed) {
|
||||
standend();
|
||||
clear();
|
||||
refresh();
|
||||
endwin();
|
||||
fprintf(stderr, "gdc terminated by signal %d\n", sigtermed);
|
||||
exit(1);
|
||||
}
|
||||
} while(--n);
|
||||
standend();
|
||||
clear();
|
||||
refresh();
|
||||
endwin();
|
||||
return(0);
|
||||
}
|
||||
|
||||
void
|
||||
set(int t, int n)
|
||||
{
|
||||
int i, m;
|
||||
|
||||
m = 7<<n;
|
||||
for(i=0; i<5; i++) {
|
||||
next[i] |= ((disp[t]>>(4-i)*3)&07)<<n;
|
||||
mask |= (next[i]^old[i])&m;
|
||||
}
|
||||
if(mask&m)
|
||||
mask |= m;
|
||||
}
|
||||
|
||||
void
|
||||
standt(int on)
|
||||
{
|
||||
if (on) {
|
||||
if(hascolor)
|
||||
attron(COLOR_PAIR(1));
|
||||
else
|
||||
attron(A_STANDOUT);
|
||||
} else {
|
||||
if(hascolor)
|
||||
attron(COLOR_PAIR(2));
|
||||
else
|
||||
attroff(A_STANDOUT);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
movto(int line, int col)
|
||||
{
|
||||
move(line, col);
|
||||
}
|
||||
|
29
lib/libncurses/TESTS/getch.c
Normal file
29
lib/libncurses/TESTS/getch.c
Normal file
@ -0,0 +1,29 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
main()
|
||||
{
|
||||
int c,i;
|
||||
initscr();
|
||||
cbreak();
|
||||
noecho();
|
||||
#if 1
|
||||
wtimeout(stdscr,1000);
|
||||
#endif
|
||||
scrollok(stdscr,TRUE);
|
||||
for (c='A';c<='Z';c++)
|
||||
for (i=0;i<25;i++)
|
||||
{
|
||||
move(i,i);
|
||||
addch(c);
|
||||
refresh();
|
||||
}
|
||||
move (0,0);
|
||||
while ((c=wgetch(stdscr))!='A')
|
||||
{
|
||||
if (c == EOF) printw(">>wait for keypress<<");
|
||||
else printw(">>%c<<\n",c);
|
||||
refresh();
|
||||
}
|
||||
endwin();
|
||||
}
|
||||
|
267
lib/libncurses/TESTS/hanoi.c
Normal file
267
lib/libncurses/TESTS/hanoi.c
Normal file
@ -0,0 +1,267 @@
|
||||
/*
|
||||
* Name: Towers of Hanoi.
|
||||
*
|
||||
* Desc:
|
||||
* This is a playable copy of towers of hanoi.
|
||||
* Its sole purpose is to demonstrate my Amiga Curses package.
|
||||
* This program should compile on any system that has Curses.
|
||||
* 'hanoi' will give a manual game with 7 playing pieces.
|
||||
* 'hanoi n' will give a manual game with n playing pieces.
|
||||
* 'hanoi n a' will give an auto solved game with n playing pieces.
|
||||
*
|
||||
* Author: Simon J Raybould (sie@fulcrum.bt.co.uk).
|
||||
*
|
||||
* Date: 05.Nov.90
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ncurses.h>
|
||||
|
||||
#define NPEGS 3 /* This is not configurable !! */
|
||||
#define MINTILES 3
|
||||
#define MAXTILES 9
|
||||
#define DEFAULTTILES 7
|
||||
#define TOPLINE 6
|
||||
#define BASELINE 16
|
||||
#define STATUSLINE (LINES-3)
|
||||
#define LEFTPEG 19
|
||||
#define MIDPEG 39
|
||||
#define RIGHTPEG 59
|
||||
|
||||
#define LENTOIND(x) (((x)-1)/2-1)
|
||||
#define OTHER(a,b) (3-((a)+(b)))
|
||||
|
||||
struct Peg {
|
||||
int Length[MAXTILES];
|
||||
int Count;
|
||||
};
|
||||
|
||||
struct Peg Pegs[NPEGS];
|
||||
int PegPos[] = { LEFTPEG, MIDPEG, RIGHTPEG };
|
||||
int TileColour[] = {
|
||||
COLOR_GREEN, /* Length 3 */
|
||||
COLOR_MAGENTA, /* Length 5 */
|
||||
COLOR_RED, /* Length 7 */
|
||||
COLOR_BLUE, /* Length 9 */
|
||||
COLOR_CYAN, /* Length 11 */
|
||||
COLOR_YELLOW, /* Length 13 */
|
||||
COLOR_GREEN, /* Length 15 */
|
||||
COLOR_MAGENTA, /* Length 17 */
|
||||
COLOR_RED, /* Length 19 */
|
||||
};
|
||||
int NMoves = 0;
|
||||
|
||||
void InitTiles(), DisplayTiles(), MakeMove(), AutoMove(), Usage();
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int NTiles, FromCol, ToCol;
|
||||
unsigned char AutoFlag = 0;
|
||||
|
||||
switch(argc) {
|
||||
case 1:
|
||||
NTiles = DEFAULTTILES;
|
||||
break;
|
||||
case 2:
|
||||
NTiles = atoi(argv[1]);
|
||||
if (NTiles > MAXTILES || NTiles < MINTILES) {
|
||||
fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (strcmp(argv[2], "a")) {
|
||||
Usage();
|
||||
exit(1);
|
||||
}
|
||||
NTiles = atoi(argv[1]);
|
||||
if (NTiles > MAXTILES || NTiles < MINTILES) {
|
||||
fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES);
|
||||
exit(1);
|
||||
}
|
||||
AutoFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
Usage();
|
||||
exit(1);
|
||||
}
|
||||
initscr();
|
||||
if (!has_colors()) {
|
||||
puts("terminal doesn't support color.");
|
||||
exit(1);
|
||||
}
|
||||
traceon();
|
||||
start_color();
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 9; i++)
|
||||
init_pair(i+1, COLOR_BLACK, TileColour[i]);
|
||||
}
|
||||
cbreak();
|
||||
if (LINES < 24) {
|
||||
fprintf(stderr, "Min screen length 24 lines\n");
|
||||
endwin();
|
||||
exit(1);
|
||||
}
|
||||
if(AutoFlag)
|
||||
leaveok(stdscr, TRUE); /* Attempt to remove cursor */
|
||||
InitTiles(NTiles);
|
||||
DisplayTiles();
|
||||
if(AutoFlag) {
|
||||
do {
|
||||
noecho();
|
||||
AutoMove(0, 2, NTiles);
|
||||
} while(!Solved(NTiles));
|
||||
sleep(2);
|
||||
} else {
|
||||
for(;;) {
|
||||
if(GetMove(&FromCol, &ToCol))
|
||||
break;
|
||||
if(InvalidMove(FromCol, ToCol)) {
|
||||
mvaddstr(STATUSLINE, 0, "Invalid Move !!");
|
||||
refresh();
|
||||
beep();
|
||||
continue;
|
||||
}
|
||||
MakeMove(FromCol, ToCol);
|
||||
if(Solved(NTiles)) {
|
||||
mvprintw(STATUSLINE, 0, "Well Done !! You did it in %d moves", NMoves);
|
||||
refresh();
|
||||
sleep(5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
endwin();
|
||||
}
|
||||
|
||||
int
|
||||
InvalidMove(int From, int To)
|
||||
{
|
||||
if(From == To)
|
||||
return TRUE;
|
||||
if(!Pegs[From].Count)
|
||||
return TRUE;
|
||||
if(Pegs[To].Count &&
|
||||
Pegs[From].Length[Pegs[From].Count-1] >
|
||||
Pegs[To].Length[Pegs[To].Count-1])
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
InitTiles(int NTiles)
|
||||
{
|
||||
int Size, SlotNo;
|
||||
|
||||
for(Size=NTiles*2+1, SlotNo=0; Size>=3; Size-=2)
|
||||
Pegs[0].Length[SlotNo++] = Size;
|
||||
|
||||
Pegs[0].Count = NTiles;
|
||||
Pegs[1].Count = 0;
|
||||
Pegs[2].Count = 0;
|
||||
}
|
||||
|
||||
#define gc() {noecho();getch();echo();}
|
||||
|
||||
void
|
||||
DisplayTiles()
|
||||
{
|
||||
int Line, Peg, SlotNo;
|
||||
char TileBuf[BUFSIZ];
|
||||
|
||||
erase();
|
||||
mvaddstr(1, 24, "T O W E R S O F H A N O I");
|
||||
mvaddstr(3, 34, "SJR 1990");
|
||||
mvprintw(19, 5, "Moves : %d", NMoves);
|
||||
standout();
|
||||
mvaddstr(BASELINE, 8, " ");
|
||||
|
||||
for(Line=TOPLINE; Line<BASELINE; Line++) {
|
||||
mvaddch(Line, LEFTPEG, ' ');
|
||||
mvaddch(Line, MIDPEG, ' ');
|
||||
mvaddch(Line, RIGHTPEG, ' ');
|
||||
}
|
||||
mvaddch(BASELINE, LEFTPEG, '1');
|
||||
mvaddch(BASELINE, MIDPEG, '2');
|
||||
mvaddch(BASELINE, RIGHTPEG, '3');
|
||||
standend();
|
||||
|
||||
/* Draw tiles */
|
||||
for(Peg=0; Peg<NPEGS; Peg++) {
|
||||
for(SlotNo=0; SlotNo<Pegs[Peg].Count; SlotNo++) {
|
||||
memset(TileBuf, ' ', Pegs[Peg].Length[SlotNo]);
|
||||
TileBuf[Pegs[Peg].Length[SlotNo]] = '\0';
|
||||
attrset(COLOR_PAIR(LENTOIND(Pegs[Peg].Length[SlotNo])));
|
||||
mvaddstr(BASELINE-(SlotNo+1),
|
||||
PegPos[Peg]-Pegs[Peg].Length[SlotNo]/2, TileBuf);
|
||||
}
|
||||
}
|
||||
attrset(A_NORMAL);
|
||||
refresh();
|
||||
}
|
||||
|
||||
int
|
||||
GetMove(int *From, int *To)
|
||||
{
|
||||
mvaddstr(STATUSLINE, 0, "Next move ('q' to quit) from ");
|
||||
clrtoeol();
|
||||
refresh();
|
||||
if((*From = getch()) == 'q')
|
||||
return TRUE;
|
||||
*From -= ('0'+1);
|
||||
addstr(" to ");
|
||||
clrtoeol();
|
||||
refresh();
|
||||
if((*To = getch()) == 'q')
|
||||
return TRUE;
|
||||
*To -= ('0'+1);
|
||||
move(STATUSLINE, 0);
|
||||
clrtoeol();
|
||||
refresh();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
MakeMove(int From, int To)
|
||||
{
|
||||
|
||||
Pegs[From].Count--;
|
||||
Pegs[To].Length[Pegs[To].Count] = Pegs[From].Length[Pegs[From].Count];
|
||||
Pegs[To].Count++;
|
||||
NMoves++;
|
||||
DisplayTiles();
|
||||
}
|
||||
|
||||
void
|
||||
AutoMove(int From, int To, int Num)
|
||||
{
|
||||
|
||||
if(Num == 1) {
|
||||
MakeMove(From, To);
|
||||
return;
|
||||
}
|
||||
AutoMove(From, OTHER(From, To), Num-1);
|
||||
MakeMove(From, To);
|
||||
AutoMove(OTHER(From, To), To, Num-1);
|
||||
}
|
||||
|
||||
int
|
||||
Solved(int NumTiles)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 1; i < NPEGS; i++)
|
||||
if (Pegs[i].Count == NumTiles)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
Usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: hanoi [<No Of Tiles>] [a]\n");
|
||||
fprintf(stderr, "The 'a' option causes the tower to be solved automatically\n");
|
||||
}
|
||||
|
322
lib/libncurses/TESTS/knight.c
Normal file
322
lib/libncurses/TESTS/knight.c
Normal file
@ -0,0 +1,322 @@
|
||||
/* Knights Tour - a brain game */
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <signal.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __386BSD__
|
||||
#define srand48 srandom
|
||||
#define lrand48 random
|
||||
#endif
|
||||
|
||||
short board [64]; /* the squares */
|
||||
char row, column; /* input characters */
|
||||
int rw,col; /* numeric equivalent of row and column */
|
||||
int curow,curcol; /* current row and column integers */
|
||||
int rdif, cdif; /* difference between input and current */
|
||||
int j; /* index into board */
|
||||
|
||||
char script[]={"'_)//,/(-)/__/__(_<_(__),|/|/_///_/_<//_/_)__o__o'______///_(--_(_)___,(_/,_/__(_\0"};
|
||||
|
||||
int ypos[] ={1,0,1,2,3,0,1,2,2,3,3,2,2,3,2,2,3,3,3,3,3,2,3,3,2,4,5,5,
|
||||
4,3,3,2,1,2,3,3,3,2,1,3,3,2,3,3,3,2,1,1,0,1,4,4,4,4,4,4,5,6,7,7,
|
||||
7,6,6,6,7,7,7,6,6,6,6,7,7,7,6,7,7,6,6,7,7};
|
||||
|
||||
int xpos[]={0,1,2,1,0,5,4,3,2,4,6,7,8,8,9,10,10,11,12,13,14,15,15,16,
|
||||
16,16,15,14,15,17,18,19,20,20,20,21,22,23,24,23,25,26,27,26,28,
|
||||
13,23,25,27,27,2,3,4,5,6,7,4,3,2,1,0,1,2,5,4,5,6,6,7,8,9,8,9,10,
|
||||
11,11,12,13,14,14,15};
|
||||
|
||||
static char *instructions[] =
|
||||
{
|
||||
" Knight's Tour is a board game for one player. It is played on",
|
||||
"an eight by eight board and is based on the allowable moves that a knight",
|
||||
"can make in the game of chess. For those who are unfamiliar with the",
|
||||
"game, a knight may move either on a row or a column but not diagonally.",
|
||||
"He may move one square in any direction and two squares in a perpendicular",
|
||||
"direction >or< two squares in any direction and one square in a",
|
||||
"perpendicular direction. He may not, of course, move off the board.",
|
||||
"",
|
||||
" At the beginning of a game you will be asked to either choose a",
|
||||
"starting square or allow the computer to select a random location.",
|
||||
"Squares are designated by a letter-number combination where the row is",
|
||||
"specified by a letter A-H and the numbers 1-8 define a column. Invalid",
|
||||
"entries are ignored and illegal moves produce a beep at the terminal.",
|
||||
"",
|
||||
" The objective is to visit every square on the board. When you claim",
|
||||
"a square a marker is placed on it to show where you've been. You may",
|
||||
"not revisit a square that you've landed on before.",
|
||||
"",
|
||||
" After each move the program checks to see if you have any legal",
|
||||
"moves left. If not, the game ends and your squares are counted. If",
|
||||
"you've made all the squares you win the game. Otherwise, you are told",
|
||||
"the number of squares you did make.",
|
||||
"END"
|
||||
};
|
||||
|
||||
void init(void);
|
||||
int play(void);
|
||||
void drawboard(void);
|
||||
void dosquares(void);
|
||||
void getfirst(void);
|
||||
void getrc(void);
|
||||
void putstars(void);
|
||||
int evalmove(void);
|
||||
int chkmoves(void);
|
||||
int endgame(void);
|
||||
int chksqr(int, int);
|
||||
void instruct(void);
|
||||
void title(int, int);
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
init ();
|
||||
for (;;)
|
||||
if (!play ()) {
|
||||
endwin ();
|
||||
exit (0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
init ()
|
||||
{
|
||||
|
||||
srand48 (getpid());
|
||||
initscr ();
|
||||
cbreak (); /* immediate char return */
|
||||
noecho (); /* no immediate echo */
|
||||
traceon();
|
||||
title (1,23);
|
||||
traceoff();
|
||||
mvaddstr (23, 25, "Would you like instructions? ");
|
||||
refresh();
|
||||
if ((toupper(getch())) == 'Y')
|
||||
instruct();
|
||||
clear ();
|
||||
}
|
||||
|
||||
int
|
||||
play ()
|
||||
{
|
||||
drawboard (); /* clear screen and drawboard */
|
||||
for (j = 0; j < 64; j++) board[j]=0;
|
||||
getfirst (); /* get the starting square */
|
||||
for (;;) {
|
||||
getrc();
|
||||
if (evalmove()) {
|
||||
putstars ();
|
||||
if (!chkmoves())
|
||||
return (endgame ());
|
||||
}
|
||||
else beep();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
drawboard ()
|
||||
{
|
||||
erase ();
|
||||
dosquares ();
|
||||
refresh ();
|
||||
mvaddstr (0, 7, "1 2 3 4 5 6 7 8");
|
||||
for (j = 0; j < 8; j++) mvaddch (2*j+2, 3, j + 'A');
|
||||
refresh ();
|
||||
mvaddstr (20, 5, "ROW:");
|
||||
mvaddstr (20, 27, "COLUMN:");
|
||||
mvaddstr (14, 49, "CURRENT ROW");
|
||||
mvaddstr (16, 49, "CURRENT COL");
|
||||
mvaddstr (22, 5, "A - H or Q to quit");
|
||||
mvaddstr (22, 27, "1 - 8 or ESC to cancel row");
|
||||
refresh ();
|
||||
title (1,40);
|
||||
}
|
||||
|
||||
void
|
||||
dosquares ()
|
||||
{
|
||||
mvaddstr (1, 6, "-------------------------------");
|
||||
for (j = 1; j < 9; j++){
|
||||
mvaddstr (2*j, 5, "| | | | | | | | |");
|
||||
mvaddstr (2*j+1, 6, "-------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
getfirst () /* get first square */
|
||||
{
|
||||
mvaddstr (23, 25, "(S)elect or (R)andom "); refresh ();
|
||||
do {
|
||||
row = toupper(getch());
|
||||
} while ((row != 'S') && (row != 'R'));
|
||||
if (row == 'R') {
|
||||
rw = lrand48() % 8;
|
||||
col = lrand48() % 8;
|
||||
j = 8* rw + col;
|
||||
row = rw + 'A';
|
||||
column = col + '1';
|
||||
}
|
||||
else {
|
||||
mvaddstr (23, 25, "Enter starting row and column");
|
||||
refresh ();
|
||||
getrc(); /* get row and column */
|
||||
}
|
||||
putstars ();
|
||||
move (23, 0);
|
||||
clrtobot();
|
||||
}
|
||||
|
||||
void
|
||||
getrc () /* get row and column */
|
||||
{
|
||||
noecho ();
|
||||
do {
|
||||
mvaddstr (20, 35, " ");
|
||||
refresh ();
|
||||
do {
|
||||
mvaddch (20, 11, ' ');
|
||||
move (20, 11);
|
||||
refresh ();
|
||||
row=toupper(getch());
|
||||
if (row == 'Q') {
|
||||
endwin ();
|
||||
exit (1);
|
||||
}
|
||||
} while ((row < 'A') || (row > 'H'));
|
||||
addch (row);
|
||||
move (20, 35);
|
||||
refresh ();
|
||||
do {
|
||||
column=getch();
|
||||
if (column == '\033') break;
|
||||
} while ((column < '1') || (column > '8'));
|
||||
if (column != '\033') addch (column);
|
||||
} while (column == '\033');
|
||||
refresh();
|
||||
rw = row - 'A';
|
||||
col= column - '1';
|
||||
j = 8 * rw + col;
|
||||
}
|
||||
|
||||
void
|
||||
putstars () /* place the stars, update board & currents */
|
||||
{
|
||||
mvaddch (2*curow+2, 38, ' ');
|
||||
mvaddch (2*rw+2, 38, '<');
|
||||
mvaddch (18, curcol*4+7, ' ');
|
||||
mvaddch (18, col*4+7, '^');
|
||||
curow = rw;
|
||||
curcol= col;
|
||||
mvaddstr (2 * rw + 2, 4*col+6, "***");
|
||||
mvaddch (14, 61, row);
|
||||
mvaddch (16, 61, column);
|
||||
refresh ();
|
||||
board[j] = 1;
|
||||
}
|
||||
|
||||
int
|
||||
evalmove() /* convert row and column to integers */
|
||||
/* and evaluate move */
|
||||
{
|
||||
rdif = rw - curow;
|
||||
cdif = col - curcol;
|
||||
rdif = abs(rw - curow);
|
||||
cdif = abs(col - curcol);
|
||||
refresh ();
|
||||
if ((rdif == 1) && (cdif == 2)) if (board [j] == 0) return (1);
|
||||
if ((rdif == 2) && (cdif == 1)) if (board [j] == 0) return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
chkmoves () /* check to see if valid moves are available */
|
||||
{
|
||||
if (chksqr(2,1)) return (1);
|
||||
if (chksqr(2,-1)) return (1);
|
||||
if (chksqr(-2,1)) return (1);
|
||||
if (chksqr(-2,-1)) return (1);
|
||||
if (chksqr(1,2)) return (1);
|
||||
if (chksqr(1,-2)) return (1);
|
||||
if (chksqr(-1,2)) return (1);
|
||||
if (chksqr(-1,-2)) return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
endgame () /* check for filled board or not */
|
||||
{
|
||||
rw = 0;
|
||||
for (j = 0; j < 64; j++) if (board[j] != 0) rw+=1;
|
||||
if (rw == 64) mvaddstr (20, 20, "Congratulations !! You got 'em all");
|
||||
else mvprintw (20, 20, "You have ended up with %2d squares",rw);
|
||||
mvaddstr (21, 25, "Play again ? (y/n) ");
|
||||
refresh ();
|
||||
if ((row=tolower(getch())) == 'y') return (1);
|
||||
else return (0);
|
||||
}
|
||||
|
||||
#ifndef abs
|
||||
abs(num)
|
||||
int num;
|
||||
{
|
||||
if (num < 0) return (-num);
|
||||
else return (num);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
chksqr (int n1, int n2)
|
||||
{
|
||||
int r1, c1;
|
||||
|
||||
r1 = rw + n1;
|
||||
c1 = col + n2;
|
||||
if ((r1<0) || (r1>7)) return (0);
|
||||
if ((c1<0) || (c1>7)) return (0);
|
||||
if (board[r1*8+c1] == 0) return (1);
|
||||
else return (0);
|
||||
}
|
||||
|
||||
void
|
||||
instruct()
|
||||
{
|
||||
int i;
|
||||
|
||||
clear ();
|
||||
for (i=0;;i++) {
|
||||
if ((strcmp(instructions[i],"END"))) mvaddstr (i, 0, instructions[i]);
|
||||
else {
|
||||
mvaddstr (23, 25, "Ready to play ? (y/n) ");
|
||||
refresh();
|
||||
if (toupper(getch()) == 'Y') {
|
||||
clear ();
|
||||
return;
|
||||
} else {
|
||||
clear ();
|
||||
refresh ();
|
||||
endwin ();
|
||||
exit (0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
title (y,x)
|
||||
int y,x;
|
||||
{
|
||||
char c;
|
||||
|
||||
j = 0;
|
||||
do {
|
||||
c = script[j];
|
||||
if (c == 0) break ;
|
||||
mvaddch (ypos[j]+y, xpos[j]+x, c);
|
||||
j++;
|
||||
} while (c != 0);
|
||||
refresh ();
|
||||
}
|
||||
|
||||
|
1038
lib/libncurses/TESTS/ncurses.c
Normal file
1038
lib/libncurses/TESTS/ncurses.c
Normal file
File diff suppressed because it is too large
Load Diff
350
lib/libncurses/TESTS/newdemo.c
Normal file
350
lib/libncurses/TESTS/newdemo.c
Normal file
@ -0,0 +1,350 @@
|
||||
/* $Header: c:/curses/demos/RCS/newdemo.c%v 2.0 1992/11/15 03:32:03 MH Rel $
|
||||
*
|
||||
* newdemo.c - A demo program using PDCurses. The program illustrate
|
||||
* the use of colours for text output.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <ncurses.h>
|
||||
|
||||
#define delay_output(x)
|
||||
|
||||
/*
|
||||
* The Australian map
|
||||
*/
|
||||
char *AusMap[16] =
|
||||
{
|
||||
" A A ",
|
||||
" N.T. AAAAA AAAA ",
|
||||
" AAAAAAAAAAA AAAAAAAA ",
|
||||
" AAAAAAAAAAAAAAAAAAAAAAAAA Qld.",
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
|
||||
" AAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
|
||||
" AAAAAAAAAAAAAAAAAAAAAAAAA N.S.W.",
|
||||
"W.A. AAAAAAAAA AAAAAA Vic.",
|
||||
" AAA S.A. AA",
|
||||
" A Tas.",
|
||||
""
|
||||
};
|
||||
|
||||
/*
|
||||
* Funny messages
|
||||
*/
|
||||
#define NMESSAGES 6
|
||||
|
||||
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",
|
||||
""
|
||||
};
|
||||
|
||||
/*
|
||||
* Main driver
|
||||
*/
|
||||
main()
|
||||
{
|
||||
WINDOW *win;
|
||||
int w, x, y, i, j, c, len;
|
||||
time_t t;
|
||||
char buffer[80], *message;
|
||||
int width, height;
|
||||
chtype save[80];
|
||||
void trap();
|
||||
|
||||
initscr();
|
||||
start_color();
|
||||
cbreak();
|
||||
signal(SIGINT, trap);
|
||||
width = 48;
|
||||
height = 14; /* Create a drawing window */
|
||||
win = newwin(height, width, (LINES-height)/2, (COLS-width)/2);
|
||||
if(win == NULL)
|
||||
{ endwin();
|
||||
return 1;
|
||||
}
|
||||
|
||||
while(1)
|
||||
{ init_pair(1,COLOR_WHITE,COLOR_BLUE);
|
||||
wattrset(win, COLOR_PAIR(1));
|
||||
werase(win);
|
||||
|
||||
init_pair(2,COLOR_RED,COLOR_RED);
|
||||
wattrset(win, COLOR_PAIR(2));
|
||||
box(win, ACS_VLINE, ACS_HLINE);
|
||||
wrefresh(win);
|
||||
/* Do ramdom output of a character */
|
||||
wattrset(win, COLOR_PAIR(1));
|
||||
c = 'a';
|
||||
for(i=0; i < 5000; ++i)
|
||||
{ x = rand() % (width-2) + 1;
|
||||
y = rand() % (height-2) + 1;
|
||||
mvwaddch(win, y, x, c);
|
||||
wrefresh(win);
|
||||
nodelay(win,TRUE);
|
||||
if (wgetch(win) != ERR)
|
||||
break;
|
||||
if(i == 2000)
|
||||
{ c = 'b';
|
||||
init_pair(3,COLOR_CYAN,COLOR_YELLOW);
|
||||
wattron(win, COLOR_PAIR(3));
|
||||
}
|
||||
}
|
||||
|
||||
SubWinTest(win);
|
||||
/* Erase and draw green window */
|
||||
init_pair(4,COLOR_YELLOW,COLOR_GREEN);
|
||||
wattrset(win, COLOR_PAIR(4) | A_BOLD);
|
||||
werase(win);
|
||||
wrefresh(win);
|
||||
/* Draw RED bounding box */
|
||||
wattrset(win, COLOR_PAIR(2));
|
||||
box(win, ' ', ' ');
|
||||
wrefresh(win);
|
||||
/* Display Australia map */
|
||||
wattrset(win, COLOR_PAIR(4) | A_BOLD);
|
||||
i = 0;
|
||||
while(*AusMap[i])
|
||||
{ mvwaddstr(win, i+1, 8, AusMap[i]);
|
||||
wrefresh(win);
|
||||
delay_output(100);
|
||||
++i;
|
||||
}
|
||||
|
||||
init_pair(5,COLOR_BLUE,COLOR_WHITE);
|
||||
wattrset(win, COLOR_PAIR(5) | A_BLINK);
|
||||
mvwaddstr(win, height-2, 6, " PDCurses 2.1 for DOS, OS/2 and Unix");
|
||||
wrefresh(win);
|
||||
|
||||
/* Draw running messages */
|
||||
init_pair(6,COLOR_YELLOW,COLOR_WHITE);
|
||||
wattrset(win, COLOR_PAIR(6));
|
||||
message = messages[0];
|
||||
len = strlen(message);
|
||||
j = 0;
|
||||
i = 2;
|
||||
w = width-2;
|
||||
while(j < NMESSAGES)
|
||||
{ strncpy(buffer, message, w - i);
|
||||
buffer[w-i] = 0;
|
||||
mvwaddstr(win, height/2, i, buffer);
|
||||
if(w - i < len)
|
||||
{ memset(buffer, ' ', i);
|
||||
strcpy(buffer, message + (w - i));
|
||||
buffer[strlen(buffer)] = ' ';
|
||||
buffer[i-2] = '\0';
|
||||
mvwaddstr(win, height/2, 2, buffer);
|
||||
}
|
||||
wrefresh(win);
|
||||
nodelay(win,TRUE);
|
||||
if (wgetch(win) != ERR)
|
||||
{ flushinp();
|
||||
break;
|
||||
}
|
||||
mvwaddch(win, height/2, i, ' ');
|
||||
i = ++i % w;
|
||||
if(i < 2)
|
||||
{ message = messages[++j%NMESSAGES];
|
||||
memset(buffer, ' ', w-2);
|
||||
buffer[w-2] = 0;
|
||||
mvwaddstr(win, height/2, 2, buffer);
|
||||
i = 2;
|
||||
}
|
||||
delay_output(300);
|
||||
}
|
||||
|
||||
j = 0;
|
||||
/* Draw running As across in RED */
|
||||
init_pair(7,COLOR_RED,COLOR_GREEN);
|
||||
wattron(win, COLOR_PAIR(7));
|
||||
for(i=2; i < width - 4; ++i)
|
||||
{ c = mvwinch(win, 4, i);
|
||||
save[j++] = c;
|
||||
c = c & 0x7f;
|
||||
mvwaddch(win, 4, i, c);
|
||||
}
|
||||
wrefresh(win);
|
||||
|
||||
/* Put a message up wait for a key */
|
||||
i = height-2;
|
||||
wattrset(win, COLOR_PAIR(5));
|
||||
mvwaddstr(win, i, 5, " Type a key to continue or 'Q' to quit ");
|
||||
wrefresh(win);
|
||||
|
||||
if(WaitForUser() == 1)
|
||||
break;
|
||||
|
||||
j = 0; /* Restore the old line */
|
||||
for(i=2; i < width - 4; ++i)
|
||||
mvwaddch(win, 4, i, save[j++]);
|
||||
wrefresh(win);
|
||||
|
||||
BouncingBalls(win);
|
||||
/* Put a message up wait for a key */
|
||||
i = height-2;
|
||||
wattrset(win, COLOR_PAIR(5));
|
||||
mvwaddstr(win, i, 5, " Type a key to continue or 'Q' to quit ");
|
||||
wrefresh(win);
|
||||
if(WaitForUser() == 1)
|
||||
break;
|
||||
}
|
||||
exit:
|
||||
endwin();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test sub windows
|
||||
*/
|
||||
SubWinTest(WINDOW *win)
|
||||
{
|
||||
int w, h, sw, sh, bx, by;
|
||||
WINDOW *swin1, *swin2, *swin3;
|
||||
|
||||
w = win->_maxx;
|
||||
h = win->_maxy;
|
||||
bx = win->_begx;
|
||||
by = win->_begy;
|
||||
sw = w / 3;
|
||||
sh = h / 3;
|
||||
if((swin1 = subwin(win, sh, sw, by+3, bx+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);
|
||||
wattrset(swin1, COLOR_PAIR(8));
|
||||
werase(swin1);
|
||||
mvwaddstr(swin1, 0, 3, "Sub-window 1");
|
||||
wrefresh(swin1);
|
||||
|
||||
init_pair(8,COLOR_CYAN,COLOR_MAGENTA);
|
||||
wattrset(swin2, COLOR_PAIR(8));
|
||||
werase(swin2);
|
||||
mvwaddstr(swin2, 0, 3, "Sub-window 2");
|
||||
wrefresh(swin2);
|
||||
|
||||
init_pair(8,COLOR_YELLOW,COLOR_GREEN);
|
||||
wattrset(swin3, COLOR_PAIR(8));
|
||||
werase(swin3);
|
||||
mvwaddstr(swin3, 0, 3, "Sub-window 3");
|
||||
wrefresh(swin3);
|
||||
|
||||
delwin(swin1);
|
||||
delwin(swin2);
|
||||
delwin(swin3);
|
||||
WaitForUser();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Bouncing balls
|
||||
*/
|
||||
BouncingBalls(WINDOW *win)
|
||||
{
|
||||
chtype c1, c2, c3;
|
||||
int w, h;
|
||||
int x1, y1, xd1, yd1;
|
||||
int x2, y2, xd2, yd2;
|
||||
int x3, y3, xd3, yd3;
|
||||
|
||||
w = win->_maxx;
|
||||
h = win->_maxy;
|
||||
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 = 0;
|
||||
xd3 = 0; yd3 = 1;
|
||||
nodelay(win,TRUE);
|
||||
while(wgetch(win) == ERR)
|
||||
{ x1 = xd1 > 0 ? ++x1 : --x1;
|
||||
if(x1 <= 1 || x1 >= w - 2)
|
||||
xd1 = xd1 ? 0 : 1;
|
||||
y1 = yd1 > 0 ? ++y1 : --y1;
|
||||
if(y1 <= 1 || y1 >= h - 2)
|
||||
yd1 = yd1 ? 0 : 1;
|
||||
|
||||
x2 = xd2 > 0 ? ++x2 : --x2;
|
||||
if(x2 <= 1 || x2 >= w - 2)
|
||||
xd2 = xd2 ? 0 : 1;
|
||||
y2 = yd2 > 0 ? ++y2 : --y2;
|
||||
if(y2 <= 1 || y2 >= h - 2)
|
||||
yd2 = yd2 ? 0 : 1;
|
||||
|
||||
x3 = xd3 > 0 ? ++x3 : --x3;
|
||||
if(x3 <= 1 || x3 >= w - 2)
|
||||
xd3 = xd3 ? 0 : 1;
|
||||
y3 = yd3 > 0 ? ++y3 : --y3;
|
||||
if(y3 <= 1 || y3 >= h - 2)
|
||||
yd3 = yd3 ? 0 : 1;
|
||||
|
||||
c1 = mvwinch(win, y1, x1);
|
||||
c2 = mvwinch(win, y2, x2);
|
||||
c3 = mvwinch(win, y3, x3);
|
||||
|
||||
init_pair(8,COLOR_RED,COLOR_BLUE);
|
||||
wattrset(win, COLOR_PAIR(8));
|
||||
mvwaddch(win, y1, x1, 'O');
|
||||
init_pair(8,COLOR_BLUE,COLOR_RED);
|
||||
wattrset(win, COLOR_PAIR(8));
|
||||
mvwaddch(win, y2, x2, '*');
|
||||
init_pair(8,COLOR_YELLOW,COLOR_WHITE);
|
||||
wattrset(win, COLOR_PAIR(8));
|
||||
mvwaddch(win, y3, x3, '@');
|
||||
wmove(win, 0, 0);
|
||||
wrefresh(win);
|
||||
mvwaddch(win, y1, x1, c1);
|
||||
mvwaddch(win, y2, x2, c2);
|
||||
mvwaddch(win, y3, x3, c3);
|
||||
delay_output(150);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait for user
|
||||
*/
|
||||
int WaitForUser()
|
||||
{
|
||||
time_t t;
|
||||
chtype key;
|
||||
|
||||
nodelay(stdscr,TRUE);
|
||||
t = time((time_t *)0);
|
||||
while(1)
|
||||
{
|
||||
if ((key = getch()) != ERR)
|
||||
{
|
||||
if (key == 'q' || key == 'Q')
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
if (time((time_t *)0) - t > 5)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Trap interrupt
|
||||
*/
|
||||
void trap()
|
||||
{
|
||||
endwin();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* End of DEMO.C */
|
120
lib/libncurses/TESTS/over.c
Normal file
120
lib/libncurses/TESTS/over.c
Normal file
@ -0,0 +1,120 @@
|
||||
/*********************************************************************
|
||||
* [program] overwrite() - Play with overwrite() function to *
|
||||
* attempt pop-up windows. *
|
||||
* ----------------------------------------------------------------- *
|
||||
* [written] 1-Feb-1993 by Neal Ensor (ensor@cs.utk.edu) *
|
||||
* ----------------------------------------------------------------- *
|
||||
* [notes] Originally written on SVR4 UNIX, then recompiled on *
|
||||
* Linux (Slackware 1.1.1, ncurses 1.8.1) *
|
||||
* ----------------------------------------------------------------- *
|
||||
* [problem] On ncurses, the overwrite() function doesn't seem to *
|
||||
* overwrite. Maybe I'm missing something, but this *
|
||||
* program in SVR4 displays three windows, waits for a *
|
||||
* keypress, then removes the top window. With ncurses, *
|
||||
* nothing changes on the display. *
|
||||
*********************************************************************/
|
||||
|
||||
# include <ncurses.h> /* ncurses include lives here */
|
||||
|
||||
main()
|
||||
{
|
||||
/****************************************************************
|
||||
* Declare three little window pointers... *
|
||||
****************************************************************/
|
||||
WINDOW *win, *win1, *win2;
|
||||
|
||||
/****************************************************************
|
||||
* Set up the screen... *
|
||||
****************************************************************/
|
||||
initscr();
|
||||
traceon();
|
||||
noecho();
|
||||
nonl();
|
||||
cbreak();
|
||||
refresh();
|
||||
|
||||
/****************************************************************
|
||||
* Draw three overlapping windows. *
|
||||
****************************************************************/
|
||||
win=newwin(6,45, 6,6);
|
||||
win1=newwin(10,20,5,5);
|
||||
win2=newwin(10,30,7,7);
|
||||
|
||||
/****************************************************************
|
||||
* Box them, and print a hidden message... *
|
||||
****************************************************************/
|
||||
box(win, 0, 0);
|
||||
box(win1, 0, 0);
|
||||
box(win2, 0, 0);
|
||||
mvwprintw(win1, 6,6, "Hey!");
|
||||
mvwaddch(win, 1, 1, '0');
|
||||
mvwaddch(win1, 1, 1, '1');
|
||||
mvwaddch(win2, 1, 1, '2');
|
||||
wnoutrefresh(win);
|
||||
wnoutrefresh(win1);
|
||||
wnoutrefresh(win2);
|
||||
doupdate();
|
||||
|
||||
/****************************************************************
|
||||
* Await a keypress to show what we've done so far. *
|
||||
****************************************************************/
|
||||
getch();
|
||||
|
||||
/****************************************************************
|
||||
* Now, overwrite win2 with contents of all lower windows IN *
|
||||
* ORDER from the stdscr up... *
|
||||
****************************************************************/
|
||||
if (overwrite(stdscr, win2) == ERR)
|
||||
fprintf(stderr, "overwrite(stdscr, win2) failed!\n");
|
||||
|
||||
touchwin(stdscr); wnoutrefresh(stdscr);
|
||||
touchwin(win); wnoutrefresh(win);
|
||||
touchwin(win1); wnoutrefresh(win1);
|
||||
touchwin(win2); wnoutrefresh(win2);
|
||||
doupdate();
|
||||
|
||||
getch();
|
||||
if (overwrite(win, win2) == ERR)
|
||||
fprintf(stderr, "overwrite(win, win2) failed!\n");
|
||||
|
||||
touchwin(stdscr); wnoutrefresh(stdscr);
|
||||
touchwin(win); wnoutrefresh(win);
|
||||
touchwin(win1); wnoutrefresh(win1);
|
||||
touchwin(win2); wnoutrefresh(win2);
|
||||
doupdate();
|
||||
|
||||
getch();
|
||||
if (overwrite(win1, win2) == ERR)
|
||||
fprintf(stderr, "overwrite(win1, win2) failed!\n");
|
||||
|
||||
/****************************************************************
|
||||
* Perform touches, and hidden refreshes on each window. *
|
||||
* ------------------------------------------------------------ *
|
||||
* NOTE: If you replace the wnoutrefresh() call with wrefresh()*
|
||||
* you can see all windows being redrawn untouched. *
|
||||
****************************************************************/
|
||||
touchwin(stdscr); wnoutrefresh(stdscr);
|
||||
touchwin(win); wnoutrefresh(win);
|
||||
touchwin(win1); wnoutrefresh(win1);
|
||||
touchwin(win2); wnoutrefresh(win2);
|
||||
doupdate();
|
||||
|
||||
/****************************************************************
|
||||
* At this point, win2 should be "destroyed"; having all other *
|
||||
* window contents overwritten onto it. The doupdate() should *
|
||||
* effectively remove it from the screen, leaving the others *
|
||||
* untouched. On SVR4, this happens, but not with ncurses. *
|
||||
* I'd suspect something in overwrite() causes this, as nothing *
|
||||
* appears to be overwritten after the calls, with no errors *
|
||||
* being reported. This was compiled on my Linux from Slackware*
|
||||
* 1.1.1, with ncurses1.8.1 recompiled on it, using the console *
|
||||
* entry from the "new" terminfo from ncurses1.8.1. *
|
||||
****************************************************************/
|
||||
getch();
|
||||
|
||||
/****************************************************************
|
||||
* Clean up our act and exit. *
|
||||
****************************************************************/
|
||||
endwin();
|
||||
}
|
||||
|
96
lib/libncurses/TESTS/rain.c
Normal file
96
lib/libncurses/TESTS/rain.c
Normal file
@ -0,0 +1,96 @@
|
||||
#include <ncurses.h>
|
||||
#include <signal.h>
|
||||
/* rain 11/3/1980 EPS/CITHEP */
|
||||
|
||||
#define cursor(col,row) move(row,col)
|
||||
|
||||
float ranf();
|
||||
void onsig();
|
||||
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int x, y, j;
|
||||
static int xpos[5], ypos[5];
|
||||
float r;
|
||||
float c;
|
||||
|
||||
for (j=SIGHUP;j<=SIGTERM;j++)
|
||||
if (signal(j,SIG_IGN)!=SIG_IGN) signal(j,onsig);
|
||||
|
||||
initscr();
|
||||
nl();
|
||||
noecho();
|
||||
r = (float)(LINES - 4);
|
||||
c = (float)(COLS - 4);
|
||||
for (j=5;--j>=0;) {
|
||||
xpos[j]=(int)(c* ranf())+2;
|
||||
ypos[j]=(int)(r* ranf())+2;
|
||||
}
|
||||
for (j=0;;) {
|
||||
x=(int)(c*ranf())+2;
|
||||
y=(int)(r*ranf())+2;
|
||||
|
||||
cursor(x,y); addch('.');
|
||||
|
||||
cursor(xpos[j],ypos[j]); addch('o');
|
||||
|
||||
if (j==0) j=4; else --j;
|
||||
cursor(xpos[j],ypos[j]); addch('O');
|
||||
|
||||
if (j==0) j=4; else --j;
|
||||
cursor(xpos[j],ypos[j]-1);
|
||||
addch('-');
|
||||
cursor(xpos[j]-1,ypos[j]);
|
||||
addstr("|.|");
|
||||
cursor(xpos[j],ypos[j]+1);
|
||||
addch('-');
|
||||
|
||||
if (j==0) j=4; else --j;
|
||||
cursor(xpos[j],ypos[j]-2);
|
||||
addch('-');
|
||||
cursor(xpos[j]-1,ypos[j]-1);
|
||||
addstr("/ \\");
|
||||
cursor(xpos[j]-2,ypos[j]);
|
||||
addstr("| O |");
|
||||
cursor(xpos[j]-1,ypos[j]+1);
|
||||
addstr("\\ /");
|
||||
cursor(xpos[j],ypos[j]+2);
|
||||
addch('-');
|
||||
|
||||
if (j==0) j=4; else --j;
|
||||
cursor(xpos[j],ypos[j]-2);
|
||||
addch(' ');
|
||||
cursor(xpos[j]-1,ypos[j]-1);
|
||||
addstr(" ");
|
||||
cursor(xpos[j]-2,ypos[j]);
|
||||
addstr(" ");
|
||||
cursor(xpos[j]-1,ypos[j]+1);
|
||||
addstr(" ");
|
||||
cursor(xpos[j],ypos[j]+2);
|
||||
addch(' ');
|
||||
xpos[j]=x; ypos[j]=y;
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
onsig(n)
|
||||
int n;
|
||||
{
|
||||
endwin();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
float
|
||||
ranf()
|
||||
{
|
||||
float rv;
|
||||
long r = rand();
|
||||
|
||||
r &= 077777;
|
||||
rv =((float)r/32767.);
|
||||
return rv;
|
||||
}
|
||||
|
30
lib/libncurses/TESTS/scroll.c
Normal file
30
lib/libncurses/TESTS/scroll.c
Normal file
@ -0,0 +1,30 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
main()
|
||||
{
|
||||
int i;
|
||||
|
||||
initscr();
|
||||
noecho();
|
||||
scrollok(stdscr, TRUE);
|
||||
setscrreg(0, 9);
|
||||
mvaddstr(0,0,"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
||||
mvaddstr(1,0,"bbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
|
||||
mvaddstr(2,0,"ccccccccccccccccccccccccccccc");
|
||||
mvaddstr(3,0,"ddddddddddddddddddddddddddddd");
|
||||
mvaddstr(4,0,"eeeeeeeeeeeeeeeeeeeeeeeeeeeee");
|
||||
mvaddstr(5,0,"fffffffffffffffffffffffffffff");
|
||||
mvaddstr(6,0,"ggggggggggggggggggggggggggggg");
|
||||
mvaddstr(7,0,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
|
||||
mvaddstr(8,0,"iiiiiiiiiiiiiiiiiiiiiiiiiiiii");
|
||||
mvaddstr(9,0,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
|
||||
refresh();
|
||||
for (i = 0; i < 4; i++) {
|
||||
getch();
|
||||
scrl(-1);
|
||||
refresh();
|
||||
}
|
||||
getch();
|
||||
endwin();
|
||||
|
||||
}
|
91
lib/libncurses/TESTS/scroll2.c
Normal file
91
lib/libncurses/TESTS/scroll2.c
Normal file
@ -0,0 +1,91 @@
|
||||
#include <ncurses.h>
|
||||
#define ROWS 20
|
||||
#define scroll_window wscrl
|
||||
|
||||
main()
|
||||
{
|
||||
int i;
|
||||
WINDOW * w;
|
||||
|
||||
|
||||
initscr();
|
||||
cbreak();
|
||||
noecho();
|
||||
w = newwin (ROWS, 35, 2, 25);
|
||||
scrollok(w, TRUE);
|
||||
wsetscrreg(w, 0, ROWS-1);
|
||||
|
||||
#ifdef LELE
|
||||
mvaddstr (0, 0, "With my function");
|
||||
#else
|
||||
mvaddstr (0, 0, "With the original wscrl");
|
||||
#endif
|
||||
refresh();
|
||||
|
||||
|
||||
for (i=0; i<ROWS-1; i++)
|
||||
{
|
||||
mvwprintw (w, i, 0, "Line number %d", i);
|
||||
}
|
||||
mvwaddstr (w, ROWS-1, 0, "Moving one line at a time");
|
||||
wrefresh(w);
|
||||
for (i = 0; i < 4; i++) {
|
||||
getch();
|
||||
scroll_window (w, 1);
|
||||
wrefresh(w);
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
getch();
|
||||
scroll_window (w, -1);
|
||||
wrefresh(w);
|
||||
}
|
||||
getch();
|
||||
wclear (w);
|
||||
|
||||
|
||||
for (i=0; i<ROWS-1; i++)
|
||||
{
|
||||
mvwprintw (w, i, 0, "Line number %d", i);
|
||||
}
|
||||
mvwaddstr (w, ROWS-1, 0, "Moving two line at a time");
|
||||
#ifndef LELE
|
||||
mvaddstr (0, 30, "** THIS FAILS ON MY MACHINE WITH A BUS ERROR
|
||||
**");
|
||||
#endif
|
||||
|
||||
|
||||
wrefresh(w);
|
||||
for (i = 0; i < 4; i++) {
|
||||
getch();
|
||||
scroll_window (w, 2);
|
||||
wrefresh(w);
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
getch();
|
||||
scroll_window (w, -2);
|
||||
wrefresh(w);
|
||||
}
|
||||
getch();
|
||||
wclear (w);
|
||||
for (i=0; i<ROWS-1; i++)
|
||||
{
|
||||
mvwprintw (w, i, 0, "Line number %d", i);
|
||||
}
|
||||
mvwaddstr (w, ROWS-1, 0, "Moving three line at a time");
|
||||
wrefresh(w);
|
||||
for (i = 0; i < 4; i++) {
|
||||
getch();
|
||||
scroll_window (w, 3);
|
||||
wrefresh(w);
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
getch();
|
||||
scroll_window (w, -3);
|
||||
wrefresh(w);
|
||||
}
|
||||
getch();
|
||||
|
||||
|
||||
endwin();
|
||||
}
|
||||
|
51
lib/libncurses/TESTS/scroll3.c
Normal file
51
lib/libncurses/TESTS/scroll3.c
Normal file
@ -0,0 +1,51 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
WINDOW *w, *x;
|
||||
|
||||
initscr();
|
||||
w = newwin(0, 0, 0, 0);
|
||||
if (argc > 2)
|
||||
x = newwin(0, 0, 0, 0);
|
||||
scrollok(w, TRUE);
|
||||
if (argc > 2)
|
||||
scrollok(x, TRUE);
|
||||
idlok(w, TRUE);
|
||||
if (argc > 2)
|
||||
idlok(x, TRUE);
|
||||
wmove(w, LINES - 1, 0);
|
||||
waddstr(w, "test 1 in w");
|
||||
wrefresh(w);
|
||||
sleep(1);
|
||||
if (argc == 2 || argc == 4)
|
||||
{
|
||||
waddch(w, '\n');
|
||||
sleep(1);
|
||||
waddch(w, '\n');
|
||||
sleep(1);
|
||||
waddch(w, '\n');
|
||||
sleep(1);
|
||||
beep();
|
||||
wrefresh(w);
|
||||
}
|
||||
sleep(1);
|
||||
if (argc > 2)
|
||||
{
|
||||
wmove(x, LINES - 1, 0);
|
||||
waddstr(x, "test 2 in x");
|
||||
sleep(1);
|
||||
waddch(x, '\n');
|
||||
sleep(1);
|
||||
waddch(x, '\n');
|
||||
sleep(1);
|
||||
waddch(x, '\n');
|
||||
sleep(1);
|
||||
beep();
|
||||
wrefresh(w);
|
||||
sleep(1);
|
||||
}
|
||||
endwin();
|
||||
return 0;
|
||||
}
|
||||
|
27
lib/libncurses/TESTS/test.c
Normal file
27
lib/libncurses/TESTS/test.c
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
#include <ncurses.h>
|
||||
|
||||
main()
|
||||
{
|
||||
int x, y;
|
||||
|
||||
initscr();
|
||||
cbreak();
|
||||
nodelay(stdscr, TRUE);
|
||||
|
||||
for (y = 0; y < 43; y++)
|
||||
for (x =0; x < 132; x++) {
|
||||
move(y,x);
|
||||
printw("X");
|
||||
refresh();
|
||||
if (!getch()) {
|
||||
beep();
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
nocbreak();
|
||||
endwin();
|
||||
}
|
||||
|
||||
|
532
lib/libncurses/TESTS/testcurs.c
Normal file
532
lib/libncurses/TESTS/testcurs.c
Normal file
@ -0,0 +1,532 @@
|
||||
/*
|
||||
*
|
||||
* This is a test program for the PDCurses screen package for IBM PC type
|
||||
* machines.
|
||||
* This program was written by John Burnell (johnb@kea.am.dsir.govt.nz)
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ncurses.h>
|
||||
|
||||
#ifdef __STDC__
|
||||
void inputTest (WINDOW *);
|
||||
void scrollTest (WINDOW *);
|
||||
void introTest (WINDOW *);
|
||||
int initTest (WINDOW **);
|
||||
void outputTest (WINDOW *);
|
||||
void padTest (WINDOW *);
|
||||
void resizeTest (WINDOW *);
|
||||
void display_menu(int,int);
|
||||
#else
|
||||
void inputTest ();
|
||||
void scrollTest ();
|
||||
void introTest ();
|
||||
int initTest ();
|
||||
void outputTest ();
|
||||
void padTest ();
|
||||
void resizeTest ();
|
||||
void display_menu();
|
||||
#endif
|
||||
|
||||
struct commands
|
||||
{
|
||||
char *text;
|
||||
#ifdef __STDC__
|
||||
void (*function)(WINDOW *);
|
||||
#else
|
||||
void (*function)();
|
||||
#endif
|
||||
};
|
||||
typedef struct commands COMMAND;
|
||||
#define MAX_OPTIONS 6
|
||||
COMMAND command[MAX_OPTIONS] =
|
||||
{
|
||||
{"Intro Test",introTest},
|
||||
{"Pad Test",padTest},
|
||||
{"Resize Test",resizeTest},
|
||||
{"Scroll Test",scrollTest},
|
||||
{"Input Test",inputTest},
|
||||
{"Output Test",outputTest}
|
||||
};
|
||||
|
||||
int width, height;
|
||||
|
||||
main()
|
||||
{
|
||||
WINDOW *win;
|
||||
int key,old_option=(-1),new_option=0;
|
||||
bool quit=FALSE;
|
||||
|
||||
#ifdef PDCDEBUG
|
||||
PDC_debug("testcurs started\n");
|
||||
#endif
|
||||
if (!initTest (&win)) {return 1;}
|
||||
|
||||
#ifdef A_COLOR
|
||||
if (has_colors())
|
||||
{
|
||||
init_pair(1,COLOR_WHITE,COLOR_BLUE);
|
||||
wattrset(win, COLOR_PAIR(1));
|
||||
}
|
||||
else
|
||||
wattrset(win, A_REVERSE);
|
||||
#else
|
||||
wattrset(win, A_REVERSE);
|
||||
#endif
|
||||
|
||||
erase();
|
||||
display_menu(old_option,new_option);
|
||||
while(1)
|
||||
{
|
||||
noecho();
|
||||
keypad(stdscr,TRUE);
|
||||
raw();
|
||||
key = getch();
|
||||
switch(key)
|
||||
{
|
||||
case 10:
|
||||
case 13:
|
||||
case KEY_ENTER:
|
||||
erase();
|
||||
refresh();
|
||||
(*command[new_option].function)(win);
|
||||
erase();
|
||||
display_menu(old_option,new_option);
|
||||
break;
|
||||
case KEY_UP:
|
||||
new_option = (new_option == 0) ? new_option : new_option-1;
|
||||
display_menu(old_option,new_option);
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
new_option = (new_option == MAX_OPTIONS-1) ? new_option : new_option+1;
|
||||
display_menu(old_option,new_option);
|
||||
break;
|
||||
case 'Q':
|
||||
case 'q':
|
||||
quit = TRUE;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
if (quit == TRUE)
|
||||
break;
|
||||
}
|
||||
|
||||
delwin (win);
|
||||
|
||||
endwin();
|
||||
return 0;
|
||||
}
|
||||
#ifdef __STDC__
|
||||
void Continue (WINDOW *win)
|
||||
#else
|
||||
void Continue (win)
|
||||
WINDOW *win;
|
||||
#endif
|
||||
{
|
||||
wmove(win, 10, 1);
|
||||
/* wclrtoeol(win);
|
||||
*/ mvwaddstr(win, 10, 1, " Press any key to continue");
|
||||
wrefresh(win);
|
||||
raw();
|
||||
wgetch(win);
|
||||
}
|
||||
#ifdef __STDC_
|
||||
int initTest (WINDOW **win)
|
||||
#else
|
||||
int initTest (win)
|
||||
WINDOW **win;
|
||||
#endif
|
||||
{
|
||||
#ifdef PDCDEBUG
|
||||
PDC_debug("initTest called\n");
|
||||
#endif
|
||||
initscr();
|
||||
#ifdef PDCDEBUG
|
||||
PDC_debug("after initscr()\n");
|
||||
#endif
|
||||
#ifdef A_COLOR
|
||||
if (has_colors())
|
||||
start_color();
|
||||
#endif
|
||||
width = 60;
|
||||
height = 13; /* Create a drawing window */
|
||||
*win = newwin(height, width, (LINES-height)/2, (COLS-width)/2);
|
||||
if(*win == NULL)
|
||||
{ endwin();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#ifdef __STDC__
|
||||
void introTest (WINDOW *win)
|
||||
#else
|
||||
void introTest (win)
|
||||
WINDOW *win;
|
||||
#endif
|
||||
{
|
||||
beep ();
|
||||
werase(win);
|
||||
|
||||
box(win, ACS_VLINE, ACS_HLINE);
|
||||
wrefresh(win);
|
||||
cbreak ();
|
||||
mvwaddstr(win, 1, 1, "You should have rectangle in the middle of the screen");
|
||||
mvwaddstr(win, 2, 1, "You should have heard a beep");
|
||||
Continue(win);
|
||||
return;
|
||||
}
|
||||
#ifdef __STDC__
|
||||
void scrollTest (WINDOW *win)
|
||||
#else
|
||||
void scrollTest (win)
|
||||
WINDOW *win;
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
int OldX, OldY;
|
||||
char *Message = "The window will now scroll slowly";
|
||||
|
||||
mvwprintw (win, height - 2, 1, Message);
|
||||
wrefresh (win);
|
||||
scrollok(win, TRUE);
|
||||
for (i = 1; i <= height; i++) {
|
||||
usleep (250);
|
||||
scroll(win);
|
||||
wrefresh (win);
|
||||
};
|
||||
|
||||
getmaxyx (win, OldY, OldX);
|
||||
mvwprintw (win, 6, 1, "The top of the window will scroll");
|
||||
wmove (win, 1, 1);
|
||||
wsetscrreg (win, 0, 4);
|
||||
box(win, ACS_VLINE, ACS_HLINE);
|
||||
wrefresh (win);
|
||||
for (i = 1; i <= 5; i++) {
|
||||
usleep (500);
|
||||
scroll(win);
|
||||
wrefresh (win);
|
||||
};
|
||||
wsetscrreg (win, 0, --OldY);
|
||||
|
||||
}
|
||||
#ifdef __STDC__
|
||||
void inputTest (WINDOW *win)
|
||||
#else
|
||||
void inputTest (win)
|
||||
WINDOW *win;
|
||||
#endif
|
||||
{
|
||||
int w, h, bx, by, sw, sh, i, c,num;
|
||||
char buffer [80];
|
||||
WINDOW *subWin;
|
||||
wclear (win);
|
||||
|
||||
w = win->_maxx;
|
||||
h = win->_maxy;
|
||||
bx = win->_begx;
|
||||
by = win->_begy;
|
||||
sw = w / 3;
|
||||
sh = h / 3;
|
||||
if((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2)) == NULL)
|
||||
return;
|
||||
|
||||
#ifdef A_COLOR
|
||||
if (has_colors())
|
||||
{
|
||||
init_pair(2,COLOR_CYAN,COLOR_BLUE);
|
||||
wattrset(subWin, COLOR_PAIR(2) | A_BOLD);
|
||||
}
|
||||
else
|
||||
wattrset(subWin, A_BOLD);
|
||||
#else
|
||||
wattrset(subWin, A_BOLD);
|
||||
#endif
|
||||
box(subWin, ACS_VLINE, ACS_HLINE);
|
||||
wrefresh(win);
|
||||
|
||||
nocbreak();
|
||||
mvwaddstr(win, 2, 1, "Press some keys for 5 seconds");
|
||||
mvwaddstr(win, 1, 1, "Pressing ^C should do nothing");
|
||||
wrefresh(win);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
werase (subWin);
|
||||
box(subWin, ACS_VLINE, ACS_HLINE);
|
||||
mvwprintw (subWin, 1, 1, "Time = %d", i);
|
||||
wrefresh(subWin);
|
||||
usleep(1000);
|
||||
flushinp();
|
||||
}
|
||||
|
||||
delwin (subWin);
|
||||
werase(win);
|
||||
flash();
|
||||
wrefresh(win);
|
||||
usleep(500);
|
||||
|
||||
mvwaddstr(win, 2, 1, "Press a key, followed by ENTER");
|
||||
wmove(win, 9, 10);
|
||||
wrefresh(win);
|
||||
echo();
|
||||
noraw();
|
||||
wgetch(win);
|
||||
flushinp();
|
||||
|
||||
wmove(win, 9, 10);
|
||||
wdelch(win);
|
||||
mvwaddstr(win, 4, 1, "The character should now have been deleted");
|
||||
Continue(win);
|
||||
|
||||
wclear (win);
|
||||
mvwaddstr(win, 2, 1, "Press a function key or an arrow key");
|
||||
wrefresh(win);
|
||||
keypad(win, TRUE);
|
||||
raw();
|
||||
c = wgetch(win);
|
||||
|
||||
nodelay(win, TRUE);
|
||||
wgetch(win);
|
||||
nodelay(win, FALSE);
|
||||
|
||||
refresh();
|
||||
wclear (win);
|
||||
mvwaddstr(win, 3, 2, "The window should have moved");
|
||||
mvwaddstr(win, 4, 2, "This text should have appeared without you pressing a key");
|
||||
mvwprintw(win, 2, 2, "Keycode = %d", c);
|
||||
mvwaddstr(win, 6, 2, "Enter a number then a string seperated by space");
|
||||
echo();
|
||||
noraw();
|
||||
mvwscanw(win, 7, 6, "%d %s", &num,buffer);
|
||||
mvwprintw(win, 8, 6, "String: %s Number: %d", buffer,num);
|
||||
Continue(win);
|
||||
}
|
||||
#ifdef __STDC__
|
||||
void outputTest (WINDOW *win)
|
||||
#else
|
||||
void outputTest (win)
|
||||
WINDOW *win;
|
||||
#endif
|
||||
{
|
||||
WINDOW *win1;
|
||||
char Buffer [80];
|
||||
chtype ch;
|
||||
|
||||
traceon();
|
||||
nl ();
|
||||
wclear (win);
|
||||
mvwaddstr(win, 1, 1, "You should now have a screen in the upper left corner, and this text should have wrapped");
|
||||
mvwin(win, 2, 1);
|
||||
Continue(win);
|
||||
|
||||
wclear(win);
|
||||
mvwaddstr(win, 1, 1, "A new window will appear with this text in it");
|
||||
mvwaddstr(win, 8, 1, "Press any key to continue");
|
||||
wrefresh(win);
|
||||
wgetch(win);
|
||||
|
||||
win1 = newwin(10, 50, 15, 25);
|
||||
if(win1 == NULL)
|
||||
{ endwin();
|
||||
return;
|
||||
}
|
||||
#ifdef A_COLOR
|
||||
if (has_colors())
|
||||
{
|
||||
init_pair(3,COLOR_BLUE,COLOR_WHITE);
|
||||
wattrset(win1, COLOR_PAIR(3));
|
||||
}
|
||||
else
|
||||
wattrset(win1, A_NORMAL);
|
||||
#else
|
||||
wattrset(win1, A_NORMAL);
|
||||
#endif
|
||||
wclear (win1);
|
||||
mvwaddstr(win1, 5, 1, "This text should appear; using overlay option");
|
||||
copywin(win, win1,0,0,0,0,10,50,TRUE);
|
||||
|
||||
#ifdef UNIX
|
||||
box(win1,ACS_VLINE,ACS_HLINE);
|
||||
#else
|
||||
box(win1,0xb3,0xc4);
|
||||
#endif
|
||||
wmove(win1, 8, 26);
|
||||
wrefresh(win1);
|
||||
wgetch(win1);
|
||||
|
||||
wclear(win1);
|
||||
wattron(win1, A_BLINK);
|
||||
mvwaddstr(win1, 4, 1, "This blinking text should appear in only the second window");
|
||||
wattroff(win1, A_BLINK);
|
||||
wrefresh(win1);
|
||||
wgetch(win1);
|
||||
delwin(win1);
|
||||
|
||||
wclear(win);
|
||||
wrefresh(win);
|
||||
mvwaddstr(win, 6, 2, "This line shouldn't appear");
|
||||
mvwaddstr(win, 4, 2, "Only half of the next line is visible");
|
||||
mvwaddstr(win, 5, 2, "Only half of the next line is visible");
|
||||
wmove(win, 6, 1);
|
||||
wclrtobot (win);
|
||||
wmove(win, 5, 20);
|
||||
wclrtoeol (win);
|
||||
mvwaddstr(win, 8, 2, "This line also shouldn't appear");
|
||||
wmove(win, 8, 1);
|
||||
wdeleteln(win);
|
||||
Continue(win);
|
||||
traceoff();
|
||||
|
||||
wmove (win, 5, 9);
|
||||
ch = winch (win);
|
||||
|
||||
wclear(win);
|
||||
wmove (win, 6, 2);
|
||||
waddstr (win, "The next char should be l: ");
|
||||
winsch (win, ch);
|
||||
Continue(win);
|
||||
|
||||
wmove(win, 5, 1);
|
||||
winsertln (win);
|
||||
mvwaddstr(win, 5, 2, "The lines below should have moved down");
|
||||
Continue(win);
|
||||
|
||||
wclear(win);
|
||||
wmove(win, 2, 2);
|
||||
wprintw(win, "This is a formatted string in a window: %d %s\n", 42, "is it");
|
||||
mvwaddstr(win, 10, 1, "Enter a string: ");
|
||||
wrefresh(win);
|
||||
noraw();
|
||||
echo();
|
||||
wscanw (win, "%s", Buffer);
|
||||
|
||||
wclear(win);
|
||||
mvwaddstr(win, 10, 1, "Enter a string");
|
||||
wrefresh(win);
|
||||
clear();
|
||||
move(0,0);
|
||||
printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
|
||||
mvaddstr(10, 1, "Enter a string: ");
|
||||
refresh();
|
||||
noraw();
|
||||
echo();
|
||||
scanw ("%s", Buffer);
|
||||
|
||||
wclear(win);
|
||||
curs_set(2);
|
||||
mvwaddstr(win, 1, 1, "The cursor should appear as a block");
|
||||
Continue(win);
|
||||
|
||||
wclear(win);
|
||||
curs_set(0);
|
||||
mvwaddstr(win, 1, 1, "The cursor should have disappeared");
|
||||
Continue(win);
|
||||
|
||||
wclear(win);
|
||||
curs_set(1);
|
||||
mvwaddstr(win, 1, 1, "The cursor should be an underline");
|
||||
Continue(win);
|
||||
}
|
||||
|
||||
#ifdef __STDC__
|
||||
void resizeTest(WINDOW *dummy)
|
||||
#else
|
||||
void resizeTest(dummy)
|
||||
WINDOW *dummy;
|
||||
#endif
|
||||
{
|
||||
WINDOW *win1;
|
||||
char Buffer [80];
|
||||
chtype ch;
|
||||
|
||||
savetty ();
|
||||
|
||||
clear();
|
||||
refresh();
|
||||
#ifdef __PDCURSES__
|
||||
resize(50);
|
||||
#endif
|
||||
|
||||
|
||||
win1 = newwin(11, 50, 14, 25);
|
||||
if(win1 == NULL)
|
||||
{ endwin();
|
||||
return;
|
||||
}
|
||||
#ifdef A_COLOR
|
||||
if (has_colors())
|
||||
{
|
||||
init_pair(3,COLOR_BLUE,COLOR_WHITE);
|
||||
wattrset(win1, COLOR_PAIR(3));
|
||||
}
|
||||
#endif
|
||||
wclear (win1);
|
||||
|
||||
mvwaddstr(win1, 1, 1, "The screen may now have 50 lines");
|
||||
Continue(win1);
|
||||
|
||||
resetty ();
|
||||
|
||||
wclear (win1);
|
||||
mvwaddstr(win1, 1, 1, "The screen should now be reset");
|
||||
Continue(win1);
|
||||
|
||||
delwin(win1);
|
||||
|
||||
clear();
|
||||
refresh();
|
||||
|
||||
}
|
||||
#ifdef __STDC__
|
||||
void padTest(WINDOW *dummy)
|
||||
#else
|
||||
void padTest(dummy)
|
||||
WINDOW *dummy;
|
||||
#endif
|
||||
{
|
||||
WINDOW *pad;
|
||||
|
||||
pad = newpad(50,100);
|
||||
mvwaddstr(pad, 5, 2, "This is a new pad");
|
||||
mvwaddstr(pad, 8, 0, "The end of this line should be truncated here:abcd");
|
||||
mvwaddstr(pad,11, 1, "This line should not appear.");
|
||||
wmove(pad, 10, 1);
|
||||
wclrtoeol(pad);
|
||||
mvwaddstr(pad, 10, 1, " Press any key to continue");
|
||||
prefresh(pad,0,0,0,0,10,45);
|
||||
keypad(pad, TRUE);
|
||||
raw();
|
||||
wgetch(pad);
|
||||
|
||||
mvwaddstr(pad, 35, 2, "This is displayed at line 35 in the pad");
|
||||
mvwaddstr(pad, 40, 1, " Press any key to continue");
|
||||
prefresh(pad,30,0,0,0,10,45);
|
||||
keypad(pad, TRUE);
|
||||
raw();
|
||||
wgetch(pad);
|
||||
|
||||
delwin(pad);
|
||||
}
|
||||
|
||||
#ifdef __STDC__
|
||||
void display_menu(int old_option,int new_option)
|
||||
#else
|
||||
void display_menu(old_option,new_option)
|
||||
int old_option,new_option;
|
||||
#endif
|
||||
{
|
||||
register int i;
|
||||
|
||||
attrset(A_NORMAL);
|
||||
mvaddstr(3,20,"PDCurses Test Program");
|
||||
|
||||
for (i=0;i<MAX_OPTIONS;i++)
|
||||
mvaddstr(5+i,25,command[i].text);
|
||||
if (old_option != (-1))
|
||||
mvaddstr(5+old_option,25,command[old_option].text);
|
||||
attrset(A_REVERSE);
|
||||
mvaddstr(5+new_option,25,command[new_option].text);
|
||||
attrset(A_NORMAL);
|
||||
mvaddstr(13,3,"Use Up and Down Arrows to select - Enter to run - Q to quit");
|
||||
refresh();
|
||||
}
|
||||
|
268
lib/libncurses/TESTS/worm.c
Normal file
268
lib/libncurses/TESTS/worm.c
Normal file
@ -0,0 +1,268 @@
|
||||
/*
|
||||
|
||||
@@@ @@@ @@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@ @@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@
|
||||
@@@ @@@ @@@@ @@@@ @@@@ @@@@ @@@ @@@@
|
||||
@@@ @@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
|
||||
@@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
|
||||
@@@@ @@@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@
|
||||
@@@@@@@@@@@@ @@@@ @@@@ @@@ @@@ @@@ @@@
|
||||
@@@@ @@@@ @@@@@@@@@@@@ @@@ @@@ @@@ @@@
|
||||
@@ @@ @@@@@@@@@@ @@@ @@@ @@@ @@@
|
||||
|
||||
Eric P. Scott
|
||||
Caltech High Energy Physics
|
||||
October, 1980
|
||||
|
||||
*/
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define cursor(col,row) move(row,col)
|
||||
|
||||
int Wrap;
|
||||
short *ref[128];
|
||||
static char flavor[]={
|
||||
'O', '*', '#', '$', '%', '0'
|
||||
};
|
||||
static short xinc[]={
|
||||
1, 1, 1, 0, -1, -1, -1, 0
|
||||
}, yinc[]={
|
||||
-1, 0, 1, 1, 1, 0, -1, -1
|
||||
};
|
||||
static struct worm {
|
||||
int orientation, head;
|
||||
short *xpos, *ypos;
|
||||
} worm[40];
|
||||
static char *field;
|
||||
static int length=16, number=3, trail=' ';
|
||||
static struct options {
|
||||
int nopts;
|
||||
int opts[3];
|
||||
} 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 } }
|
||||
}, 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 } }
|
||||
}, 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 } }
|
||||
}, 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 } }
|
||||
}, 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 } }
|
||||
}, 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 } }
|
||||
}, 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 } }
|
||||
}, 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 } }
|
||||
}, 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 } }
|
||||
};
|
||||
|
||||
void onsig();
|
||||
float ranf();
|
||||
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int x, y;
|
||||
int n;
|
||||
struct worm *w;
|
||||
struct options *op;
|
||||
int h;
|
||||
short *ip;
|
||||
int last, bottom;
|
||||
|
||||
for (x=1;x<argc;x++) {
|
||||
register char *p;
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
trail='.';
|
||||
break;
|
||||
default:
|
||||
usage:
|
||||
fprintf(stderr, "usage: %s [-field] [-length #] [-number #] [-trail]\n",*argv);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
signal(SIGINT, onsig);
|
||||
initscr();
|
||||
bottom = LINES-1;
|
||||
last = COLS-1;
|
||||
|
||||
ip=(short *)malloc(LINES*COLS*sizeof (short));
|
||||
|
||||
for (n=0;n<LINES;) {
|
||||
ref[n++]=ip; ip+=COLS;
|
||||
}
|
||||
for (ip=ref[0],n=LINES*COLS;--n>=0;) *ip++=0;
|
||||
ref[bottom][last]=1;
|
||||
for (n=number, w= &worm[0];--n>=0;w++) {
|
||||
w->orientation=w->head=0;
|
||||
if (!(ip=(short *)malloc(length*sizeof (short)))) {
|
||||
fprintf(stderr,"%s: out of memory\n",*argv);
|
||||
exit(1);
|
||||
}
|
||||
w->xpos=ip;
|
||||
for (x=length;--x>=0;) *ip++ = -1;
|
||||
if (!(ip=(short *)malloc(length*sizeof (short)))) {
|
||||
fprintf(stderr,"%s: out of memory\n",*argv);
|
||||
exit(1);
|
||||
}
|
||||
w->ypos=ip;
|
||||
for (y=length;--y>=0;) *ip++ = -1;
|
||||
}
|
||||
if (field) {
|
||||
register char *p;
|
||||
p=field;
|
||||
for (y=bottom;--y>=0;) {
|
||||
for (x=COLS;--x>=0;) {
|
||||
addch(*p++);
|
||||
if (!*p) p=field;
|
||||
}
|
||||
addch('\n');
|
||||
}
|
||||
}
|
||||
refresh();
|
||||
|
||||
for (;;) {
|
||||
for (n=0,w= &worm[0];n<number;n++,w++) {
|
||||
if ((x=w->xpos[h=w->head])<0) {
|
||||
cursor(x=w->xpos[h]=0,y=w->ypos[h]=bottom);
|
||||
addch(flavor[n%6]);
|
||||
ref[y][x]++;
|
||||
}
|
||||
else y=w->ypos[h];
|
||||
if (++h==length) h=0;
|
||||
if (w->xpos[w->head=h]>=0) {
|
||||
register int x1, y1;
|
||||
x1=w->xpos[h]; y1=w->ypos[h];
|
||||
if (--ref[y1][x1]==0) {
|
||||
cursor(x1,y1); 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:
|
||||
refresh();
|
||||
endwin();
|
||||
exit(0);
|
||||
case 1:
|
||||
w->orientation=op->opts[0];
|
||||
break;
|
||||
default:
|
||||
w->orientation=op->opts[(int)(ranf()*(float)op->nopts)];
|
||||
}
|
||||
cursor(x+=xinc[w->orientation], y+=yinc[w->orientation]);
|
||||
if (!Wrap||x!=last||y!=bottom) addch(flavor[n%6]);
|
||||
ref[w->ypos[h]=y][w->xpos[h]=x]++;
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
onsig()
|
||||
{
|
||||
endwin();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
float
|
||||
ranf()
|
||||
{
|
||||
float rv;
|
||||
long r = rand();
|
||||
|
||||
r &= 077777;
|
||||
rv =((float)r/32767.);
|
||||
return rv;
|
||||
}
|
1192
lib/libncurses/TESTS/xmas.c
Normal file
1192
lib/libncurses/TESTS/xmas.c
Normal file
File diff suppressed because it is too large
Load Diff
113
lib/libncurses/curs_addch.3
Normal file
113
lib/libncurses/curs_addch.3
Normal file
@ -0,0 +1,113 @@
|
||||
.TH curs_addch 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_addch\fR: \fBaddch\fR, \fBwaddch\fR, \fBmvaddch\fR, \fBmvwaddch\fR,
|
||||
\fBechochar\fR, \fBwechochar\fR - add a character (with attributes) to a
|
||||
\fBncurses\fR window, then advance the cursor
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBaddch(chtype ch);\fR
|
||||
.br
|
||||
\fBwaddch(WINDOW *win, chtype ch);\fR
|
||||
.br
|
||||
\fBmvaddch(int y, int x, chtype ch);\fR
|
||||
.br
|
||||
\fBmvwaddch(WINDOW *win, int y, int x, chtype ch);\fR
|
||||
.br
|
||||
\fBechochar(chtype ch);\fR
|
||||
.br
|
||||
\fBwechochar(WINDOW *win, chtype ch);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBaddch\fR, \fBwaddch\fR, \fBmvaddch\fR and \fBmvwaddch\fR routines put
|
||||
the character \fIch\fR into the given window at its current window position,
|
||||
which is then advanced. They are analogous to \fBputchar\fR in \fBstdio\fR(3).
|
||||
If the advance is at the right margin, the cursor automatically wraps to the
|
||||
beginning of the next line. At the bottom of the scrolling region, if
|
||||
\fBscrollok\fR is enabled, the scrolling region is scrolled up one line.
|
||||
|
||||
If \fIch\fR is a tab, newline, or backspace, the cursor is moved appropriately
|
||||
within the window. A newline also does a \fBclrtoeol\fR before moving. Tabs
|
||||
are considered to be at every eighth column.
|
||||
|
||||
If \fIch\fR is any control character other than tab, newline, or backspace, it
|
||||
is drawn in \fB^\fR\fIX\fR notation. Calling \fBwinch\fR after adding a
|
||||
control character does not return the control character, but instead returns
|
||||
the representation of the control character. (To emit control characters
|
||||
literally, use \fBechochar\fR.)
|
||||
|
||||
Video attributes can be combined with a character by OR-ing them into the
|
||||
parameter. This results in these attributes also being set. (The intent here
|
||||
is that text, including attributes, can be copied from one place to another
|
||||
using \fBinch\fR and \fBaddch\fR.) [see \fBstandout\fR, predefined video
|
||||
attribute constants, on the curs_attr(3X) page].
|
||||
|
||||
The \fBechochar\fR and \fBwechochar\fR routines are functionally equivalent to
|
||||
a call to \fBaddch\fR followed by a call to \fBrefresh\fR, or a call to
|
||||
\fBwaddch\fR followed by a call to \fBwrefresh\fR. The knowledge that only a
|
||||
single character is being output is taken into consideration and, for
|
||||
non-control characters, a considerable performance gain might be seen by using
|
||||
these routines instead of their equivalents.
|
||||
.SS Line Graphics
|
||||
The following variables may be used to add line drawing characters to the
|
||||
screen with routines of the \fBaddch\fR family. The default character listed
|
||||
below is used if the \fBacsc\fR capability doesn't define a terminal-specific
|
||||
replacement for it. The names are taken from the the VT100 nomenclature.
|
||||
|
||||
.TS
|
||||
l l l
|
||||
_ _ _
|
||||
l l l.
|
||||
\fIName\fR \fIDefault\fR \fIDescription\fR
|
||||
ACS_ULCORNER + upper left-hand corner
|
||||
ACS_LLCORNER + lower left-hand corner
|
||||
ACS_URCORNER + upper right-hand corner
|
||||
ACS_LRCORNER + lower right-hand corner
|
||||
ACS_RTEE + right tee
|
||||
ACS_LTEE + left tee
|
||||
ACS_BTEE + bottom tee
|
||||
ACS_TTEE + top tee
|
||||
ACS_HLINE - horizontal line
|
||||
ACS_VLINE | vertical line
|
||||
ACS_PLUS + plus
|
||||
ACS_S1 - scan line 1
|
||||
ACS_S9 \&_ scan line 9
|
||||
ACS_DIAMOND + diamond
|
||||
ACS_CKBOARD : checker board (stipple)
|
||||
ACS_DEGREE ' degree symbol
|
||||
ACS_PLMINUS # plus/minus
|
||||
ACS_BULLET o bullet
|
||||
ACS_LARROW < arrow pointing left
|
||||
ACS_RARROW > arrow pointing right
|
||||
ACS_DARROW v arrow pointing down
|
||||
ACS_UARROW ^ arrow pointing up
|
||||
ACS_BOARD # board of squares
|
||||
ACS_LANTERN # lantern symbol
|
||||
ACS_BLOCK # solid square block
|
||||
.TE
|
||||
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion, unless otherwise noted in the
|
||||
preceding routine descriptions.
|
||||
.SH BUGS
|
||||
The ncurses implementation does not yet handle insertion of a character at the
|
||||
bottom-rightmost position of the screen correctly. If the terminal has the
|
||||
auto_right_margin property, the real screen will be scrolled up one regardless
|
||||
of whether scrollok has been enabled for \fBstdscr\fR.
|
||||
|
||||
The entry points \fBechochar\fR and \fBwechochar\fR are not yet implemented in
|
||||
ncurses 1.8.1.
|
||||
.SH NOTES
|
||||
Note that \fBaddch\fR, \fBmvaddch\fR, \fBmvwaddch\fR, and
|
||||
\fBechochar\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_attr\fR(3X), \fBcurs_clear\fR(3X),
|
||||
\fBcurs_inch\fR(3X), \fBcurs_outopts\fR(3X), \fBcurs_refresh\fR(3X),
|
||||
\fBputc\fR(3S).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
50
lib/libncurses/curs_addchst.3
Normal file
50
lib/libncurses/curs_addchst.3
Normal file
@ -0,0 +1,50 @@
|
||||
.TH curs_addchstr 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_addchstr\fR: \fBaddchstr\fR, \fBaddchnstr\fR, \fBwaddchstr\fR,
|
||||
\fBwaddchnstr\fR, \fBmvaddchstr\fR, \fBmvaddchnstr\fR, \fBmvwaddchstr\fR,
|
||||
\fBmvwaddchnstr\fR - add string of characters (and attributes) to a
|
||||
\fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint addchstr(chtype *chstr);\fR
|
||||
.br
|
||||
\fBint addchnstr(chtype *chstr, int n);\fR
|
||||
.br
|
||||
\fBint waddchstr(WINDOW *win, chtype *chstr);\fR
|
||||
.br
|
||||
\fBint waddchnstr(WINDOW *win, chtype *chstr, int n);\fR
|
||||
.br
|
||||
\fBint mvaddchstr(int y, int x, chtype *chstr);\fR
|
||||
.br
|
||||
\fBint mvaddchnstr(int y, int x, chtype *chstr, int n);\fR
|
||||
.br
|
||||
\fBint mvwaddchstr(WINDOW *win, int y, int x, chtype *chstr);\fR
|
||||
.br
|
||||
\fBint mvwaddchnstr(WINDOW *win, int y, int x, chtype *chstr, int n);\fR
|
||||
.SH DESCRIPTION
|
||||
These routines copy \fIchstr\fR into the window image structure at and after
|
||||
the current cursor position. The four routines with \fIn\fR as the last
|
||||
argument copy at most \fIn\fR elements, but no more than will fit on the line.
|
||||
If \fBn\fR=\fB-1\fR then the whole string is copied, to the maximum number of
|
||||
characters that will fit on the line.
|
||||
|
||||
The window cursor is \fINOT\fR advanced, and these routines work faster than
|
||||
\fBwaddnstr\fR. On the other hand, care must be taken when using them because
|
||||
they don't perform any kind of checking (such as for the newline character),
|
||||
they don't advance the current cursor position, and they truncate the string if
|
||||
it crosses the right margin, rather then wrapping it around to the new line.
|
||||
.SH RETURN VALUES
|
||||
All these routines return the integer \fBERR\fR upon failure and an integer
|
||||
value other than \fBERR\fR upon successful completion, unless
|
||||
otherwise noted in the preceding routine descriptions.
|
||||
.SH NOTES
|
||||
Note that all routines except \fBwaddchnstr\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
44
lib/libncurses/curs_addstr.3
Normal file
44
lib/libncurses/curs_addstr.3
Normal file
@ -0,0 +1,44 @@
|
||||
.TH curs_addstr 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_addstr\fR: \fBaddstr\fR, \fBaddnstr\fR, \fBwaddstr\fR, \fBwaddnstr\fR,
|
||||
\fBmvaddstr\fR, \fBmvaddnstr\fR, \fBmvwaddstr\fR, \fBmvwaddnstr\fR - add a
|
||||
string of characters to a \fBncurses\fR window and advance cursor
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint addstr(char *str);\fR
|
||||
.br
|
||||
\fBint addnstr(char *str, int n);\fR
|
||||
.br
|
||||
\fBint waddstr(WINDOW *win, char *str);\fR
|
||||
.br
|
||||
\fBint waddnstr(WINDOW *win, char *str, int n);\fR
|
||||
.br
|
||||
\fBint mvaddstr(y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint mvaddnstr(y, int x, char *str, int n);\fR
|
||||
.br
|
||||
\fBint mvwaddstr(WINDOW *win, int y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint mvwaddnstr(WINDOW *win, int y, int x, char *str,
|
||||
int n);\fR
|
||||
.SH DESCRIPTION
|
||||
These routines write the characters of the null terminated character string
|
||||
\fIstr\fR on the given window. It is similar to calling \fBwaddch\fR once for
|
||||
each character in the string. The four routines with \fIn\fR as the last
|
||||
argument write at most \fIn\fR characters. If \fIn\fR is negative, then the
|
||||
entire string will be added.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that all of these routines except \fBwaddstr\fR and \fBwaddnstr\fR may be
|
||||
macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_addch\fR(3X).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
87
lib/libncurses/curs_attr.3
Normal file
87
lib/libncurses/curs_attr.3
Normal file
@ -0,0 +1,87 @@
|
||||
.TH curs_attr 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_attr\fR: \fBattroff\fR, \fBwattroff\fR, \fBattron\fR, \fBwattron\fR,
|
||||
\fBattrset\fR, \fBwattrset\fR, \fBstandend\fR, \fBwstandend\fR, \fBstandout\fR,
|
||||
\fBwstandout\fR - \fBncurses\fR character and window attribute control routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
.br
|
||||
\fBint attroff(int attrs);\fR
|
||||
.br
|
||||
\fBint wattroff(WINDOW *win, int attrs);\fR
|
||||
.br
|
||||
\fBint attron(int attrs);\fR
|
||||
.br
|
||||
\fBint wattron(WINDOW *win, int attrs);\fR
|
||||
.br
|
||||
\fBint attrset(int attrs);\fR
|
||||
.br
|
||||
\fBint wattrset(WINDOW *win, int attrs);\fR
|
||||
.br
|
||||
\fBint standend(void);\fR
|
||||
.br
|
||||
\fBint wstandend(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint standout(void);\fR
|
||||
.br
|
||||
\fBint wstandout(WINDOW *win);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines manipulate the current attributes of the named window. The
|
||||
current attributes of a window apply to all characters that are written into
|
||||
the window with \fBwaddch\fR, \fBwaddstr\fR and \fBwprintw\fR. Attributes are
|
||||
a property of the character, and move with the character through any scrolling
|
||||
and insert/delete line/character operations. To the extent possible, they are
|
||||
displayed as appropriate modifications to the graphic rendition of characters
|
||||
put on the screen.
|
||||
|
||||
The routine \fBattrset\fR sets the current attributes of the given window to
|
||||
\fIattrs\fR. The routine \fBattroff\fR turns off the named attributes without
|
||||
turning any other attributes on or off. The routine \fBattron\fR turns on the
|
||||
named attributes without affecting any others. The routine \fBstandout\fR is
|
||||
the same as \fBattron(A_STANDOUT)\fR. The routine \fBstandend\fR is the same
|
||||
as \fBattrset(A_NORMAL)\fR or \fBattrest(0)\fR, that is, it turns off all
|
||||
attributes.
|
||||
.SS Attributes
|
||||
The following video attributes, defined in \fB<ncurses.h>\fR, can be passed to
|
||||
the routines \fBattron\fR, \fBattroff\fR, and \fBattrset\fR, or OR-ed with the
|
||||
characters passed to \fBaddch\fR.
|
||||
|
||||
.nf
|
||||
\fBA_NORMAL\fR Normal display (no highlight)
|
||||
\fBA_STANDOUT\fR Best highlighting mode of the terminal.
|
||||
\fBA_UNDERLINE\fR Underlining
|
||||
\fBA_REVERSE\fR Reverse video
|
||||
\fBA_BLINK\fR Blinking
|
||||
\fBA_DIM\fR Half bright
|
||||
\fBA_BOLD\fR Extra bright or bold
|
||||
\fBA_ALTCHARSET\fR Alternate character set
|
||||
\fBA_CHARTEXT\fR Bit-mask to extract a character
|
||||
\fBCOLOR_PAIR(\fR\fIn\fR\fB)\fR Color-pair number \fIn\fR
|
||||
.fi
|
||||
|
||||
The following macro is the reverse of \fBCOLOR_PAIR(\fR\fIn\fR\fB)\fR:
|
||||
|
||||
.DS C
|
||||
\fBPAIR_NUMBER(\fIattrs\fR) Returns the pair number associated
|
||||
with the \fBCOLOR_PAIR(\fR\fIn\fR\fB)\fR attribute.
|
||||
.DE
|
||||
|
||||
The return values of these routines are not neaningful (many are implemented
|
||||
as macro-expanded assignments and simply return their argument). The SVr4
|
||||
manual page claims (falsely) that these routines always return \fB1\fR.
|
||||
.SH BUGS
|
||||
As of 1.8.2, ncurses attributes still have a tendency to stick on in some
|
||||
circumstances where SVr4 curses attributes would turn off.
|
||||
.SH NOTES
|
||||
Note that \fBattroff\fR, \fBwattroff\fR, \fBattron\fR, \fBwattron\fR,
|
||||
\fBattrset\fR, \fBwattrset\fR, \fBstandend\fR and \fBstandout\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_addch\fR(3X), \fBcurs_addstr\fR(3X),
|
||||
\fBcurs_printw\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
29
lib/libncurses/curs_beep.3
Normal file
29
lib/libncurses/curs_beep.3
Normal file
@ -0,0 +1,29 @@
|
||||
.TH curs_beep 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_beep\fR: \fBbeep\fR, \fBflash\fR - \fBncurses\fR bell and screen flash routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint beep(void);\fR
|
||||
.br
|
||||
\fBint flash(void);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBbeep\fR and \fBflash\fR routines are used to alert the terminal user.
|
||||
The routine \fBbeep\fR sounds an audible alarm on the terminal, if possible;
|
||||
otherwise it flashes the screen (visible bell). The routine \fBflash\fR
|
||||
flashes the screen, and if that is not possible, sounds the alert. If neither
|
||||
alert is possible, nothing happens. Nearly all terminals have an audible alert
|
||||
(bell or beep), but only some can flash the screen.
|
||||
.SH RETURN VALUE
|
||||
These routines always return \fBOK\fR.
|
||||
.SH CAPABILITIES
|
||||
\fBbell\fR, \fBflash_screen\fR.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
50
lib/libncurses/curs_bkgd.3
Normal file
50
lib/libncurses/curs_bkgd.3
Normal file
@ -0,0 +1,50 @@
|
||||
.TH curs_bkgd 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_bkgd\fR: \fBbkgdset\fR, \fBwbkgdset\fR, \fBbkgd\fR,
|
||||
\fBwbkgd\fR - \fBncurses\fR window background manipulation routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBvoid bkgdset(chtype ch);\fR
|
||||
.br
|
||||
\fBvoid wbkgdset(WINDOW *win, chtype ch);\fR
|
||||
.br
|
||||
\fBint bkgd(chtype ch);\fR
|
||||
.br
|
||||
\fBint wbkgd(WINDOW *win, chtype ch);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBbkgdset\fR and \fBwbkgdset\fR routines manipulate the
|
||||
background of the named window. Background is a \fBchtype\fR
|
||||
consisting of any combination of attributes and a character. The
|
||||
attribute part of the background is combined (ORed) with all non-blank
|
||||
characters that are written into the window with \fBwaddch\fR. Both
|
||||
the character and attribute parts of the background are combined with
|
||||
the blank characters. The background becomes a property of the
|
||||
character and moves with the character through any scrolling and
|
||||
insert/delete line/character operations. To the extent possible on a
|
||||
particular terminal, the attribute part of the background is displayed
|
||||
as the graphic rendition of the character put on the screen.
|
||||
|
||||
The \fBbkgd\fR and \fBwbkgd\fR routines combine the new background
|
||||
with every position in the window. Background is any combination of
|
||||
attributes and a character. Only the attribute part is used to set
|
||||
the background of non-blank characters, while both character and
|
||||
attributes are used for blank positions. To the extent possible on a
|
||||
particular terminal, the attribute part of the background is displayed
|
||||
as the graphic rendition of the character put on the screen.
|
||||
.SH RETURN VALUE
|
||||
\fBbkgd\fR and \fBwbkgd\fR return the integer \fBOK\fR, or a
|
||||
non-negative integer, if \fBimmedok\fR is set.
|
||||
.SH NOTES
|
||||
Note that \fBbkgdset\fR and \fBbkgd\fR may be macros.
|
||||
.SH BUGS
|
||||
These features and \fBimmedok\fR are not yet implemented in ncurses 1.8.1.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_addch\fR(3X), \fBcurs_outopts\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
67
lib/libncurses/curs_border.3
Normal file
67
lib/libncurses/curs_border.3
Normal file
@ -0,0 +1,67 @@
|
||||
.TH curs_border 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_border\fR: \fBborder\fR, \fBwborder\fR, \fBbox\fR,
|
||||
\fBhline\fR, \fBwhline\fR, \fBvline\fR, \fBwvline\fR - create
|
||||
\fBncurses\fR borders, horizontal and vertical lines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
.br
|
||||
\fBint border(chtype ls, chtype rs, chtype ts, chtype bs,
|
||||
chtype tl, chtype tr, chtype bl, chtype br);\fR
|
||||
.br
|
||||
\fBint wborder(WINDOW *win, chtype ls, chtype rs,
|
||||
chtype ts, chtype bs, chtype tl, chtype tr,
|
||||
chtype bl, chtype br);\fR
|
||||
.br
|
||||
\fBint box(WINDOW *win, chtype verch, chtype horch);\fR
|
||||
.br
|
||||
\fBint hline(chtype ch, int n);\fR
|
||||
.br
|
||||
\fBint whline(WINDOW *win, chtype ch, int n);\fR
|
||||
.br
|
||||
\fBint vline(chtype ch, int n);\fR
|
||||
.br
|
||||
\fBint wvline(WINDOW *win, chtype ch, int n);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBborder\fR, \fBwborder\fR and \fBbox\fR routines draw a box around the
|
||||
edges of a window. The argument \fIls\fR is a character and attributes used
|
||||
for the left side of the border, \fIrs\fR - right side, \fIts\fR - top side,
|
||||
\fIbs\fR - bottom side, \fItl\fR - top left-hand corner, \fItr\fR - top
|
||||
right-hand corner, \fIbl\fR - bottom left-hand corner, and \fIbr\fR - bottom
|
||||
right-hand corner. If any of these arguments is zero, then the following
|
||||
default values (defined in \fBncurses.h\fR) are used instead: \fBACS_VLINE,
|
||||
ACS_VLINE, ACS_HLINE, ACS_HLINE, \fBACS_ULCORNER, ACS_URCORNER, ACS_BLCORNER,
|
||||
ACS_BRCORNER.\fR
|
||||
|
||||
\fBbox(\fR\fIwin\fR\gB, \fR\fIverch\fR\fB, \fR\fIhorch\fR\fB)\fR is a shorthand
|
||||
for the following call: \fBwborder(\fR\fIwin\fR\fB,\fR \fIverch\fR\fB,\fR
|
||||
\fIverch\fR\fB,\fR \fIhorch\fR\fB,\fR \fIhorch\fR\fB, 0, 0, 0, 0)\fR.
|
||||
|
||||
The \fBhline\fR and \fBwhline\fR functions draw a horizontal (left to right)
|
||||
line using \fIch\fR starting at the current cursor position in the window. The
|
||||
current cursor position is not changed. The line is at most \fIn\fR characters
|
||||
long, or as many as fit into the window.
|
||||
|
||||
The \fBvline\fR and \fBwvline\fR functions draw a vertical (top to bottom) line
|
||||
using \fIch\fR starting at the current cursor position in the window. The
|
||||
current cursor position is not changed. The line is at most \fIn\fR characters
|
||||
long, or as many as fit into the window.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBOK\fR. The SVr4.0 manual says "or a
|
||||
non-negative integer if \fBimmedok\fR is set", but this appears to be an error.
|
||||
.SH NOTES
|
||||
The borders generated by these functions are \fIinside\fR borders (this
|
||||
is also true of SVr4 curses, though the fact is not documented).
|
||||
|
||||
Note that \fBborder\fR and \fBbox\fR may be macros.
|
||||
.SH BUGS
|
||||
The \fBimmedok\fR function is not yet implemented in ncurses 1.8.1.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_outopts\fR(3X).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
53
lib/libncurses/curs_clear.3
Normal file
53
lib/libncurses/curs_clear.3
Normal file
@ -0,0 +1,53 @@
|
||||
.TH curs_clear 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_clear\fR: \fBerase\fR, \fBwerase\fR, \fBclear\fR,
|
||||
\fBwclear\fR, \fBclrtobot\fR, \fBwclrtobot\fR, \fBclrtoeol\fR,
|
||||
\fBwclrtoeol\fR - clear all or part of a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB# include <ncurses.h>\fR
|
||||
|
||||
\fBint erase(void);\fR
|
||||
.br
|
||||
\fBint werase(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint clear(void);\fR
|
||||
.br
|
||||
\fBint wclear(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint clrtobot(void);\fR
|
||||
.br
|
||||
\fBint wclrtobot(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint clrtoeol(void);\fR
|
||||
.br
|
||||
\fBint wclrtoeol(WINDOW *win);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBerase\fR and \fBwerase\fR routines copy blanks to every
|
||||
position in the window, clearing the screen.
|
||||
|
||||
The \fBclear\fR and \fBwclear\fR routines are like \fBerase\fR and
|
||||
\fBwerase\fR, but they also call \fBclearok\fR, so that the screen is
|
||||
cleared completely on the next call to \fBwrefresh\fR for that window
|
||||
and repainted from scratch.
|
||||
|
||||
The \fBclrtobot\fR and \fBwclrtobot\fR routines erase from the cursor to the
|
||||
end of screen. That is, they erase all lines below the cursor in the window.
|
||||
Also, the current line to the right of the cursor, inclusive, is erased.
|
||||
|
||||
The \fBclrtoeol\fR and \fBwclrtoeol\fR routines erase the current line
|
||||
to the right of the cursor, inclusive.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBOK\fR, or a non-negative integer if
|
||||
\fBimmedok\fR is set.
|
||||
.SH NOTES
|
||||
Note that \fBerase\fR, \fBwerase\fR, \fBclear\fR, \fBwclear\fR,
|
||||
\fBclrtobot\fR, and \fBclrtoeol\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_outopts\fR(3X), \fBcurs_refresh\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
138
lib/libncurses/curs_color.3
Normal file
138
lib/libncurses/curs_color.3
Normal file
@ -0,0 +1,138 @@
|
||||
.TH curs_color 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_color\fR: \fBstart_color\fR, \fBinit_pair\fR,
|
||||
\fBinit_color\fR, \fBhas_colors\fR, \fBcan_change_color\fR,
|
||||
\fBcolor_content\fR, \fBpair_content\fR - \fBncurses\fR color
|
||||
manipulation routines
|
||||
.SH SYNOPSIS
|
||||
\fB# include <ncurses.h>\fR
|
||||
.br
|
||||
\fBint start_color(void);\fR
|
||||
.br
|
||||
\fBint init_pair(short pair, short f, short b);\fR
|
||||
.br
|
||||
\fBint init_color(short color, short r, short g, short b);\fR
|
||||
.br
|
||||
\fBbool has_colors(void);\fR
|
||||
.br
|
||||
\fBbool can_change_color(void);\fR
|
||||
.br
|
||||
\fBint color_content(short color, short *r, short *g, short *b);\fR
|
||||
.br
|
||||
\fBint pair_content(short pair, short *f, short *b);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
.SS Overview
|
||||
\fBncurses\fR support color attributes on terminals with that capability. To
|
||||
use these routines \fBstart_color\fR must be called, usually right after
|
||||
\fBinitscr\fR. Colors are always used in pairs (referred to as color-pairs).
|
||||
A color-pair consists of a foreground color (for characters) and a background
|
||||
color (for the blank field on which the characters are displayed). A
|
||||
programmer initializes a color-pair with the routine \fBinit_pair\fR. After it
|
||||
has been initialized, \fBCOLOR_PAIR\fR(\fIn\fR), a macro defined in
|
||||
\fB<ncurses.h>\fR, can be used as a new video attribute.
|
||||
|
||||
If a terminal is capable of redefining colors, the programmer can use the
|
||||
routine \fBinit_color\fR to change the definition of a color. The routines
|
||||
\fBhas_colors\fR and \fBcan_change_color\fR return \fBTRUE\fR or \fBFALSE\fR,
|
||||
depending on whether the terminal has color capabilities and whether the
|
||||
programmer can change the colors. The routine \fBcolor_content\fR allows a
|
||||
programmer to extract the amounts of red, green, and blue components in an
|
||||
initialized color. The routine \fBpair_content\fR allows a programmer to find
|
||||
out how a given color-pair is currently defined.
|
||||
.SS Routine Descriptions
|
||||
The \fBstart_color\fR routine requires no arguments. It must be
|
||||
called if the programmer wants to use colors, and before any other
|
||||
color manipulation routine is called. It is good practice to call
|
||||
this routine right after \fBinitscr\fR. \fBstart_color\fR initializes
|
||||
eight basic colors (black, red, green, yellow, blue, magenta, cyan,
|
||||
and white), and two global variables, \fBCOLORS\fR and
|
||||
\fBCOLOR_PAIRS\fR (respectively defining the maximum number of colors
|
||||
and color-pairs the terminal can support). It also restores the
|
||||
colors on the terminal to the values they had when the terminal was
|
||||
just turned on.
|
||||
|
||||
The \fBinit_pair\fR routine changes the definition of a color-pair. It takes
|
||||
three arguments: the number of the color-pair to be changed, the foreground
|
||||
color number, and the background color number. The value of the first argument
|
||||
must be between \fB1\fR and \fBCOLOR_PAIRS-1\fR. The value of the second and
|
||||
third arguments must be between 0 and \fBCOLORS\fR (the 0 color pair is wired
|
||||
to white on black and cannot be changed). If the color-pair was previously
|
||||
initialized, the screen is refreshed and all occurrences of that color-pair is
|
||||
changed to the new definition.
|
||||
|
||||
The \fBinit_color\fR routine changes the definition of a color. It takes four
|
||||
arguments: the number of the color to be changed followed by three RGB values
|
||||
(for the amounts of red, green, and blue components). The value of the first
|
||||
argument must be between \fB0\fR and \fBCOLORS\fR. (See the section
|
||||
\fBColors\fR for the default color index.) Each of the last three arguments
|
||||
must be a value between 0 and 1000. When \fBinit_color\fR is used, all
|
||||
occurrences of that color on the screen immediately change to the new
|
||||
definition.
|
||||
|
||||
The \fBhas_colors\fR routine requires no arguments. It returns \fBTRUE\fR if
|
||||
the terminal can manipulate colors; otherwise, it returns \fBFALSE\fR. This
|
||||
routine facilitates writing terminal-independent programs. For example, a
|
||||
programmer can use it to decide whether to use color or some other video
|
||||
attribute.
|
||||
|
||||
The \fBcan_change_color\fR routine requires no arguments. It returns
|
||||
\fBTRUE\fR if the terminal supports colors and can change their definitions;
|
||||
other, it returns \fBFALSE\fR. This routine facilitates writing
|
||||
terminal-independent programs.
|
||||
|
||||
The \fBcolor_content\fR routine gives programmers a way to find the intensity
|
||||
of the red, green, and blue (RGB) components in a color. It requires four
|
||||
arguments: the color number, and three addresses of \fBshort\fRs for storing
|
||||
the information about the amounts of red, green, and blue components in the
|
||||
given color. The value of the first argument must be between 0 and
|
||||
\fBCOLORS\fR. The values that are stored at the addresses pointed to by the
|
||||
last three arguments are between 0 (no component) and 1000 (maximum amount of
|
||||
component).
|
||||
|
||||
The \fBpair_content\fR routine allows programmers to find out what colors a
|
||||
given color-pair consists of. It requires three arguments: the color-pair
|
||||
number, and two addresses of \fBshort\fRs for storing the foreground and the
|
||||
background color numbers. The value of the first argument must be between 1
|
||||
and \fBCOLOR_PAIRS-1\fR. The values that are stored at the addresses pointed
|
||||
to by the second and third arguments are between 0 and \fBCOLORS\fR.
|
||||
.SS Colors
|
||||
In \fB<ncurses.h>\fR the following macros are defined. These are the default
|
||||
colors. \fBncurses\fR also assumes that \fBCOLOR_BLACK\fR is the default
|
||||
background color for all terminals.
|
||||
|
||||
.nf
|
||||
\fBCOLOR_BLACK\fR
|
||||
\fBCOLOR_RED\fR
|
||||
\fBCOLOR_GREEN\fR
|
||||
\fBCOLOR_YELLOW\fR
|
||||
\fBCOLOR_BLUE\fR
|
||||
\fBCOLOR_MAGENTA\fR
|
||||
\fBCOLOR_CYAN\fR
|
||||
\fBCOLOR_WHITE\fR
|
||||
.fi
|
||||
.SH RETURN VALUE
|
||||
All routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
|
||||
upon successful completion.
|
||||
.SH BUGS
|
||||
Several caveats apply onn 386 and 486 machines with VGA-compatible graphics:
|
||||
|
||||
COLOR_YELLOW is actually brown. To get yellow, use COLOR_YELLOW combined with
|
||||
the \fBA_BOLD\fR attribute.
|
||||
|
||||
The A_BLINK attribute should in theory cause the background to go bright. This
|
||||
often fails to work, and even some cards for which it mostly works (such as the
|
||||
Paradise and compatibles) do the wrong thing when you try to set a bright
|
||||
"yellow" background (you get a blinking yellow foreground instead).
|
||||
|
||||
Color RGB values are not settable.
|
||||
.SH CAPABILITIES
|
||||
\fBsetf\fR, \fBsetb\fR, \fBsetaf\fR, \fBsetab\fR. The ncurses library uses
|
||||
the second pair by preference, falling back to the first.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_initscr\fR(3X), \fBcurs_attr\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
34
lib/libncurses/curs_delch.3
Normal file
34
lib/libncurses/curs_delch.3
Normal file
@ -0,0 +1,34 @@
|
||||
.TH curs_delch 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_delch\fR: \fBdelch\fR, \fBwdelch\fR, \fBmvdelch\fR, \fBmvwdelch\fR -
|
||||
delete character under the cursor in a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint delch(void);\fR
|
||||
.br
|
||||
\fBint wdelch(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint mvdelch(int y, int x);\fR
|
||||
.br
|
||||
\fBint mvwdelch(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines delete the character under the cursor; all characters to the
|
||||
right of the cursor on the same line are moved to the left one position and the
|
||||
last character on the line is filled with a blank. The cursor position does
|
||||
not change (after moving to \fIy\fR, \fIx\fR, if specified). (This does not
|
||||
imply use of the hardware delete character feature.)
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that \fBdelch\fR, \fBmvdelch\fR, and \fBmvwdelch\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
53
lib/libncurses/curs_delln.3
Normal file
53
lib/libncurses/curs_delln.3
Normal file
@ -0,0 +1,53 @@
|
||||
.TH curs_deleteln 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_deleteln\fR: \fBdeleteln\fR, \fBwdeleteln\fR, \fBinsdelln\fR,
|
||||
\fBwinsdelln\fR, \fBinsertln\fR, \fBwinsertln\fR - delete and insert
|
||||
lines in a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint deleteln(void);\fR
|
||||
.br
|
||||
\fBint wdeleteln(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint insdelln(int n);\fR
|
||||
.br
|
||||
\fBint winsdelln(WINDOW *win, int n);\fR
|
||||
.br
|
||||
\fBint insertln(void);\fR
|
||||
.br
|
||||
\fBint winsertln(WINDOW *win);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBdeleteln\fR and \fBwdeleteln\fR routines delete the line under the
|
||||
cursor in the window; all lines below the current line are moved up one line.
|
||||
The bottom line of the window is cleared. The cursor position does not change.
|
||||
|
||||
The \fBinsdelln\fR and \fBwinsdelln\fR routines, for positive \fIn\fR, insert
|
||||
\fIn\fR lines into the specified window above the current line. The \fIn\fR
|
||||
bottom lines are lost. For negative \fIn\fR, delete \fIn\fR lines (starting
|
||||
with the one under the cursor), and move the remaining lines up. The bottom
|
||||
\fIn\fR lines are cleared. The current cursor position remains the same.
|
||||
|
||||
The \fBinsertln\fR and \fBinsertln\fR routines, insert a blank line above the
|
||||
current line and the bottom line is lost.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer
|
||||
value other than \fBERR\fR upon successful completion.
|
||||
.SH BUGS
|
||||
All the above should be implemented through \fBwinsdelln\fR() but
|
||||
currently only \fBinsdelln\fR() is implemented in terms of it.
|
||||
.SH NOTES
|
||||
Note that all but \fBwinsdelln\fR may be a macros.
|
||||
|
||||
These routines do not require a hardware line delete or insert feature in the
|
||||
terminal. In fact, they won't use hardware line delete/insert unless
|
||||
\fBidlok(..., TRUE)\fR has been set on the current window.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
188
lib/libncurses/curs_getch.3
Normal file
188
lib/libncurses/curs_getch.3
Normal file
@ -0,0 +1,188 @@
|
||||
.TH curs_getch 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_getch\fR: \fBgetch\fR, \fBwgetch\fR, \fBmvgetch\fR,
|
||||
\fBmvwgetch\fR, \fBungetch\fR - get (or push back) characters from
|
||||
\fBncurses\fR terminal keyboard
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint getch(void);\fR
|
||||
.br
|
||||
\fBint wgetch(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint mvgetch(int y, int x);\fR
|
||||
.br
|
||||
\fBint mvwgetch(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
\fBint ungetch(int ch);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBgetch\fR, \fBwgetch\fR, \fBmvgetch\fR and \fBmvwgetch\fR, routines read
|
||||
a character from the window. In no-delay mode, if no input is waiting, the
|
||||
value \fBERR\fR is returned. In delay mode, the program waits until the system
|
||||
passes text through to the program. Depending on the setting of \fBcbreak\fR,
|
||||
this is after one character (cbreak mode), or after the first newline (nocbreak
|
||||
mode). In half-delay mode, the program waits until a character is typed or the
|
||||
specified timeout has been reached. Unless \fBnoecho\fR has been set, the
|
||||
character will also be echoed into the designated window.
|
||||
|
||||
If the window is not a pad, and it has been moved or modified since the last
|
||||
call to \fBwrefresh\fR, \fBwrefresh\fR will be called before another character
|
||||
is read.
|
||||
|
||||
If \fBkeypad\fR is \fBTRUE\fR, and a function key is pressed, the token for
|
||||
that function key is returned instead of the raw characters. Possible function
|
||||
keys are defined in \fB<ncurses.h>\fR as macros with values outside the range
|
||||
of 8-bit characters whose names begin with \fBKEY_.\fR Thus, a variable
|
||||
intended to hold the return value of a function key must be of short size or
|
||||
larger.
|
||||
|
||||
When a character that could be the beginning of a function key is received
|
||||
(which, on modern terminals, means an escape character), \fBncurses\fR sets a
|
||||
timer. If the remainder of the sequence does not come in within the designated
|
||||
time, the character is passed through; otherwise, the function key value is
|
||||
returned. For this reason, many terminals experience a delay between the time
|
||||
a user presses the escape key and the escape is returned to the program.
|
||||
|
||||
The \fBungetch\fR routine places \fIch\fR back onto the input queue to be
|
||||
returned by the next call to \fBwgetch\fR. Note that there is, in effect,
|
||||
just one input queue for all windows.
|
||||
|
||||
.SS Function Keys
|
||||
The following function keys, defined in \fB<ncurses.h>\fR, might be returned by
|
||||
\fBgetch\fR if \fBkeypad\fR has been enabled. Note that not all of these are
|
||||
necessarily supported on any particular terminal.
|
||||
.nf
|
||||
__________________________________________________________________
|
||||
\fIName\fR \fIKey\fR \fIname\fR
|
||||
__________________________________________________________________
|
||||
KEY_BREAK Break key
|
||||
KEY_DOWN The four arrow keys ...
|
||||
KEY_UP
|
||||
KEY_LEFT
|
||||
KEY_RIGHT
|
||||
KEY_HOME Home key (upward+left arrow)
|
||||
KEY_BACKSPACE Backspace
|
||||
KEY_F0 Function keys; space for 64 keys is reserved.
|
||||
KEY_F(\fIn\fR) For 0 \fI<\fR \fIn\fR \fI<\fR 63
|
||||
KEY_DL Delete line
|
||||
KEY_IL Insert line
|
||||
KEY_DC Delete character
|
||||
KEY_IC Insert char or enter insert mode
|
||||
KEY_EIC Exit insert char mode
|
||||
KEY_CLEAR Clear screen
|
||||
KEY_EOS Clear to end of screen
|
||||
KEY_EOL Clear to end of line
|
||||
KEY_SF Scroll 1 line forward
|
||||
KEY_SR Scroll 1 line backward (reverse)
|
||||
KEY_NPAGE Next page
|
||||
KEY_PPAGE Previous page
|
||||
KEY_STAB Set tab
|
||||
KEY_CTAB Clear tab
|
||||
KEY_CATAB Clear all tabs
|
||||
KEY_ENTER Enter or send
|
||||
KEY_SRESET Soft (partial) reset
|
||||
KEY_RESET Reset or hard reset
|
||||
KEY_PRINT Print or copy
|
||||
KEY_LL Home down or bottom (lower left). Keypad is
|
||||
arranged like this:
|
||||
\fBA1\fR \fBup\fR \fBA3\fR
|
||||
\fBleft\fR \fBB2\fR \fBright\fR
|
||||
\fBC1\fR \fBdown\fR \fBC3\fR
|
||||
KEY_A1 Upper left of keypad
|
||||
KEY_A3 Upper right of keypad
|
||||
KEY_B2 Center of keypad
|
||||
KEY_C1 Lower left of keypad
|
||||
KEY_C3 Lower right of keypad
|
||||
KEY_BTAB Back tab key
|
||||
KEY_BEG Beg(inning) key
|
||||
KEY_CANCEL Cancel key
|
||||
KEY_CLOSE Close key
|
||||
KEY_COMMAND Cmd (command) key
|
||||
KEY_COPY Copy key
|
||||
KEY_CREATE Create key
|
||||
KEY_END End key
|
||||
KEY_EXIT Exit key
|
||||
KEY_FIND Find key
|
||||
KEY_HELP Help key
|
||||
KEY_MARK Mark key
|
||||
KEY_MESSAGE Message key
|
||||
KEY_MOVE Move key
|
||||
KEY_NEXT Next object key
|
||||
KEY_OPEN Open key
|
||||
KEY_OPTIONS Options key
|
||||
KEY_PREVIOUS Previous object key
|
||||
KEY_REDO Redo key
|
||||
KEY_REFERENCE Ref(erence) key
|
||||
KEY_REFRESH Refresh key
|
||||
KEY_REPLACE Replace key
|
||||
KEY_RESTART Restart key
|
||||
KEY_RESUME Resume key
|
||||
KEY_SAVE Save key
|
||||
KEY_SBEG Shifted beginning key
|
||||
KEY_SCANCEL Shifted cancel key
|
||||
KEY_SCOMMAND Shifted command key
|
||||
KEY_SCOPY Shifted copy key
|
||||
KEY_SCREATE Shifted create key
|
||||
KEY_SDC Shifted delete char key
|
||||
KEY_SDL Shifted delete line key
|
||||
KEY_SELECT Select key
|
||||
KEY_SEND Shifted end key
|
||||
KEY_SEOL Shifted clear line key
|
||||
KEY_SEXIT Shifted exit key
|
||||
KEY_SFIND Shifted find key
|
||||
KEY_SHELP Shifted help key
|
||||
KEY_SHOME Shifted home key
|
||||
KEY_SIC Shifted input key
|
||||
KEY_SLEFT Shifted left arrow key
|
||||
KEY_SMESSAGE Shifted message key
|
||||
KEY_SMOVE Shifted move key
|
||||
KEY_SNEXT Shifted next key
|
||||
KEY_SOPTIONS Shifted options key
|
||||
KEY_SPREVIOUS Shifted prev key
|
||||
KEY_SPRINT Shifted print key
|
||||
KEY_SREDO Shifted redo key
|
||||
KEY_SREPLACE Shifted replace key
|
||||
KEY_SRIGHT Shifted right arrow
|
||||
KEY_SRSUME Shifted resume key
|
||||
KEY_SSAVE Shifted save key
|
||||
KEY_SSUSPEND Shifted suspend key
|
||||
KEY_SUNDO Shifted undo key
|
||||
KEY_SUSPEND Suspend key
|
||||
KEY_UNDO Undo key
|
||||
.fi
|
||||
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer
|
||||
value other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Use of the escape key by a programmer for a single character function is
|
||||
discouraged, as it will cause a delay of up to one second while the
|
||||
keypad code looks for a following function-key sequence.
|
||||
|
||||
When using \fBgetch\fR, \fBwgetch\fR, \fBmvgetch\fR, or
|
||||
\fBmvwgetch\fR, nocbreak mode (\fBnocbreak\fR) and echo mode
|
||||
(\fBecho\fR) should not be used at the same time. Depending on the
|
||||
state of the tty driver when each character is typed, the program may
|
||||
produce undesirable results.
|
||||
|
||||
Note that \fBgetch\fR, \fBmvgetch\fR, and \fBmvwgetch\fR may be macros.
|
||||
|
||||
Historically, the set of keypad macros was largely defined by the extremely
|
||||
function-key-rich keyboard of the AT&T 7300, aka 3B1, aka Safari 4. Modern
|
||||
personal computers usually have only a small subset of these. IBM PC-style
|
||||
consoles typically support little more than \fBKEY_UP\fR, \fBKEY_DOWN\fR,
|
||||
\fBKEY_LEFT\fR, \fBKEY_RIGHT\fR, \fBKEY_HOME\fR, \fBKEY_END\fR,
|
||||
\fBKEY_NPAGE\fR, \fBKEY_PPAGE\fR, and function keys 1 through 12. The Ins key
|
||||
is usually mapped to \fBKEY_IC\fR.
|
||||
.SH CAPABILITIES
|
||||
All of the key_* capabilities; also \fBkeypad_local\fR and \fBkeypad_xmit\fR.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_inopts\fR(3X), \fBcurs_move\fR(3X),
|
||||
\fBcurs_refresh\fR(3X).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
53
lib/libncurses/curs_getstr.3
Normal file
53
lib/libncurses/curs_getstr.3
Normal file
@ -0,0 +1,53 @@
|
||||
.TH curs_getstr 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_getstr\fR: \fBgetstr\fR, \fBwgetstr\fR, \fBmvgetstr\fR,
|
||||
\fBmvwgetstr\fR, \fBwgetnstr\fR - accept character strings from
|
||||
\fBncurses\fR terminal keyboard
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint getstr(char *str);\fR
|
||||
.br
|
||||
\fBint wgetstr(WINDOW *win, char *str);\fR
|
||||
.br
|
||||
\fBint mvgetstr(int y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint mvwgetstr(WINDOW *win, int y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint wgetnstr(WINDOW *win, char *str, int n);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The function \fBgetstr\fR is equivalent to a series of calls to \fBgetch\fR,
|
||||
until a newline or carriage return is received (the terminating character is
|
||||
not included in the returned string). The resulting value is placed in the
|
||||
area pointed to by the character pointer \fIstr\fR.
|
||||
|
||||
\fBwgetnstr\fR reads at most \fIn\fR characters, thus preventing a possible
|
||||
overflow of the input buffer. Any attempt to enter more characters (other
|
||||
than the terminating newline or carriage return) causes a beep.
|
||||
|
||||
The user's erase and kill characters are interpreted. If keypad
|
||||
mode is on for the window, \fBKEY_LEFT\fR and \fBKEY_BACKSPACE\fR
|
||||
are both considered equivalent to the user's kill character.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH BUGS
|
||||
When the window is in keypad mode and the user types any special key
|
||||
other than those named above, the `character' value appended to the
|
||||
string by the ncurses implementation is predictable but not useful
|
||||
(being, in fact, the low-order eight bits of the key's KEY_ value).
|
||||
|
||||
The SVr4.0 documentation claims that "special keys (such as function
|
||||
keys, "home" key, "clear" key, \fIetc\fR.) are interpreted" without
|
||||
giving details. It lies. The actual behavior is like that of ncurses.
|
||||
.SH NOTES
|
||||
Note that \fBgetstr\fR, \fBmvgetstr\fR, and \fBmvwgetstr\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_getch\fR(3X).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
41
lib/libncurses/curs_getyx.3
Normal file
41
lib/libncurses/curs_getyx.3
Normal file
@ -0,0 +1,41 @@
|
||||
.TH curs_getyx 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_getyx\fR: \fBgetyx\fR, \fBgetparyx\fR, \fBgetbegyx\fR,
|
||||
\fBgetmaxyx\fR - get \fBncurses\fR cursor and window coordinates
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBvoid getyx(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
\fBvoid getparyx(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
\fBvoid getbegyx(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
\fBvoid getmaxyx(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBgetyx\fR macro places the cursor position of the window in the two
|
||||
integer variables \fIy\fR and \fIx\fR.
|
||||
|
||||
If \fIwin\fR is a subwindow, the \fBgetparyx\fR macro places the beginning
|
||||
coordinates of the subwindow relative to the parent window into two integer
|
||||
variables \fIy\fR and \fIx\fR. Otherwise, \fB-1\fR is placed into \fIy\fR and
|
||||
\fIx\fR.
|
||||
|
||||
Like \fBgetyx\fR, the \fBgetbegyx\fR and \fBgetmaxyx\fR macros store
|
||||
the current beginning coordinates and size of the specified window.
|
||||
.SH RETURN VALUE
|
||||
The return values of these macros are undefined (\fIi\fR.\fIe\fR.,
|
||||
they should not be used as the right-hand side of assignment
|
||||
statements).
|
||||
.SH NOTES
|
||||
All of these interfaces are macros and that "\fB&\fR" is not
|
||||
necessary before the variables \fIy\fR and \fIx\fR.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
40
lib/libncurses/curs_inch.3
Normal file
40
lib/libncurses/curs_inch.3
Normal file
@ -0,0 +1,40 @@
|
||||
.TH curs_inch 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_inch\fR: \fBinch\fR, \fBwinch\fR, \fBmvinch\fR, \fBmvwinch\fR
|
||||
- get a character and attributes from a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBchtype inch(void);\fR
|
||||
.br
|
||||
\fBchtype winch(WINDOW *win);\fR
|
||||
.br
|
||||
\fBchtype mvinch(int y, int x);\fR
|
||||
.br
|
||||
\fBchtype mvwinch(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines return the character, of type \fBchtype\fR, at the current
|
||||
position in the named window. If any attributes are set for that position,
|
||||
their values are OR-ed into the value returned. Constants defined in
|
||||
\fB<ncurses.h>\fR can be used with the \fB&\fR (logical AND) operator to
|
||||
extract the character or attributes alone.
|
||||
|
||||
.SS Attributes
|
||||
The following bit-masks may be AND-ed with characters returned by \fBwinch\fR.
|
||||
|
||||
.nf
|
||||
\fBA_CHARTEXT\fR Bit-mask to extract character
|
||||
\fBA_ATTRIBUTES\fR Bit-mask to extract attributes
|
||||
\fBA_COLOR\fR Bit-mask to extract color-pair field information
|
||||
.fi
|
||||
.SH NOTES
|
||||
Note that all of these routines may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
46
lib/libncurses/curs_inchstr.3
Normal file
46
lib/libncurses/curs_inchstr.3
Normal file
@ -0,0 +1,46 @@
|
||||
.TH curs_inchstr 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_inchstr\fR: \fBinchstr\fR, \fBinchnstr\fR, \fBwinchstr\fR,
|
||||
\fBwinchnstr\fR, \fBmvinchstr\fR, \fBmvinchnstr\fR, \fBmvwinchstr\fR,
|
||||
\fBmvwinchnstr\fR - get a string of characters (and attributes) from a
|
||||
\fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint inchstr(chtype *chstr);\fR
|
||||
.br
|
||||
\fBint inchnstr(chtype *chstr, int n);\fR
|
||||
.br
|
||||
\fBint winchstr(WINDOW *win, chtype *chstr);\fR
|
||||
.br
|
||||
\fBint winchnstr(WINDOW *win, chtype *chstr, int n);\fR
|
||||
.br
|
||||
\fBint mvinchstr(int y, int x, chtype *chstr);\fR
|
||||
.br
|
||||
\fBint mvinchnstr(int y, int x, chtype *chstr, int n);\fR
|
||||
.br
|
||||
\fBint mvwinchstr(WINDOW *win, int y, int x, chtype *chstr);\fR
|
||||
.br
|
||||
\fBint mvwinchnstr(WINDOW *win, int y, int x, chtype *chstr, int n);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines return a NULL-terminated array of \fBchtype\fR quantities,
|
||||
starting at the current cursor position in the named window and ending at the
|
||||
right margin of the window. The four functions with \fIn\fR as
|
||||
the last argument, return a leading substring at most \fIn\fR characters long.
|
||||
Constants defined in \fB<ncurses.h>\fR can be used with the \fB&\fR (logical
|
||||
AND) operator to extract the character or the attribute alone from any position
|
||||
in the \fIchstr\fR [see curs_inch(3X)].
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that all routines except \fBwinchnstr\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_inch\fR(3X).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
84
lib/libncurses/curs_initscr.3
Normal file
84
lib/libncurses/curs_initscr.3
Normal file
@ -0,0 +1,84 @@
|
||||
.TH curs_initscr 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_initscr\fR: \fBinitscr\fR, \fBnewterm\fR, \fBendwin\fR,
|
||||
\fBisendwin\fR, \fBset_term\fR, \fBdelscreen\fR - \fBncurses\fR screen
|
||||
initialization and manipulation routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBWINDOW *initscr(void);\fR
|
||||
.br
|
||||
\fBint endwin(void);\fR
|
||||
.br
|
||||
\fBint isendwin(void);\fR
|
||||
.br
|
||||
\fBSCREEN *newterm(char *type, FILE *outfd, FILE *infd);\fR
|
||||
.br
|
||||
\fBSCREEN *set_term(SCREEN *new);\fR
|
||||
.br
|
||||
\fBvoid delscreen(SCREEN* sp);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
\fBinitscr\fR is normally the first \fBncurses\fR routine to call when
|
||||
initializing a program. A few special routines sometimes need to be
|
||||
called before it; these are \fBslk_init\fR, \fBfilter\fR, \fBripoffline\fR,
|
||||
\fBuse_env\fR. For multiple-terminal applications, or in order to test
|
||||
for the presence of given capabilities, \fBnewterm\fR may be called before
|
||||
\fBinitscr\fR.
|
||||
|
||||
The initscr code determines the terminal type and initializes all \fBncurses\fR
|
||||
data structures. \fBinitscr\fR also causes the first call to \fBrefresh\fR to
|
||||
clear the screen. If errors occur, \fBinitscr\fR writes an appropriate error
|
||||
message to standard error and exits; otherwise, a pointer is returned to
|
||||
\fBstdscr\fR.
|
||||
|
||||
A program that outputs to more than one terminal should use the \fBnewterm\fR
|
||||
routine for each terminal instead of \fBinitscr\fR. A program that needs to
|
||||
inspect capabilities, so it can continue to run in a line-oriented mode if the
|
||||
terminal cannot support a screen-oriented program, would also use
|
||||
\fBnewterm\fR. The routine \fBnewterm\fR should be called once for each
|
||||
terminal. It returns a variable of type \fBSCREEN *\fR which should be saved
|
||||
as a reference to that terminal. The arguments are the \fItype\fR of the
|
||||
terminal to be used in place of \fB$TERM\fR, a file pointer for output to the
|
||||
terminal, and another file pointer for input from the terminal (if \fItype\fR
|
||||
is \fBNULL\fR, \fB$TERM\fR will be used). The program must also call
|
||||
\fBendwin\fR for each terminal being used before exiting from ncurses. If
|
||||
\fBnewterm\fR is called more than once for the same terminal, the first
|
||||
terminal referred to must be the last one for which \fBendwin\fR is called.
|
||||
|
||||
A program should always call \fBendwin\fR before exiting or escaping from
|
||||
\fBncurses\fR mode temporarily. This routine restores tty modes, moves the
|
||||
cursor to the lower left-hand corner of the screen and resets the terminal into
|
||||
the proper non-visual mode. Calling \fBrefresh\fR or \fBdoupdate\fR after a
|
||||
temporary escape causes the program to resume visual mode.
|
||||
|
||||
The \fBisendwin\fR routine returns \fBTRUE\fR if \fBendwin\fR has been
|
||||
called without any subsequent calls to \fBwrefresh\fR, and \fBFALSE\fR
|
||||
otherwise.
|
||||
|
||||
The \fBset_term\fR routine is used to switch between different
|
||||
terminals. The screen reference \fBnew\fR becomes the new current
|
||||
terminal. The previous terminal is returned by the routine. This is
|
||||
the only routine which manipulates \fBSCREEN\fR pointers; all other
|
||||
routines affect only the current terminal.
|
||||
|
||||
The \fBdelscreen\fR routine frees storage associated with the
|
||||
\fBSCREEN\fR data structure. The \fBendwin\fR routine does not do
|
||||
this, so \fBdelscreen\fR should be called after \fBendwin\fR if a
|
||||
particular \fBSCREEN\fR is no longer needed.
|
||||
.SH RETURN VALUE
|
||||
\fBendwin\fR returns the integer \fBERR\fR upon failure and \fBOK\fR
|
||||
upon successful completion.
|
||||
|
||||
Routines that return pointers always return \fBNULL\fR on error.
|
||||
.SH NOTES
|
||||
Note that \fBinitscr\fR and \fBnewterm\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_kernel\fR(3X), \fBcurs_refresh\fR(3X),
|
||||
\fBcurs_slk\fR(3X), \fBcurs_util\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
170
lib/libncurses/curs_inopts.3
Normal file
170
lib/libncurses/curs_inopts.3
Normal file
@ -0,0 +1,170 @@
|
||||
.TH curs_inopts 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_inopts\fR: \fBcbreak\fR, \fBnocbreak\fR, \fBecho\fR,
|
||||
\fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR, \fBkeypad\fR,
|
||||
\fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBraw\fR, \fBnoraw\fR,
|
||||
\fBnoqiflush\fR, \fBqiflush\fR, \fBtimeout\fR, \fBwtimeout\fR,
|
||||
\fBtypeahead\fR - \fBncurses\fR input options
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint cbreak(void);\fR
|
||||
.br
|
||||
\fBint nocbreak(void);\fR
|
||||
.br
|
||||
\fBint echo(void);\fR
|
||||
.br
|
||||
\fBint noecho(void);\fR
|
||||
.br
|
||||
\fBint halfdelay(int tenths);\fR
|
||||
.br
|
||||
\fBint intrflush(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint keypad(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint meta(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint nodelay(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint notimeout(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint raw(void);\fR
|
||||
.br
|
||||
\fBint noraw(void);\fR
|
||||
.br
|
||||
\fBvoid noqiflush(void);\fR
|
||||
.br
|
||||
\fBvoid qiflush(void);\fR
|
||||
.br
|
||||
\fBvoid timeout(int delay);\fR
|
||||
.br
|
||||
\fBvoid wtimeout(WINDOW *win, int delay);\fR
|
||||
.br
|
||||
\fBint typeahead(int fd);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
Normally, the tty driver buffers typed characters until a newline or carriage
|
||||
return is typed. The \fBcbreak\fR routine disables line buffering and
|
||||
erase/kill character-processing (interrupt and flow control characters are
|
||||
unaffected), making characters typed by the user immediately available to the
|
||||
program. The \fBnocbreak\fR routine returns the terminal to normal (cooked)
|
||||
mode.
|
||||
|
||||
Initially the terminal may or may not be in \fBcbreak\fR mode, as the mode is
|
||||
inherited; therefore, a program should call \fBcbreak\fR or \fBnocbreak\fR
|
||||
explicitly. Most interactive programs using \fBncurses\fR set the \fBcbreak\fR
|
||||
mode. Note that \fBcbreak\fR overrides \fBraw\fR. [See curs_getch(3X) for a
|
||||
discussion of how these routines interact with \fBecho\fR and \fBnoecho\fR.]
|
||||
|
||||
The \fBecho\fR and \fBnoecho\fR routines control whether characters typed by
|
||||
the user are echoed by \fBgetch\fR as they are typed. Echoing by the tty
|
||||
driver is always disabled, but initially \fBgetch\fR is in echo mode, so
|
||||
characters typed are echoed. Authors of most interactive programs prefer to do
|
||||
their own echoing in a controlled area of the screen, or not to echo at all, so
|
||||
they disable echoing by calling \fBnoecho\fR. [See curs_getch(3X) for a
|
||||
discussion of how these routines interact with \fBcbreak\fR and
|
||||
\fBnocbreak\fR.]
|
||||
|
||||
The \fBhalfdelay\fR routine is used for half-delay mode, which is similar to
|
||||
\fBcbreak\fR mode in that characters typed by the user are immediately
|
||||
available to the program. However, after blocking for \fItenths\fR tenths of
|
||||
seconds, ERR is returned if nothing has been typed. The value of \fBtenths\fR
|
||||
must be a number between 1 and 255. Use \fBnocbreak\fR to leave half-delay
|
||||
mode.
|
||||
|
||||
If the \fBintrflush\fR option is enabled, (\fIbf\fR is \fBTRUE\fR), when an
|
||||
interrupt key is pressed on the keyboard (interrupt, break, quit) all output in
|
||||
the tty driver queue will be flushed, giving the effect of faster response to
|
||||
the interrupt, but causing \fBncurses\fR to have the wrong idea of what is on
|
||||
the screen. Disabling (\fIbf\fR is \fBFALSE\fR), the option prevents the
|
||||
flush. The default for the option is inherited from the tty driver settings.
|
||||
The window argument is ignored.
|
||||
|
||||
The \fBkeypad\fR option enables the keypad of the user's terminal. If
|
||||
enabled (\fIbf\fR is \fBTRUE\fR), the user can press a function key
|
||||
(such as an arrow key) and \fBwgetch\fR returns a single value
|
||||
representing the function key, as in \fBKEY_LEFT\fR. If disabled
|
||||
(\fIbf\fR is \fBFALSE\fR), \fBncurses\fR does not treat function keys
|
||||
specially and the program has to interpret the escape sequences
|
||||
itself. If the keypad in the terminal can be turned on (made to
|
||||
transmit) and off (made to work locally), turning on this option
|
||||
causes the terminal keypad to be turned on when \fBwgetch\fR is
|
||||
called. The default value for keypad is false.
|
||||
|
||||
Initially, whether the terminal returns 7 or 8 significant bits on
|
||||
input depends on the control mode of the tty driver [see termio(7)].
|
||||
To force 8 bits to be returned, invoke \fBmeta\fR(\fIwin\fR,
|
||||
\fBTRUE\fR). To force 7 bits to be returned, invoke
|
||||
\fBmeta\fR(\fIwin\fR, \fBFALSE\fR). The window argument, \fIwin\fR,
|
||||
is always ignored. If the terminfo capabilities \fBsmm\fR (meta_on)
|
||||
and \fBrmm\fR (meta_off) are defined for the terminal, \fBsmm\fR is
|
||||
sent to the terminal when \fBmeta\fR(\fIwin\fR, \fBTRUE\fR) is called
|
||||
and \fBrmm\fR is sent when \fBmeta\fR(\fIwin\fR, \fBFALSE\fR) is
|
||||
called.
|
||||
|
||||
The \fBnodelay\fR option causes \fBgetch\fR to be a non-blocking call.
|
||||
If no input is ready, \fBgetch\fR returns \fBERR\fR. If disabled
|
||||
(\fIbf\fR is \fBFALSE\fR), \fBgetch\fR waits until a key is pressed.
|
||||
|
||||
While interpreting an input escape sequence, \fBwgetch\fR sets a timer
|
||||
while waiting for the next character. If \fBnotimeout(\fR\fIwin\fR,
|
||||
\fBTRUE\fR) is called, then \fBwgetch\fR does not set a timer. The
|
||||
purpose of the timeout is to differentiate between sequences received
|
||||
from a function key and those typed by a user.
|
||||
|
||||
With the \fBraw\fR and \fBnoraw\fR routines, the terminal is placed
|
||||
into or out of raw mode. Raw mode is similar to \fBcbreak\fR mode, in
|
||||
that characters typed are immediately passed through to the user
|
||||
program. The differences are that in raw mode, the interrupt, quit,
|
||||
suspend, and flow control characters are all passed through
|
||||
uninterpreted, instead of generating a signal. The behavior of the
|
||||
BREAK key depends on other bits in the tty driver that are not set by
|
||||
\fBncurses\fR.
|
||||
|
||||
When the \fBnoqiflush\fR routine is used, normal flush of input and
|
||||
output queues associated with the \fBINTR\fR, \fBQUIT\fR and
|
||||
\fBSUSP\fR characters will not be done [see termio(7)]. When
|
||||
\fBqiflush\fR is called, the queues will be flushed when these control
|
||||
characters are read.
|
||||
|
||||
The \fBtimeout\fR and \fBwtimeout\fR routines set blocking or
|
||||
non-blocking read for a given window. If \fIdelay\fR is negative,
|
||||
blocking read is used (\fIi\fR.\fIe\fR., waits indefinitely for
|
||||
input). If \fIdelay\fR is zero, then non-blocking read is used
|
||||
(\fIi\fR.\fIe\fR., read returns \fBERR\fR if no input is waiting). If
|
||||
\fIdelay\fR is positive, then read blocks for \fIdelay\fR
|
||||
milliseconds, and returns \fBERR\fR if there is still no input.
|
||||
Hence, these routines provide the same functionality as \fBnodelay\fR,
|
||||
plus the additional capability of being able to block for only
|
||||
\fIdelay\fR milliseconds (where \fIdelay\fR is positive).
|
||||
|
||||
\fBncurses\fR does ``line-breakout optimization'' by looking for
|
||||
typeahead periodically while updating the screen. If input is found,
|
||||
and it is coming from a tty, the current update is postponed until
|
||||
\fBrefresh\fR or \fBdoupdate\fR is called again. This allows faster
|
||||
response to commands typed in advance. Normally, the input FILE
|
||||
pointer passed to \fBnewterm\fR, or \fBstdin\fR in the case that
|
||||
\fBinitscr\fR was used, will be used to do this typeahead checking.
|
||||
The \fBtypeahead\fR routine specifies that the file descriptor
|
||||
\fIfd\fR is to be used to check for typeahead instead. If \fIfd\fR is
|
||||
-1, then no typeahead checking is done.
|
||||
.SH RETURN VALUE
|
||||
All routines that return an integer return \fBERR\fR upon failure and an
|
||||
integer value other than \fBERR\fR upon successful completion, unless otherwise
|
||||
noted in the preceding routine descriptions.
|
||||
.SH NOTES
|
||||
Note that \fBecho\fR, \fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR,
|
||||
\fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBnoqiflush\fR,
|
||||
\fBqiflush\fR, \fBtimeout\fR, and \fBwtimeout\fR may be macros.
|
||||
.SH BUGS
|
||||
The entry points \fBintrflush\fR, \fBqiflush\fR, \fBnoqiflush\fR, and
|
||||
\fBtypeahead\fR are not yet implemented in ncurses 1.8.1. The ncurses
|
||||
code does not do typeahead checking during input as SVr4 curses does.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_getch\fR(3X), \fBcurs_initscr\fR(3X), \fBtermio\fR(7)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
36
lib/libncurses/curs_insch.3
Normal file
36
lib/libncurses/curs_insch.3
Normal file
@ -0,0 +1,36 @@
|
||||
.TH curs_insch 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_insch\fR: \fBinsch\fR, \fBwinsch\fR, \fBmvinsch\fR, \fBmvwinsch\fR -
|
||||
insert a character before cursor in a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint insch(chtype ch);\fR
|
||||
.br
|
||||
\fBint winsch(WINDOW *win, chtype ch);\fR
|
||||
.br
|
||||
\fBint mvinsch(int y, int x, chtype ch);\fR
|
||||
.br
|
||||
\fBint mvwinsch(WINDOW *win, int y, int x, chtype ch);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines, insert the character \fIch\fR before the character under the
|
||||
cursor. All characters to the right of the cursor are moved one space to the
|
||||
right, with the possibility of the rightmost character on the line being lost.
|
||||
The insertion operation does not change the cursor position.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
These routines do not necessarily imply use of a hardware insert character
|
||||
feature.
|
||||
|
||||
Note that \fBinsch\fR, \fBmvinsch\fR, and \fBmvwinsch\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
57
lib/libncurses/curs_insstr.3
Normal file
57
lib/libncurses/curs_insstr.3
Normal file
@ -0,0 +1,57 @@
|
||||
.TH curs_insstr 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_instr\fR: \fBinsstr\fR, \fBinsnstr\fR, \fBwinsstr\fR, \fBwinsnstr\fR,
|
||||
\fBmvinsstr\fR, \fBmvinsnstr\fR, \fBmvwinsstr\fR, \fBmvwinsnstr\fR - insert
|
||||
string before cursor a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
.br
|
||||
\fBint insstr(char *str);\fR
|
||||
.br
|
||||
\fBint insnstr(char *str, int n);\fR
|
||||
.br
|
||||
\fBint winsstr(WINDOW *win, char *str);\fR
|
||||
.br
|
||||
\fBint winsnstr(WINDOW *win, char *str, int n);\fR
|
||||
.br
|
||||
\fBint mvinsstr(int y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint mvinsnstr(int y, int x, char *str, int n);\fR
|
||||
.br
|
||||
\fBint mvwinsstr(WINDOW *win, int y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint mvwinsnstr(WINDOW *win, int y, int x, char *str, int n);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines insert a character string (as many characters as will fit on the
|
||||
line) before the character under the cursor. All characters to the right of
|
||||
the cursor are shifted right, with the possibility of the rightmost characters
|
||||
on the line being lost. The cursor position does not change (after moving to
|
||||
\fIy\fR, \fIx\fR, if specified). The four routines with \fIn\fR as the last
|
||||
argument insert a leading substring of at most \fIn\fR characters. If
|
||||
\fIn\fR<=0, then the entire string is inserted.
|
||||
|
||||
If a character in \fIstr\fR is a tab, newline, carriage return or
|
||||
backspace, the cursor is moved appropriately within the window. A
|
||||
newline also does a \fBclrtoeol\fR before moving. Tabs are considered
|
||||
to be at every eighth column. If a character in \fIstr\fR is another
|
||||
control character, it is drawn in the \fB^\fR\fIX\fR notation.
|
||||
Calling \fBwinch\fR after adding a control character (and moving to
|
||||
it, if necessary) does not return the control character, but instead
|
||||
returns a character in the the ^-representation of the control character.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH BUGS
|
||||
Entry points for these functions are n ncurses.h but they are not
|
||||
implemented as of ncurses 1.8.5.
|
||||
.SH NOTES
|
||||
Note that all but \fBwinsnstr\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_clear\fR(3X), \fBcurs_inch\fR(3X).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
44
lib/libncurses/curs_instr.3
Normal file
44
lib/libncurses/curs_instr.3
Normal file
@ -0,0 +1,44 @@
|
||||
.TH curs_instr 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_instr\fR: \fBinstr\fR, \fBinnstr\fR, \fBwinstr\fR, \fBwinnstr\fR,
|
||||
\fBmvinstr\fR, \fBmvinnstr\fR, \fBmvwinstr\fR, \fBmvwinnstr\fR - get a string
|
||||
of characters from a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint instr(char *str);\fR
|
||||
.br
|
||||
\fBint innstr(char *str, int n);\fR
|
||||
.br
|
||||
\fBint winstr(WINDOW *win, char *str);\fR
|
||||
.br
|
||||
\fBint winnstr(WINDOW *win, char *str, int n);\fR
|
||||
.br
|
||||
\fBint mvinstr(int y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint mvinnstr(int y, int x, char *str, int n);\fR
|
||||
.br
|
||||
\fBint mvwinstr(WINDOW *win, int y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint mvwinnstr(WINDOW *win, int y, int x, char *str, int n);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines return a string of characters in \fIstr\fR, extracted starting
|
||||
at the current cursor position in the named window and ending at the right
|
||||
margin of the window. Attributes are stripped from the characters. The four
|
||||
functions with \fIn\fR as the last argument return a leading substring at most
|
||||
\fIn\fR characters long.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that all routines except \fBwinnstr\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
||||
|
113
lib/libncurses/curs_kernel.3
Normal file
113
lib/libncurses/curs_kernel.3
Normal file
@ -0,0 +1,113 @@
|
||||
.TH curs_kernel 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_kernel\fR: \fBdef_prog_mode\fR, \fBdef_shell_mode\fR,
|
||||
\fBreset_prog_mode\fR, \fBreset_shell_mode\fR, \fBresetty\fR,
|
||||
\fBsavetty\fR, \fBgetsyx\fR, \fBsetsyx\fR, \fBripoffline\fR,
|
||||
\fBcurs_set\fR, \fBnapms\fR - low-level \fBncurses\fR routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint def_prog_mode(void);\fR
|
||||
.br
|
||||
\fBint def_shell_mode(void);\fR
|
||||
.br
|
||||
\fBint reset_prog_mode(void);\fR
|
||||
.br
|
||||
\fBint reset_shell_mode(void);\fR
|
||||
.br
|
||||
\fBint resetty(void);\fR
|
||||
.br
|
||||
\fBint savetty(void);\fR
|
||||
.br
|
||||
\fBint getsyx(int y, int x);\fR
|
||||
.br
|
||||
\fBint setsyx(int y, int x);\fR
|
||||
.br
|
||||
\fBint ripoffline(int line, int (*init)(WINDOW *, int));\fR
|
||||
.br
|
||||
\fBint curs_set(int visibility);\fR
|
||||
.br
|
||||
\fBint napms(int ms);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The following routines give low-level access to various \fBncurses\fR
|
||||
capabilities. Theses routines typically are used inside library
|
||||
routines.
|
||||
|
||||
The \fBdef_prog_mode\fR and \fBdef_shell_mode\fR routines save the
|
||||
current terminal modes as the "program" (in \fBncurses\fR) or "shell"
|
||||
(not in \fBncurses\fR) state for use by the \fBreset_prog_mode\fR and
|
||||
\fBreset_shell_mode\fR routines. This is done automatically by
|
||||
\fBinitscr\fR.
|
||||
|
||||
The \fBreset_prog_mode\fR and \fBreset_shell_mode\fR routines restore
|
||||
the terminal to "program" (in \fBncurses\fR) or "shell" (out of
|
||||
\fBncurses\fR) state. These are done automatically by \fBendwin\fR
|
||||
and, after an \fBendwin\fR, by \fBdoupdate\fR, so they normally are
|
||||
not called.
|
||||
|
||||
The \fBresetty\fR and \fBsavetty\fR routines save and restore the
|
||||
state of the terminal modes. \fBsavetty\fR saves the current state in
|
||||
a buffer and \fBresetty\fR restores the state to what it was at the
|
||||
last call to \fBsavetty\fR.
|
||||
|
||||
With the \fBgetsyx\fR routine, the current coordinates of the virtual
|
||||
screen cursor are returned in \fIy\fR and \fIx\fR. If \fBleaveok\fR
|
||||
is currently \fBTRUE\fR, then \fB-1\fR,\fB-1\fR is returned. If lines
|
||||
have been removed from the top of the screen, using \fBripoffline\fR,
|
||||
\fIy\fR and \fIx\fR include these lines; therefore, \fIy\fR and
|
||||
\fIx\fR should be used only as arguments for \fBsetsyx\fR.
|
||||
|
||||
With the \fBsetsyx\fR routine, the virtual screen cursor is set to
|
||||
\fIy\fR, \fIx\fR. If \fIy\fR and \fIx\fR are both \fB-1\fR, then
|
||||
\fBleaveok\fR is set. The two routines \fBgetsyx\fR and \fBsetsyx\fR
|
||||
are designed to be used by a library routine, which manipulates
|
||||
\fBncurses\fR windows but does not want to change the current position
|
||||
of the program's cursor. The library routine would call \fBgetsyx\fR
|
||||
at the beginning, do its manipulation of its own windows, do a
|
||||
\fBwnoutrefresh\fR on its windows, call \fBsetsyx\fR, and then call
|
||||
\fBdoupdate\fR.
|
||||
|
||||
The \fBripoffline\fR routine provides access to the same facility that
|
||||
\fBslk_init\fR [see curs_slk(3X)] uses to reduce the size of the
|
||||
screen. \fBripoffline\fR must be called before \fBinitscr\fR or
|
||||
\fBnewterm\fR is called. If \fIline\fR is positive, a line is removed
|
||||
from the top of \fBstdscr\fR; if \fIline\fR is negative, a line is
|
||||
removed from the bottom. When this is done inside \fBinitscr\fR, the
|
||||
routine \fBinit\fR (supplied by the user) is called with two
|
||||
arguments: a window pointer to the one-line window that has been
|
||||
allocated and an integer with the number of columns in the window.
|
||||
Inside this initialization routine, the integer variables \fBLINES\fR
|
||||
and \fBCOLS\fR (defined in \fB<ncurses.h>\fR) are not guaranteed to be
|
||||
accurate and \fBwrefresh\fR or \fBdoupdate\fR must not be called. It
|
||||
is allowable to call \fBwnoutrefresh\fR during the initialization
|
||||
routine.
|
||||
|
||||
\fBripoffline\fR can be called up to five times before calling \fBinitscr\fR or
|
||||
\fBnewterm\fR.
|
||||
|
||||
The \fBcurs_set\fR routine sets the cursor state is set to invisible,
|
||||
normal, or very visible for \fBvisibility\fR equal to \fB0\fR,
|
||||
\fB1\fR, or \fB2\fR respectively. If the terminal supports the
|
||||
\fIvisibility\fR requested, the previous \fIcursor\fR state is
|
||||
returned; otherwise, \fBERR\fR is returned.
|
||||
|
||||
The \fBnapms\fR routine is used to sleep for \fIms\fR milliseconds.
|
||||
.SH RETURN VALUE
|
||||
Except for \fBcurs_set\fR, these routines always return \fBOK\fR.
|
||||
\fBcurs_set\fR returns the previous cursor state, or \fBERR\fR if the
|
||||
requested \fIvisibility\fR is not supported.
|
||||
.SH NOTES
|
||||
Note that \fBgetsyx\fR is a macro, so \fB&\fR is not necessary before
|
||||
the variables \fIy\fR and \fIx\fR.
|
||||
.SH BUGS
|
||||
The return value of curs_set is currently incorrect.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_initscr\fR(3X), \fBcurs_outopts\fR(3X), \fBcurs_refresh\fR(3X),
|
||||
\fBcurs_scr_dump\fR(3X), \fBcurs_slk\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
28
lib/libncurses/curs_move.3
Normal file
28
lib/libncurses/curs_move.3
Normal file
@ -0,0 +1,28 @@
|
||||
.TH curs_move 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_move\fR: \fBmove\fR, \fBwmove\fR - move \fBncurses\fR window cursor
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint move(int y, int x);\fR
|
||||
.br
|
||||
\fBint wmove(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines move the cursor associated with the window to line \fIy\fR and
|
||||
column \fIx\fR. This routine does not move the physical cursor of the terminal
|
||||
until \fBrefresh\fR is called. The position specified is relative to the upper
|
||||
left-hand corner of the window, which is (0,0).
|
||||
.SH RETURN VALUE
|
||||
These routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that \fBmove\fR may be a macro.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_refresh\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
114
lib/libncurses/curs_outopts.3
Normal file
114
lib/libncurses/curs_outopts.3
Normal file
@ -0,0 +1,114 @@
|
||||
.TH curs_outopts 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_outopts\fR: \fBclearok\fR, \fBidlok\fR, \fBidcok immedok\fR,
|
||||
\fBleaveok\fR, \fBsetscrreg\fR, \fBwsetscrreg\fR, \fBscrollok\fR,
|
||||
\fBnl\fR, \fBnonl\fR - \fBncurses\fR output options
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint clearok(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint idlok(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBvoid idcok(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBvoid immedok(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint leaveok(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint setscrreg(int top, int bot);\fR
|
||||
.br
|
||||
\fBint wsetscrreg(WINDOW *win, int top, int bot);\fR
|
||||
.br
|
||||
\fBint scrollok(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint nl(void);\fR
|
||||
.br
|
||||
\fBint nonl(void);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines set options that change the style of output within
|
||||
\fBncurses\fR. All options are initially \fBFALSE\fR, unless otherwise stated.
|
||||
It is not necessary to turn these options off before calling \fBendwin\fR.
|
||||
|
||||
With the \fBclearok\fR routine, if enabled (\fIbf\fR is \fBTRUE\fR), the next
|
||||
call to \fBwrefresh\fR with this window will clear the screen completely and
|
||||
redraw the entire screen from scratch. This is useful when the contents of the
|
||||
screen are uncertain, or in some cases for a more pleasing visual effect. If
|
||||
the \fIwin\fR argument to \fBclearok\fR is the global variable \fBcurscr\fR,
|
||||
the next call to \fBwrefresh\fR with any window causes the screen to be cleared
|
||||
and repainted from scratch.
|
||||
|
||||
With the \fBidlok\fR routine, if enabled (\fIbf\fR is \fBTRUE\fR),
|
||||
\fBncurses\fR considers using the hardware insert/delete line feature of
|
||||
terminals so equipped. If disabled (\fIbf\fR is \fBFALSE\fR), \fBncurses\fR
|
||||
very seldom uses this feature. (The insert/delete character feature is always
|
||||
considered.) This option should be enabled only if the application needs
|
||||
insert/delete line, for example, for a screen editor. It is disabled by
|
||||
default because insert/delete line tends to be visually annoying when used in
|
||||
applications where it isn't really needed. If insert/delete line cannot be
|
||||
used, \fBncurses\fR redraws the changed portions of all lines.
|
||||
|
||||
With the \fBidcok\fR routine, if enabled (\fIbf\fR is \fBTRUE\fR),
|
||||
\fBncurses\fR considers using the hardware insert/delete character feature of
|
||||
terminals so equipped. This is enabled by default.
|
||||
|
||||
With the \fBimmedok\fR routine, if enabled (\fIbf\fR is \fBTRUE)\fR, any change
|
||||
in the window image, such as the ones caused by \fBwaddch, wclrtobot, wscrl\fR,
|
||||
\fIetc\fR., automatically cause a call to \fBwrefresh\fR. However, it may
|
||||
degrade the performance considerably, due to repeated calls to \fBwrefresh\fR.
|
||||
It is disabled by default.
|
||||
|
||||
Normally, the hardware cursor is left at the location of the window cursor
|
||||
being refreshed. The \fBleaveok\fR option allows the cursor to be left
|
||||
wherever the update happens to leave it. It is useful for applications where
|
||||
the cursor is not used, since it reduces the need for cursor motions. If
|
||||
possible, the cursor is made invisible when this option is enabled.
|
||||
|
||||
The \fBsetscrreg\fR and \fBwsetscrreg\fR routines allow the application
|
||||
programmer to set a software scrolling region in a window. \fItop\fR and
|
||||
\fIbot\fR are the line numbers of the top and bottom margin of the scrolling
|
||||
region. (Line 0 is the top line of the window.) If this option and
|
||||
\fBscrollok\fR are enabled, an attempt to move off the bottom margin line
|
||||
causes all lines in the scrolling region to scroll up one line. Only the text
|
||||
of the window is scrolled. (Note that this has nothing to do with the use of a
|
||||
physical scrolling region capability in the terminal, like that in the VT100.
|
||||
If \fBidlok\fR is enabled and the terminal has either a scrolling region or
|
||||
insert/delete line capability, they will probably be used by the output
|
||||
routines.)
|
||||
|
||||
The \fBscrollok\fR option controls what happens when the cursor of a window is
|
||||
moved off the edge of the window or scrolling region, either as a result of a
|
||||
newline action on the bottom line, or typing the last character of the last
|
||||
line. If disabled, (\fIbf\fR is \fBFALSE\fR), the cursor is left on the bottom
|
||||
line. If enabled, (\fIbf\fR is \fBTRUE\fR), \fBwrefresh\fR is called on the
|
||||
window, and the physical terminal and window are scrolled up one line. [Note
|
||||
that in order to get the physical scrolling effect on the terminal, it is also
|
||||
necessary to call \fBidlok\fR.]
|
||||
|
||||
The \fBnl\fR and \fBnonl\fR routines control whether newline is translated into
|
||||
carriage return and linefeed on output, and whether return is translated into
|
||||
newline on input. Initially, the translations do occur. By disabling these
|
||||
translations using \fBnonl\fR, \fBncurses\fR is able to make better use of the
|
||||
linefeed capability, resulting in faster cursor motion.
|
||||
.SH RETURN VALUE
|
||||
\fBsetscrreg\fR and \fBwsetscrreg\fR return \fBOK\fR upon success and \fBERR\fR upon failure.
|
||||
All other routines that return an integer always return \fBOK\fR.
|
||||
.SH BUGS
|
||||
The entry points \fBidcok\fR, \fBimmedok\fR are not yet implemented in
|
||||
ncurses 1.8.1.
|
||||
.SH NOTES
|
||||
Note that \fBclearok\fR, \fBleaveok\fR, \fBscrollok\fR, \fBidcok\fR, \fBnl\fR,
|
||||
\fBnonl\fR and \fBsetscrreg\fR may be macros.
|
||||
|
||||
The \fBimmedok\fR routine is useful for windows that are used as terminal
|
||||
emulators.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_addch\fR(3X), \fBcurs_clear\fR(3X),
|
||||
\fBcurs_initscr\fR(3X), \fBcurs_scroll\fR(3X), \fBcurs_refresh\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
41
lib/libncurses/curs_overlay.3
Normal file
41
lib/libncurses/curs_overlay.3
Normal file
@ -0,0 +1,41 @@
|
||||
.TH curs_overlay 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_overlay\fR: \fBoverlay\fR, \fBoverwrite\fR, \fBcopywin\fR - overlay and
|
||||
manipulate overlapped \fBncurses\fR windows
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint overlay(WINDOW *srcwin, WINDOW *dstwin);\fR
|
||||
.br
|
||||
\fBint overwrite(WINDOW *srcwin, WINDOW *dstwin);\fR
|
||||
.br
|
||||
\fBint copywin(WINDOW *srcwin, WINDOW *dstwin, int sminrow,
|
||||
int smincol, int dminrow, int dmincol, int dmaxrow,
|
||||
int dmaxcol, int overlay);\fR
|
||||
.SH DESCRIPTION
|
||||
The \fBoverlay\fR and \fBoverwrite\fR routines overlay \fIsrcwin\fR on
|
||||
top of \fIdstwin\fR. \fIscrwin\fR and \fIdstwin\fR are not required
|
||||
to be the same size; only text where the two windows overlap is
|
||||
copied. The difference is that \fBoverlay\fR is non-destructive
|
||||
(blanks are not copied) whereas \fBoverwrite\fR is destructive.
|
||||
|
||||
The \fBcopywin\fR routine provides a finer granularity of control over the
|
||||
\fBoverlay\fR and \fBoverwrite\fR routines. Like in the \fBprefresh\fR
|
||||
routine, a rectangle is specified in the destination window, (\fIdminrow\fR,
|
||||
\fIdmincol\fR) and (\fIdmaxrow\fR, \fIdmaxcol\fR), and the upper-left-corner
|
||||
coordinates of the source window, (\fIsminrow\fR, \fIsmincol\fR). If the
|
||||
argument \fIoverlay\fR is \fBtrue\fR, then copying is non-destructive, as in
|
||||
\fBoverlay\fR.
|
||||
.SH RETURN VALUE
|
||||
Routines that return an integer return \fBERR\fR upon failure and an integer
|
||||
value other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that \fBoverlay\fR and \fBoverwrite\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_pad\fR(3X), \fBcurs_refresh\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
75
lib/libncurses/curs_pad.3
Normal file
75
lib/libncurses/curs_pad.3
Normal file
@ -0,0 +1,75 @@
|
||||
.TH curs_pad 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_pad\fR: \fBnewpad\fR, \fBsubpad\fR, \fBprefresh\fR,
|
||||
\fBpnoutrefresh\fR, \fBpechochar\fR - create and display \fBncurses\fR
|
||||
pads
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBWINDOW *newpad(int nlines, int ncols);\fR
|
||||
.br
|
||||
\fBWINDOW *subpad(WINDOW *orig, int nlines, int ncols,
|
||||
int begin_y, int begin_x);\fR
|
||||
\fBint prefresh(WINDOW *pad, int pminrow, int pmincol,
|
||||
int sminrow, int smincol, int smaxrow, int smaxcol);\fR
|
||||
\fBint pnoutrefresh(WINDOW *pad, int pminrow, int pmincol,
|
||||
int sminrow, int smincol, int smaxrow, int smaxcol);\fR
|
||||
\fBint pechochar(WINDOW *pad, chtype ch);\fR
|
||||
.SH DESCRIPTION
|
||||
The \fBnewpad\fR routine creates and returns a pointer to a new pad data
|
||||
structure with the given number of lines, \fInlines\fR, and columns,
|
||||
\fIncols\fR. A pad is like a window, except that it is not restricted by the
|
||||
screen size, and is not necessarily associated with a particular part of the
|
||||
screen. Pads can be used when a large window is needed, and only a part of the
|
||||
window will be on the screen at one time. Automatic refreshes of pads
|
||||
(\fIe\fR.\fIg\fR., from scrolling or echoing of input) do not occur. It is not
|
||||
legal to call \fBwrefresh\fR with a \fIpad\fR as an argument; the routines
|
||||
\fBprefresh\fR or \fBpnoutrefresh\fR should be called instead. Note that these
|
||||
routines require additional parameters to specify the part of the pad to be
|
||||
displayed and the location on the screen to be used for the display.
|
||||
|
||||
The \fBsubpad\fR routine creates and returns a pointer to a subwindow within a
|
||||
pad with the given number of lines, \fInlines\fR, and columns, \fIncols\fR.
|
||||
Unlike \fBsubwin\fR, which uses screen coordinates, the window is at position
|
||||
(\fIbegin\fR_\fIx\fR\fB,\fR \fIbegin\fR_\fIy\fR) on the pad. The window is
|
||||
made in the middle of the window \fIorig\fR, so that changes made to one window
|
||||
affect both windows. During the use of this routine, it will often be
|
||||
necessary to call \fBtouchwin\fR or \fBtouchline\fR on \fIorig\fR before
|
||||
calling \fBprefresh\fR.
|
||||
|
||||
The \fBprefresh\fR and \fBpnoutrefresh\fR routines are analogous to
|
||||
\fBwrefresh\fR and \fBwnoutrefresh\fR except that they relate to pads instead
|
||||
of windows. The additional parameters are needed to indicate what part of the
|
||||
pad and screen are involved. \fIpminrow\fR and \fIpmincol\fR specify the upper
|
||||
left-hand corner of the rectangle to be displayed in the pad. \fIsminrow\fR,
|
||||
\fIsmincol\fR, \fIsmaxrow\fR, and \fIsmaxcol\fR specify the edges of the
|
||||
rectangle to be displayed on the screen. The lower right-hand corner of the
|
||||
rectangle to be displayed in the pad is calculated from the screen coordinates,
|
||||
since the rectangles must be the same size. Both rectangles must be entirely
|
||||
contained within their respective structures. Negative values of
|
||||
\fIpminrow\fR, \fIpmincol\fR, \fIsminrow\fR, or \fIsmincol\fR are treated as if
|
||||
they were zero.
|
||||
|
||||
The \fBpechochar\fR routine is functionally equivalent to a call to \fBaddch\fR
|
||||
followed by a call to \fBrefresh\fR, a call to \fBwaddch\fR followed by a call
|
||||
to \fBwrefresh\fR, or a call to \fBwaddch\fR followed by a call to
|
||||
\fBprefresh.\fR The knowledge that only a single character is being output is
|
||||
taken into consideration and, for non-control characters, a considerable
|
||||
performance gain might be seen by using these routines instead of their
|
||||
equivalents. In the case of \fBpechochar\fR, the last location of the pad on
|
||||
the screen is reused for the arguments to \fBprefresh\fR.
|
||||
.SH RETURN VALUE
|
||||
Routines that return an integer return \fBERR\fR upon failure and an integer
|
||||
value other than \fBERR\fR upon successful completion.
|
||||
|
||||
Routines that return pointers return \fBNULL\fR on error.
|
||||
.SH NOTES
|
||||
Note that \fBpechochar\fR may be a macro.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_refresh\fR(3X), \fBcurs_touch\fR(3X), \fBcurs_addch\fR(3X).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
42
lib/libncurses/curs_printw.3
Normal file
42
lib/libncurses/curs_printw.3
Normal file
@ -0,0 +1,42 @@
|
||||
.TH curs_printw 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_printw\fR: \fBprintw\fR, \fBwprintw\fR, \fBmvprintw\fR,
|
||||
\fBmvwprintw\fR, \fBvwprintw\fR - print formatted output in
|
||||
\fBncurses\fR windows
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint printw(char *fmt\fR [\fB, arg\fR] \fB...);\fR
|
||||
.br
|
||||
\fBint wprintw(WINDOW *win, char *fmt\fR [\fB, arg\fR] \fB...);\fR
|
||||
.br
|
||||
\fBint mvprintw(int y, int x, char *fmt\fR [\fB, arg\fR] \fB...);\fR
|
||||
.br
|
||||
\fBint mvwprintw(WINDOW *win, int y, int x,
|
||||
\fBchar *fmt\fR [\fB, arg]\fR ...);
|
||||
|
||||
\fB#include <varargs.h>\fR
|
||||
.br
|
||||
\fBint vwprintw(WINDOW *win, char *fmt, varglist);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBprintw\fR, \fBwprintw\fR, \fBmvprintw\fR and \fBmvwprintw\fR
|
||||
routines are analogous to \fBprintf\fR [see \fBprintf\fR(3S)]. In
|
||||
effect, the string that would be output by \fBprintf\fR is output
|
||||
instead as though \fBwaddstr\fR were used on the given window.
|
||||
|
||||
The \fBvwprintw\fR routine is analogous to \fBvprintf\fR [see
|
||||
\fBprintf\fR(3S)] and performs a \fBwprintw\fR using a variable
|
||||
argument list. The third argument is a \fBva_list\fR, a pointer to a
|
||||
list of arguments, as defined in \fB<varargs.h>\fR.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBprintf\fR(3S), \fBvprintf(3S)\fR
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
69
lib/libncurses/curs_refresh.3
Normal file
69
lib/libncurses/curs_refresh.3
Normal file
@ -0,0 +1,69 @@
|
||||
.TH curs_refresh 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_refresh\fR: \fBrefresh\fR, \fBwrefresh\fR, \fBwnoutrefresh\fR,
|
||||
\fBdoupdate\fR, \fBredrawwin\fR, \fBwredrawln\fR - refresh
|
||||
\fBncurses\fR windows and lines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint refresh(void);\fR
|
||||
.br
|
||||
\fBint wrefresh(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint wnoutrefresh(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint doupdate(void);\fR
|
||||
.br
|
||||
\fBint redrawwin(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint wredrawln(WINDOW *win, int beg_line, int num_lines);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBrefresh\fR and \fBwrefresh\fR routines (or \fBwnoutrefresh\fR and
|
||||
\fBdoupdate\fR) must be called to get actual output to the terminal, as other
|
||||
routines merely manipulate data structures. The routine \fBwrefresh\fR copies
|
||||
the named window to the physical terminal screen, taking into account what is
|
||||
already there in order to do optimizations. The \fBrefresh\fR routine is the
|
||||
same, using \fBstdscr\fR as the default window. Unless \fBleaveok\fR has been
|
||||
enabled, the physical cursor of the terminal is left at the location of the
|
||||
cursor for that window.
|
||||
|
||||
The \fBwnoutrefresh\fR and \fBdoupdate\fR routines allow multiple updates with
|
||||
more efficiency than \fBwrefresh\fR alone. In addition to all the window
|
||||
structures, \fBncurses\fR keeps two data structures representing the terminal
|
||||
screen: a physical screen, describing what is actually on the screen, and a
|
||||
virtual screen, describing what the programmer wants to have on the screen.
|
||||
|
||||
The routine \fBwrefresh\fR works by first calling \fBwnoutrefresh\fR, which
|
||||
copies the named window to the virtual screen, and then calling \fBdoupdate\fR,
|
||||
which compares the virtual screen to the physical screen and does the actual
|
||||
update. If the programmer wishes to output several windows at once, a series
|
||||
of calls to \fBwrefresh\fR results in alternating calls to \fBwnoutrefresh\fR
|
||||
and \fBdoupdate\fR, causing several bursts of output to the screen. By first
|
||||
calling \fBwnoutrefresh\fR for each window, it is then possible to call
|
||||
\fBdoupdate\fR once, resulting in only one burst of output, with fewer total
|
||||
characters transmitted and less CPU time used. If the \fIwin\fR argument to
|
||||
\fBwrefresh\fR is the global variable \fBcurscr\fR, the screen is immediately
|
||||
cleared and repainted from scratch.
|
||||
|
||||
The \fBredrawwin\fR routine indicates to \fBncurses\fR that some screen lines
|
||||
are corrupted and should be thrown away before anything is written over them.
|
||||
These routines could be used for programs such as editors, which want a command
|
||||
to redraw some part of the screen or the entire screen. The routine
|
||||
\fBredrawln\fR is preferred over \fBredrawwin\fR where a noisy communication
|
||||
line exists and redrawing the entire window could be subject to even more
|
||||
communication noise. Just redrawing several lines offers the possibility that
|
||||
they would show up unblemished.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that \fBrefresh\fR and \fBredrawwin\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_outopts\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
44
lib/libncurses/curs_scanw.3
Normal file
44
lib/libncurses/curs_scanw.3
Normal file
@ -0,0 +1,44 @@
|
||||
.TH curs_scanw 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_scanw\fR: \fBscanw\fR, \fBwscanw\fR, \fBmvscanw\fR,
|
||||
\fBmvwscanw\fR, \fBvwscanw\fR - convert formatted input from a
|
||||
\fBncurses\fR widow
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint scanw(char *fmt\fR [\fB, arg\fR] \fB...);\fR
|
||||
.br
|
||||
\fBint wscanw(WINDOW *win, char *fmt\fR [\fB, arg\fR] \fB...);\fR
|
||||
.br
|
||||
\fBint mvscanw(int y, int x, char *fmt\fR [\fB, arg\fR] \fB...);\fR
|
||||
.br
|
||||
\fBint mvwscanw(WINDOW *win, int y, int x,
|
||||
char *fmt\fR [\fB, arg]\fR \fB...);\fR
|
||||
.br
|
||||
\fBint vwscanw(WINDOW *win, char *fmt, va_list varglist);\fR
|
||||
.SH DESCRIPTION
|
||||
The \fBscanw\fR, \fBwscanw\fR and \fBmvscanw\fR routines are analogous to
|
||||
\fBscanf\fR [see \fBscanf\fR(3S)]. The effect of these routines is as though
|
||||
\fBwgetstr\fR were called on the window, and the resulting line used as input
|
||||
for \fBsscanf\fR(3). Fields which do not map to a variable in the \fIfmt\fR
|
||||
field are lost.
|
||||
|
||||
The \fBvwscanw\fR routine is similar to \fBvwprintw\fR in that it performs a
|
||||
\fBwscanw\fR using a variable argument list. The third argument is a
|
||||
\fIva\fR_\fIlist\fR, a pointer to a list of arguments, as defined in
|
||||
\fB<varargs.h>\fR.
|
||||
.SH RETURN VALUE
|
||||
\fBvwscanw\fR returns \fBERR\fR on failure and an integer equal to the
|
||||
number of fields scanned on success.
|
||||
|
||||
Applications may use the return value from the \fBscanw\fR, \fBwscanw\fR,
|
||||
\fBmvscanw\fR and \fBmvwscanw\fR routines to determine the number of fields
|
||||
which were mapped in the call.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_getstr\fR, \fBcurs_printw\fR, \fBscanf\fR(3S)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
56
lib/libncurses/curs_scr_dmp.3
Normal file
56
lib/libncurses/curs_scr_dmp.3
Normal file
@ -0,0 +1,56 @@
|
||||
.TH curs_scr_dump 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_scr_dump\fR: \fBscr_dump\fR, \fBscr_restore\fR,
|
||||
\fBscr_init\fR, \fBscr_set\fR - read (write) a \fBncurses\fR screen
|
||||
from (to) a file
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint scr_dump(char *filename);\fR
|
||||
.br
|
||||
\fBint scr_restore(char *filename);\fR
|
||||
.br
|
||||
\fBint scr_init(char *filename);\fR
|
||||
.br
|
||||
\fBint scr_set(char *filename);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBscr_dump\fR routine dumps the current contents of the virtual screen
|
||||
to the file \fIfilename\fR.
|
||||
|
||||
With the \fBscr_restore\fR routine, the virtual screen is set to the contents
|
||||
of \fIfilename\fR, which must have been written using \fBscr_dump\fR. The next
|
||||
call to \fBdoupdate\fR restores the screen to the way it looked in the dump
|
||||
file.
|
||||
|
||||
With the \fBscr_init\fR routine, the contents of \fIfilename\fR are read in and
|
||||
used to initialize the \fBncurses\fR data structures about what the terminal
|
||||
currently has on its screen. If the data is determined to be valid,
|
||||
\fBncurses\fR bases its next update of the screen on this information rather
|
||||
than clearing the screen and starting from scratch. \fBscr_init\fR is used
|
||||
after \fBinitscr\fR or a \fBsystem\fR [see \fBsystem\fR(BA_LIB)] call to share
|
||||
the screen with another process which has done a \fBscr_dump\fR after its
|
||||
\fBendwin\fR call. The data is declared invalid if the time-stamp of the tty
|
||||
is old or the terminfo capabilities \fBrmcup\fR and \fBnrrmc\fR exist.
|
||||
|
||||
The \fBscr_set\fR routine is a combination of \fBscr_restore\fR and
|
||||
\fBscr_init\fR. It tells the program that the information in \fIfilename\fR is
|
||||
what is currently on the screen, and also what the program wants on the screen.
|
||||
This can be thought of as a screen inheritance function.
|
||||
|
||||
To read (write) a window from (to) a file, use the \fBgetwin\fR and
|
||||
\fBputwin\fR routines [see \fBcurs_util\fR(3X)].
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and \fBOK\fR
|
||||
upon success.
|
||||
.SH NOTES
|
||||
Note that \fBscr_init\fR, \fBscr_set\fR, and \fBscr_restore\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_initscr\fR(3X), \fBcurs_refresh\fR(3X),
|
||||
\fBcurs_util\fR(3X), \fBsystem\fR(3S)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
38
lib/libncurses/curs_scroll.3
Normal file
38
lib/libncurses/curs_scroll.3
Normal file
@ -0,0 +1,38 @@
|
||||
.TH curs_scroll 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_scroll\fR: \fBscroll\fR, \fBsrcl\fR, \fBwscrl\fR - scroll a
|
||||
\fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint scroll(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint scrl(int n);\fR
|
||||
.br
|
||||
\fBint wscrl(WINDOW *win, int n);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBscroll\fR routine scrolls the window up one line. This involves moving
|
||||
the lines in the window data structure. As an optimization, if the scrolling
|
||||
region of the window is the entire screen, the physical screen is scrolled at
|
||||
the same time.
|
||||
|
||||
With the \fBscrl\fR and \fBwscrl\fR routines, for positive \fIn\fR scroll the
|
||||
window up \fIn\fR lines (line \fIi\fR+\fIn\fR becomes \fIi\fR); otherwise
|
||||
scroll the window down \fIn\fR lines. This involves moving the lines in the
|
||||
window character image structure. The current cursor position is not changed.
|
||||
|
||||
For these functions to work, scrolling must be enabled via \fBscrollok\fR.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that \fBscrl\fR and \fBscroll\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_outopts\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
85
lib/libncurses/curs_slk.3
Normal file
85
lib/libncurses/curs_slk.3
Normal file
@ -0,0 +1,85 @@
|
||||
.TH curs_slk 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_slk\fR: \fBslk_init\fR, \fBslk_set\fR, \fBslk_refresh\fR,
|
||||
\fBslk_noutrefresh\fR, \fBslk_label\fR, \fBslk_clear\fR, \fBslk_restore\fR,
|
||||
\fBslk_touch\fR, \fBslk_attron\fR, \fBslk_attrset\fR, \fBslk_attroff\fR -
|
||||
\fBncurses\fR soft label routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint slk_init(int fmt);\fR
|
||||
.br
|
||||
\fBint slk_set(int labnum, char *label, int fmt);\fR
|
||||
.br
|
||||
\fBint slk_refresh(void);\fR
|
||||
.br
|
||||
\fBint slk_noutrefresh(void);\fR
|
||||
.br
|
||||
\fBchar *slk_label(int labnum);\fR
|
||||
.br
|
||||
\fBint slk_clear(void);\fR
|
||||
.br
|
||||
\fBint slk_restore(void);\fR
|
||||
.br
|
||||
\fBint slk_touch(void);\fR
|
||||
.br
|
||||
\fBint slk_attron(chtype attrs);\fR
|
||||
.br
|
||||
\fBint slk_attrset(chtype attrs);\fR
|
||||
.br
|
||||
\fBint slk_attroff(chtype attrs);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The slk* functions manipulate the set of soft function-key labels that exist on
|
||||
many terminals. For those terminals that do not have soft labels,
|
||||
\fBncurses\fR takes over the bottom line of \fBstdscr\fR, reducing the size of
|
||||
\fBstdscr\fR and the variable \fBLINES\fR. \fBncurses\fR standardizes on eight
|
||||
labels of up to eight characters each.
|
||||
|
||||
The \fBslk_init\fR routine must be called before \fBinitscr\fR or \fBnewterm\fR
|
||||
is called. If \fBinitscr\fR eventually uses a line from \fBstdscr\fR to
|
||||
emulate the soft labels, then \fIfmt\fR determines how the labels are arranged
|
||||
on the screen. Setting \fIfmt\fR to \fB0\fR indicates a 3-2-3 arrangement of
|
||||
the labels; \fB1\fR indicates a 4-4 arrangement.
|
||||
|
||||
With the \fBslk_set\fR routine, \fIlabnum\fR is the label number, from \fB1\fR
|
||||
to \fB8\fR. \fIlabel\fR is the string to be put on the label, up to eight
|
||||
characters in length. A null string or a null pointer sets up a blank label.
|
||||
\fIfmt\fR is either \fB0\fR, \fB1\fR, or \fB2\fR, indicating whether the label
|
||||
is to be left-justified, centered, or right-justified, respectively, within the
|
||||
label.
|
||||
|
||||
The \fBslk_refresh\fR and \fBslk_noutrefresh\fR routines correspond to
|
||||
the \fBwrefresh\fR and \fBwnoutrefresh\fR routines.
|
||||
|
||||
The \fBslk_label\fR routine returns the current label for label number
|
||||
\fIlabnum\fR, with leading and trailing blanks stripped.
|
||||
|
||||
The \fBslk_clear\fR routine clears the soft labels from the screen.
|
||||
|
||||
The \fBslk_restore\fR routine, restores the soft labels to the screen
|
||||
after a \fBslk_clear\fR has been performed.
|
||||
|
||||
The \fBslk_touch\fR routine forces all the soft labels to be output
|
||||
the next time a \fBslk_noutrefresh\fR is performed.
|
||||
|
||||
The \fBslk_attron\fR, \fBslk_attrset\fR and \fBslk_attroff\fR routines
|
||||
correspond to \fBattron\fR, \fBattrset\fR, and \fBattroff\fR. They
|
||||
have an effect only if soft labels are simulated on the bottom line of
|
||||
the screen.
|
||||
.SH RETURN VALUE
|
||||
Routines that return an integer return \fBERR\fR upon failure and an integer
|
||||
value other than \fBERR\fR upon successful completion.
|
||||
|
||||
\fBslk_label\fR returns \fBNULL\fR on error.
|
||||
.SH NOTES
|
||||
Most applications would use \fBslk_noutrefresh\fR because a
|
||||
\fBwrefresh\fR is likely to follow soon.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_attr\fR(3X), \fBcurs_initscr\fR(3X), \fBcurs_refresh\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
76
lib/libncurses/curs_termatt.3
Normal file
76
lib/libncurses/curs_termatt.3
Normal file
@ -0,0 +1,76 @@
|
||||
.TH curs_termattrs 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_termattrs\fR: \fBbaudrate\fR, \fBerasechar\fR, \fBhas_ic\fR,
|
||||
\fBhas_il\fR, \fBkillchar\fR, \fBlongname\fR, \fBtermattrs\fR,
|
||||
\fBtermname\fR - \fBncurses\fR environment query routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint baudrate(void);\fR
|
||||
.br
|
||||
\fBchar erasechar(void);\fR
|
||||
.br
|
||||
\fBint has_ic(void);\fR
|
||||
.br
|
||||
\fBint has_il(void);\fR
|
||||
.br
|
||||
\fBchar killchar(void);\fR
|
||||
.br
|
||||
\fBchar *longname(void);\fR
|
||||
.br
|
||||
\fBchtype termattrs(void);\fR
|
||||
.br
|
||||
\fBchar *termname(void);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBbaudrate\fR routine returns the output speed of the terminal. The
|
||||
number returned is in bits per second, for example \fB9600\fR, and is an
|
||||
integer.
|
||||
|
||||
The \fBerasechar\fR routine returns the user's current erase character.
|
||||
|
||||
The \fBhas_ic\fR routine is true if the terminal has insert- and delete-
|
||||
character capabilities.
|
||||
|
||||
The \fBhas_il\fR routine is true if the terminal has insert- and delete-line
|
||||
capabilities, or can simulate them using scrolling regions. This might
|
||||
be used to determine if it would be appropriate to turn on physical
|
||||
scrolling using \fBscrollok\fR.
|
||||
|
||||
The \fBkillchar\fR routine returns the user's current line kill character.
|
||||
|
||||
The \fBlongname\fR routine returns a pointer to a static area
|
||||
containing a verbose description of the current terminal. The maximum
|
||||
length of a verbose description is 128 characters. It is defined only
|
||||
after the call to \fBinitscr\fR or \fBnewterm\fR. The area is
|
||||
overwritten by each call to \fBnewterm\fR and is not restored by
|
||||
\fBset_term\fR, so the value should be saved between calls to
|
||||
\fBnewterm\fR if \fBlongname\fR is going to be used with multiple
|
||||
terminals.
|
||||
|
||||
If a given terminal doesn't support a video attribute that an
|
||||
application program is trying to use, \fBncurses\fR may substitute a
|
||||
different video attribute for it. The \fBtermattrs\fR function
|
||||
returns a logical \fBOR\fR of all video attributes supported by the
|
||||
terminal. This information is useful when a \fBncurses\fR program
|
||||
needs complete control over the appearance of the screen.
|
||||
|
||||
The \fBtermname\fR routine returns the value of the environmental
|
||||
variable \fBTERM\fR (truncated to 14 characters).
|
||||
.SH RETURN VALUE
|
||||
\fBlongname\fR and \fBtermname\fR return \fBNULL\fR on error.
|
||||
|
||||
Routines that return an integer return \fBERR\fR upon failure and an integer
|
||||
value other than \fBERR\fR upon successful completion.
|
||||
.SH BUGS
|
||||
The \fBtermattr\fR entry point is not implemented in ncurses 1.8.1.
|
||||
.SH NOTES
|
||||
Note that \fBtermattrs\fR may be a macro.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_initscr\fR(3X), \fBcurs_outopts\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
57
lib/libncurses/curs_touch.3
Normal file
57
lib/libncurses/curs_touch.3
Normal file
@ -0,0 +1,57 @@
|
||||
.TH curs_touch 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_touch\fR: \fBtouchwin\fR, \fBtouchline\fR, \fBuntouchwin\fR,
|
||||
\fBwtouchln\fR, \fBis_linetouched\fR, \fBis_wintouched\fR -
|
||||
\fBncurses\fR refresh control routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
.br
|
||||
\fBint touchwin(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint touchline(WINDOW *win, int start, int count);\fR
|
||||
.br
|
||||
\fBint untouchwin(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint wtouchln(WINDOW *win, int y, int n, int changed);\fR
|
||||
.br
|
||||
\fBint is_linetouched(WINDOW *win, int line);\fR
|
||||
.br
|
||||
\fBint is_wintouched(WINDOW *win);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBtouchwin\fR and \fBtouchline\fR routines throw away all
|
||||
optimization information about which parts of the window have been
|
||||
touched, by pretending that the entire window has been drawn on. This
|
||||
is sometimes necessary when using overlapping windows, since a change
|
||||
to one window affects the other window, but the records of which lines
|
||||
have been changed in the other window do not reflect the change. The
|
||||
routine \fBtouchline\fR only pretends that \fIcount\fR lines have been
|
||||
changed, beginning with line \fIstart\fR.
|
||||
|
||||
The \fBuntouchwin\fR routine marks all lines in the window as unchanged since
|
||||
the last call to \fBwrefresh\fR.
|
||||
|
||||
The \fBwtouchln\fR routine makes \fIn\fR lines in the window, starting
|
||||
at line \fIy\fR, look as if they have (\fIchanged\fR\fB=1\fR) or have
|
||||
not (\fIchanged\fR\fB=0\fR) been changed since the last call to
|
||||
\fBwrefresh\fR.
|
||||
|
||||
The \fBis_linetouched\fR and \fBis_wintouched\fR routines return
|
||||
\fBTRUE\fR if the specified line/window was modified since the last
|
||||
call to \fBwrefresh\fR; otherwise they return \fBFALSE\fR. In
|
||||
addition, \fBis_linetouched\fR returns \fBERR\fR if \fIline\fR is not
|
||||
valid for the given window.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion, unless otherwise noted in the
|
||||
preceding routine descriptions.
|
||||
.SH NOTES
|
||||
Note that all routines except \fBwtouchln\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_refresh\fR(3X).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
82
lib/libncurses/curs_util.3
Normal file
82
lib/libncurses/curs_util.3
Normal file
@ -0,0 +1,82 @@
|
||||
.TH curs_util 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_util\fR: \fBunctrl\fR, \fBkeyname\fR, \fBfilter\fR,
|
||||
\fBuse_env\fR, \fBputwin\fR, \fBgetwin\fR, \fBdelay_output\fR,
|
||||
\fBflushinp\fR - miscellaneous \fBncurses\fR utility routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBchar *unctrl(chtype c);\fR
|
||||
.br
|
||||
\fBchar *keyname(int c);\fR
|
||||
.br
|
||||
\fBint filter(void);\fR
|
||||
.br
|
||||
\fBvoid use_env(char bool);\fR
|
||||
.br
|
||||
\fBint putwin(WINDOW *win, FILE *filep);\fR
|
||||
.br
|
||||
\fBWINDOW *getwin(FILE *filep);\fR
|
||||
.br
|
||||
\fBint delay_output(int ms);\fR
|
||||
.br
|
||||
\fBint flushinp(void);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBunctrl\fR macro expands to a character string which is a printable
|
||||
representation of the character \fIc\fR. Control characters are displayed in
|
||||
the \fB^\fR\fIX\fR notation. Printing characters are displayed as is.
|
||||
|
||||
The \fBkeyname\fR routine returns a character string corresponding to
|
||||
the key \fIc\fR.
|
||||
|
||||
The \fBfilter\fR routine, if used, must be called before \fBinitscr\fR or
|
||||
\fBnewterm\fR are called. It makes \fBncurses\fR think that there is a
|
||||
one-line screen. \fBncurses\fR does not use any terminal capabilities
|
||||
that assume that they know on what line of the screen the cursor is
|
||||
positioned.
|
||||
|
||||
The \fBuse_env\fR routine, if used, is called before \fBinitscr\fR or
|
||||
\fBnewterm\fR are called. When called with \fBFALSE\fR as an
|
||||
argument, the values of \fBlines\fR and \fBcolumns\fR specified in the
|
||||
\fIterminfo\fR database will be used, even if environment variables
|
||||
\fBLINES\fR and \fBCOLUMNS\fR (used by default) are set, or if
|
||||
\fBncurses\fR is running in a window (in which case default behavior
|
||||
would be to use the window size if \fBLINES\fR and \fBCOLUMNS\fR are
|
||||
not set).
|
||||
|
||||
The \fBputwin\fR routine writes all data associated with window \fIwin\fR into
|
||||
the file to which \fIfilep\fR points. This information can be later retrieved
|
||||
using the \fBgetwin\fR function.
|
||||
|
||||
The \fBgetwin\fR routine reads window related data stored in the file by
|
||||
\fBputwin\fR. The routine then creates and initializes a new window using that
|
||||
data. It returns a pointer to the new window.
|
||||
|
||||
The \fBdelay_output\fR routine inserts an \fIms\fR millisecond pause
|
||||
in output. This routine should not be used extensively because
|
||||
padding characters are used rather than a CPU pause.
|
||||
|
||||
The \fBflushinp\fR routine throws away any typeahead that has been typed by the
|
||||
user and has not yet been read by the program.
|
||||
.SH RETURN VALUE
|
||||
Except for \fBflushinp\fR, routines that return an integer return
|
||||
\fBERR\fR upon failure and an integer value other than \fBERR\fR upon
|
||||
successful completion.
|
||||
|
||||
\fBflushinp\fR always returns \fBOK\fR.
|
||||
|
||||
Routines that return pointers return \fBNULL\fR on error.
|
||||
.SH BUGS
|
||||
The \fBfilter\fR and \fBdelay_output\fR entry points are not yet
|
||||
supported in ncurses 1.8.1.
|
||||
.SH NOTES
|
||||
Note that \fBunctrl\fR is a macro, which is defined in <\fBunctrl.h\fR>.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_initscr\fR(3X), \fBcurs_scr_dump\fR(3X).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
119
lib/libncurses/curs_window.3
Normal file
119
lib/libncurses/curs_window.3
Normal file
@ -0,0 +1,119 @@
|
||||
.TH curs_window 3X ""
|
||||
.SH NAME
|
||||
\fBcurs_window\fR: \fBnewwin\fR, \fBdelwin\fR, \fBmvwin\fR,
|
||||
\fBsubwin\fR, \fBderwin\fR, \fBmvderwin\fR, \fBdupwin\fR,
|
||||
\fBwsyncup\fR, \fBsyncok\fR, \fBwcursyncup\fR, \fBwsyncdown\fR -
|
||||
create \fBncurses\fR windows
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBWINDOW *newwin(int nlines, int ncols, int begin_y,\fR
|
||||
\fBintbegin_x);\fR
|
||||
|
||||
\fBint delwin(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint mvwin(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
\fBWINDOW *subwin(WINDOW *orig, int nlines, int ncols,
|
||||
int begin_y, int begin_x);\fR
|
||||
\fBWINDOW *derwin(WINDOW *orig, int nlines, int ncols,
|
||||
int begin_y, int begin_x);\fR
|
||||
\fBint mvderwin(WINDOW *win, int par_y, int par_x);\fR
|
||||
.br
|
||||
\fBWINDOW *dupwin(WINDOW *win);\fR
|
||||
.br
|
||||
\fBvoid wsyncup(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint syncok(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBvoid wcursyncup(WINDOW *win);\fR
|
||||
.br
|
||||
\fBvoid wsyncdown(WINDOW *win);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBnewwin\fR routine creates and returns a pointer to a new window with the
|
||||
given number of lines and columns. The upper left-hand corner of the window is
|
||||
at line \fIbegin\fR_\fIy\fR, column \fIbegin\fR_\fIx\fR. If either
|
||||
\fInlines\fR or \fIncols\fR is zero, they default to \fBLINES -\fR
|
||||
\fIbegin\fR_\fIy\fR and \fBCOLS -\fR \fIbegin\fR_\fIx\fR. A new full-screen
|
||||
window is created by calling \fBnewwin(0,0,0,0)\fR.
|
||||
|
||||
The \fBdelwin\fR routine deletes the named window, freeing all memory
|
||||
associated with it (it does not actually erase the window's screen
|
||||
image). Subwindows must be deleted before the main window can be
|
||||
deleted.
|
||||
|
||||
The \fBmvwin\fR routine moves the window so that the upper left-hand
|
||||
corner is at position (\fIx\fR, \fIy\fR). If the move would cause the
|
||||
window to be off the screen, it is an error and the window is not
|
||||
moved. Moving subwindows is allowed, but should be avoided.
|
||||
|
||||
The \fBsubwin\fR routine creates and returns a pointer to a new window
|
||||
with the given number of lines, \fInlines\fR, and columns,
|
||||
\fIncols\fR. The window is at position (\fIbegin\fR_\fIy\fR,
|
||||
\fIbegin\fR_\fIx\fR) on the screen. (This position is relative to the
|
||||
screen, and not to the window \fIorig\fR.) The window is made in the
|
||||
middle of the window \fIorig\fR, so that changes made to one window
|
||||
will affect both windows. The subwindow shares memory with the window
|
||||
\fIorig\fR. When using this routine, it is necessary to call
|
||||
\fBtouchwin\fR or \fBtouchline\fR on \fIorig\fR before calling
|
||||
\fBwrefresh\fR on the subwindow.
|
||||
|
||||
The \fBderwin\fR routine is the same as \fBsubwin,\fR except that
|
||||
\fIbegin\fR_\fIy\fR and \fIbegin\fR_\fIx\fR are relative to the origin
|
||||
of the window \fIorig\fR rather than the screen. There is no
|
||||
difference between the subwindows and the derived windows.
|
||||
|
||||
The \fBmvderwin\fR routine moves a derived window (or subwindow)
|
||||
inside its parent window. The screen-relative parameters of the
|
||||
window are not changed. This routine is used to display different
|
||||
parts of the parent window at the same physical position on the
|
||||
screen.
|
||||
|
||||
The \fBdupwin\fR routine creates an exact duplicate of the window \fIwin\fR.
|
||||
|
||||
Each \fBncurses\fR window maintains two data structures: the character
|
||||
image structure and the status structure. The character image
|
||||
structure is shared among all windows in the window hierarchy
|
||||
(\fIi\fR.\fIe\fR., the window with all subwindows). The status
|
||||
structure, which contains information about individual line changes in
|
||||
the window, is private to each window. The routine \fBwrefresh\fR
|
||||
uses the status data structure when performing screen updating. Since
|
||||
status structures are not shared, changes made to one window in the
|
||||
hierarchy may not be properly reflected on the screen.
|
||||
|
||||
The routine \fBwsyncup\fR causes the changes in the status structure
|
||||
of a window to be reflected in the status structures of its ancestors.
|
||||
If \fBsyncok\fR is called with second argument \fBTRUE\fR then
|
||||
\fBwsyncup\fR is called automatically whenever there is a change in
|
||||
the window.
|
||||
|
||||
The routine \fBwcursyncup\fR updates the current cursor position of all the
|
||||
ancestors of the window to reflect the current cursor position of the
|
||||
window.
|
||||
|
||||
The routine \fBwsyncdown\fR updates the status structure of the window
|
||||
to reflect the changes in the status structures of its ancestors.
|
||||
Applications seldom call this routine because it is called
|
||||
automatically by \fBwrefresh\fR.
|
||||
.SH RETURN VALUE
|
||||
Routines that return an integer return the integer \fBERR\fR upon failure and
|
||||
an integer value other than \fBERR\fR upon successful completion.
|
||||
|
||||
\fBdelwin\fR returns the integer \fBERR\fR upon failure and \fBOK\fR
|
||||
upon successful completion.
|
||||
|
||||
Routines that return pointers return \fBNULL\fR on error.
|
||||
.SH NOTES
|
||||
If many small changes are made to the window, the \fBwsyncup\fR option could
|
||||
degrade performance.
|
||||
|
||||
Note that \fBsyncok\fR may be a macro.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3X), \fBcurs_refresh\fR(3X), \fBcurs_touch\fR(3X)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
115
lib/libncurses/curses.priv.h
Normal file
115
lib/libncurses/curses.priv.h
Normal file
@ -0,0 +1,115 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
* curses.priv.h
|
||||
*
|
||||
* Header file for curses library objects which are private to
|
||||
* the library.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define inline
|
||||
#endif
|
||||
|
||||
#ifndef NOACTION
|
||||
#include <unistd.h>
|
||||
typedef struct sigaction sigaction_t;
|
||||
#else
|
||||
#include "SigAction.h"
|
||||
#endif
|
||||
|
||||
#include <ncurses.h>
|
||||
|
||||
#define min(a,b) ((a) > (b) ? (b) : (a))
|
||||
#define max(a,b) ((a) < (b) ? (b) : (a))
|
||||
|
||||
#define FG(n) ((n) & 0x0f)
|
||||
#define BG(n) (((n) & 0xf0) >> 4)
|
||||
|
||||
#define CHANGED -1
|
||||
|
||||
extern WINDOW *newscr;
|
||||
extern int _coloron;
|
||||
extern int _isendwin;
|
||||
|
||||
#ifdef TRACE
|
||||
#define T(a) if (_tracing) _tracef a
|
||||
extern int _tracing;
|
||||
#else
|
||||
#define T(a)
|
||||
#endif
|
||||
|
||||
extern int _outc(char);
|
||||
extern void init_acs(void);
|
||||
extern void tstp(int);
|
||||
extern WINDOW *makenew(int, int, int, int);
|
||||
extern int timed_wait(int fd, int wait, int *timeleft);
|
||||
|
||||
struct try {
|
||||
struct try *child; /* ptr to child. NULL if none */
|
||||
struct try *sibling; /* ptr to sibling. NULL if none */
|
||||
unsigned char ch; /* character at this node */
|
||||
unsigned short value; /* code of string so far. 0 if none. */
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure for soft labels.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
char dirty; /* all labels have changed */
|
||||
char hidden; /* soft lables are hidden */
|
||||
WINDOW *win;
|
||||
struct slk_ent {
|
||||
char text[9]; /* text for the label */
|
||||
char form_text[9]; /* formatted text (left/center/...) */
|
||||
int x; /* x coordinate of this field */
|
||||
char dirty; /* this label has changed */
|
||||
char visible; /* field is visible */
|
||||
} ent[8];
|
||||
} SLK;
|
||||
|
||||
#define FIFO_SIZE 32
|
||||
|
||||
struct screen {
|
||||
FILE *_ifp; /* input file ptr for this terminal */
|
||||
FILE *_ofp; /* output file ptr for this terminal */
|
||||
#ifdef MYTINFO
|
||||
struct _terminal *_term;
|
||||
#else
|
||||
struct term *_term; /* used by terminfo stuff */
|
||||
#endif
|
||||
WINDOW *_curscr; /* windows specific to a given terminal */
|
||||
WINDOW *_newscr;
|
||||
struct try *_keytry; /* "Try" for use with keypad mode */
|
||||
unsigned int _fifo[FIFO_SIZE]; /* Buffer for pushed back characters */
|
||||
signed char _fifohead,
|
||||
_fifotail,
|
||||
_fifopeek;
|
||||
int _cursrow; /* Row and column of physical cursor */
|
||||
int _curscol;
|
||||
bool _nl; /* True if NL -> CR/NL is on */
|
||||
bool _raw; /* True if in raw mode */
|
||||
int _cbreak; /* 1 if in cbreak mode */
|
||||
/* > 1 if in halfdelay mode */
|
||||
bool _echo; /* True if echo on */
|
||||
bool _nlmapping; /* True if terminal is really doing */
|
||||
/* NL mapping (fn of raw and nl) */
|
||||
SLK *_slk; /* ptr to soft key struct / NULL */
|
||||
int _costs[9]; /* costs of cursor movements for mvcur */
|
||||
int _costinit; /* flag wether costs[] is initialized */
|
||||
};
|
||||
|
||||
extern struct screen *SP;
|
||||
|
||||
extern int _slk_format; /* format specified in slk_init() */
|
||||
|
||||
#define MAXCOLUMNS 135
|
||||
#define MAXLINES 66
|
||||
#define UNINITIALISED ((struct try * ) -1)
|
149
lib/libncurses/keys.list
Normal file
149
lib/libncurses/keys.list
Normal file
@ -0,0 +1,149 @@
|
||||
key_a1 KEY_A1
|
||||
key_a3 KEY_A3
|
||||
key_b2 KEY_B2
|
||||
key_backspace KEY_BACKSPACE
|
||||
key_beg KEY_BEG
|
||||
key_btab KEY_BTAB
|
||||
key_c1 KEY_C1
|
||||
key_c3 KEY_C3
|
||||
key_cancel KEY_CANCEL
|
||||
key_catab KEY_CATAB
|
||||
key_clear KEY_CLEAR
|
||||
key_close KEY_CLOSE
|
||||
key_command KEY_COMMAND
|
||||
key_copy KEY_COPY
|
||||
key_create KEY_CREATE
|
||||
key_ctab KEY_CTAB
|
||||
key_dc KEY_DC
|
||||
key_dl KEY_DL
|
||||
key_down KEY_DOWN
|
||||
key_eic KEY_EIC
|
||||
key_end KEY_END
|
||||
key_enter KEY_ENTER
|
||||
key_eol KEY_EOL
|
||||
key_eos KEY_EOS
|
||||
key_exit KEY_EXIT
|
||||
key_f0 KEY_F(0)
|
||||
key_f1 KEY_F(1)
|
||||
key_f2 KEY_F(2)
|
||||
key_f3 KEY_F(3)
|
||||
key_f4 KEY_F(4)
|
||||
key_f5 KEY_F(5)
|
||||
key_f6 KEY_F(6)
|
||||
key_f7 KEY_F(7)
|
||||
key_f8 KEY_F(8)
|
||||
key_f9 KEY_F(9)
|
||||
key_f10 KEY_F(10)
|
||||
key_f11 KEY_F(11)
|
||||
key_f12 KEY_F(12)
|
||||
key_f13 KEY_F(13)
|
||||
key_f14 KEY_F(14)
|
||||
key_f15 KEY_F(15)
|
||||
key_f16 KEY_F(16)
|
||||
key_f17 KEY_F(17)
|
||||
key_f18 KEY_F(18)
|
||||
key_f19 KEY_F(19)
|
||||
key_f20 KEY_F(20)
|
||||
key_f21 KEY_F(21)
|
||||
key_f22 KEY_F(22)
|
||||
key_f23 KEY_F(23)
|
||||
key_f24 KEY_F(24)
|
||||
key_f25 KEY_F(25)
|
||||
key_f26 KEY_F(26)
|
||||
key_f27 KEY_F(27)
|
||||
key_f28 KEY_F(28)
|
||||
key_f29 KEY_F(29)
|
||||
key_f30 KEY_F(30)
|
||||
key_f31 KEY_F(31)
|
||||
key_f32 KEY_F(32)
|
||||
key_f33 KEY_F(33)
|
||||
key_f34 KEY_F(34)
|
||||
key_f35 KEY_F(35)
|
||||
key_f36 KEY_F(36)
|
||||
key_f37 KEY_F(37)
|
||||
key_f38 KEY_F(38)
|
||||
key_f39 KEY_F(39)
|
||||
key_f40 KEY_F(40)
|
||||
key_f41 KEY_F(41)
|
||||
key_f42 KEY_F(42)
|
||||
key_f43 KEY_F(43)
|
||||
key_f44 KEY_F(44)
|
||||
key_f45 KEY_F(45)
|
||||
key_f46 KEY_F(46)
|
||||
key_f47 KEY_F(47)
|
||||
key_f48 KEY_F(48)
|
||||
key_f49 KEY_F(49)
|
||||
key_f50 KEY_F(50)
|
||||
key_f51 KEY_F(51)
|
||||
key_f52 KEY_F(52)
|
||||
key_f53 KEY_F(53)
|
||||
key_f54 KEY_F(54)
|
||||
key_f55 KEY_F(55)
|
||||
key_f56 KEY_F(56)
|
||||
key_f57 KEY_F(57)
|
||||
key_f58 KEY_F(58)
|
||||
key_f59 KEY_F(59)
|
||||
key_f60 KEY_F(60)
|
||||
key_f61 KEY_F(61)
|
||||
key_f62 KEY_F(62)
|
||||
key_f63 KEY_F(63)
|
||||
key_find KEY_FIND
|
||||
key_help KEY_HELP
|
||||
key_home KEY_HOME
|
||||
key_ic KEY_IC
|
||||
key_il KEY_IL
|
||||
key_left KEY_LEFT
|
||||
key_ll KEY_LL
|
||||
key_mark KEY_MARK
|
||||
key_message KEY_MESSAGE
|
||||
key_move KEY_MOVE
|
||||
key_next KEY_NEXT
|
||||
key_npage KEY_NPAGE
|
||||
key_open KEY_OPEN
|
||||
key_options KEY_OPTIONS
|
||||
key_ppage KEY_PPAGE
|
||||
key_previous KEY_PREVIOUS
|
||||
key_print KEY_PRINT
|
||||
key_redo KEY_REDO
|
||||
key_reference KEY_REFERENCE
|
||||
key_refresh KEY_REFRESH
|
||||
key_replace KEY_REPLACE
|
||||
key_restart KEY_RESTART
|
||||
key_resume KEY_RESUME
|
||||
key_right KEY_RIGHT
|
||||
key_save KEY_SAVE
|
||||
key_sbeg KEY_SBEG
|
||||
key_scancel KEY_SCANCEL
|
||||
key_scommand KEY_SCOMMAND
|
||||
key_scopy KEY_SCOPY
|
||||
key_screate KEY_SCREATE
|
||||
key_sdc KEY_SDC
|
||||
key_sdl KEY_SDL
|
||||
key_select KEY_SELECT
|
||||
key_send KEY_SEND
|
||||
key_seol KEY_SEOL
|
||||
key_sexit KEY_SEXIT
|
||||
key_sf KEY_SF
|
||||
key_sfind KEY_SFIND
|
||||
key_shelp KEY_SHELP
|
||||
key_shome KEY_SHOME
|
||||
key_sic KEY_SIC
|
||||
key_sleft KEY_SLEFT
|
||||
key_smessage KEY_SMESSAGE
|
||||
key_smove KEY_SMOVE
|
||||
key_snext KEY_SNEXT
|
||||
key_soptions KEY_SOPTIONS
|
||||
key_sprevious KEY_SPREVIOUS
|
||||
key_sprint KEY_SPRINT
|
||||
key_sr KEY_SR
|
||||
key_sredo KEY_SREDO
|
||||
key_sreplace KEY_SREPLACE
|
||||
key_sright KEY_SRIGHT
|
||||
key_srsume KEY_SRSUME
|
||||
key_ssave KEY_SSAVE
|
||||
key_ssuspend KEY_SSUSPEND
|
||||
key_stab KEY_STAB
|
||||
key_sundo KEY_SUNDO
|
||||
key_suspend KEY_SUSPEND
|
||||
key_undo KEY_UNDO
|
||||
key_up KEY_UP
|
99
lib/libncurses/lib_acs.c
Normal file
99
lib/libncurses/lib_acs.c
Normal file
@ -0,0 +1,99 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include <nterm.h>
|
||||
#include <string.h>
|
||||
|
||||
/* line graphics */
|
||||
|
||||
|
||||
chtype acs_map[128];
|
||||
|
||||
void init_acs()
|
||||
{
|
||||
|
||||
/*
|
||||
ACS_ULCORNER (acs_map['l'])
|
||||
ACS_LLCORNER (acs_map['m'])
|
||||
ACS_URCORNER (acs_map['k'])
|
||||
ACS_LRCORNER (acs_map['j'])
|
||||
ACS_RTEE (acs_map['u'])
|
||||
ACS_LTEE (acs_map['t'])
|
||||
ACS_BTEE (acs_map['v'])
|
||||
ACS_TTEE (acs_map['w'])
|
||||
ACS_HLINE (acs_map['q'])
|
||||
ACS_VLINE (acs_map['x'])
|
||||
ACS_PLUS (acs_map['n'])
|
||||
ACS_S1 (acs_map['o']) scan line 1
|
||||
ACS_S9 (acs_map['s']) scan line 9
|
||||
ACS_DIAMOND (acs_map['`']) diamond
|
||||
ACS_CKBOARD (acs_map['a']) checker board (stipple)
|
||||
ACS_DEGREE (acs_map['f']) degree symbol
|
||||
ACS_PLMINUS (acs_map['g']) plus/minus
|
||||
ACS_BULLET (acs_map['~']) bullet
|
||||
ACS_LARROW (acs_map[',']) arrow pointing left
|
||||
ACS_RARROW (acs_map['+']) arrow pointing right
|
||||
ACS_DARROW (acs_map['.']) arrow pointing down
|
||||
ACS_UARROW (acs_map['-']) arrow pointing up
|
||||
ACS_BOARD (acs_map['h']) board of squares
|
||||
ACS_LANTERN (acs_map['I']) lantern symbol
|
||||
ACS_BLOCK (acs_map['0']) solid square block
|
||||
*/
|
||||
|
||||
T(("initializing ACS map"));
|
||||
|
||||
acs_map['l'] = acs_map['m'] = acs_map['k'] = acs_map['j'] =
|
||||
acs_map['u'] = acs_map['t'] = acs_map['v'] = acs_map['w'] = (chtype)'+' & A_CHARTEXT;
|
||||
acs_map['q'] = (chtype)'-' & A_CHARTEXT;
|
||||
acs_map['x'] = (chtype)'|' & A_CHARTEXT;
|
||||
acs_map['n'] = (chtype)'+' & A_CHARTEXT;
|
||||
acs_map['o'] = (chtype)'~' & A_CHARTEXT;
|
||||
acs_map['s'] = (chtype)'_' & A_CHARTEXT;
|
||||
acs_map['`'] = (chtype)'+' & A_CHARTEXT;
|
||||
acs_map['a'] = (chtype)':' & A_CHARTEXT;
|
||||
acs_map['f'] = (chtype)'\'' & A_CHARTEXT;
|
||||
acs_map['g'] = (chtype)'#' & A_CHARTEXT;
|
||||
acs_map['~'] = (chtype)'o' & A_CHARTEXT;
|
||||
acs_map[','] = (chtype)'<' & A_CHARTEXT;
|
||||
acs_map['+'] = (chtype)'>' & A_CHARTEXT;
|
||||
acs_map['.'] = (chtype)'v' & A_CHARTEXT;
|
||||
acs_map['-'] = (chtype)'^' & A_CHARTEXT;
|
||||
acs_map['h'] = (chtype)'#' & A_CHARTEXT;
|
||||
acs_map['I'] = (chtype)'#' & A_CHARTEXT;
|
||||
acs_map['0'] = (chtype)'#' & A_CHARTEXT;
|
||||
|
||||
if (ena_acs != NULL)
|
||||
tputs(ena_acs, 1, _outc);
|
||||
|
||||
if (acs_chars != NULL) {
|
||||
int i = 0;
|
||||
int length = strlen(acs_chars);
|
||||
|
||||
while (i < length)
|
||||
switch (acs_chars[i]) {
|
||||
case 'l':case 'm':case 'k':case 'j':
|
||||
case 'u':case 't':case 'v':case 'w':
|
||||
case 'q':case 'x':case 'n':case 'o':
|
||||
case 's':case '`':case 'a':case 'f':
|
||||
case 'g':case '~':case ',':case '+':
|
||||
case '.':case '-':case 'h':case 'I':
|
||||
case '0':
|
||||
acs_map[(unsigned int)(unsigned char)acs_chars[i]] =
|
||||
(acs_chars[++i] & A_CHARTEXT) | A_ALTCHARSET;
|
||||
default:
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef TRACE
|
||||
else {
|
||||
if (_tracing)
|
||||
_tracef("acsc not defined, using default mapping");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
86
lib/libncurses/lib_addch.c
Normal file
86
lib/libncurses/lib_addch.c
Normal file
@ -0,0 +1,86 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_addch.c
|
||||
**
|
||||
** The routine waddch().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include "unctrl.h"
|
||||
|
||||
int
|
||||
waddch(WINDOW *win, chtype c)
|
||||
{
|
||||
int x, y;
|
||||
int newx;
|
||||
chtype ch = c;
|
||||
|
||||
#if 0
|
||||
/* enabling this causes tons of tracing output
|
||||
and slow ncurses down to a crawl */
|
||||
T(("waddch(%x,%c (%x)) called", win, ch&A_CHARTEXT, ch));
|
||||
#endif
|
||||
|
||||
x = win->_curx;
|
||||
y = win->_cury;
|
||||
|
||||
if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0)
|
||||
return(ERR);
|
||||
|
||||
switch (ch&A_CHARTEXT) {
|
||||
case '\t':
|
||||
for (newx = x + (8 - (x & 07)); x < newx; x++)
|
||||
if (waddch(win, ' ') == ERR)
|
||||
return(ERR);
|
||||
return(OK);
|
||||
case '\n':
|
||||
wclrtoeol(win);
|
||||
x = 0;
|
||||
goto newline;
|
||||
case '\r':
|
||||
x = 0;
|
||||
break;
|
||||
case '\b':
|
||||
if (--x < 0)
|
||||
x = 0;
|
||||
break;
|
||||
default:
|
||||
if (ch < ' ')
|
||||
return(waddstr(win, unctrl(ch)));
|
||||
|
||||
ch |= win->_attrs;
|
||||
|
||||
if (win->_line[y][x] != ch) {
|
||||
if (win->_firstchar[y] == _NOCHANGE)
|
||||
win->_firstchar[y] = win->_lastchar[y] = x;
|
||||
else if (x < win->_firstchar[y])
|
||||
win->_firstchar[y] = x;
|
||||
else if (x > win->_lastchar[y])
|
||||
win->_lastchar[y] = x;
|
||||
|
||||
}
|
||||
|
||||
win->_line[y][x++] = ch;
|
||||
if (x > win->_maxx) {
|
||||
x = 0;
|
||||
newline:
|
||||
y++;
|
||||
if (y > win->_regbottom) {
|
||||
y--;
|
||||
if (win->_scroll)
|
||||
scroll(win);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
win->_curx = x;
|
||||
win->_cury = y;
|
||||
|
||||
return(OK);
|
||||
}
|
56
lib/libncurses/lib_addstr.c
Normal file
56
lib/libncurses/lib_addstr.c
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_addstr.c
|
||||
*
|
||||
** The routines waddnstr(), waddchnstr().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int
|
||||
waddnstr(WINDOW *win, char *str, int n)
|
||||
{
|
||||
T(("waddnstr(%x,%s,%d) called", win, str, n));
|
||||
|
||||
if (str == NULL)
|
||||
return ERR;
|
||||
|
||||
if (n < 0) {
|
||||
while (*str != '\0') {
|
||||
if (waddch(win, (unsigned char)*str++) == ERR)
|
||||
return(ERR);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
while((n-- > 0) && (*str != '\0')) {
|
||||
if (waddch(win, (unsigned char)*str++) == ERR)
|
||||
return ERR;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
waddchnstr(WINDOW *win, chtype *str, int n)
|
||||
{
|
||||
T(("waddchnstr(%x,%x,%d) called", win, str, n));
|
||||
|
||||
if (n < 0) {
|
||||
while (*str) {
|
||||
if (waddch(win, *str++) == ERR)
|
||||
return(ERR);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
while(n-- > 0) {
|
||||
if (waddch(win, *str++) == ERR)
|
||||
return ERR;
|
||||
}
|
||||
return OK;
|
||||
}
|
56
lib/libncurses/lib_beep.c
Normal file
56
lib/libncurses/lib_beep.c
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
* beep.c
|
||||
*
|
||||
* Routines beep() and flash()
|
||||
*
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include <nterm.h>
|
||||
|
||||
/*
|
||||
* beep()
|
||||
*
|
||||
* Sound the current terminal's audible bell if it has one. If not,
|
||||
* flash the screen if possible.
|
||||
*
|
||||
*/
|
||||
|
||||
int beep()
|
||||
{
|
||||
T(("beep() called"));
|
||||
|
||||
/* should make sure that we are not in altchar mode */
|
||||
if (bell)
|
||||
return(tputs(bell, 1, _outc));
|
||||
else if (flash_screen)
|
||||
return(tputs(flash_screen, 1, _outc));
|
||||
else
|
||||
return(ERR);
|
||||
}
|
||||
|
||||
/*
|
||||
* flash()
|
||||
*
|
||||
* Flash the current terminal's screen if possible. If not,
|
||||
* sound the audible bell if one exists.
|
||||
*
|
||||
*/
|
||||
|
||||
int flash()
|
||||
{
|
||||
T(("flash() called"));
|
||||
|
||||
/* should make sure that we are not in altchar mode */
|
||||
if (flash_screen)
|
||||
return(tputs(flash_screen, 1, _outc));
|
||||
else if (bell)
|
||||
return(tputs(bell, 1, _outc));
|
||||
else
|
||||
return(ERR);
|
||||
}
|
131
lib/libncurses/lib_box.c
Normal file
131
lib/libncurses/lib_box.c
Normal file
@ -0,0 +1,131 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_box.c
|
||||
**
|
||||
** line drawing routines:
|
||||
** wborder()
|
||||
** whline()
|
||||
** wvline()
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts,
|
||||
chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
|
||||
{
|
||||
int i;
|
||||
int endx, endy;
|
||||
|
||||
T(("wborder() called"));
|
||||
|
||||
if (ls == 0) ls = ACS_VLINE;
|
||||
if (rs == 0) rs = ACS_VLINE;
|
||||
if (ts == 0) ts = ACS_HLINE;
|
||||
if (bs == 0) bs = ACS_HLINE;
|
||||
if (tl == 0) tl = ACS_ULCORNER;
|
||||
if (tr == 0) tr = ACS_URCORNER;
|
||||
if (bl == 0) bl = ACS_LLCORNER;
|
||||
if (br == 0) br = ACS_LRCORNER;
|
||||
|
||||
ls |= win->_attrs;
|
||||
rs |= win->_attrs;
|
||||
ts |= win->_attrs;
|
||||
bs |= win->_attrs;
|
||||
tl |= win->_attrs;
|
||||
tr |= win->_attrs;
|
||||
bl |= win->_attrs;
|
||||
br |= win->_attrs;
|
||||
|
||||
T(("using %x, %x, %x, %x, %x, %x, %x, %x", ls, rs, ts, bs, tl, tr, bl, br));
|
||||
|
||||
endx = win->_maxx;
|
||||
endy = win->_maxy;
|
||||
|
||||
for (i = 0; i <= endx; i++) {
|
||||
win->_line[0][i] = ts;
|
||||
win->_line[endy][i] = bs;
|
||||
}
|
||||
win->_firstchar[endy] = win->_firstchar[0] = 0;
|
||||
win->_lastchar[endy] = win->_lastchar[0] = endx;
|
||||
|
||||
for (i = 0; i <= endy; i++) {
|
||||
win->_line[i][0] = ls;
|
||||
win->_line[i][endx] = rs;
|
||||
win->_firstchar[i] = 0;
|
||||
win->_lastchar[i] = endx;
|
||||
}
|
||||
win->_line[0][0] = tl;
|
||||
win->_line[0][endx] = tr;
|
||||
win->_line[endy][0] = bl;
|
||||
win->_line[endy][endx] = br;
|
||||
|
||||
#if 0
|
||||
if (! win->_scroll && (win->_flags & _SCROLLWIN))
|
||||
fp[0] = fp[endx] = lp[0] = lp[endx] = ' ';
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int whline(WINDOW *win, chtype ch, int n)
|
||||
{
|
||||
int line;
|
||||
int start;
|
||||
int end;
|
||||
|
||||
T(("whline(%x,%x,%d) called", win, ch, n));
|
||||
|
||||
line = win->_cury;
|
||||
start = win->_curx;
|
||||
end = start + n - 1;
|
||||
if (end > win->_maxx)
|
||||
end = win->_maxx;
|
||||
|
||||
if (win->_firstchar[line] == _NOCHANGE || win->_firstchar[line] > start)
|
||||
win->_firstchar[line] = start;
|
||||
if (win->_lastchar[line] == _NOCHANGE || win->_lastchar[line] < start)
|
||||
win->_lastchar[line] = end;
|
||||
|
||||
if (ch == 0)
|
||||
ch = ACS_HLINE;
|
||||
while ( end >= start) {
|
||||
win->_line[line][end] = ch | win->_attrs;
|
||||
end--;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int wvline(WINDOW *win, chtype ch, int n)
|
||||
{
|
||||
int row, col;
|
||||
int end;
|
||||
|
||||
T(("wvline(%x,%x,%d) called", win, ch, n));
|
||||
|
||||
row = win->_cury;
|
||||
col = win->_curx;
|
||||
end = row + n - 1;
|
||||
if (end > win->_maxy)
|
||||
end = win->_maxy;
|
||||
|
||||
if (ch == 0)
|
||||
ch = ACS_VLINE;
|
||||
|
||||
while(end >= row) {
|
||||
win->_line[end][col] = ch | win->_attrs;
|
||||
if (win->_firstchar[end] == _NOCHANGE || win->_firstchar[end] > col)
|
||||
win->_firstchar[end] = col;
|
||||
if (win->_lastchar[end] == _NOCHANGE || win->_lastchar[end] < col)
|
||||
win->_lastchar[end] = col;
|
||||
end--;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
24
lib/libncurses/lib_clear.c
Normal file
24
lib/libncurses/lib_clear.c
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_clear.c
|
||||
**
|
||||
** The routine wclear().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int wclear(WINDOW *win)
|
||||
{
|
||||
T(("wclear(%x) called", win));
|
||||
|
||||
werase(win);
|
||||
|
||||
win->_clear = TRUE;
|
||||
|
||||
return OK;
|
||||
}
|
53
lib/libncurses/lib_clrbot.c
Normal file
53
lib/libncurses/lib_clrbot.c
Normal file
@ -0,0 +1,53 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_clrbot.c
|
||||
**
|
||||
** The routine wclrtobot().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
#define BLANK ' '|A_NORMAL
|
||||
|
||||
int wclrtobot(WINDOW *win)
|
||||
{
|
||||
chtype *ptr, *end, *maxx = NULL;
|
||||
int y, startx, minx;
|
||||
|
||||
T(("wclrtobot(%x) called", win));
|
||||
|
||||
startx = win->_curx;
|
||||
|
||||
T(("clearing from y = %d to y = %d with maxx = %d", win->_cury, win->_maxy, win->_maxx));
|
||||
|
||||
for (y = win->_cury; y <= win->_maxy; y++) {
|
||||
minx = _NOCHANGE;
|
||||
end = &win->_line[y][win->_maxx];
|
||||
|
||||
for (ptr = &win->_line[y][startx]; ptr <= end; ptr++) {
|
||||
if (*ptr != BLANK) {
|
||||
maxx = ptr;
|
||||
if (minx == _NOCHANGE)
|
||||
minx = ptr - win->_line[y];
|
||||
*ptr = BLANK;
|
||||
}
|
||||
}
|
||||
|
||||
if (minx != _NOCHANGE) {
|
||||
if (win->_firstchar[y] > minx
|
||||
|| win->_firstchar[y] == _NOCHANGE)
|
||||
win->_firstchar[y] = minx;
|
||||
|
||||
if (win->_lastchar[y] < maxx - win->_line[y])
|
||||
win->_lastchar[y] = maxx - win->_line[y];
|
||||
}
|
||||
|
||||
startx = 0;
|
||||
}
|
||||
return OK;
|
||||
}
|
48
lib/libncurses/lib_clreol.c
Normal file
48
lib/libncurses/lib_clreol.c
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_clreol.c
|
||||
**
|
||||
** The routine wclrtoeol().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
#define BLANK ' '|A_NORMAL
|
||||
|
||||
int wclrtoeol(WINDOW *win)
|
||||
{
|
||||
chtype *maxx, *ptr, *end;
|
||||
int y, x, minx;
|
||||
|
||||
T(("wclrtoeol(%x) called", win));
|
||||
|
||||
y = win->_cury;
|
||||
x = win->_curx;
|
||||
|
||||
end = &win->_line[y][win->_maxx];
|
||||
minx = _NOCHANGE;
|
||||
maxx = &win->_line[y][x];
|
||||
|
||||
for (ptr = maxx; ptr <= end; ptr++) {
|
||||
if (*ptr != BLANK) {
|
||||
maxx = ptr;
|
||||
if (minx == _NOCHANGE)
|
||||
minx = ptr - win->_line[y];
|
||||
*ptr = BLANK;
|
||||
}
|
||||
}
|
||||
|
||||
if (minx != _NOCHANGE) {
|
||||
if (win->_firstchar[y] > minx || win->_firstchar[y] == _NOCHANGE)
|
||||
win->_firstchar[y] = minx;
|
||||
|
||||
if (win->_lastchar[y] < maxx - win->_line[y])
|
||||
win->_lastchar[y] = maxx - win->_line[y];
|
||||
}
|
||||
return(OK);
|
||||
}
|
107
lib/libncurses/lib_color.c
Normal file
107
lib/libncurses/lib_color.c
Normal file
@ -0,0 +1,107 @@
|
||||
/* This work is copyrighted. See COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/* lib_color.c
|
||||
*
|
||||
* Handles color emulation of SYS V curses
|
||||
*
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include <nterm.h>
|
||||
|
||||
int COLOR_PAIRS;
|
||||
int COLORS;
|
||||
unsigned char color_pairs[64];
|
||||
|
||||
int _coloron = 0;
|
||||
|
||||
int start_color()
|
||||
{
|
||||
T(("start_color() called."));
|
||||
|
||||
if (orig_pair != NULL)
|
||||
tputs(orig_pair, 1, _outc);
|
||||
else return ERR;
|
||||
if (max_pairs != -1)
|
||||
COLOR_PAIRS = max_pairs;
|
||||
else return ERR;
|
||||
if (max_colors != -1)
|
||||
COLORS = max_colors;
|
||||
else return ERR;
|
||||
_coloron = 1;
|
||||
|
||||
T(("started color: COLORS = %d, COLOR_PAIRS = %d", COLORS, COLOR_PAIRS));
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int init_pair(short pair, short f, short b)
|
||||
{
|
||||
T(("init_pair( %d, %d, %d )", pair, f, b));
|
||||
|
||||
if ((pair < 1) || (pair > COLOR_PAIRS))
|
||||
return ERR;
|
||||
if ((f < 0) || (f >= COLORS) || (b < 0) || (b >= COLORS))
|
||||
return ERR;
|
||||
|
||||
/* still to do:
|
||||
if pair was initialized before a screen update is performed
|
||||
replacing original pair colors with the new ones
|
||||
*/
|
||||
|
||||
color_pairs[pair] = ( (f & 0x0f) | (b & 0x0f) << 4 );
|
||||
|
||||
return color_pairs[pair];
|
||||
}
|
||||
|
||||
int init_color(short color, short r, short g, short b)
|
||||
{
|
||||
if (initialize_color != NULL) {
|
||||
if (color < 0 || color >= COLORS)
|
||||
return ERR;
|
||||
if (hue_lightness_saturation == TRUE)
|
||||
if (r < 0 || r > 360 || g < 0 || g > 100 || b < 0 || b > 100)
|
||||
return ERR;
|
||||
if (hue_lightness_saturation == FALSE)
|
||||
if (r < 0 || r > 1000 || g < 0 || g > 1000 || b < 0 || b > 1000)
|
||||
return ERR;
|
||||
|
||||
tputs(tparm(initialize_color, color, r, g, b), 1, _outc);
|
||||
return OK;
|
||||
}
|
||||
|
||||
return ERR;
|
||||
}
|
||||
|
||||
bool can_change_color()
|
||||
{
|
||||
return can_change;
|
||||
}
|
||||
|
||||
int has_colors()
|
||||
{
|
||||
return ((orig_pair != NULL) && (max_colors != -1) && (max_pairs != -1)
|
||||
&&
|
||||
(((set_foreground != NULL) && (set_background != NULL)) ||
|
||||
((set_a_foreground != NULL) && (set_a_background != NULL)))
|
||||
);
|
||||
}
|
||||
|
||||
int color_content(short color, short *r, short *g, short *b)
|
||||
{
|
||||
return ERR;
|
||||
}
|
||||
|
||||
int pair_content(short pair, short *f, short *b)
|
||||
{
|
||||
|
||||
if ((pair < 1) || (pair > COLOR_PAIRS))
|
||||
return ERR;
|
||||
*f = color_pairs[pair] & 0x0f;
|
||||
*b = color_pairs[pair] & 0xf0;
|
||||
*b >>= 4;
|
||||
return OK;
|
||||
}
|
||||
|
38
lib/libncurses/lib_delch.c
Normal file
38
lib/libncurses/lib_delch.c
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_delch.c
|
||||
**
|
||||
** The routine wdelch().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include <nterm.h>
|
||||
|
||||
int wdelch(WINDOW *win)
|
||||
{
|
||||
chtype *temp1, *temp2;
|
||||
chtype *end;
|
||||
|
||||
T(("wdelch(%x) called", win));
|
||||
|
||||
end = &win->_line[win->_cury][win->_maxx];
|
||||
temp2 = &win->_line[win->_cury][win->_curx + 1];
|
||||
temp1 = temp2 - 1;
|
||||
|
||||
while (temp1 < end)
|
||||
*temp1++ = *temp2++;
|
||||
|
||||
*temp1 = ' ' | win->_attrs;
|
||||
|
||||
win->_lastchar[win->_cury] = win->_maxx;
|
||||
|
||||
if (win->_firstchar[win->_cury] == _NOCHANGE
|
||||
|| win->_firstchar[win->_cury] > win->_curx)
|
||||
win->_firstchar[win->_cury] = win->_curx;
|
||||
return OK;
|
||||
}
|
48
lib/libncurses/lib_deleteln.c
Normal file
48
lib/libncurses/lib_deleteln.c
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_deleteln.c
|
||||
**
|
||||
** The routine wdeleteln().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include <nterm.h>
|
||||
|
||||
int wdeleteln(WINDOW *win)
|
||||
{
|
||||
chtype *end, *temp;
|
||||
int y, touched = 0;
|
||||
|
||||
T(("wdeleteln(%x) called", win));
|
||||
|
||||
temp = win->_line[win->_cury];
|
||||
|
||||
if (win->_idlok && (delete_line != NULL)) {
|
||||
putp(delete_line);
|
||||
touched = 1;
|
||||
}
|
||||
|
||||
for (y = win->_cury; y < win->_regbottom; y++) {
|
||||
win->_line[y] = win->_line[y+1];
|
||||
|
||||
if (!touched) {
|
||||
win->_firstchar[y] = 0;
|
||||
win->_lastchar[y] = win->_maxx;
|
||||
}
|
||||
}
|
||||
|
||||
win->_line[win->_regbottom] = temp;
|
||||
if (!touched) {
|
||||
win->_firstchar[win->_regbottom] = 0;
|
||||
win->_lastchar[win->_regbottom] = win->_maxx;
|
||||
}
|
||||
|
||||
for (end = &(temp[win->_maxx]); temp <= end; )
|
||||
*temp++ = ' ' | win->_attrs;
|
||||
return OK;
|
||||
}
|
35
lib/libncurses/lib_delwin.c
Normal file
35
lib/libncurses/lib_delwin.c
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_delwin.c
|
||||
**
|
||||
** The routine delwin().
|
||||
**
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "curses.priv.h"
|
||||
|
||||
int delwin(WINDOW *win)
|
||||
{
|
||||
int i;
|
||||
|
||||
T(("delwin(%x) called", win));
|
||||
|
||||
if (! (win->_flags & _SUBWIN)) {
|
||||
for (i = 0; i < win->_maxy && win->_line[i]; i++)
|
||||
free(win->_line[i]);
|
||||
}
|
||||
|
||||
free(win->_firstchar);
|
||||
free(win->_lastchar);
|
||||
free(win->_line);
|
||||
free(win);
|
||||
|
||||
touchwin(curscr);
|
||||
|
||||
return(OK);
|
||||
}
|
527
lib/libncurses/lib_doupdate.c
Normal file
527
lib/libncurses/lib_doupdate.c
Normal file
@ -0,0 +1,527 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
*
|
||||
* lib_doupdate.c
|
||||
*
|
||||
* The routine doupdate() and its dependents
|
||||
*
|
||||
*-----------------------------------------------------------------*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "curses.priv.h"
|
||||
#include <nterm.h>
|
||||
#ifdef SVR4_ACTION
|
||||
#define _POSIX_SOURCE
|
||||
#endif
|
||||
#include <signal.h>
|
||||
|
||||
static void ClrUpdate( WINDOW *scr );
|
||||
static void TransformLine( int lineno );
|
||||
static void NoIDcTransformLine( int lineno );
|
||||
static void IDcTransformLine( int lineno );
|
||||
static void ClearScreen( void );
|
||||
static void InsStr( chtype *line, int count );
|
||||
static void DelChar( int count );
|
||||
|
||||
static inline void PutAttrChar(chtype ch)
|
||||
{
|
||||
if (curscr->_attrs != (ch & (chtype)A_ATTRIBUTES)) {
|
||||
curscr->_attrs = ch & (chtype)A_ATTRIBUTES;
|
||||
vidputs(curscr->_attrs, _outc);
|
||||
}
|
||||
putc(ch & A_CHARTEXT, SP->_ofp);
|
||||
}
|
||||
|
||||
static int LRCORNER = FALSE;
|
||||
|
||||
static inline void PutChar(chtype ch)
|
||||
{
|
||||
T(("puttin %x", ch));
|
||||
if (LRCORNER == TRUE) {
|
||||
if (SP->_curscol == columns-2) {
|
||||
PutAttrChar(newscr->_line[lines-1][columns-2]);
|
||||
SP->_curscol++;
|
||||
return;
|
||||
} else if (SP->_curscol == columns-1) {
|
||||
int i = lines;
|
||||
int j = columns -1;
|
||||
if (cursor_left)
|
||||
tputs(cursor_left, 1, _outc);
|
||||
else
|
||||
mvcur(-1, -1, i-1, j);
|
||||
if (enter_insert_mode && exit_insert_mode) {
|
||||
tputs(enter_insert_mode, 1, _outc);
|
||||
PutAttrChar(newscr->_line[i-1][j]);
|
||||
tputs(exit_insert_mode, 1, _outc);
|
||||
} else if (insert_character) {
|
||||
tputs(insert_character, 1, _outc);
|
||||
PutAttrChar(newscr->_line[i-1][j]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
PutAttrChar(ch);
|
||||
SP->_curscol++;
|
||||
if (SP->_curscol >= columns) {
|
||||
if (auto_right_margin) {
|
||||
SP->_curscol = 0;
|
||||
SP->_cursrow++;
|
||||
} else {
|
||||
SP->_curscol--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void GoTo(int row, int col)
|
||||
{
|
||||
mvcur(SP->_cursrow, SP->_curscol, row, col);
|
||||
SP->_cursrow = row;
|
||||
SP->_curscol = col;
|
||||
}
|
||||
|
||||
int _outc(char ch)
|
||||
{
|
||||
putc(ch, SP->_ofp);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int doupdate(void)
|
||||
{
|
||||
int i;
|
||||
sigaction_t act, oact;
|
||||
|
||||
T(("doupdate() called"));
|
||||
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
sigaction(SIGTSTP, &act, &oact);
|
||||
|
||||
if (_isendwin == 1) {
|
||||
T(("coming back from shell mode"));
|
||||
reset_prog_mode();
|
||||
/* is this necessary? */
|
||||
if (enter_alt_charset_mode)
|
||||
init_acs();
|
||||
newscr->_clear = TRUE;
|
||||
_isendwin = 0;
|
||||
}
|
||||
|
||||
if (curscr->_clear) { /* force refresh ? */
|
||||
T(("clearing and updating curscr"));
|
||||
ClrUpdate(curscr); /* yes, clear all & update */
|
||||
curscr->_clear = FALSE; /* reset flag */
|
||||
} else {
|
||||
if (newscr->_clear) {
|
||||
T(("clearing and updating newscr"));
|
||||
ClrUpdate(newscr);
|
||||
newscr->_clear = FALSE;
|
||||
} else {
|
||||
T(("Transforming lines"));
|
||||
for (i = 0; i < lines ; i++) {
|
||||
if(newscr->_firstchar[i] != _NOCHANGE)
|
||||
TransformLine(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
T(("marking screen as updated"));
|
||||
for (i = 0; i < lines; i++) {
|
||||
newscr->_firstchar[i] = _NOCHANGE;
|
||||
newscr->_lastchar[i] = _NOCHANGE;
|
||||
}
|
||||
|
||||
curscr->_curx = newscr->_curx;
|
||||
curscr->_cury = newscr->_cury;
|
||||
|
||||
GoTo(curscr->_cury, curscr->_curx);
|
||||
|
||||
/* perhaps we should turn attributes off here */
|
||||
|
||||
if (!(curscr->_attrs & A_NORMAL))
|
||||
vidattr(curscr->_attrs = A_NORMAL);
|
||||
|
||||
fflush(SP->_ofp);
|
||||
|
||||
sigaction(SIGTSTP, &oact, NULL);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int move_right_cost = -1;
|
||||
|
||||
static int countc(char c)
|
||||
{
|
||||
return(move_right_cost++);
|
||||
}
|
||||
|
||||
/*
|
||||
** ClrUpdate(scr)
|
||||
**
|
||||
** Update by clearing and redrawing the entire screen.
|
||||
**
|
||||
*/
|
||||
|
||||
#define BLANK ' '|A_NORMAL
|
||||
|
||||
static void ClrUpdate(WINDOW *scr)
|
||||
{
|
||||
int i = 0, j = 0;
|
||||
int lastNonBlank;
|
||||
|
||||
T(("ClrUpdate(%x) called", scr));
|
||||
if (back_color_erase) {
|
||||
T(("back_color_erase, turning attributes off"));
|
||||
vidattr(A_NORMAL);
|
||||
}
|
||||
ClearScreen();
|
||||
|
||||
if ((move_right_cost == -1) && parm_right_cursor) {
|
||||
move_right_cost = 0;
|
||||
tputs(tparm(parm_right_cursor, 10), 1, countc);
|
||||
}
|
||||
|
||||
T(("updating screen from scratch"));
|
||||
for (i = 0; i < lines; i++) {
|
||||
LRCORNER = FALSE;
|
||||
lastNonBlank = columns - 1;
|
||||
|
||||
while (scr->_line[i][lastNonBlank] == BLANK )
|
||||
lastNonBlank--;
|
||||
|
||||
T(("updating line %d upto %d", i, lastNonBlank));
|
||||
|
||||
/* check if we are at the lr corner */
|
||||
if (i == lines-1)
|
||||
if ((auto_right_margin) && !(eat_newline_glitch) &&
|
||||
(lastNonBlank == columns-1) && !(scr->_scroll))
|
||||
{
|
||||
T(("Lower-right corner needs special handling"));
|
||||
LRCORNER = TRUE;
|
||||
}
|
||||
|
||||
for (j = 0; j <= lastNonBlank; j++) {
|
||||
if (parm_right_cursor) {
|
||||
static int inspace = 0;
|
||||
|
||||
T(("trying to use parm_right_cursor"));
|
||||
if ((scr->_line[i][j]) == BLANK) {
|
||||
inspace++;
|
||||
continue;
|
||||
} else if(inspace) {
|
||||
if (inspace < move_right_cost) {
|
||||
for (; inspace > 0; inspace--)
|
||||
PutChar(scr->_line[i][j-1]);
|
||||
} else {
|
||||
tputs(tparm(parm_right_cursor, inspace), 1, _outc);
|
||||
}
|
||||
inspace = 0;
|
||||
}
|
||||
}
|
||||
PutChar(scr->_line[i][j]);
|
||||
}
|
||||
/* move cursor to the next line */
|
||||
if ((!auto_right_margin) || (lastNonBlank < columns - 1) ||
|
||||
(auto_right_margin && eat_newline_glitch && lastNonBlank == columns-1))
|
||||
{
|
||||
SP->_curscol = (lastNonBlank < 0) ? 0 : lastNonBlank;
|
||||
SP->_cursrow++;
|
||||
GoTo(i+1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (scr != curscr) {
|
||||
for (i = 0; i < lines ; i++)
|
||||
for (j = 0; j < columns; j++)
|
||||
curscr->_line[i][j] = scr->_line[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** TransformLine(lineno)
|
||||
**
|
||||
** Call either IDcTransformLine or NoIDcTransformLine to do the
|
||||
** update, depending upon availability of insert/delete character.
|
||||
*/
|
||||
|
||||
static void TransformLine(int lineno)
|
||||
{
|
||||
|
||||
T(("TransformLine(%d) called",lineno));
|
||||
|
||||
if ( (insert_character || (enter_insert_mode && exit_insert_mode))
|
||||
&& delete_character)
|
||||
IDcTransformLine(lineno);
|
||||
else
|
||||
NoIDcTransformLine(lineno);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** NoIDcTransformLine(lineno)
|
||||
**
|
||||
** Transform the given line in curscr to the one in newscr, without
|
||||
** using Insert/Delete Character.
|
||||
**
|
||||
** firstChar = position of first different character in line
|
||||
** lastChar = position of last different character in line
|
||||
**
|
||||
** overwrite all characters between firstChar and lastChar.
|
||||
**
|
||||
*/
|
||||
|
||||
static void NoIDcTransformLine(int lineno)
|
||||
{
|
||||
int firstChar, lastChar;
|
||||
chtype *newLine = newscr->_line[lineno];
|
||||
chtype *oldLine = curscr->_line[lineno];
|
||||
int k;
|
||||
int attrchanged = 0;
|
||||
|
||||
T(("NoIDcTransformLine(%d) called", lineno));
|
||||
|
||||
firstChar = 0;
|
||||
while (firstChar < columns - 1 && newLine[firstChar] == oldLine[firstChar]) {
|
||||
if(ceol_standout_glitch) {
|
||||
if((newLine[firstChar] & (chtype)A_ATTRIBUTES) != (oldLine[firstChar] & (chtype)A_ATTRIBUTES))
|
||||
attrchanged = 1;
|
||||
}
|
||||
firstChar++;
|
||||
}
|
||||
|
||||
T(("first char at %d is %x", firstChar, newLine[firstChar]));
|
||||
if (firstChar > columns)
|
||||
return;
|
||||
|
||||
if(ceol_standout_glitch && attrchanged) {
|
||||
firstChar = 0;
|
||||
lastChar = columns - 1;
|
||||
GoTo(lineno, firstChar);
|
||||
if(clr_eol) {
|
||||
if (back_color_erase) {
|
||||
T(("back_color_erase, turning attributes off"));
|
||||
vidattr(A_NORMAL);
|
||||
}
|
||||
tputs(clr_eol, 1, _outc);
|
||||
}
|
||||
} else {
|
||||
lastChar = columns - 1;
|
||||
while (lastChar > firstChar && newLine[lastChar] == oldLine[lastChar])
|
||||
lastChar--;
|
||||
GoTo(lineno, firstChar);
|
||||
}
|
||||
|
||||
/* check if we are at the lr corner */
|
||||
if (lineno == lines-1)
|
||||
if ((auto_right_margin) && !(eat_newline_glitch) &&
|
||||
(lastChar == columns-1) && !(curscr->_scroll))
|
||||
{
|
||||
T(("Lower-right corner needs special handling"));
|
||||
LRCORNER = TRUE;
|
||||
}
|
||||
|
||||
T(("updating chars %d to %d", firstChar, lastChar));
|
||||
for (k = firstChar; k <= lastChar; k++) {
|
||||
PutChar(newLine[k]);
|
||||
oldLine[k] = newLine[k];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** IDcTransformLine(lineno)
|
||||
**
|
||||
** Transform the given line in curscr to the one in newscr, using
|
||||
** Insert/Delete Character.
|
||||
**
|
||||
** firstChar = position of first different character in line
|
||||
** oLastChar = position of last different character in old line
|
||||
** nLastChar = position of last different character in new line
|
||||
**
|
||||
** move to firstChar
|
||||
** overwrite chars up to min(oLastChar, nLastChar)
|
||||
** if oLastChar < nLastChar
|
||||
** insert newLine[oLastChar+1..nLastChar]
|
||||
** else
|
||||
** delete oLastChar - nLastChar spaces
|
||||
*/
|
||||
|
||||
static void IDcTransformLine(int lineno)
|
||||
{
|
||||
int firstChar, oLastChar, nLastChar;
|
||||
chtype *newLine = newscr->_line[lineno];
|
||||
chtype *oldLine = curscr->_line[lineno];
|
||||
int k, n;
|
||||
int attrchanged = 0;
|
||||
|
||||
T(("IDcTransformLine(%d) called", lineno));
|
||||
|
||||
if(ceol_standout_glitch && clr_eol) {
|
||||
firstChar = 0;
|
||||
while(firstChar < columns) {
|
||||
if((newLine[firstChar] & (chtype)A_ATTRIBUTES) != (oldLine[firstChar] & (chtype)A_ATTRIBUTES))
|
||||
attrchanged = 1;
|
||||
firstChar++;
|
||||
}
|
||||
}
|
||||
|
||||
firstChar = 0;
|
||||
|
||||
if (attrchanged) {
|
||||
GoTo(lineno, firstChar);
|
||||
if (back_color_erase) {
|
||||
T(("back_color_erase, turning attributes off"));
|
||||
vidattr(A_NORMAL);
|
||||
}
|
||||
tputs(clr_eol, 1, _outc);
|
||||
for( k = 0 ; k <= (columns-1) ; k++ )
|
||||
PutChar(newLine[k]);
|
||||
} else {
|
||||
while (firstChar < columns &&
|
||||
newLine[firstChar] == oldLine[firstChar])
|
||||
firstChar++;
|
||||
|
||||
if (firstChar >= columns)
|
||||
return;
|
||||
|
||||
oLastChar = columns - 1;
|
||||
while (oLastChar > firstChar && oldLine[oLastChar] == ' ')
|
||||
oLastChar--;
|
||||
|
||||
nLastChar = columns - 1;
|
||||
while (nLastChar > firstChar && newLine[nLastChar] == ' ')
|
||||
nLastChar--;
|
||||
|
||||
if((nLastChar == firstChar) && clr_eol) {
|
||||
GoTo(lineno, firstChar);
|
||||
if (back_color_erase) {
|
||||
T(("back_color_erase, turning attributes off"));
|
||||
vidattr(A_NORMAL);
|
||||
}
|
||||
tputs(clr_eol,1,_outc);
|
||||
if(newLine[firstChar] != ' ' )
|
||||
PutChar(newLine[firstChar]);
|
||||
} else if( newLine[nLastChar] != oldLine[oLastChar] ) {
|
||||
n = max( nLastChar , oLastChar );
|
||||
|
||||
GoTo(lineno, firstChar);
|
||||
|
||||
for( k=firstChar ; k <= n ; k++ )
|
||||
PutChar(newLine[k]);
|
||||
} else {
|
||||
while (newLine[nLastChar] == oldLine[oLastChar]) {
|
||||
nLastChar--;
|
||||
oLastChar--;
|
||||
}
|
||||
|
||||
n = min(oLastChar, nLastChar);
|
||||
|
||||
GoTo(lineno, firstChar);
|
||||
|
||||
for (k=firstChar; k <= n; k++)
|
||||
PutChar(newLine[k]);
|
||||
|
||||
if (oLastChar < nLastChar)
|
||||
InsStr(&newLine[k], nLastChar - oLastChar);
|
||||
|
||||
else if (oLastChar > nLastChar )
|
||||
DelChar(oLastChar - nLastChar);
|
||||
}
|
||||
}
|
||||
for (k = firstChar; k < columns; k++)
|
||||
oldLine[k] = newLine[k];
|
||||
}
|
||||
|
||||
/*
|
||||
** ClearScreen()
|
||||
**
|
||||
** Clear the physical screen and put cursor at home
|
||||
**
|
||||
*/
|
||||
|
||||
static void ClearScreen()
|
||||
{
|
||||
|
||||
T(("ClearScreen() called"));
|
||||
|
||||
if (clear_screen) {
|
||||
tputs(clear_screen, 1, _outc);
|
||||
SP->_cursrow = SP->_curscol = 0;
|
||||
} else if (clr_eos) {
|
||||
SP->_cursrow = SP->_curscol = -1;
|
||||
GoTo(0,0);
|
||||
|
||||
tputs(clr_eos, 1, _outc);
|
||||
} else if (clr_eol) {
|
||||
SP->_cursrow = SP->_curscol = -1;
|
||||
|
||||
while (SP->_cursrow < lines) {
|
||||
GoTo(SP->_cursrow, 0);
|
||||
tputs(clr_eol, 1, _outc);
|
||||
}
|
||||
GoTo(0,0);
|
||||
}
|
||||
T(("screen cleared"));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** InsStr(line, count)
|
||||
**
|
||||
** Insert the count characters pointed to by line.
|
||||
**
|
||||
*/
|
||||
|
||||
static void InsStr(chtype *line, int count)
|
||||
{
|
||||
T(("InsStr(%x,%d) called", line, count));
|
||||
|
||||
if (enter_insert_mode && exit_insert_mode) {
|
||||
tputs(enter_insert_mode, 1, _outc);
|
||||
while (count) {
|
||||
PutChar(*line);
|
||||
line++;
|
||||
count--;
|
||||
}
|
||||
tputs(exit_insert_mode, 1, _outc);
|
||||
} else if (parm_ich) {
|
||||
tputs(tparm(parm_ich, count), 1, _outc);
|
||||
while (count) {
|
||||
PutChar(*line);
|
||||
line++;
|
||||
count--;
|
||||
}
|
||||
} else {
|
||||
while (count) {
|
||||
tputs(insert_character, 1, _outc);
|
||||
PutChar(*line);
|
||||
line++;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** DelChar(count)
|
||||
**
|
||||
** Delete count characters at current position
|
||||
**
|
||||
*/
|
||||
|
||||
static void DelChar(int count)
|
||||
{
|
||||
T(("DelChar(%d) called", count));
|
||||
|
||||
if (parm_dch) {
|
||||
tputs(tparm(parm_dch, count), 1, _outc);
|
||||
} else {
|
||||
while (count--)
|
||||
tputs(delete_character, 1, _outc);
|
||||
}
|
||||
}
|
||||
|
44
lib/libncurses/lib_endwin.c
Normal file
44
lib/libncurses/lib_endwin.c
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_endwin.c
|
||||
**
|
||||
** The routine endwin().
|
||||
**
|
||||
*/
|
||||
|
||||
#include <nterm.h>
|
||||
#include "curses.priv.h"
|
||||
|
||||
int _isendwin;
|
||||
|
||||
int isendwin()
|
||||
{
|
||||
return _isendwin;
|
||||
}
|
||||
|
||||
int
|
||||
endwin()
|
||||
{
|
||||
T(("endwin() called"));
|
||||
|
||||
_isendwin = 1;
|
||||
|
||||
mvcur(-1, -1, lines - 1, 0);
|
||||
|
||||
if (exit_ca_mode)
|
||||
tputs(exit_ca_mode, 1, _outc);
|
||||
|
||||
if (_coloron == 1)
|
||||
tputs(orig_pair, 1, _outc);
|
||||
|
||||
if (curscr && (curscr->_attrs != A_NORMAL))
|
||||
vidattr(curscr->_attrs = A_NORMAL);
|
||||
|
||||
fflush(SP->_ofp);
|
||||
|
||||
return(reset_shell_mode());
|
||||
}
|
50
lib/libncurses/lib_erase.c
Normal file
50
lib/libncurses/lib_erase.c
Normal file
@ -0,0 +1,50 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_erase.c
|
||||
**
|
||||
** The routine werase().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include <nterm.h>
|
||||
|
||||
#define BLANK ' '
|
||||
|
||||
int werase(WINDOW *win)
|
||||
{
|
||||
int y;
|
||||
chtype *sp, *end, *start, *maxx = NULL;
|
||||
int minx;
|
||||
|
||||
T(("werase(%x) called", win));
|
||||
|
||||
for (y = win->_regtop; y <= win->_regbottom; y++) {
|
||||
minx = _NOCHANGE;
|
||||
start = win->_line[y];
|
||||
end = &start[win->_maxx];
|
||||
|
||||
maxx = start;
|
||||
for (sp = start; sp <= end; sp++) {
|
||||
maxx = sp;
|
||||
if (minx == _NOCHANGE)
|
||||
minx = sp - start;
|
||||
*sp = BLANK;
|
||||
}
|
||||
|
||||
if (minx != _NOCHANGE) {
|
||||
if (win->_firstchar[y] > minx ||
|
||||
win->_firstchar[y] == _NOCHANGE)
|
||||
win->_firstchar[y] = minx;
|
||||
|
||||
if (win->_lastchar[y] < maxx - win->_line[y])
|
||||
win->_lastchar[y] = maxx - win->_line[y];
|
||||
}
|
||||
}
|
||||
win->_curx = win->_cury = 0;
|
||||
return OK;
|
||||
}
|
217
lib/libncurses/lib_getch.c
Normal file
217
lib/libncurses/lib_getch.c
Normal file
@ -0,0 +1,217 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_getch.c
|
||||
**
|
||||
** The routine getch().
|
||||
**
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#ifdef BRAINDEAD
|
||||
extern int errno;
|
||||
#endif
|
||||
#include "curses.priv.h"
|
||||
|
||||
#define head SP->_fifohead
|
||||
#define tail SP->_fifotail
|
||||
#define peek SP->_fifopeek
|
||||
|
||||
#define h_inc() { head == FIFO_SIZE-1 ? head = 0 : head++; if (head == tail) head = -1, tail = 0;}
|
||||
#define h_dec() { head == 0 ? head = FIFO_SIZE-1 : head--; if (head == tail) tail = -1;}
|
||||
#define t_inc() { tail == FIFO_SIZE-1 ? tail = 0 : tail++; if (tail == head) tail = -1;}
|
||||
#define p_inc() { peek == FIFO_SIZE-1 ? peek = 0 : peek++;}
|
||||
|
||||
static int fifo_peek()
|
||||
{
|
||||
T(("peeking at %d", peek+1));
|
||||
return SP->_fifo[++peek];
|
||||
}
|
||||
|
||||
static inline void fifo_dump()
|
||||
{
|
||||
int i;
|
||||
T(("head = %d, tail = %d, peek = %d", head, tail, peek));
|
||||
for (i = 0; i < 10; i++)
|
||||
T(("char %d = %d (%c)", i, SP->_fifo[i], (unsigned char)SP->_fifo[i]));
|
||||
}
|
||||
|
||||
static inline int fifo_pull()
|
||||
{
|
||||
int ch;
|
||||
ch = SP->_fifo[head];
|
||||
T(("pulling %d from %d", ch, head));
|
||||
|
||||
h_inc();
|
||||
fifo_dump();
|
||||
return ch;
|
||||
}
|
||||
|
||||
int ungetch(int ch)
|
||||
{
|
||||
if (tail == -1)
|
||||
return ERR;
|
||||
if (head == -1) {
|
||||
head = 0;
|
||||
t_inc()
|
||||
} else
|
||||
h_dec();
|
||||
|
||||
SP->_fifo[head] = ch;
|
||||
T(("ungetch ok"));
|
||||
fifo_dump();
|
||||
return OK;
|
||||
}
|
||||
|
||||
static inline int fifo_push()
|
||||
{
|
||||
int n;
|
||||
unsigned char ch;
|
||||
|
||||
if (tail == -1) return ERR;
|
||||
again:
|
||||
n = read(fileno(SP->_ifp), &ch, 1);
|
||||
if (n == -1 && errno == EINTR)
|
||||
goto again;
|
||||
SP->_fifo[tail] = ch;
|
||||
if (head == -1) head = tail;
|
||||
t_inc();
|
||||
T(("pushed %d at %d", ch, tail));
|
||||
fifo_dump();
|
||||
return ch;
|
||||
}
|
||||
|
||||
static inline void fifo_clear()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < FIFO_SIZE; i++)
|
||||
SP->_fifo[i] = 0;
|
||||
head = -1; tail = peek = 0;
|
||||
}
|
||||
|
||||
static int kgetch(WINDOW *);
|
||||
|
||||
int
|
||||
wgetch(WINDOW *win)
|
||||
{
|
||||
bool setHere = FALSE; /* cbreak mode was set here */
|
||||
int ch;
|
||||
|
||||
T(("wgetch(%x) called", win));
|
||||
|
||||
/* this should be eliminated */
|
||||
if (! win->_scroll && (SP->_echo) && (win->_flags & _FULLWIN)
|
||||
&& win->_curx == win->_maxx && win->_cury == win->_maxy)
|
||||
return(ERR);
|
||||
|
||||
if ((is_wintouched(win) || (win->_flags & _HASMOVED)) &&
|
||||
!(win->_flags & _ISPAD))
|
||||
wrefresh(win);
|
||||
|
||||
if (SP->_echo && ! (SP->_raw || SP->_cbreak)) {
|
||||
cbreak();
|
||||
setHere = TRUE;
|
||||
}
|
||||
|
||||
if (win->_delay >= 0 || SP->_cbreak > 1) {
|
||||
int delay;
|
||||
|
||||
T(("timed delay in wgetch()"));
|
||||
if (SP->_cbreak > 1)
|
||||
delay = (SP->_cbreak-1) * 100;
|
||||
else
|
||||
delay = win->_delay;
|
||||
|
||||
T(("delay is %d microseconds", delay));
|
||||
|
||||
if (head == -1) /* fifo is empty */
|
||||
if (timed_wait(fileno(SP->_ifp), delay, NULL) == 0)
|
||||
return ERR;
|
||||
/* else go on to read data available */
|
||||
}
|
||||
|
||||
if (win->_use_keypad)
|
||||
ch = kgetch(win);
|
||||
else {
|
||||
fifo_push();
|
||||
ch = fifo_pull();
|
||||
}
|
||||
|
||||
/* there must be a simpler way of doing this */
|
||||
if (!(win->_flags & _ISPAD) &&
|
||||
SP->_echo && ch < 0400) { /* ch < 0400 => not a keypad key */
|
||||
mvwaddch(curscr, win->_begy + win->_cury,
|
||||
win->_begx + win->_curx, ch | win->_attrs);
|
||||
waddch(win, ch | win->_attrs);
|
||||
}
|
||||
if (setHere)
|
||||
nocbreak();
|
||||
|
||||
T(("wgetch returning : '%c', '0x%x'", ch, ch));
|
||||
|
||||
return(ch);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** int
|
||||
** kgetch()
|
||||
**
|
||||
** Get an input character, but take care of keypad sequences, returning
|
||||
** an appropriate code when one matches the input. After each character
|
||||
** is received, set a one-second alarm call. If no more of the sequence
|
||||
** is received by the time the alarm goes off, pass through the sequence
|
||||
** gotten so far.
|
||||
**
|
||||
*/
|
||||
|
||||
static int
|
||||
kgetch(WINDOW *win)
|
||||
{
|
||||
struct try *ptr;
|
||||
int ch = 0;
|
||||
int timeleft = 2000;
|
||||
|
||||
T(("kgetch(%x) called", win));
|
||||
|
||||
ptr = SP->_keytry;
|
||||
|
||||
if (head == -1) {
|
||||
ch = fifo_push();
|
||||
peek = 0;
|
||||
while (ptr != NULL) {
|
||||
T(("ch = %d", ch));
|
||||
while ((ptr != NULL) && (ptr->ch != (unsigned char)ch))
|
||||
ptr = ptr->sibling;
|
||||
|
||||
if (ptr != NULL)
|
||||
if (ptr->value != 0) { /* sequence terminated */
|
||||
T(("end of sequence"));
|
||||
fifo_clear();
|
||||
return(ptr->value);
|
||||
} else { /* go back for another character */
|
||||
ptr = ptr->child;
|
||||
T(("going back for more"));
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
T(("waiting for rest of sequence"));
|
||||
if (timed_wait(fileno(SP->_ifp), timeleft, &timeleft) < 1) {
|
||||
T(("ran out of time"));
|
||||
return(fifo_pull());
|
||||
} else {
|
||||
T(("got more!"));
|
||||
fifo_push();
|
||||
ch = fifo_peek();
|
||||
}
|
||||
}
|
||||
}
|
||||
return(fifo_pull());
|
||||
}
|
113
lib/libncurses/lib_getstr.c
Normal file
113
lib/libncurses/lib_getstr.c
Normal file
@ -0,0 +1,113 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_getstr.c
|
||||
**
|
||||
** The routine wgetstr().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include "unctrl.h"
|
||||
|
||||
inline void backspace(WINDOW *win)
|
||||
{
|
||||
mvwaddstr(curscr, win->_begy + win->_cury, win->_begx + win->_curx,
|
||||
"\b \b");
|
||||
waddstr(win, "\b \b");
|
||||
fputs("\b \b", SP->_ofp);
|
||||
fflush(SP->_ofp);
|
||||
SP->_curscol--;
|
||||
}
|
||||
|
||||
int wgetnstr(WINDOW *win, char *str, int maxlen)
|
||||
{
|
||||
bool oldnl, oldecho, oldraw, oldcbreak, oldkeypad;
|
||||
char erasec;
|
||||
char killc;
|
||||
char *oldstr;
|
||||
int ch;
|
||||
|
||||
T(("wgetnstr(%x,%x, %d) called", win, str, maxlen));
|
||||
|
||||
oldnl = SP->_nl;
|
||||
oldecho = SP->_echo;
|
||||
oldraw = SP->_raw;
|
||||
oldcbreak = SP->_cbreak;
|
||||
oldkeypad = win->_use_keypad;
|
||||
nl();
|
||||
noecho();
|
||||
noraw();
|
||||
cbreak();
|
||||
keypad(win, FALSE);
|
||||
|
||||
erasec = erasechar();
|
||||
killc = killchar();
|
||||
|
||||
oldstr = str;
|
||||
|
||||
vidattr(win->_attrs);
|
||||
if (is_wintouched(win) || (win->_flags & _HASMOVED))
|
||||
wrefresh(win);
|
||||
|
||||
while ((ch = wgetch(win)) != ERR) {
|
||||
if (ch == '\n' || ch == '\r')
|
||||
break;
|
||||
if (ch == erasec || ch == KEY_LEFT || ch == KEY_BACKSPACE) {
|
||||
if (str > oldstr) {
|
||||
str--;
|
||||
backspace(win);
|
||||
}
|
||||
} else if (ch == killc) {
|
||||
while (str > oldstr) {
|
||||
str--;
|
||||
backspace(win);
|
||||
}
|
||||
} else if (maxlen >= 0 && str - oldstr >= maxlen) {
|
||||
beep();
|
||||
} else {
|
||||
mvwaddstr(curscr, win->_begy + win->_cury,
|
||||
win->_begx + win->_curx, unctrl(ch));
|
||||
waddstr(win, unctrl(ch));
|
||||
if (oldecho == TRUE) {
|
||||
fputs(unctrl(ch), SP->_ofp);
|
||||
fflush(SP->_ofp);
|
||||
}
|
||||
SP->_curscol++;
|
||||
*str++ = ch;
|
||||
}
|
||||
}
|
||||
|
||||
win->_curx = 0;
|
||||
if (win->_cury < win->_maxy)
|
||||
win->_cury++;
|
||||
wrefresh(win);
|
||||
|
||||
if (! oldnl)
|
||||
nonl();
|
||||
|
||||
if (oldecho)
|
||||
echo();
|
||||
|
||||
if (oldraw)
|
||||
raw();
|
||||
|
||||
if (! oldcbreak)
|
||||
nocbreak();
|
||||
|
||||
if (oldkeypad)
|
||||
keypad(win, TRUE);
|
||||
|
||||
if (ch == ERR) {
|
||||
*str = '\0';
|
||||
return ERR;
|
||||
}
|
||||
*str = '\0';
|
||||
|
||||
T(("wgetnstr returns %s", oldstr));
|
||||
|
||||
return(OK);
|
||||
}
|
29
lib/libncurses/lib_inchstr.c
Normal file
29
lib/libncurses/lib_inchstr.c
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_inchstr.c
|
||||
**
|
||||
** The routine winchnstr().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int winchnstr(WINDOW *win, chtype *chstr, int i)
|
||||
{
|
||||
chtype *point, *end;
|
||||
|
||||
T(("winschnstr(%x,'%x',%d) called", win, chstr, i));
|
||||
|
||||
point = &win->_line[win->_cury][win->_curx];
|
||||
end = &win->_line[win->_cury][win->_maxx];
|
||||
if (point + i - 1 < end)
|
||||
end = point + i - 1;
|
||||
|
||||
chstr = (chtype *)malloc((end - point + 1)*sizeof(chtype));
|
||||
chstr[end - point] = '\0';
|
||||
return OK;
|
||||
}
|
32
lib/libncurses/lib_initscr.c
Normal file
32
lib/libncurses/lib_initscr.c
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_initscr.c
|
||||
**
|
||||
** The routine initscr().
|
||||
**
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "curses.priv.h"
|
||||
|
||||
WINDOW *initscr()
|
||||
{
|
||||
#ifdef TRACE
|
||||
_init_trace();
|
||||
|
||||
if (_tracing)
|
||||
_tracef("initscr() called");
|
||||
#endif
|
||||
|
||||
if (newterm(getenv("TERM"), stdout, stdin) == NULL)
|
||||
return NULL;
|
||||
else {
|
||||
def_shell_mode();
|
||||
def_prog_mode();
|
||||
return(stdscr);
|
||||
}
|
||||
}
|
36
lib/libncurses/lib_insch.c
Normal file
36
lib/libncurses/lib_insch.c
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_insch.c
|
||||
**
|
||||
** The routine winsch().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int winsch(WINDOW *win, chtype c)
|
||||
{
|
||||
chtype *temp1, *temp2;
|
||||
chtype *end;
|
||||
|
||||
T(("winsch(%x,'%x') called", win, c));
|
||||
|
||||
end = &win->_line[win->_cury][win->_curx];
|
||||
temp1 = &win->_line[win->_cury][win->_maxx];
|
||||
temp2 = temp1 - 1;
|
||||
|
||||
while (temp1 > end)
|
||||
*temp1-- = *temp2--;
|
||||
|
||||
*temp1 = c | win->_attrs;
|
||||
|
||||
win->_lastchar[win->_cury] = win->_maxx;
|
||||
if (win->_firstchar[win->_cury] == _NOCHANGE
|
||||
|| win->_firstchar[win->_cury] > win->_curx)
|
||||
win->_firstchar[win->_cury] = win->_curx;
|
||||
return OK;
|
||||
}
|
120
lib/libncurses/lib_insdel.c
Normal file
120
lib/libncurses/lib_insdel.c
Normal file
@ -0,0 +1,120 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_insdel.c
|
||||
**
|
||||
** The routine winsdel(win, n).
|
||||
** positive n insert n lines above current line
|
||||
** negative n delete n lines starting from current line
|
||||
**
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "curses.priv.h"
|
||||
#include <nterm.h>
|
||||
|
||||
int
|
||||
winsdel(WINDOW *win, int n)
|
||||
{
|
||||
int line, i;
|
||||
int touched = 0;
|
||||
chtype *ptr, *temp;
|
||||
chtype **saved;
|
||||
chtype blank = ' ';
|
||||
|
||||
T(("winsdel(%x,%d) called", win, n));
|
||||
|
||||
if (n == 0)
|
||||
return OK;
|
||||
if (n < 0 && win->_cury - n >= win->_maxy)
|
||||
/* request to delete too many lines */
|
||||
/* should we truncate to an appropriate number? */
|
||||
return ERR;
|
||||
|
||||
|
||||
saved = (chtype **)malloc(sizeof(chtype *) * abs(n));
|
||||
|
||||
if (n < 0) {
|
||||
/* save overwritten lines */
|
||||
|
||||
for (i = 0; i < -n; i++)
|
||||
saved[i] = win->_line[win->_regbottom-i];
|
||||
|
||||
/* delete n lines */
|
||||
|
||||
for (line = win->_regbottom; line >= win->_cury; line--)
|
||||
win->_line[line] = win->_line[line+n];
|
||||
|
||||
/* restore saved lines and blank them */
|
||||
|
||||
for (i = 0, line = win->_regtop; line < win->_regtop-n; line++, i++) {
|
||||
win->_line[line] = saved[i];
|
||||
temp = win->_line[line];
|
||||
for (ptr = temp; ptr - temp <= win->_maxx; ptr++)
|
||||
*ptr = blank;
|
||||
}
|
||||
}
|
||||
|
||||
if (n > 0) {
|
||||
/* save overwritten lines */
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
saved[i] = win->_line[win->_regtop+i];
|
||||
|
||||
/* insert n lines */
|
||||
|
||||
for (line = win->_regtop; line < win->_regtop + n; line++)
|
||||
win->_line[line] = win->_line[line+n];
|
||||
|
||||
/* restore saved lines and blank them */
|
||||
|
||||
for (i = 0, line = win->_regtop + n; i < n; line--, i++) {
|
||||
temp = win->_line[line] = saved[i];
|
||||
for (ptr = temp; ptr - temp <= win->_maxx; ptr++)
|
||||
*ptr = blank;
|
||||
}
|
||||
}
|
||||
|
||||
free(saved);
|
||||
|
||||
/* as an optimization, if the window is COLS wide we can try
|
||||
using idl assuming _idlok is true */
|
||||
|
||||
if (win->_maxx == columns && win->_idlok == TRUE) {
|
||||
|
||||
if (n > 0) {
|
||||
mvcur(-1, -1, win->_cury, 0);
|
||||
if (parm_insert_line) {
|
||||
putp(tparm(parm_insert_line, n));
|
||||
touched = 1;
|
||||
} else if (insert_line) {
|
||||
while (n--)
|
||||
putp(insert_line);
|
||||
touched = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (n < 0) {
|
||||
mvcur(-1, -1, win->_cury, 0);
|
||||
n = abs(n);
|
||||
if (parm_delete_line) {
|
||||
putp(tparm(parm_delete_line, n));
|
||||
touched = 1;
|
||||
} else if (delete_line) {
|
||||
while (n--)
|
||||
putp(delete_line);
|
||||
touched = 1;
|
||||
}
|
||||
}
|
||||
|
||||
mvcur(-1, -1, win->_cury, win->_curx);
|
||||
}
|
||||
if (touched == 0)
|
||||
touchline(win, win->_regtop, win->_regbottom - win->_regtop + 1);
|
||||
touched = 0;
|
||||
|
||||
return OK;
|
||||
}
|
49
lib/libncurses/lib_insertln.c
Normal file
49
lib/libncurses/lib_insertln.c
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_insertln.c
|
||||
**
|
||||
** The routine winsertln().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include <nterm.h>
|
||||
|
||||
int winsertln(WINDOW *win)
|
||||
{
|
||||
chtype *temp, *end;
|
||||
int y, touched = 0;
|
||||
|
||||
T(("winsertln(%x) called", win));
|
||||
|
||||
temp = win->_line[win->_regbottom];
|
||||
|
||||
if (win->_idlok && (insert_line != NULL)) {
|
||||
putp(insert_line);
|
||||
touched = 1;
|
||||
}
|
||||
|
||||
if (!touched) {
|
||||
win->_firstchar[win->_cury] = 0;
|
||||
win->_lastchar[win->_cury] = win->_maxx;
|
||||
}
|
||||
|
||||
for (y = win->_regbottom; y > win->_cury; y--) {
|
||||
win->_line[y] = win->_line[y-1];
|
||||
|
||||
if (!touched) {
|
||||
win->_firstchar[y] = 0;
|
||||
win->_lastchar[y] = win->_maxx;
|
||||
}
|
||||
}
|
||||
|
||||
win->_line[win->_cury] = temp;
|
||||
|
||||
for (end = &temp[win->_maxx]; temp <= end; temp++)
|
||||
*temp = ' ' | win->_attrs;
|
||||
return OK;
|
||||
}
|
21
lib/libncurses/lib_insstr.c
Normal file
21
lib/libncurses/lib_insstr.c
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_insstr.c
|
||||
**
|
||||
** The routine winsnstr().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int winsnstr(WINDOW *win, char *str, int n)
|
||||
{
|
||||
|
||||
T(("winsstr(%x,'%x',%d) called", win, str, n));
|
||||
|
||||
return OK;
|
||||
}
|
249
lib/libncurses/lib_kernel.c
Normal file
249
lib/libncurses/lib_kernel.c
Normal file
@ -0,0 +1,249 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
* lib_kernel.c
|
||||
*
|
||||
* Misc. low-level routines:
|
||||
* wattron()
|
||||
* reset_prog_mode()
|
||||
* reset_shell_mode()
|
||||
* baudrate()
|
||||
* erasechar()
|
||||
* killchar()
|
||||
* flushinp()
|
||||
* savetty()
|
||||
* resetty()
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include <nterm.h>
|
||||
|
||||
int wattron(WINDOW *win, chtype at)
|
||||
{
|
||||
win->_attrs &= (unsigned long)0xffff00ff;
|
||||
win->_attrs |= at;
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifndef MYTINFO
|
||||
int reset_prog_mode()
|
||||
{
|
||||
T(("reset_prog_mode() called"));
|
||||
|
||||
#ifdef TERMIOS
|
||||
tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb);
|
||||
#else
|
||||
stty(cur_term->Filedes, &cur_term->Nttyb);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int reset_shell_mode()
|
||||
{
|
||||
T(("reset_shell_mode() called"));
|
||||
|
||||
#ifdef TERMIOS
|
||||
tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Ottyb);
|
||||
#else
|
||||
stty(cur_term->Filedes, &cur_term->Ottyb);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
int curs_set(int vis)
|
||||
{
|
||||
T(("curs_set(%d)", vis));
|
||||
|
||||
if (vis < 0 || vis > 2)
|
||||
return ERR;
|
||||
|
||||
switch(vis) {
|
||||
case 2:
|
||||
if (cursor_visible)
|
||||
tputs(cursor_visible, 1, _outc);
|
||||
break;
|
||||
case 1:
|
||||
if (cursor_normal)
|
||||
tputs(cursor_normal, 1, _outc);
|
||||
break;
|
||||
case 0:
|
||||
if (cursor_invisible)
|
||||
tputs(cursor_invisible, 1, _outc);
|
||||
break;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* erasechar()
|
||||
*
|
||||
* Return erase character as given in cur_term->Ottyb.
|
||||
*
|
||||
*/
|
||||
|
||||
char
|
||||
erasechar()
|
||||
{
|
||||
T(("erasechar() called"));
|
||||
|
||||
#ifdef TERMIOS
|
||||
return(cur_term->Ottyb.c_cc[VERASE]);
|
||||
#else
|
||||
return(cur_term->Ottyb.sg_erase);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* killchar()
|
||||
*
|
||||
* Return kill character as given in cur_term->Ottyb.
|
||||
*
|
||||
*/
|
||||
|
||||
char
|
||||
killchar()
|
||||
{
|
||||
T(("killchar() called"));
|
||||
|
||||
#ifdef TERMIOS
|
||||
return(cur_term->Ottyb.c_cc[VKILL]);
|
||||
#else
|
||||
return(cur_term->Ottyb.sg_kill);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* flushinp()
|
||||
*
|
||||
* Flush any input on cur_term->Filedes
|
||||
*
|
||||
*/
|
||||
|
||||
int flushinp()
|
||||
{
|
||||
T(("flushinp() called"));
|
||||
|
||||
#ifdef TERMIOS
|
||||
tcflush(cur_term->Filedes, TCIFLUSH);
|
||||
#else
|
||||
ioctl(cur_term->Filedes, TIOCFLUSH, 0);
|
||||
#endif
|
||||
if (SP) {
|
||||
SP->_fifohead = -1;
|
||||
SP->_fifotail = 0;
|
||||
SP->_fifopeek = 0;
|
||||
}
|
||||
return OK;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* int
|
||||
* baudrate()
|
||||
*
|
||||
* Returns the current terminal's baud rate.
|
||||
*
|
||||
*/
|
||||
|
||||
struct speed {
|
||||
speed_t s;
|
||||
int sp;
|
||||
};
|
||||
|
||||
static struct speed speeds[] = {
|
||||
{B0, 0,},
|
||||
{B50, 50,},
|
||||
{B75, 75,},
|
||||
{B110, 110,},
|
||||
{B134, 134,},
|
||||
{B150, 150,},
|
||||
{B200, 200,},
|
||||
{B300, 300,},
|
||||
{B600, 600,},
|
||||
{B1200, 1200,},
|
||||
{B1800, 1800,},
|
||||
{B2400, 2400,},
|
||||
{B4800, 4800,},
|
||||
{B9600, 9600,},
|
||||
#define MAX_BAUD B9600
|
||||
#ifdef B19200
|
||||
#undef MAX_BAUD
|
||||
#define MAX_BAUD B19200
|
||||
{B19200, 19200,},
|
||||
#endif
|
||||
#ifdef B38400
|
||||
#undef MAX_BAUD
|
||||
#define MAX_BAUD B38400
|
||||
{B38400, 38000,}
|
||||
#endif
|
||||
};
|
||||
|
||||
int
|
||||
baudrate()
|
||||
{
|
||||
int i, ret;
|
||||
#ifdef UNTRACE
|
||||
if (_tracing)
|
||||
_tracef("baudrate() called");
|
||||
#endif
|
||||
#ifdef TERMIOS
|
||||
ret = cfgetospeed(&cur_term->Nttyb);
|
||||
#else
|
||||
ret = cur_term->Nttyb.sg_ospeed;
|
||||
#endif
|
||||
if(ret < 0 || ret > MAX_BAUD)
|
||||
return ERR;
|
||||
for (i = 0; i < (sizeof(speeds) / sizeof(struct speed)); i++)
|
||||
if (speeds[i].s == ret)
|
||||
return speeds[i].sp;
|
||||
return ERR;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** savetty() and resetty()
|
||||
**
|
||||
*/
|
||||
|
||||
static TTY buf;
|
||||
|
||||
int savetty()
|
||||
{
|
||||
T(("savetty() called"));
|
||||
|
||||
#ifdef TERMIOS
|
||||
tcgetattr(cur_term->Filedes, &buf);
|
||||
#else
|
||||
gtty(cur_term->Filedes, &buf);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
int resetty()
|
||||
{
|
||||
T(("resetty() called"));
|
||||
|
||||
#ifdef TERMIOS
|
||||
tcsetattr(cur_term->Filedes, TCSANOW, &buf);
|
||||
#else
|
||||
stty(cur_term->Filedes, &buf);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
35
lib/libncurses/lib_longname.c
Normal file
35
lib/libncurses/lib_longname.c
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_longname.c
|
||||
**
|
||||
** The routine longname().
|
||||
**
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "curses.priv.h"
|
||||
#include <nterm.h>
|
||||
|
||||
char *
|
||||
longname()
|
||||
{
|
||||
#ifndef MYTINFO
|
||||
char *ptr;
|
||||
#endif
|
||||
|
||||
T(("longname() called"));
|
||||
|
||||
#ifdef MYTINFO
|
||||
return cur_term->name_long;
|
||||
#else
|
||||
for (ptr = ttytype + strlen(ttytype); ptr > ttytype; ptr--)
|
||||
if (*ptr == '|')
|
||||
return(ptr + 1);
|
||||
|
||||
return(ttytype);
|
||||
#endif
|
||||
}
|
33
lib/libncurses/lib_move.c
Normal file
33
lib/libncurses/lib_move.c
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_move.c
|
||||
**
|
||||
** The routine wmove().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int
|
||||
wmove(WINDOW *win, int y, int x)
|
||||
{
|
||||
#ifdef TRACE
|
||||
if (_tracing)
|
||||
_tracef("wmove(%x,%d,%d) called", win, y, x);
|
||||
#endif
|
||||
|
||||
if (x >= 0 && x <= win->_maxx &&
|
||||
y >= 0 && y <= win->_maxy)
|
||||
{
|
||||
win->_curx = x;
|
||||
win->_cury = y;
|
||||
|
||||
win->_flags |= _HASMOVED;
|
||||
return(OK);
|
||||
} else
|
||||
return(ERR);
|
||||
}
|
719
lib/libncurses/lib_mvcur.c
Normal file
719
lib/libncurses/lib_mvcur.c
Normal file
@ -0,0 +1,719 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
*
|
||||
* lib_mvcur.c
|
||||
*
|
||||
* The routine mvcur() etc.
|
||||
*
|
||||
* last edit-date: [Wed Jun 16 14:13:22 1993]
|
||||
*
|
||||
* -hm conversion from termcap -> terminfo
|
||||
* -hm optimization debugging
|
||||
* -hm zeyd's ncurses 0.7 update
|
||||
* -hm eat_newline_glitch bugfix
|
||||
* -hm hpux lint'ing ..
|
||||
*
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <nterm.h>
|
||||
#include "curses.priv.h"
|
||||
|
||||
#ifndef OPT_MVCUR
|
||||
/*
|
||||
**
|
||||
** mvcur(oldrow, oldcol, newrow, newcol)
|
||||
** A hack for terminals that are smart enough
|
||||
** to know how to move cursor.
|
||||
** There is still a bug in the alternative long-
|
||||
** winded code.
|
||||
**
|
||||
*/
|
||||
|
||||
int mvcur(int oldrow, int oldcol, int newrow, int newcol)
|
||||
{
|
||||
T(("mvcur(%d,%d,%d,%d) called", oldrow, oldcol, newrow, newcol));
|
||||
|
||||
if(!cursor_address)
|
||||
return ERR;
|
||||
|
||||
newrow %= lines;
|
||||
newcol %= columns;
|
||||
|
||||
if (cursor_address)
|
||||
putp(tparm(cursor_address, newrow, newcol));
|
||||
return OK;
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define BUFSIZE 128 /* size of strategy buffer */
|
||||
|
||||
struct Sequence
|
||||
{
|
||||
int vec[BUFSIZE]; /* vector of operations */
|
||||
int *end; /* end of vector */
|
||||
int cost; /* cost of vector */
|
||||
};
|
||||
|
||||
static void row(struct Sequence *outseq, int orow, int nrow);
|
||||
static void column(struct Sequence *outseq, int ocol, int ncol);
|
||||
static void simp_col(struct Sequence *outseq, int oc, int nc);
|
||||
static void zero_seq(struct Sequence *seq);
|
||||
static void add_seq(struct Sequence *seq1, struct Sequence *seq2);
|
||||
static void out_seq(struct Sequence *seq);
|
||||
static void update_ops(void);
|
||||
static void init_costs(int costs[]);
|
||||
static int countc(char ch);
|
||||
static void add_op(struct Sequence *seq, int op, ...);
|
||||
static char *sequence(int op);
|
||||
|
||||
static int c_count; /* used for counting tputs output */
|
||||
|
||||
#define INFINITY 1000 /* biggest, impossible sequence cost */
|
||||
#define NUM_OPS 16 /* num. term. control sequences */
|
||||
#define NUM_NPARM 9 /* num. ops wo/ parameters */
|
||||
|
||||
/* operator indexes into op_info */
|
||||
|
||||
#define CARRIAGE_RETURN 0 /* watch out for nl mapping */
|
||||
#define CURS_DOWN 1
|
||||
#define CURS_HOME 2
|
||||
#define CURS_LEFT 3
|
||||
#define CURS_RIGHT 4
|
||||
#define CURS_TO_LL 5
|
||||
#define CURS_UP 6
|
||||
#define TAB 7
|
||||
#define BACK_TAB 8
|
||||
#define ROW_ADDR 9
|
||||
#define COL_ADDR 10
|
||||
#define P_DOWN_CURS 11
|
||||
#define P_LEFT_CURS 12
|
||||
#define P_RIGHT_CURS 13
|
||||
#define P_UP_CURS 14
|
||||
#define CURS_ADDR 15
|
||||
|
||||
static bool loc_init = FALSE; /* set if op_info is init'ed */
|
||||
|
||||
static bool rel_ok; /* set if we really know where we are */
|
||||
|
||||
/*
|
||||
* op_info[NUM_OPS]
|
||||
*
|
||||
* op_info[] contains for operations with no parameters
|
||||
* the cost of the operation. These ops should be first in the array.
|
||||
* For operations with parameters, op_info[] contains
|
||||
* the negative of the number of parameters.
|
||||
*/
|
||||
|
||||
static int op_info[NUM_OPS] = {
|
||||
0, /* carriage_return */
|
||||
0, /* cursor_down */
|
||||
0, /* cursor_home */
|
||||
0, /* cursor_left */
|
||||
0, /* cursor_right */
|
||||
0, /* cursor_to_ll */
|
||||
0, /* cursor_up */
|
||||
0, /* tab */
|
||||
0, /* back_tab */
|
||||
-1, /* row_address */
|
||||
-1, /* column_address */
|
||||
-1, /* parm_down_cursor */
|
||||
-1, /* parm_left_cursor */
|
||||
-1, /* parm_right_cursor */
|
||||
-1, /* parm_up_cursor */
|
||||
-2 /* cursor_address */
|
||||
};
|
||||
|
||||
/*
|
||||
** Make_seq_best(best, try)
|
||||
**
|
||||
** Make_seq_best() copies try to best if try->cost < best->cost
|
||||
**
|
||||
** fixed the old version, now it really runs .. (-hm/08.04.93)
|
||||
**
|
||||
*/
|
||||
|
||||
inline void Make_seq_best(struct Sequence *best, struct Sequence *try)
|
||||
{
|
||||
if (best->cost > try->cost) {
|
||||
register int *sptr;
|
||||
|
||||
sptr = try->vec; /* src ptr */
|
||||
best->end = best->vec; /* dst ptr */
|
||||
while(sptr != try->end) /* copy src -> dst */
|
||||
*(best->end++) = *(sptr++);
|
||||
best->cost = try->cost; /* copy cost */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
**
|
||||
** mvcur(oldrow, oldcol, newrow, newcol)
|
||||
**
|
||||
** mvcur() optimally moves the cursor from the position
|
||||
** specified by (oldrow, oldcol) to (newrow, newcol). If
|
||||
** (oldrow, oldcol) == (-1, -1), mvcur() does not use relative
|
||||
** cursor motions. If the coordinates are otherwise
|
||||
** out of bounds, it mods them into range.
|
||||
**
|
||||
** Revisions needed:
|
||||
** eat_newline_glitch, auto_right_margin
|
||||
*/
|
||||
|
||||
int mvcur(int oldrow, int oldcol, int newrow, int newcol)
|
||||
{
|
||||
struct Sequence seqA, seqB, /* allocate work structures */
|
||||
col0seq, /* sequence to get from col0 to nc */
|
||||
*best, /* best sequence so far */
|
||||
*try; /* next try */
|
||||
bool nlstat = SP->_nl; /* nl-output-mapping in effect ?*/
|
||||
|
||||
#ifdef TRACE
|
||||
if (_tracing)
|
||||
_tracef("=============================\nmvcur(%d,%d,%d,%d) called",
|
||||
oldrow, oldcol, newrow, newcol);
|
||||
#endif
|
||||
|
||||
if ((oldrow == newrow) && (oldcol == newcol))
|
||||
return OK;
|
||||
|
||||
if (oldcol == columns-1 && eat_newline_glitch && auto_right_margin) {
|
||||
tputs(tparm(cursor_address, newrow, newcol), 1, _outc);
|
||||
return OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (nlstat)
|
||||
nonl();
|
||||
#endif
|
||||
update_ops(); /* make sure op_info[] is current */
|
||||
|
||||
if (oldrow < 0 || oldcol < 0 || (eat_newline_glitch && oldcol == 0 )) {
|
||||
rel_ok = FALSE; /* relative ops ok? */
|
||||
} else {
|
||||
rel_ok = TRUE;
|
||||
oldrow %= lines; /* mod values into range */
|
||||
oldcol %= columns;
|
||||
}
|
||||
|
||||
newrow %= lines;
|
||||
newcol %= columns;
|
||||
|
||||
best = &seqA;
|
||||
try = &seqB;
|
||||
|
||||
/* try out direct cursor addressing */
|
||||
|
||||
zero_seq(best);
|
||||
add_op(best, CURS_ADDR, newrow, newcol);
|
||||
|
||||
/* try out independent row/column addressing */
|
||||
|
||||
if(rel_ok) {
|
||||
zero_seq(try);
|
||||
row(try, oldrow, newrow);
|
||||
column(try, oldcol, newcol);
|
||||
Make_seq_best(best, try);
|
||||
}
|
||||
|
||||
zero_seq(&col0seq); /* store seq. to get from c0 to nc */
|
||||
column(&col0seq, 0, newcol);
|
||||
|
||||
if(col0seq.cost < INFINITY) { /* can get from col0 to newcol */
|
||||
|
||||
/* try out homing and then row/column */
|
||||
|
||||
if (! rel_ok || newcol < oldcol || newrow < oldrow) {
|
||||
zero_seq(try);
|
||||
add_op(try, CURS_HOME, 1);
|
||||
row(try, 0, newrow);
|
||||
add_seq(try, &col0seq);
|
||||
Make_seq_best(best, try);
|
||||
}
|
||||
|
||||
/* try out homing to last line and then row/column */
|
||||
|
||||
if (! rel_ok || newcol < oldcol || newrow > oldrow) {
|
||||
zero_seq(try);
|
||||
add_op(try, CURS_TO_LL, 1);
|
||||
row(try, lines - 1, newrow);
|
||||
add_seq(try, &col0seq);
|
||||
Make_seq_best(best, try);
|
||||
}
|
||||
}
|
||||
|
||||
out_seq(best);
|
||||
#if 0
|
||||
if(nlstat)
|
||||
nl();
|
||||
#endif
|
||||
|
||||
#ifdef TRACE
|
||||
if (_tracing)
|
||||
_tracef("===================================");
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** row(outseq, oldrow, newrow)
|
||||
**
|
||||
** row() adds the best sequence for moving
|
||||
** the cursor from oldrow to newrow to seq.
|
||||
** row() considers row_address, parm_up/down_cursor
|
||||
** and cursor_up/down.
|
||||
*/
|
||||
|
||||
static void
|
||||
row(struct Sequence *outseq, /* where to put the output */
|
||||
int orow, int nrow) /* old, new cursor locations */
|
||||
{
|
||||
struct Sequence seqA, seqB,
|
||||
*best, /* best sequence so far */
|
||||
*try; /* next try */
|
||||
|
||||
int parm_cursor, one_step;
|
||||
|
||||
best = &seqA;
|
||||
try = &seqB;
|
||||
|
||||
if (nrow == orow)
|
||||
return;
|
||||
|
||||
if (nrow < orow) {
|
||||
parm_cursor = P_UP_CURS;
|
||||
one_step = CURS_UP;
|
||||
} else {
|
||||
parm_cursor = P_DOWN_CURS;
|
||||
one_step = CURS_DOWN;
|
||||
}
|
||||
|
||||
/* try out direct row addressing */
|
||||
|
||||
zero_seq(best);
|
||||
add_op(best, ROW_ADDR, nrow);
|
||||
|
||||
/* try out paramaterized up or down motion */
|
||||
|
||||
if (rel_ok) {
|
||||
zero_seq(try);
|
||||
add_op(try, parm_cursor, abs(orow - nrow));
|
||||
Make_seq_best(best, try);
|
||||
}
|
||||
|
||||
/* try getting there one step at a time... */
|
||||
|
||||
if (rel_ok) {
|
||||
zero_seq(try);
|
||||
add_op(try, one_step, abs(orow-nrow));
|
||||
Make_seq_best(best, try);
|
||||
}
|
||||
|
||||
add_seq(outseq, best);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** column(outseq, oldcol, newcol)
|
||||
**
|
||||
** column() adds the best sequence for moving
|
||||
** the cursor from oldcol to newcol to outseq.
|
||||
** column() considers column_address, parm_left/right_cursor,
|
||||
** simp_col(), and carriage_return followed by simp_col().
|
||||
*/
|
||||
|
||||
static void column(struct Sequence *outseq, /* where to put the output */
|
||||
int ocol, int ncol) /* old, new cursor column */
|
||||
{
|
||||
struct Sequence seqA, seqB,
|
||||
*best, *try;
|
||||
int parm_cursor; /* set to either parm_up/down_cursor */
|
||||
|
||||
best = &seqA;
|
||||
try = &seqB;
|
||||
|
||||
if (ncol == ocol)
|
||||
return;
|
||||
|
||||
if (ncol < ocol)
|
||||
parm_cursor = P_LEFT_CURS;
|
||||
else
|
||||
parm_cursor = P_RIGHT_CURS;
|
||||
|
||||
/* try out direct column addressing */
|
||||
|
||||
zero_seq(best);
|
||||
add_op(best, COL_ADDR, ncol);
|
||||
|
||||
/* try carriage_return then simp_col() */
|
||||
|
||||
if(! rel_ok || (ncol < ocol)) {
|
||||
zero_seq(try);
|
||||
add_op(try, CARRIAGE_RETURN, 1);
|
||||
simp_col(try, 0, ncol);
|
||||
Make_seq_best(best, try);
|
||||
}
|
||||
if(rel_ok) {
|
||||
/* try out paramaterized left or right motion */
|
||||
|
||||
zero_seq(try);
|
||||
add_op(try, parm_cursor, abs(ocol - ncol));
|
||||
Make_seq_best(best, try);
|
||||
|
||||
/* try getting there with simp_col() */
|
||||
|
||||
zero_seq(try);
|
||||
simp_col(try, ocol, ncol);
|
||||
Make_seq_best(best, try);
|
||||
}
|
||||
|
||||
add_seq(outseq, best);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** simp_col(outseq, oldcol, newcol)
|
||||
**
|
||||
** simp_col() adds the best simple sequence for getting
|
||||
** from oldcol to newcol to outseq.
|
||||
** simp_col() considers (back_)tab and cursor_left/right.
|
||||
**
|
||||
** Revisions needed:
|
||||
** Simp_col asssumes that the cost of a (back_)tab
|
||||
** is less then the cost of one-stepping to get to the same column.
|
||||
** Should sometimes use overprinting instead of cursor_right.
|
||||
*/
|
||||
|
||||
static void
|
||||
simp_col( struct Sequence *outseq, /* place to put sequence */
|
||||
int oc, int nc) /* old column, new column */
|
||||
{
|
||||
struct Sequence seqA, seqB, tabseq,
|
||||
*best, *try;
|
||||
int mytab, tabs, onepast,
|
||||
one_step, opp_step;
|
||||
|
||||
onepast = -1;
|
||||
|
||||
if (oc == nc)
|
||||
return;
|
||||
|
||||
if(! rel_ok) {
|
||||
outseq->cost = INFINITY;
|
||||
return;
|
||||
}
|
||||
|
||||
best = &seqA;
|
||||
try = &seqB;
|
||||
|
||||
if(oc < nc) {
|
||||
mytab = TAB;
|
||||
|
||||
if (init_tabs > 0 && op_info[TAB] < INFINITY) {
|
||||
tabs = (nc / init_tabs) - (oc / init_tabs);
|
||||
onepast = ((nc / init_tabs) + 1) * init_tabs;
|
||||
if (tabs)
|
||||
oc = onepast - init_tabs; /* consider it done */
|
||||
} else {
|
||||
tabs = 0;
|
||||
}
|
||||
one_step = CURS_RIGHT;
|
||||
opp_step = CURS_LEFT;
|
||||
} else {
|
||||
mytab = BACK_TAB;
|
||||
if (init_tabs > 0 && op_info[BACK_TAB] < INFINITY) {
|
||||
tabs = (oc / init_tabs) - (nc / init_tabs);
|
||||
onepast = ((nc - 1) / init_tabs) * init_tabs;
|
||||
if (tabs)
|
||||
oc = onepast + init_tabs; /* consider it done */
|
||||
} else {
|
||||
tabs = 0;
|
||||
}
|
||||
one_step = CURS_LEFT;
|
||||
opp_step = CURS_RIGHT;
|
||||
}
|
||||
|
||||
/* tab as close as possible to nc */
|
||||
|
||||
zero_seq(&tabseq);
|
||||
add_op(&tabseq, mytab, tabs);
|
||||
|
||||
/* try extra tab and backing up */
|
||||
|
||||
zero_seq(best);
|
||||
|
||||
if (onepast >= 0 && onepast < columns) {
|
||||
add_op(best, mytab, 1);
|
||||
add_op(best, opp_step, abs(onepast - nc));
|
||||
} else {
|
||||
best->cost = INFINITY; /* make sure of next swap */
|
||||
}
|
||||
|
||||
/* try stepping to nc */
|
||||
|
||||
zero_seq(try);
|
||||
add_op(try, one_step, abs(nc - oc));
|
||||
Make_seq_best(best, try);
|
||||
|
||||
if (tabseq.cost < INFINITY)
|
||||
add_seq(outseq, &tabseq);
|
||||
add_seq(outseq, best);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** zero_seq(seq) empties seq.
|
||||
** add_seq(seq1, seq2) adds seq1 to seq2.
|
||||
** out_seq(seq) outputs a sequence.
|
||||
*/
|
||||
|
||||
static void
|
||||
zero_seq(seq)
|
||||
struct Sequence *seq;
|
||||
{
|
||||
seq->end = seq->vec;
|
||||
seq->cost = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
add_seq(struct Sequence *seq1, struct Sequence *seq2)
|
||||
{
|
||||
int *vptr;
|
||||
|
||||
#ifdef TRACE
|
||||
if (_tracing)
|
||||
_tracef("add_seq(%x, %x)", seq1, seq2);
|
||||
#endif
|
||||
|
||||
if(seq1->cost >= INFINITY || seq2->cost >= INFINITY)
|
||||
seq1->cost = INFINITY;
|
||||
else {
|
||||
vptr = seq2->vec;
|
||||
while (vptr != seq2->end)
|
||||
*(seq1->end++) = *(vptr++);
|
||||
seq1->cost += seq2->cost;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
out_seq(struct Sequence *seq)
|
||||
{
|
||||
int *opptr, prm[9], ps, p, op;
|
||||
int count;
|
||||
char *sequence();
|
||||
|
||||
#ifdef TRACE
|
||||
if (_tracing)
|
||||
_tracef("out_seq(%x)", seq);
|
||||
#endif
|
||||
|
||||
if (seq->cost >= INFINITY)
|
||||
return;
|
||||
|
||||
for (opptr = seq->vec; opptr < seq->end; opptr++) {
|
||||
op = *opptr; /* grab operator */
|
||||
ps = -op_info[op];
|
||||
if(ps > 0) { /* parameterized */
|
||||
for (p = 0; p < ps; p++) /* fill in needed parms */
|
||||
prm[p] = *(++opptr);
|
||||
|
||||
tputs(tparm(sequence(op),
|
||||
prm[0], prm[1], prm[2], prm[3], prm[4],
|
||||
prm[5], prm[6], prm[7], prm[8]), 1, _outc);
|
||||
} else {
|
||||
count = *(++opptr);
|
||||
/*rev should save tputs output instead of mult calls */
|
||||
while (count--) /* do count times */
|
||||
tputs(sequence(op), 1, _outc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** update_ops()
|
||||
**
|
||||
** update_ops() makes sure that
|
||||
** the op_info[] array is updated and initializes
|
||||
** the cost array for SP if needed.
|
||||
*/
|
||||
|
||||
static void
|
||||
update_ops()
|
||||
{
|
||||
#ifdef TRACE
|
||||
if (_tracing)
|
||||
_tracef("update_ops()");
|
||||
#endif
|
||||
|
||||
if (SP) { /* SP structure exists */
|
||||
int op;
|
||||
|
||||
if (! SP->_costinit) { /* this term not yet assigned costs */
|
||||
loc_init = FALSE; /* if !SP in the future, new term */
|
||||
init_costs(SP->_costs); /* fill term costs */
|
||||
SP->_costinit = TRUE;
|
||||
}
|
||||
|
||||
for (op = 0; op < NUM_NPARM; op++)
|
||||
op_info[op] = SP->_costs[op]; /* set up op_info */
|
||||
|
||||
/* check for newline that might be mapped... */
|
||||
|
||||
if (SP->_nlmapping && index(sequence(CURS_DOWN), '\n'))
|
||||
op_info[CURS_DOWN] = INFINITY;
|
||||
} else {
|
||||
if (! loc_init) { /* using local costs */
|
||||
loc_init = TRUE;
|
||||
init_costs(op_info); /* set up op_info */
|
||||
}
|
||||
|
||||
/* check for newline that might be mapped... */
|
||||
|
||||
if (index(sequence(CURS_DOWN), '\n'))
|
||||
op_info[CURS_DOWN] = INFINITY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** init_costs(costs)
|
||||
**
|
||||
** init_costs() fills the array costs[NUM_NPARM]
|
||||
** with costs calculated by doing tputs() calls.
|
||||
*/
|
||||
|
||||
static void
|
||||
init_costs(int costs[])
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_NPARM; i++) {
|
||||
if (sequence(i) != (char *) 0) {
|
||||
c_count = 0;
|
||||
tputs(sequence(i), 1, countc);
|
||||
costs[i] = c_count;
|
||||
} else
|
||||
costs[i] = INFINITY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** countc() increments global var c_count.
|
||||
*/
|
||||
|
||||
static int countc(char ch)
|
||||
{
|
||||
return(c_count++);
|
||||
}
|
||||
|
||||
/*
|
||||
** add_op(seq, op, p0, p1, ... , p8)
|
||||
**
|
||||
** add_op() adds the operator op and the appropriate
|
||||
** number of paramaters to seq. It also increases the
|
||||
** cost appropriately.
|
||||
** if op has no parameters, p0 is taken to be a count.
|
||||
*/
|
||||
|
||||
static void add_op(struct Sequence *seq, int op, ...)
|
||||
{
|
||||
va_list argp;
|
||||
int num_ps, p;
|
||||
|
||||
#ifdef TRACE
|
||||
if (_tracing)
|
||||
_tracef("adding op %d to sequence", op);
|
||||
#endif
|
||||
va_start(argp, op);
|
||||
|
||||
num_ps = - op_info[op]; /* get parms or -cost */
|
||||
|
||||
*(seq->end++) = op;
|
||||
|
||||
if (num_ps == (- INFINITY) || sequence(op) == (char *) 0) {
|
||||
seq->cost = INFINITY;
|
||||
} else if (num_ps <= 0) { /* no parms, -cost */
|
||||
int i = va_arg(argp, int);
|
||||
seq->cost -= i * num_ps; /* ADD count * cost */
|
||||
*(seq->end++) = i;
|
||||
} else {
|
||||
int prm[9];
|
||||
|
||||
for (p = 0; p < num_ps; p++)
|
||||
*(seq->end++) = prm[p] = va_arg(argp, int);
|
||||
|
||||
c_count = 0;
|
||||
|
||||
tputs(tparm(sequence(op), prm[0], prm[1], prm[2], prm[3], prm[4],
|
||||
prm[5], prm[6], prm[7], prm[8]), 1, countc);
|
||||
|
||||
seq->cost += c_count;
|
||||
}
|
||||
va_end(argp);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** char *sequence(op)
|
||||
**
|
||||
** sequence() returns a pointer to the op's
|
||||
** terminal control sequence.
|
||||
*/
|
||||
|
||||
static char *sequence(int op)
|
||||
{
|
||||
#ifdef TRACE
|
||||
if (_tracing)
|
||||
_tracef("sequence(%d)", op);
|
||||
#endif
|
||||
switch(op) {
|
||||
case CARRIAGE_RETURN:
|
||||
return (carriage_return);
|
||||
case CURS_DOWN:
|
||||
return (cursor_down);
|
||||
case CURS_HOME:
|
||||
return (cursor_home);
|
||||
case CURS_LEFT:
|
||||
return (cursor_left);
|
||||
case CURS_RIGHT:
|
||||
return (cursor_right);
|
||||
case CURS_TO_LL:
|
||||
return (cursor_to_ll);
|
||||
case CURS_UP:
|
||||
return (cursor_up);
|
||||
case TAB:
|
||||
return (tab);
|
||||
case BACK_TAB:
|
||||
return (back_tab);
|
||||
case ROW_ADDR:
|
||||
return (row_address);
|
||||
case COL_ADDR:
|
||||
return (column_address);
|
||||
case P_DOWN_CURS:
|
||||
return (parm_down_cursor);
|
||||
case P_LEFT_CURS:
|
||||
return (parm_left_cursor);
|
||||
case P_RIGHT_CURS:
|
||||
return (parm_right_cursor);
|
||||
case P_UP_CURS:
|
||||
return (parm_up_cursor);
|
||||
case CURS_ADDR:
|
||||
return (cursor_address);
|
||||
default:
|
||||
return ((char *) 0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
29
lib/libncurses/lib_mvwin.c
Normal file
29
lib/libncurses/lib_mvwin.c
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_mvwin.c
|
||||
**
|
||||
** The routine mvwin().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include <nterm.h>
|
||||
|
||||
int mvwin(WINDOW *win, int by, int bx)
|
||||
{
|
||||
T(("mvwin(%x,%d,%d) called", win, by, bx));
|
||||
|
||||
if (by + win->_maxy > lines - 1 || bx + win->_maxx > columns - 1)
|
||||
return(ERR);
|
||||
|
||||
win->_begy = by;
|
||||
win->_begx = bx;
|
||||
|
||||
touchwin(win);
|
||||
|
||||
return(OK);
|
||||
}
|
154
lib/libncurses/lib_newterm.c
Normal file
154
lib/libncurses/lib_newterm.c
Normal file
@ -0,0 +1,154 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_newterm.c
|
||||
**
|
||||
** The newterm() function.
|
||||
**
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "curses.priv.h"
|
||||
#include <nterm.h>
|
||||
#ifdef SVR4_ACTION
|
||||
#define _POSIX_SOURCE
|
||||
#endif
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef MYTINFO
|
||||
int LINES, COLS;
|
||||
#endif
|
||||
|
||||
static void cleanup(int sig)
|
||||
{
|
||||
|
||||
if (sig == SIGSEGV)
|
||||
fprintf(stderr, "Got a segmentation violation signal, cleaning up and exiting\n");
|
||||
endwin();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
WINDOW *stdscr, *curscr, *newscr;
|
||||
SCREEN *SP;
|
||||
|
||||
struct ripoff_t
|
||||
{
|
||||
int line;
|
||||
int (*hook)();
|
||||
}
|
||||
rippedoff[5], *rsp = rippedoff;
|
||||
|
||||
SCREEN * newterm(char *term, FILE *ofp, FILE *ifp)
|
||||
{
|
||||
sigaction_t act;
|
||||
int errret;
|
||||
int stolen, topstolen;
|
||||
|
||||
#ifdef TRACE
|
||||
_init_trace();
|
||||
T(("newterm(%s,%x,%x) called", term, ofp, ifp));
|
||||
#endif
|
||||
|
||||
#ifdef MYTINFO
|
||||
if (setupterm(term, fileno(ofp), &errret) != OK)
|
||||
return NULL;
|
||||
COLS = cur_term->true_columns;
|
||||
LINES = cur_term->true_lines;
|
||||
#else
|
||||
if (setupterm(term, fileno(ofp), &errret) != 1)
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
if ((SP = (SCREEN *) malloc(sizeof *SP)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (ofp == stdout && ifp == stdin) {
|
||||
SP->_ofp = stdout;
|
||||
SP->_ifp = stdin;
|
||||
} else {
|
||||
SP->_ofp = ofp;
|
||||
SP->_ifp = ofp;
|
||||
}
|
||||
SP->_term = cur_term;
|
||||
SP->_cursrow = -1;
|
||||
SP->_curscol = -1;
|
||||
SP->_keytry = UNINITIALISED;
|
||||
SP->_nl = TRUE;
|
||||
SP->_raw = FALSE;
|
||||
SP->_cbreak = FALSE;
|
||||
SP->_echo = TRUE;
|
||||
SP->_nlmapping = TRUE;
|
||||
SP->_fifohead = -1;
|
||||
SP->_fifotail = 0;
|
||||
SP->_fifopeek = 0;
|
||||
|
||||
if (enter_ca_mode)
|
||||
putp(enter_ca_mode);
|
||||
|
||||
init_acs();
|
||||
|
||||
T(("creating newscr"));
|
||||
if ((newscr = newwin(lines, columns, 0, 0)) == (WINDOW *)NULL)
|
||||
return(NULL);
|
||||
|
||||
T(("creating curscr"));
|
||||
if ((curscr = newwin(lines, columns, 0, 0)) == (WINDOW *)NULL)
|
||||
return(NULL);
|
||||
|
||||
SP->_newscr = newscr;
|
||||
SP->_curscr = curscr;
|
||||
|
||||
newscr->_clear = TRUE;
|
||||
curscr->_clear = FALSE;
|
||||
|
||||
stolen = topstolen = 0;
|
||||
for (rsp = rippedoff; rsp->line; rsp++)
|
||||
{
|
||||
if (rsp->hook)
|
||||
if (rsp->line < 0)
|
||||
rsp->hook(newwin(1,COLS, LINES-1,0), COLS);
|
||||
else
|
||||
rsp->hook(newwin(1,COLS, topstolen++,0), COLS);
|
||||
--LINES;
|
||||
stolen++;
|
||||
}
|
||||
|
||||
act.sa_handler = tstp;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
sigaction(SIGTSTP, &act, NULL);
|
||||
act.sa_handler = cleanup;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
sigaction(SIGINT, &act, NULL);
|
||||
#if 0
|
||||
sigaction(SIGSEGV, &act, NULL);
|
||||
#endif
|
||||
if (stdscr == NULL)
|
||||
if ((stdscr = newwin(lines - stolen, columns, topstolen, 0)) == NULL)
|
||||
return(NULL);
|
||||
|
||||
T(("newterm returns %x", SP));
|
||||
|
||||
return(SP);
|
||||
}
|
||||
|
||||
int
|
||||
ripoffline(int line, int (*init)(WINDOW *, int))
|
||||
{
|
||||
if (line == 0)
|
||||
return(OK);
|
||||
|
||||
if (rsp >= rippedoff + sizeof(rippedoff)/sizeof(rippedoff[0]))
|
||||
return(ERR);
|
||||
|
||||
rsp->line = line;
|
||||
rsp->hook = init;
|
||||
rsp++;
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
177
lib/libncurses/lib_newwin.c
Normal file
177
lib/libncurses/lib_newwin.c
Normal file
@ -0,0 +1,177 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_newwin.c
|
||||
**
|
||||
** The routines newwin(), subwin() and their dependent
|
||||
**
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <nterm.h>
|
||||
#include "curses.priv.h"
|
||||
|
||||
WINDOW * newwin(int num_lines, int num_columns, int begy, int begx)
|
||||
{
|
||||
WINDOW *win;
|
||||
chtype *ptr;
|
||||
int i, j;
|
||||
|
||||
T(("newwin(%d,%d,%d,%d) called", num_lines, num_columns, begy, begx));
|
||||
|
||||
if (num_lines == 0)
|
||||
num_lines = lines - begy;
|
||||
|
||||
if (num_columns == 0)
|
||||
num_columns = columns - begx;
|
||||
|
||||
if (num_columns + begx > columns || num_lines + begy > lines)
|
||||
return NULL;
|
||||
|
||||
if ((win = makenew(num_lines, num_columns, begy, begx)) == NULL)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < num_lines; i++) {
|
||||
if ((win->_line[i] = (chtype *) calloc(num_columns, sizeof(chtype))) == NULL) {
|
||||
for (j = 0; j < i; j++)
|
||||
free(win->_line[j]);
|
||||
|
||||
free(win->_firstchar);
|
||||
free(win->_lastchar);
|
||||
free(win->_line);
|
||||
free(win);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
for (ptr = win->_line[i]; ptr < win->_line[i] + num_columns; )
|
||||
*ptr++ = ' ';
|
||||
}
|
||||
|
||||
T(("newwin: returned window is %x", win));
|
||||
|
||||
return(win);
|
||||
}
|
||||
|
||||
WINDOW * derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
|
||||
{
|
||||
WINDOW *win;
|
||||
int i;
|
||||
|
||||
T(("derwin(%x, %d,%d,%d,%d) called", orig, num_lines, num_columns, begy, begx));
|
||||
|
||||
/*
|
||||
** make sure window fits inside the original one
|
||||
*/
|
||||
if ( begy < 0 || begx < 0)
|
||||
return NULL;
|
||||
if ( begy + num_lines > orig->_maxy + 1
|
||||
|| begx + num_columns > orig->_maxx + 1)
|
||||
return NULL;
|
||||
|
||||
if (num_lines == 0)
|
||||
num_lines = orig->_maxy - orig->_begy - begy;
|
||||
|
||||
if (num_columns == 0)
|
||||
num_columns = orig->_maxx - orig->_begx - begx;
|
||||
|
||||
if ((win = makenew(num_lines, num_columns, orig->_begy + begy, orig->_begx + begx)) == NULL)
|
||||
return NULL;
|
||||
|
||||
win->_pary = begy;
|
||||
win->_parx = begx;
|
||||
|
||||
for (i = 0; i < num_lines; i++)
|
||||
win->_line[i] = &orig->_line[begy++][begx];
|
||||
|
||||
win->_flags = _SUBWIN;
|
||||
win->_parent = orig;
|
||||
|
||||
T(("derwin: returned window is %x", win));
|
||||
|
||||
return(win);
|
||||
}
|
||||
|
||||
|
||||
WINDOW *subwin(WINDOW *w, int l, int c, int y, int x)
|
||||
{
|
||||
T(("subwin(%x, %d, %d, %d, %d) called", w, l, c, y, x));
|
||||
T(("parent has begy = %d, begx = %d", w->_begy, w->_begx));
|
||||
|
||||
return derwin(w, l, c, y - w->_begy, x - w->_begx);
|
||||
}
|
||||
|
||||
WINDOW *
|
||||
makenew(int num_lines, int num_columns, int begy, int begx)
|
||||
{
|
||||
int i;
|
||||
WINDOW *win;
|
||||
|
||||
T(("makenew(%d,%d,%d,%d)", num_lines, num_columns, begy, begx));
|
||||
|
||||
if ((win = (WINDOW *) malloc(sizeof(WINDOW))) == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((win->_line = (chtype **) calloc(num_lines, sizeof (chtype *))) == NULL) {
|
||||
free(win);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((win->_firstchar = calloc(num_lines, sizeof(short))) == NULL) {
|
||||
free(win);
|
||||
free(win->_line);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((win->_lastchar = calloc(num_lines, sizeof(short))) == NULL) {
|
||||
free(win);
|
||||
free(win->_line);
|
||||
free(win->_firstchar);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
win->_curx = 0;
|
||||
win->_cury = 0;
|
||||
win->_maxy = num_lines - 1;
|
||||
win->_maxx = num_columns - 1;
|
||||
win->_begy = begy;
|
||||
win->_begx = begx;
|
||||
|
||||
win->_flags = 0;
|
||||
win->_attrs = A_NORMAL;
|
||||
|
||||
win->_clear = (num_lines == lines && num_columns == columns);
|
||||
win->_idlok = FALSE;
|
||||
win->_use_idc = TRUE;
|
||||
win->_scroll = FALSE;
|
||||
win->_leave = FALSE;
|
||||
win->_use_keypad = FALSE;
|
||||
win->_use_meta = FALSE;
|
||||
win->_delay = -1;
|
||||
win->_immed = FALSE;
|
||||
win->_sync = 0;
|
||||
win->_parx = 0;
|
||||
win->_pary = 0;
|
||||
win->_parent = (WINDOW *)NULL;
|
||||
|
||||
win->_regtop = 0;
|
||||
win->_regbottom = num_lines - 1;
|
||||
|
||||
for (i = 0; i < num_lines; i++)
|
||||
win->_firstchar[i] = win->_lastchar[i] = _NOCHANGE;
|
||||
|
||||
if (begx + num_columns == columns) {
|
||||
win->_flags |= _ENDLINE;
|
||||
|
||||
if (begx == 0 && num_lines == lines && begy == 0)
|
||||
win->_flags |= _FULLWIN;
|
||||
|
||||
if (begy + num_lines == lines)
|
||||
win->_flags |= _SCROLLWIN;
|
||||
}
|
||||
|
||||
return(win);
|
||||
}
|
229
lib/libncurses/lib_options.c
Normal file
229
lib/libncurses/lib_options.c
Normal file
@ -0,0 +1,229 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_options.c
|
||||
**
|
||||
** The routines to handle option setting.
|
||||
**
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <nterm.h>
|
||||
#include "curses.priv.h"
|
||||
|
||||
int idlok(WINDOW *win, int flag)
|
||||
{
|
||||
T(("idlok(%x,%d) called", win, flag));
|
||||
|
||||
if (insert_line || delete_line || parm_insert_line || parm_delete_line) {
|
||||
win->_idlok = flag;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int clearok(WINDOW *win, int flag)
|
||||
{
|
||||
T(("clearok(%x,%d) called", win, flag));
|
||||
|
||||
if (win == curscr)
|
||||
newscr->_clear = flag;
|
||||
else
|
||||
win->_clear = flag;
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int leaveok(WINDOW *win, int flag)
|
||||
{
|
||||
T(("leaveok(%x,%d) called", win, flag));
|
||||
|
||||
win->_leave = flag;
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int scrollok(WINDOW *win, int flag)
|
||||
{
|
||||
T(("scrollok(%x,%d) called", win, flag));
|
||||
|
||||
win->_scroll = flag;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int halfdelay(int t)
|
||||
{
|
||||
T(("halfdelay(%d) called", t));
|
||||
|
||||
if (t < 1 || t > 255)
|
||||
return ERR;
|
||||
|
||||
cbreak();
|
||||
SP->_cbreak = t+1;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int nodelay(WINDOW *win, int flag)
|
||||
{
|
||||
T(("nodelay(%x,%d) called", win, flag));
|
||||
|
||||
if (flag == TRUE)
|
||||
win->_delay = 0;
|
||||
else win->_delay = -1;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int notimeout(WINDOW *win, bool f)
|
||||
{
|
||||
T(("notimout(%x,%d) called", win, f));
|
||||
|
||||
win->_notimeout = f;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int wtimeout(WINDOW *win, int delay)
|
||||
{
|
||||
T(("wtimeout(%x,%d) called", win, delay));
|
||||
|
||||
win->_delay = delay;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static void init_keytry();
|
||||
static void add_to_try(char *, short);
|
||||
|
||||
int keypad(WINDOW *win, int flag)
|
||||
{
|
||||
T(("keypad(%x,%d) called", win, flag));
|
||||
|
||||
win->_use_keypad = flag;
|
||||
|
||||
if (flag && keypad_xmit)
|
||||
tputs(keypad_xmit, 1, _outc);
|
||||
else if (! flag && keypad_local)
|
||||
tputs(keypad_local, 1, _outc);
|
||||
|
||||
if (SP->_keytry == UNINITIALISED)
|
||||
init_keytry();
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int meta(WINDOW *win, int flag)
|
||||
{
|
||||
T(("meta(%x,%d) called", win, flag));
|
||||
|
||||
win->_use_meta = flag;
|
||||
|
||||
if (flag && meta_on)
|
||||
tputs(meta_on, 1, _outc);
|
||||
else if (! flag && meta_off)
|
||||
tputs(meta_off, 1, _outc);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** init_keytry()
|
||||
**
|
||||
** Construct the try for the current terminal's keypad keys.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
static struct try *newtry;
|
||||
|
||||
static void init_keytry()
|
||||
{
|
||||
newtry = NULL;
|
||||
|
||||
#include "keys.tries"
|
||||
|
||||
SP->_keytry = newtry;
|
||||
}
|
||||
|
||||
|
||||
static void add_to_try(char *str, short code)
|
||||
{
|
||||
static bool out_of_memory = FALSE;
|
||||
struct try *ptr, *savedptr;
|
||||
|
||||
if (! str || out_of_memory)
|
||||
return;
|
||||
|
||||
if (newtry != NULL) {
|
||||
ptr = savedptr = newtry;
|
||||
|
||||
for (;;) {
|
||||
while (ptr->ch != (unsigned char) *str
|
||||
&& ptr->sibling != NULL)
|
||||
ptr = ptr->sibling;
|
||||
|
||||
if (ptr->ch == (unsigned char) *str) {
|
||||
if (*(++str)) {
|
||||
if (ptr->child != NULL)
|
||||
ptr = ptr->child;
|
||||
else
|
||||
break;
|
||||
} else {
|
||||
ptr->value = code;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if ((ptr->sibling = (struct try *) malloc(sizeof *ptr)) == NULL) {
|
||||
out_of_memory = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
savedptr = ptr = ptr->sibling;
|
||||
ptr->child = ptr->sibling = NULL;
|
||||
ptr->ch = *str++;
|
||||
ptr->value = (short) NULL;
|
||||
|
||||
break;
|
||||
}
|
||||
} /* end for (;;) */
|
||||
} else { /* newtry == NULL :: First sequence to be added */
|
||||
savedptr = ptr = newtry = (struct try *) malloc(sizeof *ptr);
|
||||
|
||||
if (ptr == NULL) {
|
||||
out_of_memory = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
ptr->child = ptr->sibling = NULL;
|
||||
ptr->ch = *(str++);
|
||||
ptr->value = (short) NULL;
|
||||
}
|
||||
|
||||
/* at this point, we are adding to the try. ptr->child == NULL */
|
||||
|
||||
while (*str) {
|
||||
ptr->child = (struct try *) malloc(sizeof *ptr);
|
||||
|
||||
ptr = ptr->child;
|
||||
|
||||
if (ptr == NULL) {
|
||||
out_of_memory = TRUE;
|
||||
|
||||
ptr = savedptr;
|
||||
while (ptr != NULL) {
|
||||
savedptr = ptr->child;
|
||||
free(ptr);
|
||||
ptr = savedptr;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ptr->child = ptr->sibling = NULL;
|
||||
ptr->ch = *(str++);
|
||||
ptr->value = (short) NULL;
|
||||
}
|
||||
|
||||
ptr->value = code;
|
||||
return;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user