static void ntconio_open(void) { CONSOLE_CURSOR_INFO newcci; BOOL newcci_ok; TRACE(("ntconio_open\n")); set_colors(NCOLORS); set_palette(initpalettestr); hOldConsoleOutput = 0; hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE); origcci_ok = GetConsoleCursorInfo(hConsoleOutput, &origcci); GetConsoleScreenBufferInfo(hConsoleOutput, &csbi); if (csbi.dwMaximumWindowSize.Y != csbi.srWindow.Bottom - csbi.srWindow.Top + 1 || csbi.dwMaximumWindowSize.X != csbi.srWindow.Right - csbi.srWindow.Left + 1) { TRACE(("..creating alternate screen buffer\n")); hOldConsoleOutput = hConsoleOutput; hConsoleOutput = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL); SetConsoleActiveScreenBuffer(hConsoleOutput); GetConsoleScreenBufferInfo(hConsoleOutput, &csbi); newcci_ok = GetConsoleCursorInfo(hConsoleOutput, &newcci); if (newcci_ok && origcci_ok && newcci.dwSize != origcci.dwSize) { /* * Ensure that user's cursor size prefs are carried forward * in the newly created console. */ show_cursor(TRUE, origcci.dwSize); } } originalAttribute = csbi.wAttributes; crow = csbi.dwCursorPosition.Y; ccol = csbi.dwCursorPosition.X; nfcolor = cfcolor = gfcolor; nbcolor = cbcolor = gbcolor; set_current_attr(); newscreensize(csbi.dwMaximumWindowSize.Y, csbi.dwMaximumWindowSize.X); hConsoleInput = GetStdHandle(STD_INPUT_HANDLE); SetConsoleCtrlHandler(nthandler, TRUE); }
void ntcons_reopen(void) { /* If we are coming back from a shell command, pick up the current window * size, since that may have changed due to a 'mode con' command. Run * this after the 'pressreturn()' call, since otherwise that gets lost * by side-effects of this code. */ if (keyboard_was_closed) { CONSOLE_SCREEN_BUFFER_INFO temp; keyboard_was_closed = FALSE; GetConsoleScreenBufferInfo(hConsoleOutput, &temp); newscreensize(temp.dwMaximumWindowSize.Y, temp.dwMaximumWindowSize.X); } }
static int ntconio_getch(void) { INPUT_RECORD ir; DWORD nr; int key; #ifdef VAL_AUTOCOLOR int milli_ac, orig_milli_ac; #endif if (saveCount > 0) { saveCount--; return savedChar; } #ifdef VAL_AUTOCOLOR orig_milli_ac = global_b_val(VAL_AUTOCOLOR); #endif for_ever { #ifdef VAL_AUTOCOLOR milli_ac = orig_milli_ac; while (milli_ac > 0) { if (PeekConsoleInput(hConsoleInput, &ir, 1, &nr) == 0) break; /* ?? system call failed ?? */ if (nr > 0) break; /* something in the queue */ Sleep(20); /* sleep a bit, but be responsive to keybd input */ milli_ac -= 20; } if (orig_milli_ac && milli_ac <= 0) { ac_active = TRUE; autocolor(); ac_active = FALSE; } #endif if (!ReadConsoleInput(hConsoleInput, &ir, 1, &nr)) imdying(0); switch (ir.EventType) { case KEY_EVENT: key = decode_key_event(&ir); if (key == NOKYMAP) continue; if (ir.Event.KeyEvent.wRepeatCount > 1) { saveCount = ir.Event.KeyEvent.wRepeatCount - 1; savedChar = key; } return key; case WINDOW_BUFFER_SIZE_EVENT: newscreensize( ir.Event.WindowBufferSizeEvent.dwSize.Y, ir.Event.WindowBufferSizeEvent.dwSize.X ); GetConsoleScreenBufferInfo(hConsoleOutput, &csbi); continue; case MOUSE_EVENT: handle_mouse_event(ir.Event.MouseEvent); continue; } } }
/* * Make sure that the display is right. This is a three part process. First, * scan through all of the windows looking for dirty ones. Check the framing, * and refresh the screen. Second, make sure that "currow" and "curcol" are * correct for the current window. Third, make the virtual and physical * screens the same. * * int force; force update past type ahead? */ int update(int force) { struct window *wp; #if TYPEAH && ! PKCODE if (force == FALSE && typahead()) return TRUE; #endif #if VISMAC == 0 if (force == FALSE && kbdmode == PLAY) return TRUE; #endif displaying = TRUE; #if SCROLLCODE /* first, propagate mode line changes to all instances of a buffer displayed in more than one window */ wp = wheadp; while (wp != NULL) { if (wp->w_flag & WFMODE) { if (wp->w_bufp->b_nwnd > 1) { /* make sure all previous windows have this */ struct window *owp; owp = wheadp; while (owp != NULL) { if (owp->w_bufp == wp->w_bufp) owp->w_flag |= WFMODE; owp = owp->w_wndp; } } } wp = wp->w_wndp; } #endif /* update any windows that need refreshing */ wp = wheadp; while (wp != NULL) { if (wp->w_flag) { /* if the window has changed, service it */ reframe(wp); /* check the framing */ #if SCROLLCODE if (wp->w_flag & (WFKILLS | WFINS)) { scrflags |= (wp->w_flag & (WFINS | WFKILLS)); wp->w_flag &= ~(WFKILLS | WFINS); } #endif if ((wp->w_flag & ~WFMODE) == WFEDIT) updone(wp); /* update EDITed line */ else if (wp->w_flag & ~WFMOVE) updall(wp); /* update all lines */ #if SCROLLCODE if (scrflags || (wp->w_flag & WFMODE)) #else if (wp->w_flag & WFMODE) #endif modeline(wp); /* update modeline */ wp->w_flag = 0; wp->w_force = 0; } /* on to the next window */ wp = wp->w_wndp; } /* recalc the current hardware cursor location */ updpos(); #if MEMMAP && ! SCROLLCODE /* update the cursor and flush the buffers */ movecursor(currow, curcol - lbound); #endif /* check for lines to de-extend */ upddex(); /* if screen is garbage, re-plot it */ if (sgarbf != FALSE) updgar(); /* update the virtual screen to the physical screen */ updupd(force); /* update the cursor and flush the buffers */ movecursor(currow, curcol - lbound); TTflush(); displaying = FALSE; #if SIGWINCH while (chg_width || chg_height) newscreensize(chg_height, chg_width); #endif return TRUE; }