Skip to content

Commit a28864f

Browse files
committed
Merge remote-tracking branch 'origin/main' into dev/lhecker/8000-graphemes
2 parents 62b2cdb + 5b8e731 commit a28864f

File tree

16 files changed

+183
-65
lines changed

16 files changed

+183
-65
lines changed

src/cascadia/TerminalControl/TermControl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
333333
// (The window has a min. size that ensures that there's always a scrollbar thumb.)
334334
if (drawableRange < 0)
335335
{
336-
assert(false);
337336
return;
338337
}
339338

src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,18 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
302302
{
303303
return Feature_VtPassthroughMode::IsEnabled() && Feature_VtPassthroughModeSettingInUI::IsEnabled();
304304
}
305+
bool ProfileViewModel::ShowMarksAvailable() const noexcept
306+
{
307+
return Feature_ScrollbarMarks::IsEnabled();
308+
}
309+
bool ProfileViewModel::AutoMarkPromptsAvailable() const noexcept
310+
{
311+
return Feature_ScrollbarMarks::IsEnabled();
312+
}
313+
bool ProfileViewModel::RepositionCursorWithMouseAvailable() const noexcept
314+
{
315+
return Feature_ScrollbarMarks::IsEnabled();
316+
}
305317

306318
bool ProfileViewModel::UseParentProcessDirectory()
307319
{

src/cascadia/TerminalSettingsEditor/ProfileViewModel.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
8181
bool ShowUnfocusedAppearance();
8282
void CreateUnfocusedAppearance();
8383
void DeleteUnfocusedAppearance();
84+
8485
bool VtPassthroughAvailable() const noexcept;
86+
bool ShowMarksAvailable() const noexcept;
87+
bool AutoMarkPromptsAvailable() const noexcept;
88+
bool RepositionCursorWithMouseAvailable() const noexcept;
8589

8690
til::typed_event<Editor::ProfileViewModel, Editor::DeleteProfileEventArgs> DeleteProfileRequested;
8791

@@ -115,6 +119,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
115119
OBSERVABLE_PROJECTED_SETTING(_profile, Elevate);
116120
OBSERVABLE_PROJECTED_SETTING(_profile, VtPassthrough);
117121
OBSERVABLE_PROJECTED_SETTING(_profile, ReloadEnvironmentVariables);
122+
OBSERVABLE_PROJECTED_SETTING(_profile, RightClickContextMenu);
123+
OBSERVABLE_PROJECTED_SETTING(_profile, ShowMarks);
124+
OBSERVABLE_PROJECTED_SETTING(_profile, AutoMarkPrompts);
125+
OBSERVABLE_PROJECTED_SETTING(_profile, RepositionCursorWithMouse);
118126

119127
WINRT_PROPERTY(bool, IsBaseLayer, false);
120128
WINRT_PROPERTY(bool, FocusDeleteButton, false);

src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ namespace Microsoft.Terminal.Settings.Editor
7474
Boolean EditableUnfocusedAppearance { get; };
7575
Boolean ShowUnfocusedAppearance { get; };
7676
AppearanceViewModel UnfocusedAppearance { get; };
77+
7778
Boolean VtPassthroughAvailable { get; };
79+
Boolean ShowMarksAvailable { get; };
80+
Boolean AutoMarkPromptsAvailable { get; };
81+
Boolean RepositionCursorWithMouseAvailable { get; };
7882

7983
String EvaluatedIcon { get; };
8084

@@ -109,5 +113,9 @@ namespace Microsoft.Terminal.Settings.Editor
109113
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, Elevate);
110114
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, VtPassthrough);
111115
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, ReloadEnvironmentVariables);
116+
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, RightClickContextMenu);
117+
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, ShowMarks);
118+
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AutoMarkPrompts);
119+
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, RepositionCursorWithMouse);
112120
}
113121
}

src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,35 @@
127127
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
128128
</local:SettingContainer>
129129

