MCPcopy Create free account
hub / github.com/assaultcube/AC / consolebuffer

Class consolebuffer

source/src/console.h:3–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1struct cline { char *line; int millis; };
2
3template<class LINE> struct consolebuffer
4{
5 int maxlines;
6 vector<LINE> conlines;
7
8 consolebuffer(int maxlines = 100) : maxlines(maxlines) {}
9
10 LINE &addline(const char *sf, int millis) // add a line to the console buffer
11 {
12 LINE cl;
13 cl.line = conlines.length()>maxlines ? conlines.pop().line : newstringbuf(""); // constrain the buffer size
14 cl.millis = millis; // for how long to keep line on screen
15 extern void encodeigraphs(char *d, const char *s, int len);
16 encodeigraphs(cl.line, sf, MAXSTRLEN);
17 return conlines.insert(0, cl);
18 }
19
20 void setmaxlines(int numlines)
21 {
22 maxlines = numlines;
23 while(conlines.length() > maxlines) delete[] conlines.pop().line;
24 }
25
26 virtual ~consolebuffer()
27 {
28 while(conlines.length()) delete[] conlines.pop().line;
29 }
30
31 virtual void render() = 0;
32};
33
34struct textinputbuffer
35{

Callers

nothing calls this directly

Calls 4

newstringbufFunction · 0.85
encodeigraphsFunction · 0.85
lengthMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected