Expose complete history to QML
The use case for this functionality is to be able to e.g. display the terminal application's output after it was terminated. This requires exposing a `clearScreen` method to QML as the history only contains the lines not currently displayed in the widget. If we want to access the whole output we have to be able to flush the screen beforehand. The single argument overload of `Emulation::writeToStream` simplifies reading the complete history at once without having to further expose it's length.
This commit is contained in:
@@ -209,6 +209,19 @@ int KSession::historySize() const
|
||||
}
|
||||
}
|
||||
|
||||
QString KSession::getHistory() const
|
||||
{
|
||||
QString history;
|
||||
QTextStream historyStream(&history);
|
||||
PlainTextDecoder historyDecoder;
|
||||
|
||||
historyDecoder.begin(&historyStream);
|
||||
m_session->emulation()->writeToStream(&historyDecoder);
|
||||
historyDecoder.end();
|
||||
|
||||
return history;
|
||||
}
|
||||
|
||||
void KSession::sendText(QString text)
|
||||
{
|
||||
m_session->sendText(text);
|
||||
@@ -227,6 +240,11 @@ void KSession::sendKey(int rep, int key, int mod) const
|
||||
// }
|
||||
}
|
||||
|
||||
void KSession::clearScreen()
|
||||
{
|
||||
m_session->emulation()->clearEntireScreen();
|
||||
}
|
||||
|
||||
void KSession::search(const QString ®exp, int startLine, int startColumn, bool forwards)
|
||||
{
|
||||
HistorySearch *history = new HistorySearch( QPointer<Emulation>(m_session->emulation()), QRegExp(regexp), forwards, startColumn, startLine, this);
|
||||
|
||||
Reference in New Issue
Block a user