summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TEHistory.cpp4
-rw-r--r--core/apps/embeddedkonsole/commandeditdialog.cpp2
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp4
3 files changed, 5 insertions, 5 deletions
diff --git a/core/apps/embeddedkonsole/TEHistory.cpp b/core/apps/embeddedkonsole/TEHistory.cpp
index 2417af1..2e6535c 100644
--- a/core/apps/embeddedkonsole/TEHistory.cpp
+++ b/core/apps/embeddedkonsole/TEHistory.cpp
@@ -1,109 +1,109 @@
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 Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* -------------------------------------------------------------------------- */ 11/* -------------------------------------------------------------------------- */
12/* */ 12/* */
13/* Ported Qkonsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14/* */ 14/* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16/* */ 16/* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18 18
19#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( "Konsole" ); 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}
diff --git a/core/apps/embeddedkonsole/commandeditdialog.cpp b/core/apps/embeddedkonsole/commandeditdialog.cpp
index b23db18..e4255f3 100644
--- a/core/apps/embeddedkonsole/commandeditdialog.cpp
+++ b/core/apps/embeddedkonsole/commandeditdialog.cpp
@@ -59,141 +59,141 @@ CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags f
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( "Konsole" ); 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("Konsole");
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 3289a04..7812e4c 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -276,193 +276,193 @@ void Konsole::initCommandList()
276 // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); 276 // QFile histfile(QString(getenv("HOME")) + "/.bash_history");
277 if (histfile.open( IO_ReadOnly )) 277 if (histfile.open( IO_ReadOnly ))
278 { 278 {
279 QString line; 279 QString line;
280 uint i; 280 uint i;
281 HistoryList items; 281 HistoryList items;
282 282
283 int lineno = 0; 283 int lineno = 0;
284 while(!histfile.atEnd()) 284 while(!histfile.atEnd())
285 { 285 {
286 if (histfile.readLine(line, 200) < 0) 286 if (histfile.readLine(line, 200) < 0)
287 { 287 {
288 break; 288 break;
289 } 289 }
290 line = line.left(line.length()-1); 290 line = line.left(line.length()-1);
291 lineno++; 291 lineno++;
292 292
293 for(i=0; i<items.count(); i++) 293 for(i=0; i<items.count(); i++)
294 { 294 {
295 if (line == items.at(i)->line) 295 if (line == items.at(i)->line)
296 { 296 {
297 // weight recent commands & repeated commands more 297 // weight recent commands & repeated commands more
298 // by adding up the index of each command 298 // by adding up the index of each command
299 items.at(i)->count += lineno; 299 items.at(i)->count += lineno;
300 break; 300 break;
301 } 301 }
302 } 302 }
303 if (i >= items.count()) 303 if (i >= items.count())
304 { 304 {
305 items.append(new HistoryItem(lineno, line)); 305 items.append(new HistoryItem(lineno, line));
306 } 306 }
307 } 307 }
308 items.sort(); 308 items.sort();
309 int n = items.count(); 309 int n = items.count();
310 if (n > 40) 310 if (n > 40)
311 { 311 {
312 n = 40; 312 n = 40;
313 } 313 }
314 for(int i=0; i<n; i++) 314 for(int i=0; i<n; i++)
315 { 315 {
316 // should insert start of command, but keep whole thing 316 // should insert start of command, but keep whole thing
317 if (items.at(items.count()-i-1)->line.length() < 30) 317 if (items.at(items.count()-i-1)->line.length() < 30)
318 { 318 {
319 commonCombo->insertItem(items.at(items.count()-i-1)->line); 319 commonCombo->insertItem(items.at(items.count()-i-1)->line);
320 } 320 }
321 } 321 }
322 histfile.close(); 322 histfile.close();
323 } 323 }
324 } 324 }
325 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") 325 if (cfg.readEntry("Commands Set","FALSE") == "FALSE")
326 { 326 {
327 for (int i = 0; commonCmds[i] != NULL; i++) 327 for (int i = 0; commonCmds[i] != NULL; i++)
328 { 328 {
329 commonCombo->insertItem(commonCmds[i]); 329 commonCombo->insertItem(commonCmds[i]);
330 } 330 }
331 } 331 }
332 else 332 else
333 { 333 {
334 for (int i = 0; i < 100; i++) 334 for (int i = 0; i < 100; i++)
335 { 335 {
336 if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) 336 if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
337 commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); 337 commonCombo->insertItem(cfg.readEntry( QString::number(i),""));
338 } 338 }
339 } 339 }
340 340
341 341
342} 342}
343 343
344static void sig_handler(int x) 344static void sig_handler(int x)
345{ 345{
346 printf("got signal %d\n",x); 346 printf("got signal %d\n",x);
347} 347}
348 348
349void Konsole::init(const char* _pgm, QStrList & _args) 349void Konsole::init(const char* _pgm, QStrList & _args)
350{ 350{
351 351
352#if 0 352#if 0
353 for(int i=1; i<=31; i++) 353 for(int i=1; i<=31; i++)
354 { 354 {
355 if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV 355 if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV
356 && i != SIGINT && i != SIGILL && i != SIGTERM 356 && i != SIGINT && i != SIGILL && i != SIGTERM
357 && i != SIGBUS) 357 && i != SIGBUS)
358 signal(i,sig_handler); 358 signal(i,sig_handler);
359 } 359 }
360#endif 360#endif
361 signal(SIGSTOP, sig_handler); 361 signal(SIGSTOP, sig_handler);
362 signal(SIGCONT, sig_handler); 362 signal(SIGCONT, sig_handler);
363 signal(SIGTSTP, sig_handler); 363 signal(SIGTSTP, sig_handler);
364 364
365 b_scroll = TRUE; // histon; 365 b_scroll = TRUE; // histon;
366 n_keytab = 0; 366 n_keytab = 0;
367 n_render = 0; 367 n_render = 0;
368 startUp=0; 368 startUp=0;
369 fromMenu = FALSE; 369 fromMenu = FALSE;
370 fullscreen = false; 370 fullscreen = false;
371 371
372 setCaption( "Qkonsole" ); 372 setCaption( "Konsole" );
373 setIcon( Resource::loadPixmap( "qkonsole/qkonsole" ) ); 373 setIcon( Resource::loadPixmap( "qkonsole/qkonsole" ) );
374 374
375 Config cfg( "Konsole" ); 375 Config cfg( "Konsole" );
376 cfg.setGroup("Font"); 376 cfg.setGroup("Font");
377 QString tmp; 377 QString tmp;
378 378
379 // initialize the list of allowed fonts /////////////////////////////////// 379 // initialize the list of allowed fonts ///////////////////////////////////
380 380
381 QString cfgFontName = cfg.readEntry("FontName","Lcfont"); 381 QString cfgFontName = cfg.readEntry("FontName","Lcfont");
382 int cfgFontSize = cfg.readNumEntry("FontSize",18); 382 int cfgFontSize = cfg.readNumEntry("FontSize",18);
383 383
384 cfont = -1; 384 cfont = -1;
385 385
386 // this code causes repeated access to all the font files 386 // this code causes repeated access to all the font files
387 // which does slow down startup 387 // which does slow down startup
388 QFontDatabase fontDB; 388 QFontDatabase fontDB;
389 QStringList familyNames; 389 QStringList familyNames;
390 familyNames = fontDB.families( FALSE ); 390 familyNames = fontDB.families( FALSE );
391 QString s; 391 QString s;
392 int fontIndex = 0; 392 int fontIndex = 0;
393 int familyNum = 0; 393 int familyNum = 0;
394 fontList = new QPopupMenu( this ); 394 fontList = new QPopupMenu( this );
395 395
396 for(uint j = 0; j < (uint)familyNames.count(); j++) 396 for(uint j = 0; j < (uint)familyNames.count(); j++)
397 { 397 {
398 s = familyNames[j]; 398 s = familyNames[j];
399 if ( s.contains('-') ) 399 if ( s.contains('-') )
400 { 400 {
401 int i = s.find('-'); 401 int i = s.find('-');
402 s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; 402 s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]";
403 } 403 }
404 s[0] = s[0].upper(); 404 s[0] = s[0].upper();
405 405
406 QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); 406 QValueList<int> sizes = fontDB.pointSizes( familyNames[j] );
407 407
408 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(),
409 sizes.count()); 409 sizes.count());
410 410
411 if (sizes.count() > 0) 411 if (sizes.count() > 0)
412 { 412 {
413 QPopupMenu *sizeMenu; 413 QPopupMenu *sizeMenu;
414 QFont f; 414 QFont f;
415 int last_width = -1; 415 int last_width = -1;
416 sizeMenu = NULL; 416 sizeMenu = NULL;
417 417
418 for(uint i = 0; i < (uint)sizes.count() + 4; i++) 418 for(uint i = 0; i < (uint)sizes.count() + 4; i++)
419 { 419 {
420 // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); 420 // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]);
421 // need to divide by 10 on the Z, but not otherwise 421 // need to divide by 10 on the Z, but not otherwise
422 int size; 422 int size;
423 423
424 if (i >= (uint)sizes.count()) 424 if (i >= (uint)sizes.count())
425 { 425 {
426 // try for expandable fonts 426 // try for expandable fonts
427 size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); 427 size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1);
428 } 428 }
429 else 429 else
430 { 430 {
431 printf("sizes[%d] = %d\n", i, sizes[i]); 431 printf("sizes[%d] = %d\n", i, sizes[i]);
432 size = sizes[i]; 432 size = sizes[i];
433 } 433 }
434#ifndef __i386__ 434#ifndef __i386__
435 // a hack, sizes on Z seem to be points*10 435 // a hack, sizes on Z seem to be points*10
436 size /= 10; 436 size /= 10;
437#endif 437#endif
438 438
439 f = QFont(familyNames[j], size); 439 f = QFont(familyNames[j], size);
440 f.setFixedPitch(true); 440 f.setFixedPitch(true);
441 QFontMetrics fm(f); 441 QFontMetrics fm(f);
442 // don't trust f.fixedPitch() or f.exactMatch(), they lie!! 442 // don't trust f.fixedPitch() or f.exactMatch(), they lie!!
443 if (fm.width("l") == fm.width("m") 443 if (fm.width("l") == fm.width("m")
444 && (i < (uint)sizes.count() 444 && (i < (uint)sizes.count()
445 || fm.width("m") > last_width)) 445 || fm.width("m") > last_width))
446 { 446 {
447 if (i < (uint)sizes.count()) 447 if (i < (uint)sizes.count())
448 { 448 {
449 last_width = fm.width("m"); 449 last_width = fm.width("m");
450 } 450 }
451 if (sizeMenu == NULL) 451 if (sizeMenu == NULL)
452 { 452 {
453 sizeMenu = new QPopupMenu(); 453 sizeMenu = new QPopupMenu();
454 } 454 }
455 int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); 455 int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex);
456 sizeMenu->setItemParameter(id, fontIndex); 456 sizeMenu->setItemParameter(id, fontIndex);
457 sizeMenu->connectItem(id, this, SLOT(setFont(int))); 457 sizeMenu->connectItem(id, this, SLOT(setFont(int)));
458 QString name = s + " " + QString::number(size); 458 QString name = s + " " + QString::number(size);
459 fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); 459 fonts.append(new VTFont(name, f, familyNames[j], familyNum, size));
460 if (familyNames[j] == cfgFontName && size == cfgFontSize) 460 if (familyNames[j] == cfgFontName && size == cfgFontSize)
461 { 461 {
462 cfont = fontIndex; 462 cfont = fontIndex;
463 } 463 }
464 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);
465 fontIndex++; 465 fontIndex++;
466 } 466 }
467 } 467 }
468 if (sizeMenu) 468 if (sizeMenu)
@@ -1220,193 +1220,193 @@ void Konsole::newSession()
1220 1220
1221TEWidget* Konsole::getTe() 1221TEWidget* Konsole::getTe()
1222{ 1222{
1223 if (nsessions) 1223 if (nsessions)
1224 { 1224 {
1225 return (TEWidget *) tab->currentPage(); 1225 return (TEWidget *) tab->currentPage();
1226 } 1226 }
1227 else 1227 else
1228 { 1228 {
1229 return 0; 1229 return 0;
1230 } 1230 }
1231} 1231}
1232 1232
1233void Konsole::sessionListSelected(int id) 1233void Konsole::sessionListSelected(int id)
1234{ 1234{
1235 if (id < 0) 1235 if (id < 0)
1236 { 1236 {
1237 return; 1237 return;
1238 } 1238 }
1239 QString selected = sessionList->text(id); 1239 QString selected = sessionList->text(id);
1240 EKNumTabBar *tabBar = tab->getTabBar(); 1240 EKNumTabBar *tabBar = tab->getTabBar();
1241 1241
1242 int n = 0; 1242 int n = 0;
1243 for(int i = 0; n < tabBar->count(); i++) 1243 for(int i = 0; n < tabBar->count(); i++)
1244 { 1244 {
1245 if (tabBar->tab(i)) 1245 if (tabBar->tab(i))
1246 { 1246 {
1247 // printf("selected = %s tab %d = %s\n", selected.latin1(), 1247 // printf("selected = %s tab %d = %s\n", selected.latin1(),
1248 // i, tabBar->tab(i)->text().latin1()); 1248 // i, tabBar->tab(i)->text().latin1());
1249 if (tabBar->tab(i)->text() == selected) 1249 if (tabBar->tab(i)->text() == selected)
1250 { 1250 {
1251 tab->setCurrentPage(i); 1251 tab->setCurrentPage(i);
1252 break; 1252 break;
1253 } 1253 }
1254 n++; 1254 n++;
1255 } 1255 }
1256 } 1256 }
1257} 1257}
1258 1258
1259 1259
1260void Konsole::changeSession(int delta) 1260void Konsole::changeSession(int delta)
1261{ 1261{
1262 printf("delta session %d\n", delta); 1262 printf("delta session %d\n", delta);
1263 QTabBar *tabBar = tab->getTabBar(); 1263 QTabBar *tabBar = tab->getTabBar();
1264 int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; 1264 int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1;
1265 i += delta; 1265 i += delta;
1266 if (i < 0) 1266 if (i < 0)
1267 i += tabBar->count(); 1267 i += tabBar->count();
1268 if (i >= tabBar->count()) 1268 if (i >= tabBar->count())
1269 i -= tabBar->count(); 1269 i -= tabBar->count();
1270 1270
1271 QString selected = QString::number(i+1); 1271 QString selected = QString::number(i+1);
1272 int n = 0; 1272 int n = 0;
1273 for(int i = 0; n < tabBar->count(); i++) 1273 for(int i = 0; n < tabBar->count(); i++)
1274 { 1274 {
1275 if (tabBar->tab(i)) 1275 if (tabBar->tab(i))
1276 { 1276 {
1277 printf("selected = %s tab %d = %s\n", selected.latin1(), 1277 printf("selected = %s tab %d = %s\n", selected.latin1(),
1278 i, tabBar->tab(i)->text().latin1()); 1278 i, tabBar->tab(i)->text().latin1());
1279 if (tabBar->tab(i)->text() == selected) 1279 if (tabBar->tab(i)->text() == selected)
1280 { 1280 {
1281 tab->setCurrentPage(i); 1281 tab->setCurrentPage(i);
1282 break; 1282 break;
1283 } 1283 }
1284 n++; 1284 n++;
1285 } 1285 }
1286 } 1286 }
1287} 1287}
1288 1288
1289void Konsole::switchSession(QWidget* w) 1289void Konsole::switchSession(QWidget* w)
1290{ 1290{
1291 TEWidget* te = (TEWidget *) w; 1291 TEWidget* te = (TEWidget *) w;
1292 QFont teFnt = te->getVTFont(); 1292 QFont teFnt = te->getVTFont();
1293 int familyNum = -1; 1293 int familyNum = -1;
1294 1294
1295 for(uint i = 0; i < fonts.count(); i++) 1295 for(uint i = 0; i < fonts.count(); i++)
1296 { 1296 {
1297 VTFont *fnt = fonts.at(i); 1297 VTFont *fnt = fonts.at(i);
1298 bool cf = fnt->getFont() == teFnt; 1298 bool cf = fnt->getFont() == teFnt;
1299 fontList->setItemChecked(i, cf); 1299 fontList->setItemChecked(i, cf);
1300 if (cf) 1300 if (cf)
1301 { 1301 {
1302 cfont = i; 1302 cfont = i;
1303 familyNum = fnt->getFamilyNum(); 1303 familyNum = fnt->getFamilyNum();
1304 } 1304 }
1305 } 1305 }
1306 for(int i = 0; i < (int)fontList->count(); i++) 1306 for(int i = 0; i < (int)fontList->count(); i++)
1307 { 1307 {
1308 fontList->setItemChecked(i + 1000, i == familyNum); 1308 fontList->setItemChecked(i + 1000, i == familyNum);
1309 } 1309 }
1310 if (! te->currentSession->Title().isEmpty() ) 1310 if (! te->currentSession->Title().isEmpty() )
1311 { 1311 {
1312 setCaption(te->currentSession->Title() + " - QKonsole"); 1312 setCaption(te->currentSession->Title() + " - QKonsole");
1313 } 1313 }
1314 else 1314 else
1315 { 1315 {
1316 setCaption( "Qkonsole" ); 1316 setCaption( "Konsole" );
1317 } 1317 }
1318 // colorMenuSelected(te->color_menu_item); 1318 // colorMenuSelected(te->color_menu_item);
1319} 1319}
1320 1320
1321 1321
1322void Konsole::toggleFullScreen() 1322void Konsole::toggleFullScreen()
1323{ 1323{
1324 setFullScreen(! fullscreen); 1324 setFullScreen(! fullscreen);
1325} 1325}
1326 1326
1327void Konsole::setFullScreen ( bool b ) 1327void Konsole::setFullScreen ( bool b )
1328{ 1328{
1329 static QSize normalsize; 1329 static QSize normalsize;
1330 static bool listHidden; 1330 static bool listHidden;
1331 1331
1332 if (b == fullscreen) 1332 if (b == fullscreen)
1333 { 1333 {
1334 return; 1334 return;
1335 } 1335 }
1336 1336
1337 fullscreen = b; 1337 fullscreen = b;
1338 1338
1339 if ( b ) 1339 if ( b )
1340 { 1340 {
1341 if ( !normalsize. isValid ( )) 1341 if ( !normalsize. isValid ( ))
1342 { 1342 {
1343 normalsize = size ( ); 1343 normalsize = size ( );
1344 } 1344 }
1345 1345
1346 setFixedSize ( qApp-> desktop ( )-> size ( )); 1346 setFixedSize ( qApp-> desktop ( )-> size ( ));
1347 showNormal ( ); 1347 showNormal ( );
1348 reparent ( 0, WStyle_Customize | WStyle_NoBorder, 1348 reparent ( 0, WStyle_Customize | WStyle_NoBorder,
1349 QPoint ( 0, 0 )); 1349 QPoint ( 0, 0 ));
1350 showFullScreen ( ); 1350 showFullScreen ( );
1351 1351
1352 menuToolBar->hide(); 1352 menuToolBar->hide();
1353 toolBar->hide(); 1353 toolBar->hide();
1354 listHidden = secondToolBar->isHidden(); 1354 listHidden = secondToolBar->isHidden();
1355 secondToolBar->hide(); 1355 secondToolBar->hide();
1356 // commonCombo->hide(); 1356 // commonCombo->hide();
1357 tab->getTabBar()->hide(); 1357 tab->getTabBar()->hide();
1358 tab->setMargin(tab->margin()); 1358 tab->setMargin(tab->margin());
1359 1359
1360 if (show_fullscreen_msg) 1360 if (show_fullscreen_msg)
1361 { 1361 {
1362 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,
1363 qApp->desktop()->height()/16 - fullscreen_msg->height()/2); 1363 qApp->desktop()->height()/16 - fullscreen_msg->height()/2);
1364 fullscreen_msg->show(); 1364 fullscreen_msg->show();
1365 fullscreen_timer->start(3000, true); 1365 fullscreen_timer->start(3000, true);
1366 show_fullscreen_msg = false; 1366 show_fullscreen_msg = false;
1367 } 1367 }
1368 } 1368 }
1369 else 1369 else
1370 { 1370 {
1371 showNormal ( ); 1371 showNormal ( );
1372 reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); 1372 reparent ( 0, WStyle_Customize, QPoint ( 0, 0 ));
1373 resize ( normalsize ); 1373 resize ( normalsize );
1374 showMaximized ( ); 1374 showMaximized ( );
1375 normalsize = QSize ( ); 1375 normalsize = QSize ( );
1376 1376
1377 menuToolBar->show(); 1377 menuToolBar->show();
1378 toolBar->show(); 1378 toolBar->show();
1379 if(! listHidden) 1379 if(! listHidden)
1380 { 1380 {
1381 secondToolBar->show(); 1381 secondToolBar->show();
1382 } 1382 }
1383 // commonCombo->show(); 1383 // commonCombo->show();
1384 menuToolBar->show(); 1384 menuToolBar->show();
1385 if (tabPos != tm_hidden) 1385 if (tabPos != tm_hidden)
1386 { 1386 {
1387 tab->getTabBar()->show(); 1387 tab->getTabBar()->show();
1388 } 1388 }
1389 } 1389 }
1390 tab->setMargin(tab->margin()); // cause setup to run 1390 tab->setMargin(tab->margin()); // cause setup to run
1391} 1391}
1392 1392
1393 1393
1394void Konsole::fullscreenTimeout() 1394void Konsole::fullscreenTimeout()
1395{ 1395{
1396 fullscreen_msg->hide(); 1396 fullscreen_msg->hide();
1397} 1397}
1398 1398
1399void Konsole::colorMenuIsSelected(int iD) 1399void Konsole::colorMenuIsSelected(int iD)
1400{ 1400{
1401 fromMenu = TRUE; 1401 fromMenu = TRUE;
1402 colorMenuSelected(iD); 1402 colorMenuSelected(iD);
1403} 1403}
1404 1404
1405/// ------------------------------- some new stuff by L.J. Potter 1405/// ------------------------------- some new stuff by L.J. Potter
1406 1406
1407 1407
1408void Konsole::colorMenuSelected(int iD) 1408void Konsole::colorMenuSelected(int iD)
1409{ 1409{
1410 // this is NOT pretty, elegant or anything else besides functional 1410 // this is NOT pretty, elegant or anything else besides functional
1411 // QString temp; 1411 // QString temp;
1412 // qDebug( temp.sprintf("colormenu %d", iD)); 1412 // qDebug( temp.sprintf("colormenu %d", iD));