~ubuntu-branches/ubuntu/trusty/presage/trusty-proposed

« back to all changes in this revision

Viewing changes to apps/gtk/gprompter/scintilla/src/CharClassify.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Matteo Vescovi
  • Date: 2011-08-06 09:26:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110806092615-0wvhajaht9974ncx
Tags: upstream-0.8.6
ImportĀ upstreamĀ versionĀ 0.8.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
7
 
 
8
#include <stdlib.h>
 
9
#include <ctype.h>
 
10
 
 
11
#include "CharClassify.h"
 
12
 
 
13
#ifdef SCI_NAMESPACE
 
14
using namespace Scintilla;
 
15
#endif
 
16
 
 
17
// Shut up annoying Visual C++ warnings:
 
18
#ifdef _MSC_VER
 
19
#pragma warning(disable: 4514)
 
20
#endif
 
21
 
 
22
CharClassify::CharClassify() {
 
23
        SetDefaultCharClasses(true);
 
24
}
 
25
 
 
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;
 
37
        }
 
38
}
 
39
 
 
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++;
 
46
                }
 
47
        }
 
48
}