#ifndef ECODE_COMMANDPALETTE_HPP #define ECODE_COMMANDPALETTE_HPP #include #include #include #include #include using namespace EE; using namespace EE::UI::Models; using namespace EE::System; namespace ecode { using CommandPaletteModel = ItemVectorListOwnerModel; class CommandPalette { public: explicit CommandPalette( const std::shared_ptr& pool ); typedef std::function )> MatchResultCb; static std::vector> build( const std::vector& commandList, const EE::UI::KeyBindings& keybindings ); static std::shared_ptr asModel( const std::vector& commandList, const EE::UI::KeyBindings& keybindings ); void asyncFuzzyMatch( const std::string& match, const size_t& max, MatchResultCb res ) const; std::shared_ptr fuzzyMatch( const std::vector>& cmdPalette, const std::string& match, const size_t& max ) const; void setCommandPalette( const std::vector& commandList, const EE::UI::KeyBindings& keybindings ); const std::vector>& getCommandPalette() const; bool isSet() const { return !mCommandPalette.empty(); } const std::shared_ptr& getBaseModel() const; bool isEditorSet() const { return !mCommandPaletteEditor.empty(); } void setEditorCommandPalette( const std::vector& commandList, const EE::UI::KeyBindings& keybindings ); const std::shared_ptr& getCurModel() const; const std::shared_ptr& getEditorModel() const; void setCommandPaletteEditor( const std::vector>& commandPaletteEditor ); void setCurModel( const std::shared_ptr& curModel ); protected: mutable Mutex mMatchingMutex; std::shared_ptr mPool; std::vector> mCommandPalette; std::vector> mCommandPaletteEditor; std::shared_ptr mCurModel; std::shared_ptr mBaseModel; std::shared_ptr mEditorModel; }; } // namespace ecode #endif // ECODE_COMMANDPALETTE_HPP