Skip to content

Commit b529557

Browse files
committed
A setting doesn't seem feasible
1 parent ac10486 commit b529557

File tree

11 files changed

+42
-41
lines changed

11 files changed

+42
-41
lines changed

doc/cascadia/profiles.schema.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,11 +2344,6 @@
23442344
"description": "Force the terminal to use the legacy input encoding. Certain keys in some applications may stop working when enabling this setting.",
23452345
"type": "boolean"
23462346
},
2347-
"experimental.graphemes": {
2348-
"default": true,
2349-
"description": "When set to true, the terminal will use grapheme cluster boundaries for cursor movement. Otherwise, the terminal will use codepoint boundaries.",
2350-
"type": "boolean"
2351-
},
23522347
"experimental.useBackgroundImageForWindow": {
23532348
"default": false,
23542349
"description": "When set to true, the background image for the currently focused profile is expanded to encompass the entire window, beneath other panes.",

src/cascadia/TerminalCore/ICoreSettings.idl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ namespace Microsoft.Terminal.Core
2020
String WordDelimiters;
2121

2222
Boolean ForceVTInput;
23-
Boolean Graphemes;
2423
Boolean TrimBlockSelection;
2524
Boolean DetectURLs;
2625
Boolean VtPassthrough;

src/cascadia/TerminalCore/Terminal.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
#include <til/hash.h>
1515
#include <winrt/Microsoft.Terminal.Core.h>
1616

17-
#include "../../types/inc/CodepointWidthDetector.hpp"
18-
1917
using namespace winrt::Microsoft::Terminal::Core;
2018
using namespace Microsoft::Terminal::Core;
2119
using namespace Microsoft::Console;
@@ -99,7 +97,6 @@ void Terminal::UpdateSettings(ICoreSettings settings)
9997
_autoMarkPrompts = settings.AutoMarkPrompts();
10098

10199
_getTerminalInput().ForceDisableWin32InputMode(settings.ForceVTInput());
102-
CodepointWidthDetector::Singleton().SetEnableGraphemes(settings.Graphemes());
103100

104101
if (settings.TabColor() == nullptr)
105102
{

src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ namespace Microsoft.Terminal.Settings.Model
8080
INHERITABLE_SETTING(Boolean, SoftwareRendering);
8181
INHERITABLE_SETTING(Boolean, UseBackgroundImageForWindow);
8282
INHERITABLE_SETTING(Boolean, ForceVTInput);
83-
INHERITABLE_SETTING(Boolean, Graphemes);
8483
INHERITABLE_SETTING(Boolean, DebugFeaturesEnabled);
8584
INHERITABLE_SETTING(Boolean, StartOnUserLogin);
8685
INHERITABLE_SETTING(Boolean, AlwaysOnTop);

src/cascadia/TerminalSettingsModel/MTSMSettings.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Author(s):
2828
X(bool, SoftwareRendering, "experimental.rendering.software", false) \
2929
X(bool, UseBackgroundImageForWindow, "experimental.useBackgroundImageForWindow", false) \
3030
X(bool, ForceVTInput, "experimental.input.forceVT", false) \
31-
X(bool, Graphemes, "experimental.graphemes", Feature_Graphemes::IsEnabled()) \
3231
X(bool, TrimBlockSelection, "trimBlockSelection", true) \
3332
X(bool, DetectURLs, "experimental.detectURLs", true) \
3433
X(bool, AlwaysShowTabs, "alwaysShowTabs", true) \

src/cascadia/TerminalSettingsModel/TerminalSettings.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
364364
_SoftwareRendering = globalSettings.SoftwareRendering();
365365
_UseBackgroundImageForWindow = globalSettings.UseBackgroundImageForWindow();
366366
_ForceVTInput = globalSettings.ForceVTInput();
367-
_Graphemes = globalSettings.Graphemes();
368367
_TrimBlockSelection = globalSettings.TrimBlockSelection();
369368
_DetectURLs = globalSettings.DetectURLs();
370369
_EnableUnfocusedAcrylic = globalSettings.EnableUnfocusedAcrylic();

src/cascadia/TerminalSettingsModel/TerminalSettings.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
159159
INHERITABLE_SETTING(Model::TerminalSettings, bool, SoftwareRendering, false);
160160
INHERITABLE_SETTING(Model::TerminalSettings, bool, UseBackgroundImageForWindow, false);
161161
INHERITABLE_SETTING(Model::TerminalSettings, bool, ForceVTInput, false);
162-
INHERITABLE_SETTING(Model::TerminalSettings, bool, Graphemes, false);
163162

164163
INHERITABLE_SETTING(Model::TerminalSettings, hstring, PixelShaderPath);
165164
INHERITABLE_SETTING(Model::TerminalSettings, hstring, PixelShaderImagePath);

src/cascadia/inc/ControlProperties.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
X(bool, TrimBlockSelection, true) \
4747
X(bool, SuppressApplicationTitle) \
4848
X(bool, ForceVTInput, false) \
49-
X(bool, Graphemes, false) \
5049
X(winrt::hstring, StartingTitle) \
5150
X(bool, DetectURLs, true) \
5251
X(bool, VtPassthrough, false) \

src/types/CodepointWidthDetector.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#include "precomp.h"
55
#include "inc/CodepointWidthDetector.hpp"
66

7+
// Due to the Feature_Graphemes::IsEnabled() feature flagging, some code may be disabled.
8+
#pragma warning(disable : 4702) // unreachable code
9+
710
// I was trying to minimize dependencies in this code so that it's easier to port to other terminal applications.
811
// Also, it has to be fast / have minimal overhead, since it potentially parses every single input character.
912
#pragma warning(disable : 26446) // Prefer to use gsl::at() instead of unchecked subscript operator (bounds.4).
@@ -946,25 +949,27 @@ CodepointWidthDetector& CodepointWidthDetector::Singleton() noexcept
946949
return s_codepointWidthDetector;
947950
}
948951

949-
CodepointWidthDetector::CodepointWidthDetector() noexcept :
950-
_enableGraphemes{ Feature_Graphemes::IsEnabled() }
951-
{
952-
}
953-
954952
size_t CodepointWidthDetector::GraphemeNext(const std::wstring_view& str, size_t offset, int* width) noexcept
955953
{
956-
if (!_enableGraphemes.load(std::memory_order_relaxed))
954+
if constexpr (!Feature_Graphemes::IsEnabled())
957955
{
958956
return _graphemeNextOld(str, offset, width);
959957
}
960958

959+
int widthIgnored;
960+
if (!width)
961+
{
962+
width = &widthIgnored;
963+
}
964+
961965
const auto beg = str.begin();
962966
const auto end = str.end();
963967
auto it = beg + std::min(offset, str.size());
964968

965969
if (it == end)
966970
{
967-
return 0;
971+
*width = 1;
972+
return offset;
968973
}
969974

970975
char32_t cp;
@@ -1000,26 +1005,30 @@ size_t CodepointWidthDetector::GraphemeNext(const std::wstring_view& str, size_t
10001005
lead = trail;
10011006
}
10021007

1003-
if (width)
1004-
{
1005-
*width = totalWidth < 1 ? 1 : (totalWidth > 2 ? 2 : totalWidth);
1006-
}
1008+
*width = totalWidth < 1 ? 1 : (totalWidth > 2 ? 2 : totalWidth);
10071009
return it - beg;
10081010
}
10091011

10101012
// This code is identical to GraphemeNext() but with the order of operations reversed since we're iterating backwards.
10111013
size_t CodepointWidthDetector::GraphemePrev(const std::wstring_view& str, size_t offset, int* width) noexcept
10121014
{
1013-
if (!_enableGraphemes.load(std::memory_order_relaxed))
1015+
if constexpr (!Feature_Graphemes::IsEnabled())
10141016
{
10151017
return _graphemePrevOld(str, offset, width);
10161018
}
10171019

1020+
int widthIgnored;
1021+
if (!width)
1022+
{
1023+
width = &widthIgnored;
1024+
}
1025+
10181026
const auto beg = str.begin();
10191027
auto it = beg + std::min(offset, str.size());
10201028

10211029
if (it == beg)
10221030
{
1031+
*width = 1;
10231032
return 0;
10241033
}
10251034

@@ -1056,10 +1065,7 @@ size_t CodepointWidthDetector::GraphemePrev(const std::wstring_view& str, size_t
10561065
trail = lead;
10571066
}
10581067

1059-
if (width)
1060-
{
1061-
*width = totalWidth < 1 ? 1 : (totalWidth > 2 ? 2 : totalWidth);
1062-
}
1068+
*width = totalWidth < 1 ? 1 : (totalWidth > 2 ? 2 : totalWidth);
10631069
return it - beg;
10641070
}
10651071

@@ -1164,11 +1170,6 @@ catch (...)
11641170
return 1;
11651171
}
11661172

