Windowsでウィンドウサイズの修正
諏訪子 <suwako@076.moe>、2026-05-03 20:15
コミット a8eae150d48de6e696aae12b71c43488231a66d2
・親 6415199
・ファイルを見る
1個のファイル、+55 -1
| @@ -94,6 +94,40 @@ | ||
| 94 | 94 | |
| 95 | 95 | // ncurses |
| 96 | 96 | initscr(); |
| 97 | +#ifdef _WIN32 | |
| 98 | + HWND console = GetConsoleWindow(); | |
| 99 | + if (console) { | |
| 100 | + LONG style = GetWindowLong(console, GWL_STYLE); | |
| 101 | + style |= WS_MAXIMIZEBOX | WS_THICKFRAME; | |
| 102 | + SetWindowLong(console, GWL_STYLE, style); | |
| 103 | + | |
| 104 | + const int MIN_WIDTH = 100; | |
| 105 | + const int MIN_HEIGHT = 30; | |
| 106 | + | |
| 107 | + HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); | |
| 108 | + CONSOLE_SCREEN_BUFFER_INFO csbi; | |
| 109 | + GetConsoleScreenBufferInfo(hOut, &csbi); | |
| 110 | + | |
| 111 | + RECT rect; | |
| 112 | + GetWindowRect(console, &rect); | |
| 113 | + | |
| 114 | + int cw = csbi.srWindow.Right - csbi.srWindow.Left + 1; | |
| 115 | + int ch = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; | |
| 116 | + | |
| 117 | + MINMAXINFO mmi = {}; | |
| 118 | + mmi.ptMinTrackSize.x = MIN_WIDTH * 8; | |
| 119 | + mmi.ptMinTrackSize.y = MIN_HEIGHT * 16; | |
| 120 | + | |
| 121 | + COORD minBuf = { MIN_WIDTH, MIN_HEIGHT }; | |
| 122 | + SetConsoleScreenBufferSize(hOut, minBuf); | |
| 123 | + | |
| 124 | + SMALL_RECT rectWin = { 0, 0, MIN_WIDTH - 1, MIN_HEIGHT - 1 }; | |
| 125 | + SetConsoleWindowInfo(hOut, TRUE, &rectWin); | |
| 126 | + } | |
| 127 | + | |
| 128 | + resize_term(40, 120); | |
| 129 | +#endif | |
| 130 | + getmaxyx(stdscr, rows, cols); | |
| 97 | 131 | clearok(stdscr, TRUE); |
| 98 | 132 | cbreak(); |
| 99 | 133 | noecho(); |
| @@ -935,11 +969,31 @@ | ||
| 935 | 969 | |
| 936 | 970 | ch = getch(); |
| 937 | 971 | |
| 972 | + if (ch == KEY_RESIZE) { | |
| 973 | + getmaxyx(stdscr, rows, cols); | |
| 974 | + delwin(hexPanel); | |
| 975 | + delwin(asciiPanel); | |
| 976 | + | |
| 977 | + bpr = std::min<size_t>(16, (cols / 2 - 10) / 4); | |
| 978 | + if (bpr < 4) bpr = 4; | |
| 979 | + | |
| 980 | + hexPanel = newwin(rows - 3, cols / 2, 1, 0); | |
| 981 | + asciiPanel = newwin(rows - 3, cols / 2, 1, cols / 2); | |
| 982 | + | |
| 983 | + scrollok(hexPanel, TRUE); | |
| 984 | + scrollok(asciiPanel, TRUE); | |
| 985 | + wattrset(hexPanel, COLOR_PAIR(8)); | |
| 986 | + wattrset(asciiPanel, COLOR_PAIR(8)); | |
| 987 | + | |
| 988 | + render(); | |
| 989 | + continue; | |
| 990 | + } | |
| 991 | + | |
| 938 | 992 | if (!hasFile && ch != ':' && ch != 'Z') { |
| 939 | 993 | statusMode = Status_Error; |
| 940 | 994 | statusText = "ファイルを読み込んでいません。「:o <file>」を御利用下さい。"; |
| 941 | 995 | render(); |
| 942 | - return; | |
| 996 | + continue; | |
| 943 | 997 | } |
| 944 | 998 | |
| 945 | 999 | if ((ch == 'j' || ch == KEY_DOWN) && curPos + bpr < buf.size()) { |