Rev 6699 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2599 | hidnplayr | 1 | console.obj exports the following functions |
2 | |||
3 | typedef unsigned long dword; /* 32-bit unsigned integer */ |
||
4 | typedef unsigned short word; /* 16-bit unsigned integer */ |
||
5 | |||
6 | void __stdcall con_init(dword wnd_width, dword wnd_height, |
||
7 | dword scr_width, dword scr_height, const char* title); |
||
8 | Console initialization. Must be called only once. |
||
9 | wnd_width, wnd_height - width and height (in units of characters) of the visible region; |
||
10 | scr_width, scr_height - width and height (in units of characters) of console; |
||
11 | Any of these four parameters can be set to -1 (=0xFFFFFFFF) |
||
12 | to use the library's default values; |
||
13 | title - console window's caption. |
||
14 | |||
15 | void __stdcall con_exit(bool bCloseWindow); |
||
16 | You should call this funstion at the end of the program. |
||
17 | If bCloseWindow is zero, the string "[Finished]" will be added to the caption of the window |
||
18 | and the console window will remain on the screen until the user |
||
19 | closes it. |
||
20 | |||
21 | void __stdcall con_set_title(const char* title); |
||
22 | Set new window caption. |
||
23 | |||
24 | void __stdcall con_write_asciiz(const char* string); |
||
25 | Display ASCIIZ-string to the console at the current position, shifting |
||
26 | the current position. |
||
27 | |||
28 | void __stdcall con_write_string(const char* string, dword length); |
||
29 | Similar to con_write_asciiz, but length of the string must be given as a separate parameter |
||
30 | |||
31 | int __cdecl con_printf(const char* format, ...) |
||
32 | Standard "printf" function from ANSI C. |
||
33 | |||
34 | dword __stdcall con_get_flags(void); |
||
35 | Get output flags. |
||
36 | dword __stdcall con_set_flags(dword new_flags); |
||
37 | Set output flags. This function returns previous values. |
||
38 | Flags (bitmask): |
||
39 | /* text color */ |
||
40 | #define CON_COLOR_BLUE 0x01 |
||
41 | #define CON_COLOR_GREEN 0x02 |
||
42 | #define CON_COLOR_RED 0x04 |
||
43 | #define CON_COLOR_BRIGHT 0x08 |
||
44 | /* background color */ |
||
45 | #define CON_BGR_BLUE 0x10 |
||
46 | #define CON_BGR_GREEN 0x20 |
||
47 | #define CON_BGR_RED 0x40 |
||
48 | #define CON_BGR_BRIGHT 0x80 |
||
49 | /* output controls */ |
||
50 | #define CON_IGNORE_SPECIALS 0x100 |
||
51 | /* if this flag is cleared, function interprets special characters: |
||
52 | 10 ('\n') - next line |
||
53 | 13 ('\r') - carriage return |
||
54 | 8 ('\b') - backspace |
||
55 | 9 ('\t') - tab |
||
56 | 27 ('\033' = '\x1B') - the beginning of Esc-sequences; |
||
57 | otherwise, these characters will be displayed like ordinary characters. */ |
||
58 | /* Supported Esc-sequences: |
||
59 | Esc[ |
||
60 | You can specify one, two or three codes in any order; |
||
61 | |||
62 | 1 = bright selection |
||
63 | 5 = bright background |
||
64 | 7 = inverse mode (black on white) |
||
65 | 30 = black characters |
||
66 | 31 = red characters |
||
67 | 32 = green characters |
||
68 | 33 = brown characters |
||
69 | 34 = blue characters |
||
70 | 35 = purple characters |
||
71 | 36 = turqoise characters |
||
72 | 37 = white characters |
||
73 | 40 = black background |
||
74 | 41 = red background |
||
75 | 42 = green background |
||
76 | 43 = brown background |
||
77 | 44 = blue background |
||
78 | 45 = purple background |
||
79 | 46 = turqoise background |
||
80 | 47 = white background |
||
81 | The following sequences appeared in version 5 of library: |
||
82 | Esc[2J - clear screen, move cursor to upper left corner |
||
83 | Esc[ |
||
84 | move cursor to |
||
85 | Esc[ |
||
86 | Esc[ |
||
87 | Esc[ |
||
88 | Esc[ |
||
89 | */ |
||
90 | /* signal "console closed"; appeared in version 6; |
||
91 | ignored by con_set_flags */ |
||
92 | #define CON_WINDOW_CLOSED 0x200 |
||
93 | The default value for flags = 7. (grey text on black background) |
||
94 | |||
95 | int __stdcall con_get_font_height(void); |
||
96 | Get the height of the font. |
||
97 | |||
98 | int __stdcall con_get_cursor_height(void); |
||
99 | Get the height of the cursor. |
||
100 | int __stdcall con_set_cursor_height(int new_height); |
||
101 | Set the height of the cursor. This function returns previous value. |
||
102 | An attempt to set the value out of the correct interval (from 0 to |
||
103 | font_height-1) is ignored. |
||
104 | Cursor with zero height isn't displayed. |
||
105 | Default value: - 15% from font height. |
||
106 | |||
107 | int __stdcall con_getch(void); |
||
108 | Get one character from the keyboard. |
||
109 | |||
110 | For normal characters function returns ASCII-code. For extended |
||
111 | characters (eg, Fx, and arrows), first function call returns 0 |
||
112 | and second call returns the extended code (similar to the DOS-function |
||
113 | input). Starting from version 7, after closing the console window, |
||
114 | this function returns 0. |
||
115 | |||
116 | word __stdcall con_getch2(void); |
||
117 | Reads a character from the keyboard. Low byte contains the ASCII-code |
||
118 | (0 for extended characters), high byte - advanced code (like in BIOS |
||
119 | input functions). Starting from version 7, after closing the console |
||
120 | window, this function returns 0. |
||
121 | |||
122 | int __stdcall con_kbhit(void); |
||
123 | Returns 1 if a key was pressed, 0 otherwise. To read pressed keys use |
||
124 | con_getch and con_getch2. Starting from version 6, after closing |
||
125 | the console window, this function returns 1. |
||
126 | |||
127 | char* __stdcall con_gets(char* str, int n); |
||
128 | Reads a string from the keyboard. Reading is interrupted when got |
||
129 | "new line" character, or after reading the (n-1) characters (depending on |
||
130 | what comes first). In the first case the newline is also recorded in the |
||
131 | str. The acquired line is complemented by a null character. |
||
132 | Starting from version 6, the function returns a pointer to the entered |
||
133 | line if reading was successful, and NULL if the console window was closed. |
||
134 | |||
135 | typedef int (__stdcall * con_gets2_callback)(int keycode, char** pstr, int* pn, int* ppos); |
||
136 | char* __stdcall con_gets2(con_gets2_callback callback, char* str, int n); |
||
137 | Con_gets completely analogous, except that when the user |
||
138 | press unrecognized key, it calls the specified callback-procedure |
||
139 | (which may, for example, handle up / down for history and tab to enter |
||
140 | autocompletion). You should pass to the procedure: key code and three pointers |
||
141 | - to the string, to the maximum length and to the current position. |
||
142 | function may change the contents of string and may change the string |
||
143 | itself (for example, to reallocate memory for increase the limit), |
||
144 | maximum length, and position of the line - pointers are passed for it. |
||
145 | Return value: 0 = line wasn't changed 1 = line changed, you should |
||
146 | remove old string and display new, 2 = line changed, it is necessary |
||
147 | to display it; 3 = immediately exit the function. |
||
148 | Starting from version 6, the function returns a pointer to the entered |
||
149 | line with the successful reading, and NULL if the console window was closed. |
||
150 | |||
151 | void __stdcall con_cls(); |
||
152 | Clear screen and set cursor at upper left corner. |
||
153 | |||
154 | |||
155 | void __stdcall con_get_cursor_pos(int* px, int* py); |
||
156 | Wrote current (x) coordinate of cursor to *px, and (y) to *py. |
||
157 | |||
158 | void __stdcall con_set_cursor_pos(int x, int y); |
||
159 | Set the cursor position to the specified coordinates. If any of the |
||
160 | parameters beyond the relevant range (from 0 to 1 scr_width- |
||
161 | for x, from 0 to 1 for scr_height-y, scr_width scr_height and were asked if |
||
162 | call con_init), then the corresponding coordinate of the cursor does not change. |