forked from Mudlet/Mudlet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTConsole.h
More file actions
283 lines (248 loc) · 8.89 KB
/
TConsole.h
File metadata and controls
283 lines (248 loc) · 8.89 KB
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#ifndef MUDLET_TCONSOLE_H
#define MUDLET_TCONSOLE_H
/***************************************************************************
* Copyright (C) 2008-2012 by Heiko Koehn - KoehnHeiko@googlemail.com *
* Copyright (C) 2014 by Ahmed Charles - acharles@outlook.com *
* Copyright (C) 2014-2016 by Stephen Lyons - slysven@virginmedia.com *
* Copyright (C) 2016 by Ian Adkins - ieadkins@gmail.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 "TBuffer.h"
#include "pre_guard.h"
#include <QDataStream>
#include <QFile>
#include <QPointer>
#include <QTextStream>
#include <QWidget>
#include "post_guard.h"
#include <list>
#include <map>
class QCloseEvent;
class QLineEdit;
class QScrollBar;
class QToolButton;
class dlgMapper;
class Host;
class TTextEdit;
class TCommandLine;
class TLabel;
class TSplitter;
class dlgNotepad;
class TConsole : public QWidget
{
Q_OBJECT
Q_DISABLE_COPY(TConsole)
public:
TConsole(Host*, bool isDebugConsole, QWidget* parent = 0);
void reset();
void resetMainConsole();
void echoUserWindow(const QString&);
Host* getHost();
TCommandLine* mpCommandLine;
void replace(const QString&);
void insertHTML(const QString&);
void insertText(const QString&);
void insertText(const QString&, QPoint);
void insertLink(const QString&, QStringList&, QStringList&, QPoint, bool customFormat = false);
void insertLink(const QString&, QStringList&, QStringList&, bool customFormat = false);
void echoLink(const QString& text, QStringList& func, QStringList& hint, bool customFormat = false);
void setLabelStyleSheet(std::string& buf, std::string& sh);
void copy();
void cut();
void paste();
void appendBuffer();
void appendBuffer(TBuffer);
int getButtonState();
void closeEvent(QCloseEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
void pasteWindow(TBuffer);
void setUserWindow();
QStringList getLines(int from, int to);
int getLineNumber();
int getLineCount();
bool deleteLine(int);
std::list<int> getFgColor(std::string& buf);
std::list<int> getBgColor(std::string& buf);
void luaWrapLine(std::string& buf, int line);
int getColumnNumber();
void createMapper(int, int, int, int);
void loadRawFile(std::string);
void setWrapAt(int pos)
{
mWrapAt = pos;
buffer.setWrapAt(pos);
}
void setIndentCount(int count)
{
mIndentCount = count;
buffer.setWrapIndent(count);
}
void echo(const QString&);
bool moveCursor(int x, int y);
int select(const QString&, int numOfMatch = 1);
void deselect();
bool selectSection(int, int);
void skipLine();
void setFgColor(int, int, int);
void setBgColor(int, int, int);
void changeColors();
TConsole* createBuffer(const QString& name);
void scrollDown(int lines);
void scrollUp(int lines);
void print(const QString&, const QColor fgColor, const QColor bgColor);
void print(const QString& msg);
void print(const char*);
void printDebug(QColor&, QColor&, const QString&);
void printSystemMessage(const QString& msg);
void printOnDisplay(std::string&, const bool isFromServer = false);
void printCommand(QString&);
bool hasSelection();
void moveCursorEnd();
int getLastLineNumber();
void refresh();
TLabel* createLabel(const QString& name, int x, int y, int width, int height, bool fillBackground);
TConsole* createMiniConsole(const QString& name, int x, int y, int width, int height);
bool createButton(const QString& name, int x, int y, int width, int height, bool fillBackground);
bool raiseWindow(const QString& name);
bool lowerWindow(const QString& name);
bool showWindow(const QString& name);
bool hideWindow(const QString& name);
bool printWindow(const QString& name, const QString& text);
bool setBackgroundImage(const QString& name, const QString& path);
bool setBackgroundColor(const QString& name, int r, int g, int b, int alpha);
QString getCurrentLine(std::string&);
void selectCurrentLine(std::string&);
bool setMiniConsoleFontSize(std::string&, int);
void setBold(bool);
void setLink(const QString& linkText, QStringList& linkFunction, QStringList& linkHint);
void setItalics(bool);
void setUnderline(bool);
void setStrikeOut(bool);
void finalize();
void runTriggers(int);
void showStatistics();
void showEvent(QShowEvent* event) override;
void hideEvent(QHideEvent* event) override;
void setConsoleBgColor(int, int, int);
void setConsoleFgColor(int, int, int);
std::list<int> _getFgColor();
std::list<int> _getBgColor();
void _luaWrapLine(int);
QString getCurrentLine();
void selectCurrentLine();
bool saveMap(const QString&);
bool loadMap(const QString&);
bool importMap(const QString&, QString* errMsg = Q_NULLPTR);
// Returns the size of the main buffer area (excluding the command line and toolbars).
QSize getMainWindowSize() const;
void toggleLogging(bool);
QPointer<Host> mpHost;
TBuffer buffer;
static const QString cmLuaLineVariable;
TTextEdit* console;
TTextEdit* console2;
int currentFgColorProperty;
QToolButton* emergencyStop;
bool isUserScrollBack;
QWidget* layer;
QWidget* layerCommandLine;
QWidget* layerEdit;
QColor mBgColor;
int mButtonState;
TBuffer mClipboard;
QColor mCommandBgColor;
QColor mCommandFgColor;
QString mConsoleName;
QString mCurrentLine;
int mDeletedLines;
QFont mDisplayFont;
int mEngineCursor;
QColor mFgColor;
TChar mFormatBasic;
TChar mFormatSystemMessage;
int mIndentCount;
bool mIsDebugConsole;
bool mIsHighColorMode;
bool mIsSubConsole;
std::map<std::string, TLabel*> mLabelMap;
QFile mLogFile;
QString mLogFileName;
QTextStream mLogStream;
bool mLogToLogFile;
int mMainFrameBottomHeight;
int mMainFrameLeftWidth;
int mMainFrameRightWidth;
int mMainFrameTopHeight;
int mOldX;
int mOldY;
TChar mFormatCurrent;
QString mFormatSequenceRest;
bool mHighColorModeBackground;
bool mHighColorModeForeground;
QWidget* mpBaseVFrame;
QWidget* mpTopToolBar;
QWidget* mpBaseHFrame;
QWidget* mpLeftToolBar;
QWidget* mpMainFrame;
QWidget* mpRightToolBar;
QWidget* mpMainDisplay;
dlgMapper* mpMapper;
dlgNotepad* mpNotePad;
QScrollBar* mpScrollBar;
QTime mProcessingTime;
bool mRecordReplay;
QFile mReplayFile;
QDataStream mReplayStream;
TChar mStandardFormat;
QList<TConsole*> mSubConsoleList;
std::map<std::string, TConsole*> mSubConsoleMap;
QColor mSystemMessageBgColor;
QColor mSystemMessageFgColor;
bool mTriggerEngineMode;
bool mUserConsole;
QPoint mUserCursor;
bool mWaitingForHighColorCode;
bool mWindowIsHidden;
int mWrapAt;
QLineEdit* networkLatency;
QPoint P_begin;
QPoint P_end;
QString profile_name;
TSplitter* splitter;
bool mIsPromptLine;
QToolButton* logButton;
bool mUserAgreedToCloseConsole;
QLineEdit* mpBufferSearchBox;
QToolButton* mpBufferSearchUp;
QToolButton* mpBufferSearchDown;
int mCurrentSearchResult;
QList<int> mSearchResults;
QString mSearchQuery;
bool mSaveLayoutRequested;
signals:
public slots:
void slot_searchBufferUp();
void slot_searchBufferDown();
void slot_toggleReplayRecording();
void slot_stop_all_triggers(bool);
void slot_toggleLogging();
// Used by mudlet class as told by "Profile Preferences"
// =>"Copy Map" in another profile to inform a list of
// profiles - asynchronously - to load in an updated map
void slot_reloadMap(QList<QString>);
};
#endif // MUDLET_TCONSOLE_H