slang.h
来自「ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机」· C头文件 代码 · 共 1,285 行 · 第 1/3 页
H
1,285 行
SLPreprocess_Type;
extern int SLprep_open_prep (SLPreprocess_Type *);
extern void SLprep_close_prep (SLPreprocess_Type *);
extern int SLprep_line_ok (char *, SLPreprocess_Type *);
extern int SLdefine_for_ifdef (char *);
/* Adds a string to the SLang #ifdef preparsing defines. SLang already
defines MSDOS, UNIX, and VMS on the appropriate system. */
extern int (*SLprep_exists_hook) (char *, char);
/*}}}*/
/*{{{ SLsmg Screen Management Functions */
#include <stdarg.h>
extern void SLsmg_fill_region (int, int, int, int, unsigned char);
#ifndef pc_system
extern void SLsmg_set_char_set (int);
extern int SLsmg_Scroll_Hash_Border;
#endif
extern void SLsmg_suspend_smg (void);
extern void SLsmg_resume_smg (void);
extern void SLsmg_erase_eol (void);
extern void SLsmg_gotorc (int, int);
extern void SLsmg_erase_eos (void);
extern void SLsmg_reverse_video (void);
extern void SLsmg_set_color (int);
extern void SLsmg_normal_video (void);
extern void SLsmg_printf (char *, ...);
extern void SLsmg_vprintf (char *, va_list);
extern void SLsmg_write_string (char *);
extern void SLsmg_write_nstring (char *, int);
extern void SLsmg_write_char (char);
extern void SLsmg_write_nchars (char *, int);
extern void SLsmg_write_wrapped_string (char *, int, int, int, int, int);
extern void SLsmg_cls (void);
extern void SLsmg_refresh (void);
extern void SLsmg_touch_lines (int, int);
extern int SLsmg_init_smg (void);
extern void SLsmg_reset_smg (void);
extern unsigned short SLsmg_char_at(void);
extern void SLsmg_set_screen_start (int *, int *);
extern void SLsmg_draw_hline (int);
extern void SLsmg_draw_vline (int);
extern void SLsmg_draw_object (int, int, unsigned char);
extern void SLsmg_draw_box (int, int, int, int);
extern int SLsmg_get_column(void);
extern int SLsmg_get_row(void);
extern void SLsmg_forward (int);
extern void SLsmg_write_color_chars (unsigned short *, unsigned int);
extern unsigned int SLsmg_read_raw (unsigned short *, unsigned int);
extern unsigned int SLsmg_write_raw (unsigned short *, unsigned int);
extern int SLsmg_Display_Eight_Bit;
extern int SLsmg_Tab_Width;
extern int SLsmg_Newline_Moves;
extern int SLsmg_Backspace_Moves;
#ifdef pc_system
# define SLSMG_HLINE_CHAR 0xC4
# define SLSMG_VLINE_CHAR 0xB3
# define SLSMG_ULCORN_CHAR 0xDA
# define SLSMG_URCORN_CHAR 0xBF
# define SLSMG_LLCORN_CHAR 0xC0
# define SLSMG_LRCORN_CHAR 0xD9
# define SLSMG_RTEE_CHAR 0xB4
# define SLSMG_LTEE_CHAR 0xC3
# define SLSMG_UTEE_CHAR 0xC2
# define SLSMG_DTEE_CHAR 0xC1
# define SLSMG_PLUS_CHAR 0xC5
/* There are several to choose from: 0xB0, 0xB1, and 0xB2 */
# define SLSMG_CKBRD_CHAR 0xB0
#else
# define SLSMG_HLINE_CHAR 'q'
# define SLSMG_VLINE_CHAR 'x'
# define SLSMG_ULCORN_CHAR 'l'
# define SLSMG_URCORN_CHAR 'k'
# define SLSMG_LLCORN_CHAR 'm'
# define SLSMG_LRCORN_CHAR 'j'
# define SLSMG_CKBRD_CHAR 'a'
# define SLSMG_RTEE_CHAR 'u'
# define SLSMG_LTEE_CHAR 't'
# define SLSMG_UTEE_CHAR 'w'
# define SLSMG_DTEE_CHAR 'v'
# define SLSMG_PLUS_CHAR 'n'
#endif
#ifndef pc_system
# define SLSMG_COLOR_BLACK 0x000000
# define SLSMG_COLOR_RED 0x000001
# define SLSMG_COLOR_GREEN 0x000002
# define SLSMG_COLOR_BROWN 0x000003
# define SLSMG_COLOR_BLUE 0x000004
# define SLSMG_COLOR_MAGENTA 0x000005
# define SLSMG_COLOR_CYAN 0x000006
# define SLSMG_COLOR_LGRAY 0x000007
# define SLSMG_COLOR_GRAY 0x000008
# define SLSMG_COLOR_BRIGHT_RED 0x000009
# define SLSMG_COLOR_BRIGHT_GREEN 0x00000A
# define SLSMG_COLOR_BRIGHT_BROWN 0x00000B
# define SLSMG_COLOR_BRIGHT_BLUE 0x00000C
# define SLSMG_COLOR_BRIGHT_CYAN 0x00000D
# define SLSMG_COLOR_BRIGHT_MAGENTA 0x00000E
# define SLSMG_COLOR_BRIGHT_WHITE 0x00000F
#endif
/*}}}*/
/*{{{ SLang Keypad Interface */
#define SL_KEY_ERR 0xFFFF
#define SL_KEY_UP 0x101
#define SL_KEY_DOWN 0x102
#define SL_KEY_LEFT 0x103
#define SL_KEY_RIGHT 0x104
#define SL_KEY_PPAGE 0x105
#define SL_KEY_NPAGE 0x106
#define SL_KEY_HOME 0x107
#define SL_KEY_END 0x108
#define SL_KEY_A1 0x109
#define SL_KEY_A3 0x10A
#define SL_KEY_B2 0x10B
#define SL_KEY_C1 0x10C
#define SL_KEY_C3 0x10D
#define SL_KEY_REDO 0x10E
#define SL_KEY_UNDO 0x10F
#define SL_KEY_BACKSPACE 0x110
#define SL_KEY_ENTER 0x111
#define SL_KEY_IC 0x112
#define SL_KEY_DELETE 0x113
#define SL_KEY_F0 0x200
#define SL_KEY_F(X) (SL_KEY_F0 + X)
/* I do not intend to use keysymps > 0x1000. Applications can use those. */
/* Returns 0 upon success or -1 upon error. */
int SLkp_define_keysym (char *, unsigned int);
/* This function must be called AFTER SLtt_get_terminfo and not before. */
extern int SLkp_init (void);
/* This function uses SLang_getkey and assumes that what ever initialization
* is required for SLang_getkey has been performed.
*/
extern int SLkp_getkey (void);
/*}}}*/
/*{{{ SLang Scroll Interface */
typedef struct _SLscroll_Type
{
struct _SLscroll_Type *next;
struct _SLscroll_Type *prev;
unsigned int flags;
}
SLscroll_Type;
typedef struct
{
unsigned int flags;
SLscroll_Type *top_window_line; /* list element at top of window */
SLscroll_Type *bot_window_line; /* list element at bottom of window */
SLscroll_Type *current_line; /* current list element */
SLscroll_Type *lines; /* first list element */
unsigned int nrows; /* number of rows in window */
unsigned int hidden_mask; /* applied to flags in SLscroll_Type */
unsigned int line_num; /* current line number (visible) */
unsigned int num_lines; /* total number of lines (visible) */
unsigned int window_row; /* row of current_line in window */
unsigned int border; /* number of rows that form scroll border */
int cannot_scroll; /* should window scroll or recenter */
}
SLscroll_Window_Type;
extern int SLscroll_find_top (SLscroll_Window_Type *);
extern int SLscroll_find_line_num (SLscroll_Window_Type *);
extern unsigned int SLscroll_next_n (SLscroll_Window_Type *, unsigned int);
extern unsigned int SLscroll_prev_n (SLscroll_Window_Type *, unsigned int);
extern int SLscroll_pageup (SLscroll_Window_Type *);
extern int SLscroll_pagedown (SLscroll_Window_Type *);
/*}}}*/
/*{{{ Signal Routines */
typedef void SLSig_Fun_Type (int);
extern SLSig_Fun_Type *SLsignal (int, SLSig_Fun_Type *);
extern SLSig_Fun_Type *SLsignal_intr (int, SLSig_Fun_Type *);
#ifndef pc_system
extern int SLsig_block_signals (void);
extern int SLsig_unblock_signals (void);
#endif
/*}}}*/
/*{{{ Interpreter Macro Definitions */
/* This value is a main_type just like the other main_types defined
* near the definition of SLang_Name_Type. Applications should avoid using
* this so if you do not understands its role, do not use it.
*/
#define SLANG_DATA 0x30 /* real objects which may be destroyed */
/* Subtypes */
/* The definitions here are for objects that may be on the run-time stack.
* They are actually sub_types of literal and data main_types.
*/
#define VOID_TYPE 1
#define INT_TYPE 2
#ifdef FLOAT_TYPE
# undef FLOAT_TYPE
# define FLOAT_TYPE 3
#endif
#define CHAR_TYPE 4
#define INTP_TYPE 5
/* An object of INTP_TYPE should never really occur on the stack. Rather,
* the integer to which it refers will be there instead. It is defined here
* because it is a valid type for MAKE_VARIABLE.
*/
#define SLANG_OBJ_TYPE 6
/* SLANG_OBJ_TYPE refers to an object on the stack that is a pointer to
* some other object.
*/
#if 0
/* This is not ready yet. */
# define SLANG_NOOP 9
#endif
/* Everything above string should correspond to a pointer in the object
* structure. See do_binary (slang.c) for exploitation of this fact.
*/
#define STRING_TYPE 10
/* Array type MUST be the smallest number for SLuser_Object_Type structs */
#define ARRAY_TYPE 20
/* I am reserving values greater than or equal to user applications. The
* first 99 are used for S-Lang.
*/
/* Binary and Unary Subtypes */
/* Since the application can define new types and can overload the binary
* and unary operators, these definitions must be present in this file.
*/
#define SLANG_PLUS 1
#define SLANG_MINUS 2
#define SLANG_TIMES 3
#define SLANG_DIVIDE 4
#define SLANG_EQ 5
#define SLANG_NE 6
#define SLANG_GT 7
#define SLANG_GE 8
#define SLANG_LT 9
#define SLANG_LE 10
/* UNARY subtypes (may be overloaded) */
#define SLANG_ABS 11
#define SLANG_SIGN 12
#define SLANG_SQR 13
#define SLANG_MUL2 14
#define SLANG_CHS 15
/* error codes, severe errors are less than 0 */
#define SL_INVALID_PARM -6
#define SL_MALLOC_ERROR -5
#define INTERNAL_ERROR -4
#define UNKNOWN_ERROR -3
#define STACK_OVERFLOW -1
#define STACK_UNDERFLOW -2
#define INTRINSIC_ERROR 1
/* Intrinsic error is an error generated by intrinsic functions */
#define USER_BREAK 2
#define UNDEFINED_NAME 3
#define SYNTAX_ERROR 4
#define DUPLICATE_DEFINITION 5
#define TYPE_MISMATCH 6
#define READONLY_ERROR 7
#define DIVIDE_ERROR 8
/* object could not be opened */
#define SL_OBJ_NOPEN 9
/* unknown object */
#define SL_OBJ_UNKNOWN 10
extern char *SLang_Error_Message;
extern void SLadd_name(char *, long, unsigned char, unsigned char);
extern void SLadd_at_handler (long *, char *);
#define SLANG_MAKE_ARGS(out, in) ((unsigned char)(out) | ((unsigned short) (in) << 4))
#ifdef SLANG_STATS
#define MAKE_INTRINSIC(n, f, out, in) \
{0, n, (out | (in << 4)), SLANG_INTRINSIC, (long) f}
#define MAKE_VARIABLE(n, v, t, r) \
{0, n, t, (SLANG_IVARIABLE + r), (long) v}
#else
#define MAKE_INTRINSIC(n, f, out, in) \
{n, (out | (in << 4)), SLANG_INTRINSIC, (long) f}
#define MAKE_VARIABLE(n, v, t, r) \
{n, t, (SLANG_IVARIABLE + r), (long) v}
#endif
#define SLANG_END_TABLE MAKE_INTRINSIC("", 0, 0, 0)
/*}}}*/
/*{{{ Upper/Lowercase Functions */
extern void SLang_define_case(int *, int *);
extern void SLang_init_case_tables (void);
extern unsigned char Chg_UCase_Lut[256];
extern unsigned char Chg_LCase_Lut[256];
#define UPPER_CASE(x) (Chg_UCase_Lut[(unsigned char) (x)])
#define LOWER_CASE(x) (Chg_LCase_Lut[(unsigned char) (x)])
#define CHANGE_CASE(x) (((x) == Chg_LCase_Lut[(unsigned char) (x)]) ?\
Chg_UCase_Lut[(unsigned char) (x)] : Chg_LCase_Lut[(unsigned char) (x)])
/*}}}*/
/*{{{ Regular Expression Interface */
typedef struct
{
unsigned char *pat; /* regular expression pattern */
unsigned char *buf; /* buffer for compiled regexp */
unsigned int buf_len; /* length of buffer */
int case_sensitive; /* 1 if match is case sensitive */
int must_match; /* 1 if line must contain substring */
int must_match_bol; /* true if it must match beginning of line */
unsigned char must_match_str[16]; /* 15 char null term substring */
int osearch; /* 1 if ordinary search suffices */
unsigned int min_length; /* minimum length the match must be */
int beg_matches[10]; /* offset of start of \( */
unsigned int end_matches[10]; /* length of nth submatch
* Note that the entire match corresponds
* to \0
*/
int offset; /* offset to be added to beg_matches */
} SLRegexp_Type;
extern unsigned char *SLang_regexp_match(unsigned char *,
unsigned int,
SLRegexp_Type *);
extern int SLang_regexp_compile (SLRegexp_Type *);
extern char *SLregexp_quote_string (char *, char *, unsigned int);
/*}}}*/
/*{{{ SLang Command Interface */
#define SLCMD_MAX_ARGS 10
struct _SLcmd_Cmd_Type; /* Pre-declaration is needed below */
typedef struct
{
struct _SLcmd_Cmd_Type *table;
int argc;
char *string_args[SLCMD_MAX_ARGS];
int int_args[SLCMD_MAX_ARGS];
float64 float_args[SLCMD_MAX_ARGS];
unsigned char arg_type[SLCMD_MAX_ARGS];
} SLcmd_Cmd_Table_Type;
typedef struct _SLcmd_Cmd_Type
{
int (*cmdfun)(int, SLcmd_Cmd_Table_Type *);
char cmd[32];
char arg_type[SLCMD_MAX_ARGS];
} SLcmd_Cmd_Type;
extern int SLcmd_execute_string (char *, SLcmd_Cmd_Table_Type *);
/*}}}*/
/*{{{ SLang Search Interface */
typedef struct
{
int cs; /* case sensitive */
unsigned char key[256];
int ind[256];
int key_len;
int dir;
} SLsearch_Type;
extern int SLsearch_init (char *, int, int, SLsearch_Type *);
/* This routine must first be called before any search can take place.
* The second parameter specifies the direction of the search: greater than
* zero for a forwrd search and less than zero for a backward search. The
* third parameter specifies whether the search is case sensitive or not.
* The last parameter is a pointer to a structure that is filled by this
* function and it is this structure that must be passed to SLsearch.
*/
unsigned char *SLsearch (unsigned char *, unsigned char *, SLsearch_Type *);
/* To use this routine, you must first call 'SLsearch_init'. Then the first
* two parameters p1 and p2 serve to define the region over which the search
* is to take place. The third parameter is the structure that was previously
* initialized by SLsearch_init.
*
* The routine returns a pointer to the match if found otherwise it returns
* NULL.
*/
/*}}}*/
#if 0
{
#endif
#ifdef __cplusplus
}
#endif
#endif /* _DAVIS_SLANG_H_ */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?