Levente Uzonyi uploaded a new version of ShoutCore to project The Trunk:
http://source.squeak.org/trunk/ShoutCore-ul.65.mcz ==================== Summary ==================== Name: ShoutCore-ul.65 Author: ul Time: 9 July 2019, 11:00:06.496443 pm UUID: 5b4b23fe-b7de-4498-a16b-80959cfb1e62 Ancestors: ShoutCore-mt.64 Further SHTextStyler refactorings: - replaced text instance variable with temporiaries - removed monitor. backgroundProcess consistency is ensured by atomic execution of certain instructions - assume that view is never nil. It makes no sense to style when there's no view, and view is always assigned once, when a styler instance is created =============== Diff against ShoutCore-mt.64 =============== Item was changed: Object subclass: #SHTextStyler + instanceVariableNames: 'backgroundProcess view stylingEnabled' - instanceVariableNames: 'backgroundProcess text monitor view stylingEnabled' classVariableNames: '' poolDictionaries: '' category: 'ShoutCore-Styling'! !SHTextStyler commentStamp: 'tween 8/27/2004 10:54' prior: 0! I am an Abstract class. Subclasses of me can create formatted, coloured, and styled copies of Text that is given to them. They may perform their styling asynchronously, in a background process which I create and manage. My public interface is... view: aViewOrMorph - set the view that will receive notifications when styling has completed. format: aText - modifies aText's string style: aText - modifies the TextAttributes of aText, but does not change the string, then sends #stylerStyled: to the view. styleInBackgroundProcess: aText - performs style: in a background process, then sends #stylerStylednBackground: to the view. styledTextFor: aText - answers a formatted and styled copy of aText unstyledTextFrom: aText - answers a copy of aText with all TextAttributes removed Subclasses of me should re-implement... privateFormat: aText - answer a formatted version of aText; the String may be changed privateStyle: aText - modify the TextAttributes of aText; but do not change the String ! Item was removed: - ----- Method: SHTextStyler>>monitor (in category 'private') ----- - monitor - ^monitor ifNil: [monitor := Monitor new]! Item was changed: ----- Method: SHTextStyler>>style: (in category 'styling') ----- style: aText + + | text | self terminateBackgroundStylingProcess. + stylingEnabled ifFalse: [ ^self ]. + text := aText copy. + self privateStyle: text. + view stylerStyled: text! - stylingEnabled ifTrue:[ - text := aText copy. - self privateStyle: text. - view ifNotNil:[view stylerStyled: text] ]! Item was changed: ----- Method: SHTextStyler>>styleInBackgroundProcess: (in category 'styling') ----- styleInBackgroundProcess: aText + | text newBackgroundProcess | self terminateBackgroundStylingProcess. + stylingEnabled ifFalse: [ ^self ]. + text := aText copy. + newBackgroundProcess := [ + self privateStyle: text. + Project current addDeferredUIMessage: [ + view stylerStyledInBackground: text ]. + Processor activeProcess == backgroundProcess ifTrue: [ + backgroundProcess := nil ] ] newProcess + priority: Processor userBackgroundPriority; + yourself. + backgroundProcess ifNil: [ + (backgroundProcess := newBackgroundProcess) resume ]! - - stylingEnabled ifTrue: [ - text := aText copy. - self monitor critical: [ - backgroundProcess := [ - self privateStyle: text. - view ifNotNil: [:v | Project current addDeferredUIMessage: [v stylerStyledInBackground: text]]. - ] forkAt: Processor userBackgroundPriority] ] - ! Item was changed: ----- Method: SHTextStyler>>terminateBackgroundStylingProcess (in category 'private') ----- terminateBackgroundStylingProcess + "Terminate the background styling process if it exists. Assume that the first two lines are executed atomically." + backgroundProcess ifNotNil: [ :backgroundProcessToTerminate | + backgroundProcess := nil. + backgroundProcessToTerminate terminate ]! - self monitor critical: [ - backgroundProcess - ifNotNil: [ - backgroundProcess terminate. - backgroundProcess := nil]].! Item was changed: ----- Method: SHTextStyler>>veryDeepInner: (in category 'copying') ----- veryDeepInner: aDeepCopier + super veryDeepInner: aDeepCopier. + backgroundProcess := nil. - backgroundProcess := monitor := nil. - text := text veryDeepCopyWith: aDeepCopier. view := view veryDeepCopyWith: aDeepCopier! |
Free forum by Nabble | Edit this page |