summaryrefslogtreecommitdiff
path: root/core/apps/embeddedkonsole/TEWidget.cpp
Unidiff
Diffstat (limited to 'core/apps/embeddedkonsole/TEWidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TEWidget.cpp98
1 files changed, 51 insertions, 47 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp
index dc83998..f10bfb2 100644
--- a/core/apps/embeddedkonsole/TEWidget.cpp
+++ b/core/apps/embeddedkonsole/TEWidget.cpp
@@ -6,19 +6,18 @@
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
19/*! \class TEWidget 18/*! \class TEWidget
20 19
21 \brief Visible screen contents 20 \brief Visible screen contents
22 21
23 This class is responsible to map the `image' of a terminal emulation to the 22 This class is responsible to map the `image' of a terminal emulation to the
24 display. All the dependency of the emulation to a specific GUI or toolkit is 23 display. All the dependency of the emulation to a specific GUI or toolkit is
@@ -112,13 +111,13 @@ static const ColorEntry base_color_table[TABLE_COLORS] =
112 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta 111 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
113 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White 112 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
114 // intensiv 113 // intensiv
115 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), 114 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
116 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), 115 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
117 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), 116 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
118 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0xFF), 0, 0 ), 117 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
119 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) 118 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
120}; 119};
121 120
122/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) 121/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb)
123 122
124 Code 0 1 2 3 4 5 6 7 123 Code 0 1 2 3 4 5 6 7
@@ -134,12 +133,18 @@ QColor TEWidget::getDefaultBackColor()
134 133
135const ColorEntry* TEWidget::getColorTable() const 134const ColorEntry* TEWidget::getColorTable() const
136{ 135{
137 return color_table; 136 return color_table;
138} 137}
139 138
139const ColorEntry* TEWidget::getdefaultColorTable() const
140{
141 return base_color_table;
142}
143
144
140const QPixmap *TEWidget::backgroundPixmap() 145const QPixmap *TEWidget::backgroundPixmap()
141{ 146{
142 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); 147 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm");
143 const QPixmap *pm = bg; 148 const QPixmap *pm = bg;
144 return pm; 149 return pm;
145} 150}
@@ -237,28 +242,27 @@ void TEWidget::fontChange(const QFont &)
237//printf("font_w: %d\n",font_w); 242//printf("font_w: %d\n",font_w);
238//printf("font_a: %d\n",font_a); 243//printf("font_a: %d\n",font_a);
239//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); 244//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii());
240//printf("rawname: %s\n",font().rawName().ascii()); 245//printf("rawname: %s\n",font().rawName().ascii());
241 fontMap = 246 fontMap =
242#if QT_VERSION < 300 247#if QT_VERSION < 300
243 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") 248 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646")
244 ? vt100extended 249 ? vt100extended
245 : 250 :
246#endif 251#endif
247 identicalMap; 252 identicalMap;
248 propagateSize(); 253 propagateSize();
249 update(); 254 update();
250} 255}
251 256
252void TEWidget::setVTFont(const QFont& f) 257void TEWidget::setVTFont(const QFont& f)
253{ 258{
254 QFrame::setFont(f); 259 QFrame::setFont(f);
255} 260}
256 261
257QFont TEWidget::getVTFont() 262QFont TEWidget::getVTFont() {
258{
259 return font(); 263 return font();
260} 264}
261 265
262void TEWidget::setFont(const QFont &) 266void TEWidget::setFont(const QFont &)
263{ 267{
264 // ignore font change request if not coming from konsole itself 268 // ignore font change request if not coming from konsole itself
@@ -644,13 +648,13 @@ void TEWidget::mousePressEvent(QMouseEvent* ev)
644 648
645 if (mouse_marks || (ev->state() & ShiftButton)) 649 if (mouse_marks || (ev->state() & ShiftButton))
646 { 650 {
647 emit clearSelectionSignal(); 651 emit clearSelectionSignal();
648 iPntSel = pntSel = pos; 652 iPntSel = pntSel = pos;
649 actSel = 1; // left mouse button pressed but nothing selected yet. 653 actSel = 1; // left mouse button pressed but nothing selected yet.
650 grabMouse( /*crossCursor*/ ); // handle with care! 654 grabMouse( /*crossCursor*/ ); // handle with care!
651 } 655 }
652 else 656 else
653 { 657 {
654 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button 658 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button
655 } 659 }
656 } 660 }
@@ -710,15 +714,15 @@ void TEWidget::mouseMoveEvent(QMouseEvent* ev)
710 { 714 {
711 // Extend to word boundaries 715 // Extend to word boundaries
712 int i; 716 int i;
713 int selClass; 717 int selClass;
714 718
715 bool left_not_right = ( here.y() < iPntSel.y() || 719 bool left_not_right = ( here.y() < iPntSel.y() ||
716 here.y() == iPntSel.y() && here.x() < iPntSel.x() ); 720 here.y() == iPntSel.y() && here.x() < iPntSel.x() );
717 bool old_left_not_right = ( pntSel.y() < iPntSel.y() || 721 bool old_left_not_right = ( pntSel.y() < iPntSel.y() ||
718 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); 722 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() );
719 swapping = left_not_right != old_left_not_right; 723 swapping = left_not_right != old_left_not_right;
720 724
721 // Find left (left_not_right ? from here : from start) 725 // Find left (left_not_right ? from here : from start)
722 QPoint left = left_not_right ? here : iPntSel; 726 QPoint left = left_not_right ? here : iPntSel;
723 i = loc(left.x(),left.y()); 727 i = loc(left.x(),left.y());
724 selClass = charClass(image[i].c); 728 selClass = charClass(image[i].c);
@@ -972,40 +976,40 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e )
972#ifdef FAKE_CTRL_AND_ALT 976#ifdef FAKE_CTRL_AND_ALT
973 static bool control = FALSE; 977 static bool control = FALSE;
974 static bool alt = FALSE; 978 static bool alt = FALSE;
975 // Has a keyboard with no CTRL and ALT keys, but we fake it: 979 // Has a keyboard with no CTRL and ALT keys, but we fake it:
976 bool dele=FALSE; 980 bool dele=FALSE;
977 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 981 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
978 QKeyEvent* ke = (QKeyEvent*)e; 982 QKeyEvent* ke = (QKeyEvent*)e;
979 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 983 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
980 switch (ke->key()) { 984 switch (ke->key()) {
981 case Key_F9: // let this be "Control" 985 case Key_F9: // let this be "Control"
982 control = keydown; 986 control = keydown;
983 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 987 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
984 dele=TRUE; 988 dele=TRUE;
985 break; 989 break;
986 case Key_F13: // let this be "Alt" 990 case Key_F13: // let this be "Alt"
987 alt = keydown; 991 alt = keydown;
988 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 992 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
989 dele=TRUE; 993 dele=TRUE;
990 break; 994 break;
991 default: 995 default:
992 if ( control ) { 996 if ( control ) {
993 int a = toupper(ke->ascii())-64; 997 int a = toupper(ke->ascii())-64;
994 if ( a >= 0 && a < ' ' ) { 998 if ( a >= 0 && a < ' ' ) {
995 e = new QKeyEvent(e->type(), ke->key(), 999 e = new QKeyEvent(e->type(), ke->key(),
996 a, ke->state()|ControlButton, QChar(a,0)); 1000 a, ke->state()|ControlButton, QChar(a,0));
997 dele=TRUE; 1001 dele=TRUE;
998 } 1002 }
999 } 1003 }
1000 if ( alt ) { 1004 if ( alt ) {
1001 e = new QKeyEvent(e->type(), ke->key(), 1005 e = new QKeyEvent(e->type(), ke->key(),
1002 ke->ascii(), ke->state()|AltButton, ke->text()); 1006 ke->ascii(), ke->state()|AltButton, ke->text());
1003 dele=TRUE; 1007 dele=TRUE;
1004 } 1008 }
1005 } 1009 }
1006 } 1010 }
1007#endif 1011#endif
1008 1012
1009 if ( e->type() == QEvent::KeyPress ) 1013 if ( e->type() == QEvent::KeyPress )
1010 { 1014 {
1011 QKeyEvent* ke = (QKeyEvent*)e; 1015 QKeyEvent* ke = (QKeyEvent*)e;
@@ -1185,20 +1189,20 @@ void TEWidget::dropEvent(QDropEvent* event)
1185*/ 1189*/
1186 1190
1187 } 1191 }
1188 1192
1189 if (bPopup) 1193 if (bPopup)
1190 // m_drop->popup(pos() + event->pos()); 1194 // m_drop->popup(pos() + event->pos());
1191 m_drop->popup(mapToGlobal(event->pos())); 1195 m_drop->popup(mapToGlobal(event->pos()));
1192 else 1196 else
1193 { 1197 {
1194 if (currentSession) { 1198 if (currentSession) {
1195 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1199 currentSession->getEmulation()->sendString(dropText.local8Bit());
1196 } 1200 }
1197 // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1201// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1198 } 1202 }
1199 } 1203 }
1200 } 1204 }
1201 else if(QTextDrag::decode(event, dropText)) { 1205 else if(QTextDrag::decode(event, dropText)) {
1202// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1206// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1203 if (currentSession) { 1207 if (currentSession) {
1204 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1208 currentSession->getEmulation()->sendString(dropText.local8Bit());