1 // Scintilla source code edit control
2 /** @file CharClassify.cxx
3 ** Character classifications used by Document and RESearch.
5 // Copyright 2006 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
11 #include "CharClassify.h"
14 using namespace Scintilla
;
17 // Shut up annoying Visual C++ warnings:
19 #pragma warning(disable: 4514)
22 CharClassify::CharClassify() {
23 SetDefaultCharClasses(true);
26 void CharClassify::SetDefaultCharClasses(bool includeWordClass
) {
27 // Initialize all char classes to default values
28 for (int ch
= 0; ch
< 256; ch
++) {
29 if (ch
== '\r' || ch
== '\n')
30 charClass
[ch
] = ccNewLine
;
31 else if (ch
< 0x20 || ch
== ' ')
32 charClass
[ch
] = ccSpace
;
33 else if (includeWordClass
&& (ch
>= 0x80 || isalnum(ch
) || ch
== '_'))
34 charClass
[ch
] = ccWord
;
36 charClass
[ch
] = ccPunctuation
;
40 void CharClassify::SetCharClasses(const unsigned char *chars
, cc newCharClass
) {
41 // Apply the newCharClass to the specifed chars
44 charClass
[*chars
] = static_cast<unsigned char>(newCharClass
);