Windowsでウィンドウサイズの修正
This commit is contained in:
@@ -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<size_t>(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 <file>」を御利用下さい。";
|
||||
render();
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((ch == 'j' || ch == KEY_DOWN) && curPos + bpr < buf.size()) {
|
||||
|
||||
Reference in New Issue
Block a user