more shuffling...

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8347 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2004-01-14 17:21:39 +00:00
parent f4982f38a2
commit 691594432d
18 changed files with 174 additions and 179 deletions

View File

@ -28,6 +28,7 @@
#include "lyxtext.h"
#include "paragraph.h"
#include "paragraph_funcs.h"
#include "PosIterator.h"
#include "texrow.h"
#include "undo.h"
#include "WordLangTuple.h"
@ -259,7 +260,7 @@ bool BufferView::insertLyXFile(string const & filen)
string const fname = MakeAbsPath(filen);
text()->clearSelection();
clearSelection();
text()->breakParagraph(buffer()->paragraphs());
bool res = buffer()->readFile(fname, text()->cursorPar());
@ -312,7 +313,7 @@ void BufferView::gotoLabel(string const & label)
vector<string> labels;
it->getLabelList(*buffer(), labels);
if (find(labels.begin(),labels.end(),label) != labels.end()) {
text()->clearSelection();
clearSelection();
text()->setCursor(
std::distance(text()->paragraphs().begin(), it.getPar()),
it.getPos());
@ -330,7 +331,7 @@ void BufferView::undo()
return;
owner()->message(_("Undo"));
text()->clearSelection();
clearSelection();
if (!textUndo(this))
owner()->message(_("No further undo information"));
update();
@ -344,7 +345,7 @@ void BufferView::redo()
return;
owner()->message(_("Redo"));
text()->clearSelection();
clearSelection();
if (!textRedo(this))
owner()->message(_("No further redo information"));
update();
@ -551,3 +552,65 @@ CursorSlice & BufferView::selEnd()
return cursor();
return anchor() > cursor() ? anchor() : cursor();
}
void BufferView::setSelection()
{
selection().set(true);
// a selection with no contents is not a selection
if (cursor().par() == anchor().par() && cursor().pos() == anchor().pos())
selection().set(false);
}
void BufferView::clearSelection()
{
selection().set(false);
selection().mark(false);
resetAnchor();
unsetXSel();
}
/*
if the fitCursor call refers to some point in never-explored-land, then we
don't have y information in insets there, then we cannot even do an update
to get it (because we need the y infomation for setting top_y first). So
this is solved in put_selection_at with:
- setting top_y to the y of the outerPar (that has good info)
- calling update
- calling cursor().updatePos()
- then call fitCursor()
Ab.
*/
void BufferView::putSelectionAt(PosIterator const & cur,
int length, bool backwards)
{
ParIterator par(cur);
clearSelection();
LyXText * text = par.text(*buffer());
par.lockPath(this);
// hack for the chicken and egg problem
if (par.inset())
top_y(par.outerPar()->y);
update();
text->setCursor(cur.pit(), cur.pos());
fullCursor().updatePos();
if (length) {
text->setSelectionRange(length);
setSelection();
if (backwards)
std::swap(cursor(), anchor());
}
fitCursor();
update();
}

View File

@ -32,6 +32,7 @@ class LyXText;
class LyXScreen;
class LyXView;
class Painter;
class PosIterator;
class Selection;
class TeXErrors;
class UpdatableInset;
@ -142,6 +143,8 @@ public:
/// replace the currently selected word
void replaceWord(std::string const & replacestring);
/// simple replacing. Use the font of the first selected character
void replaceSelectionWithString(std::string const & str);
/// move cursor to the named label
void gotoLabel(std::string const & label);
@ -241,6 +244,12 @@ public:
CursorSlice & selEnd();
///
CursorSlice const & selEnd() const;
///
void setSelection();
///
void clearSelection();
///
void putSelectionAt(PosIterator const & cur, int length, bool backwards);
///
Selection selection_;

View File

