Skip to content

Commit

Permalink
Merge branch 'main' into feature-paging
Browse files Browse the repository at this point in the history
  • Loading branch information
j4james committed May 8, 2024
2 parents 2488e9a + 6d0342f commit 7795bab
Show file tree
Hide file tree
Showing 42 changed files with 629 additions and 883 deletions.
6 changes: 3 additions & 3 deletions build/pipelines/daily-loc-submission.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ steps:
git config --local core.autocrlf true
displayName: Prepare git submission environment

- task: MicrosoftTDBuild.tdbuild-task.tdbuild-task.TouchdownBuildTask@1
- task: MicrosoftTDBuild.tdbuild-task.tdbuild-task.TouchdownBuildTask@3
displayName: 'Touchdown Build - 7105, PRODEXT'
inputs:
teamId: 7105
authId: '$(TouchdownApplicationID)'
authKey: '$(TouchdownApplicationKey)'
TDBuildServiceConnection: $(TouchdownServiceConnection)
authType: SubjectNameIssuer
resourceFilePath: |
**\en-US\*.resw
Terminal.Internal\PDPs\Stable\PDPs\en-us\PDP.xml
Expand Down
2 changes: 1 addition & 1 deletion custom.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<XesUseOneStoreVersioning>true</XesUseOneStoreVersioning>
<XesBaseYearForStoreVersion>2024</XesBaseYearForStoreVersion>
<VersionMajor>1</VersionMajor>
<VersionMinor>21</VersionMinor>
<VersionMinor>22</VersionMinor>
<VersionInfoProductName>Windows Terminal</VersionInfoProductName>
</PropertyGroup>
</Project>
46 changes: 43 additions & 3 deletions doc/cascadia/profiles.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1501,8 +1501,10 @@
"const": "multipleActions"
},
"actions": {
"$ref": "#/$defs/ShortcutAction",
"type": "array",
"items": {
"$ref": "#/$defs/ShortcutAction"
},
"minItems": 1,
"description": "A list of other actions."
}
Expand Down Expand Up @@ -1891,6 +1893,14 @@
],
"type": "string"
},
"IconStyle": {
"enum": [
"default",
"hidden",
"monochrome"
],
"type": "string"
},
"ThemeColor": {
"description": "A special kind of color for use in themes. Can be an #rrggbb color, #rrggbbaa color, or a special value. 'accent' is evaluated as the user's selected Accent color in the OS, and 'terminalBackground' will be evaluated as the background color of the active terminal pane.",
"oneOf": [
Expand Down Expand Up @@ -1928,6 +1938,10 @@
"showCloseButton": {
"description": "Controls the visibility of the close button on the tab",
"$ref": "#/$defs/ShowCloseButton"
},
"iconStyle": {
"description": "Controls the appearance of a tab's icon",
"$ref": "#/$defs/IconStyle"
}
}
},
Expand Down Expand Up @@ -2065,6 +2079,9 @@
{
"$ref": "#/$defs/SwitchToTabAction"
},
{
"$ref": "#/$defs/ScrollToMarkAction"
},
{
"$ref": "#/$defs/MoveFocusAction"
},
Expand Down Expand Up @@ -2215,7 +2232,15 @@
"commands": {
"description": "List of commands to execute",
"items": {
"$ref": "#/$defs/Keybinding/properties/command"
"type": "object",
"properties": {
"command": {
"$ref": "#/$defs/Keybinding/properties/command"
},
"name": {
"$ref": "#/$defs/Keybinding/properties/name"
}
}
},
"minItems": 1,
"type": "array"
Expand Down Expand Up @@ -2776,20 +2801,35 @@
"type": "string"
}
},
"experimental.autoMarkPrompts": {
"autoMarkPrompts": {
"default": false,
"description": "When set to true, prompts will automatically be marked.",
"type": "boolean"
},
"experimental.autoMarkPrompts": {
"deprecated": true,
"description": "This has been replaced by autoMarkPrompts in 1.21",
"type": "boolean"
},
"experimental.retroTerminalEffect": {
"description": "When set to true, enable retro terminal effects. This is an experimental feature, and its continued existence is not guaranteed.",
"type": "boolean"
},
"experimental.showMarksOnScrollbar": {
"deprecated": true,
"description": "This has been replaced by showMarksOnScrollbar in 1.21",
"type": "boolean"
},
"showMarksOnScrollbar": {
"default": false,
"description": "When set to true, marks added to the buffer via the addMark action will appear on the scrollbar.",
"type": "boolean"
},
"experimental.rightClickContextMenu": {
"default": false,
"description": "When set to true, right-clicking on the terminal will show a context menu. When set to false, right-click will copy",
"type": "boolean"
},
"experimental.repositionCursorWithMouse": {
"default": false,
"description": "When set to true, you can move the text cursor by clicking with the mouse on the current commandline. This is an experimental feature - there are lots of edge cases where this will not work as expected.",
Expand Down
74 changes: 56 additions & 18 deletions src/buffer/out/textBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1176,36 +1176,40 @@ void TextBuffer::Reset() noexcept
_initialAttributes = _currentAttributes;
}

void TextBuffer::ClearScrollback(const til::CoordType start, const til::CoordType height)
// Arguments:
// - newFirstRow: The current y-position of the viewport. We'll clear up until here.
// - rowsToKeep: the number of rows to keep in the buffer.
void TextBuffer::ClearScrollback(const til::CoordType newFirstRow, const til::CoordType rowsToKeep)
{
if (start <= 0)
// We're already at the top? don't clear anything. There's no scrollback.
if (newFirstRow <= 0)
{
return;
}

if (height <= 0)
// The new viewport should keep 0 rows? Then just reset everything.
if (rowsToKeep <= 0)
{
_decommit();
return;
}

ClearMarksInRange(til::point{ 0, 0 }, til::point{ _width, std::max(0, newFirstRow - 1) });

// Our goal is to move the viewport to the absolute start of the underlying memory buffer so that we can
// MEM_DECOMMIT the remaining memory. _firstRow is used to make the TextBuffer behave like a circular buffer.
// The start parameter is relative to the _firstRow. The trick to get the content to the absolute start
// The newFirstRow parameter is relative to the _firstRow. The trick to get the content to the absolute start
// is to simply add _firstRow ourselves and then reset it to 0. This causes ScrollRows() to write into
// the absolute start while reading from relative coordinates. This works because GetRowByOffset()
// operates modulo the buffer height and so the possibly-too-large startAbsolute won't be an issue.
const auto startAbsolute = _firstRow + start;
const auto startAbsolute = _firstRow + newFirstRow;
_firstRow = 0;
ScrollRows(startAbsolute, height, -startAbsolute);
ScrollRows(startAbsolute, rowsToKeep, -startAbsolute);

const auto end = _estimateOffsetOfLastCommittedRow();
for (auto y = height; y <= end; ++y)
for (auto y = rowsToKeep; y <= end; ++y)
{
GetMutableRowByOffset(y).Reset(_initialAttributes);
}

ClearMarksInRange(til::point{ 0, height }, til::point{ _width, _height });
}

// Routine Description:
Expand Down Expand Up @@ -2559,6 +2563,7 @@ void TextBuffer::Serialize(const wchar_t* destination) const
TextColor previousBg;
TextColor previousUl;
uint16_t previousHyperlinkId = 0;
bool delayedLineBreak = false;

// This iterates through each row. The exit condition is at the end
// of the for() loop so that we can properly handle file flushing.
Expand All @@ -2578,9 +2583,11 @@ void TextBuffer::Serialize(const wchar_t* destination) const
}

