StringMorph and lf

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

StringMorph and lf

Dan Norton
Hi Juan,

By subclassing SystemWindow, I defined a simple window with 3 panes, using LayoutMorph
newRow for each. Two of these have StringMorph as a submorph. Strings in this app, which
are for display only, contain Character lf in several places are sent using
StringMorph>contents:. They are drawn with every lf removed. Can StringMorph be
commanded to honor the lf? Is there something better that should be used instead of
StringMorph?

Thanks,
 - Dan Norton

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: StringMorph and lf

Dan Norton
Howdy,

On 24 Jan 2015 at 20:44, [hidden email] wrote:

> Hi Juan,
>
> By subclassing SystemWindow, I defined a simple window with 3 panes,
> using LayoutMorph
> newRow for each. Two of these have StringMorph as a submorph.
> Strings in this app, which
> are for display only, contain Character lf in several places are
> sent using
> StringMorph>contents:. They are drawn with every lf removed. Can
> StringMorph be
> commanded to honor the lf? Is there something better that should be
> used instead of
> StringMorph?
>
Using StringMorph in this way may be too simplistic.
Instead use TextModelMorph with a model which is a subclass of TextModel. At least this
can draw with the lf characters in place. It's more complex and it allows editing of the string
by default but maybe that can be suppressed?

 - Dan Norton


_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: StringMorph and lf

Juan Vuletich-4
Hi Dan,

(below)

On 1/26/2015 12:19 AM, Dan wrote:

> Howdy,
>
> On 24 Jan 2015 at 20:44, [hidden email] wrote:
>
>> Hi Juan,
>>
>> By subclassing SystemWindow, I defined a simple window with 3 panes,
>> using LayoutMorph
>> newRow for each. Two of these have StringMorph as a submorph.
>> Strings in this app, which
>> are for display only, contain Character lf in several places are
>> sent using
>> StringMorph>contents:. They are drawn with every lf removed. Can
>> StringMorph be
>> commanded to honor the lf? Is there something better that should be
>> used instead of
>> StringMorph?
>>
> Using StringMorph in this way may be too simplistic.
> Instead use TextModelMorph with a model which is a subclass of TextModel. At least this
> can draw with the lf characters in place. It's more complex and it allows editing of the string
> by default but maybe that can be suppressed?
>
>   - Dan Norton
>

You don't really need a new class. This works:

         model := TextModel new contents: 'Hi folks, \this is a
multiline text, \see?' withNewLines .
         doWrap := true.
         m := TextModelMorph withModel: model.
         m wrapFlag: doWrap.
         m hideScrollBarsIndefinitely.
         m lock.
         m openInWorld

Locking the morph is not the ideal thing to do, as you can't grab it
with the halo anymore. You can add a readOnly capability to
TextModelMorph, that would be a welcome addition. Also, maybe some
convenience method with code like my snippet above could be useful.

Cheers,
Juan Vuletich


_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: StringMorph and lf

Dan Norton
On 28 Jan 2015 at 10:39, Juan Vuletich wrote:

> Hi Dan,
>
> (below)
>
> On 1/26/2015 12:19 AM, Dan wrote:
> > Howdy,
> >
> > On 24 Jan 2015 at 20:44, [hidden email] wrote:
> >
> >> Hi Juan,
> >>
> >> By subclassing SystemWindow, I defined a simple window with 3
> panes,
> >> using LayoutMorph
> >> newRow for each. Two of these have StringMorph as a submorph.
> >> Strings in this app, which
> >> are for display only, contain Character lf in several places
> are
> >> sent using
> >> StringMorph>contents:. They are drawn with every lf removed.
> Can
> >> StringMorph be
> >> commanded to honor the lf? Is there something better that should
> be
> >> used instead of
> >> StringMorph?
> >>
> > Using StringMorph in this way may be too simplistic.
> > Instead use TextModelMorph with a model which is a subclass of
> TextModel. At least this
> > can draw with the lf characters in place. It's more complex and it
> allows editing of the string
> > by default but maybe that can be suppressed?
> >
> >   - Dan Norton
> >
>
> You don't really need a new class. This works:
>
>          model := TextModel new contents: 'Hi folks, \this is a
> multiline text, \see?' withNewLines .
>          doWrap := true.
>          m := TextModelMorph withModel: model.
>          m wrapFlag: doWrap.
>          m hideScrollBarsIndefinitely.
>          m lock.
>          m openInWorld
>
> Locking the morph is not the ideal thing to do, as you can't grab it
> with the halo anymore. You can add a readOnly capability to
> TextModelMorph, that would be a welcome addition. Also, maybe some
> convenience method with code like my snippet above could be
> useful.
>
The window won't contain all the lines at times, so lock and hideScrollBarsIndefinitely prevent
the user from seeing everything. Here's what seems to give the best results so far, but there
are problems with the scroll bars. This method is sent to self by #initialize:

