]> git.saurik.com Git - wxWidgets.git/blame - utils/HelpGen/src/sourcepainter.h
attempts to fix recursive mutex initialized detection under RedHat 7.1 (new glibc)
[wxWidgets.git] / utils / HelpGen / src / sourcepainter.h
CommitLineData
cecfc5e7
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: No names yet.
3// Purpose: Contrib. demo
4// Author: Aleksandras Gluchovas
5// Modified by:
6// Created: 22/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Aleskandars Gluchovas
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __SOURCEPAINTER_G__
13#define __SOURCEPAINTER_G__
14
15#ifndef ASSERT
16#define ASSERT(x) if (!(x)) throw
17#endif
18
19#if defined( wxUSE_TEMPLATE_STL )
20
21 #include <vector.h>
22 typedef vector<int> SPBlockListT;
23
24 #ifdef WIN32
25 #include <bstring.h>
26 #else
27 #include <strclass.h>
28 #include <string.h>
29 #endif
30#else
31
32 #include "wxstlvec.h"
33 #include "wx/string.h"
34
35 // FIXME:: dirty!
36 #define string wxString
37
38 typedef WXSTL_VECTOR_SHALLOW_COPY(int) SPBlockListT;
39
40#endif
41
42#include "markup.h" // import MarkupTagsT definition
43
44// "colored" codes for highlighted blocks
45
46#define RANK_BLACK 0 // common source fragments
47#define RANK_BLUE 1 // basic types
48#define RANK_RED 2 // reserved words
49#define RANK_GREEN 3 // comments
50
51// colored block description format :
52// int( ( rank << 16 ) | ( source_range_len ) )
53
54
55// FOR NOW:: no lagnguage-map selection
56
57// source code syntax heighlighter (CPP+JAVA+VB+PASCAL)
58
59class SourcePainter
60{
61protected:
62 string mResultStr;
63 SPBlockListT mBlocks;
64 bool mCollectResultsOn;
65
66 // state variables
67 bool mIsInComment;
68 bool mCommentIsMultiline;
69public:
70
71 // assembleResultString == TRUE - instructs painter
72 // to collect each chunk of srouce passed to ProcessSource(),
73 // so that results cann be futher obtained in a single string
74 // instead of vector of block descriptions
75
76 SourcePainter( bool assembleResultString = TRUE );
77 virtual ~SourcePainter() {}
78
79 // can be called multiple times (e.g. on each source line)
80 void ProcessSource( char* src, int srcLen );
81
82 // method, for manually adjusting state of source painter
83 void SetState( bool isInComment,
84 bool commentIsMultiline );
85
86 // reinitializes object - clears results of previouse processing
87 void Init( bool assembleResultString = TRUE );
88
89 // generates string of highlighted source for the scipting
90 // language given by "tags" argument
91
92 virtual void GetResultString(string& result, MarkupTagsT tags);
93
94 // returns vector of block descriptors, see SPBlockListT definition
95 // (block descriptors can be used for fast custom hightlighted text generation)
96
97 SPBlockListT& GetBlocks();
98
99 // NOTE:: static method
100 // returns if the given word is a reserved word or basic type identifier
101 static bool IsKeyword( char* word, int wordLen );
102};
103
104#endif