Commit graph

2783 commits

Author SHA1 Message Date
Mike Griese 065e5f7d90 fix unit test build 2021-11-16 07:07:01 -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 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 999f21fcf8 Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-elevated-state-2 2021-11-11 11:55:05 -06:00
Dustin Howett f6965aeb53 Merge remote-tracking branch 'openconsole/inbox' 2021-11-10 16:30:41 -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
Leonard Hecker 305255c658
Fix a conhost binary size regression due to fmt (#11727)
6140fd9 causes a binary size regression in conhost.
This PR fixes most if not all of the regression, by replacing `FMT_STRING`
with `FMT_COMPILE` allowing us to drop most of the formatters built
into fmt during linking (for instance floating point formatters).

Additionally `std::wstring` was replaced with `fmt::basic_memory_buffer`
in the same vein as was done for VtEngine. Stack is
cheap and this prevents any unnecessary allocations.

## PR Checklist
* [x] I work here
* [x] Tests added/passed

## Validation Steps Performed
* vttest 11.2.5.3.6.7 and .8 (DECSTBM and SGR) complete successfully 
2021-11-10 21:03:47 +00:00
Mike Griese 08cbd16d47 the last of it? 2021-11-10 10:17:41 -06:00
Mike Griese db9cbf3fa8 spell 2021-11-10 10:16:31 -06:00
Mike Griese 7024f44c96 whoops 2021-11-10 10:01:52 -06:00
Dustin Howett 7db7ba1ac9 ci: fix spelling for inbox merge 2021-11-09 17:22:55 -06:00
Dustin Howett 89c2b6d580 Merge remote-tracking branch 'openconsole/inbox' 2021-11-09 17:16:59 -06:00
Dustin Howett 92643c1d34 Merged PR 6654362: [Git2Git] OS build fixes for f9b97c488
Retrieved from https://microsoft.visualstudio.com os.2020 OS official/rs_wdx_dxp_windev 063b86ac10af16cade5c0754adcbf27e7e9ae266

Related work items: MSFT-34534216, MSFT-36986009, MSFT-36986203
2021-11-09 23:16:26 +00:00
Dustin Howett e591d29000 Migrate OSS up to f9b97c488 2021-11-09 13:39:28 -06:00
Dustin Howett 88d58d313a Migrate OSS up to 3f1befb06 (Touch Keyboard Invocation) 2021-11-09 13:39:23 -06:00
Dustin Howett 87182554c8 Migrate OSS up to e5180fe88 2021-11-09 13:39:09 -06:00
Dustin Howett 5ff412fe6e Migrate OSS up to 5deb33260 (A11y Degenerate Word Movement) 2021-11-09 13:33:49 -06:00
Dustin Howett 30f7f2082b Migrate OSS up to 168d28b03 2021-11-09 13:33:29 -06:00
Dustin Howett e6b871da47 Migrate OSS up to d08afc4e8 (A11y End Of Buffer) 2021-11-09 13:32:34 -06:00
Dustin Howett f9c0f86705 Migrate OSS up to 4793541c 2021-11-09 13:32:14 -06:00
Dustin Howett 86da0e041f Migrate OSS up to c53fe1c2b (A11y End Of Buffer) 2021-11-09 13:26:44 -06:00
Dustin Howett a89b66f770 Merged PR 6598109: [Git2Git] Pull Request 6508625: Update TAEF to vPack 10.63 (latest)
A change required significant changes in TAEF published headers. This PR consumes those changes.

Related work items: #20301352
2021-11-09 19:21:35 +00:00
Mike Griese 1c66877b72 pwsh core fixed too 2021-11-09 12:44:05 -06:00
Mike Griese 5253c114ae make sure event handlers get replaced, too 2021-11-09 11:57:46 -06:00
Mike Griese fdc574929b make text selectable 2021-11-09 10:34:54 -06:00
Mike Griese c09bdbd25e Merge branch 'dev/migrie/f/just-elevated-state-2' into dev/migrie/f/non-terminal-content-elevation-warning 2021-11-09 10:32:47 -06:00
Mike Griese ce6a9c571b Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-elevated-state-2 2021-11-09 08:24:25 -06:00
Mike Griese a93d17ef09 I believe this is the rest of the comments 2021-11-09 08:24:18 -06:00
Mike Griese 4f16dfb5fd many comments 2021-11-09 08:01:47 -06:00
Mike Griese b21287140d this is the right way to initialize the unique_hlocal_security_descriptor 2021-11-09 07:47:12 -06:00
Mike Griese 25b2675d8d this works really quite well 2021-11-09 06:24:16 -06:00
Mike Griese fd849a5241 trying to do the thing eryksun mentioned. This seems to actually work to prevent non-admins from writing the file, and BOY is it simple. Still doesn't prevent the vim situation, but also do we need to prevent that footgun? probably 2021-11-08 14:30:07 -06:00
Ikko Ashimine f9b97c4880
doc: Fix typo in #885 - Terminal Settings Model.md (#11657)
Fixed typo: ocurred -> occurred

* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
2021-11-08 12:18:50 -08:00
Mike Griese a74c37bbcd
Don't crash if we fail to BeginBufferedPaint (#11674)
Fixes MSFT:34673647, at least I'm pretty sure. That's only ever hit a few
times externally, and internally it's hitting a lot on 1.9.1942 builds, which
doesn't really make any sense.
2021-11-05 19:26:59 +00:00
Sergey 55dbda02a5
fix build error at 74d21af (#11691)
#11404 and #11653 both added WM_SYSCOMMAND which prevents build. This fixes it.
2021-11-05 19:26:03 +00:00
Sergey 7aae2e9100
Fix missing window border when use "win+arrow down" in fullscreen mode in Terminal (#11653)
Window sends an event that requests exit from fullscreen then SC_RESTORE messages is sent and it is in fullscreen mode.
Closes #10607

## Validation Steps Performed
Border and tabbar now appear after exiting fullscreen via "win+arrow down".
2021-11-04 23:46:57 +00:00
Kai 74d21afacf
README.md: HTTP => HTTPS (#11671)
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? -->
## Summary of the Pull Request
Checked the link, skipping the redirect HTTP => HTTPS this way 0:-)

This one
http://azuredevopspodcast.clear-measure.com/kayla-cinnamon-and-rich-turner-on-devops-on-the-windows-terminal-team-episode-54
is still only available via HTTP, sadly.

<!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> 
## References
<http://www.runasradio.com/Shows/Show/645> is being redirected to <https://www.runasradio.com/Shows/Show/645>

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* N/A Closes #xxx
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* N/A Tests added/passed
* N/A Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* N/A Schema updated.
* [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

<!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here -->
## ~~Detailed Description of the Pull Request / Additional comments~~

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
Opened the link.
2021-11-04 22:45:19 +00:00
PankajBhojwani 52b4bb760f
Unify splitting panes and creating new tabs (#11305)
Implements `_MakePane` in `TerminalPage`, which creates a pane that then can be used to pass into another pane to split or to create a new tab with. Places where we split pane or create a new tab now use `_MakePane`. 

## PR Checklist
* [x] Closes #11021
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [x] I work here

## Validation Steps Performed
Stands up to manual testing with multiple new pane/new tab commands as well as startup actions
2021-11-04 22:29:58 +00:00
James Holderness b604117421
Standardize the color table order (#11602)
## Summary of the Pull Request

In the original implementation, we used two different orderings for the color tables. The WT color table used ANSI order, while the conhost color table used a Windows-specific order. This PR standardizes on the ANSI color order everywhere, so the usage of indexed colors is consistent across both parts of the code base, which will hopefully allow more of the code to be shared one day.

## References

This is another small step towards de-duplicating `AdaptDispatch` and `TerminalDispatch` for issue #3849, and is essentially a followup to the SGR dispatch refactoring in PR #6728.

## PR Checklist
* [x] Closes #11461
* [x] CLA signed.
* [x] Tests added/passed
* [ ] Documentation updated.
* [ ] Schema updated.
* [x] I've discussed this with core contributors already. Issue number where discussion took place: #11461

## Detailed Description of the Pull Request / Additional comments

Conhost still needs to deal with legacy attributes using Windows color order, so those values now need to be transposed to ANSI colors order when creating a `TextAttribute` object. This is done with a simple mapping table, which also handles the translation of the default color entries, so it's actually slightly faster than the original code.

And when converting `TextAttribute` values back to legacy console attributes, we were already using a mapping table to handle the narrowing of 256-color values down to 16 colors, so we just needed to adjust that table to account for the translation from ANSI to Windows, and then could make use of the same table for both 256-color and 16-color values.

There are also a few places in conhost that read from or write to the color tables, and those now need to transpose the index values. I've addressed this by creating separate `SetLegacyColorTableEntry` and `GetLegacyColorTableEntry` methods in the `Settings` class which take care of the mapping, so it's now clearer in which cases the code is dealing with legacy values, and which are ANSI values.

These methods are used in the `SetConsoleScreenBufferInfoEx` and `GetConsoleScreenBufferInfoEx` APIs, as well as a few place where color preferences are handled (the registry, shortcut links, and the properties dialog), none of which are particularly sensitive to performance. However, we also use the legacy table when looking up the default colors for rendering (which happens a lot), so I've refactored that code so the default color calculations now only occur once per frame.

The plus side of all of this is that the VT code doesn't need to do the index translation anymore, so we can finally get rid of all the calls to `XTermToWindowsIndex`, and we no longer need a separate color table initialization method for conhost, so I was able to merge a number of color initialization methods into one. We also no longer need to translate from legacy values to ANSI when generating VT sequences for conpty.

The one exception to that is the 16-color VT renderer, which uses the `TextColor::GetLegacyIndex` method to approximate 16-color equivalents for RGB and 256-color values. Since that method returns a legacy index, it still needs to be translated to ANSI before it can be used in a VT sequence. But this should be no worse than it was before.

One more special case is conhost's secret _Color Selection_ feature. That uses `Ctrl`+Number and `Alt`+Number key sequences to highlight parts of the buffer, and the mapping from number to color is based on the Windows color order. So that mapping now needs to be transposed, but that's also not performance sensitive.

The only thing that I haven't bothered to update is the trace logging code in the `Telemetry` class, which logs the first 16 entries in the color table. Those entries are now going to be in a different order, but I didn't think that would be of great concern to anyone.

## Validation Steps Performed

A lot of unit tests needed to be updated to use ANSI color constants when setting indexed colors, where before they might have been expecting values in Windows order. But this replaced a wild mix of different constants, sometimes having to use bit shifting, as well as values mapped with `XTermToWindowsIndex`, so I think the tests are a whole lot clearer now. Only a few cases have been left with literal numbers where that seemed more appropriate.

In addition to getting the unit tests working, I've also manually tested the behaviour of all the console APIs which I thought could be affected by these changes, and confirmed that they produced the same results in the new code as they did in the original implementation.

This includes:
- `WriteConsoleOutput`
- `ReadConsoleOutput`
- `SetConsoleTextAttribute` with `WriteConsoleOutputCharacter`
- `FillConsoleOutputAttribute` and `FillConsoleOutputCharacter` 
- `ScrollConsoleScreenBuffer`
- `GetConsoleScreenBufferInfo`
- `GetConsoleScreenBufferInfoEx`
- `SetConsoleScreenBufferInfoEx`

I've also manually tested changing colors via the console properties menu, the registry, and shortcut links, including setting default colors and popup colors. And I've tested that the "Quirks Mode" is still working as expected in PowerShell.

In terms of performance, I wrote a little test app that filled a 80x9999 buffer with random color combinations using `WriteConsoleOutput`, which I figured was likely to be the most performance sensitive call, and I think it now actually performs slightly better than the original implementation.

I've also tested similar code - just filling the visible window - with SGR VT sequences of various types, and the performance seems about the same as it was before.
2021-11-04 22:13:22 +00:00