Skip to content

Commit 4f86d4c

Browse files
committed
Implement the Kitty Keyboard Protocol
1 parent 27aae1f commit 4f86d4c

31 files changed

+1980
-682
lines changed

.github/actions/spelling/expect/expect.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ conterm
256256
contsf
257257
contypes
258258
conwinuserrefs
259-
coordnew
260259
COPYCOLOR
261260
COPYDATA
262261
COPYDATASTRUCT
@@ -622,7 +621,6 @@ fuzzmap
622621
fuzzwrapper
623622
fwdecl
624623
fwe
625-
fwlink
626624
fzf
627625
gci
628626
gcx
@@ -866,6 +864,7 @@ KILLACTIVE
866864
KILLFOCUS
867865
kinda
868866
KIYEOK
867+
KKP
869868
KLF
870869
KLMNO
871870
KOK
@@ -885,6 +884,7 @@ LBUTTONDOWN
885884
LBUTTONUP
886885
lcb
887886
lci
887+
LCMAP
888888
LCONTROL
889889
LCTRL
890890
lcx
@@ -1583,6 +1583,7 @@ SIZESCROLL
15831583
SKIPFONT
15841584
SKIPOWNPROCESS
15851585
SKIPOWNTHREAD
1586+
SKS
15861587
sku
15871588
sldl
15881589
SLGP

src/buffer/out/ut_textbuffer/ReflowTests.cpp

Lines changed: 2 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -600,96 +600,12 @@ namespace
600600
},
601601
},
602602
};
603-
604-
#pragma region TAEF hookup for the test case array above
605-
struct ArrayIndexTaefAdapterRow : public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom | Microsoft::WRL::InhibitFtmBase>, IDataRow>
606-
{
607-
HRESULT RuntimeClassInitialize(const size_t index)
608-
{
609-
_index = index;
610-
return S_OK;
611-
}
612-
613-
STDMETHODIMP GetTestData(BSTR /*pszName*/, SAFEARRAY** ppData) override
614-
{
615-
const auto indexString{ wil::str_printf<std::wstring>(L"%zu", _index) };
616-
auto safeArray{ SafeArrayCreateVector(VT_BSTR, 0, 1) };
617-
LONG index{ 0 };
618-
auto indexBstr{ wil::make_bstr(indexString.c_str()) };
619-
(void)SafeArrayPutElement(safeArray, &index, indexBstr.release());
620-
*ppData = safeArray;
621-
return S_OK;
622-
}
623-
624-
STDMETHODIMP GetMetadataNames(SAFEARRAY** ppMetadataNames) override
625-
{
626-
*ppMetadataNames = nullptr;
627-
return S_FALSE;
628-
}
629-
630-
STDMETHODIMP GetMetadata(BSTR /*pszName*/, SAFEARRAY** ppData) override
631-
{
632-
*ppData = nullptr;
633-
return S_FALSE;
634-
}
635-
636-
STDMETHODIMP GetName(BSTR* ppszRowName) override
637-
{
638-
*ppszRowName = nullptr;
639-
return S_FALSE;
640-
}
641-
642-
private:
643-
size_t _index;
644-
};
645-
646-
struct ArrayIndexTaefAdapterSource : public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom | Microsoft::WRL::InhibitFtmBase>, IDataSource>
647-
{
648-
STDMETHODIMP Advance(IDataRow** ppDataRow) override
649-
{
650-
if (_index < std::extent_v<decltype(testCases)>)
651-
{
652-
Microsoft::WRL::MakeAndInitialize<ArrayIndexTaefAdapterRow>(ppDataRow, _index++);
653-
}
654-
else
655-
{
656-
*ppDataRow = nullptr;
657-
}
658-
return S_OK;
659-
}
660-
661-
STDMETHODIMP Reset() override
662-
{
663-
_index = 0;
664-
return S_OK;
665-
}
666-
667-
STDMETHODIMP GetTestDataNames(SAFEARRAY** names) override
668-
{
669-
auto safeArray{ SafeArrayCreateVector(VT_BSTR, 0, 1) };
670-
LONG index{ 0 };
671-
auto dataNameBstr{ wil::make_bstr(L"index") };
672-
(void)SafeArrayPutElement(safeArray, &index, dataNameBstr.release());
673-
*names = safeArray;
674-
return S_OK;
675-
}
676-
677-
STDMETHODIMP GetTestDataType(BSTR /*name*/, BSTR* type) override
678-
{
679-
*type = nullptr;
680-
return S_OK;
681-
}
682-
683-
private:
684-
size_t _index{ 0 };
685-
};
686-
#pragma endregion
687603
}
688604

