summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TEHistory.h6
-rw-r--r--core/apps/embeddedkonsole/TEScreen.h14
-rw-r--r--core/apps/embeddedkonsole/TEWidget.cpp5
-rw-r--r--core/apps/embeddedkonsole/TEmulation.h7
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp90
-rw-r--r--core/apps/embeddedkonsole/konsole.h1
6 files changed, 83 insertions, 40 deletions
diff --git a/core/apps/embeddedkonsole/TEHistory.h b/core/apps/embeddedkonsole/TEHistory.h
index 8339ec6..11eb150 100644
--- a/core/apps/embeddedkonsole/TEHistory.h
+++ b/core/apps/embeddedkonsole/TEHistory.h
@@ -1,75 +1,75 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [TEHistory.H] History Buffer */ 3/* [TEHistory.H] History Buffer */
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#ifndef TEHISTORY_H 19#ifndef TEHISTORY_H
20#define TEHISTORY_H 20#define TEHISTORY_H
21 21
22#include "TECommon.h" 22#include "TECommon.h"
23 23
24/* 24/*
25 An extendable tmpfile(1) based buffer. 25 An extendable tmpfile(1) based buffer.
26*/ 26*/
27class HistoryBuffer 27class HistoryBuffer
28{ 28{
29public: 29public:
30 HistoryBuffer(); 30 HistoryBuffer();
31 ~HistoryBuffer(); 31 ~HistoryBuffer();
32 32
33public: 33public:
34 void setScroll(bool on); 34 void setScroll(bool on);
35 bool hasScroll(); 35 bool hasScroll();
36 36
37public: 37public:
38 void add(const unsigned char* bytes, int len); 38 void add(const unsigned char* bytes, int len);
39 void get(unsigned char* bytes, int len, int loc); 39 void get(unsigned char* bytes, int len, int loc);
40 int len(); 40 int len();
41 41
42private: 42private:
43 int ion; 43 int ion;
44 int length; 44 int length;
45}; 45};
46 46
47class HistoryScroll 47class HistoryScroll
48{ 48{
49public: 49public:
50 HistoryScroll(); 50 HistoryScroll();
51 ~HistoryScroll(); 51 ~HistoryScroll();
52 52
53public: 53public:
54 void setScroll(bool on); 54 void setScroll(bool on);
55 bool hasScroll(); 55 bool hasScroll();
56 56
57public: // access to history 57public: // access to history
58 int getLines(); 58 int getLines();
59 int getLineLen(int lineno); 59 int getLineLen(int lineno);
60 void getCells(int lineno, int colno, int count, ca res[]); 60 void getCells(int lineno, int colno, int count, ca res[]);
61 61
62public: // backward compatibility (obsolete) 62public: // backward compatibility (obsolete)
63 ca getCell(int lineno, int colno) { ca res; getCells(lineno,colno,1,&res); return res; } 63 ca getCell(int lineno, int colno) { ca res; getCells(lineno,colno,1,&res); return res; }
64 64
65public: // adding lines. 65public: // adding lines.
66 void addCells(ca a[], int count); 66 void addCells(ca a[], int count);
67 void addLine(); 67 void addLine();
68 68
69private: 69private:
70 int startOfLine(int lineno); 70 int startOfLine(int lineno);
71 HistoryBuffer index; // lines Row(int) 71 HistoryBuffer index; // lines Row(int)
72 HistoryBuffer cells; // text Row(ca) 72 HistoryBuffer cells; // text Row(ca)
73}; 73};
74 74
75#endif // TEHISTORY_H 75#endif // TEHISTORY_H
diff --git a/core/apps/embeddedkonsole/TEScreen.h b/core/apps/embeddedkonsole/TEScreen.h
index ba47ee5..a28f7c5 100644
--- a/core/apps/embeddedkonsole/TEScreen.h
+++ b/core/apps/embeddedkonsole/TEScreen.h
@@ -1,259 +1,267 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [te_screen.h] Screen Data Type */ 3/* [te_screen.h] Screen Data Type */
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#ifndef TESCREEN_H 19#ifndef TESCREEN_H
20#define TESCREEN_H 20#define TESCREEN_H
21 21
22/*! \file 22/*! \file
23*/ 23*/
24 24
25#include "TECommon.h" 25#include "TECommon.h"
26#include "TEHistory.h" 26#include "TEHistory.h"
27 27
28#define MODE_Origin 0 28#define MODE_Origin 0
29#define MODE_Wrap 1 29#define MODE_Wrap 1
30#define MODE_Insert 2 30#define MODE_Insert 2
31#define MODE_Screen 3 31#define MODE_Screen 3
32#define MODE_Cursor 4 32#define MODE_Cursor 4
33#define MODE_NewLine 5 33#define MODE_NewLine 5
34#define MODES_SCREEN 6 34#define MODES_SCREEN 6
35 35
36/*! 36/*!
37*/ 37*/
38struct ScreenParm 38struct ScreenParm
39{ 39{
40 int mode[MODES_SCREEN]; 40 int mode[MODES_SCREEN];
41}; 41};
42 42
43 43
44class TEScreen 44class TEScreen
45{ 45{
46public: 46public:
47 TEScreen(int lines, int columns); 47 TEScreen(int lines, int columns);
48 ~TEScreen(); 48 ~TEScreen();
49 49
50public: // these are all `Screen' operations 50public: // these are all `Screen' operations
51 // 51 //
52 // VT100/2 Operations ------------------ 52 // VT100/2 Operations ------------------
53 // 53 //
54 // Cursor Movement 54 // Cursor Movement
55 // 55 //
56 void cursorUp (int n); 56 void cursorUp (int n);
57 void cursorDown (int n); 57 void cursorDown (int n);
58 void cursorLeft (int n); 58 void cursorLeft (int n);
59 void cursorRight (int n); 59 void cursorRight (int n);
60 void setCursorY (int y); 60 void setCursorY (int y);
61 void setCursorX (int x); 61 void setCursorX (int x);
62 void setCursorYX (int y, int x); 62 void setCursorYX (int y, int x);
63 void setMargins (int t, int b); 63 void setMargins (int t, int b);
64 // 64 //
65 // Cursor Movement with Scrolling 65 // Cursor Movement with Scrolling
66 // 66 //
67 void NewLine (); 67 void NewLine ();
68 void NextLine (); 68 void NextLine ();
69 void index (); 69 void index ();
70 void reverseIndex(); 70 void reverseIndex();
71 // 71 //
72 void Return (); 72 void Return ();
73 void BackSpace (); 73 void BackSpace ();
74 void Tabulate (); 74 void Tabulate ();
75 // 75 //
76 // Editing 76 // Editing
77 // 77 //
78 void eraseChars (int n); 78 void eraseChars (int n);
79 void deleteChars (int n); 79 void deleteChars (int n);
80 void insertChars (int n); 80 void insertChars (int n);
81 void deleteLines (int n); 81 void deleteLines (int n);
82 void insertLines (int n); 82 void insertLines (int n);
83 // 83 //
84 // ------------------------------------- 84 // -------------------------------------
85 // 85 //
86 void clearTabStops(); 86 void clearTabStops();
87 void changeTabStop(bool set); 87 void changeTabStop(bool set);
88 // 88 //
89 void resetMode (int n); 89 void resetMode (int n);
90 void setMode (int n); 90 void setMode (int n);
91 void saveMode (int n); 91 void saveMode (int n);
92 void restoreMode (int n); 92 void restoreMode (int n);
93 // 93 //
94 void saveCursor (); 94 void saveCursor ();
95 void restoreCursor(); 95 void restoreCursor();
96 // 96 //
97 // ------------------------------------- 97 // -------------------------------------
98 // 98 //
99 void clearEntireScreen(); 99 void clearEntireScreen();
100 void clearToEndOfScreen(); 100 void clearToEndOfScreen();
101 void clearToBeginOfScreen(); 101 void clearToBeginOfScreen();
102 // 102 //
103 void clearEntireLine(); 103 void clearEntireLine();
104 void clearToEndOfLine(); 104 void clearToEndOfLine();
105 void clearToBeginOfLine(); 105 void clearToBeginOfLine();
106 // 106 //
107 void helpAlign (); 107 void helpAlign ();
108 // 108 //
109 // ------------------------------------- 109 // -------------------------------------
110 // 110 //
111 void setRendition (int rendition); 111 void setRendition (int rendition);
112 void resetRendition(int rendition); 112 void resetRendition(int rendition);
113 void setForeColor (int fgcolor); 113 void setForeColor (int fgcolor);
114 void setBackColor (int bgcolor); 114 void setBackColor (int bgcolor);
115 // 115 //
116 void setDefaultRendition(); 116 void setDefaultRendition();
117 void setForeColorToDefault(); 117 void setForeColorToDefault();
118 void setBackColorToDefault(); 118 void setBackColorToDefault();
119 // 119 //
120 // ------------------------------------- 120 // -------------------------------------
121 // 121 //
122 BOOL getMode (int n); 122 BOOL getMode (int n);
123 // 123 //
124 // only for report cursor position 124 // only for report cursor position
125 // 125 //
126 int getCursorX(); 126 int getCursorX();
127 int getCursorY(); 127 int getCursorY();
128 // 128 //
129 // ------------------------------------- 129 // -------------------------------------
130 // 130 //
131 void clear(); 131 void clear();
132 void home(); 132 void home();
133 void reset(); 133 void reset();
134 // 134 //
135 void ShowCharacter(unsigned short c); 135 void ShowCharacter(unsigned short c);
136 // 136 //
137 void resizeImage(int new_lines, int new_columns); 137 void resizeImage(int new_lines, int new_columns);
138 // 138 //
139 ca* getCookedImage(); 139 ca* getCookedImage();
140 140
141 /*! return the number of lines. */ 141 /*! return the number of lines. */
142 int getLines() { return lines; } 142 int getLines() { return lines; }
143
143 /*! return the number of columns. */ 144 /*! return the number of columns. */
144 int getColumns() { return columns; } 145 int getColumns() { return columns; }
145 146
146 /*! set the position of the history cursor. */ 147 /*! set the position of the history cursor. */
147 void setHistCursor(int cursor); 148 void setHistCursor(int cursor);
148 /*! return the position of the history cursor. */ 149 /*! return the position of the history cursor. */
149 int getHistCursor(); 150 int getHistCursor();
150 151
152 /*! set the position of the horizontal cursor. */
153 void setHorzCursor(int cursor);
154 /*! return the position of the horizontal cursor. */
155 int getHorzCursor();
156
151 int getHistLines (); 157 int getHistLines ();
152 void setScroll(bool on); 158 void setScroll(bool on);
153 bool hasScroll(); 159 bool hasScroll();
154 160
155 // 161 //
156 // Selection 162 // Selection
157 // 163 //
158 void setSelBeginXY(const int x, const int y); 164 void setSelBeginXY(const int x, const int y);
159 void setSelExtentXY(const int x, const int y); 165 void setSelExtentXY(const int x, const int y);
160 void clearSelection(); 166 void clearSelection();
161 QString getSelText(const BOOL preserve_line_breaks); 167 QString getSelText(const BOOL preserve_line_breaks);
162 168
163 void checkSelection(int from, int to); 169 void checkSelection(int from, int to);
164 170
165private: // helper 171private: // helper
166 172
167 void clearImage(int loca, int loce, char c); 173 void clearImage(int loca, int loce, char c);
168 void moveImage(int dst, int loca, int loce); 174 void moveImage(int dst, int loca, int loce);
169 175
170 void scrollUp(int from, int i); 176 void scrollUp(int from, int i);
171 void scrollDown(int from, int i); 177 void scrollDown(int from, int i);
172 178
173 void addHistLine(); 179 void addHistLine();
174 180
175 void initTabStops(); 181 void initTabStops();
176 182
177 void effectiveRendition(); 183 void effectiveRendition();
178 void reverseRendition(ca* p); 184 void reverseRendition(ca* p);
179 185
180private: 186private:
181 187
182 /* 188 /*
183 The state of the screen is more complex as one would 189 The state of the screen is more complex as one would
184 expect first. The screem does really do part of the 190 expect first. The screem does really do part of the
185 emulation providing state informations in form of modes, 191 emulation providing state informations in form of modes,
186 margins, tabulators, cursor etc. 192 margins, tabulators, cursor etc.
187 193
188 Even more unexpected are variables to save and restore 194 Even more unexpected are variables to save and restore
189 parts of the state. 195 parts of the state.
190 */ 196 */
191 197
192 // screen image ---------------- 198 // screen image ----------------
193 199
194 int lines; 200 int lines;
195 int columns; 201 int columns;
196 ca *image; // [lines][columns] 202 ca *image; // [lines][columns]
197 203
198 // history buffer --------------- 204 // history buffer ---------------
199 205
200 int histCursor; // display position relative to start of the history buffer 206 int histCursor; // display position relative to start of the history buffer
201 HistoryScroll hist; 207 HistoryScroll hist;
208
209 int horzCursor;
202 210
203 // cursor location 211 // cursor location
204 212
205 int cuX; 213 int cuX;
206 int cuY; 214 int cuY;
207 215
208 // cursor color and rendition info 216 // cursor color and rendition info
209 217
210 UINT8 cu_fg; // foreground 218 UINT8 cu_fg; // foreground
211 UINT8 cu_bg; // background 219 UINT8 cu_bg; // background
212 UINT8 cu_re; // rendition 220 UINT8 cu_re; // rendition
213 221
214 // margins ---------------- 222 // margins ----------------
215 223
216 int tmargin; // top margin 224 int tmargin; // top margin
217 int bmargin; // bottom margin 225 int bmargin; // bottom margin
218 226
219 // states ---------------- 227 // states ----------------
220 228
221 ScreenParm currParm; 229 ScreenParm currParm;
222 230
223 // ---------------------------- 231 // ----------------------------
224 232
225 bool* tabstops; 233 bool* tabstops;
226 234
227 // selection ------------------- 235 // selection -------------------
228 236
229 int sel_begin; // The first location selected. 237 int sel_begin; // The first location selected.
230 int sel_TL; // TopLeft Location. 238 int sel_TL; // TopLeft Location.
231 int sel_BR; // Bottom Right Location. 239 int sel_BR; // Bottom Right Location.
232 240
233 // effective colors and rendition ------------ 241 // effective colors and rendition ------------
234 242
235 UINT8 ef_fg; // These are derived from 243 UINT8 ef_fg; // These are derived from
236 UINT8 ef_bg; // the cu_* variables above 244 UINT8 ef_bg; // the cu_* variables above
237 UINT8 ef_re; // to speed up operation 245 UINT8 ef_re; // to speed up operation
238 246
239 // 247 //
240 // save cursor, rendition & states ------------ 248 // save cursor, rendition & states ------------
241 // 249 //
242 250
243 // cursor location 251 // cursor location
244 252
245 int sa_cuX; 253 int sa_cuX;
246 int sa_cuY; 254 int sa_cuY;
247 255
248 // rendition info 256 // rendition info
249 257
250 UINT8 sa_cu_re; 258 UINT8 sa_cu_re;
251 UINT8 sa_cu_fg; 259 UINT8 sa_cu_fg;
252 UINT8 sa_cu_bg; 260 UINT8 sa_cu_bg;
253 261
254 // modes 262 // modes
255 263
256 ScreenParm saveParm; 264 ScreenParm saveParm;
257}; 265};
258 266
259#endif // TESCREEN_H 267#endif // TESCREEN_H
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp
index c10c7a8..60021f4 100644
--- a/core/apps/embeddedkonsole/TEWidget.cpp
+++ b/core/apps/embeddedkonsole/TEWidget.cpp
@@ -143,385 +143,386 @@ const ColorEntry* TEWidget::getColorTable() const
143{ 143{
144 return color_table; 144 return color_table;
145} 145}
146 146
147const ColorEntry* TEWidget::getdefaultColorTable() const 147const ColorEntry* TEWidget::getdefaultColorTable() const
148{ 148{
149 return base_color_table; 149 return base_color_table;
150} 150}
151 151
152 152
153const QPixmap *TEWidget::backgroundPixmap() 153const QPixmap *TEWidget::backgroundPixmap()
154{ 154{
155 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); 155 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm");
156 const QPixmap *pm = bg; 156 const QPixmap *pm = bg;
157 return pm; 157 return pm;
158} 158}
159 159
160void TEWidget::setColorTable(const ColorEntry table[]) 160void TEWidget::setColorTable(const ColorEntry table[])
161{ 161{
162 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; 162 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i];
163 163
164 const QPixmap* pm = backgroundPixmap(); 164 const QPixmap* pm = backgroundPixmap();
165 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); 165 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color);
166 update(); 166 update();
167} 167}
168 168
169//FIXME: add backgroundPixmapChanged. 169//FIXME: add backgroundPixmapChanged.
170 170
171/* ------------------------------------------------------------------------- */ 171/* ------------------------------------------------------------------------- */
172/* */ 172/* */
173/* Font */ 173/* Font */
174/* */ 174/* */
175/* ------------------------------------------------------------------------- */ 175/* ------------------------------------------------------------------------- */
176 176
177/* 177/*
178 The VT100 has 32 special graphical characters. The usual vt100 extended 178 The VT100 has 32 special graphical characters. The usual vt100 extended
179 xterm fonts have these at 0x00..0x1f. 179 xterm fonts have these at 0x00..0x1f.
180 180
181 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals 181 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals
182 come in here as proper unicode characters. 182 come in here as proper unicode characters.
183 183
184 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping 184 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping
185 from unicode to 0x00..0x1f. The remaining translation is then left to the 185 from unicode to 0x00..0x1f. The remaining translation is then left to the
186 QCodec. 186 QCodec.
187*/ 187*/
188 188
189// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. 189// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i.
190 190
191unsigned short vt100_graphics[32] = 191unsigned short vt100_graphics[32] =
192{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 192{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15
193 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 193 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0,
194 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 194 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
195 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 195 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534,
196 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 196 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7
197}; 197};
198 198
199static QChar vt100extended(QChar c) 199static QChar vt100extended(QChar c)
200{ 200{
201 switch (c.unicode()) 201 switch (c.unicode())
202 { 202 {
203 case 0x25c6 : return 1; 203 case 0x25c6 : return 1;
204 case 0x2592 : return 2; 204 case 0x2592 : return 2;
205 case 0x2409 : return 3; 205 case 0x2409 : return 3;
206 case 0x240c : return 4; 206 case 0x240c : return 4;
207 case 0x240d : return 5; 207 case 0x240d : return 5;
208 case 0x240a : return 6; 208 case 0x240a : return 6;
209 case 0x00b0 : return 7; 209 case 0x00b0 : return 7;
210 case 0x00b1 : return 8; 210 case 0x00b1 : return 8;
211 case 0x2424 : return 9; 211 case 0x2424 : return 9;
212 case 0x240b : return 10; 212 case 0x240b : return 10;
213 case 0x2518 : return 11; 213 case 0x2518 : return 11;
214 case 0x2510 : return 12; 214 case 0x2510 : return 12;
215 case 0x250c : return 13; 215 case 0x250c : return 13;
216 case 0x2514 : return 14; 216 case 0x2514 : return 14;
217 case 0x253c : return 15; 217 case 0x253c : return 15;
218 case 0xf800 : return 16; 218 case 0xf800 : return 16;
219 case 0xf801 : return 17; 219 case 0xf801 : return 17;
220 case 0x2500 : return 18; 220 case 0x2500 : return 18;
221 case 0xf803 : return 19; 221 case 0xf803 : return 19;
222 case 0xf804 : return 20; 222 case 0xf804 : return 20;
223 case 0x251c : return 21; 223 case 0x251c : return 21;
224 case 0x2524 : return 22; 224 case 0x2524 : return 22;
225 case 0x2534 : return 23; 225 case 0x2534 : return 23;
226 case 0x252c : return 24; 226 case 0x252c : return 24;
227 case 0x2502 : return 25; 227 case 0x2502 : return 25;
228 case 0x2264 : return 26; 228 case 0x2264 : return 26;
229 case 0x2265 : return 27; 229 case 0x2265 : return 27;
230 case 0x03c0 : return 28; 230 case 0x03c0 : return 28;
231 case 0x2260 : return 29; 231 case 0x2260 : return 29;
232 case 0x00a3 : return 30; 232 case 0x00a3 : return 30;
233 case 0x00b7 : return 31; 233 case 0x00b7 : return 31;
234 } 234 }
235 return c; 235 return c;
236} 236}
237 237
238static QChar identicalMap(QChar c) 238static QChar identicalMap(QChar c)
239{ 239{
240 return c; 240 return c;
241} 241}
242 242
243void TEWidget::fontChange(const QFont &) 243void TEWidget::fontChange(const QFont &)
244{ 244{
245 QFontMetrics fm(font()); 245 QFontMetrics fm(font());
246 font_h = fm.height(); 246 font_h = fm.height();
247 font_w = fm.maxWidth(); 247 font_w = fm.maxWidth();
248 font_a = fm.ascent(); 248 font_a = fm.ascent();
249//printf("font_h: %d\n",font_h); 249//printf("font_h: %d\n",font_h);
250//printf("font_w: %d\n",font_w); 250//printf("font_w: %d\n",font_w);
251//printf("font_a: %d\n",font_a); 251//printf("font_a: %d\n",font_a);
252//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); 252//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii());
253//printf("rawname: %s\n",font().rawName().ascii()); 253//printf("rawname: %s\n",font().rawName().ascii());
254 fontMap = 254 fontMap =
255#if QT_VERSION < 300 255#if QT_VERSION < 300
256 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") 256 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646")
257 ? vt100extended 257 ? vt100extended
258 : 258 :
259#endif 259#endif
260 identicalMap; 260 identicalMap;
261 propagateSize(); 261 propagateSize();
262 update(); 262 update();
263} 263}
264 264
265void TEWidget::setVTFont(const QFont& f) 265void TEWidget::setVTFont(const QFont& f)
266{ 266{
267 QFrame::setFont(f); 267 QFrame::setFont(f);
268} 268}
269 269
270QFont TEWidget::getVTFont() { 270QFont TEWidget::getVTFont() {
271 return font(); 271 return font();
272} 272}
273 273
274void TEWidget::setFont(const QFont &) 274void TEWidget::setFont(const QFont &)
275{ 275{
276 // ignore font change request if not coming from konsole itself 276 // ignore font change request if not coming from konsole itself
277} 277}
278 278
279/* ------------------------------------------------------------------------- */ 279/* ------------------------------------------------------------------------- */
280/* */ 280/* */
281/* Constructor / Destructor */ 281/* Constructor / Destructor */
282/* */ 282/* */
283/* ------------------------------------------------------------------------- */ 283/* ------------------------------------------------------------------------- */
284 284
285TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) 285TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
286{ 286{
287#ifndef QT_NO_CLIPBOARD 287#ifndef QT_NO_CLIPBOARD
288 cb = QApplication::clipboard(); 288 cb = QApplication::clipboard();
289 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 289 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
290 this, SLOT(onClearSelection()) ); 290 this, SLOT(onClearSelection()) );
291#endif 291#endif
292 292
293 scrollbar = new QScrollBar(this); 293 scrollbar = new QScrollBar(this);
294 scrollbar->setCursor( arrowCursor ); 294 scrollbar->setCursor( arrowCursor );
295 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 295 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
296 296
297 hScrollbar = new QScrollBar(this); 297 hScrollbar = new QScrollBar(this);
298 hScrollbar->setCursor( arrowCursor ); 298 hScrollbar->setCursor( arrowCursor );
299 hScrollbar->setOrientation(QScrollBar::Horizontal); 299 hScrollbar->setOrientation(QScrollBar::Horizontal);
300 hScrollbar->setMaximumHeight(16); 300 hScrollbar->setMaximumHeight(16);
301 301
302 connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); 302 connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int)));
303 303
304 Config cfg("Konsole"); 304 Config cfg("Konsole");
305 cfg.setGroup("ScrollBar"); 305 cfg.setGroup("ScrollBar");
306 switch( cfg.readNumEntry("Position",2)){ 306 switch( cfg.readNumEntry("Position",2)){
307 case 0: 307 case 0:
308 scrollLoc = SCRNONE; 308 scrollLoc = SCRNONE;
309 break; 309 break;
310 case 1: 310 case 1:
311 scrollLoc = SCRLEFT; 311 scrollLoc = SCRLEFT;
312 break; 312 break;
313 case 2: 313 case 2:
314 scrollLoc = SCRRIGHT; 314 scrollLoc = SCRRIGHT;
315 break; 315 break;
316 }; 316 };
317 317
318 useHorzScroll=cfg.readBoolEntry("HorzScroll",0); 318 useHorzScroll=cfg.readBoolEntry("HorzScroll",0);
319 319
320 blinkT = new QTimer(this); 320 blinkT = new QTimer(this);
321 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); 321 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent()));
322 // blinking = FALSE; 322 // blinking = FALSE;
323 blinking = TRUE; 323 blinking = TRUE;
324 324
325 resizing = FALSE; 325 resizing = FALSE;
326 actSel = 0; 326 actSel = 0;
327 image = 0; 327 image = 0;
328 lines = 1; 328 lines = 1;
329 columns = 1; 329 columns = 1;
330 font_w = 1; 330 font_w = 1;
331 font_h = 1; 331 font_h = 1;
332 font_a = 1; 332 font_a = 1;
333 word_selection_mode = FALSE; 333 word_selection_mode = FALSE;
334 hposition = 0; 334 hposition = 0;
335 335vcolumns = 0;
336
336 setMouseMarks(TRUE); 337 setMouseMarks(TRUE);
337 setVTFont( QFont("fixed") ); 338 setVTFont( QFont("fixed") );
338 setColorTable(base_color_table); // init color table 339 setColorTable(base_color_table); // init color table
339 340
340 qApp->installEventFilter( this ); //FIXME: see below 341 qApp->installEventFilter( this ); //FIXME: see below
341// KCursor::setAutoHideCursor( this, true ); 342// KCursor::setAutoHideCursor( this, true );
342 343
343 // Init DnD //////////////////////////////////////////////////////////////// 344 // Init DnD ////////////////////////////////////////////////////////////////
344 currentSession = NULL; 345 currentSession = NULL;
345// setAcceptDrops(true); // attempt 346// setAcceptDrops(true); // attempt
346// m_drop = new QPopupMenu(this); 347// m_drop = new QPopupMenu(this);
347// m_drop->insertItem( QString("Paste"), 0); 348// m_drop->insertItem( QString("Paste"), 0);
348// m_drop->insertItem( QString("cd"), 1); 349// m_drop->insertItem( QString("cd"), 1);
349// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); 350// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int)));
350 351
351 // we need focus so that the auto-hide cursor feature works 352 // we need focus so that the auto-hide cursor feature works
352 setFocus(); 353 setFocus();
353 setFocusPolicy( WheelFocus ); 354 setFocusPolicy( WheelFocus );
354} 355}
355 356
356//FIXME: make proper destructor 357//FIXME: make proper destructor
357// Here's a start (David) 358// Here's a start (David)
358TEWidget::~TEWidget() 359TEWidget::~TEWidget()
359{ 360{
360 qApp->removeEventFilter( this ); 361 qApp->removeEventFilter( this );
361 if (image) free(image); 362 if (image) free(image);
362} 363}
363 364
364/* ------------------------------------------------------------------------- */ 365/* ------------------------------------------------------------------------- */
365/* */ 366/* */
366/* Display Operations */ 367/* Display Operations */
367/* */ 368/* */
368/* ------------------------------------------------------------------------- */ 369/* ------------------------------------------------------------------------- */
369 370
370/*! 371/*!
371 attributed string draw primitive 372 attributed string draw primitive
372*/ 373*/
373 374
374void TEWidget::drawAttrStr(QPainter &paint, QRect rect, 375void TEWidget::drawAttrStr(QPainter &paint, QRect rect,
375 QString& str, ca attr, BOOL pm, BOOL clear) 376 QString& str, ca attr, BOOL pm, BOOL clear)
376{ 377{
377 if (pm && color_table[attr.b].transparent) 378 if (pm && color_table[attr.b].transparent)
378 { 379 {
379 paint.setBackgroundMode( TransparentMode ); 380 paint.setBackgroundMode( TransparentMode );
380 if (clear) erase(rect); 381 if (clear) erase(rect);
381 } 382 }
382 else 383 else
383 { 384 {
384 if (blinking) 385 if (blinking)
385 paint.fillRect(rect, color_table[attr.b].color); 386 paint.fillRect(rect, color_table[attr.b].color);
386 else 387 else
387 { 388 {
388 paint.setBackgroundMode( OpaqueMode ); 389 paint.setBackgroundMode( OpaqueMode );
389 paint.setBackgroundColor( color_table[attr.b].color ); 390 paint.setBackgroundColor( color_table[attr.b].color );
390 } 391 }
391 } 392 }
392 393
393 if (color_table[attr.f].bold) 394 if (color_table[attr.f].bold)
394 paint.setPen(QColor( 0x8F, 0x00, 0x00 )); 395 paint.setPen(QColor( 0x8F, 0x00, 0x00 ));
395 else 396 else
396 paint.setPen(color_table[attr.f].color); 397 paint.setPen(color_table[attr.f].color);
397 398
398 paint.drawText(rect.x(),rect.y()+font_a, str); 399 paint.drawText(rect.x(),rect.y()+font_a, str);
399 400
400 if (attr.r & RE_UNDERLINE) 401 if (attr.r & RE_UNDERLINE)
401 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); 402 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 );
402} 403}
403 404
404/*! 405/*!
405 The image can only be set completely. 406 The image can only be set completely.
406 407
407 The size of the new image may or may not match the size of the widget. 408 The size of the new image may or may not match the size of the widget.
408*/ 409*/
409 410
410void TEWidget::setImage(const ca* const newimg, int lines, int columns) 411void TEWidget::setImage(const ca* const newimg, int lines, int columns)
411{ int y,x,len; 412{ int y,x,len;
412 const QPixmap* pm = backgroundPixmap(); 413 const QPixmap* pm = backgroundPixmap();
413 QPainter paint; 414 QPainter paint;
414 setUpdatesEnabled(FALSE); 415 setUpdatesEnabled(FALSE);
415 paint.begin( this ); 416 paint.begin( this );
416HCNT("setImage"); 417HCNT("setImage");
417 418
418 QPoint tL = contentsRect().topLeft(); 419 QPoint tL = contentsRect().topLeft();
419 int tLx = tL.x(); 420 int tLx = tL.x();
420 int tLy = tL.y(); 421 int tLy = tL.y();
421 hasBlinker = FALSE; 422 hasBlinker = FALSE;
422 423
423 int cf = -1; // undefined 424 int cf = -1; // undefined
424 int cb = -1; // undefined 425 int cb = -1; // undefined
425 int cr = -1; // undefined 426 int cr = -1; // undefined
426 427
427 int lins = QMIN(this->lines, QMAX(0,lines )); 428 int lins = QMIN(this->lines, QMAX(0,lines ));
428 int cols = QMIN(this->columns,QMAX(0,columns)); 429 int cols = QMIN(this->columns,QMAX(0,columns));
429 QChar *disstrU = new QChar[cols]; 430 QChar *disstrU = new QChar[cols];
430 for (y = 0; y < lins; y++) { 431 for (y = 0; y < lins; y++) {
431 const ca* lcl = &image[y*this->columns]; 432 const ca* lcl = &image[y*this->columns];
432 const ca* const ext = &newimg[y*columns]; 433 const ca* const ext = &newimg[y*columns];
433 if (!resizing) // not while resizing, we're expecting a paintEvent 434 if (!resizing) // not while resizing, we're expecting a paintEvent
434 for (x = 0; x < cols; x++) 435 for (x = 0; x < cols; x++)
435 { 436 {
436 hasBlinker |= (ext[x].r & RE_BLINK); 437 hasBlinker |= (ext[x].r & RE_BLINK);
437 if (ext[x] != lcl[x]) 438 if (ext[x] != lcl[x])
438 { 439 {
439 cr = ext[x].r; 440 cr = ext[x].r;
440 cb = ext[x].b; 441 cb = ext[x].b;
441 if (ext[x].f != cf) cf = ext[x].f; 442 if (ext[x].f != cf) cf = ext[x].f;
442 int lln = cols - x; 443 int lln = cols - x;
443 disstrU[0] = fontMap(ext[x+0].c); 444 disstrU[0] = fontMap(ext[x+0].c);
444 for (len = 1; len < lln; len++) 445 for (len = 1; len < lln; len++)
445 { 446 {
446 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || 447 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr ||
447 ext[x+len] == lcl[x+len] ) 448 ext[x+len] == lcl[x+len] )
448 break; 449 break;
449 disstrU[len] = fontMap(ext[x+len].c); 450 disstrU[len] = fontMap(ext[x+len].c);
450 } 451 }
451 QString unistr(disstrU,len); 452 QString unistr(disstrU,len);
452 drawAttrStr(paint, 453 drawAttrStr(paint,
453 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 454 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
454 unistr, ext[x], pm != NULL, true); 455 unistr, ext[x], pm != NULL, true);
455 x += len - 1; 456 x += len - 1;
456 } 457 }
457 } 458 }
458 // finally, make `image' become `newimg'. 459 // finally, make `image' become `newimg'.
459 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); 460 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca));
460 } 461 }
461 drawFrame( &paint ); 462 drawFrame( &paint );
462 paint.end(); 463 paint.end();
463 setUpdatesEnabled(TRUE); 464 setUpdatesEnabled(TRUE);
464 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms 465 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms
465 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } 466 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; }
466 delete [] disstrU; 467 delete [] disstrU;
467} 468}
468 469
469// paint Event //////////////////////////////////////////////////// 470// paint Event ////////////////////////////////////////////////////
470 471
471/*! 472/*!
472 The difference of this routine vs. the `setImage' is, 473 The difference of this routine vs. the `setImage' is,
473 that the drawing does not include a difference analysis 474 that the drawing does not include a difference analysis
474 between the old and the new image. Instead, the internal 475 between the old and the new image. Instead, the internal
475 image is used and the painting bound by the PaintEvent box. 476 image is used and the painting bound by the PaintEvent box.
476*/ 477*/
477 478
478void TEWidget::paintEvent( QPaintEvent* pe ) 479void TEWidget::paintEvent( QPaintEvent* pe )
479{ 480{
480 481
481//{ static int cnt = 0; printf("paint %d\n",cnt++); } 482//{ static int cnt = 0; printf("paint %d\n",cnt++); }
482 const QPixmap* pm = backgroundPixmap(); 483 const QPixmap* pm = backgroundPixmap();
483 QPainter paint; 484 QPainter paint;
484 setUpdatesEnabled(FALSE); 485 setUpdatesEnabled(FALSE);
485 paint.begin( this ); 486 paint.begin( this );
486 paint.setBackgroundMode( TransparentMode ); 487 paint.setBackgroundMode( TransparentMode );
487HCNT("paintEvent"); 488HCNT("paintEvent");
488 489
489 // Note that the actual widget size can be slightly larger 490 // Note that the actual widget size can be slightly larger
490 // that the image (the size is truncated towards the smaller 491 // that the image (the size is truncated towards the smaller
491 // number of characters in `resizeEvent'. The paint rectangle 492 // number of characters in `resizeEvent'. The paint rectangle
492 // can thus be larger than the image, but less then the size 493 // can thus be larger than the image, but less then the size
493 // of one character. 494 // of one character.
494 495
495 QRect rect = pe->rect().intersect(contentsRect()); 496 QRect rect = pe->rect().intersect(contentsRect());
496 497
497 QPoint tL = contentsRect().topLeft(); 498 QPoint tL = contentsRect().topLeft();
498 int tLx = tL.x(); 499 int tLx = tL.x();
499 int tLy = tL.y(); 500 int tLy = tL.y();
500 501
501 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); 502 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w));
502 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); 503 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h));
503 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); 504 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w));
504 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); 505 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h));
505 506
506 /* 507 /*
507 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, 508 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly,
508 rect.left(), rect.right(), rect.top(), rect.bottom()); 509 rect.left(), rect.right(), rect.top(), rect.bottom());
509 */ 510 */
510 511
511 // if (pm != NULL && color_table[image->b].transparent) 512 // if (pm != NULL && color_table[image->b].transparent)
512 // erase(rect); 513 // erase(rect);
513 // BL: I have no idea why we need this, and it breaks the refresh. 514 // BL: I have no idea why we need this, and it breaks the refresh.
514 515
515 QChar *disstrU = new QChar[columns]; 516 QChar *disstrU = new QChar[columns];
516 for (int y = luy; y <= rly; y++) 517 for (int y = luy; y <= rly; y++)
517 for (int x = lux; x <= rlx; x++) 518 for (int x = lux; x <= rlx; x++)
518 { 519 {
519 int len = 1; 520 int len = 1;
520 disstrU[0] = fontMap(image[loc(x,y)].c); 521 disstrU[0] = fontMap(image[loc(x,y)].c);
521 int cf = image[loc(x,y)].f; 522 int cf = image[loc(x,y)].f;
522 int cb = image[loc(x,y)].b; 523 int cb = image[loc(x,y)].b;
523 int cr = image[loc(x,y)].r; 524 int cr = image[loc(x,y)].r;
524 while (x+len <= rlx && 525 while (x+len <= rlx &&
525 image[loc(x+len,y)].f == cf && 526 image[loc(x+len,y)].f == cf &&
526 image[loc(x+len,y)].b == cb && 527 image[loc(x+len,y)].b == cb &&
527 image[loc(x+len,y)].r == cr ) 528 image[loc(x+len,y)].r == cr )
@@ -1214,194 +1215,192 @@ void TEWidget::calcGeometry()
1214 1215
1215 scrollbar->resize( QApplication::style().scrollBarExtent().width(), 1216 scrollbar->resize( QApplication::style().scrollBarExtent().width(),
1216 contentsRect().height()); 1217 contentsRect().height());
1217 qDebug("font_w %d", font_w); 1218 qDebug("font_w %d", font_w);
1218 switch(scrollLoc) 1219 switch(scrollLoc)
1219 { 1220 {
1220 case SCRNONE : 1221 case SCRNONE :
1221 columns = ( contentsRect().width() - 2 * rimX ) / font_w; 1222 columns = ( contentsRect().width() - 2 * rimX ) / font_w;
1222 blX = (contentsRect().width() - (columns*font_w) ) / 2; 1223 blX = (contentsRect().width() - (columns*font_w) ) / 2;
1223 brX = blX; 1224 brX = blX;
1224 scrollbar->hide(); 1225 scrollbar->hide();
1225 break; 1226 break;
1226 case SCRLEFT : 1227 case SCRLEFT :
1227 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1228 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1228 if(useHorzScroll) columns = columns * (font_w/2); 1229 if(useHorzScroll) columns = columns * (font_w/2);
1229 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1230 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1230 blX = brX + scrollbar->width(); 1231 blX = brX + scrollbar->width();
1231 scrollbar->move(contentsRect().topLeft()); 1232 scrollbar->move(contentsRect().topLeft());
1232 scrollbar->show(); 1233 scrollbar->show();
1233 break; 1234 break;
1234 case SCRRIGHT: 1235 case SCRRIGHT:
1235 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width() ) / font_w; 1236 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width() ) / font_w;
1236 if(useHorzScroll) columns = columns * (font_w/2); 1237 if(useHorzScroll) columns = columns * (font_w/2);
1237 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1238 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1238 if(useHorzScroll) { 1239 if(useHorzScroll) {
1239 brX = blX =2; 1240 brX = blX =2;
1240 } else { 1241 } else {
1241 brX=blX; 1242 brX=blX;
1242 } 1243 }
1243 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0) ); 1244 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0) );
1244 scrollbar->show(); 1245 scrollbar->show();
1245 break; 1246 break;
1246 } 1247 }
1247 1248
1248 if( !scrollbar->isHidden()) 1249 if( !scrollbar->isHidden())
1249 hScrollbar->resize( contentsRect().width()-SCRWIDTH, QApplication::style() 1250 hScrollbar->resize( contentsRect().width()-SCRWIDTH, QApplication::style()
1250 .scrollBarExtent().height()); 1251 .scrollBarExtent().height());
1251 else 1252 else
1252 hScrollbar->resize( contentsRect().width(), QApplication::style() 1253 hScrollbar->resize( contentsRect().width(), QApplication::style()
1253 .scrollBarExtent().height()); 1254 .scrollBarExtent().height());
1254 1255
1255 hScrollbar->move( 0, contentsRect().height() - SCRWIDTH); 1256 hScrollbar->move( 0, contentsRect().height() - SCRWIDTH);
1256 1257
1257 1258
1258 if(useHorzScroll) { 1259 if(useHorzScroll) {
1259 hScrollbar->show(); 1260 hScrollbar->show();
1260 lines = ( (contentsRect().height() - SCRWIDTH) - 2 * rimY ) / font_h; 1261 lines = ( (contentsRect().height() - SCRWIDTH) - 2 * rimY ) / font_h;
1261 bY = ((contentsRect().height() - SCRWIDTH) - (lines *font_h)) / 2; 1262 bY = ((contentsRect().height() - SCRWIDTH) - (lines *font_h)) / 2;
1262 } else { 1263 } else {
1263 hScrollbar->hide(); 1264 hScrollbar->hide();
1264 lines = (contentsRect().height() - 2 * rimY ) / font_h; 1265 lines = (contentsRect().height() - 2 * rimY ) / font_h;
1265 bY = (contentsRect().height() - (lines *font_h)) / 2; 1266 bY = (contentsRect().height() - (lines *font_h)) / 2;
1266 } 1267 }
1267 */ 1268 */
1268 //FIXME: support 'rounding' styles 1269 //FIXME: support 'rounding' styles
1269} 1270}
1270 1271
1271void TEWidget::makeImage() 1272void TEWidget::makeImage()
1272//FIXME: rename 'calcGeometry? 1273//FIXME: rename 'calcGeometry?
1273{ 1274{
1274 calcGeometry(); 1275 calcGeometry();
1275 image = (ca*) malloc(lines*columns*sizeof(ca)); 1276 image = (ca*) malloc(lines*columns*sizeof(ca));
1276 clearImage(); 1277 clearImage();
1277} 1278}
1278 1279
1279// calculate the needed size 1280// calculate the needed size
1280QSize TEWidget::calcSize(int cols, int lins) const 1281QSize TEWidget::calcSize(int cols, int lins) const
1281{ 1282{
1282 int frw = width() - contentsRect().width(); 1283 int frw = width() - contentsRect().width();
1283 int frh = height() - contentsRect().height(); 1284 int frh = height() - contentsRect().height();
1284 int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); 1285 int scw = (scrollLoc==SCRNONE?0:scrollbar->width());
1285 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); 1286 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh );
1286} 1287}
1287 1288
1288QSize TEWidget::sizeHint() const 1289QSize TEWidget::sizeHint() const
1289{ 1290{
1290 return size(); 1291 return size();
1291} 1292}
1292 1293
1293void TEWidget::styleChange(QStyle &) 1294void TEWidget::styleChange(QStyle &)
1294{ 1295{
1295 propagateSize(); 1296 propagateSize();
1296} 1297}
1297 1298
1298#ifndef QT_NO_DRAGANDDROP 1299#ifndef QT_NO_DRAGANDDROP
1299 1300
1300/* --------------------------------------------------------------------- */ 1301/* --------------------------------------------------------------------- */
1301/* */ 1302/* */
1302/* Drag & Drop */ 1303/* Drag & Drop */
1303/* */ 1304/* */
1304/* --------------------------------------------------------------------- */ 1305/* --------------------------------------------------------------------- */
1305 1306
1306 1307
1307void TEWidget::dragEnterEvent(QDragEnterEvent* e) 1308void TEWidget::dragEnterEvent(QDragEnterEvent* e)
1308{ 1309{
1309 e->accept(QTextDrag::canDecode(e) || 1310 e->accept(QTextDrag::canDecode(e) ||
1310 QUriDrag::canDecode(e)); 1311 QUriDrag::canDecode(e));
1311} 1312}
1312 1313
1313void TEWidget::dropEvent(QDropEvent* event) 1314void TEWidget::dropEvent(QDropEvent* event)
1314{ 1315{
1315 // The current behaviour when url(s) are dropped is 1316 // The current behaviour when url(s) are dropped is
1316 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd 1317 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd
1317 // * in all other cases, just paste 1318 // * in all other cases, just paste
1318 // (for non-local ones, or for a list of URLs, 'cd' is nonsense) 1319 // (for non-local ones, or for a list of URLs, 'cd' is nonsense)
1319 QStrList strlist; 1320 QStrList strlist;
1320 int file_count = 0; 1321 int file_count = 0;
1321 dropText = ""; 1322 dropText = "";
1322 bool bPopup = true; 1323 bool bPopup = true;
1323 1324
1324 if(QUriDrag::decode(event, strlist)) { 1325 if(QUriDrag::decode(event, strlist)) {
1325 if (strlist.count()) { 1326 if (strlist.count()) {
1326 for(const char* p = strlist.first(); p; p = strlist.next()) { 1327 for(const char* p = strlist.first(); p; p = strlist.next()) {
1327 if(file_count++ > 0) { 1328 if(file_count++ > 0) {
1328 dropText += " "; 1329 dropText += " ";
1329 bPopup = false; // more than one file, don't popup 1330 bPopup = false; // more than one file, don't popup
1330 } 1331 }
1331 1332
1332/* 1333/*
1333 KURL url(p); 1334 KURL url(p);
1334 if (url.isLocalFile()) { 1335 if (url.isLocalFile()) {
1335 dropText += url.path(); // local URL : remove protocol 1336 dropText += url.path(); // local URL : remove protocol
1336 } 1337 }
1337 else { 1338 else {
1338 dropText += url.prettyURL(); 1339 dropText += url.prettyURL();
1339 bPopup = false; // a non-local file, don't popup 1340 bPopup = false; // a non-local file, don't popup
1340 } 1341 }
1341*/ 1342*/
1342 1343
1343 } 1344 }
1344 1345
1345 if (bPopup) 1346 if (bPopup)
1346 // m_drop->popup(pos() + event->pos()); 1347 // m_drop->popup(pos() + event->pos());
1347 m_drop->popup(mapToGlobal(event->pos())); 1348 m_drop->popup(mapToGlobal(event->pos()));
1348 else 1349 else
1349 { 1350 {
1350 if (currentSession) { 1351 if (currentSession) {
1351 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1352 currentSession->getEmulation()->sendString(dropText.local8Bit());
1352 } 1353 }
1353// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1354// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1354 } 1355 }
1355 } 1356 }
1356 } 1357 }
1357 else if(QTextDrag::decode(event, dropText)) { 1358 else if(QTextDrag::decode(event, dropText)) {
1358// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1359// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1359 if (currentSession) { 1360 if (currentSession) {
1360 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1361 currentSession->getEmulation()->sendString(dropText.local8Bit());
1361 } 1362 }
1362 // Paste it 1363 // Paste it
1363 } 1364 }
1364} 1365}
1365#endif 1366#endif
1366 1367
1367 1368
1368void TEWidget::drop_menu_activated(int item) 1369void TEWidget::drop_menu_activated(int item)
1369{ 1370{
1370#ifndef QT_NO_DRAGANDDROP 1371#ifndef QT_NO_DRAGANDDROP
1371 switch (item) 1372 switch (item)
1372 { 1373 {
1373 case 0: // paste 1374 case 0: // paste
1374 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1375 currentSession->getEmulation()->sendString(dropText.local8Bit());
1375// KWM::activate((Window)this->winId()); 1376// KWM::activate((Window)this->winId());
1376 break; 1377 break;
1377 case 1: // cd ... 1378 case 1: // cd ...
1378 currentSession->getEmulation()->sendString("cd "); 1379 currentSession->getEmulation()->sendString("cd ");
1379 struct stat statbuf; 1380 struct stat statbuf;
1380 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) 1381 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 )
1381 { 1382 {
1382 if ( !S_ISDIR(statbuf.st_mode) ) 1383 if ( !S_ISDIR(statbuf.st_mode) )
1383 { 1384 {
1384/* 1385/*
1385 KURL url; 1386 KURL url;
1386 url.setPath( dropText ); 1387 url.setPath( dropText );
1387 dropText = url.directory( true, false ); // remove filename 1388 dropText = url.directory( true, false ); // remove filename
1388*/ 1389*/
1389 } 1390 }
1390 } 1391 }
1391 dropText.replace(QRegExp(" "), "\\ "); // escape spaces 1392 dropText.replace(QRegExp(" "), "\\ "); // escape spaces
1392 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1393 currentSession->getEmulation()->sendString(dropText.local8Bit());
1393 currentSession->getEmulation()->sendString("\n"); 1394 currentSession->getEmulation()->sendString("\n");
1394// KWM::activate((Window)this->winId()); 1395// KWM::activate((Window)this->winId());
1395 break; 1396 break;
1396 } 1397 }
1397#endif 1398#endif
1398} 1399}
1399 1400
1400void TEWidget::setWrapAt(int columns) 1401void TEWidget::setWrapAt(int columns)
1401{ 1402{
1402 vcolumns = columns; 1403 vcolumns = columns;
1403 propagateSize(); 1404 propagateSize();
1404 update(); 1405 update();
1405} 1406}
1406
1407
diff --git a/core/apps/embeddedkonsole/TEmulation.h b/core/apps/embeddedkonsole/TEmulation.h
index ec15e7a..bf43f11 100644
--- a/core/apps/embeddedkonsole/TEmulation.h
+++ b/core/apps/embeddedkonsole/TEmulation.h
@@ -1,117 +1,118 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [emulation.h] Fundamental Terminal Emulation */ 3/* [emulation.h] Fundamental Terminal Emulation */
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#ifndef EMULATION_H 19#ifndef EMULATION_H
20#define EMULATION_H 20#define EMULATION_H
21 21
22#include "TEWidget.h" 22#include "TEWidget.h"
23#include "TEScreen.h" 23#include "TEScreen.h"
24#include <qtimer.h> 24#include <qtimer.h>
25#include <stdio.h> 25#include <stdio.h>
26#include <qtextcodec.h> 26#include <qtextcodec.h>
27#include "keytrans.h" 27#include "keytrans.h"
28 28
29class TEmulation : public QObject 29class TEmulation : public QObject
30{ Q_OBJECT 30{ Q_OBJECT
31 31
32public: 32public:
33 33
34 TEmulation(TEWidget* gui); 34 TEmulation(TEWidget* gui);
35 ~TEmulation(); 35 ~TEmulation();
36 36
37public: 37public:
38 virtual void setHistory(bool on); 38 virtual void setHistory(bool on);
39 virtual bool history(); 39 virtual bool history();
40 40
41public slots: // signals incoming from TEWidget 41public slots: // signals incoming from TEWidget
42 42
43 virtual void onImageSizeChange(int lines, int columns); 43 virtual void onImageSizeChange(int lines, int columns);
44 virtual void onHistoryCursorChange(int cursor); 44 virtual void onHistoryCursorChange(int cursor);
45 virtual void onHorzCursorChange(int cursor);
45 virtual void onKeyPress(QKeyEvent*); 46 virtual void onKeyPress(QKeyEvent*);
46 47
47 virtual void clearSelection(); 48 virtual void clearSelection();
48 virtual void onSelectionBegin(const int x, const int y); 49 virtual void onSelectionBegin(const int x, const int y);
49 virtual void onSelectionExtend(const int x, const int y); 50 virtual void onSelectionExtend(const int x, const int y);
50 virtual void setSelection(const BOOL preserve_line_breaks); 51 virtual void setSelection(const BOOL preserve_line_breaks);
51 52
52public slots: // signals incoming from data source 53public slots: // signals incoming from data source
53 54
54 void onRcvBlock(const char* txt,int len); 55 void onRcvBlock(const char* txt,int len);
55 56
56signals: 57signals:
57 58
58 void sndBlock(const char* txt,int len); 59 void sndBlock(const char* txt,int len);
59 void ImageSizeChanged(int lines, int columns); 60 void ImageSizeChanged(int lines, int columns);
60 void changeColumns(int columns); 61 void changeColumns(int columns);
61 void changeTitle(int arg, const char* str); 62 void changeTitle(int arg, const char* str);
62 63
63public: 64public:
64 65
65 virtual void onRcvChar(int); 66 virtual void onRcvChar(int);
66 67
67 virtual void setMode (int) = 0; 68 virtual void setMode (int) = 0;
68 virtual void resetMode(int) = 0; 69 virtual void resetMode(int) = 0;
69 70
70 virtual void sendString(const char*) = 0; 71 virtual void sendString(const char*) = 0;
71 72
72 virtual void setConnect(bool r); 73 virtual void setConnect(bool r);
73 void setColumns(int columns); 74 void setColumns(int columns);
74 75
75 void setKeytrans(int no); 76 void setKeytrans(int no);
76 void setKeytrans(const char * no); 77 void setKeytrans(const char * no);
77 78
78protected: 79protected:
79 80
80 TEWidget* gui; 81 TEWidget* gui;
81 TEScreen* scr; // referes to one `screen' 82 TEScreen* scr; // referes to one `screen'
82 TEScreen* screen[2]; // 0 = primary, 1 = alternate 83 TEScreen* screen[2]; // 0 = primary, 1 = alternate
83 void setScreen(int n); // set `scr' to `screen[n]' 84 void setScreen(int n); // set `scr' to `screen[n]'
84 85
85 bool connected; // communicate with widget 86 bool connected; // communicate with widget
86 87
87 void setCodec(int c); // codec number, 0 = locale, 1=utf8 88 void setCodec(int c); // codec number, 0 = locale, 1=utf8
88 89
89 QTextCodec* codec; 90 QTextCodec* codec;
90 QTextCodec* localeCodec; 91 QTextCodec* localeCodec;
91 QTextDecoder* decoder; 92 QTextDecoder* decoder;
92 93
93 KeyTrans* keytrans; 94 KeyTrans* keytrans;
94 95
95// refreshing related material. 96// refreshing related material.
96// this is localized in the class. 97// this is localized in the class.
97private slots: // triggered by timer 98private slots: // triggered by timer
98 99
99 void showBulk(); 100 void showBulk();
100 101
101private: 102private:
102 103
103 void bulkNewline(); 104 void bulkNewline();
104 void bulkStart(); 105 void bulkStart();
105 void bulkEnd(); 106 void bulkEnd();
106 107
107private: 108private:
108 109
109 QTimer bulk_timer; 110 QTimer bulk_timer;
110 int bulk_nlcnt; // bulk newline counter 111 int bulk_nlcnt; // bulk newline counter
111 char* SelectedText; 112 char* SelectedText;
112 int bulk_incnt; // bulk counter 113 int bulk_incnt; // bulk counter
113 114
114 115
115}; 116};
116 117
117#endif // ifndef EMULATION_H 118#endif // ifndef EMULATION_H
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index 3c87ad4..16db0ea 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -169,805 +169,839 @@ static const char *commonCmds[] =
169}; 169};
170 170
171 171
172Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 172Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
173 QMainWindow(parent, name, fl) 173 QMainWindow(parent, name, fl)
174{ 174{
175 QStrList args; 175 QStrList args;
176 init("/bin/sh",args); 176 init("/bin/sh",args);
177} 177}
178 178
179Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 179Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
180 : QMainWindow(0, name) 180 : QMainWindow(0, name)
181{ 181{
182 init(_pgm,_args); 182 init(_pgm,_args);
183} 183}
184 184
185void Konsole::initCommandList() 185void Konsole::initCommandList()
186{ 186{
187// qDebug("Konsole::initCommandList"); 187// qDebug("Konsole::initCommandList");
188 Config cfg("Konsole"); 188 Config cfg("Konsole");
189 cfg.setGroup("Commands"); 189 cfg.setGroup("Commands");
190 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 190 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
191 commonCombo->clear(); 191 commonCombo->clear();
192 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { 192 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") {
193 for (int i = 0; commonCmds[i] != NULL; i++) { 193 for (int i = 0; commonCmds[i] != NULL; i++) {
194 commonCombo->insertItem(commonCmds[i],i); 194 commonCombo->insertItem(commonCmds[i],i);
195 } 195 }
196 } else { 196 } else {
197 for (int i = 0; i < 100; i++) { 197 for (int i = 0; i < 100; i++) {
198 if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) 198 if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
199 commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); 199 commonCombo->insertItem((cfg.readEntry( QString::number(i),"")));
200 } 200 }
201 } 201 }
202 202
203} 203}
204 204
205void Konsole::init(const char* _pgm, QStrList & _args) 205void Konsole::init(const char* _pgm, QStrList & _args)
206{ 206{
207 b_scroll = TRUE; // histon; 207 b_scroll = TRUE; // histon;
208 n_keytab = 0; 208 n_keytab = 0;
209 n_render = 0; 209 n_render = 0;
210 startUp=0; 210 startUp=0;
211 fromMenu = FALSE; 211 fromMenu = FALSE;
212 212
213 setCaption( tr("Terminal") ); 213 setCaption( tr("Terminal") );
214 setIcon( Resource::loadPixmap( "konsole" ) ); 214 setIcon( Resource::loadPixmap( "konsole" ) );
215 215
216 Config cfg("Konsole"); 216 Config cfg("Konsole");
217 cfg.setGroup("Konsole"); 217 cfg.setGroup("Konsole");
218 QString tmp; 218 QString tmp;
219 // initialize the list of allowed fonts /////////////////////////////////// 219 // initialize the list of allowed fonts ///////////////////////////////////
220 cfont = cfg.readNumEntry("FontID", 1); 220 cfont = cfg.readNumEntry("FontID", 1);
221 QFont f = QFont("Micro", 4, QFont::Normal); 221 QFont f = QFont("Micro", 4, QFont::Normal);
222 f.setFixedPitch(TRUE); 222 f.setFixedPitch(TRUE);
223 fonts.append(new VTFont(tr("Micro"), f)); 223 fonts.append(new VTFont(tr("Micro"), f));
224 224
225 f = QFont("Fixed", 7, QFont::Normal); 225 f = QFont("Fixed", 7, QFont::Normal);
226 f.setFixedPitch(TRUE); 226 f.setFixedPitch(TRUE);
227 fonts.append(new VTFont(tr("Small Fixed"), f)); 227 fonts.append(new VTFont(tr("Small Fixed"), f));
228 228
229 f = QFont("Fixed", 12, QFont::Normal); 229 f = QFont("Fixed", 12, QFont::Normal);
230 f.setFixedPitch(TRUE); 230 f.setFixedPitch(TRUE);
231 fonts.append(new VTFont(tr("Medium Fixed"), f)); 231 fonts.append(new VTFont(tr("Medium Fixed"), f));
232 232
233 // create terminal emulation framework //////////////////////////////////// 233 // create terminal emulation framework ////////////////////////////////////
234 nsessions = 0; 234 nsessions = 0;
235 235
236 tab = new EKNumTabWidget(this); 236 tab = new EKNumTabWidget(this);
237 237
238 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 238 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
239 239
240 // create terminal toolbar //////////////////////////////////////////////// 240 // create terminal toolbar ////////////////////////////////////////////////
241 setToolBarsMovable( FALSE ); 241 setToolBarsMovable( FALSE );
242 QPEToolBar *menuToolBar = new QPEToolBar( this ); 242 QPEToolBar *menuToolBar = new QPEToolBar( this );
243 menuToolBar->setHorizontalStretchable( TRUE ); 243 menuToolBar->setHorizontalStretchable( TRUE );
244 244
245 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); 245 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar );
246 246
247 fontList = new QPopupMenu( this ); 247 fontList = new QPopupMenu( this );
248 for(uint i = 0; i < fonts.count(); i++) { 248 for(uint i = 0; i < fonts.count(); i++) {
249 VTFont *fnt = fonts.at(i); 249 VTFont *fnt = fonts.at(i);
250 fontList->insertItem(fnt->getName(), i); 250 fontList->insertItem(fnt->getName(), i);
251 } 251 }
252 fontChanged(cfont); 252 fontChanged(cfont);
253 253
254 configMenu = new QPopupMenu( this); 254 configMenu = new QPopupMenu( this);
255 colorMenu = new QPopupMenu( this); 255 colorMenu = new QPopupMenu( this);
256 scrollMenu = new QPopupMenu( this); 256 scrollMenu = new QPopupMenu( this);
257 editCommandListMenu = new QPopupMenu( this); 257 editCommandListMenu = new QPopupMenu( this);
258 258
259 configMenu->insertItem(tr("Command List"), editCommandListMenu); 259 configMenu->insertItem(tr("Command List"), editCommandListMenu);
260 260
261 bool listHidden; 261 bool listHidden;
262 cfg.setGroup("Menubar"); 262 cfg.setGroup("Menubar");
263 if( cfg.readEntry("Hidden","FALSE") == "TRUE") { 263 if( cfg.readEntry("Hidden","FALSE") == "TRUE") {
264 editCommandListMenu->insertItem( tr( "Show command list" )); 264 editCommandListMenu->insertItem( tr( "Show command list" ));
265 listHidden=TRUE; 265 listHidden=TRUE;
266 } else { 266 } else {
267 editCommandListMenu->insertItem( tr( "Hide command list" )); 267 editCommandListMenu->insertItem( tr( "Hide command list" ));
268 listHidden=FALSE; 268 listHidden=FALSE;
269 } 269 }
270 270
271 cfg.setGroup("Tabs"); 271 cfg.setGroup("Tabs");
272 tmp=cfg.readEntry("Position","Bottom"); 272 tmp=cfg.readEntry("Position","Bottom");
273 if(tmp=="Top") { 273 if(tmp=="Top") {
274 tab->setTabPosition(QTabWidget::Top); 274 tab->setTabPosition(QTabWidget::Top);
275 configMenu->insertItem( tr( "Tabs on Bottom" ) ); 275 configMenu->insertItem( tr( "Tabs on Bottom" ) );
276 } else { 276 } else {
277 tab->setTabPosition(QTabWidget::Bottom); 277 tab->setTabPosition(QTabWidget::Bottom);
278 configMenu->insertItem("Tabs on Top"); 278 configMenu->insertItem("Tabs on Top");
279 } 279 }
280 configMenu->insertSeparator(2); 280 configMenu->insertSeparator(2);
281 281
282 colorMenu->insertItem(tr( "Green on Black")); 282 colorMenu->insertItem(tr( "Green on Black"));
283 colorMenu->insertItem(tr( "Black on White")); 283 colorMenu->insertItem(tr( "Black on White"));
284 colorMenu->insertItem(tr( "White on Black")); 284 colorMenu->insertItem(tr( "White on Black"));
285 colorMenu->insertItem(tr( "Black on Transparent")); 285 colorMenu->insertItem(tr( "Black on Transparent"));
286 colorMenu->insertItem(tr( "Black on Red")); 286 colorMenu->insertItem(tr( "Black on Red"));
287 colorMenu->insertItem(tr( "Red on Black")); 287 colorMenu->insertItem(tr( "Red on Black"));
288 colorMenu->insertItem(tr( "Green on Yellow")); 288 colorMenu->insertItem(tr( "Green on Yellow"));
289 colorMenu->insertItem(tr( "Blue on Magenta")); 289 colorMenu->insertItem(tr( "Blue on Magenta"));
290 colorMenu->insertItem(tr( "Magenta on Blue")); 290 colorMenu->insertItem(tr( "Magenta on Blue"));
291 colorMenu->insertItem(tr( "Cyan on White")); 291 colorMenu->insertItem(tr( "Cyan on White"));
292 colorMenu->insertItem(tr( "White on Cyan")); 292 colorMenu->insertItem(tr( "White on Cyan"));
293 colorMenu->insertItem(tr( "Blue on Black")); 293 colorMenu->insertItem(tr( "Blue on Black"));
294 colorMenu->insertItem(tr( "Amber on Black")); 294 colorMenu->insertItem(tr( "Amber on Black"));
295 colorMenu->insertItem(tr( "Custom")); 295 colorMenu->insertItem(tr( "Custom"));
296 configMenu->insertItem(tr( "Colors") ,colorMenu); 296 configMenu->insertItem(tr( "Colors") ,colorMenu);
297 297
298 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 298 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
299 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 299 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
300 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); 300 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) ));
301 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); 301 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int)));
302 connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); 302 connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int)));
303 menuBar->insertItem( tr("Font"), fontList ); 303 menuBar->insertItem( tr("Font"), fontList );
304 menuBar->insertItem( tr("Options"), configMenu ); 304 menuBar->insertItem( tr("Options"), configMenu );
305 305
306 QPEToolBar *toolbar = new QPEToolBar( this ); 306 QPEToolBar *toolbar = new QPEToolBar( this );
307 307
308 QAction *a; 308 QAction *a;
309 309
310 // Button Commands 310 // Button Commands
311 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); 311 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 );
312 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); 312 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar );
313 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 313 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
314 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); 314 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar );
315 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); 315 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
316 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); 316 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar );
317 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); 317 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
318 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); 318 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar );
319 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); 319 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
320 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 320 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
321 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); 321 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
322 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 322 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
323 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 323 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
324 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); 324 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar );
325/* 325/*
326 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); 326 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 );
327 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 327 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
328 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); 328 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 );
329 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 329 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
330*/ 330*/
331 331
332 secondToolBar = new QPEToolBar( this ); 332 secondToolBar = new QPEToolBar( this );
333 secondToolBar->setHorizontalStretchable( TRUE ); 333 secondToolBar->setHorizontalStretchable( TRUE );
334 334
335 commonCombo = new QComboBox( secondToolBar ); 335 commonCombo = new QComboBox( secondToolBar );
336 commonCombo->setMaximumWidth(236); 336 commonCombo->setMaximumWidth(236);
337 337
338 editCommandListMenu->insertItem( tr( "Quick Edit" ) ); 338 editCommandListMenu->insertItem( tr( "Quick Edit" ) );
339 if( listHidden) { 339 if( listHidden) {
340 secondToolBar->hide(); 340 secondToolBar->hide();
341 editCommandListMenu->setItemEnabled(-23 ,FALSE); 341 editCommandListMenu->setItemEnabled(-23 ,FALSE);
342 } 342 }
343 editCommandListMenu->insertItem(tr( "Edit" ) ); 343 editCommandListMenu->insertItem(tr( "Edit" ) );
344 344
345 cfg.setGroup("Commands"); 345 cfg.setGroup("Commands");
346 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 346 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
347 347
348 initCommandList(); 348 initCommandList();
349// for (int i = 0; commonCmds[i] != NULL; i++) { 349// for (int i = 0; commonCmds[i] != NULL; i++) {
350// commonCombo->insertItem( commonCmds[i], i ); 350// commonCombo->insertItem( commonCmds[i], i );
351// tmp = cfg.readEntry( QString::number(i),""); 351// tmp = cfg.readEntry( QString::number(i),"");
352// if(tmp != "") 352// if(tmp != "")
353// commonCombo->changeItem( tmp,i ); 353// commonCombo->changeItem( tmp,i );
354// } 354// }
355 355
356 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 356 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
357 357
358 scrollMenu->insertItem(tr( "None" )); 358 scrollMenu->insertItem(tr( "None" ));
359 scrollMenu->insertItem(tr( "Left" )); 359 scrollMenu->insertItem(tr( "Left" ));
360 scrollMenu->insertItem(tr( "Right" )); 360 scrollMenu->insertItem(tr( "Right" ));
361 scrollMenu->insertSeparator(4); 361// scrollMenu->insertSeparator(4);
362 scrollMenu->insertItem(tr( "Horizontal" )); 362// scrollMenu->insertItem(tr( "Horizontal" ));
363 363
364 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); 364 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu);
365
366 configMenu->insertItem(tr( "Wrap" ));
367
365//scrollMenuSelected(-29); 368//scrollMenuSelected(-29);
366// cfg.setGroup("ScrollBar"); 369// cfg.setGroup("ScrollBar");
367// if(cfg.readBoolEntry("HorzScroll",0)) { 370// if(cfg.readBoolEntry("HorzScroll",0)) {
368// if(cfg.readNumEntry("Position",2) == 0) 371// if(cfg.readNumEntry("Position",2) == 0)
369// te->setScrollbarLocation(1); 372// te->setScrollbarLocation(1);
370// else 373// else
371// te->setScrollbarLocation(0); 374// te->setScrollbarLocation(0);
372// te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 375// te->setScrollbarLocation( cfg.readNumEntry("Position",2));
373// te->setWrapAt(120); 376// te->setWrapAt(120);
374// } 377// }
375 // create applications ///////////////////////////////////////////////////// 378 // create applications /////////////////////////////////////////////////////
376 setCentralWidget(tab); 379 setCentralWidget(tab);
377 380
378 // load keymaps //////////////////////////////////////////////////////////// 381 // load keymaps ////////////////////////////////////////////////////////////
379 KeyTrans::loadAll(); 382 KeyTrans::loadAll();
380 for (int i = 0; i < KeyTrans::count(); i++) 383 for (int i = 0; i < KeyTrans::count(); i++)
381 { KeyTrans* s = KeyTrans::find(i); 384 { KeyTrans* s = KeyTrans::find(i);
382 assert( s ); 385 assert( s );
383 } 386 }
384 387
385 se_pgm = _pgm; 388 se_pgm = _pgm;
386 se_args = _args; 389 se_args = _args;
387 se_args.prepend("--login"); 390 se_args.prepend("--login");
388parseCommandLine(); 391parseCommandLine();
389 // read and apply default values /////////////////////////////////////////// 392 // read and apply default values ///////////////////////////////////////////
390 resize(321, 321); // Dummy. 393 resize(321, 321); // Dummy.
391 QSize currentSize = size(); 394 QSize currentSize = size();
392 if (currentSize != size()) 395 if (currentSize != size())
393 defaultSize = size(); 396 defaultSize = size();
394} 397}
395 398
396void Konsole::show() 399void Konsole::show()
397{ 400{
398 if ( !nsessions ) { 401 if ( !nsessions ) {
399 newSession(); 402 newSession();
400 } 403 }
401 QMainWindow::show(); 404 QMainWindow::show();
405
402} 406}
403 407
404void Konsole::initSession(const char*, QStrList &) 408void Konsole::initSession(const char*, QStrList &)
405{ 409{
406 QMainWindow::show(); 410 QMainWindow::show();
407} 411}
408 412
409Konsole::~Konsole() 413Konsole::~Konsole()
410{ 414{
411 while (nsessions > 0) { 415 while (nsessions > 0) {
412 doneSession(getTe()->currentSession, 0); 416 doneSession(getTe()->currentSession, 0);
413 } 417 }
414 418
415 Config cfg("Konsole"); 419 Config cfg("Konsole");
416 cfg.setGroup("Konsole"); 420 cfg.setGroup("Konsole");
417 cfg.writeEntry("FontID", cfont); 421 cfg.writeEntry("FontID", cfont);
418} 422}
419 423
420void Konsole::fontChanged(int f) 424void Konsole::fontChanged(int f)
421{ 425{
422 VTFont* font = fonts.at(f); 426 VTFont* font = fonts.at(f);
423 if (font != 0) { 427 if (font != 0) {
424 for(uint i = 0; i < fonts.count(); i++) { 428 for(uint i = 0; i < fonts.count(); i++) {
425 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 429 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
426 } 430 }
427 431
428 cfont = f; 432 cfont = f;
429 433
430 TEWidget* te = getTe(); 434 TEWidget* te = getTe();
431 if (te != 0) { 435 if (te != 0) {
432 te->setVTFont(font->getFont()); 436 te->setVTFont(font->getFont());
433 } 437 }
434 } 438 }
435} 439}
436 440
437 441
438void Konsole::enterCommand(int c) 442void Konsole::enterCommand(int c)
439{ 443{
440 TEWidget* te = getTe(); 444 TEWidget* te = getTe();
441 if (te != 0) { 445 if (te != 0) {
442 if(!commonCombo->editable()) { 446 if(!commonCombo->editable()) {
443 QString text = commonCombo->text(c); //commonCmds[c]; 447 QString text = commonCombo->text(c); //commonCmds[c];
444 te->emitText(text); 448 te->emitText(text);
445 } else { 449 } else {
446 changeCommand( commonCombo->text(c), c); 450 changeCommand( commonCombo->text(c), c);
447 } 451 }
448 } 452 }
449} 453}
450 454
451void Konsole::hitEnter() 455void Konsole::hitEnter()
452{ 456{
453 TEWidget* te = getTe(); 457 TEWidget* te = getTe();
454 if (te != 0) { 458 if (te != 0) {
455 te->emitText(QString("\r")); 459 te->emitText(QString("\r"));
456 } 460 }
457} 461}
458 462
459void Konsole::hitSpace() 463void Konsole::hitSpace()
460{ 464{
461 TEWidget* te = getTe(); 465 TEWidget* te = getTe();
462 if (te != 0) { 466 if (te != 0) {
463 te->emitText(QString(" ")); 467 te->emitText(QString(" "));
464 } 468 }
465} 469}
466 470
467void Konsole::hitTab() 471void Konsole::hitTab()
468{ 472{
469 TEWidget* te = getTe(); 473 TEWidget* te = getTe();
470 if (te != 0) { 474 if (te != 0) {
471 te->emitText(QString("\t")); 475 te->emitText(QString("\t"));
472 } 476 }
473} 477}
474 478
475void Konsole::hitPaste() 479void Konsole::hitPaste()
476{ 480{
477 TEWidget* te = getTe(); 481 TEWidget* te = getTe();
478 if (te != 0) { 482 if (te != 0) {
479 te->pasteClipboard(); 483 te->pasteClipboard();
480 } 484 }
481} 485}
482 486
483void Konsole::hitUp() 487void Konsole::hitUp()
484{ 488{
485 TEWidget* te = getTe(); 489 TEWidget* te = getTe();
486 if (te != 0) { 490 if (te != 0) {
487 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); 491 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
488 QApplication::sendEvent( te, &ke ); 492 QApplication::sendEvent( te, &ke );
489 } 493 }
490} 494}
491 495
492void Konsole::hitDown() 496void Konsole::hitDown()
493{ 497{
494 TEWidget* te = getTe(); 498 TEWidget* te = getTe();
495 if (te != 0) { 499 if (te != 0) {
496 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); 500 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0);
497 QApplication::sendEvent( te, &ke ); 501 QApplication::sendEvent( te, &ke );
498 } 502 }
499} 503}
500 504
501/** 505/**
502 This function calculates the size of the external widget 506 This function calculates the size of the external widget
503 needed for the internal widget to be 507 needed for the internal widget to be
504 */ 508 */
505QSize Konsole::calcSize(int columns, int lines) { 509QSize Konsole::calcSize(int columns, int lines) {
506 TEWidget* te = getTe(); 510 TEWidget* te = getTe();
507 if (te != 0) { 511 if (te != 0) {
508 QSize size = te->calcSize(columns, lines); 512 QSize size = te->calcSize(columns, lines);
509 return size; 513 return size;
510 } else { 514 } else {
511 QSize size; 515 QSize size;
512 return size; 516 return size;
513 } 517 }
514} 518}
515 519
516/** 520/**
517 sets application window to a size based on columns X lines of the te 521 sets application window to a size based on columns X lines of the te
518 guest widget. Call with (0,0) for setting default size. 522 guest widget. Call with (0,0) for setting default size.
519*/ 523*/
520 524
521void Konsole::setColLin(int columns, int lines) 525void Konsole::setColLin(int columns, int lines)
522{ 526{
523 qDebug("konsole::setColLin:: Columns %d", columns); 527 qDebug("konsole::setColLin:: Columns %d", columns);
524 528
525 if ((columns==0) || (lines==0)) 529 if ((columns==0) || (lines==0))
526 { 530 {
527 if (defaultSize.isEmpty()) // not in config file : set default value 531 if (defaultSize.isEmpty()) // not in config file : set default value
528 { 532 {
529 defaultSize = calcSize(80,24); 533 defaultSize = calcSize(80,24);
530 // notifySize(24,80); // set menu items (strange arg order !) 534 // notifySize(24,80); // set menu items (strange arg order !)
531 } 535 }
532 resize(defaultSize); 536 resize(defaultSize);
533 } else { 537 } else {
534 resize(calcSize(columns, lines)); 538 resize(calcSize(columns, lines));
535 // notifySize(lines,columns); // set menu items (strange arg order !) 539 // notifySize(lines,columns); // set menu items (strange arg order !)
536 } 540 }
537} 541}
538 542
539/* 543/*
540void Konsole::setFont(int fontno) 544void Konsole::setFont(int fontno)
541{ 545{
542 QFont f; 546 QFont f;
543 if (fontno == 0) 547 if (fontno == 0)
544 f = defaultFont = QFont( "Helvetica", 12 ); 548 f = defaultFont = QFont( "Helvetica", 12 );
545 else 549 else
546 if (fonts[fontno][0] == '-') 550 if (fonts[fontno][0] == '-')
547 f.setRawName( fonts[fontno] ); 551 f.setRawName( fonts[fontno] );
548 else 552 else
549 { 553 {
550 f.setFamily(fonts[fontno]); 554 f.setFamily(fonts[fontno]);
551 f.setRawMode( TRUE ); 555 f.setRawMode( TRUE );
552 } 556 }
553 if ( !f.exactMatch() && fontno != 0) 557 if ( !f.exactMatch() && fontno != 0)
554 { 558 {
555 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); 559 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]);
556 QMessageBox(this, msg); 560 QMessageBox(this, msg);
557 return; 561 return;
558 } 562 }
559 if (se) se->setFontNo(fontno); 563 if (se) se->setFontNo(fontno);
560 te->setVTFont(f); 564 te->setVTFont(f);
561 n_font = fontno; 565 n_font = fontno;
562} 566}
563*/ 567*/
564 568
565// --| color selection |------------------------------------------------------- 569// --| color selection |-------------------------------------------------------
566 570
567void Konsole::changeColumns(int columns) 571void Konsole::changeColumns(int columns)
568{ 572{
569 qDebug("change columns"); 573 qDebug("change columns");
570 TEWidget* te = getTe(); 574 TEWidget* te = getTe();
571 if (te != 0) { 575 if (te != 0) {
572 setColLin(columns,te->Lines()); 576 setColLin(columns,te->Lines());
573 te->update(); 577 te->update();
574 } 578 }
575} 579}
576 580
577//FIXME: If a child dies during session swap, 581//FIXME: If a child dies during session swap,
578// this routine might be called before 582// this routine might be called before
579// session swap is completed. 583// session swap is completed.
580 584
581void Konsole::doneSession(TESession*, int ) 585void Konsole::doneSession(TESession*, int )
582{ 586{
583 TEWidget *te = getTe(); 587 TEWidget *te = getTe();
584 if (te != 0) { 588 if (te != 0) {
585 te->currentSession->setConnect(FALSE); 589 te->currentSession->setConnect(FALSE);
586 tab->removeTab(te); 590 tab->removeTab(te);
587 delete te->currentSession; 591 delete te->currentSession;
588 delete te; 592 delete te;
589 nsessions--; 593 nsessions--;
590 } 594 }
591 595
592 if (nsessions == 0) { 596 if (nsessions == 0) {
593 close(); 597 close();
594 } 598 }
595} 599}
596 600
597void Konsole::newSession() { 601void Konsole::newSession() {
598 if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? 602 if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory?
599 TEWidget* te = new TEWidget(tab); 603 TEWidget* te = new TEWidget(tab);
600// te->setBackgroundMode(PaletteBase); //we want transparent!! 604// te->setBackgroundMode(PaletteBase); //we want transparent!!
601 te->setVTFont(fonts.at(cfont)->getFont()); 605 te->setVTFont(fonts.at(cfont)->getFont());
602 tab->addTab(te); 606 tab->addTab(te);
603 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); 607 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
604 te->currentSession = se; 608 te->currentSession = se;
605 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); 609 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) );
606 se->run(); 610 se->run();
607 se->setConnect(TRUE); 611 se->setConnect(TRUE);
608 se->setHistory(b_scroll); 612 se->setHistory(b_scroll);
609 tab->setCurrentPage(nsessions); 613 tab->setCurrentPage(nsessions);
610 nsessions++; 614 nsessions++;
611 setColor(); 615 doWrap();
616 setColor();
612 } 617 }
613} 618}
614 619
615TEWidget* Konsole::getTe() { 620TEWidget* Konsole::getTe() {
616 if (nsessions) { 621 if (nsessions) {
617 return (TEWidget *) tab->currentPage(); 622 return (TEWidget *) tab->currentPage();
618 } else { 623 } else {
619 return 0; 624 return 0;
620 } 625 }
621} 626}
622 627
623void Konsole::switchSession(QWidget* w) { 628void Konsole::switchSession(QWidget* w) {
624 TEWidget* te = (TEWidget *) w; 629 TEWidget* te = (TEWidget *) w;
625 630
626 QFont teFnt = te->getVTFont(); 631 QFont teFnt = te->getVTFont();
627 for(uint i = 0; i < fonts.count(); i++) { 632 for(uint i = 0; i < fonts.count(); i++) {
628 VTFont *fnt = fonts.at(i); 633 VTFont *fnt = fonts.at(i);
629 bool cf = fnt->getFont() == teFnt; 634 bool cf = fnt->getFont() == teFnt;
630 fontList->setItemChecked(i, cf); 635 fontList->setItemChecked(i, cf);
631 if (cf) { 636 if (cf) {
632 cfont = i; 637 cfont = i;
633 } 638 }
634 } 639 }
635} 640}
636 641
637void Konsole::colorMenuIsSelected(int iD) { 642void Konsole::colorMenuIsSelected(int iD) {
638 fromMenu = TRUE; 643 fromMenu = TRUE;
639 colorMenuSelected(iD); 644 colorMenuSelected(iD);
640} 645}
641 646
642/// ------------------------------- some new stuff by L.J. Potter 647/// ------------------------------- some new stuff by L.J. Potter
643void Konsole::colorMenuSelected(int iD) 648void Konsole::colorMenuSelected(int iD)
644{ // this is NOT pretty, elegant or anything else besides functional 649{ // this is NOT pretty, elegant or anything else besides functional
645// QString temp; 650// QString temp;
646// qDebug( temp.sprintf("colormenu %d", iD)); 651// qDebug( temp.sprintf("colormenu %d", iD));
647 TEWidget* te = getTe(); 652 TEWidget* te = getTe();
648 Config cfg("Konsole"); 653 Config cfg("Konsole");
649 cfg.setGroup("Colors"); 654 cfg.setGroup("Colors");
650// QColor foreground; 655// QColor foreground;
651// QColor background; 656// QColor background;
652 colorMenu->setItemChecked(lastSelectedMenu,FALSE); 657 colorMenu->setItemChecked(lastSelectedMenu,FALSE);
653 ColorEntry m_table[TABLE_COLORS]; 658 ColorEntry m_table[TABLE_COLORS];
654 const ColorEntry * defaultCt=te->getdefaultColorTable(); 659 const ColorEntry * defaultCt=te->getdefaultColorTable();
655 /////////// fore back 660 /////////// fore back
656 int i; 661 int i;
657 if(iD==-9) { // default default 662 if(iD==-9) { // default default
658 for (i = 0; i < TABLE_COLORS; i++) { 663 for (i = 0; i < TABLE_COLORS; i++) {
659 m_table[i].color = defaultCt[i].color; 664 m_table[i].color = defaultCt[i].color;
660 if(i==1 || i == 11) 665 if(i==1 || i == 11)
661 m_table[i].transparent=1; 666 m_table[i].transparent=1;
662 cfg.writeEntry("Schema","9"); 667 cfg.writeEntry("Schema","9");
663 colorMenu->setItemChecked(-9,TRUE); 668 colorMenu->setItemChecked(-9,TRUE);
664 } 669 }
665 } else { 670 } else {
666 if(iD==-6) { // green black 671 if(iD==-6) { // green black
667 foreground.setRgb(0x18,255,0x18); 672 foreground.setRgb(0x18,255,0x18);
668 background.setRgb(0x00,0x00,0x00); 673 background.setRgb(0x00,0x00,0x00);
669 cfg.writeEntry("Schema","6"); 674 cfg.writeEntry("Schema","6");
670 colorMenu->setItemChecked(-6,TRUE); 675 colorMenu->setItemChecked(-6,TRUE);
671 } 676 }
672 if(iD==-7) { // black white 677 if(iD==-7) { // black white
673 foreground.setRgb(0x00,0x00,0x00); 678 foreground.setRgb(0x00,0x00,0x00);
674 background.setRgb(0xFF,0xFF,0xFF); 679 background.setRgb(0xFF,0xFF,0xFF);
675 cfg.writeEntry("Schema","7"); 680 cfg.writeEntry("Schema","7");
676 colorMenu->setItemChecked(-7,TRUE); 681 colorMenu->setItemChecked(-7,TRUE);
677 } 682 }
678 if(iD==-8) { // white black 683 if(iD==-8) { // white black
679 foreground.setRgb(0xFF,0xFF,0xFF); 684 foreground.setRgb(0xFF,0xFF,0xFF);
680 background.setRgb(0x00,0x00,0x00); 685 background.setRgb(0x00,0x00,0x00);
681 cfg.writeEntry("Schema","8"); 686 cfg.writeEntry("Schema","8");
682 colorMenu->setItemChecked(-8,TRUE); 687 colorMenu->setItemChecked(-8,TRUE);
683 } 688 }
684 if(iD==-10) {// Black, Red 689 if(iD==-10) {// Black, Red
685 foreground.setRgb(0x00,0x00,0x00); 690 foreground.setRgb(0x00,0x00,0x00);
686 background.setRgb(0xB2,0x18,0x18); 691 background.setRgb(0xB2,0x18,0x18);
687 cfg.writeEntry("Schema","10"); 692 cfg.writeEntry("Schema","10");
688 colorMenu->setItemChecked(-10,TRUE); 693 colorMenu->setItemChecked(-10,TRUE);
689 } 694 }
690 if(iD==-11) {// Red, Black 695 if(iD==-11) {// Red, Black
691 foreground.setRgb(230,31,31); //0xB2,0x18,0x18 696 foreground.setRgb(230,31,31); //0xB2,0x18,0x18
692 background.setRgb(0x00,0x00,0x00); 697 background.setRgb(0x00,0x00,0x00);
693 cfg.writeEntry("Schema","11"); 698 cfg.writeEntry("Schema","11");
694 colorMenu->setItemChecked(-11,TRUE); 699 colorMenu->setItemChecked(-11,TRUE);
695 } 700 }
696 if(iD==-12) {// Green, Yellow - is ugly 701 if(iD==-12) {// Green, Yellow - is ugly
697// foreground.setRgb(0x18,0xB2,0x18); 702// foreground.setRgb(0x18,0xB2,0x18);
698 foreground.setRgb(36,139,10); 703 foreground.setRgb(36,139,10);
699// background.setRgb(0xB2,0x68,0x18); 704// background.setRgb(0xB2,0x68,0x18);
700 background.setRgb(255,255,0); 705 background.setRgb(255,255,0);
701 cfg.writeEntry("Schema","12"); 706 cfg.writeEntry("Schema","12");
702 colorMenu->setItemChecked(-12,TRUE); 707 colorMenu->setItemChecked(-12,TRUE);
703 } 708 }
704 if(iD==-13) {// Blue, Magenta 709 if(iD==-13) {// Blue, Magenta
705 foreground.setRgb(0x18,0xB2,0xB2); 710 foreground.setRgb(0x18,0xB2,0xB2);
706 background.setRgb(0x18,0x18,0xB2); 711 background.setRgb(0x18,0x18,0xB2);
707 cfg.writeEntry("Schema","13"); 712 cfg.writeEntry("Schema","13");
708 colorMenu->setItemChecked(-13,TRUE); 713 colorMenu->setItemChecked(-13,TRUE);
709 } 714 }
710 if(iD==-14) {// Magenta, Blue 715 if(iD==-14) {// Magenta, Blue
711 foreground.setRgb(0x18,0x18,0xB2); 716 foreground.setRgb(0x18,0x18,0xB2);
712 background.setRgb(0x18,0xB2,0xB2); 717 background.setRgb(0x18,0xB2,0xB2);
713 cfg.writeEntry("Schema","14"); 718 cfg.writeEntry("Schema","14");
714 colorMenu->setItemChecked(-14,TRUE); 719 colorMenu->setItemChecked(-14,TRUE);
715 } 720 }
716 if(iD==-15) {// Cyan, White 721 if(iD==-15) {// Cyan, White
717 foreground.setRgb(0x18,0xB2,0xB2); 722 foreground.setRgb(0x18,0xB2,0xB2);
718 background.setRgb(0xFF,0xFF,0xFF); 723 background.setRgb(0xFF,0xFF,0xFF);
719 cfg.writeEntry("Schema","15"); 724 cfg.writeEntry("Schema","15");
720 colorMenu->setItemChecked(-15,TRUE); 725 colorMenu->setItemChecked(-15,TRUE);
721 } 726 }
722 if(iD==-16) {// White, Cyan 727 if(iD==-16) {// White, Cyan
723 background.setRgb(0x18,0xB2,0xB2); 728 background.setRgb(0x18,0xB2,0xB2);
724 foreground.setRgb(0xFF,0xFF,0xFF); 729 foreground.setRgb(0xFF,0xFF,0xFF);
725 cfg.writeEntry("Schema","16"); 730 cfg.writeEntry("Schema","16");
726 colorMenu->setItemChecked(-16,TRUE); 731 colorMenu->setItemChecked(-16,TRUE);
727 } 732 }
728 if(iD==-17) {// Black, Blue 733 if(iD==-17) {// Black, Blue
729 background.setRgb(0x00,0x00,0x00); 734 background.setRgb(0x00,0x00,0x00);
730 foreground.setRgb(0x18,0xB2,0xB2); 735 foreground.setRgb(0x18,0xB2,0xB2);
731 cfg.writeEntry("Schema","17"); 736 cfg.writeEntry("Schema","17");
732 colorMenu->setItemChecked(-17,TRUE); 737 colorMenu->setItemChecked(-17,TRUE);
733 } 738 }
734 if(iD==-18) {// Black, Gold 739 if(iD==-18) {// Black, Gold
735 background.setRgb(0x00,0x00,0x00); 740 background.setRgb(0x00,0x00,0x00);
736 foreground.setRgb(255,215,0); 741 foreground.setRgb(255,215,0);
737 cfg.writeEntry("Schema","18"); 742 cfg.writeEntry("Schema","18");
738 colorMenu->setItemChecked(-18,TRUE); 743 colorMenu->setItemChecked(-18,TRUE);
739 } 744 }
740 if(iD==-19) {// Custom 745 if(iD==-19) {// Custom
741 qDebug("do custom"); 746 qDebug("do custom");
742 if(fromMenu) { 747 if(fromMenu) {
743 ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color"); 748 ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color");
744 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, 749 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this,
745 SLOT(changeForegroundColor(const QColor&))); 750 SLOT(changeForegroundColor(const QColor&)));
746 penColorPopupMenu->exec(); 751 penColorPopupMenu->exec();
747 } 752 }
748 cfg.writeEntry("Schema","19"); 753 cfg.writeEntry("Schema","19");
749 if(!fromMenu) { 754 if(!fromMenu) {
750 foreground.setNamedColor(cfg.readEntry("foreground","")); 755 foreground.setNamedColor(cfg.readEntry("foreground",""));
751 background.setNamedColor(cfg.readEntry("background","")); 756 background.setNamedColor(cfg.readEntry("background",""));
752 } 757 }
753 fromMenu=FALSE; 758 fromMenu=FALSE;
754 colorMenu->setItemChecked(-19,TRUE); 759 colorMenu->setItemChecked(-19,TRUE);
755 } 760 }
756 761
757 for (i = 0; i < TABLE_COLORS; i++) { 762 for (i = 0; i < TABLE_COLORS; i++) {
758 if(i==0 || i == 10) { 763 if(i==0 || i == 10) {
759 m_table[i].color = foreground; 764 m_table[i].color = foreground;
760 } 765 }
761 else if(i==1 || i == 11) { 766 else if(i==1 || i == 11) {
762 m_table[i].color = background; m_table[i].transparent=0; 767 m_table[i].color = background; m_table[i].transparent=0;
763 } 768 }
764 else 769 else
765 m_table[i].color = defaultCt[i].color; 770 m_table[i].color = defaultCt[i].color;
766 } 771 }
767 } 772 }
768 lastSelectedMenu = iD; 773 lastSelectedMenu = iD;
769 te->setColorTable(m_table); 774 te->setColorTable(m_table);
770 update(); 775 update();
771 776
772} 777}
773 778
774void Konsole::configMenuSelected(int iD) 779void Konsole::configMenuSelected(int iD)
775{ 780{
776// QString temp; 781 QString temp;
777// qDebug( temp.sprintf("configmenu %d",iD)); 782 qDebug( temp.sprintf("configmenu %d",iD));
778 TEWidget* te = getTe(); 783 TEWidget* te = getTe();
779 Config cfg("Konsole"); 784 Config cfg("Konsole");
780 cfg.setGroup("Menubar"); 785 cfg.setGroup("Menubar");
781 if( iD == -4) { 786 if( iD == -4) {
782 cfg.setGroup("Tabs"); 787 cfg.setGroup("Tabs");
783 QString tmp=cfg.readEntry("Position","Bottom"); 788 QString tmp=cfg.readEntry("Position","Bottom");
784 789
785 if(tmp=="Top") { 790 if(tmp=="Top") {
786 tab->setTabPosition(QTabWidget::Bottom); 791 tab->setTabPosition(QTabWidget::Bottom);
787 configMenu->changeItem( iD,"Tabs on Top"); 792 configMenu->changeItem( iD,"Tabs on Top");
788 cfg.writeEntry("Position","Bottom"); 793 cfg.writeEntry("Position","Bottom");
789 } else { 794 } else {
790 tab->setTabPosition(QTabWidget::Top); 795 tab->setTabPosition(QTabWidget::Top);
791 configMenu->changeItem( iD,"Tabs on Bottom"); 796 configMenu->changeItem( iD,"Tabs on Bottom");
792 cfg.writeEntry("Position","Top"); 797 cfg.writeEntry("Position","Top");
793 } 798 }
794 } 799 }
800 if( iD == -29) {
801 cfg.setGroup("ScrollBar");
802 bool b=cfg.readBoolEntry("HorzScroll",0);
803 b=!b;
804 cfg.writeEntry("HorzScroll", b );
805 cfg.write();
806 doWrap();
807 if(cfg.readNumEntry("Position",2) == 0) {
808 te->setScrollbarLocation(1);
809 } else {
810 te->setScrollbarLocation(0);
811 }
812 te->setScrollbarLocation( cfg.readNumEntry("Position",2));
813 }
795} 814}
796 815
797void Konsole::changeCommand(const QString &text, int c) 816void Konsole::changeCommand(const QString &text, int c)
798{ 817{
799 Config cfg("Konsole"); 818 Config cfg("Konsole");
800 cfg.setGroup("Commands"); 819 cfg.setGroup("Commands");
801 if(commonCmds[c] != text) { 820 if(commonCmds[c] != text) {
802 cfg.writeEntry(QString::number(c),text); 821 cfg.writeEntry(QString::number(c),text);
803 commonCombo->clearEdit(); 822 commonCombo->clearEdit();
804 commonCombo->setCurrentItem(c); 823 commonCombo->setCurrentItem(c);
805 } 824 }
806} 825}
807 826
808void Konsole::setColor() 827void Konsole::setColor()
809{ 828{
810 Config cfg("Konsole"); 829 Config cfg("Konsole");
811 cfg.setGroup("Colors"); 830 cfg.setGroup("Colors");
812 int scheme = cfg.readNumEntry("Schema",1); 831 int scheme = cfg.readNumEntry("Schema",1);
813 if(scheme != 1) colorMenuSelected( -scheme); 832 if(scheme != 1) colorMenuSelected( -scheme);
814} 833}
815 834
816void Konsole::scrollMenuSelected(int index) 835void Konsole::scrollMenuSelected(int index)
817{ 836{
818 qDebug( "scrollbar menu %d",index); 837 qDebug( "scrollbar menu %d",index);
819 TEWidget* te = getTe(); 838 TEWidget* te = getTe();
820 Config cfg("Konsole"); 839 Config cfg("Konsole");
821 cfg.setGroup("ScrollBar"); 840 cfg.setGroup("ScrollBar");
822 switch( index){ 841 switch( index){
823 case -25: 842 case -25:
824 te->setScrollbarLocation(0); 843 te->setScrollbarLocation(0);
825 cfg.writeEntry("Position",0); 844 cfg.writeEntry("Position",0);
826 break; 845 break;
827 case -26: 846 case -26:
828 te->setScrollbarLocation(1); 847 te->setScrollbarLocation(1);
829 cfg.writeEntry("Position",1); 848 cfg.writeEntry("Position",1);
830 break; 849 break;
831 case -27: 850 case -27:
832 te->setScrollbarLocation(2); 851 te->setScrollbarLocation(2);
833 cfg.writeEntry("Position",2); 852 cfg.writeEntry("Position",2);
834 break; 853 break;
835 case -29: { 854// case -29: {
836 bool b=cfg.readBoolEntry("HorzScroll",0); 855// bool b=cfg.readBoolEntry("HorzScroll",0);
837 cfg.writeEntry("HorzScroll", !b ); 856// cfg.writeEntry("HorzScroll", !b );
838 cfg.write(); 857// cfg.write();
839 if(cfg.readNumEntry("Position",2) == 0) 858// if(cfg.readNumEntry("Position",2) == 0) {
840 te->setScrollbarLocation(1); 859// te->setScrollbarLocation(1);
841 else 860// te->setWrapAt(0);
842 te->setScrollbarLocation(0); 861// } else {
843 te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 862// te->setScrollbarLocation(0);
844 te->setWrapAt(120); 863// te->setWrapAt(120);
845 } 864// }
846 break; 865// te->setScrollbarLocation( cfg.readNumEntry("Position",2));
866// }
867// break;
847 }; 868 };
848
849} 869}
850 870
851void Konsole::editCommandListMenuSelected(int iD) 871void Konsole::editCommandListMenuSelected(int iD)
852{ 872{
853// QString temp; 873// QString temp;
854// qDebug( temp.sprintf("edit command list %d",iD)); 874// qDebug( temp.sprintf("edit command list %d",iD));
855 TEWidget* te = getTe(); 875 TEWidget* te = getTe();
856 Config cfg("Konsole"); 876 Config cfg("Konsole");
857 cfg.setGroup("Menubar"); 877 cfg.setGroup("Menubar");
858 if( iD == -3) { 878 if( iD == -3) {
859 if(!secondToolBar->isHidden()) { 879 if(!secondToolBar->isHidden()) {
860 secondToolBar->hide(); 880 secondToolBar->hide();
861 configMenu->changeItem( iD,tr( "Show Command List" )); 881 configMenu->changeItem( iD,tr( "Show Command List" ));
862 cfg.writeEntry("Hidden","TRUE"); 882 cfg.writeEntry("Hidden","TRUE");
863 configMenu->setItemEnabled(-23 ,FALSE); 883 configMenu->setItemEnabled(-23 ,FALSE);
864 } else { 884 } else {
865 secondToolBar->show(); 885 secondToolBar->show();
866 configMenu->changeItem( iD,tr( "Hide Command List" )); 886 configMenu->changeItem( iD,tr( "Hide Command List" ));
867 cfg.writeEntry("Hidden","FALSE"); 887 cfg.writeEntry("Hidden","FALSE");
868 configMenu->setItemEnabled(-23 ,TRUE); 888 configMenu->setItemEnabled(-23 ,TRUE);
869 889
870 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { 890 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") {
871 configMenu->setItemChecked(-23,TRUE); 891 configMenu->setItemChecked(-23,TRUE);
872 commonCombo->setEditable( TRUE ); 892 commonCombo->setEditable( TRUE );
873 } else { 893 } else {
874 configMenu->setItemChecked(-23,FALSE); 894 configMenu->setItemChecked(-23,FALSE);
875 commonCombo->setEditable( FALSE ); 895 commonCombo->setEditable( FALSE );
876 } 896 }
877 } 897 }
878 } 898 }
879 if( iD == -23) { 899 if( iD == -23) {
880 cfg.setGroup("Commands"); 900 cfg.setGroup("Commands");
881// qDebug("enableCommandEdit"); 901// qDebug("enableCommandEdit");
882 if( !configMenu->isItemChecked(iD) ) { 902 if( !configMenu->isItemChecked(iD) ) {
883 commonCombo->setEditable( TRUE ); 903 commonCombo->setEditable( TRUE );
884 configMenu->setItemChecked(iD,TRUE); 904 configMenu->setItemChecked(iD,TRUE);
885 commonCombo->setCurrentItem(0); 905 commonCombo->setCurrentItem(0);
886 cfg.writeEntry("EditEnabled","TRUE"); 906 cfg.writeEntry("EditEnabled","TRUE");
887 } else { 907 } else {
888 commonCombo->setEditable( FALSE ); 908 commonCombo->setEditable( FALSE );
889 configMenu->setItemChecked(iD,FALSE); 909 configMenu->setItemChecked(iD,FALSE);
890 cfg.writeEntry("EditEnabled","FALSE"); 910 cfg.writeEntry("EditEnabled","FALSE");
891 commonCombo->setFocusPolicy(QWidget::NoFocus); 911 commonCombo->setFocusPolicy(QWidget::NoFocus);
892 te->setFocus(); 912 te->setFocus();
893 } 913 }
894 } 914 }
895 if(iD == -24) { 915 if(iD == -24) {
896 // "edit commands" 916 // "edit commands"
897 CommandEditDialog *m = new CommandEditDialog(this); 917 CommandEditDialog *m = new CommandEditDialog(this);
898 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); 918 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList()));
899 m->showMaximized(); 919 m->showMaximized();
900 } 920 }
901 921
902} 922}
903 923
904// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' 924// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V'
905void Konsole::setDocument( const QString &cmd) { 925void Konsole::setDocument( const QString &cmd) {
906 newSession(); 926 newSession();
907 TEWidget* te = getTe(); 927 TEWidget* te = getTe();
908 if(cmd.find("-e", 0, TRUE) != -1) { 928 if(cmd.find("-e", 0, TRUE) != -1) {
909 QString cmd2; 929 QString cmd2;
910 cmd2=cmd.right(cmd.length()-3)+" &"; 930 cmd2=cmd.right(cmd.length()-3)+" &";
911 system(cmd2.latin1()); 931 system(cmd2.latin1());
912 if(startUp <= 1 && nsessions < 2) { 932 if(startUp <= 1 && nsessions < 2) {
913 doneSession(getTe()->currentSession, 0); 933 doneSession(getTe()->currentSession, 0);
914 exit(0); 934 exit(0);
915 } else 935 } else
916 doneSession(getTe()->currentSession, 0); 936 doneSession(getTe()->currentSession, 0);
917 } else { 937 } else {
918 if (te != 0) { 938 if (te != 0) {
919 te->emitText(cmd+"\r"); 939 te->emitText(cmd+"\r");
920 } 940 }
921 } 941 }
922 startUp++; 942 startUp++;
923} 943}
924 944
925void Konsole::parseCommandLine() { 945void Konsole::parseCommandLine() {
926 QString cmd; 946 QString cmd;
927 // newSession(); 947 // newSession();
928 for (int i=1;i< qApp->argc();i++) { 948 for (int i=1;i< qApp->argc();i++) {
929 if( QString(qApp->argv()[i]) == "-e") { 949 if( QString(qApp->argv()[i]) == "-e") {
930 i++; 950 i++;
931 for ( int j=i;j< qApp->argc();j++) { 951 for ( int j=i;j< qApp->argc();j++) {
932 cmd+=QString(qApp->argv()[j])+" "; 952 cmd+=QString(qApp->argv()[j])+" ";
933 } 953 }
934 cmd.stripWhiteSpace(); 954 cmd.stripWhiteSpace();
935 system(cmd.latin1()); 955 system(cmd.latin1());
936 exit(0);//close(); 956 exit(0);//close();
937 } // end -e switch 957 } // end -e switch
938 } 958 }
939 startUp++; 959 startUp++;
940} 960}
941 961
942void Konsole::changeForegroundColor(const QColor &color) { 962void Konsole::changeForegroundColor(const QColor &color) {
943 Config cfg("Konsole"); 963 Config cfg("Konsole");
944 cfg.setGroup("Colors"); 964 cfg.setGroup("Colors");
945 int r, g, b; 965 int r, g, b;
946 color.rgb(&r,&g,&b); 966 color.rgb(&r,&g,&b);
947 foreground.setRgb(r,g,b); 967 foreground.setRgb(r,g,b);
948// QString colors; 968// QString colors;
949// colors.sprintf("%d,%d,%d"color.red,color.green,color.blue); 969// colors.sprintf("%d,%d,%d"color.red,color.green,color.blue);
950 cfg.writeEntry("foreground",color.name()); 970 cfg.writeEntry("foreground",color.name());
951 cfg.write(); 971 cfg.write();
952 972
953qDebug("do other dialog"); 973qDebug("do other dialog");
954 ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color"); 974 ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color");
955 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, 975 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this,
956 SLOT(changeBackgroundColor(const QColor&))); 976 SLOT(changeBackgroundColor(const QColor&)));
957 penColorPopupMenu2->exec(); 977 penColorPopupMenu2->exec();
958 978
959} 979}
960 980
961void Konsole::changeBackgroundColor(const QColor &color) { 981void Konsole::changeBackgroundColor(const QColor &color) {
962 982
963 qDebug("Change background"); 983 qDebug("Change background");
964 Config cfg("Konsole"); 984 Config cfg("Konsole");
965 cfg.setGroup("Colors"); 985 cfg.setGroup("Colors");
966 int r, g, b; 986 int r, g, b;
967 color.rgb(&r,&g,&b); 987 color.rgb(&r,&g,&b);
968 background.setRgb(r,g,b); 988 background.setRgb(r,g,b);
969// QString colors; 989// QString colors;
970// colors.sprintf("%d,%d,%d"color.red,color.green,color.blue); 990// colors.sprintf("%d,%d,%d"color.red,color.green,color.blue);
971 cfg.writeEntry("background",color.name()); 991 cfg.writeEntry("background",color.name());
972 cfg.write(); 992 cfg.write();
973} 993}
994
995void Konsole::doWrap() {
996 Config cfg("Konsole");
997 cfg.setGroup("ScrollBar");
998 TEWidget* te = getTe();
999 if( !cfg.readBoolEntry("HorzScroll",0)) {
1000 te->setWrapAt(0);
1001 configMenu->setItemChecked(-29,FALSE);
1002 } else {
1003 te->setWrapAt(90);
1004// te->setWrapAt(120);
1005 configMenu->setItemChecked(-29,TRUE);
1006 }
1007}
diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h
index 0bf3fb3..4938159 100644
--- a/core/apps/embeddedkonsole/konsole.h
+++ b/core/apps/embeddedkonsole/konsole.h
@@ -1,143 +1,144 @@
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> 33#include <qpe/qpetoolbar.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qcolor.h> 35#include <qcolor.h>
36 36
37#include "MyPty.h" 37#include "MyPty.h"
38#include "TEWidget.h" 38#include "TEWidget.h"
39#include "TEmuVt102.h" 39#include "TEmuVt102.h"
40#include "session.h" 40#include "session.h"
41 41
42class EKNumTabWidget; 42class EKNumTabWidget;
43 43
44class Konsole : public QMainWindow 44class Konsole : public QMainWindow
45{ 45{
46Q_OBJECT 46Q_OBJECT
47 47
48public: 48public:
49 49
50 Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); 50 Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
51 Konsole(const char * name, const char* pgm, QStrList & _args, int histon); 51 Konsole(const char * name, const char* pgm, QStrList & _args, int histon);
52 ~Konsole(); 52 ~Konsole();
53 void setColLin(int columns, int lines); 53 void setColLin(int columns, int lines);
54 QPEToolBar *secondToolBar; 54 QPEToolBar *secondToolBar;
55 void show(); 55 void show();
56 void setColor(); 56 void setColor();
57 int lastSelectedMenu; 57 int lastSelectedMenu;
58 int startUp; 58 int startUp;
59private slots: 59private slots:
60 void setDocument(const QString &); 60 void setDocument(const QString &);
61 void doneSession(TESession*,int); 61 void doneSession(TESession*,int);
62 void changeColumns(int); 62 void changeColumns(int);
63 void fontChanged(int); 63 void fontChanged(int);
64 void configMenuSelected(int ); 64 void configMenuSelected(int );
65 void colorMenuSelected(int); 65 void colorMenuSelected(int);
66 void colorMenuIsSelected(int); 66 void colorMenuIsSelected(int);
67 void enterCommand(int); 67 void enterCommand(int);
68 void hitEnter(); 68 void hitEnter();
69 void hitSpace(); 69 void hitSpace();
70 void hitTab(); 70 void hitTab();
71 void hitPaste(); 71 void hitPaste();
72 void hitUp(); 72 void hitUp();
73 void hitDown(); 73 void hitDown();
74 void switchSession(QWidget *); 74 void switchSession(QWidget *);
75 void newSession(); 75 void newSession();
76 void changeCommand(const QString &, int); 76 void changeCommand(const QString &, int);
77 void initCommandList(); 77 void initCommandList();
78 void scrollMenuSelected(int); 78 void scrollMenuSelected(int);
79 void editCommandListMenuSelected(int); 79 void editCommandListMenuSelected(int);
80 void parseCommandLine(); 80 void parseCommandLine();
81 void changeForegroundColor(const QColor &); 81 void changeForegroundColor(const QColor &);
82 void changeBackgroundColor(const QColor &); 82 void changeBackgroundColor(const QColor &);
83private: 83private:
84 void doWrap();
84 void init(const char* _pgm, QStrList & _args); 85 void init(const char* _pgm, QStrList & _args);
85 void initSession(const char* _pgm, QStrList & _args); 86 void initSession(const char* _pgm, QStrList & _args);
86 void runSession(TESession* s); 87 void runSession(TESession* s);
87 void setColorPixmaps(); 88 void setColorPixmaps();
88 void setHistory(bool); 89 void setHistory(bool);
89 QSize calcSize(int columns, int lines); 90 QSize calcSize(int columns, int lines);
90 TEWidget* getTe(); 91 TEWidget* getTe();
91 QStringList commands; 92 QStringList commands;
92 QLabel * msgLabel; 93 QLabel * msgLabel;
93 QColor foreground, background; 94 QColor foreground, background;
94bool fromMenu; 95bool fromMenu;
95private: 96private:
96 class VTFont 97 class VTFont
97 { 98 {
98 public: 99 public:
99 VTFont(QString name, QFont& font) 100 VTFont(QString name, QFont& font)
100 { 101 {
101 this->name = name; 102 this->name = name;
102 this->font = font; 103 this->font = font;
103 } 104 }
104 105
105 QFont& getFont() 106 QFont& getFont()
106 { 107 {
107 return font; 108 return font;
108 } 109 }
109 110
110 QString getName() 111 QString getName()
111 { 112 {
112 return name; 113 return name;
113 } 114 }
114 115
115 private: 116 private:
116 QString name; 117 QString name;
117 QFont font; 118 QFont font;
118 }; 119 };
119 120
120 EKNumTabWidget* tab; 121 EKNumTabWidget* tab;
121 int nsessions; 122 int nsessions;
122 QList<VTFont> fonts; 123 QList<VTFont> fonts;
123 int cfont; 124 int cfont;
124 QCString se_pgm; 125 QCString se_pgm;
125 QStrList se_args; 126 QStrList se_args;
126 127
127 QPopupMenu *fontList,*configMenu,*colorMenu,*scrollMenu,*editCommandListMenu; 128 QPopupMenu *fontList,*configMenu,*colorMenu,*scrollMenu,*editCommandListMenu;
128 QComboBox *commonCombo; 129 QComboBox *commonCombo;
129 // history scrolling I think 130 // history scrolling I think
130 bool b_scroll; 131 bool b_scroll;
131 132
132 int n_keytab; 133 int n_keytab;
133 int n_scroll; 134 int n_scroll;
134 int n_render; 135 int n_render;
135 QString pmPath; // pixmap path 136 QString pmPath; // pixmap path
136 QString dropText; 137 QString dropText;
137 QFont defaultFont; 138 QFont defaultFont;
138 QSize defaultSize; 139 QSize defaultSize;
139 140
140}; 141};
141 142
142#endif 143#endif
143 144