From f796b484585600f7816e56470090303b8befbe3d Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Wed, 1 Apr 2020 17:03:49 -0700 Subject: [PATCH 1/3] rename/configure copy kb arg --- .../KeyBindingsTests.cpp | 18 +++++++++--------- src/cascadia/TerminalApp/ActionArgs.h | 10 +++++----- src/cascadia/TerminalApp/ActionArgs.idl | 2 +- src/cascadia/TerminalApp/AppActionHandlers.cpp | 2 +- src/cascadia/TerminalApp/TerminalPage.cpp | 7 +++---- src/cascadia/TerminalControl/TermControl.cpp | 6 +++--- .../TerminalCore/TerminalSelection.cpp | 8 ++++---- 7 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp b/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp index f5523f8f85d..7c16e90eee6 100644 --- a/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp +++ b/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp @@ -170,8 +170,8 @@ namespace TerminalAppLocalTests { const std::string bindings0String{ R"([ { "command": "copy", "keys": ["ctrl+c"] }, - { "command": { "action": "copy", "trimWhitespace": false }, "keys": ["ctrl+shift+c"] }, - { "command": { "action": "copy", "trimWhitespace": true }, "keys": ["alt+shift+c"] }, + { "command": { "action": "copy", "singleLine": false }, "keys": ["ctrl+shift+c"] }, + { "command": { "action": "copy", "singleLine": true }, "keys": ["alt+shift+c"] }, { "command": "newTab", "keys": ["ctrl+t"] }, { "command": { "action": "newTab", "index": 0 }, "keys": ["ctrl+shift+t"] }, @@ -195,13 +195,13 @@ namespace TerminalAppLocalTests { Log::Comment(NoThrowString().Format( - L"Verify that `copy` without args parses as Copy(TrimWhitespace=true)")); + L"Verify that `copy` without args parses as Copy(SingleLine=false)")); KeyChord kc{ true, false, false, static_cast('C') }; auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc); const auto& realArgs = actionAndArgs.Args().try_as(); VERIFY_IS_NOT_NULL(realArgs); // Verify the args have the expected value - VERIFY_IS_TRUE(realArgs.TrimWhitespace()); + VERIFY_IS_FALSE(realArgs.SingleLine()); } { @@ -212,7 +212,7 @@ namespace TerminalAppLocalTests const auto& realArgs = actionAndArgs.Args().try_as(); VERIFY_IS_NOT_NULL(realArgs); // Verify the args have the expected value - VERIFY_IS_FALSE(realArgs.TrimWhitespace()); + VERIFY_IS_FALSE(realArgs.SingleLine()); } { @@ -223,7 +223,7 @@ namespace TerminalAppLocalTests const auto& realArgs = actionAndArgs.Args().try_as(); VERIFY_IS_NOT_NULL(realArgs); // Verify the args have the expected value - VERIFY_IS_TRUE(realArgs.TrimWhitespace()); + VERIFY_IS_TRUE(realArgs.SingleLine()); } { @@ -275,7 +275,7 @@ namespace TerminalAppLocalTests const auto& realArgs = actionAndArgs.Args().try_as(); VERIFY_IS_NOT_NULL(realArgs); // Verify the args have the expected value - VERIFY_IS_TRUE(realArgs.TrimWhitespace()); + VERIFY_IS_FALSE(realArgs.SingleLine()); } { @@ -287,7 +287,7 @@ namespace TerminalAppLocalTests const auto& realArgs = actionAndArgs.Args().try_as(); VERIFY_IS_NOT_NULL(realArgs); // Verify the args have the expected value - VERIFY_IS_TRUE(realArgs.TrimWhitespace()); + VERIFY_IS_FALSE(realArgs.SingleLine()); } { @@ -420,7 +420,7 @@ namespace TerminalAppLocalTests const auto& realArgs = actionAndArgs.Args().try_as(); VERIFY_IS_NOT_NULL(realArgs); // Verify the args have the expected value - VERIFY_IS_TRUE(realArgs.TrimWhitespace()); + VERIFY_IS_FALSE(realArgs.SingleLine()); } } } diff --git a/src/cascadia/TerminalApp/ActionArgs.h b/src/cascadia/TerminalApp/ActionArgs.h index 2c0a4da85c5..9a733095a9f 100644 --- a/src/cascadia/TerminalApp/ActionArgs.h +++ b/src/cascadia/TerminalApp/ActionArgs.h @@ -93,9 +93,9 @@ namespace winrt::TerminalApp::implementation struct CopyTextArgs : public CopyTextArgsT { CopyTextArgs() = default; - GETSET_PROPERTY(bool, TrimWhitespace, true); + GETSET_PROPERTY(bool, SingleLine, false); - static constexpr std::string_view TrimWhitespaceKey{ "trimWhitespace" }; + static constexpr std::string_view SingleLineKey{ "singleLine" }; public: bool Equals(const IActionArgs& other) @@ -103,7 +103,7 @@ namespace winrt::TerminalApp::implementation auto otherAsUs = other.try_as(); if (otherAsUs) { - return otherAsUs->_TrimWhitespace == _TrimWhitespace; + return otherAsUs->_SingleLine == _SingleLine; } return false; }; @@ -111,9 +111,9 @@ namespace winrt::TerminalApp::implementation { // LOAD BEARING: Not using make_self here _will_ break you in the future! auto args = winrt::make_self(); - if (auto trimWhitespace{ json[JsonKey(TrimWhitespaceKey)] }) + if (auto singleLine{ json[JsonKey(SingleLineKey)] }) { - args->_TrimWhitespace = trimWhitespace.asBool(); + args->_SingleLine = singleLine.asBool(); } return { *args, {} }; } diff --git a/src/cascadia/TerminalApp/ActionArgs.idl b/src/cascadia/TerminalApp/ActionArgs.idl index 44984588f0a..96fa3abf587 100644 --- a/src/cascadia/TerminalApp/ActionArgs.idl +++ b/src/cascadia/TerminalApp/ActionArgs.idl @@ -56,7 +56,7 @@ namespace TerminalApp [default_interface] runtimeclass CopyTextArgs : IActionArgs { - Boolean TrimWhitespace { get; }; + Boolean SingleLine { get; }; }; [default_interface] runtimeclass NewTabArgs : IActionArgs diff --git a/src/cascadia/TerminalApp/AppActionHandlers.cpp b/src/cascadia/TerminalApp/AppActionHandlers.cpp index 2b288cb1000..d0e1c027f7f 100644 --- a/src/cascadia/TerminalApp/AppActionHandlers.cpp +++ b/src/cascadia/TerminalApp/AppActionHandlers.cpp @@ -198,7 +198,7 @@ namespace winrt::TerminalApp::implementation { if (const auto& realArgs = args.ActionArgs().try_as()) { - const auto handled = _CopyText(realArgs.TrimWhitespace()); + const auto handled = _CopyText(realArgs.SingleLine()); args.Handled(handled); } } diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index 9e96cee6e38..7ca074a3166 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -1376,14 +1376,13 @@ namespace winrt::TerminalApp::implementation // Method Description: // - Copy text from the focused terminal to the Windows Clipboard // Arguments: - // - trimTrailingWhitespace: enable removing any whitespace from copied selection - // and get text to appear on separate lines. + // - singleLine: if enabled, copy contents as a single line of text // Return Value: // - true iff we we able to copy text (if a selection was active) - bool TerminalPage::_CopyText(const bool trimTrailingWhitespace) + bool TerminalPage::_CopyText(const bool singleLine) { const auto control = _GetActiveControl(); - return control.CopySelectionToClipboard(!trimTrailingWhitespace); + return control.CopySelectionToClipboard(singleLine); } // Method Description: diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 9debfc28a2a..32612a63fa9 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -1887,8 +1887,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation // Windows Clipboard (CascadiaWin32:main.cpp). // - CopyOnSelect does NOT clear the selection // Arguments: - // - collapseText: collapse all of the text to one line - bool TermControl::CopySelectionToClipboard(bool collapseText) + // - singleLine: collapse all of the text to one line + bool TermControl::CopySelectionToClipboard(bool singleLine) { if (_closing) { @@ -1905,7 +1905,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation _selectionNeedsToBeCopied = false; // extract text from buffer - const auto bufferData = _terminal->RetrieveSelectedTextFromBuffer(collapseText); + const auto bufferData = _terminal->RetrieveSelectedTextFromBuffer(singleLine); // convert text: vector --> string std::wstring textData; diff --git a/src/cascadia/TerminalCore/TerminalSelection.cpp b/src/cascadia/TerminalCore/TerminalSelection.cpp index f8a13a56151..818a6f9440d 100644 --- a/src/cascadia/TerminalCore/TerminalSelection.cpp +++ b/src/cascadia/TerminalCore/TerminalSelection.cpp @@ -221,18 +221,18 @@ void Terminal::ClearSelection() // Method Description: // - get wstring text from highlighted portion of text buffer // Arguments: -// - collapseText: collapse all of the text to one line +// - singleLine: collapse all of the text to one line // Return Value: // - wstring text from buffer. If extended to multiple lines, each line is separated by \r\n -const TextBuffer::TextAndColor Terminal::RetrieveSelectedTextFromBuffer(bool collapseText) const +const TextBuffer::TextAndColor Terminal::RetrieveSelectedTextFromBuffer(bool singleLine) const { const auto selectionRects = _GetSelectionRects(); std::function GetForegroundColor = std::bind(&Terminal::GetForegroundColor, this, std::placeholders::_1); std::function GetBackgroundColor = std::bind(&Terminal::GetBackgroundColor, this, std::placeholders::_1); - return _buffer->GetText(!collapseText, - !collapseText, + return _buffer->GetText(!singleLine, + !singleLine, selectionRects, GetForegroundColor, GetBackgroundColor); From 4e5b45dbdb1c54278b009d8e4fad55e092218462 Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Wed, 1 Apr 2020 17:19:05 -0700 Subject: [PATCH 2/3] update docs and schema --- doc/cascadia/SettingsSchema.md | 2 +- doc/cascadia/profiles.schema.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/cascadia/SettingsSchema.md b/doc/cascadia/SettingsSchema.md index 47dca51a51a..5d4ce65d384 100644 --- a/doc/cascadia/SettingsSchema.md +++ b/doc/cascadia/SettingsSchema.md @@ -115,7 +115,7 @@ For commands with arguments: | `closePane` | Close the active pane. | | | | | `closeTab` | Close the current tab. | | | | | `closeWindow` | Close the current window and all tabs within it. | | | | -| `copy` | Copy the selected terminal content to your Windows Clipboard. | `trimWhitespace` | boolean | When `true`, newlines persist from the selected text. When `false`, copied content will paste on one line. | +| `copy` | Copy the selected terminal content to your Windows Clipboard. | `singleLine` | boolean | When `true`, the copied content will paste on one line. When `false`, newlines persist from the selected text. | | `duplicateTab` | Make a copy and open the current tab. | | | | | `find` | Open the search dialog box. | | | | | `moveFocus` | Focus on a different pane depending on direction. | `direction`* | `left`, `right`, `up`, `down` | Direction in which the focus will move. | diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index 0c30bdb410c..6b7f2927f3e 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -130,10 +130,10 @@ { "properties": { "action": { "type": "string", "pattern": "copy" }, - "trimWhitespace": { + "singleLine": { "type": "boolean", - "default": true, - "description": "If true, whitespace is removed and newlines are maintained. If false, newlines are removed and whitespace is maintained." + "default": false, + "description": "If true, newlines are removed and whitespace is maintained. If false, whitespace is removed and newlines are maintained." } } } From 7cb6009de53d3a3f8badbcfd650b65ff84b76f69 Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Thu, 2 Apr 2020 10:17:44 -0700 Subject: [PATCH 3/3] Make SettingsSchema.md sound better Co-Authored-By: Mike Griese --- doc/cascadia/SettingsSchema.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/cascadia/SettingsSchema.md b/doc/cascadia/SettingsSchema.md index 5d4ce65d384..ecb3d9857d8 100644 --- a/doc/cascadia/SettingsSchema.md +++ b/doc/cascadia/SettingsSchema.md @@ -115,7 +115,7 @@ For commands with arguments: | `closePane` | Close the active pane. | | | | | `closeTab` | Close the current tab. | | | | | `closeWindow` | Close the current window and all tabs within it. | | | | -| `copy` | Copy the selected terminal content to your Windows Clipboard. | `singleLine` | boolean | When `true`, the copied content will paste on one line. When `false`, newlines persist from the selected text. | +| `copy` | Copy the selected terminal content to your Windows Clipboard. | `singleLine` | boolean | When `true`, the copied content will be copied as a single line. When `false`, newlines persist from the selected text. | | `duplicateTab` | Make a copy and open the current tab. | | | | | `find` | Open the search dialog box. | | | | | `moveFocus` | Focus on a different pane depending on direction. | `direction`* | `left`, `right`, `up`, `down` | Direction in which the focus will move. |