[squeak-dev] Headless UI manager - set active how?

Chris Muller asqueaker at gmail.com
Wed Aug 7 23:07:23 UTC 2013


Hi Frank,

> To test this, I've written a near-stub HeadlessUIManager. A UIManager
> indicates that it may be used by returning true from #isActiveManager.
>
> I have two questions:
>
> (a) How can I detect whether or not I'm running headless, from within the image?

I use the method in that CommandLine handler package I sent to you a
while back.  It simply checks command-line args:

SmalltalkImage>>#isHeadless
     "Display global is set even when headless.  So checking the -vm
arguments looking for headless operation."
     -1000
          to: -1
          do:
               [ : n |
               (#('display=none' '-headless' '-vm-display-null')
includes: (self getSystemAttribute: n)) ifTrue: [ ^ true ] ].
     ^ false

> (b) Given that MorphicUIManager class >> #isActiveManager returns true
> if there's a World, and I'm not quite ready to set World to nil
> because running headless is relatively unsupported, how do I make sure
> that _this_ UIManager runs, and not _that_ one?

How about just handling ProvideAnswerNotification from a high level?

     [nil inform: 'No changes']
          on: ProvideAnswerNotification
          do: [ : noti | noti defaultAction ]

You might want even more error handling than that, though, for running
headless.  Check out that CommandLineProcessor in the Ma-Core package.
   I've been using it for several years now for running batch in
headless or headful operation.  All the error handling for printing
messages and stack traces and exiting the image vs. halting, etc. is
handled fairly elegantly by this one class.

> I'd expected a UIManager class >> #default: like ToolSet has. Or even
> better, something based on a resumable exception.

ProvideAnswerNotification.


More information about the Squeak-dev mailing list