<body><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
                                        Btw: Have you found and read all current implementors of #withNoLineLongerThan: yet? :-)<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 06.04.2022 21:00:00 schrieb Marcel Taeumel <marcel.taeumel@hpi.de>:</p><div style='font-family:Arial,Helvetica,sans-serif'><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
                                        > <span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">Maybe just #lineWidth or #lineWidthInCharacters?</span><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">Nope. #lineWidth is too generic. "inCharacters" is an uncommon modifier of a selector.</span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">Best,</span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">Marcel</span></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 06.04.2022 20:57:22 schrieb Thiede, Christoph <christoph.thiede@student.hpi.uni-potsdam.de>:</p><div style='font-family:Arial,Helvetica,sans-serif'>

<div id="divtagdefaultwrapper" style="font-size: 12pt;color: #000000;font-family: Calibri,Helvetica,sans-serif" dir="ltr">
<p>Hi Marcel,</p>
<p><br>
</p>
<p>> <span style="font-size: 12pt">And what's so wrong with reading a method's comment if you are wondering about its effects?</span></p>
<div><br>
</div>
<div>The comments make things clear, I was just wondering whether we could find a better selector name for a more intuitive first impression. :-)</div>
<div><br>
</div>
<div>But I'm not sure myself what could be a better name. Hm ... "average characters per line" is just a unit ... Maybe just #lineWidth or #lineWidthInCharacters?</div>
<div><br>
</div>
<div>Best,</div>
<div>Christoph</div>
<p></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><span style="font-family: Calibri, sans-serif;color: #000000"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Taeumel, Marcel<br>
<b>Gesendet:</b> Mittwoch, 6. April 2022 20:51:36<br>
<b>An:</b> squeak-dev<br>
<b>Betreff:</b> Re: [squeak-dev] The Trunk: Morphic-mt.1933.mcz</span>
<div> </div>
</div>
<div>
<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
Hi Christoph --
<div><br>
</div>
<div>I don't understand what you are suggesting here. Can you elaborate?</div>
<div><br>
</div>
<div>Do you want to have the word "average" in the name as well? Or "preferred"? It depends on the font that you are using. If you are using a monospaced font, then you get the same results as #withNoLineLongerThan:.</div>
<div><br>
</div>
<div>And what's so wrong with reading a method's comment if you are wondering about its effects?</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;min-width: 500px">
<p style="color: #AAAAAA; margin-top: 10px;">Am 06.04.2022 18:39:29 schrieb christoph.thiede@student.hpi.uni-potsdam.de <christoph.thiede@student.hpi.uni-potsdam.de>:</p>
<div style="font-family:Arial,Helvetica,sans-serif">Hi Marcel,<br>
<br>
I wonder whether this name could be confusing until you read the comment in TextMorph, as this does something different than #withNoLineLongerThan: if I understood correctly:<br>
<br>
    <span style="color: #800000">self</span><span style="color: #000000"> </span>