130+
<!-- RightClickContextMenu -->
131+
<local:SettingContainer x:Uid="Profile_RightClickContextMenu"
132+
ClearSettingValue="{x:Bind Profile.ClearRightClickContextMenu}"
133+
HasSettingValue="{x:Bind Profile.HasRightClickContextMenu, Mode=OneWay}"
134+
SettingOverrideSource="{x:Bind Profile.RightClickContextMenuOverrideSource, Mode=OneWay}">
135+
<ToggleSwitch IsOn="{x:Bind Profile.RightClickContextMenu, Mode=TwoWay}"
136+
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
137+
</local:SettingContainer>
138+
139+
<!-- ShowMarks -->
140+
<local:SettingContainer x:Uid="Profile_ShowMarks"
141+
ClearSettingValue="{x:Bind Profile.ClearShowMarks}"
142+
HasSettingValue="{x:Bind Profile.HasShowMarks, Mode=OneWay}"
143+
SettingOverrideSource="{x:Bind Profile.ShowMarksOverrideSource, Mode=OneWay}"
144+
Visibility="{x:Bind Profile.ShowMarksAvailable}">
145+
<ToggleSwitch IsOn="{x:Bind Profile.ShowMarks, Mode=TwoWay}"
146+
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
147+
</local:SettingContainer>
148+
149+
<!-- AutoMarkPrompts -->
150+
<local:SettingContainer x:Uid="Profile_AutoMarkPrompts"
151+
ClearSettingValue="{x:Bind Profile.ClearAutoMarkPrompts}"
152+
HasSettingValue="{x:Bind Profile.HasAutoMarkPrompts, Mode=OneWay}"
153+
SettingOverrideSource="{x:Bind Profile.AutoMarkPromptsOverrideSource, Mode=OneWay}"
154+
Visibility="{x:Bind Profile.AutoMarkPromptsAvailable}">
155+
<ToggleSwitch IsOn="{x:Bind Profile.AutoMarkPrompts, Mode=TwoWay}"
156+
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
157+
</local:SettingContainer>
158+
130159
<!-- ReloadEnvVars -->
131160
<local:SettingContainer x:Uid="Profile_ReloadEnvVars"
132161
ClearSettingValue="{x:Bind Profile.ClearReloadEnvironmentVariables}"
@@ -135,6 +164,17 @@
135164
<ToggleSwitch IsOn="{x:Bind Profile.ReloadEnvironmentVariables, Mode=TwoWay}"
136165
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
137166
</local:SettingContainer>
167+
168+
<!-- RepositionCursorWithMouse -->
169+
<local:SettingContainer x:Uid="Profile_RepositionCursorWithMouse"
170+
ClearSettingValue="{x:Bind Profile.ClearRepositionCursorWithMouse}"
171+
HasSettingValue="{x:Bind Profile.HasRepositionCursorWithMouse, Mode=OneWay}"
172+
SettingOverrideSource="{x:Bind Profile.RepositionCursorWithMouseOverrideSource, Mode=OneWay}"
173+
Visibility="{x:Bind Profile.RepositionCursorWithMouseAvailable}">
174+
<ToggleSwitch IsOn="{x:Bind Profile.RepositionCursorWithMouse, Mode=TwoWay}"
175+
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
176+
</local:SettingContainer>
177+
138178
</StackPanel>
139179
</Grid>
140180
</Page>

src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,38 @@
12181218
<value>Enable experimental virtual terminal passthrough</value>
12191219
<comment>An option to enable experimental virtual terminal passthrough connectivity option with the underlying ConPTY</comment>
12201220
</data>
1221+
<data name="Profile_RightClickContextMenu.Header" xml:space="preserve">
1222+
<value>Display a menu on right-click</value>
1223+
<comment>This controls how a right-click behaves in the terminal</comment>
1224+
</data>
1225+
<data name="Profile_RightClickContextMenu.HelpText" xml:space="preserve">
1226+
<value>When enabled, the Terminal will display a menu on right-click. When disabled, right-clicking will copy the selected text (or paste if there's no selection).</value>
1227+
<comment>A description for what the "Display a menu on right-click" setting does. Presented near "Profile_RightClickContextMenu".</comment>
1228+
</data>
1229+
<data name="Profile_ShowMarks.Header" xml:space="preserve">
1230+
<value>Display marks on the scrollbar</value>
1231+
<comment>"Marks" are small visual indicators that can help the user identify the position of useful info in the scrollbar</comment>
1232+
</data>
1233+
<data name="Profile_ShowMarks.HelpText" xml:space="preserve">
1234+
<value>When enabled, the Terminal will display marks in the scrollbar when searching for text, or when shell integration is enabled.</value>
1235+
<comment>A description for what the "Display marks on the scrollbar" setting does. Presented near "Profile_ShowMarks".</comment>
1236+
</data>
1237+
<data name="Profile_AutoMarkPrompts.Header" xml:space="preserve">
1238+
<value>Automatically mark prompts on pressing Enter</value>
1239+
<comment>"Enter" is the enter/return key on the keyboard. This will add a mark indicating the position of a shell prompt when the user presses enter.</comment>
1240+
</data>
1241+
<data name="Profile_AutoMarkPrompts.HelpText" xml:space="preserve">
1242+
<value>When enabled, the Terminal automatically add a mark indicating the position of the end of the command when you press enter.</value>
1243+
<comment>A description for what the "Automatically mark prompts on pressing Enter" setting does. Presented near "Profile_AutoMarkPrompts".</comment>
1244+
</data>
1245+
<data name="Profile_RepositionCursorWithMouse.Header" xml:space="preserve">
1246+
<value>Experimental: Reposition the cursor with mouse clicks</value>
1247+
<comment>This allows the user to move the text cursor just by clicking with the mouse.</comment>
1248+
</data>
1249+
<data name="Profile_RepositionCursorWithMouse.HelpText" xml:space="preserve">
1250+
<value>When enabled, clicking inside the prompt will move the cursor to that position. This requires shell integration to be enabled in your shell to work as expected.</value>
1251+
<comment>A description for what the "Reload environment variables" setting does. Presented near "Profile_RepositionCursorWithMouse".</comment>
1252+
</data>
12211253
<data name="Profile_BellStyleAudible.Content" xml:space="preserve">
12221254
<value>Audible</value>
12231255
<comment>An option to choose from for the "bell style" setting. When selected, an audible cue is used to notify the user.</comment>

src/cascadia/TerminalSettingsModel/Command.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#include "Command.h"
66
#include "Command.g.cpp"
77

8-
#include "ActionAndArgs.h"
9-
#include "KeyChordSerialization.h"
108
#include <LibraryResources.h>
11-
#include "TerminalSettingsSerializationHelpers.h"
9+
#include <til/replace.h>
10+
11+
#include "KeyChordSerialization.h"
1212

1313
using namespace winrt::Microsoft::Terminal::Settings::Model;
1414
using namespace winrt::Windows::Foundation::Collections;
@@ -23,7 +23,6 @@ namespace winrt
2323
static constexpr std::string_view NameKey{ "name" };
2424
static constexpr std::string_view IconKey{ "icon" };
2525
static constexpr std::string_view ActionKey{ "command" };
26-
static constexpr std::string_view ArgsKey{ "args" };
2726
static constexpr std::string_view IterateOnKey{ "iterateOn" };
2827
static constexpr std::string_view CommandsKey{ "commands" };
2928
static constexpr std::string_view KeysKey{ "keys" };

src/cascadia/TerminalSettingsModel/KeyChordSerialization.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static KeyChord _fromString(std::wstring_view wstr)
129129
}
130130

