xref: /haiku/headers/private/debugger/source_language/SyntaxHighlighter.h (revision 2897df967633aab846ff4917b53e2af7d1e54eeb)
1  /*
2   * Copyright 2014, Rene Gollent, rene@gollent.com.
3   * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
4   * Distributed under the terms of the MIT License.
5   */
6  #ifndef SYNTAX_HIGHLIGHTER_H
7  #define SYNTAX_HIGHLIGHTER_H
8  
9  
10  #include <String.h>
11  
12  #include <Referenceable.h>
13  
14  
15  class LineDataSource;
16  class TeamTypeInformation;
17  
18  
19  enum syntax_highlight_type {
20  	SYNTAX_HIGHLIGHT_NONE = 0,
21  	SYNTAX_HIGHLIGHT_KEYWORD,
22  	SYNTAX_HIGHLIGHT_PREPROCESSOR_KEYWORD,
23  	SYNTAX_HIGHLIGHT_IDENTIFIER,
24  	SYNTAX_HIGHLIGHT_OPERATOR,
25  	SYNTAX_HIGHLIGHT_TYPE,
26  	SYNTAX_HIGHLIGHT_NUMERIC_LITERAL,
27  	SYNTAX_HIGHLIGHT_STRING_LITERAL,
28  	SYNTAX_HIGHLIGHT_COMMENT
29  };
30  
31  
32  class SyntaxHighlightInfo {
33  public:
34  	virtual						~SyntaxHighlightInfo();
35  
36  	virtual	int32				GetLineHighlightRanges(int32 line,
37  									int32* _columns,
38  									syntax_highlight_type* _types,
39  									int32 maxCount) = 0;
40  										// Returns number of filled in
41  										// (column, type) pairs.
42  										// Default is (0, SYNTAX_HIGHLIGHT_NONE)
43  										// and can be omitted.
44  };
45  
46  
47  class SyntaxHighlighter : public BReferenceable {
48  public:
49  	virtual						~SyntaxHighlighter();
50  
51  	virtual	status_t			ParseText(LineDataSource* source,
52  									TeamTypeInformation* typeInfo,
53  									SyntaxHighlightInfo*& _info) = 0;
54  										// caller owns the returned info
55  };
56  
57  
58  #endif	// SYNTAX_HIGHLIGHTER_H
59