Commit 5e1b0068 authored by Robert Knight's avatar Robert Knight

API cleanup in Session class. Remove un-needed methods and duplicates. Avoid...

API cleanup in Session class.  Remove un-needed methods and duplicates.  Avoid need to call setListenToKeyPress on new Session instances before they can receive input.

svn path=/branches/work/konsole-split-view/; revision=658772
parent 8225fd14
......@@ -147,8 +147,6 @@ void Application::detachView(Session* session)
void Application::createSession(const QString& key , ViewManager* view)
{
Session* session = SessionManager::instance()->createSession(key);
session->setListenToKeyPress(true);
//session->setConnect(true);
// create view before starting the session process so that the session doesn't suffer
// a change in terminal size right after the session starts. some applications such as GNU Screen
......
......@@ -105,7 +105,6 @@ using namespace Konsole;
Emulation::Emulation() :
currentScreen(0),
listenToKeyPress(false),
m_codec(0),
decoder(0),
keytrans(0)
......@@ -188,6 +187,8 @@ const HistoryType& Emulation::history()
void Emulation::setCodec(const QTextCodec * qtc)
{
Q_ASSERT( qtc );
m_codec = qtc;
delete decoder;
decoder = m_codec->makeDecoder();
......@@ -195,15 +196,12 @@ void Emulation::setCodec(const QTextCodec * qtc)
emit useUtf8(utf8());
}
void Emulation::setCodec(int c)
void Emulation::setCodec(EmulationCodec codec)
{
setCodec(c ? QTextCodec::codecForName("utf8")
: QTextCodec::codecForLocale());
}
void Emulation::setKeymap(int no)
{
keytrans = KeyTrans::find(no);
if ( codec == Utf8Codec )
setCodec( QTextCodec::codecForName("utf8") );
else if ( codec == LocaleCodec )
setCodec( QTextCodec::codecForLocale() );
}
void Emulation::setKeymap(const QString &id)
......@@ -216,10 +214,6 @@ QString Emulation::keymap()
return keytrans->id();
}
int Emulation::keymapNo()
{
return keytrans->numb();
}
// Interpreting Codes ---------------------------------------------------------
......@@ -261,7 +255,6 @@ void Emulation::onReceiveChar(int c)
void Emulation::onKeyPress( QKeyEvent* ev )
{
if (!listenToKeyPress) return; // someone else gets the keys
emit notifySessionState(NOTIFYNORMAL);
if (!ev->text().isEmpty())
......@@ -460,11 +453,6 @@ char Emulation::getErase()
return '\b';
}
void Emulation::setListenToKeyPress(bool l)
{
listenToKeyPress=l;
}
// ---------------------------------------------------------------------------
/*! triggered by image size change of the TerminalDisplay `gui'.
......
......@@ -196,16 +196,13 @@ public:
//virtual void setConnect(bool r);
//bool isConnected() { return connected; }
bool utf8() { return m_codec->mibEnum() == 106; }
bool utf8() { Q_ASSERT(m_codec); return m_codec->mibEnum() == 106; }
virtual char getErase();
virtual void setListenToKeyPress(bool l);
void setColumns(int columns);
void setKeymap(int no);
void setKeymap(const QString &id);
int keymapNo();
QString keymap();
virtual void clearEntireScreen() =0;
......@@ -230,9 +227,12 @@ protected:
*/
void setScreen(int index);
bool listenToKeyPress; // listen to input
void setCodec(int c); // codec number, 0 = locale, 1=utf8
enum EmulationCodec
{
LocaleCodec = 0,
Utf8Codec = 1
};
void setCodec(EmulationCodec codec); // codec number, 0 = locale, 1=utf8
//decodes an incoming C-style character stream into a unicode QString using
//the current text codec. (this allows for rendering of non-ASCII characters in text files etc.)
......
......@@ -114,7 +114,6 @@ void Part::sendInput( const QString& text )
Session* Part::createSession(const QString& key)
{
Session* session = SessionManager::instance()->createSession(key);
session->setListenToKeyPress(true);
_viewManager->createView(session);
......
......@@ -68,8 +68,6 @@ Session::Session() :
, masterMode(false)
, autoClose(true)
, wantedClose(false)
//, schema_no(0)
, _fontNo(3)
, _silenceSeconds(10)
, _addToUtmp(true)
, _flowControl(true)
......@@ -79,7 +77,6 @@ Session::Session() :
, _zmodemBusy(false)
, _zmodemProc(0)
, _zmodemProgress(0)
, _encoding_no(0)
{
//prepare DBus communication
//TODO - Re-add Session adaptor
......@@ -280,7 +277,8 @@ void Session::changeTabTextColor( int color )
void Session::setUserTitle( int what, const QString &caption )
{
bool modified = false; //set to true if anything is actually changed (eg. old _title != new _title )
//set to true if anything is actually changed (eg. old _title != new _title )
bool modified = false;
// (btw: what=0 changes _title and icon, what=1 only icon, what=2 only _title
if ((what == 0) || (what == 2)) {
......@@ -458,9 +456,7 @@ bool Session::closeSession()
void Session::feedSession(const QString &text)
{
emit disableMasterModeConnections();
setListenToKeyPress(true);
_emulation->sendText(text);
setListenToKeyPress(false);
emit enableMasterModeConnections();
}
......@@ -482,22 +478,6 @@ Session::~Session()
delete _emulation;
delete _shellProcess;
delete _zmodemProc;
QListIterator<TerminalDisplay*> viewIter(_views);
while (viewIter.hasNext())
viewIter.next()->deleteLater();
}
/*void Session::setConnect(bool c)
{
connected=c;
_emulation->setConnect(c);
setListenToKeyPress(c);
}*/
void Session::setListenToKeyPress(bool l)
{
_emulation->setListenToKeyPress(l);
}
void Session::done() {
......@@ -538,38 +518,16 @@ void Session::done(int exitStatus)
emit done(this);
}
void Session::terminate()
{
delete this;
}
Emulation* Session::emulation() const
{
return _emulation;
}
// following interfaces might be misplaced ///
int Session::encodingNo() const
{
return _encoding_no;
}
int Session::keymapNo() const
{
return _emulation->keymapNo();
}
QString Session::keymap() const
{
return _emulation->keymap();
}
int Session::fontNo() const
{
return _fontNo;
}
const QString& Session::terminalType() const
{
return _term;
......@@ -585,26 +543,11 @@ int Session::sessionId() const
return _sessionId;
}
void Session::setEncodingNo(int index)
{
_encoding_no = index;
}
void Session::setKeymapNo(int kn)
{
_emulation->setKeymap(kn);
}
void Session::setKeymap(const QString &id)
{
_emulation->setKeymap(id);
}
void Session::setFontNo(int fn)
{
_fontNo = fn;
}
void Session::setTitle(const QString& title)
{
if ( title != _title )
......@@ -676,23 +619,16 @@ void Session::clearHistory()
}
}
QStringList Session::getArgs()
QStringList Session::arguments() const
{
return _arguments;
}
QString Session::getPgm()
QString Session::program() const
{
return _program;
}
QString Session::currentWorkingDirectory()
{
Q_ASSERT(false);
return QString();
}
bool Session::isMonitorActivity() const { return monitorActivity; }
bool Session::isMonitorSilence() const { return monitorSilence; }
bool Session::isMasterMode() const { return masterMode; }
......
......@@ -57,10 +57,11 @@ class ColorScheme;
* activity.
*/
class Session : public QObject
{ Q_OBJECT
{
Q_OBJECT
public:
Q_PROPERTY(QString sessionName READ sessionName)
Q_PROPERTY(QString sessionName READ title)
Q_PROPERTY(QString encoding READ encoding WRITE setEncoding)
Q_PROPERTY(int sessionPid READ sessionPid)
Q_PROPERTY(QString keytab READ keytab WRITE setKeytab)
......@@ -91,8 +92,6 @@ public:
* all views of a session will display the same number of lines and
* columns.
*
* When the Session instance is destroyed, any views which are still
* attached will also be deleted.
*/
void addView(TerminalDisplay* widget);
/**
......@@ -108,8 +107,6 @@ public:
*/
QList<TerminalDisplay*> views() const;
void setListenToKeyPress(bool l);
/**
* Returns the terminal emulation instance being used to encode / decode
* characters to / from the process.
......@@ -119,8 +116,6 @@ public:
bool isMonitorActivity() const;
bool isMonitorSilence() const;
bool isMasterMode() const;
int encodingNo() const;
int fontNo() const;
/**
* Returns the value of the TERM environment variable which will
......@@ -155,10 +150,12 @@ public:
*/
QString displayTitle() const;
int keymapNo() const;
QString keymap() const;
QStringList getArgs();
QString getPgm();
/** Returns the arguments passed to the shell process when run() is called. */
QStringList arguments() const;
/** Returns the program name of the shell process started when run() is called. */
QString program() const;
/**
* Sets the command line arguments which the session's program will be passed when
......@@ -169,7 +166,6 @@ public:
void setProgram(const QString& program);
/** Returns the session's current working directory. */
QString currentWorkingDirectory();
QString initialWorkingDirectory() { return _initial_cwd; }
/**
......@@ -180,20 +176,13 @@ public:
void setHistory(const HistoryType&);
const HistoryType& history();
void clearHistory();
void setMonitorActivity(bool);
void setMonitorSilence(bool);
void setMonitorSilenceSeconds(int seconds);
void setMasterMode(bool);
//TODO - Remove these functions which use indicies to reference keyboard layouts,
// encodings etc. and replace them either with methods that
// use pointers or references to the font object / keyboard
// layout object etc. or a QString key
void setEncodingNo(int index);
void setKeymapNo(int kn);
void setFontNo(int fn);
void setKeymap(const QString& _id);
void setTitle(const QString& _title);
void setIconName(const QString& _iconName);
......@@ -206,11 +195,9 @@ public:
void setAutoClose(bool b) { autoClose = b; }
void renameSession(const QString &name);
bool closeSession();
void clearHistory();
void feedSession(const QString &text);
void sendSession(const QString &text);
QString sessionName() { return _title; }
/**
* Returns the process id of the terminal process.
......@@ -227,18 +214,29 @@ public:
void setEncoding(const QString &encoding);
QString keytab();
void setKeytab(const QString &keytab);
/** Returns the terminal session's window size in lines and columns. */
QSize size();
/**
* Emits a request to resize the session to accomodate
* the specified window size.
*
* @param size The size in lines and columns to request.
*/
void setSize(QSize size);
public Q_SLOTS:
public slots:
void run();
void done();
void done(int);
void terminate();
bool closeSession();
void setUserTitle( int, const QString &caption );
void changeTabTextColor( int );
void ptyError();
void slotZModemDetected();
void emitZModemDetected();
......@@ -248,7 +246,7 @@ public Q_SLOTS:
void zmodemDone();
void zmodemContinue();
Q_SIGNALS:
signals:
void processExited();
void receivedData( const QString& text );
......@@ -266,15 +264,16 @@ Q_SIGNALS:
void openUrlRequest(const QString &cwd);
void zmodemDetected(Session *);
void updateSessionConfig(Session *);
void updateSessionConfig(Session*);
void resizeSession(Session *session, QSize size);
void setSessionEncoding(Session *session, const QString &encoding);
private Q_SLOTS:
void onReceiveBlock( const char* buf, int len );
private slots:
void onReceiveBlock( const char* buffer, int len );
void monitorTimerDone();
void notifySessionState(int state);
void onContentSizeChange(int height, int width);
//automatically detach views from sessions when view is destroyed
void viewDestroyed(QObject* view);
......@@ -284,7 +283,7 @@ private:
int _uniqueIdentifier;
Pty* _shellProcess;
Pty* _shellProcess;
Emulation* _emulation;
QList<TerminalDisplay*> _views;
......@@ -298,11 +297,6 @@ private:
bool wantedClose;
QTimer* monitorTimer;
//FIXME: using the indices here
// is propably very bad. We should
// use a persistent reference instead.
//
int _fontNo;
int _silenceSeconds;
QString _title;
......@@ -333,7 +327,6 @@ private:
// Color/Font Changes by ESC Sequences
QColor _modifiedBackground; // as set by: echo -en '\033]11;Color\007
int _encoding_no;
QString _type;
......
......@@ -170,7 +170,7 @@ void Vt102Emulation::reset()
//kDebug(1211)<<"Vt102Emulation::reset() reset screen 1"<<endl;
screen[1]->reset();
//kDebug(1211)<<"Vt102Emulation::reset() setCodec()"<<endl;
setCodec(0);
setCodec(LocaleCodec);
//kDebug(1211)<<"Vt102Emulation::reset() done"<<endl;
bufferedUpdate();
......@@ -563,8 +563,8 @@ switch( N )
case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100
case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100
case TY_ESC_CS('%', 'G') : setCodec (1 ); break; //LINUX
case TY_ESC_CS('%', '@') : setCodec (0 ); break; //LINUX
case TY_ESC_CS('%', 'G') : setCodec (Utf8Codec ); break; //LINUX
case TY_ESC_CS('%', '@') : setCodec (LocaleCodec ); break; //LINUX
case TY_ESC_DE('3' ) : /* Double height line, top half */
currentScreen->setLineProperty( LINE_DOUBLEWIDTH , true );
......@@ -1016,8 +1016,6 @@ void Vt102Emulation::sendText( const QString& text )
void Vt102Emulation::onKeyPress( QKeyEvent* ev )
{
if (!listenToKeyPress) return; // someone else gets the keys
//printf("State/Key: 0x%04x 0x%04x (%d,%d)\n",ev->state(),ev->key(),ev->text().length(),ev->text().length()?ev->text().ascii()[0]:0);
// lookup in keyboard translation table ...
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment