Add command line input to Output Log in Editor

This commit is contained in:
Wojtek Figat
2024-10-20 23:23:54 +02:00
parent 91d86552cd
commit 5328ea891d
3 changed files with 123 additions and 4 deletions

View File

@@ -266,6 +266,37 @@ void DebugCommands::Execute(StringView command)
LOG(Error, "Unknown command '{}'", name);
}
void DebugCommands::Search(StringView searchText, Array<StringView>& matches, bool startsWith)
{
if (searchText.IsEmpty())
return;
ScopeLock lock(Locker);
if (!Inited)
InitCommands();
if (startsWith)
{
for (auto& command : Commands)
{
if (command.Name.StartsWith(searchText, StringSearchCase::IgnoreCase))
{
matches.Add(command.Name);
}
}
}
else
{
for (auto& command : Commands)
{
if (command.Name.Contains(searchText.Get(), StringSearchCase::IgnoreCase))
{
matches.Add(command.Name);
}
}
}
}
bool DebugCommands::Iterate(const StringView& searchText, int32& index)
{
ScopeLock lock(Locker);
@@ -286,7 +317,7 @@ bool DebugCommands::Iterate(const StringView& searchText, int32& index)
return false;
}
String DebugCommands::GetCommandName(int32 index)
StringView DebugCommands::GetCommandName(int32 index)
{
ScopeLock lock(Locker);
CHECK_RETURN(Commands.IsValidIndex(index), String::Empty);

View File

@@ -18,7 +18,15 @@ public:
/// <param name="command">The command line (optionally with arguments).</param>
API_FUNCTION() static void Execute(StringView command);
/// <summary>
/// Searches the list of commands to return candidates that match the given query text.
/// </summary>
/// <param name="searchText">The query text.</param>
/// <param name="matches">The output list of commands that match a given query (unsorted).</param>
/// <param name="startsWith">True if filter commands that start with a specific search text, otherwise will return commands that contain a specific query.</param>
API_FUNCTION() static void Search(StringView searchText, API_PARAM(Out) Array<StringView, HeapAllocation>& matches, bool startsWith = false);
public:
static bool Iterate(const StringView& searchText, int32& index);
static String GetCommandName(int32 index);
static StringView GetCommandName(int32 index);
};