eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'OSXOperatingSystem':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: OSXOperatingSystem


Inheritance:

   Object
   |
   +--AbstractOperatingSystem
      |
      +--UnixOperatingSystem
         |
         +--OSXOperatingSystem

Package:
stx:libbasic
Category:
OS-Unix
Version:
rev: 1.82 date: 2022/05/24 15:12:09
user: cg
file: OSXOperatingSystem.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


a small number of OS-X specific redefinitions here.

copyright

COPYRIGHT (c) 2013 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

cocoa - events
o  finishLaunching
tell the system, that I have finished my startup phase.
OSX will stop bounding the launch icon then.

Usage example(s):

     self finishLaunching

o  generateButtonEvent: button down: down x: screenX y: screenY
synthesize and send a button event to the screen

Usage example(s):

     OperatingSystem generateButtonEvent:1 down:true x:150 y:150.
     OperatingSystem generateButtonEvent:1 down:false x:150 y:150.

     OperatingSystem generateButtonEvent:2 down:true x:150 y:150.
     OperatingSystem generateButtonEvent:2 down:false x:150 y:150.

o  generateKeyboardEvent: keyCode down: down
synthesize and send a keyboard event to the screen

Usage example(s):

     OperatingSystem generateKeyboardEvent:6 down:true.
     OperatingSystem generateKeyboardEvent:6 down:false.

o  generateMouseMoveEventX: screenX y: screenY
synthesize and send a mouse move event to the screen

Usage example(s):

     OperatingSystem generateMouseMoveEventX:150 y:5.
     Delay waitFor:(1 seconds).
     OperatingSystem generateMouseMoveEventX:1050 y:150.

o  getNSApp
get the NSApplication instance and remember in the global named NSApp

Usage example(s):

     self getNSApp

o  mouseMoveToX: screenX y: screenY
move the mouse to an absolute screen position

Usage example(s):

     |p|

     p := OperatingSystem getMousePosition.
     OperatingSystem mouseMoveToX:0 y:0.
     Delay waitFor:(1 seconds).
     OperatingSystem mouseMoveToX:100 y:100.
     Delay waitFor:(1 seconds).
     OperatingSystem mouseMoveToX:p x y:p y.

o  receiveNextEvent

dummy shell operations
o  openApplicationForDocument: aFilenameOrStringOrURLString operation: operationSymbol
open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
This is typically used to present help-files, html documents, pdf documents etc.
operationSymbol is one of:
open (i.e. like a double click on the file in the desktop)
edit
explore (i.e. like opening a finder/explorer on a directory in the desktop)

o  openApplicationHelperCommand
Return a command line helper to open a default application for file or URL

o  openTerminalWithCommand: shellCommand inBackground: inBackground
open a new terminal, which executes a command

Usage example(s):

     OSXOperatingSystem openTerminalWithCommand:'ls -l' inBackground:true

file queries
o  caseSensitiveFilenames
return true, if the OS has caseSensitive file naming.
On MSDOS, this will return false;
on a real OS, we return true.
Be aware, that OSX can be configured to be either.
Also, that it actually depends on the mounted volume

o  defaultPackagePath
redefined to add /Application and /Library stuff

Usage example(s):

self defaultPackagePath

o  getDocumentsDirectory
return your documents directory.
Under osx, that's the user's 'Documents' folder.
The fallback for other OS's may return the user's home directory.

Usage example(s):

     OperatingSystem getDocumentsDirectory

o  getDriveList
return a list of volumes in the system.

o  getTrashDirectory
get the name of a trash folder (if the OS supports it),
or nil, if not.
Must be redefined to return non nil in concrete operating systems

o  mimeTypeForFilename: aFilename
given a filename, return a corresponding mimeType.
This is placed here, to allow for OS-specific configuration
files and/or the win32 registry to be consultet.
Returns nil if no mimeType for the given name is known.

Usage example(s):

     OSXOperatingSystem mimeTypeForFilename:'/Applications/Keynote.app/Contents/version.plist'
     OSXOperatingSystem mimeTypeForFilename:'foo'

