impr: Improve code quality
This commit is contained in:
parent
6b645192d4
commit
55d7d7c026
2
.github/workflows/analysis.yml
vendored
2
.github/workflows/analysis.yml
vendored
@ -38,7 +38,7 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
build/CMakeCache.txt
|
build/CMakeCache.txt
|
||||||
key: ${{ runner.os }}-analysis-${{ secrets.CACHE_VERSION }}-build-${{ hashFiles('**/CMakeLists.txt') }}
|
key: ${{ runner.os }}-analysis-${{ secrets.CACHE_VERSION }}-build-${{ hashFiles('**/CMakeLists.txt') }}
|
||||||
|
|
||||||
- name: ⬇️ Install dependencies
|
- name: ⬇️ Install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
|
10
.github/workflows/release.yml
vendored
10
.github/workflows/release.yml
vendored
@ -34,7 +34,7 @@ jobs:
|
|||||||
|
|
||||||
- name: 🗜️ Create tarball from sources with dependencies
|
- name: 🗜️ Create tarball from sources with dependencies
|
||||||
run: tar --exclude-vcs -czvf Full.Sources.tar.gz ImHex
|
run: tar --exclude-vcs -czvf Full.Sources.tar.gz ImHex
|
||||||
|
|
||||||
- name: ⬇️ Download artifacts from latest workflow
|
- name: ⬇️ Download artifacts from latest workflow
|
||||||
uses: dawidd6/action-download-artifact@v2
|
uses: dawidd6/action-download-artifact@v2
|
||||||
with:
|
with:
|
||||||
@ -43,7 +43,7 @@ jobs:
|
|||||||
branch: ${{ github.event.release.target_commitish }}
|
branch: ${{ github.event.release.target_commitish }}
|
||||||
workflow_conclusion: success
|
workflow_conclusion: success
|
||||||
skip_unpack: true
|
skip_unpack: true
|
||||||
|
|
||||||
- name: 🗜️ Unzip files when needed
|
- name: 🗜️ Unzip files when needed
|
||||||
run: |
|
run: |
|
||||||
for zipfile in ./*.zip
|
for zipfile in ./*.zip
|
||||||
@ -71,14 +71,14 @@ jobs:
|
|||||||
- name: ✒️ Prepare PKGBUILD
|
- name: ✒️ Prepare PKGBUILD
|
||||||
run: |
|
run: |
|
||||||
cp ImHex/dist/Arch/PKGBUILD .
|
cp ImHex/dist/Arch/PKGBUILD .
|
||||||
|
|
||||||
hash=`md5sum imhex-${{env.IMHEX_VERSION}}-ArchLinux.pkg.tar.zst-x86_64 | cut -d ' ' -f 1`
|
hash=`md5sum imhex-${{env.IMHEX_VERSION}}-ArchLinux.pkg.tar.zst-x86_64 | cut -d ' ' -f 1`
|
||||||
|
|
||||||
sed -i 's/%version%/${{env.IMHEX_VERSION}}/g' PKGBUILD
|
sed -i 's/%version%/${{env.IMHEX_VERSION}}/g' PKGBUILD
|
||||||
sed -i "s/(SKIP)/($hash)/g" PKGBUILD
|
sed -i "s/(SKIP)/($hash)/g" PKGBUILD
|
||||||
|
|
||||||
- name: ⬆️ Publish AUR package
|
- name: ⬆️ Publish AUR package
|
||||||
|
|
||||||
# I couldn't make the condition in the env directly for some reason
|
# I couldn't make the condition in the env directly for some reason
|
||||||
env:
|
env:
|
||||||
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||||
@ -113,7 +113,7 @@ jobs:
|
|||||||
tag: ImHex-v${{env.IMHEX_VERSION}}
|
tag: ImHex-v${{env.IMHEX_VERSION}}
|
||||||
repo: ImHex-Patterns
|
repo: ImHex-Patterns
|
||||||
token: ${{ secrets.RELEASE_TOKEN }}
|
token: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
|
||||||
- name: ✉️ Update C++ Plugin Template
|
- name: ✉️ Update C++ Plugin Template
|
||||||
uses: peter-evans/repository-dispatch@v2
|
uses: peter-evans/repository-dispatch@v2
|
||||||
env:
|
env:
|
||||||
|
4
.github/workflows/tests.yml
vendored
4
.github/workflows/tests.yml
vendored
@ -28,7 +28,7 @@ jobs:
|
|||||||
key: ${{ runner.os }}-tests-${{ secrets.CACHE_VERSION }}-build-${{ github.run_id }}
|
key: ${{ runner.os }}-tests-${{ secrets.CACHE_VERSION }}-build-${{ github.run_id }}
|
||||||
restore-keys: ${{ runner.os }}-tests-${{ secrets.CACHE_VERSION }}-build
|
restore-keys: ${{ runner.os }}-tests-${{ secrets.CACHE_VERSION }}-build
|
||||||
max-size: 50M
|
max-size: 50M
|
||||||
|
|
||||||
|
|
||||||
- name: 📜 Restore CMakeCache
|
- name: 📜 Restore CMakeCache
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
@ -36,7 +36,7 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
build/CMakeCache.txt
|
build/CMakeCache.txt
|
||||||
key: ${{ runner.os }}-tests-${{ secrets.CACHE_VERSION }}-build-${{ hashFiles('**/CMakeLists.txt') }}
|
key: ${{ runner.os }}-tests-${{ secrets.CACHE_VERSION }}-build-${{ hashFiles('**/CMakeLists.txt') }}
|
||||||
|
|
||||||
- name: ⬇️ Install dependencies
|
- name: ⬇️ Install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
|
@ -22,7 +22,6 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
class PopupGoto : public ViewHexEditor::Popup {
|
class PopupGoto : public ViewHexEditor::Popup {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void draw(ViewHexEditor *editor) override {
|
void draw(ViewHexEditor *editor) override {
|
||||||
ImGui::TextUnformatted("hex.builtin.view.hex_editor.menu.file.goto"_lang);
|
ImGui::TextUnformatted("hex.builtin.view.hex_editor.menu.file.goto"_lang);
|
||||||
if (ImGui::BeginTabBar("goto_tabs")) {
|
if (ImGui::BeginTabBar("goto_tabs")) {
|
||||||
@ -109,7 +108,6 @@ namespace hex::plugin::builtin {
|
|||||||
void draw(ViewHexEditor *editor) override {
|
void draw(ViewHexEditor *editor) override {
|
||||||
ImGui::TextUnformatted("hex.builtin.view.hex_editor.menu.file.select"_lang);
|
ImGui::TextUnformatted("hex.builtin.view.hex_editor.menu.file.select"_lang);
|
||||||
if (ImGui::BeginTabBar("select_tabs")) {
|
if (ImGui::BeginTabBar("select_tabs")) {
|
||||||
|
|
||||||
if (ImGui::BeginTabItem("hex.builtin.view.hex_editor.select.offset.region"_lang)) {
|
if (ImGui::BeginTabItem("hex.builtin.view.hex_editor.select.offset.region"_lang)) {
|
||||||
u64 inputA = this->m_region.getStartAddress();
|
u64 inputA = this->m_region.getStartAddress();
|
||||||
u64 inputB = this->m_region.getEndAddress();
|
u64 inputB = this->m_region.getEndAddress();
|
||||||
@ -336,9 +334,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
class PopupBaseAddress : public ViewHexEditor::Popup {
|
class PopupBaseAddress : public ViewHexEditor::Popup {
|
||||||
public:
|
public:
|
||||||
explicit PopupBaseAddress(u64 baseAddress) : m_baseAddress(baseAddress) {
|
explicit PopupBaseAddress(u64 baseAddress) : m_baseAddress(baseAddress) { }
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw(ViewHexEditor *editor) override {
|
void draw(ViewHexEditor *editor) override {
|
||||||
ImGui::TextUnformatted("hex.builtin.view.hex_editor.menu.edit.set_base"_lang);
|
ImGui::TextUnformatted("hex.builtin.view.hex_editor.menu.edit.set_base"_lang);
|
||||||
@ -547,7 +543,6 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
ImGui::SetNextWindowPos(ImGui::GetWindowPos() + ImGui::GetWindowContentRegionMin() - ImGui::GetStyle().WindowPadding, ImGuiCond_Appearing);
|
ImGui::SetNextWindowPos(ImGui::GetWindowPos() + ImGui::GetWindowContentRegionMin() - ImGui::GetStyle().WindowPadding, ImGuiCond_Appearing);
|
||||||
if (ImGui::BeginPopup("##hex_editor_popup", ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize |ImGuiWindowFlags_NoTitleBar)) {
|
if (ImGui::BeginPopup("##hex_editor_popup", ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize |ImGuiWindowFlags_NoTitleBar)) {
|
||||||
|
|
||||||
// Force close the popup when user is editing an input
|
// Force close the popup when user is editing an input
|
||||||
if(ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape))){
|
if(ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape))){
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
@ -568,7 +563,6 @@ namespace hex::plugin::builtin {
|
|||||||
ImGui::OpenPopup("hex.builtin.menu.edit"_lang);
|
ImGui::OpenPopup("hex.builtin.menu.edit"_lang);
|
||||||
|
|
||||||
if (ImGui::BeginPopup("hex.builtin.menu.edit"_lang)) {
|
if (ImGui::BeginPopup("hex.builtin.menu.edit"_lang)) {
|
||||||
|
|
||||||
bool needsSeparator = false;
|
bool needsSeparator = false;
|
||||||
for (auto &[priority, menuItem] : ContentRegistry::Interface::getMenuItems()) {
|
for (auto &[priority, menuItem] : ContentRegistry::Interface::getMenuItems()) {
|
||||||
if (menuItem.unlocalizedName != "hex.builtin.menu.edit")
|
if (menuItem.unlocalizedName != "hex.builtin.menu.edit")
|
||||||
@ -586,7 +580,6 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ViewHexEditor::drawContent() {
|
void ViewHexEditor::drawContent() {
|
||||||
|
|
||||||
if (ImGui::Begin(View::toWindowName(this->getUnlocalizedName()).c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
|
if (ImGui::Begin(View::toWindowName(this->getUnlocalizedName()).c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
|
||||||
this->m_hexEditor.setProvider(ImHexApi::Provider::get());
|
this->m_hexEditor.setProvider(ImHexApi::Provider::get());
|
||||||
|
|
||||||
@ -675,7 +668,6 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ViewHexEditor::registerShortcuts() {
|
void ViewHexEditor::registerShortcuts() {
|
||||||
|
|
||||||
// Save operations
|
// Save operations
|
||||||
ShortcutManager::addShortcut(this, CTRLCMD + Keys::S, [] {
|
ShortcutManager::addShortcut(this, CTRLCMD + Keys::S, [] {
|
||||||
save();
|
save();
|
||||||
@ -779,7 +771,6 @@ namespace hex::plugin::builtin {
|
|||||||
this->setSelection(selection.getStartAddress() + this->m_hexEditor.getBytesPerRow(), selection.getEndAddress());
|
this->setSelection(selection.getStartAddress() + this->m_hexEditor.getBytesPerRow(), selection.getEndAddress());
|
||||||
this->m_hexEditor.scrollToSelection();
|
this->m_hexEditor.scrollToSelection();
|
||||||
this->m_hexEditor.jumpIfOffScreen();
|
this->m_hexEditor.jumpIfOffScreen();
|
||||||
|
|
||||||
});
|
});
|
||||||
ShortcutManager::addShortcut(this, SHIFT + Keys::Left, [this] {
|
ShortcutManager::addShortcut(this, SHIFT + Keys::Left, [this] {
|
||||||
auto selection = getSelection();
|
auto selection = getSelection();
|
||||||
@ -989,7 +980,6 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
auto &customEncoding = this->m_hexEditor.getCustomEncoding();
|
auto &customEncoding = this->m_hexEditor.getCustomEncoding();
|
||||||
if (ImGui::MenuItem("hex.builtin.view.hex_editor.copy.custom_encoding"_lang, "", false, customEncoding.has_value())) {
|
if (ImGui::MenuItem("hex.builtin.view.hex_editor.copy.custom_encoding"_lang, "", false, customEncoding.has_value())) {
|
||||||
|
|
||||||
std::vector<u8> buffer(customEncoding->getLongestSequence(), 0x00);
|
std::vector<u8> buffer(customEncoding->getLongestSequence(), 0x00);
|
||||||
std::string string;
|
std::string string;
|
||||||
|
|
||||||
|
@ -155,9 +155,7 @@ namespace hex::plugin::builtin::ui {
|
|||||||
if (padding.is_number())
|
if (padding.is_number())
|
||||||
this->m_characterCellPadding = static_cast<int>(padding);
|
this->m_characterCellPadding = static_cast<int>(padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HexEditor::~HexEditor() {
|
HexEditor::~HexEditor() {
|
||||||
@ -277,7 +275,6 @@ namespace hex::plugin::builtin::ui {
|
|||||||
shouldExitEditingMode = asciiVisualizer.drawEditing(*this->m_editingAddress, this->m_editingBytes.data(), this->m_editingBytes.size(), this->m_upperCaseHex, this->m_enteredEditingMode);
|
shouldExitEditingMode = asciiVisualizer.drawEditing(*this->m_editingAddress, this->m_editingBytes.data(), this->m_editingBytes.size(), this->m_upperCaseHex, this->m_enteredEditingMode);
|
||||||
|
|
||||||
if (shouldExitEditingMode || this->m_shouldModifyValue) {
|
if (shouldExitEditingMode || this->m_shouldModifyValue) {
|
||||||
|
|
||||||
this->m_provider->write(*this->m_editingAddress, this->m_editingBytes.data(), this->m_editingBytes.size());
|
this->m_provider->write(*this->m_editingAddress, this->m_editingBytes.data(), this->m_editingBytes.size());
|
||||||
|
|
||||||
if (!this->m_selectionChanged && !ImGui::IsMouseDown(ImGuiMouseButton_Left) && !ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
if (!this->m_selectionChanged && !ImGui::IsMouseDown(ImGuiMouseButton_Left) && !ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
||||||
@ -378,7 +375,6 @@ namespace hex::plugin::builtin::ui {
|
|||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|
||||||
if (this->m_provider != nullptr && this->m_provider->isReadable()) {
|
if (this->m_provider != nullptr && this->m_provider->isReadable()) {
|
||||||
|
|
||||||
const auto isCurrRegionValid = [this](u64 address){
|
const auto isCurrRegionValid = [this](u64 address){
|
||||||
auto &[currRegion, currRegionValid] = this->m_currValidRegion;
|
auto &[currRegion, currRegionValid] = this->m_currValidRegion;
|
||||||
if (!Region{ address, 1 }.isWithin(currRegion)) {
|
if (!Region{ address, 1 }.isWithin(currRegion)) {
|
||||||
@ -396,7 +392,6 @@ namespace hex::plugin::builtin::ui {
|
|||||||
|
|
||||||
// Loop over rows
|
// Loop over rows
|
||||||
for (u64 y = u64(clipper.DisplayStart); y < u64(clipper.DisplayEnd); y++) {
|
for (u64 y = u64(clipper.DisplayStart); y < u64(clipper.DisplayEnd); y++) {
|
||||||
|
|
||||||
// Draw address column
|
// Draw address column
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
@ -610,7 +605,6 @@ namespace hex::plugin::builtin::ui {
|
|||||||
}
|
}
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scroll to the cursor if it's either at the top or bottom edge of the screen
|
// Scroll to the cursor if it's either at the top or bottom edge of the screen
|
||||||
@ -623,7 +617,6 @@ namespace hex::plugin::builtin::ui {
|
|||||||
if (i128(this->m_selectionEnd.value() - this->m_provider->getBaseAddress() - this->m_provider->getCurrentPageAddress()) <= (i64(clipper.DisplayStart + 3) * this->m_bytesPerRow)) {
|
if (i128(this->m_selectionEnd.value() - this->m_provider->getBaseAddress() - this->m_provider->getCurrentPageAddress()) <= (i64(clipper.DisplayStart + 3) * this->m_bytesPerRow)) {
|
||||||
this->m_shouldScrollToSelection = false;
|
this->m_shouldScrollToSelection = false;
|
||||||
ImGui::SetScrollHereY(fractionPerLine * 5);
|
ImGui::SetScrollHereY(fractionPerLine * 5);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if (y == (u64(clipper.DisplayEnd) - 1)) {
|
} else if (y == (u64(clipper.DisplayEnd) - 1)) {
|
||||||
if (i128(this->m_selectionEnd.value() - this->m_provider->getBaseAddress() - this->m_provider->getCurrentPageAddress()) >= (i64(clipper.DisplayEnd - 2) * this->m_bytesPerRow)) {
|
if (i128(this->m_selectionEnd.value() - this->m_provider->getBaseAddress() - this->m_provider->getCurrentPageAddress()) >= (i64(clipper.DisplayEnd - 2) * this->m_bytesPerRow)) {
|
||||||
@ -645,7 +638,6 @@ namespace hex::plugin::builtin::ui {
|
|||||||
this->jumpToSelection(false);
|
this->jumpToSelection(false);
|
||||||
if ((newSelection.getEndAddress()) > u64(clipper.DisplayEnd * this->m_bytesPerRow))
|
if ((newSelection.getEndAddress()) > u64(clipper.DisplayEnd * this->m_bytesPerRow))
|
||||||
this->jumpToSelection(false);
|
this->jumpToSelection(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -759,7 +751,6 @@ namespace hex::plugin::builtin::ui {
|
|||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user