|
23 | 23 | #include <memory> |
24 | 24 | #include <misc/misc.h> |
25 | 25 | #include <misc/stringops.h> |
| 26 | +#include <script/console.h> |
| 27 | +#include <script/luascript.h> |
26 | 28 | #include <serial/textstream.h> |
27 | 29 | #include <string> |
28 | 30 |
|
@@ -532,29 +534,21 @@ namespace FAGui |
532 | 534 |
|
533 | 535 | void GuiManager::consolePanel(nk_context* ctx) |
534 | 536 | { |
535 | | - static constexpr size_t bufferSize = 1024 * 1024; |
536 | | - static std::string boxBuffer; |
537 | | - static int boxLen; |
538 | | - static constexpr size_t inputSize = 512; |
539 | | - static char input[inputSize]; |
540 | | - static int inputLen; |
| 537 | + auto& c = Script::Console::getInstance(); |
541 | 538 | drawPanel(ctx, |
542 | 539 | PanelType::console, |
543 | 540 | [&]() { |
544 | 541 | nk_layout_space_begin(ctx, NK_STATIC, 0, INT_MAX); |
545 | 542 | nk_layout_space_push(ctx, nk_rect(5, 5, 490, 250)); |
546 | | - nk_edit_string(ctx, NK_EDIT_BOX | NK_EDIT_READ_ONLY, const_cast<char*>(boxBuffer.c_str()), &boxLen, bufferSize, nk_filter_default); |
| 543 | + nk_edit_string(ctx, NK_EDIT_BOX | NK_EDIT_READ_ONLY, c->getBufferPtr(), c->getBufferLen(), c->getBuffer().length(), nk_filter_default); |
547 | 544 | const int32_t height = FARender::Renderer::get()->smallFont()->height + 15; |
548 | 545 | nk_layout_space_push(ctx, nk_rect(5, 270, 490, height)); |
549 | | - nk_flags active = nk_edit_string(ctx, NK_EDIT_FIELD | NK_EDIT_SIG_ENTER, input, &inputLen, inputSize, nk_filter_ascii); |
| 546 | + nk_flags active = |
| 547 | + nk_edit_string(ctx, NK_EDIT_FIELD | NK_EDIT_SIG_ENTER, c->getInput(), c->getInputLen(), c->getInputSize(), nk_filter_ascii); |
550 | 548 |
|
551 | 549 | if (active & NK_EDIT_COMMITED) |
552 | 550 | { |
553 | | - input[inputLen] = '\n'; |
554 | | - ++inputLen; |
555 | | - boxBuffer.append(input, inputLen); |
556 | | - boxLen += inputLen; |
557 | | - inputLen = 0; |
| 551 | + c->inputCommited(); |
558 | 552 | } |
559 | 553 | nk_layout_space_end(ctx); |
560 | 554 | }, |
|
0 commit comments