On Wed, Oct 22, 2003 at 04:37:33PM +0100, John Levon wrote:
> On Wed, Oct 22, 2003 at 05:30:43PM +0200, Andre Poenitz wrote:
> 
> > Lars: Should I rename it to 'behind'?
> 
> This is a very confusing word for native English speakers ... I had real
> trouble following some lyx source that used that.
> 
> > We have currently 
> > 
> >     pos_type lastPos(Paragraph const & par, Row const & row)
> >     {
> >             if (par.empty())
> >                     return 0;
> >             pos_type pos = row.end() - 1;
> >             if (pos == par.size())
> >                     --pos;
> >             return pos;
> >     }
> > 
> > This works around other work arounds in breakRows.
> > 
> > Ideally, logic should be
> > 
> >     pos_type lastPos(Paragraph const &, Row const & row)
> >     {
> >             return row.'behind'() - 1;
> >     }
> > 
> > [... and this function removed]
> 
> Arggghhhh. Nooooo !
> 
> We've been through this before.

So?

> > which would remove lots of silly little hacks in text and row_painter.
> 
> Sorry André, your "new" lastPos() (aka what was there for some time)
> *causes bugs*. I personally fixed several of them. It is not acceptable
> IMHO for a function called lastPos() to return a nonsense value. It
> should return an iterator into the row. -1 as a value is not such an
> iterator.
> 
> It is a simple fact that code has to deal with empty rows.

In which case pos == end.

I see no particular reason in coercing rowBreakPoint into reporting
'one off' in some cases just to spill code all over to place to correct
this.

> If you have nicer ways to handle that, fine, but this isn't it.
> Those "silly little hacks" are handling a real situation, i.e. that in
> empty rows, there *is* *no* "position before the last one".

What's your point?

Better return a wrong position after the last one and check for this?
The check is needed in both cases, however, I find it much simpler to
understand

  'endpos is one after the last pos covered by this row'

than

  'endpos is one after the last pos covered by this with two exceptions'


Andre'

-- 
Those who desire to give up Freedom in order to gain Security, will not have,
nor do they deserve, either one.     (T. Jefferson or B. Franklin or both...)

Reply via email to