28#include <QtCore5Compat/QTextCodec> 
   34#include "KeyboardTranslator.h" 
   35#include "HistorySearch.h" 
   39    ,m_session(createSession(
QString()))
 
   47                if(!hasActiveProcess())
 
   49                      qDebug() <<
"Process Finished"<< m_session->iconText() << m_session->iconName() << m_session->isMonitorSilence() << m_session->program() << state << getForegroundProcessError();
 
   52                      qDebug() <<
"Process started"<< m_session->iconText() << m_session->iconName() << m_session->isMonitorSilence() << m_session->program() << state << getForegroundProcessError();
 
   55                Q_EMIT hasActiveProcessChanged();
 
   57                if(m_processName != m_session->foregroundProcessName())
 
   59                    m_processName = m_session->foregroundProcessName();
 
   60                    Q_EMIT foregroundProcessNameChanged();
 
   68                Q_EMIT bellRequest(message);
 
   73                qDebug() << 
"changeTabTextColorRequest" << state;
 
   78                qDebug() << 
"changeTabTextColorRequest" << state;
 
   83                qDebug() << 
"changeBackgroundColorRequest" << state;
 
   88                qDebug() << 
"openUrlRequest" << state;
 
   91    connect(m_session.get(), &Konsole::Session::activity, [
this]()
 
   93                qDebug() << 
"activity";
 
   94                Q_EMIT processHasSilent(false);
 
   97    connect(m_session.get(), &Konsole::Session::silence, [
this]()
 
   99                qDebug() << 
"silence";
 
  100                Q_EMIT processHasSilent(true);
 
  109        m_session->disconnect();
 
  113int KSession::getForegroundProcessError()
 const 
  115    return m_session->foregroundProcessError();    
 
  121    if(m_session->isMonitorSilence() == value)
 
  124    m_session->setMonitorSilence(value);
 
 
  130    return m_session->isMonitorSilence();
 
 
  138std::unique_ptr<Session> KSession::createSession(
QString name)
 
  140    auto session = std::make_unique<Session>();
 
  142    session->setTitle(Session::NameRole, name);
 
  154    QString envshell = getenv(
"SHELL");
 
  155    QString shellProg = !envshell.
isNull() ? envshell : QStringLiteral(
"/bin/bash");
 
  156    session->setProgram(shellProg);
 
  158    setenv(
"TERM", 
"xterm-256color", 1);
 
  163    session->setArguments(
args);
 
  164    session->setAutoClose(
true);
 
  166    session->setCodec(QTextCodec::codecForName(
"UTF-8"));
 
  168    session->setFlowControlEnabled(
true);
 
  169    session->setHistoryType(HistoryTypeBuffer(1000));
 
  170    session->setMonitorSilenceSeconds(30);
 
  171    session->setMonitorActivity(
true);
 
  174    session->setKeyBindings(
QString());
 
  183int  KSession::getRandomSeed()
 
  185    return m_session->sessionId() * 31;
 
  190    m_session->setView(display);
 
 
  195    m_session->removeView(display);
 
 
  198void KSession::sessionFinished()
 
  203void KSession::selectionChanged(
bool textSelected)
 
  205    Q_UNUSED(textSelected)
 
  210    if (m_session->isRunning())
 
 
  220    if (!m_session->isRunning())
 
  225    return m_session->sendSignal(signal);
 
 
  230    return m_session->processId();
 
 
  245    strCmd.
append(u
" | tail -1 | awk '{ print $5 }' | grep -q \\+");
 
  253        sendText(QStringLiteral(
"\x05\x15"));
 
 
  262    m_session->setEnvironment(environment);
 
 
  267    if(m_session->program() == progname)
 
  270    m_session->setProgram(progname);
 
 
  276    return m_session->program();
 
 
  281    if(_initialWorkingDirectory != dir)
 
  283        _initialWorkingDirectory = dir;
 
  284        m_session->setInitialWorkingDirectory(dir);
 
 
  290QString KSession::getInitialWorkingDirectory()
 
  292    return _initialWorkingDirectory;
 
  297    if(m_session->arguments() == 
args)
 
  300    m_session->setArguments(
args);
 
 
  306    m_session->setCodec(codec);
 
 
  324    if(m_session->historyType().isUnlimited())
 
  328        return m_session->historyType().maximumLineCount();
 
  332QString KSession::getHistory()
 const 
  335    QTextStream historyStream(&
history);
 
  336    PlainTextDecoder historyDecoder;
 
  338    historyDecoder.
begin(&historyStream);
 
  339    m_session->emulation()->writeToStream(&historyDecoder);
 
  340    historyDecoder.
end();
 
  347    m_session->sendText(text);
 
 
  369    m_session->emulation()->clearEntireScreen();
 
 
  374    HistorySearch *
history = 
new HistorySearch(
QPointer<Emulation>(m_session->emulation()), QRegExp(regexp), forwards, startColumn, startLine, 
this);
 
 
  382    m_session->setFlowControlEnabled(enabled);
 
 
  387    return m_session->flowControlEnabled();
 
 
  392    m_session->setKeyBindings(kb);
 
 
  396QString KSession::getKeyBindings()
 
  398    return m_session->keyBindings();
 
  408    return m_session->keyBindings();
 
 
  422    return m_session->userTitle();
 
  427    return m_session->processId() != m_session->foregroundProcessId();
 
 
  432    return m_session->foregroundProcessName();
 
  437    return m_session->currentDir();
 
  442    return m_session->arguments();
 
 
QString history
The commands history.
 
void clearScreen()
clearScreen
 
void titleChanged()
titleChanged
 
void removeView(TerminalDisplay *display)
removeView
 
void startShellProgram()
startShellProgram
 
void addView(TerminalDisplay *display)
addView
 
void search(const QString ®exp, int startLine=0, int startColumn=0, bool forwards=true)
Search history.
 
bool sendSignal(int signal)
sendSignal
 
void noMatchFound()
noMatchFound
 
void initialWorkingDirectoryChanged()
initialWorkingDirectoryChanged
 
QString keyBindings()
Return current key bindings.
 
QString currentDir
The current directory of the session.
 
void setTitle(QString name)
setTitle
 
void changedKeyBindings(QString kb)
changedKeyBindings
 
QString foregroundProcessName
The name of the current process running.
 
void setInitialWorkingDirectory(const QString &dir)
Initial working directory.
 
void changeDir(const QString &dir)
changeDir
 
void setArgs(const QStringList &args)
Shell program args, default is none.
 
void setShellProgram(const QString &progname)
Shell program, default is /bin/bash
 
void monitorSilenceChanged()
monitorSilenceChanged
 
void sendKey(int rep, int key, int mod) const
Emulate a key press.
 
bool hasActiveProcess
Whether the session has an active process running.
 
int historySize
Allows to set the amount of lines to store in the history.
 
void setEnvironment(const QStringList &environment)
Set the custom enviroment variables.
 
void matchFound(int startColumn, int startLine, int endColumn, int endLine)
matchFound
 
void shellProgramChanged()
shellProgramChanged
 
void setKeyBindings(const QString &kb)
Set named key binding for the session.
 
QStringList args() const
args
 
int getShellPID()
getShellPID
 
void currentDirChanged()
currentDirChanged
 
void setHistorySize(int lines)
History size for scrolling.
 
void setMonitorSilence(bool value)
setMonitorSilence
 
void setFlowControlEnabled(bool enabled)
Sets whether flow control is enabled.
 
bool flowControlEnabled(void)
Returns whether flow control is enabled.
 
static QStringList availableKeyBindings()
Sets whether the flow control warning box should be shown when the flow control stop key (Ctrl+S) is ...
 
void argsChanged()
argsChanged
 
void setTextCodec(QTextCodec *codec)
Text codec, default is UTF-8.
 
void sendText(QString text)
Send some text to terminal.
 
QString shellProgram
Allows to change the default shell program, by default bash is used.
 
bool monitorSilence
Whether to monitor when the session has gone silent.
 
QList< QString > allTranslators()
Returns a list of the names of available keyboard translators.
 
static KeyboardTranslatorManager * instance()
Returns the global KeyboardTranslatorManager instance.
 
void end() override
End decoding.
 
void begin(QTextStream *output) override
Begin decoding characters.
 
void started()
Emitted when the terminal process starts.
 
void finished()
Emitted when the terminal process exits.
 
void titleChanged()
Emitted when the session's title has changed.
 
void openUrlRequest(const QString &url)
TODO: Document me.
 
void changeTabTextColorRequest(int)
Requests that the color the text for any tabs associated with this session should be changed;.
 
void stateChanged(int state)
Emitted when the activity state of this session changes.
 
void changeBackgroundColorRequest(const QColor &)
Requests that the background color of views on this session should be changed.
 
@ NameRole
The name of the session.
 
void bellRequest(const QString &message)
Emitted when a bell event occurs in the session.
 
A widget which displays output from a terminal emulation and sends input keypresses and mouse activit...
 
KCOREADDONS_EXPORT QString quoteArg(const QString &arg)
 
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QString & append(QChar ch)
 
bool isNull() const const
 
QString & prepend(QChar ch)
 
QString & setNum(double n, char format, int precision)
 
std::string toStdString() const const
 
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)