Tell X the selection status also after it is changed by the keyboard, since

we got a consensus on this on the list.
Some calls of haveSelection are still missing, but we need to decide the
"persistent selection" question before those can be implemented properly.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16572 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2007-01-07 14:44:44 +00:00
parent 37652b6d7a
commit fed31122c4
8 changed files with 27 additions and 3 deletions

View File

@ -63,6 +63,7 @@
#include "frontends/Alert.h"
#include "frontends/FileDialog.h"
#include "frontends/FontMetrics.h"
#include "frontends/Selection.h"
#include "graphics/Previews.h"
@ -196,6 +197,7 @@ void BufferView::setBuffer(Buffer * b)
cursor_.resetAnchor();
cursor_.setCursor(buffer_->getCursor().asDocIterator(&(buffer_->inset())));
cursor_.setSelection();
theSelection().haveSelection(cursor_.selection());
}
}
@ -1298,6 +1300,7 @@ void BufferView::putSelectionAt(DocIterator const & cur,
cursor_.setSelection(cursor_, -length);
} else
cursor_.setSelection(cursor_, length);
theSelection().haveSelection(cursor_.selection());
}
}

View File

@ -46,6 +46,7 @@
#include "support/lstrings.h"
#include "frontends/Clipboard.h"
#include "frontends/Selection.h"
#include <boost/tuple/tuple.hpp>
@ -532,6 +533,7 @@ void cutSelection(LCursor & cur, bool doclear, bool realcut)
// need a valid cursor. (Lgb)
cur.clearSelection();
updateLabels(cur.buffer());
theSelection().haveSelection(false);
// tell tabular that a recent copy happened
dirtyTabularStack(false);
@ -709,6 +711,7 @@ void eraseSelection(LCursor & cur)
}
// need a valid cursor. (Lgb)
cur.clearSelection();
theSelection().haveSelection(false);
} else {
lyxerr << "can't erase this selection 1" << endl;
}

View File

@ -41,6 +41,8 @@
#include "mathed/InsetMathScript.h"
#include "mathed/MathMacroTable.h"
#include "frontends/Selection.h"
#include "support/limited_stack.h"
#include <boost/assert.hpp>
@ -558,6 +560,7 @@ bool LCursor::selHandle(bool sel)
resetAnchor();
selection() = sel;
theSelection().haveSelection(sel);
return true;
}

View File

@ -547,6 +547,8 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
cell(cur.idx())->dispatch(cur, cmd);
if (!cur.result().dispatched()) {
isRightToLeft(cur) ? movePrevCell(cur) : moveNextCell(cur);
if (cmd.action == LFUN_CHAR_FORWARD_SELECT)
theSelection().haveSelection(cur.selection());
if (sl == cur.top())
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
else
@ -559,6 +561,8 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
cell(cur.idx())->dispatch(cur, cmd);
if (!cur.result().dispatched()) {
isRightToLeft(cur) ? moveNextCell(cur) : movePrevCell(cur);
if (cmd.action == LFUN_CHAR_BACKWARD_SELECT)
theSelection().haveSelection(cur.selection());
if (sl == cur.top())
cmd = FuncRequest(LFUN_FINISHED_LEFT);
else
@ -580,6 +584,8 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
TextMetrics const & tm =
cur.bv().textMetrics(cell(cur.idx())->getText(0));
cur.pos() = tm.x2pos(cur.pit(), 0, cur.targetX());
if (cmd.action == LFUN_DOWN_SELECT)
theSelection().haveSelection(cur.selection());
}
if (sl == cur.top()) {
// we trick it to go to the RIGHT after leaving the
@ -605,6 +611,8 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
ParagraphMetrics const & pm =
tm.parMetrics(cur.lastpit());
cur.pos() = tm.x2pos(cur.pit(), pm.rows().size()-1, cur.targetX());
if (cmd.action == LFUN_UP_SELECT)
theSelection().haveSelection(cur.selection());
}
if (sl == cur.top()) {
cmd = FuncRequest(LFUN_FINISHED_UP);
@ -1868,6 +1876,7 @@ void InsetTabular::cutSelection(LCursor & cur)
if (cur.pos() > cur.lastpos())
cur.pos() = cur.lastpos();
cur.clearSelection();
theSelection().haveSelection(false);
}

View File

@ -29,6 +29,7 @@
#include "undo.h"
#include "frontends/Alert.h"
#include "frontends/Selection.h"
#include "support/convert.h"
#include "support/docstream.h"
@ -356,6 +357,7 @@ bool findNextChange(BufferView * bv)
// Now put cursor to end of selection:
bv->cursor().setCursor(cur);
bv->cursor().setSelection();
theSelection().haveSelection(bv->cursor().selection());
// if we used a lfun like in find/replace, dispatch would do
// that for us
bv->update();

View File

@ -1398,6 +1398,7 @@ bool InsetMathHull::searchForward(BufferView * bv, string const & str,
MathArray const & a = top.asInsetMath()->cell(top.idx_);
if (a.matchpart(ar, top.pos_)) {
bv->cursor().setSelection(it, ar.size());
theSelection().haveSelection(bv->cursor().selection());
current = it;
top.pos_ += ar.size();
bv->update();

View File

@ -53,6 +53,7 @@
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
#include "frontends/Selection.h"
#include "insets/insettext.h"
#include "insets/insetbibitem.h"
@ -828,6 +829,7 @@ void LyXText::selectWord(LCursor & cur, word_location loc)
cur.resetAnchor();
setCursor(cur, to.pit(), to.pos());
cur.setSelection();
theSelection().haveSelection(cur.selection());
}

View File

@ -121,8 +121,7 @@ namespace {
{
if (selecting || cur.mark())
cur.setSelection();
if (!cur.selection())
theSelection().haveSelection(false);
theSelection().haveSelection(cur.selection());
cur.bv().switchKeyMap();
}
@ -1065,7 +1064,9 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
if (lyxrc.auto_region_delete) {
if (cur.selection())
cutSelection(cur, false, false);
theSelection().haveSelection(false);
// cutSelection clears the X selection.
else
theSelection().haveSelection(false);
}
cur.clearSelection();