How to reserve a small spacing for displaying the text cursor ?

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

How to reserve a small spacing for displaying the text cursor ?

Nicolas Cellier
Though leftMargin is nil and indentation are apparently set to zero, the TextMorph is always displayed with a small spacing from the left border and right border.
This was quite long to find, but I now know:

PluggableTextMorph>>resizeScroller
    "Also needs to resize the text morph"

    super resizeScroller.
    textMorph ifNotNil:
        [textMorph extent: (self innerBounds width-6)@self height].

Unfortunately, this space is not available for displaying the cursor, because it does not belong to the TextMorph...

The cursor is always displayed to the right of CharacterBlock.
So when at the left of the line it is inside TextMorph bounds and visible because away from the borders thanks to above 3 pixels guard.
At the right of the line, it is generally visible, unless your last character unluckily fits exactly to the right bound.
But if you rightFlush/justify, the characters are then perfectly aligned, and the cursor to the right of a line becomes invisible.

It would not be unreasonnable to add some small indents to the style rather than letting the 0, but I feel like the 6 pixels could be given back to the TextMorph with a settable property, so that the Cursor could be displayed....

What do you think?


Reply | Threaded
Open this post in threaded view
|

Re: How to reserve a small spacing for displaying the text cursor ?

timrowledge

On 02-10-2013, at 3:16 PM, Nicolas Cellier <[hidden email]> wrote:
> Unfortunately, this space is not available for displaying the cursor, because it does not belong to the TextMorph…

Ouch. It *might* be worth remembering that a morph *can* display outside its bounds. At least, I'm pretty sure it can. That might work visually for some cases, though it would look pretty odd in a lot.

>
> The cursor is always displayed to the right of CharacterBlock.
> So when at the left of the line it is inside TextMorph bounds and visible because away from the borders thanks to above 3 pixels guard.
> At the right of the line, it is generally visible, unless your last character unluckily fits exactly to the right bound.
> But if you rightFlush/justify, the characters are then perfectly aligned, and the cursor to the right of a line becomes invisible.

I think this is why gutters were invented in typography. An editable view simply needs enough room at the edges to allow the editing to work. If the cursor is at extreme left or right of the view, there has to be space for it. We shouldn't forget that LTR languages need the spaces swapped and perhaps the smart thing would just be the same size gutter each side to simplify that out of the problem. I guess the gutter width would need to be 'about as wide as the cursor in use' since cursors can be changed and it isn't terrible to cut off a bit if they're wide. Personally I like a simple 1-pixel wide vertical bar but I have seen people use more ornate graphics.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Hard work pays off in the future. Laziness pays off now.



Reply | Threaded
Open this post in threaded view
|

Re: How to reserve a small spacing for displaying the text cursor ?

Chris Muller-3
In reply to this post by Nicolas Cellier
Hey Nicolas and Tim, while doing your rewrite, are you accounting for
the fact that a single "character" in a TextMorph can be any Morph?

Maui takes advantage of this feature for its built-in, mini word-processor.

On Wed, Oct 2, 2013 at 5:16 PM, Nicolas Cellier
<[hidden email]> wrote:

> Though leftMargin is nil and indentation are apparently set to zero, the
> TextMorph is always displayed with a small spacing from the left border and
> right border.
> This was quite long to find, but I now know:
>
> PluggableTextMorph>>resizeScroller
>     "Also needs to resize the text morph"
>
>     super resizeScroller.
>     textMorph ifNotNil:
>         [textMorph extent: (self innerBounds width-6)@self height].
>
> Unfortunately, this space is not available for displaying the cursor,
> because it does not belong to the TextMorph...
>
> The cursor is always displayed to the right of CharacterBlock.
> So when at the left of the line it is inside TextMorph bounds and visible
> because away from the borders thanks to above 3 pixels guard.
> At the right of the line, it is generally visible, unless your last
> character unluckily fits exactly to the right bound.
> But if you rightFlush/justify, the characters are then perfectly aligned,
> and the cursor to the right of a line becomes invisible.
>
> It would not be unreasonnable to add some small indents to the style rather
> than letting the 0, but I feel like the 6 pixels could be given back to the
> TextMorph with a settable property, so that the Cursor could be
> displayed....
>
> What do you think?
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: How to reserve a small spacing for displaying the text cursor ?

Stéphane Rollandin
> Hey Nicolas and Tim, while doing your rewrite, are you accounting for
> the fact that a single "character" in a TextMorph can be any Morph?

+1
I use embedded morphs a lot too...


Stef