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,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 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}
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/commandeditdialog.cpp b/core/apps/embeddedkonsole/commandeditdialog.cpp
index b23db18..e4255f3 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( "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
@@ -1,756 +1,756 @@
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// enhancements added by Phillip Kuhn
24//#define QT_QWS_OPIE 24//#define QT_QWS_OPIE
25 25
26#include <stdlib.h> 26#include <stdlib.h>
27 27
28#ifdef QT_QWS_OPIE 28#ifdef QT_QWS_OPIE
29#include <opie2/ocolorpopupmenu.h> 29#include <opie2/ocolorpopupmenu.h>
30#endif 30#endif
31 31
32#include <qpe/resource.h> 32#include <qpe/resource.h>
33 33
34#include <qdir.h> 34#include <qdir.h>
35#include <qevent.h> 35#include <qevent.h>
36#include <qdragobject.h> 36#include <qdragobject.h>
37#include <qobjectlist.h> 37#include <qobjectlist.h>
38#include <qtoolbutton.h> 38#include <qtoolbutton.h>
39#include <qtoolbar.h> 39#include <qtoolbar.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qfontdialog.h> 41#include <qfontdialog.h>
42#include <qglobal.h> 42#include <qglobal.h>
43#include <qpainter.h> 43#include <qpainter.h>
44#include <qmenubar.h> 44#include <qmenubar.h>
45#include <qmessagebox.h> 45#include <qmessagebox.h>
46#include <qaction.h> 46#include <qaction.h>
47#include <qapplication.h> 47#include <qapplication.h>
48#include <qfontmetrics.h> 48#include <qfontmetrics.h>
49#include <qcombobox.h> 49#include <qcombobox.h>
50#include <qevent.h> 50#include <qevent.h>
51#include <qtabwidget.h> 51#include <qtabwidget.h>
52#include <qtabbar.h> 52#include <qtabbar.h>
53#include <qpe/config.h> 53#include <qpe/config.h>
54#include <qstringlist.h> 54#include <qstringlist.h>
55#include <qpalette.h> 55#include <qpalette.h>
56#include <qfontdatabase.h> 56#include <qfontdatabase.h>
57#include <qfile.h> 57#include <qfile.h>
58#include <qspinbox.h> 58#include <qspinbox.h>
59#include <qlayout.h> 59#include <qlayout.h>
60#include <qvbox.h> 60#include <qvbox.h>
61 61
62#include <sys/wait.h> 62#include <sys/wait.h>
63#include <stdio.h> 63#include <stdio.h>
64#include <stdlib.h> 64#include <stdlib.h>
65#include <assert.h> 65#include <assert.h>
66 66
67#include "konsole.h" 67#include "konsole.h"
68#include "keytrans.h" 68#include "keytrans.h"
69#include "commandeditdialog.h" 69#include "commandeditdialog.h"
70 70
71class EKNumTabBar : public QTabBar 71class EKNumTabBar : public QTabBar
72{ 72{
73public: 73public:
74 EKNumTabBar(QWidget *parent = 0, const char *name = 0) : 74 EKNumTabBar(QWidget *parent = 0, const char *name = 0) :
75 QTabBar(parent, name) 75 QTabBar(parent, name)
76 {} 76 {}
77 77
78 // QList<QTab> *getTabList() { return(tabList()); } 78 // QList<QTab> *getTabList() { return(tabList()); }
79 79
80 void numberTabs() 80 void numberTabs()
81 { 81 {
82 // Yes, it really is this messy. QTabWidget needs functions 82 // Yes, it really is this messy. QTabWidget needs functions
83 // that provide acces to tabs in a sequential way. 83 // that provide acces to tabs in a sequential way.
84 int m=INT_MIN; 84 int m=INT_MIN;
85 for (int i=0; i<count(); i++) 85 for (int i=0; i<count(); i++)
86 { 86 {
87 QTab* left=0; 87 QTab* left=0;
88 QListIterator<QTab> it(*tabList()); 88 QListIterator<QTab> it(*tabList());
89 int x=INT_MAX; 89 int x=INT_MAX;
90 for( QTab* t; (t=it.current()); ++it ) 90 for( QTab* t; (t=it.current()); ++it )
91 { 91 {
92 int tx = t->rect().x(); 92 int tx = t->rect().x();
93 if ( tx<x && tx>m ) 93 if ( tx<x && tx>m )
94 { 94 {
95 x = tx; 95 x = tx;
96 left = t; 96 left = t;
97 } 97 }
98 } 98 }
99 if ( left ) 99 if ( left )
100 { 100 {
101 left->setText(QString::number(i+1)); 101 left->setText(QString::number(i+1));
102 m = left->rect().x(); 102 m = left->rect().x();
103 } 103 }
104 } 104 }
105 } 105 }
106 106
107 virtual QSize sizeHint() const 107 virtual QSize sizeHint() const
108 { 108 {
109 if (isHidden()) 109 if (isHidden())
110 { 110 {
111 return(QSize(0,0)); 111 return(QSize(0,0));
112 } 112 }
113 else 113 else
114 { 114 {
115 QSize size = QTabBar::sizeHint(); 115 QSize size = QTabBar::sizeHint();
116 int shrink = 5; 116 int shrink = 5;
117 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) 117 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600)
118 { 118 {
119 shrink = 10; 119 shrink = 10;
120 } 120 }
121 size.setHeight(size.height() - shrink); 121 size.setHeight(size.height() - shrink);
122 return(size); 122 return(size);
123 } 123 }
124 } 124 }
125 125
126}; 126};
127 127
128class EKNumTabWidget : public QTabWidget 128class EKNumTabWidget : public QTabWidget
129{ 129{
130public: 130public:
131 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 131 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
132 { 132 {
133 setTabBar(new EKNumTabBar(parent,"EKTabBar")); 133 setTabBar(new EKNumTabBar(parent,"EKTabBar"));
134 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); 134 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
135 } 135 }
136 136
137 EKNumTabBar *getTabBar() const 137 EKNumTabBar *getTabBar() const
138 { 138 {
139 return ((EKNumTabBar*)tabBar()); 139 return ((EKNumTabBar*)tabBar());
140 } 140 }
141 141
142 142
143 void addTab(QWidget* w) 143 void addTab(QWidget* w)
144 { 144 {
145 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 145 QTab* t = new QTab(QString::number(tabBar()->count()+1));
146 QTabWidget::addTab(w,t); 146 QTabWidget::addTab(w,t);
147 } 147 }
148 148
149 void removeTab(QWidget* w) 149 void removeTab(QWidget* w)
150 { 150 {
151 removePage(w); 151 removePage(w);
152 ((EKNumTabBar*)tabBar())->numberTabs(); 152 ((EKNumTabBar*)tabBar())->numberTabs();
153 } 153 }
154}; 154};
155 155
156// This could be configurable or dynamicly generated from the bash history 156// This could be configurable or dynamicly generated from the bash history
157// file of the user 157// file of the user
158static const char *commonCmds[] = 158static const char *commonCmds[] =
159 { 159 {
160 "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
161 "cardctl eject", 161 "cardctl eject",
162 "cat ", 162 "cat ",
163 "cd ", 163 "cd ",
164 "chmod ", 164 "chmod ",
165 "clear", 165 "clear",
166 "cp ", 166 "cp ",
167 "dc ", 167 "dc ",
168 "df ", 168 "df ",
169 "dmesg", 169 "dmesg",
170 "echo ", 170 "echo ",
171 "env", 171 "env",
172 "find ", 172 "find ",
173 "free", 173 "free",
174 "grep ", 174 "grep ",
175 "ifconfig ", 175 "ifconfig ",
176 "ipkg ", 176 "ipkg ",
177 "mkdir ", 177 "mkdir ",
178 "mv ", 178 "mv ",
179 "nc localhost 7776", 179 "nc localhost 7776",
180 "nc localhost 7777", 180 "nc localhost 7777",
181 "netstat ", 181 "netstat ",
182 "nslookup ", 182 "nslookup ",
183 "ping ", 183 "ping ",
184 "ps aux", 184 "ps aux",
185 "pwd ", 185 "pwd ",
186 "qcop QPE/System 'linkChanged(QString)' ''", 186 "qcop QPE/System 'linkChanged(QString)' ''",
187 "qcop QPE/System 'restart()'", 187 "qcop QPE/System 'restart()'",
188 "qcop QPE/System 'quit()'", 188 "qcop QPE/System 'quit()'",
189 "rm ", 189 "rm ",
190 "rmdir ", 190 "rmdir ",
191 "route ", 191 "route ",
192 "set ", 192 "set ",
193 "traceroute", 193 "traceroute",
194 194
195 /* 195 /*
196 "gzip", 196 "gzip",
197 "gunzip", 197 "gunzip",
198 "chgrp", 198 "chgrp",
199 "chown", 199 "chown",
200 "date", 200 "date",
201 "dd", 201 "dd",
202 "df", 202 "df",
203 "dmesg", 203 "dmesg",
204 "fuser", 204 "fuser",
205 "hostname", 205 "hostname",
206 "kill", 206 "kill",
207 "killall", 207 "killall",
208 "ln", 208 "ln",
209 "ping", 209 "ping",
210 "mount", 210 "mount",
211 "more", 211 "more",
212 "sort", 212 "sort",
213 "touch", 213 "touch",
214 "umount", 214 "umount",
215 "mknod", 215 "mknod",
216 "netstat", 216 "netstat",
217 */ 217 */
218 218
219 "exit", 219 "exit",
220 NULL 220 NULL
221 }; 221 };
222 222
223 223
224Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 224Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
225 QMainWindow(parent, name, fl) 225 QMainWindow(parent, name, fl)
226{ 226{
227 QStrList args; 227 QStrList args;
228 init("/bin/bash",args); 228 init("/bin/bash",args);
229} 229}
230 230
231Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 231Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
232 : QMainWindow(0, name) 232 : QMainWindow(0, name)
233{ 233{
234 init(_pgm,_args); 234 init(_pgm,_args);
235} 235}
236 236
237struct HistoryItem 237struct HistoryItem
238{ 238{
239 HistoryItem(int c, const QString &l) 239 HistoryItem(int c, const QString &l)
240 { 240 {
241 count = c; 241 count = c;
242 line = l; 242 line = l;
243 } 243 }
244 int count; 244 int count;
245 QString line; 245 QString line;
246}; 246};
247 247
248class HistoryList : public QList<HistoryItem> 248class HistoryList : public QList<HistoryItem>
249{ 249{
250 virtual int compareItems( QCollection::Item item1, QCollection::Item item2) 250 virtual int compareItems( QCollection::Item item1, QCollection::Item item2)
251 { 251 {
252 int c1 = ((HistoryItem*)item1)->count; 252 int c1 = ((HistoryItem*)item1)->count;
253 int c2 = ((HistoryItem*)item2)->count; 253 int c2 = ((HistoryItem*)item2)->count;
254 if (c1 > c2) 254 if (c1 > c2)
255 return(1); 255 return(1);
256 if (c1 < c2) 256 if (c1 < c2)
257 return(-1); 257 return(-1);
258 return(0); 258 return(0);
259 } 259 }
260}; 260};
261 261
262void Konsole::initCommandList() 262void Konsole::initCommandList()
263{ 263{
264 // qDebug("Konsole::initCommandList"); 264 // qDebug("Konsole::initCommandList");
265 Config cfg( "Konsole" ); 265 Config cfg( "Konsole" );
266 cfg.setGroup("Commands"); 266 cfg.setGroup("Commands");
267 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 267 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
268 commonCombo->clear(); 268 commonCombo->clear();
269 269
270 if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") 270 if (cfg.readEntry("ShellHistory","TRUE") == "TRUE")
271 { 271 {
272 QString histfilename = QString(getenv("HOME")) + "/.bash_history"; 272 QString histfilename = QString(getenv("HOME")) + "/.bash_history";
273 histfilename = cfg.readEntry("ShellHistoryPath",histfilename); 273 histfilename = cfg.readEntry("ShellHistoryPath",histfilename);
274 QFile histfile(histfilename); 274 QFile histfile(histfilename);
275 // note: compiler barfed on: 275 // note: compiler barfed on:
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)
469 { 469 {
470 fontList->insertItem(s, sizeMenu, familyNum + 1000); 470 fontList->insertItem(s, sizeMenu, familyNum + 1000);
471 471
472 familyNum++; 472 familyNum++;
473 } 473 }
474 } 474 }
475 475
476 } 476 }
477 477
478 if (cfont < 0 || cfont >= (int)fonts.count()) 478 if (cfont < 0 || cfont >= (int)fonts.count())
479 { 479 {
480 cfont = 0; 480 cfont = 0;
481 } 481 }
482 482
483 // create terminal emulation framework //////////////////////////////////// 483 // create terminal emulation framework ////////////////////////////////////
484 nsessions = 0; 484 nsessions = 0;
485 485
486 tab = new EKNumTabWidget(this); 486 tab = new EKNumTabWidget(this);
487 // tab->setMargin(tab->margin()-5); 487 // tab->setMargin(tab->margin()-5);
488 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 488 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
489 489
490 // create terminal toolbar //////////////////////////////////////////////// 490 // create terminal toolbar ////////////////////////////////////////////////
491 setToolBarsMovable( FALSE ); 491 setToolBarsMovable( FALSE );
492 menuToolBar = new QToolBar( this ); 492 menuToolBar = new QToolBar( this );
493 menuToolBar->setHorizontalStretchable( TRUE ); 493 menuToolBar->setHorizontalStretchable( TRUE );
494 494
495 QMenuBar *menuBar = new QMenuBar( menuToolBar ); 495 QMenuBar *menuBar = new QMenuBar( menuToolBar );
496 496
497 bool c7xx = false; 497 bool c7xx = false;
498 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) 498 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600)
499 { 499 {
500 c7xx = true; 500 c7xx = true;
501 } 501 }
502 QFont menuFont; 502 QFont menuFont;
503 menuFont.setPointSize(c7xx? 18 : 10); 503 menuFont.setPointSize(c7xx? 18 : 10);
504 qApp->setFont(menuFont, true); 504 qApp->setFont(menuFont, true);
505 505
506 setFont(cfont); 506 setFont(cfont);
507 507
508 configMenu = new QPopupMenu( this); 508 configMenu = new QPopupMenu( this);
509 colorMenu = new QPopupMenu( this); 509 colorMenu = new QPopupMenu( this);
510 scrollMenu = new QPopupMenu( this); 510 scrollMenu = new QPopupMenu( this);
511 editCommandListMenu = new QPopupMenu( this); 511 editCommandListMenu = new QPopupMenu( this);
512 512
513 configMenu->insertItem(tr("Command List"), editCommandListMenu); 513 configMenu->insertItem(tr("Command List"), editCommandListMenu);
514 514
515 bool listHidden; 515 bool listHidden;
516 cfg.setGroup("Menubar"); 516 cfg.setGroup("Menubar");
517 if( cfg.readEntry("Hidden","FALSE") == "TRUE") 517 if( cfg.readEntry("Hidden","FALSE") == "TRUE")
518 { 518 {
519 ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); 519 ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" ));
520 listHidden=TRUE; 520 listHidden=TRUE;
521 } 521 }
522 else 522 else
523 { 523 {
524 ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); 524 ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" ));
525 listHidden=FALSE; 525 listHidden=FALSE;
526 } 526 }
527 527
528 cfg.setGroup("Tabs"); 528 cfg.setGroup("Tabs");
529 529
530 tabMenu = new QPopupMenu(this); 530 tabMenu = new QPopupMenu(this);
531 tm_bottom = tabMenu->insertItem(tr("Bottom" )); 531 tm_bottom = tabMenu->insertItem(tr("Bottom" ));
532 tm_top = tabMenu->insertItem(tr("Top")); 532 tm_top = tabMenu->insertItem(tr("Top"));
533 tm_hidden = tabMenu->insertItem(tr("Hidden")); 533 tm_hidden = tabMenu->insertItem(tr("Hidden"));
534 534
535 configMenu->insertItem(tr("Tabs"), tabMenu); 535 configMenu->insertItem(tr("Tabs"), tabMenu);
536 536
537 tmp=cfg.readEntry("Position","Top"); 537 tmp=cfg.readEntry("Position","Top");
538 if(tmp=="Top") 538 if(tmp=="Top")
539 { 539 {
540 tab->setTabPosition(QTabWidget::Top); 540 tab->setTabPosition(QTabWidget::Top);
541 tab->getTabBar()->show(); 541 tab->getTabBar()->show();
542 tabPos = tm_top; 542 tabPos = tm_top;
543 } 543 }
544 else if (tmp=="Bottom") 544 else if (tmp=="Bottom")
545 { 545 {
546 tab->setTabPosition(QTabWidget::Bottom); 546 tab->setTabPosition(QTabWidget::Bottom);
547 tab->getTabBar()->show(); 547 tab->getTabBar()->show();
548 tabPos = tm_bottom; 548 tabPos = tm_bottom;
549 } 549 }
550 else 550 else
551 { 551 {
552 tab->getTabBar()->hide(); 552 tab->getTabBar()->hide();
553 tab->setMargin(tab->margin()); 553 tab->setMargin(tab->margin());
554 tabPos = tm_hidden; 554 tabPos = tm_hidden;
555 } 555 }
556 556
557 cm_bw = colorMenu->insertItem(tr( "Black on White")); 557 cm_bw = colorMenu->insertItem(tr( "Black on White"));
558 cm_wb = colorMenu->insertItem(tr( "White on Black")); 558 cm_wb = colorMenu->insertItem(tr( "White on Black"));
559 cm_gb = colorMenu->insertItem(tr( "Green on Black")); 559 cm_gb = colorMenu->insertItem(tr( "Green on Black"));
560 // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); 560 // cm_bt = colorMenu->insertItem(tr( "Black on Transparent"));
561 cm_br = colorMenu->insertItem(tr( "Black on Pink")); 561 cm_br = colorMenu->insertItem(tr( "Black on Pink"));
562 cm_rb = colorMenu->insertItem(tr( "Pink on Black")); 562 cm_rb = colorMenu->insertItem(tr( "Pink on Black"));
563 cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); 563 cm_gy = colorMenu->insertItem(tr( "Green on Yellow"));
564 cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); 564 cm_bm = colorMenu->insertItem(tr( "Blue on Magenta"));
565 cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); 565 cm_mb = colorMenu->insertItem(tr( "Magenta on Blue"));
566 cm_cw = colorMenu->insertItem(tr( "Cyan on White")); 566 cm_cw = colorMenu->insertItem(tr( "Cyan on White"));
567 cm_wc = colorMenu->insertItem(tr( "White on Cyan")); 567 cm_wc = colorMenu->insertItem(tr( "White on Cyan"));
568 cm_bb = colorMenu->insertItem(tr( "Blue on Black")); 568 cm_bb = colorMenu->insertItem(tr( "Blue on Black"));
569 cm_ab = colorMenu->insertItem(tr( "Amber on Black")); 569 cm_ab = colorMenu->insertItem(tr( "Amber on Black"));
570 cm_default = colorMenu->insertItem(tr("default")); 570 cm_default = colorMenu->insertItem(tr("default"));
571 571
572#ifdef QT_QWS_OPIE 572#ifdef QT_QWS_OPIE
573 573
574 colorMenu->insertItem(tr( "Custom")); 574 colorMenu->insertItem(tr( "Custom"));
575#endif 575#endif
576 576
577 configMenu->insertItem(tr( "Colors") ,colorMenu); 577 configMenu->insertItem(tr( "Colors") ,colorMenu);
578 578
579 sessionList = new QPopupMenu(this); 579 sessionList = new QPopupMenu(this);
580 sessionList-> insertItem ( Resource::loadPixmap ( "qkonsole/qkonsole" ), tr( "new session" ), this, 580 sessionList-> insertItem ( Resource::loadPixmap ( "qkonsole/qkonsole" ), tr( "new session" ), this,
581 SLOT(newSession()) ); 581 SLOT(newSession()) );
582 582
583 // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 583 // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
584 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 584 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
585 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); 585 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) ));
586 connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); 586 connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) ));
587 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); 587 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int)));
588 connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); 588 connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int)));
589 connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); 589 connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) );
590 590
591 menuBar->insertItem( tr("View"), configMenu ); 591 menuBar->insertItem( tr("View"), configMenu );
592 menuBar->insertItem( tr("Fonts"), fontList ); 592 menuBar->insertItem( tr("Fonts"), fontList );
593 menuBar->insertItem( tr("Sessions"), sessionList ); 593 menuBar->insertItem( tr("Sessions"), sessionList );
594 594
595 toolBar = new QToolBar( this ); 595 toolBar = new QToolBar( this );
596 596
597 QAction *a; 597 QAction *a;
598 598
599 // Button Commands 599 // Button Commands
600 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 );
601 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); 601 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) );
602 a->addTo( toolBar ); 602 a->addTo( toolBar );
603 603
604 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 );
605 connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); 605 connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) );
606 a->addTo( toolBar ); 606 a->addTo( toolBar );
607 607
608 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 );
609 connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); 609 connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) );
610 a->addTo( toolBar ); 610 a->addTo( toolBar );
611 611
612 612
613 /* 613 /*
614 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 );
615 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); 615 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar );
616 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 );
617 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); 617 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar );
618 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 );
619 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); 619 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar );
620 */ 620 */
621 /* 621 /*
622 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 );
623 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); 623 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar );
624 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 );
625 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); 625 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar );
626 */ 626 */
627 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 );
628 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); 628 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) );
629 a->addTo( toolBar ); 629 a->addTo( toolBar );
630 630
631 secondToolBar = new QToolBar( this ); 631 secondToolBar = new QToolBar( this );
632 secondToolBar->setHorizontalStretchable( TRUE ); 632 secondToolBar->setHorizontalStretchable( TRUE );
633 633
634 commonCombo = new QComboBox( secondToolBar ); 634 commonCombo = new QComboBox( secondToolBar );
635 // commonCombo->setMaximumWidth(236); 635 // commonCombo->setMaximumWidth(236);
636 636
637 ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); 637 ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) );
638 if( listHidden) 638 if( listHidden)
639 { 639 {
640 secondToolBar->hide(); 640 secondToolBar->hide();
641 editCommandListMenu->setItemEnabled(ec_quick ,FALSE); 641 editCommandListMenu->setItemEnabled(ec_quick ,FALSE);
642 } 642 }
643 ec_edit = editCommandListMenu->insertItem(tr( "Edit" ) ); 643 ec_edit = editCommandListMenu->insertItem(tr( "Edit" ) );
644 644
645 cfg.setGroup("Commands"); 645 cfg.setGroup("Commands");
646 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 646 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
647 647
648 initCommandList(); 648 initCommandList();
649 // for (int i = 0; commonCmds[i] != NULL; i++) { 649 // for (int i = 0; commonCmds[i] != NULL; i++) {
650 // commonCombo->insertItem( commonCmds[i], i ); 650 // commonCombo->insertItem( commonCmds[i], i );
651 // tmp = cfg.readEntry( QString::number(i),""); 651 // tmp = cfg.readEntry( QString::number(i),"");
652 // if(tmp != "") 652 // if(tmp != "")
653 // commonCombo->changeItem( tmp,i ); 653 // commonCombo->changeItem( tmp,i );
654 // } 654 // }
655 655
656 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 656 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
657 657
658 sm_none = scrollMenu->insertItem(tr( "None" )); 658 sm_none = scrollMenu->insertItem(tr( "None" ));
659 sm_left = scrollMenu->insertItem(tr( "Left" )); 659 sm_left = scrollMenu->insertItem(tr( "Left" ));
660 sm_right = scrollMenu->insertItem(tr( "Right" )); 660 sm_right = scrollMenu->insertItem(tr( "Right" ));
661 // scrollMenu->insertSeparator(4); 661 // scrollMenu->insertSeparator(4);
662 // scrollMenu->insertItem(tr( "Horizontal" )); 662 // scrollMenu->insertItem(tr( "Horizontal" ));
663 663
664 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); 664 configMenu->insertItem(tr( "ScrollBar" ),scrollMenu);
665 665
666 configMenu->insertItem(tr( "History" ), this, SLOT(historyDialog())); 666 configMenu->insertItem(tr( "History" ), this, SLOT(historyDialog()));
667 667
668 cm_wrap = configMenu->insertItem(tr( "Wrap" )); 668 cm_wrap = configMenu->insertItem(tr( "Wrap" ));
669 cfg.setGroup("ScrollBar"); 669 cfg.setGroup("ScrollBar");
670 configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); 670 configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0));
671 671
672 cm_beep = configMenu->insertItem(tr( "Use Beep" )); 672 cm_beep = configMenu->insertItem(tr( "Use Beep" ));
673 cfg.setGroup("Menubar"); 673 cfg.setGroup("Menubar");
674 configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); 674 configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0));
675 675
676 fullscreen_msg = new QLabel(this); 676 fullscreen_msg = new QLabel(this);
677 fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); 677 fullscreen_msg-> setAlignment ( AlignCenter | SingleLine );
678 fullscreen_msg-> hide(); 678 fullscreen_msg-> hide();
679 fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); 679 fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding ));
680 fullscreen_msg-> setAutoResize(true); 680 fullscreen_msg-> setAutoResize(true);
681 fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 681 fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
682 fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); 682 fullscreen_msg-> setText(tr("To exit fullscreen, tap here."));
683 683
684 fullscreen_timer = new QTimer(this); 684 fullscreen_timer = new QTimer(this);
685 connect(fullscreen_timer, SIGNAL(timeout()), 685 connect(fullscreen_timer, SIGNAL(timeout()),
686 this, SLOT(fullscreenTimeout())); 686 this, SLOT(fullscreenTimeout()));
687 show_fullscreen_msg = true; 687 show_fullscreen_msg = true;
688 688
689 //scrollMenuSelected(-29); 689 //scrollMenuSelected(-29);
690 // cfg.setGroup("ScrollBar"); 690 // cfg.setGroup("ScrollBar");
691 // if(cfg.readBoolEntry("HorzScroll",0)) { 691 // if(cfg.readBoolEntry("HorzScroll",0)) {
692 // if(cfg.readNumEntry("Position",2) == 0) 692 // if(cfg.readNumEntry("Position",2) == 0)
693 // te->setScrollbarLocation(1); 693 // te->setScrollbarLocation(1);
694 // else 694 // else
695 // te->setScrollbarLocation(0); 695 // te->setScrollbarLocation(0);
696 // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 696 // te->setScrollbarLocation( cfg.readNumEntry("Position",2));
697 // te->setWrapAt(120); 697 // te->setWrapAt(120);
698 // } 698 // }
699 // create applications ///////////////////////////////////////////////////// 699 // create applications /////////////////////////////////////////////////////
700 setCentralWidget(tab); 700 setCentralWidget(tab);
701 701
702 // load keymaps //////////////////////////////////////////////////////////// 702 // load keymaps ////////////////////////////////////////////////////////////
703 KeyTrans::loadAll(); 703 KeyTrans::loadAll();
704 for (int i = 0; i < KeyTrans::count(); i++) 704 for (int i = 0; i < KeyTrans::count(); i++)
705 { 705 {
706 KeyTrans* s = KeyTrans::find(i); 706 KeyTrans* s = KeyTrans::find(i);
707 assert( s ); 707 assert( s );
708 } 708 }
709 709
710 se_pgm = _pgm; 710 se_pgm = _pgm;
711 se_args = _args; 711 se_args = _args;
712 712
713 cfg.setGroup("CommandLine"); 713 cfg.setGroup("CommandLine");
714 714
715 if (cfg.hasKey("shell_args")) 715 if (cfg.hasKey("shell_args"))
716 { 716 {
717 QStringList se_args_list = cfg.readListEntry("shell_args",'|'); 717 QStringList se_args_list = cfg.readListEntry("shell_args",'|');
718 for(uint i = 0; i < se_args_list.count(); i++) 718 for(uint i = 0; i < se_args_list.count(); i++)
719 { 719 {
720 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());
721 } 721 }
722 } 722 }
723 else 723 else
724 { 724 {
725 se_args.prepend("--login"); 725 se_args.prepend("--login");
726 } 726 }
727 727
728 se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); 728 se_pgm = cfg.readEntry("shell_bin", QString(se_pgm));
729 729
730 // this is the "documentation" for those who know to look 730 // this is the "documentation" for those who know to look
731 if (! cfg.hasKey("shell_args")) 731 if (! cfg.hasKey("shell_args"))
732 { 732 {
733 cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); 733 cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|');
734 } 734 }
735 if (! cfg.hasKey("shell_bin")) 735 if (! cfg.hasKey("shell_bin"))
736 { 736 {
737 cfg.writeEntry("shell_bin",QString(se_pgm)); 737 cfg.writeEntry("shell_bin",QString(se_pgm));
738 } 738 }
739 739
740 parseCommandLine(); 740 parseCommandLine();
741 741
742 // read and apply default values /////////////////////////////////////////// 742 // read and apply default values ///////////////////////////////////////////
743 resize(321, 321); // Dummy. 743 resize(321, 321); // Dummy.
744 QSize currentSize = size(); 744 QSize currentSize = size();
745 if (currentSize != size()) 745 if (currentSize != size())
746 defaultSize = size(); 746 defaultSize = size();
747 747
748 748
749 /* allows us to catch cancel/escape */ 749 /* allows us to catch cancel/escape */
750 reparent ( 0, WStyle_Customize | WStyle_NoBorder, 750 reparent ( 0, WStyle_Customize | WStyle_NoBorder,
751 QPoint ( 0, 0 )); 751 QPoint ( 0, 0 ));
752} 752}
753 753
754void Konsole::show() 754void Konsole::show()
755{ 755{
756 if ( !nsessions ) 756 if ( !nsessions )
@@ -932,769 +932,769 @@ void Konsole::setFont(int f)
932 cfg.setGroup("Font"); 932 cfg.setGroup("Font");
933 QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); 933 QString ss = "Session"+ QString::number(tab->currentPageIndex()+1);
934 if (tab->currentPageIndex() == 0) 934 if (tab->currentPageIndex() == 0)
935 { 935 {
936 cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); 936 cfg.writeEntry("FontName", fonts.at(cfont)->getFamily());
937 cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); 937 cfg.writeEntry("FontSize", fonts.at(cfont)->getSize());
938 } 938 }
939 cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); 939 cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily());
940 cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); 940 cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize());
941 } 941 }
942} 942}
943 943
944#if 0 944#if 0
945void Konsole::fontChanged(int f) 945void Konsole::fontChanged(int f)
946{ 946{
947 VTFont* font = fonts.at(f); 947 VTFont* font = fonts.at(f);
948 if (font != 0) 948 if (font != 0)
949 { 949 {
950 for(uint i = 0; i < fonts.count(); i++) 950 for(uint i = 0; i < fonts.count(); i++)
951 { 951 {
952 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 952 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
953 } 953 }
954 954
955 cfont = f; 955 cfont = f;
956 956
957 TEWidget* te = getTe(); 957 TEWidget* te = getTe();
958 if (te != 0) 958 if (te != 0)
959 { 959 {
960 te->setVTFont(font->getFont()); 960 te->setVTFont(font->getFont());
961 } 961 }
962 } 962 }
963} 963}
964#endif 964#endif
965 965
966 966
967void Konsole::enterCommand(int c) 967void Konsole::enterCommand(int c)
968{ 968{
969 TEWidget* te = getTe(); 969 TEWidget* te = getTe();
970 if (te != 0) 970 if (te != 0)
971 { 971 {
972 if(!commonCombo->editable()) 972 if(!commonCombo->editable())
973 { 973 {
974 QString text = commonCombo->text(c); //commonCmds[c]; 974 QString text = commonCombo->text(c); //commonCmds[c];
975 te->emitText(text); 975 te->emitText(text);
976 } 976 }
977 else 977 else
978 { 978 {
979 changeCommand( commonCombo->text(c), c); 979 changeCommand( commonCombo->text(c), c);
980 } 980 }
981 } 981 }
982} 982}
983 983
984void Konsole::hitEnter() 984void Konsole::hitEnter()
985{ 985{
986 TEWidget* te = getTe(); 986 TEWidget* te = getTe();
987 if (te != 0) 987 if (te != 0)
988 { 988 {
989 te->emitText(QString("\r")); 989 te->emitText(QString("\r"));
990 } 990 }
991} 991}
992 992
993void Konsole::hitSpace() 993void Konsole::hitSpace()
994{ 994{
995 TEWidget* te = getTe(); 995 TEWidget* te = getTe();
996 if (te != 0) 996 if (te != 0)
997 { 997 {
998 te->emitText(QString(" ")); 998 te->emitText(QString(" "));
999 } 999 }
1000} 1000}
1001 1001
1002void Konsole::hitTab() 1002void Konsole::hitTab()
1003{ 1003{
1004 TEWidget* te = getTe(); 1004 TEWidget* te = getTe();
1005 if (te != 0) 1005 if (te != 0)
1006 { 1006 {
1007 te->emitText(QString("\t")); 1007 te->emitText(QString("\t"));
1008 } 1008 }
1009} 1009}
1010 1010
1011void Konsole::hitPaste() 1011void Konsole::hitPaste()
1012{ 1012{
1013 TEWidget* te = getTe(); 1013 TEWidget* te = getTe();
1014 if (te != 0) 1014 if (te != 0)
1015 { 1015 {
1016 te->pasteClipboard(); 1016 te->pasteClipboard();
1017 } 1017 }
1018} 1018}
1019 1019
1020void Konsole::hitUp() 1020void Konsole::hitUp()
1021{ 1021{
1022 TEWidget* te = getTe(); 1022 TEWidget* te = getTe();
1023 if (te != 0) 1023 if (te != 0)
1024 { 1024 {
1025 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); 1025 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
1026 QApplication::sendEvent( te, &ke ); 1026 QApplication::sendEvent( te, &ke );
1027 } 1027 }
1028} 1028}
1029 1029
1030void Konsole::hitDown() 1030void Konsole::hitDown()
1031{ 1031{
1032 TEWidget* te = getTe(); 1032 TEWidget* te = getTe();
1033 if (te != 0) 1033 if (te != 0)
1034 { 1034 {
1035 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); 1035 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0);
1036 QApplication::sendEvent( te, &ke ); 1036 QApplication::sendEvent( te, &ke );
1037 } 1037 }
1038} 1038}
1039 1039
1040/** 1040/**
1041 This function calculates the size of the external widget 1041 This function calculates the size of the external widget
1042 needed for the internal widget to be 1042 needed for the internal widget to be
1043 */ 1043 */
1044QSize Konsole::calcSize(int columns, int lines) 1044QSize Konsole::calcSize(int columns, int lines)
1045{ 1045{
1046 TEWidget* te = getTe(); 1046 TEWidget* te = getTe();
1047 if (te != 0) 1047 if (te != 0)
1048 { 1048 {
1049 QSize size = te->calcSize(columns, lines); 1049 QSize size = te->calcSize(columns, lines);
1050 return size; 1050 return size;
1051 } 1051 }
1052 else 1052 else
1053 { 1053 {
1054 QSize size; 1054 QSize size;
1055 return size; 1055 return size;
1056 } 1056 }
1057} 1057}
1058 1058
1059/** 1059/**
1060 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
1061 guest widget. Call with (0,0) for setting default size. 1061 guest widget. Call with (0,0) for setting default size.
1062*/ 1062*/
1063 1063
1064void Konsole::setColLin(int columns, int lines) 1064void Konsole::setColLin(int columns, int lines)
1065{ 1065{
1066 qDebug("konsole::setColLin:: Columns %d", columns); 1066 qDebug("konsole::setColLin:: Columns %d", columns);
1067 1067
1068 if ((columns==0) || (lines==0)) 1068 if ((columns==0) || (lines==0))
1069 { 1069 {
1070 if (defaultSize.isEmpty()) // not in config file : set default value 1070 if (defaultSize.isEmpty()) // not in config file : set default value
1071 { 1071 {
1072 defaultSize = calcSize(80,24); 1072 defaultSize = calcSize(80,24);
1073 // notifySize(24,80); // set menu items (strange arg order !) 1073 // notifySize(24,80); // set menu items (strange arg order !)
1074 } 1074 }
1075 resize(defaultSize); 1075 resize(defaultSize);
1076 } 1076 }
1077 else 1077 else
1078 { 1078 {
1079 resize(calcSize(columns, lines)); 1079 resize(calcSize(columns, lines));
1080 // notifySize(lines,columns); // set menu items (strange arg order !) 1080 // notifySize(lines,columns); // set menu items (strange arg order !)
1081 } 1081 }
1082} 1082}
1083 1083
1084/* 1084/*
1085void Konsole::setFont(int fontno) 1085void Konsole::setFont(int fontno)
1086{ 1086{
1087 QFont f; 1087 QFont f;
1088 if (fontno == 0) 1088 if (fontno == 0)
1089 f = defaultFont = QFont( "Helvetica", 12 ); 1089 f = defaultFont = QFont( "Helvetica", 12 );
1090 else 1090 else
1091 if (fonts[fontno][0] == '-') 1091 if (fonts[fontno][0] == '-')
1092 f.setRawName( fonts[fontno] ); 1092 f.setRawName( fonts[fontno] );
1093 else 1093 else
1094 { 1094 {
1095 f.setFamily(fonts[fontno]); 1095 f.setFamily(fonts[fontno]);
1096 f.setRawMode( TRUE ); 1096 f.setRawMode( TRUE );
1097 } 1097 }
1098 if ( !f.exactMatch() && fontno != 0) 1098 if ( !f.exactMatch() && fontno != 0)
1099 { 1099 {
1100 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]);
1101 QMessageBox(this, msg); 1101 QMessageBox(this, msg);
1102 return; 1102 return;
1103 } 1103 }
1104 if (se) se->setFontNo(fontno); 1104 if (se) se->setFontNo(fontno);
1105 te->setVTFont(f); 1105 te->setVTFont(f);
1106 n_font = fontno; 1106 n_font = fontno;
1107} 1107}
1108*/ 1108*/
1109 1109
1110// --| color selection |------------------------------------------------------- 1110// --| color selection |-------------------------------------------------------
1111 1111
1112void Konsole::changeColumns(int /*columns*/) 1112void Konsole::changeColumns(int /*columns*/)
1113{ //FIXME this seems to cause silliness when reset command is executed 1113{ //FIXME this seems to cause silliness when reset command is executed
1114 // qDebug("change columns"); 1114 // qDebug("change columns");
1115 // TEWidget* te = getTe(); 1115 // TEWidget* te = getTe();
1116 // if (te != 0) { 1116 // if (te != 0) {
1117 // setColLin(columns,te->Lines()); 1117 // setColLin(columns,te->Lines());
1118 // te->update(); 1118 // te->update();
1119 // } 1119 // }
1120} 1120}
1121 1121
1122//FIXME: If a child dies during session swap, 1122//FIXME: If a child dies during session swap,
1123// this routine might be called before 1123// this routine might be called before
1124// session swap is completed. 1124// session swap is completed.
1125 1125
1126void Konsole::doneSession(TEWidget* te, int ) 1126void Konsole::doneSession(TEWidget* te, int )
1127{ 1127{
1128 // TEWidget *te = NULL; 1128 // TEWidget *te = NULL;
1129 // if (sess->currentSession == tab->currentPage()) { 1129 // if (sess->currentSession == tab->currentPage()) {
1130 // printf("done current session\n"); 1130 // printf("done current session\n");
1131 // te = getTe(); 1131 // te = getTe();
1132 // } else { 1132 // } else {
1133 // int currentPage = tab->currentPageIndex(); 1133 // int currentPage = tab->currentPageIndex();
1134 // printf("done not current session\n"); 1134 // printf("done not current session\n");
1135 // for(int i = 0; i < nsessions; i++) { 1135 // for(int i = 0; i < nsessions; i++) {
1136 // tab->setCurrentPage(i); 1136 // tab->setCurrentPage(i);
1137 // printf("find session %d tab page %x session %x\n", 1137 // printf("find session %d tab page %x session %x\n",
1138 // i, tab->currentPage(), sess->currentSession); 1138 // i, tab->currentPage(), sess->currentSession);
1139 // if (tab->currentPage() == sess->currentSession) { 1139 // if (tab->currentPage() == sess->currentSession) {
1140 // printf("found session %d\n", i); 1140 // printf("found session %d\n", i);
1141 // te = tab->currentPage(); 1141 // te = tab->currentPage();
1142 // break; 1142 // break;
1143 // } 1143 // }
1144 // } 1144 // }
1145 // tab->setCurrentPage(currentPage); 1145 // tab->setCurrentPage(currentPage);
1146 // } 1146 // }
1147 if (te != 0) 1147 if (te != 0)
1148 { 1148 {
1149 te->currentSession->setConnect(FALSE); 1149 te->currentSession->setConnect(FALSE);
1150 tab->removeTab(te); 1150 tab->removeTab(te);
1151 delete te->currentSession; 1151 delete te->currentSession;
1152 delete te; 1152 delete te;
1153 sessionList->removeItem(nsessions); 1153 sessionList->removeItem(nsessions);
1154 nsessions--; 1154 nsessions--;
1155 } 1155 }
1156 if (nsessions == 0) 1156 if (nsessions == 0)
1157 { 1157 {
1158 close(); 1158 close();
1159 } 1159 }
1160} 1160}
1161 1161
1162void Konsole::changeTitle(TEWidget* te, QString newTitle ) 1162void Konsole::changeTitle(TEWidget* te, QString newTitle )
1163{ 1163{
1164 if (te == getTe()) 1164 if (te == getTe())
1165 { 1165 {
1166 setCaption(newTitle + " - QKonsole"); 1166 setCaption(newTitle + " - QKonsole");
1167 } 1167 }
1168} 1168}
1169 1169
1170 1170
1171void Konsole::newSession() 1171void Konsole::newSession()
1172{ 1172{
1173 if(nsessions < 15) 1173 if(nsessions < 15)
1174 { // 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?
1175 TEWidget* te = new TEWidget(tab); 1175 TEWidget* te = new TEWidget(tab);
1176 Config cfg( "Konsole" ); 1176 Config cfg( "Konsole" );
1177 cfg.setGroup("Menubar"); 1177 cfg.setGroup("Menubar");
1178 1178
1179 // FIXME use more defaults from config file 1179 // FIXME use more defaults from config file
1180 te->useBeep=cfg.readBoolEntry("useBeep",0); 1180 te->useBeep=cfg.readBoolEntry("useBeep",0);
1181 1181
1182 // te->setBackgroundMode(PaletteBase); //we want transparent!! 1182 // te->setBackgroundMode(PaletteBase); //we want transparent!!
1183 1183
1184 cfg.setGroup("Font"); 1184 cfg.setGroup("Font");
1185 QString sn = "Session" + QString::number(nsessions+1); 1185 QString sn = "Session" + QString::number(nsessions+1);
1186 printf("read font session %s\n", sn.latin1()); 1186 printf("read font session %s\n", sn.latin1());
1187 QString fontName = cfg.readEntry("FontName"+sn, 1187 QString fontName = cfg.readEntry("FontName"+sn,
1188 cfg.readEntry("FontName", 1188 cfg.readEntry("FontName",
1189 fonts.at(cfont)->getFamily())); 1189 fonts.at(cfont)->getFamily()));
1190 int fontSize = cfg.readNumEntry("FontSize"+sn, 1190 int fontSize = cfg.readNumEntry("FontSize"+sn,
1191 cfg.readNumEntry("FontSize", 1191 cfg.readNumEntry("FontSize",
1192 fonts.at(cfont)->getSize())); 1192 fonts.at(cfont)->getSize()));
1193 cfont = findFont(fontName, fontSize, false); 1193 cfont = findFont(fontName, fontSize, false);
1194 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);
1195 if (cfont < 0) 1195 if (cfont < 0)
1196 cfont = 0; 1196 cfont = 0;
1197 te->setVTFont(fonts.at(cfont)->getFont()); 1197 te->setVTFont(fonts.at(cfont)->getFont());
1198 1198
1199 tab->addTab(te); 1199 tab->addTab(te);
1200 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); 1200 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
1201 te->currentSession = se; 1201 te->currentSession = se;
1202 connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); 1202 connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) );
1203 connect( se, SIGNAL(changeTitle(TEWidget*,QString)), this, 1203 connect( se, SIGNAL(changeTitle(TEWidget*,QString)), this,
1204 SLOT(changeTitle(TEWidget*,QString)) ); 1204 SLOT(changeTitle(TEWidget*,QString)) );
1205 connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); 1205 connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int)));
1206 connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); 1206 connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int)));
1207 connect(te, SIGNAL(newSession()), this, SLOT(newSession())); 1207 connect(te, SIGNAL(newSession()), this, SLOT(newSession()));
1208 connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); 1208 connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen()));
1209 connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); 1209 connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool)));
1210 se->run(); 1210 se->run();
1211 se->setConnect(TRUE); 1211 se->setConnect(TRUE);
1212 se->setHistory(b_scroll); 1212 se->setHistory(b_scroll);
1213 nsessions++; 1213 nsessions++;
1214 sessionList->insertItem(QString::number(nsessions), nsessions); 1214 sessionList->insertItem(QString::number(nsessions), nsessions);
1215 sessionListSelected(nsessions); 1215 sessionListSelected(nsessions);
1216 doWrap(); 1216 doWrap();
1217 setColor(nsessions-1); 1217 setColor(nsessions-1);
1218 } 1218 }
1219} 1219}
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));
1413 1413
1414 TEWidget* te = getTe(); 1414 TEWidget* te = getTe();
1415 Config cfg( "Konsole" ); 1415 Config cfg( "Konsole" );
1416 cfg.setGroup("Colors"); 1416 cfg.setGroup("Colors");
1417 1417
1418 ColorEntry m_table[TABLE_COLORS]; 1418 ColorEntry m_table[TABLE_COLORS];
1419 const ColorEntry * defaultCt=te->getdefaultColorTable(); 1419 const ColorEntry * defaultCt=te->getdefaultColorTable();
1420 1420
1421 int i; 1421 int i;
1422 1422
1423 // te->color_menu_item = iD; 1423 // te->color_menu_item = iD;
1424 1424
1425 colorMenu->setItemChecked(cm_ab,FALSE); 1425 colorMenu->setItemChecked(cm_ab,FALSE);
1426 colorMenu->setItemChecked(cm_bb,FALSE); 1426 colorMenu->setItemChecked(cm_bb,FALSE);
1427 colorMenu->setItemChecked(cm_wc,FALSE); 1427 colorMenu->setItemChecked(cm_wc,FALSE);
1428 colorMenu->setItemChecked(cm_cw,FALSE); 1428 colorMenu->setItemChecked(cm_cw,FALSE);
1429 colorMenu->setItemChecked(cm_mb,FALSE); 1429 colorMenu->setItemChecked(cm_mb,FALSE);
1430 colorMenu->setItemChecked(cm_bm,FALSE); 1430 colorMenu->setItemChecked(cm_bm,FALSE);
1431 colorMenu->setItemChecked(cm_gy,FALSE); 1431 colorMenu->setItemChecked(cm_gy,FALSE);
1432 colorMenu->setItemChecked(cm_rb,FALSE); 1432 colorMenu->setItemChecked(cm_rb,FALSE);
1433 colorMenu->setItemChecked(cm_br,FALSE); 1433 colorMenu->setItemChecked(cm_br,FALSE);
1434 colorMenu->setItemChecked(cm_wb,FALSE); 1434 colorMenu->setItemChecked(cm_wb,FALSE);
1435 colorMenu->setItemChecked(cm_bw,FALSE); 1435 colorMenu->setItemChecked(cm_bw,FALSE);
1436 colorMenu->setItemChecked(cm_gb,FALSE); 1436 colorMenu->setItemChecked(cm_gb,FALSE);
1437 1437
1438 if(iD==cm_default) 1438 if(iD==cm_default)
1439 { // default default 1439 { // default default
1440 printf("default colors\n"); 1440 printf("default colors\n");
1441 for (i = 0; i < TABLE_COLORS; i++) 1441 for (i = 0; i < TABLE_COLORS; i++)
1442 { 1442 {
1443 m_table[i].color = defaultCt[i].color; 1443 m_table[i].color = defaultCt[i].color;
1444 if(i==1 || i == 11) 1444 if(i==1 || i == 11)
1445 m_table[i].transparent=1; 1445 m_table[i].transparent=1;
1446 colorMenu->setItemChecked(cm_default,TRUE); 1446 colorMenu->setItemChecked(cm_default,TRUE);
1447 } 1447 }
1448 te->setColorTable(m_table); 1448 te->setColorTable(m_table);
1449 } 1449 }
1450 if(iD==cm_gb) 1450 if(iD==cm_gb)
1451 { // green black 1451 { // green black
1452 foreground.setRgb(100,255,100); // (0x18,255,0x18); 1452 foreground.setRgb(100,255,100); // (0x18,255,0x18);
1453 background.setRgb(0x00,0x00,0x00); 1453 background.setRgb(0x00,0x00,0x00);
1454 colorMenu->setItemChecked(cm_gb,TRUE); 1454 colorMenu->setItemChecked(cm_gb,TRUE);
1455 } 1455 }
1456 if(iD==cm_bw) 1456 if(iD==cm_bw)
1457 { // black white 1457 { // black white
1458 foreground.setRgb(0x00,0x00,0x00); 1458 foreground.setRgb(0x00,0x00,0x00);
1459 background.setRgb(0xFF,0xFF,0xFF); 1459 background.setRgb(0xFF,0xFF,0xFF);
1460 colorMenu->setItemChecked(cm_bw,TRUE); 1460 colorMenu->setItemChecked(cm_bw,TRUE);
1461 } 1461 }
1462 if(iD==cm_wb) 1462 if(iD==cm_wb)
1463 { // white black 1463 { // white black
1464 foreground.setRgb(0xFF,0xFF,0xFF); 1464 foreground.setRgb(0xFF,0xFF,0xFF);
1465 background.setRgb(0x00,0x00,0x00); 1465 background.setRgb(0x00,0x00,0x00);
1466 colorMenu->setItemChecked(cm_wb,TRUE); 1466 colorMenu->setItemChecked(cm_wb,TRUE);
1467 } 1467 }
1468 if(iD==cm_br) 1468 if(iD==cm_br)
1469 {// Black, Red 1469 {// Black, Red
1470 foreground.setRgb(0x00,0x00,0x00); 1470 foreground.setRgb(0x00,0x00,0x00);
1471 background.setRgb(255,85,85); //(0xB2,0x18,0x18); 1471 background.setRgb(255,85,85); //(0xB2,0x18,0x18);
1472 colorMenu->setItemChecked(cm_br,TRUE); 1472 colorMenu->setItemChecked(cm_br,TRUE);
1473 } 1473 }
1474 if(iD==cm_rb) 1474 if(iD==cm_rb)
1475 {// Red, Black 1475 {// Red, Black
1476 foreground.setRgb(255,85,85); 1476 foreground.setRgb(255,85,85);
1477 background.setRgb(0x00,0x00,0x00); 1477 background.setRgb(0x00,0x00,0x00);
1478 colorMenu->setItemChecked(cm_rb,TRUE); 1478 colorMenu->setItemChecked(cm_rb,TRUE);
1479 } 1479 }
1480 if(iD==cm_gy) 1480 if(iD==cm_gy)
1481 {// Green, Yellow - is ugly 1481 {// Green, Yellow - is ugly
1482 // foreground.setRgb(0x18,0xB2,0x18); 1482 // foreground.setRgb(0x18,0xB2,0x18);
1483 foreground.setRgb(15,115,0); 1483 foreground.setRgb(15,115,0);
1484 // background.setRgb(0xB2,0x68,0x18); 1484 // background.setRgb(0xB2,0x68,0x18);
1485 background.setRgb(255,255,0); 1485 background.setRgb(255,255,0);
1486 colorMenu->setItemChecked(cm_gy,TRUE); 1486 colorMenu->setItemChecked(cm_gy,TRUE);
1487 } 1487 }
1488 if(iD==cm_bm) 1488 if(iD==cm_bm)
1489 {// Blue, Magenta 1489 {// Blue, Magenta
1490 foreground.setRgb(3,24,132); 1490 foreground.setRgb(3,24,132);
1491 background.setRgb(225,2,255); 1491 background.setRgb(225,2,255);
1492 colorMenu->setItemChecked(cm_bm,TRUE); 1492 colorMenu->setItemChecked(cm_bm,TRUE);
1493 } 1493 }
1494 if(iD==cm_mb) 1494 if(iD==cm_mb)
1495 {// Magenta, Blue 1495 {// Magenta, Blue
1496 foreground.setRgb(225,2,255); 1496 foreground.setRgb(225,2,255);
1497 background.setRgb(3,24,132); 1497 background.setRgb(3,24,132);
1498 colorMenu->setItemChecked(cm_mb,TRUE); 1498 colorMenu->setItemChecked(cm_mb,TRUE);
1499 } 1499 }
1500 if(iD==cm_cw) 1500 if(iD==cm_cw)
1501 {// Cyan, White 1501 {// Cyan, White
1502 foreground.setRgb(8,91,129); 1502 foreground.setRgb(8,91,129);
1503 background.setRgb(0xFF,0xFF,0xFF); 1503 background.setRgb(0xFF,0xFF,0xFF);
1504 colorMenu->setItemChecked(cm_cw,TRUE); 1504 colorMenu->setItemChecked(cm_cw,TRUE);
1505 } 1505 }
1506 if(iD==cm_wc) 1506 if(iD==cm_wc)
1507 {// White, Cyan 1507 {// White, Cyan
1508 background.setRgb(8,91,129); 1508 background.setRgb(8,91,129);
1509 foreground.setRgb(0xFF,0xFF,0xFF); 1509 foreground.setRgb(0xFF,0xFF,0xFF);
1510 colorMenu->setItemChecked(cm_wc,TRUE); 1510 colorMenu->setItemChecked(cm_wc,TRUE);
1511 } 1511 }
1512 if(iD==cm_bb) 1512 if(iD==cm_bb)
1513 {// Black, Blue 1513 {// Black, Blue
1514 background.setRgb(0x00,0x00,0x00); 1514 background.setRgb(0x00,0x00,0x00);
1515 foreground.setRgb(127,147,225); 1515 foreground.setRgb(127,147,225);
1516 colorMenu->setItemChecked(cm_bb,TRUE); 1516 colorMenu->setItemChecked(cm_bb,TRUE);
1517 } 1517 }
1518 if(iD==cm_ab) 1518 if(iD==cm_ab)
1519 {// Black, Gold 1519 {// Black, Gold
1520 background.setRgb(0x00,0x00,0x00); 1520 background.setRgb(0x00,0x00,0x00);
1521 foreground.setRgb(255,215,105); 1521 foreground.setRgb(255,215,105);
1522 colorMenu->setItemChecked(cm_ab,TRUE); 1522 colorMenu->setItemChecked(cm_ab,TRUE);
1523 } 1523 }
1524#ifdef QT_QWS_OPIE 1524#ifdef QT_QWS_OPIE
1525 if(iD==-19) 1525 if(iD==-19)
1526 { 1526 {
1527 // Custom 1527 // Custom
1528 qDebug("do custom"); 1528 qDebug("do custom");
1529 if(fromMenu) 1529 if(fromMenu)
1530 { 1530 {
1531 Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); 1531 Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color");
1532 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, 1532 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this,
1533 SLOT(changeForegroundColor(const QColor&))); 1533 SLOT(changeForegroundColor(const QColor&)));
1534 penColorPopupMenu->exec(); 1534 penColorPopupMenu->exec();
1535 } 1535 }
1536 if(!fromMenu) 1536 if(!fromMenu)
1537 { 1537 {
1538 foreground.setNamedColor(cfg.readEntry("foreground","")); 1538 foreground.setNamedColor(cfg.readEntry("foreground",""));
1539 background.setNamedColor(cfg.readEntry("background","")); 1539 background.setNamedColor(cfg.readEntry("background",""));
1540 } 1540 }
1541 fromMenu=FALSE; 1541 fromMenu=FALSE;
1542 colorMenu->setItemChecked(-19,TRUE); 1542 colorMenu->setItemChecked(-19,TRUE);
1543 } 1543 }
1544#endif 1544#endif
1545 1545
1546 lastSelectedMenu = iD; 1546 lastSelectedMenu = iD;
1547 1547
1548 setColors(foreground, background); 1548 setColors(foreground, background);
1549 1549
1550 QTabBar *tabBar = tab->getTabBar(); 1550 QTabBar *tabBar = tab->getTabBar();
1551 QString ss = QString("Session%1").arg(tabBar->currentTab()); 1551 QString ss = QString("Session%1").arg(tabBar->currentTab());
1552 // printf("current tab = %d\n", tabBar->currentTab()); 1552 // printf("current tab = %d\n", tabBar->currentTab());
1553 1553
1554 if (tabBar->currentTab() == 0) 1554 if (tabBar->currentTab() == 0)
1555 { 1555 {
1556 cfg.writeEntry("foregroundRed",QString::number(foreground.red())); 1556 cfg.writeEntry("foregroundRed",QString::number(foreground.red()));
1557 cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); 1557 cfg.writeEntry("foregroundGreen",QString::number(foreground.green()));
1558 cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); 1558 cfg.writeEntry("foregroundBlue",QString::number(foreground.blue()));
1559 cfg.writeEntry("backgroundRed",QString::number(background.red())); 1559 cfg.writeEntry("backgroundRed",QString::number(background.red()));
1560 cfg.writeEntry("backgroundGreen",QString::number(background.green())); 1560 cfg.writeEntry("backgroundGreen",QString::number(background.green()));
1561 cfg.writeEntry("backgroundBlue",QString::number(background.blue())); 1561 cfg.writeEntry("backgroundBlue",QString::number(background.blue()));
1562 } 1562 }
1563 cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); 1563 cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red()));
1564 cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); 1564 cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green()));
1565 cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); 1565 cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue()));
1566 cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); 1566 cfg.writeEntry("backgroundRed"+ss,QString::number(background.red()));
1567 cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); 1567 cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green()));
1568 cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); 1568 cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue()));
1569 1569
1570 update(); 1570 update();
1571} 1571}
1572 1572
1573void Konsole::setColors(QColor foreground, QColor background) 1573void Konsole::setColors(QColor foreground, QColor background)
1574{ 1574{
1575 int i; 1575 int i;
1576 ColorEntry m_table[TABLE_COLORS]; 1576 ColorEntry m_table[TABLE_COLORS];
1577 TEWidget* te = getTe(); 1577 TEWidget* te = getTe();
1578 const ColorEntry * defaultCt=te->getdefaultColorTable(); 1578 const ColorEntry * defaultCt=te->getdefaultColorTable();
1579 1579
1580 for (i = 0; i < TABLE_COLORS; i++) 1580 for (i = 0; i < TABLE_COLORS; i++)
1581 { 1581 {
1582 if(i==0 || i == 10) 1582 if(i==0 || i == 10)
1583 { 1583 {
1584 m_table[i].color = foreground; 1584 m_table[i].color = foreground;
1585 } 1585 }
1586 else if(i==1 || i == 11) 1586 else if(i==1 || i == 11)
1587 { 1587 {
1588 m_table[i].color = background; 1588 m_table[i].color = background;
1589 m_table[i].transparent=0; 1589 m_table[i].transparent=0;
1590 } 1590 }
1591 else 1591 else
1592 m_table[i].color = defaultCt[i].color; 1592 m_table[i].color = defaultCt[i].color;
1593 } 1593 }
1594 te->setColorTable(m_table); 1594 te->setColorTable(m_table);
1595} 1595}
1596 1596
1597void Konsole::tabMenuSelected(int id) 1597void Konsole::tabMenuSelected(int id)
1598{ 1598{
1599 Config cfg( "Konsole" ); 1599 Config cfg( "Konsole" );
1600 cfg.setGroup("Tabs"); 1600 cfg.setGroup("Tabs");
1601 tabMenu->setItemChecked(tabPos, false); 1601 tabMenu->setItemChecked(tabPos, false);
1602 if (id == tm_bottom) 1602 if (id == tm_bottom)
1603 { 1603 {
1604 printf("set bottom tab\n"); 1604 printf("set bottom tab\n");
1605 tab->getTabBar()->show(); 1605 tab->getTabBar()->show();
1606 tab->setTabPosition(QTabWidget::Bottom); 1606 tab->setTabPosition(QTabWidget::Bottom);
1607 tab->getTabBar()->show(); 1607 tab->getTabBar()->show();
1608 cfg.writeEntry("Position","Bottom"); 1608 cfg.writeEntry("Position","Bottom");
1609 } 1609 }
1610 else if (id == tm_top) 1610 else if (id == tm_top)
1611 { 1611 {
1612 printf("set top tab\n"); 1612 printf("set top tab\n");
1613 tab->getTabBar()->show(); 1613 tab->getTabBar()->show();
1614 tab->setTabPosition(QTabWidget::Bottom); 1614 tab->setTabPosition(QTabWidget::Bottom);
1615 tab->setTabPosition(QTabWidget::Top); 1615 tab->setTabPosition(QTabWidget::Top);
1616 tab->getTabBar()->show(); 1616 tab->getTabBar()->show();
1617 cfg.writeEntry("Position","Top"); 1617 cfg.writeEntry("Position","Top");
1618 } 1618 }
1619 else if (id == tm_hidden) 1619 else if (id == tm_hidden)
1620 { 1620 {
1621 tab->getTabBar()->hide(); 1621 tab->getTabBar()->hide();
1622 tab->setMargin(tab->margin()); 1622 tab->setMargin(tab->margin());
1623 cfg.writeEntry("Position","Hidden"); 1623 cfg.writeEntry("Position","Hidden");
1624 } 1624 }
1625 tabMenu->setItemChecked(id, true); 1625 tabMenu->setItemChecked(id, true);
1626 tabPos = id; 1626 tabPos = id;
1627} 1627}
1628 1628
1629 1629
1630void Konsole::configMenuSelected(int iD) 1630void Konsole::configMenuSelected(int iD)
1631{ 1631{
1632 // QString temp; 1632 // QString temp;
1633 // qDebug( temp.sprintf("configmenu %d",iD)); 1633 // qDebug( temp.sprintf("configmenu %d",iD));
1634 1634
1635 TEWidget* te = getTe(); 1635 TEWidget* te = getTe();
1636 Config cfg( "Konsole" ); 1636 Config cfg( "Konsole" );
1637 cfg.setGroup("Menubar"); 1637 cfg.setGroup("Menubar");
1638 if(iD == cm_wrap) 1638 if(iD == cm_wrap)
1639 { 1639 {
1640 cfg.setGroup("ScrollBar"); 1640 cfg.setGroup("ScrollBar");
1641 bool b=cfg.readBoolEntry("HorzScroll",0); 1641 bool b=cfg.readBoolEntry("HorzScroll",0);
1642 b=!b; 1642 b=!b;
1643 cfg.writeEntry("HorzScroll", b ); 1643 cfg.writeEntry("HorzScroll", b );
1644 cfg.write(); 1644 cfg.write();
1645 doWrap(); 1645 doWrap();
1646 if(cfg.readNumEntry("Position",2) == 0) 1646 if(cfg.readNumEntry("Position",2) == 0)
1647 { 1647 {
1648 te->setScrollbarLocation(1); 1648 te->setScrollbarLocation(1);
1649 } 1649 }
1650 else 1650 else
1651 { 1651 {
1652 te->setScrollbarLocation(0); 1652 te->setScrollbarLocation(0);
1653 } 1653 }
1654 te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 1654 te->setScrollbarLocation( cfg.readNumEntry("Position",2));
1655 } 1655 }
1656 if(iD == cm_beep) 1656 if(iD == cm_beep)
1657 { 1657 {
1658 cfg.setGroup("Menubar"); 1658 cfg.setGroup("Menubar");
1659 bool b=cfg.readBoolEntry("useBeep",0); 1659 bool b=cfg.readBoolEntry("useBeep",0);
1660 b=!b; 1660 b=!b;
1661 cfg.writeEntry("useBeep", b ); 1661 cfg.writeEntry("useBeep", b );
1662 cfg.write(); 1662 cfg.write();
1663 configMenu->setItemChecked(cm_beep,b); 1663 configMenu->setItemChecked(cm_beep,b);
1664 te->useBeep=b; 1664 te->useBeep=b;
1665 } 1665 }
1666} 1666}
1667 1667
1668void Konsole::changeCommand(const QString &text, int c) 1668void Konsole::changeCommand(const QString &text, int c)
1669{ 1669{
1670 Config cfg( "Konsole" ); 1670 Config cfg( "Konsole" );
1671 cfg.setGroup("Commands"); 1671 cfg.setGroup("Commands");
1672 if(commonCmds[c] != text) 1672 if(commonCmds[c] != text)
1673 { 1673 {
1674 cfg.writeEntry(QString::number(c),text); 1674 cfg.writeEntry(QString::number(c),text);
1675 commonCombo->clearEdit(); 1675 commonCombo->clearEdit();
1676 commonCombo->setCurrentItem(c); 1676 commonCombo->setCurrentItem(c);
1677 } 1677 }
1678} 1678}
1679 1679
1680void Konsole::setColor(int sess) 1680void Konsole::setColor(int sess)
1681{ 1681{
1682 Config cfg( "Konsole" ); 1682 Config cfg( "Konsole" );
1683 cfg.setGroup("Colors"); 1683 cfg.setGroup("Colors");
1684 QColor foreground, background; 1684 QColor foreground, background;
1685 QString ss = QString("Session") + QString::number(sess); 1685 QString ss = QString("Session") + QString::number(sess);
1686 foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, 1686 foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss,
1687 cfg.readNumEntry("foregroundRed",0xff)), 1687 cfg.readNumEntry("foregroundRed",0xff)),
1688 cfg.readNumEntry("foregroundGreen"+ss, 1688 cfg.readNumEntry("foregroundGreen"+ss,
1689 cfg.readNumEntry("foregroundGreen",0xff)), 1689 cfg.readNumEntry("foregroundGreen",0xff)),
1690 cfg.readNumEntry("foregroundBlue"+ss, 1690 cfg.readNumEntry("foregroundBlue"+ss,
1691 cfg.readNumEntry("foregroundBlue",0xff))); 1691 cfg.readNumEntry("foregroundBlue",0xff)));
1692 background.setRgb(cfg.readNumEntry("backgroundRed"+ss, 1692 background.setRgb(cfg.readNumEntry("backgroundRed"+ss,
1693 cfg.readNumEntry("backgroundRed",0)), 1693 cfg.readNumEntry("backgroundRed",0)),
1694 cfg.readNumEntry("backgroundGreen"+ss, 1694 cfg.readNumEntry("backgroundGreen"+ss,
1695 cfg.readNumEntry("backgroundGreen",0)), 1695 cfg.readNumEntry("backgroundGreen",0)),
1696 cfg.readNumEntry("backgroundBlue"+ss, 1696 cfg.readNumEntry("backgroundBlue"+ss,
1697 cfg.readNumEntry("backgroundBlue",0))); 1697 cfg.readNumEntry("backgroundBlue",0)));
1698 setColors(foreground, background); 1698 setColors(foreground, background);
1699} 1699}
1700 1700