Skip to content

Commit

Permalink
tutorial: extend final slide; st: fix inset for block bindings always…
Browse files Browse the repository at this point in the history
… appearing
  • Loading branch information
tom95 committed Apr 1, 2021
1 parent 30f7441 commit a44cf8c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 16 deletions.
9 changes: 6 additions & 3 deletions packages/Sandblocks-Smalltalk/SBStBlockBody.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,19 @@ SBStBlockBody >> isMethodBody [
{ #category : #'as yet unclassified' }
SBStBlockBody >> layoutCommands [

| preamble preambleHasContent |
preamble := self firstSubmorph layoutCommands.
| preamble preambleHasContent multiLine |
multiLine := self statementCount > 1 or: [temporaries hasSubmorphs].
preambleHasContent := bindings hasSubmorphs or: [temporaries hasSubmorphs].
preamble := SBAlgebraCommand container
morph: self firstSubmorph;
data: ((self firstSubmorph submorphs select: #visible) collect: #layoutCommands separatedBy: [bindings hasSubmorphs ifTrue: [SBAlgebraCommand softLineOrGap] ifFalse: [SBAlgebraCommand noop]]).

self statementCount = 0 ifTrue: [
^ SBAlgebraCommand container
morph: self;
data: {preamble}].

^ (self statementCount > 1 or: [temporaries hasSubmorphs])
^ multiLine
ifTrue: [
SBAlgebraCommand container
morph: self;
Expand Down
6 changes: 3 additions & 3 deletions packages/Sandblocks-Smalltalk/SBStMethodCategory.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Class {
SBStMethodCategory >> addMethods [

(self relatedClass organization listAtCategoryNamed: savedCategoryName) sorted do: [:method |
self addMorphBack: ((class lookupSelector: method) asSandblock
toggleCollapsed;
hResizing: #spaceFill)]
self addMorphBack: ((class lookupSelector: method) asSandblock
toggleCollapsed;
hResizing: #spaceFill)]
]

{ #category : #'as yet unclassified' }
Expand Down
13 changes: 13 additions & 0 deletions packages/Sandblocks-Tutorial/SBSortExample.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Class {
#name : #SBSortExample,
#superclass : #Object,
#category : #'Sandblocks-Tutorial'
}

{ #category : #sorting }
SBSortExample >> partition: aCollection low: aLowNumber high: aHighNumber [
]

{ #category : #sorting }
SBSortExample >> quicksort: aCollection low: aLowNumber high: aHighNumber [
]
27 changes: 17 additions & 10 deletions packages/Sandblocks-Tutorial/SBTutorialStep.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ SBTutorialStep class >> checkIsComplete: aMethodSymbol index: aNumber [
^ self progress at: aMethodSymbol ifPresent: [:list | list includes: aNumber] ifAbsent: [false]
]

{ #category : #helper }
SBTutorialStep class >> copyClass: aClass in: anEditor [

| newClass |
newClass := Compiler evaluate: ((aClass definition
copyReplaceAll: aClass name
with: (aClass name copyFrom: 3 to: aClass name size - 'Example' size), DateAndTime now asUnixTime)
copyReplaceAll: aClass category
with: 'UserObjects').
newClass copyAllCategoriesFrom: aClass.
anEditor open: (SBStClassMethodEditor new
class: newClass;
expandAll)
]

{ #category : #progress }
SBTutorialStep class >> hasProgress: aSymbol [

Expand Down Expand Up @@ -224,16 +239,8 @@ SBTutorialStep class >> stepFinal: anEditor [
SBTutorialStep new
title: 'Congratulations!';
addIntroText: 'You finished the tutorial, well done! Press the button below to create a copy of an example class where you can freely experiment with the shortcuts or jump into any existing Smalltalk method using <#openOpenWindow> (then use <Cmd+f> to directly jump to a class).';
addMorphBack: (SBButton new icon: SBIcon iconFlask label: 'Open Example Class' do: [ | newClass |
newClass := Compiler evaluate: ((SBObservableExample definition
copyReplaceAll: SBObservableExample name
with: 'Observable', DateAndTime now asUnixTime)
copyReplaceAll: SBObservableExample category
with: 'UserObjects').
newClass copyAllCategoriesFrom: SBObservableExample.
anEditor open: (SBStClassMethodEditor new
class: newClass;
expandAll)]);
addMorphBack: (SBButton new icon: SBIcon iconFlask label: 'Open Example Class' do: [self copyClass: SBObservableExample in: anEditor]);
addMorphBack: (SBButton new icon: SBIcon iconFlask label: 'Open Example Methods' do: [self copyClass: SBSortExample in: anEditor]);
setup: anEditor do: [:editor | ]
]

Expand Down

0 comments on commit a44cf8c

Please sign in to comment.