A new version of ToolBuilder-Morphic was added to project The Inbox:
http://source.squeak.org/inbox/ToolBuilder-Morphic-ct.234.mcz ==================== Summary ==================== Name: ToolBuilder-Morphic-ct.234 Author: ct Time: 5 August 2019, 2:50:11.900062 pm UUID: f6987fae-9cfa-4e44-927f-247f4eeb868e Ancestors: ToolBuilder-Morphic-mt.233 Extend #updateStyle(Now) to remove obsolete styling A call of #updateStyle(Now) implies that the text morph is used for styling, so it is not capable of storing other styles we could accidentally delete here. =============== Diff against ToolBuilder-Morphic-mt.233 =============== Item was changed: ----- Method: PluggableTextMorphPlus>>updateStyle (in category 'styling') ----- updateStyle self okToStyle + ifTrue: [styler styleInBackgroundProcess: textMorph contents] + ifFalse: [textMorph contents: textMorph contents asString].! - ifTrue: [styler styleInBackgroundProcess: textMorph contents].! Item was changed: ----- Method: PluggableTextMorphPlus>>updateStyleNow (in category 'styling') ----- updateStyleNow self okToStyle + ifTrue: [styler style: textMorph contents] + ifFalse: [textMorph contents: textMorph contents asString].! - ifTrue: [styler style: textMorph contents].! |
Hi Christoph, this is not working. We have to support manual styling and cannot just remove text attributes there. Maybe if we check whether "styer" is set. Even then, we should follow the logic in PluggableTextMorphPlus >> #stylerStyled: to remove those text attributes. Btw: You can style a piece of text manually via the context menu or [CMD]+[6..0]. Best, Marcel
|
Hi Marcel,
ok, I assumed #updateStyle would be only sent if styling is active, but I was wrong. I knew this handy styling shortcut before, and just found out that your proposed condition maybe would not be sufficient: As Shout preserves some styles (for example TextDoIts), it would be a pity to delete them when you disable syntax highlighting in Workspace. This is also what happens in Squeak-5.2, so I would like to keep Tools-ct.867.
Just one proposal to solve this:
updateStyleNow
styler ifNil: [^ self].
self okToStyle
ifTrue: [styler style: textMorph contents]
ifFalse: [textMorph contents: (styler unstyledTextFrom: textMorph contents)].
(#updateStyle analogously)
This preserves custom stylings when you toggle styling in Workspace.
---
It still does not work perfect, I think there are kept too many attributes after toggling styling off:
(custom attributes: one TextDoIt, one TextURL)
becomes to
I wonder why #unstyledTextFrom: handles all attributes on this binary way? I changed it
unstyledTextFrom: aText
"Re-implemented so that TextActions are not removed from aText"
| answer |
answer := super unstyledTextFrom: aText.
aText runs withStartStopAndValueDo: [:start :stop :attribs |
+ attribs
+ select: [:each | each shoutShouldPreserve]
+ thenDo: [:each | answer addAttribute: each from: start to: stop]].
- (attribs anySatisfy: [:each | each shoutShouldPreserve])
- ifTrue: [
- attribs do: [:eachAttrib | answer addAttribute: eachAttrib from: start to: stop]]].
^answer
and it looks like this:
Are there any reasons for the current implementation of #unstyledTextFrom:? Looking forward to your opinions :)
Best,
Christoph
Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Dienstag, 6. August 2019 09:22:37 An: John Pfersich via Squeak-dev Betreff: Re: [squeak-dev] The Inbox: ToolBuilder-Morphic-ct.234.mcz
Hi Christoph,
this is not working. We have to support manual styling and cannot just remove text attributes there. Maybe if we check whether "styer" is set. Even then, we should follow the logic in PluggableTextMorphPlus >> #stylerStyled: to remove those text attributes.
Btw: You can style a piece of text manually via the context menu or [CMD]+[6..0].
Best,
Marcel
Carpe Squeak!
|
Hi, there. There has to be a way to allow manual styling in workspaces. This doesn't do it: Yeah, I have no idea, why #unstyledTextFrom: keeps so many attributes. Has been this way like forever: Best, Marcel
|
Hi,
what exactly "doesn't do" it? Toggling styling and keeping custom stylings in Workspace by using the version from your screenshot worked for me.
#unstyledTextFrom: - are there any tests for this behavior? Should we change the implementation in the Inbox?
Best, Christoph Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Dienstag, 6. August 2019 16:00:37 An: John Pfersich via Squeak-dev Betreff: Re: [squeak-dev] The Inbox: ToolBuilder-Morphic-ct.234.mcz
Hi, there.
There has to be a way to allow manual styling in workspaces. This doesn't do it:
Yeah, I have no idea, why #unstyledTextFrom: keeps so many attributes. Has been this way like forever:
Best,
Marcel
Carpe Squeak!
|
Hi Christoph, - type something - select something - hit CMD+6 or 7 or 8 to style something That must work. :-) Best, Marcel
|
Hi Marcel,
I got it :) If it is not ok to style, #updateStyle will periodically reset all attributes possibly relating to Shout. One option would be to remove these styles once in Workspace>>#toggleStyling:. Or we could introduce a state variable for this purpose in PluggableTextMorphPlus itself.
Another approach: Maybe I misunderstood Tim Rowledge, but would it be an option to introduce an additional TextAttribute that assigns substrings to Shout? Such a TextSyntaxHighlight style would complement the effect of Morphic-mt.1498, but also allow you, for example, to format a code example in a class comment without hard-coding the current ui theme & environment. In Workspace, #toggleStyling then could add or remove such an attribute from the whole text.
One open question would be where to store the styling information? But I think it could be left in the styler instance, so TextSyntaxHighlight would only specify that something should be styled, but #aboutToStyle: was responsible for specifying the contextual information.
Best, Christoph Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Mittwoch, 7. August 2019 09:38:53 An: John Pfersich via Squeak-dev; [hidden email] Betreff: Re: [squeak-dev] The Inbox: ToolBuilder-Morphic-ct.234.mcz Hi Christoph,
- type something
- select something
- hit CMD+6 or 7 or 8 to style something
That must work. :-)
Best,
Marcel
Carpe Squeak!
|
Free forum by Nabble | Edit this page |