Commit graph

2880 commits

Author SHA1 Message Date
Dustin Howett 52d1e788f7 11680 SNAP LAYOUT 2021-11-17 17:54:50 -06:00
Dustin Howett 214af0bb74 11308 ELEV DIALOG 2021-11-17 17:54:28 -06:00
Dustin Howett b90cf8148d 11619 RRAGNAROK 2021-11-17 17:43:56 -06:00
Leonard Hecker a68b0d4f08
Introduce new TIL string helpers, teach older ones to use wmemcmp (#11725)
til::equals:
At the time of writing wmemcmp() is not an intrinsic for MSVC,
but the STL uses it to implement wide string comparisons.
This produces 3x the assembly _per_ comparison and increases
runtime by 2-3x for strings of medium length (16 characters)
and 5x or more for long strings (128 characters or more).
See: https://github.com/microsoft/STL/issues/2289

Additionally a number of case insensitive, locale unaware
helpers for prefix/suffix comparisons are introduced.
2021-11-17 23:42:40 +00:00
James Holderness 6742965bb8
Disable the acceptance of C1 control codes by default (#11690)
There are some code pages with "unmapped" code points in the C1 range,
which results in them being translated into Unicode C1 control codes,
even though that is not their intended use. To avoid having these
characters triggering unintentional escape sequences, this PR now
disables C1 controls by default.

Switching to ISO-2022 encoding will re-enable them, though, since that
is the most likely scenario in which they would be required. They can
also be explicitly enabled, even in UTF-8 mode, with the `DECAC1` escape
sequence.

What I've done is add a new mode to the `StateMachine` class that
controls whether C1 code points are interpreted as control characters or
not. When disabled, these code points are simply dropped from the
output, similar to the way a `NUL` is interpreted.

This isn't exactly the way they were handled in the v1 console (which I
think replaces them with the font _notdef_ glyph), but it matches the
XTerm behavior, which seems more appropriate considering this is in VT
mode. And it's worth noting that Windows Explorer seems to work the same
way.

As mentioned above, the mode can be enabled by designating the ISO-2022
coding system with a `DOCS` sequence, and it will be disabled again when
UTF-8 is designated. You can also enable it explicitly with a `DECAC1`
sequence (originally this was actually a DEC printer sequence, but it
doesn't seem unreasonable to use it in a terminal).

I've also extended the operations that save and restore "cursor state"
(e.g. `DECSC` and `DECRC`) to include the state of the C1 parser mode,
since it's closely tied to the code page and character sets which are
also saved there. Similarly, when a `DECSTR` sequence resets the code
page and character sets, I've now made it reset the C1 mode as well.

I should note that the new `StateMachine` mode is controlled via a
generic `SetParserMode` method (with a matching API in the `ConGetSet`
interface) to allow for easier addition of other modes in the future.
And I've reimplemented the existing ANSI/VT52 mode in terms of these
generic methods instead of it having to have its own separate APIs.

## Validation Steps Performed

Some of the unit tests for OSC sequences were using a C1 `0x9C` for the
string terminator, which doesn't work by default anymore. Since that's
not a good practice anyway, I thought it best to change those to a
standard 7-bit terminator. However, in tests that were explicitly
validating the C1 controls, I've just enabled the C1 parser mode at the
start of the tests in order to get them working again.

There were also some ANSI mode adapter tests that had to be updated to
account for the fact that it has now been reimplemented in terms of the
`SetParserMode` API.

I've added a new state machine test to validate the changes in behavior
when the C1 parser mode is enabled or disabled. And I've added an
adapter test to verify that the `DesignateCodingSystems` and
`AcceptC1Controls` methods toggle the C1 parser mode as expected.

I've manually verified the test cases in #10069 and #10310 to confirm
that they're no longer triggering control sequences by default.
Although, as I explained above, the C1 code points are completely
dropped from the output rather than displayed as _notdef_ glyphs. I
think this is a reasonable compromise though.

Closes #10069
Closes #10310
2021-11-17 23:40:31 +00:00
Leonard Hecker 131f5d2b32
Use nearby fonts for font fallback (#11764)
This commit is a minimal fix in order to pass the
`IDWriteFontCollection` we create out of .ttf files residing next to our
binaries to the `IDWriteFontFallback::MapCharacters` call. The
`IDWriteTextFormat` is used in order to carry the font collection over
into `CustomTextLayout`.

## Validation
* Put `JetBrainsMono-Regular.ttf` into the binary output directory
* Modify `HKCU:\Console\*\FaceName`  to `JetBrains Mono`
* Launch OpenConsole.exe
* OpenConsole uses JetBrains Mono ✔️

Closes #11032
Closes #11648
2021-11-16 23:22:02 +00:00
Mike Griese 6939ff77cf this can be static 2021-11-16 13:18:22 -06:00
Mike Griese 174e413f8e color transitions too 2021-11-16 13:16:04 -06:00
Mike Griese e24f4d5638 a comment too 2021-11-16 13:10:46 -06:00
Mike Griese fd2f584019 fix the system menu too 2021-11-16 13:10:32 -06:00
Mike Griese 15ab87f5d4 repair the top border resizing 2021-11-16 12:55:42 -06:00
Mike Griese aa9577bfc7 fix the pressing/hovering/tooltip interaction 2021-11-16 12:49:23 -06:00
Mike Griese 37c4cbee74 Account for window frame on button hittesting 2021-11-16 11:39:23 -06:00
Sergey 7bfaad4592
Fix missing window border when use "win+arrow down" in fullscreen mode in Conhost (#11692)
Window exits out of fullscreen if it receives SC_RESTORE

Closes #10607
2021-11-16 16:14:54 +00:00
Mike Griese 77975e88f0 Merge remote-tracking branch 'origin/main' into dev/migrie/nc-titlebar-chswan 2021-11-16 09:53:25 -06:00
Mike Griese c455418659
Separate terminal version and Windows version in issue template (#11528) 2021-11-16 07:24:42 -06:00
Mike Griese 065e5f7d90 fix unit test build 2021-11-16 07:07:01 -06:00
Mike Griese d675fd824a figure this out 2021-11-16 06:35:31 -06:00
Mike Griese b421ee6ca0 Merge remote-tracking branch 'origin/main' into dev/migrie/oop/ragnarok 2021-11-16 06:22:35 -06:00
Mike Griese 841ced7e57 cant type when it's 26 degrees in here 2021-11-16 06:06:42 -06:00
Mike Griese 056446cd3e guard some GetActiveTerminalControl calls 2021-11-16 05:58:06 -06:00
Mike Griese 25947c2f40 cleanup for the tests" 2021-11-16 05:35:47 -06:00
Mike Griese 2445cedb92 this passes all the tests 2021-11-16 05:13:16 -06:00
Mike Griese 8e43c9d8ce more tests 2021-11-15 11:22:41 -06:00
Mike Griese fd72b7992e Merge remote-tracking branch 'origin/main' into dev/migrie/f/non-terminal-content-elevation-warning 2021-11-15 10:39:36 -06:00
Mike Griese c79334ffbb
Add a file for storing elevated-only state (#11222)
## Summary of the Pull Request

This creates an `elevated-state.json` that lives in `%LOCALAPPDATA%` next to `state.json`, that's only writable when elevated. It doesn't _use_ this file for anything, it just puts the framework down for use later.

It's _just like `ApplicationState`_. We'll use it the same way. 

It's readable when unelevated, which is nice, but not writable. If you're dumb and try to write to the file when unelevated, it'll just silently do nothing.

If we try opening the file and find out the permissions are different, we'll _blow the file away entirely_. This is to prevent someone from renaming the original file (which they can do unelevated), then slapping a new file that's writable by them down in it's place. 

## References
* We're going to use this in #11096, but these PRs need to be broken up.

## PR Checklist
* [x] Closes nothing
* [x] I work here
* [x] Tests added/passed
* [ ] Requires documentation to be updated - maybe? not sure we have docs on `state.json` at all yet

## Validation Steps Performed
I've played with this much more in `dev/migrie/f/non-terminal-content-elevation-warning`

###### followed by #11308, #11310
2021-11-13 01:58:43 +01:00
Leonard Hecker 2353349fe5
Introduce AtlasEngine - A new text rendering prototype (#11623)
This commit introduces "AtlasEngine", a new text renderer based on DxEngine.
But unlike it, DirectWrite and Direct2D are only used to rasterize glyphs.
Blending and placing these glyphs into the target view is being done using
Direct3D and a simple HLSL shader. Since this new renderer more aggressively
assumes that the text is monospace, it simplifies the implementation:
The viewport is divided into cells, and its data is stored as a simple matrix.
Modifications to this matrix involve only simple pointer arithmetic and is easy
to understand. But just like with DxEngine however, DirectWrite
related code remains extremely complex and hard to understand.

Supported features:
* Basic text rendering with grayscale AA
* Foreground and background colors
* Emojis, including zero width joiners
* Underline, dotted underline, strikethrough
* Custom font axes and features
* Selections
* All cursor styles
* Full alpha support for all colors
* _Should_ work with Windows 7

Unsupported features:
* A more conservative GPU memory usage
  The backing texture atlas for glyphs is grow-only and will not shrink.
  After 256MB of memory is used up (~20k glyphs) text output
  will be broken until the renderer is restarted.
* ClearType
* Remaining gridlines (left, right, top, bottom, double underline)
* Hyperlinks don't get full underlines if hovered in WT
* Softfonts
* Non-default line renditions

Performance:
* Runs at up to native display refresh rate
  Unfortunately the frame rate often drops below refresh rate, due us
  fighting over the buffer lock with other parts of the application.
* CPU consumption is up to halved compared to DxEngine
  AtlasEngine is still highly unoptimized. Glyph hashing
  consumes up to a third of the current CPU time.
* No regressions in WT performance
  VT parsing and related buffer management takes up most of the CPU time (~85%),
  due to which the AtlasEngine can't show any further improvements.
* ~2x improvement in raw text throughput in OpenConsole
  compared to DxEngine running at 144 FPS
* ≥10x improvement in colored VT output in WT/OpenConsole
  compared to DxEngine running at 144 FPS
2021-11-13 00:10:06 +00:00
Mike Griese bad27a97ba THIS NEEDS TO GO TO THE PARENT
(cherry picked from commit b499d44d4baf21c279dbb9f3a766bc9c37528b62)
2021-11-11 17:05:28 -06:00
Mike Griese a1bfa332f3 this was a nit 2021-11-11 16:33:05 -06:00
Mike Griese 8313987490 tests are hard 2021-11-11 16:32:26 -06:00
Mike Griese 97d11d1bd3 Merge branch 'dev/migrie/f/just-elevated-state-2' into dev/migrie/f/non-terminal-content-elevation-warning 2021-11-11 13:01:37 -06:00
Mike Griese 7f03d4d1ea dustins nits 2021-11-11 12:58:50 -06:00
Mike Griese 33e96e7e66 mitigate a TOCTOU 2021-11-11 12:56:05 -06:00
Mike Griese efdc0909e8 fix the tests 2021-11-11 12:52:08 -06:00
Mike Griese 999f21fcf8 Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-elevated-state-2 2021-11-11 11:55:05 -06:00
Mike Griese 7bb8975953 more todos 2021-11-11 11:40:15 -06:00
Mike Griese 8532dd692e fix conflicts with #11625 2021-11-11 11:38:50 -06:00
Mike Griese a338ca168c Merge remote-tracking branch 'origin/main' into dev/migrie/oop/ragnarok 2021-11-11 11:08:54 -06:00
Mike Griese 5adb327703 rename this one too 2021-11-11 10:34:25 -06:00
Mike Griese 1a7649ce21 turns out this _was_ overkill 2021-11-11 10:24:09 -06:00
Mike Griese a9e706c573 fix previewing, again 2021-11-11 09:58:06 -06:00
Mike Griese 2a18d7dae3 This is a checkpoint
* Dismissing a preview with an unfocused appearance is what's really broken here. That's never going to be able to go back to the original table, because the original table will be replaced with the unfocused appearance's table on the dismiss.
    - Going to fix that by using the focused appearance's table by default for the scheme when there's an unfocused appearance.
  * This is a little janky still, we flash the old schemes through on dismiss, which is probably wrong.
2021-11-11 08:28:53 -06:00
Mike Griese ae833a77bd notes, because it's 5pm here 2021-11-10 16:54:31 -06:00
Mike Griese 88f2e64bb3 Transparency is hard 2021-11-10 16:51:09 -06:00
Dustin Howett f6965aeb53 Merge remote-tracking branch 'openconsole/inbox' 2021-11-10 16:30:41 -06:00
Mike Griese 6e8a2adbd9 MIKE YOU HAVE TEST CASES HERE
This works for opacity for all Terminal cases. Need to still fix conhost.

```json
    "persistedWindowLayouts" :
    [
        {
            "initialPosition" : "149,43",
            "initialSize" :
            {
                "height" : 901.0,
                "width" : 1499.0
            },
            "tabLayout" :
            [
                {
                    "action" : "newTab",
                    "commandline" : "c:\\windows\\system32\\cmd.exe /k colortool.exe -c",
                    "profile" : "One Half Light + cleartype + acrylic",
                    "startingDirectory" : null,
                    "suppressApplicationTitle" : false,
                    "tabTitle" : "One Half Light + cleartype + acrylic"
                },
                {
                    "action" : "splitPane",
                    "commandline" : "c:\\windows\\system32\\cmd.exe /k colortool.exe -c",
                    "profile" : "One Half Light + cleartype + vintage",
                    "size" : 0.5,
                    "split" : "right",
                    "splitMode" : "manual",
                    "startingDirectory" : null,
                    "suppressApplicationTitle" : false,
                    "tabTitle" : "One Half Light + cleartype + vintage"
                },
                {
                    "action" : "moveFocus",
                    "direction" : "previousInOrder"
                },
                {
                    "action" : "splitPane",
                    "commandline" : "c:\\windows\\system32\\cmd.exe /k colortool.exe -c",
                    "profile" : "One Half Light + grayscale + acrylic",
                    "size" : 0.70000004768371582,
                    "split" : "down",
                    "splitMode" : "manual",
                    "startingDirectory" : null,
                    "suppressApplicationTitle" : false,
                    "tabTitle" : "One Half Light + grayscale + acrylic"
                },
                {
                    "action" : "splitPane",
                    "commandline" : "c:\\windows\\system32\\cmd.exe /k colortool.exe -c",
                    "profile" : "One Half Light + cleartype + acrylic(100)",
                    "size" : 0.5,
                    "split" : "down",
                    "splitMode" : "manual",
                    "startingDirectory" : null,
                    "suppressApplicationTitle" : false,
                    "tabTitle" : "One Half Light + cleartype + acrylic(100)"
                },
                {
                    "action" : "moveFocus",
                    "direction" : "nextInOrder"
                },
                {
                    "action" : "splitPane",
                    "commandline" : "c:\\windows\\system32\\cmd.exe /k colortool.exe -c",
                    "profile" : "One Half Light + grayscale + vintage",
                    "size" : 0.70000004768371582,
                    "split" : "down",
                    "splitMode" : "manual",
                    "startingDirectory" : null,
                    "suppressApplicationTitle" : false,
                    "tabTitle" : "One Half Light + grayscale + vintage"
                },
                {
                    "action" : "splitPane",
                    "commandline" : "c:\\windows\\system32\\cmd.exe /k colortool.exe -c",
                    "profile" : "One Half Light + cleartype + vintage(100)",
                    "size" : 0.5,
                    "split" : "down",
                    "splitMode" : "manual",
                    "startingDirectory" : null,
                    "suppressApplicationTitle" : false,
                    "tabTitle" : "One Half Light + cleartype + vintage(100)"
                },
                {
                    "action" : "focusPane",
                    "id" : 5
                },
            ]
        }
    ]
```

    with the following profiles:

    ```json
            {
                "antialiasingMode": "cleartype",
                "colorScheme": "One Half Light",
                "commandline": "c:\\windows\\system32\\cmd.exe /k colortool.exe -c",
                "font":
                {
                    "size": 8
                },
                "guid": "{e7f732da-f5c2-5f52-afd2-82518887a012}",
                "name": "One Half Light + cleartype + acrylic",
                "opacity": 50,
                "useAcrylic": true
            },
            {
                "antialiasingMode": "cleartype",
                "colorScheme": "One Half Light",
                "commandline": "c:\\windows\\system32\\cmd.exe /k colortool.exe -c",
                "font":
                {
                    "size": 8
                },
                "guid": "{e52bc30c-4fa8-5650-9c00-b619544efa5e}",
                "name": "One Half Light + cleartype + vintage",
                "opacity": 50,
                "useAcrylic": false
            },
            {
                "antialiasingMode": "grayscale",
                "colorScheme": "One Half Light",
                "commandline": "c:\\windows\\system32\\cmd.exe /k colortool.exe -c",
                "font":
                {
                    "size": 8
                },
                "guid": "{a870263b-0a3f-561f-82d2-bafc1163f1fc}",
                "name": "One Half Light + grayscale + acrylic",
                "opacity": 50,
                "useAcrylic": true
            },
            {
                "antialiasingMode": "grayscale",
                "colorScheme": "One Half Light",
                "commandline": "c:\\windows\\system32\\cmd.exe /k colortool.exe -c",
                "font":
                {
                    "size": 8
                },
                "guid": "{58a6ffb9-ead3-53ae-a696-c3eb27292578}",
                "name": "One Half Light + grayscale + vintage",
                "opacity": 50,
                "useAcrylic": false
            },
            {
                "antialiasingMode": "cleartype",
                "colorScheme": "One Half Light",
                "commandline": "c:\\windows\\system32\\cmd.exe /k colortool.exe -c",
                "font":
                {
                    "size": 8
                },
                "name": "One Half Light + cleartype + acrylic(100)",
                "opacity": 100,
                "useAcrylic": true
            },
            {
                "antialiasingMode": "cleartype",
                "colorScheme": "One Half Light",
                "commandline": "c:\\windows\\system32\\cmd.exe /k colortool.exe -c",
                "font":
                {
                    "size": 8
                },
                "name": "One Half Light + cleartype + vintage(100)",
                "opacity": 100,
                "useAcrylic": false
            },

    ```
2021-11-10 16:20:13 -06:00
Mike Griese 59c193c22a okay, so it's just vintage(100)+cleartype that doesn't work. Everything else gracefully falls back to grayscale 2021-11-10 15:54:32 -06:00
Mike Griese 713f72e1e5 5/6 transparency cases seem to work. Previewing with unfocused apprearance is broken again. 2021-11-10 15:42:10 -06:00
Matt Peterson d5974f4c91
Automatically convert paths dropped on WSL instances (#11625)
Drag and drop does not work for WSL because paths are pasted as windows
paths having incorrect path separator and path root.  This PR adds code
to correct the path in TerminalControl before pasting to WSL terminals.

One problem with this approach is that it assumes the default WSL
automount root of "/mnt". It would be possible to add a setting like
"WslDragAndDropMountRoot"... but I decided it if someone wants to change
automount location it would be simple enough just to create the "/mnt"
symlink in WSL.

## Validation
Couldn't find an obvious place to add a test.  Manually tested
cut-n-paste from following paths:
- "c:\"
- "c:\subdir"
- "c:\subdir\subdir"
- "\\wsl.localhost\<distro>"
- \\wsl.localhost\<distro>\subdir"

Closes #331
2021-11-10 21:19:52 +00:00
Dustin Howett 3fc82c2d4b Migrate OSS up to 305255c65 2021-11-10 15:07:17 -06:00