setupBoard
        "Specify the layout for the <...> window"
        | status statusMorph clues |
       
        status := LayoutMorph newRow
                addMorph: (statusMorph := TextModelMorph
                        withModel: (statusString := TextModel withText: 'Status Area')).
                       
        buttonPane := LayoutMorph newRow
                padding: #center;
                color: Color lightGreen.
       
        clues := LayoutMorph newRow
                addMorph: (cluesMorph := TextModelMorph
                        withModel: (cluesString := TextModel withText: 'Clues Area')).
                       
        statusMorph askBeforeDiscardingEdits: false;
                wrapFlag: true;
                hideOrShowScrollBars.
                       
        cluesMorph askBeforeDiscardingEdits: false;
                wrapFlag: false; "false because clues are short one-liners"
                hHideScrollBar; "<--- ***** note: it is not hidden"
                hideOrShowScrollBars.
               
        self layoutMorph
                        addMorph: status proportionalHeight: 0.15;
                        addAdjusterAndMorph: buttonPane proportionalHeight: 0.05;
                        addAdjusterAndMorph: clues proportionalHeight: 0.80.

This way of laying out is a big improvement over Morphic 2. However problems with the
above are that the vertical scroll slider extends beyond its owner's extent. It resumes normal
size only after the window is resized. The horizontal scroll bar defies my efforts to remove it.
Let me know if I should send the rest of the code to you.


_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: StringMorph and lf

Juan Vuletich-4
Hi Dan,

On 1/29/2015 12:22 AM, Dan wrote:

> ...
> The window won't contain all the lines at times, so lock and hideScrollBarsIndefinitely prevent
> the user from seeing everything. Here's what seems to give the best results so far, but there
> are problems with the scroll bars. This method is sent to self by #initialize:
>
> setupBoard
> "Specify the layout for the<...>  window"
> | status statusMorph clues |
>
> status := LayoutMorph newRow
> addMorph: (statusMorph := TextModelMorph
> withModel: (statusString := TextModel withText: 'Status Area')).
>
> buttonPane := LayoutMorph newRow
> padding: #center;
> color: Color lightGreen.
>
> clues := LayoutMorph newRow
> addMorph: (cluesMorph := TextModelMorph
> withModel: (cluesString := TextModel withText: 'Clues Area')).
>
> statusMorph askBeforeDiscardingEdits: false;
> wrapFlag: true;
> hideOrShowScrollBars.
>
> cluesMorph askBeforeDiscardingEdits: false;
> wrapFlag: false; "false because clues are short one-liners"
> hHideScrollBar; "<--- ***** note: it is not hidden"
> hideOrShowScrollBars.
>
> self layoutMorph
> addMorph: status proportionalHeight: 0.15;
> addAdjusterAndMorph: buttonPane proportionalHeight: 0.05;
> addAdjusterAndMorph: clues proportionalHeight: 0.80.
>
> This way of laying out is a big improvement over Morphic 2. However problems with the
> above are that the vertical scroll slider extends beyond its owner's extent. It resumes normal
> size only after the window is resized. The horizontal scroll bar defies my efforts to remove it.
> Let me know if I should send the rest of the code to you.
>
There were a couple of bugs there. Most TextModelMorphs do wordwrap, so
wrapFlag: false isn't well tested. The attach includes fixes, and a new
capability to disable keyboard input.

Modify your code to read:

         statusMorph askBeforeDiscardingEdits: false;
                 wrapFlag: true;
             disableKeyboard.

         cluesMorph askBeforeDiscardingEdits: false;
                 wrapFlag: false; "false because clues are short one-liners"
             disableKeyboard.

There's no need to do any specific setup to scrollbars anymore.

This change set will be in the next bunch of updates.

Cheers,
Juan Vuletich

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org

