| 110 | } |
| 111 | |
| 112 | void Console::printf(const char* format, ...) |
| 113 | { |
| 114 | char buf[4096]; // TODO warning buffer overflow |
| 115 | va_list ap; |
| 116 | |
| 117 | va_start(ap, format); |
| 118 | vsnprintf(buf, sizeof(buf), format, ap); |
| 119 | va_end(ap); |
| 120 | |
| 121 | if (!m_withUI || !wid_console) { |
| 122 | fputs(buf, stdout); |
| 123 | fflush(stdout); |
| 124 | return; |
| 125 | } |
| 126 | |
| 127 | // Open the window |
| 128 | if (!wid_console->isVisible()) { |
| 129 | wid_console->openWindow(); |
| 130 | ui::Manager::getDefault()->invalidate(); |
| 131 | } |
| 132 | |
| 133 | /* update the textbox */ |
| 134 | if (!console_locked) { |
| 135 | console_locked = true; |
| 136 | |
| 137 | wid_view->setVisible(true); |
| 138 | |
| 139 | wid_console->remapWindow(); |
| 140 | wid_console->setBounds(gfx::Rect(0, 0, ui::display_w()*9/10, ui::display_h()*6/10)); |
| 141 | wid_console->centerWindow(); |
| 142 | wid_console->invalidate(); |
| 143 | } |
| 144 | |
| 145 | wid_textbox->setText(wid_textbox->text() + buf); |
| 146 | } |
| 147 | |
| 148 | // static |
| 149 | void Console::showException(const std::exception& e) |
no test coverage detected