Skip to content

Commit

Permalink
core: for click-to-add, move cursor to next insert pos after inserted
Browse files Browse the repository at this point in the history
  • Loading branch information
tom95 committed Feb 21, 2022
1 parent d826c8e commit 2f6f58c
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 5 deletions.
6 changes: 6 additions & 0 deletions packages/Sandblocks-Core/SBCursorInsert.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ SBCursorInsert >> isDistinctFrom: aPosition [
ifFalse: [self ~= aPosition]
]

{ #category : #testing }
SBCursorInsert >> isInsert [

^ true
]

{ #category : #'as yet unclassified' }
SBCursorInsert >> leaveIn: anEditor with: aCursor [

Expand Down
6 changes: 6 additions & 0 deletions packages/Sandblocks-Core/SBCursorMultiSelect.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ SBCursorMultiSelect >> initialize [
selected := OrderedCollection new
]

{ #category : #testing }
SBCursorMultiSelect >> isMultiSelect [

^ true
]

{ #category : #'as yet unclassified' }
SBCursorMultiSelect >> leaveIn: anEditor with: aCursor [

Expand Down
24 changes: 24 additions & 0 deletions packages/Sandblocks-Core/SBCursorPosition.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,30 @@ SBCursorPosition >> isDistinctFrom: aPosition [
^ self ~= aPosition
]

{ #category : #testing }
SBCursorPosition >> isInsert [

^ false
]

{ #category : #testing }
SBCursorPosition >> isMultiSelect [

^ false
]

{ #category : #testing }
SBCursorPosition >> isSelect [

^ false
]

{ #category : #testing }
SBCursorPosition >> isText [

^ false
]

{ #category : #'as yet unclassified' }
SBCursorPosition >> leaveIn: anEditor with: aCursor [

Expand Down
6 changes: 6 additions & 0 deletions packages/Sandblocks-Core/SBCursorSelect.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ SBCursorSelect >> horizontalOffsetInFloat [
ifNil: [self bounds center x]
]

{ #category : #testing }
SBCursorSelect >> isSelect [

^ true
]

{ #category : #'as yet unclassified' }
SBCursorSelect >> minimalBounds [

Expand Down
6 changes: 6 additions & 0 deletions packages/Sandblocks-Core/SBCursorText.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ SBCursorText >> initialize [
cursorIndex := 1
]

{ #category : #testing }
SBCursorText >> isText [

^ true
]

{ #category : #'as yet unclassified' }
SBCursorText >> leaveIn: anEditor with: aCursor [

Expand Down
25 changes: 20 additions & 5 deletions packages/Sandblocks-Core/SBPalettePreviewContainer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ SBPalettePreviewContainer >> initialize [
addMouseCaptureFilter: self
]

{ #category : #'as yet unclassified' }
SBPalettePreviewContainer >> insertCursorAfter: aMorph [

| afterSelf referenceBlock |
afterSelf := false.
referenceBlock := aMorph firstBlock.
aMorph parentSandblock cursorPositionsDo: [:c |
c block = referenceBlock ifTrue: [afterSelf := true].
(afterSelf and: [c isInsert and: [c container ~= aMorph and: [(c container hasOwner: aMorph) not]]]) ifTrue: [^ self sandblockEditor cursor cursorPosition: c explicitMove: true axis: #none]]
]

{ #category : #'as yet unclassified' }
SBPalettePreviewContainer >> intoWorld: aWorld [

Expand Down Expand Up @@ -112,13 +123,17 @@ SBPalettePreviewContainer >> wasSelectedFromCursor: aCursorPosition [
super wasSelectedFromCursor: aCursorPosition.

aCursorPosition mode = #insert ifTrue: [
(aCursorPosition command canInsert: self firstSubmorph do: [:morph |
aCursorPosition command canInsert: self firstSubmorph do: [:morph |
aCursorPosition command
morph: morph;
do.
Project current addDeferredUIMessage: [
self sandblockEditor cursor
cursorPosition: aCursorPosition
explicitMove: true
axis: #none]])]
SBToggledCode comment: '' active: 1 do: {
[self insertCursorAfter: morph].
[morph firstBlock select].
[
self sandblockEditor cursor
cursorPosition: aCursorPosition
explicitMove: true
axis: #none]}]]]
]

0 comments on commit 2f6f58c

Please sign in to comment.