Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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