forked from mercutiodesign/texmaker-3.3.3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lightlatexeditor.h
106 lines (94 loc) · 3.73 KB
/
lightlatexeditor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/***************************************************************************
* copyright : (C) 2003-2011 by Pascal Brachet *
* http://www.xm1math.net/texmaker/ *
* addons by Luis Silvestre *
* contains some code from CLedit (C) 2010 Heinz van Saanen -GPL *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef LIGHTLATEXEDITOR_H
#define LIGHTLATEXEDITOR_H
#include <QWidget>
#include <QString>
#include <QTextEdit>
#include <QPlainTextEdit>
#include <QTextDocument>
#include <QTextCursor>
#include <QTextBlock>
#include "lightlatexhighlighter.h"
#include "textblockselection.h"
#include "encodingprober/qencodingprober.h"
typedef int UserBookmarkList[3];
class LightLatexEditor : public QPlainTextEdit {
Q_OBJECT
public:
LightLatexEditor(QWidget *parent,QFont & efont,QList<QColor> edcolors, QList<QColor> hicolors, QString name="");
~LightLatexEditor();
static void clearMarkerFormat(const QTextBlock &block, int markerId);
void gotoLine( int line );
bool search( const QString &expr, bool cs, bool wo, bool forward, bool startAtCursor );
void changeFont(QFont & new_font);
QString getEncoding();
void setEncoding(QString enc);
int getCursorPosition(int parag, int index);
void setCursorPosition(int para, int index);
int numoflines();
int searchLine( const QString &expr);
int linefromblock(const QTextBlock& p);
UserBookmarkList UserBookmark;
void selectword(int line, int col, QString word);
LightLatexHighlighter *highlighter;
void insertNewLine();
QRectF blockGeometry(const QTextBlock & block) {
return blockBoundingGeometry(block).translated(contentOffset());
}
int getLastNumLines();
void setLastNumLines(int n);
QString beginningLine();
void updateName(QString f);
void setTextCursor(const QTextCursor &cursor);
TextBlockSelection blockSelection;
public slots:
void matchAll();
void load( const QString &f );
void setColors(QList<QColor> colors);
private:
bool inBlockSelectionMode;
QString encoding;
int lastnumlines;
QString fname;
bool matchLeftPar ( QTextBlock currentBlock, int index, int numRightPar );
bool matchRightPar( QTextBlock currentBlock, int index, int numLeftPar );
void createParSelection( int pos );
int endBlock;
QString copyBlockSelection() const;
QColor colorBackground, colorLine, colorHighlight, colorCursor;
private slots:
void jumpToEndBlock();
void matchPar();
void ensureFinalNewLine();//Qt 4.7.1 bug
void gotoBookmark1();
void gotoBookmark2();
void gotoBookmark3();
void editFind();
void editGotoLine();
void removeBlockSelection(const QString &text = QString());
void slotSelectionChanged();
protected:
void paintEvent(QPaintEvent *event);
void contextMenuEvent(QContextMenuEvent *e);
void mouseMoveEvent(QMouseEvent *);
void mousePressEvent(QMouseEvent *);
QMimeData *createMimeDataFromSelection() const;
bool canInsertFromMimeData(const QMimeData *source) const;
void insertFromMimeData(const QMimeData *source);
signals:
void updatelineWidget();
void requestFind();
void requestGotoLine();
};
#endif