terminal/src/cascadia/TerminalCore/ITerminalApi.hpp
Michael Niksa 6f667f48ae
Make the terminal parser/adapter and related classes use modern… (#3956)
## Summary of the Pull Request
Refactors parsing/adapting libraries and consumers to use safer and/or more consistent mechanisms for passing information.

## PR Checklist
* [x] I work here
* [x] Tests still pass
* [x] Am a core contributor.

## Detailed Description of the Pull Request / Additional comments
This is in support of hopefully turning audit mode on to more projects. If I turned it on, it would immediately complain about certain classes of issues like pointer and size, pointer math, etc. The changes in this refactoring will eliminate those off the top.

Additionally, this has caught a bunch of comments all over the VT classes that weren't updated to match the parameters lists.

Additionally, this has caught a handful of member variables on classes that were completely unused (and now gone).

Additionally, I'm killing almost all hungarian and shortening variable names. I'm only really leaving 'p' for pointers.

Additionally, this is vaguely in support of a future where we can have "infinite scrollback" in that I'm moving things to size_t across the board. I know it's a bit of a memory cost, but all the casting and moving between types is error prone and unfun to save a couple bytes.

## Validation Steps Performed
- [x] build it
- [x] run all the tests
- [x] everyone looked real hard at it
2019-12-19 14:12:53 -08:00

51 lines
2.1 KiB
C++

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "../../terminal/adapter/DispatchTypes.hpp"
namespace Microsoft::Terminal::Core
{
class ITerminalApi
{
public:
virtual ~ITerminalApi() {}
ITerminalApi(const ITerminalApi&) = default;
ITerminalApi(ITerminalApi&&) = default;
ITerminalApi& operator=(const ITerminalApi&) = default;
ITerminalApi& operator=(ITerminalApi&&) = default;
virtual bool PrintString(std::wstring_view string) = 0;
virtual bool ExecuteChar(wchar_t wch) = 0;
virtual bool SetTextToDefaults(bool foreground, bool background) = 0;
virtual bool SetTextForegroundIndex(BYTE colorIndex) = 0;
virtual bool SetTextBackgroundIndex(BYTE colorIndex) = 0;
virtual bool SetTextRgbColor(COLORREF color, bool foreground) = 0;
virtual bool BoldText(bool boldOn) = 0;
virtual bool UnderlineText(bool underlineOn) = 0;
virtual bool ReverseText(bool reversed) = 0;
virtual bool SetCursorPosition(short x, short y) = 0;
virtual COORD GetCursorPosition() = 0;
virtual bool DeleteCharacter(const size_t count) = 0;
virtual bool InsertCharacter(const size_t count) = 0;
virtual bool EraseCharacters(const size_t numChars) = 0;
virtual bool EraseInLine(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::EraseType eraseType) = 0;
virtual bool EraseInDisplay(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::EraseType eraseType) = 0;
virtual bool SetWindowTitle(std::wstring_view title) = 0;
virtual bool SetColorTableEntry(const size_t tableIndex, const DWORD color) = 0;
virtual bool SetCursorStyle(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle cursorStyle) = 0;
virtual bool SetDefaultForeground(const DWORD color) = 0;
virtual bool SetDefaultBackground(const DWORD color) = 0;
protected:
ITerminalApi() = default;
};
}