#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Sun, 03 Jul 2016 10:09:48 +0200
changeset 5151 23a4207e38af
parent 5149 7c471b54fe48
child 5152 5cf8652c8dd6
child 5153 32e47e338a49
#FEATURE by cg class: TerminalView added:5 methods comment/format in: #documentation changed: #doSendInterrupt #doSendKillSignal #editMenu #release
TerminalView.st
--- a/TerminalView.st	Thu Jun 30 18:30:00 2016 +0200
+++ b/TerminalView.st	Sun Jul 03 10:09:48 2016 +0200
@@ -14,22 +14,22 @@
 "{ NameSpace: Smalltalk }"
 
 TextCollector subclass:#TerminalView
-	instanceVariableNames:'inStream outStream readerProcess shellPid kbdSequences
-		escapeSequenceTree currentSequence kbdMap escapeLeadingChars
-		numberOfColumns numberOfLines shellTerminateAction rangeStartLine
-		rangeEndLine state savedCursor shellCommand shellDirectory
-		filterStream recorderStream localEcho translateNLToCRNL
-		inputTranslateCRToNL inputTranslateCRToCRNL
-		inputTranslateBackspaceToDelete autoWrapFlag masterWindow
-		alternateKeypadMode noColors sizeOfOutstandingInputToBeProcessed
-		lineEditMode lineBuffer lineBufferCursorPosition
-		lineBufferHistory lineBufferHistoryPosition maxHistorySize doUTF
-		ignoreOutput sendControlKeys
-		lastSelectedLineBufferHistoryPosition inputIsUTF8 outputIsUTF8
-		signalControlKeys'
-	classVariableNames:'Debug DebugKeyboard DefaultMaxHistorySize'
-	poolDictionaries:''
-	category:'Views-TerminalViews'
+        instanceVariableNames:'inStream outStream readerProcess shellPid kbdSequences
+                escapeSequenceTree currentSequence kbdMap escapeLeadingChars
+                numberOfColumns numberOfLines shellTerminateAction rangeStartLine
+                rangeEndLine state savedCursor shellCommand shellDirectory
+                filterStream recorderStream localEcho translateNLToCRNL
+                inputTranslateCRToNL inputTranslateCRToCRNL
+                inputTranslateBackspaceToDelete autoWrapFlag masterWindow
+                alternateKeypadMode noColors sizeOfOutstandingInputToBeProcessed
+                lineEditMode lineBuffer lineBufferCursorPosition
+                lineBufferHistory lineBufferHistoryPosition maxHistorySize doUTF
+                ignoreOutput sendControlKeys
+                lastSelectedLineBufferHistoryPosition inputIsUTF8 outputIsUTF8
+                signalControlKeys'
+        classVariableNames:'Debug DebugKeyboard DefaultMaxHistorySize'
+        poolDictionaries:''
+        category:'Views-TerminalViews'
 !
 
 !TerminalView class methodsFor:'documentation'!
@@ -69,13 +69,14 @@
     (to open a terminalView with a shell or on the output of a command),
     I can be used as a widget within an application (modem software).
 
-    Notice, some of my pty functionality and handling ex beeing extracted to
-    the separate TerminalSession class (which allows communicating with a
-    program without having its output displayed .   
-    So currently, some ugly code duplication is present.
-    Once stable, code will be refactored.   
-    For now, as terminalView is being used in
-    some of our critical applications, this refactoring has not yet been done.
+    Implementation notice: 
+        some of my pty functionality and handling is being extracted to
+        the separate TerminalSession class (which allows communicating with a
+        program without having its output displayed).   
+        So currently, some ugly code duplication is present.
+        Once stable, code will be refactored.   
+        For now, as terminalView is being used in
+        some of our critical applications, this refactoring has not yet been done.
 
     Line Editing mode:
      Cursor keys allow for th user to navigate through previously entered input (as in cmd.exe and bash).
@@ -1720,7 +1721,7 @@
     [
         self closeDownShellAndStopReaderProcess.
         self flushInput.
-    ] fork.
+    ] forkAt:(Processor systemBackgroundPriority).
     super release.
 
     "Modified: / 17-07-2014 / 19:29:55 / cg"
@@ -1949,46 +1950,28 @@
 doSendInterrupt
     "send an INT-signal to the shell (UNIX only)"
 
