Commit graph

219 commits

Author SHA1 Message Date
ironyman 9ae43377b0 Add experimental retro terminal effects (#3468)
<!-- 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
Cool retro terminal effects
- glow
- scan lines
- cool
- will make terminal competitive with iterm2

<!-- 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
* [ ] Closes #xxx
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Requires documentation to be 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
![image](https://user-images.githubusercontent.com/502496/68365644-20bda900-00e6-11ea-8a9d-0a4482e48c5a.png)
2019-12-12 13:44:01 +00:00
Carlos Zamora 2b8b034b89
Attach UiaRenderer and Fire Selection Changed Events (#2989)
This PR makes use of the UiaRenderer by attaching it to the TerminalControl and setting up selectionChanged events for accessibility.

Part 1: attaching the UiaRenderer
The uiaRenderer is treated very similarly to the dxRenderer. We have a unique_ptr ref to it in the TermControl. This gets populated when the TermControlAutomationPeer is created (thus enabling accessibility).

To prevent every TermControl from sending signals simultaneously, we specifically only enable whichever one is in an active pane.

The UiaRenderer needs to send encoded events to the automation provider (in this case, TermControlAutomationPeer). We needed our own automation events so that we can reuse this model for ConHost. This is the purpose of IUiaEventDispatcher.

We need a dispatcher for the UiaRenderer. Otherwise, we would do a lot of work to find out when to fire an event, but we wouldn't have a way of doing that.

Part 2: hooking up selection events
This provides a little bit of polish to hooking it up before. Primarily to actually make it work. This includes returning S_FALSE instead of E_NOTIMPL.

The main thing here really is just how to detect if a selection has changed. This also shows how clean adding more events will be in the future!
2019-12-11 13:52:49 -08:00
Dustin L. Howett (MSFT) 901a1e1a09
Implement ConnectionState and closeOnExit=graceful/always/never (#3623)
This pull request implements the new
`ITerminalConnection::ConnectionState` interface (enum, event) and
connects it through TerminalControl to Pane, Tab and App as specified in
#2039. It does so to implement `closeOnExit` = `graceful` in addition to
the other two normal CoE types.

It also:

* exposes the singleton `CascadiaSettings` through a function that
  looks it up by using the current Xaml application's `AppLogic`.
  * In so doing, we've broken up the weird runaround where App tells
    TerminalSettings to CloseOnExit and then later another part of App
    _asks TerminalControl_ to tell it what TerminalSettings said App
    told it earlier. `:crazy_eyes:`
* wires up a bunch of connection state points to `AzureConnection`.
  This required moving the Azure connection's state machine to use another
  enum name (oops).
* ships a helper class for managing connection state transitions.
* contains a bunch of template magic.
* introduces `WINRT_CALLBACK`, a oneshot callback like `TYPED_EVENT`.
* replaces a bunch of disparate `_connecting` and `_closing` members
  with just one uberstate.
* updates the JSON schema and defaults to prefer closeOnExit: graceful
* updates all relevant documentation

Specified in #2039
Fixes #2563

Co-authored-by: mcpiroman <38111589+mcpiroman@users.noreply.github.com>
2019-11-25 14:22:29 -08:00
Daniel599 0e36ce4d60 Reset font size key bindings (#3505)
## Summary of the Pull Request
This PR implements resetFontSize keybindings, with default keybindings `ctrl+0`.

## PR Checklist
* [x] Closes #3319
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Requires documentation to be updated

## Validation Steps Performed
Tested manually.
-----------------------------------------
* Add resetFontSize keybindings (#3319)

* update doc files

* Refactor AdjustFontSize & ResetFontSize to use _SetFontSize (#3319)

* Ran clang-format on TermControl

* Fix function usage change
2019-11-25 11:35:10 -06:00
Dustin L. Howett (MSFT) 714d79e2c8
Revert "Throttle scroll position update" (#3660)
This reverts commit 1177815f81.
2019-11-21 16:26:21 -08:00
Phil Nachreiner 62d7f11b4a Add a Windows.UI.Text.Core IME overlay to TerminalControl (#1919)
TerminalControl doesn't use any of the built in text input and edit
controls provided by XAML for text input, which means TermianlControl
needs to communicate with the Text Services Framework (TSF) in order to
provide Input Method Editor (IME) support.  Just like the rest of
Terminal we get to take advantage of newer APIs (Windows.UI.Text.Core)
namespace to provide support vs. the old TSF 1.0.

Windows.UI.Text.Core handles communication between a text edit control
and the text services primarily through a CoreTextEditContext object.

This change introduces a new UserControl TSFInputControl which is a
custom EditControl similar to the CustomEditControl sample[1].

TSFInputControl is similar (overlay with IME text) to how old console
(conimeinfo) handled IME. 

# Details
TSFInputControl is a Windows.UI.Xaml.Controls.UserControl

TSFInputControl contains a Canvas control for absolution positioning a
TextBlock control within its containing control (TerminalControl).

The TextBlock control is used for displaying candidate text from the
IME.  When the user makes a choice in the IME the TextBlock is cleared
and the text is written to the Terminal buffer like normal text.

TSFInputControl creates an instance of the CoreTextEditContext and
attaches appropriate event handlers to CoreTextEditContext in order to
interact with the IME.

A good write-up on how to interact with CoreTextEditContext can be found
here[2].

## Text Updates
Text updates from the IME come in on the TextUpdating event handler,
text updates are stored in an internal buffer (_inputBuffer).

## Completed Text
Once a user selects a text in the IME, the CompositionCompleted handler
is invoked.  The input buffer (_inputBuffer) is written to the Terminal
buffer, _inputBuffer is cleared and Canvas and TextBlock controls are
hidden until the user starts a composition session again.

## Positioning
Telling the IME where to properly position itself was the hardest part
of this change.  The IME expects to know it's location in screen
coordinates as supposed to client coordinates.  This is pretty easy if
you are a pure UWP, but since we are hosted inside a XAMLIsland the
client to screen coordinate translation is a little harder.  

### Calculating Screen Coordinates
1. Obtaining the Window position in Screen coordinates.
2. Determining the Client coordinate of the cursor.
3. Converting the Client coordinate of the cursor to Screen coordinates.
4. Offsetting the X and Y coordinate of the cursor by the position of
   the TerminalControl within the window (tabs if present, margins, etc..).
5. Applying any scale factor of the display.

Once we have the right position in screen coordinates, this is supplied
in the LayoutBounds of the CoreTextLayoutRequestedEventArgs which lets
the IME know where to position itself on the Screen.

## Font Information/Cursor/Writing to Terminal
3 events were added to the TSFInputControl to create a loosely-coupled
implementation between the TerminalControl and the TSFInputControl.
These events are used for obtaining Font information from the
TerminalControl, getting the Cursor position and writing to the terminal
buffer.

## Known Issues

- Width of TextBlock is hardcoded to 200 pixels and most likely should
  adjust to the available width of the current input line on the console
  (#3640)
- Entering text in the middle of an existing set of text has TextBlock
  render under existing text. Current Console behavior here isn't good
  experience either (writes over text)
- Text input at edges of window is clipped versus wrapping around to
  next line.  This isn't any worse than the original command line, but
  Terminal should be better (#3657)

## Future Considerations
Ideally, we'd be able to interact with the console buffer directly and
replace characters as the user types. 

## Validation
General steps to try functionality
- Open Console
- Switch to Simplified Chinese (Shortcut: Windows+Spacebar)
- Switch to Chinese mode on language bar

Scenarios validated:
- As user types unformatted candidates appear on command line and IME
  renders in correct position under unformatted characters.
- User can dismiss IME and text doesn't appear on command line 
- Switch back to English mode, functions like normal
- New tab has proper behavior
- Switching between tabs has proper behavior
- Switching away from Terminal Window with IME present causes IME to
  disappear

[1]: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CustomEditControl
[2]: https://docs.microsoft.com/en-us/windows/uwp/design/input/custom-text-input

Closes #459
Closes #2213
Closes #3641
2019-11-21 16:25:50 -08:00
Carlos Zamora 2915be5b51
Upgrade UiaProviders to WRL::ComPtr (#3051) 2019-11-21 16:08:37 -08:00
Anirudh Rayabharam 13406b746b Copy RTF data to the clipboard (#3535)
## Summary of the Pull Request
RTF data is now copied to the clipboard. Tested by copy pasting text from terminal to WordPad.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [x] Closes #2487
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Requires documentation to be updated
* [x] 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: #2487

<!-- 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
Mostly similar to PR #1224. Added a new static method `GenRTF` in `TextBuffer` that is responsible
for generating the RTF representation of a given text. The generated RTF is added to the `DataPackage` that is ultimately passed to the clipboard.

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
Validated by copy pasting text from the terminal to WordPad. Validated with different colors to make sure that is working. (MS Word seems to prefer HTML data from the clipboard instead of RTF.)

<hr>

* Copy RTF data to the clipboard

* Added comment explaining various parts of the header

* Fixed static code analysis issues and added noexcept to GenRTF()

* Removed noexcept
2019-11-13 14:13:22 -06:00
Leon Liang a404778271 Add Selection Background Color as a setting to Profiles and Col… (#3471)
<!-- 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 introduces a setting to both Profiles and ColorSchemes called <code>selectionBackground</code> that allows you to change the selection background color to what's specified. If <code>selectionBackground</code> isn't set in either the profile or color scheme, it'll default to what it was before - white.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [x] Closes #3326
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [x] Tests added/passed
* [x] Requires documentation to be updated

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
- Added selectionBackground to existing profile and colorscheme tests.
- Verified that the color does change to what I expect it to be when I add "selectionBackground" to either/both a profile and a color scheme.


<hr>

* adding selectionBackground to ColorScheme and TerminalSettings

* Changing PaintSelection inside the renderers to take a SelectionBackground COLORREF

* changes to conhost and terminal renderdata, and to terminal settings and core

* IT WORKS

* modification of unit tests, json schemas, reordering of functions

* more movement

* changed a couple of unit tests to add selectionBackground, added the setting to schemas, also added the optional setting to profiles

* default selection background should be slightly offwhite like the default foreground is

* reverting changes to .sln

* cleaning up

* adding comment

* oops

* added clangformat to my vs hehe

* moving selectionBackground to IControlSettings and removing from ICoreSettings

* trying to figure out why the WHOLE FILE LOOKS LIKE ITS CHANGED

* here it goes again

* pls

* adding default foreground as the default for selection background in dx
2019-11-13 12:17:39 -06:00
Chester Liu 1177815f81 Throttle scroll position update (#3531)
<!-- 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

Another tiny performance fix.

<!-- 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

Correct me if I'm wrong, It doesn't really make sense to update scroll status faster than frame rate limit.

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

<hr>

* Throttle scroll position update

* Review
2019-11-13 07:23:31 -06:00
Mike Griese 306e751639 Fixes #3518 (#3521) 2019-11-13 02:12:43 +00:00
d-bingham fee3fdf322 Replacing \r\n line endings with \r line endings (#3449)
<!-- 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

<!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> 
## References

#1091 
#1094 
#2390 
#3314

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [x] Closes #1091
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Requires documentation to be updated
* [x] 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

Combination of the PRs #1094, #2390, and #3314, especially as discussed in #3314.

In short, this changes line endings from Windows-space \r\n to the more universal \r.

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

Copied and pasted text into the terminal without the patch, line endings were doubled.
With the patch, line endings weren't doubled.


--------------------

* Replacing \r\n line endings with \r line endings

* Fixing Formatting
2019-11-06 08:02:55 -06:00
Dustin L. Howett (MSFT) 9dc922fc37
Unify and clean up the common build properties (#3429)
This commit cleans up and deduplicates all of the common build
preamble/postamble across exe, dll, lib and c++/winrt projects.

The following specific changes have been made:
* All projects now define their ConfigurationType
* All projects now set all their properties *before* including a common
  build file (or any other build files)
* cppwinrt.pre and cppwinrt.post now delegate most of their
  configuration to common.pre and common.post
* (becuase of the above,) all build options are conserved between
  console and c++/winrt components, including specific warnings and
  preprocessor definitions.
* More properties that are configurable per-project are now
  conditioned so the common props don't override them.
* The exe, dll, exe.or.dll, and lib postincludes have been merged into
  pre or post and switched based on condition as required
* Shared items (-shared, -common) are now explicitly vcxitems instead of
  vcxproj files.
* The link line is now manipulated after Microsoft.Cpp sets it, so the
  libraries we specify "win". All console things link first against
  onecore_apiset.lib.
* Fix all compilation errors caused by build unification
* Move CascadiaPackage's resources into a separate item file

Fixes #922.
2019-11-05 14:29:11 -08:00
mcpiroman 8c8672c87a Fix scrollbar update after terminal close (#3256) 2019-11-01 09:40:29 -07:00
Dustin L. Howett (MSFT) 1925173b02
TermControl: force all ambiguous glyphs to be narrow (#2928)
From Egmont Koblinger:
> In terminal emulation, apps have to be able to print something and
keep track of the cursor, whereas they by design have no idea of the
font being used. In many terminals the font can also be changed runtime
and it's absolutely not feasible to then rearrange the cells. In some
other cases there is no font at all (e.g. the libvterm headless terminal
emulation library, or a detached screen/tmux), or there are multiple
fonts at once (a screen/tmux attached from multiple graphical
emulators).

> The only way to do that is via some external agreement on the number
of cells, which is typically the Unicode EastAsianWidth, often accessed
via wcwidth(). It's not perfect (changes through Unicode versions, has
ambiguous characters, etc.) but is still the best we have.

> glibc's wcwidth() reports 1 for ambiguous width characters, so the de
facto standard is that in terminals they are narrow.

> If the glyph is wider then the terminal has to figure out what to do.
It could crop it (newer versions of Konsole, as far as I know), overflow
to the right (VTE), shrink it (Kitty I believe does this), etc.

See Also:
https://bugzilla.gnome.org/show_bug.cgi?id=767529
https://gitlab.freedesktop.org/terminal-wg/specifications/issues/9
https://www.unicode.org/reports/tr11/tr11-34.html

Salient point from proposed update to Unicode Standard Annex 11:
> Note: The East_Asian_Width property is not intended for use by modern
terminal emulators without appropriate tailoring on a case-by-case
basis.

Fixes #2066
Fixes #2375 

Related to #900
2019-10-15 14:54:57 -07:00
Dustin L. Howett (MSFT) df26c677ef
Upgrade to Microsoft.UI.Xaml 2.2 (#3027)
* We had to move to the final API:
   * Items -> TabItems
   * Items.VectorChanged -> TabItemsChanged
   * TabClose -> TabCloseRequested
   * TabViewItem.Icon -> TabViewItem.IconSource
* TabRowControl has been converted to a ContentPresenter, which
  simplifies its logic a little bit.
* TerminalPage now differentiates MUX and WUX a little better
* Because of the change from Icon to IconSource in TabViewItem,
  Utils::GetColoredIcon needed to be augmented to support MUX IconSources.
  It was still necessary to use for WUX, so it's been templatized.
* I moved us from WUX SplitButton to MUX SplitButton and brought the
  style in line with the one typically provided by TabView.
* Some of our local controls have had their backgrounds removed so
  they're more amenable to being placed on other surfaces.
* I'm suppressing the TabView's padding.
* I removed a number of apparently dead methods from App.
* I've simplified the dragbar's sizing logic and eventing.
* The winmd harvester needed to be taught to not try to copy winmds for
  framework packages.
* We now only initialize the terminal once we know the size

Closes #1896.
Closes #444.
Closes #857.
Closes #771.
Closes #760.
2019-10-14 22:41:43 -07:00
Zoey Riordan b9233c03d1 add wpf control (#2004)
This adds the WPF control to our project, courtesy of the Visual Studio team.
It re-hosts the Terminal Control components inside a reusable WPF adapter so it can be composed onto C# type surfaces like Visual Studio requires.
2019-10-11 14:02:09 -07:00
Leonard Hecker 33361698f7 Partially fix mapping of virtual keys to characters (#2836) 2019-10-01 11:15:30 -05:00
Brandon 083be43700 Add keyboard shortcuts to increase and decrease font size (#2700)
* Hook up font size key bindings and events

* Combine increase and decrease font size events

* Add zoom keybindings to defaults.json

* Fix whitespace
2019-09-30 08:18:05 -05:00
Carlos Zamora 6b415126fd
Improve Accessibility Reliability (#2609)
* Remove WindowUiaProvider entry points
Make TerminalAutomationPeer not crash the app if creation failed.

* code format

* prefer universal initialization

Co-Authored-By: Dustin L. Howett (MSFT) <duhowett@microsoft.com>
2019-09-23 08:59:03 -07:00
mcpiroman ed87689c04 Set Proper Background Color in HTML Copy (#2762)
* Set actual background color in HTML copy

* const

Co-Authored-By: Mike Griese <migrie@microsoft.com>

* format
2019-09-16 10:32:04 -07:00
Carlos Zamora 2ac24979da
Stylus Selection Support (#2586) 2019-09-10 10:29:31 -06:00
Michael Niksa 886d018bb4 warnings as errors for cppwinrt projects, then fix the warnings (#2660)
Fixes #1155.
2019-09-04 16:43:45 -07:00
Marcel Freiberg 02d8df8431 Don't treat the Windows keys as input (#2514)
Fixes #2506.
2019-08-23 10:56:26 -07:00
Carlos Zamora be52880620 Accessibility: Add BoundingRects to UiaTextRanges (#2423) 2019-08-20 17:50:34 -07:00
Carlos Zamora ff87190823 Added CopyOnSelect as a Global Setting (#2152)
* Added CopyOnSelect as a ControlSetting

* Updated doc

* Updated doc

* CopyOnSelect feature changes (like, overall)

* Made CopyOnSelect a CoreSetting
CopyOnSelect value accessible through Terminal's IsCopyOnSelectActive

* Refactor a bit.

* CopyOnSelect Tests

* PR nits
2019-08-20 16:42:17 +00:00
Carlos Zamora 71eaf621bc Add support for HTML copy (#1224)
* Move Clipboard::GenHTML to TextBuffer (add params)
Refactor RetrieveSelectedTextFromBuffer
Modify CopyToClipboardEventArgs to include HTML data

* minor code format fix

* PR Changes
NOTE: refactoring text buffer code is a separate task. New issue to be created.

* Refactor TextBuffer::GenHTML (#2038)

Fixes #1846.

* nit change

* x86 build fix

* nit changes
2019-08-19 22:59:01 +00:00
Carlos Zamora bd47dcc898
Accessibility: Refactor IRenderData with IUiaData (#2296)
* Refactor IRenderData with IUiaData
* remove duplicate tracking of active selection
2019-08-19 11:03:45 -07:00
Mike Griese 734fc1dcc6 Don't copy text if there's no selection (#2446)
This commit also transitions our keybinding events and event handlers to a
TypedEventHandler model with an "event args" class, as specified in the
keybinding arguments specification (#1349). In short, every event can be marked
Handled independently, and a Handled event will stop bubbling out to the
terminal. An unhandled event will be passed off to the terminal as a standard
keypress.

This unifies our keybinding event model and provides a convenient place for
binding arguments to live.

Fixes #2285.
Related to #1349, #1142.
2019-08-16 15:43:51 -07:00
Leonard Hecker 4529e46d3e Fixed Ctrl+Alt shortcuts conflicting with AltGr (#2235)
This moves the detection of AltGr keypresses in front of the shortcut
handling. This allows one to have Ctrl+Alt shortcuts, while
simultaneously being able to use the AltGr key for special characters.
2019-08-05 16:58:48 -05:00
Carlos Zamora a08666b58e Accessibility: TermControl Automation Peer (#2083)
Builds on the work of #1691 and #1915 

Let's start with the easy change:
- `TermControl`'s `controlRoot` was removed. `TermControl` is a `UserControl`
  now.

Ok. Now we've got a story to tell here....

### TermControlAP - the Automation Peer
Here's an in-depth guide on custom automation peers:
https://docs.microsoft.com/en-us/windows/uwp/design/accessibility/custom-automation-peers

We have a custom XAML element (TermControl). So XAML can't really hold our
hands and determine an accessible behavior for us. So this automation peer is
responsible for enabling that interaction.

We made it a FrameworkElementAutomationPeer to get as much accessibility as
possible from it just being a XAML element (i.e.: where are we on the screen?
what are my dimensions?). This is recommended. Any functions with "Core" at the
end, are overwritten here to tweak this automation peer into what we really
need.

But what kind of interactions can a user expect from this XAML element?
Introducing ControlPatterns! There's a ton of interfaces that just define "what
can I do". Thankfully, we already know that we're supposed to be
`ScreenInfoUiaProvider` and that was an `ITextProvider`, so let's just make the
TermControlAP an `ITextProvider` too.

So now we have a way to define what accessible actions can be performed on us,
but what should those actions do? Well let's just use the automation providers
from ConHost that are now in a shared space! (Note: this is a great place to
stop and get some coffee. We're about to hop into the .cpp file in the next
section)


### Wrapping our shared Automation Providers

Unfortunately, we can't just use the automation providers from ConHost. Or, at
least not just hook them up as easily as we wish. ConHost's UIA Providers were
written using UIAutomationCore and ITextRangeProiuder. XAML's interfaces
ITextProvider and ITextRangeProvider are lined up to be exactly the same.

So we need to wrap our ConHost UIA Providers (UIAutomationCore) with the XAML
ones. We had two providers, so that means we have two wrappers.

#### TermControlAP (XAML) <----> ScreenInfoUiaProvider (UIAutomationCore)
Each of the functions in the pragma region `ITextProvider` for
TermControlAP.cpp is just wrapping what we do in `ScreenInfoUiaProvider`, and
returning an acceptable version of it.

Most of `ScreenInfoUiaProvider`'s functions return `UiaTextRange`s. So we need
to wrap that too. That's this next section...

#### XamlUiaTextRange (XAML) <----> UiaTextRange (UIAutomationCore)
Same idea.  We're wrapping everything that we could do with `UiaTextRange` and
putting it inside of `XamlUiaTextRange`.


### Additional changes to `UiaTextRange` and `ScreenInfoUiaProvider`
If you don't know what I just said, please read this background:
- #1691: how accessibility works and the general responsibility of these two
  classes
- #1915: how we pulled these Accessibility Providers into a shared area

TL;DR: `ScreenInfoUiaProvider` lets you interact with the displayed text.
`UiaTextRange` is specific ranges of text in the display and navigate the text.

Thankfully, we didn't do many changes here. I feel like some of it is hacked
together but now that we have a somewhat working system, making changes
shouldn't be too hard...I hope.

#### UiaTextRange
We don't have access to the window handle. We really only need it to draw the
bounding rects using WinUser's `ScreenToClient()` and `ClientToScreen()`. I
need to figure out how to get around this.

In the meantime, I made the window handle optional. And if we don't have
one....well, we need to figure that out. But other than that, we have a
`UiaTextRange`.

#### ScreenInfoUiaProvider
At some point, we need to hook up this automation provider to the
WindowUiaProvider. This should help with navigation of the UIA Tree and make
everything just look waaaay better. For now, let's just do the same approach
and make the pUiaParent optional.

This one's the one I'm not that proud of, but it works. We need the parent to
get a bounding rect of the terminal. While we figure out how to attach the
WindowUiaProvider, we should at the very least be able to get a bunch of info
from our xaml automation peer. So, I've added a _getBoundingRect optional
function. This is what's called when we don't have a WindowUiaProvider as our
parent.


## Validation Steps Performed
I've been using inspect.exe to see the UIA tree.
I was able to interact with the terminal mostly fine. A few known issues below.

Unfortunately, I tried running Narrator on this and it didn't seem to like it
(by that I mean WT crashed). Then again, I don't really know how to use
narrator other than "click on object" --> "listen voice". I feel like there's a
way to get the other interactions with narrator, but I'll be looking into more
of that soon. I bet if I fix the two issues below, Narrator will be happy.

## Miscellaneous Known Issues
- `GetSelection()` and `GetVisibleRanges()` crashes. I need to debug through
  these. I want to include them in this PR.

Fixes #1353.
2019-07-30 16:43:10 -07:00
Dustin L. Howett (MSFT) 3f62c8b470
Add some ETL around profile, control and connection creation (#2125)
This commit adds some tracelogging (and telemetry) to answer the following questions:
* Do people use padding? If so, what is the common range of values?
* Are people turning off showTabsInTitlebar?
* How many different profiles are in use, and how do they break down between custom and default?
* Are people manually launching specific profiles, or using "default" fairly often?
* Are people using the Azure Cloud Shell connection?
* Are people leveraging the feature added in #2108 (autogenerating GUIDs)?
2019-07-29 17:24:20 -07:00
Robert Jordan 89190c6e6c Add support for background image alignment (as one setting) (#1959)
* Implement base background image alignment settings

TerminalSettings now has two new properties:
* BackgroundImageHorizontalAlignment
* BackgroundImageVerticalAlignment

These properties are used in TermControl::_InitializeBackgroundBrush to specify the alignment for TermControl::_bgImageLayer.

This is a base commit that will split into two possible branches:
* Use one setting in profiles.json: "backgroundImageAlignment"
* Use two settings in profiles.json: "backgroundImageHorizontal/VerticalAlignment"

* Implement background image alignment profile setting

Implement background image alignment as one profile setting.
* This has the benefit of acting as a single setting when the user would likely want to change both horizontal and vertical alignment.
* HorizontalAlignment and VerticalAlignment are still stored as a tuple in Profile because they are an optional field. And thus, it would not make sense for one of the alignments to be left unused while the other is not.
* Cons are that the tuple signature is quite long, but it is only used in a small number of locations. The Serialize method is also a little mishapen with the nested switch statements. Empty lines have been added between base-level cases to improve readability.

* Fix capitalization typo for BackgroundImageStretchModeKey

In Profiles.cpp, the key for the image stretch mode json property had a lowercase 'i' in "Backgroundimage", not following proper UpperCamelCase.
The "i" has been capitalized and the two usages of the constant have been updated as well.

* Document Background Image settings

* Adds entries SettingsSchema.md for the original 3 backgroundImage settings in addition to the new backgroundImageAlignment setting.

* Fix setting capitalization error in UsingJsonSettings.md

* The background image example in UsingJsonSettings.md listing a backgroundImageStretchMode of "Fill" has been corrected to "fill".


Fixes #1949.
2019-07-24 21:47:06 -07:00
mcpiroman 5da2ab1a86 Scroll from selection dragging out of window (#1247) (#1523)
* Scroll from selection dragging out of window
* Review changes, dynamic dt measurement, function separation
2019-07-24 09:37:17 -07:00
Leonard Hecker 7067910862 Add a ControlKeyStates wrapper class (#1718)
* Fixed a minor build warning
* Removed an unimplemented method declaration
* Added Microsoft::Terminal::Core::ControlKeyStates
// This class will act as a safe wrapper for the ControlKeyState enum,
// found in the NT console subsystem (<um/wincon.h>).
2019-07-16 11:09:29 -07:00
Mike Griese 0905140955
Refactor TerminalApp and Add Tests for Xaml Content (#1164)
* Refactors TerminalApp into two projects: 
  - TerminalAppLib, which builds a .lib, and includes all the code
  - TerminalApp, which builds a dll by linking the lib
* Adds a TerminalApp.Unit.Tests project
  - Includes the ability to test cppwinrt types we've authored using a SxS manifest for unpackaged winrt activation
  - includes the ability to test types with XAML content using an appxmanifest
* Adds a giant doc explaining how this was all done. Really, just go read that doc, it'll really help you understand what's going on in this PR.

-------------------------
These are some previous commit messages. They may be helpful to future readers.

* Start adding unittests for json parsing, end up creating a TerminalAppLib project to make a lib. See #1042

* VS automatically did this for me

* This is a dead end

  I tried including the idl-y things into the lib, but that way leads insanity

  If you want to make a StaticLibrary, then suddenly the winrt toolchain forgets
  that ProjectReferences can have winmd's in them, so it won't be able to
  compile any types from the referenced projects. If you instead try to manually
  reference the types, you'll get duplicate types up the wazoo, which of course
  is insane, since we're referencing them the _one_ time

* Yea just follow #1042 on github for status

  So current state:

  1. If you try to add a `Reference` to all of MUX.Markup, TerminalControl and
     TerminalSettings, then mdmerge will complain about all   the types from
     TerminalSettings being defined twice. In this magic scenario, the
     dependencies of TerminalControl are used directly   for some reason:

```
  12>    Load input metadata file ...OpenConsole\x64\Debug\TerminalSettings\Microsoft.Terminal.Settings.winmd.
  12>    Load input metadata file ...OpenConsole\x64\Debug\TerminalControl\Microsoft.Terminal.Settings.winmd.
  12>    Load input metadata file ...OpenConsole\x64\Debug\TerminalControl\Microsoft.Terminal.TerminalConnection.winmd.
  12>    Load input metadata file ...OpenConsole\x64\Debug\TerminalControl\Microsoft.Terminal.TerminalControl.winmd.
  12>    Load input metadata file ...OpenConsole\x64\Debug\Microsoft.UI.Xaml.Markup\Microsoft.UI.Xaml.Markup.winmd.
```

  2. If you don't add a `Reference` TerminalControl, then it'll complain about
     being unable to find the type TitleChangedEventArgs,   which is defined in
     TerminalControl.

  3. If you don't add a `Reference` TerminalSettings, then it'll complain about
     being unable to find the type KeyChord and other   types from
     TerminalSettings. In this scenario, it doesn't recurse on the other
     dependencies from TerminalControl for whatever   reason.

  4. If you instead try to add all 3 as a `ProjectReference`, then it'll
     complain about being unable to find TitleChangedEventArgs,   as in 2.
     Presumably, it;ll have troubles with the other types too, as none of the 3
     are actually included in the midlrt.rsp file.

  5. If you add all 3 as a `ProjectReference`, then also add TerminalControl as
     a `Reference`, you'll get a `MIDL2011: [msg]  unresolved type declaration
     Microsoft.UI.Xaml.Markup.XamlApplication`

  6. If you add all 3 as a `ProjectReference`, then also add TerminalControl AND
     MUX.Markup as a `Reference`, you'll get the same   result as 3.

* what if we just don't idl

  This seems to compile

* This compiles but I broke the MUX resources

  look at the App.xaml change. in this changelist. That's what's broken right now. Lets fix that!

* lets do this

    If I leave the MUX nuget out of the project, I'll get a compile error in
    App.xaml:

    ```
    ...OpenConsole\src\cascadia\TerminalApp\App.xaml(21,40): XamlCompiler error WMC0001: Unknown type 'XamlControlsResources' in XML namespace 'using:Microsoft.UI.Xaml.Controls'
    ```

    If I add it back to the project, it works

* Some cleanup from the previous commit

* This is busted again.

  Doing a clean build didn't work.

    A clean rebuild of the project, paired with some removal of dead code
    revealed a problem with what I have so far.

    TerminalAppLib depends on the generation of two headers,
    `AppKeyBindings.g.h` and `App.g.h`, as those define some of bits of the
    winrt types. They're needed to be able to compile the implementations.
    Presumably that's not getting generated by the lib project, because the dll
    project is the one to generate that file.

    So we need to move the idl's to the lib project. This created maddness,
    because of course the Duplicate Type thing. The solution to that is to
    actually mark the winrt DLLs that we're chaining up through us as

    ```
        <Private>false</Private>
        <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
    ```

    This will prevent them from getting double-included.

    This still doesn't work however, since
    ```
    app.cpp(40): error C2039: 'XamlMetaDataProvider': is not a member of 'winrt::TerminalApp'
    error C3861: 'XamlMetaDataProvider': identifier not found
    ```

    So we need to figure that out. The dll project is still generating the right
    header, so lets look there.

* Move the xaml stuff to the lib

  This compiles, but when we launch, we fail to load the tabviewcontrol
  resources again. So that's not what you want. Why is it not included?

* It works again!

  * Use the pri, xbf files from TerminalAppLib, not TerminalApp
  * Manually make TerminalApp include a reference to TerminalAppLib's
    TerminalApp.winmd. This will force the build to copy TerminalApp.winmd to
    TerminalApp/, which WindowsTerminal needs to be able to ProjectReference the
    TerminalApp project (it's expecting it to have a winmd)
  * Remove the module.g.cpp from TerminalApp, and move to TerminalAppLib. The
    dll doesn't do any codegen anymore.

* Agressively clean up these files

* Clean up unnecessary includes in the dll pch.h

* This does NOT work.

  The WindowsxamlManager call crashes. I'm thinking it has to do with activation
  of winrt types from a dll.

  Email out to @Austin-Lamb to see if he can assist

* This gets our cppwinrt types working, but xaml islands is still broken

* Split the tests apart, so they aren't insane

* These are the magic words to make xaml islands work

* All this witchcraft is necessary to make XAML+MUX work right

* Clean this up a bit and add comments

* Create an enormous doc explaining this madness

* Unsure how this got changed.

* Trying to get the CI build to work again.

  This resolves the MUX issue. We need to manually include it, because their package's target doesn't mark it as CopyLocalSatelliteAssemblies=false, Private=false.

  However, the TerminalApp project is still able to magically reason that the TerminalAppLib project should be included in the MdMerge step, because it think's it's a `GetCppWinRTStaticProjectReferences` reference.

* Update cppwinrt to the latest version - this fixes the MSBuild

  * I still need to re-add the KeyModifiers checks from TermControl. I think
    this update broke `operator&` for that enum.
  * There needs to be some cleanup obviously
  * The doc should be updated as well

* Clean up changes from cppwinrt update

* Try doing this, even though it seems wrong

* Lets try this (press x to doubt)

* Clean up vcxproj file, and remove appxmanifest change from previous commit

* Update to the latest TAEF release, maybe that'll work

* Let's try a prerelease version, shall we?

* Add notes about TAEF package, comment out tests

* Format the code

* Hopefully fix the arm64 and x86 builds

  also a typo

* Fix PR nits

* Fix some bad merge conflicts

* Some cleanup from the merge

* Well I was close to getting the merge right

* I believe this will fix CI

* Apply suggestions from code review

Co-Authored-By: Carlos Zamora <carlos.zamora@microsoft.com>

* These definitely need to be fixed

* Try version detecting in the test

  IDK if this will build, I'm letting the CI try while I clean rebuild locally

* Try blindly updating to the newest nuget version

* Revert "Try blindly updating to the newest nuget version"

This reverts commit b72bd9eb73.

* We're just going to see if these work in CI with this change

* Comment the tests back out. Windows Server 2019 is 10.0.17763.557

* Remove the nuget package

  We don't need this package anymore now that we're hosting it

* Okay this _was_ important
2019-07-15 14:27:56 -05:00
Carlos Zamora 6d3001f3b8
Double and Triple Click Selection (#1197) 2019-07-11 16:06:18 -07:00
Summon528 3ce53adf56 Implement background image over acrylic or solid color (#1107) 2019-07-10 12:54:56 -07:00
Mike Griese 2de2f445c7
Enable resizing the panes with the keyboard. (#1207)
Adds the ability to resize panes with the keyboard. 

This is accomplished by making the Column/RowDefinitions for a Pane use `GridLengthHelper::FromPixels` to set their size. We store a pair of floats that represents the relative amount that each pane takes out of the parent pane. When the window is resized, we use that percentage to figure out the new size of each child in pixels, and manually size each column. 

Then, when the user presses the keybindings for resizePane{Left/Right/Up/Down}, we'll adjust those percentages, and resize the rows/cols as appropriate.

Currently, each pane adjusts the width/height by 5% of the total size at a time. I am not in love with this, but it works for now. I think when we get support for keybindings with arbitrary arg blobs, then we could do either a percent movement, or a number of characters at a time. The number of characters one would be trickier, because we'd have to get the focused control, and get the number of pixels per character, as adjacent panes might not have the same font sizes.
2019-07-10 08:27:12 -05:00
Summon528 c6ca298fdb Make padding applied as swap chain panel's margin (#1778) 2019-07-05 10:03:51 -07:00
PankajBhojwani b353ad8c16
App now initializes the connection instead of term control. (#1676)
* App now initializes the connection instead of term control.
2019-06-28 10:55:46 -07:00
Leonard Hecker 6775325839 Fixed #521 - AltGr combinations not working (#1436)
This commit changes how TerminalControl/TerminalCore handle key events to give it better knowledge about modifier states at the lower levels.
2019-06-27 16:20:55 -07:00
d-bingham b115799810 Connect clipboard functionality to their keybindings (#1093)
* Connects clipboard functionality to their keybindings.

* Cleaning up comments and whitespace.

* Added "copyTextWithoutNewlines" keybinding.

* Fixing tabs in idl file

* Fixing merge conflicts

* Adding default keybindings for copy and paste to ctrl-shift-c and ctrl-shift-v, respectively.

* Complying with refactoring

* Fixing formatting issues
2019-06-25 12:17:02 -07:00
Carlos Zamora f30d1485cc Captured pointer for SwapChainPanel and ScrollBar separately (#1248)
* Captured pointer for SwapChainPanel and ScrollBar separately
Renamed MouseClickHandler and MouseMovedHandler to more generic names (since they handle touch events too)

Fixes #950.
2019-06-17 17:27:17 -07:00
Summon528 2a37433504 Account for padding when calculating the initial window size (#1152) 2019-06-11 18:47:27 -07:00
adiviness 9b92986b49
add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
Dustin L. Howett (MSFT) 6fc0978ddb
Properly manage teardown state in TermControl (#1199)
* Properly manage teardown state in TermControl

This commit introduces a few automatic event revokers and implements
staged Close for TermControl's constituent components.

* Only read the focused control title if there is one

Fixes #1198
Fixes #1188
2019-06-11 12:37:20 -07:00
Mike Griese 2da5b0b146
Add support for multiple panes in the same window (#825)
* Start working on adding support for panes

  See #1000 for the panes megathread on remaining work.

  The functionality will be there, but the keybinding won't be there, so people have to
  opt-in to it.
2019-06-07 16:56:44 -05:00
d-bingham 5d96ebc225 Fix acrylic brush flash/fade on new tab creation. (#1092)
Fixes #1082 -- #853's fix of the acrylic background's flash/fade on any settings change managed to cause a flash/fade on new tab creation. This change removed both flash/fades. #853 split background brush initialization from background color changes; due to the brush being constructed with a default color and then the color being initialized later, new tabs were getting the flash/fade that accompanies a re-focused fluent-style acrylic background. This PR initializes the acrylic color at brush initialization to avoid the problem.
2019-06-04 13:25:24 -07:00
d-bingham 097f7d32a6 Background image support (#853)
* Initial code check in for background images

* Cleaning up whitespace

* Whitespace cleanup

* Added/fixed comments

* Fixing tabs

* Reverting erroneous file add

* Removing custom enum for image stretching mode and using Windows::UI::Xaml::Media::Stretch instead.

* Removing now-superfluous static_cast when setting stretch mode.

* Updating code to use wstring_view (per #925)

* One last set of wstring -> wstring_view changes

* Split off brush-intialization function from TermControl::_BackgroundColorChanged and added code to prevent flicker on resetting acrylic or image backgrounds.
2019-05-29 13:35:46 -05:00
Summon528 cfc72cee5d Make sure cursor blinks after opening new tab (#1030) 2019-05-28 11:18:28 -07:00
Michael Ratanapintha 9ad2544033 Fix #936: misuse of uninitialized objects causes AppVerifier breaks on Windows Terminal startup (#1015)
* move the render thread init up; gets rid of verifier stops

* s/INVALID_HANDLE_VALUE/NULL/g since CreateEvent() and CreateThread() return a NULL HANDLE on failure; resolves another cause of AppVerifier breaks
2019-05-28 16:56:36 +00:00
Mike Griese 0f62ec81d8
Eat all tap keypresses no matter what. (#985)
Fixes #744
2019-05-24 15:04:00 -05:00
Joel Bennett efd69990c6 Add support for OSC 10 and 11 to set the default colors (#891)
* Support OSC to set default background and foreground colors

* Update the Terminal theme when the background changes

* Fix whitespace per code-review

* Add Documentation Comments

Also fix a few outdated comments and whitespace

* Update Telemetry codes per code review

* Add Unit Tests for OSC ForegroundColor and BackgroundColor

* Add a couple additional test cases

* Minor doc and whitespace change per PR review

* Update comment help per code review

* Add another OSC 10 & 11 test case, improve output

* Comments and syntax cleanup per code reviews
2019-05-24 09:53:00 -07:00
Kapperchino 1191a59681 Update scroll bar with scroll (#920)
* added another method to scroll with keyboard

* set lastscrolloffset to 0

* fixed unused variable

* renamed ViewPort to Viewport

* changed keyBoard to keyboard in the functions, and added expliantion for function
2019-05-23 13:39:29 -07:00
Anirudh Rayabharam 2d4eca7f4f Added support for DECSCUSR sequences (#941)
* Falling back to legacy cursor for higher values of CursorStyle

Co-Authored-By: Michael Niksa <miniksa@microsoft.com>
2019-05-23 10:44:27 -07:00
Dustin L. Howett (MSFT) 798912c2f4
Enable C++/WinRT Optimizations for local component builds (#949)
Fixes #945.
2019-05-23 10:36:29 -07:00
Shawn Walker-Salas 1d9cdb3d31 set identifying environment variable for new connections (#897)
* set identifying environment variable for new connections

Set a new 'WT_SESSION' environment variable when creating new terminal
connections to allow shells to detect a unique Windows Terminal session.
The value of the variable is a stringified GUID as returned by
CoCreateGuid.

How verified:
- "razzle" & vs debug build
- runut
- manual inspection

* * use winrt::guid type for connection guid
* use Utils::GuidToString for guid stringification
* expose guid parameter in ITerminalConnection idl

* - poke guid through ITerminalConnection
- misc. review fixes
- throw if CreateConPty fails in ConhostConnection::Start
- apply [[nodiscard]] and noexcept in various places

* - simplify environment variable extraction in UpdateEnvironmentMapW

* - use Utils::CreateGuid instead of CoCreateGuid in ConHostConnection()
2019-05-22 13:24:22 -07:00
Carlos Zamora 6a79025027 Bugfix: padding offsets selection (#906)
Closes #660.
2019-05-22 09:34:20 -07:00
Dreamer db637021fd Fix memory leak, use unique_ptr for Core::Terminal object (#914) 2019-05-21 14:07:03 -07:00
Hermès BÉLUSCA - MAÏTO acabbe0459 Fix it's versus its typo. (#911) 2019-05-21 06:15:44 +00:00
Mitchell Blowey 9f4ad6d1ce Fix #670: Terminal selects a char when bringing window to foreground (#856)
* Added focus tracking to TermControl to prevent clicks which refocus the terminal window from selecting text.

* Moved open brace to a new line per repo code style.

* Moved the TermControl's _MouseClickHandler's focus check into the Mouse specific block of code. This lets any touch and drag events scroll the terminal's contents.

Fixes #670.
2019-05-20 12:05:58 -07:00
Michael Ratanapintha 7533b31cbd Fix #453: Setting historySize=32767 causes WindowsTerminal to hang (#843)
* fix for historySize=32767 hang (except for historySize=0 case); tests still in progress

* tests run and almost pass - failure is a real bug in my change

* fixed bug that caused tests to fail, but it seems another bug causes the app to crash with a zero row count

* fix the additional bug (at a higher layer) mentioned in previous commit description

* Fix chk build assertion failures in new tests

It seems C++/WinRT doesn't like it when you implement a Windows Runtime
interface but then create instances of the implementing class
with function-call lifetime (aka stack allocation). That makes sense
given that WinRT objects are COM objects, but in my defense I was following
this example where they are just fine instantiating the `App` object
on the stack:
https://docs.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/author-apis#if-youre-not-authoring-a-runtime-class

* tabs to spaces

* CR feedback

* fix minor CR feedback (incorrect test log message)
2019-05-18 03:57:34 +00:00
Kapperchino 781d779b37 Added Keybindings for go up and go down page (#747)
* added keybindings

* untabfied the files

* fixed spacing issues and renamed termheight

* changed function names and other improvements

* made some auto variables const auto

* fixed tabs

* another try for the broken spacing
2019-05-15 08:21:14 -05:00
David Teresi 8c177fab4f Add cursor blinking (#686)
It even respects the user's cursor blink speed setting!
2019-05-13 18:25:54 -07:00
Mario Kneidinger aeef340bdc Fixed duplicate line in TermControl (#732) (#739)
* Fixed duplicate line in TermControl #732

* Deleted lines, because values were unnecessarily set to default values.
2019-05-13 09:11:31 -07:00
Carlos Zamora 644cd3ec6c
Bugfix: ESC didn't clear selection (except CMD) (#647)
* Bugfix: ESC didn't clear selection (except CMD)

* Bugfix: ESC didn't clear selection - moved TriggerSelection() to ClearSelection()
2019-05-10 11:16:59 -07:00
Michael Niksa 87e85603b9 Merged PR 3215853: Fix spacing/layout for block characters and many retroactively-recategorized emoji (and more!)
This encompasses a handful of problems with column counting.

The Terminal project didn't set a fallback column counter. Oops. I've fixed this to use the `DxEngine` as the fallback.

The `DxEngine` didn't implement its fallback method. Oops. I've fixed this to use the `CustomTextLayout` to figure out the advances based on the same font and fallback pattern as the real final layout, just without "rounding" it into cells yet.
- `CustomTextLayout` has been updated to move the advance-correction into a separate phase from glyph shaping. Previously, we corrected the advances to nice round cell counts during shaping, which is fine for drawing, but hard for column count analysis.
- Now that there are separate phases, an `Analyze` method was added to the `CustomTextLayout` which just performs the text analysis steps and the glyph shaping, but no advance correction to column boundaries nor actual drawing.

I've taken the caching code that I was working on to improve chafa, and I've brought it into this. Now that we're doing a lot of fallback and heavy lifting in terms of analysis via the layout, we should cache the results until the font changes.

I've adjusted how column counting is done overall. It's always been in these phases:
1. We used a quick-lookup of ranges of characters we knew to rapidly decide `Narrow`, `Wide` or `Invalid` (a.k.a. "I dunno")
2. If it was `Invalid`, we consulted a table based off of the Unicode standard that has either `Narrow`, `Wide`, or `Ambiguous` as a result.
3. If it's still `Ambiguous`, we consult a render engine fallback (usually GDI or now DX) to see how many columns it would take.
4. If we still don't know, then it's `Wide` to be safe.
- I've added an additional flow here. The quick-lookup can now return `Ambiguous` off the bat for some glyph characters in the x2000-x3000 range that used to just be simple shapes but have been retroactively recategorized as emoji and are frequently now using full width color glyphs.
- This new state causes the lookup to go immediately to the render engine if it is available instead of consulting the Unicode standard table first because the half/fullwidth table doesn't appear to have been updated for this nuance to reclass these characters as ambiguous, but we'd like to keep that table as a "generated from the spec" sort of table and keep our exceptions in the "quick lookup" function.

I have confirmed the following things "just work" now:
- The windows logo flag from the demo. (💖🌌😊)
- The dotted chart on the side of crossterm demo (•)
- The powerline characters that make arrows with the Consolas patched font (██)
- An accented é
- The warning and checkmark symbols appearing same size as the X. (✔⚠🔥)

Related work items: #21167256, #21237515, #21243859, #21274645, #21296827
2019-05-02 15:29:10 -07:00
Dustin Howett d4d59fa339 Initial release of the Windows Terminal source code
This commit introduces all of the Windows Terminal and Console Host source,
under the MIT license.
2019-05-02 15:29:04 -07:00