689605
extern "C" HRESULT __declspec(dllexport) __cdecl ReflowTestDataSource(IDataSource** ppDataSource, void*)
690606
{
691-
auto source{ Microsoft::WRL::Make<ArrayIndexTaefAdapterSource>() };
692-
return source.CopyTo(ppDataSource);
607+
*ppDataSource = new ArrayIndexTaefAdapterSource > (std::size(testCases));
608+
return S_OK;
693609
}
694610

695611
class ReflowTests

src/cascadia/TerminalCore/ICoreSettings.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ namespace Microsoft.Terminal.Core
121121
String WordDelimiters { get; };
122122

123123
Boolean ForceVTInput { get; };
124+
Boolean AllowKittyKeyboardMode { get; };
124125
Boolean AllowVtChecksumReport { get; };
125126
Boolean AllowVtClipboardWrite { get; };
126127
Boolean TrimBlockSelection { get; };

src/cascadia/TerminalCore/Terminal.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ void Terminal::UpdateSettings(ICoreSettings settings)
9898
}
9999

100100
_getTerminalInput().ForceDisableWin32InputMode(settings.ForceVTInput());
101+
_getTerminalInput().ForceDisableKittyKeyboardProtocol(!settings.AllowKittyKeyboardMode());
101102

102103
if (settings.TabColor() == nullptr)
103104
{

src/cascadia/TerminalSettingsAppAdapterLib/TerminalSettings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ namespace winrt::Microsoft::Terminal::Settings
349349
_ReloadEnvironmentVariables = profile.ReloadEnvironmentVariables();
350350
_RainbowSuggestions = profile.RainbowSuggestions();
351351
_ForceVTInput = profile.ForceVTInput();
352+
_AllowKittyKeyboardMode = profile.AllowKittyKeyboardMode();
352353
_AllowVtChecksumReport = profile.AllowVtChecksumReport();
353354
_AllowVtClipboardWrite = profile.AllowVtClipboardWrite();
354355
_PathTranslationStyle = profile.PathTranslationStyle();

src/cascadia/TerminalSettingsEditor/ProfileViewModel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
155155
OBSERVABLE_PROJECTED_SETTING(_profile, AutoMarkPrompts);
156156
OBSERVABLE_PROJECTED_SETTING(_profile, RepositionCursorWithMouse);
157157
OBSERVABLE_PROJECTED_SETTING(_profile, ForceVTInput);
158+
OBSERVABLE_PROJECTED_SETTING(_profile, AllowKittyKeyboardMode);
158159
OBSERVABLE_PROJECTED_SETTING(_profile, AllowVtChecksumReport);
159160
OBSERVABLE_PROJECTED_SETTING(_profile, AllowVtClipboardWrite);
160161
OBSERVABLE_PROJECTED_SETTING(_profile, AnswerbackMessage);

src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ namespace Microsoft.Terminal.Settings.Editor
140140
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AutoMarkPrompts);
141141
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, RepositionCursorWithMouse);
142142
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, ForceVTInput);
143+
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AllowKittyKeyboardMode);
143144
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AllowVtChecksumReport);
144145
OBSERVABLE_PROJECTED_PROFILE_SETTING(String, AnswerbackMessage);
145146
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, RainbowSuggestions);

src/cascadia/TerminalSettingsEditor/Profiles_Terminal.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@
4949
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
5050
</local:SettingContainer>
5151

