home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
fish
/
libraries
/
curses_391
/
curses.doc
< prev
next >
Wrap
Text File
|
1990-10-27
|
12KB
|
428 lines
AMIGA CURSES PACKAGE
====================
Author : Simon John Raybould (sie@fulcrum.bt.co.uk)
Date : 21st April 1990
This is a brief description of the curses functions provided by this
package. I have not gone into great detail as I assume the users of this to
already have a knowledge of UN*X curses, more than likely porting UN*X screen
based applications to the Amiga. There is plenty of curses documentation
about so I will only outline each of the functions provided.
Cheers
Sie
Below is a list of the supported functions and there operation.
===============================================================
initscr()
This is usually the first function called by a program. It creates
stdscr and must be called before any of the other functions will work.
endwin()
This should be called before exiting a curses program.
It frees all memory used and dismantles all structures.
It closes the custom screen and window used.
beep()
Produces an audible beep from the speaker. This beep is similar in pitch
and duration to the beep from a terminal when a BEL (^G) character is
recieved.
flash()
Flashes the display by complementing the background colour. With the
default black background, this will flash the screen yellow.
box(window, vertical, horizontal)
Draws a box around the edge of the window.
window - pointer returned from newwin or subwin, or stdscr even.
vertical - character to use for the verticals.
horizontal - character to use for the horizontals.
Either of the characters may be zero. In this case, the defaults of
'|' and '-' will be used for vertical and horizontal respectivly.
NOTE
----
The box drawn is INSIDE the window. Therefore any of the clear routines
will effect the box if carried out on its window.
cbreak()
nocbreak()
cbreak() puts the terminal into CBREAK mode, making characters typed
available immediately.
nocbreak() sets NOCBREAK mode and characters are not available until
a newline is typed.
The default is NOCBREAK mode, so most programs call cbreak() before
doing any reads on the keyboard.
crmode()
nocrmode()
As cbreak() and nocbreak() as shown above.
clearok(WinPtr, flag)
If flag is TRUE then this function will make every refresh clear the
display before updating it. If the flag is FALSE then the screen will
not be cleared on each refresh. The DEFAULT is FALSE.
leavok(window, flag)
If flag is TRUE then the cursor will not be displayed.
The default is FALSE and the cursor is displayed.
subwin(orig, lines, cols, beg_line, beg_col)
Creates a new window within another window. The original window has
its pointer passed as 'orig'.
The new window will be at line 'beg_line' and column 'beg_col' of the
window pointed to by 'orig'. It will be of size 'lines' lines of 'cols'
columns.
A sub-window is part of its surrounding window. When the surrounding
window is refreshed, the sub-window is refreshed as well.
newwin(lines, cols, beg_line, beg_col)
Creates a new window at line 'beg_line' and column 'beg_col'.
The size of this window is 'lines' lines of 'cols' columns.
The new window has its own data structures and does not affect any
data in other windows.
delwin(window)
Deletes a window and frees the associated memory. This should be done if
the window is no longer used.
It is not necessary to free all windows, endwin() will free all windows
still allocated before returning.
mvwin(window, new_line, new_col)
Moves a window to a new position on the screen. This position is relative
to the top left of the screen and NOT to the start of any surrounding
window in the case of sub-windows.
nl()
nonl()
nl() - Causes newline to newline/carriage return mapping on output and
return to newline mapping on input.
nonl() - disables this.
The DEFAULT is that mapping is done.
echo()
noecho()
echo() causes every character read to be echoed back to the display.
noecho() prevents the echo, this is useful when reading movement keys,
you don't want them echoed to the screen.
The DEFAULT is that echoing is performed.
nodelay(window, flag)
nodelay is enabled by a call : nodelay(stdscr, TRUE);
When in nodelay mode, getch will return -1 if there is no input pending.
The DEFAULT is nodelay FALSE and getch will wait for at least one char
in CBREAK mode or a newline otherwise.
has_colors()
start_color()
init_color(n, r, g, b)
has_colors() is to check if colours are available on this terminal.
On the Amiga, it will simply return TRUE.
start_colour() is to tell the terminal that you wish to use colour.
init_color() will alter the Red, Green and Blue content of colour n.
r, g and b are in the range 1 to 1000. The colour number 'n' is in the
range 0 to 15 and it should be noted that colour 0 is the background
colour. Initially the foreground is set to colour 1 but can be changed
with the attron() or attrset() function to any of the colours 1 to 15,
0 is not allowed as this is the background. If 0 is selected, the
foreground colour will be set to 1.
keypad(window, flag)
If flag is TRUE then the ANSI sequences for the function keys and the
cursor keys will be converted to the tokens KEY_UP, KEY_HELP, e.t.c.
The DEFAULT is that the ANSI sequences will returned.
So to cause special keys to be returned as tokens in the standard screen,
add the following line:
keypad(stdscr, TRUE);
printw(fmt, args)
wprintw(window, fmt, args)
mvprintw(line, col, fmt, args)
mvwprintw(window, line, col, fmt, args)
Offer formatted output similar to printf(3).
printw() - prints at the current position in stdscr.
wprintw() - prints at the current position in window.
mvprintw() - prints at line 'line' column 'col' in stdscr.
mvwprintw() - prints at line 'line' column 'col' in 'window'.
scanw(fmt, args)
wscanw(window, fmt, args)
mvscanw(line, col, fmt, args)
mvwscanw(window, line, col, fmt, args)
Offer formatted input similar to scanf(3).
scanw() - scans at the current position in stdscr.
wscanw() - scans at the current position in window.
mvscanw() - scans at line 'line' column 'col' in stdscr.
mvwscanw() - scans at line 'line' column 'col' in 'window'.
scrollok(window, flag)
When flag is true, curses will automatically scroll the window up one
line when output goes off the bottom.
E.g.
scrollok(stdscr, TRUE);
stdscr will then be automatically scrolled up one line when output goes
off bottom of stdscr.
The DEFAULT is that the window will NOT be scrolled, the bottom line
will be used over and over again without scrolling.
scroll(window)
The window is scrolled up one line.
setscrreg(top, bottom)
wsetscrreg(window, top, bottom)
Sets the region from line 'top' to line 'bottom' inclusive.
When output moves below line 'bottom', the region is scrolled up one line
( if scrollok() has been called ).
touchwin(window)
Will force the window to be completely refreshed on the next call to
refresh by dumping all optimisation information. This can be useful if
the state of the screen is unknown or if a window was obscured by
another window which was not a subwindow of the one it covered. Then
you may need to touchwin() the window that was covered and refresh it.
addch(c)
waddch(window, c)
mvaddch(line, col, c)
mvwaddch(window, line, col, c)
addch(c) - Prints character c at current screen position in stdscr.
addch(window, c) - Prints character c at current screen position in
window.
mvaddch(line, col, c) - Prints character c at line 'line' column 'col' in
stdscr.
mvwaddch(window, line, col, c) - Prints character c at line 'line' column
'col' in window.
addstr(str)
waddstr(window, str)
mvaddstr(line, col, str)
mvwaddstr(window, line, col, str)
addstr(str) - Prints string str at current screen position in stdscr.
waddstr(window, str) - Prints string str at current screen position in
window.
mvaddstr(line, col, str) - Prints string str at line 'line' column 'col'
in stdscr.
mvwaddstr(window, line, col, str) - Prints string str at line 'line'
column 'col' in window.
attrset(attrs)
wattrset(window, attrs)
These routines set the attributes for stdscr or the specified window in
the case of wattset() to the value passed in attrs. This is usually used
to get the attributes to a known state before using attron() and
attroff() to add and remove extra attributes respectively.
attron(attrs)
wattron(window, attrs)
These routines add the attributes specified in attrs to those already set
for stdscr or the window specified in the case of wattron(). Any previous
attributes that are not directly affected by the changes will be left as
they were.
attroff(attrs)
wattroff(window, attrs)
These routines remove the attributes specified in attrs from those set
for stdscr or the window specified in the case of wattroff().
Any previous attributes that are not directly affected by the changes
will be left as they were.
e.g.
attron(A_REVERSE)
addstr("This is in inverse");
attroff(A_REVERSE);
refresh();
standout()
wstandout(window)
These routines make the following text appear in inverse video.
standend()
wstandend(window)
These routines will return the text type to normal video.
clear()
wclear(window)
These routines will empty the screen buffer and will cause the screen
to be cleared on the next call to refresh().
erase()
werase(window)
These routines will empty the screen buffer and will cause the screen
to be cleared on the next call to refresh(). Similar to erase() except
that these will call clearok() as well.
clrtobot()
wclrtobot(window)
On the next refresh(), the window will be blanked from the current
position to bottom righthand corner.
clrtoeol()
wclrtoeol(window)
On the next refresh(), the window will be blanked from the current
position to the end of the line.
delch()
wdelch(window)
mvdelch(line, col)
mvwdelch(window, line, col)
These routines delete the character at the current position, the rest of
the line to the right of this character is slid along to the left to
fill the gap. This can be very useful in editors and the like.
getch()
wgetch(window)
mvgetch(line, col)
mvwgetch(window, line, col)
These routines return the next character from the keyboard. If cbreak()
has been called then they return as soon as there is a character to read
else they wait for a <CR> before returning. If nodelay() has been called
then they will return a character if there is one or -1 if not.
getstr()
wgetstr(window)
mvgetstr(line, col)
mvwgetstr(window, line, col)
These routines should be used to read a string in from the keyboard.
Delete is processed for you.
inch()
winch(window)
mvinch(line, col)
mvwinch(window, line, col)
These routines return the character at the current position in the
window or at the specified position in the 'mv' cases.
insch()
winsch(window)
mvinsch(line, col)
mvwinsch(window, line, col)
These routines insert a character at the current window position, or at
the specified position in the 'mv' cases. The remainder of the line is
shifted along to the right to make room. The character at the far right
is lost.
insertln()
winsterln(window)
These routines insert a line at the current window position.
All of the lines below are shifted down and the bottom line is lost.
deleteln()
wdeleteln(window)
These routines delete a line at the current window position.
All of the lines below are shifted up into the space and the bottom line
is left blank.
move(line, col)
wmove(window, line, col)
These routines set the current position to line 'line' and column 'col'.
refresh()
wrefresh(window)
These routines cause all outstanding changes to 'stdscr' or the specified
window 'wrefresh' to be sent to the screen.