Add command line input to Output Log in Editor
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user