52+
<!-- Kitty Keyboard Mode -->
53+
<local:SettingContainer x:Uid="Profile_AllowKittyKeyboardMode"
54+
ClearSettingValue="{x:Bind Profile.ClearAllowKittyKeyboardMode}"
55+
HasSettingValue="{x:Bind Profile.HasAllowKittyKeyboardMode, Mode=OneWay}"
56+
SettingOverrideSource="{x:Bind Profile.AllowKittyKeyboardModeOverrideSource, Mode=OneWay}">
57+
<ToggleSwitch IsOn="{x:Bind Profile.AllowKittyKeyboardMode, Mode=TwoWay}"
58+
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
59+
</local:SettingContainer>
60+
5261
<!-- Allow VT Checksum Report -->
5362
<local:SettingContainer x:Uid="Profile_AllowVtChecksumReport"
5463
ClearSettingValue="{x:Bind Profile.ClearAllowVtChecksumReport}"

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,10 @@
546546
<value>Use the legacy input encoding</value>
547547
<comment>Header for a control to toggle legacy input encoding for the terminal.</comment>
548548
</data>
549+
<data name="Profile_AllowKittyKeyboardMode.Header" xml:space="preserve">
550+
<value>Allow Kitty Keyboard Protocol</value>
551+
<comment>{Locked="Kitty"}Kitty is a moniker and its Keyboard Protocol is a protocol specification.</comment>
552+
</data>
549553
<data name="Profile_AllowVtChecksumReport.Header" xml:space="preserve">
550554
<value>Allow DECRQCRA (Request Checksum of Rectangular Area)</value>
551555
<comment>{Locked="DECRQCRA"}{Locked="Request Checksum of Rectangular Area"}Header for a control to toggle support for the DECRQCRA control sequence.</comment>
@@ -2583,19 +2587,19 @@
25832587
<comment>An option to choose from for the "path translation" setting.</comment>
25842588
</data>
25852589
<data name="Profile_PathTranslationStyleWsl.Content" xml:space="preserve">
2586-
<value>WSL (C:\ -> /mnt/c)</value>
2590+
<value>WSL (C:\ -&gt; /mnt/c)</value>
25872591
<comment>{Locked="WSL","C:\","/mnt/c"} An option to choose from for the "path translation" setting.</comment>
25882592
</data>
25892593
<data name="Profile_PathTranslationStyleCygwin.Content" xml:space="preserve">
2590-
<value>Cygwin (C:\ -> /cygdrive/c)</value>
2594+
<value>Cygwin (C:\ -&gt; /cygdrive/c)</value>
25912595
<comment>{Locked="Cygwin","C:\","/cygdrive/c"} An option to choose from for the "path translation" setting.</comment>
25922596
</data>
25932597
<data name="Profile_PathTranslationStyleMsys2.Content" xml:space="preserve">
2594-
<value>MSYS2 (C:\ -> /c)</value>
2598+
<value>MSYS2 (C:\ -&gt; /c)</value>
25952599
<comment>{Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting.</comment>
25962600
</data>
25972601
<data name="Profile_PathTranslationStyleMinGW.Content" xml:space="preserve">
2598-
<value>MinGW (C:\ -> C:/)</value>
2602+
<value>MinGW (C:\ -&gt; C:/)</value>
25992603
<comment>{Locked="MinGW","C:\","C:/"} An option to choose from for the "path translation" setting.</comment>
26002604
</data>
26012605
<data name="Profile_Delete_Orphaned.Header" xml:space="preserve">

src/cascadia/TerminalSettingsModel/IInheritable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private: \
136136
return std::nullopt; \
137137
} \
138138
\
139-
auto _get##name##OverrideSourceImpl()->decltype(get_strong()) \
139+
auto _get##name##OverrideSourceImpl() -> decltype(get_strong()) \
140140
{ \
141141
/*we have a value*/ \
142142
if (_##name) \
@@ -159,7 +159,7 @@ private: \
159159
} \
160160
\
161161
auto _get##name##OverrideSourceAndValueImpl() \
162-
->std::pair<decltype(get_strong()), storageType> \
162+
-> std::pair<decltype(get_strong()), storageType> \
163163
{ \
164164
/*we have a value*/ \
165165
if (_##name) \

0 commit comments

Comments
 (0)