From 5637ea1e5e67ad93f5b1eb66d690910ab658e446 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 25 Mar 2019 21:59:33 -0700 Subject: [PATCH] Add QTermWidget::saveHistory This enables an application to implement the functionality of easily opening the entire history as a file in your favorite editor. --- lib/qtermwidget.cpp | 8 ++++++++ lib/qtermwidget.h | 1 + 2 files changed, 9 insertions(+) diff --git a/lib/qtermwidget.cpp b/lib/qtermwidget.cpp index e1ee4b3..ccabfd1 100644 --- a/lib/qtermwidget.cpp +++ b/lib/qtermwidget.cpp @@ -751,3 +751,11 @@ int QTermWidget::getMargin() const { return m_impl->m_terminalDisplay->margin(); } + +void QTermWidget::saveHistory(QIODevice *device) +{ + QTextStream stream(device); + PlainTextDecoder decoder; + decoder.begin(&stream); + m_impl->m_session->emulation()->writeToStream(&decoder, 0, m_impl->m_session->emulation()->lineCount()); +} diff --git a/lib/qtermwidget.h b/lib/qtermwidget.h index e9447df..1a8d3a3 100644 --- a/lib/qtermwidget.h +++ b/lib/qtermwidget.h @@ -287,6 +287,7 @@ public slots: void toggleShowSearchBar(); + void saveHistory(QIODevice *device); protected: void resizeEvent(QResizeEvent *) override;