2009-07-14 00:45:15 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef SYNTAX_HIGHLIGHTER_H
|
|
|
|
#define SYNTAX_HIGHLIGHTER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <String.h>
|
|
|
|
|
|
|
|
#include <Referenceable.h>
|
|
|
|
|
|
|
|
|
|
|
|
enum syntax_highlight_type {
|
|
|
|
SYNTAX_HIGHLIGHT_NONE,
|
|
|
|
SYNTAX_HIGHLIGHT_KEYWORD
|
|
|
|
// TODO:...
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-12-16 16:50:30 +03:00
|
|
|
class SyntaxHighlightSource : public BReferenceable {
|
2009-07-14 00:45:15 +04:00
|
|
|
virtual ~SyntaxHighlightSource();
|
|
|
|
|
|
|
|
virtual int32 CountLines() const = 0;
|
|
|
|
virtual void GetLineAt(int32 index, BString& _line) const
|
|
|
|
= 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SyntaxHighlightInfo {
|
|
|
|
virtual ~SyntaxHighlightInfo();
|
|
|
|
|
|
|
|
virtual int32 GetLineHighlightRanges(int32 line,
|
|
|
|
int32* _columns,
|
|
|
|
syntax_highlight_type* _types,
|
|
|
|
int32 maxCount) = 0;
|
|
|
|
// Returns number of filled in
|
|
|
|
// (column, type) pairs.
|
|
|
|
// Default is (0, SYNTAX_HIGHLIGHT_NONE)
|
|
|
|
// and can be omitted.
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-12-16 16:50:30 +03:00
|
|
|
class SyntaxHighlighter : public BReferenceable {
|
2009-07-14 00:45:15 +04:00
|
|
|
public:
|
|
|
|
virtual ~SyntaxHighlighter();
|
|
|
|
|
|
|
|
virtual status_t ParseText(SyntaxHighlightSource* source,
|
|
|
|
SyntaxHighlightInfo*& _info) = 0;
|
|
|
|
// caller owns the returned info
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // SYNTAX_HIGHLIGHTER_H
|