2019-05-03 00:29:04 +02:00
|
|
|
// Copyright (c) Microsoft Corporation.
|
|
|
|
// Licensed under the MIT license.
|
|
|
|
|
Manually pass mouse wheel messages to TermControls (#5131)
## Summary of the Pull Request
As we've learned in #979, not all touchpads are created equal. Some of them have bad drivers that makes scrolling inactive windows not work. For whatever reason, these devices think the Terminal is all one giant inactive window, so we don't get the mouse wheel events through the XAML stack. We do however get the event as a `WM_MOUSEWHEEL` on those devices (a message we don't get on devices with normally functioning trackpads).
This PR attempts to take that `WM_MOUSEWHEEL` and manually dispatch it to the `TermControl`, so we can at least scroll the terminal content.
Unfortunately, this solution is not very general purpose. This only works to scroll controls that manually implement our own `IMouseWheelListener` interface. As we add more controls, we'll need to continue manually implementing this interface, until the underlying XAML Islands bug is fixed. **I don't love this**. I'd rather have a better solution, but it seems that we can't synthesize a more general-purpose `PointerWheeled` event that could get routed through the XAML tree as normal.
## References
* #2606 and microsoft/microsoft-ui-xaml#2101 - these bugs are also tracking a similar "inactive windows" / "scaled mouse events" issue in XAML
## PR Checklist
* [x] Closes #979
* [x] I work here
* [ ] Tests added/passed
* [n/a] Requires documentation to be updated
## Detailed Description of the Pull Request / Additional comments
I've also added a `til::point` conversion _to_ `winrt::Windows::Foundation::Point`, and some scaling operators for `point`
## Validation Steps Performed
* It works on my HP Spectre 2017 with a synaptics trackpad
- I also made sure to test that `tmux` works in panes on this laptop
* It works on my slaptop, and DOESN'T follow this hack codepath on this machine.
2020-04-01 18:58:16 +02:00
|
|
|
import "IMouseWheelListener.idl";
|
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
namespace Microsoft.Terminal.TerminalControl
|
|
|
|
{
|
|
|
|
delegate void TitleChangedEventArgs(String newTitle);
|
2020-01-08 22:19:23 +01:00
|
|
|
delegate void FontSizeChangedEventArgs(Int32 width, Int32 height, Boolean isInitialChange);
|
2019-05-03 00:29:04 +02:00
|
|
|
delegate void ScrollPositionChangedEventArgs(Int32 viewTop, Int32 viewHeight, Int32 bufferLength);
|
2019-08-20 00:59:01 +02:00
|
|
|
|
2020-03-05 21:35:46 +01:00
|
|
|
// C++/winrt makes it difficult to share this idl between two projects,
|
|
|
|
// Instead, we just pin the uuid and include it in both TermControl and App
|
2020-06-12 00:41:16 +02:00
|
|
|
// If you update this one, please update TerminalApp\IDirectKeyListener.idl.
|
2020-03-05 21:35:46 +01:00
|
|
|
// If you change this interface, please update the guid.
|
2020-06-12 00:41:16 +02:00
|
|
|
// If you press F7 or Alt and get a runtime error, go make sure both copies are the same.
|
|
|
|
[uuid("339e1a87-5315-4da6-96f0-565549b6472b")] interface IDirectKeyListener {
|
|
|
|
Boolean OnDirectKeyEvent(UInt32 vkey, Boolean down);
|
2020-03-05 21:35:46 +01:00
|
|
|
}
|
|
|
|
|
2019-08-20 00:59:01 +02:00
|
|
|
runtimeclass CopyToClipboardEventArgs
|
|
|
|
{
|
|
|
|
String Text { get; };
|
|
|
|
String Html { get; };
|
2019-11-13 21:13:22 +01:00
|
|
|
String Rtf { get; };
|
2019-08-20 00:59:01 +02:00
|
|
|
}
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
runtimeclass PasteFromClipboardEventArgs
|
|
|
|
{
|
|
|
|
void HandleClipboardData(String data);
|
|
|
|
}
|
|
|
|
|
2020-06-12 00:41:16 +02:00
|
|
|
[default_interface] runtimeclass TermControl : Windows.UI.Xaml.Controls.UserControl, IDirectKeyListener, IMouseWheelListener
|
2019-05-03 00:29:04 +02:00
|
|
|
{
|
2019-06-28 19:55:46 +02:00
|
|
|
TermControl(Microsoft.Terminal.Settings.IControlSettings settings, Microsoft.Terminal.TerminalConnection.ITerminalConnection connection);
|
2019-05-03 00:29:04 +02:00
|
|
|
|
Add support for running a `wt` commandline in the curent window WITH A KEYBINDING (#6537)
## Summary of the Pull Request
Adds a execute commandline action (`wt`), which lets a user bind a key to a specific `wt` commandline. This commandline will get parsed and run _in the current window_.
## References
* Related to #4472
* Related to #5400 - I need this for the commandline mode of the Command Palette
* Related to #5970
## PR Checklist
* [x] Closes oh, there's not actually an issue for this.
* [x] I work here
* [x] Tests added/passed
* [ ] Requires documentation to be updated - yes it does
## Detailed Description of the Pull Request / Additional comments
One important part of this change concerns how panes are initialized at runtime. We've had some persistent trouble with initializing multiple panes, because they rely on knowing how big they'll actually be, to be able to determine if they can split again.
We previously worked around this by ignoring the size check when we were in "startup", processing an initial commandline. This PR however requires us to be able to know the initial size of a pane at runtime, but before the parents have necessarily been added to the tree, or had their renderer's set up.
This led to the development of `Pane::PreCalculateCanSplit`, which is very highly similar to `Pane::PreCalculateAutoSplit`. This method attempts to figure out how big a pane _will_ take, before the parent has necessarily laid out.
This also involves a small change to `TermControl`, because if its renderer hasn't been set up yet, it'll always think the font is `{0, fontHeight}`, which will let the Terminal keep splitting in the x direction. This change also makes the TermControl set up a renderer to get the real font size when it hasn't yet been initialized.
## Validation Steps Performed
This was what the json blob I was using for testing evolved into
```json
{
"command": {
"action":"wt",
"commandline": "new-tab cmd.exe /k #work 15 ; split-pane cmd.exe /k #work 15 ; split-pane cmd.exe /k media-commandline ; new-tab powershell dev\\symbols.ps1 ; new-tab -p \"Ubuntu\" ; new-tab -p \"haunter.gif\" ; focus-tab -t 0",
},
"keys": ["ctrl+shift+n"]
}
```
I also added some tests.
# TODO
* [x] Creating a `{ "command": "wt" }` action without a commandline will spawn a new `wt.exe` process?
- Probably should just do nothing for the empty string
2020-07-17 23:05:29 +02:00
|
|
|
static Windows.Foundation.Size GetProposedDimensions(Microsoft.Terminal.Settings.IControlSettings settings, UInt32 dpi);
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
void UpdateSettings(Microsoft.Terminal.Settings.IControlSettings newSettings);
|
|
|
|
|
|
|
|
event TitleChangedEventArgs TitleChanged;
|
2020-01-08 22:19:23 +01:00
|
|
|
event FontSizeChangedEventArgs FontSizeChanged;
|
2019-08-20 00:59:01 +02:00
|
|
|
event Windows.Foundation.TypedEventHandler<TermControl, CopyToClipboardEventArgs> CopyToClipboard;
|
2019-05-03 00:29:04 +02:00
|
|
|
event Windows.Foundation.TypedEventHandler<TermControl, PasteFromClipboardEventArgs> PasteFromClipboard;
|
|
|
|
|
2020-01-27 16:34:12 +01:00
|
|
|
event Windows.Foundation.TypedEventHandler<TermControl, Windows.UI.Xaml.RoutedEventArgs> Initialized;
|
2019-11-25 23:22:29 +01:00
|
|
|
// This is an event handler forwarder for the underlying connection.
|
|
|
|
// We expose this and ConnectionState here so that it might eventually be data bound.
|
|
|
|
event Windows.Foundation.TypedEventHandler<TermControl, IInspectable> ConnectionStateChanged;
|
|
|
|
Microsoft.Terminal.TerminalConnection.ConnectionState ConnectionState { get; };
|
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
String Title { get; };
|
2019-08-17 00:43:51 +02:00
|
|
|
|
2020-03-09 16:17:34 +01:00
|
|
|
Boolean CopySelectionToClipboard(Boolean collapseText);
|
2019-06-25 21:17:02 +02:00
|
|
|
void PasteTextFromClipboard();
|
2019-05-03 00:29:04 +02:00
|
|
|
void Close();
|
Enable resizing the panes with the keyboard. (#1207)
Adds the ability to resize panes with the keyboard.
This is accomplished by making the Column/RowDefinitions for a Pane use `GridLengthHelper::FromPixels` to set their size. We store a pair of floats that represents the relative amount that each pane takes out of the parent pane. When the window is resized, we use that percentage to figure out the new size of each child in pixels, and manually size each column.
Then, when the user presses the keybindings for resizePane{Left/Right/Up/Down}, we'll adjust those percentages, and resize the rows/cols as appropriate.
Currently, each pane adjusts the width/height by 5% of the total size at a time. I am not in love with this, but it works for now. I think when we get support for keybindings with arbitrary arg blobs, then we could do either a percent movement, or a number of characters at a time. The number of characters one would be trickier, because we'd have to get the focused control, and get the number of pixels per character, as adjacent panes might not have the same font sizes.
2019-07-10 15:27:12 +02:00
|
|
|
Windows.Foundation.Size CharacterDimensions { get; };
|
|
|
|
Windows.Foundation.Size MinimumSize { get; };
|
2020-01-08 22:19:23 +01:00
|
|
|
Single SnapDimensionToGrid(Boolean widthOrHeight, Single dimension);
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
void ScrollViewport(Int32 viewTop);
|
|
|
|
Int32 GetScrollOffset();
|
2019-05-15 15:21:14 +02:00
|
|
|
Int32 GetViewHeight();
|
2019-05-03 00:29:04 +02:00
|
|
|
event ScrollPositionChangedEventArgs ScrollPositionChanged;
|
2019-09-30 15:18:05 +02:00
|
|
|
|
Search - add search box control and implement search experience (#3590)
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? -->
This is the PR for feature Search: #605
This PR includes the newly introduced SearchBoxControl in TermControl dir, which is the search bar for the search experience. And the codes that enable Search in Windows Terminal.
<!-- Other than the issue solved, is this relevant to any other issues/existing PRs? -->
The PR that migrates the Conhost search module: https://github.com/microsoft/terminal/pull/3279
Spec (still actively updating): https://github.com/microsoft/terminal/pull/3299
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [x] Closes #605
* [ ] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Requires documentation to be updated
* [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx
<!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here -->
These functionalities are included in the search experience.
1. Search in Terminal text buffer.
2. Automatic wrap-around.
3. Search up or down switch by clicking different buttons.
4. Search case sensitively/insensitively by clicking a button. S. Move the search box to the top/bottom by clicking a button.
6. Close by clicking 'X'.
7. Open search by ctrl + F.
When the searchbox is open, the user could still interact with the terminal by clicking the terminal input area.
While I already have the search functionalities, currently there are still some known to-do works and I will keep updating my PR:
1. Optimize the search box UI, this includes:
1) Theme adaptation. The search box background and font color
should change according to the theme,
2) Add background. Currently the elements in search box are all
transparent. However, we need a background.
3) Move button should be highlighted once clicked.
2. Accessibility: search process should be able to performed without mouse. Once the search box is focused, the user should be able to navigate between all interactive elements on the searchbox using keyboard.
<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
To test:
1. checkout this branch.
2. Build the project.
3. Start Windows Terminal and press Ctrl+F
4. The search box should appear on the top right corner.
2019-12-17 16:52:37 +01:00
|
|
|
void CreateSearchBoxControl();
|
|
|
|
|
2019-09-30 15:18:05 +02:00
|
|
|
void AdjustFontSize(Int32 fontSizeDelta);
|
2019-11-25 18:35:10 +01:00
|
|
|
void ResetFontSize();
|
2020-07-02 01:17:43 +02:00
|
|
|
|
|
|
|
void ToggleRetroEffect();
|
2019-05-03 00:29:04 +02:00
|
|
|
}
|
|
|
|
}
|