1
0
mirror of synced 2024-11-18 21:07:12 +01:00
ImHex/plugins/builtin/include/content/views/view_command_palette.hpp

57 lines
1.5 KiB
C++
Raw Normal View History

#pragma once
#include <hex.hpp>
#include <hex/views/view.hpp>
#include <imgui.h>
#include <vector>
#include <tuple>
#include <cstdio>
2021-12-07 22:47:41 +01:00
namespace hex::plugin::builtin {
class ViewCommandPalette : public View {
public:
ViewCommandPalette();
~ViewCommandPalette() override;
void drawContent() override;
void drawMenu() override;
2022-01-10 21:05:37 +01:00
[[nodiscard]] bool isAvailable() const override { return true; }
[[nodiscard]] bool shouldProcess() const override { return true; }
2022-01-10 21:05:37 +01:00
[[nodiscard]] bool hasViewMenuItemEntry() const override { return false; }
[[nodiscard]] ImVec2 getMinSize() const override { return ImVec2(400, 100); }
[[nodiscard]] ImVec2 getMaxSize() const override { return ImVec2(400, 100); }
private:
enum class MatchType {
NoMatch,
InfoMatch,
PartialMatch,
PerfectMatch
};
struct CommandResult {
std::string displayResult;
std::string matchedCommand;
std::function<void(std::string)> executeCallback;
};
bool m_commandPaletteOpen = false;
bool m_justOpened = false;
bool m_focusInputTextBox = false;
std::vector<char> m_commandBuffer;
std::vector<CommandResult> m_lastResults;
std::string m_exactResult;
void focusInputTextBox() {
this->m_focusInputTextBox = true;
}
std::vector<CommandResult> getCommandResults(const std::string &command);
};
}