-    |status|
-
     DebugKeyboard ifTrue:[
         Transcript showCR:'interrupt!!'.
     ].
-
-    shellPid notNil ifTrue:[
-        OperatingSystem isUNIXlike ifTrue:[
-            OperatingSystem interruptProcessGroup:shellPid.
-            OperatingSystem interruptProcess:shellPid.
-            "/ status := OperatingSystem childProcessWait:false pid:shellPid.
-        ] ifFalse:[
-            self warn:(resources string:'unimplemented for DOS')
-        ]
-    ] ifFalse:[
-        'VT100: no shell' infoPrintCR.
-    ].
-
-    "Modified: / 10.6.1998 / 17:49:49 / cg"
+    self sendInterruptSignal
 !
 
 doSendKillSignal
     "send a KILL-signal to the shell (UNIX only)"
 
-    |status|
-
     DebugKeyboard ifTrue:[
         Transcript showCR:'kill!!'.
     ].
-    shellPid notNil ifTrue:[
-        OperatingSystem isUNIXlike ifTrue:[
-            OperatingSystem killProcessGroup:shellPid.
-            OperatingSystem killProcess:shellPid.
-            status := OperatingSystem childProcessWait:false pid:shellPid.
-        ] ifFalse:[
-            self warn:(resources string:'unimplemented for DOS')
-        ]
-    ] ifFalse:[
-        'VT100: no shell' infoPrintCR.
-    ]
+    self sendKillSignal
+!
+
+doSendTerminateSignal
+    "send a TERM-signal to the shell (UNIX only)"
+
+    DebugKeyboard ifTrue:[
+        Transcript showCR:'terminate!!'.
+    ].
+    self sendTerminateSignal
 !
 
 editMenu
@@ -2001,6 +1984,7 @@
 
     items := #(
                     ('Interrupt'      doSendInterrupt )  
+                    ('Terminate'      doSendTerminateSignal )  
                     ('Kill'           doSendKillSignal)  
                     ('-'                              )
                     ('Clear'          doClear         )  
@@ -2074,6 +2058,54 @@
     ].
 !
 
+sendInterruptSignal
+    "send an INT-signal to the shell (UNIX only)"
+
+    shellPid notNil ifTrue:[
+        OperatingSystem isUNIXlike ifTrue:[
+            OperatingSystem interruptProcessGroup:shellPid.
+            OperatingSystem interruptProcess:shellPid.
+            "/ status := OperatingSystem childProcessWait:false pid:shellPid.
+        ] ifFalse:[
+            self warn:(resources string:'unimplemented for DOS')
+        ]
+    ] ifFalse:[
+        'VT100: no shell' infoPrintCR.
+    ].
+
+    "Modified: / 10.6.1998 / 17:49:49 / cg"
+!
+
+sendKillSignal
+    "send a KILL-signal to the shell (UNIX only)"
+
+    |status|
+
+    shellPid notNil ifTrue:[
+        OperatingSystem isUNIXlike ifTrue:[
+            OperatingSystem killProcessGroup:shellPid.
+            OperatingSystem killProcess:shellPid.
+            status := OperatingSystem childProcessWait:false pid:shellPid.
+        ] ifFalse:[
+            self warn:(resources string:'unimplemented for DOS')
+        ]
+    ] ifFalse:[
+        'VT100: no shell' infoPrintCR.
+    ]
+!
+
+sendTerminateSignal
+    "send a TERM-signal to the shell (UNIX only)"
+
+    shellPid notNil ifTrue:[
+        OperatingSystem terminateProcessGroup:shellPid.
+        OperatingSystem terminateProcess:shellPid.
+        "/ status := OperatingSystem childProcessWait:false pid:shellPid.
+    ] ifFalse:[
+        'VT100: no shell' infoPrintCR.
+    ].
+!
+
 setGreenDisplayMode
     self foregroundColor:Color green backgroundColor:Color black.
     self cursorForegroundColor:Color black backgroundColor:Color green.
@@ -2680,6 +2712,11 @@
 
 !
 
+copySelection
+    super copySelection.
+    self cursorToEndOfText
+!
+
 paste:someText
     "paste - redefined to send the chars to the shell instead
      of pasting into the view"