2
2
// Licensed under the MIT license.
3
3
4
4
#include " precomp.h"
5
-
6
5
#include " cmdline.h"
7
6
8
- #include " _output.h"
9
- #include " output.h"
10
- #include " stream.h"
11
- #include " _stream.h"
12
- #include " dbcs.h"
13
- #include " handle.h"
14
- #include " misc.h"
15
- #include " ../types/inc/convert.hpp"
16
- #include " srvinit.h"
17
-
18
- #include " ApiRoutines.h"
19
-
20
7
#include " ../interactivity/inc/ServiceLocator.hpp"
21
8
22
9
#pragma hdrstop
23
10
using Microsoft::Console::Interactivity::ServiceLocator;
24
11
25
12
// Routine Description:
26
13
// - Detects Word delimiters
27
- bool IsWordDelim (const wchar_t wch)
14
+ bool IsWordDelim (const wchar_t wch) noexcept
28
15
{
29
16
// the space character is always a word delimiter. Do not add it to the WordDelimiters global because
30
17
// that contains the user configurable word delimiters only.
@@ -33,14 +20,27 @@ bool IsWordDelim(const wchar_t wch)
33
20
return true ;
34
21
}
35
22
const auto & delimiters = ServiceLocator::LocateGlobals ().WordDelimiters ;
36
- if (delimiters.empty ())
37
- {
38
- return false ;
39
- }
40
23
return std::ranges::find (delimiters, wch) != delimiters.end ();
41
24
}
42
25
43
- bool IsWordDelim (const std::wstring_view charData)
26
+ bool IsWordDelim (const std::wstring_view& charData) noexcept
44
27
{
45
28
return charData.size () == 1 && IsWordDelim (charData.front ());
46
29
}
30
+
31
+ // Returns a truthy value for delimiters and 0 otherwise.
32
+ // The distinction between whitespace and other delimiters allows us to
33
+ // implement Windows' inconsistent, but classic, word-wise navigation.
34
+ int DelimiterClass (wchar_t wch) noexcept
35
+ {
36
+ if (wch == L' ' )
37
+ {
38
+ return 1 ;
39
+ }
40
+ const auto & delimiters = ServiceLocator::LocateGlobals ().WordDelimiters ;
41
+ if (std::find (delimiters.begin (), delimiters.end (), wch) != delimiters.end ())
42
+ {
43
+ return 2 ;
44
+ }
45
+ return 0 ;
46
+ }
0 commit comments