`HighlightedTextControl` is a XAML user control that contains a text
block and takes vector of `HighlightedText`. `HighlightedText` uses
tuples `(string, boolean)`. Allocating an entire object to store a
string and an integer felt like a waste, especially when we were doing
it thousands of times for the command palette _and just to pass them
into another object that stores a string and a few more integers
(`Run`)._
The new `HighlightedTextControl` is a standard templated control, and
supports styling of both the inner text block and of the highlighted
runs.
It no longer takes a `HighlightedText`, but rather a standard string and
a set of runs (tuple `(int start, int end)`); these can be stored more
efficiently, and this change moves the construction of text and runs
directly into `HighlightedTextControl` itself as an implementation
detail rather than an API contract.
### XAML Properties
- `Text`: the string to highlight
- `HighlightedRuns`: a vector of `(start, end)` pairs, indicating which
regions are intended to be highlighted. Can be empty (which indicates
there is no highlight and that the entire string is styled normally.)
- `TextBlockStyle`: the `Style` applied to the inner text block;
optional; allows consumers to change how both normal and highlighted
text looks.
- `HighlightedRunStyle`: a `Style` applied only to the highlighted runs;
optional; allows consumers to change how highlighted text looks. If
left NULL, highlighted runs will be bold.
`HighlightedRunStyle` is a little bodgy. It only applies to `Run`
objects (which is fine, and XAML somewhat supports), but since `Run` is
not a `FrameworkElement`, it _doesn't actually have a `Style` member._
We need to crack open the style and apply it manually, entry by entry.
`FontWeight` is special because XAML is a special little flower.
This will prevent Terminal from erroneously selecting a hidden (deleted,
disabled or otherwise) profile of the same name during restoration and
subsequently using the wrong settings.
I am not certain why we used the name at all!
Closes#19105
Right now, we do not use a sufficiently unique name to disambiguate
Terminal instances running on the same desktop.
Mutexes (mutants) are named objects that live in the user's session,
under `Sessions\1\BaseNamedObjects` (for the local desktop session).
When multiple users are logged into the same session--such as with "Run
as different user"--they share a local BaseNamedObjects namespace. Ugh.
We cannot use [`CreatePrivateNamespace`] as it requires a boundary
descriptor, and the only boundary descriptors supported by the current
API are based on package identity. I also fear that
`CreatePrivateNamespace` is subject to a race condition with
`OpenPrivateNamespace`; Create will not Open an existing one, so we
would need to back off and retry either opening or creating. Yuck.
After this commit, we will hash the user's SID into the name of both the
window class and the mutant, right after the path hash (if running
unpackaged).
Closes#18704
[`CreatePrivateNamespace`]:
https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createprivatenamespacea
The crash occurs because WinRT `abort()`s when it encounters
a `std::wstring_view` without null-terminator.
Closes#19093
## Validation Steps Performed
* Set `wtd` as the default terminal
* Launch `cmd`
* Launch `wtd`
* 2 windows ✅
When we first transitioned to the `R1` network isolation
environment--which required us to _not_ contact
powershellgallery.com--we had to give up on the `AzureFileCopy` task.
Since then, the `AzurePowerShell` task has also become somewhat broken
while OneBranch fixed the issue that prevented us from using
`AzureFileCopy`.
In short, we now need to:
- Install the Azure PowerShell modules directly from our own feed (which
satisfies the network constraint)
- ... using `PSResourceGet` ...
- ... for Windows PowerShell 5.1 ...
- which is used by `AzureFileCopy` to later perform authentication.
This changes the ConPTY handoff COM server from `REGCLS_SINGLEUSE`
to `REGCLS_MULTIPLEUSE`. The former causes a race condition, because
handoff runs concurrently with the creation of WinUI windows.
This can then result in the a window getting the wrong handoff.
It then moves the "root" of ConPTY handoff from `TerminalPage`
(WindowEmperor -> AppHost -> TerminalWindow -> TerminalPage)
into `WindowEmperor` (WindowEmperor).
Closes#19049
## Validation Steps Performed
* Launching cmd from the Start Menu shows a "Command Prompt" tab ✅
* Win+R -> `cmd` creates windows in the foreground ✅
* Win+R -> `cmd /c start /max cmd` creates a fullscreen tab ✅
* This even works for multiple windows, unlike with Canary ✅
* Win+R -> `cmd /c start /min cmd` does not work ❌
* It also doesn't work in Canary, so it's not a bug in this PR ✅
Introduces an ABI change to the ConptyClearPseudoConsole signal.
Otherwise, we have to make it so that the API call always retains
the row the cursor is on, but I feel like that makes it worse.
Closes#18732Closes#18878
## Validation Steps Performed
* Launch `ConsoleMonitor.exe`
* Create some text above & below the cursor in PowerShell
* Clear Buffer
* Buffer is cleared except for the cursor row ✅
* ...same in ConPTY ✅
Fixes a crash when multiple panes were closed simultaneously (i.e. using
broadcast input).
The root cause of this crash was that we would get a null pointer
exception when trying to access a member/function off of a null
`_content`. This is because `Pane::_CloseChild()` would always pass over
the content from the non-closed pane and attempt to hook everything up
to it.
The fix was to operate similarly to `Pane::Close()` and raise a `Closed`
event and return early. Since there's no alternative content to attach
to, might as well just close the entire pane. This propagates up the
stack of listeners to update the UI appropriately and close the parent
pane and eventually the entire tab, if necessary.
Closes#18071Closes#17432
## Validation Steps Performed
1. Open 2 panes
2. Use broadcast input to send "exit" to both panes
3. ✅ Terminal doesn't crash and the tab closes gracefully
- Various spelling fixes
- Refresh metadata (including dictionaries)
- Upgrade to v0.0.25
## Validation Steps Performed
- check-spelling has been automatically testing this repository for a
while now on a daily basis to ensure that it works fairly reliably:
https://github.com/check-spelling-sandbox/autotest-check-spelling/actions/workflows/microsoft-terminal-spelling2.yml
Specific in-code fixes:
- winget
- whereas
- tl;dr
- set up
- otherwise,
- more,
- macbook
- its
- invalid
- in order to
- if
- if the
- for this tab,...
- fall back
- course,
- cch
- aspect
- archaeologists
- an
- all at once
- a
- `...`
- ; otherwise,
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Adds logic to display a warning popup if the settings.json is marked as
read-only and we try to write to the settings.json file. Previously,
this scenario would crash, which definitely isn't right. However, a
simple fix of "not-crashing" wouldn't feel right either.
This leverages the existing infrastructure to display a warning dialog
when we failed to write to the settings file. The main annoyance here is
that that popup dialog is located in `TerminalWindow` and is normally
triggered from a failed `SettingsLoadEventArgs`. To get around this,
`CascadiaSettings::WriteSettingsToDisk()` now returns a boolean to
signal if the write was successful; whereas if it fails, a warning is
added to the settings object. If we fail to write to disk, the function
will return false and we'll raise an event with the settings' warnings
to `TerminalPage` which passes it along to `TerminalWindow`.
Additionally, this uses `IVectorView<SettingsLoadWarnings>` as opposed
to `IVector<SettingsLoadWarnings>` throughout the relevant code. It's
more correct as the list of warnings shouldn't be mutable and the
warnings from the `CascadiaSettings` object are retrieved in that
format.
## Validation Steps Performed
- ✅ Using SUI, save settings when the settings.json is set to read-only
Closes#18913
sgr_n previously used a mutable list (`seq=[]`) as its default parameter.
In Python, default arguments are instantiated once at
function‐definition time and then shared across all calls.
If any caller mutated that list (e.g., `seq.append(...)`), later
invocations would inherit the mutated state, producing unpredictable or
corrupted VT-test sequences.
## Summary of the Pull Request
Some applications that make use of the `OSC 52` clipboard sequence will
only do so if they can be certain that the terminal actually has that
functionality. Indicating our support for `OSC 52` in the `DA1` report
will give them an easy way to detect that.
## References and Relevant Issues
`OSC 52` support was added to Windows Terminal in issue #5823, and to
ConHost in issue #18949.
## Detailed Description of the Pull Request / Additional comments
Support for writing to the clipboard is indicated in the primary device
attributes report by the extension parameter `52`. This is obviously not
a standard DEC extension, but it's one that's been agreed upon by a
number of modern terminals. The extension is only reported when writing
to the clipboard is actually permitted (Windows Terminal has an option
to disable that).
## Validation Steps Performed
I've updated the Device Attributes unit test to check that we're
reporting extension `52` when clipboard access is enabled, and not
reporting it when disabled.
## PR Checklist
- [x] Closes#19017
- [x] Tests added/passed
Right now, image validation accepts web-sourced icons (boo) and rejects
images whose paths begin with `\\?\`. In addition, it will warn the user
for things out of their control like images set by fragments.
This pull request adds a filesystem path validator (which accepts images
with fully-qualified paths and UNC paths), makes the URI validator
reject any web-origin URIs (only `file` and `ms-*` are allowable), and
suppresses warnings for any images that were not _directly_ set by the
user.
Since we want to avoid using fragment images that fail validation, we no
longer `Clear` each image property but rather set it to the blank or
fallback value.
This does **not** actually add support for images at absolute paths
beginning with `\\?\`. Such images are still rejected by `Image` and the
other XAML fixtures we use for images. It's better than a warning,
though.
Closes#18703Closes#14143
Refs #18710
Refs #5204
Related to #18922 (http-origin icons will be blank everywhere and not
just the jump list ;))
* Make PowerShell profile generation try to find `pwsh.exe` before
falling back to legacy powershell
* Make profiles generated on an `arm64` host work properly
## Validation Steps Performed
* Local build ran
* Verified the new `arm64` profile works
* Verified `pwsh.exe` is used if present
* Verified `powershell.exe` is used if `pwsh` is not present in path
* Verified we don't attempt to create `arm64` host cmd/pwsh profiles if
VS is not >= 17.4
If High Contrast mode is enabled in the OS settings, we now
automatically enable `adjustIndistinguishableColors`. To accomplish
this, a new `Automatic` value is added to
`adjustIndistinguishableColors`. When it's chosen, color nudging doesn't
occur in regular contrast sessions, but we interpret the value as
`Indexed` respectively.
The new default value is `AutomaticIndexed`. Meaning that regular
contrast sessions will see no difference in behavior. However, if they
switch to high contrast mode, Windows Terminal will interpret the value
as `Indexed` at runtime. This was chosen because `Always` is more
performance intensive.
## References and Relevant Issues
#12999
## Validation Steps Performed
✅ Toggling High Contrast mode immediately triggers an updated terminal
instance with `adjustIndistinguishableColors`
Prevents a crash when no storage items are returned from a dropped path.
Terminal no longer crashes when a relative path is dragged and dropped
into the tool.
Closes#19015
With the latest winget-create release, the preferred method for
providing the GitHub token in CI/CD environment is via the environment
variable `WINGET_CREATE_GITHUB_TOKEN`. Removed use of `--token` and
switched to environment variable. See https://aka.ms/winget-create-token
for details.
This is an attempt to improve the correctness of the background fill
that the Sixel parser performs when an image is scrolled because it
doesn't fit on the screen.
This new behavior may not be exactly correct, but does at least match
the VT330 and VT340 hardware more closely than it did before.
The initial Sixel parser implementation was in PR #17421.
When a Sixel image has the background select parameter set to 0 or 2, it
fills the background up to the active raster attribute dimensions prior
to writing out any actual pixel data. But this fill operation is clamped
at the boundaries of the screen, so if the image doesn't fit, and needs
to scroll, we have to perform an additional fill at that point to cover
the background of the newly revealed rows (this is something we weren't
doing before).
This later fill uses the width of the most recent raster attributes
command, which is not necessarily the same as the initial background
fill, and fills the entire height of the new rows, regardless of the
height specified in the raster attributes command.
## Validation Steps Performed
Thanks to @al20878 and @hackerb9, we've been able to test on both a
VT330 and a VT340, and I've confirmed that we're matching the behavior
of those terminals as closely as possible. There are some edge cases
where they don't agree with each other, so we can't always match both.
I've also confirmed that the test case in issue #17946 now matches what
the OP was expecting, and the test case in #17887 at least works more
consistently now when scrolling (this is not what the OP was expecting
though).
Closes#17887Closes#17946
This adds support for copying to the clipboard in conhost using the OSC
52 escape sequence, extending the original implementation which was for
Windows Terminal only.
The Windows Terminal implementation was added in PR #5823.
Because the clipboard can't be accessed from a background thread, this
works by saving the content in a global variable, and then posting a
custom message to the main GUI thread, which takes care of the actual
copy operation.
Validation:
I've manually confirmed that tmux copy mode is now able to copy to the
system clipboard.
Closes#18943
Some minor styling tweaks to the about page.
- Tweaking the spacing of the version-checking / update available text.
- Wrapping the hyperlinkbuttons in a StackPanel so it's easier to set a
negative margin so they are visually aligned with the version / title
text.
Closes#18994
It's the fzf algorithm!
Repurposed work from #16586
- I think the fzf algo fits here where it optimizes to find the optimal
match based on consecutive chars and word boundaries.
- There are some edge cases where a match with a small gap could get a
higher score than a match of consecutive chars when the match with a
gap has other bonuses (FirstChar * Boundary Bonus). This can be
adjusted by adjusting the bonuses or removing them if needed.
- From reading the thread in #6693 it looked like you guys were leaning
towards something like the fzf algo.
- License file is now updated in
https://github.com/nvim-telescope/telescope-fzf-native.nvim repository
- https://github.com/nvim-telescope/telescope-fzf-native.nvim/pull/148
- https://github.com/junegunn/fzf/issues/4310
- Removed the following from the original implementation to minimize
complexity and the size of the PR. (Let me know if any of these should
be added back).
- Query expressions "$:StartsWith ^:EndsWith |:Or !:Not etc"
- Slab to avoid allocating the scoring matrix. This felt like overkill
for the number of items in the command pallete.
- Fallback to V1 algorithm for very long strings. I want to say that the
command palette won't have strings this long.
- Added the logic from GH#9941 that copies pattern and text chars to
string for comparision with lstrcmpi
- It does this twice now which isn't great...
Closes#6693
---------
Co-authored-by: Leonard Hecker <lhecker@microsoft.com>
Skips rendering LRI, RLI, FSI, and PDI "glyphs" in the terminal.
Does not implement BIDI/RTL; that is out of scope, see #538. This is
just a hotfix to stop spamming the console with undesired character
printouts. Once BIDI support is implemented, this change will (maybe?)
no longer be necessary.
Fixes#16574.
This pull request adds an Extensions page to the Settings UI, which lets
you enable/disable extensions and see how they affect your settings
(i.e. adding/modifying profiles and adding color schemes). This page is
specifically designed for fragment extensions and dynamic profile
generators, but can be expanded on in the future as we develop a more
advanced extensions model.
App extensions extract the name and icon from the extension package and
display it in the UI. Dynamic profile generators extract the name and
icon from the generator and display it in the UI. We prefer to use the
display name for breadcrumbs when possible.
A "NEW" badge was added to the Extensions page's `NavigationViewItem` to
highlight that it's new. It goes away once the user visits it.
## Detailed Description of the Pull Request / Additional comments
- Settings Model changes:
- `FragmentSettings` represents a parsed json fragment extension.
- `FragmentProfileEntry` and `FragmentColorSchemeEntry` are used to
track profiles and color schemes added/modified
- `ExtensionPackage` bundles the `FragmentSettings` together. This is
how we represent multiple JSON files in one extension.
- `IDynamicProfileGenerator` exposes a `DisplayName` and `Icon`
- `ExtensionPackage`s created from app extensions extract the
`DisplayName` and `Icon` from the extension
- `ApplicationState` is used to track which badges have been dismissed
and prevent them from appearing again
- a `std::unordered_set` is used to keep track of the dismissed badges,
but we only expose a get and append function via the IDL to interact
with it
- Editor changes - view models:
- `ExtensionsViewModel` operates as the main view model for the page.
- `FragmentProfileViewModel` and `FragmentColorSchemeViewModel` are used
to reference specific components of fragments. They also provide support
for navigating to the linked profile or color scheme via the settings
UI!
- `ExtensionPackageViewModel` is a VM for a group of extensions exposed
by a single source. This is mainly needed because a single source can
have multiple JSON fragments in it. This is used for the navigators on
the main page. Can be extended to provide additional information (i.e.
package logo, package name, etc.)
- `CurrentExtensionPackage` is used to track which extension package is
currently in view, if applicable (similar to how the new tab menu page
works)
- Editor changes - views:
- `Extensions.xaml` uses _a lot_ of data templates. These are reused in
`ItemsControl`s to display extension components.
- `ExtensionPackageTemplateSelector` is used to display
`ExtensionPackage`s with metadata vs simple ones that just have a source
(i.e. Git)
- Added a `NewInfoBadge` style that is just an InfoBadge with "New" in
it instead of a number or an icon. Based on
https://github.com/microsoft/PowerToys/pull/36939
- The visibility is bound to a `get` call to the `ApplicationState`
conducted via the `ExtensionsPageViewModel`. The VM is also responsible
for updating the state.
- Lazy loading extension objects
- Since most instances of Terminal won't actually open the settings UI,
it doesn't make sense to create all the extension objects upon startup.
Instead, we defer creating those objects until the user actually
navigates to the Extensions page. This is most of the work that happened
in `CascadiaSettingsSerialization.cpp`. The `SettingsLoader` can be used
specifically to load and create the extension objects.
## Validation Steps
✅ Keyboard navigation feels right
✅ Screen reader reads all info on screen properly
✅ Accessibility Insights FastPass found no issues
✅ "Discard changes" retains subpage, but removes any changes
✅ Extensions page nav item displays a badge if page hasn't been visited
✅ The badge is dismissed when the user visits the page
## Follow-ups
- Streamline a process for adding extensions from the new page
- Long-term, we can reuse the InfoBadge system and make the following
minor changes:
- `SettingContainer`: display the badge and add logic to read/write
`ApplicationState` appropriately (similarly to above)
- `XPageViewModel`:
- count all the badges that will be displayed and expose/bind that to
`InfoBadge.Value`
- If a whole page is new, we can just style the badge using the
`NewInfoBadge` style
Looks like there's a new VS version on the build agents. This just goes
through and fixes any issues they found.
There's still a COMPILER CRASH though.
## Summary of the Pull Request
Adds branding and distribution metadata to the following telemetry
events:
- ActionDispatched (branding only)
- JsonSettingsChanged
- UISettingsChanged
- SessionBecameInteractive
Also removes the settings logger output from the debugger and some
leftover debugging functions.
Adds a label to the XSettingsChanged settings value to make it easier to
read on the backend.
Once an application has returned from handling `WM_ENDSESSION`
the OS may kill the app at any point. This means we must
persist our state while inside the message handler.
Closes#17179
## Validation Steps Performed
Honestly, none. It's a race condition in the first place.
## Motivation
The motivation is that Windows users are more accustomed to working with
GUI Menus using a mouse, unlike Linux users.
## Summary of the Pull Request
added split pane with profile or duplicate up/down/left/right context
menus as submenu
added swap panes up/down/left/right context menus as submenu
added toggle pane zoom context menu
added close other panes context menu
## References :
- Relevant Issues : (#18137)
## Type of change :
- [x] New feature
---------
Co-authored-by: Mike Griese <migrie@microsoft.com>
Applies some localization fixes for the regex strings and
Settings_ResetApplicationState.HelpText.
Also renames the `_validateX()` functions to
`_validateAndPopulateXRegex()` for clarity.
This works around a bug in WinUI where it creates a single context
menu/flyout for text elements per thread, not per `XamlRoot`, similar to
many other areas. Since the `XamlRoot` cannot change after creation,
this means that once you've opened the flyout, you're locked into that
window (= XAML root) forever. You can't open the flyout in another
window and once you've closed that window, you can't open it anywhere at
all.
Closes#18599
## Validation Steps Performed
* Flies out right click in the
* About dialog ✅
* Search dialog ✅
* Word delimiters setting ✅
* Launch size setting ✅
* Across two windows ✅
If `persistedWindowLayout` is enabled, we now persist the window layout
every few minutes (excluding the text buffer).
This was done by adding a `SafeDispatcherTimer` to the `WindowEmperor`
that calls `PersistState()` every 5 minutes. For `BuildStartupKind`, I
split up `Persist` into `PersistAll` and `PersistLayout`. This way, we
go through all the same code flow that `Persist` had except for
specifically serializing the buffer.
## Validation Steps Performed
✅ (with the timer set to 3 seconds) create a window layout and ensure
the layout is restored after forcefully stopping Terminal (aka
simulating a "crash")
Closes#18838
## Summary of the Pull Request
Adds the ability to reset the settings.json file and application state
via the Settings UI. Since these are destructive operations, the
destructive styling is applied, as well as a confirmation prompt
notifying the user that this occurs immediately.
## Validation Steps Performed
✅ "reset settings" results in the correct contents for settings.json and
state.json
✅ "reset cache" results in the correct contents for state.json
Closes#947
## Summary of the Pull Request
Adds logic such that local snippets from .wt.json files are imported not
only at the current directory, but also in the parent directories.
## References and Relevant Issues
Spec:
https://github.com/microsoft/terminal/blob/main/doc/specs/%231595%20-%20Suggestions%20UI/Snippets.md
## Validation Steps Performed
`D:\test\.wt.json`: contains `Hello --> hello (parent)`
`D:\test\inner_dir\.wt.json`: contains `Hello --> hello`
- In `D:\test\`...
- ✅ `Hello` command outputs `hello (parent)`
- ✅ commands from `inner_dir` not shown
- In `D:\test\inner_dir\`...
- ✅ `Hello` command outputs `hello`
- ✅ commands from `D:\test` are shown
## PR Checklist
Closes#17805