TerminalApplication.st
changeset 13257 25b6402f5883
parent 13245 66930563e1c2
child 13259 30315be68637
--- a/TerminalApplication.st	Tue Jul 30 07:57:02 2013 +0200
+++ b/TerminalApplication.st	Tue Jul 30 09:17:39 2013 +0200
@@ -12,7 +12,7 @@
 "{ Package: 'stx:libtool' }"
 
 MultiViewToolApplication subclass:#TerminalApplication
-	instanceVariableNames:'initialDirectory'
+	instanceVariableNames:'initialDirectory keepAlive keepAliveProcess'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Interface-Smalltalk'
@@ -260,6 +260,10 @@
                   itemValue: doSendTildeStop
                 )
                (MenuItem
+                  label: 'Keep ssh Connection Alive'
+                  indication: keepSSHConnectionAliveHolder
+                )
+               (MenuItem
                   label: '-'
                 )
                (MenuItem
@@ -362,6 +366,18 @@
     "
 ! !
 
+!TerminalApplication methodsFor:'aspects'!
+
+keepSSHConnectionAliveHolder
+    keepAlive isNil ifTrue:[
+        keepAlive := false asValue.
+        keepAlive onChangeSend:#keepSSHConnectionAliveHolderChanged to:self.
+    ].
+    ^ keepAlive
+
+    "Created: / 30-07-2013 / 07:51:59 / cg"
+! !
+
 !TerminalApplication methodsFor:'menu-actions'!
 
 addWorkspace
@@ -418,6 +434,16 @@
     "Created: / 29-07-2013 / 18:20:36 / cg"
 !
 
+keepSSHConnectionAliveHolderChanged
+    keepAlive value ifTrue:[
+        self startKeepAliveProcess
+    ] ifFalse:[
+        self stopKeepAliveProcess
+    ]
+
+    "Created: / 30-07-2013 / 07:53:12 / cg"
+!
+
 menuPlayback
     |file suff|
 
@@ -478,9 +504,38 @@
 
 isModifiedWorkspace:aView
     ^ false
+!
+
+startKeepAliveProcess
+    "keep alive, by sending a return from time to time.
+     Raise to top, if connection is lost"
+
+    keepAliveProcess isNil ifTrue:[
+        keepAliveProcess :=
+            [
+                [true] whileTrue:[
+                    self sendCR:''.
+                    Delay waitForSeconds:30.
+                ].
+            ] newProcess.
+        keepAliveProcess resume.
+    ].
+
+    "Created: / 30-07-2013 / 09:14:36 / cg"
+!
+
+stopKeepAliveProcess
+    |p|
+
+    (p := keepAliveProcess) notNil ifTrue:[
+        keepAliveProcess := nil.
+        p terminate
+    ].
+
+    "Created: / 30-07-2013 / 09:15:05 / cg"
 ! !
 
-!TerminalApplication methodsFor:'startup'!
+!TerminalApplication methodsFor:'startup & release'!
 
 initialDirectory:aDirectory
     initialDirectory := aDirectory
@@ -501,6 +556,13 @@
     super postOpenWith:aBuilder
 !
 
+release
+    self stopKeepAliveProcess.
+    super release.
+
+    "Created: / 30-07-2013 / 07:54:16 / cg"
+!
+
 shellFinishedInWorkspace:aView
     "/ vt backgroundColor:(Color red).
     aView 
@@ -527,10 +589,10 @@
 !TerminalApplication class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/TerminalApplication.st,v 1.16 2013-07-29 16:29:31 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/TerminalApplication.st,v 1.17 2013-07-30 07:17:39 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/TerminalApplication.st,v 1.16 2013-07-29 16:29:31 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/TerminalApplication.st,v 1.17 2013-07-30 07:17:39 cg Exp $'
 ! !