c910045187
*cfc72cee
(origin/dev/duhowett/ibxint, github/master) Make sure cursor blinks after opening new tab (1030) *9ad25440
Fix #936: misuse of uninitialized objects causes AppVerifier breaks on Windows Terminal startup (1015) *5f938a04
Update Terminal.cpp (1034) *4c47631b
Cleanup - termDispatch.hpp & adaptDispatch.hpp overrides (1004) *cc304759
add audit mode to ci (948) *80f10796
Fix the bell sound when Alt+key is pressed. (1006) *42e87ed3
fix build break from using `await` instead of `co_await` (1009) *40b557a4
Update manifest to correct 1903 version, unref param fix (1008) *0f62ec81
Eat all tap keypresses no matter what. (985) *ce0eaab9
inbox: Merge accumulated build fixes from RS_ONECORE_DEP_ACIOSS (1002) *1c509683
add .editorconfig file (585) *efd69990
Add support for OSC 10 and 11 to set the default colors (891) Related work items: #21610659, #21838182
100 lines
3 KiB
C++
100 lines
3 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#include "pch.h"
|
|
#include "TerminalDispatch.hpp"
|
|
using namespace ::Microsoft::Terminal::Core;
|
|
using namespace ::Microsoft::Console::VirtualTerminal;
|
|
|
|
// NOTE:
|
|
// Functions related to Set Graphics Renditions (SGR) are in
|
|
// TerminalDispatchGraphics.cpp, not this file
|
|
|
|
TerminalDispatch::TerminalDispatch(ITerminalApi& terminalApi) :
|
|
_terminalApi{ terminalApi }
|
|
{
|
|
|
|
}
|
|
|
|
void TerminalDispatch::Execute(const wchar_t wchControl)
|
|
{
|
|
_terminalApi.ExecuteChar(wchControl);
|
|
}
|
|
|
|
void TerminalDispatch::Print(const wchar_t wchPrintable)
|
|
{
|
|
_terminalApi.PrintString({ &wchPrintable, 1 });
|
|
}
|
|
|
|
void TerminalDispatch::PrintString(const wchar_t *const rgwch, const size_t cch)
|
|
{
|
|
_terminalApi.PrintString({ rgwch, cch });
|
|
}
|
|
|
|
bool TerminalDispatch::CursorPosition(const unsigned int uiLine,
|
|
const unsigned int uiColumn)
|
|
{
|
|
const auto columnInBufferSpace = uiColumn - 1;
|
|
const auto lineInBufferSpace = uiLine - 1;
|
|
short x = static_cast<short>(uiColumn - 1);
|
|
short y = static_cast<short>(uiLine - 1);
|
|
return _terminalApi.SetCursorPosition(x, y);
|
|
}
|
|
|
|
bool TerminalDispatch::CursorForward(const unsigned int uiDistance)
|
|
{
|
|
const auto cursorPos = _terminalApi.GetCursorPosition();
|
|
const COORD newCursorPos { cursorPos.X + gsl::narrow<short>(uiDistance), cursorPos.Y };
|
|
return _terminalApi.SetCursorPosition(newCursorPos.X, newCursorPos.Y);
|
|
}
|
|
|
|
bool TerminalDispatch::EraseCharacters(const unsigned int uiNumChars)
|
|
{
|
|
return _terminalApi.EraseCharacters(uiNumChars);
|
|
}
|
|
|
|
bool TerminalDispatch::SetWindowTitle(std::wstring_view title)
|
|
{
|
|
return _terminalApi.SetWindowTitle(title);
|
|
}
|
|
|
|
// Method Description:
|
|
// - Sets a single entry of the colortable to a new value
|
|
// Arguments:
|
|
// - tableIndex: The VT color table index
|
|
// - dwColor: The new RGB color value to use.
|
|
// Return Value:
|
|
// True if handled successfully. False otherwise.
|
|
bool TerminalDispatch::SetColorTableEntry(const size_t tableIndex,
|
|
const DWORD dwColor)
|
|
{
|
|
return _terminalApi.SetColorTableEntry(tableIndex, dwColor);
|
|
}
|
|
|
|
bool TerminalDispatch::SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle)
|
|
{
|
|
return _terminalApi.SetCursorStyle(cursorStyle);
|
|
}
|
|
|
|
// Method Description:
|
|
// - Sets the default foreground color to a new value
|
|
// Arguments:
|
|
// - dwColor: The new RGB color value to use, in 0x00BBGGRR form
|
|
// Return Value:
|
|
// True if handled successfully. False otherwise.
|
|
bool TerminalDispatch::SetDefaultForeground(const DWORD dwColor)
|
|
{
|
|
return _terminalApi.SetDefaultForeground(dwColor);
|
|
}
|
|
|
|
// Method Description:
|
|
// - Sets the default background color to a new value
|
|
// Arguments:
|
|
// - dwColor: The new RGB color value to use, in 0x00BBGGRR form
|
|
// Return Value:
|
|
// True if handled successfully. False otherwise.
|
|
bool TerminalDispatch::SetDefaultBackground(const DWORD dwColor)
|
|
{
|
|
return _terminalApi.SetDefaultBackground(dwColor);
|
|
}
|