マウス対応の追加

諏訪子 <suwako@076.moe>、2026-05-03 19:10
コミット 07d377fbe825e83315379250d33e47fbbab3df1f ・親 7bd77a0 ・ファイルを見る

5個のファイル、+53 -2

変更 .gitignore
@@ -1,2 +1,3 @@
11 .svn
22 hexagon
3+hexagon.exe
変更 CHANGELOG.md
@@ -1,3 +1,7 @@
1+## 1.2.0 (2026年05月03日)
2+* Debianでコンパイル出来る様に
3+* マウス対応の追加
4+
15 ## 1.1.0 (2025年12月28日)
26 * PgUp・PgDownで使ってページを動ける様に
37 * ^、0、又はHOME、及び$又はENDキーで使って同じ行列で最初や最後のHEXや文字に移動ける様に
変更 Makefile
@@ -26,7 +26,7 @@
2626 .endif
2727
2828 NAME = hexagon
29-VERSION = 1.0.0
29+VERSION = 1.2.0
3030
3131 PREFIX = /usr/local
3232 .if ${OS} == "linux"
@@ -50,6 +50,10 @@
5050
5151 all:
5252 ${CC} -O3 ${CFLAGS} -o ${NAME} ${FILES} -std=c++17 -static ${LDFLAGS}
53+ strip ${NAME}
54+
55+debian:
56+ ${CC} -O3 ${CFLAGS} -o ${NAME} ${FILES} -std=c++17 -static ${LDFLAGS} -ltinfo
5357 strip ${NAME}
5458
5559 debug:
@@ -101,6 +101,10 @@
101101 raw();
102102 start_color();
103103
104+ // マウス対応
105+ mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, nullptr);
106+ isMouse = true;
107+
104108 init_pair(1, COLOR_BLACK, COLOR_WHITE); // カーソル
105109 init_pair(2, COLOR_BLACK, COLOR_GREEN); // 変更
106110 init_pair(3, COLOR_BLACK, COLOR_MAGENTA); // 普通
@@ -182,7 +186,7 @@
182186
183187 void HexEditor::topbar() {
184188 int colorPair = 3;
185- std::string status = "Hexagon 1.1.0";
189+ std::string status = "Hexagon 1.2.0";
186190 if (!headerType.empty()) status += " | FILETYPE: " + headerType;
187191
188192 std::wstring wstatus(status.begin(), status.end());
@@ -758,6 +762,39 @@
758762 render();
759763 }
760764
765+void HexEditor::handleMouse() {
766+ MEVENT event;
767+ if (getmouse(&event) != OK) return;
768+ if (!(event.bstate & BUTTON1_PRESSED)) return;
769+
770+ int mx = event.x;
771+ int my = event.y;
772+ if (my == 0 || my == rows - 1) return;
773+
774+ if (my >= 1 && my < rows - 2 && mx < cols / 2) {
775+ // HEXパネル
776+ int panelRow = my - 1;
777+ int panelCol = mx;
778+ if (panelCol < 10) return;
779+
780+ int i = (panelCol - 10) / 3;
781+ size_t offset = dpOffset + panelRow * bpr + i;
782+ if (offset < buf.size()) {
783+ curPos = offset;
784+ render();
785+ }
786+ } else if (my >= 1 && my < rows - 2 && mx >= cols / 2) {
787+ // ASCIIパネル
788+ int panelRow = my - 1;
789+ int i = mx - cols / 2;
790+ size_t offset = dpOffset + panelRow * bpr + i;
791+ if (offset < buf.size()) {
792+ curPos = offset;
793+ render();
794+ }
795+ }
796+}
797+
761798 void HexEditor::undo() {
762799 if (undoStack.empty()) {
763800 statusMode = Status_Error;
@@ -883,6 +920,9 @@
883920 handleSave();
884921 if (statusMode == Status_Error) statusMode = Status_Normal;
885922 }
923+ } else if (ch == KEY_MOUSE) {
924+ handleMouse();
925+ continue;
886926 }
887927
888928 // 画面の動き
@@ -78,6 +78,7 @@
7878 bool modified;
7979 bool running;
8080 std::string lastSearch;
81+ bool isMouse = false;
8182
8283 WINDOW *hexPanel;
8384 WINDOW *asciiPanel;
@@ -108,6 +109,7 @@
108109 void findNextMatch();
109110 void findPrevMatch();
110111 void handleReplace();
112+ void handleMouse();
111113 void undo();
112114 void redo();
113115