32 files changed, 144 insertions, 3435 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp index 315ea4a..27ba9ff 100644 --- a/noncore/apps/opie-console/MyPty.cpp +++ b/noncore/apps/opie-console/MyPty.cpp | |||
@@ -61,20 +61,16 @@ | |||
61 | 61 | ||
62 | There's a sinister ioctl(2), signal(2) and job control stuff | 62 | There's a sinister ioctl(2), signal(2) and job control stuff |
63 | nessesary to make everything work as it should. | 63 | nessesary to make everything work as it should. |
64 | */ | 64 | */ |
65 | 65 | ||
66 | #include "procctl.h" | 66 | #include "procctl.h" |
67 | #include "MyPty.h" | 67 | #include "MyPty.h" |
68 | 68 | ||
69 | /* OPIE */ | ||
70 | #include <opie2/odebug.h> | ||
71 | using namespace Opie::Core; | ||
72 | |||
73 | /* QT */ | 69 | /* QT */ |
74 | #include <qsocketnotifier.h> | 70 | #include <qsocketnotifier.h> |
75 | #include <qfile.h> | 71 | #include <qfile.h> |
76 | 72 | ||
77 | /* STD */ | 73 | /* STD */ |
78 | #include <stdlib.h> | 74 | #include <stdlib.h> |
79 | #include <stdio.h> | 75 | #include <stdio.h> |
80 | #include <signal.h> | 76 | #include <signal.h> |
@@ -97,17 +93,16 @@ using namespace Opie::Core; | |||
97 | 93 | ||
98 | /*! | 94 | /*! |
99 | Informs the client program about the | 95 | Informs the client program about the |
100 | actual size of the window. | 96 | actual size of the window. |
101 | */ | 97 | */ |
102 | 98 | ||
103 | void MyPty::setSize(int lines, int columns) | 99 | void MyPty::setSize(int lines, int columns) |
104 | { | 100 | { |
105 | owarn << "setting size" << oendl; | ||
106 | struct winsize wsize; | 101 | struct winsize wsize; |
107 | wsize.ws_row = (unsigned short)lines; | 102 | wsize.ws_row = (unsigned short)lines; |
108 | wsize.ws_col = (unsigned short)columns; | 103 | wsize.ws_col = (unsigned short)columns; |
109 | if(m_fd < 0) return; | 104 | if(m_fd < 0) return; |
110 | ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); | 105 | ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); |
111 | } | 106 | } |
112 | 107 | ||
113 | 108 | ||
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp index d168a5e..98c1793 100644 --- a/noncore/apps/opie-console/TEWidget.cpp +++ b/noncore/apps/opie-console/TEWidget.cpp | |||
@@ -1024,17 +1024,16 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | |||
1024 | return FALSE; // not us | 1024 | return FALSE; // not us |
1025 | if ( e->type() == QEvent::Wheel) { | 1025 | if ( e->type() == QEvent::Wheel) { |
1026 | QApplication::sendEvent(scrollbar, e); | 1026 | QApplication::sendEvent(scrollbar, e); |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | #ifdef FAKE_CTRL_AND_ALT | 1029 | #ifdef FAKE_CTRL_AND_ALT |
1030 | static bool control = FALSE; | 1030 | static bool control = FALSE; |
1031 | static bool alt = FALSE; | 1031 | static bool alt = FALSE; |
1032 | // odebug << " Has a keyboard with no CTRL and ALT keys, but we fake it:" << oendl; | ||
1033 | bool dele=FALSE; | 1032 | bool dele=FALSE; |
1034 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1033 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1035 | QKeyEvent* ke = (QKeyEvent*)e; | 1034 | QKeyEvent* ke = (QKeyEvent*)e; |
1036 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 1035 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
1037 | switch (ke->key()) { | 1036 | switch (ke->key()) { |
1038 | case Key_F9: // let this be "Control" | 1037 | case Key_F9: // let this be "Control" |
1039 | control = keydown; | 1038 | control = keydown; |
1040 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 1039 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
@@ -1063,21 +1062,18 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | |||
1063 | } | 1062 | } |
1064 | #endif | 1063 | #endif |
1065 | 1064 | ||
1066 | if ( e->type() == QEvent::KeyPress ) { | 1065 | if ( e->type() == QEvent::KeyPress ) { |
1067 | QKeyEvent* ke = (QKeyEvent*)e; | 1066 | QKeyEvent* ke = (QKeyEvent*)e; |
1068 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1067 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1069 | // know where the current selection is. | 1068 | // know where the current selection is. |
1070 | 1069 | ||
1071 | // odebug << "key pressed is 0x" << ke->key() << "" << oendl; | ||
1072 | 1070 | ||
1073 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker | 1071 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker |
1074 | |||
1075 | // odebug << "key pressed 2 is 0x" << ke->key() << "" << oendl; | ||
1076 | emitText("\\"); // expose | 1072 | emitText("\\"); // expose |
1077 | } else | 1073 | } else |
1078 | emit keyPressedSignal(ke); // expose | 1074 | emit keyPressedSignal(ke); // expose |
1079 | ke->accept(); | 1075 | ke->accept(); |
1080 | #ifdef FAKE_CTRL_AND_ALT | 1076 | #ifdef FAKE_CTRL_AND_ALT |
1081 | if ( dele ) delete e; | 1077 | if ( dele ) delete e; |
1082 | #endif | 1078 | #endif |
1083 | return true; // stop the event | 1079 | return true; // stop the event |
diff --git a/noncore/apps/opie-console/TEmulation.cpp b/noncore/apps/opie-console/TEmulation.cpp index 6ff73af..72cce75 100644 --- a/noncore/apps/opie-console/TEmulation.cpp +++ b/noncore/apps/opie-console/TEmulation.cpp | |||
@@ -66,20 +66,16 @@ | |||
66 | */ | 66 | */ |
67 | 67 | ||
68 | /* FIXME | 68 | /* FIXME |
69 | - evtl. the bulk operations could be made more transparent. | 69 | - evtl. the bulk operations could be made more transparent. |
70 | */ | 70 | */ |
71 | 71 | ||
72 | #include "TEmulation.h" | 72 | #include "TEmulation.h" |
73 | 73 | ||
74 | /* OPIE */ | ||
75 | #include <opie2/odebug.h> | ||
76 | using namespace Opie::Core; | ||
77 | |||
78 | /* STD */ | 74 | /* STD */ |
79 | #include <stdio.h> | 75 | #include <stdio.h> |
80 | #include <stdlib.h> | 76 | #include <stdlib.h> |
81 | #include <unistd.h> | 77 | #include <unistd.h> |
82 | 78 | ||
83 | 79 | ||
84 | /* ------------------------------------------------------------------------- */ | 80 | /* ------------------------------------------------------------------------- */ |
85 | /* */ | 81 | /* */ |
@@ -205,17 +201,16 @@ void TEmulation::onRcvChar(int c) | |||
205 | /* */ | 201 | /* */ |
206 | /* ------------------------------------------------------------------------- */ | 202 | /* ------------------------------------------------------------------------- */ |
207 | 203 | ||
208 | /*! | 204 | /*! |
209 | */ | 205 | */ |
210 | 206 | ||
211 | void TEmulation::onKeyPress( QKeyEvent* ev ) | 207 | void TEmulation::onKeyPress( QKeyEvent* ev ) |
212 | { | 208 | { |
213 | owarn << "onKeyPress,...." << oendl; | ||
214 | if (!connected) return; // someone else gets the keys | 209 | if (!connected) return; // someone else gets the keys |
215 | if (scr->getHistCursor() != scr->getHistLines()); | 210 | if (scr->getHistCursor() != scr->getHistLines()); |
216 | scr->setHistCursor(scr->getHistLines()); | 211 | scr->setHistCursor(scr->getHistLines()); |
217 | if (!ev->text().isEmpty()) | 212 | if (!ev->text().isEmpty()) |
218 | { // A block of text | 213 | { // A block of text |
219 | // Note that the text is proper unicode. | 214 | // Note that the text is proper unicode. |
220 | // We should do a conversion here, but since this | 215 | // We should do a conversion here, but since this |
221 | // routine will never be used, we simply emit plain ascii. | 216 | // routine will never be used, we simply emit plain ascii. |
diff --git a/noncore/apps/opie-console/atconfigdialog.cpp b/noncore/apps/opie-console/atconfigdialog.cpp index c998f96..f958b52 100644 --- a/noncore/apps/opie-console/atconfigdialog.cpp +++ b/noncore/apps/opie-console/atconfigdialog.cpp | |||
@@ -1,15 +1,11 @@ | |||
1 | #include "atconfigdialog.h" | 1 | #include "atconfigdialog.h" |
2 | #include "io_modem.h" | 2 | #include "io_modem.h" |
3 | 3 | ||
4 | /* OPIE */ | ||
5 | #include <opie2/odebug.h> | ||
6 | using namespace Opie::Core; | ||
7 | |||
8 | /* QT */ | 4 | /* QT */ |
9 | #include <qlineedit.h> | 5 | #include <qlineedit.h> |
10 | #include <qspinbox.h> | 6 | #include <qspinbox.h> |
11 | #include <qlayout.h> | 7 | #include <qlayout.h> |
12 | #include <qcombobox.h> | 8 | #include <qcombobox.h> |
13 | #include <qtabwidget.h> | 9 | #include <qtabwidget.h> |
14 | #include <qlabel.h> | 10 | #include <qlabel.h> |
15 | #include <qscrollview.h> | 11 | #include <qscrollview.h> |
@@ -150,18 +146,16 @@ QWidget* ATConfigDialog::tab1( QWidget* parent ) { | |||
150 | multiLineUntagBox->insertItem( tr("Yes") ); | 146 | multiLineUntagBox->insertItem( tr("Yes") ); |
151 | 147 | ||
152 | return returnWidget; | 148 | return returnWidget; |
153 | 149 | ||
154 | } | 150 | } |
155 | 151 | ||
156 | 152 | ||
157 | void ATConfigDialog::readConfig( const Profile& config ) { | 153 | void ATConfigDialog::readConfig( const Profile& config ) { |
158 | owarn << "config in atconfigdialog" << oendl; | ||
159 | |||
160 | initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) ); | 154 | initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) ); |
161 | resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) ); | 155 | resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) ); |
162 | dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) ); | 156 | dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) ); |
163 | dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); | 157 | dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); |
164 | dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) ); | 158 | dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) ); |
165 | dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); | 159 | dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); |
166 | dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) ); | 160 | dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) ); |
167 | dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); | 161 | dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); |
diff --git a/noncore/apps/opie-console/btconfigwidget.cpp b/noncore/apps/opie-console/btconfigwidget.cpp index 232e497..f2ed558 100644 --- a/noncore/apps/opie-console/btconfigwidget.cpp +++ b/noncore/apps/opie-console/btconfigwidget.cpp | |||
@@ -1,31 +1,21 @@ | |||
1 | #include "btconfigwidget.h" | ||
2 | #include "iolayerbase.h" | ||
3 | #include "comboboxhelper.h" | ||
4 | |||
1 | #include <qlabel.h> | 5 | #include <qlabel.h> |
2 | #include <qlayout.h> | 6 | #include <qlayout.h> |
3 | #include <qlineedit.h> | 7 | #include <qlineedit.h> |
4 | #include <qcombobox.h> | 8 | #include <qcombobox.h> |
5 | #include <qhbox.h> | 9 | #include <qhbox.h> |
6 | #include <qradiobutton.h> | 10 | #include <qradiobutton.h> |
7 | 11 | ||
8 | #include "iolayerbase.h" | ||
9 | #include "btconfigwidget.h" | ||
10 | 12 | ||
11 | namespace { | 13 | |
12 | void setCurrent( const QString& str, QComboBox* bo ) { | ||
13 | uint b = bo->count(); | ||
14 | for (int i = 0; i < bo->count(); i++ ) { | ||
15 | if ( bo->text(i) == str ) { | ||
16 | bo->setCurrentItem( i ); | ||
17 | return; | ||
18 | } | ||
19 | } | ||
20 | bo->insertItem( str ); | ||
21 | bo->setCurrentItem( b ); | ||
22 | } | ||
23 | } | ||
24 | 14 | ||
25 | BTConfigWidget::BTConfigWidget( const QString& name, | 15 | BTConfigWidget::BTConfigWidget( const QString& name, |
26 | QWidget* parent, | 16 | QWidget* parent, |
27 | const char* na ) | 17 | const char* na ) |
28 | : ProfileDialogConnectionWidget( name, parent, na ) { | 18 | : ProfileDialogConnectionWidget( name, parent, na ) { |
29 | 19 | ||
30 | m_lay = new QVBoxLayout( this ); | 20 | m_lay = new QVBoxLayout( this ); |
31 | 21 | ||
@@ -110,17 +100,17 @@ void BTConfigWidget::load( const Profile& prof ) { | |||
110 | break; | 100 | break; |
111 | case 9600: | 101 | case 9600: |
112 | default: | 102 | default: |
113 | m_base->setSpeed(IOLayerBase::Baud_9600 ); | 103 | m_base->setSpeed(IOLayerBase::Baud_9600 ); |
114 | break; | 104 | break; |
115 | } | 105 | } |
116 | 106 | ||
117 | if ( prof.readEntry("Device").isEmpty() ) return; | 107 | if ( prof.readEntry("Device").isEmpty() ) return; |
118 | setCurrent( prof.readEntry("Device"), m_deviceCmb ); | 108 | ComboboxHelper::setCurrent( prof.readEntry("Device"), m_deviceCmb ); |
119 | 109 | ||
120 | } | 110 | } |
121 | /* | 111 | /* |
122 | * save speed, | 112 | * save speed, |
123 | * flow, | 113 | * flow, |
124 | * parity | 114 | * parity |
125 | */ | 115 | */ |
126 | void BTConfigWidget::save( Profile& prof ) { | 116 | void BTConfigWidget::save( Profile& prof ) { |
diff --git a/noncore/apps/opie-console/comboboxhelper.cpp b/noncore/apps/opie-console/comboboxhelper.cpp new file mode 100644 index 0000000..1bfe0a7 --- a/dev/null +++ b/noncore/apps/opie-console/comboboxhelper.cpp | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002,2004 Holger Hans Peter Freyther <freyther@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This program is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.BIN. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include "comboboxhelper.h" | ||
30 | |||
31 | #include <qstring.h> | ||
32 | #include <qcombobox.h> | ||
33 | |||
34 | /** | ||
35 | * \brief Set string to be Current String inside the QCombox without duplicating it | ||
36 | * | ||
37 | * This method will make \par str the current QString. If | ||
38 | * the QString is already inside the QComboBox it will be | ||
39 | * set current. If it isn't it will be added. | ||
40 | * | ||
41 | * @param str The QString to be set current | ||
42 | * @param bo The QComboBox to operate on | ||
43 | */ | ||
44 | void ComboboxHelper::setCurrent( const QString& str, QComboBox* bo ) { | ||
45 | const uint b = bo->count(); | ||
46 | for (uint i = 0; i < b; i++ ) { | ||
47 | if ( bo->text(i) == str ) { | ||
48 | bo->setCurrentItem( i ); | ||
49 | return; | ||
50 | } | ||
51 | } | ||
52 | |||
53 | bo->insertItem( str ); | ||
54 | bo->setCurrentItem( b ); | ||
55 | } | ||
diff --git a/noncore/apps/opie-console/comboboxhelper.h b/noncore/apps/opie-console/comboboxhelper.h new file mode 100644 index 0000000..40153bf --- a/dev/null +++ b/noncore/apps/opie-console/comboboxhelper.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002,2004 Holger Hans Peter Freyther <freyther@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This program is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.BIN. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | #ifndef COMBO_BOX_HELPER_H | ||
29 | #define COMBO_BOX_HELPER_H | ||
30 | |||
31 | #include <qstring.h> | ||
32 | |||
33 | |||
34 | class QComboBox; | ||
35 | |||
36 | |||
37 | /** | ||
38 | * \brief ComboboxHelper with a small Helper for Configuring it | ||
39 | * | ||
40 | * ComboboxHelper contains methods for helping managing | ||
41 | * Comboboxes with 'dynamic' data. | ||
42 | * All Methods related to this class are static and operate | ||
43 | * on a QComboBox. | ||
44 | */ | ||
45 | struct ComboboxHelper { | ||
46 | static void setCurrent(const QString&, QComboBox *); | ||
47 | }; | ||
48 | |||
49 | #endif | ||
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp index 7010594..8883b83 100644 --- a/noncore/apps/opie-console/dialer.cpp +++ b/noncore/apps/opie-console/dialer.cpp | |||
@@ -1,15 +1,11 @@ | |||
1 | #include "dialer.h" | 1 | #include "dialer.h" |
2 | #include "io_modem.h" | 2 | #include "io_modem.h" |
3 | 3 | ||
4 | /* OPIE */ | ||
5 | #include <opie2/odebug.h> | ||
6 | using namespace Opie::Core; | ||
7 | |||
8 | /* QT */ | 4 | /* QT */ |
9 | #include <qlayout.h> | 5 | #include <qlayout.h> |
10 | #include <qprogressbar.h> | 6 | #include <qprogressbar.h> |
11 | #include <qlabel.h> | 7 | #include <qlabel.h> |
12 | #include <qpushbutton.h> | 8 | #include <qpushbutton.h> |
13 | #include <qapp.h> | 9 | #include <qapp.h> |
14 | #include <qtimer.h> | 10 | #include <qtimer.h> |
15 | #include <qmessagebox.h> | 11 | #include <qmessagebox.h> |
@@ -104,17 +100,16 @@ void Dialer::slotCancel() | |||
104 | } | 100 | } |
105 | else { | 101 | else { |
106 | accept(); | 102 | accept(); |
107 | } | 103 | } |
108 | } | 104 | } |
109 | 105 | ||
110 | void Dialer::reset() | 106 | void Dialer::reset() |
111 | { | 107 | { |
112 | owarn << "reset" << oendl; | ||
113 | switchState(state_cancel); | 108 | switchState(state_cancel); |
114 | } | 109 | } |
115 | 110 | ||
116 | void Dialer::slotAutostart() | 111 | void Dialer::slotAutostart() |
117 | { | 112 | { |
118 | //state = state_preinit; | 113 | //state = state_preinit; |
119 | dial(m_profile.readEntry("Number")); | 114 | dial(m_profile.readEntry("Number")); |
120 | } | 115 | } |
@@ -136,28 +131,25 @@ void Dialer::dial(const QString& number) | |||
136 | // modem hangup | 131 | // modem hangup |
137 | trydial(QString::null); | 132 | trydial(QString::null); |
138 | reject(); | 133 | reject(); |
139 | } | 134 | } |
140 | } | 135 | } |
141 | 136 | ||
142 | void Dialer::trydial(const QString& number) | 137 | void Dialer::trydial(const QString& number) |
143 | { | 138 | { |
144 | owarn << "TryDial:" << number.latin1() << "" << oendl; | ||
145 | if(state != state_cancel) switchState(state_preinit); | 139 | if(state != state_cancel) switchState(state_preinit); |
146 | if(cleanshutdown) | 140 | if(cleanshutdown) |
147 | { | 141 | { |
148 | owarn << "HangupString " << m_profile.readEntry("HangupString") << oendl; | ||
149 | send(m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) + "\r"); | 142 | send(m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) + "\r"); |
150 | } | 143 | } |
151 | 144 | ||
152 | if(state != state_cancel) | 145 | if(state != state_cancel) |
153 | { | 146 | { |
154 | switchState(state_init); | 147 | switchState(state_init); |
155 | // owarn << "Init String " + m_profile.readEntry("InitString") << oendl; | ||
156 | send(m_profile.readEntry("InitString",MODEM_DEFAULT_INIT_STRING ) + "\r"); | 148 | send(m_profile.readEntry("InitString",MODEM_DEFAULT_INIT_STRING ) + "\r"); |
157 | QString response2 = receive(); | 149 | QString response2 = receive(); |
158 | if(!response2.contains("\nOK\r")) | 150 | if(!response2.contains("\nOK\r")) |
159 | reset(); | 151 | reset(); |
160 | } | 152 | } |
161 | 153 | ||
162 | /*if(state != state_cancel) | 154 | /*if(state != state_cancel) |
163 | { | 155 | { |
@@ -178,33 +170,32 @@ void Dialer::trydial(const QString& number) | |||
178 | send("ATX1\r"); | 170 | send("ATX1\r"); |
179 | QString response4 = receive(); | 171 | QString response4 = receive(); |
180 | if(!response4.contains("\nOK\r")) | 172 | if(!response4.contains("\nOK\r")) |
181 | reset(); | 173 | reset(); |
182 | } | 174 | } |
183 | 175 | ||
184 | if(state != state_cancel) | 176 | if(state != state_cancel) |
185 | { | 177 | { |
186 | owarn << "progress" << oendl; | ||
187 | switchState(state_dialing); | 178 | switchState(state_dialing); |
188 | 179 | ||
189 | // send(QString("ATDT %1\r").arg(number)); | 180 | // send(QString("ATDT %1\r").arg(number)); |
190 | send(QString("%1 %2\r").arg(m_profile.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 )) | 181 | send(QString("%1 %2\r").arg(m_profile.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 )) |
191 | .arg(number)); | 182 | .arg(number)); |
192 | 183 | ||
193 | QString response5 = receive(); | 184 | QString response5 = receive(); |
194 | if(!response5.contains("CONNECT") ) | 185 | if(!response5.contains("CONNECT") ) |
195 | { | 186 | { |
196 | if(response5.contains("BUSY")) | 187 | if(response5.contains("BUSY")) |
197 | switchState(state_dialing); | 188 | switchState(state_dialing); |
198 | else | 189 | else |
199 | { | 190 | { |
200 | QMessageBox::warning(this, | 191 | QMessageBox::warning(this, |
201 | QObject::tr("Failure"), | 192 | QObject::tr("Failure"), |
202 | QObject::tr("Dialing the number failed.")); | 193 | QObject::tr("<qt>Dialing the number failed.</qt>")); |
203 | slotCancel(); | 194 | slotCancel(); |
204 | } | 195 | } |
205 | } | 196 | } |
206 | } | 197 | } |
207 | 198 | ||
208 | 199 | ||
209 | if(state != state_cancel) | 200 | if(state != state_cancel) |
210 | { | 201 | { |
@@ -214,17 +205,16 @@ void Dialer::trydial(const QString& number) | |||
214 | } | 205 | } |
215 | 206 | ||
216 | void Dialer::send(const QString& msg) | 207 | void Dialer::send(const QString& msg) |
217 | { | 208 | { |
218 | QString m = msg; | 209 | QString m = msg; |
219 | int bytes; | 210 | int bytes; |
220 | QString termination; | 211 | QString termination; |
221 | 212 | ||
222 | owarn << "Sending: " << m.latin1() << "" << oendl; | ||
223 | 213 | ||
224 | /*termination = "\r"; | 214 | /*termination = "\r"; |
225 | //termination = m_profile.readEntry("Termination"); | 215 | //termination = m_profile.readEntry("Termination"); |
226 | if(termination == "\n") m = m + "\n"; | 216 | if(termination == "\n") m = m + "\n"; |
227 | else if(termination == "\r") m = m + "\r"; | 217 | else if(termination == "\r") m = m + "\r"; |
228 | else m = m + "\r\n"; | 218 | else m = m + "\r\n"; |
229 | */ | 219 | */ |
230 | m = m.replace(QRegExp("\n"), "\r"); | 220 | m = m.replace(QRegExp("\n"), "\r"); |
@@ -247,21 +237,19 @@ QString Dialer::receive() | |||
247 | { | 237 | { |
248 | ret = ::read(m_fd, buffer, sizeof(buffer)); | 238 | ret = ::read(m_fd, buffer, sizeof(buffer)); |
249 | 239 | ||
250 | if(ret > 0) | 240 | if(ret > 0) |
251 | { | 241 | { |
252 | for(int i = 0; i < ret; i++) | 242 | for(int i = 0; i < ret; i++) |
253 | buffer[i] = buffer[i] & 0x7F; | 243 | buffer[i] = buffer[i] & 0x7F; |
254 | buffer[ret] = 0; | 244 | buffer[ret] = 0; |
255 | owarn << "Got: " << buffer << "" << oendl; | ||
256 | buf.append(QString(buffer)); | 245 | buf.append(QString(buffer)); |
257 | if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY"))) | 246 | if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY"))) |
258 | { | 247 | { |
259 | //owarn << "Receiving: '" << buf.latin1() << "'" << oendl; | ||
260 | cleanshutdown = 1; | 248 | cleanshutdown = 1; |
261 | return buf; | 249 | return buf; |
262 | }else if (buf.contains("NO CARRIER") || buf.contains("NO DIALTONE") ) { | 250 | }else if (buf.contains("NO CARRIER") || buf.contains("NO DIALTONE") ) { |
263 | cleanshutdown = 1; | 251 | cleanshutdown = 1; |
264 | return QString::null; | 252 | return QString::null; |
265 | } | 253 | } |
266 | } | 254 | } |
267 | else if(ret < 0) | 255 | else if(ret < 0) |
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index e045aef..986ae8d 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp | |||
@@ -1,22 +1,17 @@ | |||
1 | #include "TEmuVt102.h" | 1 | #include "TEmuVt102.h" |
2 | #include "profile.h" | 2 | #include "profile.h" |
3 | #include "emulation_handler.h" | 3 | #include "emulation_handler.h" |
4 | #include "script.h" | 4 | #include "script.h" |
5 | #include "logger.h" | 5 | #include "logger.h" |
6 | 6 | ||
7 | /* OPIE */ | ||
8 | #include <opie2/odebug.h> | ||
9 | |||
10 | #include <qfile.h> | 7 | #include <qfile.h> |
11 | #include <qtextstream.h> | 8 | #include <qtextstream.h> |
12 | 9 | ||
13 | using namespace Opie::Core; | ||
14 | |||
15 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) | 10 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) |
16 | : QObject(0, name ) | 11 | : QObject(0, name ) |
17 | { | 12 | { |
18 | m_teWid = new TEWidget( parent, "TerminalMain"); | 13 | m_teWid = new TEWidget( parent, "TerminalMain"); |
19 | // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) | 14 | // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) |
20 | // use setWrapAt(80) for normal console with scrollbar | 15 | // use setWrapAt(80) for normal console with scrollbar |
21 | setWrap(prof.readNumEntry("Wrap", 80) ? 0 : 80); | 16 | setWrap(prof.readNumEntry("Wrap", 80) ? 0 : 80); |
22 | m_teWid->setMinimumSize(150, 70 ); | 17 | m_teWid->setMinimumSize(150, 70 ); |
@@ -143,21 +138,19 @@ QColor EmulationHandler::foreColor(int col) { | |||
143 | case Profile::White: | 138 | case Profile::White: |
144 | /* color is black */ | 139 | /* color is black */ |
145 | co = Qt::white; | 140 | co = Qt::white; |
146 | break; | 141 | break; |
147 | case Profile::Black: | 142 | case Profile::Black: |
148 | co = Qt::black; | 143 | co = Qt::black; |
149 | break; | 144 | break; |
150 | case Profile::Green: | 145 | case Profile::Green: |
151 | owarn << "Foreground green" << oendl; | ||
152 | co = Qt::green; | 146 | co = Qt::green; |
153 | break; | 147 | break; |
154 | case Profile::Orange: | 148 | case Profile::Orange: |
155 | owarn << "Foreground orange" << oendl; | ||
156 | co.setRgb( 231, 184, 98 ); | 149 | co.setRgb( 231, 184, 98 ); |
157 | break; | 150 | break; |
158 | } | 151 | } |
159 | 152 | ||
160 | return co; | 153 | return co; |
161 | } | 154 | } |
162 | QColor EmulationHandler::backColor(int col ) { | 155 | QColor EmulationHandler::backColor(int col ) { |
163 | QColor co; | 156 | QColor co; |
@@ -167,21 +160,19 @@ QColor EmulationHandler::backColor(int col ) { | |||
167 | case Profile::White: | 160 | case Profile::White: |
168 | /* color is white */ | 161 | /* color is white */ |
169 | co = Qt::black; | 162 | co = Qt::black; |
170 | break; | 163 | break; |
171 | case Profile::Black: | 164 | case Profile::Black: |
172 | co = Qt::white; | 165 | co = Qt::white; |
173 | break; | 166 | break; |
174 | case Profile::Green: | 167 | case Profile::Green: |
175 | owarn << "Background black" << oendl; | ||
176 | co = Qt::black; | 168 | co = Qt::black; |
177 | break; | 169 | break; |
178 | case Profile::Orange: | 170 | case Profile::Orange: |
179 | owarn << "Background black" << oendl; | ||
180 | co = Qt::black; | 171 | co = Qt::black; |
181 | break; | 172 | break; |
182 | } | 173 | } |
183 | 174 | ||
184 | return co; | 175 | return co; |
185 | } | 176 | } |
186 | 177 | ||
187 | QPushButton* EmulationHandler::cornerButton() { | 178 | QPushButton* EmulationHandler::cornerButton() { |
diff --git a/noncore/apps/opie-console/emulation_widget.cpp b/noncore/apps/opie-console/emulation_widget.cpp index 4688551..f0708d0 100644 --- a/noncore/apps/opie-console/emulation_widget.cpp +++ b/noncore/apps/opie-console/emulation_widget.cpp | |||
@@ -219,20 +219,16 @@ void EmulationWidget::paintEvent( QPaintEvent* pe ) | |||
219 | drawFrame( &painter ); | 219 | drawFrame( &painter ); |
220 | painter.end(); | 220 | painter.end(); |
221 | } | 221 | } |
222 | 222 | ||
223 | void EmulationWidget::calcGeometry() | 223 | void EmulationWidget::calcGeometry() |
224 | { | 224 | { |
225 | m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() ); | 225 | m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() ); |
226 | 226 | ||
227 | odebug << QString(" TEST").arg( contentsRect().width() ) << oendl; | ||
228 | odebug << QString(" TEST").arg( contentsRect().height() ) << oendl; | ||
229 | odebug << "NEUER TESTT!!!!!!!!" << oendl; | ||
230 | |||
231 | switch( scrollLoc ) | 227 | switch( scrollLoc ) |
232 | { | 228 | { |
233 | case SCRNONE : | 229 | case SCRNONE : |
234 | m_columns = ( contentsRect().width() -2 * rimX ) / f_width; | 230 | m_columns = ( contentsRect().width() -2 * rimX ) / f_width; |
235 | m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2; | 231 | m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2; |
236 | m_brX = m_blX; | 232 | m_brX = m_blX; |
237 | m_scrollbar->hide(); | 233 | m_scrollbar->hide(); |
238 | break; | 234 | break; |
@@ -253,31 +249,29 @@ void EmulationWidget::calcGeometry() | |||
253 | } | 249 | } |
254 | 250 | ||
255 | m_lines = ( contentsRect().height() - 2 * rimY ) / f_height; | 251 | m_lines = ( contentsRect().height() - 2 * rimY ) / f_height; |
256 | m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2; | 252 | m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2; |
257 | } | 253 | } |
258 | 254 | ||
259 | void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear ) | 255 | void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear ) |
260 | { | 256 | { |
261 | owarn << "Color1 " << color_table[attr.b].color.name().latin1() << "" << oendl; | ||
262 | if ( usePixmap && color_table[attr.b].transparent ) | 257 | if ( usePixmap && color_table[attr.b].transparent ) |
263 | { | 258 | { |
264 | painter.setBackgroundMode( TransparentMode ); | 259 | painter.setBackgroundMode( TransparentMode ); |
265 | if ( clear ) | 260 | if ( clear ) |
266 | erase( rect ); | 261 | erase( rect ); |
267 | } | 262 | } |
268 | else | 263 | else |
269 | { | 264 | { |
270 | if ( blinking ) | 265 | if ( blinking ) |
271 | painter.fillRect( rect, color_table[attr.b].color ); | 266 | painter.fillRect( rect, color_table[attr.b].color ); |
272 | else | 267 | else |
273 | { | 268 | { |
274 | painter.setBackgroundMode( OpaqueMode ); | 269 | painter.setBackgroundMode( OpaqueMode ); |
275 | owarn << "Color " << color_table[attr.b].color.name().latin1() << "" << oendl; | ||
276 | painter.setBackgroundColor( color_table[attr.b].color ); | 270 | painter.setBackgroundColor( color_table[attr.b].color ); |
277 | } | 271 | } |
278 | } | 272 | } |
279 | if ( color_table[attr.f].bold ) | 273 | if ( color_table[attr.f].bold ) |
280 | painter.setPen( QColor( 0x8F, 0x00, 0x00 ) ); | 274 | painter.setPen( QColor( 0x8F, 0x00, 0x00 ) ); |
281 | else | 275 | else |
282 | painter.setPen( color_table[attr.f].color ); | 276 | painter.setPen( color_table[attr.f].color ); |
283 | painter.drawText( rect.x(), rect.y() + f_ascent, string ); | 277 | painter.drawText( rect.x(), rect.y() + f_ascent, string ); |
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp index 6613183..0abe0d9 100644 --- a/noncore/apps/opie-console/function_keyboard.cpp +++ b/noncore/apps/opie-console/function_keyboard.cpp | |||
@@ -1,14 +1,10 @@ | |||
1 | #include "function_keyboard.h" | 1 | #include "function_keyboard.h" |
2 | 2 | ||
3 | /* OPIE */ | ||
4 | #include <opie2/odebug.h> | ||
5 | using namespace Opie::Core; | ||
6 | |||
7 | /* QT */ | 3 | /* QT */ |
8 | #include <qlayout.h> | 4 | #include <qlayout.h> |
9 | #include <qlistbox.h> | 5 | #include <qlistbox.h> |
10 | #include <qlabel.h> | 6 | #include <qlabel.h> |
11 | #include <qdir.h> | 7 | #include <qdir.h> |
12 | 8 | ||
13 | #define DEFAULT_ROWS 2 | 9 | #define DEFAULT_ROWS 2 |
14 | #define DEFAULT_COLS 12 | 10 | #define DEFAULT_COLS 12 |
@@ -37,17 +33,16 @@ FunctionKeyboard::FunctionKeyboard(QWidget *parent) : | |||
37 | if (value_list.isEmpty()) continue; | 33 | if (value_list.isEmpty()) continue; |
38 | 34 | ||
39 | keys.insert( | 35 | keys.insert( |
40 | 36 | ||
41 | handle, | 37 | handle, |
42 | FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort()) | 38 | FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort()) |
43 | ); | 39 | ); |
44 | } | 40 | } |
45 | //owarn << "loaded " << keys.count() << " keys" << oendl; | ||
46 | */ | 41 | */ |
47 | if (keys.isEmpty()) loadDefaults(); | 42 | if (keys.isEmpty()) loadDefaults(); |
48 | 43 | ||
49 | 44 | ||
50 | 45 | ||
51 | } | 46 | } |
52 | 47 | ||
53 | FunctionKeyboard::~FunctionKeyboard() {} | 48 | FunctionKeyboard::~FunctionKeyboard() {} |
@@ -256,54 +251,51 @@ void FunctionKeyboard::loadDefaults() { | |||
256 | } | 251 | } |
257 | 252 | ||
258 | /* FunctionKeyboardConfig {{{1 */ | 253 | /* FunctionKeyboardConfig {{{1 */ |
259 | 254 | ||
260 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) | 255 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) |
261 | : ProfileDialogKeyWidget(name, parent, na), | 256 | : ProfileDialogKeyWidget(name, parent, na), |
262 | selectedRow(0), selectedCol(0) | 257 | selectedRow(0), selectedCol(0) |
263 | { | 258 | { |
264 | owarn << "FunctionKeyboardConfig" << oendl; | ||
265 | |||
266 | |||
267 | kb = new FunctionKeyboard(this); | 259 | kb = new FunctionKeyboard(this); |
268 | connect (kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), | 260 | connect (kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), |
269 | this, SLOT(slotKeyPressed(FKey,ushort,ushort,bool))); | 261 | this, SLOT(slotKeyPressed(FKey,ushort,ushort,bool))); |
270 | 262 | ||
271 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimensions"), this); | 263 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimensions"), this); |
272 | QLabel *l = new QLabel("Rows", dimentions); | 264 | QLabel *l = new QLabel(tr("Rows"), dimentions); |
273 | m_rowBox = new QSpinBox(1, 15, 1, dimentions); | 265 | m_rowBox = new QSpinBox(1, 15, 1, dimentions); |
274 | connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); | 266 | connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); |
275 | l = new QLabel("Columns", dimentions); | 267 | l = new QLabel(tr("Columns"), dimentions); |
276 | m_colBox = new QSpinBox(1, 15, 1, dimentions); | 268 | m_colBox = new QSpinBox(1, 15, 1, dimentions); |
277 | connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); | 269 | connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); |
278 | 270 | ||
279 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); | 271 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); |
280 | l = new QLabel("Label", editKey); | 272 | l = new QLabel(tr("Label"), editKey); |
281 | m_labels = new QComboBox(true, editKey); | 273 | m_labels = new QComboBox(true, editKey); |
282 | m_labels->setInsertionPolicy(QComboBox::AtCurrent); | 274 | m_labels->setInsertionPolicy(QComboBox::AtCurrent); |
283 | m_labels->insertItem(""); | 275 | m_labels->insertItem(""); |
284 | 276 | ||
285 | QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); | 277 | QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); |
286 | 278 | ||
287 | for (uint i = 0; i < files.count(); i++) { | 279 | for (uint i = 0; i < files.count(); i++) { |
288 | 280 | ||
289 | m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]); | 281 | m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]); |
290 | } | 282 | } |
291 | connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); | 283 | connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); |
292 | connect (m_labels, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeLabelText(const QString&))); | 284 | connect (m_labels, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeLabelText(const QString&))); |
293 | 285 | ||
294 | l = new QLabel("Q Keycode", editKey); | 286 | l = new QLabel(tr("Q Keycode", "Qt Key Code for the OnScreen Keyboard"), editKey); |
295 | m_qvalues = new QComboBox(true, editKey); | 287 | m_qvalues = new QComboBox(true, editKey); |
296 | m_qvalues->setInsertionPolicy(QComboBox::AtTop); | 288 | m_qvalues->setInsertionPolicy(QComboBox::AtTop); |
297 | m_qvalues->setDuplicatesEnabled(false); | 289 | m_qvalues->setDuplicatesEnabled(false); |
298 | m_qvalues->insertItem(""); | 290 | m_qvalues->insertItem(""); |
299 | connect (m_qvalues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeQCode(const QString&))); | 291 | connect (m_qvalues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeQCode(const QString&))); |
300 | 292 | ||
301 | l = new QLabel("Unicode Value", editKey); | 293 | l = new QLabel(tr("Unicode Value", "The Unicode value of the key"), editKey); |
302 | m_uniValues = new QComboBox(true, editKey); | 294 | m_uniValues = new QComboBox(true, editKey); |
303 | m_uniValues->setInsertionPolicy(QComboBox::AtTop); | 295 | m_uniValues->setInsertionPolicy(QComboBox::AtTop); |
304 | m_uniValues->setDuplicatesEnabled(false); | 296 | m_uniValues->setDuplicatesEnabled(false); |
305 | m_uniValues->insertItem(""); | 297 | m_uniValues->insertItem(""); |
306 | connect (m_uniValues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeUnicode(const QString&))); | 298 | connect (m_uniValues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeUnicode(const QString&))); |
307 | 299 | ||
308 | QVBoxLayout *root = new QVBoxLayout(this, 2); | 300 | QVBoxLayout *root = new QVBoxLayout(this, 2); |
309 | root->addWidget(kb); | 301 | root->addWidget(kb); |
diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp index c102427..a06b0c4 100644 --- a/noncore/apps/opie-console/io_bt.cpp +++ b/noncore/apps/opie-console/io_bt.cpp | |||
@@ -1,15 +1,11 @@ | |||
1 | 1 | ||
2 | #include "io_bt.h" | 2 | #include "io_bt.h" |
3 | 3 | ||
4 | /* OPIE */ | ||
5 | #include <opie2/odebug.h> | ||
6 | using namespace Opie::Core; | ||
7 | |||
8 | IOBt::IOBt( const Profile &config ) : IOSerial( config ) { | 4 | IOBt::IOBt( const Profile &config ) : IOSerial( config ) { |
9 | m_attach = 0; | 5 | m_attach = 0; |
10 | } | 6 | } |
11 | 7 | ||
12 | 8 | ||
13 | IOBt::~IOBt() { | 9 | IOBt::~IOBt() { |
14 | if ( m_attach ) { | 10 | if ( m_attach ) { |
15 | delete m_attach; | 11 | delete m_attach; |
@@ -30,28 +26,27 @@ void IOBt::close() { | |||
30 | bool IOBt::open() { | 26 | bool IOBt::open() { |
31 | bool ret = false; | 27 | bool ret = false; |
32 | 28 | ||
33 | // only set up bt stuff if mac address was set, otherwise use the device set | 29 | // only set up bt stuff if mac address was set, otherwise use the device set |
34 | if ( !m_mac.isEmpty() ) { | 30 | if ( !m_mac.isEmpty() ) { |
35 | 31 | ||
36 | // now it should also be checked, if there is a connection to the device with that mac allready | 32 | // now it should also be checked, if there is a connection to the device with that mac allready |
37 | // hciattach here | 33 | // hciattach here |
38 | m_attach = new OProcess(); | 34 | m_attach = new Opie::Core::OProcess(); |
39 | *m_attach << "hciattach /dev/ttyS2 any 57600"; | 35 | *m_attach << "hciattach /dev/ttyS2 any 57600"; |
40 | 36 | ||
41 | // then start hcid, then rcfomm handling (m_mac) | 37 | // then start hcid, then rcfomm handling (m_mac) |
42 | 38 | ||
43 | connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), | 39 | connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), |
44 | this, SLOT( slotExited(Opie::Core::OProcess*) ) ); | 40 | this, SLOT( slotExited(Opie::Core::OProcess*) ) ); |
45 | 41 | ||
46 | if ( m_attach->start() ) { | 42 | if ( m_attach->start() ) { |
47 | ret = IOSerial::open(); | 43 | ret = IOSerial::open(); |
48 | } else { | 44 | } else { |
49 | owarn << "could not attach to device" << oendl; | ||
50 | delete m_attach; | 45 | delete m_attach; |
51 | m_attach = 0; | 46 | m_attach = 0; |
52 | } | 47 | } |
53 | } else { | 48 | } else { |
54 | // directly to the normal serial | 49 | // directly to the normal serial |
55 | // TODO: look first if the connection really exists. ( is set up ) | 50 | // TODO: look first if the connection really exists. ( is set up ) |
56 | 51 | ||
57 | ret =IOSerial::open(); | 52 | ret =IOSerial::open(); |
@@ -73,24 +68,12 @@ void IOBt::reload( const Profile &config ) { | |||
73 | QString IOBt::identifier() const { | 68 | QString IOBt::identifier() const { |
74 | return "bluetooth"; | 69 | return "bluetooth"; |
75 | } | 70 | } |
76 | 71 | ||
77 | QString IOBt::name() const { | 72 | QString IOBt::name() const { |
78 | return "BLuetooth IO Layer"; | 73 | return "BLuetooth IO Layer"; |
79 | } | 74 | } |
80 | 75 | ||
81 | void IOBt::slotExited( OProcess* proc ){ | 76 | void IOBt::slotExited( Opie::Core::OProcess* proc ){ |
82 | close(); | 77 | close(); |
83 | delete proc; | 78 | delete proc; |
84 | } | 79 | } |
85 | |||
86 | QBitArray IOBt::supports() const { | ||
87 | return QBitArray( 3 ); | ||
88 | } | ||
89 | |||
90 | bool IOBt::isConnected() { | ||
91 | return false; | ||
92 | } | ||
93 | |||
94 | void IOBt::send(const QByteArray &data) { | ||
95 | odebug << "Please overload me..." << oendl; | ||
96 | } | ||
diff --git a/noncore/apps/opie-console/io_bt.h b/noncore/apps/opie-console/io_bt.h index 00ca7e5..156632b 100644 --- a/noncore/apps/opie-console/io_bt.h +++ b/noncore/apps/opie-console/io_bt.h | |||
@@ -22,25 +22,22 @@ class IOBt : public IOSerial { | |||
22 | 22 | ||
23 | public: | 23 | public: |
24 | 24 | ||
25 | IOBt(const Profile &); | 25 | IOBt(const Profile &); |
26 | ~IOBt(); | 26 | ~IOBt(); |
27 | 27 | ||
28 | virtual QString identifier() const; | 28 | virtual QString identifier() const; |
29 | virtual QString name() const; | 29 | virtual QString name() const; |
30 | virtual QBitArray supports() const; | ||
31 | virtual bool isConnected(); | ||
32 | 30 | ||
33 | signals: | 31 | signals: |
34 | void received(const QByteArray &); | 32 | void received(const QByteArray &); |
35 | void error(int, const QString &); | 33 | void error(int, const QString &); |
36 | 34 | ||
37 | public slots: | 35 | public slots: |
38 | virtual void send( const QByteArray& ); | ||
39 | virtual bool open(); | 36 | virtual bool open(); |
40 | virtual void close(); | 37 | virtual void close(); |
41 | virtual void reload(const Profile &); | 38 | virtual void reload(const Profile &); |
42 | 39 | ||
43 | private: | 40 | private: |
44 | Opie::Core::OProcess *m_attach; | 41 | Opie::Core::OProcess *m_attach; |
45 | QString m_mac; | 42 | QString m_mac; |
46 | private slots: | 43 | private slots: |
diff --git a/noncore/apps/opie-console/io_irda.cpp b/noncore/apps/opie-console/io_irda.cpp index 38542f5..9d27c85 100644 --- a/noncore/apps/opie-console/io_irda.cpp +++ b/noncore/apps/opie-console/io_irda.cpp | |||
@@ -1,14 +1,10 @@ | |||
1 | #include "io_irda.h" | 1 | #include "io_irda.h" |
2 | 2 | ||
3 | /* OPIE */ | ||
4 | #include <opie2/odebug.h> | ||
5 | using namespace Opie::Core; | ||
6 | |||
7 | IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { | 3 | IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { |
8 | m_attach = 0; | 4 | m_attach = 0; |
9 | } | 5 | } |
10 | 6 | ||
11 | 7 | ||
12 | IOIrda::~IOIrda() { | 8 | IOIrda::~IOIrda() { |
13 | if ( m_attach ) { | 9 | if ( m_attach ) { |
14 | delete m_attach; | 10 | delete m_attach; |
@@ -22,27 +18,26 @@ void IOIrda::close() { | |||
22 | // still need error handling | 18 | // still need error handling |
23 | delete m_attach; | 19 | delete m_attach; |
24 | } | 20 | } |
25 | 21 | ||
26 | bool IOIrda::open() { | 22 | bool IOIrda::open() { |
27 | bool ret; | 23 | bool ret; |
28 | 24 | ||
29 | // irdaattach here | 25 | // irdaattach here |
30 | m_attach = new OProcess(); | 26 | m_attach = new Opie::Core::OProcess(); |
31 | *m_attach << "irattach /dev/ttyS2 -s"; | 27 | *m_attach << "irattach /dev/ttyS2 -s"; |
32 | 28 | ||
33 | connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), | 29 | connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), |
34 | this, SLOT( slotExited(Opie::Core::OProcess*) ) ); | 30 | this, SLOT( slotExited(Opie::Core::OProcess*) ) ); |
35 | 31 | ||
36 | if ( m_attach->start() ) { | 32 | if ( m_attach->start() ) { |
37 | ret= IOSerial::open(); | 33 | ret= IOSerial::open(); |
38 | } else { | 34 | } else { |
39 | // emit error!!! | 35 | // emit error!!! |
40 | owarn << "could not attach to device" << oendl; | ||
41 | delete m_attach; | 36 | delete m_attach; |
42 | m_attach = 0l; | 37 | m_attach = 0l; |
43 | } | 38 | } |
44 | return ret; | 39 | return ret; |
45 | } | 40 | } |
46 | 41 | ||
47 | void IOIrda::reload( const Profile &config ) { | 42 | void IOIrda::reload( const Profile &config ) { |
48 | m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); | 43 | m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); |
@@ -57,24 +52,13 @@ void IOIrda::reload( const Profile &config ) { | |||
57 | QString IOIrda::identifier() const { | 52 | QString IOIrda::identifier() const { |
58 | return "irda"; | 53 | return "irda"; |
59 | } | 54 | } |
60 | 55 | ||
61 | QString IOIrda::name() const { | 56 | QString IOIrda::name() const { |
62 | return "Irda IO Layer"; | 57 | return "Irda IO Layer"; |
63 | } | 58 | } |
64 | 59 | ||
65 | void IOIrda::slotExited(OProcess* proc ){ | 60 | void IOIrda::slotExited(Opie::Core::OProcess* proc ){ |
66 | close(); | 61 | close(); |
67 | delete proc; | 62 | delete proc; |
68 | } | 63 | } |
69 | 64 | ||
70 | QBitArray IOIrda::supports()const { | ||
71 | return QBitArray( 3 ); | ||
72 | } | ||
73 | |||
74 | bool IOIrda::isConnected() { | ||
75 | return false; | ||
76 | } | ||
77 | |||
78 | void IOIrda::send(const QByteArray &data) { | ||
79 | odebug << "Please overload me..." << oendl; | ||
80 | } | ||
diff --git a/noncore/apps/opie-console/io_irda.h b/noncore/apps/opie-console/io_irda.h index fb29686..1fdbd4b 100644 --- a/noncore/apps/opie-console/io_irda.h +++ b/noncore/apps/opie-console/io_irda.h | |||
@@ -20,25 +20,22 @@ class IOIrda : public IOSerial { | |||
20 | 20 | ||
21 | public: | 21 | public: |
22 | 22 | ||
23 | IOIrda(const Profile &); | 23 | IOIrda(const Profile &); |
24 | ~IOIrda(); | 24 | ~IOIrda(); |
25 | 25 | ||
26 | virtual QString identifier() const; | 26 | virtual QString identifier() const; |
27 | virtual QString name() const; | 27 | virtual QString name() const; |
28 | virtual QBitArray supports() const; | ||
29 | virtual bool isConnected(); | ||
30 | 28 | ||
31 | signals: | 29 | signals: |
32 | void received(const QByteArray &); | 30 | void received(const QByteArray &); |
33 | void error(int, const QString &); | 31 | void error(int, const QString &); |
34 | 32 | ||
35 | public slots: | 33 | public slots: |
36 | virtual void send( const QByteArray& ); | ||
37 | virtual bool open(); | 34 | virtual bool open(); |
38 | virtual void close(); | 35 | virtual void close(); |
39 | virtual void reload(const Profile &); | 36 | virtual void reload(const Profile &); |
40 | 37 | ||
41 | private: | 38 | private: |
42 | Opie::Core::OProcess *m_attach; | 39 | Opie::Core::OProcess *m_attach; |
43 | 40 | ||
44 | private slots: | 41 | private slots: |
diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp index c499dfe..915a1d2 100644 --- a/noncore/apps/opie-console/io_modem.cpp +++ b/noncore/apps/opie-console/io_modem.cpp | |||
@@ -1,16 +1,12 @@ | |||
1 | 1 | ||
2 | #include "io_modem.h" | 2 | #include "io_modem.h" |
3 | #include "dialer.h" | 3 | #include "dialer.h" |
4 | 4 | ||
5 | /* OPIE */ | ||
6 | #include <opie2/odebug.h> | ||
7 | using namespace Opie::Core; | ||
8 | |||
9 | IOModem::IOModem( const Profile &profile ) | 5 | IOModem::IOModem( const Profile &profile ) |
10 | : IOSerial( profile ) { | 6 | : IOSerial( profile ) { |
11 | m_profile = profile; | 7 | m_profile = profile; |
12 | } | 8 | } |
13 | 9 | ||
14 | 10 | ||
15 | IOModem::~IOModem() { | 11 | IOModem::~IOModem() { |
16 | } | 12 | } |
@@ -83,26 +79,8 @@ void IOModem::reload( const Profile &config ) { | |||
83 | 79 | ||
84 | QString IOModem::identifier() const { | 80 | QString IOModem::identifier() const { |
85 | return "modem"; | 81 | return "modem"; |
86 | } | 82 | } |
87 | 83 | ||
88 | QString IOModem::name() const { | 84 | QString IOModem::name() const { |
89 | return "Modem IO Layer"; | 85 | return "Modem IO Layer"; |
90 | } | 86 | } |
91 | |||
92 | void IOModem::slotExited(OProcess* proc ){ | ||
93 | close(); | ||
94 | /* delete it afterwards */ | ||
95 | delete proc; | ||
96 | } | ||
97 | |||
98 | QBitArray IOModem::supports()const { | ||
99 | return QBitArray( 3 ); | ||
100 | } | ||
101 | |||
102 | bool IOModem::isConnected() { | ||
103 | return false; | ||
104 | } | ||
105 | |||
106 | void IOModem::send(const QByteArray &data) { | ||
107 | odebug << "Please overload me..." << oendl; | ||
108 | } | ||
diff --git a/noncore/apps/opie-console/io_modem.h b/noncore/apps/opie-console/io_modem.h index 5b99e00..056e630 100644 --- a/noncore/apps/opie-console/io_modem.h +++ b/noncore/apps/opie-console/io_modem.h | |||
@@ -40,35 +40,28 @@ class IOModem : public IOSerial { | |||
40 | 40 | ||
41 | public: | 41 | public: |
42 | 42 | ||
43 | IOModem(const Profile &); | 43 | IOModem(const Profile &); |
44 | ~IOModem(); | 44 | ~IOModem(); |
45 | 45 | ||
46 | virtual QString identifier() const; | 46 | virtual QString identifier() const; |
47 | virtual QString name() const; | 47 | virtual QString name() const; |
48 | virtual QBitArray supports() const; | ||
49 | virtual bool isConnected(); | ||
50 | 48 | ||
51 | signals: | 49 | signals: |
52 | void received(const QByteArray &); | 50 | void received(const QByteArray &); |
53 | void error(int, const QString &); | 51 | void error(int, const QString &); |
54 | 52 | ||
55 | public slots: | 53 | public slots: |
56 | virtual void send( const QByteArray& ); | ||
57 | virtual bool open(); | 54 | virtual bool open(); |
58 | virtual void close(); | 55 | virtual void close(); |
59 | virtual void reload(const Profile &); | 56 | virtual void reload(const Profile &); |
60 | 57 | ||
61 | private: | 58 | private: |
62 | 59 | ||
63 | QString m_initString, m_resetString, m_dialPref1, m_dialSuf1, m_dialPref2, | 60 | QString m_initString, m_resetString, m_dialPref1, m_dialSuf1, m_dialPref2, |
64 | m_dialSuf2, m_dialPref3, m_dialSuf3, m_connect, m_hangup, m_cancel; | 61 | m_dialSuf2, m_dialPref3, m_dialSuf3, m_connect, m_hangup, m_cancel; |
65 | int m_dialTime, m_delayRedial, m_numberTries, m_dtrDropTime, | 62 | int m_dialTime, m_delayRedial, m_numberTries, m_dtrDropTime, |
66 | m_bpsDetect, m_dcdLines, m_multiLineUntag; | 63 | m_bpsDetect, m_dcdLines, m_multiLineUntag; |
67 | Profile m_profile; | 64 | Profile m_profile; |
68 | |||
69 | private slots: | ||
70 | void slotExited(Opie::Core::OProcess* proc); | ||
71 | |||
72 | }; | 65 | }; |
73 | 66 | ||
74 | #endif | 67 | #endif |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 291912c..b3cb208 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -7,20 +7,18 @@ | |||
7 | #include "tabwidget.h" | 7 | #include "tabwidget.h" |
8 | #include "transferdialog.h" | 8 | #include "transferdialog.h" |
9 | #include "function_keyboard.h" | 9 | #include "function_keyboard.h" |
10 | #include "emulation_handler.h" | 10 | #include "emulation_handler.h" |
11 | #include "script.h" | 11 | #include "script.h" |
12 | #include "fixit.h" | 12 | #include "fixit.h" |
13 | 13 | ||
14 | /* OPIE */ | 14 | /* OPIE */ |
15 | #include <opie2/odebug.h> | ||
16 | #include <opie2/ofiledialog.h> | 15 | #include <opie2/ofiledialog.h> |
17 | #include <qpe/filemanager.h> | 16 | #include <qpe/filemanager.h> |
18 | using namespace Opie::Core; | ||
19 | using namespace Opie::Ui; | 17 | using namespace Opie::Ui; |
20 | 18 | ||
21 | /* QT */ | 19 | /* QT */ |
22 | #include <qaction.h> | 20 | #include <qaction.h> |
23 | #include <qmenubar.h> | 21 | #include <qmenubar.h> |
24 | #include <qtoolbar.h> | 22 | #include <qtoolbar.h> |
25 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
26 | #include <qwhatsthis.h> | 24 | #include <qwhatsthis.h> |
@@ -476,23 +474,21 @@ void MainWindow::slotConfigure() { | |||
476 | * delete it | 474 | * delete it |
477 | * and set the currentSession() | 475 | * and set the currentSession() |
478 | */ | 476 | */ |
479 | void MainWindow::slotClose() { | 477 | void MainWindow::slotClose() { |
480 | if (!currentSession() ) | 478 | if (!currentSession() ) |
481 | return; | 479 | return; |
482 | 480 | ||
483 | Session* ses = currentSession(); | 481 | Session* ses = currentSession(); |
484 | owarn << "removing! currentSession " << currentSession()->name().latin1() << "" << oendl; | ||
485 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 482 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
486 | m_curSession = NULL; | 483 | m_curSession = NULL; |
487 | tabWidget()->remove( /*currentSession()*/ses ); | 484 | tabWidget()->remove( /*currentSession()*/ses ); |
488 | /*it's autodelete */ | 485 | /*it's autodelete */ |
489 | m_sessions.remove( ses ); | 486 | m_sessions.remove( ses ); |
490 | owarn << "after remove!!" << oendl; | ||
491 | 487 | ||
492 | if (!currentSession() ) { | 488 | if (!currentSession() ) { |
493 | m_connect->setEnabled( false ); | 489 | m_connect->setEnabled( false ); |
494 | m_disconnect->setEnabled( false ); | 490 | m_disconnect->setEnabled( false ); |
495 | m_terminate->setEnabled( false ); | 491 | m_terminate->setEnabled( false ); |
496 | m_transfer->setEnabled( false ); | 492 | m_transfer->setEnabled( false ); |
497 | m_recordScript->setEnabled( false ); | 493 | m_recordScript->setEnabled( false ); |
498 | m_saveScript->setEnabled( false ); | 494 | m_saveScript->setEnabled( false ); |
@@ -599,26 +595,23 @@ void MainWindow::slotOpenButtons( bool state ) { | |||
599 | } else { | 595 | } else { |
600 | m_buttonBar->hide(); | 596 | m_buttonBar->hide(); |
601 | } | 597 | } |
602 | } | 598 | } |
603 | 599 | ||
604 | 600 | ||
605 | 601 | ||
606 | void MainWindow::slotSessionChanged( Session* ses ) { | 602 | void MainWindow::slotSessionChanged( Session* ses ) { |
607 | owarn << "changed!" << oendl; | ||
608 | |||
609 | if(m_curSession) | 603 | if(m_curSession) |
610 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 604 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
611 | if(ses) | 605 | if(ses) |
612 | if(ses->transferDialog()) ses->transferDialog()->show(); | 606 | if(ses->transferDialog()) ses->transferDialog()->show(); |
613 | 607 | ||
614 | if ( ses ) { | 608 | if ( ses ) { |
615 | m_curSession = ses; | 609 | m_curSession = ses; |
616 | odebug << QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) << oendl; | ||
617 | if ( m_curSession->layer()->isConnected() ) { | 610 | if ( m_curSession->layer()->isConnected() ) { |
618 | m_connect->setEnabled( false ); | 611 | m_connect->setEnabled( false ); |
619 | m_disconnect->setEnabled( true ); | 612 | m_disconnect->setEnabled( true ); |
620 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); | 613 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); |
621 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); | 614 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); |
622 | m_scripts->setItemEnabled(m_runScript_id, true); | 615 | m_scripts->setItemEnabled(m_runScript_id, true); |
623 | } else { | 616 | } else { |
624 | m_connect->setEnabled( true ); | 617 | m_connect->setEnabled( true ); |
diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp index b2f5c68..eb4bd0d 100644 --- a/noncore/apps/opie-console/modemconfigwidget.cpp +++ b/noncore/apps/opie-console/modemconfigwidget.cpp | |||
@@ -1,36 +1,22 @@ | |||
1 | #include "modemconfigwidget.h" | 1 | #include "modemconfigwidget.h" |
2 | #include "dialdialog.h" | 2 | #include "dialdialog.h" |
3 | #include "comboboxhelper.h" | ||
3 | 4 | ||
4 | /* OPIE */ | 5 | /* OPIE */ |
5 | #include <opie2/odebug.h> | ||
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | using namespace Opie::Core; | ||
8 | 7 | ||
9 | /* QT */ | 8 | /* QT */ |
10 | #include <qlabel.h> | 9 | #include <qlabel.h> |
11 | #include <qlayout.h> | 10 | #include <qlayout.h> |
12 | #include <qcombobox.h> | 11 | #include <qcombobox.h> |
13 | #include <qpushbutton.h> | 12 | #include <qpushbutton.h> |
14 | #include <qhbox.h> | 13 | #include <qhbox.h> |
15 | 14 | ||
16 | namespace { | ||
17 | void setCurrent( const QString& str, QComboBox* bo ) { | ||
18 | uint b = bo->count(); | ||
19 | for (int i = 0; i < bo->count(); i++ ) { | ||
20 | if ( bo->text(i) == str ) { | ||
21 | bo->setCurrentItem( i ); | ||
22 | return; | ||
23 | } | ||
24 | } | ||
25 | bo->insertItem( str ); | ||
26 | bo->setCurrentItem( b ); | ||
27 | } | ||
28 | } | ||
29 | 15 | ||
30 | ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, | 16 | ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, |
31 | const char* na ) | 17 | const char* na ) |
32 | : ProfileDialogConnectionWidget( name, parent, na ) { | 18 | : ProfileDialogConnectionWidget( name, parent, na ) { |
33 | 19 | ||
34 | m_lay = new QVBoxLayout( this ); | 20 | m_lay = new QVBoxLayout( this ); |
35 | m_device = new QLabel(tr( "Modem is attached to:" ), this ); | 21 | m_device = new QLabel(tr( "Modem is attached to:" ), this ); |
36 | m_deviceCmb = new QComboBox(this ); | 22 | m_deviceCmb = new QComboBox(this ); |
@@ -141,20 +127,19 @@ void ModemConfigWidget::load( const Profile& prof ) { | |||
141 | m_base->setStop( IOLayerBase::Stop_OnePointFive ); | 127 | m_base->setStop( IOLayerBase::Stop_OnePointFive ); |
142 | } else { | 128 | } else { |
143 | m_base->setStop( IOLayerBase::Stop_One ); | 129 | m_base->setStop( IOLayerBase::Stop_One ); |
144 | } | 130 | } |
145 | 131 | ||
146 | 132 | ||
147 | atConf->readConfig( prof ); | 133 | atConf->readConfig( prof ); |
148 | if ( prof.readEntry( "Device" ).isEmpty() ) { | 134 | if ( prof.readEntry( "Device" ).isEmpty() ) { |
149 | owarn << "device empty!" << oendl; | ||
150 | return; | 135 | return; |
151 | } | 136 | } |
152 | setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); | 137 | ComboboxHelper::setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); |
153 | 138 | ||
154 | 139 | ||
155 | } | 140 | } |
156 | 141 | ||
157 | /* | 142 | /* |
158 | * save speed, | 143 | * save speed, |
159 | * flow, | 144 | * flow, |
160 | * parity | 145 | * parity |
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro index d947eec..a7b9d5f 100644 --- a/noncore/apps/opie-console/opie-console.pro +++ b/noncore/apps/opie-console/opie-console.pro | |||
@@ -23,17 +23,18 @@ HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \ | |||
23 | function_keyboard.h \ | 23 | function_keyboard.h \ |
24 | receive_layer.h filereceive.h \ | 24 | receive_layer.h filereceive.h \ |
25 | script.h \ | 25 | script.h \ |
26 | dialer.h logger.h \ | 26 | dialer.h logger.h \ |
27 | terminalwidget.h \ | 27 | terminalwidget.h \ |
28 | emulation_handler.h TECommon.h \ | 28 | emulation_handler.h TECommon.h \ |
29 | TEHistory.h TEScreen.h TEWidget.h \ | 29 | TEHistory.h TEScreen.h TEWidget.h \ |
30 | TEmuVt102.h TEmulation.h MyPty.h \ | 30 | TEmuVt102.h TEmulation.h MyPty.h \ |
31 | consoleconfigwidget.h fixit.h | 31 | consoleconfigwidget.h fixit.h \ |
32 | comboboxhelper.h | ||
32 | 33 | ||
33 | SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ | 34 | SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ |
34 | file_layer.cpp filetransfer.cpp \ | 35 | file_layer.cpp filetransfer.cpp \ |
35 | main.cpp \ | 36 | main.cpp \ |
36 | metafactory.cpp \ | 37 | metafactory.cpp \ |
37 | session.cpp \ | 38 | session.cpp \ |
38 | mainwindow.cpp \ | 39 | mainwindow.cpp \ |
39 | profile.cpp \ | 40 | profile.cpp \ |
@@ -53,22 +54,23 @@ SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ | |||
53 | function_keyboard.cpp \ | 54 | function_keyboard.cpp \ |
54 | receive_layer.cpp filereceive.cpp \ | 55 | receive_layer.cpp filereceive.cpp \ |
55 | script.cpp \ | 56 | script.cpp \ |
56 | dialer.cpp logger.cpp \ | 57 | dialer.cpp logger.cpp \ |
57 | terminalwidget.cpp \ | 58 | terminalwidget.cpp \ |
58 | emulation_handler.cpp TEHistory.cpp \ | 59 | emulation_handler.cpp TEHistory.cpp \ |
59 | TEScreen.cpp TEWidget.cpp \ | 60 | TEScreen.cpp TEWidget.cpp \ |
60 | TEmuVt102.cpp TEmulation.cpp MyPty.cpp \ | 61 | TEmuVt102.cpp TEmulation.cpp MyPty.cpp \ |
61 | consoleconfigwidget.cpp fixit.cpp | 62 | consoleconfigwidget.cpp fixit.cpp \ |
63 | comboboxhelper.cpp | ||
62 | 64 | ||
63 | 65 | ||
64 | DESTDIR = $(OPIEDIR)/bin/ | 66 | DESTDIR = $(OPIEDIR)/bin/ |
65 | INTERFACES = configurebase.ui editbase.ui | 67 | INTERFACES = configurebase.ui editbase.ui |
66 | INCLUDEPATH += $(OPIEDIR)/include | 68 | INCLUDEPATH += $(OPIEDIR)/include |
67 | DEPENDPATH += $(OPIEDIR)/include | 69 | DEPENDPATH += $(OPIEDIR)/include |
68 | LIBS += -lqpe -lopiecore2 -lopieui2 -lutil | 70 | LIBS += -lqpe -lopiecore2 -lopieui2 -lutil |
69 | TARGET = opie-console | 71 | TARGET = opie-console |
70 | 72 | ||
71 | DEFINES += HAVE_OPENPTY | 73 | DEFINES += HAVE_OPENPTY |
72 | #DEFINES += EAST FSCKED_DISTRI | 74 | DEFINES += EAST FSCKED_DISTRI |
73 | 75 | ||
74 | include ( $(OPIEDIR)/include.pro ) | 76 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index dc42d8b..8109070 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp | |||
@@ -1,29 +1,25 @@ | |||
1 | #include "profileeditordialog.h" | ||
2 | #include "metafactory.h" | ||
3 | #include "comboboxhelper.h" | ||
4 | |||
5 | |||
1 | #include <qlayout.h> | 6 | #include <qlayout.h> |
2 | #include <qlineedit.h> | 7 | #include <qlineedit.h> |
3 | #include <qlabel.h> | 8 | #include <qlabel.h> |
4 | #include <qmessagebox.h> | 9 | #include <qmessagebox.h> |
5 | #include <qcombobox.h> | 10 | #include <qcombobox.h> |
6 | #include <qcheckbox.h> | 11 | #include <qcheckbox.h> |
7 | #include <qscrollview.h> | 12 | #include <qscrollview.h> |
8 | 13 | ||
9 | #include "metafactory.h" | 14 | |
10 | #include "profileeditordialog.h" | ||
11 | 15 | ||
12 | using namespace Opie::Ui; | 16 | using namespace Opie::Ui; |
13 | namespace { | 17 | |
14 | void setCurrent( const QString& str, QComboBox* bo ) { | ||
15 | for (int i = 0; i < bo->count(); i++ ) { | ||
16 | if ( bo->text(i) == str ) { | ||
17 | bo->setCurrentItem( i ); | ||
18 | } | ||
19 | } | ||
20 | }; | ||
21 | } | ||
22 | 18 | ||
23 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, | 19 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, |
24 | const Profile& prof ) | 20 | const Profile& prof ) |
25 | : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) | 21 | : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) |
26 | { | 22 | { |
27 | initUI(); | 23 | initUI(); |
28 | 24 | ||
29 | // Apply current profile | 25 | // Apply current profile |
@@ -119,18 +115,18 @@ void ProfileEditorDialog::initUI() | |||
119 | list = m_fact->terminalWidgets(); | 115 | list = m_fact->terminalWidgets(); |
120 | for (it =list.begin(); it != list.end(); ++it ) { | 116 | for (it =list.begin(); it != list.end(); ++it ) { |
121 | m_termCmb->insertItem( (*it) ); | 117 | m_termCmb->insertItem( (*it) ); |
122 | } | 118 | } |
123 | 119 | ||
124 | // load profile values | 120 | // load profile values |
125 | m_name->setText(m_prof.name()); | 121 | m_name->setText(m_prof.name()); |
126 | slotKeyActivated( "Default Keyboard" ); | 122 | slotKeyActivated( "Default Keyboard" ); |
127 | setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); | 123 | ComboboxHelper::setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); |
128 | setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); | 124 | ComboboxHelper::setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); |
129 | slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); | 125 | slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); |
130 | slotTermActivated( m_fact->external(m_prof.terminalName() ) ); | 126 | slotTermActivated( m_fact->external(m_prof.terminalName() ) ); |
131 | m_autoConnect->setChecked(m_prof.autoConnect()); | 127 | m_autoConnect->setChecked(m_prof.autoConnect()); |
132 | 128 | ||
133 | 129 | ||
134 | // signal and slots | 130 | // signal and slots |
135 | connect(m_conCmb, SIGNAL(activated(const QString&) ), | 131 | connect(m_conCmb, SIGNAL(activated(const QString&) ), |
136 | this, SLOT(slotConActivated(const QString&) ) ); | 132 | this, SLOT(slotConActivated(const QString&) ) ); |
diff --git a/noncore/apps/opie-console/serialconfigwidget.cpp b/noncore/apps/opie-console/serialconfigwidget.cpp index c4c9c99..4efb286 100644 --- a/noncore/apps/opie-console/serialconfigwidget.cpp +++ b/noncore/apps/opie-console/serialconfigwidget.cpp | |||
@@ -1,30 +1,17 @@ | |||
1 | #include <qlabel.h> | ||
2 | #include <qlayout.h> | ||
3 | #include <qcombobox.h> | ||
4 | |||
5 | #include "iolayerbase.h" | 1 | #include "iolayerbase.h" |
6 | #include "serialconfigwidget.h" | 2 | #include "serialconfigwidget.h" |
3 | #include "comboboxhelper.h" | ||
7 | 4 | ||
8 | namespace { | 5 | #include <qlabel.h> |
9 | void setCurrent( const QString& str, QComboBox* bo ) { | 6 | #include <qlayout.h> |
10 | uint b = bo->count(); | 7 | #include <qcombobox.h> |
11 | for (int i = 0; i < bo->count(); i++ ) { | ||
12 | if ( bo->text(i) == str ) { | ||
13 | bo->setCurrentItem( i ); | ||
14 | return; | ||
15 | } | ||
16 | } | ||
17 | bo->insertItem( str ); | ||
18 | bo->setCurrentItem( b ); | ||
19 | } | ||
20 | 8 | ||
21 | 9 | ||
22 | } | ||
23 | 10 | ||
24 | SerialConfigWidget::SerialConfigWidget( const QString& name, | 11 | SerialConfigWidget::SerialConfigWidget( const QString& name, |
25 | QWidget* parent, | 12 | QWidget* parent, |
26 | const char* na ) | 13 | const char* na ) |
27 | : ProfileDialogConnectionWidget( name, parent, na ) { | 14 | : ProfileDialogConnectionWidget( name, parent, na ) { |
28 | 15 | ||
29 | m_lay = new QVBoxLayout(this ); | 16 | m_lay = new QVBoxLayout(this ); |
30 | m_device = new QLabel(tr("Device"), this ); | 17 | m_device = new QLabel(tr("Device"), this ); |
@@ -111,17 +98,17 @@ void SerialConfigWidget::load( const Profile& prof ) { | |||
111 | m_base->setStop( IOLayerBase::Stop_Two ); | 98 | m_base->setStop( IOLayerBase::Stop_Two ); |
112 | } else if ( sbits == 15 ) { | 99 | } else if ( sbits == 15 ) { |
113 | m_base->setStop( IOLayerBase::Stop_OnePointFive ); | 100 | m_base->setStop( IOLayerBase::Stop_OnePointFive ); |
114 | } else { | 101 | } else { |
115 | m_base->setStop( IOLayerBase::Stop_One ); | 102 | m_base->setStop( IOLayerBase::Stop_One ); |
116 | } | 103 | } |
117 | 104 | ||
118 | if ( prof.readEntry("Device").isEmpty() ) return; | 105 | if ( prof.readEntry("Device").isEmpty() ) return; |
119 | setCurrent( prof.readEntry("Device"), m_deviceCmb ); | 106 | ComboboxHelper::setCurrent( prof.readEntry("Device"), m_deviceCmb ); |
120 | 107 | ||
121 | } | 108 | } |
122 | /* | 109 | /* |
123 | * save speed, | 110 | * save speed, |
124 | * flow, | 111 | * flow, |
125 | * parity | 112 | * parity |
126 | */ | 113 | */ |
127 | void SerialConfigWidget::save( Profile& prof ) { | 114 | void SerialConfigWidget::save( Profile& prof ) { |
diff --git a/noncore/apps/opie-console/settings.ui b/noncore/apps/opie-console/settings.ui deleted file mode 100644 index 6944dd0..0000000 --- a/noncore/apps/opie-console/settings.ui +++ b/dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>Settings</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>Settings</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>596</width> | ||
15 | <height>480</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Settings</string> | ||
21 | </property> | ||
22 | </widget> | ||
23 | </UI> | ||
diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp index f505998..3299e33 100644 --- a/noncore/apps/opie-console/sz_transfer.cpp +++ b/noncore/apps/opie-console/sz_transfer.cpp | |||
@@ -35,52 +35,35 @@ void SzTransfer::sendFile(const QString& file) { | |||
35 | this, SLOT(SzReceivedStderr(Opie::Core::OProcess*,char*,int))); | 35 | this, SLOT(SzReceivedStderr(Opie::Core::OProcess*,char*,int))); |
36 | connect(layer(), SIGNAL(received(const QByteArray&)), | 36 | connect(layer(), SIGNAL(received(const QByteArray&)), |
37 | this, SLOT(receivedStdin(const QByteArray&))); | 37 | this, SLOT(receivedStdin(const QByteArray&))); |
38 | proc->start(OProcess::NotifyOnExit, OProcess::All); | 38 | proc->start(OProcess::NotifyOnExit, OProcess::All); |
39 | 39 | ||
40 | } | 40 | } |
41 | 41 | ||
42 | void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { | 42 | void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { |
43 | |||
44 | owarn << "recieved from sz on stdout " << buflen << " bytes" << oendl; | ||
45 | |||
46 | QByteArray data(buflen); | 43 | QByteArray data(buflen); |
47 | data.fill(*buffer, buflen); | 44 | data.fill(*buffer, buflen); |
45 | |||
46 | #ifdef DEBUG_RECEIVE | ||
48 | for (uint i = 0; i < data.count(); i++ ) { | 47 | for (uint i = 0; i < data.count(); i++ ) { |
49 | printf("%c", buffer[i] ); | 48 | printf("%c", buffer[i] ); |
50 | } | 49 | } |
51 | printf("\n"); | 50 | printf("\n"); |
51 | #endif | ||
52 | 52 | ||
53 | // send out through the io layer | 53 | // send out through the io layer |
54 | layer()->send(data); | 54 | layer()->send(data); |
55 | } | 55 | } |
56 | 56 | ||
57 | void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) { | 57 | void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) { |
58 | |||
59 | // parse and show data in a progress dialog/widget | ||
60 | printf("stderr:\n"); | ||
61 | //for (int i = 0; i < length; i++) | ||
62 | // printf("%c", buffer[i]); | ||
63 | //printf("\n"); | ||
64 | } | 58 | } |
65 | 59 | ||
66 | void SzTransfer::receivedStdin(const QByteArray &data) { | 60 | void SzTransfer::receivedStdin(const QByteArray &data) { |
67 | |||
68 | owarn << "recieved from io_serial " << data.size() << " bytes" << oendl; | ||
69 | |||
70 | // recieved data from the io layer goes to sz | 61 | // recieved data from the io layer goes to sz |
71 | proc->writeStdin(data.data(), data.size()); | 62 | proc->writeStdin(data.data(), data.size()); |
72 | |||
73 | } | 63 | } |
74 | 64 | ||
75 | void SzTransfer::sent() { | 65 | void SzTransfer::sent() { |
76 | |||
77 | owarn << "sent file" << oendl; | ||
78 | |||
79 | //setcbreak(0); /* default */ | ||
80 | |||
81 | |||
82 | delete proc; | 66 | delete proc; |
83 | disconnect(layer(), SIGNAL(received(const QByteArray&)), | 67 | disconnect(layer(), SIGNAL(received(const QByteArray&)), |
84 | this, SLOT(receivedStdin(const QByteArray&))); | 68 | this, SLOT(receivedStdin(const QByteArray&))); |
85 | |||
86 | } | 69 | } |
diff --git a/noncore/apps/opie-console/tabwidget.cpp b/noncore/apps/opie-console/tabwidget.cpp index 152c26b..79ccac5 100644 --- a/noncore/apps/opie-console/tabwidget.cpp +++ b/noncore/apps/opie-console/tabwidget.cpp | |||
@@ -1,28 +1,24 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include "tabwidget.h" | 3 | #include "tabwidget.h" |
4 | 4 | ||
5 | /* OPIE */ | ||
6 | #include <opie2/odebug.h> | ||
7 | using namespace Opie::Core; | ||
8 | using Opie::Ui::OTabWidget; | 5 | using Opie::Ui::OTabWidget; |
9 | 6 | ||
10 | TabWidget::TabWidget( QWidget* parent, const char* name ) | 7 | TabWidget::TabWidget( QWidget* parent, const char* name ) |
11 | : OTabWidget( parent, name ) { | 8 | : OTabWidget( parent, name ) { |
12 | connect(this, SIGNAL( currentChanged(QWidget*) ), | 9 | connect(this, SIGNAL( currentChanged(QWidget*) ), |
13 | this, SLOT( slotCurChanged(QWidget*) ) ); | 10 | this, SLOT( slotCurChanged(QWidget*) ) ); |
14 | } | 11 | } |
15 | 12 | ||
16 | TabWidget::~TabWidget() { | 13 | TabWidget::~TabWidget() { |
17 | } | 14 | } |
18 | 15 | ||
19 | void TabWidget::add( Session* ses ) { | 16 | void TabWidget::add( Session* ses ) { |
20 | owarn << "session ses " + ses->name() << oendl; | ||
21 | if ( !ses->widgetStack() ) return; | 17 | if ( !ses->widgetStack() ) return; |
22 | //reparent( ses->widgetStack(), QPoint() ); | 18 | //reparent( ses->widgetStack(), QPoint() ); |
23 | addTab( ses->widgetStack(), "console/konsole", ses->name() ); | 19 | addTab( ses->widgetStack(), "console/konsole", ses->name() ); |
24 | //addTab( ses->widgetStack(), ses->name() ); | 20 | //addTab( ses->widgetStack(), ses->name() ); |
25 | m_map.insert( ses->widgetStack(), ses ); | 21 | m_map.insert( ses->widgetStack(), ses ); |
26 | } | 22 | } |
27 | 23 | ||
28 | void TabWidget::remove( Session* ses ) { | 24 | void TabWidget::remove( Session* ses ) { |
diff --git a/noncore/apps/opie-console/terminalwidget.cpp b/noncore/apps/opie-console/terminalwidget.cpp index 3e3b8a6..907de1b 100644 --- a/noncore/apps/opie-console/terminalwidget.cpp +++ b/noncore/apps/opie-console/terminalwidget.cpp | |||
@@ -1,15 +1,10 @@ | |||
1 | #include "terminalwidget.h" | 1 | #include "terminalwidget.h" |
2 | 2 | ||
3 | /* OPIE */ | ||
4 | #include <opie2/odebug.h> | ||
5 | |||
6 | using namespace Opie::Core; | ||
7 | |||
8 | /* QT */ | 3 | /* QT */ |
9 | #include <qlabel.h> | 4 | #include <qlabel.h> |
10 | #include <qcheckbox.h> | 5 | #include <qcheckbox.h> |
11 | #include <qcombobox.h> | 6 | #include <qcombobox.h> |
12 | #include <qradiobutton.h> | 7 | #include <qradiobutton.h> |
13 | #include <qhgroupbox.h> | 8 | #include <qhgroupbox.h> |
14 | #include <qhbuttongroup.h> | 9 | #include <qhbuttongroup.h> |
15 | #include <qlayout.h> | 10 | #include <qlayout.h> |
@@ -75,17 +70,16 @@ TerminalWidget::TerminalWidget( const QString& name, QWidget* parent, | |||
75 | m_colorBox->add( m_colorLabel ); | 70 | m_colorBox->add( m_colorLabel ); |
76 | m_colorBox->add( m_colorCmb ); | 71 | m_colorBox->add( m_colorCmb ); |
77 | 72 | ||
78 | m_lroot->add( m_groupConv ); | 73 | m_lroot->add( m_groupConv ); |
79 | m_lroot->add( m_groupOptions ); | 74 | m_lroot->add( m_groupOptions ); |
80 | m_lroot->addStretch( 0 ); | 75 | m_lroot->addStretch( 0 ); |
81 | 76 | ||
82 | // Fill in some options | 77 | // Fill in some options |
83 | owarn << "Options for terminal box" << oendl; | ||
84 | m_terminalBox->insertItem( tr("VT 100"), 0 ); // /*, id_term_vt100*/ ); | 78 | m_terminalBox->insertItem( tr("VT 100"), 0 ); // /*, id_term_vt100*/ ); |
85 | m_terminalBox->insertItem( tr("VT 102"), 1 ); // /* , id_term_vt102 */); | 79 | m_terminalBox->insertItem( tr("VT 102"), 1 ); // /* , id_term_vt102 */); |
86 | m_terminalBox->insertItem( tr("Linux Console"), 2 ); //, id_term_linux ); | 80 | m_terminalBox->insertItem( tr("Linux Console"), 2 ); //, id_term_linux ); |
87 | m_terminalBox->insertItem( tr("X-Terminal"), 3 ); //, id_term_xterm ); | 81 | m_terminalBox->insertItem( tr("X-Terminal"), 3 ); //, id_term_xterm ); |
88 | //m_terminalBox->insertItem( tr("ANSI"), id_term_ansi ); | 82 | //m_terminalBox->insertItem( tr("ANSI"), id_term_ansi ); |
89 | 83 | ||
90 | m_colorCmb->insertItem( tr("black on white"), id_term_black ); | 84 | m_colorCmb->insertItem( tr("black on white"), id_term_black ); |
91 | m_colorCmb->insertItem( tr("white on black"), id_term_white ); | 85 | m_colorCmb->insertItem( tr("white on black"), id_term_white ); |
diff --git a/noncore/apps/opie-console/vt102emulation.cpp b/noncore/apps/opie-console/vt102emulation.cpp deleted file mode 100644 index 35b789c..0000000 --- a/noncore/apps/opie-console/vt102emulation.cpp +++ b/dev/null | |||
@@ -1,1024 +0,0 @@ | |||
1 | /* ------------------------------------------------------------------------- */ | ||
2 | /* */ | ||
3 | /* [vt102emulation.cpp] VT102 Terminal Emulation */ | ||
4 | /* */ | ||
5 | /* ------------------------------------------------------------------------- */ | ||
6 | /* */ | ||
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | ||
8 | /* */ | ||
9 | /* This file is part of Konsole - an X terminal for KDE */ | ||
10 | /* */ | ||
11 | /* ------------------------------------------------------------------------- */ | ||
12 | /* */ | ||
13 | /* Ported Konsole to Qt/Embedded */ | ||
14 | /* */ | ||
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | ||
16 | /* */ | ||
17 | /* -------------------------------------------------------------------------- */ | ||
18 | |||
19 | /*! \class Vt102Emulation | ||
20 | |||
21 | \brief Actual Emulation for Konsole | ||
22 | |||
23 | \sa Widget \sa Screen \sa EmulationLayer | ||
24 | */ | ||
25 | |||
26 | #include "vt102emulation.h" | ||
27 | |||
28 | #include <stdio.h> | ||
29 | #include <unistd.h> | ||
30 | |||
31 | |||
32 | /* VT102 Terminal Emulation | ||
33 | |||
34 | This class puts together the screens, the pty and the widget to a | ||
35 | complete terminal emulation. Beside combining it's componentes, it | ||
36 | handles the emulations's protocol. | ||
37 | |||
38 | This module consists of the following sections: | ||
39 | |||
40 | - Constructor/Destructor | ||
41 | - Incoming Bytes Event pipeline | ||
42 | - Outgoing Bytes | ||
43 | - Mouse Events | ||
44 | - Keyboard Events | ||
45 | - Modes and Charset State | ||
46 | - Diagnostics | ||
47 | */ | ||
48 | |||
49 | |||
50 | /* ------------------------------------------------------------------------- */ | ||
51 | /* */ | ||
52 | /* Constructor / Destructor */ | ||
53 | /* */ | ||
54 | /* ------------------------------------------------------------------------- */ | ||
55 | |||
56 | /* | ||
57 | Nothing really intesting happens here. | ||
58 | */ | ||
59 | |||
60 | /*! | ||
61 | */ | ||
62 | |||
63 | Vt102Emulation::Vt102Emulation(WidgetLayer* gui) : EmulationLayer(gui) | ||
64 | { | ||
65 | QObject::connect(gui,SIGNAL(mouseSignal(int,int,int)), | ||
66 | this,SLOT(onMouse(int,int,int))); | ||
67 | initTokenizer(); | ||
68 | reset(); | ||
69 | } | ||
70 | |||
71 | /*! | ||
72 | */ | ||
73 | |||
74 | Vt102Emulation::~Vt102Emulation() | ||
75 | { | ||
76 | } | ||
77 | |||
78 | /*! | ||
79 | */ | ||
80 | |||
81 | void Vt102Emulation::reset() | ||
82 | { | ||
83 | resetToken(); | ||
84 | resetModes(); | ||
85 | resetCharset(0); screen[0]->reset(); | ||
86 | resetCharset(1); screen[0]->reset(); | ||
87 | setCodec(0); | ||
88 | setKeytrans("linux.keytab"); | ||
89 | } | ||
90 | |||
91 | /* ------------------------------------------------------------------------- */ | ||
92 | /* */ | ||
93 | /* Processing the incoming byte stream */ | ||
94 | /* */ | ||
95 | /* ------------------------------------------------------------------------- */ | ||
96 | |||
97 | /* Incoming Bytes Event pipeline | ||
98 | |||
99 | This section deals with decoding the incoming character stream. | ||
100 | Decoding means here, that the stream is first seperated into `tokens' | ||
101 | which are then mapped to a `meaning' provided as operations by the | ||
102 | `TEScreen' class or by the emulation class itself. | ||
103 | |||
104 | The pipeline proceeds as follows: | ||
105 | |||
106 | - Tokenizing the ESC codes (onRcvChar) | ||
107 | - VT100 code page translation of plain characters (applyCharset) | ||
108 | - Interpretation of ESC codes (tau) | ||
109 | |||
110 | The escape codes and their meaning are described in the | ||
111 | technical reference of this program. | ||
112 | */ | ||
113 | |||
114 | // Tokens ------------------------------------------------------------------ -- | ||
115 | |||
116 | /* | ||
117 | Since the tokens are the central notion if this section, we've put them | ||
118 | in front. They provide the syntactical elements used to represent the | ||
119 | terminals operations as byte sequences. | ||
120 | |||
121 | They are encodes here into a single machine word, so that we can later | ||
122 | switch over them easily. Depending on the token itself, additional | ||
123 | argument variables are filled with parameter values. | ||
124 | |||
125 | The tokens are defined below: | ||
126 | |||
127 | - CHR - Printable characters (32..255 but DEL (=127)) | ||
128 | - CTL - Control characters (0..31 but ESC (= 27), DEL) | ||
129 | - ESC - Escape codes of the form <ESC><CHR but `[]()+*#'> | ||
130 | - ESC_DE - Escape codes of the form <ESC><any of `()+*#%'> C | ||
131 | - CSI_PN - Escape codes of the form <ESC>'[' {Pn} ';' {Pn} C | ||
132 | - CSI_PS - Escape codes of the form <ESC>'[' {Pn} ';' ... C | ||
133 | - CSI_PR - Escape codes of the form <ESC>'[' '?' {Pn} ';' ... C | ||
134 | - VT52 - VT52 escape codes | ||
135 | - <ESC><Chr> | ||
136 | - <ESC>'Y'{Pc}{Pc} | ||
137 | - XTE_HA - Xterm hacks <ESC>`]' {Pn} `;' {Text} <BEL> | ||
138 | note that this is handled differently | ||
139 | |||
140 | The last two forms allow list of arguments. Since the elements of | ||
141 | the lists are treated individually the same way, they are passed | ||
142 | as individual tokens to the interpretation. Further, because the | ||
143 | meaning of the parameters are names (althought represented as numbers), | ||
144 | they are includes within the token ('N'). | ||
145 | |||
146 | */ | ||
147 | |||
148 | #define TY_CONSTR(T,A,N) ( ((((int)N) & 0xffff) << 16) | ((((int)A) & 0xff) << 8) | (((int)T) & 0xff) ) | ||
149 | |||
150 | #define TY_CHR___( ) TY_CONSTR(0,0,0) | ||
151 | #define TY_CTL___(A ) TY_CONSTR(1,A,0) | ||
152 | #define TY_ESC___(A ) TY_CONSTR(2,A,0) | ||
153 | #define TY_ESC_CS(A,B) TY_CONSTR(3,A,B) | ||
154 | #define TY_ESC_DE(A ) TY_CONSTR(4,A,0) | ||
155 | #define TY_CSI_PS(A,N) TY_CONSTR(5,A,N) | ||
156 | #define TY_CSI_PN(A ) TY_CONSTR(6,A,0) | ||
157 | #define TY_CSI_PR(A,N) TY_CONSTR(7,A,N) | ||
158 | |||
159 | #define TY_VT52__(A ) TY_CONSTR(8,A,0) | ||
160 | |||
161 | // Tokenizer --------------------------------------------------------------- -- | ||
162 | |||
163 | /* The tokenizers state | ||
164 | |||
165 | The state is represented by the buffer (pbuf, ppos), | ||
166 | and accompanied by decoded arguments kept in (argv,argc). | ||
167 | Note that they are kept internal in the tokenizer. | ||
168 | */ | ||
169 | |||
170 | void Vt102Emulation::resetToken() | ||
171 | { | ||
172 | ppos = 0; argc = 0; argv[0] = 0; argv[1] = 0; | ||
173 | } | ||
174 | |||
175 | void Vt102Emulation::addDigit(int dig) | ||
176 | { | ||
177 | argv[argc] = 10*argv[argc] + dig; | ||
178 | } | ||
179 | |||
180 | void Vt102Emulation::addArgument() | ||
181 | { | ||
182 | argc = QMIN(argc+1,MAXARGS-1); | ||
183 | argv[argc] = 0; | ||
184 | } | ||
185 | |||
186 | void Vt102Emulation::pushToToken(int cc) | ||
187 | { | ||
188 | pbuf[ppos] = cc; | ||
189 | ppos = QMIN(ppos+1,MAXPBUF-1); | ||
190 | } | ||
191 | |||
192 | // Character Classes used while decoding | ||
193 | |||
194 | #define CTL 1 | ||
195 | #define CHR 2 | ||
196 | #define CPN 4 | ||
197 | #define DIG 8 | ||
198 | #define SCS 16 | ||
199 | #define GRP 32 | ||
200 | |||
201 | void Vt102Emulation::initTokenizer() | ||
202 | { int i; UINT8* s; | ||
203 | for(i = 0; i < 256; i++) tbl[ i] = 0; | ||
204 | for(i = 0; i < 32; i++) tbl[ i] |= CTL; | ||
205 | for(i = 32; i < 256; i++) tbl[ i] |= CHR; | ||
206 | for(s = (UINT8*)"@ABCDGHLMPXcdfry"; *s; s++) tbl[*s] |= CPN; | ||
207 | for(s = (UINT8*)"0123456789" ; *s; s++) tbl[*s] |= DIG; | ||
208 | for(s = (UINT8*)"()+*%" ; *s; s++) tbl[*s] |= SCS; | ||
209 | for(s = (UINT8*)"()+*#[]%" ; *s; s++) tbl[*s] |= GRP; | ||
210 | resetToken(); | ||
211 | } | ||
212 | |||
213 | /* Ok, here comes the nasty part of the decoder. | ||
214 | |||
215 | Instead of keeping an explicit state, we deduce it from the | ||
216 | token scanned so far. It is then immediately combined with | ||
217 | the current character to form a scanning decision. | ||
218 | |||
219 | This is done by the following defines. | ||
220 | |||
221 | - P is the length of the token scanned so far. | ||
222 | - L (often P-1) is the position on which contents we base a decision. | ||
223 | - C is a character or a group of characters (taken from 'tbl'). | ||
224 | |||
225 | Note that they need to applied in proper order. | ||
226 | */ | ||
227 | |||
228 | #define lec(P,L,C) (p == (P) && s[(L)] == (C)) | ||
229 | #define lun( ) (p == 1 && cc >= 32 ) | ||
230 | #define les(P,L,C) (p == (P) && s[L] < 256 && (tbl[s[(L)]] & (C)) == (C)) | ||
231 | #define eec(C) (p >= 3 && cc == (C)) | ||
232 | #define ees(C) (p >= 3 && cc < 256 && (tbl[ cc ] & (C)) == (C)) | ||
233 | #define eps(C) (p >= 3 && s[2] != '?' && cc < 256 && (tbl[ cc ] & (C)) == (C)) | ||
234 | #define epp( ) (p >= 3 && s[2] == '?' ) | ||
235 | #define egt( ) (p == 3 && s[2] == '>' ) | ||
236 | #define Xpe (ppos>=2 && pbuf[1] == ']' ) | ||
237 | #define Xte (Xpe && cc == 7 ) | ||
238 | #define ces(C) ( cc < 256 && (tbl[ cc ] & (C)) == (C) && !Xte) | ||
239 | |||
240 | #define ESC 27 | ||
241 | #define CNTL(c) ((c)-'@') | ||
242 | |||
243 | // process an incoming unicode character | ||
244 | |||
245 | void Vt102Emulation::onRcvChar(int cc) | ||
246 | { int i; | ||
247 | |||
248 | if (cc == 127) return; //VT100: ignore. | ||
249 | |||
250 | if (ces( CTL)) | ||
251 | { // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100 | ||
252 | // This means, they do neither a resetToken nor a pushToToken. Some of them, do | ||
253 | // of course. Guess this originates from a weakly layered handling of the X-on | ||
254 | // X-off protocol, which comes really below this level. | ||
255 | if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC) resetToken(); //VT100: CAN or SUB | ||
256 | if (cc != ESC) { tau( TY_CTL___(cc+'@' ), 0, 0); return; } | ||
257 | } | ||
258 | |||
259 | pushToToken(cc); // advance the state | ||
260 | |||
261 | int* s = pbuf; | ||
262 | int p = ppos; | ||
263 | |||
264 | if (getMode(MODE_Ansi)) // decide on proper action | ||
265 | { | ||
266 | if (lec(1,0,ESC)) { return; } | ||
267 | if (les(2,1,GRP)) { return; } | ||
268 | if (Xte ) { XtermHack(); resetToken(); return; } | ||
269 | if (Xpe ) { return; } | ||
270 | if (lec(3,2,'?')) { return; } | ||
271 | if (lec(3,2,'>')) { return; } | ||
272 | if (lun( )) { tau( TY_CHR___(), applyCharset(cc), 0); resetToken(); return; } | ||
273 | if (lec(2,0,ESC)) { tau( TY_ESC___(s[1]), 0, 0); resetToken(); return; } | ||
274 | if (les(3,1,SCS)) { tau( TY_ESC_CS(s[1],s[2]), 0, 0); resetToken(); return; } | ||
275 | if (lec(3,1,'#')) { tau( TY_ESC_DE(s[2]), 0, 0); resetToken(); return; } | ||
276 | // if (egt( )) { tau( TY_CSI_PG(cc ), '>', 0); resetToken(); return; } | ||
277 | if (eps( CPN)) { tau( TY_CSI_PN(cc), argv[0],argv[1]); resetToken(); return; } | ||
278 | if (ees( DIG)) { addDigit(cc-'0'); return; } | ||
279 | if (eec( ';')) { addArgument(); return; } | ||
280 | for (i=0;i<=argc;i++) | ||
281 | if (epp( )) tau( TY_CSI_PR(cc,argv[i]), 0, 0); else | ||
282 | tau( TY_CSI_PS(cc,argv[i]), 0, 0); | ||
283 | resetToken(); | ||
284 | } | ||
285 | else // mode VT52 | ||
286 | { | ||
287 | if (lec(1,0,ESC)) return; | ||
288 | if (les(1,0,CHR)) { tau( TY_CHR___( ), s[0], 0); resetToken(); return; } | ||
289 | if (lec(2,1,'Y')) return; | ||
290 | if (lec(3,1,'Y')) return; | ||
291 | if (p < 4) { tau( TY_VT52__(s[1] ), 0, 0); resetToken(); return; } | ||
292 | tau( TY_VT52__(s[1] ), s[2],s[3]); resetToken(); return; | ||
293 | } | ||
294 | } | ||
295 | |||
296 | void Vt102Emulation::XtermHack() | ||
297 | { int i,arg = 0; | ||
298 | for (i = 2; i < ppos && '0'<=pbuf[i] && pbuf[i]<'9' ; i++) | ||
299 | arg = 10*arg + (pbuf[i]-'0'); | ||
300 | if (pbuf[i] != ';') { ReportErrorToken(); return; } | ||
301 | QChar *str = new QChar[ppos-i-2]; | ||
302 | for (int j = 0; j < ppos-i-2; j++) str[j] = pbuf[i+1+j]; | ||
303 | QString unistr(str,ppos-i-2); | ||
304 | // arg == 1 doesn't change the title. In XTerm it only changes the icon name | ||
305 | // (btw: arg=0 changes title and icon, arg=1 only icon, arg=2 only title | ||
306 | if (arg == 0 || arg == 2) emit changeTitle(arg,unistr); | ||
307 | delete [] str; | ||
308 | } | ||
309 | |||
310 | // Interpreting Codes --------------------------------------------------------- | ||
311 | |||
312 | /* | ||
313 | Now that the incoming character stream is properly tokenized, | ||
314 | meaning is assigned to them. These are either operations of | ||
315 | the current screen, or of the emulation class itself. | ||
316 | |||
317 | The token to be interpreteted comes in as a machine word | ||
318 | possibly accompanied by two parameters. | ||
319 | |||
320 | Likewise, the operations assigned to, come with up to two | ||
321 | arguments. One could consider to make up a proper table | ||
322 | from the function below. | ||
323 | |||
324 | The technical reference manual provides more informations | ||
325 | about this mapping. | ||
326 | */ | ||
327 | |||
328 | void Vt102Emulation::tau( int token, int p, int q ) | ||
329 | { | ||
330 | //scan_buffer_report(); | ||
331 | //if (token == TY_CHR___()) printf("%c",p); else | ||
332 | //printf("tau(%d,%d,%d, %d,%d)\n",(token>>0)&0xff,(token>>8)&0xff,(token>>16)&0xffff,p,q); | ||
333 | switch (token) | ||
334 | { | ||
335 | |||
336 | case TY_CHR___( ) : scr->ShowCharacter (p ); break; //UTF16 | ||
337 | |||
338 | // 127 DEL : ignored on input | ||
339 | |||
340 | case TY_CTL___('@' ) : /* NUL: ignored */ break; | ||
341 | case TY_CTL___('A' ) : /* SOH: ignored */ break; | ||
342 | case TY_CTL___('B' ) : /* STX: ignored */ break; | ||
343 | case TY_CTL___('C' ) : /* ETX: ignored */ break; | ||
344 | case TY_CTL___('D' ) : /* EOT: ignored */ break; | ||
345 | case TY_CTL___('E' ) : reportAnswerBack ( ); break; //VT100 | ||
346 | case TY_CTL___('F' ) : /* ACK: ignored */ break; | ||
347 | case TY_CTL___('G' ) : gui->bell ( ); break; //VT100 | ||
348 | case TY_CTL___('H' ) : scr->BackSpace ( ); break; //VT100 | ||
349 | case TY_CTL___('I' ) : scr->Tabulate ( ); break; //VT100 | ||
350 | case TY_CTL___('J' ) : scr->NewLine ( ); break; //VT100 | ||
351 | case TY_CTL___('K' ) : scr->NewLine ( ); break; //VT100 | ||
352 | case TY_CTL___('L' ) : scr->NewLine ( ); break; //VT100 | ||
353 | case TY_CTL___('M' ) : scr->Return ( ); break; //VT100 | ||
354 | |||
355 | case TY_CTL___('N' ) : useCharset ( 1); break; //VT100 | ||
356 | case TY_CTL___('O' ) : useCharset ( 0); break; //VT100 | ||
357 | |||
358 | case TY_CTL___('P' ) : /* DLE: ignored */ break; | ||
359 | case TY_CTL___('Q' ) : /* DC1: XON continue */ break; //VT100 | ||
360 | case TY_CTL___('R' ) : /* DC2: ignored */ break; | ||
361 | case TY_CTL___('S' ) : /* DC3: XOFF halt */ break; //VT100 | ||
362 | case TY_CTL___('T' ) : /* DC4: ignored */ break; | ||
363 | case TY_CTL___('U' ) : /* NAK: ignored */ break; | ||
364 | case TY_CTL___('V' ) : /* SYN: ignored */ break; | ||
365 | case TY_CTL___('W' ) : /* ETB: ignored */ break; | ||
366 | case TY_CTL___('X' ) : scr->ShowCharacter ( 0x2592); break; //VT100 | ||
367 | case TY_CTL___('Y' ) : /* EM : ignored */ break; | ||
368 | case TY_CTL___('Z' ) : scr->ShowCharacter ( 0x2592); break; //VT100 | ||
369 | case TY_CTL___('[' ) : /* ESC: cannot be seen here. */ break; | ||
370 | case TY_CTL___('\\' ) : /* FS : ignored */ break; | ||
371 | case TY_CTL___(']' ) : /* GS : ignored */ break; | ||
372 | case TY_CTL___('^' ) : /* RS : ignored */ break; | ||
373 | case TY_CTL___('_' ) : /* US : ignored */ break; | ||
374 | |||
375 | case TY_ESC___('D' ) : scr->index ( ); break; //VT100 | ||
376 | case TY_ESC___('E' ) : scr->NextLine ( ); break; //VT100 | ||
377 | case TY_ESC___('H' ) : scr->changeTabStop (TRUE ); break; //VT100 | ||
378 | case TY_ESC___('M' ) : scr->reverseIndex ( ); break; //VT100 | ||
379 | case TY_ESC___('Z' ) : reportTerminalType ( ); break; | ||
380 | case TY_ESC___('c' ) : reset ( ); break; | ||
381 | |||
382 | case TY_ESC___('n' ) : useCharset ( 2); break; | ||
383 | case TY_ESC___('o' ) : useCharset ( 3); break; | ||
384 | case TY_ESC___('7' ) : saveCursor ( ); break; | ||
385 | case TY_ESC___('8' ) : restoreCursor ( ); break; | ||
386 | |||
387 | case TY_ESC___('=' ) : setMode (MODE_AppKeyPad); break; | ||
388 | case TY_ESC___('>' ) : resetMode (MODE_AppKeyPad); break; | ||
389 | case TY_ESC___('<' ) : setMode (MODE_Ansi ); break; //VT100 | ||
390 | |||
391 | case TY_ESC_CS('(', '0') : setCharset (0, '0'); break; //VT100 | ||
392 | case TY_ESC_CS('(', 'A') : setCharset (0, 'A'); break; //VT100 | ||
393 | case TY_ESC_CS('(', 'B') : setCharset (0, 'B'); break; //VT100 | ||
394 | |||
395 | case TY_ESC_CS(')', '0') : setCharset (1, '0'); break; //VT100 | ||
396 | case TY_ESC_CS(')', 'A') : setCharset (1, 'A'); break; //VT100 | ||
397 | case TY_ESC_CS(')', 'B') : setCharset (1, 'B'); break; //VT100 | ||
398 | |||
399 | case TY_ESC_CS('*', '0') : setCharset (2, '0'); break; //VT100 | ||
400 | case TY_ESC_CS('*', 'A') : setCharset (2, 'A'); break; //VT100 | ||
401 | case TY_ESC_CS('*', 'B') : setCharset (2, 'B'); break; //VT100 | ||
402 | |||
403 | case TY_ESC_CS('+', '0') : setCharset (3, '0'); break; //VT100 | ||
404 | case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100 | ||
405 | case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100 | ||
406 | |||
407 | case TY_ESC_CS('%', 'G') : setCodec (1 ); break; //LINUX | ||
408 | case TY_ESC_CS('%', '@') : setCodec (0 ); break; //LINUX | ||
409 | |||
410 | case TY_ESC_DE('3' ) : /* IGNORED: double high, top half */ break; | ||
411 | case TY_ESC_DE('4' ) : /* IGNORED: double high, bottom half */ break; | ||
412 | case TY_ESC_DE('5' ) : /* IGNORED: single width, single high*/ break; | ||
413 | case TY_ESC_DE('6' ) : /* IGNORED: double width, single high*/ break; | ||
414 | case TY_ESC_DE('8' ) : scr->helpAlign ( ); break; | ||
415 | |||
416 | case TY_CSI_PS('K', 0) : scr->clearToEndOfLine ( ); break; | ||
417 | case TY_CSI_PS('K', 1) : scr->clearToBeginOfLine ( ); break; | ||
418 | case TY_CSI_PS('K', 2) : scr->clearEntireLine ( ); break; | ||
419 | case TY_CSI_PS('J', 0) : scr->clearToEndOfScreen ( ); break; | ||
420 | case TY_CSI_PS('J', 1) : scr->clearToBeginOfScreen ( ); break; | ||
421 | case TY_CSI_PS('J', 2) : scr->clearEntireScreen ( ); break; | ||
422 | case TY_CSI_PS('g', 0) : scr->changeTabStop (FALSE ); break; //VT100 | ||
423 | case TY_CSI_PS('g', 3) : scr->clearTabStops ( ); break; //VT100 | ||
424 | case TY_CSI_PS('h', 4) : scr-> setMode (MODE_Insert ); break; | ||
425 | case TY_CSI_PS('h', 20) : setMode (MODE_NewLine ); break; | ||
426 | case TY_CSI_PS('i', 0) : /* IGNORE: attached printer */ break; //VT100 | ||
427 | case TY_CSI_PS('l', 4) : scr-> resetMode (MODE_Insert ); break; | ||
428 | case TY_CSI_PS('l', 20) : resetMode (MODE_NewLine ); break; | ||
429 | |||
430 | case TY_CSI_PS('m', 0) : scr->setDefaultRendition ( ); break; | ||
431 | case TY_CSI_PS('m', 1) : scr-> setRendition (RE_BOLD ); break; //VT100 | ||
432 | case TY_CSI_PS('m', 4) : scr-> setRendition (RE_UNDERLINE); break; //VT100 | ||
433 | case TY_CSI_PS('m', 5) : scr-> setRendition (RE_BLINK ); break; //VT100 | ||
434 | case TY_CSI_PS('m', 7) : scr-> setRendition (RE_REVERSE ); break; | ||
435 | case TY_CSI_PS('m', 10) : /* IGNORED: mapping related */ break; //LINUX | ||
436 | case TY_CSI_PS('m', 11) : /* IGNORED: mapping related */ break; //LINUX | ||
437 | case TY_CSI_PS('m', 12) : /* IGNORED: mapping related */ break; //LINUX | ||
438 | case TY_CSI_PS('m', 22) : scr->resetRendition (RE_BOLD ); break; | ||
439 | case TY_CSI_PS('m', 24) : scr->resetRendition (RE_UNDERLINE); break; | ||
440 | case TY_CSI_PS('m', 25) : scr->resetRendition (RE_BLINK ); break; | ||
441 | case TY_CSI_PS('m', 27) : scr->resetRendition (RE_REVERSE ); break; | ||
442 | |||
443 | case TY_CSI_PS('m', 30) : scr->setForeColor ( 0); break; | ||
444 | case TY_CSI_PS('m', 31) : scr->setForeColor ( 1); break; | ||
445 | case TY_CSI_PS('m', 32) : scr->setForeColor ( 2); break; | ||
446 | case TY_CSI_PS('m', 33) : scr->setForeColor ( 3); break; | ||
447 | case TY_CSI_PS('m', 34) : scr->setForeColor ( 4); break; | ||
448 | case TY_CSI_PS('m', 35) : scr->setForeColor ( 5); break; | ||
449 | case TY_CSI_PS('m', 36) : scr->setForeColor ( 6); break; | ||
450 | case TY_CSI_PS('m', 37) : scr->setForeColor ( 7); break; | ||
451 | case TY_CSI_PS('m', 39) : scr->setForeColorToDefault( ); break; | ||
452 | |||
453 | case TY_CSI_PS('m', 40) : scr->setBackColor ( 0); break; | ||
454 | case TY_CSI_PS('m', 41) : scr->setBackColor ( 1); break; | ||
455 | case TY_CSI_PS('m', 42) : scr->setBackColor ( 2); break; | ||
456 | case TY_CSI_PS('m', 43) : scr->setBackColor ( 3); break; | ||
457 | case TY_CSI_PS('m', 44) : scr->setBackColor ( 4); break; | ||
458 | case TY_CSI_PS('m', 45) : scr->setBackColor ( 5); break; | ||
459 | case TY_CSI_PS('m', 46) : scr->setBackColor ( 6); break; | ||
460 | case TY_CSI_PS('m', 47) : scr->setBackColor ( 7); break; | ||
461 | case TY_CSI_PS('m', 49) : scr->setBackColorToDefault( ); break; | ||
462 | |||
463 | case TY_CSI_PS('m', 90) : scr->setForeColor ( 8); break; | ||
464 | case TY_CSI_PS('m', 91) : scr->setForeColor ( 9); break; | ||
465 | case TY_CSI_PS('m', 92) : scr->setForeColor ( 10); break; | ||
466 | case TY_CSI_PS('m', 93) : scr->setForeColor ( 11); break; | ||
467 | case TY_CSI_PS('m', 94) : scr->setForeColor ( 12); break; | ||
468 | case TY_CSI_PS('m', 95) : scr->setForeColor ( 13); break; | ||
469 | case TY_CSI_PS('m', 96) : scr->setForeColor ( 14); break; | ||
470 | case TY_CSI_PS('m', 97) : scr->setForeColor ( 15); break; | ||
471 | |||
472 | case TY_CSI_PS('m', 100) : scr->setBackColor ( 8); break; | ||
473 | case TY_CSI_PS('m', 101) : scr->setBackColor ( 9); break; | ||
474 | case TY_CSI_PS('m', 102) : scr->setBackColor ( 10); break; | ||
475 | case TY_CSI_PS('m', 103) : scr->setBackColor ( 11); break; | ||
476 | case TY_CSI_PS('m', 104) : scr->setBackColor ( 12); break; | ||
477 | case TY_CSI_PS('m', 105) : scr->setBackColor ( 13); break; | ||
478 | case TY_CSI_PS('m', 106) : scr->setBackColor ( 14); break; | ||
479 | case TY_CSI_PS('m', 107) : scr->setBackColor ( 15); break; | ||
480 | |||
481 | case TY_CSI_PS('n', 5) : reportStatus ( ); break; | ||
482 | case TY_CSI_PS('n', 6) : reportCursorPosition ( ); break; | ||
483 | case TY_CSI_PS('q', 0) : /* IGNORED: LEDs off */ break; //VT100 | ||
484 | case TY_CSI_PS('q', 1) : /* IGNORED: LED1 on */ break; //VT100 | ||
485 | case TY_CSI_PS('q', 2) : /* IGNORED: LED2 on */ break; //VT100 | ||
486 | case TY_CSI_PS('q', 3) : /* IGNORED: LED3 on */ break; //VT100 | ||
487 | case TY_CSI_PS('q', 4) : /* IGNORED: LED4 on */ break; //VT100 | ||
488 | case TY_CSI_PS('x', 0) : reportTerminalParms ( 2); break; //VT100 | ||
489 | case TY_CSI_PS('x', 1) : reportTerminalParms ( 3); break; //VT100 | ||
490 | |||
491 | case TY_CSI_PN('@' ) : scr->insertChars (p ); break; | ||
492 | case TY_CSI_PN('A' ) : scr->cursorUp (p ); break; //VT100 | ||
493 | case TY_CSI_PN('B' ) : scr->cursorDown (p ); break; //VT100 | ||
494 | case TY_CSI_PN('C' ) : scr->cursorRight (p ); break; //VT100 | ||
495 | case TY_CSI_PN('D' ) : scr->cursorLeft (p ); break; //VT100 | ||
496 | case TY_CSI_PN('G' ) : scr->setCursorX (p ); break; //LINUX | ||
497 | case TY_CSI_PN('H' ) : scr->setCursorYX (p, q); break; //VT100 | ||
498 | case TY_CSI_PN('L' ) : scr->insertLines (p ); break; | ||
499 | case TY_CSI_PN('M' ) : scr->deleteLines (p ); break; | ||
500 | case TY_CSI_PN('P' ) : scr->deleteChars (p ); break; | ||
501 | case TY_CSI_PN('X' ) : scr->eraseChars (p ); break; | ||
502 | case TY_CSI_PN('c' ) : reportTerminalType ( ); break; //VT100 | ||
503 | case TY_CSI_PN('d' ) : scr->setCursorY (p ); break; //LINUX | ||
504 | case TY_CSI_PN('f' ) : scr->setCursorYX (p, q); break; //VT100 | ||
505 | case TY_CSI_PN('r' ) : scr->setMargins (p, q); break; //VT100 | ||
506 | case TY_CSI_PN('y' ) : /* IGNORED: Confidence test */ break; //VT100 | ||
507 | |||
508 | case TY_CSI_PR('h', 1) : setMode (MODE_AppCuKeys); break; //VT100 | ||
509 | case TY_CSI_PR('l', 1) : resetMode (MODE_AppCuKeys); break; //VT100 | ||
510 | case TY_CSI_PR('s', 1) : saveMode (MODE_AppCuKeys); break; //FIXME | ||
511 | case TY_CSI_PR('r', 1) : restoreMode (MODE_AppCuKeys); break; //FIXME | ||
512 | |||
513 | case TY_CSI_PR('l', 2) : resetMode (MODE_Ansi ); break; //VT100 | ||
514 | |||
515 | case TY_CSI_PR('h', 3) : setColumns ( 132); break; //VT100 | ||
516 | case TY_CSI_PR('l', 3) : setColumns ( 80); break; //VT100 | ||
517 | |||
518 | case TY_CSI_PR('h', 4) : /* IGNORED: soft scrolling */ break; //VT100 | ||
519 | case TY_CSI_PR('l', 4) : /* IGNORED: soft scrolling */ break; //VT100 | ||
520 | |||
521 | case TY_CSI_PR('h', 5) : scr-> setMode (MODE_Screen ); break; //VT100 | ||
522 | case TY_CSI_PR('l', 5) : scr-> resetMode (MODE_Screen ); break; //VT100 | ||
523 | |||
524 | case TY_CSI_PR('h', 6) : scr-> setMode (MODE_Origin ); break; //VT100 | ||
525 | case TY_CSI_PR('l', 6) : scr-> resetMode (MODE_Origin ); break; //VT100 | ||
526 | case TY_CSI_PR('s', 6) : scr-> saveMode (MODE_Origin ); break; //FIXME | ||
527 | case TY_CSI_PR('r', 6) : scr->restoreMode (MODE_Origin ); break; //FIXME | ||
528 | |||
529 | case TY_CSI_PR('h', 7) : scr-> setMode (MODE_Wrap ); break; //VT100 | ||
530 | case TY_CSI_PR('l', 7) : scr-> resetMode (MODE_Wrap ); break; //VT100 | ||
531 | case TY_CSI_PR('s', 7) : scr-> saveMode (MODE_Wrap ); break; //FIXME | ||
532 | case TY_CSI_PR('r', 7) : scr->restoreMode (MODE_Wrap ); break; //FIXME | ||
533 | |||
534 | case TY_CSI_PR('h', 8) : /* IGNORED: autorepeat on */ break; //VT100 | ||
535 | case TY_CSI_PR('l', 8) : /* IGNORED: autorepeat off */ break; //VT100 | ||
536 | |||
537 | case TY_CSI_PR('h', 9) : /* IGNORED: interlace */ break; //VT100 | ||
538 | case TY_CSI_PR('l', 9) : /* IGNORED: interlace */ break; //VT100 | ||
539 | |||
540 | case TY_CSI_PR('h', 25) : setMode (MODE_Cursor ); break; //VT100 | ||
541 | case TY_CSI_PR('l', 25) : resetMode (MODE_Cursor ); break; //VT100 | ||
542 | |||
543 | case TY_CSI_PR('h', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM | ||
544 | case TY_CSI_PR('l', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM | ||
545 | case TY_CSI_PR('s', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM | ||
546 | case TY_CSI_PR('r', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM | ||
547 | |||
548 | case TY_CSI_PR('h', 47) : setMode (MODE_AppScreen); break; //VT100 | ||
549 | case TY_CSI_PR('l', 47) : resetMode (MODE_AppScreen); break; //VT100 | ||
550 | |||
551 | case TY_CSI_PR('h', 1000) : setMode (MODE_Mouse1000); break; //XTERM | ||
552 | case TY_CSI_PR('l', 1000) : resetMode (MODE_Mouse1000); break; //XTERM | ||
553 | case TY_CSI_PR('s', 1000) : saveMode (MODE_Mouse1000); break; //XTERM | ||
554 | case TY_CSI_PR('r', 1000) : restoreMode (MODE_Mouse1000); break; //XTERM | ||
555 | |||
556 | case TY_CSI_PR('h', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM | ||
557 | case TY_CSI_PR('l', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM | ||
558 | case TY_CSI_PR('s', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM | ||
559 | case TY_CSI_PR('r', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM | ||
560 | |||
561 | case TY_CSI_PR('h', 1047) : setMode (MODE_AppScreen); break; //XTERM | ||
562 | case TY_CSI_PR('l', 1047) : resetMode (MODE_AppScreen); break; //XTERM | ||
563 | |||
564 | //FIXME: Unitoken: save translations | ||
565 | case TY_CSI_PR('h', 1048) : saveCursor ( ); break; //XTERM | ||
566 | case TY_CSI_PR('l', 1048) : restoreCursor ( ); break; //XTERM | ||
567 | |||
568 | //FIXME: every once new sequences like this pop up in xterm. | ||
569 | // Here's a guess of what they could mean. | ||
570 | case TY_CSI_PR('h', 1049) : setMode (MODE_AppScreen); break; //XTERM | ||
571 | case TY_CSI_PR('l', 1049) : resetMode (MODE_AppScreen); break; //XTERM | ||
572 | |||
573 | //FIXME: when changing between vt52 and ansi mode evtl do some resetting. | ||
574 | case TY_VT52__('A' ) : scr->cursorUp ( 1); break; //VT52 | ||
575 | case TY_VT52__('B' ) : scr->cursorDown ( 1); break; //VT52 | ||
576 | case TY_VT52__('C' ) : scr->cursorRight ( 1); break; //VT52 | ||
577 | case TY_VT52__('D' ) : scr->cursorLeft ( 1); break; //VT52 | ||
578 | |||
579 | case TY_VT52__('F' ) : setAndUseCharset (0, '0'); break; //VT52 | ||
580 | case TY_VT52__('G' ) : setAndUseCharset (0, 'B'); break; //VT52 | ||
581 | |||
582 | case TY_VT52__('H' ) : scr->setCursorYX (1,1 ); break; //VT52 | ||
583 | case TY_VT52__('I' ) : scr->reverseIndex ( ); break; //VT52 | ||
584 | case TY_VT52__('J' ) : scr->clearToEndOfScreen ( ); break; //VT52 | ||
585 | case TY_VT52__('K' ) : scr->clearToEndOfLine ( ); break; //VT52 | ||
586 | case TY_VT52__('Y' ) : scr->setCursorYX (p-31,q-31 ); break; //VT52 | ||
587 | case TY_VT52__('Z' ) : reportTerminalType ( ); break; //VT52 | ||
588 | case TY_VT52__('<' ) : setMode (MODE_Ansi ); break; //VT52 | ||
589 | case TY_VT52__('=' ) : setMode (MODE_AppKeyPad); break; //VT52 | ||
590 | case TY_VT52__('>' ) : resetMode (MODE_AppKeyPad); break; //VT52 | ||
591 | |||
592 | default : ReportErrorToken(); break; | ||
593 | }; | ||
594 | } | ||
595 | |||
596 | /* ------------------------------------------------------------------------- */ | ||
597 | /* */ | ||
598 | /* Terminal to Host protocol */ | ||
599 | /* */ | ||
600 | /* ------------------------------------------------------------------------- */ | ||
601 | |||
602 | /* | ||
603 | Outgoing bytes originate from several sources: | ||
604 | |||
605 | - Replies to Enquieries. | ||
606 | - Mouse Events | ||
607 | - Keyboard Events | ||
608 | */ | ||
609 | |||
610 | /*! | ||
611 | */ | ||
612 | |||
613 | void Vt102Emulation::sendString(const char* s) | ||
614 | { | ||
615 | QByteArray tmp; | ||
616 | tmp.setRawData( s, strlen( s )); | ||
617 | emit sndBlock( tmp); | ||
618 | } | ||
619 | |||
620 | void Vt102Emulation::sendString(const QByteArray& s) | ||
621 | { | ||
622 | emit sndBlock( s ); | ||
623 | } | ||
624 | |||
625 | // Replies ----------------------------------------------------------------- -- | ||
626 | |||
627 | // This section copes with replies send as response to an enquiery control code. | ||
628 | |||
629 | /*! | ||
630 | */ | ||
631 | |||
632 | void Vt102Emulation::reportCursorPosition() | ||
633 | { char tmp[20]; | ||
634 | sprintf(tmp,"\033[%d;%dR",scr->getCursorY()+1,scr->getCursorX()+1); | ||
635 | sendString(tmp); | ||
636 | } | ||
637 | |||
638 | /* | ||
639 | What follows here is rather obsolete and faked stuff. | ||
640 | The correspondent enquieries are neverthenless issued. | ||
641 | */ | ||
642 | |||
643 | /*! | ||
644 | */ | ||
645 | |||
646 | void Vt102Emulation::reportTerminalType() | ||
647 | { | ||
648 | //FIXME: should change? | ||
649 | if (getMode(MODE_Ansi)) | ||
650 | // sendString("\033[?1;2c"); // I'm a VT100 with AP0 //FIXME: send only in response to ^[[0c | ||
651 | sendString("\033[>0;115;0c"); // I'm a VT220 //FIXME: send only in response to ^[[>c | ||
652 | else | ||
653 | sendString("\033/Z"); // I'm a VT52 | ||
654 | } | ||
655 | |||
656 | void Vt102Emulation::reportTerminalParms(int p) | ||
657 | // DECREPTPARM | ||
658 | { char tmp[100]; | ||
659 | sprintf(tmp,"\033[%d;1;1;112;112;1;0x",p); // not really true. | ||
660 | sendString(tmp); | ||
661 | } | ||
662 | |||
663 | /*! | ||
664 | */ | ||
665 | |||
666 | void Vt102Emulation::reportStatus() | ||
667 | { | ||
668 | sendString("\033[0n"); //VT100. Device status report. 0 = Ready. | ||
669 | } | ||
670 | |||
671 | /*! | ||
672 | */ | ||
673 | |||
674 | #define ANSWER_BACK "" // This is really obsolete VT100 stuff. | ||
675 | |||
676 | void Vt102Emulation::reportAnswerBack() | ||
677 | { | ||
678 | sendString(ANSWER_BACK); | ||
679 | } | ||
680 | |||
681 | // Mouse Handling ---------------------------------------------------------- -- | ||
682 | |||
683 | /*! | ||
684 | Mouse clicks are possibly reported to the client | ||
685 | application if it has issued interest in them. | ||
686 | They are normally consumed by the widget for copy | ||
687 | and paste, but may be propagated from the widget | ||
688 | when gui->setMouseMarks is set via setMode(MODE_Mouse1000). | ||
689 | |||
690 | `x',`y' are 1-based. | ||
691 | `ev' (event) indicates the button pressed (0-2) | ||
692 | or a general mouse release (3). | ||
693 | */ | ||
694 | |||
695 | void Vt102Emulation::onMouse( int cb, int cx, int cy ) | ||
696 | { char tmp[20]; | ||
697 | if (!connected) return; | ||
698 | sprintf(tmp,"\033[M%c%c%c",cb+040,cx+040,cy+040); | ||
699 | sendString(tmp); | ||
700 | } | ||
701 | |||
702 | // Keyboard Handling ------------------------------------------------------- -- | ||
703 | |||
704 | #define encodeMode(M,B) BITS(B,getMode(M)) | ||
705 | #define encodeStat(M,B) BITS(B,((ev->state() & (M)) == (M))) | ||
706 | |||
707 | /* | ||
708 | Keyboard event handling has been simplified somewhat by pushing | ||
709 | the complications towards a configuration file [see KeyTrans class]. | ||
710 | */ | ||
711 | |||
712 | void Vt102Emulation::onKeyPress( QKeyEvent* ev ) | ||
713 | { | ||
714 | if (!connected) return; // someone else gets the keys | ||
715 | |||
716 | //printf("State/Key: 0x%04x 0x%04x (%d,%d)\n",ev->state(),ev->key(),ev->text().length(),ev->text().length()?ev->text().ascii()[0]:0); | ||
717 | |||
718 | // revert to non-history when typing | ||
719 | if (scr->getHistCursor() != scr->getHistLines()); | ||
720 | scr->setHistCursor(scr->getHistLines()); | ||
721 | |||
722 | // lookup in keyboard translation table ... | ||
723 | int cmd; const char* txt; int len; | ||
724 | if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine , BITS_NewLine ) + // OLD, | ||
725 | encodeMode(MODE_Ansi , BITS_Ansi ) + // OBSOLETE, | ||
726 | encodeMode(MODE_AppCuKeys, BITS_AppCuKeys ) + // VT100 stuff | ||
727 | encodeStat(ControlButton , BITS_Control ) + | ||
728 | encodeStat(ShiftButton , BITS_Shift ) + | ||
729 | encodeStat(AltButton , BITS_Alt ), | ||
730 | &cmd, &txt, &len )) | ||
731 | //printf("cmd: %d, %s, %d\n",cmd,txt,len); | ||
732 | { | ||
733 | switch(cmd) // ... and execute if found. | ||
734 | { | ||
735 | case CMD_emitSelection : gui->insertSelection(); return; | ||
736 | case CMD_scrollPageUp : gui->scroll(-gui->lines()/2); return; | ||
737 | case CMD_scrollPageDown : gui->scroll(+gui->lines()/2); return; | ||
738 | case CMD_scrollLineUp : gui->scroll(-1 ); return; | ||
739 | case CMD_scrollLineDown : gui->scroll(+1 ); return; | ||
740 | case CMD_send : sendString( txt ); return; | ||
741 | case CMD_prevSession : emit prevSession(); return; | ||
742 | case CMD_nextSession : emit nextSession(); return; | ||
743 | } | ||
744 | } | ||
745 | // fall back handling | ||
746 | if (!ev->text().isEmpty()) | ||
747 | { | ||
748 | if (ev->state() & AltButton) sendString("\033"); // ESC, this is the ALT prefix | ||
749 | /// very hacky | ||
750 | if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='A')) sendString("\01"); | ||
751 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='B')) sendString("\02"); | ||
752 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='C')) sendString("\03"); | ||
753 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='D')) sendString("\04"); | ||
754 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='E')) sendString("\05"); | ||
755 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='F')) sendString("\06"); | ||
756 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='G')) sendString("\07"); | ||
757 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='H')) sendString("\010"); | ||
758 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='I')) sendString("\011"); | ||
759 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='J')) sendString("\012"); | ||
760 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='K')) sendString("\013"); | ||
761 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='L')) sendString("\014"); | ||
762 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='M')) sendString("\015"); | ||
763 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='N')) sendString("\016"); | ||
764 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='O')) sendString("\017"); | ||
765 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='P')) sendString("\020"); | ||
766 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Q')) sendString("\021"); | ||
767 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='R')) sendString("\022"); | ||
768 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='S')) sendString("\023"); | ||
769 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='T')) sendString("\024"); | ||
770 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='U')) sendString("\025"); | ||
771 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='V')) sendString("\026"); | ||
772 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='W')) sendString("\027"); | ||
773 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='X')) sendString("\030"); | ||
774 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Y')) sendString("\031"); | ||
775 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Z')) sendString("\032"); | ||
776 | else | ||
777 | { | ||
778 | QCString s = codec->fromUnicode(ev->text()); // encode for application | ||
779 | sendString( s ); // we may well have s.length() > 1 | ||
780 | } | ||
781 | return; | ||
782 | } | ||
783 | } | ||
784 | |||
785 | /* ------------------------------------------------------------------------- */ | ||
786 | /* */ | ||
787 | /* VT100 Charsets */ | ||
788 | /* */ | ||
789 | /* ------------------------------------------------------------------------- */ | ||
790 | |||
791 | // Character Set Conversion ------------------------------------------------ -- | ||
792 | |||
793 | /* | ||
794 | The processing contains a VT100 specific code translation layer. | ||
795 | It's still in use and mainly responsible for the line drawing graphics. | ||
796 | |||
797 | These and some other glyphs are assigned to codes (0x5f-0xfe) | ||
798 | normally occupied by the latin letters. Since this codes also | ||
799 | appear within control sequences, the extra code conversion | ||
800 | does not permute with the tokenizer and is placed behind it | ||
801 | in the pipeline. It only applies to tokens, which represent | ||
802 | plain characters. | ||
803 | |||
804 | This conversion it eventually continued in TEWidget.C, since | ||
805 | it might involve VT100 enhanced fonts, which have these | ||
806 | particular glyphs allocated in (0x00-0x1f) in their code page. | ||
807 | */ | ||
808 | |||
809 | #define CHARSET charset[scr==screen[1]] | ||
810 | |||
811 | // Apply current character map. | ||
812 | |||
813 | unsigned short Vt102Emulation::applyCharset(unsigned short c) | ||
814 | { | ||
815 | if (CHARSET.graphic && 0x5f <= c && c <= 0x7e) return vt100_graphics[c-0x5f]; | ||
816 | if (CHARSET.pound && c == '#' ) return 0xa3; //This mode is obsolete | ||
817 | return c; | ||
818 | } | ||
819 | |||
820 | /* | ||
821 | "Charset" related part of the emulation state. | ||
822 | This configures the VT100 charset filter. | ||
823 | |||
824 | While most operation work on the current screen, | ||
825 | the following two are different. | ||
826 | */ | ||
827 | |||
828 | void Vt102Emulation::resetCharset(int scrno) | ||
829 | { | ||
830 | charset[scrno].cu_cs = 0; | ||
831 | strncpy(charset[scrno].charset,"BBBB",4); | ||
832 | charset[scrno].sa_graphic = FALSE; | ||
833 | charset[scrno].sa_pound = FALSE; | ||
834 | charset[scrno].graphic = FALSE; | ||
835 | charset[scrno].pound = FALSE; | ||
836 | } | ||
837 | |||
838 | /*! | ||
839 | */ | ||
840 | |||
841 | void Vt102Emulation::setCharset(int n, int cs) // on both screens. | ||
842 | { | ||
843 | charset[0].charset[n&3] = cs; useCharset(charset[0].cu_cs); | ||
844 | charset[1].charset[n&3] = cs; useCharset(charset[1].cu_cs); | ||
845 | } | ||
846 | |||
847 | /*! | ||
848 | */ | ||
849 | |||
850 | void Vt102Emulation::setAndUseCharset(int n, int cs) | ||
851 | { | ||
852 | CHARSET.charset[n&3] = cs; | ||
853 | useCharset(n&3); | ||
854 | } | ||
855 | |||
856 | /*! | ||
857 | */ | ||
858 | |||
859 | void Vt102Emulation::useCharset(int n) | ||
860 | { | ||
861 | CHARSET.cu_cs = n&3; | ||
862 | CHARSET.graphic = (CHARSET.charset[n&3] == '0'); | ||
863 | CHARSET.pound = (CHARSET.charset[n&3] == 'A'); //This mode is obsolete | ||
864 | } | ||
865 | |||
866 | /*! Save the cursor position and the rendition attribute settings. */ | ||
867 | |||
868 | void Vt102Emulation::saveCursor() | ||
869 | { | ||
870 | CHARSET.sa_graphic = CHARSET.graphic; | ||
871 | CHARSET.sa_pound = CHARSET.pound; //This mode is obsolete | ||
872 | // we are not clear about these | ||
873 | //sa_charset = charsets[cScreen->charset]; | ||
874 | //sa_charset_num = cScreen->charset; | ||
875 | scr->saveCursor(); | ||
876 | } | ||
877 | |||
878 | /*! Restore the cursor position and the rendition attribute settings. */ | ||
879 | |||
880 | void Vt102Emulation::restoreCursor() | ||
881 | { | ||
882 | CHARSET.graphic = CHARSET.sa_graphic; | ||
883 | CHARSET.pound = CHARSET.sa_pound; //This mode is obsolete | ||
884 | scr->restoreCursor(); | ||
885 | } | ||
886 | |||
887 | /* ------------------------------------------------------------------------- */ | ||
888 | /* */ | ||
889 | /* Mode Operations */ | ||
890 | /* */ | ||
891 | /* ------------------------------------------------------------------------- */ | ||
892 | |||
893 | /* | ||
894 | Some of the emulations state is either added to the state of the screens. | ||
895 | |||
896 | This causes some scoping problems, since different emulations choose to | ||
897 | located the mode either to the current screen or to both. | ||
898 | |||
899 | For strange reasons, the extend of the rendition attributes ranges over | ||
900 | all screens and not over the actual screen. | ||
901 | |||
902 | We decided on the precise precise extend, somehow. | ||
903 | */ | ||
904 | |||
905 | // "Mode" related part of the state. These are all booleans. | ||
906 | |||
907 | void Vt102Emulation::resetModes() | ||
908 | { | ||
909 | resetMode(MODE_Mouse1000); saveMode(MODE_Mouse1000); | ||
910 | resetMode(MODE_AppScreen); saveMode(MODE_AppScreen); | ||
911 | // here come obsolete modes | ||
912 | resetMode(MODE_AppCuKeys); saveMode(MODE_AppCuKeys); | ||
913 | resetMode(MODE_NewLine ); | ||
914 | setMode(MODE_Ansi ); | ||
915 | } | ||
916 | |||
917 | void Vt102Emulation::setMode(int m) | ||
918 | { | ||
919 | currParm.mode[m] = TRUE; | ||
920 | switch (m) | ||
921 | { | ||
922 | case MODE_Mouse1000 : //gui->setMouseMarks(FALSE); | ||
923 | break; | ||
924 | case MODE_AppScreen : screen[1]->clearSelection(); | ||
925 | screen[1]->clearEntireScreen(); | ||
926 | setScreen(1); | ||
927 | break; | ||
928 | } | ||
929 | if (m < MODES_SCREEN || m == MODE_NewLine) | ||
930 | { | ||
931 | screen[0]->setMode(m); | ||
932 | screen[1]->setMode(m); | ||
933 | } | ||
934 | } | ||
935 | |||
936 | void Vt102Emulation::resetMode(int m) | ||
937 | { | ||
938 | currParm.mode[m] = FALSE; | ||
939 | switch (m) | ||
940 | { | ||
941 | case MODE_Mouse1000 : //gui->setMouseMarks(TRUE); | ||
942 | break; | ||
943 | case MODE_AppScreen : screen[0]->clearSelection(); | ||
944 | setScreen(0); | ||
945 | break; | ||
946 | } | ||
947 | if (m < MODES_SCREEN || m == MODE_NewLine) | ||
948 | { | ||
949 | screen[0]->resetMode(m); | ||
950 | screen[1]->resetMode(m); | ||
951 | } | ||
952 | } | ||
953 | |||
954 | void Vt102Emulation::saveMode(int m) | ||
955 | { | ||
956 | saveParm.mode[m] = currParm.mode[m]; | ||
957 | } | ||
958 | |||
959 | void Vt102Emulation::restoreMode(int m) | ||
960 | { | ||
961 | if(saveParm.mode[m]) setMode(m); else resetMode(m); | ||
962 | } | ||
963 | |||
964 | BOOL Vt102Emulation::getMode(int m) | ||
965 | { | ||
966 | return currParm.mode[m]; | ||
967 | } | ||
968 | |||
969 | void Vt102Emulation::setConnect(bool c) | ||
970 | { | ||
971 | EmulationLayer::setConnect(c); | ||
972 | if (c) | ||
973 | { // refresh mouse mode | ||
974 | if (getMode(MODE_Mouse1000)) | ||
975 | setMode(MODE_Mouse1000); | ||
976 | else | ||
977 | resetMode(MODE_Mouse1000); | ||
978 | } | ||
979 | } | ||
980 | |||
981 | /* ------------------------------------------------------------------------- */ | ||
982 | /* */ | ||
983 | /* Diagnostic */ | ||
984 | /* */ | ||
985 | /* ------------------------------------------------------------------------- */ | ||
986 | |||
987 | /*! shows the contents of the scan buffer. | ||
988 | |||
989 | This functions is used for diagnostics. It is called by \e ReportErrorToken | ||
990 | to inform about strings that cannot be decoded or handled by the emulation. | ||
991 | |||
992 | \sa ReportErrorToken | ||
993 | */ | ||
994 | |||
995 | /*! | ||
996 | */ | ||
997 | |||
998 | static void hexdump(int* s, int len) | ||
999 | { int i; | ||
1000 | for (i = 0; i < len; i++) | ||
1001 | { | ||
1002 | if (s[i] == '\\') | ||
1003 | printf("\\\\"); | ||
1004 | else | ||
1005 | if ((s[i]) > 32 && s[i] < 127) | ||
1006 | printf("%c",s[i]); | ||
1007 | else | ||
1008 | printf("\\%04x(hex)",s[i]); | ||
1009 | } | ||
1010 | } | ||
1011 | |||
1012 | void Vt102Emulation::scan_buffer_report() | ||
1013 | { | ||
1014 | if (ppos == 0 || ppos == 1 && (pbuf[0] & 0xff) >= 32) return; | ||
1015 | printf("token: "); hexdump(pbuf,ppos); printf("\n"); | ||
1016 | } | ||
1017 | |||
1018 | /*! | ||
1019 | */ | ||
1020 | |||
1021 | void Vt102Emulation::ReportErrorToken() | ||
1022 | { | ||
1023 | printf("undecodable "); scan_buffer_report(); | ||
1024 | } | ||
diff --git a/noncore/apps/opie-console/vt102emulation.h b/noncore/apps/opie-console/vt102emulation.h deleted file mode 100644 index 17ab449..0000000 --- a/noncore/apps/opie-console/vt102emulation.h +++ b/dev/null | |||
@@ -1,153 +0,0 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | ||
2 | /* */ | ||
3 | /* [TEmuVt102.h] X Terminal Emulation */ | ||
4 | /* */ | ||
5 | /* -------------------------------------------------------------------------- */ | ||
6 | /* */ | ||
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | ||
8 | /* */ | ||
9 | /* This file is part of Konsole - an X terminal for KDE */ | ||
10 | /* */ | ||
11 | /* -------------------------------------------------------------------------- */ | ||
12 | /* */ | ||
13 | /* Ported Konsole to Qt/Embedded */ | ||
14 | /* */ | ||
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | ||
16 | /* */ | ||
17 | /* -------------------------------------------------------------------------- */ | ||
18 | /* Ported embedded-konsole to opie-terminal */ | ||
19 | /* */ | ||
20 | /* Copyright (C) 2002 by opie developers <opie@handhelds.org> */ | ||
21 | /* */ | ||
22 | /* -------------------------------------------------------------------------- */ | ||
23 | |||
24 | #ifndef VT102EMU_H | ||
25 | #define VT102EMU_H | ||
26 | |||
27 | #include "widget_layer.h" | ||
28 | #include "screen.h" | ||
29 | #include "emulation_layer.h" | ||
30 | #include <qtimer.h> | ||
31 | #include <stdio.h> | ||
32 | |||
33 | // | ||
34 | |||
35 | #define MODE_AppScreen (MODES_SCREEN+0) | ||
36 | #define MODE_AppCuKeys (MODES_SCREEN+1) | ||
37 | #define MODE_AppKeyPad (MODES_SCREEN+2) | ||
38 | #define MODE_Mouse1000 (MODES_SCREEN+3) | ||
39 | #define MODE_Ansi (MODES_SCREEN+4) | ||
40 | #define MODE_total (MODES_SCREEN+5) | ||
41 | |||
42 | struct DECpar | ||
43 | { | ||
44 | BOOL mode[MODE_total]; | ||
45 | }; | ||
46 | |||
47 | struct CharCodes | ||
48 | { | ||
49 | // coding info | ||
50 | char charset[4]; // | ||
51 | int cu_cs; // actual charset. | ||
52 | bool graphic; // Some VT100 tricks | ||
53 | bool pound ; // Some VT100 tricks | ||
54 | bool sa_graphic; // saved graphic | ||
55 | bool sa_pound; // saved pound | ||
56 | }; | ||
57 | |||
58 | class Vt102Emulation: public EmulationLayer | ||
59 | { Q_OBJECT | ||
60 | |||
61 | public: | ||
62 | |||
63 | Vt102Emulation(WidgetLayer* gui); | ||
64 | ~Vt102Emulation(); | ||
65 | |||
66 | public slots: // signals incoming from Widget | ||
67 | |||
68 | void onKeyPress(QKeyEvent*); | ||
69 | void onMouse(int cb, int cx, int cy); | ||
70 | |||
71 | signals: | ||
72 | |||
73 | void changeTitle(int,const QString&); | ||
74 | void prevSession(); | ||
75 | void nextSession(); | ||
76 | |||
77 | public: | ||
78 | |||
79 | void reset(); | ||
80 | |||
81 | /** | ||
82 | * receive a char from IOLayer | ||
83 | */ | ||
84 | void onRcvChar(int cc); | ||
85 | |||
86 | /** | ||
87 | * sends a list of bytes to the IOLayer | ||
88 | */ | ||
89 | void sendString(const QByteArray&); | ||
90 | |||
91 | /** | ||
92 | * @deprecated use QByteArray instead | ||
93 | * see sendString() above | ||
94 | */ | ||
95 | void sendString(const char *); | ||
96 | |||
97 | public: | ||
98 | |||
99 | BOOL getMode (int m); | ||
100 | |||
101 | void setMode (int m); | ||
102 | void resetMode (int m); | ||
103 | void saveMode (int m); | ||
104 | void restoreMode(int m); | ||
105 | void resetModes(); | ||
106 | |||
107 | void setConnect(bool r); | ||
108 | |||
109 | private: | ||
110 | |||
111 | void resetToken(); | ||
112 | #define MAXPBUF 80 | ||
113 | void pushToToken(int cc); | ||
114 | int pbuf[MAXPBUF]; //FIXME: overflow? | ||
115 | int ppos; | ||
116 | #define MAXARGS 15 | ||
117 | void addDigit(int dig); | ||
118 | void addArgument(); | ||
119 | int argv[MAXARGS]; | ||
120 | int argc; | ||
121 | void initTokenizer(); | ||
122 | int tbl[256]; | ||
123 | |||
124 | void scan_buffer_report(); //FIXME: rename | ||
125 | void ReportErrorToken(); //FIXME: rename | ||
126 | |||
127 | void tau(int code, int p, int q); | ||
128 | void XtermHack(); | ||
129 | |||
130 | // | ||
131 | |||
132 | void reportTerminalType(); | ||
133 | void reportStatus(); | ||
134 | void reportAnswerBack(); | ||
135 | void reportCursorPosition(); | ||
136 | void reportTerminalParms(int p); | ||
137 | |||
138 | protected: | ||
139 | |||
140 | unsigned short applyCharset(unsigned short c); | ||
141 | void setCharset(int n, int cs); | ||
142 | void useCharset(int n); | ||
143 | void setAndUseCharset(int n, int cs); | ||
144 | void saveCursor(); | ||
145 | void restoreCursor(); | ||
146 | void resetCharset(int scrno); | ||
147 | CharCodes charset[2]; | ||
148 | |||
149 | DECpar currParm; | ||
150 | DECpar saveParm; | ||
151 | }; | ||
152 | |||
153 | #endif // ifndef ANSIEMU_H | ||
diff --git a/noncore/apps/opie-console/widget.cpp b/noncore/apps/opie-console/widget.cpp deleted file mode 100644 index 4a578be..0000000 --- a/noncore/apps/opie-console/widget.cpp +++ b/dev/null | |||
@@ -1,1278 +0,0 @@ | |||
1 | /* ------------------------------------------------------------------------ */ | ||
2 | /* */ | ||
3 | /* [TEWidget.C] Terminal Emulation Widget */ | ||
4 | /* */ | ||
5 | /* ------------------------------------------------------------------------ */ | ||
6 | /* */ | ||
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | ||
8 | /* */ | ||
9 | /* This file is part of Konsole - an X terminal for KDE */ | ||
10 | /* */ | ||
11 | /* ------------------------------------------------------------------------ */ | ||
12 | /* */ | ||
13 | /* Ported Konsole to Qt/Embedded */ | ||
14 | /* */ | ||
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | ||
16 | /* */ | ||
17 | /* -------------------------------------------------------------------------- */ | ||
18 | |||
19 | /* ibot: | ||
20 | i changed | ||
21 | "currentSession->getEmulation()->sendString()" to | ||
22 | "currentSession->layer()->send()" | ||
23 | # this is not right! EmulationLayer should send it... | ||
24 | i changed all those to use emulationLayer()->send() instead | ||
25 | i had to create a QByteArray before... | ||
26 | |||
27 | TODO: | ||
28 | alter Widget to use only QByteArray, where applicable. | ||
29 | */ | ||
30 | |||
31 | |||
32 | |||
33 | /*! \class Widget | ||
34 | |||
35 | \brief Visible screen contents | ||
36 | |||
37 | This class is responsible to map the `image' of a terminal emulation to the | ||
38 | display. All the dependency of the emulation to a specific GUI or toolkit is | ||
39 | localized here. Further, this widget has no knowledge about being part of an | ||
40 | emulation, it simply work within the terminal emulation framework by exposing | ||
41 | size and key events and by being ordered to show a new image. | ||
42 | |||
43 | <ul> | ||
44 | <li> The internal image has the size of the widget (evtl. rounded up) | ||
45 | <li> The external image used in setImage can have any size. | ||
46 | <li> (internally) the external image is simply copied to the internal | ||
47 | when a setImage happens. During a resizeEvent no painting is done | ||
48 | a paintEvent is expected to follow anyway. | ||
49 | </ul> | ||
50 | |||
51 | \sa TEScreen \sa Emulation | ||
52 | */ | ||
53 | |||
54 | /* FIXME: | ||
55 | - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent | ||
56 | - 'font_a' not used in mouse events | ||
57 | - add destructor | ||
58 | */ | ||
59 | |||
60 | /* TODO | ||
61 | - evtl. be sensitive to `paletteChange' while using default colors. | ||
62 | - set different 'rounding' styles? I.e. have a mode to show clipped chars? | ||
63 | */ | ||
64 | |||
65 | // #include "config.h" | ||
66 | #include "widget.h" | ||
67 | #include <qpe/config.h> | ||
68 | |||
69 | #include <qclipboard.h> | ||
70 | |||
71 | #include <stdio.h> | ||
72 | #include <stdlib.h> | ||
73 | #include <unistd.h> | ||
74 | #include <ctype.h> | ||
75 | #include <sys/stat.h> | ||
76 | #include <sys/types.h> | ||
77 | #include <signal.h> | ||
78 | |||
79 | #include <assert.h> | ||
80 | |||
81 | // #include "widget.moc" | ||
82 | //#include <kapp.h> | ||
83 | //#include <kcursor.h> | ||
84 | //#include <kurl.h> | ||
85 | //#include <kdebug.h> | ||
86 | //#include <klocale.h> | ||
87 | |||
88 | #define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) | ||
89 | #define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } | ||
90 | |||
91 | #define loc(X,Y) ((Y)*columns+(X)) | ||
92 | |||
93 | //FIXME: the rim should normally be 1, 0 only when running in full screen mode. | ||
94 | #define rimX 0 // left/right rim width | ||
95 | #define rimY 0 // top/bottom rim high | ||
96 | |||
97 | #define yMouseScroll 1 | ||
98 | // scroll increment used when dragging selection at top/bottom of window. | ||
99 | |||
100 | /* ------------------------------------------------------------------------- */ | ||
101 | /* */ | ||
102 | /* Colors */ | ||
103 | /* */ | ||
104 | /* ------------------------------------------------------------------------- */ | ||
105 | |||
106 | //FIXME: the default color table is in session.C now. | ||
107 | // We need a way to get rid of this one, here. | ||
108 | static const ColorEntry base_color_table[TABLE_COLORS] = | ||
109 | // The following are almost IBM standard color codes, with some slight | ||
110 | // gamma correction for the dim colors to compensate for bright X screens. | ||
111 | // It contains the 8 ansiterm/xterm colors in 2 intensities. | ||
112 | { | ||
113 | // Fixme: could add faint colors here, also. | ||
114 | // normal | ||
115 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback | ||
116 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red | ||
117 | ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow | ||
118 | ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta | ||
119 | ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White | ||
120 | // intensiv | ||
121 | ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), | ||
122 | ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), | ||
123 | ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), | ||
124 | ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), | ||
125 | ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) | ||
126 | }; | ||
127 | |||
128 | /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) | ||
129 | |||
130 | Code 0 1 2 3 4 5 6 7 | ||
131 | ----------- ------- ------- ------- ------- ------- ------- ------- ------- | ||
132 | ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White | ||
133 | IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White | ||
134 | */ | ||
135 | |||
136 | QColor Widget::getDefaultBackColor() | ||
137 | { | ||
138 | return color_table[DEFAULT_BACK_COLOR].color; | ||
139 | } | ||
140 | |||
141 | const ColorEntry* Widget::getColorTable() const | ||
142 | { | ||
143 | return color_table; | ||
144 | } | ||
145 | |||
146 | const ColorEntry* Widget::getdefaultColorTable() const | ||
147 | { | ||
148 | return base_color_table; | ||
149 | } | ||
150 | |||
151 | |||
152 | const QPixmap *Widget::backgroundPixmap() | ||
153 | { | ||
154 | static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); | ||
155 | const QPixmap *pm = bg; | ||
156 | return pm; | ||
157 | } | ||
158 | |||
159 | void Widget::setColorTable(const ColorEntry table[]) | ||
160 | { | ||
161 | for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; | ||
162 | |||
163 | const QPixmap* pm = backgroundPixmap(); | ||
164 | if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); | ||
165 | update(); | ||
166 | } | ||
167 | |||
168 | //FIXME: add backgroundPixmapChanged. | ||
169 | |||
170 | /* ------------------------------------------------------------------------- */ | ||
171 | /* */ | ||
172 | /* Font */ | ||
173 | /* */ | ||
174 | /* ------------------------------------------------------------------------- */ | ||
175 | |||
176 | /* | ||
177 | The VT100 has 32 special graphical characters. The usual vt100 extended | ||
178 | xterm fonts have these at 0x00..0x1f. | ||
179 | |||
180 | QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals | ||
181 | come in here as proper unicode characters. | ||
182 | |||
183 | We treat non-iso10646 fonts as VT100 extended and do the requiered mapping | ||
184 | from unicode to 0x00..0x1f. The remaining translation is then left to the | ||
185 | QCodec. | ||
186 | */ | ||
187 | |||
188 | // assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. | ||
189 | |||
190 | unsigned short vt100_graphics[32] = | ||
191 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 | ||
192 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, | ||
193 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, | ||
194 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, | ||
195 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 | ||
196 | }; | ||
197 | |||
198 | static QChar vt100extended(QChar c) | ||
199 | { | ||
200 | switch (c.unicode()) | ||
201 | { | ||
202 | case 0x25c6 : return 1; | ||
203 | case 0x2592 : return 2; | ||
204 | case 0x2409 : return 3; | ||
205 | case 0x240c : return 4; | ||
206 | case 0x240d : return 5; | ||
207 | case 0x240a : return 6; | ||
208 | case 0x00b0 : return 7; | ||
209 | case 0x00b1 : return 8; | ||
210 | case 0x2424 : return 9; | ||
211 | case 0x240b : return 10; | ||
212 | case 0x2518 : return 11; | ||
213 | case 0x2510 : return 12; | ||
214 | case 0x250c : return 13; | ||
215 | case 0x2514 : return 14; | ||
216 | case 0x253c : return 15; | ||
217 | case 0xf800 : return 16; | ||
218 | case 0xf801 : return 17; | ||
219 | case 0x2500 : return 18; | ||
220 | case 0xf803 : return 19; | ||
221 | case 0xf804 : return 20; | ||
222 | case 0x251c : return 21; | ||
223 | case 0x2524 : return 22; | ||
224 | case 0x2534 : return 23; | ||
225 | case 0x252c : return 24; | ||
226 | case 0x2502 : return 25; | ||
227 | case 0x2264 : return 26; | ||
228 | case 0x2265 : return 27; | ||
229 | case 0x03c0 : return 28; | ||
230 | case 0x2260 : return 29; | ||
231 | case 0x00a3 : return 30; | ||
232 | case 0x00b7 : return 31; | ||
233 | } | ||
234 | return c; | ||
235 | } | ||
236 | |||
237 | static QChar identicalMap(QChar c) | ||
238 | { | ||
239 | return c; | ||
240 | } | ||
241 | |||
242 | void Widget::fontChange(const QFont &) | ||
243 | { | ||
244 | QFontMetrics fm(font()); | ||
245 | font_h = fm.height(); | ||
246 | font_w = fm.maxWidth(); | ||
247 | font_a = fm.ascent(); | ||
248 | //printf("font_h: %d\n",font_h); | ||
249 | //printf("font_w: %d\n",font_w); | ||
250 | //printf("font_a: %d\n",font_a); | ||
251 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); | ||
252 | //printf("rawname: %s\n",font().rawName().ascii()); | ||
253 | fontMap = | ||
254 | #if QT_VERSION < 300 | ||
255 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") | ||
256 | ? vt100extended | ||
257 | : | ||
258 | #endif | ||
259 | identicalMap; | ||
260 | propagateSize(); | ||
261 | update(); | ||
262 | } | ||
263 | |||
264 | void Widget::setVTFont(const QFont& f) | ||
265 | { | ||
266 | QFrame::setFont(f); | ||
267 | } | ||
268 | |||
269 | QFont Widget::getVTFont() { | ||
270 | return font(); | ||
271 | } | ||
272 | |||
273 | void Widget::setFont(const QFont &) | ||
274 | { | ||
275 | // ignore font change request if not coming from konsole itself | ||
276 | } | ||
277 | |||
278 | /* ------------------------------------------------------------------------- */ | ||
279 | /* */ | ||
280 | /* Constructor / Destructor */ | ||
281 | /* */ | ||
282 | /* ------------------------------------------------------------------------- */ | ||
283 | |||
284 | Widget::Widget(QWidget *parent, const char *name) : QFrame(parent,name) | ||
285 | { | ||
286 | #ifndef QT_NO_CLIPBOARD | ||
287 | cb = QApplication::clipboard(); | ||
288 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | ||
289 | this, SLOT(onClearSelection()) ); | ||
290 | #endif | ||
291 | |||
292 | scrollbar = new QScrollBar(this); | ||
293 | scrollbar->setCursor( arrowCursor ); | ||
294 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | ||
295 | |||
296 | Config cfg("Konsole"); | ||
297 | cfg.setGroup("ScrollBar"); | ||
298 | switch( cfg.readNumEntry("Position",2)){ | ||
299 | case 0: | ||
300 | scrollLoc = SCRNONE; | ||
301 | break; | ||
302 | case 1: | ||
303 | scrollLoc = SCRLEFT; | ||
304 | break; | ||
305 | case 2: | ||
306 | scrollLoc = SCRRIGHT; | ||
307 | break; | ||
308 | }; | ||
309 | |||
310 | blinkT = new QTimer(this); | ||
311 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); | ||
312 | // blinking = FALSE; | ||
313 | blinking = TRUE; | ||
314 | |||
315 | resizing = FALSE; | ||
316 | actSel = 0; | ||
317 | image = 0; | ||
318 | lines = 1; | ||
319 | columns = 1; | ||
320 | font_w = 1; | ||
321 | font_h = 1; | ||
322 | font_a = 1; | ||
323 | word_selection_mode = FALSE; | ||
324 | |||
325 | setMouseMarks(TRUE); | ||
326 | setVTFont( QFont("fixed") ); | ||
327 | setColorTable(base_color_table); // init color table | ||
328 | |||
329 | qApp->installEventFilter( this ); //FIXME: see below | ||
330 | // KCursor::setAutoHideCursor( this, true ); | ||
331 | |||
332 | // Init DnD //////////////////////////////////////////////////////////////// | ||
333 | currentSession = NULL; | ||
334 | // setAcceptDrops(true); // attempt | ||
335 | // m_drop = new QPopupMenu(this); | ||
336 | // m_drop->insertItem( QString("Paste"), 0); | ||
337 | // m_drop->insertItem( QString("cd"), 1); | ||
338 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); | ||
339 | |||
340 | // we need focus so that the auto-hide cursor feature works | ||
341 | setFocus(); | ||
342 | setFocusPolicy( WheelFocus ); | ||
343 | } | ||
344 | |||
345 | //FIXME: make proper destructor | ||
346 | // Here's a start (David) | ||
347 | Widget::~Widget() | ||
348 | { | ||
349 | qApp->removeEventFilter( this ); | ||
350 | if (image) free(image); | ||
351 | } | ||
352 | |||
353 | /* ------------------------------------------------------------------------- */ | ||
354 | /* */ | ||
355 | /* Display Operations */ | ||
356 | /* */ | ||
357 | /* ------------------------------------------------------------------------- */ | ||
358 | |||
359 | /*! | ||
360 | attributed string draw primitive | ||
361 | */ | ||
362 | |||
363 | void Widget::drawAttrStr(QPainter &paint, QRect rect, | ||
364 | QString& str, Character attr, BOOL pm, BOOL clear) | ||
365 | { | ||
366 | if (pm && color_table[attr.b].transparent) | ||
367 | { | ||
368 | paint.setBackgroundMode( TransparentMode ); | ||
369 | if (clear) erase(rect); | ||
370 | } | ||
371 | else | ||
372 | { | ||
373 | if (blinking) | ||
374 | paint.fillRect(rect, color_table[attr.b].color); | ||
375 | else | ||
376 | { | ||
377 | paint.setBackgroundMode( OpaqueMode ); | ||
378 | paint.setBackgroundColor( color_table[attr.b].color ); | ||
379 | } | ||
380 | } | ||
381 | |||
382 | if (color_table[attr.f].bold) | ||
383 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); | ||
384 | else | ||
385 | paint.setPen(color_table[attr.f].color); | ||
386 | |||
387 | paint.drawText(rect.x(),rect.y()+font_a, str); | ||
388 | |||
389 | if (attr.r & RE_UNDERLINE) | ||
390 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); | ||
391 | } | ||
392 | |||
393 | /*! | ||
394 | The image can only be set completely. | ||
395 | |||
396 | The size of the new image may or may not match the size of the widget. | ||
397 | */ | ||
398 | |||
399 | void Widget::setImage(const Character* const newimg, int lines, int columns) | ||
400 | { int y,x,len; | ||
401 | const QPixmap* pm = backgroundPixmap(); | ||
402 | QPainter paint; | ||
403 | setUpdatesEnabled(FALSE); | ||
404 | paint.begin( this ); | ||
405 | HCNT("setImage"); | ||
406 | |||
407 | QPoint tL = contentsRect().topLeft(); | ||
408 | int tLx = tL.x(); | ||
409 | int tLy = tL.y(); | ||
410 | hasBlinker = FALSE; | ||
411 | |||
412 | int cf = -1; // undefined | ||
413 | int cb = -1; // undefined | ||
414 | int cr = -1; // undefined | ||
415 | |||
416 | int lins = QMIN(this->lines, QMAX(0,lines )); | ||
417 | int cols = QMIN(this->columns,QMAX(0,columns)); | ||
418 | QChar *disstrU = new QChar[cols]; | ||
419 | |||
420 | //{ static int cnt = 0; printf("setImage %d\n",cnt++); } | ||
421 | for (y = 0; y < lins; y++) | ||
422 | { | ||
423 | const Character* lcl = &image[y*this->columns]; | ||
424 | const Character* const ext = &newimg[y*columns]; | ||
425 | if (!resizing) // not while resizing, we're expecting a paintEvent | ||
426 | for (x = 0; x < cols; x++) | ||
427 | { | ||
428 | hasBlinker |= (ext[x].r & RE_BLINK); | ||
429 | if (ext[x] != lcl[x]) | ||
430 | { | ||
431 | cr = ext[x].r; | ||
432 | cb = ext[x].b; | ||
433 | if (ext[x].f != cf) cf = ext[x].f; | ||
434 | int lln = cols - x; | ||
435 | disstrU[0] = fontMap(ext[x+0].c); | ||
436 | for (len = 1; len < lln; len++) | ||
437 | { | ||
438 | if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || | ||
439 | ext[x+len] == lcl[x+len] ) | ||
440 | break; | ||
441 | disstrU[len] = fontMap(ext[x+len].c); | ||
442 | } | ||
443 | QString unistr(disstrU,len); | ||
444 | drawAttrStr(paint, | ||
445 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), | ||
446 | unistr, ext[x], pm != NULL, true); | ||
447 | x += len - 1; | ||
448 | } | ||
449 | } | ||
450 | // finally, make `image' become `newimg'. | ||
451 | memcpy((void*)lcl,(const void*)ext,cols*sizeof(Character)); | ||
452 | } | ||
453 | drawFrame( &paint ); | ||
454 | paint.end(); | ||
455 | setUpdatesEnabled(TRUE); | ||
456 | if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms | ||
457 | if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } | ||
458 | delete [] disstrU; | ||
459 | } | ||
460 | |||
461 | // paint Event //////////////////////////////////////////////////// | ||
462 | |||
463 | /*! | ||
464 | The difference of this routine vs. the `setImage' is, | ||
465 | that the drawing does not include a difference analysis | ||
466 | between the old and the new image. Instead, the internal | ||
467 | image is used and the painting bound by the PaintEvent box. | ||
468 | */ | ||
469 | |||
470 | void Widget::paintEvent( QPaintEvent* pe ) | ||
471 | { | ||
472 | |||
473 | //{ static int cnt = 0; printf("paint %d\n",cnt++); } | ||
474 | const QPixmap* pm = backgroundPixmap(); | ||
475 | QPainter paint; | ||
476 | setUpdatesEnabled(FALSE); | ||
477 | paint.begin( this ); | ||
478 | paint.setBackgroundMode( TransparentMode ); | ||
479 | HCNT("paintEvent"); | ||
480 | |||
481 | // Note that the actual widget size can be slightly larger | ||
482 | // that the image (the size is truncated towards the smaller | ||
483 | // number of characters in `resizeEvent'. The paint rectangle | ||
484 | // can thus be larger than the image, but less then the size | ||
485 | // of one character. | ||
486 | |||
487 | QRect rect = pe->rect().intersect(contentsRect()); | ||
488 | |||
489 | QPoint tL = contentsRect().topLeft(); | ||
490 | int tLx = tL.x(); | ||
491 | int tLy = tL.y(); | ||
492 | |||
493 | int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); | ||
494 | int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); | ||
495 | int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); | ||
496 | int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); | ||
497 | |||
498 | /* | ||
499 | printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, | ||
500 | rect.left(), rect.right(), rect.top(), rect.bottom()); | ||
501 | */ | ||
502 | |||
503 | // if (pm != NULL && color_table[image->b].transparent) | ||
504 | // erase(rect); | ||
505 | // BL: I have no idea why we need this, and it breaks the refresh. | ||
506 | |||
507 | QChar *disstrU = new QChar[columns]; | ||
508 | for (int y = luy; y <= rly; y++) | ||
509 | for (int x = lux; x <= rlx; x++) | ||
510 | { | ||
511 | int len = 1; | ||
512 | disstrU[0] = fontMap(image[loc(x,y)].c); | ||
513 | int cf = image[loc(x,y)].f; | ||
514 | int cb = image[loc(x,y)].b; | ||
515 | int cr = image[loc(x,y)].r; | ||
516 | while (x+len <= rlx && | ||
517 | image[loc(x+len,y)].f == cf && | ||
518 | image[loc(x+len,y)].b == cb && | ||
519 | image[loc(x+len,y)].r == cr ) | ||
520 | { | ||
521 | disstrU[len] = fontMap(image[loc(x+len,y)].c); | ||
522 | len += 1; | ||
523 | } | ||
524 | QString unistr(disstrU,len); | ||
525 | drawAttrStr(paint, | ||
526 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), | ||
527 | unistr, image[loc(x,y)], pm != NULL, false); | ||
528 | x += len - 1; | ||
529 | } | ||
530 | delete [] disstrU; | ||
531 | drawFrame( &paint ); | ||
532 | paint.end(); | ||
533 | setUpdatesEnabled(TRUE); | ||
534 | } | ||
535 | |||
536 | void Widget::blinkEvent() | ||
537 | { | ||
538 | blinking = !blinking; | ||
539 | repaint(FALSE); | ||
540 | } | ||
541 | |||
542 | /* ------------------------------------------------------------------------- */ | ||
543 | /* */ | ||
544 | /* Resizing */ | ||
545 | /* */ | ||
546 | /* ------------------------------------------------------------------------- */ | ||
547 | |||
548 | void Widget::resizeEvent(QResizeEvent* ev) | ||
549 | { | ||
550 | // printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); | ||
551 | //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); | ||
552 | //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); | ||
553 | //printf("curren: %d,%d\n",width(),height()); | ||
554 | HCNT("resizeEvent"); | ||
555 | |||
556 | // see comment in `paintEvent' concerning the rounding. | ||
557 | //FIXME: could make a routine here; check width(),height() | ||
558 | assert(ev->size().width() == width()); | ||
559 | assert(ev->size().height() == height()); | ||
560 | |||
561 | propagateSize(); | ||
562 | } | ||
563 | |||
564 | void Widget::propagateSize() | ||
565 | { | ||
566 | Character* oldimg = image; | ||
567 | int oldlin = lines; | ||
568 | int oldcol = columns; | ||
569 | makeImage(); | ||
570 | // we copy the old image to reduce flicker | ||
571 | int lins = QMIN(oldlin,lines); | ||
572 | int cols = QMIN(oldcol,columns); | ||
573 | if (oldimg) | ||
574 | { | ||
575 | for (int lin = 0; lin < lins; lin++) | ||
576 | memcpy((void*)&image[columns*lin], | ||
577 | (void*)&oldimg[oldcol*lin],cols*sizeof(Character)); | ||
578 | free(oldimg); //FIXME: try new,delete | ||
579 | } | ||
580 | else | ||
581 | clearImage(); | ||
582 | |||
583 | //NOTE: control flows from the back through the chest right into the eye. | ||
584 | // `emu' will call back via `setImage'. | ||
585 | |||
586 | resizing = TRUE; | ||
587 | emit changedImageSizeSignal(lines, columns); // expose resizeEvent | ||
588 | resizing = FALSE; | ||
589 | } | ||
590 | |||
591 | /* ------------------------------------------------------------------------- */ | ||
592 | /* */ | ||
593 | /* Scrollbar */ | ||
594 | /* */ | ||
595 | /* ------------------------------------------------------------------------- */ | ||
596 | |||
597 | void Widget::scrollChanged(int) | ||
598 | { | ||
599 | emit changedHistoryCursor(scrollbar->value()); //expose | ||
600 | } | ||
601 | |||
602 | void Widget::setScroll(int cursor, int slines) | ||
603 | { | ||
604 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | ||
605 | scrollbar->setRange(0,slines); | ||
606 | scrollbar->setSteps(1,lines); | ||
607 | scrollbar->setValue(cursor); | ||
608 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | ||
609 | } | ||
610 | |||
611 | void Widget::setScrollbarLocation(int loc) | ||
612 | { | ||
613 | if (scrollLoc == loc) return; // quickly | ||
614 | scrollLoc = loc; | ||
615 | propagateSize(); | ||
616 | update(); | ||
617 | } | ||
618 | |||
619 | /* ------------------------------------------------------------------------- */ | ||
620 | /* */ | ||
621 | /* Mouse */ | ||
622 | /* */ | ||
623 | /* ------------------------------------------------------------------------- */ | ||
624 | |||
625 | /*! | ||
626 | Three different operations can be performed using the mouse, and the | ||
627 | routines in this section serve all of them: | ||
628 | |||
629 | 1) The press/release events are exposed to the application | ||
630 | 2) Marking (press and move left button) and Pasting (press middle button) | ||
631 | 3) The right mouse button is used from the configuration menu | ||
632 | |||
633 | NOTE: During the marking process we attempt to keep the cursor within | ||
634 | the bounds of the text as being displayed by setting the mouse position | ||
635 | whenever the mouse has left the text area. | ||
636 | |||
637 | Two reasons to do so: | ||
638 | 1) QT does not allow the `grabMouse' to confine-to the Widget. | ||
639 | Thus a `XGrapPointer' would have to be used instead. | ||
640 | 2) Even if so, this would not help too much, since the text area | ||
641 | of the Widget is normally not identical with it's bounds. | ||
642 | |||
643 | The disadvantage of the current handling is, that the mouse can visibly | ||
644 | leave the bounds of the widget and is then moved back. Because of the | ||
645 | current construction, and the reasons mentioned above, we cannot do better | ||
646 | without changing the overall construction. | ||
647 | */ | ||
648 | |||
649 | /*! | ||
650 | */ | ||
651 | |||
652 | void Widget::mousePressEvent(QMouseEvent* ev) | ||
653 | { | ||
654 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | ||
655 | if ( !contentsRect().contains(ev->pos()) ) return; | ||
656 | QPoint tL = contentsRect().topLeft(); | ||
657 | int tLx = tL.x(); | ||
658 | int tLy = tL.y(); | ||
659 | |||
660 | word_selection_mode = FALSE; | ||
661 | |||
662 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); | ||
663 | if ( ev->button() == LeftButton) | ||
664 | { | ||
665 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | ||
666 | |||
667 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; | ||
668 | |||
669 | if (mouse_marks || (ev->state() & ShiftButton)) | ||
670 | { | ||
671 | emit clearSelectionSignal(); | ||
672 | iPntSel = pntSel = pos; | ||
673 | actSel = 1; // left mouse button pressed but nothing selected yet. | ||
674 | grabMouse( /*crossCursor*/ ); // handle with care! | ||
675 | } | ||
676 | else | ||
677 | { | ||
678 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button | ||
679 | } | ||
680 | } | ||
681 | if ( ev->button() == MidButton ) | ||
682 | { | ||
683 | emitSelection(); | ||
684 | } | ||
685 | if ( ev->button() == RightButton ) // Configure | ||
686 | { | ||
687 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); | ||
688 | } | ||
689 | } | ||
690 | |||
691 | void Widget::mouseMoveEvent(QMouseEvent* ev) | ||
692 | { | ||
693 | // for auto-hiding the cursor, we need mouseTracking | ||
694 | if (ev->state() == NoButton ) return; | ||
695 | |||
696 | if (actSel == 0) return; | ||
697 | |||
698 | // don't extend selection while pasting | ||
699 | if (ev->state() & MidButton) return; | ||
700 | |||
701 | //if ( !contentsRect().contains(ev->pos()) ) return; | ||
702 | QPoint tL = contentsRect().topLeft(); | ||
703 | int tLx = tL.x(); | ||
704 | int tLy = tL.y(); | ||
705 | int scroll = scrollbar->value(); | ||
706 | |||
707 | // we're in the process of moving the mouse with the left button pressed | ||
708 | // the mouse cursor will kept catched within the bounds of the text in | ||
709 | // this widget. | ||
710 | |||
711 | // Adjust position within text area bounds. See FIXME above. | ||
712 | QPoint pos = ev->pos(); | ||
713 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); | ||
714 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); | ||
715 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); | ||
716 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); | ||
717 | // check if we produce a mouse move event by this | ||
718 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); | ||
719 | |||
720 | if ( pos.y() == tLy+bY+lines*font_h-1 ) | ||
721 | { | ||
722 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward | ||
723 | } | ||
724 | if ( pos.y() == tLy+bY ) | ||
725 | { | ||
726 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback | ||
727 | } | ||
728 | |||
729 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); | ||
730 | QPoint ohere; | ||
731 | bool swapping = FALSE; | ||
732 | |||
733 | if ( word_selection_mode ) | ||
734 | { | ||
735 | // Extend to word boundaries | ||
736 | int i; | ||
737 | int selClass; | ||
738 | |||
739 | bool left_not_right = ( here.y() < iPntSel.y() || | ||
740 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); | ||
741 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || | ||
742 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); | ||
743 | swapping = left_not_right != old_left_not_right; | ||
744 | |||
745 | // Find left (left_not_right ? from here : from start) | ||
746 | QPoint left = left_not_right ? here : iPntSel; | ||
747 | i = loc(left.x(),left.y()); | ||
748 | selClass = charClass(image[i].c); | ||
749 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) | ||
750 | { i--; left.rx()--; } | ||
751 | |||
752 | // Find left (left_not_right ? from start : from here) | ||
753 | QPoint right = left_not_right ? iPntSel : here; | ||
754 | i = loc(right.x(),right.y()); | ||
755 | selClass = charClass(image[i].c); | ||
756 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) | ||
757 | { i++; right.rx()++; } | ||
758 | |||
759 | // Pick which is start (ohere) and which is extension (here) | ||
760 | if ( left_not_right ) | ||
761 | { | ||
762 | here = left; ohere = right; | ||
763 | } | ||
764 | else | ||
765 | { | ||
766 | here = right; ohere = left; | ||
767 | } | ||
768 | } | ||
769 | |||
770 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved | ||
771 | |||
772 | if ( word_selection_mode ) { | ||
773 | if ( actSel < 2 || swapping ) { | ||
774 | emit beginSelectionSignal( ohere.x(), ohere.y() ); | ||
775 | } | ||
776 | } else if ( actSel < 2 ) { | ||
777 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); | ||
778 | } | ||
779 | |||
780 | actSel = 2; // within selection | ||
781 | pntSel = here; | ||
782 | emit extendSelectionSignal( here.x(), here.y() ); | ||
783 | } | ||
784 | |||
785 | void Widget::mouseReleaseEvent(QMouseEvent* ev) | ||
786 | { | ||
787 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | ||
788 | if ( ev->button() == LeftButton) | ||
789 | { | ||
790 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); | ||
791 | preserve_line_breaks = TRUE; | ||
792 | actSel = 0; | ||
793 | |||
794 | //FIXME: emits a release event even if the mouse is | ||
795 | // outside the range. The procedure used in `mouseMoveEvent' | ||
796 | // applies here, too. | ||
797 | |||
798 | QPoint tL = contentsRect().topLeft(); | ||
799 | int tLx = tL.x(); | ||
800 | int tLy = tL.y(); | ||
801 | |||
802 | if (!mouse_marks && !(ev->state() & ShiftButton)) | ||
803 | emit mouseSignal( 3, // release | ||
804 | (ev->x()-tLx-blX)/font_w + 1, | ||
805 | (ev->y()-tLy-bY)/font_h + 1 ); | ||
806 | releaseMouse(); | ||
807 | } | ||
808 | } | ||
809 | |||
810 | void Widget::mouseDoubleClickEvent(QMouseEvent* ev) | ||
811 | { | ||
812 | if ( ev->button() != LeftButton) return; | ||
813 | |||
814 | QPoint tL = contentsRect().topLeft(); | ||
815 | int tLx = tL.x(); | ||
816 | int tLy = tL.y(); | ||
817 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | ||
818 | |||
819 | // pass on double click as two clicks. | ||
820 | if (!mouse_marks && !(ev->state() & ShiftButton)) | ||
821 | { | ||
822 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | ||
823 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release | ||
824 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | ||
825 | return; | ||
826 | } | ||
827 | |||
828 | |||
829 | emit clearSelectionSignal(); | ||
830 | QPoint bgnSel = pos; | ||
831 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | ||
832 | int i = loc(bgnSel.x(),bgnSel.y()); | ||
833 | iPntSel = bgnSel; | ||
834 | |||
835 | word_selection_mode = TRUE; | ||
836 | |||
837 | // find word boundaries... | ||
838 | int selClass = charClass(image[i].c); | ||
839 | { | ||
840 | // set the start... | ||
841 | int x = bgnSel.x(); | ||
842 | while ( x > 0 && charClass(image[i-1].c) == selClass ) | ||
843 | { i--; x--; } | ||
844 | bgnSel.setX(x); | ||
845 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); | ||
846 | |||
847 | // set the end... | ||
848 | i = loc( endSel.x(), endSel.y() ); | ||
849 | x = endSel.x(); | ||
850 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) | ||
851 | { i++; x++ ; } | ||
852 | endSel.setX(x); | ||
853 | actSel = 2; // within selection | ||
854 | emit extendSelectionSignal( endSel.x(), endSel.y() ); | ||
855 | emit endSelectionSignal(preserve_line_breaks); | ||
856 | preserve_line_breaks = TRUE; | ||
857 | } | ||
858 | } | ||
859 | |||
860 | void Widget::focusInEvent( QFocusEvent * ) | ||
861 | { | ||
862 | |||
863 | // do nothing, to prevent repainting | ||
864 | } | ||
865 | |||
866 | |||
867 | void Widget::focusOutEvent( QFocusEvent * ) | ||
868 | { | ||
869 | // do nothing, to prevent repainting | ||
870 | } | ||
871 | |||
872 | bool Widget::focusNextPrevChild( bool next ) | ||
873 | { | ||
874 | if (next) | ||
875 | return false; // This disables changing the active part in konqueror | ||
876 | // when pressing Tab | ||
877 | return QFrame::focusNextPrevChild( next ); | ||
878 | } | ||
879 | |||
880 | |||
881 | int Widget::charClass(char ch) const | ||
882 | { | ||
883 | // This might seem like overkill, but imagine if ch was a Unicode | ||
884 | // character (Qt 2.0 QChar) - it might then be sensible to separate | ||
885 | // the different language ranges, etc. | ||
886 | |||
887 | if ( isspace(ch) ) return ' '; | ||
888 | |||
889 | static const char *word_characters = ":@-./_~"; | ||
890 | if ( isalnum(ch) || strchr(word_characters, ch) ) | ||
891 | return 'a'; | ||
892 | |||
893 | // Everything else is weird | ||
894 | return 1; | ||
895 | } | ||
896 | |||
897 | void Widget::setMouseMarks(bool on) | ||
898 | { | ||
899 | mouse_marks = on; | ||
900 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); | ||
901 | } | ||
902 | |||
903 | /* ------------------------------------------------------------------------- */ | ||
904 | /* */ | ||
905 | /* Clipboard */ | ||
906 | /* */ | ||
907 | /* ------------------------------------------------------------------------- */ | ||
908 | |||
909 | #undef KeyPress | ||
910 | |||
911 | void Widget::emitSelection() | ||
912 | // Paste Clipboard by simulating keypress events | ||
913 | { | ||
914 | #ifndef QT_NO_CLIPBOARD | ||
915 | QString text = QApplication::clipboard()->text(); | ||
916 | if ( ! text.isNull() ) | ||
917 | { | ||
918 | text.replace(QRegExp("\n"), "\r"); | ||
919 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | ||
920 | emit keyPressedSignal(&e); // expose as a big fat keypress event | ||
921 | emit clearSelectionSignal(); | ||
922 | } | ||
923 | #endif | ||
924 | } | ||
925 | |||
926 | void Widget::emitText(QString text) | ||
927 | { | ||
928 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | ||
929 | emit keyPressedSignal(&e); // expose as a big fat keypress event | ||
930 | } | ||
931 | |||
932 | void Widget::pasteClipboard( ) | ||
933 | { | ||
934 | emitSelection(); | ||
935 | } | ||
936 | |||
937 | void Widget::setSelection(const QString& t) | ||
938 | { | ||
939 | #ifndef QT_NO_CLIPBOARD | ||
940 | // Disconnect signal while WE set the clipboard | ||
941 | QObject *cb = QApplication::clipboard(); | ||
942 | QObject::disconnect( cb, SIGNAL(dataChanged()), | ||
943 | this, SLOT(onClearSelection()) ); | ||
944 | |||
945 | QApplication::clipboard()->setText(t); | ||
946 | |||
947 | QObject::connect( cb, SIGNAL(dataChanged()), | ||
948 | this, SLOT(onClearSelection()) ); | ||
949 | #endif | ||
950 | } | ||
951 | |||
952 | void Widget::onClearSelection() | ||
953 | { | ||
954 | emit clearSelectionSignal(); | ||
955 | } | ||
956 | |||
957 | /* ------------------------------------------------------------------------- */ | ||
958 | /* */ | ||
959 | /* Keyboard */ | ||
960 | /* */ | ||
961 | /* ------------------------------------------------------------------------- */ | ||
962 | |||
963 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' | ||
964 | // due to a bug in `QT' or the ignorance of the author to prevent | ||
965 | // repaint events being emitted to the screen whenever one leaves | ||
966 | // or reenters the screen to/from another application. | ||
967 | // | ||
968 | // Troll says one needs to change focusInEvent() and focusOutEvent(), | ||
969 | // which would also let you have an in-focus cursor and an out-focus | ||
970 | // cursor like xterm does. | ||
971 | |||
972 | // for the auto-hide cursor feature, I added empty focusInEvent() and | ||
973 | // focusOutEvent() so that update() isn't called. | ||
974 | // For auto-hide, we need to get keypress-events, but we only get them when | ||
975 | // we have focus. | ||
976 | |||
977 | void Widget::doScroll(int lines) | ||
978 | { | ||
979 | scrollbar->setValue(scrollbar->value()+lines); | ||
980 | } | ||
981 | |||
982 | bool Widget::eventFilter( QObject *obj, QEvent *e ) | ||
983 | { | ||
984 | if ( (e->type() == QEvent::Accel || | ||
985 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | ||
986 | static_cast<QKeyEvent *>( e )->ignore(); | ||
987 | return true; | ||
988 | } | ||
989 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | ||
990 | return FALSE; // not us | ||
991 | if ( e->type() == QEvent::Wheel) { | ||
992 | QApplication::sendEvent(scrollbar, e); | ||
993 | } | ||
994 | |||
995 | #ifdef FAKE_CTRL_AND_ALT | ||
996 | static bool control = FALSE; | ||
997 | static bool alt = FALSE; | ||
998 | bool dele=FALSE; | ||
999 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | ||
1000 | QKeyEvent* ke = (QKeyEvent*)e; | ||
1001 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | ||
1002 | switch (ke->key()) { | ||
1003 | case Key_F9: // let this be "Control" | ||
1004 | control = keydown; | ||
1005 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | ||
1006 | dele=TRUE; | ||
1007 | break; | ||
1008 | case Key_F13: // let this be "Alt" | ||
1009 | alt = keydown; | ||
1010 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | ||
1011 | dele=TRUE; | ||
1012 | break; | ||
1013 | default: | ||
1014 | if ( control ) { | ||
1015 | int a = toupper(ke->ascii())-64; | ||
1016 | if ( a >= 0 && a < ' ' ) { | ||
1017 | e = new QKeyEvent(e->type(), ke->key(), | ||
1018 | a, ke->state()|ControlButton, QChar(a,0)); | ||
1019 | dele=TRUE; | ||
1020 | } | ||
1021 | } | ||
1022 | if ( alt ) { | ||
1023 | e = new QKeyEvent(e->type(), ke->key(), | ||
1024 | ke->ascii(), ke->state()|AltButton, ke->text()); | ||
1025 | dele=TRUE; | ||
1026 | } | ||
1027 | } | ||
1028 | } | ||
1029 | #endif | ||
1030 | |||
1031 | if ( e->type() == QEvent::KeyPress ) { | ||
1032 | QKeyEvent* ke = (QKeyEvent*)e; | ||
1033 | actSel=0; // Key stroke implies a screen update, so Widget won't | ||
1034 | // know where the current selection is. | ||
1035 | |||
1036 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker | ||
1037 | emitText("\\"); // expose | ||
1038 | } else | ||
1039 | emit keyPressedSignal(ke); // expose | ||
1040 | ke->accept(); | ||
1041 | #ifdef FAKE_CTRL_AND_ALT | ||
1042 | if ( dele ) delete e; | ||
1043 | #endif | ||
1044 | return true; // stop the event | ||
1045 | } | ||
1046 | if ( e->type() == QEvent::Enter ) { | ||
1047 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | ||
1048 | this, SLOT(onClearSelection()) ); | ||
1049 | } | ||
1050 | if ( e->type() == QEvent::Leave ) { | ||
1051 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | ||
1052 | this, SLOT(onClearSelection()) ); | ||
1053 | } | ||
1054 | return QFrame::eventFilter( obj, e ); | ||
1055 | } | ||
1056 | |||
1057 | /* ------------------------------------------------------------------------- */ | ||
1058 | /* */ | ||
1059 | /* Frame */ | ||
1060 | /* */ | ||
1061 | /* ------------------------------------------------------------------------- */ | ||
1062 | |||
1063 | void Widget::frameChanged() | ||
1064 | { | ||
1065 | propagateSize(); | ||
1066 | update(); | ||
1067 | } | ||
1068 | |||
1069 | /* ------------------------------------------------------------------------- */ | ||
1070 | /* */ | ||
1071 | /* Sound */ | ||
1072 | /* */ | ||
1073 | /* ------------------------------------------------------------------------- */ | ||
1074 | |||
1075 | void Widget::Bell() | ||
1076 | { | ||
1077 | QApplication::beep(); | ||
1078 | } | ||
1079 | |||
1080 | /* ------------------------------------------------------------------------- */ | ||
1081 | /* */ | ||
1082 | /* Auxiluary */ | ||
1083 | /* */ | ||
1084 | /* ------------------------------------------------------------------------- */ | ||
1085 | |||
1086 | void Widget::clearImage() | ||
1087 | // initialize the image | ||
1088 | // for internal use only | ||
1089 | { | ||
1090 | for (int y = 0; y < lines; y++) | ||
1091 | for (int x = 0; x < columns; x++) | ||
1092 | { | ||
1093 | image[loc(x,y)].c = 0xff; //' '; | ||
1094 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | ||
1095 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | ||
1096 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | ||
1097 | } | ||
1098 | } | ||
1099 | |||
1100 | // Create Image /////////////////////////////////////////////////////// | ||
1101 | |||
1102 | void Widget::calcGeometry() | ||
1103 | { | ||
1104 | //FIXME: set rimX == rimY == 0 when running in full screen mode. | ||
1105 | |||
1106 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | ||
1107 | contentsRect().height()); | ||
1108 | switch(scrollLoc) | ||
1109 | { | ||
1110 | case SCRNONE : | ||
1111 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | ||
1112 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | ||
1113 | brX = blX; | ||
1114 | scrollbar->hide(); | ||
1115 | break; | ||
1116 | case SCRLEFT : | ||
1117 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | ||
1118 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | ||
1119 | blX = brX + scrollbar->width(); | ||
1120 | scrollbar->move(contentsRect().topLeft()); | ||
1121 | scrollbar->show(); | ||
1122 | break; | ||
1123 | case SCRRIGHT: | ||
1124 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | ||
1125 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | ||
1126 | brX = blX; | ||
1127 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | ||
1128 | scrollbar->show(); | ||
1129 | break; | ||
1130 | } | ||
1131 | //FIXME: support 'rounding' styles | ||
1132 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | ||
1133 | bY = (contentsRect().height() - (lines *font_h)) / 2; | ||
1134 | } | ||
1135 | |||
1136 | void Widget::makeImage() | ||
1137 | //FIXME: rename 'calcGeometry? | ||
1138 | { | ||
1139 | calcGeometry(); | ||
1140 | image = (Character*) malloc(lines*columns*sizeof(Character)); | ||
1141 | clearImage(); | ||
1142 | } | ||
1143 | |||
1144 | // calculate the needed size | ||
1145 | QSize Widget::calcSize(int cols, int lins) const | ||
1146 | { | ||
1147 | int frw = width() - contentsRect().width(); | ||
1148 | int frh = height() - contentsRect().height(); | ||
1149 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); | ||
1150 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); | ||
1151 | } | ||
1152 | |||
1153 | QSize Widget::sizeHint() const | ||
1154 | { | ||
1155 | return size(); | ||
1156 | } | ||
1157 | |||
1158 | void Widget::styleChange(QStyle &) | ||
1159 | { | ||
1160 | propagateSize(); | ||
1161 | } | ||
1162 | |||
1163 | #ifndef QT_NO_DRAGANDDROP | ||
1164 | |||
1165 | /* --------------------------------------------------------------------- */ | ||
1166 | /* */ | ||
1167 | /* Drag & Drop */ | ||
1168 | /* */ | ||
1169 | /* --------------------------------------------------------------------- */ | ||
1170 | |||
1171 | |||
1172 | void Widget::dragEnterEvent(QDragEnterEvent* e) | ||
1173 | { | ||
1174 | e->accept(QTextDrag::canDecode(e) || | ||
1175 | QUriDrag::canDecode(e)); | ||
1176 | } | ||
1177 | |||
1178 | void Widget::dropEvent(QDropEvent* event) | ||
1179 | { | ||
1180 | // The current behaviour when url(s) are dropped is | ||
1181 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd | ||
1182 | // * in all other cases, just paste | ||
1183 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) | ||
1184 | QStrList strlist; | ||
1185 | int file_count = 0; | ||
1186 | dropText = ""; | ||
1187 | bool bPopup = true; | ||
1188 | |||
1189 | if(QUriDrag::decode(event, strlist)) { | ||
1190 | if (strlist.count()) { | ||
1191 | for(const char* p = strlist.first(); p; p = strlist.next()) { | ||
1192 | if(file_count++ > 0) { | ||
1193 | dropText += " "; | ||
1194 | bPopup = false; // more than one file, don't popup | ||
1195 | } | ||
1196 | |||
1197 | /* | ||
1198 | KURL url(p); | ||
1199 | if (url.isLocalFile()) { | ||
1200 | dropText += url.path(); // local URL : remove protocol | ||
1201 | } | ||
1202 | else { | ||
1203 | dropText += url.prettyURL(); | ||
1204 | bPopup = false; // a non-local file, don't popup | ||
1205 | } | ||
1206 | */ | ||
1207 | |||
1208 | } | ||
1209 | |||
1210 | if (bPopup) | ||
1211 | // m_drop->popup(pos() + event->pos()); | ||
1212 | m_drop->popup(mapToGlobal(event->pos())); | ||
1213 | else | ||
1214 | { | ||
1215 | if (currentSession) { | ||
1216 | //currentSession->getEmulation()->sendString(dropText.local8Bit()); | ||
1217 | QByteArray tmp; | ||
1218 | // ibot: this should be pretty wrong... | ||
1219 | // now it sends to the right layer | ||
1220 | currentSession-> emulationLayer()->send( tmp.setRawData( dropText.local8Bit())); | ||
1221 | } | ||
1222 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | ||
1223 | } | ||
1224 | } | ||
1225 | } | ||
1226 | else if(QTextDrag::decode(event, dropText)) { | ||
1227 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | ||
1228 | if (currentSession) { | ||
1229 | //currentSession->getEmulation()->sendString(dropText.local8Bit()); | ||
1230 | QByteArray tmp; | ||
1231 | currentSession->emulationLayer()->send( tmp.setRawData( dropText.local8Bit())); | ||
1232 | } | ||
1233 | // Paste it | ||
1234 | } | ||
1235 | } | ||
1236 | #endif | ||
1237 | |||
1238 | |||
1239 | void Widget::drop_menu_activated(int item) | ||
1240 | { | ||
1241 | #ifndef QT_NO_DRAGANDDROP | ||
1242 | QByteArray tmp; | ||
1243 | switch (item) | ||
1244 | { | ||
1245 | case 0: // paste | ||
1246 | //currentSession->getEmulation()->sendString(dropText.local8Bit()); | ||
1247 | currentSession->emulationLayer()->send( tmp.setRawData( dropText.local8Bit())); | ||
1248 | |||
1249 | // KWM::activate((Window)this->winId()); | ||
1250 | break; | ||
1251 | case 1: // cd ... | ||
1252 | //currentSession->getEmulation()->sendString("cd "); | ||
1253 | tmp.setRawData( "cd " ); | ||
1254 | currentSession->emulationLayer()->send( tmp ); | ||
1255 | struct stat statbuf; | ||
1256 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) | ||
1257 | { | ||
1258 | if ( !S_ISDIR(statbuf.st_mode) ) | ||
1259 | { | ||
1260 | /* | ||
1261 | KURL url; | ||
1262 | url.setPath( dropText ); | ||
1263 | dropText = url.directory( true, false ); // remove filename | ||
1264 | */ | ||
1265 | } | ||
1266 | } | ||
1267 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces | ||
1268 | QByteArray tmp2; | ||
1269 | tmp.setRawDate( dropText.local8Bit() + "\n" ); | ||
1270 | //currentSession->getEmulation()->sendString(dropText.local8Bit()); | ||
1271 | //currentSession->getEmulation()->sendString("\n"); | ||
1272 | currentSession->emulationLayer()->send( tmp ); | ||
1273 | // KWM::activate((Window)this->winId()); | ||
1274 | break; | ||
1275 | } | ||
1276 | #endif | ||
1277 | } | ||
1278 | |||
diff --git a/noncore/apps/opie-console/widget.h b/noncore/apps/opie-console/widget.h deleted file mode 100644 index cfd709c..0000000 --- a/noncore/apps/opie-console/widget.h +++ b/dev/null | |||
@@ -1,213 +0,0 @@ | |||
1 | /* ----------------------------------------------------------------------- */ | ||
2 | /* */ | ||
3 | /* [widget.h] Terminal Emulation Widget */ | ||
4 | /* */ | ||
5 | /* ----------------------------------------------------------------------- */ | ||
6 | /* */ | ||
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | ||
8 | /* */ | ||
9 | /* This file was part of Konsole - an X terminal for KDE */ | ||
10 | /* */ | ||
11 | /* ----------------------------------------------------------------------- */ | ||
12 | /* */ | ||
13 | /* Ported Konsole to Qt/Embedded */ | ||
14 | /* */ | ||
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | ||
16 | /* */ | ||
17 | /* -------------------------------------------------------------------------- */ | ||
18 | /* */ | ||
19 | /* modified to suit opie-console */ | ||
20 | /* */ | ||
21 | /* Copyright (c) 2002 by opie developers <opie@handhelds.org> */ | ||
22 | /* */ | ||
23 | /* ------------------------------------------------------------------------ */ | ||
24 | |||
25 | // ibot: TODO * | ||
26 | |||
27 | #ifndef WIDGET_H | ||
28 | #define WIDGET_H | ||
29 | |||
30 | #include <qapplication.h> | ||
31 | #include <qwidget.h> | ||
32 | #include <qlabel.h> | ||
33 | #include <qtimer.h> | ||
34 | #include <qcolor.h> | ||
35 | #include <qkeycode.h> | ||
36 | #include <qscrollbar.h> | ||
37 | |||
38 | #include <qpopupmenu.h> | ||
39 | |||
40 | #include "common.h" | ||
41 | |||
42 | extern unsigned short vt100_graphics[32]; | ||
43 | |||
44 | class Session; | ||
45 | |||
46 | // class Konsole; | ||
47 | |||
48 | class Widget : public QFrame | ||
49 | // a widget representing attributed text | ||
50 | { Q_OBJECT | ||
51 | |||
52 | // friend class Konsole; | ||
53 | |||
54 | public: | ||
55 | |||
56 | Widget(QWidget *parent=0, const char *name=0); | ||
57 | virtual ~Widget(); | ||
58 | |||
59 | public: | ||
60 | |||
61 | QColor getDefaultBackColor(); | ||
62 | |||
63 | const ColorEntry* getColorTable() const; | ||
64 | const ColorEntry* getdefaultColorTable() const; | ||
65 | void setColorTable(const ColorEntry table[]); | ||
66 | |||
67 | void setScrollbarLocation(int loc); | ||
68 | enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 }; | ||
69 | |||
70 | void setScroll(int cursor, int lines); | ||
71 | void doScroll(int lines); | ||
72 | |||
73 | void emitSelection(); | ||
74 | |||
75 | public: | ||
76 | |||
77 | void setImage(const Character* const newimg, int lines, int columns); | ||
78 | |||
79 | int Lines() { return lines; } | ||
80 | int Columns() { return columns; } | ||
81 | |||
82 | void calcGeometry(); | ||
83 | void propagateSize(); | ||
84 | QSize calcSize(int cols, int lins) const; | ||
85 | |||
86 | QSize sizeHint() const; | ||
87 | |||
88 | public: | ||
89 | |||
90 | void Bell(); | ||
91 | void emitText(QString text); | ||
92 | void pasteClipboard(); | ||
93 | |||
94 | signals: | ||
95 | |||
96 | void keyPressedSignal(QKeyEvent *e); | ||
97 | void mouseSignal(int cb, int cx, int cy); | ||
98 | void changedImageSizeSignal(int lines, int columns); | ||
99 | void changedHistoryCursor(int value); | ||
100 | void configureRequest( Widget*, int state, int x, int y ); | ||
101 | |||
102 | void clearSelectionSignal(); | ||
103 | void beginSelectionSignal( const int x, const int y ); | ||
104 | void extendSelectionSignal( const int x, const int y ); | ||
105 | void endSelectionSignal(const BOOL preserve_line_breaks); | ||
106 | |||
107 | |||
108 | protected: | ||
109 | |||
110 | virtual void styleChange( QStyle& ); | ||
111 | |||
112 | bool eventFilter( QObject *, QEvent * ); | ||
113 | |||
114 | void drawAttrStr(QPainter &paint, QRect rect, | ||
115 | QString& str, Character attr, BOOL pm, BOOL clear); | ||
116 | void paintEvent( QPaintEvent * ); | ||
117 | |||
118 | void resizeEvent(QResizeEvent*); | ||
119 | |||
120 | void fontChange(const QFont &font); | ||
121 | void frameChanged(); | ||
122 | |||
123 | void mouseDoubleClickEvent(QMouseEvent* ev); | ||
124 | void mousePressEvent( QMouseEvent* ); | ||
125 | void mouseReleaseEvent( QMouseEvent* ); | ||
126 | void mouseMoveEvent( QMouseEvent* ); | ||
127 | |||
128 | void focusInEvent( QFocusEvent * ); | ||
129 | void focusOutEvent( QFocusEvent * ); | ||
130 | bool focusNextPrevChild( bool next ); | ||
131 | |||
132 | #ifndef QT_NO_DRAGANDDROP | ||
133 | // Dnd | ||
134 | void dragEnterEvent(QDragEnterEvent* event); | ||
135 | void dropEvent(QDropEvent* event); | ||
136 | #endif | ||
137 | |||
138 | virtual int charClass(char) const; | ||
139 | |||
140 | void clearImage(); | ||
141 | |||
142 | public: | ||
143 | const QPixmap *backgroundPixmap(); | ||
144 | |||
145 | void setSelection(const QString &t); | ||
146 | |||
147 | virtual void setFont(const QFont &); | ||
148 | void setVTFont(const QFont &); | ||
149 | QFont getVTFont(); | ||
150 | |||
151 | void setMouseMarks(bool on); | ||
152 | |||
153 | public slots: | ||
154 | |||
155 | void onClearSelection(); | ||
156 | |||
157 | protected slots: | ||
158 | |||
159 | void scrollChanged(int value); | ||
160 | void blinkEvent(); | ||
161 | |||
162 | private: | ||
163 | |||
164 | QChar (*fontMap)(QChar); // possible vt100 font extention | ||
165 | |||
166 | bool fixed_font; // has fixed pitch | ||
167 | int font_h; // height | ||
168 | int font_w; // width | ||
169 | int font_a; // ascend | ||
170 | |||
171 | int blX; // actual offset (left) | ||
172 | int brX; // actual offset (right) | ||
173 | int bY; // actual offset | ||
174 | |||
175 | int lines; | ||
176 | int columns; | ||
177 | Character *image; // [lines][columns] | ||
178 | |||
179 | ColorEntry color_table[TABLE_COLORS]; | ||
180 | |||
181 | BOOL resizing; | ||
182 | bool mouse_marks; | ||
183 | |||
184 | void makeImage(); | ||
185 | |||
186 | QPoint iPntSel; // initial selection point | ||
187 | QPoint pntSel; // current selection point | ||
188 | int actSel; // selection state | ||
189 | BOOL word_selection_mode; | ||
190 | BOOL preserve_line_breaks; | ||
191 | |||
192 | QClipboard* cb; | ||
193 | QScrollBar* scrollbar; | ||
194 | int scrollLoc; | ||
195 | |||
196 | //#define SCRNONE 0 | ||
197 | //#define SCRLEFT 1 | ||
198 | //#define SCRRIGHT 2 | ||
199 | |||
200 | BOOL blinking; // hide text in paintEvent | ||
201 | BOOL hasBlinker; // has characters to blink | ||
202 | QTimer* blinkT; // active when hasBlinker | ||
203 | QPopupMenu* m_drop; | ||
204 | QString dropText; | ||
205 | public: | ||
206 | // current session in this widget | ||
207 | // ibot: switch from TESession to Session! | ||
208 | Session *currentSession; | ||
209 | private slots: | ||
210 | void drop_menu_activated(int item); | ||
211 | }; | ||
212 | |||
213 | #endif // TE_WIDGET_H | ||
diff --git a/noncore/apps/opie-console/widget_layer.cpp b/noncore/apps/opie-console/widget_layer.cpp deleted file mode 100644 index afded92..0000000 --- a/noncore/apps/opie-console/widget_layer.cpp +++ b/dev/null | |||
@@ -1,242 +0,0 @@ | |||
1 | /* ------------------------------------------------------------------------- */ | ||
2 | /* */ | ||
3 | /* widget_layer.cpp Widget Layer */ | ||
4 | /* */ | ||
5 | /* opie developers <opie@handhelds.org> */ | ||
6 | /* */ | ||
7 | /* ------------------------------------------------------------------------- */ | ||
8 | |||
9 | |||
10 | |||
11 | #include "widget_layer.h" | ||
12 | |||
13 | |||
14 | #include <string.h> | ||
15 | //#include < | ||
16 | |||
17 | |||
18 | |||
19 | |||
20 | WidgetLayer::WidgetLayer( const Profile &config, QWidget *parent, const char *name ) : QFrame( parent, name ) | ||
21 | { | ||
22 | // get the clipboard | ||
23 | m_clipboard = QApplication::clipboard(); | ||
24 | |||
25 | // when data on clipboard changes, clear selection | ||
26 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), | ||
27 | (QObject*)this, SLOT( onClearSelection() ) ); | ||
28 | |||
29 | // initialize vars: | ||
30 | m_lines = 1; | ||
31 | m_columns = 1; | ||
32 | m_resizing = false; | ||
33 | |||
34 | // just for demonstrating | ||
35 | //m_image = QArray<Character>( m_lines * m_columns ); | ||
36 | m_image = QArray<Character>( 1 ); | ||
37 | |||
38 | // we need to install an event filter, | ||
39 | // to emit keypresses. | ||
40 | qApp->installEventFilter( this ); | ||
41 | |||
42 | } | ||
43 | |||
44 | |||
45 | WidgetLayer::~WidgetLayer() | ||
46 | { | ||
47 | // clean up | ||
48 | delete m_image; | ||
49 | } | ||
50 | |||
51 | |||
52 | QSize WidgetLayer::sizeHint() | ||
53 | { | ||
54 | return size(); | ||
55 | } | ||
56 | |||
57 | |||
58 | /* --------------------------------- audio ---------------------------------- */ | ||
59 | |||
60 | void WidgetLayer::bell() | ||
61 | { | ||
62 | QApplication::beep(); | ||
63 | } | ||
64 | |||
65 | bool WidgetLayer::eventFilter( QObject *obj, QEvent *e ) | ||
66 | { | ||
67 | if ( (e->type() == QEvent::Accel || | ||
68 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | ||
69 | static_cast<QKeyEvent *>( e )->ignore(); | ||
70 | return true; | ||
71 | } | ||
72 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | ||
73 | return false; // not us | ||
74 | |||
75 | #ifdef FAKE_CTRL_AND_ALT | ||
76 | static bool control = false; | ||
77 | static bool alt = false; | ||
78 | bool dele = false; | ||
79 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | ||
80 | QKeyEvent* ke = (QKeyEvent*)e; | ||
81 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | ||
82 | switch (ke->key()) { | ||
83 | case Key_F9: // let this be "Control" | ||
84 | control = keydown; | ||
85 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | ||
86 | dele=TRUE; | ||
87 | break; | ||
88 | case Key_F13: // let this be "Alt" | ||
89 | alt = keydown; | ||
90 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | ||
91 | dele=TRUE; | ||
92 | break; | ||
93 | default: | ||
94 | if ( control ) { | ||
95 | int a = toupper(ke->ascii())-64; | ||
96 | if ( a >= 0 && a < ' ' ) { | ||
97 | e = new QKeyEvent(e->type(), ke->key(), | ||
98 | a, ke->state()|ControlButton, | ||
99 | QChar(a,0)); | ||
100 | dele=TRUE; | ||
101 | } | ||
102 | } | ||
103 | if ( alt ) { | ||
104 | e = new QKeyEvent(e->type(), ke->key(), | ||
105 | ke->ascii(), ke->state()|AltButton, ke->text()); | ||
106 | dele=TRUE; | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | #endif | ||
111 | |||
112 | if ( e->type() == QEvent::KeyPress ) { | ||
113 | QKeyEvent* ke = (QKeyEvent*)e; | ||
114 | //actSel=0; // Key stroke implies a screen update, so Widget won't | ||
115 | // know where the current selection is. | ||
116 | |||
117 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker | ||
118 | insertText("\\"); // expose | ||
119 | } else | ||
120 | emit keyPressed( ke ); // expose | ||
121 | ke->accept(); | ||
122 | #ifdef FAKE_CTRL_AND_ALT | ||
123 | if ( dele ) delete e; | ||
124 | #endif | ||
125 | return true; // stop the event | ||
126 | } | ||
127 | return QFrame::eventFilter( obj, e ); | ||
128 | } | ||
129 | |||
130 | |||
131 | /* --------------------------------- screen --------------------------------- */ | ||
132 | |||
133 | |||
134 | void WidgetLayer::propagateSize() | ||
135 | { | ||
136 | QArray<Character> oldimage = m_image.copy(); | ||
137 | int oldlines = m_lines; | ||
138 | int oldcolumns = m_columns; | ||
139 | |||
140 | makeImage(); | ||
141 | |||
142 | // copy old image, to reduce flicker | ||
143 | if ( ! oldimage.isEmpty() ) | ||
144 | { | ||
145 | int lins = QMIN( oldlines, m_lines ); | ||
146 | int cols = QMIN( oldcolumns, m_columns ); | ||
147 | for ( int lin = 0; lin < lins; ++lin ) | ||
148 | { | ||
149 | memcpy( (void*) &m_image[m_columns*lin], | ||
150 | (void*) &oldimage[oldcolumns*lin], | ||
151 | cols*sizeof( Character ) ); | ||
152 | } | ||
153 | } | ||
154 | else | ||
155 | clearImage(); | ||
156 | |||
157 | delete oldimage; | ||
158 | |||
159 | m_resizing = true; | ||
160 | emit imageSizeChanged( m_lines, m_columns ); | ||
161 | m_resizing = false; | ||
162 | } | ||
163 | |||
164 | void WidgetLayer::makeImage() | ||
165 | { | ||
166 | calcGeometry(); | ||
167 | m_image = QArray<Character>( m_columns * m_lines ); | ||
168 | clearImage(); | ||
169 | } | ||
170 | |||
171 | void WidgetLayer::clearImage() | ||
172 | { | ||
173 | //should this belong here?? | ||
174 | for ( int y = 0; y < m_lines; y++ ) | ||
175 | for ( int x = 0; x < m_columns; x++ ) | ||
176 | { | ||
177 | m_image[loc(x,y)].c = 0xff; | ||
178 | m_image[loc(x,y)].f = 0xff; | ||
179 | m_image[loc(x,y)].b = 0xff; | ||
180 | m_image[loc(x,y)].r = 0xff; | ||
181 | } | ||
182 | } | ||
183 | |||
184 | /* --------------------------------- selection ------------------------------ */ | ||
185 | |||
186 | void WidgetLayer::pasteClipboard() | ||
187 | { | ||
188 | insertSelection(); | ||
189 | } | ||
190 | |||
191 | |||
192 | void WidgetLayer::insertSelection() | ||
193 | { | ||
194 | QString text = QApplication::clipboard()->text(); | ||
195 | if ( ! text.isNull() ) | ||
196 | { | ||
197 | text.replace( QRegExp( "\n" ), "\r" ); | ||
198 | insertText( text ); | ||
199 | // selection should be unselected | ||
200 | emit selectionCleared(); | ||
201 | } | ||
202 | } | ||
203 | |||
204 | void WidgetLayer::insertText( QString text ) | ||
205 | { | ||
206 | // text is inserted as key event | ||
207 | QKeyEvent e( QEvent::KeyPress, 0, -1, 0, text); | ||
208 | emit keyPressed( &e ); | ||
209 | } | ||
210 | |||
211 | void WidgetLayer::onClearSelection() | ||
212 | { | ||
213 | emit selectionCleared(); | ||
214 | } | ||
215 | |||
216 | void WidgetLayer::setSelection( const QString& text ) | ||
217 | { | ||
218 | // why get the clipboard, we have it as instance var... | ||
219 | QObject *m_clipboard = QApplication::clipboard(); | ||
220 | |||
221 | // we know, that cliboard changes, when we change clipboard | ||
222 | QObject::disconnect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), | ||
223 | (QObject*) this, SLOT( selectionCleared() ) ); | ||
224 | |||
225 | QApplication::clipboard()->setText( text ); | ||
226 | |||
227 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), | ||
228 | (QObject*) this, SLOT( selectionCleared() ) ); | ||
229 | } | ||
230 | |||
231 | |||
232 | ///////// | ||
233 | // special font characters | ||
234 | ///////// | ||
235 | unsigned short vt100_graphics[32] = | ||
236 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 | ||
237 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, | ||
238 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, | ||
239 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, | ||
240 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 | ||
241 | }; | ||
242 | |||
diff --git a/noncore/apps/opie-console/widget_layer.h b/noncore/apps/opie-console/widget_layer.h deleted file mode 100644 index 6812711..0000000 --- a/noncore/apps/opie-console/widget_layer.h +++ b/dev/null | |||
@@ -1,265 +0,0 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | ||
2 | /* */ | ||
3 | /* [widget_layer.h] Widget Layer */ | ||
4 | /* */ | ||
5 | /* -------------------------------------------------------------------------- */ | ||
6 | |||
7 | // proposal of a widget Layer in opie-console | ||
8 | // | ||
9 | // fellow devels: | ||
10 | // just mail me (ibotty@web.de), what you additionally need from the main widget | ||
11 | // (or say in chat) | ||
12 | |||
13 | #ifndef WIDGET_LAYER_H | ||
14 | #define WIDGET_LAYER_H | ||
15 | |||
16 | // qt includes | ||
17 | #include <qapplication.h> | ||
18 | #include <qframe.h> | ||
19 | #include <qarray.h> | ||
20 | #include <qtimer.h> | ||
21 | #include <qkeycode.h> | ||
22 | #include <qclipboard.h> | ||
23 | |||
24 | |||
25 | // opie-console includes | ||
26 | #include "session.h" | ||
27 | #include "common.h" | ||
28 | #include "profile.h" | ||
29 | |||
30 | |||
31 | /* | ||
32 | * given a pseudo location ( column, line ), | ||
33 | * returns the actual index, in the QArray<Character> | ||
34 | */ | ||
35 | #define loc(X,Y) ((Y)*m_columns+(X)) | ||
36 | |||
37 | |||
38 | |||
39 | extern unsigned short vt100_graphics[32]; | ||
40 | |||
41 | class WidgetLayer : public QFrame | ||
42 | { Q_OBJECT | ||
43 | |||
44 | public: | ||
45 | |||
46 | /** | ||
47 | * constructor | ||
48 | * @param const Profile &config, the configuration for this widget | ||
49 | * @param QWidget *parent, the parent widget | ||
50 | * @param const char *name, the name of the widget, defaults to "" | ||
51 | */ | ||
52 | WidgetLayer( const Profile& config, QWidget *parent=0, const char *name=0 ); | ||
53 | |||
54 | /** | ||
55 | * destructor | ||
56 | */ | ||
57 | virtual ~WidgetLayer(); | ||
58 | |||
59 | public: | ||
60 | /** | ||
61 | * sets the image | ||
62 | * @param QArray<Character> const newimg, the new image | ||
63 | * @param int lines, lines count of newimg | ||
64 | * @param int columns, columns count of newimg | ||
65 | */ | ||
66 | virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0; | ||
67 | |||
68 | /** | ||
69 | * annoy the user | ||
70 | */ | ||
71 | void bell(); | ||
72 | |||
73 | /** | ||
74 | * @return int m_lines, the lines count | ||
75 | */ | ||
76 | int lines(){ return m_lines; } | ||
77 | |||
78 | /** | ||
79 | * @return int m_columns, the columns count | ||
80 | */ | ||
81 | int columns(){ return m_columns; } | ||
82 | |||
83 | /** | ||
84 | * insert current selection (currently this is only the clipboard) | ||
85 | */ | ||
86 | void insertSelection(); | ||
87 | |||
88 | /** | ||
89 | * insert text | ||
90 | * @param QString text, the text to be inserted | ||
91 | */ | ||
92 | void insertText( QString text ); | ||
93 | |||
94 | /** | ||
95 | * set selection (clipboard) to text | ||
96 | * @param const QString &text, the text to be selected | ||
97 | */ | ||
98 | void setSelection( const QString &text ); | ||
99 | |||
100 | /** | ||
101 | * paste content of clipboard | ||
102 | */ | ||
103 | void pasteClipboard(); | ||
104 | |||
105 | |||
106 | /** | ||
107 | * reload configuration | ||
108 | * @param const Profile& config, the config to be used (may be the same as in constructor) | ||
109 | */ | ||
110 | virtual void reloadConfig( const Profile& config ) = 0; | ||
111 | |||
112 | |||
113 | /** | ||
114 | * sets the scrollbar (if implemented by successor of this class) | ||
115 | */ | ||
116 | virtual void setScroll( int cursor, int slines ) = 0; | ||
117 | |||
118 | /** | ||
119 | * scrolls (if implemented, by successor of this class) | ||
120 | * @param int value, how much the widget should scroll up (positive value) or down (negative value) | ||
121 | */ | ||
122 | virtual void scroll( int value ) = 0; | ||
123 | |||
124 | |||
125 | virtual bool eventFilter( QObject *obj, QEvent *event ); | ||
126 | |||
127 | |||
128 | QSize sizeHint(); | ||
129 | |||
130 | virtual QSize calcSize( int cols, int lins ) const = 0; | ||
131 | signals: | ||
132 | |||
133 | /** | ||
134 | * key was pressed | ||
135 | */ | ||
136 | void keyPressed( QKeyEvent *e ); | ||
137 | |||
138 | /** | ||
139 | * whenever Mouse selects something | ||
140 | * @param int button, the button that us pressed : | ||
141 | * 0left Button | ||
142 | * 3Button released | ||
143 | * @param int x, x position | ||
144 | * @param int y, y position | ||
145 | * | ||
146 | * // numbering due to layout in old TEWidget | ||
147 | */ | ||
148 | void mousePressed( int button, int x, int y ); | ||
149 | |||
150 | /** | ||
151 | * size of image changed | ||
152 | * @param int lines, line count of new size | ||
153 | * @param int columns, column count of new size | ||
154 | */ | ||
155 | void imageSizeChanged( int lines, int columns ); | ||
156 | |||
157 | /** | ||
158 | * cursor in history changed | ||
159 | * @param int value, value of history cursor | ||
160 | */ | ||
161 | void historyCursorChanged( int value ); | ||
162 | |||
163 | /** | ||
164 | * selection should be cleared | ||
165 | */ | ||
166 | void selectionCleared(); | ||
167 | |||
168 | /** | ||
169 | * selection begin | ||
170 | * @param const int x, x position | ||
171 | * @param const int y, y position | ||
172 | */ | ||
173 | void selectionBegin( const int x, const int y ); | ||
174 | |||
175 | /** | ||
176 | * selection extended | ||
177 | * (from begin (s.a.) to x, y) | ||
178 | * @param const int x, x position | ||
179 | * @param const int y, y position | ||
180 | */ | ||
181 | void selectionExtended( const int x, const int y ); | ||
182 | |||
183 | /** | ||
184 | * selection end | ||
185 | * @param const bool lineBreakPreserve, preserve line breaks in selection | ||
186 | */ | ||
187 | void selectionEnd( const bool lineBreakPreserve ); | ||
188 | |||
189 | |||
190 | |||
191 | // protected methods | ||
192 | protected: | ||
193 | |||
194 | // image operations | ||
195 | |||
196 | /** | ||
197 | * changes image, to suit new size | ||
198 | * TODO: find meaningful name! | ||
199 | */ | ||
200 | void propagateSize(); | ||
201 | |||
202 | /** | ||
203 | *determines count of lines and columns | ||
204 | */ | ||
205 | virtual void calcGeometry() = 0; | ||
206 | |||
207 | /** | ||
208 | * makes an empty image | ||
209 | */ | ||
210 | void makeImage(); | ||
211 | |||
212 | /** | ||
213 | * clears the image | ||
214 | */ | ||
215 | void clearImage(); | ||
216 | |||
217 | protected slots: | ||
218 | |||
219 | /** | ||
220 | * clear selection | ||
221 | */ | ||
222 | void onClearSelection(); | ||
223 | |||
224 | |||
225 | // protected vars | ||
226 | protected: | ||
227 | |||
228 | /** | ||
229 | * current Session | ||
230 | */ | ||
231 | Session *m_session; | ||
232 | |||
233 | /** | ||
234 | * current character image | ||
235 | * | ||
236 | * a Character at loc( column, line ) | ||
237 | * has the actual index: | ||
238 | * ix = line * m_columns + column; | ||
239 | * | ||
240 | * use loc( x, y ) macro to access. | ||
241 | */ | ||
242 | QArray<Character> m_image; | ||
243 | |||
244 | /** | ||
245 | * lines count | ||
246 | */ | ||
247 | int m_lines; | ||
248 | |||
249 | /** | ||
250 | * columns count | ||
251 | */ | ||
252 | int m_columns; | ||
253 | |||
254 | /** | ||
255 | * clipboard | ||
256 | */ | ||
257 | QClipboard* m_clipboard; | ||
258 | |||
259 | /** | ||
260 | * whether widget is resizing | ||
261 | */ | ||
262 | bool m_resizing; | ||
263 | }; | ||
264 | |||
265 | #endif // WIDGET_LAYER_H | ||