📄 cref.txt
字号:
USAGE int SLsmg_reset_smg (void); DESCRIPTION `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. SEE ALSO SLsmg_init_smg--------------------------------------------------------------SLsmg_char_at SYNOPSIS Get the character at the current position on the virtual display USAGE unsigned short SLsmg_char_at(void) DESCRIPTION The `SLsmg_char_at' function returns the character and its color at the current position on the virtual display. SEE ALSO SLsmg_read_raw, SLsmg_write_char--------------------------------------------------------------SLsmg_set_screen_start SYNOPSIS Set the origin of the virtual display USAGE void SLsmg_set_screen_start (int *r, int *c) DESCRIPTION `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 \tt{slang/demo/pager.c} for how this function may be used to scroll horizontally. SEE ALSO SLsmg_init_smg--------------------------------------------------------------SLsmg_draw_hline SYNOPSIS Draw a horizontal line USAGE void SLsmg_draw_hline (unsigned int len) DESCRIPTION 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. SEE ALSO SLsmg_draw_vline--------------------------------------------------------------SLsmg_draw_vline SYNOPSIS Draw a vertical line USAGE void SLsmg_draw_vline (unsigned int len); DESCRIPTION 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. SEE ALSO ??--------------------------------------------------------------SLsmg_draw_object SYNOPSIS Draw an object from the alternate character set USAGE void SLsmg_draw_object (int r, int c, unsigned char obj) DESCRIPTION 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 SEE ALSO SLsmg_draw_vline, SLsmg_draw_hline, SLsmg_draw_box--------------------------------------------------------------SLsmg_draw_box SYNOPSIS Draw a box on the virtual display USAGE void SLsmg_draw_box (int r, int c, unsigned int dr, unsigned int dc) DESCRIPTION `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. SEE ALSO SLsmg_draw_vline, SLsmg_draw_hline, SLsmg_draw_object--------------------------------------------------------------SLsmg_set_color_in_region SYNOPSIS Change the color of a specifed region USAGE void SLsmg_set_color_in_region (color, r, c, dr, dc) int color; int r, c; unsigned int dr, dc; DESCRIPTION `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. SEE ALSO SLsmg_draw_box, SLsmg_set_color--------------------------------------------------------------SLsmg_get_column SYNOPSIS Get the column of the virtual cursor USAGE int SLsmg_get_column(void); DESCRIPTION The `SLsmg_get_column' function returns the current column of the virtual cursor on the virtual display. SEE ALSO SLsmg_get_row, SLsmg_gotorc--------------------------------------------------------------SLsmg_get_row SYNOPSIS Get the row of the virtual cursor USAGE int SLsmg_get_row(void); DESCRIPTION The `SLsmg_get_row' function returns the current row of the virtual cursor on the virtual display. SEE ALSO SLsmg_get_column, SLsmg_gotorc--------------------------------------------------------------SLsmg_forward SYNOPSIS Move the virtual cursor forward n columns USAGE void SLsmg_forward (int n); DESCRIPTION The `SLsmg_forward' function moves the virtual cursor forward `n' columns. SEE ALSO SLsmg_gotorc--------------------------------------------------------------SLsmg_write_color_chars SYNOPSIS Write characters with color descriptors to virtual display USAGE void SLsmg_write_color_chars (unsigned short *s, unsigned int len) DESCRIPTION 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. SEE ALSO SLsmg_char_at, SLsmg_write_raw--------------------------------------------------------------SLsmg_read_raw SYNOPSIS Read characters from the virtual display USAGE unsigned int SLsmg_read_raw (unsigned short *buf, unsigned int len) DESCRIPTION `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. NOTES 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. SEE ALSO SLsmg_char_at, SLsmg_write_raw--------------------------------------------------------------SLsmg_write_raw SYNOPSIS Write characters directly to the virtual display USAGE unsigned int SLsmg_write_raw (unsigned short *buf, unsigned int len) DESCRIPTION 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. NOTES 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. SEE ALSO SLsmg_read_raw--------------------------------------------------------------SLallocate_load_type SYNOPSIS Allocate a SLang_Load_Type object USAGE SLang_Load_Type *SLallocate_load_type (char *name) DESCRIPTION The `SLallocate_load_type' function allocates and initializes space for a `SLang_Load_Type' object and returns it. Upon failure, the function returns `NULL'. The parameter `name' must uniquely identify the object. For example, if the object represents a file, then `name' could be the absolute path name of the file. SEE ALSO SLdeallocate_load_type, SLang_load_object--------------------------------------------------------------SLdeallocate_load_type SYNOPSIS Free a SLang_Load_Type object USAGE void SLdeallocate_load_type (SLang_Load_Type *slt) DESCRIPTION This function frees the memory associated with a `SLang_Load_Type' object that was acquired from a call to the `SLallocate_load_type' function. SEE ALSO SLallocate_load_type, SLang_load_object--------------------------------------------------------------SLang_load_object SYNOPSIS Load an object into the interpreter USAGE int SLang_load_object (SLang_Load_Type *obj) DESCRIPTION The function `SLang_load_object' is a generic function that may be used to loaded an object of type `SLang_Load_Type' into the interpreter. For example, the functions `SLang_load_file' and `SLang_load_string' are wrappers around this function to load a file and a string, respectively. SEE ALSO SLang_load_file, SLang_load_string, SLallocate_load_type--------------------------------------------------------------SLclass_allocate_class SYNOPSIS Allocate a class for a new data type USAGE SLang_Class_Type *SLclass_allocate_class (char *name) DESCRIPTION The purpose of this function is to allocate and initialize space that defines a new data type or class called `name'. If successful, a pointer to the class is returned, or upon failure the function returns `NULL'. This function does not automatically create the new data type. Callback functions must first be associated with the data type via functions such as `SLclass_set_push_function', and the data type must be registered with the interpreter via `SLclass_register_class'. See the S-Lang library programmer's guide for more information. SEE ALSO SLclass_register_class, SLclass_set_push_function--------------------------------------------------------------SLclass_register_class SYNOPSIS Register a new data type with the interpreter USAGE int SLclass_register_class (cl, type, sizeof_type, class_type) SLang_Class_Type *cl unsigned char type unsigned int sizeof_type unsigned char class_type DESCRIPTION The `SLclass_register_class' function is used to register a new class or data type with the interpreter. If successful, the function returns `0', or upon failure, it returns `-1'. The first parameter, `cl', must have been previously obtained via the `SLclass_allocate_class' function. The second parameter, `type' specifies the data type of the new class. It must be an unsigned character with value greater that `127'. The values in the range `0-127' are reserved for internal use by the library. The size that the data type represents in bytes is specified by the third parameter, `sizeof_type'. This value should not be confused with the sizeof the structure that represents the data type, unless the data type is of class `SLANG_CLASS_TYPE_VECTOR' or `SLANG_CLASS_TYPE_SCALAR'. For pointer objects, the value of this parameter is just `sizeof(void *)'. The final parameter specifies the class type of the data type. It must be one of the values: SLANG_CLASS_TYPE_SCALAR SLANG_CLASS_TYPE_VECTOR SLANG_CLASS_TYPE_PTR SLANG_CLASS_TYPE_MMT The `SLANG_CLASS_TYPE_SCALAR' indicates that the new data type is a scalar. Examples of scalars in `SLANG_INT_TYPE' and `SLANG_DOUBLE_TYPE'. Setting `class_type' to SLANG_CLASS_TYPE_VECTOR implies that the new data type is a vector, or a 1-d array of scalar types. An example of a data type of this class is the `SLANG_COMPLEX_TYPE', which represents complex numbers. `SLANG_CLASS_TYPE_PTR' specifies the data type is of a pointer type. Examples of data types of this class include `SLANG_STRING_TYPE' and `SLANG_ARRAY_TYPE'. Such types must provide for their own memory management. Data types of class `SLANG_CLASS_TYPE_MMT' are pointer types except that the memory management, i.e., creation and destruction of the type, is handled by the interpreter. Such a type is called a _memory managed type_. An example of this data type is the `SLANG_FILEPTR_TYPE'. NOTES See the \slang-c-programmers-guide for more information. SEE ALSO SLclass_allocate_class--------------------------------------------------------------SLclass_set_string_function SYNOPSIS Set a data type's string representation callback USAGE int SLclass_set_string_function (cl, sfun) SLang_Class_Type *cl char *(*sfun) (unsigned char, VOID_STAR); DESCRIPTION The `SLclass_set_string_function' routine is used to define a callback function, `sfun', that will be used when a string representation of an object of the data type represented by `cl' is needed. `cl' must have already been obtained via a call to `SLclass_allocate_class'. When called, `sfun' will be passed two arguments: a unsigned char which represents the data type, and the address of the object for which a string represetation is required. The callback function must return a _malloced_ string. Upon success, `SLclass_set_string_function' returns zero, or upon error it returns -1. EXAMPLE A callback function that handles both `SLANG_STRING_TYPE' and `SLANG_INT_TYPE' variables looks like: char *string_and_int_callback (unsigned char type, VOID_STAR addr) { char buf[64]; switch (type) { case SLANG_STRING_TYPE: return SLmake_string (*(char **)addr); case SLANG_INTEGER_TYPE: sprintf (buf, "%d", *(int *)addr); return SLmake_string (buf); } return NULL; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -