// Copyright (c) 2008-2023 the Urho3D project // License: MIT #include "../Precompiled.h" #include "../Core/Context.h" #include "../Core/CoreEvents.h" #include "../Engine/Console.h" #include "../Engine/EngineEvents.h" #include "../Graphics/Graphics.h" #include "../Input/Input.h" #include "../IO/IOEvents.h" #include "../IO/Log.h" #include "../Resource/ResourceCache.h" #include "../UI/DropDownList.h" #include "../UI/Font.h" #include "../UI/LineEdit.h" #include "../UI/ListView.h" #include "../UI/ScrollBar.h" #include "../UI/Text.h" #include "../UI/UI.h" #include "../UI/UIEvents.h" #include #include "../DebugNew.h" namespace Urho3D { static const int DEFAULT_CONSOLE_ROWS = 16; static const int DEFAULT_HISTORY_SIZE = 16; const char* logStyles[] = { "ConsoleTraceText", "ConsoleDebugText", "ConsoleInfoText", "ConsoleWarningText", "ConsoleErrorText", "ConsoleText" }; Console::Console(Context* context) : Object(context), autoVisibleOnError_(false), historyRows_(DEFAULT_HISTORY_SIZE), historyPosition_(0), autoCompletePosition_(0), historyOrAutoCompleteChange_(false), printing_(false) { auto* ui = GetSubsystem(); UIElement* uiRoot = ui->GetRoot(); // By default prevent the automatic showing of the screen keyboard focusOnShow_ = !ui->GetUseScreenKeyboard(); background_ = uiRoot->CreateChild(); background_->SetBringToBack(false); background_->SetClipChildren(true); background_->SetEnabled(true); background_->SetVisible(false); // Hide by default background_->SetPriority(200); // Show on top of the debug HUD background_->SetBringToBack(false); background_->SetLayout(LM_VERTICAL); rowContainer_ = background_->CreateChild(); rowContainer_->SetHighlightMode(HM_ALWAYS); rowContainer_->SetMultiselect(true); commandLine_ = background_->CreateChild(); commandLine_->SetLayoutMode(LM_HORIZONTAL); commandLine_->SetLayoutSpacing(1); interpreters_ = commandLine_->CreateChild(); lineEdit_ = commandLine_->CreateChild(); lineEdit_->SetFocusMode(FM_FOCUSABLE); // Do not allow defocus with ESC closeButton_ = uiRoot->CreateChild