131131
using nameToVkeyPair = std::pair<std::wstring_view, int32_t>;
132-
static constinit til::static_map nameToVkey{
132+
static constexpr til::static_map nameToVkey{
133133
// The above VKEY_NAME_PAIRS macro contains a list of key-binding names for each virtual key.
134134
// This god-awful macro inverts VKEY_NAME_PAIRS and creates a static map of key-binding names to virtual keys.
135135
// clang-format off
@@ -245,7 +245,7 @@ static KeyChord _fromString(std::wstring_view wstr)
245245
static std::wstring _toString(const KeyChord& chord)
246246
{
247247
using vkeyToNamePair = std::pair<int32_t, std::wstring_view>;
248-
static constinit til::static_map vkeyToName{
248+
static constexpr til::static_map vkeyToName{
249249
// The above VKEY_NAME_PAIRS macro contains a list of key-binding strings for each virtual key.
250250
// This macro picks the first (most preferred) name and creates a static map of virtual keys to key-binding names.
251251
#define GENERATOR(vkey, name1, ...) vkeyToNamePair{ vkey, name1 },

src/inc/til.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include "til/color.h"
2121
#include "til/enumset.h"
2222
#include "til/pmr.h"
23-
#include "til/replace.h"
2423
#include "til/string.h"
24+
#include "til/type_traits.h"
2525
#include "til/u8u16convert.h"
2626

2727
// Use keywords on TraceLogging providers to specify the category
@@ -54,6 +54,24 @@
5454

5555
namespace til // Terminal Implementation Library. Also: "Today I Learned"
5656
{
57+
template<typename T>
58+
as_view_t<T> clamp_slice_abs(const T& view, size_t beg, size_t end)
59+
{
60+
const auto len = view.size();
61+
end = std::min(end, len);
62+
beg = std::min(beg, end);
63+
return { view.data() + beg, end - beg };
64+
}
65+
66+
template<typename T>
67+
as_view_t<T> clamp_slice_len(const T& view, size_t start, size_t count)
68+
{
69+
const auto len = view.size();
70+
start = std::min(start, len);
71+
count = std::min(count, len - start);
72+
return { view.data() + start, count };
73+
}
74+
5775
template<typename T>
5876
void manage_vector(std::vector<T>& vector, typename std::vector<T>::size_type requestedSize, float shrinkThreshold)
5977
{

src/inc/til/bytes.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
#pragma once
55

6-
#include "type_traits.h"
7-
86
namespace til
97
{
108
template<ContiguousBytes Target>

0 commit comments

Comments
 (0)