summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp103
1 files changed, 88 insertions, 15 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
@@ -18,9 +18,11 @@
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>
@@ -48,9 +50,9 @@
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
@@ -61,8 +63,12 @@
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 {
@@ -177,19 +183,20 @@ static const char *commonCmds[] =
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
181 187 // signal (SIGSTOP, SIG_IGN);
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();
@@ -204,9 +211,9 @@ static void konsoleInit(const char** shell) {
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}
@@ -218,9 +225,9 @@ Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
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
@@ -260,8 +267,9 @@ void Konsole::init(const char* _pgm, QStrList & _args)
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
@@ -272,9 +280,72 @@ void Konsole::init(const char* _pgm, QStrList & _args)
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
276 // create terminal emulation framework //////////////////////////////////// 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
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
@@ -291,8 +362,9 @@ void Konsole::init(const char* _pgm, QStrList & _args)
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);
@@ -624,15 +696,16 @@ void Konsole::setFont(int fontno)
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{
629// qDebug("change columns"); 701 //FIXME this seems to cause silliness when reset command is executed
630// TEWidget* te = getTe(); 702 // qDebug("change columns");
631// if (te != 0) { 703 // TEWidget* te = getTe();
632// setColLin(columns,te->Lines()); 704 // if (te != 0) {
633// te->update(); 705 // setColLin(columns,te->Lines());
634// } 706 // te->update();
707 // }
635} 708}
636 709
637//FIXME: If a child dies during session swap, 710//FIXME: If a child dies during session swap,
638// this routine might be called before 711// this routine might be called before