a998bcf207
* Use the Bold(1) SGR parameter in only one case -- White-on-Black. * Use the 0x9X and 0x10X SGR parameters to set intense/bright colors for both foreground and background. Detailed changes: * DkGray background: - Previously, this background was handled identically to the Black background. - Now it is treated like the non-grayscale colors, and the foreground/background are set exactly. * Black background: - LtGray foreground is unchanged: default text colors - White foreground is unchanged: text is bolded - DkGray is fixed: instead of concealing the text, set the foreground to DkGray, falling back to LtGray. * LtGray background: - Previously, this background was handled exactly the same way as the White background. - Now it is treated like any other non-grayscale color. * White background: - Black foreground is unchanged: only an Invert is output. - LtGray: previously, the text was concealed. Now it is handled like Black, and only an Invert is output. - DkGray: previously only Invert was output. Now DkGray is also output. - White is effectively unchanged; it is still concealed if possible. Also: set the console colors to LtGray-on-Black on startup. The heuristic makes little sense with other colors. Fixes https://github.com/rprichard/winpty/issues/39
88 lines
2.7 KiB
C++
88 lines
2.7 KiB
C++
// Copyright (c) 2011-2012 Ryan Prichard
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to
|
|
// deal in the Software without restriction, including without limitation the
|
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
// sell copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
// IN THE SOFTWARE.
|
|
|
|
#ifndef WIN32CONSOLE_H
|
|
#define WIN32CONSOLE_H
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
#include <wchar.h>
|
|
#include <windows.h>
|
|
#include "Coord.h"
|
|
#include "SmallRect.h"
|
|
|
|
struct ConsoleScreenBufferInfo : CONSOLE_SCREEN_BUFFER_INFO
|
|
{
|
|
ConsoleScreenBufferInfo()
|
|
{
|
|
memset(this, 0, sizeof(*this));
|
|
}
|
|
|
|
Coord bufferSize() const { return dwSize; }
|
|
SmallRect windowRect() const { return srWindow; }
|
|
Coord cursorPosition() const { return dwCursorPosition; }
|
|
};
|
|
|
|
class Win32Console
|
|
{
|
|
public:
|
|
Win32Console();
|
|
~Win32Console();
|
|
|
|
HANDLE conin();
|
|
HANDLE conout();
|
|
HWND hwnd();
|
|
void postCloseMessage();
|
|
void clearLines(int row, int count, const ConsoleScreenBufferInfo &info);
|
|
void clearAllLines(const ConsoleScreenBufferInfo &info);
|
|
|
|
// Buffer and window sizes.
|
|
ConsoleScreenBufferInfo bufferInfo();
|
|
Coord bufferSize();
|
|
SmallRect windowRect();
|
|
void resizeBuffer(const Coord &size);
|
|
void moveWindow(const SmallRect &rect);
|
|
|
|
// Cursor.
|
|
Coord cursorPosition();
|
|
void setCursorPosition(const Coord &point);
|
|
|
|
// Input stream.
|
|
void writeInput(const INPUT_RECORD *ir, int count=1);
|
|
bool processedInputMode();
|
|
|
|
// Screen content.
|
|
void read(const SmallRect &rect, CHAR_INFO *data);
|
|
void write(const SmallRect &rect, const CHAR_INFO *data);
|
|
|
|
// Title.
|
|
std::wstring title();
|
|
void setTitle(const std::wstring &title);
|
|
|
|
void setTextAttribute(WORD attributes);
|
|
|
|
private:
|
|
HANDLE m_conin;
|
|
HANDLE m_conout;
|
|
std::vector<wchar_t> m_titleWorkBuf;
|
|
};
|
|
|
|
#endif // WIN32CONSOLE_H
|