<body><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
Hi Levente,<div><br></div><div>nice! :-) For the background process, I would either closure "view" or check for nil because any do-it in the UI process might re-configure the styler. </div><div><br></div><div>Best,</div><div>Marcel</div><div class="mb_sig"></div><blockquote class="history_container" type="cite" style="border-left-style:solid;border-width:1px; margin-top:20px; margin-left:0px;padding-left:10px;">
<p style="color: #AAAAAA; margin-top: 10px;">Am 09.07.2019 23:00:45 schrieb commits@source.squeak.org <commits@source.squeak.org>:</p><div style="font-family:Arial,Helvetica,sans-serif">Levente Uzonyi uploaded a new version of ShoutCore to project The Inbox:<br>http://source.squeak.org/inbox/ShoutCore-ul.65.mcz<br><br>==================== Summary ====================<br><br>Name: ShoutCore-ul.65<br>Author: ul<br>Time: 9 July 2019, 11:00:06.496443 pm<br>UUID: 5b4b23fe-b7de-4498-a16b-80959cfb1e62<br>Ancestors: ShoutCore-mt.64<br><br>Further SHTextStyler refactorings:<br>- replaced text instance variable with temporiaries<br>- removed monitor. backgroundProcess consistency is ensured by atomic execution of certain instructions<br>- 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<br><br>=============== Diff against ShoutCore-mt.64 ===============<br><br>Item was changed:<br> Object subclass: #SHTextStyler<br>+ instanceVariableNames: 'backgroundProcess view stylingEnabled'<br>- instanceVariableNames: 'backgroundProcess text monitor view stylingEnabled'<br> classVariableNames: ''<br> poolDictionaries: ''<br> category: 'ShoutCore-Styling'!<br> <br> !SHTextStyler commentStamp: 'tween 8/27/2004 10:54' prior: 0!<br> I am an Abstract class.<br> Subclasses of me can create formatted, coloured, and styled copies of Text that is given to them.<br> They may perform their styling asynchronously, in a background process which I create and manage.<br> <br> My public interface is...<br> <br> view: aViewOrMorph - set the view that will receive notifications when styling has completed.<br> <br> format: aText - modifies aText's string<br> <br> style: aText - modifies the TextAttributes of aText, but does not change the string, then sends #stylerStyled: to the view.<br> <br> styleInBackgroundProcess: aText - performs style: in a background process, then sends #stylerStylednBackground: to the view.<br> <br> styledTextFor: aText - answers a formatted and styled copy of aText<br> <br> unstyledTextFrom: aText - answers a copy of aText with all TextAttributes removed<br> <br> Subclasses of me should re-implement...<br> <br> privateFormat: aText - answer a formatted version of aText; the String may be changed<br> privateStyle: aText - modify the TextAttributes of aText; but do not change the String<br> <br> <br> <br> <br> !<br><br>Item was removed:<br>- ----- Method: SHTextStyler>>monitor (in category 'private') -----<br>- monitor<br>- ^monitor ifNil: [monitor := Monitor new]!<br><br>Item was changed:<br> ----- Method: SHTextStyler>>style: (in category 'styling') -----<br> style: aText<br>+ <br>+ | text |<br> self terminateBackgroundStylingProcess.<br>+ stylingEnabled ifFalse: [ ^self ].<br>+ text := aText copy.<br>+ self privateStyle: text.<br>+ view stylerStyled: text!<br>- stylingEnabled ifTrue:[<br>- text := aText copy.<br>- self privateStyle: text.<br>- view ifNotNil:[view stylerStyled: text] ]!<br><br>Item was changed:<br> ----- Method: SHTextStyler>>styleInBackgroundProcess: (in category 'styling') -----<br> styleInBackgroundProcess: aText<br> <br>+ | text newBackgroundProcess |<br> self terminateBackgroundStylingProcess.<br>+ stylingEnabled ifFalse: [ ^self ].<br>+ text := aText copy.<br>+ newBackgroundProcess := [<br>+ self privateStyle: text.<br>+ Project current addDeferredUIMessage: [<br>+ view stylerStyledInBackground: text ].<br>+ Processor activeProcess == backgroundProcess ifTrue: [<br>+ backgroundProcess := nil ] ] newProcess<br>+ priority: Processor userBackgroundPriority;<br>+ yourself.<br>+ backgroundProcess ifNil: [<br>+ (backgroundProcess := newBackgroundProcess) resume ]!<br>- <br>- stylingEnabled ifTrue: [<br>- text := aText copy.<br>- self monitor critical: [<br>- backgroundProcess := [<br>- self privateStyle: text.<br>- view ifNotNil: [:v | Project current addDeferredUIMessage: [v stylerStyledInBackground: text]].<br>- ] forkAt: Processor userBackgroundPriority] ]<br>- !<br><br>Item was changed:<br> ----- Method: SHTextStyler>>terminateBackgroundStylingProcess (in category 'private') -----<br> terminateBackgroundStylingProcess<br>+ "Terminate the background styling process if it exists. Assume that the first two lines are executed atomically."<br> <br>+ backgroundProcess ifNotNil: [ :backgroundProcessToTerminate |<br>+ backgroundProcess := nil.<br>+ backgroundProcessToTerminate terminate ]!<br>- self monitor critical: [<br>- backgroundProcess <br>- ifNotNil: [<br>- backgroundProcess terminate.<br>- backgroundProcess := nil]].!<br><br>Item was changed:<br> ----- Method: SHTextStyler>>veryDeepInner: (in category 'copying') -----<br> veryDeepInner: aDeepCopier<br>+ <br> super veryDeepInner: aDeepCopier.<br>+ backgroundProcess := nil.<br>- backgroundProcess := monitor := nil.<br>- text := text veryDeepCopyWith: aDeepCopier.<br> view := view veryDeepCopyWith: aDeepCopier!<br><br><br></div></blockquote>
</div></body>