|
@@ -31,18 +31,30 @@ bool Console::isVisible() {
|
31
|
31
|
return mVisible;
|
32
|
32
|
}
|
33
|
33
|
|
|
34
|
+template<typename T>
|
|
35
|
+Console &Console::operator<<(T t) {
|
|
36
|
+ printBuffer << t;
|
|
37
|
+
|
|
38
|
+ if (printBuffer.str().back() == '\n') {
|
|
39
|
+ mHistory.push_back(printBuffer.str().substr(0, printBuffer.str().length() - 1));
|
|
40
|
+#ifdef DEBUG
|
|
41
|
+ std::cout << printBuffer.str().substr(0, printBuffer.str().length() - 1) << std::endl;
|
|
42
|
+#endif
|
|
43
|
+ printBuffer.str("");
|
|
44
|
+ }
|
|
45
|
+
|
|
46
|
+ return (*this);
|
|
47
|
+}
|
|
48
|
+
|
|
49
|
+// Deprecated!
|
34
|
50
|
void Console::print(const char *s, ...) {
|
35
|
51
|
va_list args;
|
36
|
52
|
va_start(args, s);
|
37
|
53
|
char *tmp = bufferString(s, args);
|
38
|
54
|
va_end(args);
|
39
|
55
|
|
40
|
|
- if (tmp != NULL) {
|
41
|
|
- mHistory.push_back(std::string(tmp));
|
42
|
|
-#ifdef DEBUG
|
43
|
|
- std::cout << tmp << std::endl;
|
44
|
|
-#endif
|
45
|
|
- }
|
|
56
|
+ if (tmp != nullptr)
|
|
57
|
+ (*this) << tmp << endl;
|
46
|
58
|
|
47
|
59
|
delete [] tmp;
|
48
|
60
|
}
|
|
@@ -80,6 +92,7 @@ void Console::display() {
|
80
|
92
|
mLineOffset = 0;
|
81
|
93
|
}
|
82
|
94
|
|
|
95
|
+ // Draw status line
|
83
|
96
|
getFont().drawText(10, 10, 0.70f, BLUE,
|
84
|
97
|
"%s uptime %lus scroll %d%%", VERSION, systemTimerGet() / 1000, scrollIndicator);
|
85
|
98
|
|
|
@@ -93,6 +106,7 @@ void Console::display() {
|
93
|
106
|
} else if (lineCount < mHistory.size()) {
|
94
|
107
|
historyOffset = mHistory.size() - lineCount;
|
95
|
108
|
}
|
|
109
|
+
|
96
|
110
|
for (int i = 0; i < end; i++) {
|
97
|
111
|
getFont().drawText(10, (unsigned int)((i + drawOffset) * lineSteps) + firstLine,
|
98
|
112
|
0.75f, BLUE, "%s", mHistory[i + historyOffset - mLineOffset].c_str());
|
|
@@ -122,6 +136,7 @@ void Console::handleKeyboard(KeyboardButton key, bool pressed) {
|
122
|
136
|
mHistoryPointer = 0;
|
123
|
137
|
}
|
124
|
138
|
|
|
139
|
+ // Delete last character
|
125
|
140
|
if (pressed && (key == backspaceKey)) {
|
126
|
141
|
if ((mPartialInput.length() == 0)
|
127
|
142
|
&& (mInputBuffer.length() > 0)) {
|