@ -414,7 +414,7 @@ void BufferView::Pimpl::resizeCurrentBuffer()
text->setCursor(selstartpar, selstartpos);
bv_->resetAnchor();
text->setCursor(selendpar, selendpos);
text->setSelection();
bv_->setSelection();
text->setCursor(par, pos);
} else {
text->setCursor(par, pos);
@ -554,7 +554,7 @@ void BufferView::Pimpl::selectionLost()
{
if (available()) {
screen().hideCursor();
bv_->getLyXText()->clearSelection();
bv_->clearSelection();
xsel_cache_.set = false;
}
}
@ -661,7 +661,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
string const fname = saved_positions[i].filename;
bv_->text()->clearSelection();
bv_->clearSelection();
if (fname != buffer_->fileName()) {
Buffer * b = 0;
@ -713,7 +713,7 @@ void BufferView::Pimpl::center()
{
LyXText * text = bv_->text();
text->clearSelection();
bv_->clearSelection();
int const half_height = workarea().workHeight() / 2;
int new_y = std::max(0, text->cursorY() - half_height);
@ -751,7 +751,7 @@ InsetOld * BufferView::Pimpl::getInsetByCode(InsetOld::Code code)
// should work for now. Better infrastructure is coming. (Lgb)
Buffer * b = bv_->buffer();
LyXText * text = bv_->getLyXText();
LyXText * text = bv_->getLyXText();
Buffer::inset_iterator beg = b->inset_iterator_begin();
Buffer::inset_iterator end = b->inset_iterator_end();
@ -1243,6 +1243,33 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
lyx::find::replace(ev);
break;
case LFUN_MARK_OFF:
bv_->clearSelection();
bv_->update();
bv_->resetAnchor();
ev.message(N_("Mark off"));
break;
case LFUN_MARK_ON:
bv_->clearSelection();
bv_->selection().mark(true);
bv_->update();
bv_->resetAnchor();
ev.message(N_("Mark on"));
break;
case LFUN_SETMARK:
bv_->clearSelection();
if (bv_->selection().mark()) {
ev.message(N_("Mark removed"));
} else {
bv_->selection().mark(true);
ev.message(N_("Mark set"));
}
bv_->resetAnchor();
bv_->update();
break;
case LFUN_UNKNOWN_ACTION:
ev.errorMessage(N_("Unknown function!"));
break;
@ -1261,7 +1288,7 @@ bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
bv_->text()->recUndo(bv_->text()->cursor().par());
freezeUndo();
bv_->text()->clearSelection();
bv_->clearSelection();
if (!lout.empty()) {
bv_->text()->breakParagraph(bv_->buffer()->paragraphs());

View File

@ -14,6 +14,7 @@
#include "buffer.h"
#include "BufferView.h"
#include "cursor_slice.h"
#include "iterators.h"
#include "lyxtext.h"
#include "paragraph.h"
@ -26,6 +27,7 @@
using boost::prior;
PosIterator & PosIterator::operator++()
{
BOOST_ASSERT(!stack_.empty());
@ -128,7 +130,7 @@ PosIterator::PosIterator(ParagraphList * pl, ParagraphList::iterator pit,
PosIterator::PosIterator(BufferView & bv)
{
LyXText * text = bv.getLyXText();
lyx::pos_type pos = text->cursor().pos();
lyx::pos_type pos = bv.cursor().pos();
ParagraphList::iterator pit = text->cursorPar();
ParIterator par = bv.buffer()->par_iterator_begin();

View File

@ -27,7 +27,6 @@
#include "lyxrow.h"
#include "paragraph.h"
#include "ParagraphParameters.h"
#include "PosIterator.h"
#include "iterators.h"
#include "frontends/Alert.h"
@ -265,47 +264,4 @@ void replaceSelection(LyXText * text)
}
}
/*
if the fitCursor call refers to some point in never-explored-land, then we
don't have y information in insets there, then we cannot even do an update
to get it (because we need the y infomation for setting top_y first). So
this is solved in put_selection_at with:
- setting top_y to the y of the outerPar (that has good info)
- calling update
- calling cursor().updatePos()
- then call fitCursor()
Ab.
*/
void put_selection_at(BufferView * bv, PosIterator const & cur,
int length, bool backwards)
{
ParIterator par(cur);
bv->getLyXText()->clearSelection();
LyXText * text = par.text(*bv->buffer());
par.lockPath(bv);
// hack for the chicken and egg problem
if (par.inset())
bv->top_y(par.outerPar()->y);
bv->update();
text->setCursor(cur.pit(), cur.pos());
bv->fullCursor().updatePos();
if (length) {
text->setSelectionRange(length);
text->setSelection();
if (backwards)
std::swap(text->cursor(), text->anchor());
}
bv->fitCursor();
bv->update();
}
} // namespace bv_funcs

View File

@ -37,9 +37,6 @@ bool string2font(std::string const & data, LyXFont & font, bool & toggle);
* frontends.
*/
std::string const freefont2string();
///
void put_selection_at(BufferView * bv, PosIterator const & cur,
int length, bool backwards);
/// what type of depth change to make

View File

@ -13,7 +13,6 @@
#include "ControlErrorList.h"
#include "buffer.h"
#include "BufferView.h"
#include "bufferview_funcs.h"
#include "debug.h"
#include "iterators.h"
#include "lyxtext.h"
@ -75,5 +74,5 @@ void ControlErrorList::goTo(int item)
// Now make the selection.
PosIterator const pos = pit.asPosIterator(start);
bv_funcs::put_selection_at(kernel().bufferview(), pos, range, false);
kernel().bufferview()->putSelectionAt(pos, range, false);
}

View File

@ -236,7 +236,7 @@ void ControlSpellchecker::check()
if (!word_.word().empty()) {
int const size = word_.word().size();
advance(cur, -size);
bv_funcs::put_selection_at(bufferview(), cur, size, false);
bufferview()->putSelectionAt(cur, size, false);
advance(cur, size);
} else {
showSummary();

View File

@ -423,7 +423,7 @@ void InsetTabular::lfunMouseMotion(FuncRequest const & cmd)
setPos(bv, cmd.x, cmd.y);
if (!hasSelection()) {
setSelection(actcell, actcell);
tabular.getCellInset(actcell).text_.setSelection();
bv->setSelection();
} else {
bv->cursor().cell(actcell);
setSelection(sel_cell_start, actcell);

View File

@ -84,7 +84,7 @@ public:
///
void updateLocal(BufferView *) const;
///
bool insetAllowed(InsetOld::Code code) const { return true; }
bool insetAllowed(InsetOld::Code) const { return true; }
///
bool isTextInset() const { return true; }
/** returns true if, when outputing LaTeX, font changes should

View File

@ -277,7 +277,7 @@ void InsetText::edit(BufferView * bv, bool left)
int const par = left ? 0 : paragraphs().size() - 1;
int const pos = left ? 0 : paragraphs().back().size();
text_.setCursor(par, pos);
text_.clearSelection();
bv->clearSelection();
finishUndo();
sanitizeEmptyText(bv);
updateLocal(bv);
@ -290,7 +290,7 @@ void InsetText::edit(BufferView * bv, int x, int y)
lyxerr << "InsetText::edit xy" << endl;
old_par = -1;
text_.setCursorFromCoordinates(x - text_.xo_, y + bv->top_y() - text_.yo_);
text_.clearSelection();
bv->clearSelection();
finishUndo();
sanitizeEmptyText(bv);
updateLocal(bv);
@ -542,7 +542,7 @@ void InsetText::collapseParagraphs(BufferView * bv)
first->insertChar(first_par_size, ' ');
}
text_.clearSelection();
bv->clearSelection();
mergeParagraph(bv->buffer()->params(), paragraphs(), first);
}
}

View File

@ -358,7 +358,7 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
// clear the selection
if (bv->text() == bv->getLyXText())
bv->text()->clearSelection();
bv->clearSelection();
if (asParagraph)
bv->getLyXText()->insertStringAsParagraphs(tmpstr);
else

View File

@ -16,6 +16,7 @@
#include "lyxfind.h"
#include "buffer.h"
#include "cursor_slice.h"
#include "BufferView.h"
#include "debug.h"
#include "iterators.h"
@ -38,8 +39,6 @@ using lyx::support::lowercase;
using lyx::support::uppercase;
using lyx::support::split;
using bv_funcs::put_selection_at;
using std::ostringstream;
using std::string;
@ -202,7 +201,7 @@ bool findNextChange(BufferView * bv)
}
}
pos_type length = end - pos;
put_selection_at(bv, cur, length, true);
bv->putSelectionAt(cur, length, true);
return true;
}
@ -317,7 +316,7 @@ bool find(BufferView * bv, string const & searchstr, bool cs, bool mw, bool fw)
: findBackwards(cur, beg, match);
if (found)
put_selection_at(bv, cur, searchstr.length(), !fw);
bv->putSelectionAt(cur, searchstr.length(), !fw);
return found;
}
@ -354,7 +353,7 @@ int replaceAll(BufferView * bv,
PosIterator beg = buf.pos_iterator_begin();
bv->text()->init(bv);
put_selection_at(bv, beg, 0, false);
bv->putSelectionAt(beg, 0, false);
if (num)
buf.markDirty();
return num;

View File

@ -15,7 +15,6 @@
#define LYXTEXT_H
#include "bufferview_funcs.h"
#include "cursor_slice.h"
#include "Bidi.h"
#include "layout.h"
#include "lyxfont.h"
@ -405,11 +404,6 @@ public:
/// access to the selection anchor
CursorSlice const & anchor() const;
///
void setSelection();
///
void clearSelection();
public:
///
int height;

View File

@ -833,7 +833,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
// convenience function
void LyXText::redoParagraph()
{
clearSelection();
bv()->clearSelection();
redoParagraph(cursorPar());
setCursorIntern(cursor().par(), cursor().pos());
}
@ -1106,7 +1106,7 @@ void LyXText::selectWord(word_location loc)
return;
bv()->resetAnchor();
setCursor(to.par(), to.pos());
setSelection();
bv()->setSelection();
}
@ -1133,7 +1133,7 @@ void LyXText::acceptChange()
recordUndo(Undo::INSERT, this, startc.par());
getPar(startc)->acceptChange(startc.pos(), endc.pos());
finishUndo();
clearSelection();
bv()->clearSelection();
redoParagraph(getPar(startc));
setCursorIntern(startc.par(), 0);
}
@ -1152,7 +1152,7 @@ void LyXText::rejectChange()
recordUndo(Undo::INSERT, this, startc.par());
getPar(startc)->rejectChange(startc.pos(), endc.pos());
finishUndo();
clearSelection();
bv()->clearSelection();
redoParagraph(getPar(startc));
setCursorIntern(startc.par(), 0);
}
@ -1172,7 +1172,7 @@ void LyXText::deleteWordForward()
setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos());
bv()->resetAnchor();
cursor() = tmpcursor;
setSelection();
bv()->setSelection();
cutSelection(true, false);
}
}
@ -1190,7 +1190,7 @@ void LyXText::deleteWordBackward()
setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos());
bv()->resetAnchor();
cursor() = tmpcursor;
setSelection();
bv()->setSelection();
cutSelection(true, false);
}
}
@ -1209,7 +1209,7 @@ void LyXText::deleteLineForward()
setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos());
bv()->resetAnchor();
cursor() = tmpcursor;
setSelection();
bv()->setSelection();
// What is this test for ??? (JMarc)
if (!bv()->selection().set())
deleteWordForward();
@ -1957,24 +1957,3 @@ CursorSlice const & LyXText::anchor() const
{
return bv()->anchor();
}
void LyXText::setSelection()
{
bv()->selection().set(true);
// a selection with no contents is not a selection
if (cursor().par() == anchor().par() && cursor().pos() == anchor().pos())
bv()->selection().set(false);
}
void LyXText::clearSelection()
{
bv()->selection().set(false);
bv()->selection().mark(false);
bv()->resetAnchor();
// reset this in the bv()!
if (bv() && bv()->text())
bv()->unsetXSel();
}

View File

@ -530,7 +530,7 @@ void LyXText::toggleFree(LyXFont const & font, bool toggleall)
// Implicit selections are cleared afterwards
//and cursor is set to the original position.
if (implicitSelection) {
clearSelection();
bv()->clearSelection();
cursor() = resetCursor;
bv()->resetAnchor();
}
@ -560,7 +560,7 @@ string LyXText::getStringToIndex()
// Clear the implicit selection.
if (implicitSelection)
clearSelection();
bv()->clearSelection();
return idxstring;
}
@ -968,7 +968,7 @@ void LyXText::cutSelection(bool doclear, bool realcut)
cursor().par(parOffset(endpit));
// need a valid cursor. (Lgb)
clearSelection();
bv()->clearSelection();
updateCounters();
}
@ -1024,11 +1024,10 @@ void LyXText::pasteSelection(size_t sel_index)
redoParagraphs(cursorPar(), endpit);
clearSelection();
bv()->clearSelection();
bv()->resetAnchor();
setCursor(ppp.first, ppp.second);
setSelection();
bv()->setSelection();
updateCounters();
}
@ -1041,7 +1040,7 @@ void LyXText::setSelectionRange(lyx::pos_type length)
bv()->resetAnchor();
while (length--)
cursorRight(true);
setSelection();
bv()->setSelection();
}
@ -1082,14 +1081,13 @@ void LyXText::insertStringAsLines(string const & str)
recUndo(cursor().par());
// only to be sure, should not be neccessary
clearSelection();
bv()->clearSelection();
bv()->buffer()->insertStringAsLines(pit, pos, current_font, str);
redoParagraphs(cursorPar(), endpit);
bv()->resetAnchor();
setCursor(pit, pos);
setSelection();
bv()->setSelection();
}
@ -1401,7 +1399,7 @@ DispatchResult LyXText::moveRightIntern(bool front, bool activate_inset, bool se
return DispatchResult(true, true);
cursorRight(true);
if (!selecting)
clearSelection();
bv()->clearSelection();
return DispatchResult(true);
}
@ -1413,7 +1411,7 @@ DispatchResult LyXText::moveLeftIntern(bool front,
return DispatchResult(false, FINISHED);
cursorLeft(true);
if (!selecting)
clearSelection();
bv()->clearSelection();
if (activate_inset && checkAndActivateInset(front))
return DispatchResult(true, true);
return DispatchResult(true);
@ -1425,7 +1423,7 @@ DispatchResult LyXText::moveUp()
if (cursorPar() == firstPar() && cursorRow() == firstRow())
return DispatchResult(false, FINISHED_UP);
cursorUp(false);
clearSelection();
bv()->clearSelection();
return DispatchResult(true);
}
@ -1435,7 +1433,7 @@ DispatchResult LyXText::moveDown()
if (cursorPar() == lastPar() && cursorRow() == lastRow())
return DispatchResult(false, FINISHED_DOWN);
cursorDown(false);
clearSelection();
bv()->clearSelection();
return DispatchResult(true);
}
@ -1562,6 +1560,9 @@ void LyXText::fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where)
bool LyXText::deleteEmptyParagraphMechanism(CursorSlice const & old_cursor)
{
#warning Disabled as it crashes after the cursor data shift... (Andre)
return false;
// Would be wrong to delete anything if we have a selection.
if (bv()->selection().set())
return false;

View File

@ -215,10 +215,8 @@ namespace {
void moveCursor(BufferView * bv, bool selecting)
{
LyXText * lt = bv->getLyXText();
if (selecting || bv->selection().mark())
lt->setSelection();
bv->setSelection();
if (!bv->selection().set())
bv->haveSelection(false);
@ -321,7 +319,7 @@ bool LyXText::gotoNextInset(vector<InsetOld::Code> const & codes,
void LyXText::gotoInset(vector<InsetOld::Code> const & codes,
bool same_content)
{
clearSelection();
bv()->clearSelection();
string contents;
if (same_content && cursor().pos() < cursorPar()->size()
@ -486,26 +484,26 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
}
case LFUN_DELETE_WORD_FORWARD:
clearSelection();
bv->clearSelection();
deleteWordForward();
finishChange(bv);
break;
case LFUN_DELETE_WORD_BACKWARD:
clearSelection();
bv->clearSelection();
deleteWordBackward();
finishChange(bv);
break;
case LFUN_DELETE_LINE_FORWARD:
clearSelection();
bv->clearSelection();
deleteLineForward();
finishChange(bv);
break;
case LFUN_WORDRIGHT:
if (!bv->selection().mark())
clearSelection();
bv->clearSelection();
if (rtl())
cursorLeftOneWord();
else
@ -515,7 +513,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_WORDLEFT:
if (!bv->selection().mark())
clearSelection();
bv->clearSelection();
if (rtl())
cursorRightOneWord();
else
@ -525,14 +523,14 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_BEGINNINGBUF:
if (!bv->selection().mark())
clearSelection();
bv->clearSelection();
cursorTop();
finishChange(bv);
break;
case LFUN_ENDBUF:
if (bv->selection().mark())
clearSelection();
bv->clearSelection();
cursorBottom();
finishChange(bv);
break;
@ -657,21 +655,21 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_UP_PARAGRAPH:
if (!bv->selection().mark())
clearSelection();
bv->clearSelection();
cursorUpParagraph();
finishChange(bv);
break;
case LFUN_DOWN_PARAGRAPH:
if (!bv->selection().mark())
clearSelection();
bv->clearSelection();
cursorDownParagraph();
finishChange(bv, false);
break;
case LFUN_PRIOR:
if (!bv->selection().mark())
clearSelection();
bv->clearSelection();
finishChange(bv, false);
if (cursorPar() == firstPar() && cursorRow() == firstRow())
return DispatchResult(false, FINISHED_UP);
@ -680,7 +678,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_NEXT:
if (!bv->selection().mark())
clearSelection();
bv->clearSelection();
finishChange(bv, false);
if (cursorPar() == lastPar() && cursorRow() == lastRow())
return DispatchResult(false, FINISHED_DOWN);
@ -689,14 +687,14 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_HOME:
if (!bv->selection().mark())
clearSelection();
bv->clearSelection();
cursorHome();
finishChange(bv, false);
break;
case LFUN_END:
if (!bv->selection().mark())
clearSelection();
bv->clearSelection();
cursorEnd();
finishChange(bv, false);
break;
@ -881,7 +879,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
break;
case LFUN_INSET_TOGGLE:
clearSelection();
bv->clearSelection();
if (!toggleInset())
return DispatchResult(false);
bv->update();
@ -916,33 +914,6 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
specialChar(this, bv, InsetSpecialChar::MENU_SEPARATOR);
break;
case LFUN_MARK_OFF:
clearSelection();
bv->update();
bv->resetAnchor();
cmd.message(N_("Mark off"));
break;
case LFUN_MARK_ON:
clearSelection();
bv->selection().mark(true);
bv->update();
bv->resetAnchor();
cmd.message(N_("Mark on"));
break;
case LFUN_SETMARK:
clearSelection();
if (bv->selection().mark()) {
cmd.message(N_("Mark removed"));
} else {
bv->selection().mark(true);
cmd.message(N_("Mark set"));
}
bv->resetAnchor();
bv->update();
break;
case LFUN_UPCASE_WORD:
changeCase(LyXText::text_uppercase);
bv->update();
@ -972,7 +943,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
pasteSelection(strToUnsignedInt(cmd.argument));
else
pasteSelection(0);
clearSelection(); // bug 393
bv->clearSelection(); // bug 393
bv->update();
bv->switchKeyMap();
finishUndo();
@ -1097,9 +1068,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
}
case LFUN_PASTESELECTION: {
// this was originally a bv->text->clearSelection(), i.e
// the outermost LyXText!
clearSelection();
bv->clearSelection();
string const clip = bv->getClipboard();
if (!clip.empty()) {
if (cmd.argument == "paragraph")
@ -1179,7 +1148,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
cursorHome();
bv->resetAnchor();
cursorEnd();
setSelection();
bv->setSelection();
bv->haveSelection(bv->selection().set());
}
break;
@ -1221,7 +1190,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
else if (cmd.y - bv->top_y() < 0)
cursorUp(true);
}
setSelection();
bv->setSelection();
break;
}
@ -1256,7 +1225,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
selection_possible = true;
// Clear the selection
clearSelection();
bv->clearSelection();
// Right click on a footnote flag opens float menu
if (cmd.button() == mouse_button::button3) {
@ -1326,7 +1295,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
bv->haveSelection(false);
}
clearSelection();
bv->clearSelection();
LyXFont const old_font = real_current_font;
string::const_iterator cit = cmd.argument.begin();

View File

@ -17,6 +17,7 @@
#include "undo.h"
#include "buffer.h"
#include "cursor_slice.h"
#include "debug.h"
#include "BufferView.h"
#include "iterators.h"
@ -178,11 +179,11 @@ bool performUndoOrRedo(BufferView * bv, Undo const & undo)
<< std::endl;
// set cursor again to force the position to be the right one
text->cursor().par(undo.cursor_par);
text->cursor().pos(undo.cursor_pos);
bv->cursor().par(undo.cursor_par);
bv->cursor().pos(undo.cursor_pos);
// clear any selection
text->clearSelection();
bv->clearSelection();
bv->resetAnchor();
text->updateCounters();
@ -224,9 +225,8 @@ bool textUndoOrRedo(BufferView * bv,
advance(last, plist.size() - undo.end_par + 1);
otherstack.top().pars.insert(otherstack.top().pars.begin(), first, last);
}
LyXText * text = pit.text(buf);
otherstack.top().cursor_pos = text->cursor().pos();
otherstack.top().cursor_par = text->cursor().par();
otherstack.top().cursor_pos = bv->cursor().pos();
otherstack.top().cursor_par = bv->cursor().par();
lyxerr << " undo other: " << otherstack.top() << std::endl;
}