[45157b3] | 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 QTermWidget : 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 | QTermWidget(int startnow = 1, //start shell programm immediatelly |
---|
| 49 | QWidget *parent = 0); |
---|
| 50 | ~QTermWidget(); |
---|
| 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 | void setTerminalFont(QFont &font); |
---|
| 60 | |
---|
| 61 | // Shell program, default is /bin/bash |
---|
| 62 | void setShellProgram(QString &progname); |
---|
| 63 | |
---|
| 64 | // Shell program args, default is none |
---|
| 65 | void setArgs(QStringList &args); |
---|
| 66 | |
---|
| 67 | //Text codec, default is UTF-8 |
---|
| 68 | void setTextCodec(QTextCodec *codec); |
---|
| 69 | |
---|
| 70 | //Color scheme, default is white on black |
---|
| 71 | void setColorScheme(int scheme); |
---|
| 72 | |
---|
| 73 | //set size |
---|
| 74 | void setSize(int h, int v); |
---|
| 75 | |
---|
| 76 | // History size for scrolling |
---|
| 77 | void setHistorySize(int lines); //infinite if lines < 0 |
---|
| 78 | |
---|
| 79 | // Presence of scrollbar |
---|
| 80 | void setScrollBarPosition(ScrollBarPosition); |
---|
| 81 | |
---|
| 82 | // Send some text to terminal |
---|
| 83 | void sendText(QString &text); |
---|
| 84 | |
---|
| 85 | signals: |
---|
| 86 | void finished(); |
---|
| 87 | |
---|
| 88 | protected: |
---|
| 89 | virtual void resizeEvent(QResizeEvent *); |
---|
| 90 | |
---|
| 91 | protected slots: |
---|
| 92 | void sessionFinished(); |
---|
| 93 | |
---|
| 94 | private: |
---|
| 95 | void init(); |
---|
| 96 | TermWidgetImpl *m_impl; |
---|
| 97 | }; |
---|
| 98 | |
---|
| 99 | |
---|
| 100 | //Maybe useful, maybe not |
---|
| 101 | |
---|
| 102 | #ifdef __cplusplus |
---|
| 103 | extern "C" |
---|
| 104 | #endif |
---|
| 105 | void *createTermWidget(int startnow, void *parent); |
---|
| 106 | |
---|
| 107 | #endif |
---|
| 108 | |
---|