]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/stc/scintilla/src/CharClassify.cxx
acab4b2295522ff19d1e1f54c71a84c661c6df0e
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.
10 #include "CharClassify.h"
12 // Shut up annoying Visual C++ warnings:
14 #pragma warning(disable: 4514)
17 CharClassify::CharClassify() {
18 SetDefaultCharClasses(true);
21 void CharClassify::SetDefaultCharClasses(bool includeWordClass
) {
22 // Initialize all char classes to default values
23 for (int ch
= 0; ch
< 256; ch
++) {
24 if (ch
== '\r' || ch
== '\n')
25 charClass
[ch
] = ccNewLine
;
26 else if (ch
< 0x20 || ch
== ' ')
27 charClass
[ch
] = ccSpace
;
28 else if (includeWordClass
&& (ch
>= 0x80 || isalnum(ch
) || ch
== '_'))
29 charClass
[ch
] = ccWord
;
31 charClass
[ch
] = ccPunctuation
;
35 void CharClassify::SetCharClasses(const unsigned char *chars
, cc newCharClass
) {
36 // Apply the newCharClass to the specifed chars
39 charClass
[*chars
] = static_cast<unsigned char>(newCharClass
);