1
0
mirror of synced 2024-11-12 10:10:53 +01:00
ImHex/include/views/view_command_palette.hpp
WerWolv e74c0f5cf5 sys: Tons of long overdue cleanup
- std::string -> const std::string& where needed
- Added a FileIO abstraction class
- Fixed recent files not updating
- Removed localization file from global include
- Renamed lang to pattern_language/pl
- Renamed EventFileDropped to RequestFileOpen
2021-09-08 15:18:24 +02:00

61 lines
1.5 KiB
C++

#pragma once
#include <hex.hpp>
#include <hex/views/view.hpp>
#include <imgui.h>
#include <vector>
#include <tuple>
#include <cstdio>
namespace hex {
namespace prv { class Provider; }
class ViewCommandPalette : public View {
public:
ViewCommandPalette();
~ViewCommandPalette() override;
void drawContent() override;
void drawMenu() override;
bool isAvailable() override { return true; }
bool shouldProcess() override { return true; }
bool handleShortcut(bool keys[512], bool ctrl, bool shift, bool alt) override;
bool hasViewMenuItemEntry() override { return false; }
ImVec2 getMinSize() override { return ImVec2(400, 100); }
ImVec2 getMaxSize() 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);
};
}