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

57 lines
1.6 KiB
C++
Raw Normal View History

#pragma once
#include <hex/ui/view.hpp>
#include <imgui.h>
#include <vector>
2021-12-07 22:47:41 +01:00
namespace hex::plugin::builtin {
class ViewCommandPalette : public View::Special {
public:
ViewCommandPalette();
~ViewCommandPalette() override = default;
void drawContent() override {}
void drawAlwaysVisibleContent() override;
[[nodiscard]] bool shouldDraw() const override { return false; }
2022-01-10 21:05:37 +01:00
[[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(std::min(ImHexApi::System::getMainWindowSize().x, 600_scaled), 150_scaled); }
[[nodiscard]] ImVec2 getMaxSize() const override { return this->getMinSize(); }
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;
2022-02-01 22:09:44 +01:00
bool m_justOpened = false;
bool m_focusInputTextBox = false;
bool m_moveCursorToEnd = false;
std::string m_commandBuffer;
std::vector<CommandResult> m_lastResults;
std::string m_exactResult;
void focusInputTextBox() {
2023-12-19 13:10:25 +01:00
m_focusInputTextBox = true;
}
2023-11-10 20:47:08 +01:00
std::vector<CommandResult> getCommandResults(const std::string &input);
};
}