forked from Mudlet/Mudlet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TTextEdit.h
163 lines (143 loc) · 6.33 KB
/
TTextEdit.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#ifndef MUDLET_TTEXTEDIT_H
#define MUDLET_TTEXTEDIT_H
/***************************************************************************
* Copyright (C) 2008-2011 by Heiko Koehn - KoehnHeiko@googlemail.com *
* Copyright (C) 2014 by Ahmed Charles - acharles@outlook.com *
* *
* 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. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "pre_guard.h"
#include <QMap>
#include <QPointer>
#include <QTime>
#include <QWidget>
#include "post_guard.h"
#include <string>
class Host;
class TBuffer;
class TConsole;
class QScrollBar;
class QString;
class TTextEdit : public QWidget
{
Q_OBJECT
public:
TTextEdit( TConsole *,
QWidget *,
TBuffer * pB,
Host * pH,
bool isDebugConsole,
bool isSplitScreen );
void paintEvent( QPaintEvent* ) override;
void contextMenuEvent ( QContextMenuEvent * event ) override;
void drawForeground(QPainter &, const QRect & );
void drawFrame(QPainter &, const QRect & );
void drawBackground( QPainter &, const QRect &, const QColor & );
void updateLastLine();
void drawCharacters( QPainter & painter,
const QRect & rect,
QString & text,
bool isBold,
bool isUnderline,
bool isItalics,
bool isStrikeOut,
QColor & fgColor,
QColor & bgColor );
std::string getCurrentTime();
void showNewLines();
void forceUpdate();
void needUpdate( int, int );
void scrollTo( int );
void scrollUp( int lines );
void scrollDown( int lines );
void wheelEvent( QWheelEvent * e ) override;
void resizeEvent( QResizeEvent * event ) override;
void mousePressEvent( QMouseEvent * ) override;
void mouseReleaseEvent( QMouseEvent * ) override;
void mouseMoveEvent( QMouseEvent * ) override;
void showEvent ( QShowEvent * event ) override;
void updateScreenView();
void highlight();
void unHighlight( QRegion & );
void swap( QPoint & p1, QPoint & p2 );
void focusInEvent( QFocusEvent * event ) override;
int imageTopLine();
int bufferScrollUp( int lines );
int bufferScrollDown( int lines );
bool isTailMode();
void copySelectionToClipboard();
void setConsoleFgColor( int r, int g, int b ){mFgColor = QColor(r,g,b);}
void setConsoleBgColor( int r, int g, int b ){mBgColor = QColor(r,g,b);}
void setIsMiniConsole(){ mIsMiniConsole = true; }
void copySelectionToClipboardHTML();
QColor mBgColor;
int mCursorY;
QFont mDisplayFont;
QColor mFgColor;
int mFontAscent;
int mFontDescent;
bool mIsCommandPopup;
bool mIsTailMode;
QMap<QString, QString> mPopupCommands;
int mScrollVector;
QRegion mSelectedRegion;
bool mShowTimeStamps;
int mWrapAt;
int mWrapIndentCount;
qreal mLetterSpacing;
signals:
public slots:
void slot_toggleTimeStamps();
void slot_copySelectionToClipboard();
void slot_scrollBarMoved( int );
void slot_popupMenu();
void slot_copySelectionToClipboardHTML();
private:
void initDefaultSettings();
QFont mCommandLineFont;
QFont mCommandSeperator;
int mFontHeight;
int mFontWidth;
bool mForceUpdate;
bool mHighlight_on;
bool mHighlightingBegin;
bool mHighlightingEnd;
bool mInit_OK;
bool mInversOn;
bool mIsDebugConsole;
bool mIsMiniConsole;
bool mIsSplitScreen;
int mLastRenderBottom;
int mLeftMargin;
bool mMouseTracking;
int mOldScrollPos;
QPoint mP_aussen;
QPoint mPA;
bool mPainterInit;
QPoint mPB;
TBuffer * mpBuffer;
TConsole * mpConsole;
QPointer<Host> mpHost;
QScrollBar * mpScrollBar;
int mScreenHeight;
QPixmap mScreenMap;
int mScreenWidth;
bool mScrollUp;
int mTopMargin;
bool mUpdateSlice;
QTime mLastClickTimer;
};
#endif // MUDLET_TTEXTEDIT_H