This PR resolves an issue where scrollbar marks created by shell
integration sequences (OSC 133 FTCS, OSC 1337 iTerm2, and OSC 9;12
ConEmu sequences) were not visible on the scrollbar until the user
manually scrolled.
The problem was that while marks were being created in the buffer
correctly, the UI wasn't being notified to refresh the scrollbar
display. The fix adds a new NotifyShellIntegrationMark() method to the
ITerminalApi interface that calls _NotifyScrollEvent() to trigger
scrollbar refresh, and updates all shell integration sequence handlers
in AdaptDispatch to call this notification method after creating marks.
This ensures scrollbar marks appear immediately when shell integration
sequences are processed, bringing feature parity between auto-detected
and shell-integration-based marks.
Closes#19104
Most of `ColorHelper` was unused and one of them had UB.
Related to #19183
## Validation Steps Performed
* Set a custom tabRow theme color
Split button looks similar to before ✅
* White/black FG color decision for colored
tabs is similar to before ✅
This PR fixes issue #7130 where WT_SESSION and WT_PROFILE_ID environment
variables were being duplicated in the WSLENV environment variable when
multiple terminal sessions were created.
The previous implementation always appended WT_SESSION:WT_PROFILE_ID: to
WSLENV without checking if these variables already existed, causing
duplication.
Closes#7130
Co-authored-by: Leonard Hecker <lhecker@microsoft.com>
The bulk of this work is changing `Command::Name` (and its descendants
like `GenerateName`) to support looking up names in English and in the
local language.
When matching a "palette item" with a "subtitle" (a new field introduced
to store the English command name when the current language is not
English), the weight of the subtitle is used only if it is greater than
the weight of the name. This ensures that we do not penalize or
over-promote results that contain similar Latin letters in both fields.
Refs #19130, #19131, #19132, #19165Closes#7039
Right now, when a Command's name is `{"key": "ResourceName"}` we resolve
the resource immediately at load time. That prevents us from looking it
up later in another language if we need to.
This pull request introduces an intermediate representation for command
names which is be resolved during `Command::Name`.
Refs #7039
Reverts most of the styling changes done in #19001 to the key chords
displayed in the SUI's Actions page. The `CornerRadius` was kept at the
updated value of `ControlCornerRadius` for consistency.
The only other changes in #19001 that were kept for this page include:
- `EditButtonIconSize`: 15 --> 14
- `AccentEditButtonStyle` > `Padding`: 3 --> 4
- Command name's `FontWeight` reduced to `Normal`
- `AddNewButton` > `Margin` added (set to `0,12,0,0` to provide spacing
between breadcrumb header and button)
This PR is a (first) design pass on the Terminal settings UX to bring
consistency and alignment with the rest of the OS and other settings
surfaces.
High-level changes include:
- Using WinUI brushes vs. UWP/OS brushes. [See brushes overview in the
WinUI 3 Gallery:](winui3gallery://item/Color).
- Updating pixel values for margins, fontsizes, paddings etc. using
units of 4. See [the design guidelines for more
info](https://learn.microsoft.com/en-us/windows/apps/design/basics/content-basics).
- Adding rounded corners on various elements to be consistent with the
Windows 11 look and feel (using the ControlCornerRadius or
OverlayCornerRadius WinUI resources as much as possible).
- Decreasing the page header titles / breadcrumb so it feels a bit less
cramped.
- Fixing a bug where the title of the page was not aligned with the
content when resizing the window (note to self: should fix this in
PowerToys too):
- Ensuring the subheader texts for settings categories are inline with
the rest of the OS (== decreasing the fontsize).
---------
Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
This removes the need to construct two objects per tab (TabBase, Actual
Tab) and the other overhead inherent in WinRT composition-based
inheritance.
Important renames:
- `GetTerminalTabImpl` -> `GetTabImpl`
This pull request does not rename `TerminalTabStatus`; that is left as
work for a future PR.
Closes#17529
## Summary of the Pull Request
Adds new telemetry events to track traffic through the new tab menu.
Specifically, the following events are added:
- `NewTabMenuDefaultButtonClicked`: Event emitted when the default
button from the new tab split button is invoked
- `NewTabMenuOpened`: Event emitted when the new tab menu is opened
- `NewTabMenuClosed`: Event emitted when the new tab menu is closed
- `NewTabMenuItemClicked`: Event emitted when an item from the new tab
menu is invoked
- Has an `ItemType` parameter that can be set to `Settings`,
`CommandPalette`, `About, `Profile`, `Action`
- Has a `TabCount` parameter that keeps tracked of the number of tabs in
the window before changing the state
- `NewTabMenuCreatedNewTerminalSession`: Event emitted when a new
terminal was created via the new tab menu
- Has a `SessionType` parameter that can be set to `ElevatedWindow`,
`Window`, `Pane`, `Tab`
- Instead of `TabCount`, has a `NewTabCount` that keeps track of the
_new_ number of tabs after the session has been created
- `NewTabMenuItemElevateSubmenuItemClicked`: Event emitted when the
elevate submenu item from the new tab menu is invoked
## Validation Steps Performed
Used TVPP to see events generated from interacting with the new tab
menu.
## Summary of the Pull Request
This PR introduces an experimental setting that allows to toggle opacity
changes with scrolling.
## References and Relevant Issues
#3793
## Detailed Description of the Pull Request / Additional comments
By default, holding Ctrl + Shift while scrolling changes the terminal's
opacity. This PR adds an option to disable that behavior.
## Validation Steps Performed
I built the project locally and verified that the new feature works as
intended.
## PR Checklist
- [x] Resolves
https://github.com/microsoft/terminal/issues/3793#issuecomment-3085684640
- [x] Tests ~~added/~~ passed
- [x] Documentation updated
- If checked, please file a pull request on [our docs
repo](https://github.com/MicrosoftDocs/terminal) and link it here:
https://github.com/MicrosoftDocs/terminal/pull/873
- [X] Schema updated (if necessary)
In #19132, we introduced caching for BasePaletteItem::ResolvedIcon as a
late optimization.
We actually can't cache those, because they're UI elements, with parents
and relationships and all. When you filter a list with icons and the
list elements change physical position, they're assigned new templates--
and new parents.
Fixes e7939bb4e
Co-authored-by: Eric Nelson <e82.eric@gmail.com>
PR #17330 changed FilteredCommand so that FilteredTask could derive from
it. It also **did not** implement FilteredTask as a derived class.
We've been carrying around the debt of a decision we un-decided for like
a year.
This PR adds a new global setting `scrollToZoom` that allows users to
enable font zooming with scrolling. When disabled, **this setting
prevents accidental font size changes** that can occur when users scroll
while holding the Ctrl key.
Note: after disabling this setting, users may still change font size
using `Ctrl+` and `Ctrl-` keyboard shortcuts. Other Ctrl+Scroll
functionality (like transparency adjustments) remains unaffected.
## Validation Steps Performed
- Verified the setting can be toggled in the Settings UI (Interaction
tab)
- Confirmed that when disabled, holding Ctrl and scrolling no longer
changes font size
- Validated that the setting persists across terminal restarts
---
Note: I used the existing `FocusFollowMouse` setting as a reference for
implementing this.
Closes#11710Closes#3793Closes#11906Closes#3990
Right now, we construct **two objects** for every palette item: the
derived type and the base type. It's unnnecessary.
This pull request replaces WinRT composition with a good old-fashioned
`enum ThingType`.
This also removes many of our palette items from our IDL. The only ones
that are necessary to expose via our WinRT API surface are the ones that
are used in XAML documents.
I originally removed the caching for `Command.Name`, but it turns out
that something calls `Name` roughly 17 times **per command** and having
the generator running that often is a serious waste of CPU.
## Validation Steps
- [x] Tab Switcher still live-updates when it is in use
- [x] Command searching still works
- [x] Commandline mode still works
- [x] Suggestions control still works
This pull request elevates ScopedResourceLoader to the API surface of
LibraryResources, which will allow any library resource consumer to
directly interact with its resource loader.
One of those new interactions is to make a sub-context with a specific
narrowed-down qualifier. Like this:
```c++
auto englishOnlyLoader = GetLibraryResourceLoader().WithQualifier(L"language", L"en-us");
/* auto foo = */ englishOnlyLoader.GetLocalizedString(USES_RESOURCE(L"AppName"));
```
If an IME provider sets both `crText` and `crBk` we should respect this,
but the previous logic would incorrectly assert for `crLine !=
TF_CT_NONE`.
## Validation Steps Performed
❌ I'm not aware which TSF even sets these colors in a
way that's compatible with us in the first place...
`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