#FEATURE by cg
class: Win32OperatingSystem class
CTRL-C
codepage support (terminal output was interpreted wrong)
added:
#getConsoleOutputCP
#primGenerateConsoleCtrlEvent:
#sendCtrlCToProcess:
comment/format in:
#clipboardContainsBitmap
#clipboardContainsFormat:
changed: #primGenerateConsoleCtrlEvent:processGroupId:
category of:17 methods
--- a/Win32OperatingSystem.st Mon Dec 16 11:42:32 2019 +0100
+++ b/Win32OperatingSystem.st Mon Dec 16 11:59:23 2019 +0100
@@ -1721,17 +1721,17 @@
^ PerformanceData
! !
-!Win32OperatingSystem class methodsFor:'clipboard'!
+!Win32OperatingSystem class methodsFor:'clipboard & console'!
clipboardContainsBitmap
- "Answer whether the clipboard contains a bitmap."
+ "Answer whether the clipboard contains a bitmap."
^self clipboardContainsFormat: 2 "CfBitmap"
!
clipboardContainsFormat: aCfConstant
- "Answer true if the clipboard contains data in
- the format described by aCfConstant. "
+ "Answer true if the clipboard contains data in
+ the format described by aCfConstant. "
^self primIsClipboardFormatAvailable: aCfConstant
!
@@ -1760,6 +1760,17 @@
"Modified: / 03-08-2018 / 11:15:47 / Stefan Vogel"
!
+getConsoleOutputCP
+ "get the console's output code page identifier"
+
+ <apicall: uint "GetConsoleOutputCP" () module: "kernel32.dll" >
+ ^self primitiveFailed
+
+ "
+ OperatingSystem getConsoleOutputCP
+ "
+!
+
getDesktopWindow
^self primGetDesktopWindow
@@ -1794,6 +1805,20 @@
^self primitiveFailed
!
+primGenerateConsoleCtrlEvent:dwProcessId
+ "it looks as if that does not work at the moment,
+ unless the process has the same console as me.
+ This is not the case with embedded terminals, so CTRL-C cannot be sent to it."
+
+%{
+ if ( __isSmallInteger(dwProcessId) ) {
+ GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, __intVal(dwProcessId));
+ RETURN( self );
+ }
+%}.
+ self primitiveFailed:#invalidParameter.
+!
+
primGetDesktopWindow
<apicall: ulongReturn "GetDesktopWindow" () module: "user32.dll" >
@@ -7905,6 +7930,18 @@
"Created: / 28-05-2015 / 14:14:53 / gg"
!
+sendCtrlCToProcess:processHandleOrPid
+ "it looks as if that does not work at the moment,
+ unless the process has the same console as me.
+ This is not the case with embedded terminals, so CTRL-C cannot be sent to it."
+
+ |pid|
+
+ pid := processHandleOrPid isInteger ifTrue:[processHandleOrPid] ifFalse:[processHandleOrPid pid].
+ self primGenerateConsoleCtrlEvent:pid
+ "/ self primGenerateConsoleCtrlEvent:17764
+!
+
sendSignal:signalNumber to:processId
"send a unix signal to some process (maybe myself).
Returns false if any error occurred, true otherwise.