TerminalApplication.st
branchjv
changeset 13289 cc75e3cd0362
parent 13250 0decde6c459d
parent 13260 c3f318979431
child 15566 184cea584be5
--- a/TerminalApplication.st	Sun Jul 28 11:38:21 2013 +0100
+++ b/TerminalApplication.st	Thu Aug 01 10:27:56 2013 +0100
@@ -12,7 +12,7 @@
 "{ Package: 'stx:libtool' }"
 
 MultiViewToolApplication subclass:#TerminalApplication
-	instanceVariableNames:'initialDirectory'
+	instanceVariableNames:'initialDirectory keepAlive keepAliveProcess'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Interface-Smalltalk'
@@ -170,6 +170,17 @@
                   label: 'Green'
                   itemValue: setGreenDisplayMode
                 )
+               (MenuItem
+                  label: 'Red'
+                  itemValue: setRedDisplayMode
+                )
+               (MenuItem
+                  label: '-'
+                )
+               (MenuItem
+                  label: 'Ignore Text Color Commands'
+                  indication: noColors:
+                )
                )
               nil
               nil
@@ -245,6 +256,17 @@
                   label: '-'
                 )
                (MenuItem
+                  label: 'Send "~." (ssh/telnet quit)'
+                  itemValue: doSendTildeStop
+                )
+               (MenuItem
+                  label: 'Keep Connection Alive'
+                  indication: keepSSHConnectionAliveHolder
+                )
+               (MenuItem
+                  label: '-'
+                )
+               (MenuItem
                   label: 'Reset Terminal'
                   itemValue: doReset
                 )
@@ -279,6 +301,8 @@
         nil
         nil
       )
+
+    "Modified: / 30-07-2013 / 11:01:18 / cg"
 !
 
 tabMenu
@@ -344,6 +368,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
@@ -394,6 +430,22 @@
     self selectedWorkspacesTextView doSendKillSignal.
 !
 
+doSendTildeStop
+    self selectedWorkspacesTextView send:'~.'.
+
+    "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|
 
@@ -406,6 +458,14 @@
     ]
 !
 
+noColors
+    ^ self selectedWorkspacesTextView noColors
+!
+
+noColors:aBoolean
+    self selectedWorkspacesTextView noColors:aBoolean.
+!
+
 openDocumentation
     "opens the documentation file"
 
@@ -434,6 +494,10 @@
     self selectedWorkspacesTextView setNormalDisplayMode.
 !
 
+setRedDisplayMode
+    self selectedWorkspacesTextView setRedDisplayMode.
+!
+
 setReverseDisplayMode
     self selectedWorkspacesTextView setReverseDisplayMode.
 ! !
@@ -442,10 +506,58 @@
 
 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 selectedWorkspacesTextView 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'!
 
+startShellInSelectedWindow
+    |vt|
+
+    vt := self selectedWorkspacesTextView.
+    (vt notNil and:[vt superView realized]) ifFalse:[
+        self window sensor pushUserEvent:#startShellInSelectedWindow for:self.
+        ^ self.
+    ].
+
+    vt startShellIn:initialDirectory.
+    vt shellTerminateAction:[self shellFinishedInWorkspace:vt].
+    vt masterWindow:(self window).  "/ to change window title
+
+    "Modified: / 07-04-2011 / 09:03:55 / cg"
+    "Modified: / 03-04-2012 / 10:31:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!TerminalApplication methodsFor:'startup & release'!
+
 initialDirectory:aDirectory
     initialDirectory := aDirectory
 !
@@ -465,34 +577,28 @@
     super postOpenWith:aBuilder
 !
 
+release
+    self stopKeepAliveProcess.
+    super release.
+
+    "Created: / 30-07-2013 / 07:54:16 / cg"
+!
+
 shellFinishedInWorkspace:aView
     "/ vt backgroundColor:(Color red).
     aView 
         cr; 
         nextPutLine:('>> shell terminated.' asText allBold colorizeAllWith:Color red).
-!
-
-startShellInSelectedWindow
-    |vt|
-
-    vt := self selectedWorkspacesTextView.
-    (vt notNil and:[vt superView realized]) ifFalse:[
-        self window sensor pushUserEvent:#startShellInSelectedWindow for:self.
-        ^ self.
-    ].
-
-    vt startShellIn:initialDirectory.
-    vt shellTerminateAction:[self shellFinishedInWorkspace:vt].
-    vt masterWindow:(self window).  "/ to change window title
-
-    "Modified: / 07-04-2011 / 09:03:55 / cg"
-    "Modified: / 03-04-2012 / 10:31:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !TerminalApplication class methodsFor:'documentation'!
 
+version
+    ^ '$Header: /cvs/stx/stx/libtool/TerminalApplication.st,v 1.19 2013-07-30 09:02:01 cg Exp $'
+!
+
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/TerminalApplication.st,v 1.13 2013-07-23 21:08:55 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/TerminalApplication.st,v 1.19 2013-07-30 09:02:01 cg Exp $'
 !
 
 version_HG