summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -1,88 +1,94 @@
/* ---------------------------------------------------------------------- */
/* */
/* [main.C] Konsole */
/* */
/* ---------------------------------------------------------------------- */
/* */
/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
/* */
/* This file is part of Konsole, an X terminal. */
/* */
/* The material contained in here more or less directly orginates from */
/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
/* */
/* ---------------------------------------------------------------------- */
/* */
/* Ported Konsole to Qt/Embedded */
/* */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
/* */
/* -------------------------------------------------------------------------- */
// enhancements added by L.J. Potter <ljp@llornkcor.com>
-#define QT_QWS_OPIE
+//#define QT_QWS_OPIE
+
+#include "signal.h"
#include <qpe/resource.h>
#include <qdir.h>
#include <qevent.h>
#include <qdragobject.h>
#include <qobjectlist.h>
#include <qtoolbutton.h>
#include <qtoolbar.h>
#include <qpushbutton.h>
#include <qfontdialog.h>
#include <qglobal.h>
#include <qpainter.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qaction.h>
#include <qapplication.h>
#include <qfontmetrics.h>
#include <qcombobox.h>
#include <qevent.h>
#include <qtabwidget.h>
#include <qtabbar.h>
#include <qpe/config.h>
#include <qstringlist.h>
#include <qpalette.h>
#include <unistd.h>
#include <pwd.h>
#include <sys/types.h>
-#include <sys/wait.h>
+//#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "konsole.h"
#include "keytrans.h"
#include "commandeditdialog.h"
#ifdef QT_QWS_OPIE
#include <opie/colorpopupmenu.h>
#endif
+#include <qfontdatabase.h> // U.B.
+#include <qstringlist.h> // U.B.
+#include <qvaluelist.h> // U.B.
+
class EKNumTabBar : public QTabBar {
public:
void numberTabs()
{
// Yes, it really is this messy. QTabWidget needs functions
// that provide acces to tabs in a sequential way.
int m=INT_MIN;
for (int i=0; i<count(); i++) {
QTab* left=0;
QListIterator<QTab> it(*tabList());
int x=INT_MAX;
for( QTab* t; (t=it.current()); ++it ) {
int tx = t->rect().x();
if ( tx<x && tx>m ) {
x = tx;
left = t;
}
}
if ( left ) {
left->setText(QString::number(i+1));
m = left->rect().x();
}
}
}
@@ -157,162 +163,228 @@ static const char *commonCmds[] =
"dmesg",
"fuser",
"hostname",
"kill",
"killall",
"ln",
"ping",
"mount",
"more",
"sort",
"touch",
"umount",
"mknod",
"netstat",
*/
"exit",
NULL
};
static void konsoleInit(const char** shell) {
if(setuid(getuid()) !=0) qDebug("setuid failed");
if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges
-
+// signal (SIGSTOP, SIG_IGN);
+
// QPEApplication::grabKeyboard(); // for CTRL and ALT
- qDebug("keyboard grabbed");
+// qDebug("keyboard grabbed");
#ifdef FAKE_CTRL_AND_ALT
qDebug("Fake Ctrl and Alt defined");
QPEApplication::grabKeyboard(); // for CTRL and ALT
#endif
*shell = getenv("SHELL");
- qWarning("SHell initially is %s", *shell );
+// qWarning("SHell initially is %s", *shell );
if (shell == NULL || *shell == '\0') {
struct passwd *ent = 0;
uid_t me = getuid();
*shell = "/bin/sh";
while ( (ent = getpwent()) != 0 ) {
if (ent->pw_uid == me) {
if (ent->pw_shell != "")
*shell = ent->pw_shell;
break;
}
}
endpwent();
}
- qWarning("SHELL now is %s", *shell );
+// qWarning("SHELL now is %s", *shell );
if( putenv((char*)"COLORTERM=") !=0)
qDebug("putenv failed"); // to trigger mc's color detection
}
Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
QMainWindow(parent, name, fl)
{
QStrList tmp; const char* shell;
setCaption( tr("Terminal") );
konsoleInit( &shell);
- qWarning("Using shell %s", shell);
+// qWarning("Using shell %s", shell);
init(shell,tmp);
}
void Konsole::initCommandList()
{
// qDebug("Konsole::initCommandList");
Config cfg("Konsole");
cfg.setGroup("Commands");
commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
commonCombo->clear();
if (cfg.readEntry("Commands Set","FALSE") == "FALSE") {
for (int i = 0; commonCmds[i] != NULL; i++) {
commonCombo->insertItem(commonCmds[i],i);
}
} else {
for (int i = 0; i < 100; i++) {
if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
commonCombo->insertItem((cfg.readEntry( QString::number(i),"")));
}
}
}
void Konsole::init(const char* _pgm, QStrList & _args)
{
b_scroll = TRUE; // histon;
n_keytab = 0;
n_render = 0;
startUp=0;
fromMenu = FALSE;
setCaption( tr("Terminal") );
setIcon( Resource::loadPixmap( "konsole" ) );
Config cfg("Konsole");
cfg.setGroup("Konsole");
QString tmp;
// initialize the list of allowed fonts ///////////////////////////////////
cfont = cfg.readNumEntry("FontID", 1);
+
QFont f = QFont("Micro", 4, QFont::Normal);
f.setFixedPitch(TRUE);
fonts.append(new VTFont(tr("Micro"), f));
f = QFont("Fixed", 7, QFont::Normal);
f.setFixedPitch(TRUE);
fonts.append(new VTFont(tr("Small Fixed"), f));
f = QFont("Fixed", 12, QFont::Normal);
f.setFixedPitch(TRUE);
fonts.append(new VTFont(tr("Medium Fixed"), f));
- // create terminal emulation framework ////////////////////////////////////
+// NEW STUFF
+
+ QStringList ignfont = cfg.readListEntry("IgnFont", ',');
+ /* If there is no "IgnFont = ..." entry in "myonsole.conf",
+ * put some Japanese fonts of the SL-C7x0 to "ignfont". */
+
+ if (ignfont.isEmpty()) {
+ ignfont = QStringList::split (',',"jisupasp,mmkjg1,mmkjg4,mmkjg5");
+ }
+
+// QFont
+ f = QFont("Fixed", 16, QFont::Normal);
+ f.setFixedPitch(true);
+ fonts.append(new VTFont(tr("Default"), f));
+
+ int fcount = 1;
+
+ f.setCharSet(QFont::AnyCharSet);
+ f.setStyleHint(QFont::TypeWriter, QFont::PreferMatch);
+// f.setWeight(QFont::Normal);
+
+ /*
+ * Look for installed font families. If the family is not in
+ * the "ignfont" list, look for available sizes.
+ * If it is fixed pitch font, put the font and the size
+ * to the fontlist.
+ */
+ QFontDatabase fdb;
+ QStringList ff = fdb.families(false);
+
+ for (QStringList::Iterator it = ff.begin(); it != ff.end(); ++it ) {
+ QString fit = *it;
+
+ if( fit != "fixed" && fit != "micro" ) {
+ if ( ignfont.contains(*it) == 0) {
+ QValueList<int> pt = fdb.pointSizes(*it);
+
+ for (QValueList<int>::Iterator itv = pt.begin();
+ itv != pt.end(); ++itv ) {
+ int size = (*itv)/10;
+ if(size > 0) {
+ f.setFamily(*it);
+ f.setPointSize(size);
+ }
+
+ QFontMetrics fm(f);
+
+//qDebug("%s %d:\twidth('i')=%d, width('w')=%d", (*it).latin1(), (*itv)/10, fm.width('i'), fm.width('w'));
+
+ if (fm.width('i') == fm.width('w') ) {
+ qDebug((*it));
+ f.setFixedPitch(true);
+ fonts.append(new VTFont(*it + ' ' + QString::number(size), f));
+ fcount++;
+ }
+ }
+ }
+ }
+ }
+
+// END NEW STUFF
+
+
+// create terminal emulation framework ////////////////////////////////////
nsessions = 0;
tab = new EKNumTabWidget(this);
connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
// create terminal toolbar ////////////////////////////////////////////////
setToolBarsMovable( FALSE );
QToolBar *menuToolBar = new QToolBar( this );
menuToolBar->setHorizontalStretchable( TRUE );
QMenuBar *menuBar = new QMenuBar( menuToolBar );
fontList = new QPopupMenu( this );
for(uint i = 0; i < fonts.count(); i++) {
VTFont *fnt = fonts.at(i);
fontList->insertItem(fnt->getName(), i);
}
+
fontChanged(cfont);
configMenu = new QPopupMenu( this);
colorMenu = new QPopupMenu( this);
scrollMenu = new QPopupMenu( this);
editCommandListMenu = new QPopupMenu( this);
configMenu->insertItem(tr("Command List"), editCommandListMenu);
bool listHidden;
cfg.setGroup("Menubar");
if( cfg.readEntry("Hidden","FALSE") == "TRUE") {
editCommandListMenu->insertItem( tr( "Show command list" ));
listHidden=TRUE;
} else {
editCommandListMenu->insertItem( tr( "Hide command list" ));
listHidden=FALSE;
}
cfg.setGroup("Tabs");
tmp=cfg.readEntry("Position","Bottom");
if(tmp=="Top") {
tab->setTabPosition(QTabWidget::Top);
configMenu->insertItem( tr( "Tabs on Bottom" ) );
@@ -604,55 +676,56 @@ void Konsole::setFont(int fontno)
f = defaultFont = QFont( "Helvetica", 12 );
else
if (fonts[fontno][0] == '-')
f.setRawName( fonts[fontno] );
else
{
f.setFamily(fonts[fontno]);
f.setRawMode( TRUE );
}
if ( !f.exactMatch() && fontno != 0)
{
QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]);
QMessageBox(this, msg);
return;
}
if (se) se->setFontNo(fontno);
te->setVTFont(f);
n_font = fontno;
}
*/
// --| color selection |-------------------------------------------------------
void Konsole::changeColumns(int columns)
-{ //FIXME this seems to cause silliness when reset command is executed
-// qDebug("change columns");
-// TEWidget* te = getTe();
-// if (te != 0) {
-// setColLin(columns,te->Lines());
-// te->update();
-// }
+{
+ //FIXME this seems to cause silliness when reset command is executed
+// qDebug("change columns");
+// TEWidget* te = getTe();
+// if (te != 0) {
+// setColLin(columns,te->Lines());
+// te->update();
+// }
}
//FIXME: If a child dies during session swap,
// this routine might be called before
// session swap is completed.
void Konsole::doneSession(TESession*, int )
{
TEWidget *te = getTe();
if (te != 0) {
te->currentSession->setConnect(FALSE);
tab->removeTab(te);
delete te->currentSession;
delete te;
nsessions--;
}
if (nsessions == 0) {
close();
}
}
void Konsole::newSession() {
if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory?