The slsmg
module provides access to SLsmg routines, which is
an interface to platform indepented routines for manipulating the display
on a terminal.
It may be loaded using require("slsmg")
.
Suspend screen management
slsmg_suspend_smg ()
The slsmg_suspend_smg
function 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.
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
slsmg_resume_smg ()
The slsmg_resume_smg
function should be called after
slsmg_suspend_smg
to redraw the display exactly like it was
before slsmg_suspend_smg
was called.
slsmg_suspend_smg
Erase to the end of the row
slsmg_erase_eol ()
The slsmg_erase_eol
function 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
slsmg_gotorc (Integer_Type r, 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
slsmg_erase_eos ()
The slsmg_erase_eos
function 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
slsmg_reverse_video ()
This function is nothing more than slsmg_set_color(1)
.
slsmg_set_color
Set the current color
slsmg_set_color (Integer_Type c)
The slsmg_set_color
function is used to set the current
color. The parameter c
is a color object descriptor.
Actual foreground and background colors may be associated with a
color descriptor via the slsmg_define_color
function.
This example defines color 7
to be green foreground on black
background and then displays some text in this color:
require ("slsmg");
variable
ref,
row = SLsmg_Screen_Rows / 2,
txt = [
"This should be displayed in green under a black background",
"Press enter to close this window"];
slsmg_init_smg ();
slsmg_define_color (7, "green", "black");
slsmg_gotorc (row, SLsmg_Screen_Cols / 2 - strlen (txt[0]) / 2);
slsmg_set_color (7);
slsmg_write_string (txt[0]);
row++;
slsmg_gotorc (row, SLsmg_Screen_Cols / 2 - strlen (txt[1]) / 2);
slsmg_write_string (txt[1]);
slsmg_refresh ();
()=fgets(&ref, stdin);
Set the current color to 0
slsmg_normal_video ()
The slsmg_normal_video
function sets the current color descriptor to 0
.
slsmg_set_color
slsmg_write_string (String_Type s)
Clear the virtual display
slsmg_cls ()
The slsmg_cls
function 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
slsmg_refresh ()
The slsmg_refresh
function updates the physical display to
look like the virtual display.
slsmg_suspend_smg, slsmg_init_smg, slsmg_reset_smg
Reset the SLsmg
routines
slsmg_reset_smg ()
The slsmg_reset_smg
function resets the SLsmg
screen management routines by freeing all memory allocated
while it was active and also put the terminal's display in
it's default state.
slsmg_init_smg
Initialize the SLsmg
routines
slsmg_init_smg ()
The slsmg_init_smg
function initializes the SLsmg
screen
management routines. Specifically, this function allocates space
for the virtual display and puts the terminal's physical display in
the proper state.
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.
slsmg_reset_smg
Write the first n characters of a string on the display
slsmg_write_nstring (String_Type s, Integer_Type len)
The slsmg_write_nstring
function 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
Write a string to the display with wrapping
slsmg_write_wrapped_string (String_Type s, Integer_Type r, c, dr, dc, fill)
The slsmg_write_wrapped_string
function 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 dc
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
Get the character at the current position on the virtual display
Integer_Type slsmg_char_at ()
The slsmg_char_at
function returns the character and its color
at the current position on the virtual display.
Set the origin of the virtual display
slsmg_set_screen_start (Integer_Type r, c)
The slsmg_set_screen_start
function sets the origin of
the virtual display to the row r
and the column c
.
slsmg_init_smg
Draw a horizontal line
slsmg_draw_hline (Integer_Type 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
slsmg_draw_vline (Integer_Type 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
slsmg_draw_object (Integer_Type r, c, 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
slsmg_draw_box (Integer_Type r, c, dr, dc)
The slsmg_draw_box
function 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 length and width of the box is
specified by dr
and dc
, respectively.
slsmg_draw_vline, slsmg_draw_hline, slsmg_draw_object
Get the column of the virtual cursor
Integer_Type slsmg_get_column ()
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
Integer_Type slsmg_get_row ()
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
slsmg_forward (Integer_Type n)
The slsmg_forward
function moves the virtual cursor forward
n
columns.
slsmg_gotorc
Change the color of a specifed region
slsmg_set_color_in_region (Integer_Type color, r, c, dr, dc)
The slsmg_set_color_in_region
function may be used to
change the color of a rectangular region whose upper left corner
is given by (r
,c
), and whose height and width is given
by dr
and dc
, respectively. The color of the region
is given by the color
parameter.
slsmg_draw_box, slsmg_set_color
slsmg_define_color (Integer_Type obj, String_Type fg, bg)
The slsmg_define_color
function associates the color
descriptor obj
with a foreground and a background color.
The fg
and bg
colors can be one of the following strings:
"color0" or "black", "color8" or "gray",
"color1" or "red", "color9" or "brightred",
"color2" or "green", "color10" or "brightgreen",
"color3" or "brown", "color11" or "yellow",
"color4" or "blue", "color12" or "brightblue",
"color5" or "magenta", "color13" or "brightmagenta",
"color6" or "cyan", "color14" or "brightcyan",
"color7" or "lightgray", "color15" or "white"
slsmg_write_to_status_line (String_Type s)