summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJekyll Wu <adaptee@gmail.com>2012-01-26 11:04:54 (GMT)
committerJekyll Wu <adaptee@gmail.com>2012-01-26 13:20:09 (GMT)
commit95b8d5551e9cf7dae76854b9f31d1374c5e3aee5 (patch)
tree535a8ddd42c3011ec153e05300db8fe93141a5eb
parentdebfec2eb3c8ede89977b1f7d755b9f0d8a31e31 (diff)
Add dbus method for setting and querying history size per session
FEATURE: 120040 FIXED-IN: 4.9
-rw-r--r--src/Session.cpp28
-rw-r--r--src/Session.h17
2 files changed, 45 insertions, 0 deletions
diff --git a/src/Session.cpp b/src/Session.cpp
index a172b8c..c8f33d4 100644
--- a/src/Session.cpp
+++ b/src/Session.cpp
@@ -1275,6 +1275,34 @@ QString Session::tabTitleFormat(int context) const
}
}
+void Session::setHistorySize(int lines)
+{
+ if ( lines < 0 ) {
+ setHistoryType(HistoryTypeFile());
+ }
+ else if ( lines == 0 ) {
+ setHistoryType(HistoryTypeNone());
+ }
+ else {
+ setHistoryType(CompactHistoryType(lines));
+ }
+}
+
+int Session::historySize() const
+{
+ const HistoryType& currentHistory = historyType();
+
+ if (currentHistory.isEnabled()) {
+ if (currentHistory.isUnlimited()) {
+ return -1;
+ } else {
+ return currentHistory.maximumLineCount();
+ }
+ } else {
+ return 0;
+ }
+}
+
int Session::foregroundProcessId()
{
int pid;
diff --git a/src/Session.h b/src/Session.h
index e58476b..67a4bd2 100644
--- a/src/Session.h
+++ b/src/Session.h
@@ -522,6 +522,23 @@ public slots:
*/
Q_SCRIPTABLE QString tabTitleFormat(int context) const;
+ /**
+ * Sets the history capacity of this session.
+ *
+ * @param size The history capacity in unit of lines. Its value can be:
+ * <ul>
+ * <li> positive integer - fixed size history</li>
+ * <li> 0 - no history</li>
+ * <li> negative integer - unlimited history</li>
+ * </ul>
+ */
+ Q_SCRIPTABLE void setHistorySize(int lines) ;
+
+ /**
+ * Returns the history capacity of this session.
+ */
+ Q_SCRIPTABLE int historySize() const;
+
signals:
/** Emitted when the terminal process starts. */