diff options
author | nyamatongwe <devnull@localhost> | 2006-02-25 02:43:03 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2006-02-25 02:43:03 +0000 |
commit | 818cf866da84841e0f46c8f7b717b18926032f25 (patch) | |
tree | 2bdb32179d450bb6b0356d501eccb7bb978c5098 /src/CharClassify.cxx | |
parent | 89cb4070bf10f7143df9a40aed89693b029f7e2e (diff) | |
download | scintilla-mirror-818cf866da84841e0f46c8f7b717b18926032f25.tar.gz |
Patch from Greg Smith with further modifications moved character
classification from Document into a separate CharClassify class and file
and uses this from RESearch for regular expression word end \< and \>
instead of built-in table.
Diffstat (limited to 'src/CharClassify.cxx')
-rw-r--r-- | src/CharClassify.cxx | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/CharClassify.cxx b/src/CharClassify.cxx new file mode 100644 index 000000000..acab4b229 --- /dev/null +++ b/src/CharClassify.cxx @@ -0,0 +1,43 @@ +// Scintilla source code edit control +/** @file CharClassify.cxx + ** Character classifications used by Document and RESearch. + **/ +// Copyright 2006 by Neil Hodgson <neilh@scintilla.org> +// The License.txt file describes the conditions under which this software may be distributed. + +#include <ctype.h> + +#include "CharClassify.h" + +// Shut up annoying Visual C++ warnings: +#ifdef _MSC_VER +#pragma warning(disable: 4514) +#endif + +CharClassify::CharClassify() { + SetDefaultCharClasses(true); +} + +void CharClassify::SetDefaultCharClasses(bool includeWordClass) { + // Initialize all char classes to default values + for (int ch = 0; ch < 256; ch++) { + if (ch == '\r' || ch == '\n') + charClass[ch] = ccNewLine; + else if (ch < 0x20 || ch == ' ') + charClass[ch] = ccSpace; + else if (includeWordClass && (ch >= 0x80 || isalnum(ch) || ch == '_')) + charClass[ch] = ccWord; + else + charClass[ch] = ccPunctuation; + } +} + +void CharClassify::SetCharClasses(const unsigned char *chars, cc newCharClass) { + // Apply the newCharClass to the specifed chars + if (chars) { + while (*chars) { + charClass[*chars] = static_cast<unsigned char>(newCharClass); + chars++; + } + } +} |