This pull request introduces a new profile setting,
`compatibility.allowOSC52`, which defaults to `true`. When disabled, it
will not allow applications to write to the clipboard.
Security-minded folks may choose to disable it.
Reroutes the `closeWindow` action to use the `CloseWindow()` method like
the window's X button does. This includes logic to display the
confirmation dialog.
Also removes `CloseRequested` as it was only used by this action
handler. We already have `CloseWindowRequested` so we're just using that
instead.
## Validation Steps Performed
✅ `closeWindow` action while multiple tabs opened brings up the
confirmation dialog
Closes#17613
There's an existing WinUI bug where a nested Grid has it's star-sizing
ignored on Windows 10. This resulted in the New Tab Menu page looking
weird on Windows 10. This PR fixes the layout issue by applying a max
width to the first column, which will be clipped as necessary to make
space for the second column.
Part of #18281
## Validation Steps Performed
Validated the page looks good on Windows 10 and Windows 11, even after
resizing the window.
Fixes a few accessibility bugs in the SettingContainer previews. Main
changes include:
- `SettingContainer` was considered a separate UIA element from the
inner expander. It's been marked as `AccessibilityView=Raw` to "remove"
it from the UIA tree.
- Added a `CurrentValueAccessibleName` property to the
`SettingContainer` to expose the current value to the screen reader for
`SettingContainer`s that have expanders. Non-expander
`SetttingContainer`s already worked fine.
- Applied `CurrentValueAccessibleName` to various settings throughout
the settings UI for full coverage. Added a `CurrentValue` for the ones
that were missing it.
- Removed a redundant/hidden tab stop in `Icon`
`Padding` was not updated since #18300 is handling that. This'll just
automatically make it accessible.
Font axes and features weren't updated to show previews, but I'm happy
to do it if given a suggestion.
Part of #18318
## Details
- `SettingContainer` updates:
- `AccessibilityView = Raw` for `SettingContainer`s with expanders. This
is because the expander itself is the one we care about. No need to have
another layer of UIA objects saying it's a group.
- Added a `CurrentValueAccessibleName` property
- This specifically defines what should be read out by the screen
reader, similar to `AutomationProperties.Name`
- It updates automatically when `CurrentValue` changes.
- It's applied on the inner `Expander`, if one exists.
- The accessible name is constructed to be `"<Header>:
<CurrentValueAccessibleName>"`. If `CurrentValueAccessibleName` isn't
provided, we try to use the `CurrentValue` if it's a string.
- Profile (and appearance) settings:
- `Icon`'s value is now read out by a screen reader instead of staying
silent. It'll read the icon path.
- A redundant/hidden tab stop was removed from `Icon`.
- `TabTitle` now displays/reads "None" if no tab title is set.
- `ColorScheme` is now read out by a screen reader.
- The color scheme overrides (i.e. `Foreground`, `Background`,
`SelectionBackground`, and `CursorColor`) are now read out by a screen
reader. Format is "#<hex value>".
- `BackgroundImageAlignment` is now displayed and read out by a screen
reader.
- `LaunchSize` is now displayed and read out by a screen reader. Format
is "Width x Height".
## Validation Steps Performed
Tabbed through the settings UI with a screen reader. Each of these
settings now reads out a preview.
This fixes the bit check for key down and adds a few comments.
Closes#18331
## Validation Steps Performed
Printing the resulting INPUT_RECORDs shows both key down and up events
when pressing F7. Alt-Space now also works again.
The CoreWindow approach to implementing this has proven itself to be bug
prone. This PR switches to using the much better Win32 ShowCursor API,
which uses a reference count. This prevents the exact sort of race
condition we have where we we disable the cursor in our code and the
WinUI code then sets it to a different cursor internally which gets the
system out of sync. There's no WinUI API to just hide the cursor and if
it did, it would probably be a Boolean which would result in the same
issue.
Closes#18400
## Validation Steps Performed
It's difficult to assert the correctness of this approach, outside of
just trying it out (which I did and it works). The good news is that
this uses a static bool to ensure we only hide it exactly once and show
it exactly once and we do the latter on every WM_ACTIVATE message which
should hopefully restore the cursor when tabbing out and back in at
least.
CodeQL is raising errors when building Visual Studio since they have a
dependency on Windows Terminal for our integrated terminal. The issue
raised by CodeQL refers to a non-constant string format, but in this
case the string comes from a resource file and should be considered
constant.
The conhost window uses the window message WM_GETDPISCALEDSIZE to scale
its client rect non-linearly. This is done to keep the rows and columns
from changing when the window changes (font sizes scale non-linearly).
If you size the window such that the text perfectly fits the width (and
cursor is on the first row of the next line), dragging the window
between monitors with different DPIs should NOT change how much of the
text fits on each line.
https://learn.microsoft.com/en-us/windows/win32/hidpi/wm-getdpiscaledsize
The current code is assuming that the size that should be scaled is the
current window size. This is sometimes the case, for example when
dragging a window between monitors, but it is not always the case. This
message can sometimes contain a size that is different from the window's
current size. For example, if the window is maximized, minimized, or
snapped (the size in these cases is the normal rect, or restore rect).
The msdn page above does (now) call this out, though it is possible that
this was added after this conhost code was added...
> The LPARAM is an in/out pointer to a SIZE struct. The _In_ value in
the LPARAM is the pending size of the window after a user-initiated move
or a call to SetWindowPos.
If the window is being resized, this size is not necessarily the same as
the window's current size at the time this message is received.
This incorrect assumption can cause the conhost window to be
unexpectedly large/small in some cases. For example:
1. Requires two monitors, set to different DPIs.
2. Size window somewhat small, and type text to fit exactly the width of
the window, putting cursor on first row of next line.
3. Win+Left (or otherwise snap/arrange the window).
4. Win+Shift+Left (migrates the window to the other monitor)
5. Win+Shift+Down (restore window, can also click maximize caption
button twice, maximizing then restoring)
Expected: The window should restore to the original logical size, with
the text perfectly fitting one line.
Actual: The window restores to another size; it is the snapped size on
the original monitor (the size of the window at the time it was changing
DPI, in step 4 above).
## References and Relevant Issues
This message (WM_GETDPISCALEDSIZE) is not widely used, but it is used by
dialogs (user32!CreateDialog), since they also size their windows using
font sizes. The code in this change borrows from the code in the dialog
manager, user32!GetDialogDpiScaledSize.
## Detailed Description of the Pull Request / Additional comments
The WM_GETDPISCALEDSIZE message contains the new DPI and the new size,
which is an in/out parameter. It starts as the new window size, scaled
to the window's current DPI, and is expected to be scaled to the new
DPI.
The client area (the part with the text) is NOT scaled linearly. For
example, if the font at 100% DPI has a height of 7, it could have a
height of 15 at 200%. (And if it did have a height of 14, linearly
scaled, it would surely not be linearly scaled at 150%, since fonts
cannot have a height of 10.5.) To pick the right size, we need to
resolve the font at the new DPI and use its actual size to scale the
client area.
To keep the amount of text in the window the same, we need to remove the
non-client area of the window (caption bars, resize borders, etc). The
non-client area is outside the area with the text, and its size depends
on the window's DPI and window styles. To remove it and add it back, we
need to:
- Reduce the provided window rect size by the non-client size at the
current DPI.
- Scale the client size using the new/old font sizes.
- Expand the final size by the non-client size at the new DPI.
Fixes
* Cursor vanishing, because
```cpp
CoreWindow::GetForCurrentThread().PointerCursor()
```
returned a non-null, but still invisible cursor.
* Alt/F7 not dispatching to newly created windows, because the
`WM_ACTIVATE` message now arrives before the `AppHost` is initialized.
This caused the messages to be delivered to old windows.
* Windows Terminal blocking expedited shutdown,
because we return `FALSE` on non-`ENDSESSION_CLOSEAPP` messages.
Closes#18331Closes#18335
## Validation Steps Performed
* Cursor still doesn't really vanish for me in the first place ✅
* Alt/F7 work in new windows without triggering old ones ✅
win10-* is no longer a valid rid
https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/8.0/rid-graph
This package would fail to install the dependencies to the correct
location in .net 8 and later by default. win-x64 is a valid runtime id
in prior .net versions so I think this should be back compat.
Without this the package fails to do its job on newer builds unless `
<UseRidGraph>true</UseRidGraph>` and the user sets `win10-x64` as their
RID in their project file.
Forgetti di spaghetti in #18215.
Closes#18324
## Validation Steps Performed
* Launch through the start menu
* Explicitly minimize
* Then...
* Launch through the start menu again ✅
* Launch via wtd.exe in Win+R ✅
* Launch via wtd.exe in another Terminal ✅
* Launch via handoff ✅
CodeQL is raising errors when building Visual Studio since we have a
dependency on Windows Terminal for our integrated terminal. The issue
raised is not applicable to this case and therefore requires a
suppression comment to ignore the raised error.
## Summary of the Pull Request
Adds the Profile.BellSound setting to the Settings UI under the Profile > Advanced page.
- View changes:
- The setting is exposed via an expander placed near the Profile.BellStyle setting.
- Added a button to be able to preview the added sound
- Added a browse button that opens a file picker
- Added a delete button to be able to delete each sound entry
- View model changes:
- `CurrentBellSounds` keeps track of the bell sounds added and exposed via the UI.
- `BellSoundViewModel` wraps each sound. This allows us to listen (and propagate) changes to the registered sounds.
- `BellSoundPreview` provides a written preview of the current bell sound to display in the expander
#10000
As before, a minor refactor:
* I started off by removing the Monarch/Peasant with the goal of moving
it into and deduplicating its functionality with `WindowEmperor`.
* Since I needed a replacement for the Monarch (= ensures that there's
a single instance), I wrote single-instance code with a NT mutex
and by yeeting data across processes with `WM_COPYDATA`.
* This resulted in severe threading issues, because it now started up
way faster. The more I tried to solve them the deeper I had to dig,
because you can't just put a mutex around `CascadiaSettings`.
I then tried to seeif WinUI can run multiple windows on a single
thread and, as it turns out, it can.
So, I removed the multi- from the window threading.
* At this point I had dig about 1 mile deep and brought no ladder.
So, to finish it up, I had to clean up the entire eventing system
around `WindowEmperor`, cleaned up all the coroutines,
and cleaned up all the callbacks.
Closes#16183Closes#16221Closes#16487Closes#16532Closes#16733Closes#16755Closes#17015Closes#17360Closes#17420Closes#17457Closes#17799Closes#17976Closes#18057Closes#18084Closes#18169Closes#18176Closes#18191
## Validation Steps Performed
* It does not crash ✅
* New/close tab ✅
* New/close window ✅
* Move tabs between windows ✅
* Split tab into new window ✅
* Persist windows on exit / restore startup ✅
## Summary of the Pull Request
Adds some pre-existing settings ($profile.foreground,
$profile.background, $profile.selectionBackground, $profile.cursorColor)
to the settings UI. This was accomplished by introducing a new control:
NullableColorPicker. This control allows the user to pick a color from
the color scheme, set the color to null, and select a color from an
advanced color picker.
Improves the UI for the Profile.Icon setting by adding an "Icon Type"
combo box. This allows the user to pick from multiple options:
- None: sets the icon to "none" which is interpreted as no icon
- Built-in Icon: presents a combo box that enumerates the Segoe MDL 2
assets
- Emoji: presents a text box with a hint to open the emoji picker
- File: presents a text box to input the path of the image to use
Additionally, the rendered icon is displayed in the setting container.
If "none", "none" is presented to the user (localized).
## References and Relevant Issues
#10000
## Detailed Description of the Pull Request / Additional comments
- NullableColorPicker control
- includes a built-in NullColorButton to set the current value to null
- includes a "More colors..." button to display an advanced color picker
- uses data templates on data templates (data templates squared?) to
convert the current color scheme into a grid of color chips
- color chips display a checkmark (similar to Windows settings
personalization). This automatically updates its color to stay compliant
with color contrast.
- color chips are added to a list so we can (un)check them when a new
color is selected
- SettingsContainer changes
- Forked `ExpanderSettingContainerStyle` to allow for a custom preview
template. This way, we can display the current value in the expander and
we're not just limited to text.
- changed type of `CurrentValue` property from `String` to
`IInspectable`
- added `CurrentValueTemplate` property to control how to display the
current value
- Miscellaneous:
- Added a few converters (`BooleanToVisibility`, `ColorToString`,
`ColorToBrush`)
- Added `NameWithHexCode` to `ColorTableEntry` to expose a color as `Red
#RRGGBB` (used for tooltips and a11y)
- Added `ForegroundPreview` (and equivalent for other colors) to
AppearanceViewModel to deduce the color that will be used
## Validation Steps Performed
- [X] a11y pass (NVDA, keyboard)
- [X] set the color to one of the color chips
- [X] set the color to null
- [X] set the color to a value from the integrated color picker
- [X] control updates properly when a new color scheme is selected
- [X] control updates properly when a color scheme has multiple colors
of the same value
## Follow-ups
- [A11y] Screen readers don't read expander's preview text
- Add Tab Color to settings UI
- Update CursorColor preview to display #FFFFFF as "invert"
- Use Leonard's font picker UI, with the Segoe icon picker, so that you
can filter the list
If we colored a tab, then switched to another tab, there's a bug that
the unselected tab loses its color. This was introduced in PR #18109.
This PR fixes that by actually applying the selected color to the tab
(whoops). Additionally, I removed setting the
"TabViewItemHeaderCloseButtonBackground" resource because it looked
weird (see comment in PR).
Closes#18226
Left, Top, Right and Bottom paddings can be set separetely in
`Appearance`. I tried to make it as close as possible to one of the
suggestions in #9127. I hope it doesn't look that bad.
Closes#9127
* Previously we would mark all gc=Cf (Control, format) codepoints
as zero-width, but that ignores that the majority of them are also
GCB=CN (Control = does not join), which meant we ended up with
zero-width grapheme clusters. Those cannot exist under a terminal.
So, this PR makes all gc=Cf, GCB=CN codepoints zero-width, but also
treats them as Extender codepoints, which mirrors `wcswidth`.
* This PR also updates the tables to Unicode 16.0.
* Finally, there's a minor code cleanup of the generator.
Closes#18267
## Validation Steps Performed
* Unit tests ✅
* Thai does not have random gaps anymore due to ZWSP ✅
This increases the console IO buffer size to retain at least 128KiB as
this matches the default buffer size of `cat`. This avoids allocator
churn due to constantly freeing and reallocating buffers. In the future
this should ideally use a better suited, cheap allocator.
Closes#18286
## Summary of the Pull Request
Added open current directory action.
## References and Relevant Issues
Need to set this:
https://learn.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory
## Detailed Description of the Pull Request / Additional comments
## Validation Steps Performed
- Ensure shell has been configured
- Run "Open current working directory" action in command palette
- File explorer opens the correct directory
## PR Checklist
- [x] Closes#12859
- [ ] Tests added/passed
- [ ] Documentation updated
- If checked, please file a pull request on [our docs
repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
- [ ] Schema updated (if necessary)
This upgrades to [check-spelling v0.0.24].
A number of GitHub APIs are being turned off shortly, so we need to
upgrade or various uncertain outcomes will occur.
There are some minor bugs that I'm aware of and which I've fixed since
this release (including a couple I discovered while preparing this PR).
There's a new accessibility forbidden pattern:
#### Should be `cannot` (or `can't`)
See https://www.grammarly.com/blog/cannot-or-can-not/
> Don't use `can not` when you mean `cannot`. The only time you're
likely to see `can not` written as separate words is when the word `can`
happens to precede some other phrase that happens to start with `not`.
> `Can't` is a contraction of `cannot`, and it's best suited for
informal writing.
> In formal writing and where contractions are frowned upon, use
`cannot`.
> It is possible to write `can not`, but you generally find it only as
part of some other construction, such as `not only . . . but also.`
- if you encounter such a case, add a pattern for that case to
patterns.txt.
```
\b[Cc]an not\b
```
[check-spelling v0.0.24]: https://github.com/check-spelling/check-spelling/releases/tag/v0.0.24
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
## Summary of the Pull Request
Adds customization for the New Tab Menu to the settings UI.
- Settings Model changes:
- The Settings UI generally works by creating a copy of the entire
settings model objects on which we apply the changes to. Turns out, we
completely left the NewTabMenu out of that process. So I went ahead and
implemented it.
- `FolderEntry`
- `FolderEntry` exposes `Entries()` (used by the new tab menu to figure
out what to actually render) and `RawEntries()` (the actual JSON data
deserialized into settings model objects). I went ahead and exposed
`RawEntries()` since we'll need to apply changes to it to then
serialize.
- View Model:
- `NewTabMenuViewModel` is the main view model that interacts with the
page. It maintains the current view of items and applies changes to the
settings model.
- `NewTabMenuEntryViewModel` and all of the other `_EntryViewModel`
classes are wrappers for the settings model NTM entries.
- `FolderTreeViewEntry` encapsulates `FolderEntryViewModel`. It allows
us to construct a `TreeView` of just folders.
- View changes and additions:
- Added FontIconGlyph to the SettingContainer
- Added a New Tab Menu item to the navigation view
- Adding entries: a stack of SettingContainers is used here. We use the
new `FontIconGlyph` to make this look nice!
- Reordering entries: drag and drop is supported! This might not work in
admin mode though, and we can't drag and drop into folders. Buttons were
added to make this keyboard accessible.
- To move entries into a folder, a button was added which then displays
a TreeView of all folders.
- Multiple entries can be moved to a folder or deleted at once!
- Breadcrumbs are used for folders
- When a folder is entered, additional controls are displayed to
customize that folder.
## Verification
- ✅ a11y pass
- ✅ keyboard accessible
- scenarios:
- ✅ add entries (except actions)
- ✅ changes propagated to settings model (aka "saving works")
- ✅ reorder entries
- ✅ move entries to an existing folder
- ✅ delete multiple entries
- ✅ delete individual entries
- ✅ display entries (including actions)
## Follow-ups
- [ ] add support for adding and editing action entries
- [ ] when we discard changes or save, it would be cool if we could stay
on the same page
- [ ] allow customizing the folder entry _before_ adding it (current
workaround is to add it, then edit it)
- [ ] improve UI for setting icon (reuse UI from #17965)
There were two bugs:
* Ever since the conhost v1 -> v2 rewrite the `readDataDirect.cpp`
implementation incorrectly passed `false` as the wait flag.
The unintentional mistake is obvious in hindsight as the
check for `CONSOLE_STATUS_WAIT` makes no sense in this case.
* The ConPTY integration into `InputBuffer` was done incorrectly,
as it would unconditionally wake up the readers/waiters without
checking if the buffer is now actually non-empty.
Closes#15859
## Validation Steps Performed
Test code:
```cpp
#include <Windows.h>
#include <stdio.h>
int main() {
HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
INPUT_RECORD buf[128];
DWORD read;
SetConsoleMode(
in,
ENABLE_PROCESSED_INPUT | ENABLE_VIRTUAL_TERMINAL_INPUT
);
for (int i = 0; ReadConsoleInputW(in, buf, 128, &read); ++i) {
printf("%d read=%lu\n", i, read);
}
return 0;
}
```
Run it under Windows Terminal and type any input. >50% of all
inputs will result in `read=0`. This is fixed after this PR.
As it turns out, you cannot use `<uap17:UpdateWhileInUse>`
(or any other newer namespace) unless you declare a corresponding
`MaxVersionTested` in your package manifest.
It does not appear that there's a reason for this, it just is.
`MaxVersionTested` is not to be confused with the `maxversiontested`,
which is something else entirely, but I updated it for safe measure.
Since `maxversiontested` is not a "max", but rather a list
of tested versions, it gets appended to the end of the list.
Closes#18119
The current `FindWindowOfActiveTSF` implementation can
result in infinite recursion which we must guard again.
This change is not tested as I don't know how to trigger
the issue to begin with (a missing CoreInput thread).
This change prevents `throttled_func` from reading uninitialized memory
under some yet-unkown circumstances. The tl;dr is:
This simply moves the callback invocation into the storage.
That way we can centrally avoid invoking the callback accidentally.
* This fixes a regression in 391abafc, which caused attached clients
to receive CTRL_CLOSE_EVENTs, etc., in oldest-to-newest order,
while historically the opposite is expected.
* It also changes the behavior of `ProcessCtrlEvents` to dispatch
these events no matter whether a client is already dead.
This restores the Windows XP to Windows 8.1 behavior.
Both of these fixes would address the issue on their own.
Closes#15373
## Validation Steps Performed
* CloseTest from our repository shows newest-to-oldest order again.
* node gets killed when run under npm and closing the tab.
This reverts commit 5fdfd51209fc681e66657d6697ce031bc4319619,
because 3 people complained about this change VS 1 person
requesting the change to be made in the first place.
Closes#18138Reopens#17797 for discussion
When file/folder is dropped to the terminal, its path is translated and
quoted with a pair of single quotes if necessary.
However, the terminal control does not escape single quotes (allowed in
the Win32 subsystem) that need escapes when translated.
On the translation styles other than `"none"` (note: all other
translation styles are currently intended for the POSIX shell), it
causes incorrect path to be pasted when the path contains one or more
single quotes (see #18006 for an example).
With this commit, the terminal control escapes a single quote with a
valid escape sequence `'\''` (finish quote, print a single quote then
begin quote again) when the path translation is required.
## History
### v1 → v2
* Changed escape sequence from `'"'"'` to much shorter `'\''`.
* Reflected comments by the reviewer.
### v2 → v3
* Overhaul after addition of multiple path translation styles (not just
WSL but Cygwin and MSYS).
* More clarification both in the code and in the commit message.
### v3 → v4 (current)
* Minor clarification both in the code and in the commit message.
## References and Relevant Issues
* #18006
* #16214
* #18195
## Detailed Description of the Pull Request / Additional comments
This is a follow-up of #16214 and #18195, fixing #18006.
Closes#18006
microsoft/vcpkg-tool#1474 now validates that the target triplet is
valid. Unfortunately, `ARM64` is not valid... despite VS defaulting to
it.
VS 17.12 moved to the newer version of the vcpkg tool.
Given that we still want to build on VS 17.12, this commit adds a local
workaround.
See DD-2302065 for the internal tracking bug.
See microsoft/vcpkg#42182 for the upstream fix.
## Summary of the Pull Request
This extends the copy command to be able to include control sequences,
for use in tools that subsequently know how to parse and display that.
## References and Relevant Issues
https://github.com/microsoft/terminal/issues/15703
## Detailed Description of the Pull Request / Additional comments
At a high level, this:
- Expands the `CopyTextArgs` to have a `withControlSequences` bool.
- Plumbs that bool down through many layers to where we actuall get
data out of the text buffer.
- Modifies the existing `TextBuffer::Serialize` to be more generic
and renames it to `TextBuffer::ChunkedSerialize`.
- Uses the new `ChunkedSerialize` to generate the data for the copy
request.
## Validation Steps Performed
To test this I've manually:
- Generated some styled terminal contents, copied it with the control
sequences, pasted it into a file, `cat`ed the file and seen that it
looks the same.
- Set `"firstWindowPreference": "persistedWindowLayout"` and
validated that the contents of windows are saved and
restored with styling intact.
I also checked that `Invoke-OpenConsoleTests` passed.
## PR Checklist
- [x] Closes#15703
- [ ] 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/756
- [x] Schema updated (if necessary)
`pathTranslationStyle` has four options:
- `none`: Do no translation
- `wsl`: Translate `C:\` to `/mnt/c` and `\\wsl$\Foo\bar` to `/bar`
- `cygwin`: Translate `C:\` to `/cygdrive/c`
- `msys2`: Translate `C:\` to `/c`
It is intended as a broadly-supported replacement for us checking the
source every time the user drops a path.
We no longer need to push the source name all the way down to the
control.
I am hesitant to commit to using other folks' product names in our
settings model,
however, these are almost certainly more recognizable than whatever
other weird
names we could come up with.
The Git Bash fragment extension profile could conceivably use
`pathTranslationStyle`
`msys2` to make sure drag/dropped paths look right.