summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TECommon.h6
-rw-r--r--core/apps/embeddedkonsole/TEWidget.cpp98
-rw-r--r--core/apps/embeddedkonsole/TEWidget.h8
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp430
-rw-r--r--core/apps/embeddedkonsole/konsole.h22
5 files changed, 412 insertions, 152 deletions
diff --git a/core/apps/embeddedkonsole/TECommon.h b/core/apps/embeddedkonsole/TECommon.h
index 261d51b..5db41ad 100644
--- a/core/apps/embeddedkonsole/TECommon.h
+++ b/core/apps/embeddedkonsole/TECommon.h
@@ -1,114 +1,114 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [TECommon.h] Common Definitions */ 3/* [TECommon.h] Common Definitions */
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/*! \file TECommon.h 19/*! \file TECommon.h
20 \brief Definitions shared between TEScreen and TEWidget. 20 \brief Definitions shared between TEScreen and TEWidget.
21*/ 21*/
22 22
23#ifndef TECOMMON_H 23#ifndef TECOMMON_H
24#define TECOMMON_H 24#define TECOMMON_H
25 25
26#include <qcolor.h> 26#include <qcolor.h>
27 27
28#ifndef BOOL 28#ifndef BOOL
29typedef int BOOL; 29typedef int BOOL;
30#endif 30#endif
31 31
32#ifndef FALSE 32#ifndef FALSE
33#define FALSE 0 33#define FALSE 0
34#endif 34#endif
35 35
36#ifndef TRUE 36#ifndef TRUE
37#define TRUE 1 37#define TRUE 1
38#endif 38#endif
39 39
40#ifndef UINT8 40#ifndef UINT8
41typedef unsigned char UINT8; 41typedef unsigned char UINT8;
42#endif 42#endif
43 43
44#ifndef UINT16 44#ifndef UINT16
45typedef unsigned short UINT16; 45typedef unsigned short UINT16;
46#endif 46#endif
47 47
48// Attributed Character Representations /////////////////////////////// 48// Attributed Character Representations ///////////////////////////////
49 49
50// Colors 50// Colors
51 51
52#define BASE_COLORS (2+8) 52#define BASE_COLORS (2+8)
53#define INTENSITIES 2 53#define INTENSITIES 2
54#define TABLE_COLORS (INTENSITIES*BASE_COLORS) 54#define TABLE_COLORS (INTENSITIES*BASE_COLORS)
55 55
56#define DEFAULT_FORE_COLOR 0 56#define DEFAULT_FORE_COLOR 0
57#define DEFAULT_BACK_COLOR 1 57#define DEFAULT_BACK_COLOR 1
58 58
59#define DEFAULT_RENDITION 0 59#define DEFAULT_RENDITION 0
60#define RE_BOLD (1 << 0) 60#define RE_BOLD (1 << 0)
61#define RE_BLINK (1 << 1) 61#define RE_BLINK (1 << 1)
62#define RE_UNDERLINE (1 << 2) 62#define RE_UNDERLINE (1 << 2)
63#define RE_REVERSE (1 << 3) // Screen only 63#define RE_REVERSE (1 << 3) // Screen only
64#define RE_INTENSIVE (1 << 3) // Widget only 64#define RE_INTENSIVE (1 << 3) // Widget only
65 65
66/*! \class ca 66/*! \class ca
67 * \brief a character with rendition attributes. 67 * \brief a character with rendition attributes.
68*/ 68*/
69 69
70class ca 70class ca
71{ 71{
72public: 72public:
73 inline ca(UINT16 _c = ' ', 73 inline ca(UINT16 _c = ' ',
74 UINT8 _f = DEFAULT_FORE_COLOR, 74 UINT8 _f = DEFAULT_FORE_COLOR,
75 UINT8 _b = DEFAULT_BACK_COLOR, 75 UINT8 _b = DEFAULT_BACK_COLOR,
76 UINT8 _r = DEFAULT_RENDITION) 76 UINT8 _r = DEFAULT_RENDITION)
77 : c(_c), f(_f), b(_b), r(_r) {} 77 : c(_c), f(_f), b(_b), r(_r) {}
78public: 78public:
79 UINT16 c; // character 79 UINT16 c; // character
80 UINT8 f; // foreground color 80 UINT8 f; // foreground color
81 UINT8 b; // background color 81 UINT8 b; // background color
82 UINT8 r; // rendition 82 UINT8 r; // rendition
83public: 83public:
84 friend BOOL operator == (ca a, ca b); 84 friend BOOL operator == (ca a, ca b);
85 friend BOOL operator != (ca a, ca b); 85 friend BOOL operator != (ca a, ca b);
86}; 86};
87 87
88inline BOOL operator == (ca a, ca b) 88inline BOOL operator == (ca a, ca b)
89{ 89{
90 return a.c == b.c && a.f == b.f && a.b == b.b && a.r == b.r; 90 return a.c == b.c && a.f == b.f && a.b == b.b && a.r == b.r;
91} 91}
92 92
93inline BOOL operator != (ca a, ca b) 93inline BOOL operator != (ca a, ca b)
94{ 94{
95 return a.c != b.c || a.f != b.f || a.b != b.b || a.r != b.r; 95 return a.c != b.c || a.f != b.f || a.b != b.b || a.r != b.r;
96} 96}
97 97
98/*! 98/*!
99*/ 99*/
100struct ColorEntry 100struct ColorEntry
101{ 101{
102 ColorEntry(QColor c, bool tr, bool b) : color(c), transparent(tr), bold(b) {} 102 ColorEntry(QColor c, bool tr, bool b) : color(c), transparent(tr), bold(b) {}
103 ColorEntry() : transparent(false), bold(false) {} // default constructors 103 ColorEntry() : transparent(false), bold(false) {} // default constructors
104 void operator=(const ColorEntry& rhs) { 104 void operator=(const ColorEntry& rhs) {
105 color = rhs.color; 105 color = rhs.color;
106 transparent = rhs.transparent; 106 transparent = rhs.transparent;
107 bold = rhs.bold; 107 bold = rhs.bold;
108 } 108 }
109 QColor color; 109 QColor color;
110 bool transparent; // if used on bg 110 bool transparent; // if used on bg
111 bool bold; // if used on fg 111 bool bold; // if used on fg
112}; 112};
113 113
114#endif // TECOMMON_H 114#endif // TECOMMON_H
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
@@ -1,450 +1,454 @@
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
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
25 localized here. Further, this widget has no knowledge about being part of an 24 localized here. Further, this widget has no knowledge about being part of an
26 emulation, it simply work within the terminal emulation framework by exposing 25 emulation, it simply work within the terminal emulation framework by exposing
27 size and key events and by being ordered to show a new image. 26 size and key events and by being ordered to show a new image.
28 27
29 <ul> 28 <ul>
30 <li> The internal image has the size of the widget (evtl. rounded up) 29 <li> The internal image has the size of the widget (evtl. rounded up)
31 <li> The external image used in setImage can have any size. 30 <li> The external image used in setImage can have any size.
32 <li> (internally) the external image is simply copied to the internal 31 <li> (internally) the external image is simply copied to the internal
33 when a setImage happens. During a resizeEvent no painting is done 32 when a setImage happens. During a resizeEvent no painting is done
34 a paintEvent is expected to follow anyway. 33 a paintEvent is expected to follow anyway.
35 </ul> 34 </ul>
36 35
37 \sa TEScreen \sa Emulation 36 \sa TEScreen \sa Emulation
38*/ 37*/
39 38
40/* FIXME: 39/* FIXME:
41 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent 40 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent
42 - 'font_a' not used in mouse events 41 - 'font_a' not used in mouse events
43 - add destructor 42 - add destructor
44*/ 43*/
45 44
46/* TODO 45/* TODO
47 - evtl. be sensitive to `paletteChange' while using default colors. 46 - evtl. be sensitive to `paletteChange' while using default colors.
48 - set different 'rounding' styles? I.e. have a mode to show clipped chars? 47 - set different 'rounding' styles? I.e. have a mode to show clipped chars?
49*/ 48*/
50 49
51// #include "config.h" 50// #include "config.h"
52#include "TEWidget.h" 51#include "TEWidget.h"
53#include "session.h" 52#include "session.h"
54 53
55#include <qcursor.h> 54#include <qcursor.h>
56#include <qregexp.h> 55#include <qregexp.h>
57#include <qpainter.h> 56#include <qpainter.h>
58#include <qclipboard.h> 57#include <qclipboard.h>
59#include <qstyle.h> 58#include <qstyle.h>
60#include <qfile.h> 59#include <qfile.h>
61#include <qdragobject.h> 60#include <qdragobject.h>
62 61
63#include <stdio.h> 62#include <stdio.h>
64#include <stdlib.h> 63#include <stdlib.h>
65#include <unistd.h> 64#include <unistd.h>
66#include <ctype.h> 65#include <ctype.h>
67#include <sys/stat.h> 66#include <sys/stat.h>
68#include <sys/types.h> 67#include <sys/types.h>
69#include <signal.h> 68#include <signal.h>
70 69
71#include <assert.h> 70#include <assert.h>
72 71
73// #include "TEWidget.moc" 72// #include "TEWidget.moc"
74//#include <kapp.h> 73//#include <kapp.h>
75//#include <kcursor.h> 74//#include <kcursor.h>
76//#include <kurl.h> 75//#include <kurl.h>
77//#include <kdebug.h> 76//#include <kdebug.h>
78//#include <klocale.h> 77//#include <klocale.h>
79 78
80#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) 79#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__)
81#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } 80#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); }
82 81
83#define loc(X,Y) ((Y)*columns+(X)) 82#define loc(X,Y) ((Y)*columns+(X))
84 83
85//FIXME: the rim should normally be 1, 0 only when running in full screen mode. 84//FIXME: the rim should normally be 1, 0 only when running in full screen mode.
86#define rimX 0 // left/right rim width 85#define rimX 0 // left/right rim width
87#define rimY 0 // top/bottom rim high 86#define rimY 0 // top/bottom rim high
88 87
89#define SCRWIDTH 16 // width of the scrollbar 88#define SCRWIDTH 16 // width of the scrollbar
90 89
91#define yMouseScroll 1 90#define yMouseScroll 1
92// scroll increment used when dragging selection at top/bottom of window. 91// scroll increment used when dragging selection at top/bottom of window.
93 92
94/* ------------------------------------------------------------------------- */ 93/* ------------------------------------------------------------------------- */
95/* */ 94/* */
96/* Colors */ 95/* Colors */
97/* */ 96/* */
98/* ------------------------------------------------------------------------- */ 97/* ------------------------------------------------------------------------- */
99 98
100//FIXME: the default color table is in session.C now. 99//FIXME: the default color table is in session.C now.
101// We need a way to get rid of this one, here. 100// We need a way to get rid of this one, here.
102static const ColorEntry base_color_table[TABLE_COLORS] = 101static const ColorEntry base_color_table[TABLE_COLORS] =
103// The following are almost IBM standard color codes, with some slight 102// The following are almost IBM standard color codes, with some slight
104// gamma correction for the dim colors to compensate for bright X screens. 103// gamma correction for the dim colors to compensate for bright X screens.
105// It contains the 8 ansiterm/xterm colors in 2 intensities. 104// It contains the 8 ansiterm/xterm colors in 2 intensities.
106{ 105{
107 // Fixme: could add faint colors here, also. 106 // Fixme: could add faint colors here, also.
108 // normal 107 // normal
109 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback 108 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
110 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red 109 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
111 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow 110 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
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
125 ----------- ------- ------- ------- ------- ------- ------- ------- ------- 124 ----------- ------- ------- ------- ------- ------- ------- ------- -------
126 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White 125 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White
127 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White 126 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White
128*/ 127*/
129 128
130QColor TEWidget::getDefaultBackColor() 129QColor TEWidget::getDefaultBackColor()
131{ 130{
132 return color_table[DEFAULT_BACK_COLOR].color; 131 return color_table[DEFAULT_BACK_COLOR].color;
133} 132}
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}
146 151
147void TEWidget::setColorTable(const ColorEntry table[]) 152void TEWidget::setColorTable(const ColorEntry table[])
148{ 153{
149 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; 154 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i];
150 155
151 const QPixmap* pm = backgroundPixmap(); 156 const QPixmap* pm = backgroundPixmap();
152 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); 157 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color);
153 update(); 158 update();
154} 159}
155 160
156//FIXME: add backgroundPixmapChanged. 161//FIXME: add backgroundPixmapChanged.
157 162
158/* ------------------------------------------------------------------------- */ 163/* ------------------------------------------------------------------------- */
159/* */ 164/* */
160/* Font */ 165/* Font */
161/* */ 166/* */
162/* ------------------------------------------------------------------------- */ 167/* ------------------------------------------------------------------------- */
163 168
164/* 169/*
165 The VT100 has 32 special graphical characters. The usual vt100 extended 170 The VT100 has 32 special graphical characters. The usual vt100 extended
166 xterm fonts have these at 0x00..0x1f. 171 xterm fonts have these at 0x00..0x1f.
167 172
168 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals 173 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals
169 come in here as proper unicode characters. 174 come in here as proper unicode characters.
170 175
171 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping 176 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping
172 from unicode to 0x00..0x1f. The remaining translation is then left to the 177 from unicode to 0x00..0x1f. The remaining translation is then left to the
173 QCodec. 178 QCodec.
174*/ 179*/
175 180
176// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. 181// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i.
177 182
178unsigned short vt100_graphics[32] = 183unsigned short vt100_graphics[32] =
179{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 184{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15
180 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 185 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0,
181 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 186 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
182 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 187 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534,
183 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 188 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7
184}; 189};
185 190
186static QChar vt100extended(QChar c) 191static QChar vt100extended(QChar c)
187{ 192{
188 switch (c.unicode()) 193 switch (c.unicode())
189 { 194 {
190 case 0x25c6 : return 1; 195 case 0x25c6 : return 1;
191 case 0x2592 : return 2; 196 case 0x2592 : return 2;
192 case 0x2409 : return 3; 197 case 0x2409 : return 3;
193 case 0x240c : return 4; 198 case 0x240c : return 4;
194 case 0x240d : return 5; 199 case 0x240d : return 5;
195 case 0x240a : return 6; 200 case 0x240a : return 6;
196 case 0x00b0 : return 7; 201 case 0x00b0 : return 7;
197 case 0x00b1 : return 8; 202 case 0x00b1 : return 8;
198 case 0x2424 : return 9; 203 case 0x2424 : return 9;
199 case 0x240b : return 10; 204 case 0x240b : return 10;
200 case 0x2518 : return 11; 205 case 0x2518 : return 11;
201 case 0x2510 : return 12; 206 case 0x2510 : return 12;
202 case 0x250c : return 13; 207 case 0x250c : return 13;
203 case 0x2514 : return 14; 208 case 0x2514 : return 14;
204 case 0x253c : return 15; 209 case 0x253c : return 15;
205 case 0xf800 : return 16; 210 case 0xf800 : return 16;
206 case 0xf801 : return 17; 211 case 0xf801 : return 17;
207 case 0x2500 : return 18; 212 case 0x2500 : return 18;
208 case 0xf803 : return 19; 213 case 0xf803 : return 19;
209 case 0xf804 : return 20; 214 case 0xf804 : return 20;
210 case 0x251c : return 21; 215 case 0x251c : return 21;
211 case 0x2524 : return 22; 216 case 0x2524 : return 22;
212 case 0x2534 : return 23; 217 case 0x2534 : return 23;
213 case 0x252c : return 24; 218 case 0x252c : return 24;
214 case 0x2502 : return 25; 219 case 0x2502 : return 25;
215 case 0x2264 : return 26; 220 case 0x2264 : return 26;
216 case 0x2265 : return 27; 221 case 0x2265 : return 27;
217 case 0x03c0 : return 28; 222 case 0x03c0 : return 28;
218 case 0x2260 : return 29; 223 case 0x2260 : return 29;
219 case 0x00a3 : return 30; 224 case 0x00a3 : return 30;
220 case 0x00b7 : return 31; 225 case 0x00b7 : return 31;
221 } 226 }
222 return c; 227 return c;
223} 228}
224 229
225static QChar identicalMap(QChar c) 230static QChar identicalMap(QChar c)
226{ 231{
227 return c; 232 return c;
228} 233}
229 234
230void TEWidget::fontChange(const QFont &) 235void TEWidget::fontChange(const QFont &)
231{ 236{
232 QFontMetrics fm(font()); 237 QFontMetrics fm(font());
233 font_h = fm.height(); 238 font_h = fm.height();
234 font_w = fm.maxWidth(); 239 font_w = fm.maxWidth();
235 font_a = fm.ascent(); 240 font_a = fm.ascent();
236//printf("font_h: %d\n",font_h); 241//printf("font_h: %d\n",font_h);
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
265} 269}
266 270
267/* ------------------------------------------------------------------------- */ 271/* ------------------------------------------------------------------------- */
268/* */ 272/* */
269/* Constructor / Destructor */ 273/* Constructor / Destructor */
270/* */ 274/* */
271/* ------------------------------------------------------------------------- */ 275/* ------------------------------------------------------------------------- */
272 276
273TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) 277TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
274{ 278{
275#ifndef QT_NO_CLIPBOARD 279#ifndef QT_NO_CLIPBOARD
276 cb = QApplication::clipboard(); 280 cb = QApplication::clipboard();
277 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 281 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
278 this, SLOT(onClearSelection()) ); 282 this, SLOT(onClearSelection()) );
279#endif 283#endif
280 284
281 scrollbar = new QScrollBar(this); 285 scrollbar = new QScrollBar(this);
282 scrollbar->setCursor( arrowCursor ); 286 scrollbar->setCursor( arrowCursor );
283 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 287 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
284 scrollLoc = SCRNONE; 288 scrollLoc = SCRNONE;
285 289
286 blinkT = new QTimer(this); 290 blinkT = new QTimer(this);
287 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); 291 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent()));
288 // blinking = FALSE; 292 // blinking = FALSE;
289 blinking = TRUE; 293 blinking = TRUE;
290 294
291 resizing = FALSE; 295 resizing = FALSE;
292 actSel = 0; 296 actSel = 0;
293 image = 0; 297 image = 0;
294 lines = 1; 298 lines = 1;
295 columns = 1; 299 columns = 1;
296 font_w = 1; 300 font_w = 1;
297 font_h = 1; 301 font_h = 1;
298 font_a = 1; 302 font_a = 1;
299 word_selection_mode = FALSE; 303 word_selection_mode = FALSE;
300 304
301 setMouseMarks(TRUE); 305 setMouseMarks(TRUE);
302 setVTFont( QFont("fixed") ); 306 setVTFont( QFont("fixed") );
303 setColorTable(base_color_table); // init color table 307 setColorTable(base_color_table); // init color table
304 308
305 qApp->installEventFilter( this ); //FIXME: see below 309 qApp->installEventFilter( this ); //FIXME: see below
306// KCursor::setAutoHideCursor( this, true ); 310// KCursor::setAutoHideCursor( this, true );
307 311
308 // Init DnD //////////////////////////////////////////////////////////////// 312 // Init DnD ////////////////////////////////////////////////////////////////
309 currentSession = NULL; 313 currentSession = NULL;
310// setAcceptDrops(true); // attempt 314// setAcceptDrops(true); // attempt
311// m_drop = new QPopupMenu(this); 315// m_drop = new QPopupMenu(this);
312// m_drop->insertItem( QString("Paste"), 0); 316// m_drop->insertItem( QString("Paste"), 0);
313// m_drop->insertItem( QString("cd"), 1); 317// m_drop->insertItem( QString("cd"), 1);
314// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); 318// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int)));
315 319
316 // we need focus so that the auto-hide cursor feature works 320 // we need focus so that the auto-hide cursor feature works
317 setFocus(); 321 setFocus();
318 setFocusPolicy( WheelFocus ); 322 setFocusPolicy( WheelFocus );
319} 323}
320 324
321//FIXME: make proper destructor 325//FIXME: make proper destructor
322// Here's a start (David) 326// Here's a start (David)
323TEWidget::~TEWidget() 327TEWidget::~TEWidget()
324{ 328{
325 qApp->removeEventFilter( this ); 329 qApp->removeEventFilter( this );
326 if (image) free(image); 330 if (image) free(image);
327} 331}
328 332
329/* ------------------------------------------------------------------------- */ 333/* ------------------------------------------------------------------------- */
330/* */ 334/* */
331/* Display Operations */ 335/* Display Operations */
332/* */ 336/* */
333/* ------------------------------------------------------------------------- */ 337/* ------------------------------------------------------------------------- */
334 338
335/*! 339/*!
336 attributed string draw primitive 340 attributed string draw primitive
337*/ 341*/
338 342
339void TEWidget::drawAttrStr(QPainter &paint, QRect rect, 343void TEWidget::drawAttrStr(QPainter &paint, QRect rect,
340 QString& str, ca attr, BOOL pm, BOOL clear) 344 QString& str, ca attr, BOOL pm, BOOL clear)
341{ 345{
342 if (pm && color_table[attr.b].transparent) 346 if (pm && color_table[attr.b].transparent)
343 { 347 {
344 paint.setBackgroundMode( TransparentMode ); 348 paint.setBackgroundMode( TransparentMode );
345 if (clear) erase(rect); 349 if (clear) erase(rect);
346 } 350 }
347 else 351 else
348 { 352 {
349 if (blinking) 353 if (blinking)
350 paint.fillRect(rect, color_table[attr.b].color); 354 paint.fillRect(rect, color_table[attr.b].color);
351 else 355 else
352 { 356 {
353 paint.setBackgroundMode( OpaqueMode ); 357 paint.setBackgroundMode( OpaqueMode );
354 paint.setBackgroundColor( color_table[attr.b].color ); 358 paint.setBackgroundColor( color_table[attr.b].color );
355 } 359 }
356 } 360 }
357 361
358 if (color_table[attr.f].bold) 362 if (color_table[attr.f].bold)
359 paint.setPen(QColor( 0x8F, 0x00, 0x00 )); 363 paint.setPen(QColor( 0x8F, 0x00, 0x00 ));
360 else 364 else
361 paint.setPen(color_table[attr.f].color); 365 paint.setPen(color_table[attr.f].color);
362 366
363 paint.drawText(rect.x(),rect.y()+font_a, str); 367 paint.drawText(rect.x(),rect.y()+font_a, str);
364 368
365 if (attr.r & RE_UNDERLINE) 369 if (attr.r & RE_UNDERLINE)
366 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); 370 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 );
367} 371}
368 372
369/*! 373/*!
370 The image can only be set completely. 374 The image can only be set completely.
371 375
372 The size of the new image may or may not match the size of the widget. 376 The size of the new image may or may not match the size of the widget.
373*/ 377*/
374 378
375void TEWidget::setImage(const ca* const newimg, int lines, int columns) 379void TEWidget::setImage(const ca* const newimg, int lines, int columns)
376{ int y,x,len; 380{ int y,x,len;
377 const QPixmap* pm = backgroundPixmap(); 381 const QPixmap* pm = backgroundPixmap();
378 QPainter paint; 382 QPainter paint;
379 setUpdatesEnabled(FALSE); 383 setUpdatesEnabled(FALSE);
380 paint.begin( this ); 384 paint.begin( this );
381HCNT("setImage"); 385HCNT("setImage");
382 386
383 QPoint tL = contentsRect().topLeft(); 387 QPoint tL = contentsRect().topLeft();
384 int tLx = tL.x(); 388 int tLx = tL.x();
385 int tLy = tL.y(); 389 int tLy = tL.y();
386 hasBlinker = FALSE; 390 hasBlinker = FALSE;
387 391
388 int cf = -1; // undefined 392 int cf = -1; // undefined
389 int cb = -1; // undefined 393 int cb = -1; // undefined
390 int cr = -1; // undefined 394 int cr = -1; // undefined
391 395
392 int lins = QMIN(this->lines, QMAX(0,lines )); 396 int lins = QMIN(this->lines, QMAX(0,lines ));
393 int cols = QMIN(this->columns,QMAX(0,columns)); 397 int cols = QMIN(this->columns,QMAX(0,columns));
394 QChar *disstrU = new QChar[cols]; 398 QChar *disstrU = new QChar[cols];
395 399
396//{ static int cnt = 0; printf("setImage %d\n",cnt++); } 400//{ static int cnt = 0; printf("setImage %d\n",cnt++); }
397 for (y = 0; y < lins; y++) 401 for (y = 0; y < lins; y++)
398 { 402 {
399 const ca* lcl = &image[y*this->columns]; 403 const ca* lcl = &image[y*this->columns];
400 const ca* const ext = &newimg[y*columns]; 404 const ca* const ext = &newimg[y*columns];
401 if (!resizing) // not while resizing, we're expecting a paintEvent 405 if (!resizing) // not while resizing, we're expecting a paintEvent
402 for (x = 0; x < cols; x++) 406 for (x = 0; x < cols; x++)
403 { 407 {
404 hasBlinker |= (ext[x].r & RE_BLINK); 408 hasBlinker |= (ext[x].r & RE_BLINK);
405 if (ext[x] != lcl[x]) 409 if (ext[x] != lcl[x])
406 { 410 {
407 cr = ext[x].r; 411 cr = ext[x].r;
408 cb = ext[x].b; 412 cb = ext[x].b;
409 if (ext[x].f != cf) cf = ext[x].f; 413 if (ext[x].f != cf) cf = ext[x].f;
410 int lln = cols - x; 414 int lln = cols - x;
411 disstrU[0] = fontMap(ext[x+0].c); 415 disstrU[0] = fontMap(ext[x+0].c);
412 for (len = 1; len < lln; len++) 416 for (len = 1; len < lln; len++)
413 { 417 {
414 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || 418 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr ||
415 ext[x+len] == lcl[x+len] ) 419 ext[x+len] == lcl[x+len] )
416 break; 420 break;
417 disstrU[len] = fontMap(ext[x+len].c); 421 disstrU[len] = fontMap(ext[x+len].c);
418 } 422 }
419 QString unistr(disstrU,len); 423 QString unistr(disstrU,len);
420 drawAttrStr(paint, 424 drawAttrStr(paint,
421 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 425 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
422 unistr, ext[x], pm != NULL, true); 426 unistr, ext[x], pm != NULL, true);
423 x += len - 1; 427 x += len - 1;
424 } 428 }
425 } 429 }
426 // finally, make `image' become `newimg'. 430 // finally, make `image' become `newimg'.
427 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); 431 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca));
428 } 432 }
429 drawFrame( &paint ); 433 drawFrame( &paint );
430 paint.end(); 434 paint.end();
431 setUpdatesEnabled(TRUE); 435 setUpdatesEnabled(TRUE);
432 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms 436 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms
433 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } 437 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; }
434 delete [] disstrU; 438 delete [] disstrU;
435} 439}
436 440
437// paint Event //////////////////////////////////////////////////// 441// paint Event ////////////////////////////////////////////////////
438 442
439/*! 443/*!
440 The difference of this routine vs. the `setImage' is, 444 The difference of this routine vs. the `setImage' is,
441 that the drawing does not include a difference analysis 445 that the drawing does not include a difference analysis
442 between the old and the new image. Instead, the internal 446 between the old and the new image. Instead, the internal
443 image is used and the painting bound by the PaintEvent box. 447 image is used and the painting bound by the PaintEvent box.
444*/ 448*/
445 449
446void TEWidget::paintEvent( QPaintEvent* pe ) 450void TEWidget::paintEvent( QPaintEvent* pe )
447{ 451{
448 452
449//{ static int cnt = 0; printf("paint %d\n",cnt++); } 453//{ static int cnt = 0; printf("paint %d\n",cnt++); }
450 const QPixmap* pm = backgroundPixmap(); 454 const QPixmap* pm = backgroundPixmap();
@@ -458,786 +462,786 @@ HCNT("paintEvent");
458 // that the image (the size is truncated towards the smaller 462 // that the image (the size is truncated towards the smaller
459 // number of characters in `resizeEvent'. The paint rectangle 463 // number of characters in `resizeEvent'. The paint rectangle
460 // can thus be larger than the image, but less then the size 464 // can thus be larger than the image, but less then the size
461 // of one character. 465 // of one character.
462 466
463 QRect rect = pe->rect().intersect(contentsRect()); 467 QRect rect = pe->rect().intersect(contentsRect());
464 468
465 QPoint tL = contentsRect().topLeft(); 469 QPoint tL = contentsRect().topLeft();
466 int tLx = tL.x(); 470 int tLx = tL.x();
467 int tLy = tL.y(); 471 int tLy = tL.y();
468 472
469 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); 473 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w));
470 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); 474 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h));
471 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); 475 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w));
472 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); 476 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h));
473 477
474 /* 478 /*
475 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, 479 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly,
476 rect.left(), rect.right(), rect.top(), rect.bottom()); 480 rect.left(), rect.right(), rect.top(), rect.bottom());
477 */ 481 */
478 482
479 // if (pm != NULL && color_table[image->b].transparent) 483 // if (pm != NULL && color_table[image->b].transparent)
480 // erase(rect); 484 // erase(rect);
481 // BL: I have no idea why we need this, and it breaks the refresh. 485 // BL: I have no idea why we need this, and it breaks the refresh.
482 486
483 QChar *disstrU = new QChar[columns]; 487 QChar *disstrU = new QChar[columns];
484 for (int y = luy; y <= rly; y++) 488 for (int y = luy; y <= rly; y++)
485 for (int x = lux; x <= rlx; x++) 489 for (int x = lux; x <= rlx; x++)
486 { 490 {
487 int len = 1; 491 int len = 1;
488 disstrU[0] = fontMap(image[loc(x,y)].c); 492 disstrU[0] = fontMap(image[loc(x,y)].c);
489 int cf = image[loc(x,y)].f; 493 int cf = image[loc(x,y)].f;
490 int cb = image[loc(x,y)].b; 494 int cb = image[loc(x,y)].b;
491 int cr = image[loc(x,y)].r; 495 int cr = image[loc(x,y)].r;
492 while (x+len <= rlx && 496 while (x+len <= rlx &&
493 image[loc(x+len,y)].f == cf && 497 image[loc(x+len,y)].f == cf &&
494 image[loc(x+len,y)].b == cb && 498 image[loc(x+len,y)].b == cb &&
495 image[loc(x+len,y)].r == cr ) 499 image[loc(x+len,y)].r == cr )
496 { 500 {
497 disstrU[len] = fontMap(image[loc(x+len,y)].c); 501 disstrU[len] = fontMap(image[loc(x+len,y)].c);
498 len += 1; 502 len += 1;
499 } 503 }
500 QString unistr(disstrU,len); 504 QString unistr(disstrU,len);
501 drawAttrStr(paint, 505 drawAttrStr(paint,
502 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 506 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
503 unistr, image[loc(x,y)], pm != NULL, false); 507 unistr, image[loc(x,y)], pm != NULL, false);
504 x += len - 1; 508 x += len - 1;
505 } 509 }
506 delete [] disstrU; 510 delete [] disstrU;
507 drawFrame( &paint ); 511 drawFrame( &paint );
508 paint.end(); 512 paint.end();
509 setUpdatesEnabled(TRUE); 513 setUpdatesEnabled(TRUE);
510} 514}
511 515
512void TEWidget::blinkEvent() 516void TEWidget::blinkEvent()
513{ 517{
514 blinking = !blinking; 518 blinking = !blinking;
515 repaint(FALSE); 519 repaint(FALSE);
516} 520}
517 521
518/* ------------------------------------------------------------------------- */ 522/* ------------------------------------------------------------------------- */
519/* */ 523/* */
520/* Resizing */ 524/* Resizing */
521/* */ 525/* */
522/* ------------------------------------------------------------------------- */ 526/* ------------------------------------------------------------------------- */
523 527
524void TEWidget::resizeEvent(QResizeEvent* ev) 528void TEWidget::resizeEvent(QResizeEvent* ev)
525{ 529{
526 //printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); 530 //printf("resize: %d,%d\n",ev->size().width(),ev->size().height());
527 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); 531 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h);
528 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); 532 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h);
529 //printf("curren: %d,%d\n",width(),height()); 533 //printf("curren: %d,%d\n",width(),height());
530HCNT("resizeEvent"); 534HCNT("resizeEvent");
531 535
532 // see comment in `paintEvent' concerning the rounding. 536 // see comment in `paintEvent' concerning the rounding.
533 //FIXME: could make a routine here; check width(),height() 537 //FIXME: could make a routine here; check width(),height()
534 assert(ev->size().width() == width()); 538 assert(ev->size().width() == width());
535 assert(ev->size().height() == height()); 539 assert(ev->size().height() == height());
536 540
537 propagateSize(); 541 propagateSize();
538} 542}
539 543
540void TEWidget::propagateSize() 544void TEWidget::propagateSize()
541{ 545{
542 ca* oldimg = image; 546 ca* oldimg = image;
543 int oldlin = lines; 547 int oldlin = lines;
544 int oldcol = columns; 548 int oldcol = columns;
545 makeImage(); 549 makeImage();
546 // we copy the old image to reduce flicker 550 // we copy the old image to reduce flicker
547 int lins = QMIN(oldlin,lines); 551 int lins = QMIN(oldlin,lines);
548 int cols = QMIN(oldcol,columns); 552 int cols = QMIN(oldcol,columns);
549 if (oldimg) 553 if (oldimg)
550 { 554 {
551 for (int lin = 0; lin < lins; lin++) 555 for (int lin = 0; lin < lins; lin++)
552 memcpy((void*)&image[columns*lin], 556 memcpy((void*)&image[columns*lin],
553 (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); 557 (void*)&oldimg[oldcol*lin],cols*sizeof(ca));
554 free(oldimg); //FIXME: try new,delete 558 free(oldimg); //FIXME: try new,delete
555 } 559 }
556 else 560 else
557 clearImage(); 561 clearImage();
558 562
559 //NOTE: control flows from the back through the chest right into the eye. 563 //NOTE: control flows from the back through the chest right into the eye.
560 // `emu' will call back via `setImage'. 564 // `emu' will call back via `setImage'.
561 565
562 resizing = TRUE; 566 resizing = TRUE;
563 emit changedImageSizeSignal(lines, columns); // expose resizeEvent 567 emit changedImageSizeSignal(lines, columns); // expose resizeEvent
564 resizing = FALSE; 568 resizing = FALSE;
565} 569}
566 570
567/* ------------------------------------------------------------------------- */ 571/* ------------------------------------------------------------------------- */
568/* */ 572/* */
569/* Scrollbar */ 573/* Scrollbar */
570/* */ 574/* */
571/* ------------------------------------------------------------------------- */ 575/* ------------------------------------------------------------------------- */
572 576
573void TEWidget::scrollChanged(int) 577void TEWidget::scrollChanged(int)
574{ 578{
575 emit changedHistoryCursor(scrollbar->value()); //expose 579 emit changedHistoryCursor(scrollbar->value()); //expose
576} 580}
577 581
578void TEWidget::setScroll(int cursor, int slines) 582void TEWidget::setScroll(int cursor, int slines)
579{ 583{
580 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 584 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
581 scrollbar->setRange(0,slines); 585 scrollbar->setRange(0,slines);
582 scrollbar->setSteps(1,lines); 586 scrollbar->setSteps(1,lines);
583 scrollbar->setValue(cursor); 587 scrollbar->setValue(cursor);
584 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 588 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
585} 589}
586 590
587void TEWidget::setScrollbarLocation(int loc) 591void TEWidget::setScrollbarLocation(int loc)
588{ 592{
589 if (scrollLoc == loc) return; // quickly 593 if (scrollLoc == loc) return; // quickly
590 scrollLoc = loc; 594 scrollLoc = loc;
591 propagateSize(); 595 propagateSize();
592 update(); 596 update();
593} 597}
594 598
595/* ------------------------------------------------------------------------- */ 599/* ------------------------------------------------------------------------- */
596/* */ 600/* */
597/* Mouse */ 601/* Mouse */
598/* */ 602/* */
599/* ------------------------------------------------------------------------- */ 603/* ------------------------------------------------------------------------- */
600 604
601/*! 605/*!
602 Three different operations can be performed using the mouse, and the 606 Three different operations can be performed using the mouse, and the
603 routines in this section serve all of them: 607 routines in this section serve all of them:
604 608
605 1) The press/release events are exposed to the application 609 1) The press/release events are exposed to the application
606 2) Marking (press and move left button) and Pasting (press middle button) 610 2) Marking (press and move left button) and Pasting (press middle button)
607 3) The right mouse button is used from the configuration menu 611 3) The right mouse button is used from the configuration menu
608 612
609 NOTE: During the marking process we attempt to keep the cursor within 613 NOTE: During the marking process we attempt to keep the cursor within
610 the bounds of the text as being displayed by setting the mouse position 614 the bounds of the text as being displayed by setting the mouse position
611 whenever the mouse has left the text area. 615 whenever the mouse has left the text area.
612 616
613 Two reasons to do so: 617 Two reasons to do so:
614 1) QT does not allow the `grabMouse' to confine-to the TEWidget. 618 1) QT does not allow the `grabMouse' to confine-to the TEWidget.
615 Thus a `XGrapPointer' would have to be used instead. 619 Thus a `XGrapPointer' would have to be used instead.
616 2) Even if so, this would not help too much, since the text area 620 2) Even if so, this would not help too much, since the text area
617 of the TEWidget is normally not identical with it's bounds. 621 of the TEWidget is normally not identical with it's bounds.
618 622
619 The disadvantage of the current handling is, that the mouse can visibly 623 The disadvantage of the current handling is, that the mouse can visibly
620 leave the bounds of the widget and is then moved back. Because of the 624 leave the bounds of the widget and is then moved back. Because of the
621 current construction, and the reasons mentioned above, we cannot do better 625 current construction, and the reasons mentioned above, we cannot do better
622 without changing the overall construction. 626 without changing the overall construction.
623*/ 627*/
624 628
625/*! 629/*!
626*/ 630*/
627 631
628void TEWidget::mousePressEvent(QMouseEvent* ev) 632void TEWidget::mousePressEvent(QMouseEvent* ev)
629{ 633{
630//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 634//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
631 if ( !contentsRect().contains(ev->pos()) ) return; 635 if ( !contentsRect().contains(ev->pos()) ) return;
632 QPoint tL = contentsRect().topLeft(); 636 QPoint tL = contentsRect().topLeft();
633 int tLx = tL.x(); 637 int tLx = tL.x();
634 int tLy = tL.y(); 638 int tLy = tL.y();
635 639
636 word_selection_mode = FALSE; 640 word_selection_mode = FALSE;
637 641
638//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); 642//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY);
639 if ( ev->button() == LeftButton) 643 if ( ev->button() == LeftButton)
640 { 644 {
641 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 645 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
642 646
643 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; 647 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ;
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 }
657 if ( ev->button() == MidButton ) 661 if ( ev->button() == MidButton )
658 { 662 {
659 emitSelection(); 663 emitSelection();
660 } 664 }
661 if ( ev->button() == RightButton ) // Configure 665 if ( ev->button() == RightButton ) // Configure
662 { 666 {
663 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); 667 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() );
664 } 668 }
665} 669}
666 670
667void TEWidget::mouseMoveEvent(QMouseEvent* ev) 671void TEWidget::mouseMoveEvent(QMouseEvent* ev)
668{ 672{
669 // for auto-hiding the cursor, we need mouseTracking 673 // for auto-hiding the cursor, we need mouseTracking
670 if (ev->state() == NoButton ) return; 674 if (ev->state() == NoButton ) return;
671 675
672 if (actSel == 0) return; 676 if (actSel == 0) return;
673 677
674 // don't extend selection while pasting 678 // don't extend selection while pasting
675 if (ev->state() & MidButton) return; 679 if (ev->state() & MidButton) return;
676 680
677 //if ( !contentsRect().contains(ev->pos()) ) return; 681 //if ( !contentsRect().contains(ev->pos()) ) return;
678 QPoint tL = contentsRect().topLeft(); 682 QPoint tL = contentsRect().topLeft();
679 int tLx = tL.x(); 683 int tLx = tL.x();
680 int tLy = tL.y(); 684 int tLy = tL.y();
681 int scroll = scrollbar->value(); 685 int scroll = scrollbar->value();
682 686
683 // we're in the process of moving the mouse with the left button pressed 687 // we're in the process of moving the mouse with the left button pressed
684 // the mouse cursor will kept catched within the bounds of the text in 688 // the mouse cursor will kept catched within the bounds of the text in
685 // this widget. 689 // this widget.
686 690
687 // Adjust position within text area bounds. See FIXME above. 691 // Adjust position within text area bounds. See FIXME above.
688 QPoint pos = ev->pos(); 692 QPoint pos = ev->pos();
689 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); 693 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX );
690 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); 694 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w );
691 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); 695 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY );
692 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); 696 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 );
693 // check if we produce a mouse move event by this 697 // check if we produce a mouse move event by this
694 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); 698 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos));
695 699
696 if ( pos.y() == tLy+bY+lines*font_h-1 ) 700 if ( pos.y() == tLy+bY+lines*font_h-1 )
697 { 701 {
698 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward 702 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward
699 } 703 }
700 if ( pos.y() == tLy+bY ) 704 if ( pos.y() == tLy+bY )
701 { 705 {
702 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback 706 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback
703 } 707 }
704 708
705 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); 709 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h);
706 QPoint ohere; 710 QPoint ohere;
707 bool swapping = FALSE; 711 bool swapping = FALSE;
708 712
709 if ( word_selection_mode ) 713 if ( word_selection_mode )
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);
725 while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) 729 while ( left.x() > 0 && charClass(image[i-1].c) == selClass )
726 { i--; left.rx()--; } 730 { i--; left.rx()--; }
727 731
728 // Find left (left_not_right ? from start : from here) 732 // Find left (left_not_right ? from start : from here)
729 QPoint right = left_not_right ? iPntSel : here; 733 QPoint right = left_not_right ? iPntSel : here;
730 i = loc(right.x(),right.y()); 734 i = loc(right.x(),right.y());
731 selClass = charClass(image[i].c); 735 selClass = charClass(image[i].c);
732 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) 736 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass )
733 { i++; right.rx()++; } 737 { i++; right.rx()++; }
734 738
735 // Pick which is start (ohere) and which is extension (here) 739 // Pick which is start (ohere) and which is extension (here)
736 if ( left_not_right ) 740 if ( left_not_right )
737 { 741 {
738 here = left; ohere = right; 742 here = left; ohere = right;
739 } 743 }
740 else 744 else
741 { 745 {
742 here = right; ohere = left; 746 here = right; ohere = left;
743 } 747 }
744 } 748 }
745 749
746 if (here == pntSel && scroll == scrollbar->value()) return; // not moved 750 if (here == pntSel && scroll == scrollbar->value()) return; // not moved
747 751
748 if ( word_selection_mode ) { 752 if ( word_selection_mode ) {
749 if ( actSel < 2 || swapping ) { 753 if ( actSel < 2 || swapping ) {
750 emit beginSelectionSignal( ohere.x(), ohere.y() ); 754 emit beginSelectionSignal( ohere.x(), ohere.y() );
751 } 755 }
752 } else if ( actSel < 2 ) { 756 } else if ( actSel < 2 ) {
753 emit beginSelectionSignal( pntSel.x(), pntSel.y() ); 757 emit beginSelectionSignal( pntSel.x(), pntSel.y() );
754 } 758 }
755 759
756 actSel = 2; // within selection 760 actSel = 2; // within selection
757 pntSel = here; 761 pntSel = here;
758 emit extendSelectionSignal( here.x(), here.y() ); 762 emit extendSelectionSignal( here.x(), here.y() );
759} 763}
760 764
761void TEWidget::mouseReleaseEvent(QMouseEvent* ev) 765void TEWidget::mouseReleaseEvent(QMouseEvent* ev)
762{ 766{
763//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 767//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
764 if ( ev->button() == LeftButton) 768 if ( ev->button() == LeftButton)
765 { 769 {
766 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); 770 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks);
767 preserve_line_breaks = TRUE; 771 preserve_line_breaks = TRUE;
768 actSel = 0; 772 actSel = 0;
769 773
770 //FIXME: emits a release event even if the mouse is 774 //FIXME: emits a release event even if the mouse is
771 // outside the range. The procedure used in `mouseMoveEvent' 775 // outside the range. The procedure used in `mouseMoveEvent'
772 // applies here, too. 776 // applies here, too.
773 777
774 QPoint tL = contentsRect().topLeft(); 778 QPoint tL = contentsRect().topLeft();
775 int tLx = tL.x(); 779 int tLx = tL.x();
776 int tLy = tL.y(); 780 int tLy = tL.y();
777 781
778 if (!mouse_marks && !(ev->state() & ShiftButton)) 782 if (!mouse_marks && !(ev->state() & ShiftButton))
779 emit mouseSignal( 3, // release 783 emit mouseSignal( 3, // release
780 (ev->x()-tLx-blX)/font_w + 1, 784 (ev->x()-tLx-blX)/font_w + 1,
781 (ev->y()-tLy-bY)/font_h + 1 ); 785 (ev->y()-tLy-bY)/font_h + 1 );
782 releaseMouse(); 786 releaseMouse();
783 } 787 }
784} 788}
785 789
786void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) 790void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev)
787{ 791{
788 if ( ev->button() != LeftButton) return; 792 if ( ev->button() != LeftButton) return;
789 793
790 QPoint tL = contentsRect().topLeft(); 794 QPoint tL = contentsRect().topLeft();
791 int tLx = tL.x(); 795 int tLx = tL.x();
792 int tLy = tL.y(); 796 int tLy = tL.y();
793 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 797 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
794 798
795 // pass on double click as two clicks. 799 // pass on double click as two clicks.
796 if (!mouse_marks && !(ev->state() & ShiftButton)) 800 if (!mouse_marks && !(ev->state() & ShiftButton))
797 { 801 {
798 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 802 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
799 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release 803 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release
800 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 804 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
801 return; 805 return;
802 } 806 }
803 807
804 808
805 emit clearSelectionSignal(); 809 emit clearSelectionSignal();
806 QPoint bgnSel = pos; 810 QPoint bgnSel = pos;
807 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 811 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
808 int i = loc(bgnSel.x(),bgnSel.y()); 812 int i = loc(bgnSel.x(),bgnSel.y());
809 iPntSel = bgnSel; 813 iPntSel = bgnSel;
810 814
811 word_selection_mode = TRUE; 815 word_selection_mode = TRUE;
812 816
813 // find word boundaries... 817 // find word boundaries...
814 int selClass = charClass(image[i].c); 818 int selClass = charClass(image[i].c);
815 { 819 {
816 // set the start... 820 // set the start...
817 int x = bgnSel.x(); 821 int x = bgnSel.x();
818 while ( x > 0 && charClass(image[i-1].c) == selClass ) 822 while ( x > 0 && charClass(image[i-1].c) == selClass )
819 { i--; x--; } 823 { i--; x--; }
820 bgnSel.setX(x); 824 bgnSel.setX(x);
821 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); 825 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() );
822 826
823 // set the end... 827 // set the end...
824 i = loc( endSel.x(), endSel.y() ); 828 i = loc( endSel.x(), endSel.y() );
825 x = endSel.x(); 829 x = endSel.x();
826 while( x < columns-1 && charClass(image[i+1].c) == selClass ) 830 while( x < columns-1 && charClass(image[i+1].c) == selClass )
827 { i++; x++ ; } 831 { i++; x++ ; }
828 endSel.setX(x); 832 endSel.setX(x);
829 actSel = 2; // within selection 833 actSel = 2; // within selection
830 emit extendSelectionSignal( endSel.x(), endSel.y() ); 834 emit extendSelectionSignal( endSel.x(), endSel.y() );
831 emit endSelectionSignal(preserve_line_breaks); 835 emit endSelectionSignal(preserve_line_breaks);
832 preserve_line_breaks = TRUE; 836 preserve_line_breaks = TRUE;
833 } 837 }
834} 838}
835 839
836void TEWidget::focusInEvent( QFocusEvent * ) 840void TEWidget::focusInEvent( QFocusEvent * )
837{ 841{
838 // do nothing, to prevent repainting 842 // do nothing, to prevent repainting
839} 843}
840 844
841 845
842void TEWidget::focusOutEvent( QFocusEvent * ) 846void TEWidget::focusOutEvent( QFocusEvent * )
843{ 847{
844 // do nothing, to prevent repainting 848 // do nothing, to prevent repainting
845} 849}
846 850
847bool TEWidget::focusNextPrevChild( bool next ) 851bool TEWidget::focusNextPrevChild( bool next )
848{ 852{
849 if (next) 853 if (next)
850 return false; // This disables changing the active part in konqueror 854 return false; // This disables changing the active part in konqueror
851 // when pressing Tab 855 // when pressing Tab
852 return QFrame::focusNextPrevChild( next ); 856 return QFrame::focusNextPrevChild( next );
853} 857}
854 858
855 859
856int TEWidget::charClass(char ch) const 860int TEWidget::charClass(char ch) const
857{ 861{
858 // This might seem like overkill, but imagine if ch was a Unicode 862 // This might seem like overkill, but imagine if ch was a Unicode
859 // character (Qt 2.0 QChar) - it might then be sensible to separate 863 // character (Qt 2.0 QChar) - it might then be sensible to separate
860 // the different language ranges, etc. 864 // the different language ranges, etc.
861 865
862 if ( isspace(ch) ) return ' '; 866 if ( isspace(ch) ) return ' ';
863 867
864 static const char *word_characters = ":@-./_~"; 868 static const char *word_characters = ":@-./_~";
865 if ( isalnum(ch) || strchr(word_characters, ch) ) 869 if ( isalnum(ch) || strchr(word_characters, ch) )
866 return 'a'; 870 return 'a';
867 871
868 // Everything else is weird 872 // Everything else is weird
869 return 1; 873 return 1;
870} 874}
871 875
872void TEWidget::setMouseMarks(bool on) 876void TEWidget::setMouseMarks(bool on)
873{ 877{
874 mouse_marks = on; 878 mouse_marks = on;
875 setCursor( mouse_marks ? ibeamCursor : arrowCursor ); 879 setCursor( mouse_marks ? ibeamCursor : arrowCursor );
876} 880}
877 881
878/* ------------------------------------------------------------------------- */ 882/* ------------------------------------------------------------------------- */
879/* */ 883/* */
880/* Clipboard */ 884/* Clipboard */
881/* */ 885/* */
882/* ------------------------------------------------------------------------- */ 886/* ------------------------------------------------------------------------- */
883 887
884#undef KeyPress 888#undef KeyPress
885 889
886void TEWidget::emitSelection() 890void TEWidget::emitSelection()
887// Paste Clipboard by simulating keypress events 891// Paste Clipboard by simulating keypress events
888{ 892{
889#ifndef QT_NO_CLIPBOARD 893#ifndef QT_NO_CLIPBOARD
890 QString text = QApplication::clipboard()->text(); 894 QString text = QApplication::clipboard()->text();
891 if ( ! text.isNull() ) 895 if ( ! text.isNull() )
892 { 896 {
893 text.replace(QRegExp("\n"), "\r"); 897 text.replace(QRegExp("\n"), "\r");
894 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 898 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
895 emit keyPressedSignal(&e); // expose as a big fat keypress event 899 emit keyPressedSignal(&e); // expose as a big fat keypress event
896 emit clearSelectionSignal(); 900 emit clearSelectionSignal();
897 } 901 }
898#endif 902#endif
899} 903}
900 904
901void TEWidget::emitText(QString text) 905void TEWidget::emitText(QString text)
902{ 906{
903 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 907 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
904 emit keyPressedSignal(&e); // expose as a big fat keypress event 908 emit keyPressedSignal(&e); // expose as a big fat keypress event
905} 909}
906 910
907void TEWidget::pasteClipboard( ) 911void TEWidget::pasteClipboard( )
908{ 912{
909 emitSelection(); 913 emitSelection();
910} 914}
911 915
912void TEWidget::setSelection(const QString& t) 916void TEWidget::setSelection(const QString& t)
913{ 917{
914#ifndef QT_NO_CLIPBOARD 918#ifndef QT_NO_CLIPBOARD
915 // Disconnect signal while WE set the clipboard 919 // Disconnect signal while WE set the clipboard
916 QObject *cb = QApplication::clipboard(); 920 QObject *cb = QApplication::clipboard();
917 QObject::disconnect( cb, SIGNAL(dataChanged()), 921 QObject::disconnect( cb, SIGNAL(dataChanged()),
918 this, SLOT(onClearSelection()) ); 922 this, SLOT(onClearSelection()) );
919 923
920 QApplication::clipboard()->setText(t); 924 QApplication::clipboard()->setText(t);
921 925
922 QObject::connect( cb, SIGNAL(dataChanged()), 926 QObject::connect( cb, SIGNAL(dataChanged()),
923 this, SLOT(onClearSelection()) ); 927 this, SLOT(onClearSelection()) );
924#endif 928#endif
925} 929}
926 930
927void TEWidget::onClearSelection() 931void TEWidget::onClearSelection()
928{ 932{
929 emit clearSelectionSignal(); 933 emit clearSelectionSignal();
930} 934}
931 935
932/* ------------------------------------------------------------------------- */ 936/* ------------------------------------------------------------------------- */
933/* */ 937/* */
934/* Keyboard */ 938/* Keyboard */
935/* */ 939/* */
936/* ------------------------------------------------------------------------- */ 940/* ------------------------------------------------------------------------- */
937 941
938//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' 942//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent'
939// due to a bug in `QT' or the ignorance of the author to prevent 943// due to a bug in `QT' or the ignorance of the author to prevent
940// repaint events being emitted to the screen whenever one leaves 944// repaint events being emitted to the screen whenever one leaves
941// or reenters the screen to/from another application. 945// or reenters the screen to/from another application.
942// 946//
943// Troll says one needs to change focusInEvent() and focusOutEvent(), 947// Troll says one needs to change focusInEvent() and focusOutEvent(),
944// which would also let you have an in-focus cursor and an out-focus 948// which would also let you have an in-focus cursor and an out-focus
945// cursor like xterm does. 949// cursor like xterm does.
946 950
947// for the auto-hide cursor feature, I added empty focusInEvent() and 951// for the auto-hide cursor feature, I added empty focusInEvent() and
948// focusOutEvent() so that update() isn't called. 952// focusOutEvent() so that update() isn't called.
949// For auto-hide, we need to get keypress-events, but we only get them when 953// For auto-hide, we need to get keypress-events, but we only get them when
950// we have focus. 954// we have focus.
951 955
952void TEWidget::doScroll(int lines) 956void TEWidget::doScroll(int lines)
953{ 957{
954 scrollbar->setValue(scrollbar->value()+lines); 958 scrollbar->setValue(scrollbar->value()+lines);
955} 959}
956 960
957bool TEWidget::eventFilter( QObject *obj, QEvent *e ) 961bool TEWidget::eventFilter( QObject *obj, QEvent *e )
958{ 962{
959 if ( (e->type() == QEvent::Accel || 963 if ( (e->type() == QEvent::Accel ||
960 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) 964 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this )
961 { 965 {
962 static_cast<QKeyEvent *>( e )->ignore(); 966 static_cast<QKeyEvent *>( e )->ignore();
963 return true; 967 return true;
964 } 968 }
965 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 969 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
966 return FALSE; // not us 970 return FALSE; // not us
967 if ( e->type() == QEvent::Wheel) 971 if ( e->type() == QEvent::Wheel)
968 { 972 {
969 QApplication::sendEvent(scrollbar, e); 973 QApplication::sendEvent(scrollbar, e);
970 } 974 }
971 975
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;
1012 1016
1013 actSel=0; // Key stroke implies a screen update, so TEWidget won't 1017 actSel=0; // Key stroke implies a screen update, so TEWidget won't
1014 // know where the current selection is. 1018 // know where the current selection is.
1015 1019
1016 emit keyPressedSignal(ke); // expose 1020 emit keyPressedSignal(ke); // expose
1017 ke->accept(); 1021 ke->accept();
1018#ifdef FAKE_CTRL_AND_ALT 1022#ifdef FAKE_CTRL_AND_ALT
1019 if ( dele ) delete e; 1023 if ( dele ) delete e;
1020#endif 1024#endif
1021 return true; // stop the event 1025 return true; // stop the event
1022 } 1026 }
1023 if ( e->type() == QEvent::Enter ) 1027 if ( e->type() == QEvent::Enter )
1024 { 1028 {
1025 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1029 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1026 this, SLOT(onClearSelection()) ); 1030 this, SLOT(onClearSelection()) );
1027 } 1031 }
1028 if ( e->type() == QEvent::Leave ) 1032 if ( e->type() == QEvent::Leave )
1029 { 1033 {
1030 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1034 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1031 this, SLOT(onClearSelection()) ); 1035 this, SLOT(onClearSelection()) );
1032 } 1036 }
1033 return QFrame::eventFilter( obj, e ); 1037 return QFrame::eventFilter( obj, e );
1034} 1038}
1035 1039
1036/* ------------------------------------------------------------------------- */ 1040/* ------------------------------------------------------------------------- */
1037/* */ 1041/* */
1038/* Frame */ 1042/* Frame */
1039/* */ 1043/* */
1040/* ------------------------------------------------------------------------- */ 1044/* ------------------------------------------------------------------------- */
1041 1045
1042void TEWidget::frameChanged() 1046void TEWidget::frameChanged()
1043{ 1047{
1044 propagateSize(); 1048 propagateSize();
1045 update(); 1049 update();
1046} 1050}
1047 1051
1048/* ------------------------------------------------------------------------- */ 1052/* ------------------------------------------------------------------------- */
1049/* */ 1053/* */
1050/* Sound */ 1054/* Sound */
1051/* */ 1055/* */
1052/* ------------------------------------------------------------------------- */ 1056/* ------------------------------------------------------------------------- */
1053 1057
1054void TEWidget::Bell() 1058void TEWidget::Bell()
1055{ 1059{
1056 QApplication::beep(); 1060 QApplication::beep();
1057} 1061}
1058 1062
1059/* ------------------------------------------------------------------------- */ 1063/* ------------------------------------------------------------------------- */
1060/* */ 1064/* */
1061/* Auxiluary */ 1065/* Auxiluary */
1062/* */ 1066/* */
1063/* ------------------------------------------------------------------------- */ 1067/* ------------------------------------------------------------------------- */
1064 1068
1065void TEWidget::clearImage() 1069void TEWidget::clearImage()
1066// initialize the image 1070// initialize the image
1067// for internal use only 1071// for internal use only
1068{ 1072{
1069 for (int y = 0; y < lines; y++) 1073 for (int y = 0; y < lines; y++)
1070 for (int x = 0; x < columns; x++) 1074 for (int x = 0; x < columns; x++)
1071 { 1075 {
1072 image[loc(x,y)].c = 0xff; //' '; 1076 image[loc(x,y)].c = 0xff; //' ';
1073 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; 1077 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
1074 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; 1078 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
1075 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; 1079 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
1076 } 1080 }
1077} 1081}
1078 1082
1079// Create Image /////////////////////////////////////////////////////// 1083// Create Image ///////////////////////////////////////////////////////
1080 1084
1081void TEWidget::calcGeometry() 1085void TEWidget::calcGeometry()
1082{ 1086{
1083 //FIXME: set rimX == rimY == 0 when running in full screen mode. 1087 //FIXME: set rimX == rimY == 0 when running in full screen mode.
1084 1088
1085 scrollbar->resize(QApplication::style().scrollBarExtent().width(), 1089 scrollbar->resize(QApplication::style().scrollBarExtent().width(),
1086 contentsRect().height()); 1090 contentsRect().height());
1087 switch(scrollLoc) 1091 switch(scrollLoc)
1088 { 1092 {
1089 case SCRNONE : 1093 case SCRNONE :
1090 columns = ( contentsRect().width() - 2 * rimX ) / font_w; 1094 columns = ( contentsRect().width() - 2 * rimX ) / font_w;
1091 blX = (contentsRect().width() - (columns*font_w) ) / 2; 1095 blX = (contentsRect().width() - (columns*font_w) ) / 2;
1092 brX = blX; 1096 brX = blX;
1093 scrollbar->hide(); 1097 scrollbar->hide();
1094 break; 1098 break;
1095 case SCRLEFT : 1099 case SCRLEFT :
1096 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1100 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1097 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1101 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1098 blX = brX + scrollbar->width(); 1102 blX = brX + scrollbar->width();
1099 scrollbar->move(contentsRect().topLeft()); 1103 scrollbar->move(contentsRect().topLeft());
1100 scrollbar->show(); 1104 scrollbar->show();
1101 break; 1105 break;
1102 case SCRRIGHT: 1106 case SCRRIGHT:
1103 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1107 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1104 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1108 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1105 brX = blX; 1109 brX = blX;
1106 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); 1110 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
1107 scrollbar->show(); 1111 scrollbar->show();
1108 break; 1112 break;
1109 } 1113 }
1110 //FIXME: support 'rounding' styles 1114 //FIXME: support 'rounding' styles
1111 lines = ( contentsRect().height() - 2 * rimY ) / font_h; 1115 lines = ( contentsRect().height() - 2 * rimY ) / font_h;
1112 bY = (contentsRect().height() - (lines *font_h)) / 2; 1116 bY = (contentsRect().height() - (lines *font_h)) / 2;
1113} 1117}
1114 1118
1115void TEWidget::makeImage() 1119void TEWidget::makeImage()
1116//FIXME: rename 'calcGeometry? 1120//FIXME: rename 'calcGeometry?
1117{ 1121{
1118 calcGeometry(); 1122 calcGeometry();
1119 image = (ca*) malloc(lines*columns*sizeof(ca)); 1123 image = (ca*) malloc(lines*columns*sizeof(ca));
1120 clearImage(); 1124 clearImage();
1121} 1125}
1122 1126
1123// calculate the needed size 1127// calculate the needed size
1124QSize TEWidget::calcSize(int cols, int lins) const 1128QSize TEWidget::calcSize(int cols, int lins) const
1125{ 1129{
1126 int frw = width() - contentsRect().width(); 1130 int frw = width() - contentsRect().width();
1127 int frh = height() - contentsRect().height(); 1131 int frh = height() - contentsRect().height();
1128 int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); 1132 int scw = (scrollLoc==SCRNONE?0:scrollbar->width());
1129 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); 1133 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh );
1130} 1134}
1131 1135
1132QSize TEWidget::sizeHint() const 1136QSize TEWidget::sizeHint() const
1133{ 1137{
1134 return size(); 1138 return size();
1135} 1139}
1136 1140
1137void TEWidget::styleChange(QStyle &) 1141void TEWidget::styleChange(QStyle &)
1138{ 1142{
1139 propagateSize(); 1143 propagateSize();
1140} 1144}
1141 1145
1142#ifndef QT_NO_DRAGANDDROP 1146#ifndef QT_NO_DRAGANDDROP
1143 1147
1144/* --------------------------------------------------------------------- */ 1148/* --------------------------------------------------------------------- */
1145/* */ 1149/* */
1146/* Drag & Drop */ 1150/* Drag & Drop */
1147/* */ 1151/* */
1148/* --------------------------------------------------------------------- */ 1152/* --------------------------------------------------------------------- */
1149 1153
1150 1154
1151void TEWidget::dragEnterEvent(QDragEnterEvent* e) 1155void TEWidget::dragEnterEvent(QDragEnterEvent* e)
1152{ 1156{
1153 e->accept(QTextDrag::canDecode(e) || 1157 e->accept(QTextDrag::canDecode(e) ||
1154 QUriDrag::canDecode(e)); 1158 QUriDrag::canDecode(e));
1155} 1159}
1156 1160
1157void TEWidget::dropEvent(QDropEvent* event) 1161void TEWidget::dropEvent(QDropEvent* event)
1158{ 1162{
1159 // The current behaviour when url(s) are dropped is 1163 // The current behaviour when url(s) are dropped is
1160 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd 1164 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd
1161 // * in all other cases, just paste 1165 // * in all other cases, just paste
1162 // (for non-local ones, or for a list of URLs, 'cd' is nonsense) 1166 // (for non-local ones, or for a list of URLs, 'cd' is nonsense)
1163 QStrList strlist; 1167 QStrList strlist;
1164 int file_count = 0; 1168 int file_count = 0;
1165 dropText = ""; 1169 dropText = "";
1166 bool bPopup = true; 1170 bool bPopup = true;
1167 1171
1168 if(QUriDrag::decode(event, strlist)) { 1172 if(QUriDrag::decode(event, strlist)) {
1169 if (strlist.count()) { 1173 if (strlist.count()) {
1170 for(const char* p = strlist.first(); p; p = strlist.next()) { 1174 for(const char* p = strlist.first(); p; p = strlist.next()) {
1171 if(file_count++ > 0) { 1175 if(file_count++ > 0) {
1172 dropText += " "; 1176 dropText += " ";
1173 bPopup = false; // more than one file, don't popup 1177 bPopup = false; // more than one file, don't popup
1174 } 1178 }
1175 1179
1176/* 1180/*
1177 KURL url(p); 1181 KURL url(p);
1178 if (url.isLocalFile()) { 1182 if (url.isLocalFile()) {
1179 dropText += url.path(); // local URL : remove protocol 1183 dropText += url.path(); // local URL : remove protocol
1180 } 1184 }
1181 else { 1185 else {
1182 dropText += url.prettyURL(); 1186 dropText += url.prettyURL();
1183 bPopup = false; // a non-local file, don't popup 1187 bPopup = false; // a non-local file, don't popup
1184 } 1188 }
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());
1205 } 1209 }
1206 // Paste it 1210 // Paste it
1207 } 1211 }
1208} 1212}
1209#endif 1213#endif
1210 1214
1211 1215
1212void TEWidget::drop_menu_activated(int item) 1216void TEWidget::drop_menu_activated(int item)
1213{ 1217{
1214#ifndef QT_NO_DRAGANDDROP 1218#ifndef QT_NO_DRAGANDDROP
1215 switch (item) 1219 switch (item)
1216 { 1220 {
1217 case 0: // paste 1221 case 0: // paste
1218 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1222 currentSession->getEmulation()->sendString(dropText.local8Bit());
1219// KWM::activate((Window)this->winId()); 1223// KWM::activate((Window)this->winId());
1220 break; 1224 break;
1221 case 1: // cd ... 1225 case 1: // cd ...
1222 currentSession->getEmulation()->sendString("cd "); 1226 currentSession->getEmulation()->sendString("cd ");
1223 struct stat statbuf; 1227 struct stat statbuf;
1224 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) 1228 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 )
1225 { 1229 {
1226 if ( !S_ISDIR(statbuf.st_mode) ) 1230 if ( !S_ISDIR(statbuf.st_mode) )
1227 { 1231 {
1228/* 1232/*
1229 KURL url; 1233 KURL url;
1230 url.setPath( dropText ); 1234 url.setPath( dropText );
1231 dropText = url.directory( true, false ); // remove filename 1235 dropText = url.directory( true, false ); // remove filename
1232*/ 1236*/
1233 } 1237 }
1234 } 1238 }
1235 dropText.replace(QRegExp(" "), "\\ "); // escape spaces 1239 dropText.replace(QRegExp(" "), "\\ "); // escape spaces
1236 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1240 currentSession->getEmulation()->sendString(dropText.local8Bit());
1237 currentSession->getEmulation()->sendString("\n"); 1241 currentSession->getEmulation()->sendString("\n");
1238// KWM::activate((Window)this->winId()); 1242// KWM::activate((Window)this->winId());
1239 break; 1243 break;
1240 } 1244 }
1241#endif 1245#endif
1242} 1246}
1243 1247
diff --git a/core/apps/embeddedkonsole/TEWidget.h b/core/apps/embeddedkonsole/TEWidget.h
index 3f9f4ae..40e1aea 100644
--- a/core/apps/embeddedkonsole/TEWidget.h
+++ b/core/apps/embeddedkonsole/TEWidget.h
@@ -1,202 +1,202 @@
1/* ----------------------------------------------------------------------- */ 1/* ----------------------------------------------------------------------- */
2/* */ 2/* */
3/* [te_widget.h] Terminal Emulation Widget */ 3/* [te_widget.h] 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
19#ifndef TE_WIDGET_H 18#ifndef TE_WIDGET_H
20#define TE_WIDGET_H 19#define TE_WIDGET_H
21 20
22#include <qwidget.h> 21#include <qwidget.h>
23#include <qlabel.h> 22#include <qlabel.h>
24#include <qtimer.h> 23#include <qtimer.h>
25#include <qcolor.h> 24#include <qcolor.h>
26#include <qkeycode.h> 25#include <qkeycode.h>
27#include <qscrollbar.h> 26#include <qscrollbar.h>
28 27
29#include <qpopupmenu.h> 28#include <qpopupmenu.h>
30 29
31#include "TECommon.h" 30#include "TECommon.h"
32 31
33extern unsigned short vt100_graphics[32]; 32extern unsigned short vt100_graphics[32];
34 33
35class TESession; 34class TESession;
36 35
37// class Konsole; 36// class Konsole;
38 37
39class TEWidget : public QFrame 38class TEWidget : public QFrame
40// a widget representing attributed text 39// a widget representing attributed text
41{ Q_OBJECT 40{ Q_OBJECT
42 41
43// friend class Konsole; 42// friend class Konsole;
44 43
45public: 44public:
46 45
47 TEWidget(QWidget *parent=0, const char *name=0); 46 TEWidget(QWidget *parent=0, const char *name=0);
48 virtual ~TEWidget(); 47 virtual ~TEWidget();
49 48
50public: 49public:
51 50
52 QColor getDefaultBackColor(); 51 QColor getDefaultBackColor();
53 52
54 const ColorEntry* getColorTable() const; 53 const ColorEntry* getColorTable() const;
54 const ColorEntry* getdefaultColorTable() const;
55 void setColorTable(const ColorEntry table[]); 55 void setColorTable(const ColorEntry table[]);
56 56
57 void setScrollbarLocation(int loc); 57 void setScrollbarLocation(int loc);
58 enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 }; 58 enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 };
59 59
60 void setScroll(int cursor, int lines); 60 void setScroll(int cursor, int lines);
61 void doScroll(int lines); 61 void doScroll(int lines);
62 62
63 void emitSelection(); 63 void emitSelection();
64 64
65public: 65public:
66 66
67 void setImage(const ca* const newimg, int lines, int columns); 67 void setImage(const ca* const newimg, int lines, int columns);
68 68
69 int Lines() { return lines; } 69 int Lines() { return lines; }
70 int Columns() { return columns; } 70 int Columns() { return columns; }
71 71
72 void calcGeometry(); 72 void calcGeometry();
73 void propagateSize(); 73 void propagateSize();
74 QSize calcSize(int cols, int lins) const; 74 QSize calcSize(int cols, int lins) const;
75 75
76 QSize sizeHint() const; 76 QSize sizeHint() const;
77 77
78public: 78public:
79 79
80 void Bell(); 80 void Bell();
81 void emitText(QString text); 81 void emitText(QString text);
82 void pasteClipboard(); 82 void pasteClipboard();
83 83
84signals: 84signals:
85 85
86 void keyPressedSignal(QKeyEvent *e); 86 void keyPressedSignal(QKeyEvent *e);
87 void mouseSignal(int cb, int cx, int cy); 87 void mouseSignal(int cb, int cx, int cy);
88 void changedImageSizeSignal(int lines, int columns); 88 void changedImageSizeSignal(int lines, int columns);
89 void changedHistoryCursor(int value); 89 void changedHistoryCursor(int value);
90 void configureRequest( TEWidget*, int state, int x, int y ); 90 void configureRequest( TEWidget*, int state, int x, int y );
91 91
92 void clearSelectionSignal(); 92 void clearSelectionSignal();
93 void beginSelectionSignal( const int x, const int y ); 93 void beginSelectionSignal( const int x, const int y );
94 void extendSelectionSignal( const int x, const int y ); 94 void extendSelectionSignal( const int x, const int y );
95 void endSelectionSignal(const BOOL preserve_line_breaks); 95 void endSelectionSignal(const BOOL preserve_line_breaks);
96 96
97 97
98protected: 98protected:
99 99
100 virtual void styleChange( QStyle& ); 100 virtual void styleChange( QStyle& );
101 101
102 bool eventFilter( QObject *, QEvent * ); 102 bool eventFilter( QObject *, QEvent * );
103 103
104 void drawAttrStr(QPainter &paint, QRect rect, 104 void drawAttrStr(QPainter &paint, QRect rect,
105 QString& str, ca attr, BOOL pm, BOOL clear); 105 QString& str, ca attr, BOOL pm, BOOL clear);
106 void paintEvent( QPaintEvent * ); 106 void paintEvent( QPaintEvent * );
107 107
108 void resizeEvent(QResizeEvent*); 108 void resizeEvent(QResizeEvent*);
109 109
110 void fontChange(const QFont &font); 110 void fontChange(const QFont &font);
111 void frameChanged(); 111 void frameChanged();
112 112
113 void mouseDoubleClickEvent(QMouseEvent* ev); 113 void mouseDoubleClickEvent(QMouseEvent* ev);
114 void mousePressEvent( QMouseEvent* ); 114 void mousePressEvent( QMouseEvent* );
115 void mouseReleaseEvent( QMouseEvent* ); 115 void mouseReleaseEvent( QMouseEvent* );
116 void mouseMoveEvent( QMouseEvent* ); 116 void mouseMoveEvent( QMouseEvent* );
117 117
118 void focusInEvent( QFocusEvent * ); 118 void focusInEvent( QFocusEvent * );
119 void focusOutEvent( QFocusEvent * ); 119 void focusOutEvent( QFocusEvent * );
120 bool focusNextPrevChild( bool next ); 120 bool focusNextPrevChild( bool next );
121 121
122#ifndef QT_NO_DRAGANDDROP 122#ifndef QT_NO_DRAGANDDROP
123 // Dnd 123 // Dnd
124 void dragEnterEvent(QDragEnterEvent* event); 124 void dragEnterEvent(QDragEnterEvent* event);
125 void dropEvent(QDropEvent* event); 125 void dropEvent(QDropEvent* event);
126#endif 126#endif
127 127
128 virtual int charClass(char) const; 128 virtual int charClass(char) const;
129 129
130 void clearImage(); 130 void clearImage();
131 131
132public: 132public:
133 const QPixmap *backgroundPixmap(); 133 const QPixmap *backgroundPixmap();
134 134
135 void setSelection(const QString &t); 135 void setSelection(const QString &t);
136 136
137 virtual void setFont(const QFont &); 137 virtual void setFont(const QFont &);
138 void setVTFont(const QFont &); 138 void setVTFont(const QFont &);
139 QFont getVTFont(); 139 QFont getVTFont();
140 140
141 void setMouseMarks(bool on); 141 void setMouseMarks(bool on);
142 142
143public slots: 143public slots:
144 144
145 void onClearSelection(); 145 void onClearSelection();
146 146
147protected slots: 147protected slots:
148 148
149 void scrollChanged(int value); 149 void scrollChanged(int value);
150 void blinkEvent(); 150 void blinkEvent();
151 151
152private: 152private:
153 153
154 QChar (*fontMap)(QChar); // possible vt100 font extention 154 QChar (*fontMap)(QChar); // possible vt100 font extention
155 155
156 bool fixed_font; // has fixed pitch 156 bool fixed_font; // has fixed pitch
157 int font_h; // height 157 int font_h; // height
158 int font_w; // width 158 int font_w; // width
159 int font_a; // ascend 159 int font_a; // ascend
160 160
161 int blX; // actual offset (left) 161 int blX; // actual offset (left)
162 int brX; // actual offset (right) 162 int brX; // actual offset (right)
163 int bY; // actual offset 163 int bY; // actual offset
164 164
165 int lines; 165 int lines;
166 int columns; 166 int columns;
167 ca *image; // [lines][columns] 167 ca *image; // [lines][columns]
168 168
169 ColorEntry color_table[TABLE_COLORS]; 169 ColorEntry color_table[TABLE_COLORS];
170 170
171 BOOL resizing; 171 BOOL resizing;
172 bool mouse_marks; 172 bool mouse_marks;
173 173
174 void makeImage(); 174 void makeImage();
175 175
176 QPoint iPntSel; // initial selection point 176 QPoint iPntSel; // initial selection point
177 QPoint pntSel; // current selection point 177 QPoint pntSel; // current selection point
178 int actSel; // selection state 178 int actSel; // selection state
179 BOOL word_selection_mode; 179 BOOL word_selection_mode;
180 BOOL preserve_line_breaks; 180 BOOL preserve_line_breaks;
181 181
182 QClipboard* cb; 182 QClipboard* cb;
183 QScrollBar* scrollbar; 183 QScrollBar* scrollbar;
184 int scrollLoc; 184 int scrollLoc;
185 185
186//#define SCRNONE 0 186//#define SCRNONE 0
187//#define SCRLEFT 1 187//#define SCRLEFT 1
188//#define SCRRIGHT 2 188//#define SCRRIGHT 2
189 189
190 BOOL blinking; // hide text in paintEvent 190 BOOL blinking; // hide text in paintEvent
191 BOOL hasBlinker; // has characters to blink 191 BOOL hasBlinker; // has characters to blink
192 QTimer* blinkT; // active when hasBlinker 192 QTimer* blinkT; // active when hasBlinker
193 QPopupMenu* m_drop; 193 QPopupMenu* m_drop;
194 QString dropText; 194 QString dropText;
195 public: 195 public:
196 // current session in this widget 196 // current session in this widget
197 TESession *currentSession; 197 TESession *currentSession;
198private slots: 198private slots:
199 void drop_menu_activated(int item); 199 void drop_menu_activated(int item);
200}; 200};
201 201
202#endif // TE_WIDGET_H 202#endif // TE_WIDGET_H
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index 7253baf..1102ef3 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -1,512 +1,762 @@
1/* ---------------------------------------------------------------------- */ 1/* ---------------------------------------------------------------------- */
2/* */ 2/* */
3/* [main.C] Konsole */ 3/* [main.C] Konsole */
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. */ 9/* This file is part of Konsole, an X terminal. */
10/* */ 10/* */
11/* The material contained in here more or less directly orginates from */ 11/* The material contained in here more or less directly orginates from */
12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ 12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
13/* */ 13/* */
14/* ---------------------------------------------------------------------- */ 14/* ---------------------------------------------------------------------- */
15 /* */ 15/* */
16/* Ported Konsole to Qt/Embedded */ 16/* Ported Konsole to Qt/Embedded */
17 /* */ 17/* */
18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
19 /* */ 19/* */
20/* -------------------------------------------------------------------------- */ 20/* -------------------------------------------------------------------------- */
21 21
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23 23
24#include <qdir.h> 24#include <qdir.h>
25#include <qevent.h> 25#include <qevent.h>
26#include <qdragobject.h> 26#include <qdragobject.h>
27#include <qobjectlist.h> 27#include <qobjectlist.h>
28#include <qtoolbutton.h> 28#include <qtoolbutton.h>
29#include <qpe/qpetoolbar.h> 29#include <qpe/qpetoolbar.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qfontdialog.h> 31#include <qfontdialog.h>
32#include <qglobal.h> 32#include <qglobal.h>
33#include <qpainter.h> 33#include <qpainter.h>
34#include <qpe/qpemenubar.h> 34#include <qpe/qpemenubar.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36#include <qaction.h> 36#include <qaction.h>
37#include <qapplication.h> 37#include <qapplication.h>
38#include <qfontmetrics.h> 38#include <qfontmetrics.h>
39#include <qcombobox.h> 39#include <qcombobox.h>
40#include <qevent.h> 40#include <qevent.h>
41#include <qtabwidget.h> 41#include <qtabwidget.h>
42#include <qtabbar.h> 42#include <qtabbar.h>
43#include <qpe/config.h> 43#include <qpe/config.h>
44#include <qstringlist.h>
45#include <qpalette.h>
44 46
45#include <sys/wait.h> 47#include <sys/wait.h>
46#include <stdio.h> 48#include <stdio.h>
47#include <stdlib.h> 49#include <stdlib.h>
48#include <assert.h> 50#include <assert.h>
49 51
50#include "konsole.h" 52#include "konsole.h"
51#include "keytrans.h" 53#include "keytrans.h"
52 54
53class EKNumTabBar : public QTabBar { 55class EKNumTabBar : public QTabBar {
54public: 56public:
55 void numberTabs() 57 void numberTabs()
56 { 58 {
57 // Yes, it really is this messy. QTabWidget needs functions 59 // Yes, it really is this messy. QTabWidget needs functions
58 // that provide acces to tabs in a sequential way. 60 // that provide acces to tabs in a sequential way.
59 int m=INT_MIN; 61 int m=INT_MIN;
60 for (int i=0; i<count(); i++) { 62 for (int i=0; i<count(); i++) {
61 QTab* left=0; 63 QTab* left=0;
62 QListIterator<QTab> it(*tabList()); 64 QListIterator<QTab> it(*tabList());
63 int x=INT_MAX; 65 int x=INT_MAX;
64 for( QTab* t; (t=it.current()); ++it ) { 66 for( QTab* t; (t=it.current()); ++it ) {
65 int tx = t->rect().x(); 67 int tx = t->rect().x();
66 if ( tx<x && tx>m ) { 68 if ( tx<x && tx>m ) {
67 x = tx; 69 x = tx;
68 left = t; 70 left = t;
69 } 71 }
70 } 72 }
71 if ( left ) { 73 if ( left ) {
72 left->setText(QString::number(i+1)); 74 left->setText(QString::number(i+1));
73 m = left->rect().x(); 75 m = left->rect().x();
74 } 76 }
75 } 77 }
76 } 78 }
77}; 79};
78 80
79class EKNumTabWidget : public QTabWidget { 81class EKNumTabWidget : public QTabWidget {
80public: 82public:
81 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 83 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
82 { 84 {
83 } 85 }
84 86
85 void addTab(QWidget* w) 87 void addTab(QWidget* w)
86 { 88 {
87 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 89 QTab* t = new QTab(QString::number(tabBar()->count()+1));
88 QTabWidget::addTab(w,t); 90 QTabWidget::addTab(w,t);
89 } 91 }
90 92
91 void removeTab(QWidget* w) 93 void removeTab(QWidget* w)
92 { 94 {
93 removePage(w); 95 removePage(w);
94 ((EKNumTabBar*)tabBar())->numberTabs(); 96 ((EKNumTabBar*)tabBar())->numberTabs();
95 } 97 }
96}; 98};
97 99
98// This could be configurable or dynamicly generated from the bash history 100// This could be configurable or dynamicly generated from the bash history
99// file of the user 101// file of the user
100static const char *commonCmds[] = 102static const char *commonCmds[] =
101{ 103{
102 "ls ", 104 "ls ", // I left this here, cause it looks better than the first alpha
103 //"ls -la ", 105 "cardctl eject",
106 "cat ",
104 "cd ", 107 "cd ",
105 "pwd", 108 "chmod ",
106 //"cat", 109 "cp ",
107 //"less ", 110 "dc ",
108 //"vi ", 111 "df ",
109 //"man ", 112 "dmesg",
110 "echo ", 113 "echo ",
111 "set ", 114 "find ",
112 //"ps", 115 "free",
113 "ps aux",
114 //"tar",
115 //"tar -zxf",
116 "grep ", 116 "grep ",
117 //"grep -i", 117 "ifconfig ",
118 //"mkdir", 118 "ipkg ",
119 "cp ", 119 "mkdir ",
120 "mv ", 120 "mv ",
121 "nc localhost 7776",
122 "nc localhost 7777",
123 "nslookup ",
124 "ping ",
125 "ps aux",
126 "pwd ",
121 "rm ", 127 "rm ",
122 "rmdir ", 128 "rmdir ",
123 //"chmod", 129 "route ",
124 //"su", 130 "set ",
125// "top", 131 "traceroute",
126 //"find",
127 //"make",
128 //"tail",
129 "cardctl eject",
130 "ifconfig ",
131// "iwconfig eth0 ",
132 "nc localhost 7777",
133 "nc localhost 7776",
134 //"mount /dev/hda1",
135 132
136/* 133/*
137 "gzip", 134 "gzip",
138 "gunzip", 135 "gunzip",
139 "chgrp", 136 "chgrp",
140 "chown", 137 "chown",
141 "date", 138 "date",
142 "dd", 139 "dd",
143 "df", 140 "df",
144 "dmesg", 141 "dmesg",
145 "fuser", 142 "fuser",
146 "hostname", 143 "hostname",
147 "kill", 144 "kill",
148 "killall", 145 "killall",
149 "ln", 146 "ln",
150 "ping", 147 "ping",
151 "mount", 148 "mount",
152 "more", 149 "more",
153 "sort", 150 "sort",
154 "touch", 151 "touch",
155 "umount", 152 "umount",
156 "mknod", 153 "mknod",
157 "netstat", 154 "netstat",
158*/ 155*/
159 156
160 "exit", 157 "exit",
161 NULL 158 NULL
162}; 159};
163 160
164 161
165Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 162Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
166 QMainWindow(parent, name, fl) 163 QMainWindow(parent, name, fl)
167{ 164{
168 QStrList args; 165 QStrList args;
169 init("/bin/sh",args); 166 init("/bin/sh",args);
170} 167}
171 168
172Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 169Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
173 : QMainWindow(0, name) 170 : QMainWindow(0, name)
174{ 171{
175 init(_pgm,_args); 172 init(_pgm,_args);
176} 173}
177 174
178void Konsole::init(const char* _pgm, QStrList & _args) 175void Konsole::init(const char* _pgm, QStrList & _args)
179{ 176{
180 b_scroll = TRUE; // histon; 177 b_scroll = TRUE; // histon;
181 n_keytab = 0; 178 n_keytab = 0;
182 n_render = 0; 179 n_render = 0;
183 180
184 setCaption( tr("Terminal") ); 181 setCaption( tr("Terminal") );
185 setIcon( Resource::loadPixmap( "konsole" ) ); 182 setIcon( Resource::loadPixmap( "konsole" ) );
186 183
187 Config cfg("Konsole"); 184 Config cfg("Konsole");
188 cfg.setGroup("Konsole"); 185 cfg.setGroup("Konsole");
189 186 QString tmp;
190 // initialize the list of allowed fonts /////////////////////////////////// 187 // initialize the list of allowed fonts ///////////////////////////////////
191 cfont = cfg.readNumEntry("FontID", 1); 188 cfont = cfg.readNumEntry("FontID", 1);
192 QFont f = QFont("Micro", 4, QFont::Normal); 189 QFont f = QFont("Micro", 4, QFont::Normal);
193 f.setFixedPitch(TRUE); 190 f.setFixedPitch(TRUE);
194 fonts.append(new VTFont(tr("Micro"), f)); 191 fonts.append(new VTFont(tr("Micro"), f));
195 192
196 f = QFont("Fixed", 7, QFont::Normal); 193 f = QFont("Fixed", 7, QFont::Normal);
197 f.setFixedPitch(TRUE); 194 f.setFixedPitch(TRUE);
198 fonts.append(new VTFont(tr("Small Fixed"), f)); 195 fonts.append(new VTFont(tr("Small Fixed"), f));
199 196
200 f = QFont("Fixed", 12, QFont::Normal); 197 f = QFont("Fixed", 12, QFont::Normal);
201 f.setFixedPitch(TRUE); 198 f.setFixedPitch(TRUE);
202 fonts.append(new VTFont(tr("Medium Fixed"), f)); 199 fonts.append(new VTFont(tr("Medium Fixed"), f));
203 200
204 // create terminal emulation framework //////////////////////////////////// 201 // create terminal emulation framework ////////////////////////////////////
205 nsessions = 0; 202 nsessions = 0;
203
206 tab = new EKNumTabWidget(this); 204 tab = new EKNumTabWidget(this);
207 tab->setTabPosition(QTabWidget::Bottom); 205
208 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 206 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
209 207
210 // create terminal toolbar //////////////////////////////////////////////// 208 // create terminal toolbar ////////////////////////////////////////////////
211 setToolBarsMovable( FALSE ); 209 setToolBarsMovable( FALSE );
212 QPEToolBar *menuToolBar = new QPEToolBar( this ); 210 QPEToolBar *menuToolBar = new QPEToolBar( this );
213 menuToolBar->setHorizontalStretchable( TRUE ); 211 menuToolBar->setHorizontalStretchable( TRUE );
214 212
215 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); 213 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar );
216 214
217 fontList = new QPopupMenu( this ); 215 fontList = new QPopupMenu( this );
218 for(uint i = 0; i < fonts.count(); i++) { 216 for(uint i = 0; i < fonts.count(); i++) {
219 VTFont *fnt = fonts.at(i); 217 VTFont *fnt = fonts.at(i);
220 fontList->insertItem(fnt->getName(), i); 218 fontList->insertItem(fnt->getName(), i);
221 } 219 }
222 fontChanged(cfont); 220 fontChanged(cfont);
223 221
222 configMenu = new QPopupMenu( this);
223 colorMenu = new QPopupMenu( this);
224
225 bool listHidden;
226 cfg.setGroup("Menubar");
227 if( cfg.readEntry("Hidden","FALSE") == "TRUE") {
228 configMenu->insertItem("Show command list");
229 listHidden=TRUE;
230 } else {
231 configMenu->insertItem("Hide command list");
232 listHidden=FALSE;
233 }
234
235 cfg.setGroup("Tabs");
236 tmp=cfg.readEntry("Position","Bottom");
237 if(tmp=="Top") {
238 tab->setTabPosition(QTabWidget::Top);
239 configMenu->insertItem("Tabs on Bottom");
240 } else {
241 tab->setTabPosition(QTabWidget::Bottom);
242 configMenu->insertItem("Tabs on Top");
243 }
244 configMenu->insertSeparator(2);
245
246 colorMenu->insertItem("Green on Black");
247 colorMenu->insertItem("Black on White");
248 colorMenu->insertItem("White on Black");
249 colorMenu->insertItem("Black on Transparent");
250 colorMenu->insertItem("Black on Red");
251 colorMenu->insertItem("Red on Black");
252 colorMenu->insertItem("Green on Yellow");
253 colorMenu->insertItem("Blue on Magenta");
254 colorMenu->insertItem("Magenta on Blue");
255 colorMenu->insertItem("Cyan on White");
256 colorMenu->insertItem("White on Cyan");
257 colorMenu->insertItem("Blue on Black");
258 configMenu->insertItem("Colors",colorMenu);
259
224 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 260 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
261 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
262 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) ));
225 263
226 menuBar->insertItem( tr("Font"), fontList ); 264 menuBar->insertItem( tr("Font"), fontList );
265 menuBar->insertItem( tr("Options"), configMenu );
227 266
228 QPEToolBar *toolbar = new QPEToolBar( this ); 267 QPEToolBar *toolbar = new QPEToolBar( this );
229 268
230 QAction *a; 269 QAction *a;
231 270
232 // Button Commands 271 // Button Commands
233 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); 272 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 );
234 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); 273 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar );
235 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 274 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
236 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); 275 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar );
237 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); 276 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
238 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); 277 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar );
239 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); 278 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
240 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); 279 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar );
241 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); 280 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
242 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 281 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
243 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); 282 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
244 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 283 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
245 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 284 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
246 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); 285 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar );
247/* 286/*
248 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); 287 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 );
249 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 288 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
250 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); 289 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 );
251 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 290 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
252*/ 291*/
253 292
254 QPEToolBar *secondToolBar = new QPEToolBar( this ); 293 secondToolBar = new QPEToolBar( this );
255 secondToolBar->setHorizontalStretchable( TRUE ); 294 secondToolBar->setHorizontalStretchable( TRUE );
256 295
257 QComboBox *commonCombo = new QComboBox( secondToolBar ); 296 commonCombo = new QComboBox( secondToolBar );
258// commonCombo->setEditable( TRUE ); 297
259 for (int i = 0; commonCmds[i] != NULL; i++) 298 if( listHidden)
260 commonCombo->insertItem( commonCmds[i], i ); 299 secondToolBar->hide();
300 configMenu->insertItem( "Edit Command List");
301
302 cfg.setGroup("Commands");
303 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
304
305 for (int i = 0; commonCmds[i] != NULL; i++) {
306 commonCombo->insertItem( commonCmds[i], i );
307 tmp = cfg.readEntry( QString::number(i),"");
308 if(tmp != "")
309 commonCombo->changeItem( tmp,i );
310 }
311
261 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 312 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
262 313
263 // create applications ///////////////////////////////////////////////////// 314 // create applications /////////////////////////////////////////////////////
264 setCentralWidget(tab); 315 setCentralWidget(tab);
265 316
266 // load keymaps //////////////////////////////////////////////////////////// 317 // load keymaps ////////////////////////////////////////////////////////////
267 KeyTrans::loadAll(); 318 KeyTrans::loadAll();
268 for (int i = 0; i < KeyTrans::count(); i++) 319 for (int i = 0; i < KeyTrans::count(); i++)
269 { KeyTrans* s = KeyTrans::find(i); 320 { KeyTrans* s = KeyTrans::find(i);
270 assert( s ); 321 assert( s );
271 } 322 }
272 323
273 se_pgm = _pgm; 324 se_pgm = _pgm;
274 se_args = _args; 325 se_args = _args;
275 326
276 // read and apply default values /////////////////////////////////////////// 327 // read and apply default values ///////////////////////////////////////////
277 resize(321, 321); // Dummy. 328 resize(321, 321); // Dummy.
278 QSize currentSize = size(); 329 QSize currentSize = size();
279 if (currentSize != size()) 330 if (currentSize != size())
280 defaultSize = size(); 331 defaultSize = size();
332
281} 333}
282 334
283void Konsole::show() 335void Konsole::show()
284{ 336{
285 if ( !nsessions ) { 337 if ( !nsessions ) {
286 newSession(); 338 newSession();
287 } 339 }
288 QMainWindow::show(); 340 QMainWindow::show();
289} 341}
290 342
291void Konsole::initSession(const char*, QStrList &) 343void Konsole::initSession(const char*, QStrList &)
292{ 344{
293 QMainWindow::show(); 345 QMainWindow::show();
294} 346}
295 347
296Konsole::~Konsole() 348Konsole::~Konsole()
297{ 349{
298 while (nsessions > 0) { 350 while (nsessions > 0) {
299 doneSession(getTe()->currentSession, 0); 351 doneSession(getTe()->currentSession, 0);
300 } 352 }
301 353
302 Config cfg("Konsole"); 354 Config cfg("Konsole");
303 cfg.setGroup("Konsole"); 355 cfg.setGroup("Konsole");
304 cfg.writeEntry("FontID", cfont); 356 cfg.writeEntry("FontID", cfont);
305} 357}
306 358
307void Konsole::fontChanged(int f) 359void Konsole::fontChanged(int f)
308{ 360{
309 VTFont* font = fonts.at(f); 361 VTFont* font = fonts.at(f);
310 if (font != 0) { 362 if (font != 0) {
311 for(uint i = 0; i < fonts.count(); i++) { 363 for(uint i = 0; i < fonts.count(); i++) {
312 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 364 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
313 } 365 }
314 366
315 cfont = f; 367 cfont = f;
316 368
317 TEWidget* te = getTe(); 369 TEWidget* te = getTe();
318 if (te != 0) { 370 if (te != 0) {
319 te->setVTFont(font->getFont()); 371 te->setVTFont(font->getFont());
320 } 372 }
321 } 373 }
322} 374}
323 375
376
324void Konsole::enterCommand(int c) 377void Konsole::enterCommand(int c)
325{ 378{
326 TEWidget* te = getTe(); 379 TEWidget* te = getTe();
327 if (te != 0) { 380 if (te != 0) {
328 QString text = commonCmds[c]; 381 if(!commonCombo->editable()) {
329 te->emitText(text); 382 QString text = commonCombo->text(c); //commonCmds[c];
383 te->emitText(text);
384 } else {
385 changeCommand( commonCombo->text(c), c);
386 }
330 } 387 }
331} 388}
332 389
333void Konsole::hitEnter() 390void Konsole::hitEnter()
334{ 391{
335 TEWidget* te = getTe(); 392 TEWidget* te = getTe();
336 if (te != 0) { 393 if (te != 0) {
337 te->emitText(QString("\r")); 394 te->emitText(QString("\r"));
338 } 395 }
339} 396}
340 397
341void Konsole::hitSpace() 398void Konsole::hitSpace()
342{ 399{
343 TEWidget* te = getTe(); 400 TEWidget* te = getTe();
344 if (te != 0) { 401 if (te != 0) {
345 te->emitText(QString(" ")); 402 te->emitText(QString(" "));
346 } 403 }
347} 404}
348 405
349void Konsole::hitTab() 406void Konsole::hitTab()
350{ 407{
351 TEWidget* te = getTe(); 408 TEWidget* te = getTe();
352 if (te != 0) { 409 if (te != 0) {
353 te->emitText(QString("\t")); 410 te->emitText(QString("\t"));
354 } 411 }
355} 412}
356 413
357void Konsole::hitPaste() 414void Konsole::hitPaste()
358{ 415{
359 TEWidget* te = getTe(); 416 TEWidget* te = getTe();
360 if (te != 0) { 417 if (te != 0) {
361 te->pasteClipboard(); 418 te->pasteClipboard();
362 } 419 }
363} 420}
364 421
365void Konsole::hitUp() 422void Konsole::hitUp()
366{ 423{
367 TEWidget* te = getTe(); 424 TEWidget* te = getTe();
368 if (te != 0) { 425 if (te != 0) {
369 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); 426 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
370 QApplication::sendEvent( te, &ke ); 427 QApplication::sendEvent( te, &ke );
371 } 428 }
372} 429}
373 430
374void Konsole::hitDown() 431void Konsole::hitDown()
375{ 432{
376 TEWidget* te = getTe(); 433 TEWidget* te = getTe();
377 if (te != 0) { 434 if (te != 0) {
378 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); 435 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0);
379 QApplication::sendEvent( te, &ke ); 436 QApplication::sendEvent( te, &ke );
380 } 437 }
381} 438}
382 439
383/** 440/**
384 This function calculates the size of the external widget 441 This function calculates the size of the external widget
385 needed for the internal widget to be 442 needed for the internal widget to be
386 */ 443 */
387QSize Konsole::calcSize(int columns, int lines) { 444QSize Konsole::calcSize(int columns, int lines) {
388 TEWidget* te = getTe(); 445 TEWidget* te = getTe();
389 if (te != 0) { 446 if (te != 0) {
390 QSize size = te->calcSize(columns, lines); 447 QSize size = te->calcSize(columns, lines);
391 return size; 448 return size;
392 } else { 449 } else {
393 QSize size; 450 QSize size;
394 return size; 451 return size;
395 } 452 }
396} 453}
397 454
398/** 455/**
399 sets application window to a size based on columns X lines of the te 456 sets application window to a size based on columns X lines of the te
400 guest widget. Call with (0,0) for setting default size. 457 guest widget. Call with (0,0) for setting default size.
401*/ 458*/
402 459
403void Konsole::setColLin(int columns, int lines) 460void Konsole::setColLin(int columns, int lines)
404{ 461{
405 if ((columns==0) || (lines==0)) 462 if ((columns==0) || (lines==0))
406 { 463 {
407 if (defaultSize.isEmpty()) // not in config file : set default value 464 if (defaultSize.isEmpty()) // not in config file : set default value
408 { 465 {
409 defaultSize = calcSize(80,24); 466 defaultSize = calcSize(80,24);
410 // notifySize(24,80); // set menu items (strange arg order !) 467 // notifySize(24,80); // set menu items (strange arg order !)
411 } 468 }
412 resize(defaultSize); 469 resize(defaultSize);
413 } else { 470 } else {
414 resize(calcSize(columns, lines)); 471 resize(calcSize(columns, lines));
415 // notifySize(lines,columns); // set menu items (strange arg order !) 472 // notifySize(lines,columns); // set menu items (strange arg order !)
416 } 473 }
417} 474}
418 475
419/* 476/*
420void Konsole::setFont(int fontno) 477void Konsole::setFont(int fontno)
421{ 478{
422 QFont f; 479 QFont f;
423 if (fontno == 0) 480 if (fontno == 0)
424 f = defaultFont = QFont( "Helvetica", 12 ); 481 f = defaultFont = QFont( "Helvetica", 12 );
425 else 482 else
426 if (fonts[fontno][0] == '-') 483 if (fonts[fontno][0] == '-')
427 f.setRawName( fonts[fontno] ); 484 f.setRawName( fonts[fontno] );
428 else 485 else
429 { 486 {
430 f.setFamily(fonts[fontno]); 487 f.setFamily(fonts[fontno]);
431 f.setRawMode( TRUE ); 488 f.setRawMode( TRUE );
432 } 489 }
433 if ( !f.exactMatch() && fontno != 0) 490 if ( !f.exactMatch() && fontno != 0)
434 { 491 {
435 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); 492 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]);
436 QMessageBox(this, msg); 493 QMessageBox(this, msg);
437 return; 494 return;
438 } 495 }
439 if (se) se->setFontNo(fontno); 496 if (se) se->setFontNo(fontno);
440 te->setVTFont(f); 497 te->setVTFont(f);
441 n_font = fontno; 498 n_font = fontno;
442} 499}
443*/ 500*/
444 501
445// --| color selection |------------------------------------------------------- 502// --| color selection |-------------------------------------------------------
446 503
447void Konsole::changeColumns(int columns) 504void Konsole::changeColumns(int columns)
448{ 505{
449 TEWidget* te = getTe(); 506 TEWidget* te = getTe();
450 if (te != 0) { 507 if (te != 0) {
451 setColLin(columns,te->Lines()); 508 setColLin(columns,te->Lines());
452 te->update(); 509 te->update();
453 } 510 }
454} 511}
455 512
456//FIXME: If a child dies during session swap, 513//FIXME: If a child dies during session swap,
457// this routine might be called before 514// this routine might be called before
458// session swap is completed. 515// session swap is completed.
459 516
460void Konsole::doneSession(TESession*, int ) 517void Konsole::doneSession(TESession*, int )
461{ 518{
462 TEWidget *te = getTe(); 519 TEWidget *te = getTe();
463 if (te != 0) { 520 if (te != 0) {
464 te->currentSession->setConnect(FALSE); 521 te->currentSession->setConnect(FALSE);
465 tab->removeTab(te); 522 tab->removeTab(te);
466 delete te->currentSession; 523 delete te->currentSession;
467 delete te; 524 delete te;
468 nsessions--; 525 nsessions--;
469 } 526 }
470 527
471 if (nsessions == 0) { 528 if (nsessions == 0) {
472 close(); 529 close();
473 } 530 }
474} 531}
475 532
476
477void Konsole::newSession() { 533void Konsole::newSession() {
478 TEWidget* te = new TEWidget(tab); 534 if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory?
479 te->setBackgroundMode(PaletteBase); 535 TEWidget* te = new TEWidget(tab);
480 te->setVTFont(fonts.at(cfont)->getFont()); 536// te->setBackgroundMode(PaletteBase); //we want transparent!!
481 tab->addTab(te); 537 te->setVTFont(fonts.at(cfont)->getFont());
482 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); 538 tab->addTab(te);
483 te->currentSession = se; 539 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
484 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); 540 te->currentSession = se;
485 se->run(); 541 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) );
486 se->setConnect(TRUE); 542 se->run();
487 se->setHistory(b_scroll); 543 se->setConnect(TRUE);
488 tab->setCurrentPage(nsessions); 544 se->setHistory(b_scroll);
489 nsessions++; 545 tab->setCurrentPage(nsessions);
546 nsessions++;
547 setColor();
548 }
490} 549}
491 550
492TEWidget* Konsole::getTe() { 551TEWidget* Konsole::getTe() {
493 if (nsessions) { 552 if (nsessions) {
494 return (TEWidget *) tab->currentPage(); 553 return (TEWidget *) tab->currentPage();
495 } else { 554 } else {
496 return 0; 555 return 0;
497 } 556 }
498 } 557}
499 558
500void Konsole::switchSession(QWidget* w) { 559void Konsole::switchSession(QWidget* w) {
501 TEWidget* te = (TEWidget *) w; 560 TEWidget* te = (TEWidget *) w;
502 561
503 QFont teFnt = te->getVTFont(); 562 QFont teFnt = te->getVTFont();
504 for(uint i = 0; i < fonts.count(); i++) { 563 for(uint i = 0; i < fonts.count(); i++) {
505 VTFont *fnt = fonts.at(i); 564 VTFont *fnt = fonts.at(i);
506 bool cf = fnt->getFont() == teFnt; 565 bool cf = fnt->getFont() == teFnt;
507 fontList->setItemChecked(i, cf); 566 fontList->setItemChecked(i, cf);
508 if (cf) { 567 if (cf) {
509 cfont = i; 568 cfont = i;
510 } 569 }
511 } 570 }
512} 571}
572
573/// ------------------------------- some new stuff by L.J. Potter
574void Konsole::colorMenuSelected(int iD)
575{ // this is NOT pretty, elegant or anything else besides functional
576// QString temp;
577// temp.sprintf("%d", iD);
578// qDebug(temp);
579 TEWidget* te = getTe();
580 Config cfg("Konsole");
581 cfg.setGroup("Colors");
582 QColor foreground;
583 QColor background;
584 colorMenu->setItemChecked(lastSelectedMenu,FALSE);
585 ColorEntry m_table[TABLE_COLORS];
586 const ColorEntry * defaultCt=te->getdefaultColorTable();
587 /////////// fore back
588 int i;
589 if(iD==-8) { // default default
590 for (i = 0; i < TABLE_COLORS; i++) {
591 m_table[i].color = defaultCt[i].color;
592 if(i==1 || i == 11)
593 m_table[i].transparent=1;
594 cfg.writeEntry("Schema","8");
595 colorMenu->setItemChecked(-8,TRUE);
596 }
597 } else {
598 if(iD==-5) { // green black
599 foreground.setRgb(0x18,255,0x18);
600 background.setRgb(0x00,0x00,0x00);
601 cfg.writeEntry("Schema","5");
602 colorMenu->setItemChecked(-5,TRUE);
603 }
604 if(iD==-6) { // black white
605 foreground.setRgb(0x00,0x00,0x00);
606 background.setRgb(0xFF,0xFF,0xFF);
607 cfg.writeEntry("Schema","6");
608 colorMenu->setItemChecked(-6,TRUE);
609 }
610 if(iD==-7) { // white black
611 foreground.setRgb(0xFF,0xFF,0xFF);
612 background.setRgb(0x00,0x00,0x00);
613 cfg.writeEntry("Schema","7");
614 colorMenu->setItemChecked(-7,TRUE);
615 }
616 if(iD==-9) {// Black, Red
617 foreground.setRgb(0x00,0x00,0x00);
618 background.setRgb(0xB2,0x18,0x18);
619 cfg.writeEntry("Schema","9");
620 colorMenu->setItemChecked(-9,TRUE);
621 }
622 if(iD==-10) {// Red, Black
623 foreground.setRgb(230,31,31); //0xB2,0x18,0x18
624 background.setRgb(0x00,0x00,0x00);
625 cfg.writeEntry("Schema","10");
626 colorMenu->setItemChecked(-10,TRUE);
627 }
628 if(iD==-11) {// Green, Yellow - is ugly
629// foreground.setRgb(0x18,0xB2,0x18);
630 foreground.setRgb(36,139,10);
631// background.setRgb(0xB2,0x68,0x18);
632 background.setRgb(255,255,0);
633 cfg.writeEntry("Schema","11");
634 colorMenu->setItemChecked(-11,TRUE);
635 }
636 if(iD==-12) {// Blue, Magenta
637 foreground.setRgb(0x18,0xB2,0xB2);
638 background.setRgb(0x18,0x18,0xB2);
639 cfg.writeEntry("Schema","12");
640 colorMenu->setItemChecked(-12,TRUE);
641 }
642 if(iD==-13) {// Magenta, Blue
643 foreground.setRgb(0x18,0x18,0xB2);
644 background.setRgb(0x18,0xB2,0xB2);
645 cfg.writeEntry("Schema","13");
646 colorMenu->setItemChecked(-13,TRUE);
647 }
648 if(iD==-14) {// Cyan, White
649 foreground.setRgb(0x18,0xB2,0xB2);
650 background.setRgb(0xFF,0xFF,0xFF);
651 cfg.writeEntry("Schema","14");
652 colorMenu->setItemChecked(-14,TRUE);
653 }
654 if(iD==-15) {// White, Cyan
655 background.setRgb(0x18,0xB2,0xB2);
656 foreground.setRgb(0xFF,0xFF,0xFF);
657 cfg.writeEntry("Schema","15");
658 colorMenu->setItemChecked(-15,TRUE);
659 }
660 if(iD==-16) {// Black, Blue
661 background.setRgb(0x00,0x00,0x00);
662 foreground.setRgb(0x18,0xB2,0xB2);
663 cfg.writeEntry("Schema","16");
664 colorMenu->setItemChecked(-16,TRUE);
665 }
666
667 for (i = 0; i < TABLE_COLORS; i++) {
668 if(i==0 || i == 10) {
669 m_table[i].color = foreground;
670 }
671 else if(i==1 || i == 11) {
672 m_table[i].color = background; m_table[i].transparent=0;
673 }
674 else
675 m_table[i].color = defaultCt[i].color;
676 }
677 }
678 lastSelectedMenu = iD;
679 te->setColorTable(m_table);
680// update();
681}
682
683void Konsole::configMenuSelected(int iD)
684{
685// QString temp;
686// temp.sprintf("%d",iD);
687// qDebug(temp);
688 TEWidget* te = getTe();
689 Config cfg("Konsole");
690 cfg.setGroup("Menubar");
691 if( iD == -2) {
692 if(!secondToolBar->isHidden()) {
693 secondToolBar->hide();
694 configMenu->changeItem( iD,"Show Command List");
695 cfg.writeEntry("Hidden","TRUE");
696 configMenu->setItemEnabled(-20 ,FALSE);
697 } else {
698 secondToolBar->show();
699 configMenu->changeItem( iD,"Hide Command List");
700 cfg.writeEntry("Hidden","FALSE");
701 configMenu->setItemEnabled(-20 ,TRUE);
702
703 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") {
704 configMenu->setItemChecked(-16,TRUE);
705 commonCombo->setEditable( TRUE );
706 } else {
707 configMenu->setItemChecked(-20,FALSE);
708 commonCombo->setEditable( FALSE );
709 }
710 }
711 }
712 if( iD == -3) {
713 cfg.setGroup("Tabs");
714 QString tmp=cfg.readEntry("Position","Top");
715
716 if(tmp=="Top") {
717 tab->setTabPosition(QTabWidget::Bottom);
718 configMenu->changeItem( iD,"Tabs on Top");
719 cfg.writeEntry("Position","Bottom");
720 } else {
721 tab->setTabPosition(QTabWidget::Top);
722 configMenu->changeItem( iD,"Tabs on Bottom");
723 cfg.writeEntry("Position","Top");
724 }
725 }
726 if( iD == -20) {
727 cfg.setGroup("Commands");
728// qDebug("enableCommandEdit");
729 if( !configMenu->isItemChecked(iD) ) {
730 commonCombo->setEditable( TRUE );
731 configMenu->setItemChecked(iD,TRUE);
732 commonCombo->setCurrentItem(0);
733 cfg.writeEntry("EditEnabled","TRUE");
734 } else {
735 commonCombo->setEditable( FALSE );
736 configMenu->setItemChecked(iD,FALSE);
737 cfg.writeEntry("EditEnabled","FALSE");
738 commonCombo->setFocusPolicy(QWidget::NoFocus);
739 te->setFocus();
740 }
741 }
742}
743
744void Konsole::changeCommand(const QString &text, int c)
745{
746 Config cfg("Konsole");
747 cfg.setGroup("Commands");
748 if(commonCmds[c] != text) {
749 cfg.writeEntry(QString::number(c),text);
750 commonCombo->clearEdit();
751 commonCombo->setCurrentItem(c);
752 }
753}
754
755void Konsole::setColor()
756{
757 Config cfg("Konsole");
758 cfg.setGroup("Colors");
759 int scheme = cfg.readNumEntry("Schema",1);
760 if(scheme != 1) colorMenuSelected( -scheme);
761
762}
diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h
index 819ea5d..40003d4 100644
--- a/core/apps/embeddedkonsole/konsole.h
+++ b/core/apps/embeddedkonsole/konsole.h
@@ -1,125 +1,131 @@
1/* ----------------------------------------------------------------------- */ 1/* ----------------------------------------------------------------------- */
2/* */ 2/* */
3/* [konsole.h] Konsole */ 3/* [konsole.h] Konsole */
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. */ 9/* This file is part of Konsole, an X terminal. */
10/* */ 10/* */
11/* The material contained in here more or less directly orginates from */ 11/* The material contained in here more or less directly orginates from */
12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ 12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
13/* */ 13/* */
14/* -------------------------------------------------------------------------- */ 14/* -------------------------------------------------------------------------- */
15 /* */ 15/* */
16/* Ported Konsole to Qt/Embedded */ 16/* Ported Konsole to Qt/Embedded */
17 /* */ 17/* */
18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
19 /* */ 19/* */
20/* -------------------------------------------------------------------------- */ 20/* -------------------------------------------------------------------------- */
21 21
22#ifndef KONSOLE_H 22#ifndef KONSOLE_H
23#define KONSOLE_H 23#define KONSOLE_H
24 24
25 25
26#include <qmainwindow.h> 26#include <qmainwindow.h>
27#include <qaction.h> 27#include <qaction.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qstrlist.h> 29#include <qstrlist.h>
30#include <qintdict.h> 30#include <qintdict.h>
31#include <qptrdict.h> 31#include <qptrdict.h>
32#include <qtabwidget.h> 32#include <qtabwidget.h>
33#include <qpe/qpetoolbar.h>
34#include <qcombobox.h>
33 35
34#include "MyPty.h" 36#include "MyPty.h"
35#include "TEWidget.h" 37#include "TEWidget.h"
36#include "TEmuVt102.h" 38#include "TEmuVt102.h"
37#include "session.h" 39#include "session.h"
38 40
39class EKNumTabWidget; 41class EKNumTabWidget;
40 42
41class Konsole : public QMainWindow 43class Konsole : public QMainWindow
42{ 44{
43Q_OBJECT 45Q_OBJECT
44 46
45public: 47public:
46 48
47 Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); 49 Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
48 Konsole(const char * name, const char* pgm, QStrList & _args, int histon); 50 Konsole(const char * name, const char* pgm, QStrList & _args, int histon);
49 ~Konsole(); 51 ~Konsole();
50 void setColLin(int columns, int lines); 52 void setColLin(int columns, int lines);
51 53 QPEToolBar *secondToolBar;
52 void show(); 54 void show();
53 55 void setColor();
56 int lastSelectedMenu;
54private slots: 57private slots:
55 void doneSession(TESession*,int); 58 void doneSession(TESession*,int);
56 void changeColumns(int); 59 void changeColumns(int);
57 void fontChanged(int); 60 void fontChanged(int);
61 void configMenuSelected(int );
62 void colorMenuSelected(int);
58 void enterCommand(int); 63 void enterCommand(int);
59 void hitEnter(); 64 void hitEnter();
60 void hitSpace(); 65 void hitSpace();
61 void hitTab(); 66 void hitTab();
62 void hitPaste(); 67 void hitPaste();
63 void hitUp(); 68 void hitUp();
64 void hitDown(); 69 void hitDown();
65 void switchSession(QWidget *); 70 void switchSession(QWidget *);
66 void newSession(); 71 void newSession();
72 void changeCommand(const QString &, int);
67 73
68private: 74private:
69 void init(const char* _pgm, QStrList & _args); 75 void init(const char* _pgm, QStrList & _args);
70 void initSession(const char* _pgm, QStrList & _args); 76 void initSession(const char* _pgm, QStrList & _args);
71 void runSession(TESession* s); 77 void runSession(TESession* s);
72 void setColorPixmaps(); 78 void setColorPixmaps();
73 void setHistory(bool); 79 void setHistory(bool);
74 QSize calcSize(int columns, int lines); 80 QSize calcSize(int columns, int lines);
75 TEWidget* getTe(); 81 TEWidget* getTe();
76 82
77private: 83private:
78 class VTFont 84 class VTFont
79 { 85 {
80 public: 86 public:
81 VTFont(QString name, QFont& font) 87 VTFont(QString name, QFont& font)
82 { 88 {
83 this->name = name; 89 this->name = name;
84 this->font = font; 90 this->font = font;
85 } 91 }
86 92
87 QFont& getFont() 93 QFont& getFont()
88 { 94 {
89 return font; 95 return font;
90 } 96 }
91 97
92 QString getName() 98 QString getName()
93 { 99 {
94 return name; 100 return name;
95 } 101 }
96 102
97 private: 103 private:
98 QString name; 104 QString name;
99 QFont font; 105 QFont font;
100 }; 106 };
101 107
102 EKNumTabWidget* tab; 108 EKNumTabWidget* tab;
103 int nsessions; 109 int nsessions;
104 QList<VTFont> fonts; 110 QList<VTFont> fonts;
105 int cfont; 111 int cfont;
106 QCString se_pgm; 112 QCString se_pgm;
107 QStrList se_args; 113 QStrList se_args;
108 114
109 QPopupMenu* fontList; 115 QPopupMenu* fontList,*configMenu,*colorMenu;
110 116 QComboBox *commonCombo;
111 // history scrolling I think 117 // history scrolling I think
112 bool b_scroll; 118 bool b_scroll;
113 119
114 int n_keytab; 120 int n_keytab;
115 int n_scroll; 121 int n_scroll;
116 int n_render; 122 int n_render;
117 QString pmPath; // pixmap path 123 QString pmPath; // pixmap path
118 QString dropText; 124 QString dropText;
119 QFont defaultFont; 125 QFont defaultFont;
120 QSize defaultSize; 126 QSize defaultSize;
121 127
122}; 128};
123 129
124#endif 130#endif
125 131