2170-TextMorphEnhancements-JuanVuletich-2015Jan29-10h15m-jmv.3.cs.zip (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: StringMorph and lf

Dan Norton
Hi Juan,

On 29 Jan 2015 at 11:38, Juan Vuletich wrote:

> Hi Dan,
>
> On 1/29/2015 12:22 AM, Dan wrote:
> > ...
> > The window won't contain all the lines at times, so lock and
> hideScrollBarsIndefinitely prevent
> > the user from seeing everything. Here's what seems to give the
> best results so far, but there
> > are problems with the scroll bars. This method is sent to self by
> #initialize:
> >
> > setupBoard
> > "Specify the layout for the<...>  window"
> > | status statusMorph clues |
> >
> > status := LayoutMorph newRow
> > addMorph: (statusMorph := TextModelMorph
> > withModel: (statusString := TextModel withText: 'Status
> Area')).
> >
> > buttonPane := LayoutMorph newRow
> > padding: #center;
> > color: Color lightGreen.
> >
> > clues := LayoutMorph newRow
> > addMorph: (cluesMorph := TextModelMorph
> > withModel: (cluesString := TextModel withText: 'Clues
> Area')).
> >
> > statusMorph askBeforeDiscardingEdits: false;
> > wrapFlag: true;
> > hideOrShowScrollBars.
> >
> > cluesMorph askBeforeDiscardingEdits: false;
> > wrapFlag: false; "false because clues are short one-liners"
> > hHideScrollBar; "<--- ***** note: it is not hidden"
> > hideOrShowScrollBars.
> >
> > self layoutMorph
> > addMorph: status proportionalHeight: 0.15;
> > addAdjusterAndMorph: buttonPane proportionalHeight: 0.05;
> > addAdjusterAndMorph: clues proportionalHeight: 0.80.
> >
> > This way of laying out is a big improvement over Morphic 2.
> However problems with the
> > above are that the vertical scroll slider extends beyond its
> owner's extent. It resumes normal
> > size only after the window is resized. The horizontal scroll bar
> defies my efforts to remove it.
> > Let me know if I should send the rest of the code to you.
> >
>
> There were a couple of bugs there. Most TextModelMorphs do wordwrap,
> so
> wrapFlag: false isn't well tested. The attach includes fixes, and a
> new
> capability to disable keyboard input.
>
> Modify your code to read:
>
>          statusMorph askBeforeDiscardingEdits: false;
>                  wrapFlag: true;
>              disableKeyboard.
>
>          cluesMorph askBeforeDiscardingEdits: false;
>                  wrapFlag: false; "false because clues are short
> one-liners"
>              disableKeyboard.
>
> There's no need to do any specific setup to scrollbars anymore.
>
> This change set will be in the next bunch of updates.
>
This is better - I especially appreciate #disableKeyboard. The cursor can not be inserted and
although selection appears, copy and paste do nothing. The horizontal scroll bar does not
appear and neither does the vertical, at least at first. But when the vertical is actually needed,
it does not appear unless the window border is clicked. At times it loses track of the size of
what needs to be scrolled. The scroll wheel no longer works.

Thanks,
 - Dan



_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: StringMorph and lf

Juan Vuletich-4
Hi Dan,

On 1/29/2015 5:32 PM, Dan wrote:
> ...
> This is better - I especially appreciate #disableKeyboard. The cursor can not be inserted and
> although selection appears, copy and paste do nothing.

Change #2170 makes #disableKeyboard to _completely_  disable keyboard.
But copy and paste work if invoked from the menu, right mouse click.

> The horizontal scroll bar does not
> appear and neither does the vertical, at least at first. But when the vertical is actually needed,
> it does not appear unless the window border is clicked. At times it loses track of the size of
> what needs to be scrolled.

The attach fixes this bug.

> The scroll wheel no longer works.

Yes, this is because the VM sends scroll wheel events as keyboard arrow
keystrokes.

Maybe a better solution would be to just disable keystrokes that modify
the text, but not others (arrow / scroll wheel, selection and clipboard
commands, etc).

I won't be able to work on this for the next few days, so please open an
issue at https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev/issues

Cheers,
Juan Vuletich
> Thanks,
>   - Dan


_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org

2171-TextModelMorphFix-JuanVuletich-2015Jan30-15h53m-jmv.2.cs.zip (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: StringMorph and lf

Dan Norton
In reply to this post by Dan Norton
Hi Juan,

One more tweak perhaps? ;) To see the problem...

Write approx. 120 lines, causing vScroll to appear.
Move the slider to the bottom and leave it there.
Replace the lines with perhaps 2 dozen, which require no vScroll.
Unfortunately, the pane is blank and vScroll disappears.
The only(?) way to get back to the top is to make vScroll reappear by resizing.
(The lines mentioned are written by sending #actualContents: to the TextModel.)

Otherwise your changes are looking good. I'll open that issue you mentioned on GitHub.

Thanks,
 - Dan

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: StringMorph and lf

Juan Vuletich-4
On 30/01/2015 11:37 p.m., Dan wrote:

> Hi Juan,
>
> One more tweak perhaps? ;) To see the problem...
>
> Write approx. 120 lines, causing vScroll to appear.
> Move the slider to the bottom and leave it there.
> Replace the lines with perhaps 2 dozen, which require no vScroll.
> Unfortunately, the pane is blank and vScroll disappears.
> The only(?) way to get back to the top is to make vScroll reappear by resizing.
> (The lines mentioned are written by sending #actualContents: to the TextModel.)
Thanks, Dan. Good catch. Fix attached.

> Otherwise your changes are looking good. I'll open that issue you mentioned on GitHub.
>
> Thanks,
>   - Dan

Cheers,
Juan Vuletich

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org

2172-PluggableScrollPaneFix-JuanVuletich-2015Jan31-00h30m-jmv.1.cs.st (1K) Download Attachment