[squeak-dev] Review Request: informUserDuringResult.2.cs

christoph.thiede at student.hpi.uni-potsdam.de christoph.thiede at student.hpi.uni-potsdam.de
Wed May 25 20:40:08 UTC 2022


As we are in feature freeze, I am requesting a review from the list first, but I would rather classify this as a fix than as a fixer. Unless any weird code out there relied on #informUser:during: returning a UIManager instance or something similar, I would not expect any regressions with that.

Best,
Christoph

=============== Summary ===============

Change Set:        informUserDuringResult
Date:            25 May 2022
Author:            Christoph Thiede

This changeset modifies all implementors of #informUser{:d,D}uring: to ensure that always the result of aBlock will be returned.

=============== Diff ===============

ClassBuilder>>informUserDuring: {private} · ct 5/25/2022 22:32 (changed)
informUserDuring: aBlock
-     self class isSilent ifTrue:[^aBlock value].
-     UIManager default informUserDuring:[:bar|
+ 
+     | result |
+     self class isSilent ifTrue: [^ aBlock value].
+     
+     result := Project uiManager informUserDuring: [:bar |
        progress := bar.
        aBlock value].
-     progress := nil.
+     progress := nil.
+     ^ result

DummyUIManager>>informUserDuring: {ui requests} · ct 5/25/2022 22:32 (changed)
informUserDuring: aBlock
-     aBlock value: Association new.
+     ^ aBlock value: Association new

MVCMenuMorph>>informUserAt:during: {invoking} · ct 5/25/2022 22:34 (changed)
informUserAt: aPoint during: aBlock
    "Add this menu to the Morphic world during the execution of the given block."

-     | title w |
-     Smalltalk isMorphic ifFalse: [^ self].
+     | title w result |
+     Smalltalk isMorphic ifFalse: [^ aBlock value].
    
    title := self allMorphs detect: [:ea | ea hasProperty: #titleString].
    title := title submorphs first.
    self visible: false.
    w := self currentWorld.
-     aBlock value: [:string|
+     result := aBlock value: [:string|
        self visible ifFalse: [
            w addMorph: self centeredNear: aPoint.
            self visible: true].
        title contents: string.
        self setConstrainedPosition: Sensor cursorPoint hangOut: false.
        self changed.
        w displayWorld         "show myself"
    ]. 
    self delete.
-     w displayWorld.
+     w displayWorld.
+     ^ result

MVCUIManager>>informUser:during: {ui requests} · ct 5/25/2022 22:31 (changed)
informUser: aStringOrText during: aBlock
    "Display a message above (or below if insufficient room) the cursor 
    during execution of the given block.
        Project uiManager informUser: 'Just a sec!' during: [1 second wait].
    "
-     (SelectionMenu labels: '')
+     ^ (SelectionMenu labels: '')
        displayAt: Sensor cursorPoint
        withCaption: (aStringOrText ifNotNil: [
            "This is a compromise. See commentary in DialogWindow >> #message:."
            aStringOrText withNoLineLongerThan: (aStringOrText size > 900 ifTrue: [65] ifFalse: [45])])
        during: aBlock

MVCUIManager>>informUserDuring: {ui requests} · ct 5/25/2022 22:33 (changed)
informUserDuring: aBlock
    "Display a message above (or below if insufficient room) the cursor 
    during execution of the given block.
        UIManager default informUserDuring:[:bar|
            #(one two three) do:[:info|
                bar value: info.
                (Delay forSeconds: 1) wait]]"
-     aBlock value:[:string| Transcript cr; show: string].
+     ^ aBlock value: [:string | Transcript cr; show: string]

MenuMorph>>informUserAt:during: {modal control} · ct 5/25/2022 22:34 (changed)
informUserAt: aPoint during: aBlock
    "Add this menu to the Morphic world during the execution of the given block."

-     | title world |
+     | title world result |
    title := self allMorphs detect: [ :ea | ea hasProperty: #titleString ].
    title := title submorphs first.
    self visible: false.
    world := self currentWorld.
-     aBlock value: [:string|
+     result := aBlock value: [:string|
        self visible ifFalse:[
            world addMorph: self centeredNear: aPoint.
            self visible: true].
        title contents: string.
        self setConstrainedPosition: self currentHand cursorPoint hangOut: false.
        self changed.
        world displayWorld "show myself"]. 
    self delete.
-     world displayWorld.
+     world displayWorld.
+     ^ result

MorphicUIManager>>informUserDuring: {ui requests} · ct 5/25/2022 22:32 (changed)
informUserDuring: aBlock
    "Display a message above (or below if insufficient room) the cursor 
    during execution of the given block.
        UIManager default informUserDuring:[:bar|
            #(one two three) do:[:info|
                bar value: info.
                (Delay forSeconds: 1) wait]]"
-     SystemProgressMorph
+     ^ SystemProgressMorph
        informUserAt: nil during: aBlock.

PopUpMenu>>displayAt:withCaption:during: {displaying} · ct 5/25/2022 22:33 (changed)
displayAt: aPoint withCaption: captionOrNil during: aBlock
    "Display the receiver just to the right of aPoint while aBlock is evaluated.  If the receiver is forced off screen, display it just to the right."
-     | delta savedArea captionForm captionSave outerFrame captionText tFrame frameSaveLoc captionBox |
+     | delta savedArea captionForm captionSave outerFrame captionText tFrame frameSaveLoc captionBox result |
    marker ifNil: [self computeForm].
    frame := frame align: marker leftCenter with: aPoint + (2 at 0).
    outerFrame := frame.
    captionOrNil notNil ifTrue:
        [captionText := (DisplayText
                text: captionOrNil asText
                textStyle: self class standardMenuStyle copy centered)
                    foregroundColor: (self userInterfaceTheme textColor ifNil: [Color black])
                    backgroundColor: (self userInterfaceTheme color ifNil: [Color white]).
        tFrame := captionText boundingBox insetBy: -2.
        outerFrame := frame merge: (tFrame align: tFrame bottomCenter
                    with: frame topCenter + (0 at 2))].
    delta := outerFrame amountToTranslateWithin: Display boundingBox.
    frame right > Display boundingBox right
        ifTrue: [delta := 0 - frame width @ delta y].
    frame := frame translateBy: delta.
    captionOrNil notNil ifTrue:
        [captionForm := captionText form.
        captionBox := captionForm boundingBox expandBy: 4.
        captionBox := captionBox align: captionBox bottomCenter
                                with: frame topCenter + (0 at 2).
        captionSave := Form fromDisplay: captionBox.
        Display border: captionBox width: 4 fillColor: (self userInterfaceTheme color ifNil: [Color white]).
        Display border: captionBox width: 2 fillColor: (self userInterfaceTheme textColor ifNil: [Color black]).
        captionForm displayAt: captionBox topLeft + 4].
    marker := marker align: marker leftCenter with: aPoint + delta +  (2 at 0).
    savedArea := Form fromDisplay: frame.
    self menuForm displayOn: Display at: (frameSaveLoc := frame topLeft).
    selection ~= 0 ifTrue: [Display reverse: marker].
-     Cursor normal showWhile: aBlock.
+     result := Cursor normal showWhile: aBlock.
    savedArea displayOn: Display at: frameSaveLoc.
    captionOrNil notNil ifTrue:
-         [captionSave displayOn: Display at: captionBox topLeft]
+         [captionSave displayOn: Display at: captionBox topLeft].
+     ^ result

SystemProgressMorph class>>informUserAt:during: {instance creation} · ct 5/25/2022 22:34 (changed)
informUserAt: aPoint during: workBlock
-     ProgressInitiationException 
+     ^ ProgressInitiationException 
        display: ' '
        at: aPoint 
        from: 0 
        to: 0 
        during: workBlock

UIManagerTest>>testInformUserDuring {tests} · ct 5/25/2022 22:37
+ testInformUserDuring
+ 
+     self assert: 42 equals:
+         (Project uiManager informUser: 'test' during: [6 * 7]).

---
Sent from Squeak Inbox Talk
["informUserDuringResult.2.cs"]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220525/692efc9c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: informUserDuringResult.2.cs
Type: application/octet-stream
Size: 6024 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220525/692efc9c/attachment.obj>


More information about the Squeak-dev mailing list