const auto& runs = row.Attributes().runs();
auto it = runs.begin();
const auto beg = runs.begin();
const auto end = runs.end();
auto it = beg;
const auto last = end - 1;
const auto lastCharX = row.MeasureRight();
til::CoordType oldX = 0;

for (; it != end; ++it)
Expand Down Expand Up @@ -2760,24 +2767,55 @@ void TextBuffer::Serialize(const wchar_t* destination) const
}
}

// Initially, the buffer is initialized with the default attributes, but once it begins to scroll,
// newly scrolled in rows are initialized with the current attributes. This means we need to set
// the current attributes to those of the upcoming row before the row comes up. Or inversely:
// We let the row come up, let it set its attributes and only then print the newline.
if (delayedLineBreak)
{
buffer.append(L"\r\n");
delayedLineBreak = false;
}

auto newX = oldX + it->length;
// Trim whitespace with default attributes from the end of each line.
if (it == last && it->value == TextAttribute{})

// Since our text buffer doesn't store the original input text, the information over the amount of trailing
// whitespaces was lost. If we don't do anything here then a row that just says "Hello" would be serialized
// to "Hello ...". If the user restores the buffer dump with a different window size,
// this would result in some fairly ugly reflow. This code attempts to at least trim trailing whitespaces.
//
// As mentioned above for `delayedLineBreak`, rows are initialized with their first attribute, BUT
// only if the viewport has begun to scroll. Otherwise, they're initialized with the default attributes.
// In other words, we can only skip \x1b[K = Erase in Line, if both the first/last attribute are the default attribute.
static constexpr TextAttribute defaultAttr;
const auto trimTrailingWhitespaces = it == last && lastCharX < newX;
const auto clearToEndOfLine = trimTrailingWhitespaces && beg->value != defaultAttr || beg->value != defaultAttr;

