24 #ifndef KLFLATEXEDIT_H 25 #define KLFLATEXEDIT_H 32 #include <QContextMenuEvent> 34 #include <QSyntaxHighlighter> 35 #include <QTextCharFormat> 45 struct KLFLatexEditPrivate;
55 Q_PROPERTY(
int heightHintLines READ heightHintLines WRITE setHeightHintLines) ;
56 Q_PROPERTY(
bool wrapLines READ wrapLines WRITE setWrapLines) ;
74 int heightHintLines()
const;
80 virtual QSize sizeHint()
const;
84 bool wrapLines()
const;
99 void setLatex(
const QString& latex);
105 void setWrapLines(
bool wrap);
108 void setHeightHintLines(
int lines);
112 void insertDelimiter(
const QString& delim,
int charsBack = 1);
115 void setPalette(
const QPalette& palette);
119 virtual bool canInsertFromMimeData(
const QMimeData *source)
const;
120 virtual void insertFromMimeData(
const QMimeData *source);
127 struct KLFLatexParenSpecsPrivate;
133 enum Flag { None = 0x00, IsLaTeXBrace = 0x01, AllowAlone = 0x02 };
162 IdentifyFlagOpen = 0x01,
163 IdentifyFlagClose = 0x02,
164 IdentifyFlagOpenClose = IdentifyFlagOpen|IdentifyFlagClose
171 int identifyParen(
const QString& parenstr, uint identflags);
177 int identifyModifier(
const QString& modstr, uint identflags);
191 Q_PROPERTY(
bool highlightEnabled READ highlightEnabled WRITE setHighlightEnabled) ;
192 Q_PROPERTY(
bool highlightParensOnly READ highlightParensOnly WRITE setHighlightParensOnly) ;
193 Q_PROPERTY(
bool highlightLonelyParens READ highlightLonelyParens WRITE setHighlightLonelyParens) ;
194 Q_PROPERTY(
QTextFormat fmtKeyword READ fmtKeyword WRITE setFmtKeyword) ;
195 Q_PROPERTY(
QTextFormat fmtComment READ fmtComment WRITE setFmtComment) ;
196 Q_PROPERTY(
QTextFormat fmtParenMatch READ fmtParenMatch WRITE setFmtParenMatch) ;
197 Q_PROPERTY(
QTextFormat fmtParenMismatch READ fmtParenMismatch WRITE setFmtParenMismatch) ;
198 Q_PROPERTY(
QTextFormat fmtLonelyParen READ fmtLonelyParen WRITE setFmtLonelyParen) ;
205 enum Type { Normal = 0, Keyword, Comment, Paren };
207 KeywordMask = 1 << Keyword,
208 CommentMask = 1 << Comment,
209 ParenMask = 1 << Paren };
213 :
type(t), pos(a), len(l),
keyword(), parenmatch(None), parenisopening(false),
214 parenmodifier(), parenstr(), parenotherpos(-1)
230 bool parenIsLatexBrace()
const;
240 QList<ParsedBlock> parsedBlocksForPos(
int pos,
unsigned int filter_type = 0xffffffff)
const;
242 virtual void highlightBlock(
const QString& text);
254 void newSymbolTyped(
const QString& symbolName);
257 void setCaretPos(
int position);
264 void setHighlightEnabled(
bool on);
265 void setHighlightParensOnly(
bool on);
266 void setHighlightLonelyParens(
bool on);
275 QTextEdit *_textedit;
279 enum Format { FNormal = 0, FKeyWord, FComment, FParenMatch, FParenMismatch, FLonelyParen };
282 FormatRule(
int ps = -1,
int l = 0, Format f = FNormal,
bool needsfocus =
false)
283 : pos(ps), len(l),
format(f), onlyIfFocus(needsfocus)
292 int end()
const {
return pos + len; }
301 void parseEverything();
311 bool highlightParensOnly;
312 bool highlightLonelyParens;
QTextCharFormat fmtParenMatch() const
static KLFLatexParenSpecs parenSpecs
Base declarations for klatexformula and some utilities.
KLF_EXPORT QDebug operator<<(QDebug str, const KLFLatexSyntaxHighlighter::ParsedBlock &p)
bool highlightLonelyParens() const
ParenSpec(const QString &o, const QString &c, uint f=0x00)
bool highlightEnabled() const
An abstract handler for when data is dropped.
QTextCharFormat fmtLonelyParen() const
#define KLF_DECLARE_PRIVATE(ClassName)
QTextCharFormat fmtParenMismatch() const
A text edit field that edits latex code.
QTextCharFormat fmtKeyword() const
QTextCharFormat fmtComment() const
QList< ParsedBlock > parsedContent() const
ParenModifierSpec(const QString &o, const QString &c)
ParsedBlock(Type t=Normal, int a=-1, int l=-1)
bool highlightParensOnly() const