From a8eae150d48de6e696aae12b71c43488231a66d2 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 20:15:47 +0900 Subject: [PATCH] =?UTF-8?q?Windows=E3=81=A7=E3=82=A6=E3=82=A3=E3=83=B3?= =?UTF-8?q?=E3=83=89=E3=82=A6=E3=82=B5=E3=82=A4=E3=82=BA=E3=81=AE=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hexeditor.cc | 56 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/hexeditor.cc b/src/hexeditor.cc index 305d51f..96680bf 100644 --- a/src/hexeditor.cc +++ b/src/hexeditor.cc @@ -94,6 +94,40 @@ HexEditor::HexEditor(const std::string &filename) // ncurses initscr(); +#ifdef _WIN32 + HWND console = GetConsoleWindow(); + if (console) { + LONG style = GetWindowLong(console, GWL_STYLE); + style |= WS_MAXIMIZEBOX | WS_THICKFRAME; + SetWindowLong(console, GWL_STYLE, style); + + const int MIN_WIDTH = 100; + const int MIN_HEIGHT = 30; + + HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); + CONSOLE_SCREEN_BUFFER_INFO csbi; + GetConsoleScreenBufferInfo(hOut, &csbi); + + RECT rect; + GetWindowRect(console, &rect); + + int cw = csbi.srWindow.Right - csbi.srWindow.Left + 1; + int ch = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; + + MINMAXINFO mmi = {}; + mmi.ptMinTrackSize.x = MIN_WIDTH * 8; + mmi.ptMinTrackSize.y = MIN_HEIGHT * 16; + + COORD minBuf = { MIN_WIDTH, MIN_HEIGHT }; + SetConsoleScreenBufferSize(hOut, minBuf); + + SMALL_RECT rectWin = { 0, 0, MIN_WIDTH - 1, MIN_HEIGHT - 1 }; + SetConsoleWindowInfo(hOut, TRUE, &rectWin); + } + + resize_term(40, 120); +#endif + getmaxyx(stdscr, rows, cols); clearok(stdscr, TRUE); cbreak(); noecho(); @@ -935,11 +969,31 @@ void HexEditor::input() { ch = getch(); + if (ch == KEY_RESIZE) { + getmaxyx(stdscr, rows, cols); + delwin(hexPanel); + delwin(asciiPanel); + + bpr = std::min(16, (cols / 2 - 10) / 4); + if (bpr < 4) bpr = 4; + + hexPanel = newwin(rows - 3, cols / 2, 1, 0); + asciiPanel = newwin(rows - 3, cols / 2, 1, cols / 2); + + scrollok(hexPanel, TRUE); + scrollok(asciiPanel, TRUE); + wattrset(hexPanel, COLOR_PAIR(8)); + wattrset(asciiPanel, COLOR_PAIR(8)); + + render(); + continue; + } + if (!hasFile && ch != ':' && ch != 'Z') { statusMode = Status_Error; statusText = "ファイルを読み込んでいません。「:o 」を御利用下さい。"; render(); - return; + continue; } if ((ch == 'j' || ch == KEY_DOWN) && curPos + bpr < buf.size()) {