📄 cref.tm
字号:
\usage{int SLsmg_reset_smg (void);}\description \var{SLsmg_reset_smg} resets the \var{SLsmg} screen management routines by freeing all memory allocated while it was active. It also calls \var{SLtt_reset_video} to put the terminal's display in it default state.\seealso{SLsmg_init_smg}\done\function{SLsmg_char_at}\synopsis{Get the character at the current position on the virtual display}\usage{unsigned short SLsmg_char_at(void)}\description The \var{SLsmg_char_at} function returns the character and its color at the current position on the virtual display.\seealso{SLsmg_read_raw, SLsmg_write_char}\done\function{SLsmg_set_screen_start}\synopsis{Set the origin of the virtual display}\usage{void SLsmg_set_screen_start (int *r, int *c)}\description \var{SLsmg_set_screen_start} sets the origin of the virtual display to the row \var{*r} and the column \var{*c}. If either \var{r} or \var{c} is \var{NULL}, then the corresponding value will be set to \var{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.\seealso{SLsmg_init_smg}\done\function{SLsmg_draw_hline}\synopsis{Draw a horizontal line}\usage{void SLsmg_draw_hline (unsigned int len)}\description The \var{SLsmg_draw_hline} function draws a horizontal line of length \var{len} on the virtual display. The position of the virtual cursor is left at the end of the line.\seealso{SLsmg_draw_vline}\done\function{SLsmg_draw_vline}\synopsis{Draw a vertical line}\usage{void SLsmg_draw_vline (unsigned int len);}\description The \var{SLsmg_draw_vline} function draws a vertical line of length \var{len} on the virtual display. The position of the virtual cursor is left at the end of the line.\seealso{??}\done\function{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 \var{SLsmg_draw_object} function may be used to place the object specified by \var{obj} at row \var{r} and column \var{c}. The object is really a character from the alternate character set and may be specified using one of the following constants:#v+ 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#v-\seealso{SLsmg_draw_vline, SLsmg_draw_hline, SLsmg_draw_box}\done\function{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 \var{SLsmg_draw_box} uses the \var{SLsmg_draw_hline} and \var{SLsmg_draw_vline} functions to draw a rectangular box on the virtual display. The box's upper left corner is placed at row \var{r} and column \var{c}. The width and length of the box is specified by \var{dc} and \var{dr}, respectively.\seealso{SLsmg_draw_vline, SLsmg_draw_hline, SLsmg_draw_object}\done\function{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)}#v+ int color; int r, c; unsigned int dr, dc;#v-\description \var{SLsmg_set_color_in_region} may be used to change the color of a rectangular region whose upper left corner is given by (\var{r},\var{c}), and whose width and height is given by \var{dc} and \var{dr}, respectively. The color of the region is given by the \var{color} parameter.\seealso{SLsmg_draw_box, SLsmg_set_color}\done\function{SLsmg_get_column}\synopsis{Get the column of the virtual cursor}\usage{int SLsmg_get_column(void);}\description The \var{SLsmg_get_column} function returns the current column of the virtual cursor on the virtual display.\seealso{SLsmg_get_row, SLsmg_gotorc}\done\function{SLsmg_get_row}\synopsis{Get the row of the virtual cursor}\usage{int SLsmg_get_row(void);}\description The \var{SLsmg_get_row} function returns the current row of the virtual cursor on the virtual display.\seealso{SLsmg_get_column, SLsmg_gotorc}\done\function{SLsmg_forward}\synopsis{Move the virtual cursor forward n columns}\usage{void SLsmg_forward (int n);}\description The \var{SLsmg_forward} function moves the virtual cursor forward \var{n} columns.\seealso{SLsmg_gotorc}\done\function{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 \var{SLsmg_write_color_chars} function may be used to write \var{len} characters, each with a different color descriptor to the virtual display. Each character and its associated color are encoded as an \exmp{unsigned short} such that the lower eight bits form the character and the next eight bits form the color.\seealso{SLsmg_char_at, SLsmg_write_raw}\done\function{SLsmg_read_raw}\synopsis{Read characters from the virtual display}\usage{unsigned int SLsmg_read_raw (unsigned short *buf, unsigned int len)}\description \var{SLsmg_read_raw} attempts to read \var{len} characters from the current position on the virtual display into the buffer specified by \var{buf}. It returns the number of characters actually read. This number will be less than \var{len} if an attempt is made to read past the right margin of the display.\notes The purpose of the pair of functions, \var{SLsmg_read_raw} and \var{SLsmg_write_raw}, is to permit one to copy the contents of one region of the virtual display to another region.\seealso{SLsmg_char_at, SLsmg_write_raw}\done\function{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 \var{SLsmg_write_raw} function attempts to write \var{len} characters specified by \var{buf} to the display at the current position. It returns the number of characters successfully written, which will be less than \var{len} if an attempt is made to write past the right margin.\notes The purpose of the pair of functions, \var{SLsmg_read_raw} and \var{SLsmg_write_raw}, is to permit one to copy the contents of one region of the virtual display to another region.\seealso{SLsmg_read_raw}\done\function{SLallocate_load_type}\synopsis{Allocate a SLang_Load_Type object}\usage{SLang_Load_Type *SLallocate_load_type (char *name)}\description The \var{SLallocate_load_type} function allocates and initializes space for a \var{SLang_Load_Type} object and returns it. Upon failure, the function returns \var{NULL}. The parameter \var{name} must uniquely identify the object. For example, if the object represents a file, then \var{name} could be the absolute path name of the file.\seealso{SLdeallocate_load_type, SLang_load_object}\done\function{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 \var{SLang_Load_Type} object that was acquired from a call to the \var{SLallocate_load_type} function.\seealso{SLallocate_load_type, SLang_load_object}\done\function{SLang_load_object}\synopsis{Load an object into the interpreter}\usage{int SLang_load_object (SLang_Load_Type *obj)}\description The function \var{SLang_load_object} is a generic function that may be used to loaded an object of type \var{SLang_Load_Type} into the interpreter. For example, the functions \var{SLang_load_file} and \var{SLang_load_string} are wrappers around this function to load a file and a string, respectively.\seealso{SLang_load_file, SLang_load_string, SLallocate_load_type}\done\function{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 \var{name}. If successful, a pointer to the class is returned, or upon failure the function returns \var{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 \var{SLclass_set_push_function}, and the data type must be registered with the interpreter via \var{SLclass_register_class}. See the \slang library programmer's guide for more information.\seealso{SLclass_register_class, SLclass_set_push_function}\done\function{SLclass_register_class}\synopsis{Register a new data type with the interpreter}\usage{int SLclass_register_class (cl, type, sizeof_type, class_type)}#v+ SLang_Class_Type *cl unsigned char type unsigned int sizeof_type unsigned char class_type#v-\description The \var{SLclass_register_class} function is used to register a new class or data type with the interpreter. If successful, the function returns \exmp{0}, or upon failure, it returns \var{-1}. The first parameter, \var{cl}, must have been previously obtained via the \var{SLclass_allocate_class} function. The second parameter, \var{type} specifies the data type of the new class. It must be an unsigned character with value greater that \exmp{127}. The values in the range \exmp{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, \var{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 \var{SLANG_CLASS_TYPE_VECTOR} or \var{SLANG_CLASS_TYPE_SCALAR}. For pointer objects, the value of this parameter is just \var{sizeof(void *)}. The final parameter specifies the class type of the data type. It must be one of the values:#v+ SLANG_CLASS_TYPE_SCALAR SLANG_CLASS_TYPE_VECTOR SLANG_CLASS_TYPE_PTR SLANG_CLASS_TYPE_MMT#v- The \var{SLANG_CLASS_TYPE_SCALAR} indicates that the new data type is a scalar. Examples of scalars in \var{SLANG_INT_TYPE} and \var{SLANG_DOUBLE_TYPE}. Setting \var{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 \var{SLANG_COMPLEX_TYPE}, which represents complex numbers. \var{SLANG_CLASS_TYPE_PTR} specifies the data type is of a pointer type. Examples of data types of this class include \var{SLANG_STRING_TYPE} and \var{SLANG_ARRAY_TYPE}. Such types must provide for their own memory management. Data types of class \var{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 \em{memory managed type}. An example of this data type is the \var{SLANG_FILEPTR_TYPE}.\notes See the \slang-c-programmers-guide for more information.\seealso{SLclass_allocate_class}\done\function{SLclass_set_string_function}\synopsis{Set a data type's string representation callback}\usage{int SLclass_set_string_function (cl, sfun)}#v+ SLang_Class_Type *cl char *(*sfun) (unsigned char, VOID_STAR);#v-\description The \var{SLclass_set_string_function} routine is used to define a callback function, \var{sfun}, that will be used when a string representation of an object of the data type represented by \var{cl} is needed. \var{cl} must have already been obtained via a call to \var{SLclass_allocate_class}. When called, \var{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 \em{malloced} string. Upon success, \var{SLclass_set_string_function} returns zero, or upon error it returns \-1.\example A callback function that handles both \var{SLANG_STRING_TYPE} and \var{SLANG_INT_TYPE} variables looks like:#v+ 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; }#v-\notes The default string callback simply returns the name of the data type.\seealso{SLclass_allocate_class, SLclass_register_class}\done\function{SLclass_set_destroy_function}\synopsis{Set the destroy method callback for a data type}\usage{int SLclass_set_destroy_function (cl, destroy_fun)}#v+ SLang_Class_Type *cl void (*destroy_fun) (unsigned char, VOID_STAR);#v-\description \var{SLclass_set_destroy_function} is used to set the destroy callback for a data type. The data type's class \var{cl} must have been previously obtained via a call to \var{SLclass_allocate_class}. When called, \var{destroy_fun} will be passed two arguments: a unsigned char which represents the data type, and the address of the object to be destroyed. \var{SLclass_set_destroy_function} returns zero upon success, and
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -