-rw-r--r-- | noncore/apps/opie-console/TEScreen.cpp | 17 | ||||
-rw-r--r-- | noncore/apps/opie-console/TEScreen.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/TEmulation.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/TEmulation.h | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 35 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.cpp | 25 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.h | 11 |
10 files changed, 64 insertions, 42 deletions
diff --git a/noncore/apps/opie-console/TEScreen.cpp b/noncore/apps/opie-console/TEScreen.cpp index a3d115d..2675d31 100644 --- a/noncore/apps/opie-console/TEScreen.cpp +++ b/noncore/apps/opie-console/TEScreen.cpp @@ -980,17 +980,17 @@ void TEScreen::setSelExtentXY(const int x, const int y) sel_TL = sel_begin; sel_BR = l; } } QString TEScreen::getSelText(const BOOL preserve_line_breaks) { - if (sel_begin == -1) + if (sel_begin == -1) return QString::null; // Selection got clear while selecting. int *m; // buffer to fill. int s, d; // source index, dest. index. int hist_BR = loc(0, hist.getLines()); int hY = sel_TL / columns; int hX = sel_TL % columns; int eol; // end of line @@ -1010,17 +1010,17 @@ QString TEScreen::getSelText(const BOOL preserve_line_breaks) // buffer. eol = hist.getLineLen(hY); if ((hY == (sel_BR / columns)) && (eol >= (sel_BR % columns))) { eol = sel_BR % columns + 1; } - + while (hX < eol) { m[d++] = hist.getCell(hY, hX++).c; s++; } if (s <= sel_BR) { @@ -1107,24 +1107,35 @@ QString TEScreen::getSelText(const BOOL preserve_line_breaks) } QChar* qc = new QChar[d]; for (int i = 0; i < d; i++) { qc[i] = m[i]; } - + QString res(qc, d); delete m; delete qc; return res; } +QString TEScreen::getHistory() { + sel_begin = 0; + sel_BR = sel_begin; + sel_TL = sel_begin; + setSelExtentXY(columns-1,lines-1); + QString tmp=getSelText(true); + while (tmp.at(tmp.length()-2).unicode()==10 && tmp.at(tmp.length()-1).unicode()==10) + tmp.truncate(tmp.length()-1); + + return tmp; +} /* above ... end of line processing for selection -- psilva cases: 1) (eol+1)%columns == 0 --> the whole line is filled. If the last char is a space, insert (preserve) space. otherwise leave the text alone, so that words that are broken by linewrap are preserved. diff --git a/noncore/apps/opie-console/TEScreen.h b/noncore/apps/opie-console/TEScreen.h index 473ce79..a840b44 100644 --- a/noncore/apps/opie-console/TEScreen.h +++ b/noncore/apps/opie-console/TEScreen.h @@ -157,16 +157,18 @@ public: // these are all `Screen' operations // void setSelBeginXY(const int x, const int y); void setSelExtentXY(const int x, const int y); void clearSelection(); QString getSelText(const BOOL preserve_line_breaks); void checkSelection(int from, int to); + QString getHistory(); + private: // helper void clearImage(int loca, int loce, char c); void moveImage(int dst, int loca, int loce); void scrollUp(int from, int i); void scrollDown(int from, int i); diff --git a/noncore/apps/opie-console/TEmulation.cpp b/noncore/apps/opie-console/TEmulation.cpp index 7a0c624..3b1b9e1 100644 --- a/noncore/apps/opie-console/TEmulation.cpp +++ b/noncore/apps/opie-console/TEmulation.cpp @@ -266,17 +266,19 @@ void TEmulation::setSelection(const BOOL preserve_line_breaks) { if (!t.isNull()) gui->setSelection(t); } void TEmulation::clearSelection() { if (!connected) return; scr->clearSelection(); showBulk(); } - +void TEmulation::streamHistory(QTextStream* stream) { + *stream << scr->getHistory(); +} // Refreshing -------------------------------------------------------------- -- #define BULK_TIMEOUT 20 /*! called when \n comes in. Evtl. triggers showBulk at endBulk */ diff --git a/noncore/apps/opie-console/TEmulation.h b/noncore/apps/opie-console/TEmulation.h index ec15e7a..d7b3d6d 100644 --- a/noncore/apps/opie-console/TEmulation.h +++ b/noncore/apps/opie-console/TEmulation.h @@ -19,36 +19,39 @@ #ifndef EMULATION_H #define EMULATION_H #include "TEWidget.h" #include "TEScreen.h" #include <qtimer.h> #include <stdio.h> #include <qtextcodec.h> +#include <qtextstream.h> + #include "keytrans.h" class TEmulation : public QObject { Q_OBJECT public: TEmulation(TEWidget* gui); ~TEmulation(); public: virtual void setHistory(bool on); virtual bool history(); + virtual void streamHistory( QTextStream* ); public slots: // signals incoming from TEWidget virtual void onImageSizeChange(int lines, int columns); virtual void onHistoryCursorChange(int cursor); virtual void onKeyPress(QKeyEvent*); - + virtual void clearSelection(); virtual void onSelectionBegin(const int x, const int y); virtual void onSelectionExtend(const int x, const int y); virtual void setSelection(const BOOL preserve_line_breaks); public slots: // signals incoming from data source void onRcvBlock(const char* txt,int len); @@ -70,16 +73,18 @@ public: virtual void sendString(const char*) = 0; virtual void setConnect(bool r); void setColumns(int columns); void setKeytrans(int no); void setKeytrans(const char * no); + + protected: TEWidget* gui; TEScreen* scr; // referes to one `screen' TEScreen* screen[2]; // 0 = primary, 1 = alternate void setScreen(int n); // set `scr' to `screen[n]' bool connected; // communicate with widget diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index 7924568..235facb 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp @@ -26,16 +26,19 @@ EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const c this, SLOT(recvEmulation(const char*, int) ) ); m_teEmu->setConnect( true ); m_teEmu->setHistory( TRUE ); load( prof ); } +TEmulation* EmulationHandler::emulation() { + return m_teEmu; +} EmulationHandler::~EmulationHandler() { if (isRecording()) clearScript(); delete m_teEmu; delete m_teWid; } void EmulationHandler::load( const Profile& prof) { diff --git a/noncore/apps/opie-console/emulation_handler.h b/noncore/apps/opie-console/emulation_handler.h index 7bc6f16..1338525 100644 --- a/noncore/apps/opie-console/emulation_handler.h +++ b/noncore/apps/opie-console/emulation_handler.h @@ -42,16 +42,17 @@ public: /** * delete all components */ ~EmulationHandler(); void load( const Profile& ); QWidget* widget(); + TEmulation *emulation(); void setColor( const QColor& fore, const QColor& back ); QPushButton* cornerButton(); /* Scripts */ /* Create a new script and record all typed characters */ void startRecording(); /* Return whether we are currently recording a script */ diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index d221715..01468ca 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -4,24 +4,26 @@ #include <qmenubar.h> #include <qlabel.h> #include <qpopupmenu.h> #include <qtoolbar.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qwhatsthis.h> #include <qfileinfo.h> +#include <qtextstream.h> #include <qpe/resource.h> #include <qpe/qpeapplication.h> #include <qpe/filemanager.h> #include <qpe/mimetype.h> #include <opie/ofiledialog.h> +#include "TEmulation.h" #include "keytrans.h" #include "profileeditordialog.h" #include "configdialog.h" #include "default.h" #include "metafactory.h" #include "profile.h" #include "profilemanager.h" #include "mainwindow.h" @@ -236,16 +238,22 @@ void MainWindow::initUI() { m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) , QString::null, 0, this, 0); m_fullscreen->addTo( m_console ); connect( m_fullscreen, SIGNAL( activated() ), this, SLOT( slotFullscreen() ) ); m_console->insertSeparator(); + + QAction *a = new QAction(); + a->setText( tr("Save history") ); + a->addTo( m_console ); + connect(a, SIGNAL(activated() ), + this, SLOT(slotSaveHistory() ) ); /* * terminate action */ m_terminate = new QAction(); m_terminate->setText( tr("Terminate") ); m_terminate->addTo( m_console ); connect(m_terminate, SIGNAL(activated() ), this, SLOT(slotTerminate() ) ); @@ -297,17 +305,17 @@ void MainWindow::initUI() { m_keyBar->setHorizontalStretchable( TRUE ); m_keyBar->hide(); m_kb = new FunctionKeyboard(m_keyBar); connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); - QAction *a = new QAction(tr("Copy"), + a = new QAction(tr("Copy"), Resource::loadPixmap("copy"), QString::null, 0, this, 0 ); //a->addTo( m_icons ); connect( a, SIGNAL(activated() ), this, SLOT(slotCopy() ) ); QAction *paste = new QAction(tr("Paste"), Resource::loadPixmap("paste"), QString::null, @@ -763,8 +771,33 @@ void MainWindow::slotSaveSession() { QMessageBox::information(this, tr("Save Connection"), tr("<qt>There is no Connection.</qt>"), 1 ); return; } manager()->add( currentSession()->profile() ); manager()->save(); populateProfiles(); } +void MainWindow::slotSaveHistory() { + QMap<QString, QStringList> map; + QStringList text; + text << "text/plain"; + map.insert(tr("History"), text ); + QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); + if (filename.isEmpty() ) return; + + QFileInfo info(filename); + + DocLnk nf; + nf.setType("text/plain"); + nf.setFile(filename); + nf.setName(info.fileName()); + + + QFile file(filename); + file.open(IO_WriteOnly ); + QTextStream str(&file ); + if ( currentSession() ) + currentSession()->emulationHandler()->emulation()->streamHistory(&str); + + file.close(); + nf.writeLink(); +} diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index 37219c5..0fac38b 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h @@ -65,16 +65,17 @@ private slots: void slotOpenButtons(bool); void slotRecordScript(); void slotSaveScript(); void slotRunScript(int); void slotFullscreen(); void slotWrap(); void slotSessionChanged( Session* ); void slotKeyReceived(FKey, ushort, ushort, bool); + void slotSaveHistory(); /* what could these both slot do? */ void slotCopy(); void slotPaste(); /* save the currentSession() to Profiles */ void slotSaveSession(); diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp index 0b43e17..24928e7 100644 --- a/noncore/apps/opie-console/metafactory.cpp +++ b/noncore/apps/opie-console/metafactory.cpp @@ -38,22 +38,16 @@ void MetaFactory::addFileTransferLayer( const QCString& name, m_fileFact.insert( str, lay ); } void MetaFactory::addReceiveLayer( const QCString& name, const QString& str, receivelayer lay) { m_strings.insert(str, name ); m_receiveFact.insert( str, lay ); } -void MetaFactory::addEmulationLayer( const QCString& name, - const QString& str, - emulationLayer em) { - m_strings.insert(str, name ); - m_emu.insert( str, em ); -} QStringList MetaFactory::ioLayers()const { QStringList list; QMap<QString, iolayer>::ConstIterator it; for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { list << it.key(); } return list; } @@ -84,24 +78,16 @@ QStringList MetaFactory::fileTransferLayers()const { QStringList MetaFactory::receiveLayers()const { QStringList list; QMap<QString, receivelayer>::ConstIterator it; for ( it = m_receiveFact.begin(); it != m_receiveFact.end(); ++it ) { list << it.key(); } return list; } -QStringList MetaFactory::emulationLayers()const { - QStringList list; - QMap<QString, emulationLayer>::ConstIterator it; - for ( it = m_emu.begin(); it != m_emu.end(); ++it ) { - list << it.key(); - } - return list; -} IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { IOLayer* lay = 0l; QMap<QString, iolayer>::Iterator it; it = m_layerFact.find( str ); if ( it != m_layerFact.end() ) { lay = (*(it.data()))(prof); @@ -143,27 +129,16 @@ ProfileDialogWidget *MetaFactory::newKeyboardPlugin( const QString& str, QWidget QMap<QString, configWidget>::Iterator it; it = m_keyFact.find( str ); if ( it != m_keyFact.end() ) { wid = (*(it.data() ) )(str,parent); } return wid; } -EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, WidgetLayer* wid) { - EmulationLayer* lay = 0l; - - QMap<QString, emulationLayer>::Iterator it; - it = m_emu.find( str ); - if ( it != m_emu.end() ) { - lay = (*(it.data() ) )(wid); - } - - return lay; -} FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) { FileTransferLayer* file = 0l; QMap<QString, filelayer>::Iterator it; it = m_fileFact.find( str ); if ( it != m_fileFact.end() ) { file = (*(it.data() ) )(lay); } return file; diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h index f89136c..bcc40db 100644 --- a/noncore/apps/opie-console/metafactory.h +++ b/noncore/apps/opie-console/metafactory.h @@ -11,26 +11,24 @@ #include <qpe/config.h> #include "io_layer.h" #include "file_layer.h" #include "receive_layer.h" #include "profile.h" #include "profiledialogwidget.h" -#include "emulation_layer.h" class WidgetLayer; class MetaFactory { public: typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent); typedef IOLayer* (*iolayer)(const Profile& ); typedef FileTransferLayer* (*filelayer)(IOLayer*); typedef ReceiveLayer* (*receivelayer)(IOLayer*); - typedef EmulationLayer* (*emulationLayer)(WidgetLayer* ); MetaFactory(); ~MetaFactory(); /** * add a ProfileDialogWidget to the factory * name is the name shown to the user */ @@ -56,43 +54,35 @@ public: */ void addFileTransferLayer( const QCString& name, const QString&, filelayer ); void addReceiveLayer( const QCString& name, const QString&, receivelayer); - /** - * adds a Factory for Emulation to the Layer.. - */ - void addEmulationLayer ( const QCString& name, - const QString& uiString, - emulationLayer ); /* translated UI Strings */ QStringList ioLayers()const; QStringList connectionWidgets()const; /** * Terminal Configuration widgets */ QStringList terminalWidgets()const; QStringList fileTransferLayers()const; QStringList receiveLayers()const; - QStringList emulationLayers()const; /** * the generation... */ IOLayer* newIOLayer( const QString&,const Profile& ); ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* ); ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* ); ProfileDialogWidget* newKeyboardPlugin( const QString&, QWidget* ); - EmulationLayer* newEmulationLayer(const QString&, WidgetLayer* ); FileTransferLayer* newFileTransfer(const QString&, IOLayer* ); ReceiveLayer* newReceive(const QString&, IOLayer* ); /* * internal takes the maybe translated * public QString and maps it to the internal * not translatable QCString */ @@ -108,13 +98,12 @@ public: private: QMap<QString, QCString> m_strings; QMap<QString, configWidget> m_conFact; QMap<QString, configWidget> m_termFact; QMap<QString, configWidget> m_keyFact; QMap<QString, iolayer> m_layerFact; QMap<QString, filelayer> m_fileFact; QMap<QString, receivelayer> m_receiveFact; - QMap<QString, emulationLayer> m_emu; }; #endif |