]>
git.saurik.com Git - wxWidgets.git/blob - utils/HelpGen/src/sourcepainter.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleskandars Gluchovas
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __SOURCEPAINTER_G__
13 #define __SOURCEPAINTER_G__
16 #define ASSERT(x) if (!(x)) throw
19 #if defined( wxUSE_TEMPLATE_STL )
22 typedef vector
<int> SPBlockListT
;
33 #include "wx/string.h"
39 #define string wxString
42 typedef WXSTL_VECTOR_SHALLOW_COPY(int) SPBlockListT
;
46 #include "markup.h" // import MarkupTagsT definition
48 // "colored" codes for highlighted blocks
50 #define RANK_BLACK 0 // common source fragments
51 #define RANK_BLUE 1 // basic types
52 #define RANK_RED 2 // reserved words
53 #define RANK_GREEN 3 // comments
55 // colored block description format :
56 // int( ( rank << 16 ) | ( source_range_len ) )
59 // FOR NOW:: no lagnguage-map selection
61 // source code syntax heighlighter (CPP+JAVA+VB+PASCAL)
68 bool mCollectResultsOn
;
72 bool mCommentIsMultiline
;
75 // assembleResultString == true - instructs painter
76 // to collect each chunk of srouce passed to ProcessSource(),
77 // so that results cann be futher obtained in a single string
78 // instead of vector of block descriptions
80 SourcePainter( bool assembleResultString
= true );
81 virtual ~SourcePainter() {}
83 // can be called multiple times (e.g. on each source line)
84 void ProcessSource( char* src
, int srcLen
);
86 // method, for manually adjusting state of source painter
87 void SetState( bool isInComment
,
88 bool commentIsMultiline
);
90 // reinitializes object - clears results of previouse processing
91 void Init( bool assembleResultString
= true );
93 // generates string of highlighted source for the scipting
94 // language given by "tags" argument
96 virtual void GetResultString(wxString
& result
, MarkupTagsT tags
);
98 // returns vector of block descriptors, see SPBlockListT definition
99 // (block descriptors can be used for fast custom highlighted text generation)
101 SPBlockListT
& GetBlocks();
103 // NOTE:: static method
104 // returns if the given word is a reserved word or basic type identifier
105 static bool IsKeyword( char* word
, int wordLen
);