Skip to content

Commit

Permalink
core: fixes to block-collapse-by-default
Browse files Browse the repository at this point in the history
  • Loading branch information
tom95 committed Sep 22, 2023
1 parent aedf2da commit 9230635
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
8 changes: 7 additions & 1 deletion packages/Sandblocks-TreeSitter/SBFileEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Class {
#category : #'Sandblocks-TreeSitter-Files'
}

{ #category : #'as yet unclassified' }
SBFileEditor class >> for: aPath [

self openProject: aPath
]

{ #category : #'as yet unclassified' }
SBFileEditor class >> openProject: aPath [

Expand Down Expand Up @@ -119,7 +125,7 @@ SBFileEditor >> openFile: aFile [
aFile isDirectory ifFalse: [ | newFile |
newFile := (SBToggledCode
comment: ''
active: 2
active: 1
do: {[SBTSFile forNoReplace: aFile pathString]. [SBTSFile for: aFile pathString]}) ifNil: [^ nil].
self openMorphInView: newFile.
self runtimesDo: [:r | r didOpen: newFile].
Expand Down
12 changes: 10 additions & 2 deletions packages/Sandblocks-TreeSitter/SBTSCollapsed.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SBTSCollapsed >> block: aBlock [
{ #category : #'as yet unclassified' }
SBTSCollapsed >> color [

^ block color
^ self parentSandblock drawnColor
]

{ #category : #'as yet unclassified' }
Expand All @@ -41,10 +41,18 @@ SBTSCollapsed >> initialize [

self
layoutInset: 2;
changeTableLayout;
layoutPolicy: SBAlgebraLayout new;
cellGap: 4
]

{ #category : #'as yet unclassified' }
SBTSCollapsed >> layoutCommands [

^ SBAlgebraCommand container
data: {self firstSubmorph layoutCommands};
morph: self
]

{ #category : #'as yet unclassified' }
SBTSCollapsed >> printOn: aStream [

Expand Down
11 changes: 9 additions & 2 deletions packages/Sandblocks-TreeSitter/SBTSLanguage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ SBTSLanguage class >> canParse: aString [

{ #category : #configuration }
SBTSLanguage class >> collapseAll: aBlock [
"can be implemented by the respective languages"
<action>


aBlock allMorphsDepthFirstDo: [:m | (m isTSBlock and: [m class ~= SBTSCollapsed and: [self shouldCollapse: m]]) ifTrue: [m replaceBy: (SBTSCollapsed new block: m)]].
^ aBlock
]

{ #category : #configuration }
Expand Down Expand Up @@ -569,6 +570,12 @@ SBTSLanguage class >> scopesAround: aBlock do: aClosure [
current := current parentSandblock]
]

{ #category : #'as yet unclassified' }
SBTSLanguage class >> shouldCollapse: aBlock [

^ false
]

{ #category : #configuration }
SBTSLanguage class >> shouldSkipParsing: aTypeString cursor: aCursor [

Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-TreeSitter/SBVisExample.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Class {

{ #category : #'as yet unclassified' }
SBVisExample >> build [
<lang: #typescript match: '(call_expression (arguments . (expression) @render (string (string_fragment) @color)))' sample: 'visualize(random_points(), "red")' keyword: 'visualize'>
<lang: #typescript match: '(call_expression (identifier) ="random_points" (arguments . (expression) @render (string (string_fragment) @color)))' sample: 'visualize(random_points(), "red")' keyword: 'visualize'>

self layoutInset: 4.
self addMorphBack: (self createBindingBlock: 'render').
Expand Down
6 changes: 6 additions & 0 deletions packages/Sandblocks-Typescript/SBTypescript.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11160,6 +11160,12 @@ SBTypescript class >> rootRuleName [
^ 'program'
]

{ #category : #configuration }
SBTypescript class >> shouldCollapse: aBlock [

^ aBlock type = #'statement_block'
]

{ #category : #configuration }
SBTypescript class >> softLineBreakBetween: aBlock and: anotherBlock [

Expand Down

0 comments on commit 9230635

Please sign in to comment.