summaryrefslogtreecommitdiff
path: root/core/apps/embeddedkonsole
Unidiff
Diffstat (limited to 'core/apps/embeddedkonsole') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp87
1 files changed, 80 insertions, 7 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index fff2f68..a5adc03 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -16,13 +16,15 @@
16/* Ported Konsole to Qt/Embedded */ 16/* Ported Konsole to Qt/Embedded */
17/* */ 17/* */
18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
19/* */ 19/* */
20/* -------------------------------------------------------------------------- */ 20/* -------------------------------------------------------------------------- */
21// enhancements added by L.J. Potter <ljp@llornkcor.com> 21// enhancements added by L.J. Potter <ljp@llornkcor.com>
22#define QT_QWS_OPIE 22//#define QT_QWS_OPIE
23
24#include "signal.h"
23 25
24#include <qpe/resource.h> 26#include <qpe/resource.h>
25 27
26#include <qdir.h> 28#include <qdir.h>
27#include <qevent.h> 29#include <qevent.h>
28#include <qdragobject.h> 30#include <qdragobject.h>
@@ -46,25 +48,29 @@
46#include <qstringlist.h> 48#include <qstringlist.h>
47#include <qpalette.h> 49#include <qpalette.h>
48 50
49#include <unistd.h> 51#include <unistd.h>
50#include <pwd.h> 52#include <pwd.h>
51#include <sys/types.h> 53#include <sys/types.h>
52#include <sys/wait.h> 54//#include <sys/wait.h>
53#include <stdio.h> 55#include <stdio.h>
54#include <stdlib.h> 56#include <stdlib.h>
55#include <assert.h> 57#include <assert.h>
56 58
57#include "konsole.h" 59#include "konsole.h"
58#include "keytrans.h" 60#include "keytrans.h"
59#include "commandeditdialog.h" 61#include "commandeditdialog.h"
60 62
61#ifdef QT_QWS_OPIE 63#ifdef QT_QWS_OPIE
62#include <opie/colorpopupmenu.h> 64#include <opie/colorpopupmenu.h>
63#endif 65#endif
64 66
67 #include <qfontdatabase.h>// U.B.
68 #include <qstringlist.h>// U.B.
69 #include <qvaluelist.h> // U.B.
70
65class EKNumTabBar : public QTabBar { 71class EKNumTabBar : public QTabBar {
66public: 72public:
67 void numberTabs() 73 void numberTabs()
68 { 74 {
69 // Yes, it really is this messy. QTabWidget needs functions 75 // Yes, it really is this messy. QTabWidget needs functions
70 // that provide acces to tabs in a sequential way. 76 // that provide acces to tabs in a sequential way.
@@ -175,23 +181,24 @@ static const char *commonCmds[] =
175}; 181};
176 182
177static void konsoleInit(const char** shell) { 183static void konsoleInit(const char** shell) {
178 if(setuid(getuid()) !=0) qDebug("setuid failed"); 184 if(setuid(getuid()) !=0) qDebug("setuid failed");
179 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges 185 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges
180 186
187 // signal (SIGSTOP, SIG_IGN);
181 188
182// QPEApplication::grabKeyboard(); // for CTRL and ALT 189// QPEApplication::grabKeyboard(); // for CTRL and ALT
183 190
184 qDebug("keyboard grabbed"); 191// qDebug("keyboard grabbed");
185#ifdef FAKE_CTRL_AND_ALT 192#ifdef FAKE_CTRL_AND_ALT
186 qDebug("Fake Ctrl and Alt defined"); 193 qDebug("Fake Ctrl and Alt defined");
187 QPEApplication::grabKeyboard(); // for CTRL and ALT 194 QPEApplication::grabKeyboard(); // for CTRL and ALT
188#endif 195#endif
189 196
190 *shell = getenv("SHELL"); 197 *shell = getenv("SHELL");
191 qWarning("SHell initially is %s", *shell ); 198// qWarning("SHell initially is %s", *shell );
192 199
193 if (shell == NULL || *shell == '\0') { 200 if (shell == NULL || *shell == '\0') {
194 struct passwd *ent = 0; 201 struct passwd *ent = 0;
195 uid_t me = getuid(); 202 uid_t me = getuid();
196 *shell = "/bin/sh"; 203 *shell = "/bin/sh";
197 204
@@ -202,13 +209,13 @@ static void konsoleInit(const char** shell) {
202 break; 209 break;
203 } 210 }
204 } 211 }
205 endpwent(); 212 endpwent();
206 } 213 }
207 214
208 qWarning("SHELL now is %s", *shell ); 215// qWarning("SHELL now is %s", *shell );
209 216
210 if( putenv((char*)"COLORTERM=") !=0) 217 if( putenv((char*)"COLORTERM=") !=0)
211 qDebug("putenv failed"); // to trigger mc's color detection 218 qDebug("putenv failed"); // to trigger mc's color detection
212} 219}
213 220
214Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 221Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
@@ -216,13 +223,13 @@ Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
216{ 223{
217 QStrList tmp; const char* shell; 224 QStrList tmp; const char* shell;
218 225
219 setCaption( tr("Terminal") ); 226 setCaption( tr("Terminal") );
220 227
221 konsoleInit( &shell); 228 konsoleInit( &shell);
222 qWarning("Using shell %s", shell); 229// qWarning("Using shell %s", shell);
223 init(shell,tmp); 230 init(shell,tmp);
224} 231}
225 232
226 233
227 234
228void Konsole::initCommandList() 235void Konsole::initCommandList()
@@ -258,24 +265,88 @@ void Konsole::init(const char* _pgm, QStrList & _args)
258 265
259 Config cfg("Konsole"); 266 Config cfg("Konsole");
260 cfg.setGroup("Konsole"); 267 cfg.setGroup("Konsole");
261 QString tmp; 268 QString tmp;
262 // initialize the list of allowed fonts /////////////////////////////////// 269 // initialize the list of allowed fonts ///////////////////////////////////
263 cfont = cfg.readNumEntry("FontID", 1); 270 cfont = cfg.readNumEntry("FontID", 1);
271
264 QFont f = QFont("Micro", 4, QFont::Normal); 272 QFont f = QFont("Micro", 4, QFont::Normal);
265 f.setFixedPitch(TRUE); 273 f.setFixedPitch(TRUE);
266 fonts.append(new VTFont(tr("Micro"), f)); 274 fonts.append(new VTFont(tr("Micro"), f));
267 275
268 f = QFont("Fixed", 7, QFont::Normal); 276 f = QFont("Fixed", 7, QFont::Normal);
269 f.setFixedPitch(TRUE); 277 f.setFixedPitch(TRUE);
270 fonts.append(new VTFont(tr("Small Fixed"), f)); 278 fonts.append(new VTFont(tr("Small Fixed"), f));
271 279
272 f = QFont("Fixed", 12, QFont::Normal); 280 f = QFont("Fixed", 12, QFont::Normal);
273 f.setFixedPitch(TRUE); 281 f.setFixedPitch(TRUE);
274 fonts.append(new VTFont(tr("Medium Fixed"), f)); 282 fonts.append(new VTFont(tr("Medium Fixed"), f));
275 283
284// NEW STUFF
285
286 QStringList ignfont = cfg.readListEntry("IgnFont", ',');
287 /* If there is no "IgnFont = ..." entry in "myonsole.conf",
288 * put some Japanese fonts of the SL-C7x0 to "ignfont". */
289
290 if (ignfont.isEmpty()) {
291 ignfont = QStringList::split (',',"jisupasp,mmkjg1,mmkjg4,mmkjg5");
292 }
293
294 //QFont
295 f = QFont("Fixed", 16, QFont::Normal);
296 f.setFixedPitch(true);
297 fonts.append(new VTFont(tr("Default"), f));
298
299 int fcount = 1;
300
301 f.setCharSet(QFont::AnyCharSet);
302 f.setStyleHint(QFont::TypeWriter, QFont::PreferMatch);
303// f.setWeight(QFont::Normal);
304
305 /*
306 * Look for installed font families. If the family is not in
307 * the "ignfont" list, look for available sizes.
308 * If it is fixed pitch font, put the font and the size
309 * to the fontlist.
310 */
311 QFontDatabase fdb;
312 QStringList ff = fdb.families(false);
313
314 for (QStringList::Iterator it = ff.begin(); it != ff.end(); ++it ) {
315 QString fit = *it;
316
317 if( fit != "fixed" && fit != "micro" ) {
318 if ( ignfont.contains(*it) == 0) {
319 QValueList<int> pt = fdb.pointSizes(*it);
320
321 for (QValueList<int>::Iterator itv = pt.begin();
322 itv != pt.end(); ++itv ) {
323 int size = (*itv)/10;
324 if(size > 0) {
325 f.setFamily(*it);
326 f.setPointSize(size);
327 }
328
329 QFontMetrics fm(f);
330
331//qDebug("%s %d:\twidth('i')=%d, width('w')=%d", (*it).latin1(), (*itv)/10, fm.width('i'), fm.width('w'));
332
333 if (fm.width('i') == fm.width('w') ) {
334 qDebug((*it));
335 f.setFixedPitch(true);
336 fonts.append(new VTFont(*it + ' ' + QString::number(size), f));
337 fcount++;
338 }
339 }
340 }
341 }
342 }
343
344// END NEW STUFF
345
346
276 // create terminal emulation framework //////////////////////////////////// 347 // create terminal emulation framework ////////////////////////////////////
277 nsessions = 0; 348 nsessions = 0;
278 349
279 tab = new EKNumTabWidget(this); 350 tab = new EKNumTabWidget(this);
280 351
281 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 352 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
@@ -289,12 +360,13 @@ void Konsole::init(const char* _pgm, QStrList & _args)
289 360
290 fontList = new QPopupMenu( this ); 361 fontList = new QPopupMenu( this );
291 for(uint i = 0; i < fonts.count(); i++) { 362 for(uint i = 0; i < fonts.count(); i++) {
292 VTFont *fnt = fonts.at(i); 363 VTFont *fnt = fonts.at(i);
293 fontList->insertItem(fnt->getName(), i); 364 fontList->insertItem(fnt->getName(), i);
294 } 365 }
366
295 fontChanged(cfont); 367 fontChanged(cfont);
296 368
297 configMenu = new QPopupMenu( this); 369 configMenu = new QPopupMenu( this);
298 colorMenu = new QPopupMenu( this); 370 colorMenu = new QPopupMenu( this);
299 scrollMenu = new QPopupMenu( this); 371 scrollMenu = new QPopupMenu( this);
300 editCommandListMenu = new QPopupMenu( this); 372 editCommandListMenu = new QPopupMenu( this);
@@ -622,13 +694,14 @@ void Konsole::setFont(int fontno)
622} 694}
623*/ 695*/
624 696
625// --| color selection |------------------------------------------------------- 697// --| color selection |-------------------------------------------------------
626 698
627void Konsole::changeColumns(int columns) 699void Konsole::changeColumns(int columns)
628{ //FIXME this seems to cause silliness when reset command is executed 700{
701 //FIXME this seems to cause silliness when reset command is executed
629// qDebug("change columns"); 702// qDebug("change columns");
630// TEWidget* te = getTe(); 703// TEWidget* te = getTe();
631// if (te != 0) { 704// if (te != 0) {
632// setColLin(columns,te->Lines()); 705// setColLin(columns,te->Lines());
633// te->update(); 706// te->update();
634// } 707// }