Class Text : category 'emphasis' - method #allBold BUT NO #allItalics?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Class Text : category 'emphasis' - method #allBold BUT NO #allItalics?

Hannes Hirzel
Hello

there is a method #allBold in class Text


allBold
        "Force this whole text to be bold."
        string size = 0 ifTrue: [^self].
        self makeBoldFrom: 1 to: string size


but no method allItalics

That would be something like


allItalics
        string size = 0 ifTrue: [^self].
        self addAttribute: TextEmphasis italic from: 1 to: string size.


Should this be added?


Regards

Hannes

Reply | Threaded
Open this post in threaded view
|

Re: Class Text : category 'emphasis' - method #allBold BUT NO #allItalics?

timrowledge


> On 06-07-2018, at 1:30 AM, H. Hirzel <[hidden email]> wrote:
> [snip]
> allItalics
> string size = 0 ifTrue: [^self].
> self addAttribute: TextEmphasis italic from: 1 to: string size.
>
>
> Should this be added?

Well, it certainly isn't an expensive method to add, so one could say "certainly! go for it!". Given that there's a modest number of text emphases involved (bold, underline, strikeout, italic, regular, maybe one day 'styled by shout') it wouldn't be ridiculous to have each one covered.

On the other hand, where does one stop? It's always tricky. I suppose one argument would be "if it was useful it would be there already" but that devolves rapidly into the sort of nonsense you see from naive wannabe economists. In this case, you've done the work to write it, it's small and simple, so stick it in.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
"Bother" said Pooh, as the IRS kicked his door in.