Function render
Synopsis
#include <Source/Falcor/Utils/Scripting/Console.h>
void render(Gui *pGui, bool &show)
Description
Renders the console and handles important keyboard input events:
- The "`" key is used to open/close the console.
- The ESC key is used to close the console if currently open.
- The UP/DOWN keys are used to browse through the history.
- Parameters
[ in ]
pGui
- GUI.[in/out]
- show Flag to indicate if console is shown.
Source
Lines 75-108 in Source/Falcor/Utils/Scripting/Console.cpp. Line 51 in Source/Falcor/Utils/Scripting/Console.h.
void Console::render(Gui* pGui, bool& show)
{
// Toggle console with "`" key.
if (ImGui::IsKeyPressed('`')) show = !show;
// Allow closing console with escape key.
if (show && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape))) show = false;
if (!show) return;
ConsoleWindow w(pGui);
ImGui::BeginChild("log", {0, w.height - ImGui::GetTextLineHeight() - 5});
ImGui::PushTextWrapPos();
ImGui::TextUnformatted(mLog.c_str());
ImGui::PopTextWrapPos();
if (mScrollToBottom)
{
ImGui::SetScrollHere(1.0f);
mScrollToBottom = false;
}
ImGui::EndChild();
ImGui::PushItemWidth(ImGui::GetWindowWidth());
if (ImGui::InputText("##console", mCmdBuffer, arraysize(mCmdBuffer), ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackHistory | ImGuiInputTextFlags_CallbackCharFilter, &inputTextCallback, this))
{
enterCommand();
ImGui::GetIO().KeysDown[(uint32_t)KeyboardEvent::Key::Enter] = false;
}
// Stick focus to console text input.
ImGui::SetWindowFocus();
ImGui::SetKeyboardFocusHere();
pGui->setActiveFont("");
}