25 #ifndef _gconsolewindow_h 26 #define _gconsolewindow_h 35 #include <QReadWriteLock> 39 #include "gtextarea.h" 43 #include "consolestreambuf.h" 57 class GConsoleWindow :
public GWindow {
59 static bool consoleEnabled();
60 static string getDefaultFont();
61 static GConsoleWindow* instance();
62 static bool isInitialized();
63 static void setConsoleEnabled(
bool enabled);
65 virtual void clearConsole();
66 virtual void clipboardCopy();
67 virtual void clipboardCut();
68 virtual void clipboardPaste();
69 void close()
override;
70 virtual void compareOutput(
const string& filename);
71 virtual string getAllOutput()
const;
76 virtual string getErrorColor()
const;
77 string
getFont()
const override;
80 virtual string getOutputColor()
const;
81 virtual string getUserInputColor()
const;
82 virtual bool hasInputScript()
const;
83 virtual bool isClearEnabled()
const;
84 virtual bool isEcho()
const;
85 virtual bool isLocationSaved()
const;
86 virtual bool isLocked()
const;
87 virtual void loadConfiguration();
88 virtual void loadInputScript(
int number);
89 virtual void loadInputScript(
const string& filename);
90 virtual void print(
const string& str,
bool isStdErr =
false);
91 virtual void println(
bool isStdErr =
false);
92 virtual void println(
const string& str,
bool isStdErr =
false);
93 virtual string readLine();
95 virtual void saveAs(
const string& filename =
"");
96 virtual void saveConfiguration(
bool prompt =
true);
97 virtual void selectAll();
100 virtual void setClearEnabled(
bool clearEnabled);
101 virtual void setConsoleSize(
double width,
double height);
102 void setColor(
int color)
override;
103 void setColor(
const string& color)
override;
104 virtual void setEcho(
bool echo);
105 virtual void setErrorColor(
const string& errorColor);
106 void setFont(
const QFont& font)
override;
107 void setFont(
const string& font)
override;
110 virtual void setLocationSaved(
bool locationSaved);
111 virtual void setLocked(
bool locked);
112 virtual void setOutputColor(
int rgb);
113 virtual void setOutputColor(
const string& outputColor);
114 void setSize(
double width,
double height)
override;
115 virtual void setUserInputColor(
const string& userInputColor);
116 virtual void showAboutDialog();
117 virtual void showColorDialog(
bool background =
false);
118 virtual void showCompareOutputDialog();
119 virtual void showFontDialog();
120 virtual void showInputScriptDialog();
121 virtual void showPrintDialog();
122 virtual void shutdown(
const string& reason);
125 static const bool ALLOW_RICH_INPUT_EDITING;
128 static const double DEFAULT_X;
129 static const double DEFAULT_Y;
130 static const string CONFIG_FILE_NAME;
131 static const string DEFAULT_FONT_FAMILY;
132 static const string DEFAULT_FONT_WEIGHT;
133 static const int DEFAULT_FONT_SIZE;
134 static const int MIN_FONT_SIZE;
135 static const int MAX_FONT_SIZE;
136 static const string DEFAULT_ERROR_COLOR;
137 static const string DEFAULT_ERROR_COLOR_DARK_MODE;
138 static const string DEFAULT_USER_INPUT_COLOR;
139 static const string DEFAULT_USER_INPUT_COLOR_DARK_MODE;
140 static GConsoleWindow* _instance;
141 static bool _consoleEnabled;
143 Q_DISABLE_COPY(GConsoleWindow)
146 ~GConsoleWindow()
override;
150 QTextFragment getUserInputFragment()
const;
151 int getUserInputStart()
const;
152 int getUserInputEnd()
const;
153 bool isCursorInUserInputArea()
const;
154 bool isSelectionInUserInputArea()
const;
155 void processBackspace(
int key);
156 void processCommandHistory(
int delta);
158 void processKeyPress(
GEvent event);
159 void processUserInputEnterKey();
160 void processUserInputKey(
int key);
161 void setUserInput(
const string& userInput);
170 int _commandHistoryIndex;
173 string _userInputColor;
175 string _lastSaveFileName;
176 std::queue<string> _inputLines;
177 std::queue<string> _inputScript;
178 std::vector<string> _inputCommandHistory;
179 sgl::qtgui::ConsoleStreambufQt* _cinout_new_buf;
180 sgl::qtgui::ConsoleStreambufQt* _cerr_new_buf;
181 std::streambuf* _cin_old_buf;
182 std::streambuf* _cout_old_buf;
183 std::streambuf* _cerr_old_buf;
184 std::ostringstream _allOutputBuffer;
185 QReadWriteLock _cinMutex;
186 QReadWriteLock _cinQueueMutex;
190 #endif // _gconsolewindow_h virtual void setSize(double width, double height)
Sets the window's total width and height in pixels.
Definition: gwindow.cpp:1196
virtual int getColorInt() const
Returns the current foreground outline color of the interactor as an RGB integer. ...
Definition: gdrawingsurface.cpp:246
virtual string getBackground() const
Returns the current background color of the interactor as a string.
Definition: gdrawingsurface.cpp:222
virtual string getForeground() const
Returns the current foreground outline color of the interactor as a string.
Definition: gdrawingsurface.cpp:278
virtual string getColor() const
Returns the current foreground outline color of the interactor as a string.
Definition: gdrawingsurface.cpp:238
A GEvent represents a user action that has occurred on a graphical interactor.
Definition: gevent.h:153
virtual void setForeground(int color)
Sets the current foreground outline color of the interactor as an RGB integer.
Definition: gdrawingsurface.cpp:439
static const int DEFAULT_WIDTH
The default width of a newly created window in pixels if its width is not explicitly specified...
Definition: gwindow.h:125
virtual int getBackgroundInt() const
Returns the current background color of the interactor as an RGB integer.
Definition: gdrawingsurface.cpp:230
static const int DEFAULT_HEIGHT
The default height of a newly created window in pixels if its height is not explicitly specified...
Definition: gwindow.h:131
virtual string getFont() const
Returns the current text font of the interactor as a font string.
Definition: gdrawingsurface.cpp:270
virtual int getForegroundInt() const
Returns the current foreground outline color of the interactor as an RGB integer. ...
Definition: gdrawingsurface.cpp:282
A GTextArea is a multi-line editable text box.
Definition: gtextarea.h:33
void setBackground(int color) override
Sets the current background color of the interactor as an RGB integer.
Definition: gwindow.cpp:1024
This class represents a graphics window that supports simple graphics.
Definition: gwindow.h:98
virtual void close()
Closes the window.
Definition: gwindow.cpp:595