summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/TEScreen.cpp17
-rw-r--r--noncore/apps/opie-console/TEScreen.h2
-rw-r--r--noncore/apps/opie-console/TEmulation.cpp4
-rw-r--r--noncore/apps/opie-console/TEmulation.h7
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp3
-rw-r--r--noncore/apps/opie-console/emulation_handler.h1
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp35
-rw-r--r--noncore/apps/opie-console/mainwindow.h1
-rw-r--r--noncore/apps/opie-console/metafactory.cpp25
-rw-r--r--noncore/apps/opie-console/metafactory.h11
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
@@ -940,231 +940,242 @@ void TEScreen::setBackColorToDefault()
void TEScreen::setForeColorToDefault()
{
cu_fg = DEFAULT_FORE_COLOR;
effectiveRendition();
}
/* ------------------------------------------------------------------------- */
/* */
/* Marking & Selection */
/* */
/* ------------------------------------------------------------------------- */
void TEScreen::clearSelection()
{
sel_BR = -1;
sel_TL = -1;
sel_begin = -1;
}
void TEScreen::setSelBeginXY(const int x, const int y)
{
sel_begin = loc(x,y+histCursor) ;
sel_BR = sel_begin;
sel_TL = sel_begin;
}
void TEScreen::setSelExtentXY(const int x, const int y)
{
if (sel_begin == -1) return;
int l = loc(x,y + histCursor);
if (l < sel_begin)
{
sel_TL = l;
sel_BR = sel_begin;
}
else
{
/* FIXME, HACK to correct for x too far to the right... */
if (( x == columns )|| (x == 0)) l--;
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
s = sel_TL; // tracks copy in source.
// allocate buffer for maximum
// possible size...
d = (sel_BR - sel_TL) / columns + 1;
m = new int[d * (columns + 1) + 2];
d = 0;
while (s <= sel_BR)
{
if (s < hist_BR)
{ // get lines from hist.history
// 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)
{
// The line break handling
// It's different from the screen
// image case!
if (eol % columns == 0)
{
// That's either a completely filled
// line or an empty line
if (eol == 0)
{
m[d++] = '\n';
}
else
{
// We have a full line.
// FIXME: How can we handle newlines
// at this position?!
}
}
else if ((eol + 1) % columns == 0)
{
// FIXME: We don't know if this was a
// space at the last position or a
// short line!!
m[d++] = ' ';
}
else
{
// We have a short line here. Put a
// newline or a space into the
// buffer.
m[d++] = preserve_line_breaks ? '\n' : ' ';
}
}
hY++;
hX = 0;
s = hY * columns;
}
else
{ // or from screen image.
eol = (s / columns + 1) * columns - 1;
if (eol < sel_BR)
{
while ((eol > s) &&
isspace(image[eol - hist_BR].c))
{
eol--;
}
}
else
{
eol = sel_BR;
}
while (s <= eol)
{
m[d++] = image[s++ - hist_BR].c;
}
if (eol < sel_BR)
{
// eol processing see below ...
if ((eol + 1) % columns == 0)
{
if (image[eol - hist_BR].c == ' ')
{
m[d++] = ' ';
}
}
else
{
m[d++] = ((preserve_line_breaks ||
((eol % columns) == 0)) ?
'\n' : ' ');
}
}
s = (eol / columns + 1) * columns;
}
}
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.
FIXME:
* this suppresses \n for command output that is
sized to the exact column width of the screen.
2) eol%columns == 0 --> blank line.
insert a \n unconditionally.
Do it either you would because you are in preserve_line_break mode,
or because it's an ASCII paragraph delimiter, so even when
not preserving line_breaks, you want to preserve paragraph breaks.
3) else --> partially filled line
insert a \n in preserve line break mode, else a space
The space prevents concatenation of the last word of one
line with the first of the next.
*/
void TEScreen::addHistLine()
{
assert(hasScroll() || histCursor == 0);
// add to hist buffer
// we have to take care about scrolling, too...
if (hasScroll())
{ ca dft;
int end = columns-1;
while (end >= 0 && image[end] == dft)
end -= 1;
hist.addCells(image,end+1);
hist.addLine();
// adjust history cursor
histCursor += (hist.getLines()-1 == histCursor);
}
if (!hasScroll()) histCursor = 0; //FIXME: a poor workaround
}
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
@@ -117,96 +117,98 @@ public: // these are all `Screen' operations
void setForeColorToDefault();
void setBackColorToDefault();
//
// -------------------------------------
//
BOOL getMode (int n);
//
// only for report cursor position
//
int getCursorX();
int getCursorY();
//
// -------------------------------------
//
void clear();
void home();
void reset();
//
void ShowCharacter(unsigned short c);
//
void resizeImage(int new_lines, int new_columns);
//
ca* getCookedImage();
/*! return the number of lines. */
int getLines() { return lines; }
/*! return the number of columns. */
int getColumns() { return columns; }
/*! set the position of the history cursor. */
void setHistCursor(int cursor);
/*! return the position of the history cursor. */
int getHistCursor();
int getHistLines ();
void setScroll(bool on);
bool hasScroll();
//
// Selection
//
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);
void addHistLine();
void initTabStops();
void effectiveRendition();
void reverseRendition(ca* p);
private:
/*
The state of the screen is more complex as one would
expect first. The screem does really do part of the
emulation providing state informations in form of modes,
margins, tabulators, cursor etc.
Even more unexpected are variables to save and restore
parts of the state.
*/
// screen image ----------------
int lines;
int columns;
ca *image; // [lines][columns]
// history buffer ---------------
int histCursor; // display position relative to start of the history buffer
HistoryScroll hist;
// cursor location
int cuX;
int cuY;
// cursor color and rendition info
UINT8 cu_fg; // foreground
UINT8 cu_bg; // background
UINT8 cu_re; // rendition
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
@@ -226,97 +226,99 @@ void TEmulation::onKeyPress( QKeyEvent* ev )
}
// Unblocking, Byte to Unicode translation --------------------------------- --
/*
We are doing code conversion from locale to unicode first.
*/
void TEmulation::onRcvBlock(const char *s, int len)
{
bulkStart();
bulk_incnt += 1;
for (int i = 0; i < len; i++)
{
QString result = decoder->toUnicode(&s[i],1);
int reslen = result.length();
for (int j = 0; j < reslen; j++)
onRcvChar(result[j].unicode());
if (s[i] == '\n') bulkNewline();
}
bulkEnd();
}
// Selection --------------------------------------------------------------- --
void TEmulation::onSelectionBegin(const int x, const int y) {
if (!connected) return;
scr->setSelBeginXY(x,y);
showBulk();
}
void TEmulation::onSelectionExtend(const int x, const int y) {
if (!connected) return;
scr->setSelExtentXY(x,y);
showBulk();
}
void TEmulation::setSelection(const BOOL preserve_line_breaks) {
if (!connected) return;
QString t = scr->getSelText(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
*/
void TEmulation::bulkNewline()
{
bulk_nlcnt += 1;
bulk_incnt = 0; // reset bulk counter since `nl' rule applies
}
/*!
*/
void TEmulation::showBulk()
{
bulk_nlcnt = 0; // reset bulk newline counter
bulk_incnt = 0; // reset bulk counter
if (connected)
{
ca* image = scr->getCookedImage(); // get the image
gui->setImage(image,
scr->getLines(),
scr->getColumns()); // actual refresh
free(image);
//FIXME: check that we do not trigger other draw event here.
gui->setScroll(scr->getHistCursor(),scr->getHistLines());
}
}
void TEmulation::bulkStart()
{
if (bulk_timer.isActive()) bulk_timer.stop();
}
void TEmulation::bulkEnd()
{
if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 )
showBulk(); // resets bulk_??cnt to 0, too.
else
bulk_timer.start(BULK_TIMEOUT,TRUE);
}
void TEmulation::setConnect(bool c)
{
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
@@ -1,117 +1,122 @@
/* -------------------------------------------------------------------------- */
/* */
/* [emulation.h] Fundamental Terminal Emulation */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
/* */
/* This file is part of Konsole - an X terminal for KDE */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* Ported Konsole to Qt/Embedded */
/* */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
/* */
/* -------------------------------------------------------------------------- */
#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);
signals:
void sndBlock(const char* txt,int len);
void ImageSizeChanged(int lines, int columns);
void changeColumns(int columns);
void changeTitle(int arg, const char* str);
public:
virtual void onRcvChar(int);
virtual void setMode (int) = 0;
virtual void resetMode(int) = 0;
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
void setCodec(int c); // codec number, 0 = locale, 1=utf8
QTextCodec* codec;
QTextCodec* localeCodec;
QTextDecoder* decoder;
KeyTrans* keytrans;
// refreshing related material.
// this is localized in the class.
private slots: // triggered by timer
void showBulk();
private:
void bulkNewline();
void bulkStart();
void bulkEnd();
private:
QTimer bulk_timer;
int bulk_nlcnt; // bulk newline counter
char* SelectedText;
int bulk_incnt; // bulk counter
};
#endif // ifndef EMULATION_H
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
@@ -1,81 +1,84 @@
#include <qwidget.h>
#include <qpushbutton.h>
#include "TEWidget.h"
#include "TEmuVt102.h"
#include "profile.h"
#include "emulation_handler.h"
#include "script.h"
EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
: QObject(0, name )
{
m_teWid = new TEWidget( parent, "TerminalMain");
// use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar)
// use setWrapAt(80) for normal console with scrollbar
setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80);
m_teWid->setMinimumSize(150, 70 );
m_script = 0;
parent->resize( m_teWid->calcSize(80, 24 ) );
m_teEmu = new TEmuVt102(m_teWid );
connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ),
this, SIGNAL(changeSize(int, int) ) );
connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ),
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) {
m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
int num = prof.readNumEntry("Color");
setColor( foreColor(num), backColor(num) );
m_teWid->setBackgroundColor(backColor(num) );
int term = prof.readNumEntry("Terminal", 0) ;
switch(term) {
default:
case Profile::VT102:
case Profile::VT100:
m_teEmu->setKeytrans("vt100.keytab");
break;
case Profile::Linux:
m_teEmu->setKeytrans("linux.keytab");
break;
case Profile::XTerm:
m_teEmu->setKeytrans("default.Keytab");
break;
}
}
void EmulationHandler::recv( const QByteArray& ar) {
m_teEmu->onRcvBlock(ar.data(), ar.count() );
}
void EmulationHandler::recvEmulation(const char* src, int len ) {
QByteArray ar(len);
memcpy(ar.data(), src, sizeof(char) * len );
if (isRecording())
m_script->append(ar);
emit send(ar);
}
QWidget* EmulationHandler::widget() {
return m_teWid;
}
/*
* allocate a new table of colors
*/
void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
ColorEntry table[TABLE_COLORS];
const ColorEntry *defaultCt = m_teWid->getdefaultColorTable();
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
@@ -2,93 +2,94 @@
#define OPIE_EMULATION_HANDLER_H
#include <qobject.h>
#include <qcolor.h>
#include <qcstring.h>
/*
* Badly ibotty lacks the time to finish
* his widget in time..
* Never the less we've to have an EmulationWidget
* This is why I'm taking the inferior not cleaned
* up TE* KDE STUFF
*/
/**
* This is the layer above the IOLayer*
* This nice QObject here will get stuff from
* got a slot and a signal
* the signal for data
* the slot for receiving
* it'll set up the widget internally
* and manage the communication between
* the pre QByteArray world!
*/
class Profile;
class QWidget;
class QPushButton;
class TEWidget;
class TEmulation;
class QFont;
class Script;
class EmulationHandler : public QObject {
Q_OBJECT
public:
/**
* simple c'tor the parent of the TEWdiget
* and a name
* and a Profile
*/
EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l );
/**
* 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 */
bool isRecording();
/* Return the current script (or NULL) */
Script *script();
/* Stop recording and remove the current script from memory */
void clearScript();
/* Run a script by forwarding its keys to the EmulationLayer */
void runScript(const Script *);
/* Propagate change to widget */
void setWrap(int columns);
signals:
void send( const QByteArray& );
void changeSize(int rows, int cols );
public slots:
void recv( const QByteArray& );
void paste();
void copy();
private slots:
void recvEmulation( const char*, int len );
private:
QFont font( int );
QColor foreColor(int );
QColor backColor(int );
private:
TEWidget* m_teWid;
TEmulation* m_teEmu;
Script * m_script;
};
#endif
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
@@ -1,67 +1,69 @@
#include <assert.h>
#include <qaction.h>
#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"
#include "tabwidget.h"
#include "transferdialog.h"
#include "function_keyboard.h"
#include "emulation_handler.h"
#include "script.h"
static char * filesave_xpm[] = {
"16 16 78 1",
" c None",
". c #343434",
"+ c #A0A0A0",
"@ c #565656",
"# c #9E9E9E",
"$ c #525252",
"% c #929292",
"& c #676767",
"* c #848484",
"= c #666666",
"- c #D8D8D8",
"; c #FFFFFF",
"> c #DBDBDB",
", c #636363",
"' c #989898",
") c #2D2D2D",
"! c #909090",
"~ c #AEAEAE",
"{ c #EAEAEA",
"] c #575757",
"^ c #585858",
"/ c #8A8A8A",
"( c #828282",
"_ c #6F6F6F",
": c #C9C9C9",
"< c #050505",
"[ c #292929",
"} c #777777",
"| c #616161",
"1 c #3A3A3A",
"2 c #BEBEBE",
"3 c #2C2C2C",
@@ -196,158 +198,164 @@ void MainWindow::initUI() {
m_console->insertSeparator();
/*
* connect action
*/
m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"),
QString::null, 0, this, 0 );
m_connect->addTo( m_console );
connect(m_connect, SIGNAL(activated() ),
this, SLOT(slotConnect() ) );
/*
* disconnect action
*/
m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"),
QString::null, 0, this, 0 );
m_disconnect->addTo( m_console );
connect(m_disconnect, SIGNAL(activated() ),
this, SLOT(slotDisconnect() ) );
m_console->insertSeparator();
m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null,
0, this, 0 );
m_transfer->addTo( m_console );
connect(m_transfer, SIGNAL(activated() ),
this, SLOT(slotTransfer() ) );
/*
* immediate change of line wrap policy
*/
m_isWrapped = false;
m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 );
m_wrap->addTo( m_console );
connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) );
/*
* fullscreen
*/
m_isFullscreen = false;
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() ) );
m_closewindow = new QAction();
m_closewindow->setText( tr("Close Window") );
m_closewindow->addTo( m_console );
connect( m_closewindow, SIGNAL(activated() ),
this, SLOT(slotClose() ) );
/*
* script actions
*/
m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
m_recordScript->addTo(m_scripts);
connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
m_saveScript->addTo(m_scripts);
connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
/*
* action that open/closes the keyboard
*/
m_openKeys = new QAction (tr("Open Keyboard..."),
Resource::loadPixmap( "console/keys/keyboard_icon" ),
QString::null, 0, this, 0);
m_openKeys->setToggleAction(true);
connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
/* insert the submenu */
m_console->insertItem(tr("New from Profile"), m_sessionsPop,
-1, 0);
/* insert the connection menu */
m_bar->insertItem( tr("Connection"), m_console );
/* the scripts menu */
m_bar->insertItem( tr("Scripts"), m_scripts );
/* and the keyboard */
m_keyBar = new QToolBar(this);
addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
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,
0, this, 0 );
connect( paste, SIGNAL(activated() ),
this, SLOT(slotPaste() ) );
newCon->addTo( m_icons );
m_setProfiles->addTo( m_icons );
paste->addTo( m_icons );
m_openKeys->addTo(m_icons);
m_fullscreen->addTo( m_icons );
m_connect->setEnabled( false );
m_disconnect->setEnabled( false );
m_terminate->setEnabled( false );
m_transfer->setEnabled( false );
m_scripts->setItemEnabled(m_runScript_id, false);
m_recordScript->setEnabled( false );
m_saveScript->setEnabled( false );
m_fullscreen->setEnabled( false );
m_closewindow->setEnabled( false );
m_wrap->setEnabled( false );
/*
* connect to the menu activation
*/
connect( m_sessionsPop, SIGNAL(activated( int ) ),
this, SLOT(slotProfile( int ) ) );
m_consoleWindow = new TabWidget( this, "blah");
connect(m_consoleWindow, SIGNAL(activated(Session*) ),
this, SLOT(slotSessionChanged(Session*) ) );
setCentralWidget( m_consoleWindow );
}
ProfileManager* MainWindow::manager() {
return m_manager;
}
TabWidget* MainWindow::tabWidget() {
return m_consoleWindow;
@@ -723,48 +731,73 @@ void MainWindow::slotFullscreen() {
( ( m_curSession->emulationHandler() )->cornerButton() )->show();
connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
}
m_isFullscreen = !m_isFullscreen;
}
void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) {
if ( m_curSession ) {
QEvent::Type state;
if (pressed) state = QEvent::KeyPress;
else state = QEvent::KeyRelease;
QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode)));
// is this the best way to do this? cant figure out any other way to work
QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
ke.ignore();
}
}
void MainWindow::slotCopy() {
if (!currentSession() ) return;
currentSession()->emulationHandler()->copy();
}
void MainWindow::slotPaste() {
if (!currentSession() ) return;
currentSession()->emulationHandler()->paste();
}
/*
* Save the session
*/
void MainWindow::slotSaveSession() {
if (!currentSession() ) {
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
@@ -25,96 +25,97 @@ class DocLnk;
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 );
~MainWindow();
/**
* our factory to generate IOLayer and so on
*
*/
MetaFactory* factory();
/**
* A session contains a QWidget*,
* an IOLayer* and some infos for us
*/
Session* currentSession();
/**
* the session list
*/
QList<Session> sessions();
/**
*
*/
ProfileManager* manager();
TabWidget* tabWidget();
private slots:
void slotNew();
void slotConnect();
void slotDisconnect();
void slotTerminate();
void slotConfigure();
void slotClose();
void slotProfile(int);
void slotTransfer();
void slotOpenKeb(bool);
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();
private:
void initUI();
void populateProfiles();
void populateScripts();
void create( const Profile& );
/**
* the current session
*/
Session* m_curSession;
/**
* the session list
*/
QList<Session> m_sessions;
QList<DocLnk> m_scriptsData;
/**
* the metafactory
*/
MetaFactory* m_factory;
ProfileManager* m_manager;
TabWidget* m_consoleWindow;
QToolBar* m_tool;
QToolBar* m_icons;
QToolBar* m_keyBar;
QToolBar* m_buttonBar;
QMenuBar* m_bar;
QPopupMenu* m_console;
QPopupMenu* m_sessionsPop;
QPopupMenu* m_scriptsPop;
QPopupMenu* m_scripts;
QAction* m_connect;
QAction* m_disconnect;
QAction* m_terminate;
QAction* m_transfer;
QAction* m_setProfiles;
QAction* m_openKeys;
QAction* m_openButtons;
QAction* m_recordScript;
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
@@ -1,190 +1,165 @@
#include <qpe/config.h>
#include "metafactory.h"
MetaFactory::MetaFactory() {
}
MetaFactory::~MetaFactory() {
}
void MetaFactory::addConnectionWidgetFactory( const QCString& name,
const QString& str,
configWidget wid) {
m_strings.insert( str, name );
m_conFact.insert( str, wid );
}
void MetaFactory::addTerminalWidgetFactory( const QCString& name,
const QString& str,
configWidget wid ) {
m_strings.insert( str, name );
m_termFact.insert( str, wid );
}
void MetaFactory::addKeyboardWidgetFactory( const QCString& name,
const QString & str,
configWidget wid) {
m_strings.insert( str, name );
m_keyFact.insert( str, wid );
}
void MetaFactory::addIOLayerFactory( const QCString& name,
const QString& str,
iolayer lay) {
m_strings.insert( str, name );
m_layerFact.insert( str, lay );
}
void MetaFactory::addFileTransferLayer( const QCString& name,
const QString& str,
filelayer lay) {
m_strings.insert(str, 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;
}
QStringList MetaFactory::connectionWidgets()const {
QStringList list;
QMap<QString, configWidget>::ConstIterator it;
for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) {
list << it.key();
}
return list;
}
QStringList MetaFactory::terminalWidgets()const {
QStringList list;
QMap<QString, configWidget>::ConstIterator it;
for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) {
list << it.key();
}
return list;
}
QStringList MetaFactory::fileTransferLayers()const {
QStringList list;
QMap<QString, filelayer>::ConstIterator it;
for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) {
list << it.key();
}
return list;
}
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);
/*
iolayer laye = it.data();
lay = (*laye )(conf);*/
}
return lay;
}
ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) {
ProfileDialogWidget* wid = 0l;
QMap<QString, configWidget>::Iterator it;
it = m_conFact.find( str );
if ( it != m_conFact.end() ) {
wid = (*(it.data() ) )(str,parent);
}
return wid;
}
ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) {
if (str.isEmpty() )
return 0l;
ProfileDialogWidget* wid = 0l;
QMap<QString, configWidget>::Iterator it;
it = m_termFact.find( str );
if ( it != m_termFact.end() ) {
wid = (*(it.data() ) )(str,parent);
}
return wid;
}
ProfileDialogWidget *MetaFactory::newKeyboardPlugin( const QString& str, QWidget *parent) {
if (str.isEmpty() )
return 0l;
ProfileDialogWidget* wid = 0l;
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;
}
ReceiveLayer* MetaFactory::newReceive(const QString& str, IOLayer* lay ) {
ReceiveLayer* file = 0l;
QMap<QString, receivelayer>::Iterator it;
it = m_receiveFact.find( str );
if ( it != m_receiveFact.end() ) {
file = (*(it.data() ) )(lay);
}
return file;
}
QCString MetaFactory::internal( const QString& str )const {
return m_strings[str];
}
QString MetaFactory::external( const QCString& str )const {
QMap<QString, QCString>::ConstIterator it;
for ( it = m_strings.begin(); it != m_strings.end(); ++it ) {
if ( it.data() == str )
return it.key();
}
return QString::null;
}
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
@@ -1,120 +1,109 @@
#ifndef OPIE_META_FACTORY_H
#define OPIE_META_FACTORY_H
/**
* The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets
* and to instantiate these implementations on demand
*/
#include <qwidget.h>
#include <qmap.h>
#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
*/
void addConnectionWidgetFactory( const QCString& internalName,
const QString& uiString,
configWidget );
void addTerminalWidgetFactory ( const QCString& internalName,
const QString& name,
configWidget );
void addKeyboardWidgetFactory ( const QCString& internalName,
const QString& name,
configWidget );
/**
* adds an IOLayer factory
*/
void addIOLayerFactory( const QCString&,
const QString&,
iolayer );
/**
* adds a FileTransfer Layer
*/
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
*/
QCString internal( const QString& )const;
/*
* external takes the internal name
* it returns a translated name
*/
QString external( const QCString& )const;
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