マウス対応の追加
諏訪子 <suwako@076.moe>、2026-05-03 19:10
コミット 07d377fbe825e83315379250d33e47fbbab3df1f
・親 7bd77a0
・ファイルを見る
5個のファイル、+53 -2
変更
.gitignore
| @@ -1,2 +1,3 @@ | ||
| 1 | 1 | .svn |
| 2 | 2 | hexagon |
| 3 | +hexagon.exe |
変更
CHANGELOG.md
| @@ -1,3 +1,7 @@ | ||
| 1 | +## 1.2.0 (2026年05月03日) | |
| 2 | +* Debianでコンパイル出来る様に | |
| 3 | +* マウス対応の追加 | |
| 4 | + | |
| 1 | 5 | ## 1.1.0 (2025年12月28日) |
| 2 | 6 | * PgUp・PgDownで使ってページを動ける様に |
| 3 | 7 | * ^、0、又はHOME、及び$又はENDキーで使って同じ行列で最初や最後のHEXや文字に移動ける様に |
変更
Makefile
| @@ -26,7 +26,7 @@ | ||
| 26 | 26 | .endif |
| 27 | 27 | |
| 28 | 28 | NAME = hexagon |
| 29 | -VERSION = 1.0.0 | |
| 29 | +VERSION = 1.2.0 | |
| 30 | 30 | |
| 31 | 31 | PREFIX = /usr/local |
| 32 | 32 | .if ${OS} == "linux" |
| @@ -50,6 +50,10 @@ | ||
| 50 | 50 | |
| 51 | 51 | all: |
| 52 | 52 | ${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 | |
| 53 | 57 | strip ${NAME} |
| 54 | 58 | |
| 55 | 59 | debug: |
| @@ -101,6 +101,10 @@ | ||
| 101 | 101 | raw(); |
| 102 | 102 | start_color(); |
| 103 | 103 | |
| 104 | + // マウス対応 | |
| 105 | + mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, nullptr); | |
| 106 | + isMouse = true; | |
| 107 | + | |
| 104 | 108 | init_pair(1, COLOR_BLACK, COLOR_WHITE); // カーソル |
| 105 | 109 | init_pair(2, COLOR_BLACK, COLOR_GREEN); // 変更 |
| 106 | 110 | init_pair(3, COLOR_BLACK, COLOR_MAGENTA); // 普通 |
| @@ -182,7 +186,7 @@ | ||
| 182 | 186 | |
| 183 | 187 | void HexEditor::topbar() { |
| 184 | 188 | int colorPair = 3; |
| 185 | - std::string status = "Hexagon 1.1.0"; | |
| 189 | + std::string status = "Hexagon 1.2.0"; | |
| 186 | 190 | if (!headerType.empty()) status += " | FILETYPE: " + headerType; |
| 187 | 191 | |
| 188 | 192 | std::wstring wstatus(status.begin(), status.end()); |
| @@ -758,6 +762,39 @@ | ||
| 758 | 762 | render(); |
| 759 | 763 | } |
| 760 | 764 | |
| 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 | + | |
| 761 | 798 | void HexEditor::undo() { |
| 762 | 799 | if (undoStack.empty()) { |
| 763 | 800 | statusMode = Status_Error; |
| @@ -883,6 +920,9 @@ | ||
| 883 | 920 | handleSave(); |
| 884 | 921 | if (statusMode == Status_Error) statusMode = Status_Normal; |
| 885 | 922 | } |
| 923 | + } else if (ch == KEY_MOUSE) { | |
| 924 | + handleMouse(); | |
| 925 | + continue; | |
| 886 | 926 | } |
| 887 | 927 | |
| 888 | 928 | // 画面の動き |
| @@ -78,6 +78,7 @@ | ||
| 78 | 78 | bool modified; |
| 79 | 79 | bool running; |
| 80 | 80 | std::string lastSearch; |
| 81 | + bool isMouse = false; | |
| 81 | 82 | |
| 82 | 83 | WINDOW *hexPanel; |
| 83 | 84 | WINDOW *asciiPanel; |
| @@ -108,6 +109,7 @@ | ||
| 108 | 109 | void findNextMatch(); |
| 109 | 110 | void findPrevMatch(); |
| 110 | 111 | void handleReplace(); |
| 112 | + void handleMouse(); | |
| 111 | 113 | void undo(); |
| 112 | 114 | void redo(); |
| 113 | 115 |