Commit graph

1845 commits

Author SHA1 Message Date
Param Siddharth c5366cea75
Minor grammatical fix (#8603)
Merely fixed the capitalization of a word.

## Detailed Description of the Pull Request / Additional comments
- Inside `doc/AddASetting.md`, on line 14, the sentence previously began with the verb "add" with a lowercase alphabet.
- I replaced "add" with "Add".
  ``` md
  [12] ...  
  [13]   2. Add matching fields to Settings.hpp
  [14]     - Add getters, setters, the whole drill.
  [15] ...
  ```
2020-12-17 15:12:36 -08:00
Kiminori Kaburagi 477c04ab94
Cleanup extraneous local leftover from #8194 (#8605)
Cleanup extraneous local leftover from #8194

## PR Checklist
* [x] Closes leftover from #8194
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA.
2020-12-17 23:06:50 +00:00
Kiminori Kaburagi b8e6b8e27c
Set Tab tooltip explicitly (#8298)
<!-- 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
The tab tooltip is no longer empty when it was toggle zoomed.
<!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> 
## References

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [x] Closes #8199 
* [ ] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* [ ] 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
2020-12-17 14:22:19 +00:00
Austin Lamb 539a5dc0af
Greatly reduce allocations in the conhost/OpenConsole startup path (#8489)
I was looking at conhost/OpenConsole and noticed it was being pretty
inefficient with allocations due to some usages of std::deque and
std::vector that didn't need to be done quite that way.

So this uses std::vector for the TextBuffer's storage of ROW objects,
which allows one allocation to contiguously reserve space for all the
ROWs - on Desktop this is 9001 ROW objects which means it saves 9000
allocations that the std::deque would have done.  Plus it has the
benefit of increasing locality of the ROW objects since deque is going
to chase pointers more often with its data structure.

Then, within each ROW there are CharRow and ATTR_ROW objects that use
std::vector today.  This changes them to use Boost's small_vector, which
is a variation of vector that allows for the so-called "small string
optimization."  Since we know the typical size of these vectors, we can
pre-reserve the right number of elements directly in the
CharRow/ATTR_ROW instances, avoiding any heap allocations at all for
constructing these objects.

There are a ton of variations on this "small_vector" concept out there
in the world - this one in Boost, LLVM has one called SmallVector,
Electronic Arts' STL has a small_vector, Facebook's folly library has
one...there are a silly number of these out there.  But Boost seems like
it's by far the easiest to consume in terms of integration into this
repo, the CI/CD pipeline, licensing, and stuff like that, so I went with
the boost version.

In terms of numbers, I measured the startup path of OpenConsole.exe on
my dev box for Release x64 configuration.  My box is an i7-6700k @ 4
Ghz, with 32 GB RAM, not that I think machine config matters much here:

|        | Allocation count    | Allocated bytes    | CPU usage (ms) |
| ------ | ------------------- | ------------------ | -------------- |
| Before | 29,461              | 4,984,640          | 103            |
| After  | 2,459 (-91%)        | 4,853,931 (-2.6%)  | 96 (-7%)       |

Along the way, I also fixed a dynamic initializer I happened to spot in
the registry code, and updated some docs.

## Validation Steps Performed
- Ran "runut", "runft" and "runuia" locally and confirmed results are
  the same as the main branch
- Profiled the before/after numbers in the Visual Studio profiler, for
  the numbers shown in the table

Co-authored-by: Austin Lamb <austinl@microsoft.com>
2020-12-16 10:40:30 -08:00
PankajBhojwani 551cc9a98b
Add a progress ring indicator to the tab header (#8133)
This commit adds a [progress ring] to the tab header when we receive an
OSC 9 sequence. 

Adds an event handler in `Tab.cpp` for the event we raise when we get a
request to set the taskbar state/progress. This event handler updates
the tab header with the active control's state/progress. 

When we want to show the progress ring, we hide the tab icon and place
the progress ring over it. 

[progress ring]: https://docs.microsoft.com/en-us/uwp/api/Microsoft.UI.Xaml.Controls.ProgressRing?view=winui-2.4

References #6700
2020-12-16 02:45:15 +00:00
Don-Vito 22d43a431c
Introduce parsed command line text to command palette (#8515)
This commit introduces another optional text block in palette that will
be shown in the command line mode (above the history). This text block
will either contain a list of parsed command lines or a description why
the parsing failed

Closes #8344
Closes #7284
2020-12-16 02:03:13 +00:00
Dustin L. Howett fb3d772615
Convert DeviceComm into an interface and add handle exchange (#8367)
This commit replaces DeviceComm with the interface IDeviceComm and the
concrete implementation type ConDrvDeviceComm. This work is done in
preparation for different device backends.

In addition to separating out ConDrv-specific behavior, I've introduced
a "handle exchange" interface.

HANDLE EXCHANGE
---------------

There are points where we give ConDrv opaque handle identifiers to our
input buffer, output buffer and process data. The exact content of the
opaque identifier is meaningless to ConDrv: the driver's only
interaction with these identifiers is to hold onto them and send back
whichever are pertinent for each API call.

Because of that, we used the raw register-width pointer value of the
input buffer, output buffer or process data _as_ the opaque handle
value.

This works very well for ConDrv <-> conhost using the ConDrvDeviceComm.
It works less well for something like the "logging" DeviceComm that will
log packets to a file: those packets *cannot* contain pointer values (!)

To address this, and to afford flexibility to DeviceComm implementers,
I've introduced a two-member complement of handle management functions:

* `ULONG_PTR PutHandle(void*)` registers an object with the DeviceComm
  and returns an opaque identifier.
* `void* GetHandle(ULONG_PTR)` takes an opaque identifier and returns
  the original object.

ConDrvDeviceComm implements PutHandle and GetHandle by casting the
object pointer to the "opaque handle value", which maintains wire format
compatibility[1] with revisions of conhost prior to this change.

Simpler DeviceComm implementations that require handle tracking but
cannot bear raw pointers can implement these functions by returning an
autoincrementing ID (or similar) and registering the raw object pointer
in a mapping.

I've audited all existing handle exchanges with the driver and updated
them to use Put/GetHandle.

(I intended to add DestroyHandle, but we are not equipped for handle
removal at the moment. ConsoleHandleData/ConsoleProcessHandle are
destroyed during wait routine completion, on client disconnect, etc.
This does mean that an id<->pointer mapping will grow without bound, but
at a cost of ~8 bytes per entry and a short-lived console session I am
not too concerned about the cost.)

[1] Wire format compatibility is not required, and later we may want to
switch ConDrvDeviceComm to `EncodePointer` and `DecodePointer` just to
insulate us against a spurious ConDrv packet allowing for an arbitrary
4/8-byte read and subsequent liftoff into space.
2020-12-15 23:07:43 +00:00
Mike Griese b140299e50
Implement user-specified pixel shaders, redux (#8565)
Co-authored-by: mrange <marten_range@hotmail.com>

I loved the pixel shaders in #7058, but that PR needed a bit of polish
to be ready for ingestion. This PR is almost _exactly_ that PR, with
some small changes.

* It adds a new pre-profile setting `"experimental.pixelShaderPath"`,
  which lets the user set a pixel shader to use with the Terminal.
    - CHANGED FROM #7058: It does _not_ add any built-in shaders.
    - CHANGED FROM #7058: it will _override_
      `experimental.retroTerminalEffect`
* It adds a bunch of sample shaders in `samples/shaders`. Included: 
    - A NOP shader as a base to build from.
    - An "invert" shader that inverts the colors, as a simple example
    - An "grayscale" shader that converts all colors to grayscale, as a
      simple example
    - An "raster bars" shader that draws some colored bars on the screen
      with a drop shadow, as a more involved example
    - The original retro terminal effects, as a more involved example
    - It also includes a broken shader, as an example of what heppens
      when the shader fails to compile
    - CHANGED FROM #7058: It does _not_ add the "retroII" shader we were
      all worried about.
* When a shader fails to be found or fails to compile, we'll display an
  error dialog to the user with a relevant error message.
    - CHANGED FROM #7058: Originally, #7058 would display "error bars"
      on the screen. I've removed that, and had the Terminal disable the
      shader entirely then.
* Renames the `toggleRetroEffect` action to `toggleShaderEffect`.
  (`toggleRetroEffect` is now an alias to `toggleShaderEffect`). This
  action will turn the shader OR the retro effects on/off. 

`toggleShaderEffect` works the way you'd expect it to, but the mental
math on _how_ is a little weird. The logic is basically:

```
useShader = shaderEffectsEnabled ? 
                (pixelShaderProvided ? 
                    pixelShader : 
                    (retroEffectEnabled ? 
                        retroEffect : null
                    )
                ) : 
                null
```

and `toggleShaderEffect` toggles `shaderEffectsEnabled`.

* If you've got both a shader and retro enabled, `toggleShaderEffect`
  will toggle between the shader on/off.
* If you've got a shader and retro disabled, `toggleShaderEffect` will
  toggle between the shader on/off.

References #6191
References #7058

Closes #7013

Closes #3930 "Add setting to retro terminal shader to control blur
radius, color" 
Closes #3929 "Add setting to retro terminal shader to enable drawing
scanlines" 
     - At this point, just roll your own version of the shader.
2020-12-15 20:40:22 +00:00
Kiminori Kaburagi e943785e1a
Calculate initial height properly (#8584)
Closes #8527
2020-12-15 20:29:08 +00:00
Don-Vito da6705c086
Fix deserialization failure message of combined types (#8558)
Closes #7690
2020-12-15 11:33:52 -08:00
Don-Vito a1f42e87a8
Fix Copy to Clipboard to preserve visual structure of block selection (#8579)
There are two issue with copy to clipboard when block is selected:
* We don't add new lines for lines that were wrapped
* We remove trailing whitespaces which is not intuitive in block selection.

Fixed the copy logic to always add newlines and not to remove
whitespaces when block is selected.

Even if shift is pressed!

## Detailed Description of the Pull Request / Additional comments
* Added optional parameter to `TextBuffer::GetText` 
that allows to apply formatting (includeCRLF / trimming) 
to lines that were wrapped
* Changed `Terminal::RetrieveSelectedTextFromBuffer` 
to apply the following parameters when block is selected:
  * includeCRLF = true
  * trimTrailingWhitespaces = false
  * apply the formatting above to all rows, including the ones 
that were wrapped 

## Validation Steps Performed
* Manual tests for both block and standard selection
* Copy with both right-click and command
* Added UT

Closes #6740
2020-12-14 23:32:44 +00:00
James Holderness cae0f9a718
Fix color selection operations in conhost (#8577)
In conhost there is a keyboard shortcut that applies colors to the
selected range of text, and another shortcut that searches for the
selected text, and applies colors to any matching content. The former
operation doesn't work correctly when the selection is wrapped, and both
have problems when the selected text spans DBCS characters. This PR
attempts to fix those issues.

The problem with the color section was that it applied the color to a
simple rect spanning the start and end points of the selection. I've now
updated it to use the `Selection::GetSelectionRects` method, which
correctly handles a wrapped range of lines, and makes sure that double
width characters are fully covered.

The problem with the "find-and-color" operation was in the way it
obtained the search text from the selected screen cells. Since it
retrieved one cell at a time, and a DBCS character can span two cells,
that resulted in some characters being repeated in the search text. I've
now corrected that code to take the width of the characters into
account.

## Validation Steps Performed
I've manually verified that the test cases described in #8572 and #8574
are now working correctly.

Closes #8572
Closes #8574
2020-12-14 19:45:49 +00:00
Dustin Howett 61ccf44f22
Revert "Enable shortcut while CommandPalette is open (#8044)"
This reverts commit 1965fb5e73.
2020-12-14 11:35:50 -08:00
Mike Griese ff5b2b84d2
Replace the KB Dialog with a InfoBar (#8524)
This changes the keyboard warning from a dialog to an `InfoBar`, which
we just got in MUX 2.5. Some users were unhappy that we'd always display
the dialog. We learned from the input team that this service _should_
always be enabled. We're also learing from users that they don't always
want it enabled. 

We're working with the Input team to help us figure out how this service
can be disabled _and the Terminal work just fine_. They're confident
that it _shouldn't_. For 99% of our users, they're right. So we don't
want to get rid of the dialog entirely, we want to understand how this
is possible. While we wait, let's make the message less aggressive.

This is instead of making a `iKnowWhatImDoingDisableTheKeyboardWarning`
setting to disable the dialog. Props to @cornem for suggesting the less
aggressive solution. 

## Validation Steps Performed
Tested manually, but by forcing the message to always display. Disabling
the service requires two full reboots, and _ain't nobody got time for
that_.

Closes #8228
Closes #4448, for now
2020-12-14 17:37:33 +00:00
Kiminori Kaburagi 1965fb5e73
Enable shortcut while CommandPalette is open (#8044)
<!-- 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
It is maybe not the best way since I had to get all the cases for key handling so I just created for each of them. As a result the code get longer(not optimized). Most difficult thing was Next tab and Previous tab I just could not solve it.

### 9 commands that couldn't enabled > <
     1. Increase font size               -> could not find VirtualKey for "-"
     2. Decrease font size             -> could not find VirtualKey for "+"
     3. Split pane, split:horizontal -> could not find VirtualKey for "-"
     4. Split pane, split:vertical     -> could not find VirtualKey for "+"
     5. Open default settings        -> could not find VirtualKey for ","
     6. Open settings file               -> could not find VirtualKey for ","
     7. Open new tab dropdown    -> could not resolve keybindings
     8. Next tab                               -> could not resolve keybindings
     9. Previous tab                        -> could not resolve keybindings
 
<!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> 
## References

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [x] Closes #6679
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* [ ] 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
2020-12-14 17:11:24 +00:00
Dustin Howett d02812d699 Add a keybinding option to Terminal to open the Settings UI (#8048)
This commit iontroduces another `target` to the `openSettings` binding:
`settingsUI`. It opens the settings UI introduced in the previous
commit.

Closes #1564
Closes #8048 (PR)

Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
Co-authored-by: Leon Liang <lelian@microsoft.com>
2020-12-11 13:47:10 -08:00
Dustin Howett 3e2b94334d Introduce the Terminal Settings Editor (#8048)
This commit introduces the terminal settings editor (to wit: the
Settings UI) as a standalone project. This project, and this commit, is
the result of two and a half months of work.

TSE started as a hackathon project in the Microsoft 2020 Hackathon, and
from there it's grown to be a bona-fide graphical settings editor.

There is a lot of xaml data binding in here, a number of views and a
number of view models, and a bunch of paradigms that we've been
reviewing and testing out and designing and refining.

Specified in #6720, #8269
Follow-up work in #6800
Closes #1564
Closes #8048 (PR)

Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com>
Co-authored-by: Alberto Medina Gutierrez <almedina@microsoft.com>
Co-authored-by: John Grandle <jograndl@microsoft.com>
Co-authored-by: xerootg <xerootg@users.noreply.github.com>
Co-authored-by: Scott <sarmiger1@gmail.com>
Co-authored-by: Vineeth Thomas Alex <vineeththomasalex@gmail.com>
Co-authored-by: Leon Liang <lelian@microsoft.com>
Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
Signed-off-by: Dustin L. Howett <duhowett@microsoft.com>
2020-12-11 13:47:10 -08:00
Carlos Zamora b80a4e45cc
Introduce ProfileDefaults, CreateNewProfile, default icon
This commit is an amalgamation of some of the TSM changes in PR #8048.
It:
* Introduces CascadiaSettings.CreateNewProfile to add a new profile
* Introduces CascadiaSettings.ProfileDefaults, which returns the
  "defaults" object as a profile
* Fixes the font weight deserializer to work on uint16_ts
* Fixes a property getter in ColorScheme to not be a property getter
* Fixes a reserialization error with default profiles
* Sets a default icon for all profiles (to the C:\ Segoe MDL2 icon)
2020-12-11 13:22:16 -08:00
Leon Liang 1d10235c8e
Introduce public enum name<->value mappings to TSM
The settings UI will eventually need to know about the available enum
values for a given field. This offers that capability.
2020-12-11 13:19:03 -08:00
Leon Liang 2f9f103282
Move IconSourceConverter from TerminalApp to TSM
The Settings UI will need to take a dependency on IconSourceConverter.
2020-12-11 13:17:22 -08:00
Chester Liu 219ee0c654
Exclude more rarely-used stuff from Windows headers (#8513)
This PR defines a series of `NOSOMETHING` macros in PCHs, in order to
prevent `windows.h` from bringing a lot of rarely used things into the
project. 

Theoretically this should make PCH generation and overall complication
faster, but I didn't really benchmark the speed. 

Another benefit would be reducing the symbol noises caused by
`windows.h`.
2020-12-11 19:35:23 +00:00
Don-Vito 8f60cfae41
Fix next tab activation in focus mode upon tab closing (#8549)
## PR Checklist
* [x] Closes https://github.com/microsoft/terminal/issues/7916
* [x] CLA signed. 
* [ ] Tests added/passed
* [ ] Documentation updated. 
* [ ] Schema updated.
* [ ] I've discussed this with core contributors already. 

## Detailed Description of the Pull Request / Additional comments
Upon tab close the tabview is responsible to issue tab selection for the next active tab.
However this doesn't happen when tabview is hidden.
There was a special treatment for this scenario for full screen mode.
Added the same treatment to focus mode (as the tabview is not visible in this case as well).

## Validation Steps Performed
Manual tests
2020-12-11 18:58:48 +00:00
Kayla Cinnamon ba8f38507e
Settings UI inheritance spec (#8269)
Spec on how we display profile inheritance inside the settings UI.

[Markdown View](https://github.com/microsoft/terminal/blob/dev/cazamor/spec/sui-inheritance/doc/specs/%231564%20-%20Settings%20UI/cascading-settings.md)

## References
#1564 - Settings UI
2020-12-11 10:42:57 -08:00
PankajBhojwani 04309a2a49
Support for navigating panes by MRU (#8183)
Adds a "move to previous pane" and "move to next pane" keybinding, which
navigates to the last/first focused pane

We assign pane IDs on creation and maintain a vector of active pane IDs
in MRU order. Navigating panes by MRU then requires specifying which
pane ID we want to focus. 

From our offline discussion (thanks @zadjii-msft for the concise
description):

> For the record, the full spec I'm imagining is:
> 
> { command": { "action": "focus(Next|Prev)Pane", "order": "inOrder"|"mru", "useSwitcher": true|false } },
> 
> and order defaults to mru, and useSwitcher will default to true, when
> there is a switcher. So 
> 
> { command": { "action": "focusNextPane" } },
> { command": { "action": "focusNextPane", "order": "mru" } },
> 
> these are the same action. (but right now we don't support the order
> param)
>  
> Then there'll be another PR for "focusPane(target=id)"
> 
> Then a third PR for "focus(Next|Prev)Pane(order=inOrder)"

> for the record, I prefer this approach over the "one action to rule
> them all" version with both target and order/direction as params,
> because I don't like the confusion of what happens if there's both
> target and order/direction provided. 

References #1000 
Closes #2871
2020-12-11 18:36:05 +00:00
Dustin L. Howett eb2be374fd
Fix SA for Visual Studio 16.8 (#8551)
I added `enum class` to one thing and decided that that was quite enough
before disabling the `enum class` warning.

Looks like 16.8 made more map/vector operations noexcept, so we have to
re-annotate to remain compliant.
2020-12-11 05:04:30 +00:00
Don-Vito 4111be389d
Make schema compliant by fixing CloseTab* index definitions (#8547)
* The index field should be of type `"null"` and not `null`.
* The default value should be `null` and not `""`

Closes #8024
2020-12-10 20:26:56 -08:00
Mike Griese f751cad2cf
Add some logging around tab renamer usage (#8520)
We've got similar logging around the command palette, we really should have the same logging on the tab renamer as well.

## PR Checklist
* [x] I work here
* [ ] Tests added/passed
* [n/a] Requires documentation to be updated

## Validation Steps Performed

![image](https://user-images.githubusercontent.com/18356694/101487414-c237af80-3923-11eb-9997-81549e4f1a1b.png)
Look, it works
2020-12-10 17:12:50 +00:00
Dustin L. Howett 540cc33d1f
Update Win32 Toolkit (6.1.2) and VCRT Forwarders (1.0.4) (#8501)
There's a handful of small changes in these updates:

The Win32 Toolkit is now built with CFG (I think), and
the VCRT forwarders are now the (second) non-RC version.
2020-12-10 01:30:00 +00:00
Kiminori Kaburagi 6952f1acda
Change tab close and rename icons to better fit the UI (#8424)
Closes #8419

Co-authored-by: KiminoriKaburagi <heipo_nogu@outlook.jp>
2020-12-09 17:25:50 -08:00
Don-Vito c2e84d1a90
Teach Find command to populate the search box with selected text (#8521)
If a single line of text is selected, use it to populate the search box.

Closes #8307
2020-12-10 01:24:16 +00:00
Don-Vito 89d82ff546
Teach CommandPalette model to natively support tabs and command lines (#8420)
First step towards #8415:
* Introduce `PaletteItem` and derive from it to provide native support
  for tabs and command lines (`ActionPaletteItem` / `TabPaletteItem`,
  `CommandLinePaltteItem`)
* Remove business logic behind PaletteItem from palette (aka dispatch
  commands and preview tabs externally)
2020-12-10 00:36:28 +00:00
Don-Vito e1a8657370
Make command palette ephemeral (#8377)
So the implementation is somewhat dirty.
The ideas was nice - add lostFocusHandler

However it broke few things:
* In the TabSwitcher the ListItem must be focusable since otherwise 
the SingleSelectionMode behavior breaks. 
To address this I had to put the lostFocusHandler on the items as well
 
* When you click the flyout, the palette loses focus, 
which makes the terminal page to set the focus on the tab, closing the flyout. 
To address this I had to ensure the tab won't get focused once the flyout is open.
In addition, flyout should fix the focus before opening, 
otherwise alt+tab will put a focus on a tab row rather than on tab

* I also had to close the palette if the tab order changes.
To prevent inconsistencies.

Closes #8355
2020-12-09 22:01:08 +00:00
Dustin L. Howett 0bf9dcb63e
Delete the old PackageES code signing configs (#8536)
We've moved to the recommended internal code signing service
and no longer need these configurations.
2020-12-09 12:50:42 -08:00
Mike Griese 1d08288406
Fix the feature tests with a retry (#8534)
A bunch of our feature tests don't work reliably in CI. They rely on
creating a new `OpenConsole.exe` window, then running the test _in that
console_. As a part of that test setup, the test runner used to wait a
second to attach to the newly created console. Then the test goes on
it's merry way, assuming the console is ready to go. However, in CI,
that might take more than a second. If it does, then the test would fail
pretty immediately, as soon as it tries to get at the buffer of the new
console.

This PR introduces a little retry loop to the test init. After attaching
to the new console, we'll try and get at the screen buffer. If that
fails, we'll wait a second and try again. We'll try 5 times total,
before bailing entirely. Hopefully, this should mitigate most of the
random CI failures we get in the feature tests.

Closes #8495
2020-12-09 11:02:23 -08:00
Kiminori Kaburagi 0b88694c07
Add ScrollHome and ScrollEnd (#8459)
<!-- 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
This PR adds shortcut action so that users can scroll.
I used `UINT16_MAX` for `rowsToScroll`.
<!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> 
## References

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [x] Closes #7542
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* [ ] 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
2020-12-08 17:28:41 +00:00
Austin Lamb ddfb6adb98
Add a subset of boost (#8492)
In my #8489 we want to use boost's small_vector type, but that PR is
kinda messy by adding boost and also making a meaningful change.  So
here I'm splitting out the boost addition to its own PR so that one can
be more focused on the allocation improvement and consumption of boost.
2020-12-05 01:25:55 +00:00
Mike Griese 05c0d4c0e4
Add a keybinding to break straight into the debugger (#8498)
Have you ever wanted to debug the Terminal, but weren't sure which of
your Terminal windows was the one you needed to attach to? Now you don't
need to worry! Simply execute the `breakIntoDebugger` action, and the
Terminal will `DebugBreak()` for you!

This requires that the user has set `"debugFeatures": true`

Validated by adding a command:
{
    "command": "breakIntoDebugger",
    "keys": "ctrl+alt+shift+f1",
    "name": "DebugBreak()"
},

...and verifying that it pops open the post-mortem debugger (windbg).
2020-12-04 15:54:59 -08:00
Dustin L. Howett 87492c4a26
Update to Microsoft.UI.Xaml 2.5 "stable" (#8500)
This commit moves us to the Xaml prerelease (201202003) that is
equivalent to public stable release 2.5.

Remember, we need to use prereleases for some silly reason.
2020-12-04 23:49:45 +00:00
Dustin L. Howett d944d9f181
wpf: target netcoreapp3.1, clean up test project path (#8491)
There were some minor annoyances with the WPF projects.

1. WpfTerminalTestNetCore was in an unnecessary same-named subdirectory
2. The build started throwing deprecation warnings because `netcoreapp3.0` is not LTS and is going away.
2020-12-04 18:17:25 +00:00
Mike Griese 88039532cd
Fix the path to the local unittests in runut (#8499)
This is the same root cause as #8485. We moved the output of a bunch
of projects to be unified. We forgot to update all the test scripts.

In this case, the LocalTests were still using the old path that's
_not_ under `bin/`
2020-12-04 10:08:40 -08:00
Dustin L. Howett 956a045a85
doc: Add a spec for Application State (#7972)
This commit introduces a specification for "cross-session" app state
that isn't stored in the user's settings.json.

Specs #8324
2020-12-03 17:52:03 -08:00
James Holderness 3ccd831a3b
Fix rendering of DBCS characters when partially off screen (#8438)
When the renderer is called on to render part of a line starting halfway
through a DBCS character (as can occur in conhost when the viewport is
offset horizontally), it could result in the character not being
displayed, and/or with following the characters drawn in the wrong
place. This PR is an attempt to fix those problems. 

The original code for handling the trailing half of fullwidth glyphs was
introduced in PR #4668 to fix issue #2191.

When the content being rendered starts with the trailing half of a DBCS
character, the renderer tries to move the `screenPoint` back a position,
so it can instead render the full character, but instructing the render
engine to trim off the left half of it.

If the X position was already in column 0, though, it would instead move
forward one position, intending to skip that character. At best this
would mean the half character wouldn't be rendered, but since the
iterator wasn't incremented correctly, it actually just ended up
rendering the character in the wrong place.

The fix for this was simply to drop the check for the X position being
in column 0, and allow it go negative. The rendering engine would then
just start rendering the character partially off screen, and only the
second half of it would be displayed, which is exactly what is needed.

The second problem was that the code incrementing the iterator was using
the `columnCount` variable rather than the `it->Columns()` value for the
current position. When dealing with the trailing half of a DBCS
character, the `columnCount` is 2, but the `Columns()` value is 1. If
you use the former rather than the later, then the renderer may skip the
following character.

## Validation Steps Performed
I've developed a more easily reproducible version of the test case
described in #8390, and confirmed that the problem no longer occurs when
this PR is applied.

I've also manually confirmed that the problem described in #2191 that
was fixed by PR #4668 is still working correctly now.

Closes #8390
2020-12-04 00:39:23 +00:00
James Holderness 2a2f6b32a2
Correct horizontal coordinates in viewport overflow test (#8456)
When resizing the buffer in the `SetConsoleScreenBufferSize` and
`SetConsoleScreenBufferInfoEx` APIs, we have tests in place to make sure
that the resize doesn't result in the viewport extending past the bottom
or right of the buffer (since that can eventually result in exceptions
being thrown). Unfortunately these tests were using the wrong X
coordinate, so they failed to detect an overflow along the horizontal
axis. This PR corrects that mistake.

PR #8309 was where the overflow detection was initially added.

The original code was using the `Viewport::EndExclusive` method to
determine the extent of the viewport, mistakenly thinking that it
returned the bottom right coordinates (it actually returns the left
coordinate). So I've now added a `BottomRightExclusive` method to the
`Viewport` class, that actually does return the coordinates we need, and
have updated the overflow tests to use that method instead.

## Validation Steps Performed
I've manually confirmed that the test case is issue #8453 is no longer
throwing an exception. 

Closes #8453
2020-12-03 21:53:16 +00:00
Dustin L. Howett 104a4e48bd
Refactor DEC/ANSI modes to avoid duplication when we add SM/RM (#8469)
I was about to add `SetAnsiMode`/`ResetAnsiMode` for `SM` and `RM` when I
realized that we probably don't need yet another enum of mode types, set and
reset functions, and a mode helper for ANSI standard modes when we already have
one for DEC Private modes.

This commit:

1. Changes the enum `PrivateModeParams` to just be `ModeParams`
2. Differentiates ANSI Standard modes (IRM, KAM, SRM, ...) from DEC
   Private modes (DECCOLM, DECCKM, ...) using a flag bit set in the enum
   value.
3. Introduces a helper class for constructing these values much like
   `VTID`. That helper takes a bitmask and applies it to an input to
   produce the final enum value.
4. Dispatches all mode set/reset through a common Set/Reset and
   `_ModeHelper` that uses the existing enum values.

[1] These modes are in separate namespaces with some overlap. We want to
differentiate them at dispatch time to ensure that `\e[2h` and `\e[?2h` are
given different treatment, and ensure that `\e[1000h` doesn't activate xterm
mouse mode.

Fixes #8457.
2020-12-03 21:51:59 +00:00
Mike Griese 8d26f45278
Add a bunch of my specs to the roadmap (#8487)
I've opened a bunch of specs for features on the roadmap. 
It's probably best if I actually updated the roadmap to reflect them.
2020-12-03 13:01:02 -06:00
James Holderness 3995196072
Correct paths in the the runut and runft test scripts (#8488)
This corrects the path to `Terminal.Core.Unit.Tests.dll` in the `runut`
unit test script and makes the `runft` feature test script capable of
working with _Release_ builds as well as _Debug_ builds.

The path to `Terminal.Core.Unit.Tests.dll` changed when the project was
restructured, and the `runut` script was never updated to reflect that
change. That has now been corrected.

And the `runft` script used to be hard coded to look for tests in the
_Debug_ directory, but it has now been updated to use the
`%_LAST_BUILD_CONF%` environment variable, so it should work for both
_Debug_ and _Release_ builds.

## Validation Steps Performed
I've manually confirmed that the `runut` and `runft` scripts now work as
expected.

Closes #8485
2020-12-03 10:38:18 -08:00
Don-Vito f072eaf9d8
Add launchMode parameter to ToggleCommandPalette action (#8382)
## PR Checklist
* [x] Closes https://github.com/microsoft/terminal/issues/8322
* [x] CLA signed. 
* [x] Tests added/passed
* [x] Documentation updated - https://github.com/MicrosoftDocs/terminal/pull/202
* [x] Schema updated.
* [x] I've discussed this with core contributors already. 

## Detailed Description of the Pull Request / Additional comments
Added an optional launchMode parameter to "commandPalette" command. 
The values of the launchMode are either "action" (default) or "command line".

## Validation Steps Performed
* Manual tests
2020-12-03 16:15:31 +00:00
Chester Liu 3181b6a517
Improve OSC 8 Hyperlink parsing logic (#7962)
This PR improves the OSC 8 Hyperlink parsing logic, by adding support to
`:` in params.

## Validation Steps Performed

Tests added & passed.
2020-12-03 00:33:29 +00:00
Chester Liu 60f1b0b285
Improve clipboard handling in "drag and drop" scenario (#8461)
This PR improves the clipboard handling logic of "drag and drop" in
TermControl, making it more useful and less likely to crash.

* Added support for two more categories of content, `ApplicationLink`
  and `WebLink`.
* Reordered the ifs, making `StorageItem` the last clause. With WT being
  a text-oriented application, I think we can safely assume that the
  content being pasted is likely to be text/links.
* Catch possible exceptions during
  `e.DataView().GetStorageItemsAsync()`.

Closes #7804
2020-12-02 23:30:52 +00:00
Carlos Zamora d3bcd85900
Represent BackgroundImageAlignment as ConvergedAlignment (#8468)
`backgroundImageAlignment` is exposed as 1 setting in the JSON, but
stored as two separate settings (`HorizontalAlignment` and
`VerticalAlignment`). This PR introduces `ConvergedAlignment` as a flag
enum that can be a combination of horizontal and vertical Alignments.
TSM now solely uses this `ConvergedAlignment`, and TerminalSettings
performs a conversion from this new enum to the traditional
`HorizontalAlignment` and `VerticalAlignment` for consumption.

## Validation Steps Performed
Manually tested changing the `backgroundImageAlignment` in my
settings.json and checking if the image updated appropriately.
2020-12-02 23:14:11 +00:00