summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TEHistory.cpp2
-rw-r--r--core/apps/embeddedkonsole/TEScreen.cpp2
-rw-r--r--core/apps/embeddedkonsole/TEWidget.cpp4
-rw-r--r--core/apps/embeddedkonsole/commandeditdialog.cpp2
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp31
5 files changed, 21 insertions, 20 deletions
diff --git a/core/apps/embeddedkonsole/TEHistory.cpp b/core/apps/embeddedkonsole/TEHistory.cpp
index 504cd13..2417af1 100644
--- a/core/apps/embeddedkonsole/TEHistory.cpp
+++ b/core/apps/embeddedkonsole/TEHistory.cpp
@@ -1,230 +1,230 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [TEHistory.C] History Buffer */ 3/* [TEHistory.C] 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 Qkonsole - an X terminal for KDE */ 9/* This file is part of Qkonsole - an X terminal for KDE */
10/* */ 10/* */
11/* -------------------------------------------------------------------------- */ 11/* -------------------------------------------------------------------------- */
12/* */ 12/* */
13/* Ported Qkonsole to Qt/Embedded */ 13/* Ported Qkonsole 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#include "TEHistory.h" 19#include "TEHistory.h"
20#include <stdlib.h> 20#include <stdlib.h>
21#include <assert.h> 21#include <assert.h>
22#include <stdio.h> 22#include <stdio.h>
23#include <sys/types.h> 23#include <sys/types.h>
24#include <unistd.h> 24#include <unistd.h>
25#include <errno.h> 25#include <errno.h>
26 26
27#include <qpe/config.h> 27#include <qpe/config.h>
28 28
29#define HERE printf("%s(%d): here\n",__FILE__,__LINE__) 29#define HERE printf("%s(%d): here\n",__FILE__,__LINE__)
30 30
31/* 31/*
32 An arbitrary long scroll. 32 An arbitrary long scroll.
33 33
34 One can modify the scroll only by adding either cells 34 One can modify the scroll only by adding either cells
35 or newlines, but access it randomly. 35 or newlines, but access it randomly.
36 36
37 The model is that of an arbitrary wide typewriter scroll 37 The model is that of an arbitrary wide typewriter scroll
38 in that the scroll is a serie of lines and each line is 38 in that the scroll is a serie of lines and each line is
39 a serie of cells with no overwriting permitted. 39 a serie of cells with no overwriting permitted.
40 40
41 The implementation provides arbitrary length and numbers 41 The implementation provides arbitrary length and numbers
42 of cells and line/column indexed read access to the scroll 42 of cells and line/column indexed read access to the scroll
43 at constant costs. 43 at constant costs.
44 44
45*/ 45*/
46 46
47 47
48HistoryScroll::HistoryScroll() 48HistoryScroll::HistoryScroll()
49{ 49{
50 m_lines = NULL; 50 m_lines = NULL;
51 m_max_lines = 0; 51 m_max_lines = 0;
52 m_cells = NULL; 52 m_cells = NULL;
53 m_max_cells = 0; 53 m_max_cells = 0;
54 m_num_lines = 0; 54 m_num_lines = 0;
55 m_first_line = 0; 55 m_first_line = 0;
56 m_last_cell = 0; 56 m_last_cell = 0;
57 m_start_line = 0; 57 m_start_line = 0;
58} 58}
59 59
60HistoryScroll::~HistoryScroll() 60HistoryScroll::~HistoryScroll()
61{ 61{
62 setSize(0,0); 62 setSize(0,0);
63} 63}
64 64
65void HistoryScroll::setSize(int lines, int cells) 65void HistoryScroll::setSize(int lines, int cells)
66{ 66{
67 // could try to preserve the existing data... 67 // could try to preserve the existing data...
68 // printf("setSize(%d,%d)\n", lines, cells); 68 // printf("setSize(%d,%d)\n", lines, cells);
69 if (m_lines) { 69 if (m_lines) {
70 delete m_lines; 70 delete m_lines;
71 m_lines = NULL; 71 m_lines = NULL;
72 } 72 }
73 if (m_cells) { 73 if (m_cells) {
74 delete m_cells; 74 delete m_cells;
75 m_cells = NULL; 75 m_cells = NULL;
76 } 76 }
77 m_max_lines = m_max_cells = 0; 77 m_max_lines = m_max_cells = 0;
78 if (lines > 0 && cells > 0) { 78 if (lines > 0 && cells > 0) {
79 m_max_lines = lines; 79 m_max_lines = lines;
80 m_lines = new int[m_max_lines]; 80 m_lines = new int[m_max_lines];
81 m_lines[0] = 0; 81 m_lines[0] = 0;
82 m_max_cells = cells; 82 m_max_cells = cells;
83 m_cells = new ca[m_max_cells]; 83 m_cells = new ca[m_max_cells];
84 } 84 }
85 m_first_line = 0; 85 m_first_line = 0;
86 m_num_lines = 0; 86 m_num_lines = 0;
87 m_last_cell = 0; 87 m_last_cell = 0;
88 m_start_line = 0; 88 m_start_line = 0;
89} 89}
90 90
91void HistoryScroll::setScroll(bool on) 91void HistoryScroll::setScroll(bool on)
92{ 92{
93 Config cfg("Qkonsole"); 93 Config cfg( "Konsole" );
94 cfg.setGroup("History"); 94 cfg.setGroup("History");
95 // printf("setScroll(%d)\n", on); 95 // printf("setScroll(%d)\n", on);
96 if (on) { 96 if (on) {
97 int lines = cfg.readNumEntry("history_lines",300); 97 int lines = cfg.readNumEntry("history_lines",300);
98 int avg_line = cfg.readNumEntry("avg_line_length",60); 98 int avg_line = cfg.readNumEntry("avg_line_length",60);
99 int cells = lines * avg_line; 99 int cells = lines * avg_line;
100 setSize(lines,cells); 100 setSize(lines,cells);
101 } else { 101 } else {
102 setSize(0,0); 102 setSize(0,0);
103 } 103 }
104} 104}
105 105
106bool HistoryScroll::hasScroll() 106bool HistoryScroll::hasScroll()
107{ 107{
108 return (m_max_lines > 0); 108 return (m_max_lines > 0);
109} 109}
110 110
111int HistoryScroll::getLines() 111int HistoryScroll::getLines()
112{ 112{
113 return(m_num_lines); 113 return(m_num_lines);
114} 114}
115 115
116int HistoryScroll::getLineLen(int lineno) 116int HistoryScroll::getLineLen(int lineno)
117{ 117{
118 if (!hasScroll()) return 0; 118 if (!hasScroll()) return 0;
119 if (lineno >= m_num_lines) { 119 if (lineno >= m_num_lines) {
120 // printf("getLineLen(%d) out of range %d\n", lineno, m_num_lines); 120 // printf("getLineLen(%d) out of range %d\n", lineno, m_num_lines);
121 return(0); 121 return(0);
122 } 122 }
123 int len = startOfLine(lineno+1) - startOfLine(lineno); 123 int len = startOfLine(lineno+1) - startOfLine(lineno);
124 if (len < 0) { 124 if (len < 0) {
125 len += m_max_cells; 125 len += m_max_cells;
126 } 126 }
127 // printf("getLineLen(%d) = %d\n", lineno, len); 127 // printf("getLineLen(%d) = %d\n", lineno, len);
128 return(len); 128 return(len);
129} 129}
130 130
131int HistoryScroll::startOfLine(int lineno) 131int HistoryScroll::startOfLine(int lineno)
132{ 132{
133 // printf("startOfLine(%d) =", lineno); 133 // printf("startOfLine(%d) =", lineno);
134 if (!hasScroll()) return 0; 134 if (!hasScroll()) return 0;
135 assert(lineno >= 0 && lineno <= m_num_lines); 135 assert(lineno >= 0 && lineno <= m_num_lines);
136 if (lineno < m_num_lines) { 136 if (lineno < m_num_lines) {
137 int index = lineno + m_first_line; 137 int index = lineno + m_first_line;
138 if (index >= m_max_lines) 138 if (index >= m_max_lines)
139 index -= m_max_lines; 139 index -= m_max_lines;
140 // printf("%d\n", m_lines[index]); 140 // printf("%d\n", m_lines[index]);
141 return(m_lines[index]); 141 return(m_lines[index]);
142 } else { 142 } else {
143 // printf("last %d\n", m_last_cell); 143 // printf("last %d\n", m_last_cell);
144 return(m_last_cell); 144 return(m_last_cell);
145 } 145 }
146} 146}
147 147
148void HistoryScroll::getCells(int lineno, int colno, int count, ca *res) 148void HistoryScroll::getCells(int lineno, int colno, int count, ca *res)
149{ 149{
150 // printf("getCells(%d,%d,%d) num_lines=%d\n", lineno, colno, count, m_num_lines); 150 // printf("getCells(%d,%d,%d) num_lines=%d\n", lineno, colno, count, m_num_lines);
151 assert(hasScroll()); 151 assert(hasScroll());
152 assert(lineno >= 0 && lineno < m_num_lines); 152 assert(lineno >= 0 && lineno < m_num_lines);
153 int index = lineno + m_first_line; 153 int index = lineno + m_first_line;
154 if (index >= m_max_lines) 154 if (index >= m_max_lines)
155 index -= m_max_lines; 155 index -= m_max_lines;
156 assert(index >= 0 && index < m_max_lines); 156 assert(index >= 0 && index < m_max_lines);
157 index = m_lines[index] + colno; 157 index = m_lines[index] + colno;
158 assert(index >= 0 && index < m_max_cells); 158 assert(index >= 0 && index < m_max_cells);
159 while(count-- > 0) { 159 while(count-- > 0) {
160 *res++ = m_cells[index]; 160 *res++ = m_cells[index];
161 if (++index >= m_max_cells) { 161 if (++index >= m_max_cells) {
162 index = 0; 162 index = 0;
163 } 163 }
164 } 164 }
165} 165}
166 166
167void HistoryScroll::addCells(ca *text, int count) 167void HistoryScroll::addCells(ca *text, int count)
168{ 168{
169 if (!hasScroll()) return; 169 if (!hasScroll()) return;
170 int start_cell = m_last_cell; 170 int start_cell = m_last_cell;
171 // printf("addCells count=%d start=%d first_line=%d first_cell=%d lines=%d\n", 171 // printf("addCells count=%d start=%d first_line=%d first_cell=%d lines=%d\n",
172 // count, start_cell, m_first_line, m_lines[m_first_line], m_num_lines); 172 // count, start_cell, m_first_line, m_lines[m_first_line], m_num_lines);
173 if (count <= 0) { 173 if (count <= 0) {
174 return; 174 return;
175 } 175 }
176 while(count-- > 0) { 176 while(count-- > 0) {
177 assert (m_last_cell >= 0 && m_last_cell < m_max_cells ); 177 assert (m_last_cell >= 0 && m_last_cell < m_max_cells );
178 m_cells[m_last_cell] = *text++; 178 m_cells[m_last_cell] = *text++;
179 if (++m_last_cell >= m_max_cells) { 179 if (++m_last_cell >= m_max_cells) {
180 m_last_cell = 0; 180 m_last_cell = 0;
181 } 181 }
182 } 182 }
183 if (m_num_lines > 1) { 183 if (m_num_lines > 1) {
184 if (m_last_cell > start_cell) { 184 if (m_last_cell > start_cell) {
185 while(m_num_lines > 0 185 while(m_num_lines > 0
186 && m_lines[m_first_line] >= start_cell 186 && m_lines[m_first_line] >= start_cell
187 && m_lines[m_first_line] < m_last_cell) { 187 && m_lines[m_first_line] < m_last_cell) {
188 // printf("A remove %d>%d && %d<%d first_line=%d num_lines=%d\n", 188 // printf("A remove %d>%d && %d<%d first_line=%d num_lines=%d\n",
189 // m_lines[m_first_line], start_cell, m_lines[m_first_line], m_last_cell, 189 // m_lines[m_first_line], start_cell, m_lines[m_first_line], m_last_cell,
190 // m_first_line, m_num_lines); 190 // m_first_line, m_num_lines);
191 if (++m_first_line >= m_max_lines) { 191 if (++m_first_line >= m_max_lines) {
192 m_first_line = 0; 192 m_first_line = 0;
193 } 193 }
194 m_num_lines--; 194 m_num_lines--;
195 } 195 }
196 } else { 196 } else {
197 while(m_num_lines > 0 197 while(m_num_lines > 0
198 && (m_lines[m_first_line] >= start_cell 198 && (m_lines[m_first_line] >= start_cell
199 || m_lines[m_first_line] < m_last_cell)) { 199 || m_lines[m_first_line] < m_last_cell)) {
200 // printf("B remove %d>%d || %d<%d first_line=%d num_lines=%d\n", 200 // printf("B remove %d>%d || %d<%d first_line=%d num_lines=%d\n",
201 // m_lines[m_first_line], start_cell, m_lines[m_first_line], m_last_cell, 201 // m_lines[m_first_line], start_cell, m_lines[m_first_line], m_last_cell,
202 // m_first_line, m_num_lines); 202 // m_first_line, m_num_lines);
203 if (++m_first_line >= m_max_lines) { 203 if (++m_first_line >= m_max_lines) {
204 m_first_line = 0; 204 m_first_line = 0;
205 } 205 }
206 m_num_lines--; 206 m_num_lines--;
207 } 207 }
208 } 208 }
209 } 209 }
210} 210}
211 211
212void HistoryScroll::addLine() 212void HistoryScroll::addLine()
213{ 213{
214 if (!hasScroll()) return; 214 if (!hasScroll()) return;
215 int index = m_first_line + m_num_lines; 215 int index = m_first_line + m_num_lines;
216 if (index >= m_max_lines) { 216 if (index >= m_max_lines) {
217 index -= m_max_lines; 217 index -= m_max_lines;
218 } 218 }
219 // printf("addLine line=%d cell=%d\n", index, m_last_cell); 219 // printf("addLine line=%d cell=%d\n", index, m_last_cell);
220 assert(index >= 0 && index < m_max_lines); 220 assert(index >= 0 && index < m_max_lines);
221 m_lines[index] = m_start_line; 221 m_lines[index] = m_start_line;
222 m_start_line = m_last_cell; 222 m_start_line = m_last_cell;
223 if (m_num_lines >= m_max_lines) { 223 if (m_num_lines >= m_max_lines) {
224 if (++m_first_line >= m_num_lines) { 224 if (++m_first_line >= m_num_lines) {
225 m_first_line = 0; 225 m_first_line = 0;
226 } 226 }
227 } else { 227 } else {
228 m_num_lines++; 228 m_num_lines++;
229 } 229 }
230} 230}
diff --git a/core/apps/embeddedkonsole/TEScreen.cpp b/core/apps/embeddedkonsole/TEScreen.cpp
index 4ebc28e..3dbcec2 100644
--- a/core/apps/embeddedkonsole/TEScreen.cpp
+++ b/core/apps/embeddedkonsole/TEScreen.cpp
@@ -181,769 +181,769 @@ void TEScreen::setMargins(int top, int bot)
181 __FILE__,__LINE__,top,bot); 181 __FILE__,__LINE__,top,bot);
182 return; // Default error action: ignore 182 return; // Default error action: ignore
183 } 183 }
184 tmargin = top; 184 tmargin = top;
185 bmargin = bot; 185 bmargin = bot;
186 cuX = 0; 186 cuX = 0;
187 cuY = getMode(MODE_Origin) ? top : 0; 187 cuY = getMode(MODE_Origin) ? top : 0;
188} 188}
189 189
190/*! 190/*!
191 Move the cursor down one line. 191 Move the cursor down one line.
192 192
193 If cursor is on bottom margin, the region between the 193 If cursor is on bottom margin, the region between the
194 actual top and bottom margin is scrolled up instead. 194 actual top and bottom margin is scrolled up instead.
195*/ 195*/
196 196
197void TEScreen::index() 197void TEScreen::index()
198//=IND 198//=IND
199{ 199{
200 if (cuY == bmargin) 200 if (cuY == bmargin)
201 { 201 {
202 if (tmargin == 0 && bmargin == lines-1) addHistLine(); // hist.history 202 if (tmargin == 0 && bmargin == lines-1) addHistLine(); // hist.history
203 scrollUp(tmargin,1); 203 scrollUp(tmargin,1);
204 } 204 }
205 else if (cuY < lines-1) 205 else if (cuY < lines-1)
206 cuY += 1; 206 cuY += 1;
207} 207}
208 208
209/*! 209/*!
210 Move the cursor up one line. 210 Move the cursor up one line.
211 211
212 If cursor is on the top margin, the region between the 212 If cursor is on the top margin, the region between the
213 actual top and bottom margin is scrolled down instead. 213 actual top and bottom margin is scrolled down instead.
214*/ 214*/
215 215
216void TEScreen::reverseIndex() 216void TEScreen::reverseIndex()
217//=RI 217//=RI
218{ 218{
219 if (cuY == tmargin) 219 if (cuY == tmargin)
220 scrollDown(tmargin,1); 220 scrollDown(tmargin,1);
221 else if (cuY > 0) 221 else if (cuY > 0)
222 cuY -= 1; 222 cuY -= 1;
223} 223}
224 224
225/*! 225/*!
226 Move the cursor to the begin of the next line. 226 Move the cursor to the begin of the next line.
227 227
228 If cursor is on bottom margin, the region between the 228 If cursor is on bottom margin, the region between the
229 actual top and bottom margin is scrolled up. 229 actual top and bottom margin is scrolled up.
230*/ 230*/
231 231
232void TEScreen::NextLine() 232void TEScreen::NextLine()
233//=NEL 233//=NEL
234{ 234{
235 Return(); index(); 235 Return(); index();
236} 236}
237 237
238// Line Editing ---------------------------------------------------------------- 238// Line Editing ----------------------------------------------------------------
239 239
240/*! \section inserting / deleting characters 240/*! \section inserting / deleting characters
241*/ 241*/
242 242
243/*! erase `n' characters starting from (including) the cursor position. 243/*! erase `n' characters starting from (including) the cursor position.
244 244
245 The line is filled in from the right with spaces. 245 The line is filled in from the right with spaces.
246*/ 246*/
247 247
248void TEScreen::eraseChars(int n) 248void TEScreen::eraseChars(int n)
249{ 249{
250 if (n == 0) n = 1; // Default 250 if (n == 0) n = 1; // Default
251 int p = QMAX(0,QMIN(cuX+n-1,columns-1)); 251 int p = QMAX(0,QMIN(cuX+n-1,columns-1));
252 clearImage(loc(cuX,cuY),loc(p,cuY),' '); 252 clearImage(loc(cuX,cuY),loc(p,cuY),' ');
253} 253}
254 254
255/*! delete `n' characters starting from (including) the cursor position. 255/*! delete `n' characters starting from (including) the cursor position.
256 256
257 The line is filled in from the right with spaces. 257 The line is filled in from the right with spaces.
258*/ 258*/
259 259
260void TEScreen::deleteChars(int n) 260void TEScreen::deleteChars(int n)
261{ 261{
262 if (n == 0) n = 1; // Default 262 if (n == 0) n = 1; // Default
263 int p = QMAX(0,QMIN(cuX+n,columns-1)); 263 int p = QMAX(0,QMIN(cuX+n,columns-1));
264 moveImage(loc(cuX,cuY),loc(p,cuY),loc(columns-1,cuY)); 264 moveImage(loc(cuX,cuY),loc(p,cuY),loc(columns-1,cuY));
265 clearImage(loc(columns-n,cuY),loc(columns-1,cuY),' '); 265 clearImage(loc(columns-n,cuY),loc(columns-1,cuY),' ');
266} 266}
267 267
268/*! insert `n' spaces at the cursor position. 268/*! insert `n' spaces at the cursor position.
269 269
270 The cursor is not moved by the operation. 270 The cursor is not moved by the operation.
271*/ 271*/
272 272
273void TEScreen::insertChars(int n) 273void TEScreen::insertChars(int n)
274{ 274{
275 if (n == 0) n = 1; // Default 275 if (n == 0) n = 1; // Default
276 int p = QMAX(0,QMIN(columns-1-n,columns-1)); 276 int p = QMAX(0,QMIN(columns-1-n,columns-1));
277 int q = QMAX(0,QMIN(cuX+n,columns-1)); 277 int q = QMAX(0,QMIN(cuX+n,columns-1));
278 moveImage(loc(q,cuY),loc(cuX,cuY),loc(p,cuY)); 278 moveImage(loc(q,cuY),loc(cuX,cuY),loc(p,cuY));
279 clearImage(loc(cuX,cuY),loc(q-1,cuY),' '); 279 clearImage(loc(cuX,cuY),loc(q-1,cuY),' ');
280} 280}
281 281
282/*! delete `n' lines starting from (including) the cursor position. 282/*! delete `n' lines starting from (including) the cursor position.
283 283
284 The cursor is not moved by the operation. 284 The cursor is not moved by the operation.
285*/ 285*/
286 286
287void TEScreen::deleteLines(int n) 287void TEScreen::deleteLines(int n)
288{ 288{
289 if (n == 0) n = 1; // Default 289 if (n == 0) n = 1; // Default
290 scrollUp(cuY,n); 290 scrollUp(cuY,n);
291} 291}
292 292
293/*! insert `n' lines at the cursor position. 293/*! insert `n' lines at the cursor position.
294 294
295 The cursor is not moved by the operation. 295 The cursor is not moved by the operation.
296*/ 296*/
297 297
298void TEScreen::insertLines(int n) 298void TEScreen::insertLines(int n)
299{ 299{
300 if (n == 0) n = 1; // Default 300 if (n == 0) n = 1; // Default
301 scrollDown(cuY,n); 301 scrollDown(cuY,n);
302} 302}
303 303
304// Mode Operations ----------------------------------------------------------- 304// Mode Operations -----------------------------------------------------------
305 305
306/*! Set a specific mode. */ 306/*! Set a specific mode. */
307 307
308void TEScreen::setMode(int m) 308void TEScreen::setMode(int m)
309{ 309{
310 currParm.mode[m] = TRUE; 310 currParm.mode[m] = TRUE;
311 switch(m) 311 switch(m)
312 { 312 {
313 case MODE_Origin : cuX = 0; cuY = tmargin; break; //FIXME: home 313 case MODE_Origin : cuX = 0; cuY = tmargin; break; //FIXME: home
314 } 314 }
315} 315}
316 316
317/*! Reset a specific mode. */ 317/*! Reset a specific mode. */
318 318
319void TEScreen::resetMode(int m) 319void TEScreen::resetMode(int m)
320{ 320{
321 currParm.mode[m] = FALSE; 321 currParm.mode[m] = FALSE;
322 switch(m) 322 switch(m)
323 { 323 {
324 case MODE_Origin : cuX = 0; cuY = 0; break; //FIXME: home 324 case MODE_Origin : cuX = 0; cuY = 0; break; //FIXME: home
325 } 325 }
326} 326}
327 327
328/*! Save a specific mode. */ 328/*! Save a specific mode. */
329 329
330void TEScreen::saveMode(int m) 330void TEScreen::saveMode(int m)
331{ 331{
332 saveParm.mode[m] = currParm.mode[m]; 332 saveParm.mode[m] = currParm.mode[m];
333} 333}
334 334
335/*! Restore a specific mode. */ 335/*! Restore a specific mode. */
336 336
337void TEScreen::restoreMode(int m) 337void TEScreen::restoreMode(int m)
338{ 338{
339 currParm.mode[m] = saveParm.mode[m]; 339 currParm.mode[m] = saveParm.mode[m];
340} 340}
341 341
342//NOTE: this is a helper function 342//NOTE: this is a helper function
343/*! Return the setting a specific mode. */ 343/*! Return the setting a specific mode. */
344BOOL TEScreen::getMode(int m) 344BOOL TEScreen::getMode(int m)
345{ 345{
346 return currParm.mode[m]; 346 return currParm.mode[m];
347} 347}
348 348
349/*! Save the cursor position and the rendition attribute settings. */ 349/*! Save the cursor position and the rendition attribute settings. */
350 350
351void TEScreen::saveCursor() 351void TEScreen::saveCursor()
352{ 352{
353 sa_cuX = cuX; 353 sa_cuX = cuX;
354 sa_cuY = cuY; 354 sa_cuY = cuY;
355 sa_cu_re = cu_re; 355 sa_cu_re = cu_re;
356 sa_cu_fg = cu_fg; 356 sa_cu_fg = cu_fg;
357 sa_cu_bg = cu_bg; 357 sa_cu_bg = cu_bg;
358} 358}
359 359
360/*! Restore the cursor position and the rendition attribute settings. */ 360/*! Restore the cursor position and the rendition attribute settings. */
361 361
362void TEScreen::restoreCursor() 362void TEScreen::restoreCursor()
363{ 363{
364 cuX = QMIN(sa_cuX,columns-1); 364 cuX = QMIN(sa_cuX,columns-1);
365 cuY = QMIN(sa_cuY,lines-1); 365 cuY = QMIN(sa_cuY,lines-1);
366 cu_re = sa_cu_re; 366 cu_re = sa_cu_re;
367 cu_fg = sa_cu_fg; 367 cu_fg = sa_cu_fg;
368 cu_bg = sa_cu_bg; 368 cu_bg = sa_cu_bg;
369 effectiveRendition(); 369 effectiveRendition();
370} 370}
371 371
372/* ------------------------------------------------------------------------- */ 372/* ------------------------------------------------------------------------- */
373/* */ 373/* */
374/* Screen Operations */ 374/* Screen Operations */
375/* */ 375/* */
376/* ------------------------------------------------------------------------- */ 376/* ------------------------------------------------------------------------- */
377 377
378/*! Assing a new size to the screen. 378/*! Assing a new size to the screen.
379 379
380 The topmost left position is maintained, while lower lines 380 The topmost left position is maintained, while lower lines
381 or right hand side columns might be removed or filled with 381 or right hand side columns might be removed or filled with
382 spaces to fit the new size. 382 spaces to fit the new size.
383 383
384 The region setting is reset to the whole screen and the 384 The region setting is reset to the whole screen and the
385 tab positions reinitialized. 385 tab positions reinitialized.
386*/ 386*/
387 387
388void TEScreen::resizeImage(int new_lines, int new_columns) 388void TEScreen::resizeImage(int new_lines, int new_columns)
389{ 389{
390 if (cuY > new_lines-1) { 390 if (cuY > new_lines-1) {
391// attempt to preserve focus and lines 391// attempt to preserve focus and lines
392 bmargin = lines-1; //FIXME: margin lost 392 bmargin = lines-1; //FIXME: margin lost
393 for (int i = 0; i < cuY-(new_lines-1); i++) { 393 for (int i = 0; i < cuY-(new_lines-1); i++) {
394 addHistLine(); scrollUp(horzCursor,1); 394 addHistLine(); scrollUp(horzCursor,1);
395 } 395 }
396 } 396 }
397 397
398 // make new image 398 // make new image
399 ca* newimg = (ca*)malloc( new_lines * new_columns * sizeof( ca)); 399 ca* newimg = (ca*)malloc( new_lines * new_columns * sizeof( ca));
400 400
401 clearSelection(); 401 clearSelection();
402 402
403 // clear new image 403 // clear new image
404 for (int y = 0; y < new_lines; y++) 404 for (int y = 0; y < new_lines; y++)
405 for (int x = 0; x < new_columns; x++) { 405 for (int x = 0; x < new_columns; x++) {
406 newimg[y*new_columns+x].c = ' '; 406 newimg[y*new_columns+x].c = ' ';
407 newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; 407 newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR;
408 newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR; 408 newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR;
409 newimg[y*new_columns+x].r = DEFAULT_RENDITION; 409 newimg[y*new_columns+x].r = DEFAULT_RENDITION;
410 } 410 }
411 int cpy_lines = QMIN(new_lines, lines); 411 int cpy_lines = QMIN(new_lines, lines);
412 int cpy_columns = QMIN(new_columns,columns); 412 int cpy_columns = QMIN(new_columns,columns);
413 // copy to new image 413 // copy to new image
414 for (int y = 0; y < cpy_lines; y++) 414 for (int y = 0; y < cpy_lines; y++)
415 for (int x = 0; x < cpy_columns; x++) { 415 for (int x = 0; x < cpy_columns; x++) {
416 newimg[y*new_columns+x].c = image[loc(x,y)].c; 416 newimg[y*new_columns+x].c = image[loc(x,y)].c;
417 newimg[y*new_columns+x].f = image[loc(x,y)].f; 417 newimg[y*new_columns+x].f = image[loc(x,y)].f;
418 newimg[y*new_columns+x].b = image[loc(x,y)].b; 418 newimg[y*new_columns+x].b = image[loc(x,y)].b;
419 newimg[y*new_columns+x].r = image[loc(x,y)].r; 419 newimg[y*new_columns+x].r = image[loc(x,y)].r;
420 } 420 }
421 free(image); 421 free(image);
422 image = newimg; 422 image = newimg;
423 lines = new_lines; 423 lines = new_lines;
424 columns = new_columns; 424 columns = new_columns;
425 cuX = QMIN(cuX,columns-1); 425 cuX = QMIN(cuX,columns-1);
426 cuY = QMIN(cuY,lines-1); 426 cuY = QMIN(cuY,lines-1);
427 427
428 // FIXME: try to keep values, evtl. 428 // FIXME: try to keep values, evtl.
429 tmargin=0; 429 tmargin=0;
430 bmargin=lines-1; 430 bmargin=lines-1;
431 initTabStops(); 431 initTabStops();
432 clearSelection(); 432 clearSelection();
433} 433}
434 434
435/* 435/*
436 Clarifying rendition here and in TEWidget. 436 Clarifying rendition here and in TEWidget.
437 437
438 currently, TEWidget's color table is 438 currently, TEWidget's color table is
439 0 1 2 .. 9 10 .. 17 439 0 1 2 .. 9 10 .. 17
440 dft_fg, dft_bg, dim 0..7, intensive 0..7 440 dft_fg, dft_bg, dim 0..7, intensive 0..7
441 441
442 cu_fg, cu_bg contain values 0..8; 442 cu_fg, cu_bg contain values 0..8;
443 - 0 = default color 443 - 0 = default color
444 - 1..8 = ansi specified color 444 - 1..8 = ansi specified color
445 445
446 re_fg, re_bg contain values 0..17 446 re_fg, re_bg contain values 0..17
447 due to the TEWidget's color table 447 due to the TEWidget's color table
448 448
449 rendition attributes are 449 rendition attributes are
450 450
451 attr widget screen 451 attr widget screen
452 -------------- ------ ------ 452 -------------- ------ ------
453 RE_UNDERLINE XX XX affects foreground only 453 RE_UNDERLINE XX XX affects foreground only
454 RE_BLINK XX XX affects foreground only 454 RE_BLINK XX XX affects foreground only
455 RE_BOLD XX XX affects foreground only 455 RE_BOLD XX XX affects foreground only
456 RE_REVERSE -- XX 456 RE_REVERSE -- XX
457 RE_TRANSPARENT XX -- affects background only 457 RE_TRANSPARENT XX -- affects background only
458 RE_INTENSIVE XX -- affects foreground only 458 RE_INTENSIVE XX -- affects foreground only
459 459
460 Note that RE_BOLD is used in both widget 460 Note that RE_BOLD is used in both widget
461 and screen rendition. Since xterm/vt102 461 and screen rendition. Since xterm/vt102
462 is to poor to distinguish between bold 462 is to poor to distinguish between bold
463 (which is a font attribute) and intensive 463 (which is a font attribute) and intensive
464 (which is a color attribute), we translate 464 (which is a color attribute), we translate
465 this and RE_BOLD in falls eventually appart 465 this and RE_BOLD in falls eventually appart
466 into RE_BOLD and RE_INTENSIVE. 466 into RE_BOLD and RE_INTENSIVE.
467*/ 467*/
468 468
469void TEScreen::reverseRendition(ca* p) 469void TEScreen::reverseRendition(ca* p)
470{ UINT8 f = p->f; UINT8 b = p->b; 470{ UINT8 f = p->f; UINT8 b = p->b;
471 p->f = b; p->b = f; //p->r &= ~RE_TRANSPARENT; 471 p->f = b; p->b = f; //p->r &= ~RE_TRANSPARENT;
472} 472}
473 473
474void TEScreen::effectiveRendition() 474void TEScreen::effectiveRendition()
475// calculate rendition 475// calculate rendition
476{ 476{
477 ef_re = cu_re & (RE_UNDERLINE | RE_BLINK); 477 ef_re = cu_re & (RE_UNDERLINE | RE_BLINK);
478 if (cu_re & RE_REVERSE) 478 if (cu_re & RE_REVERSE)
479 { 479 {
480 ef_fg = cu_bg; 480 ef_fg = cu_bg;
481 ef_bg = cu_fg; 481 ef_bg = cu_fg;
482 } 482 }
483 else 483 else
484 { 484 {
485 ef_fg = cu_fg; 485 ef_fg = cu_fg;
486 ef_bg = cu_bg; 486 ef_bg = cu_bg;
487 } 487 }
488 if (cu_re & RE_BOLD) 488 if (cu_re & RE_BOLD)
489 { 489 {
490 if (ef_fg < BASE_COLORS) 490 if (ef_fg < BASE_COLORS)
491 ef_fg += BASE_COLORS; 491 ef_fg += BASE_COLORS;
492 else 492 else
493 ef_fg -= BASE_COLORS; 493 ef_fg -= BASE_COLORS;
494 } 494 }
495} 495}
496 496
497/*! 497/*!
498 returns the image. 498 returns the image.
499 499
500 Get the size of the image by \sa getLines and \sa getColumns. 500 Get the size of the image by \sa getLines and \sa getColumns.
501 501
502 NOTE that the image returned by this function must later be 502 NOTE that the image returned by this function must later be
503 freed. 503 freed.
504 504
505*/ 505*/
506 506
507ca* TEScreen::getCookedImage() 507ca* TEScreen::getCookedImage()
508{ 508{
509 int x,y; 509 int x,y;
510 ca* merged = (ca*)malloc(lines*columns*sizeof(ca)); 510 ca* merged = (ca*)malloc(lines*columns*sizeof(ca));
511 ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); 511 ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION);
512 512
513 if (histCursor > hist.getLines()) { 513 if (histCursor > hist.getLines()) {
514 histCursor = hist.getLines(); 514 histCursor = hist.getLines();
515 } 515 }
516 516
517 for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++) 517 for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++)
518 { 518 {
519 int len = QMIN(columns,hist.getLineLen(y+histCursor)); 519 int len = QMIN(columns,hist.getLineLen(y+histCursor));
520 int yp = y*columns; 520 int yp = y*columns;
521 int yq = (y+histCursor)*columns; 521 int yq = (y+histCursor)*columns;
522 522
523 hist.getCells(y+histCursor,0,len,merged+yp); 523 hist.getCells(y+histCursor,0,len,merged+yp);
524 for (x = len; x < columns; x++) merged[yp+x] = dft; 524 for (x = len; x < columns; x++) merged[yp+x] = dft;
525 for (x = 0; x < columns; x++) 525 for (x = 0; x < columns; x++)
526 { int p=x + yp; int q=x + yq; 526 { int p=x + yp; int q=x + yq;
527 if ( ( q >= sel_TL ) && ( q <= sel_BR ) ) 527 if ( ( q >= sel_TL ) && ( q <= sel_BR ) )
528 reverseRendition(&merged[p]); // for selection 528 reverseRendition(&merged[p]); // for selection
529 } 529 }
530 } 530 }
531 if (lines >= hist.getLines()-histCursor) 531 if (lines >= hist.getLines()-histCursor)
532 { 532 {
533 for (y = (hist.getLines()-histCursor); y < lines ; y++) 533 for (y = (hist.getLines()-histCursor); y < lines ; y++)
534 { 534 {
535 int yp = y*columns; 535 int yp = y*columns;
536 int yq = (y+histCursor)*columns; 536 int yq = (y+histCursor)*columns;
537 int yr = (y-hist.getLines()+histCursor)*columns; 537 int yr = (y-hist.getLines()+histCursor)*columns;
538 for (x = 0; x < columns; x++) 538 for (x = 0; x < columns; x++)
539 { int p = x + yp; int q = x + yq; int r = x + yr; 539 { int p = x + yp; int q = x + yq; int r = x + yr;
540 merged[p] = image[r]; 540 merged[p] = image[r];
541 if ( q >= sel_TL && q <= sel_BR ) 541 if ( q >= sel_TL && q <= sel_BR )
542 reverseRendition(&merged[p]); // for selection 542 reverseRendition(&merged[p]); // for selection
543 } 543 }
544 544
545 } 545 }
546 } 546 }
547 // evtl. inverse display 547 // evtl. inverse display
548 if (getMode(MODE_Screen)) 548 if (getMode(MODE_Screen))
549 { int i,n = lines*columns; 549 { int i,n = lines*columns;
550 for (i = 0; i < n; i++) 550 for (i = 0; i < n; i++)
551 reverseRendition(&merged[i]); // for reverse display 551 reverseRendition(&merged[i]); // for reverse display
552 } 552 }
553 if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible 553 if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible
554 reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]); 554 reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]);
555 return merged; 555 return merged;
556 556
557} 557}
558 558
559 559
560/*! 560/*!
561*/ 561*/
562 562
563void TEScreen::reset() 563void TEScreen::reset()
564{ 564{
565 Config cfg("Qkonsole"); 565 Config cfg( "Konsole" );
566 cfg.setGroup("ScrollBar"); 566 cfg.setGroup("ScrollBar");
567 if( !cfg.readBoolEntry("HorzScroll",0) ) 567 if( !cfg.readBoolEntry("HorzScroll",0) )
568 setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin 568 setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin
569 569
570 570
571 resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1] 571 resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1]
572 resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke 572 resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke
573 setMode(MODE_Cursor); // cursor visible 573 setMode(MODE_Cursor); // cursor visible
574 resetMode(MODE_Screen); // screen not inverse 574 resetMode(MODE_Screen); // screen not inverse
575 resetMode(MODE_NewLine); 575 resetMode(MODE_NewLine);
576 576
577 tmargin=0; 577 tmargin=0;
578 bmargin=lines-1; 578 bmargin=lines-1;
579 579
580 setDefaultRendition(); 580 setDefaultRendition();
581 saveCursor(); 581 saveCursor();
582 582
583 clear(); 583 clear();
584} 584}
585 585
586/*! Clear the entire screen and home the cursor. 586/*! Clear the entire screen and home the cursor.
587*/ 587*/
588 588
589void TEScreen::clear() 589void TEScreen::clear()
590{ 590{
591 clearEntireScreen(); 591 clearEntireScreen();
592 home(); 592 home();
593} 593}
594 594
595/*! Moves the cursor left one column. 595/*! Moves the cursor left one column.
596*/ 596*/
597 597
598void TEScreen::BackSpace() 598void TEScreen::BackSpace()
599{ 599{
600 cuX = QMAX(0,cuX-1); 600 cuX = QMAX(0,cuX-1);
601 if (BS_CLEARS) image[loc(cuX,cuY)].c = ' '; 601 if (BS_CLEARS) image[loc(cuX,cuY)].c = ' ';
602} 602}
603 603
604/*! 604/*!
605*/ 605*/
606 606
607void TEScreen::Tabulate() 607void TEScreen::Tabulate()
608{ 608{
609 // note that TAB is a format effector (does not write ' '); 609 // note that TAB is a format effector (does not write ' ');
610 cursorRight(1); while(cuX < columns-1 && !tabstops[cuX]) cursorRight(1); 610 cursorRight(1); while(cuX < columns-1 && !tabstops[cuX]) cursorRight(1);
611} 611}
612 612
613void TEScreen::clearTabStops() 613void TEScreen::clearTabStops()
614{ 614{
615 for (int i = 0; i < columns; i++) tabstops[i-1] = FALSE; 615 for (int i = 0; i < columns; i++) tabstops[i-1] = FALSE;
616} 616}
617 617
618void TEScreen::changeTabStop(bool set) 618void TEScreen::changeTabStop(bool set)
619{ 619{
620 if (cuX >= columns) return; 620 if (cuX >= columns) return;
621 tabstops[cuX] = set; 621 tabstops[cuX] = set;
622} 622}
623 623
624void TEScreen::initTabStops() 624void TEScreen::initTabStops()
625{ 625{
626 if (tabstops) free(tabstops); 626 if (tabstops) free(tabstops);
627 tabstops = (bool*)malloc(columns*sizeof(bool)); 627 tabstops = (bool*)malloc(columns*sizeof(bool));
628 // Arrg! The 1st tabstop has to be one longer than the other. 628 // Arrg! The 1st tabstop has to be one longer than the other.
629 // i.e. the kids start counting from 0 instead of 1. 629 // i.e. the kids start counting from 0 instead of 1.
630 // Other programs might behave correctly. Be aware. 630 // Other programs might behave correctly. Be aware.
631 for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0); 631 for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0);
632} 632}
633 633
634/*! 634/*!
635 This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine) 635 This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine)
636 depending on the NewLine Mode (LNM). This mode also 636 depending on the NewLine Mode (LNM). This mode also
637 affects the key sequence returned for newline ([CR]LF). 637 affects the key sequence returned for newline ([CR]LF).
638*/ 638*/
639 639
640void TEScreen::NewLine() 640void TEScreen::NewLine()
641{ 641{
642 if (getMode(MODE_NewLine)) Return(); 642 if (getMode(MODE_NewLine)) Return();
643 index(); 643 index();
644} 644}
645 645
646/*! put `c' literally onto the screen at the current cursor position. 646/*! put `c' literally onto the screen at the current cursor position.
647 647
648 VT100 uses the convention to produce an automatic newline (am) 648 VT100 uses the convention to produce an automatic newline (am)
649 with the *first* character that would fall onto the next line (xenl). 649 with the *first* character that would fall onto the next line (xenl).
650*/ 650*/
651 651
652void TEScreen::checkSelection(int from, int to) 652void TEScreen::checkSelection(int from, int to)
653{ 653{
654 if (sel_begin == -1) return; 654 if (sel_begin == -1) return;
655 int scr_TL = loc(0, hist.getLines()); 655 int scr_TL = loc(0, hist.getLines());
656 //Clear entire selection if it overlaps region [from, to] 656 //Clear entire selection if it overlaps region [from, to]
657 if ( (sel_BR > (from+scr_TL) )&&(sel_TL < (to+scr_TL)) ) 657 if ( (sel_BR > (from+scr_TL) )&&(sel_TL < (to+scr_TL)) )
658 { 658 {
659 clearSelection(); 659 clearSelection();
660 } 660 }
661} 661}
662 662
663void TEScreen::ShowCharacter(unsigned short c) 663void TEScreen::ShowCharacter(unsigned short c)
664{ 664{
665 // Note that VT100 does wrapping BEFORE putting the character. 665 // Note that VT100 does wrapping BEFORE putting the character.
666 // This has impact on the assumption of valid cursor positions. 666 // This has impact on the assumption of valid cursor positions.
667 // We indicate the fact that a newline has to be triggered by 667 // We indicate the fact that a newline has to be triggered by
668 // putting the cursor one right to the last column of the screen. 668 // putting the cursor one right to the last column of the screen.
669 669
670 if (cuX >= columns) 670 if (cuX >= columns)
671 { 671 {
672 if (getMode(MODE_Wrap)) NextLine(); else cuX = columns - 1; 672 if (getMode(MODE_Wrap)) NextLine(); else cuX = columns - 1;
673 // comment out for no wrap 673 // comment out for no wrap
674 } 674 }
675 675
676 if (getMode(MODE_Insert)) insertChars(1); 676 if (getMode(MODE_Insert)) insertChars(1);
677 677
678 int i = loc( cuX, cuY); 678 int i = loc( cuX, cuY);
679 679
680 checkSelection(i, i); // check if selection is still valid. 680 checkSelection(i, i); // check if selection is still valid.
681 681
682 image[i].c = c; 682 image[i].c = c;
683 image[i].f = ef_fg; 683 image[i].f = ef_fg;
684 image[i].b = ef_bg; 684 image[i].b = ef_bg;
685 image[i].r = ef_re; 685 image[i].r = ef_re;
686 686
687 cuX += 1; 687 cuX += 1;
688} 688}
689 689
690// Region commands ------------------------------------------------------------- 690// Region commands -------------------------------------------------------------
691 691
692 692
693/*! scroll up `n' lines within current region. 693/*! scroll up `n' lines within current region.
694 The `n' new lines are cleared. 694 The `n' new lines are cleared.
695 \sa setRegion \sa scrollDown 695 \sa setRegion \sa scrollDown
696*/ 696*/
697 697
698void TEScreen::scrollUp(int from, int n) 698void TEScreen::scrollUp(int from, int n)
699{ 699{
700 if (n <= 0 || from + n > bmargin) return; 700 if (n <= 0 || from + n > bmargin) return;
701 //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. 701 //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds.
702 702
703 moveImage( loc( 0, from), loc( 0, from + n), loc( columns - 1, bmargin)); 703 moveImage( loc( 0, from), loc( 0, from + n), loc( columns - 1, bmargin));
704 clearImage( loc( 0, bmargin - n + 1), loc( columns - 1, bmargin), ' '); 704 clearImage( loc( 0, bmargin - n + 1), loc( columns - 1, bmargin), ' ');
705} 705}
706 706
707/*! scroll down `n' lines within current region. 707/*! scroll down `n' lines within current region.
708 The `n' new lines are cleared. 708 The `n' new lines are cleared.
709 \sa setRegion \sa scrollUp 709 \sa setRegion \sa scrollUp
710*/ 710*/
711 711
712void TEScreen::scrollDown(int from, int n) 712void TEScreen::scrollDown(int from, int n)
713{ 713{
714 714
715//FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. 715//FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds.
716 if (n <= 0) return; 716 if (n <= 0) return;
717 if (from > bmargin) return; 717 if (from > bmargin) return;
718 if (from + n > bmargin) n = bmargin - from; 718 if (from + n > bmargin) n = bmargin - from;
719 719
720 moveImage( loc(0,from+n), loc(0,from), loc(columns-1,bmargin-n)); 720 moveImage( loc(0,from+n), loc(0,from), loc(columns-1,bmargin-n));
721 clearImage(loc(0,from),loc(columns-1,from+n-1),' '); 721 clearImage(loc(0,from),loc(columns-1,from+n-1),' ');
722} 722}
723 723
724 724
725 725
726/*! position the cursor to a specific line and column. */ 726/*! position the cursor to a specific line and column. */
727void TEScreen::setCursorYX(int y, int x) 727void TEScreen::setCursorYX(int y, int x)
728{ 728{
729 setCursorY(y); setCursorX(x); 729 setCursorY(y); setCursorX(x);
730} 730}
731 731
732/*! Set the cursor to x-th line. */ 732/*! Set the cursor to x-th line. */
733 733
734void TEScreen::setCursorX(int x) 734void TEScreen::setCursorX(int x)
735{ 735{
736 if (x == 0) x = 1; // Default 736 if (x == 0) x = 1; // Default
737 x -= 1; // Adjust 737 x -= 1; // Adjust
738 cuX = QMAX(0,QMIN(columns-1, x)); 738 cuX = QMAX(0,QMIN(columns-1, x));
739} 739}
740 740
741/*! Set the cursor to y-th line. */ 741/*! Set the cursor to y-th line. */
742 742
743void TEScreen::setCursorY(int y) 743void TEScreen::setCursorY(int y)
744{ 744{
745 if (y == 0) y = 1; // Default 745 if (y == 0) y = 1; // Default
746 y -= 1; // Adjust 746 y -= 1; // Adjust
747 cuY = QMAX(0,QMIN(lines -1, y + (getMode(MODE_Origin) ? tmargin : 0) )); 747 cuY = QMAX(0,QMIN(lines -1, y + (getMode(MODE_Origin) ? tmargin : 0) ));
748} 748}
749 749
750/*! set cursor to the `left upper' corner of the screen (1,1). 750/*! set cursor to the `left upper' corner of the screen (1,1).
751*/ 751*/
752 752
753void TEScreen::home() 753void TEScreen::home()
754{ 754{
755 cuX = 0; 755 cuX = 0;
756 cuY = 0; 756 cuY = 0;
757} 757}
758 758
759/*! set cursor to the begin of the current line. 759/*! set cursor to the begin of the current line.
760*/ 760*/
761 761
762void TEScreen::Return() 762void TEScreen::Return()
763{ 763{
764 cuX = 0; 764 cuX = 0;
765} 765}
766 766
767/*! returns the current cursor columns. 767/*! returns the current cursor columns.
768*/ 768*/
769 769
770int TEScreen::getCursorX() 770int TEScreen::getCursorX()
771{ 771{
772 return cuX; 772 return cuX;
773} 773}
774 774
775/*! returns the current cursor line. 775/*! returns the current cursor line.
776*/ 776*/
777 777
778int TEScreen::getCursorY() 778int TEScreen::getCursorY()
779{ 779{
780 return cuY; 780 return cuY;
781} 781}
782 782
783// Erasing --------------------------------------------------------------------- 783// Erasing ---------------------------------------------------------------------
784 784
785/*! \section Erasing 785/*! \section Erasing
786 786
787 This group of operations erase parts of the screen contents by filling 787 This group of operations erase parts of the screen contents by filling
788 it with spaces colored due to the current rendition settings. 788 it with spaces colored due to the current rendition settings.
789 789
790 Althought the cursor position is involved in most of these operations, 790 Althought the cursor position is involved in most of these operations,
791 it is never modified by them. 791 it is never modified by them.
792*/ 792*/
793 793
794/*! fill screen between (including) `loca' and `loce' with spaces. 794/*! fill screen between (including) `loca' and `loce' with spaces.
795 795
796 This is an internal helper functions. The parameter types are internal 796 This is an internal helper functions. The parameter types are internal
797 addresses of within the screen image and make use of the way how the 797 addresses of within the screen image and make use of the way how the
798 screen matrix is mapped to the image vector. 798 screen matrix is mapped to the image vector.
799*/ 799*/
800 800
801void TEScreen::clearImage(int loca, int loce, char c) 801void TEScreen::clearImage(int loca, int loce, char c)
802{ int i; 802{ int i;
803 int scr_TL=loc(0,hist.getLines()); 803 int scr_TL=loc(0,hist.getLines());
804 //FIXME: check positions 804 //FIXME: check positions
805 805
806 //Clear entire selection if it overlaps region to be moved... 806 //Clear entire selection if it overlaps region to be moved...
807 if ( (sel_BR > (loca+scr_TL) )&&(sel_TL < (loce+scr_TL)) ) 807 if ( (sel_BR > (loca+scr_TL) )&&(sel_TL < (loce+scr_TL)) )
808 { 808 {
809 clearSelection(); 809 clearSelection();
810 } 810 }
811 for (i = loca; i <= loce; i++) 811 for (i = loca; i <= loce; i++)
812 { 812 {
813 image[i].c = c; 813 image[i].c = c;
814 image[i].f = ef_fg; //DEFAULT_FORE_COLOR; //FIXME: xterm and linux/ansi 814 image[i].f = ef_fg; //DEFAULT_FORE_COLOR; //FIXME: xterm and linux/ansi
815 image[i].b = ef_bg; //DEFAULT_BACK_COLOR; // many have different 815 image[i].b = ef_bg; //DEFAULT_BACK_COLOR; // many have different
816 image[i].r = ef_re; //DEFAULT_RENDITION; // ideas here. 816 image[i].r = ef_re; //DEFAULT_RENDITION; // ideas here.
817 } 817 }
818} 818}
819 819
820/*! move image between (including) `loca' and `loce' to 'dst'. 820/*! move image between (including) `loca' and `loce' to 'dst'.
821 821
822 This is an internal helper functions. The parameter types are internal 822 This is an internal helper functions. The parameter types are internal
823 addresses of within the screen image and make use of the way how the 823 addresses of within the screen image and make use of the way how the
824 screen matrix is mapped to the image vector. 824 screen matrix is mapped to the image vector.
825*/ 825*/
826 826
827void TEScreen::moveImage(int dst, int loca, int loce) 827void TEScreen::moveImage(int dst, int loca, int loce)
828{ 828{
829//FIXME: check positions 829//FIXME: check positions
830 if (loce < loca) { 830 if (loce < loca) {
831 // kdDebug() << "WARNING!!! call to TEScreen:moveImage with loce < loca!" << endl; 831 // kdDebug() << "WARNING!!! call to TEScreen:moveImage with loce < loca!" << endl;
832 return; 832 return;
833 } 833 }
834 memmove(&image[dst],&image[loca],(loce-loca+1)*sizeof(ca)); 834 memmove(&image[dst],&image[loca],(loce-loca+1)*sizeof(ca));
835} 835}
836 836
837/*! clear from (including) current cursor position to end of screen. 837/*! clear from (including) current cursor position to end of screen.
838*/ 838*/
839 839
840void TEScreen::clearToEndOfScreen() 840void TEScreen::clearToEndOfScreen()
841{ 841{
842 clearImage(loc(cuX,cuY),loc(columns-1,lines-1),' '); 842 clearImage(loc(cuX,cuY),loc(columns-1,lines-1),' ');
843} 843}
844 844
845/*! clear from begin of screen to (including) current cursor position. 845/*! clear from begin of screen to (including) current cursor position.
846*/ 846*/
847 847
848void TEScreen::clearToBeginOfScreen() 848void TEScreen::clearToBeginOfScreen()
849{ 849{
850 clearImage(loc(0,0),loc(cuX,cuY),' '); 850 clearImage(loc(0,0),loc(cuX,cuY),' ');
851} 851}
852 852
853/*! clear the entire screen. 853/*! clear the entire screen.
854*/ 854*/
855 855
856void TEScreen::clearEntireScreen() 856void TEScreen::clearEntireScreen()
857{ 857{
858 clearImage(loc(0,0),loc(columns-1,lines-1),' '); 858 clearImage(loc(0,0),loc(columns-1,lines-1),' ');
859} 859}
860 860
861/*! fill screen with 'E' 861/*! fill screen with 'E'
862 This is to aid screen alignment 862 This is to aid screen alignment
863*/ 863*/
864 864
865void TEScreen::helpAlign() 865void TEScreen::helpAlign()
866{ 866{
867 clearImage(loc(0,0),loc(columns-1,lines-1),'E'); 867 clearImage(loc(0,0),loc(columns-1,lines-1),'E');
868} 868}
869 869
870/*! clear from (including) current cursor position to end of current cursor line. 870/*! clear from (including) current cursor position to end of current cursor line.
871*/ 871*/
872 872
873void TEScreen::clearToEndOfLine() 873void TEScreen::clearToEndOfLine()
874{ 874{
875 clearImage(loc(cuX,cuY),loc(columns-1,cuY),' '); 875 clearImage(loc(cuX,cuY),loc(columns-1,cuY),' ');
876} 876}
877 877
878/*! clear from begin of current cursor line to (including) current cursor position. 878/*! clear from begin of current cursor line to (including) current cursor position.
879*/ 879*/
880 880
881void TEScreen::clearToBeginOfLine() 881void TEScreen::clearToBeginOfLine()
882{ 882{
883 clearImage(loc(0,cuY),loc(cuX,cuY),' '); 883 clearImage(loc(0,cuY),loc(cuX,cuY),' ');
884} 884}
885 885
886/*! clears entire current cursor line 886/*! clears entire current cursor line
887*/ 887*/
888 888
889void TEScreen::clearEntireLine() 889void TEScreen::clearEntireLine()
890{ 890{
891 clearImage( loc( 0, cuY),loc( columns - 1, cuY),' '); 891 clearImage( loc( 0, cuY),loc( columns - 1, cuY),' ');
892} 892}
893 893
894// Rendition ------------------------------------------------------------------ 894// Rendition ------------------------------------------------------------------
895 895
896/*! 896/*!
897 set rendition mode 897 set rendition mode
898*/ 898*/
899 899
900void TEScreen::setRendition(int re) 900void TEScreen::setRendition(int re)
901{ 901{
902 cu_re |= re; 902 cu_re |= re;
903 effectiveRendition(); 903 effectiveRendition();
904} 904}
905 905
906/*! 906/*!
907 reset rendition mode 907 reset rendition mode
908*/ 908*/
909 909
910void TEScreen::resetRendition(int re) 910void TEScreen::resetRendition(int re)
911{ 911{
912 cu_re &= ~re; 912 cu_re &= ~re;
913 effectiveRendition(); 913 effectiveRendition();
914} 914}
915 915
916/*! 916/*!
917*/ 917*/
918 918
919void TEScreen::setDefaultRendition() 919void TEScreen::setDefaultRendition()
920{ 920{
921 setForeColorToDefault(); 921 setForeColorToDefault();
922 setBackColorToDefault(); 922 setBackColorToDefault();
923 cu_re = DEFAULT_RENDITION; 923 cu_re = DEFAULT_RENDITION;
924 effectiveRendition(); 924 effectiveRendition();
925} 925}
926 926
927/*! 927/*!
928*/ 928*/
929 929
930void TEScreen::setForeColor(int fgcolor) 930void TEScreen::setForeColor(int fgcolor)
931{ 931{
932 cu_fg = (fgcolor&7)+((fgcolor&8) ? 4+8 : 2); 932 cu_fg = (fgcolor&7)+((fgcolor&8) ? 4+8 : 2);
933 effectiveRendition(); 933 effectiveRendition();
934} 934}
935 935
936/*! 936/*!
937*/ 937*/
938 938
939void TEScreen::setBackColor(int bgcolor) 939void TEScreen::setBackColor(int bgcolor)
940{ 940{
941 cu_bg = (bgcolor&7)+((bgcolor&8) ? 4+8 : 2); 941 cu_bg = (bgcolor&7)+((bgcolor&8) ? 4+8 : 2);
942 effectiveRendition(); 942 effectiveRendition();
943} 943}
944 944
945/*! 945/*!
946*/ 946*/
947 947
948void TEScreen::setBackColorToDefault() 948void TEScreen::setBackColorToDefault()
949{ 949{
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp
index 98c3cdf..2e3e0f5 100644
--- a/core/apps/embeddedkonsole/TEWidget.cpp
+++ b/core/apps/embeddedkonsole/TEWidget.cpp
@@ -1,693 +1,693 @@
1/* ------------------------------------------------------------------------ */ 1/* ------------------------------------------------------------------------ */
2/* */ 2/* */
3/* [TEWidget.C] Terminal Emulation Widget */ 3/* [TEWidget.C] Terminal Emulation Widget */
4/* */ 4/* */
5/* ------------------------------------------------------------------------ */ 5/* ------------------------------------------------------------------------ */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* ------------------------------------------------------------------------ */ 11/* ------------------------------------------------------------------------ */
12/* */ 12/* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14/* */ 14/* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16/* */ 16/* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18/*! \class TEWidget 18/*! \class TEWidget
19 19
20 \brief Visible screen contents 20 \brief Visible screen contents
21 21
22 This class is responsible to map the `image' of a terminal emulation to the 22 This class is responsible to map the `image' of a terminal emulation to the
23 display. All the dependency of the emulation to a specific GUI or toolkit is 23 display. All the dependency of the emulation to a specific GUI or toolkit is
24 localized here. Further, this widget has no knowledge about being part of an 24 localized here. Further, this widget has no knowledge about being part of an
25 emulation, it simply work within the terminal emulation framework by exposing 25 emulation, it simply work within the terminal emulation framework by exposing
26 size and key events and by being ordered to show a new image. 26 size and key events and by being ordered to show a new image.
27 27
28 <ul> 28 <ul>
29 <li> The internal image has the size of the widget (evtl. rounded up) 29 <li> The internal image has the size of the widget (evtl. rounded up)
30 <li> The external image used in setImage can have any size. 30 <li> The external image used in setImage can have any size.
31 <li> (internally) the external image is simply copied to the internal 31 <li> (internally) the external image is simply copied to the internal
32 when a setImage happens. During a resizeEvent no painting is done 32 when a setImage happens. During a resizeEvent no painting is done
33 a paintEvent is expected to follow anyway. 33 a paintEvent is expected to follow anyway.
34 </ul> 34 </ul>
35 35
36 \sa TEScreen \sa Emulation 36 \sa TEScreen \sa Emulation
37*/ 37*/
38 38
39/* FIXME: 39/* FIXME:
40 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent 40 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent
41 - 'font_a' not used in mouse events 41 - 'font_a' not used in mouse events
42 - add destructor 42 - add destructor
43*/ 43*/
44 44
45/* TODO 45/* TODO
46 - evtl. be sensitive to `paletteChange' while using default colors. 46 - evtl. be sensitive to `paletteChange' while using default colors.
47 - set different 'rounding' styles? I.e. have a mode to show clipped chars? 47 - set different 'rounding' styles? I.e. have a mode to show clipped chars?
48*/ 48*/
49 49
50// #include "config.h" 50// #include "config.h"
51#include "TEWidget.h" 51#include "TEWidget.h"
52#include "session.h" 52#include "session.h"
53#include <qpe/config.h> 53#include <qpe/config.h>
54 54
55#include <qpe/resource.h> 55#include <qpe/resource.h>
56#include <qpe/sound.h> 56#include <qpe/sound.h>
57 57
58#if !(QT_NO_COP) 58#if !(QT_NO_COP)
59#include <qpe/qcopenvelope_qws.h> 59#include <qpe/qcopenvelope_qws.h>
60#endif 60#endif
61 61
62#include <qcursor.h> 62#include <qcursor.h>
63#include <qregexp.h> 63#include <qregexp.h>
64#include <qpainter.h> 64#include <qpainter.h>
65#include <qclipboard.h> 65#include <qclipboard.h>
66#include <qstyle.h> 66#include <qstyle.h>
67#include <qfile.h> 67#include <qfile.h>
68#include <qdragobject.h> 68#include <qdragobject.h>
69#include <qnamespace.h> 69#include <qnamespace.h>
70 70
71#include <stdio.h> 71#include <stdio.h>
72#include <stdlib.h> 72#include <stdlib.h>
73#include <unistd.h> 73#include <unistd.h>
74#include <ctype.h> 74#include <ctype.h>
75#include <sys/stat.h> 75#include <sys/stat.h>
76#include <sys/types.h> 76#include <sys/types.h>
77#include <signal.h> 77#include <signal.h>
78 78
79#include <assert.h> 79#include <assert.h>
80 80
81// #include "TEWidget.moc" 81// #include "TEWidget.moc"
82//#include <kapp.h> 82//#include <kapp.h>
83//#include <kcursor.h> 83//#include <kcursor.h>
84//#include <kurl.h> 84//#include <kurl.h>
85//#include <kdebug.h> 85//#include <kdebug.h>
86//#include <klocale.h> 86//#include <klocale.h>
87 87
88#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) 88#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__)
89#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } 89#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); }
90 90
91#define loc(X,Y) ((Y)*columns+(X)) 91#define loc(X,Y) ((Y)*columns+(X))
92 92
93//FIXME: the rim should normally be 1, 0 only when running in full screen mode. 93//FIXME: the rim should normally be 1, 0 only when running in full screen mode.
94#define rimX 0 // left/right rim width 94#define rimX 0 // left/right rim width
95#define rimY 0 // top/bottom rim high 95#define rimY 0 // top/bottom rim high
96 96
97#define SCRWIDTH 16 // width of the scrollbar 97#define SCRWIDTH 16 // width of the scrollbar
98 98
99#define yMouseScroll 1 99#define yMouseScroll 1
100// scroll increment used when dragging selection at top/bottom of window. 100// scroll increment used when dragging selection at top/bottom of window.
101 101
102/* ------------------------------------------------------------------------- */ 102/* ------------------------------------------------------------------------- */
103/* */ 103/* */
104/* Colors */ 104/* Colors */
105/* */ 105/* */
106/* ------------------------------------------------------------------------- */ 106/* ------------------------------------------------------------------------- */
107 107
108//FIXME: the default color table is in session.C now. 108//FIXME: the default color table is in session.C now.
109// We need a way to get rid of this one, here. 109// We need a way to get rid of this one, here.
110static const ColorEntry base_color_table[TABLE_COLORS] = 110static const ColorEntry base_color_table[TABLE_COLORS] =
111// The following are almost IBM standard color codes, with some slight 111// The following are almost IBM standard color codes, with some slight
112// gamma correction for the dim colors to compensate for bright X screens. 112// gamma correction for the dim colors to compensate for bright X screens.
113// It contains the 8 ansiterm/xterm colors in 2 intensities. 113// It contains the 8 ansiterm/xterm colors in 2 intensities.
114{ 114{
115 // Fixme: could add faint colors here, also. 115 // Fixme: could add faint colors here, also.
116 // normal 116 // normal
117 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback 117 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
118 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red 118 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
119 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow 119 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
120 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta 120 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
121 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White 121 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
122 // intensiv 122 // intensiv
123 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), 123 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
124 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), 124 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
125 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), 125 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
126 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), 126 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
127 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) 127 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
128}; 128};
129 129
130/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) 130/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb)
131 131
132 Code 0 1 2 3 4 5 6 7 132 Code 0 1 2 3 4 5 6 7
133 ----------- ------- ------- ------- ------- ------- ------- ------- ------- 133 ----------- ------- ------- ------- ------- ------- ------- ------- -------
134 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White 134 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White
135 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White 135 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White
136*/ 136*/
137 137
138QColor TEWidget::getDefaultBackColor() 138QColor TEWidget::getDefaultBackColor()
139{ 139{
140 return color_table[DEFAULT_BACK_COLOR].color; 140 return color_table[DEFAULT_BACK_COLOR].color;
141} 141}
142 142
143const ColorEntry* TEWidget::getColorTable() const 143const ColorEntry* TEWidget::getColorTable() const
144{ 144{
145 return color_table; 145 return color_table;
146} 146}
147 147
148const ColorEntry* TEWidget::getdefaultColorTable() const 148const ColorEntry* TEWidget::getdefaultColorTable() const
149{ 149{
150 return base_color_table; 150 return base_color_table;
151} 151}
152 152
153 153
154const QPixmap *TEWidget::backgroundPixmap() 154const QPixmap *TEWidget::backgroundPixmap()
155{ 155{
156 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); 156 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm");
157 const QPixmap *pm = bg; 157 const QPixmap *pm = bg;
158 return pm; 158 return pm;
159} 159}
160 160
161void TEWidget::setColorTable(const ColorEntry table[]) 161void TEWidget::setColorTable(const ColorEntry table[])
162{ 162{
163 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; 163 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i];
164 164
165 const QPixmap* pm = backgroundPixmap(); 165 const QPixmap* pm = backgroundPixmap();
166 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); 166 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color);
167 update(); 167 update();
168} 168}
169 169
170//FIXME: add backgroundPixmapChanged. 170//FIXME: add backgroundPixmapChanged.
171 171
172/* ------------------------------------------------------------------------- */ 172/* ------------------------------------------------------------------------- */
173/* */ 173/* */
174/* Font */ 174/* Font */
175/* */ 175/* */
176/* ------------------------------------------------------------------------- */ 176/* ------------------------------------------------------------------------- */
177 177
178/* 178/*
179 The VT100 has 32 special graphical characters. The usual vt100 extended 179 The VT100 has 32 special graphical characters. The usual vt100 extended
180 xterm fonts have these at 0x00..0x1f. 180 xterm fonts have these at 0x00..0x1f.
181 181
182 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals 182 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals
183 come in here as proper unicode characters. 183 come in here as proper unicode characters.
184 184
185 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping 185 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping
186 from unicode to 0x00..0x1f. The remaining translation is then left to the 186 from unicode to 0x00..0x1f. The remaining translation is then left to the
187 QCodec. 187 QCodec.
188*/ 188*/
189 189
190// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. 190// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i.
191 191
192unsigned short vt100_graphics[32] = 192unsigned short vt100_graphics[32] =
193{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 193{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15
194 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 194 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0,
195 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 195 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
196 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 196 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534,
197 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 197 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7
198}; 198};
199 199
200static QChar vt100extended(QChar c) 200static QChar vt100extended(QChar c)
201{ 201{
202 switch (c.unicode()) 202 switch (c.unicode())
203 { 203 {
204 case 0x25c6 : return 1; 204 case 0x25c6 : return 1;
205 case 0x2592 : return 2; 205 case 0x2592 : return 2;
206 case 0x2409 : return 3; 206 case 0x2409 : return 3;
207 case 0x240c : return 4; 207 case 0x240c : return 4;
208 case 0x240d : return 5; 208 case 0x240d : return 5;
209 case 0x240a : return 6; 209 case 0x240a : return 6;
210 case 0x00b0 : return 7; 210 case 0x00b0 : return 7;
211 case 0x00b1 : return 8; 211 case 0x00b1 : return 8;
212 case 0x2424 : return 9; 212 case 0x2424 : return 9;
213 case 0x240b : return 10; 213 case 0x240b : return 10;
214 case 0x2518 : return 11; 214 case 0x2518 : return 11;
215 case 0x2510 : return 12; 215 case 0x2510 : return 12;
216 case 0x250c : return 13; 216 case 0x250c : return 13;
217 case 0x2514 : return 14; 217 case 0x2514 : return 14;
218 case 0x253c : return 15; 218 case 0x253c : return 15;
219 case 0xf800 : return 16; 219 case 0xf800 : return 16;
220 case 0xf801 : return 17; 220 case 0xf801 : return 17;
221 case 0x2500 : return 18; 221 case 0x2500 : return 18;
222 case 0xf803 : return 19; 222 case 0xf803 : return 19;
223 case 0xf804 : return 20; 223 case 0xf804 : return 20;
224 case 0x251c : return 21; 224 case 0x251c : return 21;
225 case 0x2524 : return 22; 225 case 0x2524 : return 22;
226 case 0x2534 : return 23; 226 case 0x2534 : return 23;
227 case 0x252c : return 24; 227 case 0x252c : return 24;
228 case 0x2502 : return 25; 228 case 0x2502 : return 25;
229 case 0x2264 : return 26; 229 case 0x2264 : return 26;
230 case 0x2265 : return 27; 230 case 0x2265 : return 27;
231 case 0x03c0 : return 28; 231 case 0x03c0 : return 28;
232 case 0x2260 : return 29; 232 case 0x2260 : return 29;
233 case 0x00a3 : return 30; 233 case 0x00a3 : return 30;
234 case 0x00b7 : return 31; 234 case 0x00b7 : return 31;
235 } 235 }
236 return c; 236 return c;
237} 237}
238 238
239static QChar identicalMap(QChar c) 239static QChar identicalMap(QChar c)
240{ 240{
241 return c; 241 return c;
242} 242}
243 243
244void TEWidget::fontChange(const QFont &) 244void TEWidget::fontChange(const QFont &)
245{ 245{
246 QFontMetrics fm(font()); 246 QFontMetrics fm(font());
247 font_h = fm.height(); 247 font_h = fm.height();
248 // font_w = fm.maxWidth(); 248 // font_w = fm.maxWidth();
249 font_w = fm.width("m"); 249 font_w = fm.width("m");
250 font_a = fm.ascent(); 250 font_a = fm.ascent();
251 printf("font h=%d max_width=%d width_m=%d assent=%d\n", font_h, 251 printf("font h=%d max_width=%d width_m=%d assent=%d\n", font_h,
252 fm.maxWidth(), font_w, font_a); 252 fm.maxWidth(), font_w, font_a);
253 253
254 //printf("font_h: %d\n",font_h); 254 //printf("font_h: %d\n",font_h);
255 //printf("font_w: %d\n",font_w); 255 //printf("font_w: %d\n",font_w);
256 //printf("font_a: %d\n",font_a); 256 //printf("font_a: %d\n",font_a);
257 //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); 257 //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii());
258 //printf("rawname: %s\n",font().rawName().ascii()); 258 //printf("rawname: %s\n",font().rawName().ascii());
259 fontMap = 259 fontMap =
260#if QT_VERSION < 300 260#if QT_VERSION < 300
261 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") 261 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646")
262 ? vt100extended 262 ? vt100extended
263 : 263 :
264#endif 264#endif
265 identicalMap; 265 identicalMap;
266 propagateSize(); 266 propagateSize();
267 update(); 267 update();
268} 268}
269 269
270void TEWidget::setVTFont(const QFont& f) 270void TEWidget::setVTFont(const QFont& f)
271{ 271{
272 QFrame::setFont(f); 272 QFrame::setFont(f);
273} 273}
274 274
275QFont TEWidget::getVTFont() { 275QFont TEWidget::getVTFont() {
276 return font(); 276 return font();
277} 277}
278 278
279void TEWidget::setFont(const QFont &) 279void TEWidget::setFont(const QFont &)
280{ 280{
281 // ignore font change request if not coming from konsole itself 281 // ignore font change request if not coming from konsole itself
282} 282}
283 283
284/* ------------------------------------------------------------------------- */ 284/* ------------------------------------------------------------------------- */
285/* */ 285/* */
286/* Constructor / Destructor */ 286/* Constructor / Destructor */
287/* */ 287/* */
288/* ------------------------------------------------------------------------- */ 288/* ------------------------------------------------------------------------- */
289 289
290TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) 290TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
291{ 291{
292#ifndef QT_NO_CLIPBOARD 292#ifndef QT_NO_CLIPBOARD
293 cb = QApplication::clipboard(); 293 cb = QApplication::clipboard();
294 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 294 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
295 this, SLOT(onClearSelection()) ); 295 this, SLOT(onClearSelection()) );
296#endif 296#endif
297 297
298 scrollbar = new QScrollBar(this); 298 scrollbar = new QScrollBar(this);
299 scrollbar->setCursor( arrowCursor ); 299 scrollbar->setCursor( arrowCursor );
300 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 300 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
301 301
302 hScrollbar = new QScrollBar(this); 302 hScrollbar = new QScrollBar(this);
303 hScrollbar->setCursor( arrowCursor ); 303 hScrollbar->setCursor( arrowCursor );
304 hScrollbar->setOrientation(QScrollBar::Horizontal); 304 hScrollbar->setOrientation(QScrollBar::Horizontal);
305 // hScrollbar->setMaximumHeight(16); 305 // hScrollbar->setMaximumHeight(16);
306 306
307 connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); 307 connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int)));
308 308
309 Config cfg("Qkonsole"); 309 Config cfg( "Konsole" );
310 cfg.setGroup("ScrollBar"); 310 cfg.setGroup("ScrollBar");
311 switch( cfg.readNumEntry("Position",2)){ 311 switch( cfg.readNumEntry("Position",2)){
312 case 0: 312 case 0:
313 scrollLoc = SCRNONE; 313 scrollLoc = SCRNONE;
314 break; 314 break;
315 case 1: 315 case 1:
316 scrollLoc = SCRLEFT; 316 scrollLoc = SCRLEFT;
317 break; 317 break;
318 case 2: 318 case 2:
319 scrollLoc = SCRRIGHT; 319 scrollLoc = SCRRIGHT;
320 break; 320 break;
321 }; 321 };
322 322
323 useHorzScroll=cfg.readBoolEntry("HorzScroll",0); 323 useHorzScroll=cfg.readBoolEntry("HorzScroll",0);
324 324
325 blinkT = new QTimer(this); 325 blinkT = new QTimer(this);
326 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); 326 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent()));
327 // blinking = FALSE; 327 // blinking = FALSE;
328 blinking = TRUE; 328 blinking = TRUE;
329 329
330 resizing = FALSE; 330 resizing = FALSE;
331 actSel = 0; 331 actSel = 0;
332 image = 0; 332 image = 0;
333 lines = 1; 333 lines = 1;
334 columns = 1; 334 columns = 1;
335 font_w = 1; 335 font_w = 1;
336 font_h = 1; 336 font_h = 1;
337 font_a = 1; 337 font_a = 1;
338 word_selection_mode = FALSE; 338 word_selection_mode = FALSE;
339 hposition = 0; 339 hposition = 0;
340 vcolumns = 0; 340 vcolumns = 0;
341 useBeep = true; 341 useBeep = true;
342 342
343 setMouseMarks(TRUE); 343 setMouseMarks(TRUE);
344 setVTFont( QFont("fixed") ); 344 setVTFont( QFont("fixed") );
345 setColorTable(base_color_table); // init color table 345 setColorTable(base_color_table); // init color table
346 346
347 qApp->installEventFilter( this ); //FIXME: see below 347 qApp->installEventFilter( this ); //FIXME: see below
348// KCursor::setAutoHideCursor( this, true ); 348// KCursor::setAutoHideCursor( this, true );
349 349
350 // Init DnD //////////////////////////////////////////////////////////////// 350 // Init DnD ////////////////////////////////////////////////////////////////
351 currentSession = NULL; 351 currentSession = NULL;
352// setAcceptDrops(true); // attempt 352// setAcceptDrops(true); // attempt
353// m_drop = new QPopupMenu(this); 353// m_drop = new QPopupMenu(this);
354// m_drop->insertItem( QString("Paste"), 0); 354// m_drop->insertItem( QString("Paste"), 0);
355// m_drop->insertItem( QString("cd"), 1); 355// m_drop->insertItem( QString("cd"), 1);
356// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); 356// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int)));
357 357
358 // we need focus so that the auto-hide cursor feature works 358 // we need focus so that the auto-hide cursor feature works
359 setFocus(); 359 setFocus();
360 setFocusPolicy( WheelFocus ); 360 setFocusPolicy( WheelFocus );
361} 361}
362 362
363//FIXME: make proper destructor 363//FIXME: make proper destructor
364// Here's a start (David) 364// Here's a start (David)
365TEWidget::~TEWidget() 365TEWidget::~TEWidget()
366{ 366{
367 qApp->removeEventFilter( this ); 367 qApp->removeEventFilter( this );
368 if (image) free(image); 368 if (image) free(image);
369} 369}
370 370
371/* ------------------------------------------------------------------------- */ 371/* ------------------------------------------------------------------------- */
372/* */ 372/* */
373/* Display Operations */ 373/* Display Operations */
374/* */ 374/* */
375/* ------------------------------------------------------------------------- */ 375/* ------------------------------------------------------------------------- */
376 376
377/*! 377/*!
378 attributed string draw primitive 378 attributed string draw primitive
379*/ 379*/
380 380
381void TEWidget::drawAttrStr(QPainter &paint, QRect rect, 381void TEWidget::drawAttrStr(QPainter &paint, QRect rect,
382 QString& str, ca attr, BOOL pm, BOOL clear) 382 QString& str, ca attr, BOOL pm, BOOL clear)
383{ 383{
384 if (pm && color_table[attr.b].transparent) 384 if (pm && color_table[attr.b].transparent)
385 { 385 {
386 paint.setBackgroundMode( TransparentMode ); 386 paint.setBackgroundMode( TransparentMode );
387 if (clear) erase(rect); 387 if (clear) erase(rect);
388 } 388 }
389 else 389 else
390 { 390 {
391 if (blinking) 391 if (blinking)
392 paint.fillRect(rect, color_table[attr.b].color); 392 paint.fillRect(rect, color_table[attr.b].color);
393 else 393 else
394 { 394 {
395 paint.setBackgroundMode( OpaqueMode ); 395 paint.setBackgroundMode( OpaqueMode );
396 paint.setBackgroundColor( color_table[attr.b].color ); 396 paint.setBackgroundColor( color_table[attr.b].color );
397 } 397 }
398 } 398 }
399 399
400 if (color_table[attr.f].bold) 400 if (color_table[attr.f].bold)
401 paint.setPen(QColor( 0x8F, 0x00, 0x00 )); 401 paint.setPen(QColor( 0x8F, 0x00, 0x00 ));
402 else 402 else
403 paint.setPen(color_table[attr.f].color); 403 paint.setPen(color_table[attr.f].color);
404 404
405 paint.drawText(rect.x(),rect.y()+font_a, str); 405 paint.drawText(rect.x(),rect.y()+font_a, str);
406 406
407 if (attr.r & RE_UNDERLINE) 407 if (attr.r & RE_UNDERLINE)
408 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); 408 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 );
409} 409}
410 410
411/*! 411/*!
412 The image can only be set completely. 412 The image can only be set completely.
413 413
414 The size of the new image may or may not match the size of the widget. 414 The size of the new image may or may not match the size of the widget.
415*/ 415*/
416 416
417void TEWidget::setImage(const ca* const newimg, int lines, int columns) 417void TEWidget::setImage(const ca* const newimg, int lines, int columns)
418{ int y,x,len; 418{ int y,x,len;
419 const QPixmap* pm = backgroundPixmap(); 419 const QPixmap* pm = backgroundPixmap();
420 QPainter paint; 420 QPainter paint;
421 setUpdatesEnabled(FALSE); 421 setUpdatesEnabled(FALSE);
422 paint.begin( this ); 422 paint.begin( this );
423HCNT("setImage"); 423HCNT("setImage");
424 424
425 QPoint tL = contentsRect().topLeft(); 425 QPoint tL = contentsRect().topLeft();
426 int tLx = tL.x(); 426 int tLx = tL.x();
427 int tLy = tL.y(); 427 int tLy = tL.y();
428 hasBlinker = FALSE; 428 hasBlinker = FALSE;
429 429
430 int cf = -1; // undefined 430 int cf = -1; // undefined
431 int cb = -1; // undefined 431 int cb = -1; // undefined
432 int cr = -1; // undefined 432 int cr = -1; // undefined
433 433
434 int lins = QMIN(this->lines, QMAX(0,lines )); 434 int lins = QMIN(this->lines, QMAX(0,lines ));
435 int cols = QMIN(this->columns,QMAX(0,columns)); 435 int cols = QMIN(this->columns,QMAX(0,columns));
436 QChar *disstrU = new QChar[cols]; 436 QChar *disstrU = new QChar[cols];
437 for (y = 0; y < lins; y++) { 437 for (y = 0; y < lins; y++) {
438 const ca* lcl = &image[y*this->columns]; 438 const ca* lcl = &image[y*this->columns];
439 const ca* const ext = &newimg[y*columns]; 439 const ca* const ext = &newimg[y*columns];
440 if (!resizing) // not while resizing, we're expecting a paintEvent 440 if (!resizing) // not while resizing, we're expecting a paintEvent
441 for (x = 0; x < cols; x++) 441 for (x = 0; x < cols; x++)
442 { 442 {
443 hasBlinker |= (ext[x].r & RE_BLINK); 443 hasBlinker |= (ext[x].r & RE_BLINK);
444 if (ext[x] != lcl[x]) 444 if (ext[x] != lcl[x])
445 { 445 {
446 cr = ext[x].r; 446 cr = ext[x].r;
447 cb = ext[x].b; 447 cb = ext[x].b;
448 if (ext[x].f != cf) cf = ext[x].f; 448 if (ext[x].f != cf) cf = ext[x].f;
449 int lln = cols - x; 449 int lln = cols - x;
450 disstrU[0] = fontMap(ext[x+0].c); 450 disstrU[0] = fontMap(ext[x+0].c);
451 for (len = 1; len < lln; len++) 451 for (len = 1; len < lln; len++)
452 { 452 {
453 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || 453 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr ||
454 ext[x+len] == lcl[x+len] ) 454 ext[x+len] == lcl[x+len] )
455 break; 455 break;
456 disstrU[len] = fontMap(ext[x+len].c); 456 disstrU[len] = fontMap(ext[x+len].c);
457 } 457 }
458 QString unistr(disstrU,len); 458 QString unistr(disstrU,len);
459 drawAttrStr(paint, 459 drawAttrStr(paint,
460 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 460 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
461 unistr, ext[x], pm != NULL, true); 461 unistr, ext[x], pm != NULL, true);
462 x += len - 1; 462 x += len - 1;
463 } 463 }
464 } 464 }
465 // finally, make `image' become `newimg'. 465 // finally, make `image' become `newimg'.
466 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); 466 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca));
467 } 467 }
468 drawFrame( &paint ); 468 drawFrame( &paint );
469 paint.end(); 469 paint.end();
470 setUpdatesEnabled(TRUE); 470 setUpdatesEnabled(TRUE);
471 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms 471 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms
472 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } 472 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; }
473 delete [] disstrU; 473 delete [] disstrU;
474} 474}
475 475
476// paint Event //////////////////////////////////////////////////// 476// paint Event ////////////////////////////////////////////////////
477 477
478/*! 478/*!
479 The difference of this routine vs. the `setImage' is, 479 The difference of this routine vs. the `setImage' is,
480 that the drawing does not include a difference analysis 480 that the drawing does not include a difference analysis
481 between the old and the new image. Instead, the internal 481 between the old and the new image. Instead, the internal
482 image is used and the painting bound by the PaintEvent box. 482 image is used and the painting bound by the PaintEvent box.
483*/ 483*/
484 484
485void TEWidget::paintEvent( QPaintEvent* pe ) 485void TEWidget::paintEvent( QPaintEvent* pe )
486{ 486{
487 487
488//{ static int cnt = 0; printf("paint %d\n",cnt++); } 488//{ static int cnt = 0; printf("paint %d\n",cnt++); }
489 const QPixmap* pm = backgroundPixmap(); 489 const QPixmap* pm = backgroundPixmap();
490 QPainter paint; 490 QPainter paint;
491 setUpdatesEnabled(FALSE); 491 setUpdatesEnabled(FALSE);
492 paint.begin( this ); 492 paint.begin( this );
493 paint.setBackgroundMode( TransparentMode ); 493 paint.setBackgroundMode( TransparentMode );
494HCNT("paintEvent"); 494HCNT("paintEvent");
495 495
496 // Note that the actual widget size can be slightly larger 496 // Note that the actual widget size can be slightly larger
497 // that the image (the size is truncated towards the smaller 497 // that the image (the size is truncated towards the smaller
498 // number of characters in `resizeEvent'. The paint rectangle 498 // number of characters in `resizeEvent'. The paint rectangle
499 // can thus be larger than the image, but less then the size 499 // can thus be larger than the image, but less then the size
500 // of one character. 500 // of one character.
501 501
502 QRect rect = pe->rect().intersect(contentsRect()); 502 QRect rect = pe->rect().intersect(contentsRect());
503 503
504 QPoint tL = contentsRect().topLeft(); 504 QPoint tL = contentsRect().topLeft();
505 int tLx = tL.x(); 505 int tLx = tL.x();
506 int tLy = tL.y(); 506 int tLy = tL.y();
507 507
508 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); 508 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w));
509 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); 509 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h));
510 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); 510 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w));
511 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); 511 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h));
512 512
513 /* 513 /*
514 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, 514 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly,
515 rect.left(), rect.right(), rect.top(), rect.bottom()); 515 rect.left(), rect.right(), rect.top(), rect.bottom());
516 */ 516 */
517 517
518 // if (pm != NULL && color_table[image->b].transparent) 518 // if (pm != NULL && color_table[image->b].transparent)
519 // erase(rect); 519 // erase(rect);
520 // BL: I have no idea why we need this, and it breaks the refresh. 520 // BL: I have no idea why we need this, and it breaks the refresh.
521 521
522 QChar *disstrU = new QChar[columns]; 522 QChar *disstrU = new QChar[columns];
523 for (int y = luy; y <= rly; y++) 523 for (int y = luy; y <= rly; y++)
524 for (int x = lux; x <= rlx; x++) 524 for (int x = lux; x <= rlx; x++)
525 { 525 {
526 int len = 1; 526 int len = 1;
527 disstrU[0] = fontMap(image[loc(x,y)].c); 527 disstrU[0] = fontMap(image[loc(x,y)].c);
528 int cf = image[loc(x,y)].f; 528 int cf = image[loc(x,y)].f;
529 int cb = image[loc(x,y)].b; 529 int cb = image[loc(x,y)].b;
530 int cr = image[loc(x,y)].r; 530 int cr = image[loc(x,y)].r;
531 while (x+len <= rlx && 531 while (x+len <= rlx &&
532 image[loc(x+len,y)].f == cf && 532 image[loc(x+len,y)].f == cf &&
533 image[loc(x+len,y)].b == cb && 533 image[loc(x+len,y)].b == cb &&
534 image[loc(x+len,y)].r == cr ) 534 image[loc(x+len,y)].r == cr )
535 { 535 {
536 disstrU[len] = fontMap(image[loc(x+len,y)].c); 536 disstrU[len] = fontMap(image[loc(x+len,y)].c);
537 len += 1; 537 len += 1;
538 } 538 }
539 QString unistr(disstrU,len); 539 QString unistr(disstrU,len);
540 drawAttrStr(paint, 540 drawAttrStr(paint,
541 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 541 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
542 unistr, image[loc(x,y)], pm != NULL, false); 542 unistr, image[loc(x,y)], pm != NULL, false);
543 x += len - 1; 543 x += len - 1;
544 } 544 }
545 delete [] disstrU; 545 delete [] disstrU;
546 drawFrame( &paint ); 546 drawFrame( &paint );
547 paint.end(); 547 paint.end();
548 setUpdatesEnabled(TRUE); 548 setUpdatesEnabled(TRUE);
549} 549}
550 550
551void TEWidget::blinkEvent() 551void TEWidget::blinkEvent()
552{ 552{
553 blinking = !blinking; 553 blinking = !blinking;
554 repaint(FALSE); 554 repaint(FALSE);
555} 555}
556 556
557/* ------------------------------------------------------------------------- */ 557/* ------------------------------------------------------------------------- */
558/* */ 558/* */
559/* Resizing */ 559/* Resizing */
560/* */ 560/* */
561/* ------------------------------------------------------------------------- */ 561/* ------------------------------------------------------------------------- */
562 562
563void TEWidget::resizeEvent(QResizeEvent* ev) 563void TEWidget::resizeEvent(QResizeEvent* ev)
564{ 564{
565// printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); 565// printf("resize: %d,%d\n",ev->size().width(),ev->size().height());
566 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); 566 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h);
567 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); 567 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h);
568 //printf("curren: %d,%d\n",width(),height()); 568 //printf("curren: %d,%d\n",width(),height());
569HCNT("resizeEvent"); 569HCNT("resizeEvent");
570 570
571 // see comment in `paintEvent' concerning the rounding. 571 // see comment in `paintEvent' concerning the rounding.
572 //FIXME: could make a routine here; check width(),height() 572 //FIXME: could make a routine here; check width(),height()
573 assert(ev->size().width() == width()); 573 assert(ev->size().width() == width());
574 assert(ev->size().height() == height()); 574 assert(ev->size().height() == height());
575 575
576 propagateSize(); 576 propagateSize();
577} 577}
578 578
579void TEWidget::propagateSize() 579void TEWidget::propagateSize()
580{ 580{
581 ca* oldimg = image; 581 ca* oldimg = image;
582 int oldlin = lines; 582 int oldlin = lines;
583 int oldcol = columns; 583 int oldcol = columns;
584 makeImage(); 584 makeImage();
585 // we copy the old image to reduce flicker 585 // we copy the old image to reduce flicker
586 int lins = QMIN(oldlin,lines); 586 int lins = QMIN(oldlin,lines);
587 int cols = QMIN(oldcol,columns); 587 int cols = QMIN(oldcol,columns);
588 if (oldimg) 588 if (oldimg)
589 { 589 {
590 for (int lin = 0; lin < lins; lin++) 590 for (int lin = 0; lin < lins; lin++)
591 memcpy((void*)&image[columns*lin], 591 memcpy((void*)&image[columns*lin],
592 (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); 592 (void*)&oldimg[oldcol*lin],cols*sizeof(ca));
593 free(oldimg); //FIXME: try new,delete 593 free(oldimg); //FIXME: try new,delete
594 } 594 }
595 else 595 else
596 clearImage(); 596 clearImage();
597 597
598 //NOTE: control flows from the back through the chest right into the eye. 598 //NOTE: control flows from the back through the chest right into the eye.
599 // `emu' will call back via `setImage'. 599 // `emu' will call back via `setImage'.
600 600
601 resizing = TRUE; 601 resizing = TRUE;
602 emit changedImageSizeSignal(lines, columns); // expose resizeEvent 602 emit changedImageSizeSignal(lines, columns); // expose resizeEvent
603 resizing = FALSE; 603 resizing = FALSE;
604} 604}
605 605
606/* ------------------------------------------------------------------------- */ 606/* ------------------------------------------------------------------------- */
607/* */ 607/* */
608/* Scrollbar */ 608/* Scrollbar */
609/* */ 609/* */
610/* ------------------------------------------------------------------------- */ 610/* ------------------------------------------------------------------------- */
611 611
612void TEWidget::scrollChanged(int) { 612void TEWidget::scrollChanged(int) {
613 emit changedHistoryCursor(scrollbar->value()); //expose 613 emit changedHistoryCursor(scrollbar->value()); //expose
614} 614}
615 615
616void TEWidget::hScrollChanged(int loc) { 616void TEWidget::hScrollChanged(int loc) {
617 hposition = loc; 617 hposition = loc;
618 propagateSize(); 618 propagateSize();
619 update(); 619 update();
620 620
621// emit changedHorzCursor( hScrollbar->value()); //expose 621// emit changedHorzCursor( hScrollbar->value()); //expose
622} 622}
623 623
624void TEWidget::setScroll(int cursor, int slines) 624void TEWidget::setScroll(int cursor, int slines)
625{ 625{
626 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 626 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
627 scrollbar->setRange(0,slines); 627 scrollbar->setRange(0,slines);
628 scrollbar->setSteps(1,lines); 628 scrollbar->setSteps(1,lines);
629 scrollbar->setValue(cursor); 629 scrollbar->setValue(cursor);
630 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 630 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
631} 631}
632 632
633void TEWidget::setScrollbarLocation(int loc) 633void TEWidget::setScrollbarLocation(int loc)
634{ 634{
635 if (scrollLoc == loc) return; // quickly 635 if (scrollLoc == loc) return; // quickly
636 scrollLoc = loc; 636 scrollLoc = loc;
637 propagateSize(); 637 propagateSize();
638 update(); 638 update();
639} 639}
640 640
641/* ------------------------------------------------------------------------- */ 641/* ------------------------------------------------------------------------- */
642/* */ 642/* */
643/* Mouse */ 643/* Mouse */
644/* */ 644/* */
645/* ------------------------------------------------------------------------- */ 645/* ------------------------------------------------------------------------- */
646 646
647/*! 647/*!
648 Three different operations can be performed using the mouse, and the 648 Three different operations can be performed using the mouse, and the
649 routines in this section serve all of them: 649 routines in this section serve all of them:
650 650
651 1) The press/release events are exposed to the application 651 1) The press/release events are exposed to the application
652 2) Marking (press and move left button) and Pasting (press middle button) 652 2) Marking (press and move left button) and Pasting (press middle button)
653 3) The right mouse button is used from the configuration menu 653 3) The right mouse button is used from the configuration menu
654 654
655 NOTE: During the marking process we attempt to keep the cursor within 655 NOTE: During the marking process we attempt to keep the cursor within
656 the bounds of the text as being displayed by setting the mouse position 656 the bounds of the text as being displayed by setting the mouse position
657 whenever the mouse has left the text area. 657 whenever the mouse has left the text area.
658 658
659 Two reasons to do so: 659 Two reasons to do so:
660 1) QT does not allow the `grabMouse' to confine-to the TEWidget. 660 1) QT does not allow the `grabMouse' to confine-to the TEWidget.
661 Thus a `XGrapPointer' would have to be used instead. 661 Thus a `XGrapPointer' would have to be used instead.
662 2) Even if so, this would not help too much, since the text area 662 2) Even if so, this would not help too much, since the text area
663 of the TEWidget is normally not identical with it's bounds. 663 of the TEWidget is normally not identical with it's bounds.
664 664
665 The disadvantage of the current handling is, that the mouse can visibly 665 The disadvantage of the current handling is, that the mouse can visibly
666 leave the bounds of the widget and is then moved back. Because of the 666 leave the bounds of the widget and is then moved back. Because of the
667 current construction, and the reasons mentioned above, we cannot do better 667 current construction, and the reasons mentioned above, we cannot do better
668 without changing the overall construction. 668 without changing the overall construction.
669*/ 669*/
670 670
671/*! 671/*!
672*/ 672*/
673 673
674void TEWidget::mousePressEvent(QMouseEvent* ev) 674void TEWidget::mousePressEvent(QMouseEvent* ev)
675{ 675{
676//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 676//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
677 if ( !contentsRect().contains(ev->pos()) ) return; 677 if ( !contentsRect().contains(ev->pos()) ) return;
678 QPoint tL = contentsRect().topLeft(); 678 QPoint tL = contentsRect().topLeft();
679 int tLx = tL.x(); 679 int tLx = tL.x();
680 int tLy = tL.y(); 680 int tLy = tL.y();
681 681
682 mouse_down_x = ev->x(); 682 mouse_down_x = ev->x();
683 mouse_down_y = ev->y(); 683 mouse_down_y = ev->y();
684 684
685//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); 685//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY);
686 if ( ev->button() == LeftButton) 686 if ( ev->button() == LeftButton)
687 { 687 {
688 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 688 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
689 689
690 word_selection_mode = (ev->state() & ShiftButton); 690 word_selection_mode = (ev->state() & ShiftButton);
691 691
692 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; 692 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ;
693 693
@@ -846,588 +846,588 @@ void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev)
846 QPoint tL = contentsRect().topLeft(); 846 QPoint tL = contentsRect().topLeft();
847 int tLx = tL.x(); 847 int tLx = tL.x();
848 int tLy = tL.y(); 848 int tLy = tL.y();
849 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 849 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
850 850
851 // pass on double click as two clicks. 851 // pass on double click as two clicks.
852 if (!mouse_marks && !(ev->state() & ShiftButton)) 852 if (!mouse_marks && !(ev->state() & ShiftButton))
853 { 853 {
854 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 854 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
855 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release 855 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release
856 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 856 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
857 return; 857 return;
858 } 858 }
859 859
860 860
861 emit clearSelectionSignal(); 861 emit clearSelectionSignal();
862 QPoint bgnSel = pos; 862 QPoint bgnSel = pos;
863 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 863 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
864 int i = loc(bgnSel.x(),bgnSel.y()); 864 int i = loc(bgnSel.x(),bgnSel.y());
865 iPntSel = bgnSel; 865 iPntSel = bgnSel;
866 866
867 word_selection_mode = TRUE; 867 word_selection_mode = TRUE;
868 868
869 // find word boundaries... 869 // find word boundaries...
870 int selClass = charClass(image[i].c); 870 int selClass = charClass(image[i].c);
871 { 871 {
872 // set the start... 872 // set the start...
873 int x = bgnSel.x(); 873 int x = bgnSel.x();
874 while ( x > 0 && charClass(image[i-1].c) == selClass ) 874 while ( x > 0 && charClass(image[i-1].c) == selClass )
875 { i--; x--; } 875 { i--; x--; }
876 bgnSel.setX(x); 876 bgnSel.setX(x);
877 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); 877 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() );
878 878
879 // set the end... 879 // set the end...
880 i = loc( endSel.x(), endSel.y() ); 880 i = loc( endSel.x(), endSel.y() );
881 x = endSel.x(); 881 x = endSel.x();
882 while( x < columns-1 && charClass(image[i+1].c) == selClass ) 882 while( x < columns-1 && charClass(image[i+1].c) == selClass )
883 { i++; x++ ; } 883 { i++; x++ ; }
884 endSel.setX(x); 884 endSel.setX(x);
885 actSel = 2; // within selection 885 actSel = 2; // within selection
886 emit extendSelectionSignal( endSel.x(), endSel.y() ); 886 emit extendSelectionSignal( endSel.x(), endSel.y() );
887 emit endSelectionSignal(preserve_line_breaks); 887 emit endSelectionSignal(preserve_line_breaks);
888 preserve_line_breaks = TRUE; 888 preserve_line_breaks = TRUE;
889 } 889 }
890} 890}
891 891
892void TEWidget::focusInEvent( QFocusEvent * ) 892void TEWidget::focusInEvent( QFocusEvent * )
893{ 893{
894 894
895 // do nothing, to prevent repainting 895 // do nothing, to prevent repainting
896} 896}
897 897
898 898
899void TEWidget::focusOutEvent( QFocusEvent * ) 899void TEWidget::focusOutEvent( QFocusEvent * )
900{ 900{
901 // do nothing, to prevent repainting 901 // do nothing, to prevent repainting
902} 902}
903 903
904bool TEWidget::focusNextPrevChild( bool next ) 904bool TEWidget::focusNextPrevChild( bool next )
905{ 905{
906 if (next) 906 if (next)
907 return false; // This disables changing the active part in konqueror 907 return false; // This disables changing the active part in konqueror
908 // when pressing Tab 908 // when pressing Tab
909 return QFrame::focusNextPrevChild( next ); 909 return QFrame::focusNextPrevChild( next );
910} 910}
911 911
912 912
913int TEWidget::charClass(char ch) const 913int TEWidget::charClass(char ch) const
914{ 914{
915 // This might seem like overkill, but imagine if ch was a Unicode 915 // This might seem like overkill, but imagine if ch was a Unicode
916 // character (Qt 2.0 QChar) - it might then be sensible to separate 916 // character (Qt 2.0 QChar) - it might then be sensible to separate
917 // the different language ranges, etc. 917 // the different language ranges, etc.
918 918
919 if ( isspace(ch) ) return ' '; 919 if ( isspace(ch) ) return ' ';
920 920
921 static const char *word_characters = ":@-./_~"; 921 static const char *word_characters = ":@-./_~";
922 if ( isalnum(ch) || strchr(word_characters, ch) ) 922 if ( isalnum(ch) || strchr(word_characters, ch) )
923 return 'a'; 923 return 'a';
924 924
925 // Everything else is weird 925 // Everything else is weird
926 return 1; 926 return 1;
927} 927}
928 928
929void TEWidget::setMouseMarks(bool on) 929void TEWidget::setMouseMarks(bool on)
930{ 930{
931 mouse_marks = on; 931 mouse_marks = on;
932 setCursor( mouse_marks ? ibeamCursor : arrowCursor ); 932 setCursor( mouse_marks ? ibeamCursor : arrowCursor );
933} 933}
934 934
935/* ------------------------------------------------------------------------- */ 935/* ------------------------------------------------------------------------- */
936/* */ 936/* */
937/* Clipboard */ 937/* Clipboard */
938/* */ 938/* */
939/* ------------------------------------------------------------------------- */ 939/* ------------------------------------------------------------------------- */
940 940
941#undef KeyPress 941#undef KeyPress
942 942
943void TEWidget::emitSelection() 943void TEWidget::emitSelection()
944// Paste Clipboard by simulating keypress events 944// Paste Clipboard by simulating keypress events
945{ 945{
946#ifndef QT_NO_CLIPBOARD 946#ifndef QT_NO_CLIPBOARD
947 QString text = QApplication::clipboard()->text(); 947 QString text = QApplication::clipboard()->text();
948 //qDebug(text); 948 //qDebug(text);
949 if ( ! text.isNull()) 949 if ( ! text.isNull())
950 { 950 {
951 text.replace(QRegExp("\n"), "\r"); 951 text.replace(QRegExp("\n"), "\r");
952 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 952 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
953 emit keyPressedSignal(&e); // expose as a big fat keypress event 953 emit keyPressedSignal(&e); // expose as a big fat keypress event
954 emit clearSelectionSignal(); 954 emit clearSelectionSignal();
955 } 955 }
956#endif 956#endif
957} 957}
958 958
959void TEWidget::emitText(QString text) 959void TEWidget::emitText(QString text)
960{ 960{
961 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 961 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
962 emit keyPressedSignal(&e); // expose as a big fat keypress event 962 emit keyPressedSignal(&e); // expose as a big fat keypress event
963} 963}
964 964
965void TEWidget::pasteClipboard( ) 965void TEWidget::pasteClipboard( )
966{ 966{
967 emitSelection(); 967 emitSelection();
968} 968}
969 969
970void TEWidget::setSelection(const QString& t) 970void TEWidget::setSelection(const QString& t)
971{ 971{
972#ifndef QT_NO_CLIPBOARD 972#ifndef QT_NO_CLIPBOARD
973 // Disconnect signal while WE set the clipboard 973 // Disconnect signal while WE set the clipboard
974 QObject *cb = QApplication::clipboard(); 974 QObject *cb = QApplication::clipboard();
975 QObject::disconnect( cb, SIGNAL(dataChanged()), 975 QObject::disconnect( cb, SIGNAL(dataChanged()),
976 this, SLOT(onClearSelection()) ); 976 this, SLOT(onClearSelection()) );
977 977
978 QApplication::clipboard()->setText(t); 978 QApplication::clipboard()->setText(t);
979 979
980 QObject::connect( cb, SIGNAL(dataChanged()), 980 QObject::connect( cb, SIGNAL(dataChanged()),
981 this, SLOT(onClearSelection()) ); 981 this, SLOT(onClearSelection()) );
982#endif 982#endif
983} 983}
984 984
985void TEWidget::onClearSelection() 985void TEWidget::onClearSelection()
986{ 986{
987 emit clearSelectionSignal(); 987 emit clearSelectionSignal();
988} 988}
989 989
990/* ------------------------------------------------------------------------- */ 990/* ------------------------------------------------------------------------- */
991/* */ 991/* */
992/* Keyboard */ 992/* Keyboard */
993/* */ 993/* */
994/* ------------------------------------------------------------------------- */ 994/* ------------------------------------------------------------------------- */
995 995
996//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' 996//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent'
997// due to a bug in `QT' or the ignorance of the author to prevent 997// due to a bug in `QT' or the ignorance of the author to prevent
998// repaint events being emitted to the screen whenever one leaves 998// repaint events being emitted to the screen whenever one leaves
999// or reenters the screen to/from another application. 999// or reenters the screen to/from another application.
1000// 1000//
1001// Troll says one needs to change focusInEvent() and focusOutEvent(), 1001// Troll says one needs to change focusInEvent() and focusOutEvent(),
1002// which would also let you have an in-focus cursor and an out-focus 1002// which would also let you have an in-focus cursor and an out-focus
1003// cursor like xterm does. 1003// cursor like xterm does.
1004 1004
1005// for the auto-hide cursor feature, I added empty focusInEvent() and 1005// for the auto-hide cursor feature, I added empty focusInEvent() and
1006// focusOutEvent() so that update() isn't called. 1006// focusOutEvent() so that update() isn't called.
1007// For auto-hide, we need to get keypress-events, but we only get them when 1007// For auto-hide, we need to get keypress-events, but we only get them when
1008// we have focus. 1008// we have focus.
1009 1009
1010void TEWidget::doScroll(int lines) 1010void TEWidget::doScroll(int lines)
1011{ 1011{
1012 scrollbar->setValue(scrollbar->value()+lines); 1012 scrollbar->setValue(scrollbar->value()+lines);
1013} 1013}
1014 1014
1015void TEWidget::doHScroll(int lines) { 1015void TEWidget::doHScroll(int lines) {
1016 hScrollbar->setValue( hScrollbar->value()+lines); 1016 hScrollbar->setValue( hScrollbar->value()+lines);
1017} 1017}
1018 1018
1019bool TEWidget::eventFilter( QObject *obj, QEvent *e ) 1019bool TEWidget::eventFilter( QObject *obj, QEvent *e )
1020{ 1020{
1021 if ( (e->type() == QEvent::Accel || 1021 if ( (e->type() == QEvent::Accel ||
1022 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 1022 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
1023 static_cast<QKeyEvent *>( e )->ignore(); 1023 static_cast<QKeyEvent *>( e )->ignore();
1024 return true; 1024 return true;
1025 } 1025 }
1026 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 1026 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
1027 return FALSE; // not us 1027 return FALSE; // not us
1028 if ( e->type() == QEvent::Wheel) { 1028 if ( e->type() == QEvent::Wheel) {
1029 QApplication::sendEvent(scrollbar, e); 1029 QApplication::sendEvent(scrollbar, e);
1030 } 1030 }
1031 1031
1032#ifdef FAKE_CTRL_AND_ALT 1032#ifdef FAKE_CTRL_AND_ALT
1033 static bool control = FALSE; 1033 static bool control = FALSE;
1034 static bool alt = FALSE; 1034 static bool alt = FALSE;
1035// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 1035// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
1036 bool dele=FALSE; 1036 bool dele=FALSE;
1037 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1037 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1038 QKeyEvent* ke = (QKeyEvent*)e; 1038 QKeyEvent* ke = (QKeyEvent*)e;
1039 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 1039 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
1040 switch (ke->key()) { 1040 switch (ke->key()) {
1041 case Key_F9: // let this be "Control" 1041 case Key_F9: // let this be "Control"
1042 control = keydown; 1042 control = keydown;
1043 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 1043 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
1044 dele=TRUE; 1044 dele=TRUE;
1045 break; 1045 break;
1046 case Key_F13: // let this be "Alt" 1046 case Key_F13: // let this be "Alt"
1047 alt = keydown; 1047 alt = keydown;
1048 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 1048 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
1049 dele=TRUE; 1049 dele=TRUE;
1050 break; 1050 break;
1051 default: 1051 default:
1052 if ( control ) { 1052 if ( control ) {
1053 int a = toupper(ke->ascii())-64; 1053 int a = toupper(ke->ascii())-64;
1054 if ( a >= 0 && a < ' ' ) { 1054 if ( a >= 0 && a < ' ' ) {
1055 e = new QKeyEvent(e->type(), ke->key(), 1055 e = new QKeyEvent(e->type(), ke->key(),
1056 a, ke->state()|ControlButton, QChar(a,0)); 1056 a, ke->state()|ControlButton, QChar(a,0));
1057 dele=TRUE; 1057 dele=TRUE;
1058 } 1058 }
1059 } 1059 }
1060 if ( alt ) { 1060 if ( alt ) {
1061 e = new QKeyEvent(e->type(), ke->key(), 1061 e = new QKeyEvent(e->type(), ke->key(),
1062 ke->ascii(), ke->state()|AltButton, ke->text()); 1062 ke->ascii(), ke->state()|AltButton, ke->text());
1063 dele=TRUE; 1063 dele=TRUE;
1064 } 1064 }
1065 } 1065 }
1066 } 1066 }
1067#endif 1067#endif
1068 1068
1069 if ( e->type() == QEvent::KeyPress ) { 1069 if ( e->type() == QEvent::KeyPress ) {
1070 QKeyEvent* ke = (QKeyEvent*)e; 1070 QKeyEvent* ke = (QKeyEvent*)e;
1071 actSel=0; // Key stroke implies a screen update, so TEWidget won't 1071 actSel=0; // Key stroke implies a screen update, so TEWidget won't
1072 // know where the current selection is. 1072 // know where the current selection is.
1073 1073
1074// qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); 1074// qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state());
1075 1075
1076 bool special_function = true; 1076 bool special_function = true;
1077 switch(ke->key()) { 1077 switch(ke->key()) {
1078 //case 0x201b: // fn-5 1078 //case 0x201b: // fn-5
1079 //case Key_F1: 1079 //case Key_F1:
1080 // switch sessions (?) 1080 // switch sessions (?)
1081 // emitText("\\"); // expose (??) 1081 // emitText("\\"); // expose (??)
1082 // break; 1082 // break;
1083 1083
1084 case 0x2016: // fn-p 1084 case 0x2016: // fn-p
1085 case Key_F2: 1085 case Key_F2:
1086 pasteClipboard(); 1086 pasteClipboard();
1087 break; 1087 break;
1088 1088
1089 case 0x2018: // fn-S 1089 case 0x2018: // fn-S
1090 case Key_F3: 1090 case Key_F3:
1091 emit changeSession(1); 1091 emit changeSession(1);
1092 break; 1092 break;
1093 1093
1094 case 0x2019: // fn-n 1094 case 0x2019: // fn-n
1095 emit newSession(); 1095 emit newSession();
1096 break; 1096 break;
1097 1097
1098 case Qt::Key_Tab: 1098 case Qt::Key_Tab:
1099 if (ke->state() == ControlButton) { 1099 if (ke->state() == ControlButton) {
1100 emit changeSession(1); 1100 emit changeSession(1);
1101 } else { 1101 } else {
1102 special_function = false; 1102 special_function = false;
1103 } 1103 }
1104 break; 1104 break;
1105 1105
1106#if 0 1106#if 0
1107 case Qt::Key_Left: 1107 case Qt::Key_Left:
1108 if (vcolumns == 0) { 1108 if (vcolumns == 0) {
1109 emit changeSession(-1); 1109 emit changeSession(-1);
1110 } else { 1110 } else {
1111 special_function = false; 1111 special_function = false;
1112 } 1112 }
1113 break; 1113 break;
1114 1114
1115 case Qt::Key_Right: 1115 case Qt::Key_Right:
1116 if (vcolumns == 0) { 1116 if (vcolumns == 0) {
1117 emit changeSession(1); 1117 emit changeSession(1);
1118 } else { 1118 } else {
1119 special_function = false; 1119 special_function = false;
1120 } 1120 }
1121 break; 1121 break;
1122#endif 1122#endif
1123 1123
1124 case 0x201b: // fn-5 1124 case 0x201b: // fn-5
1125 case Key_F4: 1125 case Key_F4:
1126 emit toggleFullScreen(); 1126 emit toggleFullScreen();
1127 break; 1127 break;
1128 1128
1129 case 0x200f: // fn-1 magnify minus 1129 case 0x200f: // fn-1 magnify minus
1130 case Key_F5: 1130 case Key_F5:
1131 emit changeFontSize(-1); 1131 emit changeFontSize(-1);
1132 break; 1132 break;
1133 1133
1134 case 0x2010: // fn-2 magnify plus 1134 case 0x2010: // fn-2 magnify plus
1135 case Key_F6: 1135 case Key_F6:
1136 emit changeFontSize(1); 1136 emit changeFontSize(1);
1137 break; 1137 break;
1138 1138
1139 default: 1139 default:
1140 special_function = false; 1140 special_function = false;
1141 } 1141 }
1142 if (special_function) { 1142 if (special_function) {
1143 return true; 1143 return true;
1144 } 1144 }
1145 // else if( ke->state() == ControlButton && ke->key() == Key_V) { 1145 // else if( ke->state() == ControlButton && ke->key() == Key_V) {
1146 // pasteClipboard(); 1146 // pasteClipboard();
1147 // } 1147 // }
1148 // else if( ke->state() == ControlButton && ke->key() == Key_C) { 1148 // else if( ke->state() == ControlButton && ke->key() == Key_C) {
1149 // pasteClipboard(); 1149 // pasteClipboard();
1150 // } 1150 // }
1151 emit keyPressedSignal(ke); // expose 1151 emit keyPressedSignal(ke); // expose
1152 ke->accept(); 1152 ke->accept();
1153#ifdef FAKE_CTRL_AND_ALT 1153#ifdef FAKE_CTRL_AND_ALT
1154 if ( dele ) delete e; 1154 if ( dele ) delete e;
1155#endif 1155#endif
1156 return true; // stop the event 1156 return true; // stop the event
1157 } 1157 }
1158 if ( e->type() == QEvent::Enter ) { 1158 if ( e->type() == QEvent::Enter ) {
1159 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1159 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1160 this, SLOT(onClearSelection()) ); 1160 this, SLOT(onClearSelection()) );
1161 } 1161 }
1162 if ( e->type() == QEvent::Leave ) { 1162 if ( e->type() == QEvent::Leave ) {
1163 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1163 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1164 this, SLOT(onClearSelection()) ); 1164 this, SLOT(onClearSelection()) );
1165 } 1165 }
1166 return QFrame::eventFilter( obj, e ); 1166 return QFrame::eventFilter( obj, e );
1167} 1167}
1168 1168
1169/* ------------------------------------------------------------------------- */ 1169/* ------------------------------------------------------------------------- */
1170/* */ 1170/* */
1171/* Frame */ 1171/* Frame */
1172/* */ 1172/* */
1173/* ------------------------------------------------------------------------- */ 1173/* ------------------------------------------------------------------------- */
1174 1174
1175void TEWidget::frameChanged() 1175void TEWidget::frameChanged()
1176{ 1176{
1177 propagateSize(); 1177 propagateSize();
1178 update(); 1178 update();
1179} 1179}
1180/* ------------------------------------------------------------------------- */ 1180/* ------------------------------------------------------------------------- */
1181/* */ 1181/* */
1182/* Sound */ 1182/* Sound */
1183/* */ 1183/* */
1184/* ------------------------------------------------------------------------- */ 1184/* ------------------------------------------------------------------------- */
1185 1185
1186void TEWidget::Bell() 1186void TEWidget::Bell()
1187{ 1187{
1188//#ifdef QT_QWS_SL5XXX 1188//#ifdef QT_QWS_SL5XXX
1189//# ifndef QT_NO_COP 1189//# ifndef QT_NO_COP
1190 if(useBeep) 1190 if(useBeep)
1191 QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); 1191 QCopEnvelope( "QPE/TaskBar", "soundAlarm()" );
1192 1192
1193//# endif 1193//# endif
1194//#else 1194//#else
1195//# ifndef QT_NO_SOUND 1195//# ifndef QT_NO_SOUND
1196// QSound::play(Resource::findSound("alarm")); 1196// QSound::play(Resource::findSound("alarm"));
1197//# endif 1197//# endif
1198//#endif 1198//#endif
1199 1199
1200// QApplication::beep(); 1200// QApplication::beep();
1201} 1201}
1202 1202
1203/* ------------------------------------------------------------------------- */ 1203/* ------------------------------------------------------------------------- */
1204/* */ 1204/* */
1205/* Auxiluary */ 1205/* Auxiluary */
1206/* */ 1206/* */
1207/* ------------------------------------------------------------------------- */ 1207/* ------------------------------------------------------------------------- */
1208 1208
1209void TEWidget::clearImage() 1209void TEWidget::clearImage()
1210// initialize the image 1210// initialize the image
1211// for internal use only 1211// for internal use only
1212{ 1212{
1213 for (int y = 0; y < lines; y++) 1213 for (int y = 0; y < lines; y++)
1214 for (int x = 0; x < columns; x++) 1214 for (int x = 0; x < columns; x++)
1215 { 1215 {
1216 image[loc(x,y)].c = 0xff; //' '; 1216 image[loc(x,y)].c = 0xff; //' ';
1217 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; 1217 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
1218 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; 1218 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
1219 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; 1219 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
1220 } 1220 }
1221} 1221}
1222 1222
1223// Create Image /////////////////////////////////////////////////////// 1223// Create Image ///////////////////////////////////////////////////////
1224 1224
1225void TEWidget::calcGeometry() 1225void TEWidget::calcGeometry()
1226{ 1226{
1227 int showhscrollbar = 1; 1227 int showhscrollbar = 1;
1228 int hwidth = 0; 1228 int hwidth = 0;
1229 int dcolumns; 1229 int dcolumns;
1230 Config cfg("Qkonsole"); 1230 Config cfg( "Konsole" );
1231 cfg.setGroup("ScrollBar"); 1231 cfg.setGroup("ScrollBar");
1232 useHorzScroll=cfg.readBoolEntry("HorzScroll",0); 1232 useHorzScroll=cfg.readBoolEntry("HorzScroll",0);
1233 1233
1234 if(vcolumns == 0) showhscrollbar = 0; 1234 if(vcolumns == 0) showhscrollbar = 0;
1235 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); 1235 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width();
1236 1236
1237 scrollbar->resize(QApplication::style().scrollBarExtent().width(), 1237 scrollbar->resize(QApplication::style().scrollBarExtent().width(),
1238 contentsRect().height() - hwidth); 1238 contentsRect().height() - hwidth);
1239 1239
1240 switch(scrollLoc) { 1240 switch(scrollLoc) {
1241 case SCRNONE : 1241 case SCRNONE :
1242 columns = ( contentsRect().width() - 2 * rimX ) / font_w; 1242 columns = ( contentsRect().width() - 2 * rimX ) / font_w;
1243 dcolumns = columns; 1243 dcolumns = columns;
1244 if(vcolumns) columns = vcolumns; 1244 if(vcolumns) columns = vcolumns;
1245 blX = (contentsRect().width() - (columns*font_w) ) / 2; 1245 blX = (contentsRect().width() - (columns*font_w) ) / 2;
1246 if(showhscrollbar) 1246 if(showhscrollbar)
1247 blX = -hposition * font_w; 1247 blX = -hposition * font_w;
1248 brX = blX; 1248 brX = blX;
1249 scrollbar->hide(); 1249 scrollbar->hide();
1250 break; 1250 break;
1251 case SCRLEFT : 1251 case SCRLEFT :
1252 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1252 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1253 dcolumns = columns; 1253 dcolumns = columns;
1254 if(vcolumns) columns = vcolumns; 1254 if(vcolumns) columns = vcolumns;
1255 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1255 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1256 if(showhscrollbar) 1256 if(showhscrollbar)
1257 brX = -hposition * font_w; 1257 brX = -hposition * font_w;
1258 blX = brX + scrollbar->width(); 1258 blX = brX + scrollbar->width();
1259 scrollbar->move(contentsRect().topLeft()); 1259 scrollbar->move(contentsRect().topLeft());
1260 scrollbar->show(); 1260 scrollbar->show();
1261 break; 1261 break;
1262 case SCRRIGHT: 1262 case SCRRIGHT:
1263 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1263 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1264 dcolumns = columns; 1264 dcolumns = columns;
1265 if(vcolumns) columns = vcolumns; 1265 if(vcolumns) columns = vcolumns;
1266 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1266 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1267 if(showhscrollbar) 1267 if(showhscrollbar)
1268 blX = -hposition * font_w; 1268 blX = -hposition * font_w;
1269 brX = blX; 1269 brX = blX;
1270 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); 1270 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
1271 scrollbar->show(); 1271 scrollbar->show();
1272 break; 1272 break;
1273 } 1273 }
1274 //FIXME: support 'rounding' styles 1274 //FIXME: support 'rounding' styles
1275 lines = ( contentsRect().height() - 2 * rimY ) / font_h; 1275 lines = ( contentsRect().height() - 2 * rimY ) / font_h;
1276 bY = (contentsRect().height() - (lines *font_h)) / 2; 1276 bY = (contentsRect().height() - (lines *font_h)) / 2;
1277 1277
1278 if(showhscrollbar == 1) { 1278 if(showhscrollbar == 1) {
1279 hScrollbar->resize(contentsRect().width() - hwidth, hwidth); 1279 hScrollbar->resize(contentsRect().width() - hwidth, hwidth);
1280 hScrollbar->setRange(0, vcolumns - dcolumns); 1280 hScrollbar->setRange(0, vcolumns - dcolumns);
1281 1281
1282 QPoint p = contentsRect().bottomLeft(); 1282 QPoint p = contentsRect().bottomLeft();
1283 if(scrollLoc == SCRLEFT) 1283 if(scrollLoc == SCRLEFT)
1284 hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth)); 1284 hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth));
1285 else 1285 else
1286 hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); 1286 hScrollbar->move(QPoint(p.x(), p.y() - hwidth));
1287 1287
1288 hScrollbar->show(); 1288 hScrollbar->show();
1289 } 1289 }
1290 else hScrollbar->hide(); 1290 else hScrollbar->hide();
1291 1291
1292 if(showhscrollbar == 1) { 1292 if(showhscrollbar == 1) {
1293 lines = lines - (hwidth / font_h) - 1; 1293 lines = lines - (hwidth / font_h) - 1;
1294 if(lines < 1) lines = 1; 1294 if(lines < 1) lines = 1;
1295 } 1295 }
1296 //FIXME: support 'rounding' styles 1296 //FIXME: support 'rounding' styles
1297} 1297}
1298 1298
1299void TEWidget::makeImage() 1299void TEWidget::makeImage()
1300//FIXME: rename 'calcGeometry? 1300//FIXME: rename 'calcGeometry?
1301{ 1301{
1302 calcGeometry(); 1302 calcGeometry();
1303 image = (ca*) malloc(lines*columns*sizeof(ca)); 1303 image = (ca*) malloc(lines*columns*sizeof(ca));
1304 clearImage(); 1304 clearImage();
1305} 1305}
1306 1306
1307// calculate the needed size 1307// calculate the needed size
1308QSize TEWidget::calcSize(int cols, int lins) const 1308QSize TEWidget::calcSize(int cols, int lins) const
1309{ 1309{
1310 int frw = width() - contentsRect().width(); 1310 int frw = width() - contentsRect().width();
1311 int frh = height() - contentsRect().height(); 1311 int frh = height() - contentsRect().height();
1312 int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); 1312 int scw = (scrollLoc==SCRNONE?0:scrollbar->width());
1313 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); 1313 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh );
1314} 1314}
1315 1315
1316QSize TEWidget::sizeHint() const 1316QSize TEWidget::sizeHint() const
1317{ 1317{
1318 return size(); 1318 return size();
1319} 1319}
1320 1320
1321void TEWidget::styleChange(QStyle &) 1321void TEWidget::styleChange(QStyle &)
1322{ 1322{
1323 propagateSize(); 1323 propagateSize();
1324} 1324}
1325 1325
1326#ifndef QT_NO_DRAGANDDROP 1326#ifndef QT_NO_DRAGANDDROP
1327 1327
1328/* --------------------------------------------------------------------- */ 1328/* --------------------------------------------------------------------- */
1329/* */ 1329/* */
1330/* Drag & Drop */ 1330/* Drag & Drop */
1331/* */ 1331/* */
1332/* --------------------------------------------------------------------- */ 1332/* --------------------------------------------------------------------- */
1333 1333
1334 1334
1335void TEWidget::dragEnterEvent(QDragEnterEvent* e) 1335void TEWidget::dragEnterEvent(QDragEnterEvent* e)
1336{ 1336{
1337 e->accept(QTextDrag::canDecode(e) || 1337 e->accept(QTextDrag::canDecode(e) ||
1338 QUriDrag::canDecode(e)); 1338 QUriDrag::canDecode(e));
1339} 1339}
1340 1340
1341void TEWidget::dropEvent(QDropEvent* event) 1341void TEWidget::dropEvent(QDropEvent* event)
1342{ 1342{
1343 // The current behaviour when url(s) are dropped is 1343 // The current behaviour when url(s) are dropped is
1344 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd 1344 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd
1345 // * in all other cases, just paste 1345 // * in all other cases, just paste
1346 // (for non-local ones, or for a list of URLs, 'cd' is nonsense) 1346 // (for non-local ones, or for a list of URLs, 'cd' is nonsense)
1347 QStrList strlist; 1347 QStrList strlist;
1348 int file_count = 0; 1348 int file_count = 0;
1349 dropText = ""; 1349 dropText = "";
1350 bool bPopup = true; 1350 bool bPopup = true;
1351 1351
1352 if(QUriDrag::decode(event, strlist)) { 1352 if(QUriDrag::decode(event, strlist)) {
1353 if (strlist.count()) { 1353 if (strlist.count()) {
1354 for(const char* p = strlist.first(); p; p = strlist.next()) { 1354 for(const char* p = strlist.first(); p; p = strlist.next()) {
1355 if(file_count++ > 0) { 1355 if(file_count++ > 0) {
1356 dropText += " "; 1356 dropText += " ";
1357 bPopup = false; // more than one file, don't popup 1357 bPopup = false; // more than one file, don't popup
1358 } 1358 }
1359 1359
1360/* 1360/*
1361 KURL url(p); 1361 KURL url(p);
1362 if (url.isLocalFile()) { 1362 if (url.isLocalFile()) {
1363 dropText += url.path(); // local URL : remove protocol 1363 dropText += url.path(); // local URL : remove protocol
1364 } 1364 }
1365 else { 1365 else {
1366 dropText += url.prettyURL(); 1366 dropText += url.prettyURL();
1367 bPopup = false; // a non-local file, don't popup 1367 bPopup = false; // a non-local file, don't popup
1368 } 1368 }
1369*/ 1369*/
1370 1370
1371 } 1371 }
1372 1372
1373 if (bPopup) 1373 if (bPopup)
1374 // m_drop->popup(pos() + event->pos()); 1374 // m_drop->popup(pos() + event->pos());
1375 m_drop->popup(mapToGlobal(event->pos())); 1375 m_drop->popup(mapToGlobal(event->pos()));
1376 else 1376 else
1377 { 1377 {
1378 if (currentSession) { 1378 if (currentSession) {
1379 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1379 currentSession->getEmulation()->sendString(dropText.local8Bit());
1380 } 1380 }
1381// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1381// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1382 } 1382 }
1383 } 1383 }
1384 } 1384 }
1385 else if(QTextDrag::decode(event, dropText)) { 1385 else if(QTextDrag::decode(event, dropText)) {
1386// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1386// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1387 if (currentSession) { 1387 if (currentSession) {
1388 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1388 currentSession->getEmulation()->sendString(dropText.local8Bit());
1389 } 1389 }
1390 // Paste it 1390 // Paste it
1391 } 1391 }
1392} 1392}
1393#endif 1393#endif
1394 1394
1395 1395
1396void TEWidget::drop_menu_activated(int item) 1396void TEWidget::drop_menu_activated(int item)
1397{ 1397{
1398#ifndef QT_NO_DRAGANDDROP 1398#ifndef QT_NO_DRAGANDDROP
1399 switch (item) 1399 switch (item)
1400 { 1400 {
1401 case 0: // paste 1401 case 0: // paste
1402 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1402 currentSession->getEmulation()->sendString(dropText.local8Bit());
1403// KWM::activate((Window)this->winId()); 1403// KWM::activate((Window)this->winId());
1404 break; 1404 break;
1405 case 1: // cd ... 1405 case 1: // cd ...
1406 currentSession->getEmulation()->sendString("cd "); 1406 currentSession->getEmulation()->sendString("cd ");
1407 struct stat statbuf; 1407 struct stat statbuf;
1408 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) 1408 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 )
1409 { 1409 {
1410 if ( !S_ISDIR(statbuf.st_mode) ) 1410 if ( !S_ISDIR(statbuf.st_mode) )
1411 { 1411 {
1412/* 1412/*
1413 KURL url; 1413 KURL url;
1414 url.setPath( dropText ); 1414 url.setPath( dropText );
1415 dropText = url.directory( true, false ); // remove filename 1415 dropText = url.directory( true, false ); // remove filename
1416*/ 1416*/
1417 } 1417 }
1418 } 1418 }
1419 dropText.replace(QRegExp(" "), "\\ "); // escape spaces 1419 dropText.replace(QRegExp(" "), "\\ "); // escape spaces
1420 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1420 currentSession->getEmulation()->sendString(dropText.local8Bit());
1421 currentSession->getEmulation()->sendString("\n"); 1421 currentSession->getEmulation()->sendString("\n");
1422// KWM::activate((Window)this->winId()); 1422// KWM::activate((Window)this->winId());
1423 break; 1423 break;
1424 } 1424 }
1425#endif 1425#endif
1426} 1426}
1427 1427
1428void TEWidget::setWrapAt(int columns) 1428void TEWidget::setWrapAt(int columns)
1429{ 1429{
1430 vcolumns = columns; 1430 vcolumns = columns;
1431 propagateSize(); 1431 propagateSize();
1432 update(); 1432 update();
1433} 1433}
diff --git a/core/apps/embeddedkonsole/commandeditdialog.cpp b/core/apps/embeddedkonsole/commandeditdialog.cpp
index 03cba87..b23db18 100644
--- a/core/apps/embeddedkonsole/commandeditdialog.cpp
+++ b/core/apps/embeddedkonsole/commandeditdialog.cpp
@@ -1,199 +1,199 @@
1//comandeditdialog.cpp 1//comandeditdialog.cpp
2 2
3#include "commandeditdialog.h" 3#include "commandeditdialog.h"
4#include "playlistselection.h" 4#include "playlistselection.h"
5#include <qstring.h> 5#include <qstring.h>
6#include <qpe/config.h> 6#include <qpe/config.h>
7#include <qtoolbar.h> 7#include <qtoolbar.h>
8#include <qwidget.h> 8#include <qwidget.h>
9#include <qmenubar.h> 9#include <qmenubar.h>
10#include <qpe/resource.h> 10#include <qpe/resource.h>
11#include <qlist.h> 11#include <qlist.h>
12#include <qtoolbutton.h> 12#include <qtoolbutton.h>
13#include <qvbox.h> 13#include <qvbox.h>
14#include <qlistview.h> 14#include <qlistview.h>
15#include <qlineedit.h> 15#include <qlineedit.h>
16#include <qheader.h> 16#include <qheader.h>
17#include <qlabel.h> 17#include <qlabel.h>
18#include <qmessagebox.h> 18#include <qmessagebox.h>
19#include "smallcommandeditdialogbase.h" 19#include "smallcommandeditdialogbase.h"
20 20
21CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl ) 21CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl )
22 : CommandEditDialogBase(parent, name, TRUE, fl) 22 : CommandEditDialogBase(parent, name, TRUE, fl)
23 23
24{ 24{
25 m_SuggestedCommandList->addColumn( tr("Command Selection") ); 25 m_SuggestedCommandList->addColumn( tr("Command Selection") );
26 m_SuggestedCommandList->header()->hide(); 26 m_SuggestedCommandList->header()->hide();
27 m_SuggestedCommandList->setSorting(-1,FALSE); 27 m_SuggestedCommandList->setSorting(-1,FALSE);
28 m_SuggestedCommandList->clearSelection(); 28 m_SuggestedCommandList->clearSelection();
29 m_SuggestedCommandList->setSorting(0,TRUE); 29 m_SuggestedCommandList->setSorting(0,TRUE);
30 QListViewItem *item; 30 QListViewItem *item;
31 item = new QListViewItem( m_SuggestedCommandList,"export "); 31 item = new QListViewItem( m_SuggestedCommandList,"export ");
32 item = new QListViewItem( m_SuggestedCommandList,"ifconfig "); 32 item = new QListViewItem( m_SuggestedCommandList,"ifconfig ");
33 item = new QListViewItem( m_SuggestedCommandList,"ipkg "); 33 item = new QListViewItem( m_SuggestedCommandList,"ipkg ");
34 item = new QListViewItem( m_SuggestedCommandList,"gzip "); 34 item = new QListViewItem( m_SuggestedCommandList,"gzip ");
35 item = new QListViewItem( m_SuggestedCommandList,"gunzip "); 35 item = new QListViewItem( m_SuggestedCommandList,"gunzip ");
36 item = new QListViewItem( m_SuggestedCommandList,"chgrp "); 36 item = new QListViewItem( m_SuggestedCommandList,"chgrp ");
37 item = new QListViewItem( m_SuggestedCommandList,"chown "); 37 item = new QListViewItem( m_SuggestedCommandList,"chown ");
38 item = new QListViewItem( m_SuggestedCommandList,"date "); 38 item = new QListViewItem( m_SuggestedCommandList,"date ");
39 item = new QListViewItem( m_SuggestedCommandList,"dd "); 39 item = new QListViewItem( m_SuggestedCommandList,"dd ");
40 item = new QListViewItem( m_SuggestedCommandList,"dmesg "); 40 item = new QListViewItem( m_SuggestedCommandList,"dmesg ");
41 item = new QListViewItem( m_SuggestedCommandList,"fuser "); 41 item = new QListViewItem( m_SuggestedCommandList,"fuser ");
42 item = new QListViewItem( m_SuggestedCommandList,"hostname "); 42 item = new QListViewItem( m_SuggestedCommandList,"hostname ");
43 item = new QListViewItem( m_SuggestedCommandList,"kill "); 43 item = new QListViewItem( m_SuggestedCommandList,"kill ");
44 item = new QListViewItem( m_SuggestedCommandList,"killall "); 44 item = new QListViewItem( m_SuggestedCommandList,"killall ");
45 item = new QListViewItem( m_SuggestedCommandList,"ln "); 45 item = new QListViewItem( m_SuggestedCommandList,"ln ");
46 item = new QListViewItem( m_SuggestedCommandList,"ln -s "); 46 item = new QListViewItem( m_SuggestedCommandList,"ln -s ");
47 item = new QListViewItem( m_SuggestedCommandList,"lsmod"); 47 item = new QListViewItem( m_SuggestedCommandList,"lsmod");
48 item = new QListViewItem( m_SuggestedCommandList,"depmod -a"); 48 item = new QListViewItem( m_SuggestedCommandList,"depmod -a");
49 item = new QListViewItem( m_SuggestedCommandList,"modprobe "); 49 item = new QListViewItem( m_SuggestedCommandList,"modprobe ");
50 item = new QListViewItem( m_SuggestedCommandList,"mount "); 50 item = new QListViewItem( m_SuggestedCommandList,"mount ");
51 item = new QListViewItem( m_SuggestedCommandList,"more "); 51 item = new QListViewItem( m_SuggestedCommandList,"more ");
52 item = new QListViewItem( m_SuggestedCommandList,"sort "); 52 item = new QListViewItem( m_SuggestedCommandList,"sort ");
53 item = new QListViewItem( m_SuggestedCommandList,"touch "); 53 item = new QListViewItem( m_SuggestedCommandList,"touch ");
54 item = new QListViewItem( m_SuggestedCommandList,"umount "); 54 item = new QListViewItem( m_SuggestedCommandList,"umount ");
55 item = new QListViewItem( m_SuggestedCommandList,"mknod "); 55 item = new QListViewItem( m_SuggestedCommandList,"mknod ");
56 item = new QListViewItem( m_SuggestedCommandList,"netstat "); 56 item = new QListViewItem( m_SuggestedCommandList,"netstat ");
57 item = new QListViewItem( m_SuggestedCommandList,"route "); 57 item = new QListViewItem( m_SuggestedCommandList,"route ");
58 item = new QListViewItem( m_SuggestedCommandList,"cardctl eject "); 58 item = new QListViewItem( m_SuggestedCommandList,"cardctl eject ");
59 m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); 59 m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE);
60 m_SuggestedCommandList->sort(); 60 m_SuggestedCommandList->sort();
61 61
62 connect( m_SuggestedCommandList, SIGNAL( clicked( QListViewItem * ) ), m_PlayListSelection, SLOT( addToSelection( QListViewItem *) ) ); 62 connect( m_SuggestedCommandList, SIGNAL( clicked( QListViewItem * ) ), m_PlayListSelection, SLOT( addToSelection( QListViewItem *) ) );
63 63
64 64
65 65
66 ToolButton1->setTextLabel("new"); 66 ToolButton1->setTextLabel("new");
67 ToolButton1->setPixmap(Resource::loadPixmap("new")); 67 ToolButton1->setPixmap(Resource::loadPixmap("new"));
68 ToolButton1->setAutoRaise(TRUE); 68 ToolButton1->setAutoRaise(TRUE);
69 ToolButton1->setFocusPolicy(QWidget::NoFocus); 69 ToolButton1->setFocusPolicy(QWidget::NoFocus);
70 connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); 70 connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog()));
71 71
72 ToolButton2->setTextLabel("edit"); 72 ToolButton2->setTextLabel("edit");
73 ToolButton2->setPixmap(Resource::loadPixmap("edit")); 73 ToolButton2->setPixmap(Resource::loadPixmap("edit"));
74 ToolButton2->setAutoRaise(TRUE); 74 ToolButton2->setAutoRaise(TRUE);
75 ToolButton2->setFocusPolicy(QWidget::NoFocus); 75 ToolButton2->setFocusPolicy(QWidget::NoFocus);
76 connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); 76 connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog()));
77 77
78 ToolButton3->setTextLabel("delete"); 78 ToolButton3->setTextLabel("delete");
79 ToolButton3->setPixmap(Resource::loadPixmap("editdelete")); 79 ToolButton3->setPixmap(Resource::loadPixmap("editdelete"));
80 ToolButton3->setAutoRaise(TRUE); 80 ToolButton3->setAutoRaise(TRUE);
81 ToolButton3->setFocusPolicy(QWidget::NoFocus); 81 ToolButton3->setFocusPolicy(QWidget::NoFocus);
82 connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); 82 connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected()));
83 83
84 ToolButton4->setTextLabel("up"); 84 ToolButton4->setTextLabel("up");
85 ToolButton4->setPixmap(Resource::loadPixmap("up")); 85 ToolButton4->setPixmap(Resource::loadPixmap("up"));
86 ToolButton4->setAutoRaise(TRUE); 86 ToolButton4->setAutoRaise(TRUE);
87 ToolButton4->setFocusPolicy(QWidget::NoFocus); 87 ToolButton4->setFocusPolicy(QWidget::NoFocus);
88 connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); 88 connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp()));
89 89
90 ToolButton5->setTextLabel("down"); 90 ToolButton5->setTextLabel("down");
91 ToolButton5->setPixmap(Resource::loadPixmap("down")); 91 ToolButton5->setPixmap(Resource::loadPixmap("down"));
92 ToolButton5->setAutoRaise(TRUE); 92 ToolButton5->setAutoRaise(TRUE);
93 ToolButton5->setFocusPolicy(QWidget::NoFocus); 93 ToolButton5->setFocusPolicy(QWidget::NoFocus);
94 94
95connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); 95connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown()));
96 96
97 97
98 98
99 99
100 QListViewItem *current = m_SuggestedCommandList->selectedItem(); 100 QListViewItem *current = m_SuggestedCommandList->selectedItem();
101 if ( current ) 101 if ( current )
102 item->moveItem( current ); 102 item->moveItem( current );
103 m_SuggestedCommandList->setSelected( item, TRUE ); 103 m_SuggestedCommandList->setSelected( item, TRUE );
104 m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); 104 m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() );
105 Config cfg("Qkonsole"); 105 Config cfg( "Konsole" );
106 cfg.setGroup("Commands"); 106 cfg.setGroup("Commands");
107 if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { 107 if (cfg.readEntry("Commands Set","FALSE") == "TRUE") {
108 for (int i = 0; i < 100; i++) { 108 for (int i = 0; i < 100; i++) {
109 QString tmp; 109 QString tmp;
110 tmp = cfg.readEntry( QString::number(i),""); 110 tmp = cfg.readEntry( QString::number(i),"");
111 if (!tmp.isEmpty()) 111 if (!tmp.isEmpty())
112 m_PlayListSelection->addStringToSelection(tmp); 112 m_PlayListSelection->addStringToSelection(tmp);
113 } 113 }
114 } else { 114 } else {
115 115
116m_PlayListSelection->addStringToSelection("ls "); 116m_PlayListSelection->addStringToSelection("ls ");
117m_PlayListSelection->addStringToSelection("cardctl eject"); 117m_PlayListSelection->addStringToSelection("cardctl eject");
118m_PlayListSelection->addStringToSelection("cat "); 118m_PlayListSelection->addStringToSelection("cat ");
119m_PlayListSelection->addStringToSelection("cd "); 119m_PlayListSelection->addStringToSelection("cd ");
120m_PlayListSelection->addStringToSelection("chmod "); 120m_PlayListSelection->addStringToSelection("chmod ");
121m_PlayListSelection->addStringToSelection("cp "); 121m_PlayListSelection->addStringToSelection("cp ");
122m_PlayListSelection->addStringToSelection("dc "); 122m_PlayListSelection->addStringToSelection("dc ");
123m_PlayListSelection->addStringToSelection("df "); 123m_PlayListSelection->addStringToSelection("df ");
124m_PlayListSelection->addStringToSelection("dmesg"); 124m_PlayListSelection->addStringToSelection("dmesg");
125m_PlayListSelection->addStringToSelection("echo "); 125m_PlayListSelection->addStringToSelection("echo ");
126m_PlayListSelection->addStringToSelection("env"); 126m_PlayListSelection->addStringToSelection("env");
127m_PlayListSelection->addStringToSelection("find "); 127m_PlayListSelection->addStringToSelection("find ");
128m_PlayListSelection->addStringToSelection("free"); 128m_PlayListSelection->addStringToSelection("free");
129m_PlayListSelection->addStringToSelection("grep "); 129m_PlayListSelection->addStringToSelection("grep ");
130m_PlayListSelection->addStringToSelection("ifconfig "); 130m_PlayListSelection->addStringToSelection("ifconfig ");
131m_PlayListSelection->addStringToSelection("ipkg "); 131m_PlayListSelection->addStringToSelection("ipkg ");
132m_PlayListSelection->addStringToSelection("mkdir "); 132m_PlayListSelection->addStringToSelection("mkdir ");
133m_PlayListSelection->addStringToSelection("mv "); 133m_PlayListSelection->addStringToSelection("mv ");
134m_PlayListSelection->addStringToSelection("nc localhost 7776"); 134m_PlayListSelection->addStringToSelection("nc localhost 7776");
135m_PlayListSelection->addStringToSelection("nc localhost 7777"); 135m_PlayListSelection->addStringToSelection("nc localhost 7777");
136m_PlayListSelection->addStringToSelection("nslookup "); 136m_PlayListSelection->addStringToSelection("nslookup ");
137m_PlayListSelection->addStringToSelection("ping "); 137m_PlayListSelection->addStringToSelection("ping ");
138m_PlayListSelection->addStringToSelection("ps aux"); 138m_PlayListSelection->addStringToSelection("ps aux");
139m_PlayListSelection->addStringToSelection("pwd "); 139m_PlayListSelection->addStringToSelection("pwd ");
140m_PlayListSelection->addStringToSelection("rm "); 140m_PlayListSelection->addStringToSelection("rm ");
141m_PlayListSelection->addStringToSelection("rmdir "); 141m_PlayListSelection->addStringToSelection("rmdir ");
142m_PlayListSelection->addStringToSelection("route "); 142m_PlayListSelection->addStringToSelection("route ");
143m_PlayListSelection->addStringToSelection("set "); 143m_PlayListSelection->addStringToSelection("set ");
144m_PlayListSelection->addStringToSelection("traceroute"); 144m_PlayListSelection->addStringToSelection("traceroute");
145 145
146} 146}
147} 147}
148CommandEditDialog::~CommandEditDialog() 148CommandEditDialog::~CommandEditDialog()
149{ 149{
150} 150}
151 151
152void CommandEditDialog::accept() 152void CommandEditDialog::accept()
153{ 153{
154int i = 0; 154int i = 0;
155 Config *cfg = new Config("Qkonsole"); 155 Config *cfg = new Config("Qkonsole");
156 cfg->setGroup("Commands"); 156 cfg->setGroup("Commands");
157 cfg->clearGroup(); 157 cfg->clearGroup();
158 158
159 QListViewItemIterator it( m_PlayListSelection ); 159 QListViewItemIterator it( m_PlayListSelection );
160 160
161 for ( ; it.current(); ++it ) { 161 for ( ; it.current(); ++it ) {
162// qDebug(it.current()->text(0)); 162// qDebug(it.current()->text(0));
163 cfg->writeEntry(QString::number(i),it.current()->text(0)); 163 cfg->writeEntry(QString::number(i),it.current()->text(0));
164 i++; 164 i++;
165 165
166 } 166 }
167 cfg->writeEntry("Commands Set","TRUE"); 167 cfg->writeEntry("Commands Set","TRUE");
168// qDebug("CommandEditDialog::accept() - written"); 168// qDebug("CommandEditDialog::accept() - written");
169 delete cfg; 169 delete cfg;
170 emit commandsEdited(); 170 emit commandsEdited();
171 close(); 171 close();
172 172
173 173
174 174
175 175
176 176
177} 177}
178 178
179void CommandEditDialog::showEditDialog() 179void CommandEditDialog::showEditDialog()
180{ 180{
181editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); 181editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE);
182d->setCaption("Edit command"); 182d->setCaption("Edit command");
183d->TextLabel->setText("Edit command:"); 183d->TextLabel->setText("Edit command:");
184d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); 184d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0));
185int i = d->exec(); 185int i = d->exec();
186if ((i==1) && (!(d->commandEdit->text()).isEmpty())) 186if ((i==1) && (!(d->commandEdit->text()).isEmpty()))
187 m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); 187 m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text()));
188} 188}
189 189
190void CommandEditDialog::showAddDialog() 190void CommandEditDialog::showAddDialog()
191{ 191{
192 192
193editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); 193editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE);
194int i = d->exec(); 194int i = d->exec();
195if ((i==1) && (!(d->commandEdit->text()).isEmpty())) 195if ((i==1) && (!(d->commandEdit->text()).isEmpty()))
196m_PlayListSelection->addStringToSelection(d->commandEdit->text()); 196m_PlayListSelection->addStringToSelection(d->commandEdit->text());
197 197
198} 198}
199 199
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index 46c0203..3289a04 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -1,1918 +1,1919 @@
1 1
2/* ---------------------------------------------------------------------- */ 2/* ---------------------------------------------------------------------- */
3/* */ 3/* */
4/* [main.C] Konsole */ 4/* [main.C] Konsole */
5/* */ 5/* */
6/* ---------------------------------------------------------------------- */ 6/* ---------------------------------------------------------------------- */
7/* */ 7/* */
8/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 8/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
9/* */ 9/* */
10/* This file is part of Konsole, an X terminal. */ 10/* This file is part of Konsole, an X terminal. */
11/* */ 11/* */
12/* The material contained in here more or less directly orginates from */ 12/* The material contained in here more or less directly orginates from */
13/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ 13/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
14/* */ 14/* */
15/* ---------------------------------------------------------------------- */ 15/* ---------------------------------------------------------------------- */
16/* */ 16/* */
17/* Ported Konsole to Qt/Embedded */ 17/* Ported Konsole to Qt/Embedded */
18/* */ 18/* */
19/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 19/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
20/* */ 20/* */
21/* -------------------------------------------------------------------------- */ 21/* -------------------------------------------------------------------------- */
22// enhancements added by L.J. Potter <ljp@llornkcor.com> 22// enhancements added by L.J. Potter <ljp@llornkcor.com>
23// enhancements added by Phillip Kuhn
23//#define QT_QWS_OPIE 24//#define QT_QWS_OPIE
24 25
25#include <stdlib.h> 26#include <stdlib.h>
26 27
27#ifdef QT_QWS_OPIE 28#ifdef QT_QWS_OPIE
28#include <opie2/ocolorpopupmenu.h> 29#include <opie2/ocolorpopupmenu.h>
29#endif 30#endif
30 31
31#include <qpe/resource.h> 32#include <qpe/resource.h>
32 33
33#include <qdir.h> 34#include <qdir.h>
34#include <qevent.h> 35#include <qevent.h>
35#include <qdragobject.h> 36#include <qdragobject.h>
36#include <qobjectlist.h> 37#include <qobjectlist.h>
37#include <qtoolbutton.h> 38#include <qtoolbutton.h>
38#include <qtoolbar.h> 39#include <qtoolbar.h>
39#include <qpushbutton.h> 40#include <qpushbutton.h>
40#include <qfontdialog.h> 41#include <qfontdialog.h>
41#include <qglobal.h> 42#include <qglobal.h>
42#include <qpainter.h> 43#include <qpainter.h>
43#include <qmenubar.h> 44#include <qmenubar.h>
44#include <qmessagebox.h> 45#include <qmessagebox.h>
45#include <qaction.h> 46#include <qaction.h>
46#include <qapplication.h> 47#include <qapplication.h>
47#include <qfontmetrics.h> 48#include <qfontmetrics.h>
48#include <qcombobox.h> 49#include <qcombobox.h>
49#include <qevent.h> 50#include <qevent.h>
50#include <qtabwidget.h> 51#include <qtabwidget.h>
51#include <qtabbar.h> 52#include <qtabbar.h>
52#include <qpe/config.h> 53#include <qpe/config.h>
53#include <qstringlist.h> 54#include <qstringlist.h>
54#include <qpalette.h> 55#include <qpalette.h>
55#include <qfontdatabase.h> 56#include <qfontdatabase.h>
56#include <qfile.h> 57#include <qfile.h>
57#include <qspinbox.h> 58#include <qspinbox.h>
58#include <qlayout.h> 59#include <qlayout.h>
59#include <qvbox.h> 60#include <qvbox.h>
60 61
61#include <sys/wait.h> 62#include <sys/wait.h>
62#include <stdio.h> 63#include <stdio.h>
63#include <stdlib.h> 64#include <stdlib.h>
64#include <assert.h> 65#include <assert.h>
65 66
66#include "konsole.h" 67#include "konsole.h"
67#include "keytrans.h" 68#include "keytrans.h"
68#include "commandeditdialog.h" 69#include "commandeditdialog.h"
69 70
70class EKNumTabBar : public QTabBar 71class EKNumTabBar : public QTabBar
71{ 72{
72public: 73public:
73 EKNumTabBar(QWidget *parent = 0, const char *name = 0) : 74 EKNumTabBar(QWidget *parent = 0, const char *name = 0) :
74 QTabBar(parent, name) 75 QTabBar(parent, name)
75 {} 76 {}
76 77
77 // QList<QTab> *getTabList() { return(tabList()); } 78 // QList<QTab> *getTabList() { return(tabList()); }
78 79
79 void numberTabs() 80 void numberTabs()
80 { 81 {
81 // Yes, it really is this messy. QTabWidget needs functions 82 // Yes, it really is this messy. QTabWidget needs functions
82 // that provide acces to tabs in a sequential way. 83 // that provide acces to tabs in a sequential way.
83 int m=INT_MIN; 84 int m=INT_MIN;
84 for (int i=0; i<count(); i++) 85 for (int i=0; i<count(); i++)
85 { 86 {
86 QTab* left=0; 87 QTab* left=0;
87 QListIterator<QTab> it(*tabList()); 88 QListIterator<QTab> it(*tabList());
88 int x=INT_MAX; 89 int x=INT_MAX;
89 for( QTab* t; (t=it.current()); ++it ) 90 for( QTab* t; (t=it.current()); ++it )
90 { 91 {
91 int tx = t->rect().x(); 92 int tx = t->rect().x();
92 if ( tx<x && tx>m ) 93 if ( tx<x && tx>m )
93 { 94 {
94 x = tx; 95 x = tx;
95 left = t; 96 left = t;
96 } 97 }
97 } 98 }
98 if ( left ) 99 if ( left )
99 { 100 {
100 left->setText(QString::number(i+1)); 101 left->setText(QString::number(i+1));
101 m = left->rect().x(); 102 m = left->rect().x();
102 } 103 }
103 } 104 }
104 } 105 }
105 106
106 virtual QSize sizeHint() const 107 virtual QSize sizeHint() const
107 { 108 {
108 if (isHidden()) 109 if (isHidden())
109 { 110 {
110 return(QSize(0,0)); 111 return(QSize(0,0));
111 } 112 }
112 else 113 else
113 { 114 {
114 QSize size = QTabBar::sizeHint(); 115 QSize size = QTabBar::sizeHint();
115 int shrink = 5; 116 int shrink = 5;
116 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) 117 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600)
117 { 118 {
118 shrink = 10; 119 shrink = 10;
119 } 120 }
120 size.setHeight(size.height() - shrink); 121 size.setHeight(size.height() - shrink);
121 return(size); 122 return(size);
122 } 123 }
123 } 124 }
124 125
125}; 126};
126 127
127class EKNumTabWidget : public QTabWidget 128class EKNumTabWidget : public QTabWidget
128{ 129{
129public: 130public:
130 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 131 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
131 { 132 {
132 setTabBar(new EKNumTabBar(parent,"EKTabBar")); 133 setTabBar(new EKNumTabBar(parent,"EKTabBar"));
133 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); 134 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
134 } 135 }
135 136
136 EKNumTabBar *getTabBar() const 137 EKNumTabBar *getTabBar() const
137 { 138 {
138 return ((EKNumTabBar*)tabBar()); 139 return ((EKNumTabBar*)tabBar());
139 } 140 }
140 141
141 142
142 void addTab(QWidget* w) 143 void addTab(QWidget* w)
143 { 144 {
144 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 145 QTab* t = new QTab(QString::number(tabBar()->count()+1));
145 QTabWidget::addTab(w,t); 146 QTabWidget::addTab(w,t);
146 } 147 }
147 148
148 void removeTab(QWidget* w) 149 void removeTab(QWidget* w)
149 { 150 {
150 removePage(w); 151 removePage(w);
151 ((EKNumTabBar*)tabBar())->numberTabs(); 152 ((EKNumTabBar*)tabBar())->numberTabs();
152 } 153 }
153}; 154};
154 155
155// This could be configurable or dynamicly generated from the bash history 156// This could be configurable or dynamicly generated from the bash history
156// file of the user 157// file of the user
157static const char *commonCmds[] = 158static const char *commonCmds[] =
158 { 159 {
159 "ls ", // I left this here, cause it looks better than the first alpha 160 "ls ", // I left this here, cause it looks better than the first alpha
160 "cardctl eject", 161 "cardctl eject",
161 "cat ", 162 "cat ",
162 "cd ", 163 "cd ",
163 "chmod ", 164 "chmod ",
164 "clear", 165 "clear",
165 "cp ", 166 "cp ",
166 "dc ", 167 "dc ",
167 "df ", 168 "df ",
168 "dmesg", 169 "dmesg",
169 "echo ", 170 "echo ",
170 "env", 171 "env",
171 "find ", 172 "find ",
172 "free", 173 "free",
173 "grep ", 174 "grep ",
174 "ifconfig ", 175 "ifconfig ",
175 "ipkg ", 176 "ipkg ",
176 "mkdir ", 177 "mkdir ",
177 "mv ", 178 "mv ",
178 "nc localhost 7776", 179 "nc localhost 7776",
179 "nc localhost 7777", 180 "nc localhost 7777",
180 "netstat ", 181 "netstat ",
181 "nslookup ", 182 "nslookup ",
182 "ping ", 183 "ping ",
183 "ps aux", 184 "ps aux",
184 "pwd ", 185 "pwd ",
185 "qcop QPE/System 'linkChanged(QString)' ''", 186 "qcop QPE/System 'linkChanged(QString)' ''",
186 "qcop QPE/System 'restart()'", 187 "qcop QPE/System 'restart()'",
187 "qcop QPE/System 'quit()'", 188 "qcop QPE/System 'quit()'",
188 "rm ", 189 "rm ",
189 "rmdir ", 190 "rmdir ",
190 "route ", 191 "route ",
191 "set ", 192 "set ",
192 "traceroute", 193 "traceroute",
193 194
194 /* 195 /*
195 "gzip", 196 "gzip",
196 "gunzip", 197 "gunzip",
197 "chgrp", 198 "chgrp",
198 "chown", 199 "chown",
199 "date", 200 "date",
200 "dd", 201 "dd",
201 "df", 202 "df",
202 "dmesg", 203 "dmesg",
203 "fuser", 204 "fuser",
204 "hostname", 205 "hostname",
205 "kill", 206 "kill",
206 "killall", 207 "killall",
207 "ln", 208 "ln",
208 "ping", 209 "ping",
209 "mount", 210 "mount",
210 "more", 211 "more",
211 "sort", 212 "sort",
212 "touch", 213 "touch",
213 "umount", 214 "umount",
214 "mknod", 215 "mknod",
215 "netstat", 216 "netstat",
216 */ 217 */
217 218
218 "exit", 219 "exit",
219 NULL 220 NULL
220 }; 221 };
221 222
222 223
223Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 224Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
224 QMainWindow(parent, name, fl) 225 QMainWindow(parent, name, fl)
225{ 226{
226 QStrList args; 227 QStrList args;
227 init("/bin/bash",args); 228 init("/bin/bash",args);
228} 229}
229 230
230Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 231Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
231 : QMainWindow(0, name) 232 : QMainWindow(0, name)
232{ 233{
233 init(_pgm,_args); 234 init(_pgm,_args);
234} 235}
235 236
236struct HistoryItem 237struct HistoryItem
237{ 238{
238 HistoryItem(int c, const QString &l) 239 HistoryItem(int c, const QString &l)
239 { 240 {
240 count = c; 241 count = c;
241 line = l; 242 line = l;
242 } 243 }
243 int count; 244 int count;
244 QString line; 245 QString line;
245}; 246};
246 247
247class HistoryList : public QList<HistoryItem> 248class HistoryList : public QList<HistoryItem>
248{ 249{
249 virtual int compareItems( QCollection::Item item1, QCollection::Item item2) 250 virtual int compareItems( QCollection::Item item1, QCollection::Item item2)
250 { 251 {
251 int c1 = ((HistoryItem*)item1)->count; 252 int c1 = ((HistoryItem*)item1)->count;
252 int c2 = ((HistoryItem*)item2)->count; 253 int c2 = ((HistoryItem*)item2)->count;
253 if (c1 > c2) 254 if (c1 > c2)
254 return(1); 255 return(1);
255 if (c1 < c2) 256 if (c1 < c2)
256 return(-1); 257 return(-1);
257 return(0); 258 return(0);
258 } 259 }
259}; 260};
260 261
261void Konsole::initCommandList() 262void Konsole::initCommandList()
262{ 263{
263 // qDebug("Konsole::initCommandList"); 264 // qDebug("Konsole::initCommandList");
264 Config cfg("Qkonsole"); 265 Config cfg( "Konsole" );
265 cfg.setGroup("Commands"); 266 cfg.setGroup("Commands");
266 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 267 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
267 commonCombo->clear(); 268 commonCombo->clear();
268 269
269 if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") 270 if (cfg.readEntry("ShellHistory","TRUE") == "TRUE")
270 { 271 {
271 QString histfilename = QString(getenv("HOME")) + "/.bash_history"; 272 QString histfilename = QString(getenv("HOME")) + "/.bash_history";
272 histfilename = cfg.readEntry("ShellHistoryPath",histfilename); 273 histfilename = cfg.readEntry("ShellHistoryPath",histfilename);
273 QFile histfile(histfilename); 274 QFile histfile(histfilename);
274 // note: compiler barfed on: 275 // note: compiler barfed on:
275 // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); 276 // QFile histfile(QString(getenv("HOME")) + "/.bash_history");
276 if (histfile.open( IO_ReadOnly )) 277 if (histfile.open( IO_ReadOnly ))
277 { 278 {
278 QString line; 279 QString line;
279 uint i; 280 uint i;
280 HistoryList items; 281 HistoryList items;
281 282
282 int lineno = 0; 283 int lineno = 0;
283 while(!histfile.atEnd()) 284 while(!histfile.atEnd())
284 { 285 {
285 if (histfile.readLine(line, 200) < 0) 286 if (histfile.readLine(line, 200) < 0)
286 { 287 {
287 break; 288 break;
288 } 289 }
289 line = line.left(line.length()-1); 290 line = line.left(line.length()-1);
290 lineno++; 291 lineno++;
291 292
292 for(i=0; i<items.count(); i++) 293 for(i=0; i<items.count(); i++)
293 { 294 {
294 if (line == items.at(i)->line) 295 if (line == items.at(i)->line)
295 { 296 {
296 // weight recent commands & repeated commands more 297 // weight recent commands & repeated commands more
297 // by adding up the index of each command 298 // by adding up the index of each command
298 items.at(i)->count += lineno; 299 items.at(i)->count += lineno;
299 break; 300 break;
300 } 301 }
301 } 302 }
302 if (i >= items.count()) 303 if (i >= items.count())
303 { 304 {
304 items.append(new HistoryItem(lineno, line)); 305 items.append(new HistoryItem(lineno, line));
305 } 306 }
306 } 307 }
307 items.sort(); 308 items.sort();
308 int n = items.count(); 309 int n = items.count();
309 if (n > 40) 310 if (n > 40)
310 { 311 {
311 n = 40; 312 n = 40;
312 } 313 }
313 for(int i=0; i<n; i++) 314 for(int i=0; i<n; i++)
314 { 315 {
315 // should insert start of command, but keep whole thing 316 // should insert start of command, but keep whole thing
316 if (items.at(items.count()-i-1)->line.length() < 30) 317 if (items.at(items.count()-i-1)->line.length() < 30)
317 { 318 {
318 commonCombo->insertItem(items.at(items.count()-i-1)->line); 319 commonCombo->insertItem(items.at(items.count()-i-1)->line);
319 } 320 }
320 } 321 }
321 histfile.close(); 322 histfile.close();
322 } 323 }
323 } 324 }
324 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") 325 if (cfg.readEntry("Commands Set","FALSE") == "FALSE")
325 { 326 {
326 for (int i = 0; commonCmds[i] != NULL; i++) 327 for (int i = 0; commonCmds[i] != NULL; i++)
327 { 328 {
328 commonCombo->insertItem(commonCmds[i]); 329 commonCombo->insertItem(commonCmds[i]);
329 } 330 }
330 } 331 }
331 else 332 else
332 { 333 {
333 for (int i = 0; i < 100; i++) 334 for (int i = 0; i < 100; i++)
334 { 335 {
335 if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) 336 if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
336 commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); 337 commonCombo->insertItem(cfg.readEntry( QString::number(i),""));
337 } 338 }
338 } 339 }
339 340
340 341
341} 342}
342 343
343static void sig_handler(int x) 344static void sig_handler(int x)
344{ 345{
345 printf("got signal %d\n",x); 346 printf("got signal %d\n",x);
346} 347}
347 348
348void Konsole::init(const char* _pgm, QStrList & _args) 349void Konsole::init(const char* _pgm, QStrList & _args)
349{ 350{
350 351
351#if 0 352#if 0
352 for(int i=1; i<=31; i++) 353 for(int i=1; i<=31; i++)
353 { 354 {
354 if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV 355 if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV
355 && i != SIGINT && i != SIGILL && i != SIGTERM 356 && i != SIGINT && i != SIGILL && i != SIGTERM
356 && i != SIGBUS) 357 && i != SIGBUS)
357 signal(i,sig_handler); 358 signal(i,sig_handler);
358 } 359 }
359#endif 360#endif
360 signal(SIGSTOP, sig_handler); 361 signal(SIGSTOP, sig_handler);
361 signal(SIGCONT, sig_handler); 362 signal(SIGCONT, sig_handler);
362 signal(SIGTSTP, sig_handler); 363 signal(SIGTSTP, sig_handler);
363 364
364 b_scroll = TRUE; // histon; 365 b_scroll = TRUE; // histon;
365 n_keytab = 0; 366 n_keytab = 0;
366 n_render = 0; 367 n_render = 0;
367 startUp=0; 368 startUp=0;
368 fromMenu = FALSE; 369 fromMenu = FALSE;
369 fullscreen = false; 370 fullscreen = false;
370 371
371 setCaption( "Qkonsole" ); 372 setCaption( "Qkonsole" );
372 setIcon( Resource::loadPixmap( "qkonsole/qkonsole" ) ); 373 setIcon( Resource::loadPixmap( "qkonsole/qkonsole" ) );
373 374
374 Config cfg("Qkonsole"); 375 Config cfg( "Konsole" );
375 cfg.setGroup("Font"); 376 cfg.setGroup("Font");
376 QString tmp; 377 QString tmp;
377 378
378 // initialize the list of allowed fonts /////////////////////////////////// 379 // initialize the list of allowed fonts ///////////////////////////////////
379 380
380 QString cfgFontName = cfg.readEntry("FontName","Lcfont"); 381 QString cfgFontName = cfg.readEntry("FontName","Lcfont");
381 int cfgFontSize = cfg.readNumEntry("FontSize",18); 382 int cfgFontSize = cfg.readNumEntry("FontSize",18);
382 383
383 cfont = -1; 384 cfont = -1;
384 385
385 // this code causes repeated access to all the font files 386 // this code causes repeated access to all the font files
386 // which does slow down startup 387 // which does slow down startup
387 QFontDatabase fontDB; 388 QFontDatabase fontDB;
388 QStringList familyNames; 389 QStringList familyNames;
389 familyNames = fontDB.families( FALSE ); 390 familyNames = fontDB.families( FALSE );
390 QString s; 391 QString s;
391 int fontIndex = 0; 392 int fontIndex = 0;
392 int familyNum = 0; 393 int familyNum = 0;
393 fontList = new QPopupMenu( this ); 394 fontList = new QPopupMenu( this );
394 395
395 for(uint j = 0; j < (uint)familyNames.count(); j++) 396 for(uint j = 0; j < (uint)familyNames.count(); j++)
396 { 397 {
397 s = familyNames[j]; 398 s = familyNames[j];
398 if ( s.contains('-') ) 399 if ( s.contains('-') )
399 { 400 {
400 int i = s.find('-'); 401 int i = s.find('-');
401 s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; 402 s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]";
402 } 403 }
403 s[0] = s[0].upper(); 404 s[0] = s[0].upper();
404 405
405 QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); 406 QValueList<int> sizes = fontDB.pointSizes( familyNames[j] );
406 407
407 printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), 408 printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(),
408 sizes.count()); 409 sizes.count());
409 410
410 if (sizes.count() > 0) 411 if (sizes.count() > 0)
411 { 412 {
412 QPopupMenu *sizeMenu; 413 QPopupMenu *sizeMenu;
413 QFont f; 414 QFont f;
414 int last_width = -1; 415 int last_width = -1;
415 sizeMenu = NULL; 416 sizeMenu = NULL;
416 417
417 for(uint i = 0; i < (uint)sizes.count() + 4; i++) 418 for(uint i = 0; i < (uint)sizes.count() + 4; i++)
418 { 419 {
419 // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); 420 // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]);
420 // need to divide by 10 on the Z, but not otherwise 421 // need to divide by 10 on the Z, but not otherwise
421 int size; 422 int size;
422 423
423 if (i >= (uint)sizes.count()) 424 if (i >= (uint)sizes.count())
424 { 425 {
425 // try for expandable fonts 426 // try for expandable fonts
426 size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); 427 size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1);
427 } 428 }
428 else 429 else
429 { 430 {
430 printf("sizes[%d] = %d\n", i, sizes[i]); 431 printf("sizes[%d] = %d\n", i, sizes[i]);
431 size = sizes[i]; 432 size = sizes[i];
432 } 433 }
433#ifndef __i386__ 434#ifndef __i386__
434 // a hack, sizes on Z seem to be points*10 435 // a hack, sizes on Z seem to be points*10
435 size /= 10; 436 size /= 10;
436#endif 437#endif
437 438
438 f = QFont(familyNames[j], size); 439 f = QFont(familyNames[j], size);
439 f.setFixedPitch(true); 440 f.setFixedPitch(true);
440 QFontMetrics fm(f); 441 QFontMetrics fm(f);
441 // don't trust f.fixedPitch() or f.exactMatch(), they lie!! 442 // don't trust f.fixedPitch() or f.exactMatch(), they lie!!
442 if (fm.width("l") == fm.width("m") 443 if (fm.width("l") == fm.width("m")
443 && (i < (uint)sizes.count() 444 && (i < (uint)sizes.count()
444 || fm.width("m") > last_width)) 445 || fm.width("m") > last_width))
445 { 446 {
446 if (i < (uint)sizes.count()) 447 if (i < (uint)sizes.count())
447 { 448 {
448 last_width = fm.width("m"); 449 last_width = fm.width("m");
449 } 450 }
450 if (sizeMenu == NULL) 451 if (sizeMenu == NULL)
451 { 452 {
452 sizeMenu = new QPopupMenu(); 453 sizeMenu = new QPopupMenu();
453 } 454 }
454 int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); 455 int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex);
455 sizeMenu->setItemParameter(id, fontIndex); 456 sizeMenu->setItemParameter(id, fontIndex);
456 sizeMenu->connectItem(id, this, SLOT(setFont(int))); 457 sizeMenu->connectItem(id, this, SLOT(setFont(int)));
457 QString name = s + " " + QString::number(size); 458 QString name = s + " " + QString::number(size);
458 fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); 459 fonts.append(new VTFont(name, f, familyNames[j], familyNum, size));
459 if (familyNames[j] == cfgFontName && size == cfgFontSize) 460 if (familyNames[j] == cfgFontName && size == cfgFontSize)
460 { 461 {
461 cfont = fontIndex; 462 cfont = fontIndex;
462 } 463 }
463 printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); 464 printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size);
464 fontIndex++; 465 fontIndex++;
465 } 466 }
466 } 467 }
467 if (sizeMenu) 468 if (sizeMenu)
468 { 469 {
469 fontList->insertItem(s, sizeMenu, familyNum + 1000); 470 fontList->insertItem(s, sizeMenu, familyNum + 1000);
470 471
471 familyNum++; 472 familyNum++;
472 } 473 }
473 } 474 }
474 475
475 } 476 }
476 477
477 if (cfont < 0 || cfont >= (int)fonts.count()) 478 if (cfont < 0 || cfont >= (int)fonts.count())
478 { 479 {
479 cfont = 0; 480 cfont = 0;
480 } 481 }
481 482
482 // create terminal emulation framework //////////////////////////////////// 483 // create terminal emulation framework ////////////////////////////////////
483 nsessions = 0; 484 nsessions = 0;
484 485
485 tab = new EKNumTabWidget(this); 486 tab = new EKNumTabWidget(this);
486 // tab->setMargin(tab->margin()-5); 487 // tab->setMargin(tab->margin()-5);
487 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 488 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
488 489
489 // create terminal toolbar //////////////////////////////////////////////// 490 // create terminal toolbar ////////////////////////////////////////////////
490 setToolBarsMovable( FALSE ); 491 setToolBarsMovable( FALSE );
491 menuToolBar = new QToolBar( this ); 492 menuToolBar = new QToolBar( this );
492 menuToolBar->setHorizontalStretchable( TRUE ); 493 menuToolBar->setHorizontalStretchable( TRUE );
493 494
494 QMenuBar *menuBar = new QMenuBar( menuToolBar ); 495 QMenuBar *menuBar = new QMenuBar( menuToolBar );
495 496
496 bool c7xx = false; 497 bool c7xx = false;
497 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) 498 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600)
498 { 499 {
499 c7xx = true; 500 c7xx = true;
500 } 501 }
501 QFont menuFont; 502 QFont menuFont;
502 menuFont.setPointSize(c7xx? 18 : 10); 503 menuFont.setPointSize(c7xx? 18 : 10);
503 qApp->setFont(menuFont, true); 504 qApp->setFont(menuFont, true);
504 505
505 setFont(cfont); 506 setFont(cfont);
506 507
507 configMenu = new QPopupMenu( this); 508 configMenu = new QPopupMenu( this);
508 colorMenu = new QPopupMenu( this); 509 colorMenu = new QPopupMenu( this);
509 scrollMenu = new QPopupMenu( this); 510 scrollMenu = new QPopupMenu( this);
510 editCommandListMenu = new QPopupMenu( this); 511 editCommandListMenu = new QPopupMenu( this);
511 512
512 configMenu->insertItem(tr("Command List"), editCommandListMenu); 513 configMenu->insertItem(tr("Command List"), editCommandListMenu);
513 514
514 bool listHidden; 515 bool listHidden;
515 cfg.setGroup("Menubar"); 516 cfg.setGroup("Menubar");
516 if( cfg.readEntry("Hidden","FALSE") == "TRUE") 517 if( cfg.readEntry("Hidden","FALSE") == "TRUE")
517 { 518 {
518 ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); 519 ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" ));
519 listHidden=TRUE; 520 listHidden=TRUE;
520 } 521 }
521 else 522 else
522 { 523 {
523 ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); 524 ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" ));
524 listHidden=FALSE; 525 listHidden=FALSE;
525 } 526 }
526 527
527 cfg.setGroup("Tabs"); 528 cfg.setGroup("Tabs");
528 529
529 tabMenu = new QPopupMenu(this); 530 tabMenu = new QPopupMenu(this);
530 tm_bottom = tabMenu->insertItem(tr("Bottom" )); 531 tm_bottom = tabMenu->insertItem(tr("Bottom" ));
531 tm_top = tabMenu->insertItem(tr("Top")); 532 tm_top = tabMenu->insertItem(tr("Top"));
532 tm_hidden = tabMenu->insertItem(tr("Hidden")); 533 tm_hidden = tabMenu->insertItem(tr("Hidden"));
533 534
534 configMenu->insertItem(tr("Tabs"), tabMenu); 535 configMenu->insertItem(tr("Tabs"), tabMenu);
535 536
536 tmp=cfg.readEntry("Position","Top"); 537 tmp=cfg.readEntry("Position","Top");
537 if(tmp=="Top") 538 if(tmp=="Top")
538 { 539 {
539 tab->setTabPosition(QTabWidget::Top); 540 tab->setTabPosition(QTabWidget::Top);
540 tab->getTabBar()->show(); 541 tab->getTabBar()->show();
541 tabPos = tm_top; 542 tabPos = tm_top;
542 } 543 }
543 else if (tmp=="Bottom") 544 else if (tmp=="Bottom")
544 { 545 {
545 tab->setTabPosition(QTabWidget::Bottom); 546 tab->setTabPosition(QTabWidget::Bottom);
546 tab->getTabBar()->show(); 547 tab->getTabBar()->show();
547 tabPos = tm_bottom; 548 tabPos = tm_bottom;
548 } 549 }
549 else 550 else
550 { 551 {
551 tab->getTabBar()->hide(); 552 tab->getTabBar()->hide();
552 tab->setMargin(tab->margin()); 553 tab->setMargin(tab->margin());
553 tabPos = tm_hidden; 554 tabPos = tm_hidden;
554 } 555 }
555 556
556 cm_bw = colorMenu->insertItem(tr( "Black on White")); 557 cm_bw = colorMenu->insertItem(tr( "Black on White"));
557 cm_wb = colorMenu->insertItem(tr( "White on Black")); 558 cm_wb = colorMenu->insertItem(tr( "White on Black"));
558 cm_gb = colorMenu->insertItem(tr( "Green on Black")); 559 cm_gb = colorMenu->insertItem(tr( "Green on Black"));
559 // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); 560 // cm_bt = colorMenu->insertItem(tr( "Black on Transparent"));
560 cm_br = colorMenu->insertItem(tr( "Black on Pink")); 561 cm_br = colorMenu->insertItem(tr( "Black on Pink"));
561 cm_rb = colorMenu->insertItem(tr( "Pink on Black")); 562 cm_rb = colorMenu->insertItem(tr( "Pink on Black"));
562 cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); 563 cm_gy = colorMenu->insertItem(tr( "Green on Yellow"));
563 cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); 564 cm_bm = colorMenu->insertItem(tr( "Blue on Magenta"));
564 cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); 565 cm_mb = colorMenu->insertItem(tr( "Magenta on Blue"));
565 cm_cw = colorMenu->insertItem(tr( "Cyan on White")); 566 cm_cw = colorMenu->insertItem(tr( "Cyan on White"));
566 cm_wc = colorMenu->insertItem(tr( "White on Cyan")); 567 cm_wc = colorMenu->insertItem(tr( "White on Cyan"));
567 cm_bb = colorMenu->insertItem(tr( "Blue on Black")); 568 cm_bb = colorMenu->insertItem(tr( "Blue on Black"));
568 cm_ab = colorMenu->insertItem(tr( "Amber on Black")); 569 cm_ab = colorMenu->insertItem(tr( "Amber on Black"));
569 cm_default = colorMenu->insertItem(tr("default")); 570 cm_default = colorMenu->insertItem(tr("default"));
570 571
571#ifdef QT_QWS_OPIE 572#ifdef QT_QWS_OPIE
572 573
573 colorMenu->insertItem(tr( "Custom")); 574 colorMenu->insertItem(tr( "Custom"));
574#endif 575#endif
575 576
576 configMenu->insertItem(tr( "Colors") ,colorMenu); 577 configMenu->insertItem(tr( "Colors") ,colorMenu);
577 578
578 sessionList = new QPopupMenu(this); 579 sessionList = new QPopupMenu(this);
579 sessionList-> insertItem ( Resource::loadPixmap ( "qkonsole/qkonsole" ), tr( "new session" ), this, 580 sessionList-> insertItem ( Resource::loadPixmap ( "qkonsole/qkonsole" ), tr( "new session" ), this,
580 SLOT(newSession()) ); 581 SLOT(newSession()) );
581 582
582 // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 583 // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
583 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 584 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
584 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); 585 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) ));
585 connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); 586 connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) ));
586 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); 587 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int)));
587 connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); 588 connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int)));
588 connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); 589 connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) );
589 590
590 menuBar->insertItem( tr("View"), configMenu ); 591 menuBar->insertItem( tr("View"), configMenu );
591 menuBar->insertItem( tr("Fonts"), fontList ); 592 menuBar->insertItem( tr("Fonts"), fontList );
592 menuBar->insertItem( tr("Sessions"), sessionList ); 593 menuBar->insertItem( tr("Sessions"), sessionList );
593 594
594 toolBar = new QToolBar( this ); 595 toolBar = new QToolBar( this );
595 596
596 QAction *a; 597 QAction *a;
597 598
598 // Button Commands 599 // Button Commands
599 a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); 600 a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 );
600 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); 601 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) );
601 a->addTo( toolBar ); 602 a->addTo( toolBar );
602 603
603 a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); 604 a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 );
604 connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); 605 connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) );
605 a->addTo( toolBar ); 606 a->addTo( toolBar );
606 607
607 a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); 608 a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 );
608 connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); 609 connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) );
609 a->addTo( toolBar ); 610 a->addTo( toolBar );
610 611
611 612
612 /* 613 /*
613 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 614 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
614 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); 615 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar );
615 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); 616 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
616 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); 617 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar );
617 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); 618 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
618 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); 619 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar );
619 */ 620 */
620 /* 621 /*
621 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); 622 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
622 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); 623 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar );
623 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); 624 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
624 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); 625 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar );
625 */ 626 */
626 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 627 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
627 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); 628 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) );
628 a->addTo( toolBar ); 629 a->addTo( toolBar );
629 630
630 secondToolBar = new QToolBar( this ); 631 secondToolBar = new QToolBar( this );
631 secondToolBar->setHorizontalStretchable( TRUE ); 632 secondToolBar->setHorizontalStretchable( TRUE );
632 633
633 commonCombo = new QComboBox( secondToolBar ); 634 commonCombo = new QComboBox( secondToolBar );
634 // commonCombo->setMaximumWidth(236); 635 // commonCombo->setMaximumWidth(236);
635 636
636 ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); 637 ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) );
637 if( listHidden) 638 if( listHidden)
638 { 639 {
639 secondToolBar->hide(); 640 secondToolBar->hide();
640 editCommandListMenu->setItemEnabled(ec_quick ,FALSE); 641 editCommandListMenu->setItemEnabled(ec_quick ,FALSE);
641 } 642 }
642 ec_edit = editCommandListMenu->insertItem(tr( "Edit" ) ); 643 ec_edit = editCommandListMenu->insertItem(tr( "Edit" ) );
643 644
644 cfg.setGroup("Commands"); 645 cfg.setGroup("Commands");
645 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 646 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
646 647
647 initCommandList(); 648 initCommandList();
648 // for (int i = 0; commonCmds[i] != NULL; i++) { 649 // for (int i = 0; commonCmds[i] != NULL; i++) {
649 // commonCombo->insertItem( commonCmds[i], i ); 650 // commonCombo->insertItem( commonCmds[i], i );
650 // tmp = cfg.readEntry( QString::number(i),""); 651 // tmp = cfg.readEntry( QString::number(i),"");
651 // if(tmp != "") 652 // if(tmp != "")
652 // commonCombo->changeItem( tmp,i ); 653 // commonCombo->changeItem( tmp,i );
653 // } 654 // }
654 655
655 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 656 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
656 657
657 sm_none = scrollMenu->insertItem(tr( "None" )); 658 sm_none = scrollMenu->insertItem(tr( "None" ));
658 sm_left = scrollMenu->insertItem(tr( "Left" )); 659 sm_left = scrollMenu->insertItem(tr( "Left" ));
659 sm_right = scrollMenu->insertItem(tr( "Right" )); 660 sm_right = scrollMenu->insertItem(tr( "Right" ));
660 // scrollMenu->insertSeparator(4); 661 // scrollMenu->insertSeparator(4);
661 // scrollMenu->insertItem(tr( "Horizontal" )); 662 // scrollMenu->insertItem(tr( "Horizontal" ));
662 663
663 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); 664 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu);
664 665
665 configMenu->insertItem(tr( "History" ), this, SLOT(historyDialog())); 666 configMenu->insertItem(tr( "History" ), this, SLOT(historyDialog()));
666 667
667 cm_wrap = configMenu->insertItem(tr( "Wrap" )); 668 cm_wrap = configMenu->insertItem(tr( "Wrap" ));
668 cfg.setGroup("ScrollBar"); 669 cfg.setGroup("ScrollBar");
669 configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); 670 configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0));
670 671
671 cm_beep = configMenu->insertItem(tr( "Use Beep" )); 672 cm_beep = configMenu->insertItem(tr( "Use Beep" ));
672 cfg.setGroup("Menubar"); 673 cfg.setGroup("Menubar");
673 configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); 674 configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0));
674 675
675 fullscreen_msg = new QLabel(this); 676 fullscreen_msg = new QLabel(this);
676 fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); 677 fullscreen_msg-> setAlignment ( AlignCenter | SingleLine );
677 fullscreen_msg-> hide(); 678 fullscreen_msg-> hide();
678 fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); 679 fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding ));
679 fullscreen_msg-> setAutoResize(true); 680 fullscreen_msg-> setAutoResize(true);
680 fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 681 fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
681 fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); 682 fullscreen_msg-> setText(tr("To exit fullscreen, tap here."));
682 683
683 fullscreen_timer = new QTimer(this); 684 fullscreen_timer = new QTimer(this);
684 connect(fullscreen_timer, SIGNAL(timeout()), 685 connect(fullscreen_timer, SIGNAL(timeout()),
685 this, SLOT(fullscreenTimeout())); 686 this, SLOT(fullscreenTimeout()));
686 show_fullscreen_msg = true; 687 show_fullscreen_msg = true;
687 688
688 //scrollMenuSelected(-29); 689 //scrollMenuSelected(-29);
689 // cfg.setGroup("ScrollBar"); 690 // cfg.setGroup("ScrollBar");
690 // if(cfg.readBoolEntry("HorzScroll",0)) { 691 // if(cfg.readBoolEntry("HorzScroll",0)) {
691 // if(cfg.readNumEntry("Position",2) == 0) 692 // if(cfg.readNumEntry("Position",2) == 0)
692 // te->setScrollbarLocation(1); 693 // te->setScrollbarLocation(1);
693 // else 694 // else
694 // te->setScrollbarLocation(0); 695 // te->setScrollbarLocation(0);
695 // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 696 // te->setScrollbarLocation( cfg.readNumEntry("Position",2));
696 // te->setWrapAt(120); 697 // te->setWrapAt(120);
697 // } 698 // }
698 // create applications ///////////////////////////////////////////////////// 699 // create applications /////////////////////////////////////////////////////
699 setCentralWidget(tab); 700 setCentralWidget(tab);
700 701
701 // load keymaps //////////////////////////////////////////////////////////// 702 // load keymaps ////////////////////////////////////////////////////////////
702 KeyTrans::loadAll(); 703 KeyTrans::loadAll();
703 for (int i = 0; i < KeyTrans::count(); i++) 704 for (int i = 0; i < KeyTrans::count(); i++)
704 { 705 {
705 KeyTrans* s = KeyTrans::find(i); 706 KeyTrans* s = KeyTrans::find(i);
706 assert( s ); 707 assert( s );
707 } 708 }
708 709
709 se_pgm = _pgm; 710 se_pgm = _pgm;
710 se_args = _args; 711 se_args = _args;
711 712
712 cfg.setGroup("CommandLine"); 713 cfg.setGroup("CommandLine");
713 714
714 if (cfg.hasKey("shell_args")) 715 if (cfg.hasKey("shell_args"))
715 { 716 {
716 QStringList se_args_list = cfg.readListEntry("shell_args",'|'); 717 QStringList se_args_list = cfg.readListEntry("shell_args",'|');
717 for(uint i = 0; i < se_args_list.count(); i++) 718 for(uint i = 0; i < se_args_list.count(); i++)
718 { 719 {
719 se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); 720 se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1());
720 } 721 }
721 } 722 }
722 else 723 else
723 { 724 {
724 se_args.prepend("--login"); 725 se_args.prepend("--login");
725 } 726 }
726 727
727 se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); 728 se_pgm = cfg.readEntry("shell_bin", QString(se_pgm));
728 729
729 // this is the "documentation" for those who know to look 730 // this is the "documentation" for those who know to look
730 if (! cfg.hasKey("shell_args")) 731 if (! cfg.hasKey("shell_args"))
731 { 732 {
732 cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); 733 cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|');
733 } 734 }
734 if (! cfg.hasKey("shell_bin")) 735 if (! cfg.hasKey("shell_bin"))
735 { 736 {
736 cfg.writeEntry("shell_bin",QString(se_pgm)); 737 cfg.writeEntry("shell_bin",QString(se_pgm));
737 } 738 }
738 739
739 parseCommandLine(); 740 parseCommandLine();
740 741
741 // read and apply default values /////////////////////////////////////////// 742 // read and apply default values ///////////////////////////////////////////
742 resize(321, 321); // Dummy. 743 resize(321, 321); // Dummy.
743 QSize currentSize = size(); 744 QSize currentSize = size();
744 if (currentSize != size()) 745 if (currentSize != size())
745 defaultSize = size(); 746 defaultSize = size();
746 747
747 748
748 /* allows us to catch cancel/escape */ 749 /* allows us to catch cancel/escape */
749 reparent ( 0, WStyle_Customize | WStyle_NoBorder, 750 reparent ( 0, WStyle_Customize | WStyle_NoBorder,
750 QPoint ( 0, 0 )); 751 QPoint ( 0, 0 ));
751} 752}
752 753
753void Konsole::show() 754void Konsole::show()
754{ 755{
755 if ( !nsessions ) 756 if ( !nsessions )
756 { 757 {
757 newSession(); 758 newSession();
758 } 759 }
759 QMainWindow::show(); 760 QMainWindow::show();
760 761
761} 762}
762 763
763void Konsole::initSession(const char*, QStrList &) 764void Konsole::initSession(const char*, QStrList &)
764{ 765{
765 QMainWindow::show(); 766 QMainWindow::show();
766} 767}
767 768
768Konsole::~Konsole() 769Konsole::~Konsole()
769{ 770{
770 while (nsessions > 0) 771 while (nsessions > 0)
771 { 772 {
772 doneSession(getTe(), 0); 773 doneSession(getTe(), 0);
773 } 774 }
774} 775}
775 776
776void 777void
777Konsole::historyDialog() 778Konsole::historyDialog()
778{ 779{
779 QDialog *d = new QDialog ( this, "histdlg", true ); 780 QDialog *d = new QDialog ( this, "histdlg", true );
780 // d-> setCaption ( tr( "History" )); 781 // d-> setCaption ( tr( "History" ));
781 782
782 QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); 783 QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 );
783 784
784 QLabel *l = new QLabel ( tr( "History Lines:" ), d ); 785 QLabel *l = new QLabel ( tr( "History Lines:" ), d );
785 lay-> addWidget ( l ); 786 lay-> addWidget ( l );
786 787
787 Config cfg("Qkonsole"); 788 Config cfg( "Konsole" );
788 cfg.setGroup("History"); 789 cfg.setGroup("History");
789 int hist = cfg.readNumEntry("history_lines",300); 790 int hist = cfg.readNumEntry("history_lines",300);
790 int avg_line = cfg.readNumEntry("avg_line_length",60); 791 int avg_line = cfg.readNumEntry("avg_line_length",60);
791 792
792 QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); 793 QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d );
793 spin-> setValue ( hist ); 794 spin-> setValue ( hist );
794 spin-> setWrapping ( true ); 795 spin-> setWrapping ( true );
795 spin-> setButtonSymbols ( QSpinBox::PlusMinus ); 796 spin-> setButtonSymbols ( QSpinBox::PlusMinus );
796 lay-> addWidget ( spin ); 797 lay-> addWidget ( spin );
797 798
798 if ( d-> exec ( ) == QDialog::Accepted ) 799 if ( d-> exec ( ) == QDialog::Accepted )
799 { 800 {
800 cfg.writeEntry("history_lines", spin->value()); 801 cfg.writeEntry("history_lines", spin->value());
801 cfg.writeEntry("avg_line_length", avg_line); 802 cfg.writeEntry("avg_line_length", avg_line);
802 if (getTe() != NULL) 803 if (getTe() != NULL)
803 { 804 {
804 getTe()->currentSession->setHistory(true); 805 getTe()->currentSession->setHistory(true);
805 } 806 }
806 } 807 }
807 808
808 delete d; 809 delete d;
809} 810}
810 811
811 812
812void Konsole::cycleZoom() 813void Konsole::cycleZoom()
813{ 814{
814 TEWidget* te = getTe(); 815 TEWidget* te = getTe();
815 QFont font = te->getVTFont(); 816 QFont font = te->getVTFont();
816 int size = font.pointSize(); 817 int size = font.pointSize();
817 changeFontSize(1); 818 changeFontSize(1);
818 font = te->getVTFont(); 819 font = te->getVTFont();
819 if (font.pointSize() <= size) 820 if (font.pointSize() <= size)
820 { 821 {
821 do 822 do
822 { 823 {
823 font = te->getVTFont(); 824 font = te->getVTFont();
824 size = font.pointSize(); 825 size = font.pointSize();
825 changeFontSize(-1); 826 changeFontSize(-1);
826 font = te->getVTFont(); 827 font = te->getVTFont();
827 } 828 }
828 while (font.pointSize() < size); 829 while (font.pointSize() < size);
829 } 830 }
830} 831}
831 832
832void Konsole::changeFontSize(int delta) 833void Konsole::changeFontSize(int delta)
833{ 834{
834 // printf("delta font size %d\n", delta); 835 // printf("delta font size %d\n", delta);
835 TEWidget* te = getTe(); 836 TEWidget* te = getTe();
836 QFont font = te->getVTFont(); 837 QFont font = te->getVTFont();
837 int size = font.pointSize(); 838 int size = font.pointSize();
838 int closest = delta > 0? 10000 : -10000; 839 int closest = delta > 0? 10000 : -10000;
839 int closest_font = -1; 840 int closest_font = -1;
840 for(uint i = 0; i < fonts.count(); i++) 841 for(uint i = 0; i < fonts.count(); i++)
841 { 842 {
842 if (fonts.at(i)->getFont() == font) 843 if (fonts.at(i)->getFont() == font)
843 { 844 {
844 if (delta > 0) 845 if (delta > 0)
845 { 846 {
846 if (i+1 < fonts.count() 847 if (i+1 < fonts.count()
847 && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) 848 && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum())
848 { 849 {
849 setFont(i+1); 850 setFont(i+1);
850 printf("font %d\n", i+1); 851 printf("font %d\n", i+1);
851 return; 852 return;
852 } 853 }
853 } 854 }
854 else if (delta < 0) 855 else if (delta < 0)
855 { 856 {
856 if (i > 0 857 if (i > 0
857 && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) 858 && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum())
858 { 859 {
859 setFont(i-1); 860 setFont(i-1);
860 printf("font %d\n", i-1); 861 printf("font %d\n", i-1);
861 return; 862 return;
862 } 863 }
863 } 864 }
864 } 865 }
865 int fsize = fonts.at(i)->getSize(); 866 int fsize = fonts.at(i)->getSize();
866 printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); 867 printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest);
867 if ((delta > 0 && fsize > size && fsize < closest) 868 if ((delta > 0 && fsize > size && fsize < closest)
868 || (delta < 0 && fsize < size && fsize > closest)) 869 || (delta < 0 && fsize < size && fsize > closest))
869 { 870 {
870 closest = fsize; 871 closest = fsize;
871 closest_font = i; 872 closest_font = i;
872 } 873 }
873 } 874 }
874 if (closest_font >= 0) 875 if (closest_font >= 0)
875 { 876 {
876 printf("font closest %d (%d)\n", closest_font, closest); 877 printf("font closest %d (%d)\n", closest_font, closest);
877 setFont(closest_font); 878 setFont(closest_font);
878 } 879 }
879} 880}
880 881
881int Konsole::findFont(QString name, int size, bool exactMatch) 882int Konsole::findFont(QString name, int size, bool exactMatch)
882{ 883{
883 for(uint i = 0; i < fonts.count(); i++) 884 for(uint i = 0; i < fonts.count(); i++)
884 { 885 {
885 if (fonts.at(i)->getName() == name 886 if (fonts.at(i)->getName() == name
886 && fonts.at(i)->getSize() == size) 887 && fonts.at(i)->getSize() == size)
887 { 888 {
888 return(i); 889 return(i);
889 } 890 }
890 } 891 }
891 if (exactMatch) 892 if (exactMatch)
892 { 893 {
893 return(-1); 894 return(-1);
894 } 895 }
895 for(uint i = 0; i < fonts.count(); i++) 896 for(uint i = 0; i < fonts.count(); i++)
896 { 897 {
897 if (fonts.at(i)->getSize() == size) 898 if (fonts.at(i)->getSize() == size)
898 { 899 {
899 return(i); 900 return(i);
900 } 901 }
901 } 902 }
902 return(-1); 903 return(-1);
903} 904}
904 905
905void Konsole::setFont(int f) 906void Konsole::setFont(int f)
906{ 907{
907 VTFont* font = fonts.at(f); 908 VTFont* font = fonts.at(f);
908 if (font) 909 if (font)
909 { 910 {
910 TEWidget* te = getTe(); 911 TEWidget* te = getTe();
911 if (te != 0) 912 if (te != 0)
912 { 913 {
913 te->setVTFont(font->getFont()); 914 te->setVTFont(font->getFont());
914 } 915 }
915 cfont = f; 916 cfont = f;
916 917
917 int familyNum = font->getFamilyNum(); 918 int familyNum = font->getFamilyNum();
918 int size = font->getSize(); 919 int size = font->getSize();
919 printf("familyNum = %d size = %d count=%d\n", familyNum, size, 920 printf("familyNum = %d size = %d count=%d\n", familyNum, size,
920 fontList->count()); 921 fontList->count());
921 for(int i = 0; i < (int)fontList->count(); i++) 922 for(int i = 0; i < (int)fontList->count(); i++)
922 { 923 {
923 fontList->setItemChecked(i + 1000, i == familyNum); 924 fontList->setItemChecked(i + 1000, i == familyNum);
924 } 925 }
925 for(int i = 0; i < (int)fonts.count(); i++) 926 for(int i = 0; i < (int)fonts.count(); i++)
926 { 927 {
927 fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum 928 fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum
928 && fonts.at(i)->getSize() == size); 929 && fonts.at(i)->getSize() == size);
929 } 930 }
930 Config cfg("Qkonsole"); 931 Config cfg( "Konsole" );
931 cfg.setGroup("Font"); 932 cfg.setGroup("Font");
932 QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); 933 QString ss = "Session"+ QString::number(tab->currentPageIndex()+1);
933 if (tab->currentPageIndex() == 0) 934 if (tab->currentPageIndex() == 0)
934 { 935 {
935 cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); 936 cfg.writeEntry("FontName", fonts.at(cfont)->getFamily());
936 cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); 937 cfg.writeEntry("FontSize", fonts.at(cfont)->getSize());
937 } 938 }
938 cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); 939 cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily());
939 cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); 940 cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize());
940 } 941 }
941} 942}
942 943
943#if 0 944#if 0
944void Konsole::fontChanged(int f) 945void Konsole::fontChanged(int f)
945{ 946{
946 VTFont* font = fonts.at(f); 947 VTFont* font = fonts.at(f);
947 if (font != 0) 948 if (font != 0)
948 { 949 {
949 for(uint i = 0; i < fonts.count(); i++) 950 for(uint i = 0; i < fonts.count(); i++)
950 { 951 {
951 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 952 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
952 } 953 }
953 954
954 cfont = f; 955 cfont = f;
955 956
956 TEWidget* te = getTe(); 957 TEWidget* te = getTe();
957 if (te != 0) 958 if (te != 0)
958 { 959 {
959 te->setVTFont(font->getFont()); 960 te->setVTFont(font->getFont());
960 } 961 }
961 } 962 }
962} 963}
963#endif 964#endif
964 965
965 966
966void Konsole::enterCommand(int c) 967void Konsole::enterCommand(int c)
967{ 968{
968 TEWidget* te = getTe(); 969 TEWidget* te = getTe();
969 if (te != 0) 970 if (te != 0)
970 { 971 {
971 if(!commonCombo->editable()) 972 if(!commonCombo->editable())
972 { 973 {
973 QString text = commonCombo->text(c); //commonCmds[c]; 974 QString text = commonCombo->text(c); //commonCmds[c];
974 te->emitText(text); 975 te->emitText(text);
975 } 976 }
976 else 977 else
977 { 978 {
978 changeCommand( commonCombo->text(c), c); 979 changeCommand( commonCombo->text(c), c);
979 } 980 }
980 } 981 }
981} 982}
982 983
983void Konsole::hitEnter() 984void Konsole::hitEnter()
984{ 985{
985 TEWidget* te = getTe(); 986 TEWidget* te = getTe();
986 if (te != 0) 987 if (te != 0)
987 { 988 {
988 te->emitText(QString("\r")); 989 te->emitText(QString("\r"));
989 } 990 }
990} 991}
991 992
992void Konsole::hitSpace() 993void Konsole::hitSpace()
993{ 994{
994 TEWidget* te = getTe(); 995 TEWidget* te = getTe();
995 if (te != 0) 996 if (te != 0)
996 { 997 {
997 te->emitText(QString(" ")); 998 te->emitText(QString(" "));
998 } 999 }
999} 1000}
1000 1001
1001void Konsole::hitTab() 1002void Konsole::hitTab()
1002{ 1003{
1003 TEWidget* te = getTe(); 1004 TEWidget* te = getTe();
1004 if (te != 0) 1005 if (te != 0)
1005 { 1006 {
1006 te->emitText(QString("\t")); 1007 te->emitText(QString("\t"));
1007 } 1008 }
1008} 1009}
1009 1010
1010void Konsole::hitPaste() 1011void Konsole::hitPaste()
1011{ 1012{
1012 TEWidget* te = getTe(); 1013 TEWidget* te = getTe();
1013 if (te != 0) 1014 if (te != 0)
1014 { 1015 {
1015 te->pasteClipboard(); 1016 te->pasteClipboard();
1016 } 1017 }
1017} 1018}
1018 1019
1019void Konsole::hitUp() 1020void Konsole::hitUp()
1020{ 1021{
1021 TEWidget* te = getTe(); 1022 TEWidget* te = getTe();
1022 if (te != 0) 1023 if (te != 0)
1023 { 1024 {
1024 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); 1025 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
1025 QApplication::sendEvent( te, &ke ); 1026 QApplication::sendEvent( te, &ke );
1026 } 1027 }
1027} 1028}
1028 1029
1029void Konsole::hitDown() 1030void Konsole::hitDown()
1030{ 1031{
1031 TEWidget* te = getTe(); 1032 TEWidget* te = getTe();
1032 if (te != 0) 1033 if (te != 0)
1033 { 1034 {
1034 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); 1035 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0);
1035 QApplication::sendEvent( te, &ke ); 1036 QApplication::sendEvent( te, &ke );
1036 } 1037 }
1037} 1038}
1038 1039
1039/** 1040/**
1040 This function calculates the size of the external widget 1041 This function calculates the size of the external widget
1041 needed for the internal widget to be 1042 needed for the internal widget to be
1042 */ 1043 */
1043QSize Konsole::calcSize(int columns, int lines) 1044QSize Konsole::calcSize(int columns, int lines)
1044{ 1045{
1045 TEWidget* te = getTe(); 1046 TEWidget* te = getTe();
1046 if (te != 0) 1047 if (te != 0)
1047 { 1048 {
1048 QSize size = te->calcSize(columns, lines); 1049 QSize size = te->calcSize(columns, lines);
1049 return size; 1050 return size;
1050 } 1051 }
1051 else 1052 else
1052 { 1053 {
1053 QSize size; 1054 QSize size;
1054 return size; 1055 return size;
1055 } 1056 }
1056} 1057}
1057 1058
1058/** 1059/**
1059 sets application window to a size based on columns X lines of the te 1060 sets application window to a size based on columns X lines of the te
1060 guest widget. Call with (0,0) for setting default size. 1061 guest widget. Call with (0,0) for setting default size.
1061*/ 1062*/
1062 1063
1063void Konsole::setColLin(int columns, int lines) 1064void Konsole::setColLin(int columns, int lines)
1064{ 1065{
1065 qDebug("konsole::setColLin:: Columns %d", columns); 1066 qDebug("konsole::setColLin:: Columns %d", columns);
1066 1067
1067 if ((columns==0) || (lines==0)) 1068 if ((columns==0) || (lines==0))
1068 { 1069 {
1069 if (defaultSize.isEmpty()) // not in config file : set default value 1070 if (defaultSize.isEmpty()) // not in config file : set default value
1070 { 1071 {
1071 defaultSize = calcSize(80,24); 1072 defaultSize = calcSize(80,24);
1072 // notifySize(24,80); // set menu items (strange arg order !) 1073 // notifySize(24,80); // set menu items (strange arg order !)
1073 } 1074 }
1074 resize(defaultSize); 1075 resize(defaultSize);
1075 } 1076 }
1076 else 1077 else
1077 { 1078 {
1078 resize(calcSize(columns, lines)); 1079 resize(calcSize(columns, lines));
1079 // notifySize(lines,columns); // set menu items (strange arg order !) 1080 // notifySize(lines,columns); // set menu items (strange arg order !)
1080 } 1081 }
1081} 1082}
1082 1083
1083/* 1084/*
1084void Konsole::setFont(int fontno) 1085void Konsole::setFont(int fontno)
1085{ 1086{
1086 QFont f; 1087 QFont f;
1087 if (fontno == 0) 1088 if (fontno == 0)
1088 f = defaultFont = QFont( "Helvetica", 12 ); 1089 f = defaultFont = QFont( "Helvetica", 12 );
1089 else 1090 else
1090 if (fonts[fontno][0] == '-') 1091 if (fonts[fontno][0] == '-')
1091 f.setRawName( fonts[fontno] ); 1092 f.setRawName( fonts[fontno] );
1092 else 1093 else
1093 { 1094 {
1094 f.setFamily(fonts[fontno]); 1095 f.setFamily(fonts[fontno]);
1095 f.setRawMode( TRUE ); 1096 f.setRawMode( TRUE );
1096 } 1097 }
1097 if ( !f.exactMatch() && fontno != 0) 1098 if ( !f.exactMatch() && fontno != 0)
1098 { 1099 {
1099 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); 1100 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]);
1100 QMessageBox(this, msg); 1101 QMessageBox(this, msg);
1101 return; 1102 return;
1102 } 1103 }
1103 if (se) se->setFontNo(fontno); 1104 if (se) se->setFontNo(fontno);
1104 te->setVTFont(f); 1105 te->setVTFont(f);
1105 n_font = fontno; 1106 n_font = fontno;
1106} 1107}
1107*/ 1108*/
1108 1109
1109// --| color selection |------------------------------------------------------- 1110// --| color selection |-------------------------------------------------------
1110 1111
1111void Konsole::changeColumns(int /*columns*/) 1112void Konsole::changeColumns(int /*columns*/)
1112{ //FIXME this seems to cause silliness when reset command is executed 1113{ //FIXME this seems to cause silliness when reset command is executed
1113 // qDebug("change columns"); 1114 // qDebug("change columns");
1114 // TEWidget* te = getTe(); 1115 // TEWidget* te = getTe();
1115 // if (te != 0) { 1116 // if (te != 0) {
1116 // setColLin(columns,te->Lines()); 1117 // setColLin(columns,te->Lines());
1117 // te->update(); 1118 // te->update();
1118 // } 1119 // }
1119} 1120}
1120 1121
1121//FIXME: If a child dies during session swap, 1122//FIXME: If a child dies during session swap,
1122// this routine might be called before 1123// this routine might be called before
1123// session swap is completed. 1124// session swap is completed.
1124 1125
1125void Konsole::doneSession(TEWidget* te, int ) 1126void Konsole::doneSession(TEWidget* te, int )
1126{ 1127{
1127 // TEWidget *te = NULL; 1128 // TEWidget *te = NULL;
1128 // if (sess->currentSession == tab->currentPage()) { 1129 // if (sess->currentSession == tab->currentPage()) {
1129 // printf("done current session\n"); 1130 // printf("done current session\n");
1130 // te = getTe(); 1131 // te = getTe();
1131 // } else { 1132 // } else {
1132 // int currentPage = tab->currentPageIndex(); 1133 // int currentPage = tab->currentPageIndex();
1133 // printf("done not current session\n"); 1134 // printf("done not current session\n");
1134 // for(int i = 0; i < nsessions; i++) { 1135 // for(int i = 0; i < nsessions; i++) {
1135 // tab->setCurrentPage(i); 1136 // tab->setCurrentPage(i);
1136 // printf("find session %d tab page %x session %x\n", 1137 // printf("find session %d tab page %x session %x\n",
1137 // i, tab->currentPage(), sess->currentSession); 1138 // i, tab->currentPage(), sess->currentSession);
1138 // if (tab->currentPage() == sess->currentSession) { 1139 // if (tab->currentPage() == sess->currentSession) {
1139 // printf("found session %d\n", i); 1140 // printf("found session %d\n", i);
1140 // te = tab->currentPage(); 1141 // te = tab->currentPage();
1141 // break; 1142 // break;
1142 // } 1143 // }
1143 // } 1144 // }
1144 // tab->setCurrentPage(currentPage); 1145 // tab->setCurrentPage(currentPage);
1145 // } 1146 // }
1146 if (te != 0) 1147 if (te != 0)
1147 { 1148 {
1148 te->currentSession->setConnect(FALSE); 1149 te->currentSession->setConnect(FALSE);
1149 tab->removeTab(te); 1150 tab->removeTab(te);
1150 delete te->currentSession; 1151 delete te->currentSession;
1151 delete te; 1152 delete te;
1152 sessionList->removeItem(nsessions); 1153 sessionList->removeItem(nsessions);
1153 nsessions--; 1154 nsessions--;
1154 } 1155 }
1155 if (nsessions == 0) 1156 if (nsessions == 0)
1156 { 1157 {
1157 close(); 1158 close();
1158 } 1159 }
1159} 1160}
1160 1161
1161void Konsole::changeTitle(TEWidget* te, QString newTitle ) 1162void Konsole::changeTitle(TEWidget* te, QString newTitle )
1162{ 1163{
1163 if (te == getTe()) 1164 if (te == getTe())
1164 { 1165 {
1165 setCaption(newTitle + " - QKonsole"); 1166 setCaption(newTitle + " - QKonsole");
1166 } 1167 }
1167} 1168}
1168 1169
1169 1170
1170void Konsole::newSession() 1171void Konsole::newSession()
1171{ 1172{
1172 if(nsessions < 15) 1173 if(nsessions < 15)
1173 { // seems to be something weird about 16 tabs on the Zaurus.... memory? 1174 { // seems to be something weird about 16 tabs on the Zaurus.... memory?
1174 TEWidget* te = new TEWidget(tab); 1175 TEWidget* te = new TEWidget(tab);
1175 Config cfg("Qkonsole"); 1176 Config cfg( "Konsole" );
1176 cfg.setGroup("Menubar"); 1177 cfg.setGroup("Menubar");
1177 1178
1178 // FIXME use more defaults from config file 1179 // FIXME use more defaults from config file
1179 te->useBeep=cfg.readBoolEntry("useBeep",0); 1180 te->useBeep=cfg.readBoolEntry("useBeep",0);
1180 1181
1181 // te->setBackgroundMode(PaletteBase); //we want transparent!! 1182 // te->setBackgroundMode(PaletteBase); //we want transparent!!
1182 1183
1183 cfg.setGroup("Font"); 1184 cfg.setGroup("Font");
1184 QString sn = "Session" + QString::number(nsessions+1); 1185 QString sn = "Session" + QString::number(nsessions+1);
1185 printf("read font session %s\n", sn.latin1()); 1186 printf("read font session %s\n", sn.latin1());
1186 QString fontName = cfg.readEntry("FontName"+sn, 1187 QString fontName = cfg.readEntry("FontName"+sn,
1187 cfg.readEntry("FontName", 1188 cfg.readEntry("FontName",
1188 fonts.at(cfont)->getFamily())); 1189 fonts.at(cfont)->getFamily()));
1189 int fontSize = cfg.readNumEntry("FontSize"+sn, 1190 int fontSize = cfg.readNumEntry("FontSize"+sn,
1190 cfg.readNumEntry("FontSize", 1191 cfg.readNumEntry("FontSize",
1191 fonts.at(cfont)->getSize())); 1192 fonts.at(cfont)->getSize()));
1192 cfont = findFont(fontName, fontSize, false); 1193 cfont = findFont(fontName, fontSize, false);
1193 printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); 1194 printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont);
1194 if (cfont < 0) 1195 if (cfont < 0)
1195 cfont = 0; 1196 cfont = 0;
1196 te->setVTFont(fonts.at(cfont)->getFont()); 1197 te->setVTFont(fonts.at(cfont)->getFont());
1197 1198
1198 tab->addTab(te); 1199 tab->addTab(te);
1199 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); 1200 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
1200 te->currentSession = se; 1201 te->currentSession = se;
1201 connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); 1202 connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) );
1202 connect( se, SIGNAL(changeTitle(TEWidget*,QString)), this, 1203 connect( se, SIGNAL(changeTitle(TEWidget*,QString)), this,
1203 SLOT(changeTitle(TEWidget*,QString)) ); 1204 SLOT(changeTitle(TEWidget*,QString)) );
1204 connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); 1205 connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int)));
1205 connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); 1206 connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int)));
1206 connect(te, SIGNAL(newSession()), this, SLOT(newSession())); 1207 connect(te, SIGNAL(newSession()), this, SLOT(newSession()));
1207 connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); 1208 connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen()));
1208 connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); 1209 connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool)));
1209 se->run(); 1210 se->run();
1210 se->setConnect(TRUE); 1211 se->setConnect(TRUE);
1211 se->setHistory(b_scroll); 1212 se->setHistory(b_scroll);
1212 nsessions++; 1213 nsessions++;
1213 sessionList->insertItem(QString::number(nsessions), nsessions); 1214 sessionList->insertItem(QString::number(nsessions), nsessions);
1214 sessionListSelected(nsessions); 1215 sessionListSelected(nsessions);
1215 doWrap(); 1216 doWrap();
1216 setColor(nsessions-1); 1217 setColor(nsessions-1);
1217 } 1218 }
1218} 1219}
1219 1220
1220TEWidget* Konsole::getTe() 1221TEWidget* Konsole::getTe()
1221{ 1222{
1222 if (nsessions) 1223 if (nsessions)
1223 { 1224 {
1224 return (TEWidget *) tab->currentPage(); 1225 return (TEWidget *) tab->currentPage();
1225 } 1226 }
1226 else 1227 else
1227 { 1228 {
1228 return 0; 1229 return 0;
1229 } 1230 }
1230} 1231}
1231 1232
1232void Konsole::sessionListSelected(int id) 1233void Konsole::sessionListSelected(int id)
1233{ 1234{
1234 if (id < 0) 1235 if (id < 0)
1235 { 1236 {
1236 return; 1237 return;
1237 } 1238 }
1238 QString selected = sessionList->text(id); 1239 QString selected = sessionList->text(id);
1239 EKNumTabBar *tabBar = tab->getTabBar(); 1240 EKNumTabBar *tabBar = tab->getTabBar();
1240 1241
1241 int n = 0; 1242 int n = 0;
1242 for(int i = 0; n < tabBar->count(); i++) 1243 for(int i = 0; n < tabBar->count(); i++)
1243 { 1244 {
1244 if (tabBar->tab(i)) 1245 if (tabBar->tab(i))
1245 { 1246 {
1246 // printf("selected = %s tab %d = %s\n", selected.latin1(), 1247 // printf("selected = %s tab %d = %s\n", selected.latin1(),
1247 // i, tabBar->tab(i)->text().latin1()); 1248 // i, tabBar->tab(i)->text().latin1());
1248 if (tabBar->tab(i)->text() == selected) 1249 if (tabBar->tab(i)->text() == selected)
1249 { 1250 {
1250 tab->setCurrentPage(i); 1251 tab->setCurrentPage(i);
1251 break; 1252 break;
1252 } 1253 }
1253 n++; 1254 n++;
1254 } 1255 }
1255 } 1256 }
1256} 1257}
1257 1258
1258 1259
1259void Konsole::changeSession(int delta) 1260void Konsole::changeSession(int delta)
1260{ 1261{
1261 printf("delta session %d\n", delta); 1262 printf("delta session %d\n", delta);
1262 QTabBar *tabBar = tab->getTabBar(); 1263 QTabBar *tabBar = tab->getTabBar();
1263 int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; 1264 int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1;
1264 i += delta; 1265 i += delta;
1265 if (i < 0) 1266 if (i < 0)
1266 i += tabBar->count(); 1267 i += tabBar->count();
1267 if (i >= tabBar->count()) 1268 if (i >= tabBar->count())
1268 i -= tabBar->count(); 1269 i -= tabBar->count();
1269 1270
1270 QString selected = QString::number(i+1); 1271 QString selected = QString::number(i+1);
1271 int n = 0; 1272 int n = 0;
1272 for(int i = 0; n < tabBar->count(); i++) 1273 for(int i = 0; n < tabBar->count(); i++)
1273 { 1274 {
1274 if (tabBar->tab(i)) 1275 if (tabBar->tab(i))
1275 { 1276 {
1276 printf("selected = %s tab %d = %s\n", selected.latin1(), 1277 printf("selected = %s tab %d = %s\n", selected.latin1(),
1277 i, tabBar->tab(i)->text().latin1()); 1278 i, tabBar->tab(i)->text().latin1());
1278 if (tabBar->tab(i)->text() == selected) 1279 if (tabBar->tab(i)->text() == selected)
1279 { 1280 {
1280 tab->setCurrentPage(i); 1281 tab->setCurrentPage(i);
1281 break; 1282 break;
1282 } 1283 }
1283 n++; 1284 n++;
1284 } 1285 }
1285 } 1286 }
1286} 1287}
1287 1288
1288void Konsole::switchSession(QWidget* w) 1289void Konsole::switchSession(QWidget* w)
1289{ 1290{
1290 TEWidget* te = (TEWidget *) w; 1291 TEWidget* te = (TEWidget *) w;
1291 QFont teFnt = te->getVTFont(); 1292 QFont teFnt = te->getVTFont();
1292 int familyNum = -1; 1293 int familyNum = -1;
1293 1294
1294 for(uint i = 0; i < fonts.count(); i++) 1295 for(uint i = 0; i < fonts.count(); i++)
1295 { 1296 {
1296 VTFont *fnt = fonts.at(i); 1297 VTFont *fnt = fonts.at(i);
1297 bool cf = fnt->getFont() == teFnt; 1298 bool cf = fnt->getFont() == teFnt;
1298 fontList->setItemChecked(i, cf); 1299 fontList->setItemChecked(i, cf);
1299 if (cf) 1300 if (cf)
1300 { 1301 {
1301 cfont = i; 1302 cfont = i;
1302 familyNum = fnt->getFamilyNum(); 1303 familyNum = fnt->getFamilyNum();
1303 } 1304 }
1304 } 1305 }
1305 for(int i = 0; i < (int)fontList->count(); i++) 1306 for(int i = 0; i < (int)fontList->count(); i++)
1306 { 1307 {
1307 fontList->setItemChecked(i + 1000, i == familyNum); 1308 fontList->setItemChecked(i + 1000, i == familyNum);
1308 } 1309 }
1309 if (! te->currentSession->Title().isEmpty() ) 1310 if (! te->currentSession->Title().isEmpty() )
1310 { 1311 {
1311 setCaption(te->currentSession->Title() + " - QKonsole"); 1312 setCaption(te->currentSession->Title() + " - QKonsole");
1312 } 1313 }
1313 else 1314 else
1314 { 1315 {
1315 setCaption( "Qkonsole" ); 1316 setCaption( "Qkonsole" );
1316 } 1317 }
1317 // colorMenuSelected(te->color_menu_item); 1318 // colorMenuSelected(te->color_menu_item);
1318} 1319}
1319 1320
1320 1321
1321void Konsole::toggleFullScreen() 1322void Konsole::toggleFullScreen()
1322{ 1323{
1323 setFullScreen(! fullscreen); 1324 setFullScreen(! fullscreen);
1324} 1325}
1325 1326
1326void Konsole::setFullScreen ( bool b ) 1327void Konsole::setFullScreen ( bool b )
1327{ 1328{
1328 static QSize normalsize; 1329 static QSize normalsize;
1329 static bool listHidden; 1330 static bool listHidden;
1330 1331
1331 if (b == fullscreen) 1332 if (b == fullscreen)
1332 { 1333 {
1333 return; 1334 return;
1334 } 1335 }
1335 1336
1336 fullscreen = b; 1337 fullscreen = b;
1337 1338
1338 if ( b ) 1339 if ( b )
1339 { 1340 {
1340 if ( !normalsize. isValid ( )) 1341 if ( !normalsize. isValid ( ))
1341 { 1342 {
1342 normalsize = size ( ); 1343 normalsize = size ( );
1343 } 1344 }
1344 1345
1345 setFixedSize ( qApp-> desktop ( )-> size ( )); 1346 setFixedSize ( qApp-> desktop ( )-> size ( ));
1346 showNormal ( ); 1347 showNormal ( );
1347 reparent ( 0, WStyle_Customize | WStyle_NoBorder, 1348 reparent ( 0, WStyle_Customize | WStyle_NoBorder,
1348 QPoint ( 0, 0 )); 1349 QPoint ( 0, 0 ));
1349 showFullScreen ( ); 1350 showFullScreen ( );
1350 1351
1351 menuToolBar->hide(); 1352 menuToolBar->hide();
1352 toolBar->hide(); 1353 toolBar->hide();
1353 listHidden = secondToolBar->isHidden(); 1354 listHidden = secondToolBar->isHidden();
1354 secondToolBar->hide(); 1355 secondToolBar->hide();
1355 // commonCombo->hide(); 1356 // commonCombo->hide();
1356 tab->getTabBar()->hide(); 1357 tab->getTabBar()->hide();
1357 tab->setMargin(tab->margin()); 1358 tab->setMargin(tab->margin());
1358 1359
1359 if (show_fullscreen_msg) 1360 if (show_fullscreen_msg)
1360 { 1361 {
1361 fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, 1362 fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2,
1362 qApp->desktop()->height()/16 - fullscreen_msg->height()/2); 1363 qApp->desktop()->height()/16 - fullscreen_msg->height()/2);
1363 fullscreen_msg->show(); 1364 fullscreen_msg->show();
1364 fullscreen_timer->start(3000, true); 1365 fullscreen_timer->start(3000, true);
1365 show_fullscreen_msg = false; 1366 show_fullscreen_msg = false;
1366 } 1367 }
1367 } 1368 }
1368 else 1369 else
1369 { 1370 {
1370 showNormal ( ); 1371 showNormal ( );
1371 reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); 1372 reparent ( 0, WStyle_Customize, QPoint ( 0, 0 ));
1372 resize ( normalsize ); 1373 resize ( normalsize );
1373 showMaximized ( ); 1374 showMaximized ( );
1374 normalsize = QSize ( ); 1375 normalsize = QSize ( );
1375 1376
1376 menuToolBar->show(); 1377 menuToolBar->show();
1377 toolBar->show(); 1378 toolBar->show();
1378 if(! listHidden) 1379 if(! listHidden)
1379 { 1380 {
1380 secondToolBar->show(); 1381 secondToolBar->show();
1381 } 1382 }
1382 // commonCombo->show(); 1383 // commonCombo->show();
1383 menuToolBar->show(); 1384 menuToolBar->show();
1384 if (tabPos != tm_hidden) 1385 if (tabPos != tm_hidden)
1385 { 1386 {
1386 tab->getTabBar()->show(); 1387 tab->getTabBar()->show();
1387 } 1388 }
1388 } 1389 }
1389 tab->setMargin(tab->margin()); // cause setup to run 1390 tab->setMargin(tab->margin()); // cause setup to run
1390} 1391}
1391 1392
1392 1393
1393void Konsole::fullscreenTimeout() 1394void Konsole::fullscreenTimeout()
1394{ 1395{
1395 fullscreen_msg->hide(); 1396 fullscreen_msg->hide();
1396} 1397}
1397 1398
1398void Konsole::colorMenuIsSelected(int iD) 1399void Konsole::colorMenuIsSelected(int iD)
1399{ 1400{
1400 fromMenu = TRUE; 1401 fromMenu = TRUE;
1401 colorMenuSelected(iD); 1402 colorMenuSelected(iD);
1402} 1403}
1403 1404
1404/// ------------------------------- some new stuff by L.J. Potter 1405/// ------------------------------- some new stuff by L.J. Potter
1405 1406
1406 1407
1407void Konsole::colorMenuSelected(int iD) 1408void Konsole::colorMenuSelected(int iD)
1408{ 1409{
1409 // this is NOT pretty, elegant or anything else besides functional 1410 // this is NOT pretty, elegant or anything else besides functional
1410 // QString temp; 1411 // QString temp;
1411 // qDebug( temp.sprintf("colormenu %d", iD)); 1412 // qDebug( temp.sprintf("colormenu %d", iD));
1412 1413
1413 TEWidget* te = getTe(); 1414 TEWidget* te = getTe();
1414 Config cfg("Qkonsole"); 1415 Config cfg( "Konsole" );
1415 cfg.setGroup("Colors"); 1416 cfg.setGroup("Colors");
1416 1417
1417 ColorEntry m_table[TABLE_COLORS]; 1418 ColorEntry m_table[TABLE_COLORS];
1418 const ColorEntry * defaultCt=te->getdefaultColorTable(); 1419 const ColorEntry * defaultCt=te->getdefaultColorTable();
1419 1420
1420 int i; 1421 int i;
1421 1422
1422 // te->color_menu_item = iD; 1423 // te->color_menu_item = iD;
1423 1424
1424 colorMenu->setItemChecked(cm_ab,FALSE); 1425 colorMenu->setItemChecked(cm_ab,FALSE);
1425 colorMenu->setItemChecked(cm_bb,FALSE); 1426 colorMenu->setItemChecked(cm_bb,FALSE);
1426 colorMenu->setItemChecked(cm_wc,FALSE); 1427 colorMenu->setItemChecked(cm_wc,FALSE);
1427 colorMenu->setItemChecked(cm_cw,FALSE); 1428 colorMenu->setItemChecked(cm_cw,FALSE);
1428 colorMenu->setItemChecked(cm_mb,FALSE); 1429 colorMenu->setItemChecked(cm_mb,FALSE);
1429 colorMenu->setItemChecked(cm_bm,FALSE); 1430 colorMenu->setItemChecked(cm_bm,FALSE);
1430 colorMenu->setItemChecked(cm_gy,FALSE); 1431 colorMenu->setItemChecked(cm_gy,FALSE);
1431 colorMenu->setItemChecked(cm_rb,FALSE); 1432 colorMenu->setItemChecked(cm_rb,FALSE);
1432 colorMenu->setItemChecked(cm_br,FALSE); 1433 colorMenu->setItemChecked(cm_br,FALSE);
1433 colorMenu->setItemChecked(cm_wb,FALSE); 1434 colorMenu->setItemChecked(cm_wb,FALSE);
1434 colorMenu->setItemChecked(cm_bw,FALSE); 1435 colorMenu->setItemChecked(cm_bw,FALSE);
1435 colorMenu->setItemChecked(cm_gb,FALSE); 1436 colorMenu->setItemChecked(cm_gb,FALSE);
1436 1437
1437 if(iD==cm_default) 1438 if(iD==cm_default)
1438 { // default default 1439 { // default default
1439 printf("default colors\n"); 1440 printf("default colors\n");
1440 for (i = 0; i < TABLE_COLORS; i++) 1441 for (i = 0; i < TABLE_COLORS; i++)
1441 { 1442 {
1442 m_table[i].color = defaultCt[i].color; 1443 m_table[i].color = defaultCt[i].color;
1443 if(i==1 || i == 11) 1444 if(i==1 || i == 11)
1444 m_table[i].transparent=1; 1445 m_table[i].transparent=1;
1445 colorMenu->setItemChecked(cm_default,TRUE); 1446 colorMenu->setItemChecked(cm_default,TRUE);
1446 } 1447 }
1447 te->setColorTable(m_table); 1448 te->setColorTable(m_table);
1448 } 1449 }
1449 if(iD==cm_gb) 1450 if(iD==cm_gb)
1450 { // green black 1451 { // green black
1451 foreground.setRgb(100,255,100); // (0x18,255,0x18); 1452 foreground.setRgb(100,255,100); // (0x18,255,0x18);
1452 background.setRgb(0x00,0x00,0x00); 1453 background.setRgb(0x00,0x00,0x00);
1453 colorMenu->setItemChecked(cm_gb,TRUE); 1454 colorMenu->setItemChecked(cm_gb,TRUE);
1454 } 1455 }
1455 if(iD==cm_bw) 1456 if(iD==cm_bw)
1456 { // black white 1457 { // black white
1457 foreground.setRgb(0x00,0x00,0x00); 1458 foreground.setRgb(0x00,0x00,0x00);
1458 background.setRgb(0xFF,0xFF,0xFF); 1459 background.setRgb(0xFF,0xFF,0xFF);
1459 colorMenu->setItemChecked(cm_bw,TRUE); 1460 colorMenu->setItemChecked(cm_bw,TRUE);
1460 } 1461 }
1461 if(iD==cm_wb) 1462 if(iD==cm_wb)
1462 { // white black 1463 { // white black
1463 foreground.setRgb(0xFF,0xFF,0xFF); 1464 foreground.setRgb(0xFF,0xFF,0xFF);
1464 background.setRgb(0x00,0x00,0x00); 1465 background.setRgb(0x00,0x00,0x00);
1465 colorMenu->setItemChecked(cm_wb,TRUE); 1466 colorMenu->setItemChecked(cm_wb,TRUE);
1466 } 1467 }
1467 if(iD==cm_br) 1468 if(iD==cm_br)
1468 {// Black, Red 1469 {// Black, Red
1469 foreground.setRgb(0x00,0x00,0x00); 1470 foreground.setRgb(0x00,0x00,0x00);
1470 background.setRgb(255,85,85); //(0xB2,0x18,0x18); 1471 background.setRgb(255,85,85); //(0xB2,0x18,0x18);
1471 colorMenu->setItemChecked(cm_br,TRUE); 1472 colorMenu->setItemChecked(cm_br,TRUE);
1472 } 1473 }
1473 if(iD==cm_rb) 1474 if(iD==cm_rb)
1474 {// Red, Black 1475 {// Red, Black
1475 foreground.setRgb(255,85,85); 1476 foreground.setRgb(255,85,85);
1476 background.setRgb(0x00,0x00,0x00); 1477 background.setRgb(0x00,0x00,0x00);
1477 colorMenu->setItemChecked(cm_rb,TRUE); 1478 colorMenu->setItemChecked(cm_rb,TRUE);
1478 } 1479 }
1479 if(iD==cm_gy) 1480 if(iD==cm_gy)
1480 {// Green, Yellow - is ugly 1481 {// Green, Yellow - is ugly
1481 // foreground.setRgb(0x18,0xB2,0x18); 1482 // foreground.setRgb(0x18,0xB2,0x18);
1482 foreground.setRgb(15,115,0); 1483 foreground.setRgb(15,115,0);
1483 // background.setRgb(0xB2,0x68,0x18); 1484 // background.setRgb(0xB2,0x68,0x18);
1484 background.setRgb(255,255,0); 1485 background.setRgb(255,255,0);
1485 colorMenu->setItemChecked(cm_gy,TRUE); 1486 colorMenu->setItemChecked(cm_gy,TRUE);
1486 } 1487 }
1487 if(iD==cm_bm) 1488 if(iD==cm_bm)
1488 {// Blue, Magenta 1489 {// Blue, Magenta
1489 foreground.setRgb(3,24,132); 1490 foreground.setRgb(3,24,132);
1490 background.setRgb(225,2,255); 1491 background.setRgb(225,2,255);
1491 colorMenu->setItemChecked(cm_bm,TRUE); 1492 colorMenu->setItemChecked(cm_bm,TRUE);
1492 } 1493 }
1493 if(iD==cm_mb) 1494 if(iD==cm_mb)
1494 {// Magenta, Blue 1495 {// Magenta, Blue
1495 foreground.setRgb(225,2,255); 1496 foreground.setRgb(225,2,255);
1496 background.setRgb(3,24,132); 1497 background.setRgb(3,24,132);
1497 colorMenu->setItemChecked(cm_mb,TRUE); 1498 colorMenu->setItemChecked(cm_mb,TRUE);
1498 } 1499 }
1499 if(iD==cm_cw) 1500 if(iD==cm_cw)
1500 {// Cyan, White 1501 {// Cyan, White
1501 foreground.setRgb(8,91,129); 1502 foreground.setRgb(8,91,129);
1502 background.setRgb(0xFF,0xFF,0xFF); 1503 background.setRgb(0xFF,0xFF,0xFF);
1503 colorMenu->setItemChecked(cm_cw,TRUE); 1504 colorMenu->setItemChecked(cm_cw,TRUE);
1504 } 1505 }
1505 if(iD==cm_wc) 1506 if(iD==cm_wc)
1506 {// White, Cyan 1507 {// White, Cyan
1507 background.setRgb(8,91,129); 1508 background.setRgb(8,91,129);
1508 foreground.setRgb(0xFF,0xFF,0xFF); 1509 foreground.setRgb(0xFF,0xFF,0xFF);
1509 colorMenu->setItemChecked(cm_wc,TRUE); 1510 colorMenu->setItemChecked(cm_wc,TRUE);
1510 } 1511 }
1511 if(iD==cm_bb) 1512 if(iD==cm_bb)
1512 {// Black, Blue 1513 {// Black, Blue
1513 background.setRgb(0x00,0x00,0x00); 1514 background.setRgb(0x00,0x00,0x00);
1514 foreground.setRgb(127,147,225); 1515 foreground.setRgb(127,147,225);
1515 colorMenu->setItemChecked(cm_bb,TRUE); 1516 colorMenu->setItemChecked(cm_bb,TRUE);
1516 } 1517 }
1517 if(iD==cm_ab) 1518 if(iD==cm_ab)
1518 {// Black, Gold 1519 {// Black, Gold
1519 background.setRgb(0x00,0x00,0x00); 1520 background.setRgb(0x00,0x00,0x00);
1520 foreground.setRgb(255,215,105); 1521 foreground.setRgb(255,215,105);
1521 colorMenu->setItemChecked(cm_ab,TRUE); 1522 colorMenu->setItemChecked(cm_ab,TRUE);
1522 } 1523 }
1523#ifdef QT_QWS_OPIE 1524#ifdef QT_QWS_OPIE
1524 if(iD==-19) 1525 if(iD==-19)
1525 { 1526 {
1526 // Custom 1527 // Custom
1527 qDebug("do custom"); 1528 qDebug("do custom");
1528 if(fromMenu) 1529 if(fromMenu)
1529 { 1530 {
1530 Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); 1531 Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color");
1531 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, 1532 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this,
1532 SLOT(changeForegroundColor(const QColor&))); 1533 SLOT(changeForegroundColor(const QColor&)));
1533 penColorPopupMenu->exec(); 1534 penColorPopupMenu->exec();
1534 } 1535 }
1535 if(!fromMenu) 1536 if(!fromMenu)
1536 { 1537 {
1537 foreground.setNamedColor(cfg.readEntry("foreground","")); 1538 foreground.setNamedColor(cfg.readEntry("foreground",""));
1538 background.setNamedColor(cfg.readEntry("background","")); 1539 background.setNamedColor(cfg.readEntry("background",""));
1539 } 1540 }
1540 fromMenu=FALSE; 1541 fromMenu=FALSE;
1541 colorMenu->setItemChecked(-19,TRUE); 1542 colorMenu->setItemChecked(-19,TRUE);
1542 } 1543 }
1543#endif 1544#endif
1544 1545
1545 lastSelectedMenu = iD; 1546 lastSelectedMenu = iD;
1546 1547
1547 setColors(foreground, background); 1548 setColors(foreground, background);
1548 1549
1549 QTabBar *tabBar = tab->getTabBar(); 1550 QTabBar *tabBar = tab->getTabBar();
1550 QString ss = QString("Session%1").arg(tabBar->currentTab()); 1551 QString ss = QString("Session%1").arg(tabBar->currentTab());
1551 // printf("current tab = %d\n", tabBar->currentTab()); 1552 // printf("current tab = %d\n", tabBar->currentTab());
1552 1553
1553 if (tabBar->currentTab() == 0) 1554 if (tabBar->currentTab() == 0)
1554 { 1555 {
1555 cfg.writeEntry("foregroundRed",QString::number(foreground.red())); 1556 cfg.writeEntry("foregroundRed",QString::number(foreground.red()));
1556 cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); 1557 cfg.writeEntry("foregroundGreen",QString::number(foreground.green()));
1557 cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); 1558 cfg.writeEntry("foregroundBlue",QString::number(foreground.blue()));
1558 cfg.writeEntry("backgroundRed",QString::number(background.red())); 1559 cfg.writeEntry("backgroundRed",QString::number(background.red()));
1559 cfg.writeEntry("backgroundGreen",QString::number(background.green())); 1560 cfg.writeEntry("backgroundGreen",QString::number(background.green()));
1560 cfg.writeEntry("backgroundBlue",QString::number(background.blue())); 1561 cfg.writeEntry("backgroundBlue",QString::number(background.blue()));
1561 } 1562 }
1562 cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); 1563 cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red()));
1563 cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); 1564 cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green()));
1564 cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); 1565 cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue()));
1565 cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); 1566 cfg.writeEntry("backgroundRed"+ss,QString::number(background.red()));
1566 cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); 1567 cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green()));
1567 cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); 1568 cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue()));
1568 1569
1569 update(); 1570 update();
1570} 1571}
1571 1572
1572void Konsole::setColors(QColor foreground, QColor background) 1573void Konsole::setColors(QColor foreground, QColor background)
1573{ 1574{
1574 int i; 1575 int i;
1575 ColorEntry m_table[TABLE_COLORS]; 1576 ColorEntry m_table[TABLE_COLORS];
1576 TEWidget* te = getTe(); 1577 TEWidget* te = getTe();
1577 const ColorEntry * defaultCt=te->getdefaultColorTable(); 1578 const ColorEntry * defaultCt=te->getdefaultColorTable();
1578 1579
1579 for (i = 0; i < TABLE_COLORS; i++) 1580 for (i = 0; i < TABLE_COLORS; i++)
1580 { 1581 {
1581 if(i==0 || i == 10) 1582 if(i==0 || i == 10)
1582 { 1583 {
1583 m_table[i].color = foreground; 1584 m_table[i].color = foreground;
1584 } 1585 }
1585 else if(i==1 || i == 11) 1586 else if(i==1 || i == 11)
1586 { 1587 {
1587 m_table[i].color = background; 1588 m_table[i].color = background;
1588 m_table[i].transparent=0; 1589 m_table[i].transparent=0;
1589 } 1590 }
1590 else 1591 else
1591 m_table[i].color = defaultCt[i].color; 1592 m_table[i].color = defaultCt[i].color;
1592 } 1593 }
1593 te->setColorTable(m_table); 1594 te->setColorTable(m_table);
1594} 1595}
1595 1596
1596void Konsole::tabMenuSelected(int id) 1597void Konsole::tabMenuSelected(int id)
1597{ 1598{
1598 Config cfg("Qkonsole"); 1599 Config cfg( "Konsole" );
1599 cfg.setGroup("Tabs"); 1600 cfg.setGroup("Tabs");
1600 tabMenu->setItemChecked(tabPos, false); 1601 tabMenu->setItemChecked(tabPos, false);
1601 if (id == tm_bottom) 1602 if (id == tm_bottom)
1602 { 1603 {
1603 printf("set bottom tab\n"); 1604 printf("set bottom tab\n");
1604 tab->getTabBar()->show(); 1605 tab->getTabBar()->show();
1605 tab->setTabPosition(QTabWidget::Bottom); 1606 tab->setTabPosition(QTabWidget::Bottom);
1606 tab->getTabBar()->show(); 1607 tab->getTabBar()->show();
1607 cfg.writeEntry("Position","Bottom"); 1608 cfg.writeEntry("Position","Bottom");
1608 } 1609 }
1609 else if (id == tm_top) 1610 else if (id == tm_top)
1610 { 1611 {
1611 printf("set top tab\n"); 1612 printf("set top tab\n");
1612 tab->getTabBar()->show(); 1613 tab->getTabBar()->show();
1613 tab->setTabPosition(QTabWidget::Bottom); 1614 tab->setTabPosition(QTabWidget::Bottom);
1614 tab->setTabPosition(QTabWidget::Top); 1615 tab->setTabPosition(QTabWidget::Top);
1615 tab->getTabBar()->show(); 1616 tab->getTabBar()->show();
1616 cfg.writeEntry("Position","Top"); 1617 cfg.writeEntry("Position","Top");
1617 } 1618 }
1618 else if (id == tm_hidden) 1619 else if (id == tm_hidden)
1619 { 1620 {
1620 tab->getTabBar()->hide(); 1621 tab->getTabBar()->hide();
1621 tab->setMargin(tab->margin()); 1622 tab->setMargin(tab->margin());
1622 cfg.writeEntry("Position","Hidden"); 1623 cfg.writeEntry("Position","Hidden");
1623 } 1624 }
1624 tabMenu->setItemChecked(id, true); 1625 tabMenu->setItemChecked(id, true);
1625 tabPos = id; 1626 tabPos = id;
1626} 1627}
1627 1628
1628 1629
1629void Konsole::configMenuSelected(int iD) 1630void Konsole::configMenuSelected(int iD)
1630{ 1631{
1631 // QString temp; 1632 // QString temp;
1632 // qDebug( temp.sprintf("configmenu %d",iD)); 1633 // qDebug( temp.sprintf("configmenu %d",iD));
1633 1634
1634 TEWidget* te = getTe(); 1635 TEWidget* te = getTe();
1635 Config cfg("Qkonsole"); 1636 Config cfg( "Konsole" );
1636 cfg.setGroup("Menubar"); 1637 cfg.setGroup("Menubar");
1637 if(iD == cm_wrap) 1638 if(iD == cm_wrap)
1638 { 1639 {
1639 cfg.setGroup("ScrollBar"); 1640 cfg.setGroup("ScrollBar");
1640 bool b=cfg.readBoolEntry("HorzScroll",0); 1641 bool b=cfg.readBoolEntry("HorzScroll",0);
1641 b=!b; 1642 b=!b;
1642 cfg.writeEntry("HorzScroll", b ); 1643 cfg.writeEntry("HorzScroll", b );
1643 cfg.write(); 1644 cfg.write();
1644 doWrap(); 1645 doWrap();
1645 if(cfg.readNumEntry("Position",2) == 0) 1646 if(cfg.readNumEntry("Position",2) == 0)
1646 { 1647 {
1647 te->setScrollbarLocation(1); 1648 te->setScrollbarLocation(1);
1648 } 1649 }
1649 else 1650 else
1650 { 1651 {
1651 te->setScrollbarLocation(0); 1652 te->setScrollbarLocation(0);
1652 } 1653 }
1653 te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 1654 te->setScrollbarLocation( cfg.readNumEntry("Position",2));
1654 } 1655 }
1655 if(iD == cm_beep) 1656 if(iD == cm_beep)
1656 { 1657 {
1657 cfg.setGroup("Menubar"); 1658 cfg.setGroup("Menubar");
1658 bool b=cfg.readBoolEntry("useBeep",0); 1659 bool b=cfg.readBoolEntry("useBeep",0);
1659 b=!b; 1660 b=!b;
1660 cfg.writeEntry("useBeep", b ); 1661 cfg.writeEntry("useBeep", b );
1661 cfg.write(); 1662 cfg.write();
1662 configMenu->setItemChecked(cm_beep,b); 1663 configMenu->setItemChecked(cm_beep,b);
1663 te->useBeep=b; 1664 te->useBeep=b;
1664 } 1665 }
1665} 1666}
1666 1667
1667void Konsole::changeCommand(const QString &text, int c) 1668void Konsole::changeCommand(const QString &text, int c)
1668{ 1669{
1669 Config cfg("Qkonsole"); 1670 Config cfg( "Konsole" );
1670 cfg.setGroup("Commands"); 1671 cfg.setGroup("Commands");
1671 if(commonCmds[c] != text) 1672 if(commonCmds[c] != text)
1672 { 1673 {
1673 cfg.writeEntry(QString::number(c),text); 1674 cfg.writeEntry(QString::number(c),text);
1674 commonCombo->clearEdit(); 1675 commonCombo->clearEdit();
1675 commonCombo->setCurrentItem(c); 1676 commonCombo->setCurrentItem(c);
1676 } 1677 }
1677} 1678}
1678 1679
1679void Konsole::setColor(int sess) 1680void Konsole::setColor(int sess)
1680{ 1681{
1681 Config cfg("Qkonsole"); 1682 Config cfg( "Konsole" );
1682 cfg.setGroup("Colors"); 1683 cfg.setGroup("Colors");
1683 QColor foreground, background; 1684 QColor foreground, background;
1684 QString ss = QString("Session") + QString::number(sess); 1685 QString ss = QString("Session") + QString::number(sess);
1685 foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, 1686 foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss,
1686 cfg.readNumEntry("foregroundRed",0xff)), 1687 cfg.readNumEntry("foregroundRed",0xff)),
1687 cfg.readNumEntry("foregroundGreen"+ss, 1688 cfg.readNumEntry("foregroundGreen"+ss,
1688 cfg.readNumEntry("foregroundGreen",0xff)), 1689 cfg.readNumEntry("foregroundGreen",0xff)),
1689 cfg.readNumEntry("foregroundBlue"+ss, 1690 cfg.readNumEntry("foregroundBlue"+ss,
1690 cfg.readNumEntry("foregroundBlue",0xff))); 1691 cfg.readNumEntry("foregroundBlue",0xff)));
1691 background.setRgb(cfg.readNumEntry("backgroundRed"+ss, 1692 background.setRgb(cfg.readNumEntry("backgroundRed"+ss,
1692 cfg.readNumEntry("backgroundRed",0)), 1693 cfg.readNumEntry("backgroundRed",0)),
1693 cfg.readNumEntry("backgroundGreen"+ss, 1694 cfg.readNumEntry("backgroundGreen"+ss,
1694 cfg.readNumEntry("backgroundGreen",0)), 1695 cfg.readNumEntry("backgroundGreen",0)),
1695 cfg.readNumEntry("backgroundBlue"+ss, 1696 cfg.readNumEntry("backgroundBlue"+ss,
1696 cfg.readNumEntry("backgroundBlue",0))); 1697 cfg.readNumEntry("backgroundBlue",0)));
1697 setColors(foreground, background); 1698 setColors(foreground, background);
1698} 1699}
1699 1700
1700void Konsole::scrollMenuSelected(int index) 1701void Konsole::scrollMenuSelected(int index)
1701{ 1702{
1702 // qDebug( "scrollbar menu %d",index); 1703 // qDebug( "scrollbar menu %d",index);
1703 1704
1704 TEWidget* te = getTe(); 1705 TEWidget* te = getTe();
1705 Config cfg("Qkonsole"); 1706 Config cfg( "Konsole" );
1706 cfg.setGroup("ScrollBar"); 1707 cfg.setGroup("ScrollBar");
1707 1708
1708 if(index == sm_none) 1709 if(index == sm_none)
1709 { 1710 {
1710 te->setScrollbarLocation(0); 1711 te->setScrollbarLocation(0);
1711 cfg.writeEntry("Position",0); 1712 cfg.writeEntry("Position",0);
1712 } 1713 }
1713 else if(index == sm_left) 1714 else if(index == sm_left)
1714 { 1715 {
1715 te->setScrollbarLocation(1); 1716 te->setScrollbarLocation(1);
1716 cfg.writeEntry("Position",1); 1717 cfg.writeEntry("Position",1);
1717 } 1718 }
1718 else if(index == sm_right) 1719 else if(index == sm_right)
1719 { 1720 {
1720 te->setScrollbarLocation(2); 1721 te->setScrollbarLocation(2);
1721 cfg.writeEntry("Position",2); 1722 cfg.writeEntry("Position",2);
1722 } 1723 }
1723 scrollMenu->setItemChecked(sm_none, index == sm_none); 1724 scrollMenu->setItemChecked(sm_none, index == sm_none);
1724 scrollMenu->setItemChecked(sm_left, index == sm_left); 1725 scrollMenu->setItemChecked(sm_left, index == sm_left);
1725 scrollMenu->setItemChecked(sm_right, index == sm_right); 1726 scrollMenu->setItemChecked(sm_right, index == sm_right);
1726} 1727}
1727 1728
1728// case -29: { 1729// case -29: {
1729// bool b=cfg.readBoolEntry("HorzScroll",0); 1730// bool b=cfg.readBoolEntry("HorzScroll",0);
1730// cfg.writeEntry("HorzScroll", !b ); 1731// cfg.writeEntry("HorzScroll", !b );
1731// cfg.write(); 1732// cfg.write();
1732// if(cfg.readNumEntry("Position",2) == 0) { 1733// if(cfg.readNumEntry("Position",2) == 0) {
1733// te->setScrollbarLocation(1); 1734// te->setScrollbarLocation(1);
1734// te->setWrapAt(0); 1735// te->setWrapAt(0);
1735// } else { 1736// } else {
1736// te->setScrollbarLocation(0); 1737// te->setScrollbarLocation(0);
1737// te->setWrapAt(120); 1738// te->setWrapAt(120);
1738// } 1739// }
1739// te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 1740// te->setScrollbarLocation( cfg.readNumEntry("Position",2));
1740// } 1741// }
1741// break; 1742// break;
1742 1743
1743void Konsole::editCommandListMenuSelected(int iD) 1744void Konsole::editCommandListMenuSelected(int iD)
1744{ 1745{
1745 // QString temp; 1746 // QString temp;
1746 // qDebug( temp.sprintf("edit command list %d",iD)); 1747 // qDebug( temp.sprintf("edit command list %d",iD));
1747 1748
1748 // FIXME: more cleanup needed here 1749 // FIXME: more cleanup needed here
1749 1750
1750 1751
1751 TEWidget* te = getTe(); 1752 TEWidget* te = getTe();
1752 Config cfg("Qkonsole"); 1753 Config cfg( "Konsole" );
1753 cfg.setGroup("Menubar"); 1754 cfg.setGroup("Menubar");
1754 if( iD == ec_cmdlist) 1755 if( iD == ec_cmdlist)
1755 { 1756 {
1756 if(!secondToolBar->isHidden()) 1757 if(!secondToolBar->isHidden())
1757 { 1758 {
1758 secondToolBar->hide(); 1759 secondToolBar->hide();
1759 configMenu->changeItem( iD,tr( "Show Command List" )); 1760 configMenu->changeItem( iD,tr( "Show Command List" ));
1760 cfg.writeEntry("Hidden","TRUE"); 1761 cfg.writeEntry("Hidden","TRUE");
1761 configMenu->setItemEnabled(ec_edit ,FALSE); 1762 configMenu->setItemEnabled(ec_edit ,FALSE);
1762 configMenu->setItemEnabled(ec_quick ,FALSE); 1763 configMenu->setItemEnabled(ec_quick ,FALSE);
1763 } 1764 }
1764 else 1765 else
1765 { 1766 {
1766 secondToolBar->show(); 1767 secondToolBar->show();
1767 configMenu->changeItem( iD,tr( "Hide Command List" )); 1768 configMenu->changeItem( iD,tr( "Hide Command List" ));
1768 cfg.writeEntry("Hidden","FALSE"); 1769 cfg.writeEntry("Hidden","FALSE");
1769 configMenu->setItemEnabled(ec_edit ,TRUE); 1770 configMenu->setItemEnabled(ec_edit ,TRUE);
1770 configMenu->setItemEnabled(ec_quick ,TRUE); 1771 configMenu->setItemEnabled(ec_quick ,TRUE);
1771 1772
1772 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") 1773 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE")
1773 { 1774 {
1774 configMenu->setItemChecked(ec_edit,TRUE); 1775 configMenu->setItemChecked(ec_edit,TRUE);
1775 commonCombo->setEditable( TRUE ); 1776 commonCombo->setEditable( TRUE );
1776 } 1777 }
1777 else 1778 else
1778 { 1779 {
1779 configMenu->setItemChecked(ec_edit,FALSE); 1780 configMenu->setItemChecked(ec_edit,FALSE);
1780 commonCombo->setEditable( FALSE ); 1781 commonCombo->setEditable( FALSE );
1781 } 1782 }
1782 } 1783 }
1783 } 1784 }
1784 if( iD == ec_quick) 1785 if( iD == ec_quick)
1785 { 1786 {
1786 cfg.setGroup("Commands"); 1787 cfg.setGroup("Commands");
1787 // qDebug("enableCommandEdit"); 1788 // qDebug("enableCommandEdit");
1788 if( !configMenu->isItemChecked(iD) ) 1789 if( !configMenu->isItemChecked(iD) )
1789 { 1790 {
1790 commonCombo->setEditable( TRUE ); 1791 commonCombo->setEditable( TRUE );
1791 configMenu->setItemChecked(iD,TRUE); 1792 configMenu->setItemChecked(iD,TRUE);
1792 commonCombo->setCurrentItem(0); 1793 commonCombo->setCurrentItem(0);
1793 cfg.writeEntry("EditEnabled","TRUE"); 1794 cfg.writeEntry("EditEnabled","TRUE");
1794 } 1795 }
1795 else 1796 else
1796 { 1797 {
1797 commonCombo->setEditable( FALSE ); 1798 commonCombo->setEditable( FALSE );
1798 configMenu->setItemChecked(iD,FALSE); 1799 configMenu->setItemChecked(iD,FALSE);
1799 cfg.writeEntry("EditEnabled","FALSE"); 1800 cfg.writeEntry("EditEnabled","FALSE");
1800 commonCombo->setFocusPolicy(QWidget::NoFocus); 1801 commonCombo->setFocusPolicy(QWidget::NoFocus);
1801 te->setFocus(); 1802 te->setFocus();
1802 } 1803 }
1803 } 1804 }
1804 if(iD == ec_edit) 1805 if(iD == ec_edit)
1805 { 1806 {
1806 // "edit commands" 1807 // "edit commands"
1807 CommandEditDialog *m = new CommandEditDialog(this); 1808 CommandEditDialog *m = new CommandEditDialog(this);
1808 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); 1809 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList()));
1809 m->showMaximized(); 1810 m->showMaximized();
1810 } 1811 }
1811 1812
1812} 1813}
1813 1814
1814// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' 1815// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V'
1815void Konsole::setDocument( const QString &cmd) 1816void Konsole::setDocument( const QString &cmd)
1816{ 1817{
1817 newSession(); 1818 newSession();
1818 TEWidget* te = getTe(); 1819 TEWidget* te = getTe();
1819 if(cmd.find("-e", 0, TRUE) != -1) 1820 if(cmd.find("-e", 0, TRUE) != -1)
1820 { 1821 {
1821 QString cmd2; 1822 QString cmd2;
1822 cmd2=cmd.right(cmd.length()-3)+" &"; 1823 cmd2=cmd.right(cmd.length()-3)+" &";
1823 system(cmd2.latin1()); 1824 system(cmd2.latin1());
1824 if(startUp <= 1 && nsessions < 2) 1825 if(startUp <= 1 && nsessions < 2)
1825 { 1826 {
1826 doneSession(getTe(), 0); 1827 doneSession(getTe(), 0);
1827 exit(0); 1828 exit(0);
1828 } 1829 }
1829 else 1830 else
1830 doneSession(getTe(), 0); 1831 doneSession(getTe(), 0);
1831 } 1832 }
1832 else 1833 else
1833 { 1834 {
1834 if (te != 0) 1835 if (te != 0)
1835 { 1836 {
1836 te->emitText(cmd+"\r"); 1837 te->emitText(cmd+"\r");
1837 } 1838 }
1838 } 1839 }
1839 startUp++; 1840 startUp++;
1840} 1841}
1841 1842
1842 1843
1843// what is the point of this when you can just 1844// what is the point of this when you can just
1844// run commands by using the shell directly?? 1845// run commands by using the shell directly??
1845void Konsole::parseCommandLine() 1846void Konsole::parseCommandLine()
1846{ 1847{
1847 QString cmd; 1848 QString cmd;
1848 // newSession(); 1849 // newSession();
1849 for (int i=1;i< qApp->argc();i++) 1850 for (int i=1;i< qApp->argc();i++)
1850 { 1851 {
1851 if( QString(qApp->argv()[i]) == "-e") 1852 if( QString(qApp->argv()[i]) == "-e")
1852 { 1853 {
1853 i++; 1854 i++;
1854 for ( int j=i;j< qApp->argc();j++) 1855 for ( int j=i;j< qApp->argc();j++)
1855 { 1856 {
1856 cmd+=QString(qApp->argv()[j])+" "; 1857 cmd+=QString(qApp->argv()[j])+" ";
1857 } 1858 }
1858 cmd.stripWhiteSpace(); 1859 cmd.stripWhiteSpace();
1859 system(cmd.latin1()); 1860 system(cmd.latin1());
1860 exit(0);//close(); 1861 exit(0);//close();
1861 } // end -e switch 1862 } // end -e switch
1862 } 1863 }
1863 startUp++; 1864 startUp++;
1864} 1865}
1865 1866
1866void Konsole::changeForegroundColor(const QColor &color) 1867void Konsole::changeForegroundColor(const QColor &color)
1867{ 1868{
1868 Config cfg("Qkonsole"); 1869 Config cfg( "Konsole" );
1869 cfg.setGroup("Colors"); 1870 cfg.setGroup("Colors");
1870 int r, g, b; 1871 int r, g, b;
1871 color.rgb(&r,&g,&b); 1872 color.rgb(&r,&g,&b);
1872 foreground.setRgb(r,g,b); 1873 foreground.setRgb(r,g,b);
1873 1874
1874 cfg.writeEntry("foreground",color.name()); 1875 cfg.writeEntry("foreground",color.name());
1875 qDebug("foreground "+color.name()); 1876 qDebug("foreground "+color.name());
1876 cfg.write(); 1877 cfg.write();
1877 1878
1878 qDebug("do other dialog"); 1879 qDebug("do other dialog");
1879#ifdef QT_QWS_OPIE 1880#ifdef QT_QWS_OPIE
1880 1881
1881 Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color"); 1882 Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color");
1882 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, 1883 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this,
1883 SLOT(changeBackgroundColor(const QColor&))); 1884 SLOT(changeBackgroundColor(const QColor&)));
1884 penColorPopupMenu2->exec(); 1885 penColorPopupMenu2->exec();
1885#endif 1886#endif
1886} 1887}
1887 1888
1888void Konsole::changeBackgroundColor(const QColor &color) 1889void Konsole::changeBackgroundColor(const QColor &color)
1889{ 1890{
1890 1891
1891 qDebug("Change background"); 1892 qDebug("Change background");
1892 Config cfg("Qkonsole"); 1893 Config cfg( "Konsole" );
1893 cfg.setGroup("Colors"); 1894 cfg.setGroup("Colors");
1894 int r, g, b; 1895 int r, g, b;
1895 color.rgb(&r,&g,&b); 1896 color.rgb(&r,&g,&b);
1896 background.setRgb(r,g,b); 1897 background.setRgb(r,g,b);
1897 cfg.writeEntry("background",color.name()); 1898 cfg.writeEntry("background",color.name());
1898 qDebug("background "+color.name()); 1899 qDebug("background "+color.name());
1899 cfg.write(); 1900 cfg.write();
1900} 1901}
1901 1902
1902void Konsole::doWrap() 1903void Konsole::doWrap()
1903{ 1904{
1904 Config cfg("Qkonsole"); 1905 Config cfg( "Konsole" );
1905 cfg.setGroup("ScrollBar"); 1906 cfg.setGroup("ScrollBar");
1906 TEWidget* te = getTe(); 1907 TEWidget* te = getTe();
1907 if( !cfg.readBoolEntry("HorzScroll",0)) 1908 if( !cfg.readBoolEntry("HorzScroll",0))
1908 { 1909 {
1909 te->setWrapAt(0); 1910 te->setWrapAt(0);
1910 configMenu->setItemChecked( cm_wrap,TRUE); 1911 configMenu->setItemChecked( cm_wrap,TRUE);
1911 } 1912 }
1912 else 1913 else
1913 { 1914 {
1914 // te->setWrapAt(90); 1915 // te->setWrapAt(90);
1915 te->setWrapAt(120); 1916 te->setWrapAt(120);
1916 configMenu->setItemChecked( cm_wrap,FALSE); 1917 configMenu->setItemChecked( cm_wrap,FALSE);
1917 } 1918 }
1918} 1919}