-rw-r--r-- | core/apps/embeddedkonsole/TEHistory.cpp | 4 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/commandeditdialog.cpp | 2 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/core/apps/embeddedkonsole/TEHistory.cpp b/core/apps/embeddedkonsole/TEHistory.cpp index 2417af1..2e6535c 100644 --- a/core/apps/embeddedkonsole/TEHistory.cpp +++ b/core/apps/embeddedkonsole/TEHistory.cpp @@ -1,109 +1,109 @@ /* -------------------------------------------------------------------------- */ /* */ /* [TEHistory.C] History Buffer */ /* */ /* -------------------------------------------------------------------------- */ /* */ /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ /* */ -/* This file is part of Qkonsole - an X terminal for KDE */ +/* This file is part of Konsole - an X terminal for KDE */ /* */ /* -------------------------------------------------------------------------- */ /* */ -/* Ported Qkonsole to Qt/Embedded */ +/* Ported Konsole to Qt/Embedded */ /* */ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ /* */ /* -------------------------------------------------------------------------- */ #include "TEHistory.h" #include <stdlib.h> #include <assert.h> #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <errno.h> #include <qpe/config.h> #define HERE printf("%s(%d): here\n",__FILE__,__LINE__) /* An arbitrary long scroll. One can modify the scroll only by adding either cells or newlines, but access it randomly. The model is that of an arbitrary wide typewriter scroll in that the scroll is a serie of lines and each line is a serie of cells with no overwriting permitted. The implementation provides arbitrary length and numbers of cells and line/column indexed read access to the scroll at constant costs. */ HistoryScroll::HistoryScroll() { m_lines = NULL; m_max_lines = 0; m_cells = NULL; m_max_cells = 0; m_num_lines = 0; m_first_line = 0; m_last_cell = 0; m_start_line = 0; } HistoryScroll::~HistoryScroll() { setSize(0,0); } void HistoryScroll::setSize(int lines, int cells) { // could try to preserve the existing data... // printf("setSize(%d,%d)\n", lines, cells); if (m_lines) { delete m_lines; m_lines = NULL; } if (m_cells) { delete m_cells; m_cells = NULL; } m_max_lines = m_max_cells = 0; if (lines > 0 && cells > 0) { m_max_lines = lines; m_lines = new int[m_max_lines]; m_lines[0] = 0; m_max_cells = cells; m_cells = new ca[m_max_cells]; } m_first_line = 0; m_num_lines = 0; m_last_cell = 0; m_start_line = 0; } void HistoryScroll::setScroll(bool on) { Config cfg( "Konsole" ); cfg.setGroup("History"); // printf("setScroll(%d)\n", on); if (on) { int lines = cfg.readNumEntry("history_lines",300); int avg_line = cfg.readNumEntry("avg_line_length",60); int cells = lines * avg_line; setSize(lines,cells); } else { setSize(0,0); } } bool HistoryScroll::hasScroll() { return (m_max_lines > 0); } diff --git a/core/apps/embeddedkonsole/commandeditdialog.cpp b/core/apps/embeddedkonsole/commandeditdialog.cpp index b23db18..e4255f3 100644 --- a/core/apps/embeddedkonsole/commandeditdialog.cpp +++ b/core/apps/embeddedkonsole/commandeditdialog.cpp @@ -59,141 +59,141 @@ CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags f m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); m_SuggestedCommandList->sort(); connect( m_SuggestedCommandList, SIGNAL( clicked( QListViewItem * ) ), m_PlayListSelection, SLOT( addToSelection( QListViewItem *) ) ); ToolButton1->setTextLabel("new"); ToolButton1->setPixmap(Resource::loadPixmap("new")); ToolButton1->setAutoRaise(TRUE); ToolButton1->setFocusPolicy(QWidget::NoFocus); connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); ToolButton2->setTextLabel("edit"); ToolButton2->setPixmap(Resource::loadPixmap("edit")); ToolButton2->setAutoRaise(TRUE); ToolButton2->setFocusPolicy(QWidget::NoFocus); connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); ToolButton3->setTextLabel("delete"); ToolButton3->setPixmap(Resource::loadPixmap("editdelete")); ToolButton3->setAutoRaise(TRUE); ToolButton3->setFocusPolicy(QWidget::NoFocus); connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); ToolButton4->setTextLabel("up"); ToolButton4->setPixmap(Resource::loadPixmap("up")); ToolButton4->setAutoRaise(TRUE); ToolButton4->setFocusPolicy(QWidget::NoFocus); connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); ToolButton5->setTextLabel("down"); ToolButton5->setPixmap(Resource::loadPixmap("down")); ToolButton5->setAutoRaise(TRUE); ToolButton5->setFocusPolicy(QWidget::NoFocus); connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); QListViewItem *current = m_SuggestedCommandList->selectedItem(); if ( current ) item->moveItem( current ); m_SuggestedCommandList->setSelected( item, TRUE ); m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); Config cfg( "Konsole" ); cfg.setGroup("Commands"); if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { for (int i = 0; i < 100; i++) { QString tmp; tmp = cfg.readEntry( QString::number(i),""); if (!tmp.isEmpty()) m_PlayListSelection->addStringToSelection(tmp); } } else { m_PlayListSelection->addStringToSelection("ls "); m_PlayListSelection->addStringToSelection("cardctl eject"); m_PlayListSelection->addStringToSelection("cat "); m_PlayListSelection->addStringToSelection("cd "); m_PlayListSelection->addStringToSelection("chmod "); m_PlayListSelection->addStringToSelection("cp "); m_PlayListSelection->addStringToSelection("dc "); m_PlayListSelection->addStringToSelection("df "); m_PlayListSelection->addStringToSelection("dmesg"); m_PlayListSelection->addStringToSelection("echo "); m_PlayListSelection->addStringToSelection("env"); m_PlayListSelection->addStringToSelection("find "); m_PlayListSelection->addStringToSelection("free"); m_PlayListSelection->addStringToSelection("grep "); m_PlayListSelection->addStringToSelection("ifconfig "); m_PlayListSelection->addStringToSelection("ipkg "); m_PlayListSelection->addStringToSelection("mkdir "); m_PlayListSelection->addStringToSelection("mv "); m_PlayListSelection->addStringToSelection("nc localhost 7776"); m_PlayListSelection->addStringToSelection("nc localhost 7777"); m_PlayListSelection->addStringToSelection("nslookup "); m_PlayListSelection->addStringToSelection("ping "); m_PlayListSelection->addStringToSelection("ps aux"); m_PlayListSelection->addStringToSelection("pwd "); m_PlayListSelection->addStringToSelection("rm "); m_PlayListSelection->addStringToSelection("rmdir "); m_PlayListSelection->addStringToSelection("route "); m_PlayListSelection->addStringToSelection("set "); m_PlayListSelection->addStringToSelection("traceroute"); } } CommandEditDialog::~CommandEditDialog() { } void CommandEditDialog::accept() { int i = 0; - Config *cfg = new Config("Qkonsole"); + Config *cfg = new Config("Konsole"); cfg->setGroup("Commands"); cfg->clearGroup(); QListViewItemIterator it( m_PlayListSelection ); for ( ; it.current(); ++it ) { // qDebug(it.current()->text(0)); cfg->writeEntry(QString::number(i),it.current()->text(0)); i++; } cfg->writeEntry("Commands Set","TRUE"); // qDebug("CommandEditDialog::accept() - written"); delete cfg; emit commandsEdited(); close(); } void CommandEditDialog::showEditDialog() { editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); d->setCaption("Edit command"); d->TextLabel->setText("Edit command:"); d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); int i = d->exec(); if ((i==1) && (!(d->commandEdit->text()).isEmpty())) m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); } void CommandEditDialog::showAddDialog() { editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); int i = d->exec(); if ((i==1) && (!(d->commandEdit->text()).isEmpty())) m_PlayListSelection->addStringToSelection(d->commandEdit->text()); } diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 3289a04..7812e4c 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp @@ -276,193 +276,193 @@ void Konsole::initCommandList() // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); if (histfile.open( IO_ReadOnly )) { QString line; uint i; HistoryList items; int lineno = 0; while(!histfile.atEnd()) { if (histfile.readLine(line, 200) < 0) { break; } line = line.left(line.length()-1); lineno++; for(i=0; i<items.count(); i++) { if (line == items.at(i)->line) { // weight recent commands & repeated commands more // by adding up the index of each command items.at(i)->count += lineno; break; } } if (i >= items.count()) { items.append(new HistoryItem(lineno, line)); } } items.sort(); int n = items.count(); if (n > 40) { n = 40; } for(int i=0; i<n; i++) { // should insert start of command, but keep whole thing if (items.at(items.count()-i-1)->line.length() < 30) { commonCombo->insertItem(items.at(items.count()-i-1)->line); } } histfile.close(); } } if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { for (int i = 0; commonCmds[i] != NULL; i++) { commonCombo->insertItem(commonCmds[i]); } } else { for (int i = 0; i < 100; i++) { if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); } } } static void sig_handler(int x) { printf("got signal %d\n",x); } void Konsole::init(const char* _pgm, QStrList & _args) { #if 0 for(int i=1; i<=31; i++) { if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV && i != SIGINT && i != SIGILL && i != SIGTERM && i != SIGBUS) signal(i,sig_handler); } #endif signal(SIGSTOP, sig_handler); signal(SIGCONT, sig_handler); signal(SIGTSTP, sig_handler); b_scroll = TRUE; // histon; n_keytab = 0; n_render = 0; startUp=0; fromMenu = FALSE; fullscreen = false; - setCaption( "Qkonsole" ); + setCaption( "Konsole" ); setIcon( Resource::loadPixmap( "qkonsole/qkonsole" ) ); Config cfg( "Konsole" ); cfg.setGroup("Font"); QString tmp; // initialize the list of allowed fonts /////////////////////////////////// QString cfgFontName = cfg.readEntry("FontName","Lcfont"); int cfgFontSize = cfg.readNumEntry("FontSize",18); cfont = -1; // this code causes repeated access to all the font files // which does slow down startup QFontDatabase fontDB; QStringList familyNames; familyNames = fontDB.families( FALSE ); QString s; int fontIndex = 0; int familyNum = 0; fontList = new QPopupMenu( this ); for(uint j = 0; j < (uint)familyNames.count(); j++) { s = familyNames[j]; if ( s.contains('-') ) { int i = s.find('-'); s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; } s[0] = s[0].upper(); QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), sizes.count()); if (sizes.count() > 0) { QPopupMenu *sizeMenu; QFont f; int last_width = -1; sizeMenu = NULL; for(uint i = 0; i < (uint)sizes.count() + 4; i++) { // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); // need to divide by 10 on the Z, but not otherwise int size; if (i >= (uint)sizes.count()) { // try for expandable fonts size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); } else { printf("sizes[%d] = %d\n", i, sizes[i]); size = sizes[i]; } #ifndef __i386__ // a hack, sizes on Z seem to be points*10 size /= 10; #endif f = QFont(familyNames[j], size); f.setFixedPitch(true); QFontMetrics fm(f); // don't trust f.fixedPitch() or f.exactMatch(), they lie!! if (fm.width("l") == fm.width("m") && (i < (uint)sizes.count() || fm.width("m") > last_width)) { if (i < (uint)sizes.count()) { last_width = fm.width("m"); } if (sizeMenu == NULL) { sizeMenu = new QPopupMenu(); } int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); sizeMenu->setItemParameter(id, fontIndex); sizeMenu->connectItem(id, this, SLOT(setFont(int))); QString name = s + " " + QString::number(size); fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); if (familyNames[j] == cfgFontName && size == cfgFontSize) { cfont = fontIndex; } printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); fontIndex++; } } if (sizeMenu) @@ -1220,193 +1220,193 @@ void Konsole::newSession() TEWidget* Konsole::getTe() { if (nsessions) { return (TEWidget *) tab->currentPage(); } else { return 0; } } void Konsole::sessionListSelected(int id) { if (id < 0) { return; } QString selected = sessionList->text(id); EKNumTabBar *tabBar = tab->getTabBar(); int n = 0; for(int i = 0; n < tabBar->count(); i++) { if (tabBar->tab(i)) { // printf("selected = %s tab %d = %s\n", selected.latin1(), // i, tabBar->tab(i)->text().latin1()); if (tabBar->tab(i)->text() == selected) { tab->setCurrentPage(i); break; } n++; } } } void Konsole::changeSession(int delta) { printf("delta session %d\n", delta); QTabBar *tabBar = tab->getTabBar(); int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; i += delta; if (i < 0) i += tabBar->count(); if (i >= tabBar->count()) i -= tabBar->count(); QString selected = QString::number(i+1); int n = 0; for(int i = 0; n < tabBar->count(); i++) { if (tabBar->tab(i)) { printf("selected = %s tab %d = %s\n", selected.latin1(), i, tabBar->tab(i)->text().latin1()); if (tabBar->tab(i)->text() == selected) { tab->setCurrentPage(i); break; } n++; } } } void Konsole::switchSession(QWidget* w) { TEWidget* te = (TEWidget *) w; QFont teFnt = te->getVTFont(); int familyNum = -1; for(uint i = 0; i < fonts.count(); i++) { VTFont *fnt = fonts.at(i); bool cf = fnt->getFont() == teFnt; fontList->setItemChecked(i, cf); if (cf) { cfont = i; familyNum = fnt->getFamilyNum(); } } for(int i = 0; i < (int)fontList->count(); i++) { fontList->setItemChecked(i + 1000, i == familyNum); } if (! te->currentSession->Title().isEmpty() ) { setCaption(te->currentSession->Title() + " - QKonsole"); } else { - setCaption( "Qkonsole" ); + setCaption( "Konsole" ); } // colorMenuSelected(te->color_menu_item); } void Konsole::toggleFullScreen() { setFullScreen(! fullscreen); } void Konsole::setFullScreen ( bool b ) { static QSize normalsize; static bool listHidden; if (b == fullscreen) { return; } fullscreen = b; if ( b ) { if ( !normalsize. isValid ( )) { normalsize = size ( ); } setFixedSize ( qApp-> desktop ( )-> size ( )); showNormal ( ); reparent ( 0, WStyle_Customize | WStyle_NoBorder, QPoint ( 0, 0 )); showFullScreen ( ); menuToolBar->hide(); toolBar->hide(); listHidden = secondToolBar->isHidden(); secondToolBar->hide(); // commonCombo->hide(); tab->getTabBar()->hide(); tab->setMargin(tab->margin()); if (show_fullscreen_msg) { fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, qApp->desktop()->height()/16 - fullscreen_msg->height()/2); fullscreen_msg->show(); fullscreen_timer->start(3000, true); show_fullscreen_msg = false; } } else { showNormal ( ); reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); resize ( normalsize ); showMaximized ( ); normalsize = QSize ( ); menuToolBar->show(); toolBar->show(); if(! listHidden) { secondToolBar->show(); } // commonCombo->show(); menuToolBar->show(); if (tabPos != tm_hidden) { tab->getTabBar()->show(); } } tab->setMargin(tab->margin()); // cause setup to run } void Konsole::fullscreenTimeout() { fullscreen_msg->hide(); } void Konsole::colorMenuIsSelected(int iD) { fromMenu = TRUE; colorMenuSelected(iD); } /// ------------------------------- some new stuff by L.J. Potter void Konsole::colorMenuSelected(int iD) { // this is NOT pretty, elegant or anything else besides functional // QString temp; // qDebug( temp.sprintf("colormenu %d", iD)); |