Skip to content

Commit

Permalink
enforced the new keyboard interface for all commands #326
Browse files Browse the repository at this point in the history
  • Loading branch information
rzaharia committed Jul 30, 2024
1 parent 903d6e3 commit 0189c54
Show file tree
Hide file tree
Showing 27 changed files with 110 additions and 5 deletions.
6 changes: 2 additions & 4 deletions GViewCore/include/GView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions GViewCore/src/Type/DefaultTypePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class DefaultType : public TypeInterface
void RunCommand(std::string_view) override
{
}
bool UpdateKeys(KeyboardControlsInterface* interface) override
{
return true;
}

~DefaultType()
{
}
Expand Down
4 changes: 4 additions & 0 deletions GViewCore/src/Type/FolderViewPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions Types/BMP/include/bmp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions Types/CPP/include/cpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions Types/CSV/include/csv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ namespace Type
void RunCommand(std::string_view) override
{
}
bool UpdateKeys(KeyboardControlsInterface* interface) override
{
return true;
}
bool Update(Reference<GView::Object> obj);
bool HasPanel(Panels::IDs id);
void UpdateBufferViewZones(GView::View::BufferViewer::Settings& settings);
Expand Down
4 changes: 4 additions & 0 deletions Types/ELF/include/elf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<GView::Utils::SelectionZoneInterface> selectionZoneInterface;
Expand Down
4 changes: 4 additions & 0 deletions Types/EML/include/eml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

};

Expand Down
4 changes: 4 additions & 0 deletions Types/ICO/include/ico.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions Types/INI/include/ini.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions Types/ISO/include/iso.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions Types/JCLASS/src/jclass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions Types/JOB/include/JOB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class JOBFile : public TypeInterface
void RunCommand(std::string_view) override
{
}
virtual bool UpdateKeys(KeyboardControlsInterface* interface) override
{
return true;
}

public:
Reference<GView::Utils::SelectionZoneInterface> selectionZoneInterface;
Expand Down
4 changes: 4 additions & 0 deletions Types/JS/include/js.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions Types/JSON/include/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions Types/JT/include/JT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class JTFile : public TypeInterface
void RunCommand(std::string_view) override
{
}
virtual bool UpdateKeys(KeyboardControlsInterface* interface) override
{
return true;
}

public:
Reference<GView::Utils::SelectionZoneInterface> selectionZoneInterface;
Expand Down
4 changes: 4 additions & 0 deletions Types/LNK/include/LNK.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class LNKFile : public TypeInterface
void RunCommand(std::string_view) override
{
}
virtual bool UpdateKeys(KeyboardControlsInterface* interface) override
{
return true;
}

public:
Reference<GView::Utils::SelectionZoneInterface> selectionZoneInterface;
Expand Down
3 changes: 2 additions & 1 deletion Types/MACHO/include/MachO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions Types/MACHO/src/MachOFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions Types/MAM/include/MAM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class MAMFile : public TypeInterface

return selectionZoneInterface->GetSelectionZone(index);
}
virtual bool UpdateKeys(KeyboardControlsInterface* interface) override;
};

namespace Panels
Expand Down
7 changes: 7 additions & 0 deletions Types/MAM/src/MAMFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions Types/PCAP/include/PCAP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<GView::Utils::SelectionZoneInterface> selectionZoneInterface;
Expand Down
4 changes: 4 additions & 0 deletions Types/PREFETCH/include/Prefetch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ class PrefetchFile : public TypeInterface

return selectionZoneInterface->GetSelectionZone(index);
}
virtual bool UpdateKeys(KeyboardControlsInterface* interface) override
{
return true;
}
};

namespace Panels
Expand Down
4 changes: 4 additions & 0 deletions Types/PYEXTRACTOR/include/pyextractor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions Types/SQLite/include/sqlite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Types/VBA/include/vba.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<GView::Utils::SelectionZoneInterface> selectionZoneInterface;
Expand Down
5 changes: 5 additions & 0 deletions Types/ZIP/include/zip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0189c54

Please sign in to comment.