scintilla: Update scintilla with changeset 3662:1d1c06df8a2f using gtk+3
[anjuta-extras.git] / plugins / scintilla / scintilla / CharClassify.cxx
blobc16af454761d3a4a6eacb3dced142a80d6a91736
1 // Scintilla source code edit control
2 /** @file CharClassify.cxx
3 ** Character classifications used by Document and RESearch.
4 **/
5 // Copyright 2006 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
8 #include <stdlib.h>
9 #include <ctype.h>
11 #include "CharClassify.h"
13 #ifdef SCI_NAMESPACE
14 using namespace Scintilla;
15 #endif
17 // Shut up annoying Visual C++ warnings:
18 #ifdef _MSC_VER
19 #pragma warning(disable: 4514)
20 #endif
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;
35 else
36 charClass[ch] = ccPunctuation;
40 void CharClassify::SetCharClasses(const unsigned char *chars, cc newCharClass) {
41 // Apply the newCharClass to the specifed chars
42 if (chars) {
43 while (*chars) {
44 charClass[*chars] = static_cast<unsigned char>(newCharClass);
45 chars++;