-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathconsole.inc
More file actions
177 lines (164 loc) · 7.62 KB
/
console.inc
File metadata and controls
177 lines (164 loc) · 7.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#if defined _console_included
#endinput
#endif
#define _console_included
/**
* <library name="console" summary="Console output.">
* <license>
* (c) Copyright 1998-2011, ITB CompuPhase
* This file is provided as is (no warranties).
* </license>
* <summary pawndoc="true">
* This library uses the enhanced <em>pawndoc.xsl</em> from
* <a href="https://github.com/pawn-lang/pawndoc">pawn-lang/pawndoc</a>.
* This XSL has features such as library and markdown support, and will not
* render this message when used.
* </summary>
* </library>
*/
/// <p/>
#pragma library Console
/**
* <library>console</library>
*/
/* */ native __print(const string[]) = print;
/**
* <library>console</library>
* <summary>Prints a string to the server console (not in-game chat) and logs (server_log.txt).</summary>
* <param name="string">The string to print</param>
* <param name="foreground">The string to print</param>
* <param name="background">Colour codes for the foreground and the background of the text string;
* see function <c>setattr</c> for a list of colours. When left at <c>-1</c>, the default colours
* are used. Note that a terminal or a host application may not support colours.</param>
* <seealso name="printf"/>
* <return>This function always returns 0.</return>
*/
/*
native print(const string[], foreground = -1, background = -1);
*/
stock print(const __string[], __foreground = -1, __background = -1)
{
// Quote:
//
// > Note that a [...] host application may not support colours
//
// So we can just ignore them.
#pragma unused __foreground, __background
return __print(__string);
}
/**
* <library>console</library>
* <summary>Outputs a formatted string on the console (the server window, not the in-game chat).</summary>
* <param name="format">The format string</param>
* <param name="">Indefinite number of arguments of any tag</param>
* <seealso name="print"/>
* <seealso name="format"/>
* <remarks>The format string or its output should not exceed 1024 characters. Anything beyond that
* length can lead to a server to crash.</remarks>
* <remarks>This function doesn't support <a href="#strpack">packed</a> strings.</remarks>
* <remarks>
* <b>Format Specifiers:</b><p/>
* <ul>
* <li><b><c>%i</c></b> - integer (whole number)</li>
* <li><b><c>%d</c></b> - integer (whole number).</li>
* <li><b><c>%s</c></b> - string</li>
* <li><b><c>%f</c></b> - floating-point number (Float: tag)</li>
* <li><b><c>%c</c></b> - ASCII character</li>
* <li><b><c>%x</c></b> - hexadecimal number</li>
* <li><b><c>%b</c></b> - binary number</li>
* <li><b><c>%%</c></b> - literal <b><c>%</c></b></li>
* <li><b><c>%q</c></b> - escape a text for SQLite. (Added in <b>0.3.7 R2</b>)</li>
* </ul>
* </remarks>
* <remarks>The values for the placeholders follow in the exact same order as parameters in the call.
* For example, <b><c>"I am %i years old"</c></b> - the <b><c>%i</c></b> will be replaced with an Integer
* variable, which is the person's age.</remarks>
* <remarks>You may optionally put a number between the <b><c>%</c></b> and the letter of the placeholder
* code. This number indicates the field width; if the size of the parameter to print at the position
* of the placeholder is smaller than the field width, the field is expanded with spaces. To cut the
* number of decimal places beeing shown of a float, you can add <b><c>.<max number></c></b> between
* the <b><c>%</c></b> and the <b><c>f</c></b>. (example: <b><c>%.2f</c></b>)</remarks>
* <return>This function always returns 0.</return>
*/
native printf(const format[], {Float, _}:...);
/**
* <library>console</library>
* <summary>Clear the rest of the line.</summary>
* <seealso name="clrscr"/>
* <return>This function always returns 0.</return>
* <remarks>Clears the line at which the cursor is, from the position of the cursor to the right
* margin of the console. This function does not move the cursor.</remarks>
*/
forward clreol();
/**
* <library>console</library>
* <summary>Clear the screen.</summary>
* <seealso name="clreol"/>
* <return>This function always returns 0.</return>
* <remarks>Clears the display and moves the cursor to the upper left corner.</remarks>
*/
forward clrscr();
/**
* <library>console</library>
* <summary>Read one character.</summary>
* <param name="echo">If <c>true</c>, the character read from the keyboard is echoed on the display.</param>
* <seealso name="getstring"/>
* <return>The numeric code for the character that is read (this is usually the ASCII code).</return>
*/
forward getchar(bool:echo = true);
/**
* <library>console</library>
* <summary>Read a line.</summary>
* <param name="string"></param>
* <param name="size"></param>
* <param name="pack"></param>
* <seealso name="getchar"/>
* <return>The number of characters read, excluding the terminating null character.</return>
* <remarks>Function <c>getstring</c> stops reading when either the enter key is typed or the
* maximum length is reached. The maximum length is in cells (not characters) and it includes a
* terminating null character. The function can read both packed and unpacked strings; when reading
* a packed string, the function may read more characters than the size parameter specifies, since
* each cell holds multiple characters.</remarks>
*/
forward getstring(string[], size = sizeof (string), bool:pack = false);
/**
* <library>console</library>
* <summary>Read a number.</summary>
* <param name="base">Must be between 2 and 36, use 10 for decimal or 16 for hexadecimal.</param>
* <param name="end">The character code that terminates the input. More than one character may be listed.</param>
* <param name="..."></param>
* <seealso name="getstring"/>
* <return>The value that is read.</return>
* <remarks>Read a value (a signed number) from the keyboard. The <c>getvalue</c> function allows
* you to read in a numeric radix from 2 to 36 (the base parameter) with decimal radix by default.
* By default the input ends when the user types the enter key, but one or more different keys may
* be selected (the end parameter and subsequent). In the list of terminating keys, a positive
* number (like <c>'\r'</c>) displays the key and terminates input, and a negative number terminates
* input without displaying the terminating key.</remarks>
*/
forward getvalue(base = 10, end = '\r', ...);
/**
* <library>console</library>
* <summary>Set cursor location.</summary>
* <param name="x"></param>
* <param name="y">The new cursor position.</param>
* <seealso name="clrscr"/>
* <return><c>true</c> if the cursor moved and <c>false</c> if the requested position is invalid.</return>
* <remarks>Sets the cursor position on the console. The upper left corner is at <c>(1,1)</c>.</remarks>
*/
forward bool:gotoxy(x = 1, y = 1);
/**
* <library>console</library>
* <summary>Set text colours.</summary>
* <param name="foreground">The string to print</param>
* <param name="background">Colour codes for the foreground and the background of the text string;
* see function <c>setattr</c> for a list of colours. When left at <c>-1</c>, the default colours
* are used. Note that a terminal or a host application may not support colours</param>
* <seealso name="clrscr"/>
* <return>This function always returns 0.</return>
* <remarks>On most systems, the colour value must be a value between zero and seven, as per the
* ANSI escape sequences, ISO 6429. Predefined constants for the colours are <c>black (0)</c>,
* <c>red (1)</c>, <c>green (2)</c>, <c>yellow (3)</c>, <c>blue (4)</c>, <c>magenta (5)</c>,
* <c>cyan (6)</c>, and <c>white (7)</c>.</remarks>
*/
forward setattr(foreground = -1, background = -1);