Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search - add search box control and implement search experience #3590

Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
66aeec0
Make search a shared component for conhost and terminal
KaiyuWang16 Oct 21, 2019
02a280c
Remove inclusion of deprecated interface file
KaiyuWang16 Oct 22, 2019
030961e
Code review changes, remove text buffer modification in Terminal
KaiyuWang16 Oct 22, 2019
7eb30f6
remove unreferenced objects to fix build errors
KaiyuWang16 Oct 22, 2019
fd0090e
Fix test failure, guarantee uiaData object is correctly initialized i…
KaiyuWang16 Oct 23, 2019
c45ef9c
minor comment typo fix and format fix
KaiyuWang16 Oct 23, 2019
eae5d88
Add SearchBoxControl user control
KaiyuWang16 Nov 1, 2019
1cdd414
do not add SearchBox to TermControl for now
KaiyuWang16 Nov 1, 2019
14586d8
First prototype of Search Experience
KaiyuWang16 Nov 6, 2019
9007f87
Add calculation to correctly locate searched text on the visible view
KaiyuWang16 Nov 6, 2019
f2189c2
Search Capabilities - Add search box and search method
KaiyuWang16 Nov 9, 2019
767ff10
Reduce search and wrap-up time
KaiyuWang16 Nov 12, 2019
eb48d74
Add key bindings and close handler
KaiyuWang16 Nov 13, 2019
821bbef
Enable searchBox alignment change
KaiyuWang16 Nov 14, 2019
9b74089
Use stackpanel to replace grid
KaiyuWang16 Nov 14, 2019
478405e
Fix typos and format issues
KaiyuWang16 Nov 15, 2019
f441add
Merge branch 'master' into dev/kawa/605-Search-Experice-Implementatio…
KaiyuWang16 Nov 15, 2019
a161352
comment out unused parameters in event handlers
KaiyuWang16 Nov 15, 2019
7ef6cc9
Accessibility - tab navigation
KaiyuWang16 Nov 21, 2019
5d8dc4c
Code review changes
KaiyuWang16 Nov 21, 2019
c95ec72
Improve search algorithm, use togggle button
KaiyuWang16 Nov 22, 2019
ce84004
PR code review changes
KaiyuWang16 Nov 23, 2019
7b64cf2
format fix
KaiyuWang16 Nov 23, 2019
200725d
Merge branch 'master' into dev/kawa/605-Search-Experice-Implementatio…
KaiyuWang16 Nov 26, 2019
cc20901
Change Automation properties name
KaiyuWang16 Nov 26, 2019
f8fec6f
Change FontIcon ThemeSource to use text color
KaiyuWang16 Nov 26, 2019
11b82b0
Add new experience for move and search direction button
KaiyuWang16 Nov 27, 2019
d457331
code review feedbacks
KaiyuWang16 Nov 28, 2019
4dae340
Merge branch 'master' into dev/kawa/605-Search-Experice-Implementatio…
KaiyuWang16 Dec 2, 2019
94ac16e
Fix build errors after syncing
KaiyuWang16 Dec 2, 2019
40d9596
add empty text check and recover project file
KaiyuWang16 Dec 2, 2019
ae65f82
remove tabs and add more comments
KaiyuWang16 Dec 3, 2019
6d0b57a
new UI experience
KaiyuWang16 Dec 5, 2019
b853c1d
Change keybinding name
KaiyuWang16 Dec 5, 2019
a0fbe2f
Round corner and new FontIcon for case match
KaiyuWang16 Dec 6, 2019
a033037
Use PathIcon and remove placeholder text when focused
KaiyuWang16 Dec 7, 2019
64c6d55
Merge branch 'master' into dev/kawa/605-Search-Experice-Implementatio…
KaiyuWang16 Dec 7, 2019
702d295
code review chanegs
KaiyuWang16 Dec 9, 2019
1b847ee
Merge branch 'master' into dev/kawa/605-Search-Experice-Implementatio…
KaiyuWang16 Dec 9, 2019
2dd88a7
recover SettingSchema file
KaiyuWang16 Dec 9, 2019
cdded13
fix bugs and CR changes
KaiyuWang16 Dec 10, 2019
8f7f9a3
fix build errors
KaiyuWang16 Dec 10, 2019
0c65122
use _selectionVerticalOffset to replace ViewStartIndex
KaiyuWang16 Dec 11, 2019
20d3452
Support single letter search and add tooltips
KaiyuWang16 Dec 11, 2019
1e06c52
Merge branch 'master' into dev/kawa/605-Search-Experice-Implementatio…
KaiyuWang16 Dec 11, 2019
31e47fb
Fix a build error
KaiyuWang16 Dec 11, 2019
43f3d6b
Code review changes
KaiyuWang16 Dec 12, 2019
8f36e97
fix format
KaiyuWang16 Dec 12, 2019
8bf675a
fix GetTextBufferEndPosition and some CR feedbacks
KaiyuWang16 Dec 12, 2019
5b95b01
Use fix color on TextBox placeholder color to avoid XAML bug
KaiyuWang16 Dec 13, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/cascadia/SettingsSchema.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ Commands listed below are per the implementation in [`src/cascadia/TerminalApp/A
- moveFocusRight
- moveFocusUp
- moveFocusDown
- toggleFullscreen
- toggleFullscreen
- find

## Example Keys
- ctrl+1
Expand Down
34 changes: 27 additions & 7 deletions src/buffer/out/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,7 @@ bool Search::FindNext()
// - Takes the found word and selects it in the screen buffer
void Search::Select() const
{
// Only select if we've found something.
if (_coordSelStart != _coordSelEnd)
{
_uiaData.SelectNewRegion(_coordSelStart, _coordSelEnd);
}
_uiaData.SelectNewRegion(_coordSelStart, _coordSelEnd);
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved
}

// Routine Description:
Expand Down Expand Up @@ -142,6 +138,7 @@ std::pair<COORD, COORD> Search::GetFoundLocation() const noexcept
COORD Search::s_GetInitialAnchor(IUiaData& uiaData, const Direction direction)
{
const auto& textBuffer = uiaData.GetTextBuffer();
const COORD textBufferEndPosition = uiaData.GetTextBufferEndPosition();
if (uiaData.IsSelectionActive())
{
auto anchor = uiaData.GetSelectionAnchor();
Expand All @@ -152,6 +149,10 @@ COORD Search::s_GetInitialAnchor(IUiaData& uiaData, const Direction direction)
else
{
textBuffer.GetSize().DecrementInBoundsCircular(anchor);
// If the selection starts at (0, 0), we need to make sure
// it does not exceed the text buffer end position
anchor.X = std::min(textBufferEndPosition.X, anchor.X);
anchor.Y = std::min(textBufferEndPosition.Y, anchor.Y);
}
return anchor;
}
Expand All @@ -163,8 +164,7 @@ COORD Search::s_GetInitialAnchor(IUiaData& uiaData, const Direction direction)
}
else
{
const auto bufferSize = textBuffer.GetSize().Dimensions();
return { bufferSize.X - 1, bufferSize.Y - 1 };
return textBufferEndPosition;
}
}
}
Expand Down Expand Up @@ -293,6 +293,26 @@ void Search::_UpdateNextPosition()
{
THROW_HR(E_NOTIMPL);
}

// To reduce wrap-around time, if the next position is larger than
// the end position of the written text
// We put the next position to:
// Forward: (0, 0)
// Backward: the position of the end of the text buffer
const COORD bufferEndPosition = _uiaData.GetTextBufferEndPosition();

if (_coordNext.Y > bufferEndPosition.Y ||
(_coordNext.Y == bufferEndPosition.Y && _coordNext.X > bufferEndPosition.X))
{
if (_direction == Direction::Forward)
{
_coordNext = { 0 };
}
else
{
_coordNext = bufferEndPosition;
}
}
}

// Routine Description:
Expand Down
2 changes: 1 addition & 1 deletion src/buffer/out/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Search final

private:
wchar_t _ApplySensitivity(const wchar_t wch) const noexcept;
bool Search::_FindNeedleInHaystackAt(const COORD pos, COORD& start, COORD& end) const;
bool _FindNeedleInHaystackAt(const COORD pos, COORD& start, COORD& end) const;
bool _CompareChars(const std::wstring_view one, const std::wstring_view two) const noexcept;
void _UpdateNextPosition();

Expand Down
8 changes: 7 additions & 1 deletion src/cascadia/TerminalApp/AppActionHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ namespace winrt::TerminalApp::implementation
}
}

void TerminalPage::_HandleFind(const IInspectable& /*sender*/,
const TerminalApp::ActionEventArgs& args)
{
_Find();
args.Handled(true);
}

void TerminalPage::_HandleResetFontSize(const IInspectable& /*sender*/,
const TerminalApp::ActionEventArgs& args)
{
Expand All @@ -228,5 +235,4 @@ namespace winrt::TerminalApp::implementation
_ToggleFullscreen();
args.Handled(true);
}

}
2 changes: 2 additions & 0 deletions src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ static constexpr std::string_view MoveFocusLeftKey{ "moveFocusLeft" }; // Legacy
static constexpr std::string_view MoveFocusRightKey{ "moveFocusRight" }; // Legacy
static constexpr std::string_view MoveFocusUpKey{ "moveFocusUp" }; // Legacy
static constexpr std::string_view MoveFocusDownKey{ "moveFocusDown" }; // Legacy
static constexpr std::string_view FindKey{ "find" };
static constexpr std::string_view ToggleFullscreenKey{ "toggleFullscreen" };

// Specifically use a map here over an unordered_map. We want to be able to
Expand Down Expand Up @@ -142,6 +143,7 @@ static const std::map<std::string_view, ShortcutAction, std::less<>> commandName
{ ToggleFullscreenKey, ShortcutAction::ToggleFullscreen },
{ SplitPaneKey, ShortcutAction::SplitPane },
{ UnboundKey, ShortcutAction::Invalid },
{ FindKey, ShortcutAction::Find },
};

// Function Description:
Expand Down
5 changes: 5 additions & 0 deletions src/cascadia/TerminalApp/ShortcutActionDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ namespace winrt::TerminalApp::implementation
_AdjustFontSizeHandlers(*this, *eventArgs);
break;
}
case ShortcutAction::Find:
{
_FindHandlers(*this, *eventArgs);
break;
}
case ShortcutAction::ResetFontSize:
{
_ResetFontSizeHandlers(*this, *eventArgs);
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/ShortcutActionDispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace winrt::TerminalApp::implementation
TYPED_EVENT(ScrollDownPage, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs);
TYPED_EVENT(OpenSettings, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs);
TYPED_EVENT(ResizePane, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs);
TYPED_EVENT(Find, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs);
TYPED_EVENT(MoveFocus, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs);
TYPED_EVENT(ToggleFullscreen, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs);
// clang-format on
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalApp/ShortcutActionDispatch.idl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ namespace TerminalApp
MoveFocusRight, // Legacy
MoveFocusUp, // Legacy
MoveFocusDown, // Legacy
Find,
ToggleFullscreen,
OpenSettings
};
Expand Down Expand Up @@ -97,6 +98,7 @@ namespace TerminalApp
event Windows.Foundation.TypedEventHandler<ShortcutActionDispatch, ActionEventArgs> ScrollDownPage;
event Windows.Foundation.TypedEventHandler<ShortcutActionDispatch, ActionEventArgs> OpenSettings;
event Windows.Foundation.TypedEventHandler<ShortcutActionDispatch, ActionEventArgs> ResizePane;
event Windows.Foundation.TypedEventHandler<ShortcutActionDispatch, ActionEventArgs> Find;
event Windows.Foundation.TypedEventHandler<ShortcutActionDispatch, ActionEventArgs> MoveFocus;
event Windows.Foundation.TypedEventHandler<ShortcutActionDispatch, ActionEventArgs> ToggleFullscreen;
}
Expand Down
16 changes: 15 additions & 1 deletion src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ namespace winrt::TerminalApp::implementation
// Hook up the ShortcutActionDispatch object's events to our handlers.
// They should all be hooked up here, regardless of whether or not
// there's an actual keychord for them.

_actionDispatch->OpenNewTabDropdown({ this, &TerminalPage::_HandleOpenNewTabDropdown });
_actionDispatch->DuplicateTab({ this, &TerminalPage::_HandleDuplicateTab });
_actionDispatch->CloseTab({ this, &TerminalPage::_HandleCloseTab });
Expand All @@ -651,6 +650,7 @@ namespace winrt::TerminalApp::implementation
_actionDispatch->MoveFocus({ this, &TerminalPage::_HandleMoveFocus });
_actionDispatch->CopyText({ this, &TerminalPage::_HandleCopyText });
_actionDispatch->AdjustFontSize({ this, &TerminalPage::_HandleAdjustFontSize });
_actionDispatch->Find({ this, &TerminalPage::_HandleFind });
_actionDispatch->ResetFontSize({ this, &TerminalPage::_HandleResetFontSize });
_actionDispatch->ToggleFullscreen({ this, &TerminalPage::_HandleToggleFullscreen });
}
Expand Down Expand Up @@ -1417,6 +1417,20 @@ namespace winrt::TerminalApp::implementation
}
}

// Method Description:
// - Called when the user tries to do a search using keybindings.
// This will tell the current focused terminal control to create
// a search box and enable find process.
// Arguments:
// - <none>
// Return Value:
// - <none>
void TerminalPage::_Find()
{
const auto termControl = _GetActiveControl();
termControl.CreateSearchBoxControl();
}

// Method Description:
// - Toggles fullscreen mode. Hides the tab row, and raises our
// ToggleFullscreen event.
Expand Down
3 changes: 3 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ namespace winrt::TerminalApp::implementation
void _OnContentSizeChanged(const IInspectable& /*sender*/, Windows::UI::Xaml::SizeChangedEventArgs const& e);
void _OnTabCloseRequested(const IInspectable& sender, const Microsoft::UI::Xaml::Controls::TabViewTabCloseRequestedEventArgs& eventArgs);

void _Find();

void _RefreshUIForSettingsReload();

void _ToggleFullscreen();
Expand All @@ -148,6 +150,7 @@ namespace winrt::TerminalApp::implementation
void _HandleCopyText(const IInspectable& sender, const TerminalApp::ActionEventArgs& args);
void _HandleCloseWindow(const IInspectable&, const TerminalApp::ActionEventArgs& args);
void _HandleAdjustFontSize(const IInspectable& sender, const TerminalApp::ActionEventArgs& args);
void _HandleFind(const IInspectable& sender, const TerminalApp::ActionEventArgs& args);
void _HandleResetFontSize(const IInspectable& sender, const TerminalApp::ActionEventArgs& args);
void _HandleToggleFullscreen(const IInspectable& sender, const TerminalApp::ActionEventArgs& args);
#pragma endregion
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
{ "command": { "action": "switchToTab", "index": 6 }, "keys": ["ctrl+alt+7"] },
{ "command": { "action": "switchToTab", "index": 7 }, "keys": ["ctrl+alt+8"] },
{ "command": { "action": "switchToTab", "index": 8 }, "keys": ["ctrl+alt+9"] },
{ "command": "find", "keys": [ "ctrl+shift+f" ] },
{ "command": "toggleFullscreen", "keys": [ "alt+enter" ] },
{ "command": "toggleFullscreen", "keys": [ "f11" ] }
]
Expand Down
Loading