| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #include "pikaConsoleWindow.h"
- #include <logs/assert.h>
- #include <iostream>
- namespace pika
- {
- void ConsoleWindow::init(pika::pikaImgui::ImGuiIdsManager &idManager)
- {
- imguiId = idManager.getImguiIds();
- s.reserve(4000);
- }
- void ConsoleWindow::update(pika::LogManager &logManager, bool &open)
- {
- //s += buffer->get;
- //*buffer = std::streambuf();
- //s += std::string{(std::istreambuf_iterator<char>(buffer)),
- // std::istreambuf_iterator<char>()};
- constexpr int SIZE = 3000; //todo
-
- if (s.size() > SIZE)
- {
- s.erase(0, s.size() - SIZE);
- }
- ImGui::PushID(imguiId);
- if (!ImGui::Begin(ICON_NAME, &open))
- {
- ImGui::End();
- ImGui::PopID();
- return;
- }
-
- ImGui::BeginChild("##console scrolling", ImVec2(0, 0), false);
- ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
-
- ImGui::TextWrapped(s.c_str());
- //ImGui::TextUnformatted(s.c_str());
- ImGui::PopStyleVar();
- if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY())
- ImGui::SetScrollHereY(1.0f);
- ImGui::EndChild();
- ImGui::End();
- ImGui::PopID();
- }
- };
|