2020-12-16 21:43:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex.hpp>
|
2022-02-01 17:09:40 +00:00
|
|
|
#include <hex/ui/view.hpp>
|
2020-12-16 21:43:07 +00:00
|
|
|
|
2021-01-13 16:28:27 +00:00
|
|
|
#include <imgui.h>
|
2020-12-16 21:43:07 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <tuple>
|
|
|
|
#include <cstdio>
|
|
|
|
|
2021-12-07 21:47:41 +00:00
|
|
|
namespace hex::plugin::builtin {
|
2020-12-16 21:43:07 +00:00
|
|
|
|
|
|
|
class ViewCommandPalette : public View {
|
|
|
|
public:
|
|
|
|
ViewCommandPalette();
|
2022-03-04 19:52:39 +00:00
|
|
|
~ViewCommandPalette() override = default;
|
2020-12-16 21:43:07 +00:00
|
|
|
|
2020-12-22 17:10:01 +00:00
|
|
|
void drawContent() override;
|
2022-01-23 01:28:38 +00:00
|
|
|
|
2022-01-10 20:05:37 +00:00
|
|
|
[[nodiscard]] bool isAvailable() const override { return true; }
|
|
|
|
[[nodiscard]] bool shouldProcess() const override { return true; }
|
2020-12-16 21:43:07 +00:00
|
|
|
|
2022-01-10 20:05:37 +00:00
|
|
|
[[nodiscard]] bool hasViewMenuItemEntry() const override { return false; }
|
2022-01-15 23:48:35 +00:00
|
|
|
[[nodiscard]] ImVec2 getMinSize() const override { return { 400, 100 }; }
|
|
|
|
[[nodiscard]] ImVec2 getMaxSize() const override { return { 400, 100 }; }
|
2020-12-16 21:43:07 +00:00
|
|
|
|
|
|
|
private:
|
2022-03-04 19:52:39 +00:00
|
|
|
enum class MatchType
|
|
|
|
{
|
2021-02-08 18:56:04 +00:00
|
|
|
NoMatch,
|
|
|
|
InfoMatch,
|
|
|
|
PartialMatch,
|
|
|
|
PerfectMatch
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CommandResult {
|
|
|
|
std::string displayResult;
|
|
|
|
std::string matchedCommand;
|
|
|
|
std::function<void(std::string)> executeCallback;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool m_commandPaletteOpen = false;
|
2022-02-01 21:09:44 +00:00
|
|
|
bool m_justOpened = false;
|
|
|
|
bool m_focusInputTextBox = false;
|
2021-02-08 18:56:04 +00:00
|
|
|
|
2020-12-16 21:43:07 +00:00
|
|
|
std::vector<char> m_commandBuffer;
|
2021-02-08 18:56:04 +00:00
|
|
|
std::vector<CommandResult> m_lastResults;
|
2020-12-16 21:43:07 +00:00
|
|
|
std::string m_exactResult;
|
|
|
|
|
2021-02-08 18:56:04 +00:00
|
|
|
void focusInputTextBox() {
|
|
|
|
this->m_focusInputTextBox = true;
|
|
|
|
}
|
|
|
|
|
2021-09-08 13:18:24 +00:00
|
|
|
std::vector<CommandResult> getCommandResults(const std::string &command);
|
2020-12-16 21:43:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|