15631
|
1 /* Copyright (C) 2008 e_k (e_k@users.sourceforge.net) |
|
2 |
|
3 This library is free software; you can redistribute it and/or |
|
4 modify it under the terms of the GNU Library General Public |
|
5 License as published by the Free Software Foundation; either |
|
6 version 2 of the License, or (at your option) any later version. |
|
7 |
|
8 This library is distributed in the hope that it will be useful, |
|
9 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
11 Library General Public License for more details. |
|
12 |
|
13 You should have received a copy of the GNU Library General Public License |
|
14 along with this library; see the file COPYING.LIB. If not, write to |
|
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
16 Boston, MA 02110-1301, USA. |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef _Q_TERM_WIDGET |
|
21 #define _Q_TERM_WIDGET |
|
22 |
|
23 #include <QtGui> |
|
24 |
|
25 struct TermWidgetImpl; |
|
26 |
|
27 enum COLOR_SCHEME { COLOR_SCHEME_WHITE_ON_BLACK = 1, |
|
28 COLOR_SCHEME_GREEN_ON_BLACK, |
|
29 COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW }; |
|
30 |
|
31 class QTerminal : public QWidget |
|
32 { |
|
33 Q_OBJECT |
|
34 public: |
|
35 |
|
36 enum ScrollBarPosition |
|
37 { |
|
38 /** Do not show the scroll bar. */ |
|
39 NoScrollBar=0, |
|
40 /** Show the scroll bar on the left side of the display. */ |
|
41 ScrollBarLeft=1, |
|
42 /** Show the scroll bar on the right side of the display. */ |
|
43 ScrollBarRight=2 |
|
44 }; |
|
45 |
|
46 |
|
47 //Creation of widget |
|
48 QTerminal(int startnow = 1, //start shell programm immediatelly |
|
49 QWidget *parent = 0); |
|
50 ~QTerminal(); |
|
51 |
|
52 //start shell program if it was not started in constructor |
|
53 void startShellProgram(); |
|
54 |
|
55 //look-n-feel, if you don`t like defaults |
|
56 |
|
57 // Terminal font |
|
58 // Default is application font with family Monospace, size 10 |
|
59 // USE ONLY FIXED-PITCH FONT! |
|
60 // otherwise symbols' position could be incorrect |
|
61 void setTerminalFont(QFont &font); |
|
62 |
|
63 //environment |
|
64 void setEnvironment(const QStringList& environment); |
|
65 |
|
66 // Shell program, default is /bin/bash |
|
67 void setShellProgram(const QString &progname); |
|
68 |
|
69 //working directory |
|
70 void setWorkingDirectory(const QString& dir); |
|
71 |
|
72 // Shell program args, default is none |
|
73 void setArgs(QStringList &args); |
|
74 |
|
75 //Text codec, default is UTF-8 |
|
76 void setTextCodec(QTextCodec *codec); |
|
77 |
|
78 //Color scheme, default is white on black |
|
79 void setColorScheme(int scheme); |
|
80 |
|
81 //set size |
|
82 void setSize(int h, int v); |
|
83 |
|
84 // History size for scrolling |
|
85 void setHistorySize(int lines); //infinite if lines < 0 |
|
86 |
|
87 // Presence of scrollbar |
|
88 void setScrollBarPosition(ScrollBarPosition); |
|
89 |
|
90 // Send some text to terminal |
|
91 void sendText(QString &text); |
|
92 |
|
93 // Sets whether flow control is enabled |
|
94 void setFlowControlEnabled(bool enabled); |
|
95 |
|
96 // Returns whether flow control is enabled |
|
97 bool flowControlEnabled(void); |
|
98 |
|
99 /** |
|
100 * Sets whether the flow control warning box should be shown |
|
101 * when the flow control stop key (Ctrl+S) is pressed. |
|
102 */ |
|
103 void setFlowControlWarningEnabled(bool enabled); |
|
104 |
|
105 // Sets read-only mode to terminal |
|
106 void setReadOnly(bool); |
|
107 |
|
108 signals: |
|
109 void finished(); |
|
110 |
|
111 public slots: |
|
112 // Paste clipboard content to terminal |
|
113 void copyClipboard(); |
|
114 |
|
115 // Copies selection to clipboard |
|
116 void pasteClipboard(); |
|
117 |
|
118 protected: |
|
119 virtual void resizeEvent(QResizeEvent *); |
|
120 void *getTerminalDisplay(); |
|
121 |
|
122 protected slots: |
|
123 void sessionFinished(); |
|
124 |
|
125 private: |
|
126 void init(); |
|
127 TermWidgetImpl *m_impl; |
|
128 }; |
|
129 |
|
130 |
|
131 //Maybe useful, maybe not |
|
132 |
|
133 #ifdef __cplusplus |
|
134 extern "C" |
|
135 #endif |
|
136 void *createTermWidget(int startnow, void *parent); |
|
137 |
|
138 #endif |
|
139 |