マウス対応の追加

This commit is contained in:
2026-05-03 19:10:35 +09:00
parent 7bd77a0da6
commit 07d377fbe8
5 changed files with 53 additions and 2 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
.svn .svn
hexagon hexagon
hexagon.exe

View File

@@ -1,3 +1,7 @@
## 1.2.0 (2026年05月03日)
* Debianでコンパイル出来る様に
* マウス対応の追加
## 1.1.0 (2025年12月28日) ## 1.1.0 (2025年12月28日)
* PgUp・PgDownで使ってページを動ける様に * PgUp・PgDownで使ってページを動ける様に
* ^、0、又はHOME、及び$又はENDキーで使って同じ行列で最初や最後のHEXや文字に移動ける様に * ^、0、又はHOME、及び$又はENDキーで使って同じ行列で最初や最後のHEXや文字に移動ける様に

View File

@@ -26,7 +26,7 @@ ARCH = powerpc
.endif .endif
NAME = hexagon NAME = hexagon
VERSION = 1.0.0 VERSION = 1.2.0
PREFIX = /usr/local PREFIX = /usr/local
.if ${OS} == "linux" .if ${OS} == "linux"
@@ -52,6 +52,10 @@ all:
${CC} -O3 ${CFLAGS} -o ${NAME} ${FILES} -std=c++17 -static ${LDFLAGS} ${CC} -O3 ${CFLAGS} -o ${NAME} ${FILES} -std=c++17 -static ${LDFLAGS}
strip ${NAME} strip ${NAME}
debian:
${CC} -O3 ${CFLAGS} -o ${NAME} ${FILES} -std=c++17 -static ${LDFLAGS} -ltinfo
strip ${NAME}
debug: debug:
${CC} -g ${CFLAGS} -o ${NAME} ${FILES} -std=c++17 ${LDFLAGS} ${CC} -g ${CFLAGS} -o ${NAME} ${FILES} -std=c++17 ${LDFLAGS}

View File

@@ -101,6 +101,10 @@ HexEditor::HexEditor(const std::string &filename)
raw(); raw();
start_color(); start_color();
// マウス対応
mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, nullptr);
isMouse = true;
init_pair(1, COLOR_BLACK, COLOR_WHITE); // カーソル init_pair(1, COLOR_BLACK, COLOR_WHITE); // カーソル
init_pair(2, COLOR_BLACK, COLOR_GREEN); // 変更 init_pair(2, COLOR_BLACK, COLOR_GREEN); // 変更
init_pair(3, COLOR_BLACK, COLOR_MAGENTA); // 普通 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() { void HexEditor::topbar() {
int colorPair = 3; int colorPair = 3;
std::string status = "Hexagon 1.1.0"; std::string status = "Hexagon 1.2.0";
if (!headerType.empty()) status += " | FILETYPE: " + headerType; if (!headerType.empty()) status += " | FILETYPE: " + headerType;
std::wstring wstatus(status.begin(), status.end()); std::wstring wstatus(status.begin(), status.end());
@@ -758,6 +762,39 @@ void HexEditor::handleReplace() {
render(); 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() { void HexEditor::undo() {
if (undoStack.empty()) { if (undoStack.empty()) {
statusMode = Status_Error; statusMode = Status_Error;
@@ -883,6 +920,9 @@ void HexEditor::input() {
handleSave(); handleSave();
if (statusMode == Status_Error) statusMode = Status_Normal; if (statusMode == Status_Error) statusMode = Status_Normal;
} }
} else if (ch == KEY_MOUSE) {
handleMouse();
continue;
} }
// 画面の動き // 画面の動き

View File

@@ -78,6 +78,7 @@ class HexEditor {
bool modified; bool modified;
bool running; bool running;
std::string lastSearch; std::string lastSearch;
bool isMouse = false;
WINDOW *hexPanel; WINDOW *hexPanel;
WINDOW *asciiPanel; WINDOW *asciiPanel;
@@ -108,6 +109,7 @@ class HexEditor {
void findNextMatch(); void findNextMatch();
void findPrevMatch(); void findPrevMatch();
void handleReplace(); void handleReplace();
void handleMouse();
void undo(); void undo();
void redo(); void redo();