1167-
void CodepointWidthDetector::SetEnableGraphemes(const bool enable) noexcept
1168-
{
1169-
_enableGraphemes.store(enable, std::memory_order_relaxed);
1170-
}
1171-
11721173
// Method Description:
11731174
// - Sets a function that should be used as the fallback mechanism for
11741175
// determining a particular glyph's width, should the glyph be an ambiguous

src/types/inc/CodepointWidthDetector.hpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,19 @@ struct CodepointWidthDetector
77
{
88
static CodepointWidthDetector& Singleton() noexcept;
99

10-
CodepointWidthDetector() noexcept;
11-
1210
size_t GraphemeNext(const std::wstring_view& str, size_t offset, int* width) noexcept;
1311
size_t GraphemePrev(const std::wstring_view& str, size_t offset, int* width) noexcept;
1412

15-
void SetEnableGraphemes(bool enable) noexcept;
1613
void SetFallbackMethod(std::function<bool(const std::wstring_view&)> pfnFallback) noexcept;
1714
void ClearFallbackCache() noexcept;
1815

1916
private:
2017
__declspec(noinline) int _checkFallbackViaCache(char32_t codepoint) noexcept;
2118

22-
__declspec(noinline) size_t _graphemeNextOld(const std::wstring_view& str, size_t offset, int* width) noexcept;
23-
__declspec(noinline) size_t _graphemePrevOld(const std::wstring_view& str, size_t offset, int* width) noexcept;
19+
size_t _graphemeNextOld(const std::wstring_view& str, size_t offset, int* width) noexcept;
20+
size_t _graphemePrevOld(const std::wstring_view& str, size_t offset, int* width) noexcept;
2421
int _getWidthOld(char32_t cp) noexcept;
2522

2623
std::unordered_map<char32_t, uint8_t> _fallbackCache;
2724
std::function<bool(const std::wstring_view&)> _pfnFallbackMethod;
28-
std::atomic<bool> _enableGraphemes;
2925
};

0 commit comments

Comments
 (0)