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
|
{
conskip += n;
if (conskip < 0)
conskip = 0;
}
COMMANDN(conskip, setconskip, ARG_1INT)
void
conline(const char *sf, bool highlight) // add a line to the console buffer
{
cline cl;
cl.cref = conlines.length() > 100
? conlines.pop().cref
: newstringbuf(""); // constrain the buffer size
cl.outtime = lastmillis; // for how long to keep line on screen
conlines.insert(0, cl);
if (highlight) // show line in a different colour, for chat etc.
{
cl.cref[0] = '\f';
cl.cref[1] = 0;
strcat_s(cl.cref, sf);
} else {
strcpy_s(cl.cref, sf);
};
puts(cl.cref);
#ifndef OF_WINDOWS
fflush(stdout);
#endif
}
void
conoutf(OFString *str, ...)
{
sprintf_sdv(sf, str.UTF8String);
const char *s = sf;
int n = 0;
while (strlen(s) > WORDWRAP) // cut strings to fit on screen
{
string t;
strn0cpy(t, s, WORDWRAP + 1);
conline(t, n++ != 0);
s += WORDWRAP;
}
conline(s, n != 0);
};
void
renderconsole() // render buffer taking into account time & scrolling
{
int nd = 0;
char *refs[ndraw];
loopv(conlines) if (conskip ? i >= conskip - 1 ||
|
|
|
|
|
<
>
|
|
|
>
|
>
>
|
>
|
|
|
|
|
|
|
<
>
>
|
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
|
{
conskip += n;
if (conskip < 0)
conskip = 0;
}
COMMANDN(conskip, setconskip, ARG_1INT)
static void
conline(OFString *sf, bool highlight) // add a line to the console buffer
{
cline cl;
cl.cref = conlines.length() > 100
? conlines.pop().cref
: newstringbuf(""); // constrain the buffer size
cl.outtime = lastmillis; // for how long to keep line on screen
conlines.insert(0, cl);
if (highlight) // show line in a different colour, for chat etc.
{
cl.cref[0] = '\f';
cl.cref[1] = 0;
strcat_s(cl.cref, sf.UTF8String);
} else {
strcpy_s(cl.cref, sf.UTF8String);
}
puts(cl.cref);
#ifndef OF_WINDOWS
fflush(stdout);
#endif
}
void
conoutf(OFConstantString *format, ...)
{
@autoreleasepool {
va_list arguments;
va_start(arguments, format);
OFString *string = [[OFString alloc] initWithFormat:format
arguments:arguments];
va_end(arguments);
int n = 0;
while (string.length > WORDWRAP) {
conline([string substringToIndex:WORDWRAP], n++ != 0);
string = [string substringFromIndex:WORDWRAP];
}
conline(string, n != 0);
}
}
void
renderconsole() // render buffer taking into account time & scrolling
{
int nd = 0;
char *refs[ndraw];
loopv(conlines) if (conskip ? i >= conskip - 1 ||
|