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";
|
2020-08-07 16:46:52 +02:00
|
|
|
import "IControlSettings.idl";
|
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
|
|
|
|
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.
|
2020-08-15 01:44:39 +02:00
|
|
|
[uuid("0ddf4edc-3fda-4dee-97ca-a417ee3dd510")] interface IDirectKeyListener {
|
|
|
|
Boolean OnDirectKeyEvent(UInt32 vkey, UInt8 scanCode, Boolean down);
|
2020-03-05 21:35:46 +01:00
|
|
|
}
|
|
|
|
|
Add copyFormatting keybinding arg and array support (#6004)
Adds array support for the existing `copyFormatting` global setting.
This allows users to define which formats they would specifically like
to be copied.
A boolean value is still accepted and is translated to the following:
- `false` --> `"none"` or `[]`
- `true` --> `"all"` or `["html", "rtf"]`
This also adds `copyFormatting` as a keybinding arg for `copy`. As with
the global setting, a boolean value and array value is accepted.
CopyFormat is a WinRT enum where each accepted format is a flag.
Currently accepted formats include `html`, and `rtf`. A boolean value is
accepted and converted. `true` is a conjunction of all the formats.
`false` only includes plain text.
For the global setting, `null` is not accepted. We already have a
default value from before so no worries there.
For the keybinding arg, `null` (the default value) means that we just do
what the global arg says to do. Overall, the `copyFormatting` keybinding
arg is an override of the global setting **when using that keybinding**.
References #5212 - Spec for formatted copying
References #2690 - disable html copy
Validated behavior with every combination of values below:
- `copyFormatting` global: { `true`, `false`, `[]`, `["html"]` }
- `copyFormatting` copy arg:
{ `null`, `true`, `false`, `[]`, `[, "html"]`}
Closes #4191
Closes #5262
2020-08-15 03:02:24 +02:00
|
|
|
[flags]
|
|
|
|
enum CopyFormat
|
|
|
|
{
|
|
|
|
HTML = 0x1,
|
|
|
|
RTF = 0x2,
|
|
|
|
All = 0xffffffff
|
|
|
|
};
|
|
|
|
|
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; };
|
Add copyFormatting keybinding arg and array support (#6004)
Adds array support for the existing `copyFormatting` global setting.
This allows users to define which formats they would specifically like
to be copied.
A boolean value is still accepted and is translated to the following:
- `false` --> `"none"` or `[]`
- `true` --> `"all"` or `["html", "rtf"]`
This also adds `copyFormatting` as a keybinding arg for `copy`. As with
the global setting, a boolean value and array value is accepted.
CopyFormat is a WinRT enum where each accepted format is a flag.
Currently accepted formats include `html`, and `rtf`. A boolean value is
accepted and converted. `true` is a conjunction of all the formats.
`false` only includes plain text.
For the global setting, `null` is not accepted. We already have a
default value from before so no worries there.
For the keybinding arg, `null` (the default value) means that we just do
what the global arg says to do. Overall, the `copyFormatting` keybinding
arg is an override of the global setting **when using that keybinding**.
References #5212 - Spec for formatted copying
References #2690 - disable html copy
Validated behavior with every combination of values below:
- `copyFormatting` global: { `true`, `false`, `[]`, `["html"]` }
- `copyFormatting` copy arg:
{ `null`, `true`, `false`, `[]`, `[, "html"]`}
Closes #4191
Closes #5262
2020-08-15 03:02:24 +02:00
|
|
|
Windows.Foundation.IReference<CopyFormat> Formats { get; };
|
2019-08-20 00:59:01 +02:00
|
|
|
}
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
runtimeclass PasteFromClipboardEventArgs
|
|
|
|
{
|
|
|
|
void HandleClipboardData(String data);
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:52:39 +02:00
|
|
|
runtimeclass OpenHyperlinkEventArgs
|
|
|
|
{
|
|
|
|
String Uri { get; };
|
|
|
|
}
|
|
|
|
|
2020-11-11 03:24:06 +01:00
|
|
|
enum NoticeLevel
|
|
|
|
{
|
|
|
|
Debug = 10,
|
|
|
|
Info = 20,
|
|
|
|
Warning = 30,
|
|
|
|
Error = 40,
|
|
|
|
};
|
|
|
|
|
|
|
|
runtimeclass NoticeEventArgs
|
|
|
|
{
|
|
|
|
NoticeLevel Level { get; };
|
|
|
|
String Message { get; };
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2020-08-07 16:46:52 +02:00
|
|
|
TermControl(Microsoft.Terminal.TerminalControl.IControlSettings settings, Microsoft.Terminal.TerminalConnection.ITerminalConnection connection);
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2020-08-07 16:46:52 +02:00
|
|
|
static Windows.Foundation.Size GetProposedDimensions(Microsoft.Terminal.TerminalControl.IControlSettings settings, UInt32 dpi);
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2020-08-07 16:46:52 +02:00
|
|
|
void UpdateSettings(Microsoft.Terminal.TerminalControl.IControlSettings newSettings);
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2020-08-10 18:21:56 +02:00
|
|
|
Microsoft.Terminal.TerminalControl.IControlSettings Settings { get; };
|
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
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-09-03 19:52:39 +02:00
|
|
|
event Windows.Foundation.TypedEventHandler<TermControl, OpenHyperlinkEventArgs> OpenHyperlink;
|
2020-11-11 03:24:06 +01:00
|
|
|
event Windows.Foundation.TypedEventHandler<TermControl, NoticeEventArgs> RaiseNotice;
|
2020-10-01 03:00:06 +02:00
|
|
|
event Windows.Foundation.TypedEventHandler<Object, Object> WarningBell;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
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
|
|
|
|
Add copyFormatting keybinding arg and array support (#6004)
Adds array support for the existing `copyFormatting` global setting.
This allows users to define which formats they would specifically like
to be copied.
A boolean value is still accepted and is translated to the following:
- `false` --> `"none"` or `[]`
- `true` --> `"all"` or `["html", "rtf"]`
This also adds `copyFormatting` as a keybinding arg for `copy`. As with
the global setting, a boolean value and array value is accepted.
CopyFormat is a WinRT enum where each accepted format is a flag.
Currently accepted formats include `html`, and `rtf`. A boolean value is
accepted and converted. `true` is a conjunction of all the formats.
`false` only includes plain text.
For the global setting, `null` is not accepted. We already have a
default value from before so no worries there.
For the keybinding arg, `null` (the default value) means that we just do
what the global arg says to do. Overall, the `copyFormatting` keybinding
arg is an override of the global setting **when using that keybinding**.
References #5212 - Spec for formatted copying
References #2690 - disable html copy
Validated behavior with every combination of values below:
- `copyFormatting` global: { `true`, `false`, `[]`, `["html"]` }
- `copyFormatting` copy arg:
{ `null`, `true`, `false`, `[]`, `[, "html"]`}
Closes #4191
Closes #5262
2020-08-15 03:02:24 +02:00
|
|
|
Boolean CopySelectionToClipboard(Boolean singleLine, Windows.Foundation.IReference<CopyFormat> formats);
|
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
|
|
|
|
2020-08-12 15:46:53 +02:00
|
|
|
void SendInput(String input);
|
2020-07-02 01:17:43 +02:00
|
|
|
void ToggleRetroEffect();
|
2020-08-08 01:07:42 +02:00
|
|
|
|
|
|
|
Windows.Foundation.IReference<Windows.UI.Color> TabColor { get; };
|
|
|
|
event Windows.Foundation.TypedEventHandler<Object, Object> TabColorChanged;
|
2019-05-03 00:29:04 +02:00
|
|
|
}
|
|
|
|
}
|