From 0189c54bc54f4cc229519fb95da1ca030f645bdc Mon Sep 17 00:00:00 2001 From: rzaharia Date: Wed, 31 Jul 2024 01:09:18 +0300 Subject: [PATCH] enforced the new keyboard interface for all commands #326 --- GViewCore/include/GView.hpp | 6 ++---- GViewCore/src/Type/DefaultTypePlugin.cpp | 5 +++++ GViewCore/src/Type/FolderViewPlugin.cpp | 4 ++++ Types/BMP/include/bmp.hpp | 4 ++++ Types/CPP/include/cpp.hpp | 4 ++++ Types/CSV/include/csv.hpp | 4 ++++ Types/ELF/include/elf.hpp | 4 ++++ Types/EML/include/eml.hpp | 4 ++++ Types/ICO/include/ico.hpp | 4 ++++ Types/INI/include/ini.hpp | 4 ++++ Types/ISO/include/iso.hpp | 4 ++++ Types/JCLASS/src/jclass.hpp | 4 ++++ Types/JOB/include/JOB.hpp | 4 ++++ Types/JS/include/js.hpp | 4 ++++ Types/JSON/include/json.hpp | 4 ++++ Types/JT/include/JT.hpp | 4 ++++ Types/LNK/include/LNK.hpp | 4 ++++ Types/MACHO/include/MachO.hpp | 3 ++- Types/MACHO/src/MachOFile.cpp | 7 +++++++ Types/MAM/include/MAM.hpp | 1 + Types/MAM/src/MAMFile.cpp | 7 +++++++ Types/PCAP/include/PCAP.hpp | 4 ++++ Types/PREFETCH/include/Prefetch.hpp | 4 ++++ Types/PYEXTRACTOR/include/pyextractor.hpp | 4 ++++ Types/SQLite/include/sqlite.hpp | 5 +++++ Types/VBA/include/vba.hpp | 4 ++++ Types/ZIP/include/zip.hpp | 5 +++++ 27 files changed, 110 insertions(+), 5 deletions(-) diff --git a/GViewCore/include/GView.hpp b/GViewCore/include/GView.hpp index eb17932b..9c2c5b3a 100644 --- a/GViewCore/include/GView.hpp +++ b/GViewCore/include/GView.hpp @@ -45,10 +45,8 @@ struct CORE_EXPORT TypeInterface { virtual std::string_view GetTypeName() = 0; virtual void RunCommand(std::string_view commandName) = 0; - virtual bool UpdateKeys(KeyboardControlsInterface* interface)//TODO: =0; - { - return true; - } + virtual bool UpdateKeys(KeyboardControlsInterface* interface) = 0; + virtual ~TypeInterface(){} struct SelectionZone { diff --git a/GViewCore/src/Type/DefaultTypePlugin.cpp b/GViewCore/src/Type/DefaultTypePlugin.cpp index c19b369c..4b41f14c 100644 --- a/GViewCore/src/Type/DefaultTypePlugin.cpp +++ b/GViewCore/src/Type/DefaultTypePlugin.cpp @@ -13,6 +13,11 @@ class DefaultType : public TypeInterface void RunCommand(std::string_view) override { } + bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } + ~DefaultType() { } diff --git a/GViewCore/src/Type/FolderViewPlugin.cpp b/GViewCore/src/Type/FolderViewPlugin.cpp index 17fddd30..6f90d54b 100644 --- a/GViewCore/src/Type/FolderViewPlugin.cpp +++ b/GViewCore/src/Type/FolderViewPlugin.cpp @@ -44,6 +44,10 @@ class FolderType : public TypeInterface, public View::ContainerViewer::Enumerate void RunCommand(std::string_view) override { } + bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } virtual bool BeginIteration(std::u16string_view path, AppCUI::Controls::TreeViewItem parent) override; virtual bool PopulateItem(TreeViewItem item) override; diff --git a/Types/BMP/include/bmp.hpp b/Types/BMP/include/bmp.hpp index 9a3aa92a..fd6aed81 100644 --- a/Types/BMP/include/bmp.hpp +++ b/Types/BMP/include/bmp.hpp @@ -60,6 +60,10 @@ namespace Type void RunCommand(std::string_view) override { } + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } bool LoadImageToObject(Image& img, uint32 index) override; diff --git a/Types/CPP/include/cpp.hpp b/Types/CPP/include/cpp.hpp index 40426e21..96653faa 100644 --- a/Types/CPP/include/cpp.hpp +++ b/Types/CPP/include/cpp.hpp @@ -88,6 +88,10 @@ namespace Type void RunCommand(std::string_view) override { } + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } virtual void GetTokenIDStringRepresentation(uint32 id, AppCUI::Utils::String& str) override; virtual void PreprocessText(GView::View::LexicalViewer::TextEditor& editor) override; diff --git a/Types/CSV/include/csv.hpp b/Types/CSV/include/csv.hpp index 0809c858..3ea0d565 100644 --- a/Types/CSV/include/csv.hpp +++ b/Types/CSV/include/csv.hpp @@ -38,6 +38,10 @@ namespace Type void RunCommand(std::string_view) override { } + bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } bool Update(Reference obj); bool HasPanel(Panels::IDs id); void UpdateBufferViewZones(GView::View::BufferViewer::Settings& settings); diff --git a/Types/ELF/include/elf.hpp b/Types/ELF/include/elf.hpp index dafef3be..9e344508 100644 --- a/Types/ELF/include/elf.hpp +++ b/Types/ELF/include/elf.hpp @@ -102,6 +102,10 @@ class ELFFile : public TypeInterface, public GView::View::BufferViewer::OffsetTr void RunCommand(std::string_view) override { } + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } public: Reference selectionZoneInterface; diff --git a/Types/EML/include/eml.hpp b/Types/EML/include/eml.hpp index 58db0f33..e17298c2 100644 --- a/Types/EML/include/eml.hpp +++ b/Types/EML/include/eml.hpp @@ -88,6 +88,10 @@ namespace Type // View::ContainerViewer::OpenItemInterface virtual void OnOpenItem(std::u16string_view path, AppCUI::Controls::TreeViewItem item) override; + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } }; diff --git a/Types/ICO/include/ico.hpp b/Types/ICO/include/ico.hpp index 063ab732..4a801b1b 100644 --- a/Types/ICO/include/ico.hpp +++ b/Types/ICO/include/ico.hpp @@ -75,6 +75,10 @@ namespace Type void RunCommand(std::string_view) override { } + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } bool LoadImageToObject(Image& img, uint32 index) override; diff --git a/Types/INI/include/ini.hpp b/Types/INI/include/ini.hpp index a8646f9c..8cd317bd 100644 --- a/Types/INI/include/ini.hpp +++ b/Types/INI/include/ini.hpp @@ -85,6 +85,10 @@ namespace Type void RunCommand(std::string_view) override { } + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } virtual void GetTokenIDStringRepresentation(uint32 id, AppCUI::Utils::String& str) override; virtual void PreprocessText(GView::View::LexicalViewer::TextEditor& editor) override; diff --git a/Types/ISO/include/iso.hpp b/Types/ISO/include/iso.hpp index c19f73e7..01c07d6a 100644 --- a/Types/ISO/include/iso.hpp +++ b/Types/ISO/include/iso.hpp @@ -41,6 +41,10 @@ class ISOFile : public TypeInterface, public View::ContainerViewer::EnumerateInt { } + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } virtual bool BeginIteration(std::u16string_view path, AppCUI::Controls::TreeViewItem parent) override; virtual bool PopulateItem(TreeViewItem item) override; virtual void OnOpenItem(std::u16string_view path, AppCUI::Controls::TreeViewItem item) override; diff --git a/Types/JCLASS/src/jclass.hpp b/Types/JCLASS/src/jclass.hpp index e7ba242f..0680f77f 100644 --- a/Types/JCLASS/src/jclass.hpp +++ b/Types/JCLASS/src/jclass.hpp @@ -10,5 +10,9 @@ class ClassViewer : public TypeInterface public: string_view GetTypeName() override; void RunCommand(std::string_view) override; + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } }; } // namespace GView::Type::JClass diff --git a/Types/JOB/include/JOB.hpp b/Types/JOB/include/JOB.hpp index c422e3a0..0c1489d8 100644 --- a/Types/JOB/include/JOB.hpp +++ b/Types/JOB/include/JOB.hpp @@ -30,6 +30,10 @@ class JOBFile : public TypeInterface void RunCommand(std::string_view) override { } + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } public: Reference selectionZoneInterface; diff --git a/Types/JS/include/js.hpp b/Types/JS/include/js.hpp index e317c078..dc7daafd 100644 --- a/Types/JS/include/js.hpp +++ b/Types/JS/include/js.hpp @@ -469,6 +469,10 @@ namespace Type void RunCommand(std::string_view) override { } + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } virtual void GetTokenIDStringRepresentation(uint32 id, AppCUI::Utils::String& str) override; virtual void PreprocessText(GView::View::LexicalViewer::TextEditor& editor) override; virtual void AnalyzeText(GView::View::LexicalViewer::SyntaxManager& syntax) override; diff --git a/Types/JSON/include/json.hpp b/Types/JSON/include/json.hpp index 35dada51..9de1dbc3 100644 --- a/Types/JSON/include/json.hpp +++ b/Types/JSON/include/json.hpp @@ -53,6 +53,10 @@ namespace Type void RunCommand(std::string_view) override { } + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } virtual void GetTokenIDStringRepresentation(uint32 id, AppCUI::Utils::String& str) override; virtual void PreprocessText(GView::View::LexicalViewer::TextEditor& editor) override; virtual void AnalyzeText(GView::View::LexicalViewer::SyntaxManager& syntax) override; diff --git a/Types/JT/include/JT.hpp b/Types/JT/include/JT.hpp index 294dae0d..da6976c8 100644 --- a/Types/JT/include/JT.hpp +++ b/Types/JT/include/JT.hpp @@ -32,6 +32,10 @@ class JTFile : public TypeInterface void RunCommand(std::string_view) override { } + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } public: Reference selectionZoneInterface; diff --git a/Types/LNK/include/LNK.hpp b/Types/LNK/include/LNK.hpp index ba0c4f82..9afa86ff 100644 --- a/Types/LNK/include/LNK.hpp +++ b/Types/LNK/include/LNK.hpp @@ -44,6 +44,10 @@ class LNKFile : public TypeInterface void RunCommand(std::string_view) override { } + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } public: Reference selectionZoneInterface; diff --git a/Types/MACHO/include/MachO.hpp b/Types/MACHO/include/MachO.hpp index e4c26e39..eca7d98b 100644 --- a/Types/MACHO/include/MachO.hpp +++ b/Types/MACHO/include/MachO.hpp @@ -237,8 +237,9 @@ class MachOFile : public TypeInterface, virtual bool BeginIteration(std::u16string_view path, AppCUI::Controls::TreeViewItem parent) override; virtual bool PopulateItem(TreeViewItem item) override; virtual void OnOpenItem(std::u16string_view path, AppCUI::Controls::TreeViewItem item) override; + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override; - private: +private: bool ComputeHash(const Buffer& buffer, uint8 hashType, std::string& output) const; bool GetColorForBuffer(uint64 offset, BufferView buf, GView::View::BufferViewer::BufferColor& result) override; diff --git a/Types/MACHO/src/MachOFile.cpp b/Types/MACHO/src/MachOFile.cpp index 3c155837..9c15c75d 100644 --- a/Types/MACHO/src/MachOFile.cpp +++ b/Types/MACHO/src/MachOFile.cpp @@ -1171,6 +1171,13 @@ void MachOFile::OnOpenItem(std::u16string_view, AppCUI::Controls::TreeViewItem i GView::App::OpenBuffer(buffer, data->info.name, fullPath, GView::App::OpenMethod::BestMatch); } +bool MachOFile::UpdateKeys(KeyboardControlsInterface* interface) +{ + for (auto& entry : Commands::MACHO_COMMANDS) + interface->RegisterKey(&entry); + return true; +} + bool MachOFile::GetColorForBufferIntel(uint64 offset, BufferView buf, GView::View::BufferViewer::BufferColor& result) { const auto* p = buf.begin(); diff --git a/Types/MAM/include/MAM.hpp b/Types/MAM/include/MAM.hpp index b05612e2..bf6b0a04 100644 --- a/Types/MAM/include/MAM.hpp +++ b/Types/MAM/include/MAM.hpp @@ -49,6 +49,7 @@ class MAMFile : public TypeInterface return selectionZoneInterface->GetSelectionZone(index); } + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override; }; namespace Panels diff --git a/Types/MAM/src/MAMFile.cpp b/Types/MAM/src/MAMFile.cpp index 9c797d61..a54d51c6 100644 --- a/Types/MAM/src/MAMFile.cpp +++ b/Types/MAM/src/MAMFile.cpp @@ -21,6 +21,13 @@ void MAMFile::RunCommand(std::string_view commandName) } } +bool MAMFile::UpdateKeys(KeyboardControlsInterface* interface) +{ + for (auto& entry : MAM_COMMANDS) + interface->RegisterKey(&entry); + return true; +} + bool MAMFile::Decompress() { Buffer uncompressed; diff --git a/Types/PCAP/include/PCAP.hpp b/Types/PCAP/include/PCAP.hpp index 8e9bd0e5..777feca2 100644 --- a/Types/PCAP/include/PCAP.hpp +++ b/Types/PCAP/include/PCAP.hpp @@ -33,6 +33,10 @@ class PCAPFile : public TypeInterface, public View::ContainerViewer::EnumerateIn virtual bool BeginIteration(std::u16string_view path, AppCUI::Controls::TreeViewItem parent) override; virtual bool PopulateItem(TreeViewItem item) override; virtual void OnOpenItem(std::u16string_view path, AppCUI::Controls::TreeViewItem item) override; + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } public: Reference selectionZoneInterface; diff --git a/Types/PREFETCH/include/Prefetch.hpp b/Types/PREFETCH/include/Prefetch.hpp index 04255c4f..b05a6495 100644 --- a/Types/PREFETCH/include/Prefetch.hpp +++ b/Types/PREFETCH/include/Prefetch.hpp @@ -111,6 +111,10 @@ class PrefetchFile : public TypeInterface return selectionZoneInterface->GetSelectionZone(index); } + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } }; namespace Panels diff --git a/Types/PYEXTRACTOR/include/pyextractor.hpp b/Types/PYEXTRACTOR/include/pyextractor.hpp index 4e1943ef..d8966dbb 100644 --- a/Types/PYEXTRACTOR/include/pyextractor.hpp +++ b/Types/PYEXTRACTOR/include/pyextractor.hpp @@ -92,6 +92,10 @@ class PYEXTRACTORFile : public TypeInterface, public View::ContainerViewer::Enum virtual bool BeginIteration(std::u16string_view path, AppCUI::Controls::TreeViewItem parent) override; virtual bool PopulateItem(TreeViewItem item) override; virtual void OnOpenItem(std::u16string_view path, AppCUI::Controls::TreeViewItem item) override; + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } private: bool SetCookiePosition(); diff --git a/Types/SQLite/include/sqlite.hpp b/Types/SQLite/include/sqlite.hpp index 1ea5f551..cbef6e23 100644 --- a/Types/SQLite/include/sqlite.hpp +++ b/Types/SQLite/include/sqlite.hpp @@ -24,6 +24,11 @@ class SQLiteFile : public TypeInterface void GetStatementResult(const std::string_view& entity, bool fromTable); virtual void RunCommand(std::string_view commandName) override; + + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } }; namespace Panels diff --git a/Types/VBA/include/vba.hpp b/Types/VBA/include/vba.hpp index cd1216d8..79093695 100644 --- a/Types/VBA/include/vba.hpp +++ b/Types/VBA/include/vba.hpp @@ -29,6 +29,10 @@ namespace Type virtual void AnalyzeText(GView::View::LexicalViewer::SyntaxManager& syntax) override; virtual bool StringToContent(std::u16string_view string, AppCUI::Utils::UnicodeStringBuilder& result) override; virtual bool ContentToString(std::u16string_view content, AppCUI::Utils::UnicodeStringBuilder& result) override; + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } public: Reference selectionZoneInterface; diff --git a/Types/ZIP/include/zip.hpp b/Types/ZIP/include/zip.hpp index f690bd50..b5da1ce1 100644 --- a/Types/ZIP/include/zip.hpp +++ b/Types/ZIP/include/zip.hpp @@ -51,6 +51,11 @@ class ZIPFile : public TypeInterface, public View::ContainerViewer::EnumerateInt return selectionZoneInterface->GetSelectionZone(index); } + + virtual bool UpdateKeys(KeyboardControlsInterface* interface) override + { + return true; + } }; namespace Panels