Re: justification/cursor navigation issues



On Thu, 2005-08-25 at 16:35 -0400, Owen Taylor wrote:
> On Fri, 2005-08-19 at 16:41 +0100, Damon Chaplin wrote:
> > I'm working on a patch for justification:
> >    http://bugzilla.gnome.org/show_bug.cgi?id=64538
> > 
> > One of the last remaining problems is with cursor navigation.
> > (Currently if you press the up arrow at the ends of lines it does
> > nothing, and if you press the down arrow it jumps down 2 lines.)
> > 
> > I think some of the cursor navigation code assumes that all the text in
> > the PangoLayoutLines and PangoLayoutRun/PangoItems is contiguous.
> 
> I'm not quite sure what you mean by "contiguous", but my general
> is feeling is that various things should be preserved:
> 
>  - Every character should be part of a cluster
>  - The runs of a line should be visually contiguous

The problem is code like this:

      if (run->item->offset <= index
          && run->item->offset + run->item->length > index)
        ....

My code trims spaces, adjusting the PangoItems so they don't cover the
spaces any more. This causes problems in code like the above (because
the index isn't in any item at all).

The alternative would be to include the whitespace in the PangoItems,
but not in the glyphstring. (I think there are problems with this
approach as well, though I'm not sure.)


> > However, my justification code trims whitespace at the ends of lines
> > (and in future it may do things like replace text for hyphenation).
> 
> While whitespace shouldn't be taken into account for line wrapping,
> I don't know if trimming it is right.
> 
> Think about the behavior when editing left justified wrapped text -
> when entering spaces at the end of the line, the cursor should continue
> to move to the right ... (probably stopping at the right margin rather
> than continuing and adding a scrollbar.)
> 
> It would be very odd if space did nothing until you typed the next
> character.
> 
> So we need to know how wide the whitespace of a line is when computing
> the cursor position. If we set it to zero with in the PangoGlyphString
> then we've lost the necessary information.

I hadn't thought of the ragged text case before. That will need a few
changes. (Argh!) I agree that we should fit in as many spaces as
possible in that case.

For justified text I think you have to trim whitespace, except on the
last line, where I suppose you do the same as for ragged text above.

Damon





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]