Skip to content

Commit

Permalink
remanent portion update is more efficient
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Apr 20, 2023
1 parent 7cf09d9 commit 6583316
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Album-Brick-NU/AlbTextAdornmentStencilBuilder.class.st
@@ -1,6 +1,6 @@
Class {
#name : #AlbTextAdornmentStencilBuilder,
#superclass : #BrStencilBuilder,
#superclass : #AnObsoleteBrStencilBuilder,
#instVars : [
'editorElement',
'segmentPiece'
Expand Down
16 changes: 11 additions & 5 deletions src/Album/AlbRemanentsUpdater.class.st
Expand Up @@ -71,16 +71,19 @@ AlbRemanentsUpdater >> createPortionsIn: anEditorElement [
| collector subTextOnScreen founds |
monitor critical: [
self terminateUpdater.
self resetPortions.
self remanentText ifNil: [ ^ self ].
self remanentText ifEmpty: [ ^ self ].
subTextOnScreen := anEditorElement subTextOnScreen.
updaterProcess := [
(Delay forMilliseconds: self updateDelay) wait.
collector := BlIntervalCollector new text: subTextOnScreen asString.
founds := collector searchAll: self remanentString.
founds do: [ :interval | self portionInterval: interval + subTextOnScreen textOffset in: anEditorElement ].
anEditorElement frontLayer addChildren: (portions reject: [ :r | r hasParent ]).
anEditorElement selectedText asString = self remanentString
ifTrue: [
collector := BlIntervalCollector new text: subTextOnScreen asString.
founds := collector searchAll: self remanentString.
self resetPortions.
founds do: [ :interval |
self portionInterval: interval + subTextOnScreen textOffset in: anEditorElement ].
anEditorElement frontLayer addChildren: (portions reject: [ :r | r hasParent ])].
updaterProcess := nil ]
forkAt: Processor systemBackgroundPriority
named: 'Album remanent selection updater task' ]
Expand All @@ -97,6 +100,7 @@ AlbRemanentsUpdater >> cursorMovedIn: anEditorElement [
{ #category : #'infinite element changes' }
AlbRemanentsUpdater >> extentChangedIn: anEditorElement [

self resetPortions.
super extentChangedIn: anEditorElement.
self updateOppositeDelimiterIn: anEditorElement

Expand Down Expand Up @@ -184,6 +188,7 @@ AlbRemanentsUpdater >> remanentText [
{ #category : #'infinite element changes' }
AlbRemanentsUpdater >> scrollEventIn: anEditorElement [

self resetPortions.
super scrollEventIn: anEditorElement.
self updateOppositeDelimiterIn: anEditorElement

Expand All @@ -194,6 +199,7 @@ AlbRemanentsUpdater >> selectionChangedIn: anEditorElement [

super selectionChangedIn: anEditorElement.
remanentText := anEditorElement selectedText.
remanentText ifEmpty: [ ^ self resetPortions ].
self createPortionsIn: anEditorElement.
self updateOppositeDelimiterIn: anEditorElement
]
Expand Down
6 changes: 4 additions & 2 deletions src/Album/AlbTextPortionUpdater.class.st
Expand Up @@ -41,7 +41,9 @@ AlbTextPortionUpdater >> onInstalledIn: anEditorElement [
on: AlbCursorMovedEvent
do: [ :evt |
self cursorMovedIn: anEditorElement ].
selectionHandler := BlEventHandler on: AlbSelectionChangedEvent do: [ self selectionChangedIn: anEditorElement ].
selectionHandler := BlEventHandler
on: AlbSelectionChangedEvent
do: [ self selectionChangedIn: anEditorElement ].
extentChangeHandler := BlEventHandler
on: BlElementExtentChangedEvent
do: [ :evt |
Expand Down Expand Up @@ -122,7 +124,7 @@ AlbTextPortionUpdater >> textEditedIn: anInfiniteElement [
{ #category : #private }
AlbTextPortionUpdater >> updateDelay [

^ 50
^ 20
]

{ #category : #'infinite element changes' }
Expand Down

0 comments on commit 6583316

Please sign in to comment.