マウス対応の追加
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
.svn
|
||||
hexagon
|
||||
hexagon.exe
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
## 1.2.0 (2026年05月03日)
|
||||
* Debianでコンパイル出来る様に
|
||||
* マウス対応の追加
|
||||
|
||||
## 1.1.0 (2025年12月28日)
|
||||
* PgUp・PgDownで使ってページを動ける様に
|
||||
* ^、0、又はHOME、及び$又はENDキーで使って同じ行列で最初や最後のHEXや文字に移動ける様に
|
||||
|
||||
6
Makefile
6
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}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
// 画面の動き
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user