Andre Poenitz wrote:
On Wed, Sep 24, 2008 at 09:11:19PM +0200, Vincent van Ravesteijn - TNW wrote:
How can I modify the anchor position of a selection ?
void InsetListings::doDispatch(Cursor & cur, FuncRequest & cmd)
{
++cur.anchor().pos()
}
Or something like this..
In the following code, shouldn't we return a const CursorSlice and/or
document that the returned CursorSlice isn't the true anchor, but a
normalized _copy_ of the anchor ?
/// access to normalized selection anchor
CursorSlice Cursor::anchor() const
{
LASSERT(anchor_.depth() >= depth(), /**/);
CursorSlice normal = anchor_[depth() - 1];
if (depth() < anchor_.depth() && top() <= normal) {
// anchor is behind cursor -> move anchor behind the
inset
++normal.pos();
}
return normal;
}
You can do both.
But anchor() does not seem to be used much outside of Cursor anyway,
so returning a const ref to the un-normalized anchor and normalizing
explicitly if needed might be an option, too.
Andre'
Well, I wasn't that clear, but all attempts failed until I came across
the following :
//private:
/// the anchor position
DocIterator anchor_;
Now, I understand why somebody has commented out the private label! This
is the only way to get to the anchor without a copy is made along the
road...
Grrrrrrrrrrrr..
Vincent