o  pathNameForDrive: driveName
given a drive name, return the pathname to open it as a directory.
For Windows, this is the driveName itself.
For OSX, '/Volumes' is prepended.
Other OSs might prepent the pount point (i.e. /mnt/)

o  pathOfSTXExecutable
return the full path of the running ST/X executable program.
Strange though, the inherited code will not be able to figure out
my path IFF ST/X is launched by the Finder (eg. click on desktop icon).
For this, we must ask NSMainBundle, which was done in the main startup code

o  supportsVolumes
return true if the os support a list of drives/volumes
(here we can return a list of mounted drives in /Volumes)

initialization
o  initializeCodeset
(comment from inherited method)
initialize the codeset, we are running under.
The codeset is determined from the environment.
The LC_CTYPE locale is set from the environment as a side effect.

interrupts & signals
o  enableHardSignalInterrupts
OSX sends SIGABRT for NSExceptions

o  enableUserInterrupts
osx seems to raise SIGUSR1 at times;

quartz - screen
o  getFrameBufferImage: displayNr
returns the framebuffer as an image object

Usage example(s):

     self getFrameBufferImage:0

o  getFrameBufferImage: displayNr in: aRectangleOrNil
returns the frameBuffer (if rect-arg is nil)
or part of the framebuffer (if non-nil) as an image object

Usage example(s):

     self getFrameBufferImage:0 in:nil
     self getFrameBufferImage:0 in:(100@100 corner:301@303)

     Delay waitFor:3 seconds. self getFrameBufferImage:0 in:nil

o  getMousePosition
on OSX+XQuartz, we have the top menuBar's height not included in
the x pointer position. See comment below

Usage example(s):

     Delay waitForSeconds:3.
     OperatingSystem getMousePosition
     Display pointerPosition
     (OperatingSystem getMousePosition - Display pointerPosition)

o  getScreenBounds: displayNr
returns the bounds of the screen.
This is needed, because the dimension of the XQuartz screen does not include the dock.

Usage example(s):

     self getScreenBounds:0

sound & voice
o  bestVoiceForLanguage: language
choose a voice as per language

Usage example(s):

     OperatingSystem setVoice:'Andrea' forLanguage:'fr'
     OperatingSystem setVoice:nil forLanguage:'fr'

     self bestVoiceForLanguage:'de'
     self bestVoiceForLanguage:'en'
     self bestVoiceForLanguage:'es'
     self bestVoiceForLanguage:'fr'

o  canPlaySound
(comment from inherited method)
OperatingSystem subclasses which can, redefine this

o  canSpeak

o  playSound: soundFile
use 'afplay ...'

Usage example(s):

     self playSound:(Expecco::Expecco projectDirectory / 'resources/sounds/test_complete.wav')

o  voiceCommandSpec
triples are:

o  voiceInfo
return a list of available voices plus info:
for each available voice, a triple is returned, containing:
voiceName language_territory comment/description

Usage example(s):

     OperatingSystem voiceInfo

o  voiceMapping
return a mapping from common (OS-independent) voice names
to OS-specific names or IDs.
The speak:voiceName interface will recognize both.
For portable programs, always use the OS-independent name and
let every OS xlate to its internal name.

Usage example(s):

     OperatingSystem voiceMapping

time and date
o  getMonotonicNanosecondTime
This returns the nanosecond timer's value

Usage example(s):

     self getMonotonicNanosecondTime

     |t1 t2|
     t1 := self getMonotonicNanosecondTime.
     t2 := self getMonotonicNanosecondTime.
     t2 - t1

o  getOSTimeWithNanos
This returns the OS time as a 2-element vector with milliseconds (as before)
plus nanoseconds.
The base of the returned value is not consistent across
different OS's - some return the number of nanoseconds since jan, 1st 1970;
others since 1900. The Time classes are prepared for this, and
convert as appropriate (by using my fromOSTime: conversion methods).

Don't use this method in application code since it is an internal (private)
interface. For compatibility use instances of Time, Date or Timestamp to work with.


Instance protocol:

* instance *
o  initInterrupts
initialize interrupts

Usage example(s):

     Smalltalk initInterrupts


Private classes:

    SigUSR1Notification


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sun, 22 Dec 2024 02:49:13 GMT