void CloseConsole() { ScrBuf.Flush(); Console.SetCursorInfo(InitialCursorInfo); ChangeConsoleMode(InitialConsoleMode); Console.SetTitle(strInitTitle); Console.SetSize(InitialSize); COORD CursorPos = {}; Console.GetCursorPosition(CursorPos); SHORT Height = InitWindowRect.Bottom-InitWindowRect.Top, Width = InitWindowRect.Right-InitWindowRect.Left; if (CursorPos.Y > InitWindowRect.Bottom || CursorPos.Y < InitWindowRect.Top) InitWindowRect.Top = Max(0, CursorPos.Y-Height); if (CursorPos.X > InitWindowRect.Right || CursorPos.X < InitWindowRect.Left) InitWindowRect.Left = Max(0, CursorPos.X-Width); InitWindowRect.Bottom = InitWindowRect.Top + Height; InitWindowRect.Right = InitWindowRect.Left + Width; Console.SetWindowRect(InitWindowRect); Console.SetSize(InitialSize); delete KeyQueue; KeyQueue=nullptr; ConsoleIcons.restorePreviousIcons(); }
void SetFarConsoleMode(BOOL SetsActiveBuffer) { int Mode=ENABLE_WINDOW_INPUT; if (Opt.Mouse) { //ENABLE_EXTENDED_FLAGS actually disables all the extended flags. Mode|=ENABLE_MOUSE_INPUT|ENABLE_EXTENDED_FLAGS; } else { //если вдруг изменили опцию во время работы фара, то включим то что надо Mode|=InitialConsoleMode&(ENABLE_EXTENDED_FLAGS|ENABLE_QUICK_EDIT_MODE); } if (SetsActiveBuffer) Console.SetActiveScreenBuffer(Console.GetOutputHandle()); ChangeConsoleMode(Mode); //востановим дефолтный режим вывода, а то есть такие проги что сбрасывают ChangeConsoleMode(ENABLE_PROCESSED_OUTPUT|ENABLE_WRAP_AT_EOL_OUTPUT, 1); ChangeConsoleMode(ENABLE_PROCESSED_OUTPUT|ENABLE_WRAP_AT_EOL_OUTPUT, 2); }
void CloseConsole() { Global->ScrBuf->Flush(); Console().SetCursorInfo(InitialCursorInfo); ChangeConsoleMode(InitialConsoleMode); Console().SetTitle(Global->strInitTitle); Console().SetSize(InitialSize); COORD CursorPos = {}; Console().GetCursorPosition(CursorPos); SHORT Height = InitWindowRect.Bottom-InitWindowRect.Top, Width = InitWindowRect.Right-InitWindowRect.Left; if (CursorPos.Y > InitWindowRect.Bottom || CursorPos.Y < InitWindowRect.Top) InitWindowRect.Top = std::max(0, CursorPos.Y-Height); if (CursorPos.X > InitWindowRect.Right || CursorPos.X < InitWindowRect.Left) InitWindowRect.Left = std::max(0, CursorPos.X-Width); InitWindowRect.Bottom = InitWindowRect.Top + Height; InitWindowRect.Right = InitWindowRect.Left + Width; Console().SetWindowRect(InitWindowRect); Console().SetSize(InitialSize); KeyQueue().clear(); ConsoleIcons().restorePreviousIcons(); CancelIoInProgress().Close(); }