if (trimTrailingWhitespaces)
{
// This can result in oldX > newX, but that's okay because GetText()
// is robust against that and returns an empty string.
newX = row.MeasureRight();
newX = lastCharX;
}

buffer.append(row.GetText(oldX, newX));

if (clearToEndOfLine)
{
buffer.append(L"\x1b[K");
}

oldX = newX;
}

const auto moreRowsRemaining = currentRow < lastRowWithText;
delayedLineBreak = !row.WasWrapForced();

if (!row.WasWrapForced() || !moreRowsRemaining)
if (!moreRowsRemaining)
{
buffer.append(L"\r\n");
if (previousHyperlinkId)
{
buffer.append(L"\x1b]8;;\x1b\\");
}
buffer.append(L"\x1b[m\r\n");
}

if (buffer.size() >= writeThreshold || !moreRowsRemaining)
Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/TerminalControl/ControlCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
std::chrono::milliseconds{ 100 },
[weakTerminal = std::weak_ptr{ _terminal }, weakThis = get_weak(), dispatcher = _dispatcher]() {
dispatcher.TryEnqueue(DispatcherQueuePriority::Normal, [weakThis]() {
if (const auto self = weakThis.get(); !self->_IsClosing())
if (const auto self = weakThis.get(); self && !self->_IsClosing())
{
self->OutputIdle.raise(*self, nullptr);
}
Expand All @@ -179,7 +179,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_dispatcher,
std::chrono::milliseconds{ 8 },
[weakThis = get_weak()](const auto& update) {
if (auto core{ weakThis.get() }; !core->_IsClosing())
if (auto core{ weakThis.get() }; core && !core->_IsClosing())
{
core->ScrollPositionChanged.raise(*core, update);
}
Expand Down
14 changes: 8 additions & 6 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
dispatcher,
TerminalWarningBellInterval,
[weakThis = get_weak()]() {
if (auto control{ weakThis.get() }; !control->_IsClosing())
if (auto control{ weakThis.get() }; control && !control->_IsClosing())
{
control->WarningBell.raise(*control, nullptr);
}
Expand All @@ -258,7 +258,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
dispatcher,
ScrollBarUpdateInterval,
[weakThis = get_weak()](const auto& update) {
if (auto control{ weakThis.get() }; !control->_IsClosing())
if (auto control{ weakThis.get() }; control && !control->_IsClosing())
{
control->_throttledUpdateScrollbar(update);
}
Expand Down Expand Up @@ -301,7 +301,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_originalSelectedSecondaryElements.Append(e);
}
ContextMenu().Closed([weakThis = get_weak()](auto&&, auto&&) {
if (auto control{ weakThis.get() }; !control->_IsClosing())
if (auto control{ weakThis.get() }; control && !control->_IsClosing())
{
const auto& menu{ control->ContextMenu() };
menu.PrimaryCommands().Clear();
Expand All @@ -317,7 +317,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
});
SelectionContextMenu().Closed([weakThis = get_weak()](auto&&, auto&&) {
if (auto control{ weakThis.get() }; !control->_IsClosing())
if (auto control{ weakThis.get() }; control && !control->_IsClosing())
{
const auto& menu{ control->SelectionContextMenu() };
menu.PrimaryCommands().Clear();
Expand Down Expand Up @@ -544,7 +544,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}

_searchBox->Open([weakThis = get_weak()]() {
if (const auto self = weakThis.get(); !self->_IsClosing())
if (const auto self = weakThis.get(); self && !self->_IsClosing())
{
self->_searchBox->SetFocusOnTextbox();
self->_refreshSearch();
Expand Down Expand Up @@ -1120,7 +1120,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
co_return;
}

const auto hr = args.Result();
// HRESULT is a signed 32-bit integer which would result in a hex output like "-0x7766FFF4",
// but canonically HRESULTs are displayed unsigned as "0x8899000C". See GH#11556.
const auto hr = std::bit_cast<uint32_t>(args.Result());
const auto parameter = args.Parameter();
winrt::hstring message;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,16 @@
<value>Durchsuchen…</value>
<comment>Button label that opens a file picker in a new window. The "..." is standard to mean it will open a new window.</comment>
</data>
<data name="Profile_AddFontAxisButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Neue Schriftachse hinzufügen</value>
</data>
<data name="Profile_AddNewFontAxis.Text" xml:space="preserve">
<value>Neu hinzufügen</value>
<comment>Button label that adds a new font axis for the current font.</comment>
</data>
<data name="Profile_AddFontFeatureButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Neues Schriftmerkmal hinzufügen</value>
</data>
<data name="Profile_AddNewFontFeature.Text" xml:space="preserve">
<value>Neu hinzufügen</value>
<comment>Button label that adds a new font feature for the current font.</comment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,16 @@
<value>Examinar...</value>
<comment>Button label that opens a file picker in a new window. The "..." is standard to mean it will open a new window.</comment>
</data>
<data name="Profile_AddFontAxisButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Agregar nuevo eje de fuente</value>
</data>
<data name="Profile_AddNewFontAxis.Text" xml:space="preserve">
<value>Agregar nuevo</value>
<comment>Button label that adds a new font axis for the current font.</comment>
</data>
<data name="Profile_AddFontFeatureButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Agregar nueva característica de fuente</value>
</data>
<data name="Profile_AddNewFontFeature.Text" xml:space="preserve">
<value>Agregar nuevo</value>
<comment>Button label that adds a new font feature for the current font.</comment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,16 @@
<value>Parcourir...</value>
<comment>Button label that opens a file picker in a new window. The "..." is standard to mean it will open a new window.</comment>
</data>
<data name="Profile_AddFontAxisButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Ajouter un nouvel axe de police</value>
</data>
<data name="Profile_AddNewFontAxis.Text" xml:space="preserve">
<value>Ajouter nouveau</value>
<comment>Button label that adds a new font axis for the current font.</comment>
</data>
<data name="Profile_AddFontFeatureButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Ajouter une nouvelle fonctionnalité de police</value>
</data>
<data name="Profile_AddNewFontFeature.Text" xml:space="preserve">
<value>Ajouter nouveau</value>
<comment>Button label that adds a new font feature for the current font.</comment>
Expand Down
Loading

0 comments on commit 7795bab

Please sign in to comment.