PackageES is deprecated by known scourge-on-earth OneBranch, and is now
the cause of some non-compliance.
I got permission from them to open-source it, so that's coming next.
For now, we can just depend on a package based on our code based on
theirs.
Tested and working for C++ (DLL, EXE), C#, NuGet and MSIX.
## Summary of the Pull Request
This commit fixes the middle mouse button handler. The `PointerReleased` callback is registered, but it is not operational because, on the Release event, the mouse button is no longer pressed. We need to track its state and act accordingly.
Issue was introduced by commit 05e7ea1423, which changed the event handler from `PointerPressed` to `PointerReleased`, rendering it inoperative. Instead, the default handler is used. The main issue is that when the close button is hidden with the `showCloseButton` option, the default handler no longer closes the tab on middle mouse clicks.
Also made it consistent with the Settings tab, which was never converted to `PointerReleased` and is still handled with a custom handler.
## References and Relevant Issues
Related commit 05e7ea1423
## Validation Steps Performed
I've been using this commit locally for quite some time, figured out I might as well share it.
Added tab color indicator for the tab switch menu. Tab color indicators
have the same color as the background color of the tabs. If a tab has
the default background color, the indicator is not shown in the tab
switch menu.
Closes#17465
By translating the clip rectangle into a source-relative coordinate
space we can calculate the intersection that must be copied
much much more easily. I should've done that from the start.
Closes#17801
## Validation Steps Performed
* Test code provided in #17801
Under ConPTY we don't load any user settings. `SetUpConsole` notes:
> If we are [ConPTY], we don't want to load any user settings,
> because that could result in some strange rendering results [...]
This enables deduplication by default, which I figured wouldn't cause
any regressions since it's a user-controllable setting anyway, while
it's clearly something the average user wants enabled, for the same
reason that PSReadLine has HistoryNoDuplicates enabled by default.
Closes#17797
## Validation Steps Performed
* Launch conhost, enter 2 commands, press F7, select the older one,
press Enter, press F7. 2 entries ✅
* Launch WT, enter 2 commands, press F7, select the older one,
press Enter, press F7. 2 entries ✅
`GetChar` checks if the vkey is VK_ESCAPE. `CharToKeyEvents` however
tries really hard to figure out the vkeys of all characters.
To avoid these issues all we need to do is to simply use the existing
`WriteString` function we already use for all other VT responses.
If it's good for conhost responses, it's good for ConPTY responses.
Additionally, this removes another `IsVtInputEnabled` which was
redundant with `WriteString` which worked exactly the same internally.
Closes#17813Closes#17851
Probably also related to #17823
## Validation Steps Performed
* Wrote a small app to send and receive a DA1 request. It works ✅
* WSL already worked to begin with (and still works now) ✅
* No double-encoding of mouse input events ✅
## Summary of the Pull Request
When an app makes a VT request that returns a `DCS` response, and it
hasn't also enabled VT input mode, the new passthrough implementation
loses that response. All the app receives is an `Alt`+`\` key press
triggered by the `ST` terminator. This PR fixes that issue.
## References and Relevant Issues
This is one of the unresolved issues tracked in #17643.
## Detailed Description of the Pull Request / Additional comments
The way `DCS` sequences are handled in the input state machine engine is
by returning a nullptr from `ActionDcsDispatch`, which tells the state
machine to ignore that content. But the sequence is still buffered, and
when the `ST` terminator is eventually received, that buffer is flushed,
which passes the whole thing through to the app.
Originally this only worked when VT input mode was enabled, otherwise
the `ST` sequence is converted into a key press, and the buffered `DCS`
content is lost. The way it works now is we set a flag when the `DCS`
introducer is received, and if that flag is set when the `ST` arrives,
we know to trigger a flush rather a key press.
## Validation Steps Performed
I've tested a `DA3` request from the cmd shell (i.e. `echo ^[[=c`), and
confirmed that now works as expected. I've also hacked Windows Terminal
to disable win32-input mode, so I could check how it works with conpty
clients generating standard VT input, and confirmed that an `Alt`+`\`
keypress is still translated correctly.
Worked with @ekoschik on this one.
## Bug the first: the MSAL window `ixptools` spawns
> The auth prompt in pwsh.exe is disabling the terminal window while its
opened and re-enabling it when the window closes. BUT it is enabling
Terminal after dismissing itself, instead of before, which means
terminal is disabled when activated.
>
> Terminal wants focus on the ISLAND window (a grandchild; island is
parented to bridge, which is parented to terminal’s TLW). When it is
activated, it gets a `WM_SETFOCUS` (in response to DefWindowProc
`WM_ACTIVATE`). From `WM_SETFOCUS` it calls `SetFocus` on the bridge
window, and similarly the bridge calls `SetFocus` on the island.
>
> If the TLW is disabled, these `SetFocus` calls fail (see [this
check](#internal-link-redacted) in `SetFocus`). In the case above, this
leaves Terminal’s TLW as focus, and it doesn’t handle keyboard input.
Note that the window IS foreground/active, but because focus is not on
the island it doesn’t see the keyboard input. Another thing to note is
that clicking on the space to the right of the tabs does NOT revive
keyboard input, but clicking on the tabs or main area does.
> **I recommend having the TLW handle WM_ENABLE and call SetFocus on the
island window.**
And guess what, that works!
## Bug the second: When sublime text is the git `EDITOR`, it doesn't
toss focus back to the Terminal
> In this case, Sublime is calling SFW on the pseudo console window. I
don’t have its code, but it is presumably doing something like
SetForegroundWindow(GetConsoleWindow()). This queues an event to the
pseudo window, and when that event is processed the pseudo window
becomes the active and focus window on the queue (which is shared with
Terminal).
>
> The sublime window dismisses itself and does the above SFW call.
Dismissing immediately activates the Terminal TLW, which does the
triple-focus dance (TLW sets focus on itself, then bridge, then island).
This completes but is overwritten immediately when the pseudo window
activates itself. Note that the pseudo window is active at this point
(not the terminal window).
> **I recommend having the Pseudo console window handle WM_ACTIVATE by
calling SetFocus on the island window (and not passing the message to
DefWindowProc).**
And guess what, that works!
----
Closes#15956 (I did test this)
This might be related to #13388, we'll have folks try canary and check
Spacing marks are called so, because they have a positive advance
width, unlike their non-spacing neighbors (as the name indicates).
After this we stop assigning such gc=Mc codepoints a zero width.
Closes#17810
## Summary of the Pull Request
Add action IDs to the default commands for color selection
## Validation Steps Performed
Color selection commands now show up in the command palette
## PR Checklist
- [x] Closes#17819
- [ ] 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)
`ResizeWindow` event in `TerminalApi` is handled and bubbled to
`TerminalApi->ControlCore->TermControl->TerminalPage->AppHost`. Resizing
is accepted only if the window is not in fullscreen or quake mode, and
has 1 tab and pane.
Relevant issues: #5094
This shortens VtPipeTerm quite a bit, which used to have various debug
flags and modes. I kept the `--out` flag to redirect the output to a
file, but I removed the `--debug` (pipe the output through WSL and
show escape sequences visually) and `--headless` (hide conpty) flags.
I did this, because VtPipeTerm always used the system ConPTY API
but I needed it to use my local OpenConsole. I also wanted it to
use overlapped IO for testing but found that it was too difficult
to refactor make that work.
I also noticed that the project was the only holdout for
`conpty.h` which had to be kept in sync with `winconpty.h`.
## Summary of the Pull Request
When a VT title sequence sets the title to a blank string, that is meant
to trigger a reset to the default starting value. This used to work in
the past because the blank value was dealt with by conhost, so Windows
Terminal never received a blank title, but that's no longer the case
with the new VT passthrough. This PR fixes the issue by getting Windows
Terminal to handle the blank title strings itself.
## References and Relevant Issues
VT passthrough was introduced in PR #17510.
## Validation Steps Performed
I've manually verified that the `OSC 0`, `OSC 2`, and `DECSWT` sequences
now correctly reset the title when passed a blank title string.
## PR Checklist
- [x] Closes#17800
This adds logic to get the DA1 report from the hosting terminal on
startup. We then use the information to figure out if it supports
rectangular area operations. If so, we can use DECCRA/DECFRA to
implement ScrollConsoleScreenBuffer.
This additionally changes `ScrollConsoleScreenBuffer` to always
forbid control characters as the fill character, even in conhost
(via `VtIo::SanitizeUCS2`). My hope is that this makes the API
more consistent and robust as it avoids another source for
invisible control characters in the text buffer.
Part of #17643
## Validation Steps Performed
* New tests ✅
Adds functionality throughout the settings model to keep track of which
settings have been set.
There are two entry points:
- AppLogic.cpp: this is where we perform a settings reload by loading
the JSON
- MainPage.cpp: this is where the Save button is clicked in the settings
UI
Both of these entry points call into
`CascadiaSettings::LogSettingChanges()` where we aggregate the list of
changes (specifically, _which_ settings changed, not _what_ their value
is).
Just about all of the settings model objects now have a
`LogSettingChanges(std::set& changes, std::string_view context)` on
them.
- `changes` is where we aggregate all of the changes to. In it being a
set, we don't need to worry about duplicates and can do things like
iterate across all of the profiles.
- `context` prepends a string to the setting. This'll allow us to better
identify where a setting was changes (i.e. "global.X" are global
settings). We also use this to distinguish between settings set in the
~base layer~ profile defaults vs individual profiles.
The change log in each object is modified via two ways:
- `LayerJson()` changes: this is useful for detecting JSON changes! All
we're doing is checking if the setting has a value (due to inheritance,
just about everything is an optional here!). If the value is set, we add
the json key to the change log
- `INHERITABLE_SETTING_WITH_LOGGING` in IInheritable.h: we already use
this macro to define getters and setters. This new macro updates the
setter to check if the value was set to something different. If so, log
it!
Other notes:
- We're not distinguishing between `defaultAppearance` and
`unfocusedAppearance`
- We are distinguishing between `profileDefaults` and `profile` (any
other profile)
- New Tab Menu Customization:
- we really just care about the entry types. Handled in
`GlobalAppSettings`
- Font:
- We still have support for legacy values here. We still want to track
them, but just use the modern keys.
- `Theme`:
- We don't do inheritance here, so we have to approach it differently.
During the JSON load, we log each setting. However, we don't have
`LayerJson`! So instead, do the work in `CascadiaSettings` and store the
changes there. Note that we don't track any changes made via setters.
This is fine for now since themes aren't even in the settings UI, so we
wouldn't get much use out of it anyways.
- Actions:
- Actions are weird because we can have nested and iterable actions too,
but `ActionsAndArgs` as a whole add a ton of functionality. I handled it
over in `Command::LogSettingChanges` and we generally just serialize it
to JSON to get the keys. It's a lot easier than dealing with the object
model.
Epic: #10000
Auto-Save (ish): #12424
This is particularly relevant to pwsh with the "ghost text" enabled. In
that scenario, pwsh writes out the predicted command to the right of the
cursor. With `showSuggestions(useCommandline=true)`, we'd auto-include
that text in the filter, and that was effectively useless.
This instead defaults us to not use anything to the right of the cursor
(inclusive) for what we consider "the current commandline"
closes#17772
1. Don't crash on a cmdpal "duplicate pane" of a snippets pane
* Found while trying to solve bug the third.
* "Duplicate pane" with a snippets pane would crash. This was due to us
attempting to `PreviewText` when there was no buffer yet.
(`_activeBuffer()` strikes again)
2. dismiss the preview from cmdpal correctly too
* Again while looking for part the third, I hit this
* I have a `sendInput(input: "a")` command. This is the first command in
the palette. And opening a new pane would... preview that command in the
new pane? weird. Moving the line in `CommandPalette::_close` fixes this
3. Don't crash when we're restoring a snippets pane and there's a bunch
of windows
* This was the real bug I was trying to fix
* Looks like if you have enough panes & windows, there's enough of a
delay between ctoring a snippets pane and actually calling
`_UpdateSettings` on it, that the XAML loads and tries to bind to
`_allTasks`, which _hadn't been constructed yet_
* closes#17793
This PR clones `winrt::fire_and_forget` and replaces the uncaught
exception handler with one that logs instead of terminating.
My hope is that this removes one source of random crashes.
## Validation Steps Performed
I added a `THROW_HR` to `TermControl::UpdateControlSettings`
before and after the suspension point and ensured the application
won't crash anymore.
* Repurposes `_sendInputToConnection` to send output to the connection
no matter whether the terminal is read-only or not.
Now `SendInput` is the function responsible for the UI handling.
* Buffers responses in a VT string into a single string
before sending it as a response all at once.
This reduces the chances for the UI thread to insert cursor positions
and similar into the input pipe, because we're not constantly unlocking
the terminal lock anymore for every response. The only way now that
unrelated inputs are inserted into the input pipe is because the VT
requests (e.g. DA1, DSR, etc.) are broken up across >1 reads.
This also fixes VT responses in read-only panes.
Closes#17775
## Validation Steps Performed
* Repeatedly run `echo ^[[c` in cmd.
DA1 responses don't stack & always stay the same ✅
* Run nvim in WSL. Doesn't deadlock when pasting 1MB. ✅
* Run the repro from #17775, which requests a ton of OSC 4
(color palette) responses. Jiggle the cursor on top of the window.
Responses never get split up. ✅
I guess I didn't realize that `SendCharEvent` could get called before `Create`. In that scenario, `enter` would hit the automark codepath (due to #17761), then crash because there was no text buffer.
Pretty easy to prevent.
Closes#17776
I used this very bad regex to try and find all the `\x1b`'s in ScreenBufferTests that weren't in a ProcessString call:
```
(?<!ProcessString.*)\x1b\[
```
And these looked like the ones that were the only violations.
Closes#17736
## Summary of the Pull Request
Improves Quick Fix's suggestions to use WinGet API and actually query
winget for packages based on the missing command.
To interact with the WinGet API, we need the
`Microsoft.WindowsPackageManager.ComInterop` NuGet package.
`Microsoft.WindowsPackageManager.ComInterop.Additional.targets` is used
to copy over the winmd into CascadiaPackage. The build variable
`TerminalWinGetInterop` is used to import the package properly.
`WindowsPackageManagerFactory` is used as a centralized way to generate
the winget objects. Long-term, we may need to do manual activation for
elevated sessions, which this class can easily be extended to support.
In the meantime, we'll just use the normal `winrt::create_instance` on
all sessions.
In `TerminalPage`, we conduct the search asynchronously when a missing
command was found. Search results are limited to 20 packages. We try to
retrieve packages with the following filters set, then fallback into the
next step:
1. `PackageMatchField::Command`,
`PackageFieldMatchOption::StartsWithCaseInsensitive`
2. `PackageMatchField::Name`,
`PackageFieldMatchOption::ContainsCaseInsensitive`
3. `PackageMatchField::Moniker`,
`PackageFieldMatchOption::ContainsCaseInsensitive`
This aligns with the Microsoft.WinGet.CommandNotFound PowerShell module
([link to relevant
code](9bc83617b9/src/WinGetCommandNotFoundFeedbackPredictor.cs (L165-L202))).
Closes#17378Closes#17631
Support for elevated sessions tracked in #17677
## References
-
https://github.com/microsoft/winget-cli/blob/master/src/Microsoft.Management.Deployment/PackageManager.idl:
winget object documentation
## Validation Steps Performed
- [X] unelevated sessions --> winget query performed and presented
- [X] elevated sessions --> nothing happens (got rid of `winget install
{}` suggestion)
Pretty obvious in retrospect. If there's no results, then we need to
preview
_nothing_ to make sure that we clear out any old previews.
Closes#17773
Additionally, while I was here:
I realized why it seems like the selected item is so wacky when you
first open the sxnui:
* on launch we're not scrolling to the bottom item (which makes it
awkward in bottom up mode)
* when we filter the list, we're maintaining the selection _index_, not
the selection _item_.
Alas, that second part is... shockingly bodgy.
PR #10642 and #11290 introduced an adjustment for the cursor position
used to generate VT mouse mode events.
One of the decisions made in those PRs was to only send coordinates
where Y was >= 0, so if you were off the top of the screen you wouldn't
get any events. However, terminal emulators are expected to send
_clamped_ events when the mouse is off the screen. This decision broke
clamping Y to 0 when the mouse was above the screen.
The other decision was to only adjust the Y coordinate if the core's
`ScrollOffset` was greater than 0. It turns out that `ScrollOffset` _is
0_ when you are scrolled all the way back in teh buffer. With this
check, we would clamp coordinates properly _until the top line of the
scrollback was visible_, at which point we would send those coordinates
over directly. This resulted in the same weird behavior as observed in
#10190.
I've fixed both of those things. Core is expected to receive negative
coordinates and clamp them to the viewport. ScrollOffset should never be
below 0, as it refers to the top visible buffer line.
In addition to that, #17744 uncovered that we were allowing
autoscrolling to happen even when VT mouse events were being generated.
I added a way for `ControlInteractivity` to halt further event
processing. It's crude.
Refs #10190Closes#17744
We were erroneously eating Alt followed by VK_ADD. This change makes
sure we cache key presses and releases that happen once a numpad
composition is active so that we can send them when you release Alt.
Right now, we only send them when you release Alt after composing Alt
and VK_ADD (entering hex mode) and only if you haven't inserted an
actual hex numpad code. This does mean that `Alt VK_ADD 0 0 H I` will
result in an input of "+hi". That... seems like a small price to pay for
Alt VK_ADD working again.
Closes#17762
#17510 made it so that VT requests like DA1 are passed through to the
hosting terminal and so conhost stopped responding to them on its own.
But since our input parser doesn't support proper passthrough (yet),
it swallowed the response coming from the terminal.
To solve this issue, this PR repurposes the existing boolean return
values to indicate to the parser whether the current sequence should
be flushed to the dispatcher as-is. The output parser always returns
true (success) and leaves its pass-through handler empty, while the
input parser returns false for sequences it doesn't expect.
## Validation Steps Performed
* Launch cmd
* Press `Ctrl+[`, `[`, `c`, `Enter` (= `^[[c` = DA1 request)
* DA1 response is visible ✅
This pull request adds support for setting and querying the selection
color with `OSC 17`.
To make this possible, I had to move selection color down into the color
table where it always belonged. This lets us get rid of the special
`SetSelectionColor` method from the surface of AtlasEngine, and reunites
selection colors with the rest of the special colors.
When you close a window, it naturally loses focus.
We were trying to use members of the control to update its appearance on
focus loss after it got torn down.
Closes#17520
Swapped the `swprintf_s` with no failure checks against a
`str_printf_nothrow` with checks. I also deduplicated the
`CreateProcess` calls since they're mostly identical.
Closes#16860
Some simple logic to report whenever an action has successfully occurred
(and what ShortcutAction was used).
Note, there will be some false positives here from startup. I noticed we
get a `newTab` on launch. This is probably a result of restoring the
window layout of the previous session since we're using ActionAndArgs
for that.
Same justification as #17749.
We will revert this when either OneBranch Custom Pools become
fit-for-purpose or they upgrade to VS 17.11. Or the heat death of the
universe.
This pull request adds support for querying all of the "dynamic
resource" colors (foreground, background, cursor) as well as the entire
color palette using OSC 4, 10, 11 and 12 with the `?` color specifier.
To ease integration and to make it easier to extend later, I have
consolidated `SetDefaultForeground`, `SetDefaultBackground` and
`SetCursorColor` into one function `SetXtermColorResource`, plus its
analog `RequestXtermColorResource`.
Those functions will map xterm resource OSC numbers to color table
entries and optionally color _alias_ entries using a constant table. The
alias mappings are required to support reassigning the default
foreground and background to their indexed entries after a `DECAC`.
While there are only three real entries in the mapping table right now,
I have designs on bringing in selection background (xterm "highlight")
and foreground (xterm "highlightText").
We can also extend this to support resetting via OSC 110-119. However,
at the adapter layer we do not have the requisite information to restore
any of the colors (even the cursor color!) to the user's defaults.
`OSC 10` and `OSC 11` queries report the final values of
`DECAC`-reassigned entries, under the assumption that an application
asking for them wants to make a determination regardless of their
internal meaning to us (that is: they read through the aliased color to
its final destination in the color palette.)
I've tested this with lsix, which detects the background color before
generating sixel previews. It works great!
ConPTY does not currently pass OSC sequences received on the input
handle, so work was required to make it do so.
Closes#3718
Fixes a regression from the actions MVVM change in #14292 - attempting
to overwrite a keybinding was displaying a warning but propagating the
change before the user acknowledged it.
The overwrite key binding warning in the SUI works like before
Closes#17754
As we discussed in bug bash.
There's really no downside to us enabling it by default (and leaving
showMarksOnScrollbar: false). It'll mark lines as "prompts" when the
user hits enter. This will have a couple good side effects:
* When folks have right-aligned prompts (like, from oh-my-posh), the
`enter` will terminate where shell integration thinks the command is, so
that the right-prompt doesn't end up in the commandline history
* the scrollToMark actions will Just Work without any other shell
integration
Closes#17632
By manually setting the `_windowTarget` to `0`, we can make sure to toss
`x-save` commandlines at the current terminal window (so long as there
is one).
Edge cases:
* You passed other subcommands with `x-save`: Well, we'll do whatever we
would have normally done for multiple subcommands. We won't `x-save` in
the current window, we'll obey your settings. That seems to make sense
* You ran `wt x-save` without an open Terminal window: We'll open a
terminal window during the process of handling it. That seems sensible.
Closes#17366
In #16886, the key for the nested action got renamed from `Split
Pane...` to `Split pane`. This accidentally caused a collision because
now there's two actions with the same name! The settings model then
prefers the user's action over the one defined in defaults.json, thus
completely hiding the nested version.
I tried to balance the stylistic recommendations from #16846 (mainly
[this
comment](https://github.com/microsoft/terminal/issues/16846#issuecomment-2005007519)
since it gave some excellent examples) while trying to maintain muscle
memory as much as possible (with similar substring sequences). There was
also one case where we still used "the tab" so I removed the "the" for
consistency.
Side effect of #16886 which closed#16846Closes#17294Closes#17684
Does what it says on the tin.
Part of #17737
## Validation Steps Performed
* In WSL run
`printf "\e[?9001h"; sleep 1; printf "\e[?9001l"; read`
* Wait 1s and press Enter
* Run `showkey -a`
* Esc works ✅
I don't know what has changed between #17450 and now, but that fix
doesn't seem necessary anymore. If you add this action:
```json
{
"keys": "ctrl+a",
"command":
{
"action": "splitPane",
"commandline": "cmd /c exit"
}
}
```
and repeatedly spam Ctrl-A it used to lead to crashes. That doesn't
happen anymore, because some other PR must've fixed that.
Reverting #17450 fixes the issue found in #17578: Because the content
pointer didn't get reset to null anymore it meant that the root
pane retained the pointer after a split. After closing the split off
pane, it would assign the remaining one back to the root, which would
cause the still existing content pointer to be closed. That pointer
is potentially the same as the remaining pane and so no close events
would get received anymore.
Closes#17578
## Validation Steps Performed
* Add the above action and spam it ✅
* Start with an empty window, split pane, type `exit` in the new pane
then type it in the original pane. It closes the window ✅
## Summary of the Pull Request
Fixes the `RangeFromPoint` API such that we're now properly locking when
we attempt to retrieve the viewport data. This also corrects the
conversion from `UiaPoint` (screen position) to buffer coordinates
(buffer cell).
Closes#17579
## Detailed Description of the Pull Request / Additional comments
- `UiaTextRangeBase::Initialize(UiaPoint)`:
- reordered logic to clamp to client area first, then begin conversion
to buffer coordinates
- properly lock when retrieving the viewport data
- updated `_TranslatePointToScreen` and `_TranslatePointFromScreen` to
use `&` instead of `*`
- we weren't properly updating the parameter before
- `TermControlUiaTextRange::_TranslatePointFromScreen()`
- `includeOffsets` was basically copied over from
`_TranslatePointToScreen`. The math itself was straight up wrong since
we had to do it backwards.
## Validation Steps Performed
✅ Moved WT to top-left of monitor, then used inspect.exe to call
`RangeFromPoint` API when mouse cursor is on top-left buffer cell (also
meticulously stepped through the two functions ensuring everything was
correct).
`ProcessString` may delete the ASB and cause a dangling screen info
pointer. As such, we must avoid using the pointer after the call.
Closes#17709
## Validation Steps Performed
I couldn't repro the issue.