<span style="color: #000080">inform:</span><span style="color: #000000"> </span><span style="color: #000000">(</span><span style="color: #000000">String</span><span style="color: #000000">
</span><span style="color: #000080">new:</span><span style="color: #000000"> </span>
<span style="color: #800000">100</span><span style="color: #000000"> </span><span style="color: #000080">withAll:</span><span style="color: #000000">
</span><span style="color: #800000">$</span><span style="color: #800000">l</span><span style="color: #000000">)</span><span style="color: #000000">
</span><span style="color: #000080">,</span><span style="color: #000000"> </span>
<span style="color: #000000">(</span><span style="color: #000000">String</span><span style="color: #000000">
</span><span style="color: #000080">new:</span><span style="color: #000000"> </span>
<span style="color: #800000">100</span><span style="color: #000000"> </span><span style="color: #000080">withAll:</span><span style="color: #000000">
</span><span style="color: #800000">$</span><span style="color: #800000">m</span><span style="color: #000000">)</span><br>
<br>
What do you think? :)<br>
<br>
Best,<br>
Christoph<br>
<br>
<span style="color: #808080">---<br>
</span><span style="color: #808080"><i>Sent from </i></span><span style="color: #808080"><i><a href="https://github.com/hpi-swa-lab/squeak-inbox-talk"><u><span style="color: #808080">Squeak Inbox Talk</span></u></a></i></span><br>
<br>
On 2022-03-14T14:52:41+00:00, commits@source.squeak.org wrote:<br>
<br>
> Marcel Taeumel uploaded a new version of Morphic to project The Trunk:<br>
> http://source.squeak.org/trunk/Morphic-mt.1933.mcz<br>
> <br>
> ==================== Summary ====================<br>
> <br>
> Name: Morphic-mt.1933<br>
> Author: mt<br>
> Time: 14 March 2022, 3:52:34.242786 pm<br>
> UUID: bcc808d3-6e90-2449-9f8d-e675490af6eb<br>
> Ancestors: Morphic-mt.1932<br>
> <br>
> Adds #numCharactersPerLine: to TextMorph and PluggableTextMorph. Complements Graphics-mt.498 to compute font-based composition rectangle via TextStyle.<br>
> <br>
> Use it, for example, to do line wrapping not only at the widget border but also at the (visual) wrap border in code panes.<br>
> <br>
> (Minor fix in FontImporterTool, too.)<br>
> <br>
> =============== Diff against Morphic-mt.1932 ===============<br>
> <br>
> Item was changed:<br>
> ----- Method: FontImporterTool>>selectedFont: (in category 'accessing') -----<br>
> selectedFont: aTTCFont<br>
> <br>
>     selectedFont := aTTCFont.<br>
>     <br>
>     self changed: #previewText.<br>
>     self changed: #selectedFontTextStyle.<br>
>     <br>
>     self changed: #filename.<br>
>     self changed: #copyright.<br>
>     <br>
>     self changed: #pointSizeInput.<br>
> +     "self changed: #lineSpacingInput. -- already via #selectedFontTextStyle"<br>
> -     self changed: #lineSpacingInput.    <br>
>     self changed: #ttExtraScaleInput.<br>
>     self changed: #ttExtraGapInput.<br>
>     <br>
>     self changed: #installButtonColor.<br>
>     self changed: #installButtonLabel.<br>
>     self changed: #installButtonEnabled.<br>
>     <br>
>     self changed: #windowTitle.!<br>
> <br>
> Item was changed:<br>
> ----- Method: NewParagraph>>adjustRightXDownTo: (in category 'private') -----<br>
> adjustRightXDownTo: minWidth<br>
>     | shrink minRight |<br>
>     minRight := container left + minWidth.<br>
>     shrink := container right - (maxRightX max: minRight).<br>
>     lines do: [:line | line paddingWidth: (line paddingWidth - shrink)].<br>
>     containerUnadjusted := container.<br>
> +     container := container withRight: (maxRightX max: minRight).!<br>
> -     container := container withRight: (maxRightX + self caretWidth max: minRight).!<br>
> <br>
> Item was added:<br>
> + ----- Method: NewParagraph>>asText (in category 'converting') -----<br>
> + asText<br>
> +     "Answer the receiver's text after being composed. Use #text if you want to retain the layout before composition."<br>
> + <br>
> +     ^ self asTextWithLineBreaks!<br>
> <br>
> Item was added:<br>
> + ----- Method: NewParagraph>>asTextWithLineBreaks (in category 'converting') -----<br>
> + asTextWithLineBreaks<br>
> +     "Answer a text that has all soft line breaks converted to hard line breaks. Add the current style's default font as a text attribute only if a) the style is not the default and b) the first character has no other font set. See Text >> #asTextMorph."<br>
> + <br>
> +     | result |<br>
> +     result := Text streamContents: [:s | lines do: [:textLine |<br>
> +         | lastChar lastIndex break |<br>
> +         lastChar := text at: textLine last.<br>
> +         (break := CharacterSet separators includes: lastChar)<br>
> +             ifTrue: [lastIndex := textLine last - 1]<br>
> +             ifFalse: [lastIndex := textLine last].<br>
> +         "1) Copy text line, which may be due to a soft line break"<br>
> +         s nextPutAll: (text copyFrom: textLine first to: lastIndex).<br>
> +         "2) Add a hard line break."<br>
> +         break ifTrue: [s nextPutAll: (String cr asText<br>
> +             addAllAttributes: (text attributesAt: textLine last);<br>
> +             yourself)]]].<br>
> +     <br>
> +     ((text fontAt: 1 withDefault: nil) isNil and: [<br>
> +         textStyle defaultFamilyName ~= TextStyle default defaultFamilyName])<br>
> +             ifTrue: [result addAttribute: (TextFontReference toFont: textStyle defaultFont)].<br>
> + <br>
> +     ^ result!<br>
> <br>
> Item was changed:<br>
> ScrollPane subclass: #PluggableTextMorph<br>
>     instanceVariableNames: 'textMorph getTextSelector setTextSelector getSelectionSelector hasUnacceptedEdits hasUserEdited askBeforeDiscardingEdits selectionInterval hasEditingConflicts editTextSelector wantsWrapBorder getFontSelector getTextStyleSelector'<br>
> +     classVariableNames: 'AdornmentCache SimpleFrameAdornments SoftLineWrap SoftLineWrapAtVisualWrapBorder VisualWrapBorder VisualWrapBorderLimit'<br>
> -     classVariableNames: 'AdornmentCache SimpleFrameAdornments SoftLineWrap VisualWrapBorder VisualWrapBorderLimit'<br>
>     poolDictionaries: ''<br>
>     category: 'Morphic-Pluggable Widgets'!<br>
> <br>
> Item was changed:<br>
> ----- Method: PluggableTextMorph class>>softLineWrap (in category 'preferences') -----<br>
> softLineWrap<br>
> +     <preference: 'Use soft line wrap at widget border'<br>
> +         categoryList: #(scrolling editing Accessibility)<br>
> +         description: 'Wrap text lines to avoid horizontal scrolling in text widgets. This is the default for all kinds of multi-line text fields in a scrollable container, not only for source code.'<br>
> -     <preference: 'Use soft line wrap'<br>
> -         categoryList: #(scrolling editing)<br>
> -         description: 'Wrap text lines to avoid horizontal scrolling.'<br>
>         type: #Boolean><br>
>     ^ SoftLineWrap ifNil: [true]!<br>
> <br>
> Item was added:<br>
> + ----- Method: PluggableTextMorph class>>softLineWrapAtVisualWrapBorder (in category 'preferences') -----<br>
> + softLineWrapAtVisualWrapBorder<br>
> +     <preference: 'Use soft line wrap at wrap border (in code panes)'<br>
> +         categoryList: #(scrolling editing Accessibility)<br>
> +         description: 'Wrap text lines at the (maybe visual) wrap border in code panes. See #visualWrapBorderLimit and #visualWrapBorder.'<br>
> +         type: #Boolean><br>
> +     ^ SoftLineWrapAtVisualWrapBorder ifNil: [false]!<br>
> <br>
> Item was added:<br>
> + ----- Method: PluggableTextMorph class>>softLineWrapAtVisualWrapBorder: (in category 'preferences') -----<br>
> + softLineWrapAtVisualWrapBorder: aBooleanOrNil<br>
> + <br>
> +     aBooleanOrNil == SoftLineWrapAtVisualWrapBorder ifTrue: [^ self].<br>
> +     SoftLineWrapAtVisualWrapBorder := aBooleanOrNil.<br>
> +     self updateCodePanes.!<br>
> <br>
> Item was added:<br>
> + ----- Method: PluggableTextMorph class>>updateCodePanes (in category 'preferences') -----<br>
> + updateCodePanes<br>
> + <br>
> + <br>
> +     self flag: #todo. "mt Only for code panes!!"<br>
> +     <br>
> +     self softLineWrapAtVisualWrapBorder<br>
> +         ifTrue: [<br>
> +             PluggableTextMorph allSubInstancesDo: [:m |<br>
> +                 (m styler class = (TextStyler for: #Smalltalk)) ifTrue: [<br>
> +                     m<br>
> +                         wantsWrapBorder: self visualWrapBorder;<br>
> +                         numCharactersPerLine: self visualWrapBorderLimit]]]<br>
> +         ifFalse: [<br>
> +             PluggableTextMorph allSubInstancesDo: [:m |<br>
> +                 (m styler class = (TextStyler for: #Smalltalk)) ifTrue: [<br>
> +                     m<br>
> +                         wantsWrapBorder: self visualWrapBorder;<br>
> +                         numCharactersPerLine: nil;<br>
> +                         changed "redraw #visualWrapBorderLimit"]]].!<br>
> <br>
> Item was changed:<br>
> ----- Method: PluggableTextMorph class>>visualWrapBorder (in category 'preferences') -----<br>
> visualWrapBorder<br>
> +     <preference: 'Show wrap border in code panes'<br>
> +         categoryList: #(editing visuals performance Accessibility)<br>
> -     <preference: 'Show wrap border in code panes.'<br>
> -         categoryList: #(editing visuals performance)<br>
>         description: 'Show a visual border after a specific amount of characters. Makes sense for monospaced fonts.'<br>
>         type: #Boolean><br>
>     ^ VisualWrapBorder ifNil: [false]!<br>
> <br>
> Item was changed:<br>
> ----- Method: PluggableTextMorph class>>visualWrapBorder: (in category 'preferences') -----<br>
> + visualWrapBorder: aBooleanOrNil<br>
> - visualWrapBorder: aBoolean<br>
> <br>
> +     aBooleanOrNil == VisualWrapBorder ifTrue: [^ self].<br>
> +     VisualWrapBorder := aBooleanOrNil.<br>
> +     self updateCodePanes.!<br>
> -     VisualWrapBorder := aBoolean.!<br>
> <br>
> Item was changed:<br>
> ----- Method: PluggableTextMorph class>>visualWrapBorderLimit (in category 'preferences') -----<br>
> visualWrapBorderLimit<br>
> +     <preference: 'Wrap border limit (in code panes)'<br>
> +         categoryList: #(editing visuals performance Accessibility)<br>
> +         description: 'In all code panes, indicate an expected wrapping border after a certain amount of characters. It will be a perfect fit for monospaced fonts and average over lines for proportional fonts. This border can be purely visual or also introduce
 soft line breaks. See #visualWrapBorder and #softLineWrapAtVisualWrapBorder.'<br>
> +         type: #String "Support negative values and floats"><br>
> -     <preference: 'Wrap border limit'<br>
> -         categoryList: #(editing visuals performance)<br>
> -         description: 'Amount of characters after the border should be drawn.'<br>
> -         type: #Number><br>
>     ^ VisualWrapBorderLimit ifNil: [80]!<br>
> <br>
> Item was changed:<br>
> ----- Method: PluggableTextMorph class>>visualWrapBorderLimit: (in category 'preferences') -----<br>
> + visualWrapBorderLimit: aNumberOrNil<br>
> - visualWrapBorderLimit: aNumber<br>
> <br>
> +     aNumberOrNil == VisualWrapBorderLimit ifTrue: [^ self].<br>
> +     VisualWrapBorderLimit := aNumberOrNil ifNotNil: [:num | num asNumber].<br>
> +     self updateCodePanes.!<br>
> -     VisualWrapBorderLimit := aNumber asInteger.!<br>
> <br>
> Item was changed:<br>
> ----- Method: PluggableTextMorph>>drawWrapBorderOn: (in category 'drawing') -----<br>
> drawWrapBorderOn: aCanvas<br>
> <br>
> +     | box offset rect |<br>
> -     | offset rect |<br>
>     self wantsWrapBorder ifFalse: [^ self].<br>
>     textMorph ifNil: [^ self].<br>
>     <br>
> +     box := textMorph innerBounds.<br>
> +     textMorph margins ifNotNil: [:m | box := box insetBy: m].<br>
> -     offset := textMorph margins isRectangle<br>
> -         ifTrue: [textMorph margins left]<br>
> -         ifFalse: [textMorph margins isPoint<br>
> -             ifTrue: [textMorph margins x]<br>
> -             ifFalse: [textMorph margins]].<br>
> -     offset := offset + ((textMorph textStyle defaultFont widthOf: $x) * self class visualWrapBorderLimit).<br>
> -     offset > self width ifTrue: [^ self].<br>
>     <br>
> +     offset := box left + (textMorph textStyle compositionWidthFor: self class<br>
> + visualWrapBorderLimit).<br>
> +     self numCharactersPerLine ifNotNil: [<br>
> +         "Respect right margins only if we wrap at that border to not draw over glyphs."<br>
> +         offset := offset + (textMorph innerBounds right - box right) + self borderWidth].<br>
> +     offset > scroller width ifTrue: [^ self].<br>
> +     <br>
>     rect := scroller topLeft + (offset @ 0) corner: scroller bottomRight.<br>
> <br>
>     aCanvas<br>
>         fillRectangle: rect<br>
>         color: self wrapBorderColor.<br>
>     aCanvas<br>
>         line: rect topLeft<br>
>         to: rect bottomLeft<br>
> +         width: self borderWidth<br>
> -         width: self borderStyle width<br>
>         color: (self wrapBorderColor muchDarker alpha: 0.5).!<br>
> <br>
> Item was added:<br>
> + ----- Method: PluggableTextMorph>>numCharactersPerLine (in category 'accessing') -----<br>
> + numCharactersPerLine<br>
> + <br>
> +     ^ textMorph numCharactersPerLine!<br>
> <br>
> Item was added:<br>
> + ----- Method: PluggableTextMorph>>numCharactersPerLine: (in category 'accessing') -----<br>
> + numCharactersPerLine: numCharsOrNil<br>
> + <br>
> +     textMorph numCharactersPerLine: numCharsOrNil.!<br>
> <br>
> Item was changed:<br>
> ----- Method: PluggableTextMorph>>wantsWrapBorder: (in category 'accessing') -----<br>
> wantsWrapBorder: aBoolean<br>
> <br>
> +     wantsWrapBorder = aBoolean ifTrue: [^ self].<br>
> +     wantsWrapBorder := aBoolean.<br>
> +     self changed.!<br>
> -     wantsWrapBorder := aBoolean.!<br>
> <br>
> Item was changed:<br>
> ----- Method: Text>>asTextMorph (in category '*Morphic-converting') -----<br>
> asTextMorph<br>
> +     "Install the receiver in a text morph. Derive an appropriate text style from the receiver's first-character attributes (e.g., to make tabs look correct)."<br>
> + <br>
> +     ^ TextMorph new<br>
> +         contentsAsIs: self;<br>
> +         textStyle: (self fontAt: 1 withStyle: TextStyle default)<br>
> +             asNewTextStyle;<br>
> +         yourself!<br>
> -     ^ TextMorph new contentsAsIs: self!<br>
> <br>
> Item was changed:<br>
> RectangleMorph subclass: #TextMorph<br>
> +     instanceVariableNames: 'textStyle text wrapFlag paragraph editor container predecessor successor backgroundColor margins readOnly autoFit plainTextOnly numCharactersPerLine'<br>
> -     instanceVariableNames: 'textStyle text wrapFlag paragraph editor container predecessor successor backgroundColor margins readOnly autoFit plainTextOnly'<br>
>     classVariableNames: 'CaretForm DefaultEditorClass'<br>
>     poolDictionaries: ''<br>
>     category: 'Morphic-Basic'!<br>
> <br>
> !TextMorph commentStamp: 'nice 3/24/2010 07:40' prior: 0!<br>
> TextMorphs support display of text with emphasis. They also support reasonable text-editing capabilities, as well as embedded hot links, and the ability to embed submorphs in the text.<br>
> <br>
> Late in life, TextMorph was made a subclass of BorderedMorph to provide border and background color if desired. In order to keep things compatible, protocols have been redirected so that color (preferably textColor) relates to the text, and backgroundColor
 relates to the inner fill color.<br>
> <br>
> Text display is clipped to the innerBounds of the rectangle, and text composition is normally performed within a rectangle which is innerBounds inset by the margins parameter.<br>
> <br>
> If text has been embedded in another object, one can elect to fill the owner's shape, in which case the text will be laid out in the shape of the owner's shadow image (including any submorphs other than the text). One can also elect to have the text avoid
 occlusions, in which case it will avoid the bounds of any sibling morphs that appear in front of it. It may be necessary to update bounds in order for the text runaround to notice the presence of a new occluding shape.<br>
> <br>
> The optional autoFitContents property enables the following feature: if the text contents changes, then the bounds of the morph will be adjusted to fit the minimum rectangle that encloses the text (plus any margins specified). Similarly, any attempt to change
 the size of the morph will be resisted if this parameter is set. Except...<br>
> <br>
> If the wrapFlag parameter is true, then text will be wrapped at word boundaries based on the composition width (innerBounds insetBy: margins) width. Thus an attempt to resize the morph in autofit mode, if it changes the width, will cause the text to be recomposed
 with the new width, and then the bounds will be reset to the minimum enclosing rectangle. Similarly, if the text contents are changed with the wrapFlag set to true, word wrap will be performed based on the current compostion width, after which the bounds will
 be set (or not), based on the autoFitcontents property.<br>
> <br>
> Note that fonts can only be applied to the TextMorph as a whole. While you can change the size, color, and emphasis of a subsection of the text and have it apply to only that subsection, changing the font changes the font for the entire contents of the TextMorph.
<br>
> <br>
> Still a TextMorph can be composed of several texts of different fonts<br>
> | font1 font2 t1 t2 tMorph|<br>
> tMorph := TextMorph new.<br>
> font1 := (TextFontReference toFont: (StrikeFont familyName: 'Atlanta' size: 22)).<br>
> font2 := (TextFontReference toFont: (StrikeFont familyName: 'Atlanta' size: 11)).<br>
> t1 := 'this is font1' asText addAttribute: font1.<br>
> t2 := ' and this is font2' asText addAttribute: font2.<br>
> tMorph contents: (t1,t2).<br>
> tMorph openInHand.<br>
> <br>
> <br>
> Yet to do:<br>
> Make a comprehensive control for the eyedropper, with border width and color, inner color and text color, and margin widths.!<br>
> <br>
> Item was changed:<br>
> ----- Method: TextMorph>>compositionRectangle (in category 'private') -----<br>
> compositionRectangle<br>
> <br>
>     | compRect minW minH |<br>
>     compRect := self innerBounds.<br>
>     margins ifNotNil: [compRect := compRect insetBy: margins].<br>
>     minW := self minCompositionWidth.<br>
>     minH := self minCompositionHeight.<br>
>     compRect width < minW ifTrue: [compRect := compRect withWidth: minW].<br>
>     compRect height < minH ifTrue: [compRect := compRect withHeight: minH].<br>
> +     numCharactersPerLine ifNotNil: [<br>
> +         | preferredWidth |<br>
> +         preferredWidth := textStyle compositionWidthFor: numCharactersPerLine.<br>
> +         wrapFlag<br>
> +             ifTrue: [compRect := compRect withWidth: (compRect width min: preferredWidth)]<br>
> +             ifFalse: [compRect := compRect withWidth: preferredWidth]].<br>
>     ^ compRect!<br>
> <br>
> Item was changed:<br>
> ----- Method: TextMorph>>container (in category 'geometry') -----<br>
> container<br>
>     "Return the container for composing this text. There are four cases:<br>
>     1. container is specified as, eg, an arbitrary shape,<br>
>     2. container is specified as the bound rectangle, because<br>
>         this morph is linked to others,<br>
>     3. container is nil, and wrap is true -- grow downward as necessary,<br>
>     4. container is nil, and wrap is false -- grow in 2D as necessary."<br>
> <br>
> +     container ifNil: [<br>
> +         successor ifNotNil: [^ self compositionRectangle].<br>
> +         ^ wrapFlag<br>
> +             ifTrue: [self compositionRectangle withHeight: self maximumContainerExtent y]<br>
> +             ifFalse: [<br>
> +                 numCharactersPerLine<br>
> +                     ifNil: [self compositionRectangle topLeft extent: self maximumContainerExtent]<br>
> +                     ifNotNil: [self compositionRectangle withHeight: self maximumContainerExtent y]]].<br>
> -     container ifNil:<br>
> -         [successor ifNotNil: [^ self compositionRectangle].<br>
> -         wrapFlag ifTrue: [^ self compositionRectangle withHeight: self maximumContainerExtent y].<br>
> -         ^ self compositionRectangle topLeft extent: self maximumContainerExtent].<br>
>     ^ container!<br>
> <br>
> Item was changed:<br>
> ----- Method: TextMorph>>fit (in category 'private') -----<br>
> fit<br>
>     "Adjust my bounds to fit the text. Should be a no-op if autoFit is not specified.<br>
>     Required after the text changes,<br>
>     or if wrapFlag is true and the user attempts to change the extent."<br>
> <br>
>     | newExtent para cBounds lastOfLines heightOfLast |<br>
> +     self isAutoFit<br>
> +         ifTrue: "Adjust at least my height"<br>
> +             [wrapFlag<br>
> +                 ifTrue: "Keep my width"<br>
> +                     [ | box | <br>
> +                     box := self innerBounds. "i.e, no borders"<br>
> +                     margins ifNotNil: [box := box insetBy: margins].<br>
> +                     newExtent := box width @ self paragraph extent y]<br>
> +                 ifFalse: "Adjust my width"<br>
> +                     [ newExtent := self paragraph extent ].<br>
> -     self isAutoFit <br>
> -         ifTrue: <br>
> -             [<br>
> -             newExtent := self paragraph extent.<br>
>             newExtent := newExtent + (2 * self borderWidth).<br>
>             margins <br>
>                 ifNotNil: [newExtent := ((0 @ 0 extent: newExtent) expandBy: margins) extent].<br>
>             newExtent ~= bounds extent <br>
>                 ifTrue: <br>
>                     [(container isNil and: [successor isNil]) <br>
>                         ifTrue: <br>
>                             [para := paragraph.    "Save para (layoutChanged smashes it)"<br>
>                             super extent: newExtent.<br>
>                             paragraph := para]].<br>
>             container notNil & successor isNil <br>
>                 ifTrue: <br>
>                     [cBounds := container bounds truncated.<br>
>                     "23 sept 2000 - try to allow vertical growth"<br>
>                     lastOfLines := self paragraph lines last.<br>
>                     heightOfLast := lastOfLines bottom - lastOfLines top.<br>
>                     (lastOfLines last < text size <br>
>                         and: [lastOfLines bottom + heightOfLast >= self bottom])
<br>
>                             ifTrue: <br>
>                                 [container releaseCachedState.<br>
>                                 cBounds := cBounds origin corner: cBounds corner + (0 @ heightOfLast)].<br>
>                     self privateBounds: cBounds]].<br>
> <br>
>     "These statements should be pushed back into senders"<br>
>     self paragraph positionWhenComposed: self position.<br>
>     successor ifNotNil: [successor predecessorChanged].<br>
>     self changed    "Too conservative: only paragraph composition<br>
>                     should cause invalidation."!<br>
> <br>
> Item was added:<br>
> + ----- Method: TextMorph>>numCharactersPerLine (in category 'layout') -----<br>
> + numCharactersPerLine<br>
> + <br>
> +     ^ numCharactersPerLine!<br>
> <br>
> Item was added:<br>
> + ----- Method: TextMorph>>numCharactersPerLine: (in category 'layout') -----<br>
> + numCharactersPerLine: numCharsOrNil<br>
> +     "Reset composition rectangle to approx. numChars per line. Will be a perfect fit for monospaced fonts, average over multiple lines for other fonts. See commentary in #withNoLineLongerThan: and TextStyle >> #compositionWidthFor:."<br>
> +     <br>
> +     numCharactersPerLine = numCharsOrNil ifTrue: [^ self].<br>
> +     numCharactersPerLine := numCharsOrNil.<br>
> +     self releaseParagraph; changed.!<br>
> <br>
> Item was added:<br>
> + ----- Method: TextMorph>>withNoLineLongerThan: (in category 'converting') -----<br>
> + withNoLineLongerThan: numChars<br>
> +     "Convenience only to establish this protocol across String, Text, and TextMorph."<br>
> + <br>
> +     self numCharactersPerLine: numChars.<br>
> +     ^ self paragraph asTextWithLineBreaks!<br>
> <br>
> </div>
</blockquote>
</div>
</div>
</div></blockquote>
                                        </div></div></blockquote>
                                        </div></body>