diff options
Diffstat (limited to 'gui.cpp')
-rw-r--r-- | gui.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -68,7 +68,9 @@ bool GUI::showing() { /* ConsoleWindow */ -ConsoleWindow::ConsoleWindow() { +ConsoleWindow::ConsoleWindow(Lua *lua) { + this->lua = lua; + WindowManager& wmgr(WindowManager::getSingleton()); wnd = wmgr.loadWindowLayout("console.layout"); @@ -128,7 +130,21 @@ void ConsoleWindow::handle_input() { if(!s.size()) return; - FormattedListboxTextItem *item = new FormattedListboxTextItem(String((utf8*)s.c_str()), HTF_WORDWRAP_LEFT_ALIGNED); + add_line(s); + + try { + lua->dostring(s); + } catch(LuaError& e) { + add_line(e.what()); + } +} + +void ConsoleWindow::add_line(const std::string& line) { + add_line(line.c_str()); +} + +void ConsoleWindow::add_line(const char *line) { + FormattedListboxTextItem *item = new FormattedListboxTextItem(String((utf8*)line), HTF_WORDWRAP_LEFT_ALIGNED); listbox->addItem(item); listbox->ensureItemIsVisible(item); } |