| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b591e05 commit 8a67d6a
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,10 +46,18 @@ class SPythonConsoleEditableTextBox : public SEditableTextBox | |||
| 46 | 46 | ]); | |
| 47 | 47 | } | |
| 48 | 48 | ||
| 49 | + void SetPythonBox(SPythonConsoleInputBox *box) { | ||
| 50 | + SPythonConsoleEditableText *PythonEditableText = (SPythonConsoleEditableText *)EditableText.Get(); | ||
| 51 | + PythonEditableText->PythonConsoleInputBox = box; | ||
| 52 | + } | ||
| 53 | + | ||
| 49 | 54 | private: | |
| 50 | 55 | class SPythonConsoleEditableText : public SEditableText | |
| 51 | 56 | { | |
| 52 | 57 | public: | |
| 58 | + | ||
| 59 | + SPythonConsoleInputBox *PythonConsoleInputBox; | ||
| 60 | + | ||
| 53 | 61 | SLATE_BEGIN_ARGS(SPythonConsoleEditableText) {} | |
| 54 | 62 | /** The text that appears when there is nothing typed into the search box */ | |
| 55 | 63 | SLATE_ATTRIBUTE(FText, HintText) | |
@@ -81,6 +89,22 @@ class SPythonConsoleEditableTextBox : public SEditableTextBox | |||
| 81 | 89 | { | |
| 82 | 90 | return FReply::Unhandled(); | |
| 83 | 91 | } | |
| 92 | + else if (InKeyEvent.GetKey() == EKeys::Up) { | ||
| 93 | + if (PythonConsoleInputBox->HistoryPosition > 0) { | ||
| 94 | + PythonConsoleInputBox->HistoryPosition--; | ||
| 95 | + this->SetText(FText::FromString(PythonConsoleInputBox->History[PythonConsoleInputBox->HistoryPosition])); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + return FReply::Handled(); | ||
| 99 | + } | ||
| 100 | + else if (InKeyEvent.GetKey() == EKeys::Down) { | ||
| 101 | + if (PythonConsoleInputBox->HistoryPosition < PythonConsoleInputBox->History.Num() - 2) { | ||
| 102 | + PythonConsoleInputBox->HistoryPosition++; | ||
| 103 | + this->SetText(FText::FromString(PythonConsoleInputBox->History[PythonConsoleInputBox->HistoryPosition])); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + return FReply::Handled(); | ||
| 107 | + } | ||
| 84 | 108 | else | |
| 85 | 109 | { | |
| 86 | 110 | return SEditableText::OnKeyDown(MyGeometry, InKeyEvent); | |
@@ -128,7 +152,7 @@ SPythonConsoleInputBox::SPythonConsoleInputBox() | |||
| 128 | 152 | : bIgnoreUIUpdate(false) | |
| 129 | 153 | { | |
| 130 | 154 | FScopePythonGIL gil; | |
| 131 | - | ||
| 155 | + | ||
| 132 | 156 | } | |
| 133 | 157 | ||
| 134 | 158 | BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION | |
@@ -144,6 +168,9 @@ void SPythonConsoleInputBox::Construct(const FArguments& InArgs) | |||
| 144 | 168 | .HintText(NSLOCTEXT("PythonConsole", "TypeInConsoleHint", "Enter python command")) | |
| 145 | 169 | ||
| 146 | 170 | ]; | |
| 171 | + | ||
| 172 | + SPythonConsoleEditableTextBox *TextBox = (SPythonConsoleEditableTextBox *)InputText.Get(); | ||
| 173 | + TextBox->SetPythonBox(this); | ||
| 147 | 174 | } | |
| 148 | 175 | void SPythonConsoleInputBox::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) | |
| 149 | 176 | { | |
@@ -170,6 +197,9 @@ void SPythonConsoleInputBox::OnTextCommitted(const FText& InText, ETextCommit::T | |||
| 170 | 197 | // re-entered. We want to make sure the text string is empty on re-entry, so we'll clear it out | |
| 171 | 198 | const FString ExecString = InText.ToString(); | |
| 172 | 199 | ||
| 200 | + this->History.Add(ExecString); | ||
| 201 | + this->HistoryPosition = this->History.Num(); | ||
| 202 | + | ||
| 173 | 203 | UE_LOG(LogTemp, Log, TEXT(">>> %s"), *ExecString); | |
| 174 | 204 | ||
| 175 | 205 | // Clear the console input area | |
@@ -182,7 +212,7 @@ void SPythonConsoleInputBox::OnTextCommitted(const FText& InText, ETextCommit::T | |||
| 182 | 212 | FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked<FUnrealEnginePythonModule>("UnrealEnginePython"); | |
| 183 | 213 | PythonModule.RunString(TCHAR_TO_UTF8(*ExecString)); | |
| 184 | 214 | ||
| 185 | - | ||
| 215 | + | ||
| 186 | 216 | } | |
| 187 | 217 | ||
| 188 | 218 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,6 +60,11 @@ class SPythonConsoleInputBox | |||
| 60 | 60 | /** SWidget interface */ | |
| 61 | 61 | virtual void Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime ) override; | |
| 62 | 62 | ||
| 63 | + | ||
| 64 | + TArray<FString> History; | ||
| 65 | + int HistoryPosition; | ||
| 66 | + | ||
| 67 | + | ||
| 63 | 68 | protected: | |
| 64 | 69 | ||
| 65 | 70 | virtual bool SupportsKeyboardFocus() const override { return true; } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments