2019-05-03 00:29:04 +02:00
|
|
|
/*++
|
|
|
|
Copyright (c) Microsoft Corporation
|
|
|
|
Licensed under the MIT license.
|
|
|
|
|
|
|
|
Module Name:
|
|
|
|
- XtermEngine.hpp
|
|
|
|
|
|
|
|
Abstract:
|
|
|
|
- This is the definition of the VT specific implementation of the renderer.
|
|
|
|
This is the xterm implementation, which supports advanced sequences such as
|
|
|
|
inserting and deleting lines, but only 16 colors.
|
|
|
|
|
|
|
|
This engine supports both xterm and xterm-ascii VT modes.
|
|
|
|
The difference being that xterm-ascii will render any characters above 0x7f
|
|
|
|
as '?', in order to support older legacy tools.
|
|
|
|
|
|
|
|
Author(s):
|
|
|
|
- Mike Griese (migrie) 01-Sept-2017
|
|
|
|
--*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "vtrenderer.hpp"
|
|
|
|
|
|
|
|
namespace Microsoft::Console::Render
|
|
|
|
{
|
|
|
|
class XtermEngine : public VtEngine
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
XtermEngine(_In_ wil::unique_hfile hPipe,
|
|
|
|
const Microsoft::Console::IDefaultColorProvider& colorProvider,
|
|
|
|
const Microsoft::Console::Types::Viewport initialViewport,
|
|
|
|
_In_reads_(cColorTable) const COLORREF* const ColorTable,
|
|
|
|
const WORD cColorTable,
|
|
|
|
const bool fUseAsciiOnly);
|
|
|
|
|
|
|
|
virtual ~XtermEngine() override = default;
|
|
|
|
|
2019-06-11 22:27:09 +02:00
|
|
|
[[nodiscard]] HRESULT StartPaint() noexcept override;
|
|
|
|
[[nodiscard]] HRESULT EndPaint() noexcept override;
|
|
|
|
|
2019-10-03 01:11:27 +02:00
|
|
|
[[nodiscard]] HRESULT PaintCursor(const CursorOptions& options) noexcept override;
|
|
|
|
|
2019-06-11 22:27:09 +02:00
|
|
|
[[nodiscard]] virtual HRESULT UpdateDrawingBrushes(const COLORREF colorForeground,
|
|
|
|
const COLORREF colorBackground,
|
|
|
|
const WORD legacyColorAttribute,
|
Add support for passing through extended text attributes, like… (#2917)
## Summary of the Pull Request
Adds support for Italics, Blinking, Invisible, CrossedOut text, THROUGH CONPTY. This does **NOT** add support for those styles to conhost or the terminal.
We will store these "Extended Text Attributes" in a `TextAttribute`. When we go to render a line, we'll see if the state has changed from our previous state, and if so, we'll appropriately toggle that state with VT. Boldness has been moved from a `bool` to a single bit in these flags.
Technically, now that these are stored in the buffer, we only need to make changes to the renderers to be able to support them. That's not being done as a part of this PR however.
## References
See also #2915 and #2916, which are some follow-up tasks from this fix. I thought them too risky for 20H1.
## PR Checklist
* [x] Closes #2554
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated
<hr>
* store text with extended attributes too
* Plumb attributes through all the renderers
* parse extended attrs, though we're not renderering them right
* Render these states correctly
* Add a very extensive test
* Cleanup for PR
* a block of PR feedback
* add 512 test cases
* Fix the build
* Fix @carlos-zamora's suggestions
* @miniksa's PR feedback
2019-10-04 22:53:54 +02:00
|
|
|
const ExtendedAttributes extendedAttrs,
|
2019-06-11 22:27:09 +02:00
|
|
|
const bool isSettingDefaultBrushes) noexcept override;
|
|
|
|
[[nodiscard]] HRESULT PaintBufferLine(std::basic_string_view<Cluster> const clusters,
|
|
|
|
const COORD coord,
|
|
|
|
const bool trimLeft) noexcept override;
|
|
|
|
[[nodiscard]] HRESULT ScrollFrame() noexcept override;
|
|
|
|
|
|
|
|
[[nodiscard]] HRESULT InvalidateScroll(const COORD* const pcoordDelta) noexcept override;
|
|
|
|
|
2019-12-19 23:12:53 +01:00
|
|
|
[[nodiscard]] HRESULT WriteTerminalW(const std::wstring_view str) noexcept override;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
const COLORREF* const _ColorTable;
|
|
|
|
const WORD _cColorTable;
|
|
|
|
const bool _fUseAsciiOnly;
|
|
|
|
bool _previousLineWrapped;
|
|
|
|
bool _usingUnderLine;
|
|
|
|
bool _needToDisableCursor;
|
2019-10-03 01:11:27 +02:00
|
|
|
bool _lastCursorIsVisible;
|
|
|
|
bool _nextCursorIsVisible;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2019-06-11 22:27:09 +02:00
|
|
|
[[nodiscard]] HRESULT _MoveCursor(const COORD coord) noexcept override;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2019-06-11 22:27:09 +02:00
|
|
|
[[nodiscard]] HRESULT _UpdateUnderline(const WORD wLegacyAttrs) noexcept;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2019-06-11 22:27:09 +02:00
|
|
|
[[nodiscard]] HRESULT _DoUpdateTitle(const std::wstring& newTitle) noexcept override;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2019-06-11 22:27:09 +02:00
|
|
|
#ifdef UNIT_TESTING
|
2019-05-03 00:29:04 +02:00
|
|
|
friend class VtRendererTest;
|
Create tests that roundtrip output through a conpty to a Terminal (#4213)
## Summary of the Pull Request
This PR adds two tests:
* First, I started by writing a test where I could write output to the console host and inspect what output came out of conpty. This is the `ConptyOutputTests` in the host unit tests.
* Then I got crazy and thought _"what if I could take that output and dump it straight into the `Terminal`"_? Hence, the `ConptyRoundtripTests` were born, into the TerminalCore unit tests.
## References
Done in pursuit of #4200, but I felt this warranted it's own atomic PR
## PR Checklist
* [x] Doesn't close anything on it's own.
* [x] I work here
* [x] you better believe this adds tests
* [n/a] Requires documentation to be updated
## Detailed Description of the Pull Request / Additional comments
From the comment in `ConptyRoundtripTests`:
> This test class creates an in-proc conpty host as well as a Terminal, to
> validate that strings written to the conpty create the same resopnse on the
> terminal end. Tests can be written that validate both the contents of the
> host buffer as well as the terminal buffer. Everytime that
> `renderer.PaintFrame()` is called, the tests will validate the expected
> output, and then flush the output of the VtEngine straight to th
Also, some other bits had to be updated:
* The renderer needed to be able to survive without a thread, so I hadded a simple check that it actually had a thread before calling `pThread->NotifyPaint`
* Bits in `CommonState` used `NTSTATUS_FROM_HRESULT` which did _not_ work outside the host project. Since the `NTSTATUS` didn't seem that important, I replaced that with a `HRESULT`
* `CommonState` likes to initialize the console to some _weird_ defaults. I added an optional param to let us just use the defaults.
2020-01-17 17:40:12 +01:00
|
|
|
friend class ConptyOutputTests;
|
2019-06-11 22:27:09 +02:00
|
|
|
#endif
|
2019-05-03 00:29:04 +02:00
|
|
|
};
|
|
|
|
}
|