From 07d377fbe825e83315379250d33e47fbbab3df1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Sun, 3 May 2026 19:10:35 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=9E=E3=82=A6=E3=82=B9=E5=AF=BE=E5=BF=9C?= =?UTF-8?q?=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + CHANGELOG.md | 4 ++++ Makefile | 6 +++++- src/hexeditor.cc | 42 +++++++++++++++++++++++++++++++++++++++++- src/hexeditor.hh | 2 ++ 5 files changed, 53 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 479b8ea..4437c0f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .svn hexagon +hexagon.exe diff --git a/CHANGELOG.md b/CHANGELOG.md index 98c55e0..a801bfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.0 (2026年05月03日) +* Debianでコンパイル出来る様に +* マウス対応の追加 + ## 1.1.0 (2025年12月28日) * PgUp・PgDownで使ってページを動ける様に * ^、0、又はHOME、及び$又はENDキーで使って同じ行列で最初や最後のHEXや文字に移動ける様に diff --git a/Makefile b/Makefile index 462420a..627da9d 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ ARCH = powerpc .endif NAME = hexagon -VERSION = 1.0.0 +VERSION = 1.2.0 PREFIX = /usr/local .if ${OS} == "linux" @@ -52,6 +52,10 @@ all: ${CC} -O3 ${CFLAGS} -o ${NAME} ${FILES} -std=c++17 -static ${LDFLAGS} strip ${NAME} +debian: + ${CC} -O3 ${CFLAGS} -o ${NAME} ${FILES} -std=c++17 -static ${LDFLAGS} -ltinfo + strip ${NAME} + debug: ${CC} -g ${CFLAGS} -o ${NAME} ${FILES} -std=c++17 ${LDFLAGS} diff --git a/src/hexeditor.cc b/src/hexeditor.cc index b557bf6..8086b25 100644 --- a/src/hexeditor.cc +++ b/src/hexeditor.cc @@ -101,6 +101,10 @@ HexEditor::HexEditor(const std::string &filename) raw(); start_color(); + // マウス対応 + mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, nullptr); + isMouse = true; + init_pair(1, COLOR_BLACK, COLOR_WHITE); // カーソル init_pair(2, COLOR_BLACK, COLOR_GREEN); // 変更 init_pair(3, COLOR_BLACK, COLOR_MAGENTA); // 普通 @@ -182,7 +186,7 @@ void HexEditor::highlightcol(size_t i, size_t row, uint8_t byte) { void HexEditor::topbar() { int colorPair = 3; - std::string status = "Hexagon 1.1.0"; + std::string status = "Hexagon 1.2.0"; if (!headerType.empty()) status += " | FILETYPE: " + headerType; std::wstring wstatus(status.begin(), status.end()); @@ -758,6 +762,39 @@ void HexEditor::handleReplace() { render(); } +void HexEditor::handleMouse() { + MEVENT event; + if (getmouse(&event) != OK) return; + if (!(event.bstate & BUTTON1_PRESSED)) return; + + int mx = event.x; + int my = event.y; + if (my == 0 || my == rows - 1) return; + + if (my >= 1 && my < rows - 2 && mx < cols / 2) { + // HEXパネル + int panelRow = my - 1; + int panelCol = mx; + if (panelCol < 10) return; + + int i = (panelCol - 10) / 3; + size_t offset = dpOffset + panelRow * bpr + i; + if (offset < buf.size()) { + curPos = offset; + render(); + } + } else if (my >= 1 && my < rows - 2 && mx >= cols / 2) { + // ASCIIパネル + int panelRow = my - 1; + int i = mx - cols / 2; + size_t offset = dpOffset + panelRow * bpr + i; + if (offset < buf.size()) { + curPos = offset; + render(); + } + } +} + void HexEditor::undo() { if (undoStack.empty()) { statusMode = Status_Error; @@ -883,6 +920,9 @@ void HexEditor::input() { handleSave(); if (statusMode == Status_Error) statusMode = Status_Normal; } + } else if (ch == KEY_MOUSE) { + handleMouse(); + continue; } // 画面の動き diff --git a/src/hexeditor.hh b/src/hexeditor.hh index b777dda..b09e254 100644 --- a/src/hexeditor.hh +++ b/src/hexeditor.hh @@ -78,6 +78,7 @@ class HexEditor { bool modified; bool running; std::string lastSearch; + bool isMouse = false; WINDOW *hexPanel; WINDOW *asciiPanel; @@ -108,6 +109,7 @@ class HexEditor { void findNextMatch(); void findPrevMatch(); void handleReplace(); + void handleMouse(); void undo(); void redo();