Path: utzoo!attcan!uunet!snorkelwacker!ira.uka.de!smurf!gopnbg!mcshh!shin From: shin@mcshh.hanse.de (Thomas Braun) Newsgroups: comp.lang.smalltalk Subject: POSTING: A Watch For Smalltalk/V286 Keywords: Interrupt, Multi Processing Message-ID: <8125@mcshh.hanse.de> Date: 29 Sep 90 05:27:27 GMT Distribution: comp Lines: 97 " Smalltalk/V286 Source: 'watch.sml' ---------------------------------------------------------- This file installs a visible watch on the DisplayScreen by defining and redefining methods for the classes String, Process and ScreenDispatcher. When loaded, you will find a new option in the ScreenMenu of the ScreenDispatcher to switch the watch on and off. I wrote this little piece while studying multi processing capabilities of Smalltalk/V. It shows how to bring up a background process initiated by interrupt and signaling the KeyboardSemaphore good vibes... Thomas Braun ---------------------------------------------------------- To load this file evaluate the following message (File pathName: 'watch.sml') fileIn; close. where the file should be in the current directory. "! Smalltalk at: #Watch put: (0=1)! Transcript cr; show: 'Filing in the visible watch...'! !String methods ! displayAt: aPoint font: aFont foreColor: fore backColor: back "Output the receiver onto the display screen." CharacterScanner new initialize: Display boundingBox font: aFont; setForeColor: fore backColor: back; display: self at: aPoint! ! !Process class methods ! timerInterrupt "Implement the timer interrupt." PendingEvents add: (Message new selector: #clockEvent:; arguments: (Array with: 1)). (Time now) printString displayAt: 656 @ 0 font: (Font eightLine) foreColor: Form white backColor: Form gray. KeyboardSemaphore signal. self enableInterrupts: true! ! !ScreenDispatcher class methods ! initialize "Private - Initialize the system menu." | aString | BackupWindow ifTrue: [aString := 'dos shell\speed/space\exit Smalltalk\browse disk\open workspace\browse classes\redraw screen\save image\switch clock\run demo' withCrs] ifFalse:[aString := 'dos shell\space/speed\exit Smalltalk\browse disk\open workspace\browse classes\redraw screen\save image\switch clock\run demo' withCrs]. ScreenMenu := Menu labels: aString lines: #(3 7) selectors: #(dosMenu speedSpace exit openDiskBrowser openWorkspace openClassBrowser redraw save switchWatch runDemo)! ! !ScreenDispatcher methods ! switchWatch "switch the watch on and off" Watch ifTrue: [ Time clockTicksOff. Watch := (0=1). ' ' displayAt: 650 @ 2 font: (Font fourteenLine) foreColor: Form white backColor: Form gray.] ifFalse:[ Time clockTickPeriod:20. Watch := (0=0)] ! ! ScreenDispatcher initialize.! Transcript show: 'Done.' withCrs. ! -------------------------cut here-------------------------- Thomas Braun uucp: ..mcshh!shin Vedd. Brueckenstr.81 phone: 49 040 784258 2000 Hamburg 26 GERMANY -----------------------------------------------------------