Fill a rectangular region with a character
void SLsmg_fill_region (r, c, nr, nc, ch)
int r
int c
unsigned int nr
unsigned int nc
unsigned char ch
The SLsmg_fill_region
function may be used to a
rectangular region with the character ch
in the current color.
The rectangle's upper left corner is at row r
and column
c
, and spans nr
rows and nc
columns. The position
of the virtual cursor will be left at (r
, c
).
SLsmg_write_char, SLsmg_set_color
Turn on or off line drawing characters
void SLsmg_set_char_set (int a);
SLsmg_set_char_set
may be used to select or deselect the line drawing
character set as the current character set. If a
is non-zero,
the line drawing character set will be selected. Otherwise, the
standard character set will be selected.
There is no guarantee that this function will actually enable the use of line drawing characters. All it does is cause subsequent characters to be rendered using the terminal's alternate character set. Such character sets usually contain line drawing characters.
SLsmg_write_char, SLtt_get_terminfo
Set the size of the border for the scroll hash
int SLsmg_Scroll_Hash_Border = 0;
This variable may be used to ignore the characters that occur at the beginning and the end of a row when performing the hash calculation to determine whether or not a line has scrolled. The default value is zero which means that all the characters on a line will be used.
SLsmg_refresh
Suspend screen management
int SLsmg_suspend_smg (void)
SLsmg_suspend_smg
can be used to suspend the state of the
screen management facility during suspension of the program. Use of
this function will reset the display back to its default state. The
funtion SLsmg_resume_smg
should be called after suspension.
It returns zero upon success, or -1
upon error.
This function is similar to SLsmg_reset_smg
except that the
state of the display prior to calling SLsmg_suspend_smg
is saved.
SLsmg_resume_smg, SLsmg_reset_smg
Resume screen management
int SLsmg_resume_smg (void)
SLsmg_resume_smg
should be called after
SLsmg_suspend_smg
to redraw the display exactly like it was
before SLsmg_suspend_smg
was called. It returns zero upon
success, or -1
upon error.
SLsmg_suspend_smg
Erase to the end of the row
void SLsmg_erase_eol (void);
SLsmg_erase_eol
erases all characters from the current
position to the end of the line. The newly created space is given
the color of the current color. This function has no effect on the
position of the virtual cursor.
SLsmg_gotorc, SLsmg_erase_eos, SLsmg_fill_region
Move the virtual cursor
void SLsmg_gotorc (int r, int c)
The SLsmg_gotorc
function moves the virtual cursor to the row
r
and column c
. The first row and first column is
specified by r = 0
and c = 0
.
SLsmg_refresh
Erase to the end of the screen
void SLsmg_erase_eos (void);
The SLsmg_erase_eos
is like SLsmg_erase_eol
except that
it erases all text from the current position to the end of the
display. The current color will be used to set the background of
the erased area.
SLsmg_erase_eol
Set the current color to 1
void SLsmg_reverse_video (void);
This function is nothing more than SLsmg_set_color(1)
.
SLsmg_set_color
Set the current color
void SLsmg_set_color (int c);
SLsmg_set_color
is used to set the current color. The
parameter c
is really a color object descriptor. Actual
foreground and background colors as well as other visual attributes
may be associated with a color descriptor via the
SLtt_set_color
function.
This example defines color 7
to be green foreground on black
background and then displays some text in this color:
SLtt_set_color (7, NULL, "green", "black");
SLsmg_set_color (7);
SLsmg_write_string ("Hello");
SLsmg_refresh ();
It is important to understand that the screen managment routines
know nothing about the actual colors associated with a color
descriptor. Only the descriptor itself is used by the SLsmg
routines. The lower level SLtt
interface converts the color
descriptors to actual colors. Thus
SLtt_set_color (7, NULL, "green", "black");
SLsmg_set_color (7);
SLsmg_write_string ("Hello");
SLtt_set_color (7, NULL, "red", "blue");
SLsmg_write_string ("World");
SLsmg_refresh ();
will result in "hello"
displayed in red on blue and not
green on black.
SLtt_set_color, SLtt_set_color_object
Set the current color to 0
void SLsmg_normal_video (void);
SLsmg_normal_video
sets the current color descriptor to 0
.
SLsmg_set_color
Format a string on the virtual display
void SLsmg_printf (char *fmt, ...)
SLsmg_printf
format a printf
style variable argument
list and writes it on the virtual display. The virtual cursor will
be moved to the end of the string.
SLsmg_write_string, SLsmg_vprintf
Format a string on the virtual display
void SLsmg_vprintf (char *fmt, va_list ap)
SLsmg_vprintf
formats a string in the manner of vprintf
and writes the result to the display. The virtual cursor is
advanced to the end of the string.
SLsmg_write_string, SLsmg_printf
Write a character string on the display
void SLsmg_write_string (char *s)
The function SLsmg_write_string
displays the string s
on
the virtual display at the current position and moves the position
to the end of the string.
SLsmg_printf, SLsmg_write_nstring
Write the first n characters of a string on the display
void SLsmg_write_nstring (char *s, unsigned int n);
SLsmg_write_nstring
writes the first n
characters of
s
to this virtual display. If the length of the string
s
is less than n
, the spaces will used until
n
characters have been written. s
can be NULL
, in
which case n
spaces will be written.
SLsmg_write_string, SLsmg_write_nchars
Write a character to the virtual display
void SLsmg_write_char (char ch);
SLsmg_write_char
writes the character ch
to the virtual
display.
SLsmg_write_nchars, SLsmg_write_string
Write n characters to the virtual display
void SLsmg_write_nchars (char *s, unsigned int n);
SLsmg_write_nchars
writes at most n
characters from the
string s
to the display. If the length of s
is less
than n
, the whole length of the string will get written.
This function differs from SLsmg_write_nstring
in that
SLsmg_write_nstring
will pad the string to write exactly
n
characters. SLsmg_write_nchars
does not perform any
padding.
SLsmg_write_nchars, SLsmg_write_nstring
Write a string to the display with wrapping
void SLsmg_write_wrapped_string (s, r, c, nr, nc, fill)
char *s
int r, c
unsigned int nr, nc
int fill
SLsmg_write_wrapped_string
writes the string s
to the
virtual display. The string will be confined to the rectangular
region whose upper right corner is at row r
and column c
,
and consists of nr
rows and nc
columns. The string will
be wrapped at the boundaries of the box. If fill
is non-zero,
the last line to which characters have been written will get padded
with spaces.
This function does not wrap on word boundaries. However, it will wrap when a newline charater is encountered.
SLsmg_write_string
Clear the virtual display
void SLsmg_cls (void)
SLsmg_cls
erases the virtual display using the current color.
This will cause the physical display to get cleared the next time
SLsmg_refresh
is called.
This function is not the same as
SLsmg_gotorc (0,0); SLsmg_erase_eos ();
since these statements do not guarantee that the physical screen
will get cleared.
SLsmg_refresh, SLsmg_erase_eos
Update physical screen
void SLsmg_refresh (void)
The SLsmg_refresh
function updates the physical display to
look like the virtual display.
SLsmg_suspend_smg, SLsmg_init_smg, SLsmg_reset_smg
Mark lines on the virtual display for redisplay
void SLsmg_touch_lines (int r, unsigned int nr)
SLsmg_touch_lines
marks the nr
lines on the virtual
display starting at row r
for redisplay upon the next call to
SLsmg_refresh
.
This function should rarely be called, if ever. If you find that
you need to call this function, then your application should be
modified to properly use the SLsmg
screen management routines.
This function is provided only for curses compatibility.
SLsmg_refresh
Initialize the SLsmg
routines
int SLsmg_init_smg (void)
The SLsmg_init_smg
function initializes the SLsmg
screen
management routines. Specifically, this function allocates space
for the virtual display and calls SLtt_init_video
to put the
terminal's physical display in the proper state. It is up to the
caller to make sure that the SLtt
routines are initialized via
SLtt_get_terminfo
before calling SLsmg_init_smg
.
This function should also be called any time the size of the physical display has changed so that it can reallocate a new virtual display to match the physical display.
It returns zero upon success, or -1
upon failure.
SLsmg_reset_smg
Reset the SLsmg
routines
int SLsmg_reset_smg (void);
SLsmg_reset_smg
resets the SLsmg
screen management
routines by freeing all memory allocated while it was active. It
also calls SLtt_reset_video
to put the terminal's display in
it default state.
SLsmg_init_smg
Get the character at the current position on the virtual display
unsigned short SLsmg_char_at(void)
The SLsmg_char_at
function returns the character and its color
at the current position on the virtual display.
SLsmg_read_raw, SLsmg_write_char
Set the origin of the virtual display
void SLsmg_set_screen_start (int *r, int *c)
SLsmg_set_screen_start
sets the origin of the virtual display
to the row *r
and the column *c
. If either r
or c
is NULL
, then the corresponding value will be set to 0
.
Otherwise, the location specified by the pointers will be updated to
reflect the old origin.
See slang/demo/pager.c
for how this function may be used to
scroll horizontally.
SLsmg_init_smg
Draw a horizontal line
void SLsmg_draw_hline (unsigned int len)
The SLsmg_draw_hline
function draws a horizontal line of
length len
on the virtual display. The position of the
virtual cursor is left at the end of the line.
SLsmg_draw_vline
Draw a vertical line
void SLsmg_draw_vline (unsigned int len);
The SLsmg_draw_vline
function draws a vertical line of
length len
on the virtual display. The position of the
virtual cursor is left at the end of the line.
??
Draw an object from the alternate character set
void SLsmg_draw_object (int r, int c, unsigned char obj)
The SLsmg_draw_object
function may be used to place the object
specified by obj
at row r
and column c
. The
object is really a character from the alternate character set and
may be specified using one of the following constants:
SLSMG_HLINE_CHAR Horizontal line
SLSMG_VLINE_CHAR Vertical line
SLSMG_ULCORN_CHAR Upper left corner
SLSMG_URCORN_CHAR Upper right corner
SLSMG_LLCORN_CHAR Lower left corner
SLSMG_LRCORN_CHAR Lower right corner
SLSMG_CKBRD_CHAR Checkboard character
SLSMG_RTEE_CHAR Right Tee
SLSMG_LTEE_CHAR Left Tee
SLSMG_UTEE_CHAR Up Tee
SLSMG_DTEE_CHAR Down Tee
SLSMG_PLUS_CHAR Plus or Cross character
SLsmg_draw_vline, SLsmg_draw_hline, SLsmg_draw_box
Draw a box on the virtual display
void SLsmg_draw_box (int r, int c, unsigned int dr, unsigned int dc)
SLsmg_draw_box
uses the SLsmg_draw_hline
and
SLsmg_draw_vline
functions to draw a rectangular box on the
virtual display. The box's upper left corner is placed at row
r
and column c
. The width and length of the box is
specified by dc
and dr
, respectively.
SLsmg_draw_vline, SLsmg_draw_hline, SLsmg_draw_object
Change the color of a specifed region
void SLsmg_set_color_in_region (color, r, c, dr, dc)
int color;
int r, c;
unsigned int dr, dc;
SLsmg_set_color_in_region
may be used to change the color of a
rectangular region whose upper left corner is given by
(r
,c
), and whose width and height is given by dc
and dr
, respectively. The color of the region is given by the
color
parameter.
SLsmg_draw_box, SLsmg_set_color
Get the column of the virtual cursor
int SLsmg_get_column(void);
The SLsmg_get_column
function returns the current column of
the virtual cursor on the virtual display.
SLsmg_get_row, SLsmg_gotorc
Get the row of the virtual cursor
int SLsmg_get_row(void);
The SLsmg_get_row
function returns the current row of the
virtual cursor on the virtual display.
SLsmg_get_column, SLsmg_gotorc
Move the virtual cursor forward n columns
void SLsmg_forward (int n);
The SLsmg_forward
function moves the virtual cursor forward
n
columns.
SLsmg_gotorc
Write characters with color descriptors to virtual display
void SLsmg_write_color_chars (unsigned short *s, unsigned int len)
The SLsmg_write_color_chars
function may be used to write
len
characters, each with a different color descriptor to the
virtual display. Each character and its associated color are
encoded as an unsigned short
such that the lower eight bits
form the character and the next eight bits form the color.
SLsmg_char_at, SLsmg_write_raw
Read characters from the virtual display
unsigned int SLsmg_read_raw (SLsmg_Char_Type *buf, unsigned int len)
SLsmg_read_raw
attempts to read len
characters from the
current position on the virtual display into the buffer specified by
buf
. It returns the number of characters actually read. This
number will be less than len
if an attempt is made to read
past the right margin of the display.
The purpose of the pair of functions, SLsmg_read_raw
and
SLsmg_write_raw
, is to permit one to copy the contents of one
region of the virtual display to another region.
SLsmg_char_at, SLsmg_write_raw
Write characters directly to the virtual display
unsigned int SLsmg_write_raw (unsigned short *buf, unsigned int len)
The SLsmg_write_raw
function attempts to write len
characters specified by buf
to the display at the current
position. It returns the number of characters successfully written,
which will be less than len
if an attempt is made to write
past the right margin.
The purpose of the pair of functions, SLsmg_read_raw
and
SLsmg_write_raw
, is to permit one to copy the contents of one
region of the virtual display to another region.
SLsmg_read_raw