summaryrefslogtreecommitdiff
authoribotty <ibotty>2002-10-11 17:43:18 (UTC)
committer ibotty <ibotty>2002-10-11 17:43:18 (UTC)
commit01f26248efccbd764e7c82b74372f33a4bbae303 (patch) (unidiff)
treea13712dabfa9aaeb7d9ad9353e434b8976234836
parent00005567e4841af1f0efe090160881b286574493 (diff)
downloadopie-01f26248efccbd764e7c82b74372f33a4bbae303.zip
opie-01f26248efccbd764e7c82b74372f33a4bbae303.tar.gz
opie-01f26248efccbd764e7c82b74372f33a4bbae303.tar.bz2
changed references to widget into references to widgetLayer or EmulationWidget.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/metafactory.cpp2
-rw-r--r--noncore/apps/opie-console/metafactory.h6
-rw-r--r--noncore/apps/opie-console/profilemanager.cpp5
-rw-r--r--noncore/apps/opie-console/session.cpp6
-rw-r--r--noncore/apps/opie-console/session.h8
-rw-r--r--noncore/apps/opie-console/widget.cpp12
-rw-r--r--noncore/apps/opie-console/widget_layer.h3
7 files changed, 23 insertions, 19 deletions
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp
index 02a9f9b..2b672cf 100644
--- a/noncore/apps/opie-console/metafactory.cpp
+++ b/noncore/apps/opie-console/metafactory.cpp
@@ -1,139 +1,139 @@
1#include <qpe/config.h> 1#include <qpe/config.h>
2#include "metafactory.h" 2#include "metafactory.h"
3 3
4MetaFactory::MetaFactory() { 4MetaFactory::MetaFactory() {
5} 5}
6MetaFactory::~MetaFactory() { 6MetaFactory::~MetaFactory() {
7 7
8} 8}
9void MetaFactory::addConnectionWidgetFactory( const QCString& name, 9void MetaFactory::addConnectionWidgetFactory( const QCString& name,
10 const QString& str, 10 const QString& str,
11 configWidget wid) { 11 configWidget wid) {
12 m_strings.insert( str, name ); 12 m_strings.insert( str, name );
13 m_conFact.insert( str, wid ); 13 m_conFact.insert( str, wid );
14} 14}
15void MetaFactory::addTerminalWidgetFactory( const QCString& name, 15void MetaFactory::addTerminalWidgetFactory( const QCString& name,
16 const QString& str, 16 const QString& str,
17 configWidget wid ) { 17 configWidget wid ) {
18 m_strings.insert( str, name ); 18 m_strings.insert( str, name );
19 m_termFact.insert( str, wid ); 19 m_termFact.insert( str, wid );
20} 20}
21void MetaFactory::addIOLayerFactory( const QCString& name, 21void MetaFactory::addIOLayerFactory( const QCString& name,
22 const QString& str, 22 const QString& str,
23 iolayer lay) { 23 iolayer lay) {
24 m_strings.insert( str, name ); 24 m_strings.insert( str, name );
25 m_layerFact.insert( str, lay ); 25 m_layerFact.insert( str, lay );
26} 26}
27void MetaFactory::addFileTransferLayer( const QCString& name, 27void MetaFactory::addFileTransferLayer( const QCString& name,
28 const QString& str, 28 const QString& str,
29 filelayer lay) { 29 filelayer lay) {
30 m_strings.insert(str, name ); 30 m_strings.insert(str, name );
31 m_fileFact.insert( str, lay ); 31 m_fileFact.insert( str, lay );
32} 32}
33void MetaFactory::addEmulationLayer( const QCString& name, 33void MetaFactory::addEmulationLayer( const QCString& name,
34 const QString& str, 34 const QString& str,
35 emulationLayer em) { 35 emulationLayer em) {
36 m_strings.insert(str, name ); 36 m_strings.insert(str, name );
37 m_emu.insert( str, em ); 37 m_emu.insert( str, em );
38} 38}
39QStringList MetaFactory::ioLayers()const { 39QStringList MetaFactory::ioLayers()const {
40 QStringList list; 40 QStringList list;
41 QMap<QString, iolayer>::ConstIterator it; 41 QMap<QString, iolayer>::ConstIterator it;
42 for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { 42 for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) {
43 list << it.key(); 43 list << it.key();
44 } 44 }
45 return list; 45 return list;
46} 46}
47QStringList MetaFactory::connectionWidgets()const { 47QStringList MetaFactory::connectionWidgets()const {
48 QStringList list; 48 QStringList list;
49 QMap<QString, configWidget>::ConstIterator it; 49 QMap<QString, configWidget>::ConstIterator it;
50 for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) { 50 for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) {
51 list << it.key(); 51 list << it.key();
52 } 52 }
53 return list; 53 return list;
54} 54}
55QStringList MetaFactory::terminalWidgets()const { 55QStringList MetaFactory::terminalWidgets()const {
56 QStringList list; 56 QStringList list;
57 QMap<QString, configWidget>::ConstIterator it; 57 QMap<QString, configWidget>::ConstIterator it;
58 for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) { 58 for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) {
59 list << it.key(); 59 list << it.key();
60 } 60 }
61 return list; 61 return list;
62} 62}
63QStringList MetaFactory::fileTransferLayers()const { 63QStringList MetaFactory::fileTransferLayers()const {
64 QStringList list; 64 QStringList list;
65 QMap<QString, filelayer>::ConstIterator it; 65 QMap<QString, filelayer>::ConstIterator it;
66 for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { 66 for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) {
67 list << it.key(); 67 list << it.key();
68 } 68 }
69 return list; 69 return list;
70} 70}
71QStringList MetaFactory::emulationLayers()const { 71QStringList MetaFactory::emulationLayers()const {
72 QStringList list; 72 QStringList list;
73 QMap<QString, emulationLayer>::ConstIterator it; 73 QMap<QString, emulationLayer>::ConstIterator it;
74 for ( it = m_emu.begin(); it != m_emu.end(); ++it ) { 74 for ( it = m_emu.begin(); it != m_emu.end(); ++it ) {
75 list << it.key(); 75 list << it.key();
76 } 76 }
77 return list; 77 return list;
78} 78}
79 79
80IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { 80IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
81 IOLayer* lay = 0l; 81 IOLayer* lay = 0l;
82 82
83 QMap<QString, iolayer>::Iterator it; 83 QMap<QString, iolayer>::Iterator it;
84 it = m_layerFact.find( str ); 84 it = m_layerFact.find( str );
85 if ( it != m_layerFact.end() ) { 85 if ( it != m_layerFact.end() ) {
86 lay = (*(it.data()))(prof); 86 lay = (*(it.data()))(prof);
87 /* 87 /*
88 iolayer laye = it.data(); 88 iolayer laye = it.data();
89 lay = (*laye )(conf);*/ 89 lay = (*laye )(conf);*/
90 } 90 }
91 91
92 return lay; 92 return lay;
93} 93}
94 94
95ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) { 95ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) {
96 ProfileDialogWidget* wid = 0l; 96 ProfileDialogWidget* wid = 0l;
97 97
98 QMap<QString, configWidget>::Iterator it; 98 QMap<QString, configWidget>::Iterator it;
99 it = m_conFact.find( str ); 99 it = m_conFact.find( str );
100 if ( it != m_conFact.end() ) { 100 if ( it != m_conFact.end() ) {
101 wid = (*(it.data() ) )(str,parent); 101 wid = (*(it.data() ) )(str,parent);
102 } 102 }
103 return wid; 103 return wid;
104} 104}
105ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) { 105ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) {
106 if (str.isEmpty() ) 106 if (str.isEmpty() )
107 return 0l; 107 return 0l;
108 ProfileDialogWidget* wid = 0l; 108 ProfileDialogWidget* wid = 0l;
109 qWarning("new terminalPlugin %s %l", str.latin1(), parent ); 109 qWarning("new terminalPlugin %s %l", str.latin1(), parent );
110 110
111 QMap<QString, configWidget>::Iterator it; 111 QMap<QString, configWidget>::Iterator it;
112 it = m_termFact.find( str ); 112 it = m_termFact.find( str );
113 if ( it != m_termFact.end() ) { 113 if ( it != m_termFact.end() ) {
114 wid = (*(it.data() ) )(str,parent); 114 wid = (*(it.data() ) )(str,parent);
115 } 115 }
116 return wid; 116 return wid;
117} 117}
118EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, Widget* wid) { 118EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, WidgetLayer* wid) {
119 EmulationLayer* lay = 0l; 119 EmulationLayer* lay = 0l;
120 120
121 QMap<QString, emulationLayer>::Iterator it; 121 QMap<QString, emulationLayer>::Iterator it;
122 it = m_emu.find( str ); 122 it = m_emu.find( str );
123 if ( it != m_emu.end() ) { 123 if ( it != m_emu.end() ) {
124 lay = (*(it.data() ) )(wid); 124 lay = (*(it.data() ) )(wid);
125 } 125 }
126 126
127 return lay; 127 return lay;
128} 128}
129QCString MetaFactory::internal( const QString& str )const { 129QCString MetaFactory::internal( const QString& str )const {
130 return m_strings[str]; 130 return m_strings[str];
131} 131}
132QString MetaFactory::external( const QCString& str )const { 132QString MetaFactory::external( const QCString& str )const {
133 QMap<QString, QCString>::ConstIterator it; 133 QMap<QString, QCString>::ConstIterator it;
134 for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { 134 for ( it = m_strings.begin(); it != m_strings.end(); ++it ) {
135 if ( it.data() == str ) 135 if ( it.data() == str )
136 return it.key(); 136 return it.key();
137 } 137 }
138 return QString::null; 138 return QString::null;
139} 139}
diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h
index 71c35a2..d05ece4 100644
--- a/noncore/apps/opie-console/metafactory.h
+++ b/noncore/apps/opie-console/metafactory.h
@@ -1,106 +1,106 @@
1#ifndef OPIE_META_FACTORY_H 1#ifndef OPIE_META_FACTORY_H
2#define OPIE_META_FACTORY_H 2#define OPIE_META_FACTORY_H
3 3
4/** 4/**
5 * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets 5 * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets
6 * and to instantiate these implementations on demand 6 * and to instantiate these implementations on demand
7 */ 7 */
8 8
9#include <qwidget.h> 9#include <qwidget.h>
10#include <qmap.h> 10#include <qmap.h>
11 11
12#include <qpe/config.h> 12#include <qpe/config.h>
13 13
14#include "io_layer.h" 14#include "io_layer.h"
15#include "file_layer.h" 15#include "file_layer.h"
16#include "profile.h" 16#include "profile.h"
17#include "profiledialogwidget.h" 17#include "profiledialogwidget.h"
18#include "emulation_layer.h" 18#include "emulation_layer.h"
19 19
20class Widget; 20class WidgetLayer;
21class MetaFactory { 21class MetaFactory {
22public: 22public:
23 typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent); 23 typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent);
24 typedef IOLayer* (*iolayer)(const Profile& ); 24 typedef IOLayer* (*iolayer)(const Profile& );
25 typedef FileTransferLayer* (*filelayer)(IOLayer*); 25 typedef FileTransferLayer* (*filelayer)(IOLayer*);
26 typedef EmulationLayer* (*emulationLayer)(Widget* ); 26 typedef EmulationLayer* (*emulationLayer)(WidgetLayer* );
27 27
28 MetaFactory(); 28 MetaFactory();
29 ~MetaFactory(); 29 ~MetaFactory();
30 30
31 /** 31 /**
32 * add a ProfileDialogWidget to the factory 32 * add a ProfileDialogWidget to the factory
33 * name is the name shown to the user 33 * name is the name shown to the user
34 */ 34 */
35 void addConnectionWidgetFactory( const QCString& internalName, 35 void addConnectionWidgetFactory( const QCString& internalName,
36 const QString& uiString, 36 const QString& uiString,
37 configWidget ); 37 configWidget );
38 void addTerminalWidgetFactory ( const QCString& internalName, 38 void addTerminalWidgetFactory ( const QCString& internalName,
39 const QString& name, 39 const QString& name,
40 configWidget ); 40 configWidget );
41 41
42 /** 42 /**
43 * adds an IOLayer factory 43 * adds an IOLayer factory
44 */ 44 */
45 void addIOLayerFactory( const QCString&, 45 void addIOLayerFactory( const QCString&,
46 const QString&, 46 const QString&,
47 iolayer ); 47 iolayer );
48 48
49 /** 49 /**
50 * adds a FileTransfer Layer 50 * adds a FileTransfer Layer
51 */ 51 */
52 void addFileTransferLayer( const QCString& name, 52 void addFileTransferLayer( const QCString& name,
53 const QString&, 53 const QString&,
54 filelayer ); 54 filelayer );
55 55
56 /** 56 /**
57 * adds a Factory for Emulation to the Layer.. 57 * adds a Factory for Emulation to the Layer..
58 */ 58 */
59 void addEmulationLayer ( const QCString& name, 59 void addEmulationLayer ( const QCString& name,
60 const QString& uiString, 60 const QString& uiString,
61 emulationLayer ); 61 emulationLayer );
62 62
63 /* translated UI Strings */ 63 /* translated UI Strings */
64 QStringList ioLayers()const; 64 QStringList ioLayers()const;
65 QStringList connectionWidgets()const; 65 QStringList connectionWidgets()const;
66 66
67 /** 67 /**
68 * Terminal Configuration widgets 68 * Terminal Configuration widgets
69 */ 69 */
70 QStringList terminalWidgets()const; 70 QStringList terminalWidgets()const;
71 QStringList fileTransferLayers()const; 71 QStringList fileTransferLayers()const;
72 QStringList emulationLayers()const; 72 QStringList emulationLayers()const;
73 73
74 /** 74 /**
75 * the generation... 75 * the generation...
76 */ 76 */
77 IOLayer* newIOLayer( const QString&,const Profile& ); 77 IOLayer* newIOLayer( const QString&,const Profile& );
78 ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* ); 78 ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* );
79 ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* ); 79 ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* );
80 EmulationLayer* newEmulationLayer(const QString&, Widget* ); 80 EmulationLayer* newEmulationLayer(const QString&, WidgetLayer* );
81 81
82 /* 82 /*
83 * internal takes the maybe translated 83 * internal takes the maybe translated
84 * public QString and maps it to the internal 84 * public QString and maps it to the internal
85 * not translatable QCString 85 * not translatable QCString
86 */ 86 */
87 QCString internal( const QString& )const; 87 QCString internal( const QString& )const;
88 88
89 /* 89 /*
90 * external takes the internal name 90 * external takes the internal name
91 * it returns a translated name 91 * it returns a translated name
92 */ 92 */
93 QString external( const QCString& )const; 93 QString external( const QCString& )const;
94 94
95 95
96private: 96private:
97 QMap<QString, QCString> m_strings; 97 QMap<QString, QCString> m_strings;
98 QMap<QString, configWidget> m_conFact; 98 QMap<QString, configWidget> m_conFact;
99 QMap<QString, configWidget> m_termFact; 99 QMap<QString, configWidget> m_termFact;
100 QMap<QString, iolayer> m_layerFact; 100 QMap<QString, iolayer> m_layerFact;
101 QMap<QString, filelayer> m_fileFact; 101 QMap<QString, filelayer> m_fileFact;
102 QMap<QString, emulationLayer> m_emu; 102 QMap<QString, emulationLayer> m_emu;
103}; 103};
104 104
105 105
106#endif 106#endif
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp
index dcf3cbd..78751e7 100644
--- a/noncore/apps/opie-console/profilemanager.cpp
+++ b/noncore/apps/opie-console/profilemanager.cpp
@@ -1,126 +1,127 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include <qfile.h> 4#include <qfile.h>
5#include <qlayout.h> 5#include <qlayout.h>
6#include <qwidgetstack.h> 6#include <qwidgetstack.h>
7 7
8#include <qpe/config.h> 8#include <qpe/config.h>
9 9
10#include "widget.h" 10#include "widget_layer.h"
11#include "emulation_widget.h"
11#include "metafactory.h" 12#include "metafactory.h"
12#include "profileconfig.h" 13#include "profileconfig.h"
13#include "profilemanager.h" 14#include "profilemanager.h"
14 15
15ProfileManager::ProfileManager( MetaFactory* fact ) 16ProfileManager::ProfileManager( MetaFactory* fact )
16 : m_fact( fact ) 17 : m_fact( fact )
17{ 18{
18 19
19} 20}
20ProfileManager::~ProfileManager() { 21ProfileManager::~ProfileManager() {
21 22
22} 23}
23void ProfileManager::load() { 24void ProfileManager::load() {
24 m_list.clear(); 25 m_list.clear();
25 qWarning("load"); 26 qWarning("load");
26 ProfileConfig conf("opie-console-profiles"); 27 ProfileConfig conf("opie-console-profiles");
27 QStringList groups = conf.groups(); 28 QStringList groups = conf.groups();
28 QStringList::Iterator it; 29 QStringList::Iterator it;
29 30
30 /* 31 /*
31 * for each profile 32 * for each profile
32 */ 33 */
33 for ( it = groups.begin(); it != groups.end(); ++it ) { 34 for ( it = groups.begin(); it != groups.end(); ++it ) {
34 qWarning("group " + (*it) ); 35 qWarning("group " + (*it) );
35 conf.setGroup( (*it) ); 36 conf.setGroup( (*it) );
36 Profile prof; 37 Profile prof;
37 prof.setName( conf.readEntry("name") ); 38 prof.setName( conf.readEntry("name") );
38 prof.setIOLayer( conf.readEntry("iolayer").utf8() ); 39 prof.setIOLayer( conf.readEntry("iolayer").utf8() );
39 prof.setTerminalName( conf.readEntry("term").utf8() ); 40 prof.setTerminalName( conf.readEntry("term").utf8() );
40 qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() ); 41 qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() );
41 prof.setBackground( conf.readNumEntry("back") ); 42 prof.setBackground( conf.readNumEntry("back") );
42 prof.setForeground( conf.readNumEntry("fore") ); 43 prof.setForeground( conf.readNumEntry("fore") );
43 prof.setTerminal( conf.readNumEntry("terminal") ); 44 prof.setTerminal( conf.readNumEntry("terminal") );
44 prof.setConf( conf.items( (*it) ) ); 45 prof.setConf( conf.items( (*it) ) );
45 46
46 /* now add it */ 47 /* now add it */
47 m_list.append( prof ); 48 m_list.append( prof );
48 } 49 }
49 50
50} 51}
51void ProfileManager::clear() { 52void ProfileManager::clear() {
52 m_list.clear(); 53 m_list.clear();
53} 54}
54Profile::ValueList ProfileManager::all()const { 55Profile::ValueList ProfileManager::all()const {
55 return m_list; 56 return m_list;
56} 57}
57/* 58/*
58 * Our goal is to create a Session 59 * Our goal is to create a Session
59 * We will load the the IOLayer and EmulationLayer 60 * We will load the the IOLayer and EmulationLayer
60 * from the factory 61 * from the factory
61 * we will generate a QWidgetStack 62 * we will generate a QWidgetStack
62 * add a dummy widget with layout 63 * add a dummy widget with layout
63 * add "Widget" to the layout 64 * add "Widget" to the layout
64 * add the dummy to the stack 65 * add the dummy to the stack
65 * raise the dummy 66 * raise the dummy
66 * call session->connect(= 67 * call session->connect(=
67 * this way we only need to reparent 68 * this way we only need to reparent
68 * in TabWidget 69 * in TabWidget
69 */ 70 */
70Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) { 71Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) {
71 Session* session = new Session(); 72 Session* session = new Session();
72 session->setName( prof.name() ); 73 session->setName( prof.name() );
73 /* translate the internal name to the external */ 74 /* translate the internal name to the external */
74 session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) , 75 session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) ,
75 prof) ); 76 prof) );
76 77
77 QWidgetStack *stack = new QWidgetStack(parent); 78 QWidgetStack *stack = new QWidgetStack(parent);
78 session->setWidgetStack( stack ); 79 session->setWidgetStack( stack );
79 QWidget* dummy = new QWidget(stack ); 80 QWidget* dummy = new QWidget(stack );
80 QHBoxLayout* lay = new QHBoxLayout(dummy ); 81 QHBoxLayout* lay = new QHBoxLayout(dummy );
81 stack->addWidget( dummy, 0 ); 82 stack->addWidget( dummy, 0 );
82 stack->raiseWidget( 0 ); 83 stack->raiseWidget( 0 );
83 Widget* wid = new Widget(dummy ); 84 WidgetLayer* wid = new EmulationWidget( prof, dummy );
84 lay->addWidget( wid ); 85 lay->addWidget( wid );
85 86
86 session->setEmulationWidget( wid ); 87 session->setEmulationWidget( wid );
87 session->setEmulationLayer( m_fact->newEmulationLayer( m_fact->external( prof.terminalName() ), 88 session->setEmulationLayer( m_fact->newEmulationLayer( m_fact->external( prof.terminalName() ),
88 wid ) ); 89 wid ) );
89 session->connect(); 90 session->connect();
90 91
91 return session; 92 return session;
92} 93}
93void ProfileManager::save( ) { 94void ProfileManager::save( ) {
94 QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); 95 QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) );
95 ProfileConfig conf("opie-console-profiles"); 96 ProfileConfig conf("opie-console-profiles");
96 Profile::ValueList::Iterator it; 97 Profile::ValueList::Iterator it;
97 for (it = m_list.begin(); it != m_list.end(); ++it ) { 98 for (it = m_list.begin(); it != m_list.end(); ++it ) {
98 conf.setGroup( (*it).name() ); 99 conf.setGroup( (*it).name() );
99 conf.writeEntry( "name", (*it).name() ); 100 conf.writeEntry( "name", (*it).name() );
100 conf.writeEntry( "iolayer", QString::fromUtf8( (*it).ioLayerName() ) ); 101 conf.writeEntry( "iolayer", QString::fromUtf8( (*it).ioLayerName() ) );
101 conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) ); 102 conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) );
102 conf.writeEntry( "back", (*it).background() ); 103 conf.writeEntry( "back", (*it).background() );
103 conf.writeEntry( "fore", (*it).foreground() ); 104 conf.writeEntry( "fore", (*it).foreground() );
104 conf.writeEntry( "terminal", (*it).terminal() ); 105 conf.writeEntry( "terminal", (*it).terminal() );
105 /* now the config stuff */ 106 /* now the config stuff */
106 QMap<QString, QString> map = (*it).conf(); 107 QMap<QString, QString> map = (*it).conf();
107 QMap<QString, QString>::Iterator it; 108 QMap<QString, QString>::Iterator it;
108 for ( it = map.begin(); it != map.end(); ++it ) { 109 for ( it = map.begin(); it != map.end(); ++it ) {
109 conf.writeEntry( it.key(), it.data() ); 110 conf.writeEntry( it.key(), it.data() );
110 } 111 }
111 } 112 }
112} 113}
113void ProfileManager::setProfiles( const Profile::ValueList& list ) { 114void ProfileManager::setProfiles( const Profile::ValueList& list ) {
114 m_list = list; 115 m_list = list;
115}; 116};
116Profile ProfileManager::profile( const QString& name )const { 117Profile ProfileManager::profile( const QString& name )const {
117 Profile prof; 118 Profile prof;
118 Profile::ValueList::ConstIterator it; 119 Profile::ValueList::ConstIterator it;
119 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 120 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
120 if ( name == (*it).name() ) { 121 if ( name == (*it).name() ) {
121 prof = (*it); 122 prof = (*it);
122 break; 123 break;
123 } 124 }
124 } 125 }
125 return prof; 126 return prof;
126} 127}
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp
index 42b0583..ff2c3e2 100644
--- a/noncore/apps/opie-console/session.cpp
+++ b/noncore/apps/opie-console/session.cpp
@@ -1,81 +1,81 @@
1 1
2 2
3#include "io_layer.h" 3#include "io_layer.h"
4#include "file_layer.h" 4#include "file_layer.h"
5#include "widget.h" 5#include "widget_layer.h"
6#include "emulation_layer.h" 6#include "emulation_layer.h"
7#include "session.h" 7#include "session.h"
8 8
9 9
10Session::Session() { 10Session::Session() {
11 m_widget = 0l; 11 m_widget = 0l;
12 m_layer = 0l; 12 m_layer = 0l;
13 m_widLay = 0l; 13 m_widLay = 0l;
14 m_emLay = 0l; 14 m_emLay = 0l;
15} 15}
16Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) 16Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay)
17 : m_name( na ), m_widget( widget ), m_layer( lay ) 17 : m_name( na ), m_widget( widget ), m_layer( lay )
18{ 18{
19 m_widLay = 0l; 19 m_widLay = 0l;
20 m_emLay = 0l; 20 m_emLay = 0l;
21} 21}
22Session::~Session() { 22Session::~Session() {
23 delete m_layer; 23 delete m_layer;
24 delete m_emLay; 24 delete m_emLay;
25 delete m_widget; 25 delete m_widget;
26 /* the widget layer should be deleted by the m_widget */ 26 /* the widget layer should be deleted by the m_widget */
27} 27}
28QString Session::name()const { 28QString Session::name()const {
29 return m_name; 29 return m_name;
30} 30}
31QWidgetStack* Session::widgetStack() { 31QWidgetStack* Session::widgetStack() {
32 return m_widget; 32 return m_widget;
33} 33}
34IOLayer* Session::layer() { 34IOLayer* Session::layer() {
35 return m_layer; 35 return m_layer;
36} 36}
37EmulationLayer* Session::emulationLayer() { 37EmulationLayer* Session::emulationLayer() {
38 return m_emLay; 38 return m_emLay;
39} 39}
40Widget* Session::emulationWidget() { 40WidgetLayer* Session::emulationWidget() {
41 return m_widLay; 41 return m_widLay;
42} 42}
43void Session::connect() { 43void Session::connect() {
44 if ( !m_layer || !m_emLay ) 44 if ( !m_layer || !m_emLay )
45 return; 45 return;
46 46
47 QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), 47 QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ),
48 m_emLay, SLOT(onRcvBlock(const QByteArray&) ) ); 48 m_emLay, SLOT(onRcvBlock(const QByteArray&) ) );
49 QObject::connect(m_emLay, SIGNAL(sndBlock(const QByteArray&) ), 49 QObject::connect(m_emLay, SIGNAL(sndBlock(const QByteArray&) ),
50 m_layer, SLOT(send(const QByteArray&) ) ); 50 m_layer, SLOT(send(const QByteArray&) ) );
51} 51}
52void Session::disconnect() { 52void Session::disconnect() {
53 if ( !m_layer || !m_emLay ) 53 if ( !m_layer || !m_emLay )
54 return; 54 return;
55 55
56 QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), 56 QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ),
57 m_emLay, SLOT(onRcvBlock(const QByteArray&) ) ); 57 m_emLay, SLOT(onRcvBlock(const QByteArray&) ) );
58 QObject::disconnect(m_emLay, SIGNAL(sndBlock(const QByteArray&) ), 58 QObject::disconnect(m_emLay, SIGNAL(sndBlock(const QByteArray&) ),
59 m_layer, SLOT(send(const QByteArray&) ) ); 59 m_layer, SLOT(send(const QByteArray&) ) );
60} 60}
61void Session::setName( const QString& na){ 61void Session::setName( const QString& na){
62 m_name = na; 62 m_name = na;
63} 63}
64void Session::setWidgetStack( QWidgetStack* wid ) { 64void Session::setWidgetStack( QWidgetStack* wid ) {
65 delete m_widget; 65 delete m_widget;
66 /* the EmulationLayer was destroyed... */ 66 /* the EmulationLayer was destroyed... */
67 delete m_emLay; 67 delete m_emLay;
68 m_widget = wid; 68 m_widget = wid;
69} 69}
70void Session::setIOLayer( IOLayer* lay ) { 70void Session::setIOLayer( IOLayer* lay ) {
71 delete m_layer; 71 delete m_layer;
72 m_layer = lay; 72 m_layer = lay;
73} 73}
74void Session::setEmulationLayer( EmulationLayer* lay ) { 74void Session::setEmulationLayer( EmulationLayer* lay ) {
75 delete m_emLay; 75 delete m_emLay;
76 m_emLay = lay; 76 m_emLay = lay;
77} 77}
78void Session::setEmulationWidget( Widget* lay ) { 78void Session::setEmulationWidget( WidgetLayer* lay ) {
79 delete m_widLay; 79 delete m_widLay;
80 m_widLay = lay; 80 m_widLay = lay;
81} 81}
diff --git a/noncore/apps/opie-console/session.h b/noncore/apps/opie-console/session.h
index c3673fc..64c2cdb 100644
--- a/noncore/apps/opie-console/session.h
+++ b/noncore/apps/opie-console/session.h
@@ -1,74 +1,74 @@
1#ifndef OPIE_SESSION_H 1#ifndef OPIE_SESSION_H
2#define OPIE_SESSION_H 2#define OPIE_SESSION_H
3 3
4#include <qwidgetstack.h> 4#include <qwidgetstack.h>
5 5
6class IOLayer; 6class IOLayer;
7class EmulationLayer; 7class EmulationLayer;
8class Widget; 8class WidgetLayer;
9/** 9/**
10 * This is a Session. A session contains 10 * This is a Session. A session contains
11 * a QWidget pointer and a IOLayer 11 * a QWidget pointer and a IOLayer
12 * Imagine a session like a collection of what 12 * Imagine a session like a collection of what
13 * is needed to show your widget in a tab ;) 13 * is needed to show your widget in a tab ;)
14 */ 14 */
15class Session { 15class Session {
16public: 16public:
17 /** 17 /**
18 * c'tor with widget and layer 18 * c'tor with widget and layer
19 * ownership get's transfered 19 * ownership get's transfered
20 */ 20 */
21 Session(); 21 Session();
22 Session( const QString&, QWidgetStack* widget, IOLayer* ); 22 Session( const QString&, QWidgetStack* widget, IOLayer* );
23 ~Session(); 23 ~Session();
24 24
25 /** 25 /**
26 * return the name of the session 26 * return the name of the session
27 */ 27 */
28 QString name()const; 28 QString name()const;
29 29
30 /** 30 /**
31 * return the widgetstack 31 * return the widgetstack
32 * this is used to be semi modal 32 * this is used to be semi modal
33 * for FileTransfer 33 * for FileTransfer
34 * 34 *
35 * semi modal == SessionModal 35 * semi modal == SessionModal
36 */ 36 */
37 QWidgetStack* widgetStack(); 37 QWidgetStack* widgetStack();
38 38
39 /** 39 /**
40 * return the layer 40 * return the layer
41 */ 41 */
42 IOLayer* layer(); 42 IOLayer* layer();
43 43
44 EmulationLayer* emulationLayer(); 44 EmulationLayer* emulationLayer();
45 Widget* emulationWidget(); 45 WidgetLayer* emulationWidget();
46 46
47 /* 47 /*
48 * connects the data flow from 48 * connects the data flow from
49 * the IOLayer to the EmulationLayer 49 * the IOLayer to the EmulationLayer
50 */ 50 */
51 void connect(); 51 void connect();
52 52
53 /* 53 /*
54 * disconnect the dataflow 54 * disconnect the dataflow
55 * this will be done for ft 55 * this will be done for ft
56 */ 56 */
57 void disconnect(); 57 void disconnect();
58 58
59 void setWidgetStack( QWidgetStack* widget ); 59 void setWidgetStack( QWidgetStack* widget );
60 void setEmulationLayer( EmulationLayer* lay ); 60 void setEmulationLayer( EmulationLayer* lay );
61 void setEmulationWidget( Widget* lay ); 61 void setEmulationWidget( WidgetLayer* lay );
62 void setIOLayer( IOLayer* ); 62 void setIOLayer( IOLayer* );
63 void setName( const QString& ); 63 void setName( const QString& );
64 64
65private: 65private:
66 QString m_name; 66 QString m_name;
67 QWidgetStack* m_widget; 67 QWidgetStack* m_widget;
68 IOLayer* m_layer; 68 IOLayer* m_layer;
69 EmulationLayer* m_emLay; 69 EmulationLayer* m_emLay;
70 Widget* m_widLay; 70 WidgetLayer* m_widLay;
71 71
72}; 72};
73 73
74#endif 74#endif
diff --git a/noncore/apps/opie-console/widget.cpp b/noncore/apps/opie-console/widget.cpp
index b8f2906..d948179 100644
--- a/noncore/apps/opie-console/widget.cpp
+++ b/noncore/apps/opie-console/widget.cpp
@@ -1,535 +1,536 @@
1/* ------------------------------------------------------------------------ */ 1/* ------------------------------------------------------------------------ */
2/* */ 2/* */
3/* [TEWidget.C] Terminal Emulation Widget */ 3/* [TEWidget.C] Terminal Emulation Widget */
4/* */ 4/* */
5/* ------------------------------------------------------------------------ */ 5/* ------------------------------------------------------------------------ */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* ------------------------------------------------------------------------ */ 11/* ------------------------------------------------------------------------ */
12/* */ 12/* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14/* */ 14/* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16/* */ 16/* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18 18
19/* ibot: 19/* ibot:
20 i changed 20 i changed
21 "currentSession->getEmulation()->sendString()" to 21 "currentSession->getEmulation()->sendString()" to
22 "currentSession->layer()->send()" 22 "currentSession->layer()->send()"
23 # this is not right! EmulationLayer should send it... 23 # this is not right! EmulationLayer should send it...
24 i changed all those to use emulationLayer()->send() instead
24 i had to create a QByteArray before... 25 i had to create a QByteArray before...
25 26
26TODO: 27TODO:
27alter Widget to use only QByteArray, where applicable. 28alter Widget to use only QByteArray, where applicable.
28*/ 29*/
29 30
30 31
31 32
32/*! \class Widget 33/*! \class Widget
33 34
34 \brief Visible screen contents 35 \brief Visible screen contents
35 36
36 This class is responsible to map the `image' of a terminal emulation to the 37 This class is responsible to map the `image' of a terminal emulation to the
37 display. All the dependency of the emulation to a specific GUI or toolkit is 38 display. All the dependency of the emulation to a specific GUI or toolkit is
38 localized here. Further, this widget has no knowledge about being part of an 39 localized here. Further, this widget has no knowledge about being part of an
39 emulation, it simply work within the terminal emulation framework by exposing 40 emulation, it simply work within the terminal emulation framework by exposing
40 size and key events and by being ordered to show a new image. 41 size and key events and by being ordered to show a new image.
41 42
42 <ul> 43 <ul>
43 <li> The internal image has the size of the widget (evtl. rounded up) 44 <li> The internal image has the size of the widget (evtl. rounded up)
44 <li> The external image used in setImage can have any size. 45 <li> The external image used in setImage can have any size.
45 <li> (internally) the external image is simply copied to the internal 46 <li> (internally) the external image is simply copied to the internal
46 when a setImage happens. During a resizeEvent no painting is done 47 when a setImage happens. During a resizeEvent no painting is done
47 a paintEvent is expected to follow anyway. 48 a paintEvent is expected to follow anyway.
48 </ul> 49 </ul>
49 50
50 \sa TEScreen \sa Emulation 51 \sa TEScreen \sa Emulation
51*/ 52*/
52 53
53/* FIXME: 54/* FIXME:
54 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent 55 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent
55 - 'font_a' not used in mouse events 56 - 'font_a' not used in mouse events
56 - add destructor 57 - add destructor
57*/ 58*/
58 59
59/* TODO 60/* TODO
60 - evtl. be sensitive to `paletteChange' while using default colors. 61 - evtl. be sensitive to `paletteChange' while using default colors.
61 - set different 'rounding' styles? I.e. have a mode to show clipped chars? 62 - set different 'rounding' styles? I.e. have a mode to show clipped chars?
62*/ 63*/
63 64
64// #include "config.h" 65// #include "config.h"
65#include "widget.h" 66#include "widget.h"
66#include "session.h" 67#include "session.h"
67#include <qpe/config.h> 68#include <qpe/config.h>
68#include <qapplication.h> 69#include <qapplication.h>
69 70
70#include <qcursor.h> 71#include <qcursor.h>
71#include <qregexp.h> 72#include <qregexp.h>
72#include <qpainter.h> 73#include <qpainter.h>
73#include <qclipboard.h> 74#include <qclipboard.h>
74#include <qstyle.h> 75#include <qstyle.h>
75#include <qfile.h> 76#include <qfile.h>
76#include <qdragobject.h> 77#include <qdragobject.h>
77 78
78#include <stdio.h> 79#include <stdio.h>
79#include <stdlib.h> 80#include <stdlib.h>
80#include <unistd.h> 81#include <unistd.h>
81#include <ctype.h> 82#include <ctype.h>
82#include <sys/stat.h> 83#include <sys/stat.h>
83#include <sys/types.h> 84#include <sys/types.h>
84#include <signal.h> 85#include <signal.h>
85 86
86#include <assert.h> 87#include <assert.h>
87 88
88// #include "widget.moc" 89// #include "widget.moc"
89//#include <kapp.h> 90//#include <kapp.h>
90//#include <kcursor.h> 91//#include <kcursor.h>
91//#include <kurl.h> 92//#include <kurl.h>
92//#include <kdebug.h> 93//#include <kdebug.h>
93//#include <klocale.h> 94//#include <klocale.h>
94 95
95#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) 96#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__)
96#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } 97#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); }
97 98
98#define loc(X,Y) ((Y)*columns+(X)) 99#define loc(X,Y) ((Y)*columns+(X))
99 100
100//FIXME: the rim should normally be 1, 0 only when running in full screen mode. 101//FIXME: the rim should normally be 1, 0 only when running in full screen mode.
101#define rimX 0 // left/right rim width 102#define rimX 0 // left/right rim width
102#define rimY 0 // top/bottom rim high 103#define rimY 0 // top/bottom rim high
103 104
104#define SCRWIDTH 16 // width of the scrollbar 105#define SCRWIDTH 16 // width of the scrollbar
105 106
106#define yMouseScroll 1 107#define yMouseScroll 1
107// scroll increment used when dragging selection at top/bottom of window. 108// scroll increment used when dragging selection at top/bottom of window.
108 109
109/* ------------------------------------------------------------------------- */ 110/* ------------------------------------------------------------------------- */
110/* */ 111/* */
111/* Colors */ 112/* Colors */
112/* */ 113/* */
113/* ------------------------------------------------------------------------- */ 114/* ------------------------------------------------------------------------- */
114 115
115//FIXME: the default color table is in session.C now. 116//FIXME: the default color table is in session.C now.
116// We need a way to get rid of this one, here. 117// We need a way to get rid of this one, here.
117static const ColorEntry base_color_table[TABLE_COLORS] = 118static const ColorEntry base_color_table[TABLE_COLORS] =
118// The following are almost IBM standard color codes, with some slight 119// The following are almost IBM standard color codes, with some slight
119// gamma correction for the dim colors to compensate for bright X screens. 120// gamma correction for the dim colors to compensate for bright X screens.
120// It contains the 8 ansiterm/xterm colors in 2 intensities. 121// It contains the 8 ansiterm/xterm colors in 2 intensities.
121{ 122{
122 // Fixme: could add faint colors here, also. 123 // Fixme: could add faint colors here, also.
123 // normal 124 // normal
124 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback 125 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
125 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red 126 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
126 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow 127 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
127 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta 128 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
128 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White 129 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
129 // intensiv 130 // intensiv
130 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), 131 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
131 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), 132 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
132 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), 133 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
133 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), 134 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
134 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) 135 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
135}; 136};
136 137
137/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) 138/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb)
138 139
139 Code 0 1 2 3 4 5 6 7 140 Code 0 1 2 3 4 5 6 7
140 ----------- ------- ------- ------- ------- ------- ------- ------- ------- 141 ----------- ------- ------- ------- ------- ------- ------- ------- -------
141 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White 142 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White
142 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White 143 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White
143*/ 144*/
144 145
145QColor Widget::getDefaultBackColor() 146QColor Widget::getDefaultBackColor()
146{ 147{
147 return color_table[DEFAULT_BACK_COLOR].color; 148 return color_table[DEFAULT_BACK_COLOR].color;
148} 149}
149 150
150const ColorEntry* Widget::getColorTable() const 151const ColorEntry* Widget::getColorTable() const
151{ 152{
152 return color_table; 153 return color_table;
153} 154}
154 155
155const ColorEntry* Widget::getdefaultColorTable() const 156const ColorEntry* Widget::getdefaultColorTable() const
156{ 157{
157 return base_color_table; 158 return base_color_table;
158} 159}
159 160
160 161
161const QPixmap *Widget::backgroundPixmap() 162const QPixmap *Widget::backgroundPixmap()
162{ 163{
163 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); 164 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm");
164 const QPixmap *pm = bg; 165 const QPixmap *pm = bg;
165 return pm; 166 return pm;
166} 167}
167 168
168void Widget::setColorTable(const ColorEntry table[]) 169void Widget::setColorTable(const ColorEntry table[])
169{ 170{
170 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; 171 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i];
171 172
172 const QPixmap* pm = backgroundPixmap(); 173 const QPixmap* pm = backgroundPixmap();
173 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); 174 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color);
174 update(); 175 update();
175} 176}
176 177
177//FIXME: add backgroundPixmapChanged. 178//FIXME: add backgroundPixmapChanged.
178 179
179/* ------------------------------------------------------------------------- */ 180/* ------------------------------------------------------------------------- */
180/* */ 181/* */
181/* Font */ 182/* Font */
182/* */ 183/* */
183/* ------------------------------------------------------------------------- */ 184/* ------------------------------------------------------------------------- */
184 185
185/* 186/*
186 The VT100 has 32 special graphical characters. The usual vt100 extended 187 The VT100 has 32 special graphical characters. The usual vt100 extended
187 xterm fonts have these at 0x00..0x1f. 188 xterm fonts have these at 0x00..0x1f.
188 189
189 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals 190 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals
190 come in here as proper unicode characters. 191 come in here as proper unicode characters.
191 192
192 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping 193 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping
193 from unicode to 0x00..0x1f. The remaining translation is then left to the 194 from unicode to 0x00..0x1f. The remaining translation is then left to the
194 QCodec. 195 QCodec.
195*/ 196*/
196 197
197// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. 198// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i.
198 199
199unsigned short vt100_graphics[32] = 200unsigned short vt100_graphics[32] =
200{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 201{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15
201 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 202 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0,
202 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 203 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
203 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 204 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534,
204 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 205 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7
205}; 206};
206 207
207static QChar vt100extended(QChar c) 208static QChar vt100extended(QChar c)
208{ 209{
209 switch (c.unicode()) 210 switch (c.unicode())
210 { 211 {
211 case 0x25c6 : return 1; 212 case 0x25c6 : return 1;
212 case 0x2592 : return 2; 213 case 0x2592 : return 2;
213 case 0x2409 : return 3; 214 case 0x2409 : return 3;
214 case 0x240c : return 4; 215 case 0x240c : return 4;
215 case 0x240d : return 5; 216 case 0x240d : return 5;
216 case 0x240a : return 6; 217 case 0x240a : return 6;
217 case 0x00b0 : return 7; 218 case 0x00b0 : return 7;
218 case 0x00b1 : return 8; 219 case 0x00b1 : return 8;
219 case 0x2424 : return 9; 220 case 0x2424 : return 9;
220 case 0x240b : return 10; 221 case 0x240b : return 10;
221 case 0x2518 : return 11; 222 case 0x2518 : return 11;
222 case 0x2510 : return 12; 223 case 0x2510 : return 12;
223 case 0x250c : return 13; 224 case 0x250c : return 13;
224 case 0x2514 : return 14; 225 case 0x2514 : return 14;
225 case 0x253c : return 15; 226 case 0x253c : return 15;
226 case 0xf800 : return 16; 227 case 0xf800 : return 16;
227 case 0xf801 : return 17; 228 case 0xf801 : return 17;
228 case 0x2500 : return 18; 229 case 0x2500 : return 18;
229 case 0xf803 : return 19; 230 case 0xf803 : return 19;
230 case 0xf804 : return 20; 231 case 0xf804 : return 20;
231 case 0x251c : return 21; 232 case 0x251c : return 21;
232 case 0x2524 : return 22; 233 case 0x2524 : return 22;
233 case 0x2534 : return 23; 234 case 0x2534 : return 23;
234 case 0x252c : return 24; 235 case 0x252c : return 24;
235 case 0x2502 : return 25; 236 case 0x2502 : return 25;
236 case 0x2264 : return 26; 237 case 0x2264 : return 26;
237 case 0x2265 : return 27; 238 case 0x2265 : return 27;
238 case 0x03c0 : return 28; 239 case 0x03c0 : return 28;
239 case 0x2260 : return 29; 240 case 0x2260 : return 29;
240 case 0x00a3 : return 30; 241 case 0x00a3 : return 30;
241 case 0x00b7 : return 31; 242 case 0x00b7 : return 31;
242 } 243 }
243 return c; 244 return c;
244} 245}
245 246
246static QChar identicalMap(QChar c) 247static QChar identicalMap(QChar c)
247{ 248{
248 return c; 249 return c;
249} 250}
250 251
251void Widget::fontChange(const QFont &) 252void Widget::fontChange(const QFont &)
252{ 253{
253 QFontMetrics fm(font()); 254 QFontMetrics fm(font());
254 font_h = fm.height(); 255 font_h = fm.height();
255 font_w = fm.maxWidth(); 256 font_w = fm.maxWidth();
256 font_a = fm.ascent(); 257 font_a = fm.ascent();
257//printf("font_h: %d\n",font_h); 258//printf("font_h: %d\n",font_h);
258//printf("font_w: %d\n",font_w); 259//printf("font_w: %d\n",font_w);
259//printf("font_a: %d\n",font_a); 260//printf("font_a: %d\n",font_a);
260//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); 261//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii());
261//printf("rawname: %s\n",font().rawName().ascii()); 262//printf("rawname: %s\n",font().rawName().ascii());
262 fontMap = 263 fontMap =
263#if QT_VERSION < 300 264#if QT_VERSION < 300
264 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") 265 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646")
265 ? vt100extended 266 ? vt100extended
266 : 267 :
267#endif 268#endif
268 identicalMap; 269 identicalMap;
269 propagateSize(); 270 propagateSize();
270 update(); 271 update();
271} 272}
272 273
273void Widget::setVTFont(const QFont& f) 274void Widget::setVTFont(const QFont& f)
274{ 275{
275 QFrame::setFont(f); 276 QFrame::setFont(f);
276} 277}
277 278
278QFont Widget::getVTFont() { 279QFont Widget::getVTFont() {
279 return font(); 280 return font();
280} 281}
281 282
282void Widget::setFont(const QFont &) 283void Widget::setFont(const QFont &)
283{ 284{
284 // ignore font change request if not coming from konsole itself 285 // ignore font change request if not coming from konsole itself
285} 286}
286 287
287/* ------------------------------------------------------------------------- */ 288/* ------------------------------------------------------------------------- */
288/* */ 289/* */
289/* Constructor / Destructor */ 290/* Constructor / Destructor */
290/* */ 291/* */
291/* ------------------------------------------------------------------------- */ 292/* ------------------------------------------------------------------------- */
292 293
293Widget::Widget(QWidget *parent, const char *name) : QFrame(parent,name) 294Widget::Widget(QWidget *parent, const char *name) : QFrame(parent,name)
294{ 295{
295#ifndef QT_NO_CLIPBOARD 296#ifndef QT_NO_CLIPBOARD
296 cb = QApplication::clipboard(); 297 cb = QApplication::clipboard();
297 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 298 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
298 this, SLOT(onClearSelection()) ); 299 this, SLOT(onClearSelection()) );
299#endif 300#endif
300 301
301 scrollbar = new QScrollBar(this); 302 scrollbar = new QScrollBar(this);
302 scrollbar->setCursor( arrowCursor ); 303 scrollbar->setCursor( arrowCursor );
303 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 304 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
304 305
305 Config cfg("Konsole"); 306 Config cfg("Konsole");
306 cfg.setGroup("ScrollBar"); 307 cfg.setGroup("ScrollBar");
307 switch( cfg.readNumEntry("Position",2)){ 308 switch( cfg.readNumEntry("Position",2)){
308 case 0: 309 case 0:
309 scrollLoc = SCRNONE; 310 scrollLoc = SCRNONE;
310 break; 311 break;
311 case 1: 312 case 1:
312 scrollLoc = SCRLEFT; 313 scrollLoc = SCRLEFT;
313 break; 314 break;
314 case 2: 315 case 2:
315 scrollLoc = SCRRIGHT; 316 scrollLoc = SCRRIGHT;
316 break; 317 break;
317 }; 318 };
318 319
319 blinkT = new QTimer(this); 320 blinkT = new QTimer(this);
320 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); 321 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent()));
321 // blinking = FALSE; 322 // blinking = FALSE;
322 blinking = TRUE; 323 blinking = TRUE;
323 324
324 resizing = FALSE; 325 resizing = FALSE;
325 actSel = 0; 326 actSel = 0;
326 image = 0; 327 image = 0;
327 lines = 1; 328 lines = 1;
328 columns = 1; 329 columns = 1;
329 font_w = 1; 330 font_w = 1;
330 font_h = 1; 331 font_h = 1;
331 font_a = 1; 332 font_a = 1;
332 word_selection_mode = FALSE; 333 word_selection_mode = FALSE;
333 334
334 setMouseMarks(TRUE); 335 setMouseMarks(TRUE);
335 setVTFont( QFont("fixed") ); 336 setVTFont( QFont("fixed") );
336 setColorTable(base_color_table); // init color table 337 setColorTable(base_color_table); // init color table
337 338
338 qApp->installEventFilter( this ); //FIXME: see below 339 qApp->installEventFilter( this ); //FIXME: see below
339// KCursor::setAutoHideCursor( this, true ); 340// KCursor::setAutoHideCursor( this, true );
340 341
341 // Init DnD //////////////////////////////////////////////////////////////// 342 // Init DnD ////////////////////////////////////////////////////////////////
342 currentSession = NULL; 343 currentSession = NULL;
343// setAcceptDrops(true); // attempt 344// setAcceptDrops(true); // attempt
344// m_drop = new QPopupMenu(this); 345// m_drop = new QPopupMenu(this);
345// m_drop->insertItem( QString("Paste"), 0); 346// m_drop->insertItem( QString("Paste"), 0);
346// m_drop->insertItem( QString("cd"), 1); 347// m_drop->insertItem( QString("cd"), 1);
347// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); 348// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int)));
348 349
349 // we need focus so that the auto-hide cursor feature works 350 // we need focus so that the auto-hide cursor feature works
350 setFocus(); 351 setFocus();
351 setFocusPolicy( WheelFocus ); 352 setFocusPolicy( WheelFocus );
352} 353}
353 354
354//FIXME: make proper destructor 355//FIXME: make proper destructor
355// Here's a start (David) 356// Here's a start (David)
356Widget::~Widget() 357Widget::~Widget()
357{ 358{
358 qApp->removeEventFilter( this ); 359 qApp->removeEventFilter( this );
359 if (image) free(image); 360 if (image) free(image);
360} 361}
361 362
362/* ------------------------------------------------------------------------- */ 363/* ------------------------------------------------------------------------- */
363/* */ 364/* */
364/* Display Operations */ 365/* Display Operations */
365/* */ 366/* */
366/* ------------------------------------------------------------------------- */ 367/* ------------------------------------------------------------------------- */
367 368
368/*! 369/*!
369 attributed string draw primitive 370 attributed string draw primitive
370*/ 371*/
371 372
372void Widget::drawAttrStr(QPainter &paint, QRect rect, 373void Widget::drawAttrStr(QPainter &paint, QRect rect,
373 QString& str, Character attr, BOOL pm, BOOL clear) 374 QString& str, Character attr, BOOL pm, BOOL clear)
374{ 375{
375 if (pm && color_table[attr.b].transparent) 376 if (pm && color_table[attr.b].transparent)
376 { 377 {
377 paint.setBackgroundMode( TransparentMode ); 378 paint.setBackgroundMode( TransparentMode );
378 if (clear) erase(rect); 379 if (clear) erase(rect);
379 } 380 }
380 else 381 else
381 { 382 {
382 if (blinking) 383 if (blinking)
383 paint.fillRect(rect, color_table[attr.b].color); 384 paint.fillRect(rect, color_table[attr.b].color);
384 else 385 else
385 { 386 {
386 paint.setBackgroundMode( OpaqueMode ); 387 paint.setBackgroundMode( OpaqueMode );
387 paint.setBackgroundColor( color_table[attr.b].color ); 388 paint.setBackgroundColor( color_table[attr.b].color );
388 } 389 }
389 } 390 }
390 391
391 if (color_table[attr.f].bold) 392 if (color_table[attr.f].bold)
392 paint.setPen(QColor( 0x8F, 0x00, 0x00 )); 393 paint.setPen(QColor( 0x8F, 0x00, 0x00 ));
393 else 394 else
394 paint.setPen(color_table[attr.f].color); 395 paint.setPen(color_table[attr.f].color);
395 396
396 paint.drawText(rect.x(),rect.y()+font_a, str); 397 paint.drawText(rect.x(),rect.y()+font_a, str);
397 398
398 if (attr.r & RE_UNDERLINE) 399 if (attr.r & RE_UNDERLINE)
399 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); 400 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 );
400} 401}
401 402
402/*! 403/*!
403 The image can only be set completely. 404 The image can only be set completely.
404 405
405 The size of the new image may or may not match the size of the widget. 406 The size of the new image may or may not match the size of the widget.
406*/ 407*/
407 408
408void Widget::setImage(const Character* const newimg, int lines, int columns) 409void Widget::setImage(const Character* const newimg, int lines, int columns)
409{ int y,x,len; 410{ int y,x,len;
410 const QPixmap* pm = backgroundPixmap(); 411 const QPixmap* pm = backgroundPixmap();
411 QPainter paint; 412 QPainter paint;
412 setUpdatesEnabled(FALSE); 413 setUpdatesEnabled(FALSE);
413 paint.begin( this ); 414 paint.begin( this );
414HCNT("setImage"); 415HCNT("setImage");
415 416
416 QPoint tL = contentsRect().topLeft(); 417 QPoint tL = contentsRect().topLeft();
417 int tLx = tL.x(); 418 int tLx = tL.x();
418 int tLy = tL.y(); 419 int tLy = tL.y();
419 hasBlinker = FALSE; 420 hasBlinker = FALSE;
420 421
421 int cf = -1; // undefined 422 int cf = -1; // undefined
422 int cb = -1; // undefined 423 int cb = -1; // undefined
423 int cr = -1; // undefined 424 int cr = -1; // undefined
424 425
425 int lins = QMIN(this->lines, QMAX(0,lines )); 426 int lins = QMIN(this->lines, QMAX(0,lines ));
426 int cols = QMIN(this->columns,QMAX(0,columns)); 427 int cols = QMIN(this->columns,QMAX(0,columns));
427 QChar *disstrU = new QChar[cols]; 428 QChar *disstrU = new QChar[cols];
428 429
429//{ static int cnt = 0; printf("setImage %d\n",cnt++); } 430//{ static int cnt = 0; printf("setImage %d\n",cnt++); }
430 for (y = 0; y < lins; y++) 431 for (y = 0; y < lins; y++)
431 { 432 {
432 const Character* lcl = &image[y*this->columns]; 433 const Character* lcl = &image[y*this->columns];
433 const Character* const ext = &newimg[y*columns]; 434 const Character* const ext = &newimg[y*columns];
434 if (!resizing) // not while resizing, we're expecting a paintEvent 435 if (!resizing) // not while resizing, we're expecting a paintEvent
435 for (x = 0; x < cols; x++) 436 for (x = 0; x < cols; x++)
436 { 437 {
437 hasBlinker |= (ext[x].r & RE_BLINK); 438 hasBlinker |= (ext[x].r & RE_BLINK);
438 if (ext[x] != lcl[x]) 439 if (ext[x] != lcl[x])
439 { 440 {
440 cr = ext[x].r; 441 cr = ext[x].r;
441 cb = ext[x].b; 442 cb = ext[x].b;
442 if (ext[x].f != cf) cf = ext[x].f; 443 if (ext[x].f != cf) cf = ext[x].f;
443 int lln = cols - x; 444 int lln = cols - x;
444 disstrU[0] = fontMap(ext[x+0].c); 445 disstrU[0] = fontMap(ext[x+0].c);
445 for (len = 1; len < lln; len++) 446 for (len = 1; len < lln; len++)
446 { 447 {
447 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || 448 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr ||
448 ext[x+len] == lcl[x+len] ) 449 ext[x+len] == lcl[x+len] )
449 break; 450 break;
450 disstrU[len] = fontMap(ext[x+len].c); 451 disstrU[len] = fontMap(ext[x+len].c);
451 } 452 }
452 QString unistr(disstrU,len); 453 QString unistr(disstrU,len);
453 drawAttrStr(paint, 454 drawAttrStr(paint,
454 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 455 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
455 unistr, ext[x], pm != NULL, true); 456 unistr, ext[x], pm != NULL, true);
456 x += len - 1; 457 x += len - 1;
457 } 458 }
458 } 459 }
459 // finally, make `image' become `newimg'. 460 // finally, make `image' become `newimg'.
460 memcpy((void*)lcl,(const void*)ext,cols*sizeof(Character)); 461 memcpy((void*)lcl,(const void*)ext,cols*sizeof(Character));
461 } 462 }
462 drawFrame( &paint ); 463 drawFrame( &paint );
463 paint.end(); 464 paint.end();
464 setUpdatesEnabled(TRUE); 465 setUpdatesEnabled(TRUE);
465 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms 466 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms
466 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } 467 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; }
467 delete [] disstrU; 468 delete [] disstrU;
468} 469}
469 470
470// paint Event //////////////////////////////////////////////////// 471// paint Event ////////////////////////////////////////////////////
471 472
472/*! 473/*!
473 The difference of this routine vs. the `setImage' is, 474 The difference of this routine vs. the `setImage' is,
474 that the drawing does not include a difference analysis 475 that the drawing does not include a difference analysis
475 between the old and the new image. Instead, the internal 476 between the old and the new image. Instead, the internal
476 image is used and the painting bound by the PaintEvent box. 477 image is used and the painting bound by the PaintEvent box.
477*/ 478*/
478 479
479void Widget::paintEvent( QPaintEvent* pe ) 480void Widget::paintEvent( QPaintEvent* pe )
480{ 481{
481 482
482//{ static int cnt = 0; printf("paint %d\n",cnt++); } 483//{ static int cnt = 0; printf("paint %d\n",cnt++); }
483 const QPixmap* pm = backgroundPixmap(); 484 const QPixmap* pm = backgroundPixmap();
484 QPainter paint; 485 QPainter paint;
485 setUpdatesEnabled(FALSE); 486 setUpdatesEnabled(FALSE);
486 paint.begin( this ); 487 paint.begin( this );
487 paint.setBackgroundMode( TransparentMode ); 488 paint.setBackgroundMode( TransparentMode );
488HCNT("paintEvent"); 489HCNT("paintEvent");
489 490
490 // Note that the actual widget size can be slightly larger 491 // Note that the actual widget size can be slightly larger
491 // that the image (the size is truncated towards the smaller 492 // that the image (the size is truncated towards the smaller
492 // number of characters in `resizeEvent'. The paint rectangle 493 // number of characters in `resizeEvent'. The paint rectangle
493 // can thus be larger than the image, but less then the size 494 // can thus be larger than the image, but less then the size
494 // of one character. 495 // of one character.
495 496
496 QRect rect = pe->rect().intersect(contentsRect()); 497 QRect rect = pe->rect().intersect(contentsRect());
497 498
498 QPoint tL = contentsRect().topLeft(); 499 QPoint tL = contentsRect().topLeft();
499 int tLx = tL.x(); 500 int tLx = tL.x();
500 int tLy = tL.y(); 501 int tLy = tL.y();
501 502
502 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); 503 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w));
503 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); 504 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h));
504 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); 505 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w));
505 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); 506 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h));
506 507
507 /* 508 /*
508 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, 509 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly,
509 rect.left(), rect.right(), rect.top(), rect.bottom()); 510 rect.left(), rect.right(), rect.top(), rect.bottom());
510 */ 511 */
511 512
512 // if (pm != NULL && color_table[image->b].transparent) 513 // if (pm != NULL && color_table[image->b].transparent)
513 // erase(rect); 514 // erase(rect);
514 // BL: I have no idea why we need this, and it breaks the refresh. 515 // BL: I have no idea why we need this, and it breaks the refresh.
515 516
516 QChar *disstrU = new QChar[columns]; 517 QChar *disstrU = new QChar[columns];
517 for (int y = luy; y <= rly; y++) 518 for (int y = luy; y <= rly; y++)
518 for (int x = lux; x <= rlx; x++) 519 for (int x = lux; x <= rlx; x++)
519 { 520 {
520 int len = 1; 521 int len = 1;
521 disstrU[0] = fontMap(image[loc(x,y)].c); 522 disstrU[0] = fontMap(image[loc(x,y)].c);
522 int cf = image[loc(x,y)].f; 523 int cf = image[loc(x,y)].f;
523 int cb = image[loc(x,y)].b; 524 int cb = image[loc(x,y)].b;
524 int cr = image[loc(x,y)].r; 525 int cr = image[loc(x,y)].r;
525 while (x+len <= rlx && 526 while (x+len <= rlx &&
526 image[loc(x+len,y)].f == cf && 527 image[loc(x+len,y)].f == cf &&
527 image[loc(x+len,y)].b == cb && 528 image[loc(x+len,y)].b == cb &&
528 image[loc(x+len,y)].r == cr ) 529 image[loc(x+len,y)].r == cr )
529 { 530 {
530 disstrU[len] = fontMap(image[loc(x+len,y)].c); 531 disstrU[len] = fontMap(image[loc(x+len,y)].c);
531 len += 1; 532 len += 1;
532 } 533 }
533 QString unistr(disstrU,len); 534 QString unistr(disstrU,len);
534 drawAttrStr(paint, 535 drawAttrStr(paint,
535 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 536 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
@@ -721,571 +722,572 @@ void Widget::mouseMoveEvent(QMouseEvent* ev)
721 QPoint pos = ev->pos(); 722 QPoint pos = ev->pos();
722 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); 723 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX );
723 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); 724 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w );
724 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); 725 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY );
725 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); 726 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 );
726 // check if we produce a mouse move event by this 727 // check if we produce a mouse move event by this
727 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); 728 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos));
728 729
729 if ( pos.y() == tLy+bY+lines*font_h-1 ) 730 if ( pos.y() == tLy+bY+lines*font_h-1 )
730 { 731 {
731 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward 732 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward
732 } 733 }
733 if ( pos.y() == tLy+bY ) 734 if ( pos.y() == tLy+bY )
734 { 735 {
735 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback 736 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback
736 } 737 }
737 738
738 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); 739 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h);
739 QPoint ohere; 740 QPoint ohere;
740 bool swapping = FALSE; 741 bool swapping = FALSE;
741 742
742 if ( word_selection_mode ) 743 if ( word_selection_mode )
743 { 744 {
744 // Extend to word boundaries 745 // Extend to word boundaries
745 int i; 746 int i;
746 int selClass; 747 int selClass;
747 748
748 bool left_not_right = ( here.y() < iPntSel.y() || 749 bool left_not_right = ( here.y() < iPntSel.y() ||
749 here.y() == iPntSel.y() && here.x() < iPntSel.x() ); 750 here.y() == iPntSel.y() && here.x() < iPntSel.x() );
750 bool old_left_not_right = ( pntSel.y() < iPntSel.y() || 751 bool old_left_not_right = ( pntSel.y() < iPntSel.y() ||
751 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); 752 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() );
752 swapping = left_not_right != old_left_not_right; 753 swapping = left_not_right != old_left_not_right;
753 754
754 // Find left (left_not_right ? from here : from start) 755 // Find left (left_not_right ? from here : from start)
755 QPoint left = left_not_right ? here : iPntSel; 756 QPoint left = left_not_right ? here : iPntSel;
756 i = loc(left.x(),left.y()); 757 i = loc(left.x(),left.y());
757 selClass = charClass(image[i].c); 758 selClass = charClass(image[i].c);
758 while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) 759 while ( left.x() > 0 && charClass(image[i-1].c) == selClass )
759 { i--; left.rx()--; } 760 { i--; left.rx()--; }
760 761
761 // Find left (left_not_right ? from start : from here) 762 // Find left (left_not_right ? from start : from here)
762 QPoint right = left_not_right ? iPntSel : here; 763 QPoint right = left_not_right ? iPntSel : here;
763 i = loc(right.x(),right.y()); 764 i = loc(right.x(),right.y());
764 selClass = charClass(image[i].c); 765 selClass = charClass(image[i].c);
765 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) 766 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass )
766 { i++; right.rx()++; } 767 { i++; right.rx()++; }
767 768
768 // Pick which is start (ohere) and which is extension (here) 769 // Pick which is start (ohere) and which is extension (here)
769 if ( left_not_right ) 770 if ( left_not_right )
770 { 771 {
771 here = left; ohere = right; 772 here = left; ohere = right;
772 } 773 }
773 else 774 else
774 { 775 {
775 here = right; ohere = left; 776 here = right; ohere = left;
776 } 777 }
777 } 778 }
778 779
779 if (here == pntSel && scroll == scrollbar->value()) return; // not moved 780 if (here == pntSel && scroll == scrollbar->value()) return; // not moved
780 781
781 if ( word_selection_mode ) { 782 if ( word_selection_mode ) {
782 if ( actSel < 2 || swapping ) { 783 if ( actSel < 2 || swapping ) {
783 emit beginSelectionSignal( ohere.x(), ohere.y() ); 784 emit beginSelectionSignal( ohere.x(), ohere.y() );
784 } 785 }
785 } else if ( actSel < 2 ) { 786 } else if ( actSel < 2 ) {
786 emit beginSelectionSignal( pntSel.x(), pntSel.y() ); 787 emit beginSelectionSignal( pntSel.x(), pntSel.y() );
787 } 788 }
788 789
789 actSel = 2; // within selection 790 actSel = 2; // within selection
790 pntSel = here; 791 pntSel = here;
791 emit extendSelectionSignal( here.x(), here.y() ); 792 emit extendSelectionSignal( here.x(), here.y() );
792} 793}
793 794
794void Widget::mouseReleaseEvent(QMouseEvent* ev) 795void Widget::mouseReleaseEvent(QMouseEvent* ev)
795{ 796{
796//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 797//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
797 if ( ev->button() == LeftButton) 798 if ( ev->button() == LeftButton)
798 { 799 {
799 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); 800 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks);
800 preserve_line_breaks = TRUE; 801 preserve_line_breaks = TRUE;
801 actSel = 0; 802 actSel = 0;
802 803
803 //FIXME: emits a release event even if the mouse is 804 //FIXME: emits a release event even if the mouse is
804 // outside the range. The procedure used in `mouseMoveEvent' 805 // outside the range. The procedure used in `mouseMoveEvent'
805 // applies here, too. 806 // applies here, too.
806 807
807 QPoint tL = contentsRect().topLeft(); 808 QPoint tL = contentsRect().topLeft();
808 int tLx = tL.x(); 809 int tLx = tL.x();
809 int tLy = tL.y(); 810 int tLy = tL.y();
810 811
811 if (!mouse_marks && !(ev->state() & ShiftButton)) 812 if (!mouse_marks && !(ev->state() & ShiftButton))
812 emit mouseSignal( 3, // release 813 emit mouseSignal( 3, // release
813 (ev->x()-tLx-blX)/font_w + 1, 814 (ev->x()-tLx-blX)/font_w + 1,
814 (ev->y()-tLy-bY)/font_h + 1 ); 815 (ev->y()-tLy-bY)/font_h + 1 );
815 releaseMouse(); 816 releaseMouse();
816 } 817 }
817} 818}
818 819
819void Widget::mouseDoubleClickEvent(QMouseEvent* ev) 820void Widget::mouseDoubleClickEvent(QMouseEvent* ev)
820{ 821{
821 if ( ev->button() != LeftButton) return; 822 if ( ev->button() != LeftButton) return;
822 823
823 QPoint tL = contentsRect().topLeft(); 824 QPoint tL = contentsRect().topLeft();
824 int tLx = tL.x(); 825 int tLx = tL.x();
825 int tLy = tL.y(); 826 int tLy = tL.y();
826 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 827 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
827 828
828 // pass on double click as two clicks. 829 // pass on double click as two clicks.
829 if (!mouse_marks && !(ev->state() & ShiftButton)) 830 if (!mouse_marks && !(ev->state() & ShiftButton))
830 { 831 {
831 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 832 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
832 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release 833 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release
833 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 834 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
834 return; 835 return;
835 } 836 }
836 837
837 838
838 emit clearSelectionSignal(); 839 emit clearSelectionSignal();
839 QPoint bgnSel = pos; 840 QPoint bgnSel = pos;
840 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 841 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
841 int i = loc(bgnSel.x(),bgnSel.y()); 842 int i = loc(bgnSel.x(),bgnSel.y());
842 iPntSel = bgnSel; 843 iPntSel = bgnSel;
843 844
844 word_selection_mode = TRUE; 845 word_selection_mode = TRUE;
845 846
846 // find word boundaries... 847 // find word boundaries...
847 int selClass = charClass(image[i].c); 848 int selClass = charClass(image[i].c);
848 { 849 {
849 // set the start... 850 // set the start...
850 int x = bgnSel.x(); 851 int x = bgnSel.x();
851 while ( x > 0 && charClass(image[i-1].c) == selClass ) 852 while ( x > 0 && charClass(image[i-1].c) == selClass )
852 { i--; x--; } 853 { i--; x--; }
853 bgnSel.setX(x); 854 bgnSel.setX(x);
854 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); 855 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() );
855 856
856 // set the end... 857 // set the end...
857 i = loc( endSel.x(), endSel.y() ); 858 i = loc( endSel.x(), endSel.y() );
858 x = endSel.x(); 859 x = endSel.x();
859 while( x < columns-1 && charClass(image[i+1].c) == selClass ) 860 while( x < columns-1 && charClass(image[i+1].c) == selClass )
860 { i++; x++ ; } 861 { i++; x++ ; }
861 endSel.setX(x); 862 endSel.setX(x);
862 actSel = 2; // within selection 863 actSel = 2; // within selection
863 emit extendSelectionSignal( endSel.x(), endSel.y() ); 864 emit extendSelectionSignal( endSel.x(), endSel.y() );
864 emit endSelectionSignal(preserve_line_breaks); 865 emit endSelectionSignal(preserve_line_breaks);
865 preserve_line_breaks = TRUE; 866 preserve_line_breaks = TRUE;
866 } 867 }
867} 868}
868 869
869void Widget::focusInEvent( QFocusEvent * ) 870void Widget::focusInEvent( QFocusEvent * )
870{ 871{
871 872
872 // do nothing, to prevent repainting 873 // do nothing, to prevent repainting
873} 874}
874 875
875 876
876void Widget::focusOutEvent( QFocusEvent * ) 877void Widget::focusOutEvent( QFocusEvent * )
877{ 878{
878 // do nothing, to prevent repainting 879 // do nothing, to prevent repainting
879} 880}
880 881
881bool Widget::focusNextPrevChild( bool next ) 882bool Widget::focusNextPrevChild( bool next )
882{ 883{
883 if (next) 884 if (next)
884 return false; // This disables changing the active part in konqueror 885 return false; // This disables changing the active part in konqueror
885 // when pressing Tab 886 // when pressing Tab
886 return QFrame::focusNextPrevChild( next ); 887 return QFrame::focusNextPrevChild( next );
887} 888}
888 889
889 890
890int Widget::charClass(char ch) const 891int Widget::charClass(char ch) const
891{ 892{
892 // This might seem like overkill, but imagine if ch was a Unicode 893 // This might seem like overkill, but imagine if ch was a Unicode
893 // character (Qt 2.0 QChar) - it might then be sensible to separate 894 // character (Qt 2.0 QChar) - it might then be sensible to separate
894 // the different language ranges, etc. 895 // the different language ranges, etc.
895 896
896 if ( isspace(ch) ) return ' '; 897 if ( isspace(ch) ) return ' ';
897 898
898 static const char *word_characters = ":@-./_~"; 899 static const char *word_characters = ":@-./_~";
899 if ( isalnum(ch) || strchr(word_characters, ch) ) 900 if ( isalnum(ch) || strchr(word_characters, ch) )
900 return 'a'; 901 return 'a';
901 902
902 // Everything else is weird 903 // Everything else is weird
903 return 1; 904 return 1;
904} 905}
905 906
906void Widget::setMouseMarks(bool on) 907void Widget::setMouseMarks(bool on)
907{ 908{
908 mouse_marks = on; 909 mouse_marks = on;
909 setCursor( mouse_marks ? ibeamCursor : arrowCursor ); 910 setCursor( mouse_marks ? ibeamCursor : arrowCursor );
910} 911}
911 912
912/* ------------------------------------------------------------------------- */ 913/* ------------------------------------------------------------------------- */
913/* */ 914/* */
914/* Clipboard */ 915/* Clipboard */
915/* */ 916/* */
916/* ------------------------------------------------------------------------- */ 917/* ------------------------------------------------------------------------- */
917 918
918#undef KeyPress 919#undef KeyPress
919 920
920void Widget::emitSelection() 921void Widget::emitSelection()
921// Paste Clipboard by simulating keypress events 922// Paste Clipboard by simulating keypress events
922{ 923{
923#ifndef QT_NO_CLIPBOARD 924#ifndef QT_NO_CLIPBOARD
924 QString text = QApplication::clipboard()->text(); 925 QString text = QApplication::clipboard()->text();
925 if ( ! text.isNull() ) 926 if ( ! text.isNull() )
926 { 927 {
927 text.replace(QRegExp("\n"), "\r"); 928 text.replace(QRegExp("\n"), "\r");
928 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 929 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
929 emit keyPressedSignal(&e); // expose as a big fat keypress event 930 emit keyPressedSignal(&e); // expose as a big fat keypress event
930 emit clearSelectionSignal(); 931 emit clearSelectionSignal();
931 } 932 }
932#endif 933#endif
933} 934}
934 935
935void Widget::emitText(QString text) 936void Widget::emitText(QString text)
936{ 937{
937 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 938 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
938 emit keyPressedSignal(&e); // expose as a big fat keypress event 939 emit keyPressedSignal(&e); // expose as a big fat keypress event
939} 940}
940 941
941void Widget::pasteClipboard( ) 942void Widget::pasteClipboard( )
942{ 943{
943 emitSelection(); 944 emitSelection();
944} 945}
945 946
946void Widget::setSelection(const QString& t) 947void Widget::setSelection(const QString& t)
947{ 948{
948#ifndef QT_NO_CLIPBOARD 949#ifndef QT_NO_CLIPBOARD
949 // Disconnect signal while WE set the clipboard 950 // Disconnect signal while WE set the clipboard
950 QObject *cb = QApplication::clipboard(); 951 QObject *cb = QApplication::clipboard();
951 QObject::disconnect( cb, SIGNAL(dataChanged()), 952 QObject::disconnect( cb, SIGNAL(dataChanged()),
952 this, SLOT(onClearSelection()) ); 953 this, SLOT(onClearSelection()) );
953 954
954 QApplication::clipboard()->setText(t); 955 QApplication::clipboard()->setText(t);
955 956
956 QObject::connect( cb, SIGNAL(dataChanged()), 957 QObject::connect( cb, SIGNAL(dataChanged()),
957 this, SLOT(onClearSelection()) ); 958 this, SLOT(onClearSelection()) );
958#endif 959#endif
959} 960}
960 961
961void Widget::onClearSelection() 962void Widget::onClearSelection()
962{ 963{
963 emit clearSelectionSignal(); 964 emit clearSelectionSignal();
964} 965}
965 966
966/* ------------------------------------------------------------------------- */ 967/* ------------------------------------------------------------------------- */
967/* */ 968/* */
968/* Keyboard */ 969/* Keyboard */
969/* */ 970/* */
970/* ------------------------------------------------------------------------- */ 971/* ------------------------------------------------------------------------- */
971 972
972//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' 973//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent'
973// due to a bug in `QT' or the ignorance of the author to prevent 974// due to a bug in `QT' or the ignorance of the author to prevent
974// repaint events being emitted to the screen whenever one leaves 975// repaint events being emitted to the screen whenever one leaves
975// or reenters the screen to/from another application. 976// or reenters the screen to/from another application.
976// 977//
977// Troll says one needs to change focusInEvent() and focusOutEvent(), 978// Troll says one needs to change focusInEvent() and focusOutEvent(),
978// which would also let you have an in-focus cursor and an out-focus 979// which would also let you have an in-focus cursor and an out-focus
979// cursor like xterm does. 980// cursor like xterm does.
980 981
981// for the auto-hide cursor feature, I added empty focusInEvent() and 982// for the auto-hide cursor feature, I added empty focusInEvent() and
982// focusOutEvent() so that update() isn't called. 983// focusOutEvent() so that update() isn't called.
983// For auto-hide, we need to get keypress-events, but we only get them when 984// For auto-hide, we need to get keypress-events, but we only get them when
984// we have focus. 985// we have focus.
985 986
986void Widget::doScroll(int lines) 987void Widget::doScroll(int lines)
987{ 988{
988 scrollbar->setValue(scrollbar->value()+lines); 989 scrollbar->setValue(scrollbar->value()+lines);
989} 990}
990 991
991bool Widget::eventFilter( QObject *obj, QEvent *e ) 992bool Widget::eventFilter( QObject *obj, QEvent *e )
992{ 993{
993 if ( (e->type() == QEvent::Accel || 994 if ( (e->type() == QEvent::Accel ||
994 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 995 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
995 static_cast<QKeyEvent *>( e )->ignore(); 996 static_cast<QKeyEvent *>( e )->ignore();
996 return true; 997 return true;
997 } 998 }
998 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 999 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
999 return FALSE; // not us 1000 return FALSE; // not us
1000 if ( e->type() == QEvent::Wheel) { 1001 if ( e->type() == QEvent::Wheel) {
1001 QApplication::sendEvent(scrollbar, e); 1002 QApplication::sendEvent(scrollbar, e);
1002 } 1003 }
1003 1004
1004#ifdef FAKE_CTRL_AND_ALT 1005#ifdef FAKE_CTRL_AND_ALT
1005 static bool control = FALSE; 1006 static bool control = FALSE;
1006 static bool alt = FALSE; 1007 static bool alt = FALSE;
1007// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 1008// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
1008 bool dele=FALSE; 1009 bool dele=FALSE;
1009 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1010 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1010 QKeyEvent* ke = (QKeyEvent*)e; 1011 QKeyEvent* ke = (QKeyEvent*)e;
1011 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 1012 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
1012 switch (ke->key()) { 1013 switch (ke->key()) {
1013 case Key_F9: // let this be "Control" 1014 case Key_F9: // let this be "Control"
1014 control = keydown; 1015 control = keydown;
1015 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 1016 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
1016 dele=TRUE; 1017 dele=TRUE;
1017 break; 1018 break;
1018 case Key_F13: // let this be "Alt" 1019 case Key_F13: // let this be "Alt"
1019 alt = keydown; 1020 alt = keydown;
1020 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 1021 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
1021 dele=TRUE; 1022 dele=TRUE;
1022 break; 1023 break;
1023 default: 1024 default:
1024 if ( control ) { 1025 if ( control ) {
1025 int a = toupper(ke->ascii())-64; 1026 int a = toupper(ke->ascii())-64;
1026 if ( a >= 0 && a < ' ' ) { 1027 if ( a >= 0 && a < ' ' ) {
1027 e = new QKeyEvent(e->type(), ke->key(), 1028 e = new QKeyEvent(e->type(), ke->key(),
1028 a, ke->state()|ControlButton, QChar(a,0)); 1029 a, ke->state()|ControlButton, QChar(a,0));
1029 dele=TRUE; 1030 dele=TRUE;
1030 } 1031 }
1031 } 1032 }
1032 if ( alt ) { 1033 if ( alt ) {
1033 e = new QKeyEvent(e->type(), ke->key(), 1034 e = new QKeyEvent(e->type(), ke->key(),
1034 ke->ascii(), ke->state()|AltButton, ke->text()); 1035 ke->ascii(), ke->state()|AltButton, ke->text());
1035 dele=TRUE; 1036 dele=TRUE;
1036 } 1037 }
1037 } 1038 }
1038 } 1039 }
1039#endif 1040#endif
1040 1041
1041 if ( e->type() == QEvent::KeyPress ) { 1042 if ( e->type() == QEvent::KeyPress ) {
1042 QKeyEvent* ke = (QKeyEvent*)e; 1043 QKeyEvent* ke = (QKeyEvent*)e;
1043 actSel=0; // Key stroke implies a screen update, so Widget won't 1044 actSel=0; // Key stroke implies a screen update, so Widget won't
1044 // know where the current selection is. 1045 // know where the current selection is.
1045 1046
1046// qDebug("key pressed is 0x%x",ke->key()); 1047// qDebug("key pressed is 0x%x",ke->key());
1047 1048
1048 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker 1049 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
1049 1050
1050// qDebug("key pressed 2 is 0x%x",ke->key()); 1051// qDebug("key pressed 2 is 0x%x",ke->key());
1051 emitText("\\"); // expose 1052 emitText("\\"); // expose
1052 } else 1053 } else
1053 emit keyPressedSignal(ke); // expose 1054 emit keyPressedSignal(ke); // expose
1054 ke->accept(); 1055 ke->accept();
1055#ifdef FAKE_CTRL_AND_ALT 1056#ifdef FAKE_CTRL_AND_ALT
1056 if ( dele ) delete e; 1057 if ( dele ) delete e;
1057#endif 1058#endif
1058 return true; // stop the event 1059 return true; // stop the event
1059 } 1060 }
1060 if ( e->type() == QEvent::Enter ) { 1061 if ( e->type() == QEvent::Enter ) {
1061 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1062 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1062 this, SLOT(onClearSelection()) ); 1063 this, SLOT(onClearSelection()) );
1063 } 1064 }
1064 if ( e->type() == QEvent::Leave ) { 1065 if ( e->type() == QEvent::Leave ) {
1065 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1066 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1066 this, SLOT(onClearSelection()) ); 1067 this, SLOT(onClearSelection()) );
1067 } 1068 }
1068 return QFrame::eventFilter( obj, e ); 1069 return QFrame::eventFilter( obj, e );
1069} 1070}
1070 1071
1071/* ------------------------------------------------------------------------- */ 1072/* ------------------------------------------------------------------------- */
1072/* */ 1073/* */
1073/* Frame */ 1074/* Frame */
1074/* */ 1075/* */
1075/* ------------------------------------------------------------------------- */ 1076/* ------------------------------------------------------------------------- */
1076 1077
1077void Widget::frameChanged() 1078void Widget::frameChanged()
1078{ 1079{
1079 propagateSize(); 1080 propagateSize();
1080 update(); 1081 update();
1081} 1082}
1082 1083
1083/* ------------------------------------------------------------------------- */ 1084/* ------------------------------------------------------------------------- */
1084/* */ 1085/* */
1085/* Sound */ 1086/* Sound */
1086/* */ 1087/* */
1087/* ------------------------------------------------------------------------- */ 1088/* ------------------------------------------------------------------------- */
1088 1089
1089void Widget::Bell() 1090void Widget::Bell()
1090{ 1091{
1091 QApplication::beep(); 1092 QApplication::beep();
1092} 1093}
1093 1094
1094/* ------------------------------------------------------------------------- */ 1095/* ------------------------------------------------------------------------- */
1095/* */ 1096/* */
1096/* Auxiluary */ 1097/* Auxiluary */
1097/* */ 1098/* */
1098/* ------------------------------------------------------------------------- */ 1099/* ------------------------------------------------------------------------- */
1099 1100
1100void Widget::clearImage() 1101void Widget::clearImage()
1101// initialize the image 1102// initialize the image
1102// for internal use only 1103// for internal use only
1103{ 1104{
1104 for (int y = 0; y < lines; y++) 1105 for (int y = 0; y < lines; y++)
1105 for (int x = 0; x < columns; x++) 1106 for (int x = 0; x < columns; x++)
1106 { 1107 {
1107 image[loc(x,y)].c = 0xff; //' '; 1108 image[loc(x,y)].c = 0xff; //' ';
1108 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; 1109 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
1109 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; 1110 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
1110 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; 1111 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
1111 } 1112 }
1112} 1113}
1113 1114
1114// Create Image /////////////////////////////////////////////////////// 1115// Create Image ///////////////////////////////////////////////////////
1115 1116
1116void Widget::calcGeometry() 1117void Widget::calcGeometry()
1117{ 1118{
1118 //FIXME: set rimX == rimY == 0 when running in full screen mode. 1119 //FIXME: set rimX == rimY == 0 when running in full screen mode.
1119 1120
1120 scrollbar->resize(QApplication::style().scrollBarExtent().width(), 1121 scrollbar->resize(QApplication::style().scrollBarExtent().width(),
1121 contentsRect().height()); 1122 contentsRect().height());
1122 switch(scrollLoc) 1123 switch(scrollLoc)
1123 { 1124 {
1124 case SCRNONE : 1125 case SCRNONE :
1125 columns = ( contentsRect().width() - 2 * rimX ) / font_w; 1126 columns = ( contentsRect().width() - 2 * rimX ) / font_w;
1126 blX = (contentsRect().width() - (columns*font_w) ) / 2; 1127 blX = (contentsRect().width() - (columns*font_w) ) / 2;
1127 brX = blX; 1128 brX = blX;
1128 scrollbar->hide(); 1129 scrollbar->hide();
1129 break; 1130 break;
1130 case SCRLEFT : 1131 case SCRLEFT :
1131 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1132 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1132 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1133 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1133 blX = brX + scrollbar->width(); 1134 blX = brX + scrollbar->width();
1134 scrollbar->move(contentsRect().topLeft()); 1135 scrollbar->move(contentsRect().topLeft());
1135 scrollbar->show(); 1136 scrollbar->show();
1136 break; 1137 break;
1137 case SCRRIGHT: 1138 case SCRRIGHT:
1138 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1139 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1139 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1140 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1140 brX = blX; 1141 brX = blX;
1141 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); 1142 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
1142 scrollbar->show(); 1143 scrollbar->show();
1143 break; 1144 break;
1144 } 1145 }
1145 //FIXME: support 'rounding' styles 1146 //FIXME: support 'rounding' styles
1146 lines = ( contentsRect().height() - 2 * rimY ) / font_h; 1147 lines = ( contentsRect().height() - 2 * rimY ) / font_h;
1147 bY = (contentsRect().height() - (lines *font_h)) / 2; 1148 bY = (contentsRect().height() - (lines *font_h)) / 2;
1148} 1149}
1149 1150
1150void Widget::makeImage() 1151void Widget::makeImage()
1151//FIXME: rename 'calcGeometry? 1152//FIXME: rename 'calcGeometry?
1152{ 1153{
1153 calcGeometry(); 1154 calcGeometry();
1154 image = (Character*) malloc(lines*columns*sizeof(Character)); 1155 image = (Character*) malloc(lines*columns*sizeof(Character));
1155 clearImage(); 1156 clearImage();
1156} 1157}
1157 1158
1158// calculate the needed size 1159// calculate the needed size
1159QSize Widget::calcSize(int cols, int lins) const 1160QSize Widget::calcSize(int cols, int lins) const
1160{ 1161{
1161 int frw = width() - contentsRect().width(); 1162 int frw = width() - contentsRect().width();
1162 int frh = height() - contentsRect().height(); 1163 int frh = height() - contentsRect().height();
1163 int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); 1164 int scw = (scrollLoc==SCRNONE?0:scrollbar->width());
1164 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); 1165 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh );
1165} 1166}
1166 1167
1167QSize Widget::sizeHint() const 1168QSize Widget::sizeHint() const
1168{ 1169{
1169 return size(); 1170 return size();
1170} 1171}
1171 1172
1172void Widget::styleChange(QStyle &) 1173void Widget::styleChange(QStyle &)
1173{ 1174{
1174 propagateSize(); 1175 propagateSize();
1175} 1176}
1176 1177
1177#ifndef QT_NO_DRAGANDDROP 1178#ifndef QT_NO_DRAGANDDROP
1178 1179
1179/* --------------------------------------------------------------------- */ 1180/* --------------------------------------------------------------------- */
1180/* */ 1181/* */
1181/* Drag & Drop */ 1182/* Drag & Drop */
1182/* */ 1183/* */
1183/* --------------------------------------------------------------------- */ 1184/* --------------------------------------------------------------------- */
1184 1185
1185 1186
1186void Widget::dragEnterEvent(QDragEnterEvent* e) 1187void Widget::dragEnterEvent(QDragEnterEvent* e)
1187{ 1188{
1188 e->accept(QTextDrag::canDecode(e) || 1189 e->accept(QTextDrag::canDecode(e) ||
1189 QUriDrag::canDecode(e)); 1190 QUriDrag::canDecode(e));
1190} 1191}
1191 1192
1192void Widget::dropEvent(QDropEvent* event) 1193void Widget::dropEvent(QDropEvent* event)
1193{ 1194{
1194 // The current behaviour when url(s) are dropped is 1195 // The current behaviour when url(s) are dropped is
1195 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd 1196 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd
1196 // * in all other cases, just paste 1197 // * in all other cases, just paste
1197 // (for non-local ones, or for a list of URLs, 'cd' is nonsense) 1198 // (for non-local ones, or for a list of URLs, 'cd' is nonsense)
1198 QStrList strlist; 1199 QStrList strlist;
1199 int file_count = 0; 1200 int file_count = 0;
1200 dropText = ""; 1201 dropText = "";
1201 bool bPopup = true; 1202 bool bPopup = true;
1202 1203
1203 if(QUriDrag::decode(event, strlist)) { 1204 if(QUriDrag::decode(event, strlist)) {
1204 if (strlist.count()) { 1205 if (strlist.count()) {
1205 for(const char* p = strlist.first(); p; p = strlist.next()) { 1206 for(const char* p = strlist.first(); p; p = strlist.next()) {
1206 if(file_count++ > 0) { 1207 if(file_count++ > 0) {
1207 dropText += " "; 1208 dropText += " ";
1208 bPopup = false; // more than one file, don't popup 1209 bPopup = false; // more than one file, don't popup
1209 } 1210 }
1210 1211
1211/* 1212/*
1212 KURL url(p); 1213 KURL url(p);
1213 if (url.isLocalFile()) { 1214 if (url.isLocalFile()) {
1214 dropText += url.path(); // local URL : remove protocol 1215 dropText += url.path(); // local URL : remove protocol
1215 } 1216 }
1216 else { 1217 else {
1217 dropText += url.prettyURL(); 1218 dropText += url.prettyURL();
1218 bPopup = false; // a non-local file, don't popup 1219 bPopup = false; // a non-local file, don't popup
1219 } 1220 }
1220*/ 1221*/
1221 1222
1222 } 1223 }
1223 1224
1224 if (bPopup) 1225 if (bPopup)
1225 // m_drop->popup(pos() + event->pos()); 1226 // m_drop->popup(pos() + event->pos());
1226 m_drop->popup(mapToGlobal(event->pos())); 1227 m_drop->popup(mapToGlobal(event->pos()));
1227 else 1228 else
1228 { 1229 {
1229 if (currentSession) { 1230 if (currentSession) {
1230 //currentSession->getEmulation()->sendString(dropText.local8Bit()); 1231 //currentSession->getEmulation()->sendString(dropText.local8Bit());
1231 QByteArray tmp; 1232 QByteArray tmp;
1232 // ibot: this should be pretty wrong... 1233 // ibot: this should be pretty wrong...
1233 currentSession->layer()->send( tmp.setRawData( dropText.local8Bit())); 1234 // now it sends to the right layer
1235 currentSession-> emulationLayer()->send( tmp.setRawData( dropText.local8Bit()));
1234 } 1236 }
1235 // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1237 // kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1236 } 1238 }
1237 } 1239 }
1238 } 1240 }
1239 else if(QTextDrag::decode(event, dropText)) { 1241 else if(QTextDrag::decode(event, dropText)) {
1240// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1242// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1241 if (currentSession) { 1243 if (currentSession) {
1242 //currentSession->getEmulation()->sendString(dropText.local8Bit()); 1244 //currentSession->getEmulation()->sendString(dropText.local8Bit());
1243 QByteArray tmp; 1245 QByteArray tmp;
1244 currentSession->layer()->send( tmp.setRawData( dropText.local8Bit())); 1246 currentSession->emulationLayer()->send( tmp.setRawData( dropText.local8Bit()));
1245 } 1247 }
1246 // Paste it 1248 // Paste it
1247 } 1249 }
1248} 1250}
1249#endif 1251#endif
1250 1252
1251 1253
1252void Widget::drop_menu_activated(int item) 1254void Widget::drop_menu_activated(int item)
1253{ 1255{
1254#ifndef QT_NO_DRAGANDDROP 1256#ifndef QT_NO_DRAGANDDROP
1255 QByteArray tmp; 1257 QByteArray tmp;
1256 switch (item) 1258 switch (item)
1257 { 1259 {
1258 case 0: // paste 1260 case 0: // paste
1259 //currentSession->getEmulation()->sendString(dropText.local8Bit()); 1261 //currentSession->getEmulation()->sendString(dropText.local8Bit());
1260 currentSession->layer()->send( tmp.setRawData( dropText.local8Bit())); 1262 currentSession->emulationLayer()->send( tmp.setRawData( dropText.local8Bit()));
1261 1263
1262// KWM::activate((Window)this->winId()); 1264// KWM::activate((Window)this->winId());
1263 break; 1265 break;
1264 case 1: // cd ... 1266 case 1: // cd ...
1265 //currentSession->getEmulation()->sendString("cd "); 1267 //currentSession->getEmulation()->sendString("cd ");
1266 tmp.setRawData( "cd " ); 1268 tmp.setRawData( "cd " );
1267 currentSession->layer()->send( tmp ); 1269 currentSession->emulationLayer()->send( tmp );
1268 struct stat statbuf; 1270 struct stat statbuf;
1269 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) 1271 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 )
1270 { 1272 {
1271 if ( !S_ISDIR(statbuf.st_mode) ) 1273 if ( !S_ISDIR(statbuf.st_mode) )
1272 { 1274 {
1273/* 1275/*
1274 KURL url; 1276 KURL url;
1275 url.setPath( dropText ); 1277 url.setPath( dropText );
1276 dropText = url.directory( true, false ); // remove filename 1278 dropText = url.directory( true, false ); // remove filename
1277*/ 1279*/
1278 } 1280 }
1279 } 1281 }
1280 dropText.replace(QRegExp(" "), "\\ "); // escape spaces 1282 dropText.replace(QRegExp(" "), "\\ "); // escape spaces
1281 QByteArray tmp2; 1283 QByteArray tmp2;
1282 tmp.setRawDate( dropText.local8Bit() + "\n" ); 1284 tmp.setRawDate( dropText.local8Bit() + "\n" );
1283 //currentSession->getEmulation()->sendString(dropText.local8Bit()); 1285 //currentSession->getEmulation()->sendString(dropText.local8Bit());
1284 //currentSession->getEmulation()->sendString("\n"); 1286 //currentSession->getEmulation()->sendString("\n");
1285 currentSession->layer()->send( tmp ); 1287 currentSession->emulationLayer()->send( tmp );
1286// KWM::activate((Window)this->winId()); 1288// KWM::activate((Window)this->winId());
1287 break; 1289 break;
1288 } 1290 }
1289#endif 1291#endif
1290} 1292}
1291 1293
diff --git a/noncore/apps/opie-console/widget_layer.h b/noncore/apps/opie-console/widget_layer.h
index 5bd2ef9..01a4614 100644
--- a/noncore/apps/opie-console/widget_layer.h
+++ b/noncore/apps/opie-console/widget_layer.h
@@ -1,254 +1,255 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [widget_layer.h] Widget Layer */ 3/* [widget_layer.h] Widget Layer */
4/* */ 4/* */
5/* -------------------------------------------------------------------------- */ 5/* -------------------------------------------------------------------------- */
6 6
7// proposal of a widget Layer in opie-console 7// proposal of a widget Layer in opie-console
8// 8//
9// fellow devels: 9// fellow devels:
10// just mail me (ibotty@web.de), what you additionally need from the main widget 10// just mail me (ibotty@web.de), what you additionally need from the main widget
11// (or say in chat) 11// (or say in chat)
12 12
13#ifndef WIDGET_LAYER_H 13#ifndef WIDGET_LAYER_H
14#define WIDGET_LAYER_H 14#define WIDGET_LAYER_H
15 15
16// qt includes 16// qt includes
17#include <qapplication.h> 17#include <qapplication.h>
18#include <qframe.h> 18#include <qframe.h>
19#include <qarray.h> 19#include <qarray.h>
20#include <qtimer.h> 20#include <qtimer.h>
21#include <qkeycode.h> 21#include <qkeycode.h>
22#include <qclipboard.h> 22#include <qclipboard.h>
23 23
24 24
25// opie-console includes 25// opie-console includes
26#include "session.h" 26#include "session.h"
27#include "common.h" 27#include "common.h"
28#include "profile.h" 28#include "profile.h"
29/* 29/*
30 * given a pseudo location ( column, line ), 30 * given a pseudo location ( column, line ),
31 * returns the actual index, in the QArray<Character> 31 * returns the actual index, in the QArray<Character>
32 */ 32 */
33#define loc(X,Y) ((Y)*m_columns+(X)) 33#define loc(X,Y) ((Y)*m_columns+(X))
34 34
35 35
36 36
37 37
38class WidgetLayer : public QFrame 38class WidgetLayer : public QFrame
39{ Q_OBJECT 39{ Q_OBJECT
40 40
41public: 41public:
42 42
43 /** 43 /**
44 * constructor 44 * constructor
45 * @param const Profile &config, the configuration for this widget 45 * @param const Profile &config, the configuration for this widget
46 * @param QWidget *parent, the parent widget 46 * @param QWidget *parent, the parent widget
47 * @param const char *name, the name of the widget, defaults to "" 47 * @param const char *name, the name of the widget, defaults to ""
48 */ 48 */
49 WidgetLayer( const Profile& config, QWidget *parent=0, const char *name=0 ); 49 WidgetLayer( const Profile& config, QWidget *parent=0, const char *name=0 );
50 50
51 /** 51 /**
52 * destructor 52 * destructor
53 */ 53 */
54 virtual ~WidgetLayer(); 54 virtual ~WidgetLayer();
55 55
56public: 56public:
57 /** 57 /**
58 * sets the image 58 * sets the image
59 * @param QArray<Character> const newimg, the new image 59 * @param QArray<Character> const newimg, the new image
60 * @param int lines, lines count of newimg 60 * @param int lines, lines count of newimg
61 * @param int columns, columns count of newimg 61 * @param int columns, columns count of newimg
62 */ 62 */
63 virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0; 63 virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0;
64 64
65 /** 65 /**
66 * annoy the user 66 * annoy the user
67 */ 67 */
68 void bell(); 68 void bell();
69 69
70 /** 70 /**
71 * @return int m_lines, the lines count 71 * @return int m_lines, the lines count
72 */ 72 */
73 int lines(){ return m_lines; } 73 int lines(){ return m_lines; }
74 74
75 /** 75 /**
76 * @return int m_columns, the columns count 76 * @return int m_columns, the columns count
77 */ 77 */
78 int columns(){ return m_columns; } 78 int columns(){ return m_columns; }
79 79
80 /** 80 /**
81 * insert current selection (currently this is only the clipboard) 81 * insert current selection (currently this is only the clipboard)
82 */ 82 */
83 void insertSelection(); 83 void insertSelection();
84 84
85 /** 85 /**
86 * insert text 86 * insert text
87 * @param QString text, the text to be inserted 87 * @param QString text, the text to be inserted
88 */ 88 */
89 void insertText( QString text ); 89 void insertText( QString text );
90 90
91 /** 91 /**
92 * set selection (clipboard) to text 92 * set selection (clipboard) to text
93 * @param const QString &text, the text to be selected 93 * @param const QString &text, the text to be selected
94 */ 94 */
95 void setSelection( const QString &text ); 95 void setSelection( const QString &text );
96 96
97 /** 97 /**
98 * paste content of clipboard 98 * paste content of clipboard
99 */ 99 */
100 void pasteClipboard(); 100 void pasteClipboard();
101 101
102 102
103 /** 103 /**
104 * reload configuration 104 * reload configuration
105 * @param const Profile& config, the config to be used (may be the same as in constructor)
105 */ 106 */
106 virtual void reloadConfig() = 0; 107 virtual void reloadConfig( const Profile& config ) = 0;
107 108
108 109
109 /** 110 /**
110 * sets the scrollbar (if implemented by successor of this class) 111 * sets the scrollbar (if implemented by successor of this class)
111 */ 112 */
112 virtual void setScroll( int cursor, int slines ); 113 virtual void setScroll( int cursor, int slines );
113 114
114 /** 115 /**
115 * scrolls (if implemented, by successor of this class) 116 * scrolls (if implemented, by successor of this class)
116 * @param int value, how much the widget should scroll up (positive value) or down (negative value) 117 * @param int value, how much the widget should scroll up (positive value) or down (negative value)
117 */ 118 */
118 virtual void scroll( int value ); 119 virtual void scroll( int value );
119 120
120signals: 121signals:
121 122
122 /** 123 /**
123 * key was pressed 124 * key was pressed
124 */ 125 */
125 void keyPressed( QKeyEvent *e ); 126 void keyPressed( QKeyEvent *e );
126 127
127 /** 128 /**
128 * whenever Mouse selects something 129 * whenever Mouse selects something
129 * @param int button, the button that us pressed : 130 * @param int button, the button that us pressed :
130 * 0left Button 131 * 0left Button
131 * 3Button released 132 * 3Button released
132 * @param int x, x position 133 * @param int x, x position
133 * @param int y, y position 134 * @param int y, y position
134 * 135 *
135 * // numbering due to layout in old TEWidget 136 * // numbering due to layout in old TEWidget
136 */ 137 */
137 void mousePressed( int button, int x, int y ); 138 void mousePressed( int button, int x, int y );
138 139
139 /** 140 /**
140 * size of image changed 141 * size of image changed
141 * @param int lines, line count of new size 142 * @param int lines, line count of new size
142 * @param int columns, column count of new size 143 * @param int columns, column count of new size
143 */ 144 */
144 void imageSizeChanged( int lines, int columns ); 145 void imageSizeChanged( int lines, int columns );
145 146
146 /** 147 /**
147 * cursor in history changed 148 * cursor in history changed
148 * @param int value, value of history cursor 149 * @param int value, value of history cursor
149 */ 150 */
150 void historyCursorChanged( int value ); 151 void historyCursorChanged( int value );
151 152
152 /** 153 /**
153 * selection should be cleared 154 * selection should be cleared
154 */ 155 */
155 void selectionCleared(); 156 void selectionCleared();
156 157
157 /** 158 /**
158 * selection begin 159 * selection begin
159 * @param const int x, x position 160 * @param const int x, x position
160 * @param const int y, y position 161 * @param const int y, y position
161 */ 162 */
162 void selectionBegin( const int x, const int y ); 163 void selectionBegin( const int x, const int y );
163 164
164 /** 165 /**
165 * selection extended 166 * selection extended
166 * (from begin (s.a.) to x, y) 167 * (from begin (s.a.) to x, y)
167 * @param const int x, x position 168 * @param const int x, x position
168 * @param const int y, y position 169 * @param const int y, y position
169 */ 170 */
170 void selectionExtended( const int x, const int y ); 171 void selectionExtended( const int x, const int y );
171 172
172 /** 173 /**
173 * selection end 174 * selection end
174 * @param const bool lineBreakPreserve, preserve line breaks in selection 175 * @param const bool lineBreakPreserve, preserve line breaks in selection
175 */ 176 */
176 void selectionEnd( const bool lineBreakPreserve ); 177 void selectionEnd( const bool lineBreakPreserve );
177 178
178 179
179 180
180// protected methods 181// protected methods
181protected: 182protected:
182 183
183 // image operations 184 // image operations
184 185
185 /** 186 /**
186 * changes image, to suit new size 187 * changes image, to suit new size
187 * TODO: find meaningful name! 188 * TODO: find meaningful name!
188 */ 189 */
189 void propagateSize(); 190 void propagateSize();
190 191
191 /** 192 /**
192 *determines count of lines and columns 193 *determines count of lines and columns
193 */ 194 */
194 virtual void calcGeometry() = 0; 195 virtual void calcGeometry() = 0;
195 196
196 /** 197 /**
197 * makes an empty image 198 * makes an empty image
198 */ 199 */
199 void makeImage(); 200 void makeImage();
200 201
201 /** 202 /**
202 * clears the image 203 * clears the image
203 */ 204 */
204 void clearImage(); 205 void clearImage();
205 206
206protected slots: 207protected slots:
207 208
208 /** 209 /**
209 * clear selection 210 * clear selection
210 */ 211 */
211 void onClearSelection(); 212 void onClearSelection();
212 213
213 214
214// protected vars 215// protected vars
215protected: 216protected:
216 217
217 /** 218 /**
218 * current Session 219 * current Session
219 */ 220 */
220 Session *m_session; 221 Session *m_session;
221 222
222 /** 223 /**
223 * current character image 224 * current character image
224 * 225 *
225 * a Character at loc( column, line ) 226 * a Character at loc( column, line )
226 * has the actual index: 227 * has the actual index:
227 * ix = line * m_columns + column; 228 * ix = line * m_columns + column;
228 * 229 *
229 * use loc( x, y ) macro to access. 230 * use loc( x, y ) macro to access.
230 */ 231 */
231 QArray<Character> m_image; 232 QArray<Character> m_image;
232 233
233 /** 234 /**
234 * lines count 235 * lines count
235 */ 236 */
236 int m_lines; 237 int m_lines;
237 238
238 /** 239 /**
239 * columns count 240 * columns count
240 */ 241 */
241 int m_columns; 242 int m_columns;
242 243
243 /** 244 /**
244 * clipboard 245 * clipboard
245 */ 246 */
246 QClipboard* m_clipboard; 247 QClipboard* m_clipboard;
247 248
248 /** 249 /**
249 * whether widget is resizing 250 * whether widget is resizing
250 */ 251 */
251 bool m_resizing; 252 bool m_resizing;
252}; 253};
253 254
254#endif // WIDGET_LAYER_H 255#endif // WIDGET_LAYER_H