Jean-Marc Lasgouttes wrote:
"Bo" == Bo Peng <[EMAIL PROTECTED]> writes:

Concerning your approach, many things are still missing (IMO of
course). For example, self-insert will replace the selection if
there is one, so you should save the selection.

Bo> This is expected, and can be solved easily by adding SaveSelection
Bo> flag to this LFUN. The advantage of my patch is that I can handle
Bo> all these cases in a uniform way, in a single file
Bo> (LyXAction.cpp).

OTOH, in my approach I try to put the calls at the place where the
selection is actually lost, which makes the code simpler to
understand. (and shall I say shorter?)

The patch is shorter yes but I don't think the final code will be shorter.

Here is what I came up with. Note that now saveSelection does its job
only if cursor is actually bv.cursor() (to make Abdel happy).

Why don't you just passed cur.bv().cursor()?

if (cur.selection()) {
        LYXERR(Debug::ACTION) << BOOST_CURRENT_FUNCTION << ": `"
                   << to_utf8(cur.selectionAsString(true)) << "'."
                   << endl;
        copySelectionToStack(cur.bv().cursor(), selectionBuffer);
}


The changes in Text3.cpp should go in anyway, I think. The
semantics of the LFUNS with a selection was bad.

Yes.


The only known issue now is that I do not handle BUFFER_SWITCH. It is
not that I cannot add one line in an LFUN, but I'd like first to
understand what the policy is: can we have several selections active
different bufferviews?

Yes. Each BufferView has its own cursor and thus its own selection. The only reason why a BufferView selection could be cleared externally is if we aknowledge the ClearSelection command from X11, which we don't.


AFAIK, Bo's code does not work with multiple
windows (where no buffer-switch happens).

Why is that? IIRC he saves the selection in LyXFunc::setLyXView().

Abdel.

Reply via email to