-/* This file is part of
- * ======================================================
+/**
+ * \file text3.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * LyX, The Document Processor
+ * \author Asger Alstrup
+ * \author Lars Gullik Bjønnes
+ * \author Alfredo Braunstein
+ * \author Angus Leeming
+ * \author John Levon
+ * \author André Pönitz
*
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2002 The LyX Team.
- *
- * ====================================================== */
+ * Full author contact details are available in file CREDITS.
+ */
#include <config.h>
#include "lyxtext.h"
-#include "lyxrow.h"
#include "paragraph.h"
#include "BufferView.h"
#include "funcrequest.h"
#include "debug.h"
#include "bufferparams.h"
#include "buffer.h"
+#include "bufferview_funcs.h"
#include "ParagraphParameters.h"
#include "gettext.h"
#include "factory.h"
#include "language.h"
#include "support/tostr.h"
#include "support/lstrings.h"
+#include "support/LAssert.h"
#include "frontends/LyXView.h"
#include "frontends/screen.h"
#include "frontends/Dialogs.h"
#include <clocale>
using namespace lyx::support;
+using namespace bv_funcs;
using std::endl;
using std::find;
{
LyXText * lt = bv->getLyXText();
- if (selecting || lt->selection.mark()) {
+ //if (!lt->selection.set())
+ // lt->selection.cursor = lt->cursor;
+
+ if (selecting || lt->selection.mark())
lt->setSelection();
- if (lt->isInInset())
- bv->updateInset(lt->inset_owner);
- else
- bv->toggleToggle();
- }
- if (!lt->isInInset()) {
- bv->update(lt, BufferView::SELECT);
- } else if (bv->text->refreshStatus() != LyXText::REFRESH_NONE) {
- bv->update(BufferView::SELECT);
- }
if (!lt->selection.set())
bv->haveSelection(false);
+ bv->update();
bv->switchKeyMap();
}
// check if the given co-ordinates are inside an inset at the
// given cursor, if one exists. If so, the inset is returned,
// and the co-ordinates are made relative. Otherwise, 0 is returned.
- Inset * checkInset(BufferView * bv, LyXText & text,
+ InsetOld * checkInset(BufferView * /*bv*/, LyXText & text,
LyXCursor const & cur, int & x, int & y)
{
lyx::pos_type const pos = cur.pos();
if (pos >= par->size() || !par->isInset(pos))
return 0;
- Inset /*const*/ * inset = par->getInset(pos);
+ InsetOld /*const*/ * inset = par->getInset(pos);
if (!isEditableInset(inset))
return 0;
// get inset dimensions
Assert(par->getInset(pos));
- LyXFont const & font = text.getFont(bv->buffer(), par, pos);
+ LyXFont const & font = text.getFont(par, pos);
- int const width = inset->width(bv, font);
+ int const width = inset->width();
int const inset_x = font.isVisibleRightToLeft()
- ? (cur.ix() - width) : cur.ix();
+ ? (cur.x() - width) : cur.x();
Box b(
inset_x + inset->scroll(),
inset_x + width,
- cur.iy() - inset->ascent(bv, font),
- cur.iy() + inset->descent(bv, font)
+ cur.y() - inset->ascent(),
+ cur.y() + inset->descent()
);
- if (!b.contained(x, y)) {
+ if (!b.contains(x, y)) {
lyxerr[Debug::GUI] << "Missed inset at x,y "
<< x << ',' << y
<< " box " << b << endl;
x -= b.x1;
// The origin of an inset is on the baseline
- y -= text.cursor.iy();
+ y -= text.cursor.y();
return inset;
}
} // anon namespace
-Inset * LyXText::checkInsetHit(int & x, int & y)
+InsetOld * LyXText::checkInsetHit(int & x, int & y)
{
- int y_tmp = y + top_y();
+ int y_tmp = y + bv_owner->top_y();
LyXCursor cur;
setCursorFromCoordinates(cur, x, y_tmp);
- Inset * inset = checkInset(bv(), *this, cur, x, y_tmp);
+ InsetOld * inset = checkInset(bv(), *this, cur, x, y_tmp);
if (inset) {
y = y_tmp;
return inset;
}
-bool LyXText::gotoNextInset(vector<Inset::Code> const & codes,
+bool LyXText::gotoNextInset(vector<InsetOld::Code> const & codes,
string const & contents)
{
ParagraphList::iterator end = ownerParagraphs().end();
ParagraphList::iterator pit = cursor.par();
pos_type pos = cursor.pos();
- Inset * inset;
+ InsetOld * inset;
do {
if (pos + 1 < pit->size()) {
++pos;
}
-void LyXText::gotoInset(vector<Inset::Code> const & codes,
+void LyXText::gotoInset(vector<InsetOld::Code> const & codes,
bool same_content)
{
bv()->beforeChange(this);
- update();
string contents;
if (same_content && cursor.pos() < cursor.par()->size()
&& cursor.par()->isInset(cursor.pos())) {
- Inset const * inset = cursor.par()->getInset(cursor.pos());
+ InsetOld const * inset = cursor.par()->getInset(cursor.pos());
if (find(codes.begin(), codes.end(), inset->lyxCode())
!= codes.end())
contents = static_cast<InsetCommand const *>(inset)->getContents();
bv()->owner()->message(_("No more insets"));
}
}
- update();
+ bv()->update();
selection.cursor = cursor;
}
-void LyXText::gotoInset(Inset::Code code, bool same_content)
+void LyXText::gotoInset(InsetOld::Code code, bool same_content)
{
- gotoInset(vector<Inset::Code>(1, code), same_content);
+ gotoInset(vector<InsetOld::Code>(1, code), same_content);
}
void LyXText::cursorPrevious()
{
- int y = top_y();
+ int y = bv_owner->top_y();
+
+ RowList::iterator rit = cursorRow();
- if (cursorRow() == rows().begin()) {
- if (y > 0) {
- int new_y = bv()->text->top_y() - bv()->workHeight();
- bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y);
+ if (rit == firstRow()) {
+ if (y > 0)
bv()->updateScrollbar();
- }
return;
}
- RowList::iterator cursorrow = cursorRow();
-
setCursorFromCoordinates(cursor.x_fix(), y);
finishUndo();
int new_y;
- if (cursorrow == bv()->text->cursorRow()) {
+ if (rit == bv()->text->cursorRow()) {
// we have a row which is taller than the workarea. The
// simplest solution is to move to the previous row instead.
cursorUp(true);
return;
// This is what we used to do, so we wouldn't skip right past
// tall rows, but it's not working right now.
-#if 0
- new_y = bv->text->top_y() - bv->workHeight();
-#endif
} else {
if (inset_owner) {
- new_y = bv()->text->cursor.iy()
+ new_y = bv()->text->cursor.y()
+ bv()->theLockingInset()->insetInInsetY() + y
- + cursorRow()->height()
+ + rit->height()
- bv()->workHeight() + 1;
} else {
new_y = cursor.y()
- - cursorRow()->baseline()
- + cursorRow()->height()
+ - rit->baseline()
+ + rit->height()
- bv()->workHeight() + 1;
}
}
- bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y);
- if (cursorRow() != rows().begin()) {
- LyXCursor cur;
- setCursor(cur, boost::prior(cursorRow())->par(),
- boost::prior(cursorRow())->pos(), false);
- if (cur.y() > top_y()) {
- cursorUp(true);
- }
- }
+
+ LyXCursor cur;
+ ParagraphList::iterator pit = cursor.par();
+ previousRow(pit, rit);
+ setCursor(cur, pit, rit->pos(), false);
+ if (cur.y() > bv_owner->top_y())
+ cursorUp(true);
bv()->updateScrollbar();
}
void LyXText::cursorNext()
{
- int topy = top_y();
+ int topy = bv_owner->top_y();
- if (boost::next(cursorRow()) == rows().end()) {
- int y = cursor.y() - cursorRow()->baseline() +
- cursorRow()->height();
- if (y > topy + bv()->workHeight()) {
- bv()->screen().draw(bv()->text, bv(), bv()->text->top_y() + bv()->workHeight());
- bv()->updateScrollbar();
- }
+ RowList::iterator rit = cursorRow();
+ if (rit == lastRow()) {
+ int y = cursor.y() - rit->baseline() + cursorRow()->height();
+ if (y > topy + bv()->workHeight())
+ bv_owner->updateScrollbar();
return;
}
- int y = topy + bv()->workHeight();
+ int y = topy + bv_owner->workHeight();
if (inset_owner && !topy) {
- y -= (bv()->text->cursor.iy()
- - bv()->text->top_y()
- + bv()->theLockingInset()->insetInInsetY());
+ y -= (bv_owner->text->cursor.y()
+ - bv_owner->top_y()
+ + bv_owner->theLockingInset()->insetInInsetY());
}
- getRowNearY(y);
+ ParagraphList::iterator dummypit;
+ y = getRowNearY(y, dummypit)->y();
- RowList::iterator cursorrow = cursorRow();
setCursorFromCoordinates(cursor.x_fix(), y);
// + bv->workHeight());
finishUndo();
int new_y;
- if (cursorrow == bv()->text->cursorRow()) {
+ if (rit == bv_owner->text->cursorRow()) {
// we have a row which is taller than the workarea. The
// simplest solution is to move to the next row instead.
cursorDown(true);
// This is what we used to do, so we wouldn't skip right past
// tall rows, but it's not working right now.
#if 0
- new_y = bv->text->top_y() + bv->workHeight();
+ new_y = bv->top_y() + bv->workHeight();
#endif
} else {
if (inset_owner) {
- new_y = bv()->text->cursor.iy()
+ new_y = bv()->text->cursor.y()
+ bv()->theLockingInset()->insetInInsetY()
- + y - cursorRow()->baseline();
+ + y - rit->baseline();
} else {
- new_y = cursor.y() - cursorRow()->baseline();
- }
- }
- bv()->screen().draw(bv()->text, bv(), new_y);
-
- RowList::iterator next_row = boost::next(cursorRow());
- if (next_row != rows().end()) {
- LyXCursor cur;
- setCursor(cur, next_row->par(), next_row->pos(), false);
- if (cur.y() < top_y() + bv()->workHeight()) {
- cursorDown(true);
+ new_y = cursor.y() - cursorRow()->baseline();
}
}
+
+ ParagraphList::iterator pit = cursor.par();
+ nextRow(pit, rit);
+ LyXCursor cur;
+ setCursor(cur, pit, rit->pos(), false);
+ if (cur.y() < bv_owner->top_y() + bv()->workHeight())
+ cursorDown(true);
bv()->updateScrollbar();
}
-void LyXText::update()
-{
- bv()->update(this, BufferView::SELECT);
-}
-
namespace {
void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind)
{
- lt->update();
+ bv->update();
InsetSpecialChar * new_inset = new InsetSpecialChar(kind);
+ replaceSelection(lt);
if (!bv->insertInset(new_inset))
delete new_inset;
else
void doInsertInset(LyXText * lt, FuncRequest const & cmd,
bool edit, bool pastesel)
{
- Inset * inset = createInset(cmd);
+ InsetOld * inset = createInset(cmd);
BufferView * bv = cmd.view();
if (inset) {
}
-Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
+InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
{
lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << cmd.action
<<"] arg[" << cmd.argument << ']' << endl;
for (; tmp != end; ++tmp) {
if (tmp->params().startOfAppendix()) {
- setUndo(bv, Undo::EDIT, tmp);
+ recordUndo(bv, Undo::ATOMIC, tmp);
tmp->params().startOfAppendix(false);
- int tmpy;
- setHeightOfRow(getRow(tmp, 0, tmpy));
+ redoParagraph(tmp);
break;
}
}
- setUndo(bv, Undo::EDIT, pit);
+ recordUndo(bv, Undo::ATOMIC, pit);
pit->params().startOfAppendix(start);
// we can set the refreshing parameters now
updateCounters();
- redoHeightOfParagraph();
- postPaint(0);
+ redoParagraph(cursor.par());
setCursor(cursor.par(), cursor.pos());
- update();
+ bv->update();
break;
}
case LFUN_DELETE_WORD_FORWARD:
bv->beforeChange(this);
- update();
deleteWordForward();
- update();
finishChange(bv);
break;
case LFUN_DELETE_WORD_BACKWARD:
bv->beforeChange(this);
- update();
deleteWordBackward();
- update();
finishChange(bv);
break;
case LFUN_DELETE_LINE_FORWARD:
bv->beforeChange(this);
- update();
deleteLineForward();
- update();
finishChange(bv);
break;
case LFUN_WORDRIGHT:
if (!selection.mark())
bv->beforeChange(this);
- update();
if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
cursorLeftOneWord();
else
case LFUN_WORDLEFT:
if (!selection.mark())
bv->beforeChange(this);
- update();
if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
cursorRightOneWord();
else
case LFUN_BEGINNINGBUF:
if (!selection.mark())
bv->beforeChange(this);
- update();
cursorTop();
finishChange(bv);
break;
case LFUN_ENDBUF:
if (selection.mark())
bv->beforeChange(this);
- update();
cursorBottom();
finishChange(bv);
break;
case LFUN_RIGHTSEL:
- update();
+ if (!selection.set())
+ selection.cursor = cursor;
if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
cursorLeft(bv);
else
break;
case LFUN_LEFTSEL:
- update();
+ if (!selection.set())
+ selection.cursor = cursor;
if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
cursorRight(bv);
else
break;
case LFUN_UPSEL:
- update();
+ if (!selection.set())
+ selection.cursor = cursor;
cursorUp(true);
finishChange(bv, true);
break;
case LFUN_DOWNSEL:
- update();
+ if (!selection.set())
+ selection.cursor = cursor;
cursorDown(true);
finishChange(bv, true);
break;
case LFUN_UP_PARAGRAPHSEL:
- update();
+ if (!selection.set())
+ selection.cursor = cursor;
cursorUpParagraph();
finishChange(bv, true);
break;
case LFUN_DOWN_PARAGRAPHSEL:
- update();
+ if (!selection.set())
+ selection.cursor = cursor;
cursorDownParagraph();
finishChange(bv, true);
break;
case LFUN_PRIORSEL:
- update();
+ if (!selection.set())
+ selection.cursor = cursor;
cursorPrevious();
finishChange(bv, true);
break;
case LFUN_NEXTSEL:
- update();
+ if (!selection.set())
+ selection.cursor = cursor;
cursorNext();
finishChange(bv, true);
break;
case LFUN_HOMESEL:
- update();
+ if (!selection.set())
+ selection.cursor = cursor;
cursorHome();
finishChange(bv, true);
break;
case LFUN_ENDSEL:
- update();
+ if (!selection.set())
+ selection.cursor = cursor;
cursorEnd();
finishChange(bv, true);
break;
case LFUN_WORDRIGHTSEL:
- update();
if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
cursorLeftOneWord();
else
break;
case LFUN_WORDLEFTSEL:
- update();
if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
cursorRightOneWord();
else
break;
case LFUN_WORDSEL: {
- update();
- LyXCursor cur1;
+ LyXCursor cur1 = cursor;
LyXCursor cur2;
- getWord(cur1, cur2, WHOLE_WORD);
+ ::getWord(cur1, cur2, lyx::WHOLE_WORD, ownerParagraphs());
setCursor(cur1.par(), cur1.pos());
bv->beforeChange(this);
setCursor(cur2.par(), cur2.pos());
bool is_rtl = cursor.par()->isRightToLeftPar(bv->buffer()->params);
if (!selection.mark())
bv->beforeChange(this);
- update();
if (is_rtl)
cursorLeft(false);
if (cursor.pos() < cursor.par()->size()
&& cursor.par()->isInset(cursor.pos())
&& isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) {
- Inset * tmpinset = cursor.par()->getInset(cursor.pos());
+ InsetOld * tmpinset = cursor.par()->getInset(cursor.pos());
cmd.message(tmpinset->editMessage());
FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "right" : "left");
tmpinset->localDispatch(cmd1);
bool const is_rtl = cursor.par()->isRightToLeftPar(bv->buffer()->params);
if (!selection.mark())
bv->beforeChange(this);
- update();
LyXCursor const cur = cursor;
if (!is_rtl)
cursorLeft(false);
cursor.pos() < cursor.par()->size() &&
cursor.par()->isInset(cursor.pos()) &&
isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) {
- Inset * tmpinset = cursor.par()->getInset(cursor.pos());
+ InsetOld * tmpinset = cursor.par()->getInset(cursor.pos());
cmd.message(tmpinset->editMessage());
FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "left" : "right");
tmpinset->localDispatch(cmd1);
case LFUN_UP:
if (!selection.mark())
bv->beforeChange(this);
- bv->update(this, BufferView::UPDATE);
- cursorUp(bv);
+ cursorUp(false);
finishChange(bv);
break;
case LFUN_DOWN:
if (!selection.mark())
bv->beforeChange(this);
- bv->update(this, BufferView::UPDATE);
- cursorDown(bv);
+ cursorDown(false);
finishChange(bv);
break;
case LFUN_UP_PARAGRAPH:
if (!selection.mark())
bv->beforeChange(this);
- bv->update(this, BufferView::UPDATE);
cursorUpParagraph();
finishChange(bv);
break;
case LFUN_DOWN_PARAGRAPH:
if (!selection.mark())
bv->beforeChange(this);
- bv->update(this, BufferView::UPDATE);
cursorDownParagraph();
finishChange(bv, false);
break;
case LFUN_PRIOR:
if (!selection.mark())
bv->beforeChange(this);
- bv->update(this, BufferView::UPDATE);
cursorPrevious();
finishChange(bv, false);
- // was:
- // finishUndo();
- // moveCursorUpdate(bv, false, false);
- // owner_->view_state_changed();
break;
case LFUN_NEXT:
if (!selection.mark())
bv->beforeChange(this);
- bv->update(this, BufferView::UPDATE);
cursorNext();
finishChange(bv, false);
break;
case LFUN_HOME:
if (!selection.mark())
bv->beforeChange(this);
- update();
cursorHome();
finishChange(bv, false);
break;
case LFUN_END:
if (!selection.mark())
bv->beforeChange(this);
- update();
cursorEnd();
finishChange(bv, false);
break;
if (cursor.pos() <= body)
break;
- bv->beforeChange(this);
+ replaceSelection(bv->getLyXText());
insertInset(new InsetNewline);
- update();
setCursor(cursor.par(), cursor.pos());
moveCursorUpdate(bv, false);
break;
if (!selection.set()) {
Delete();
selection.cursor = cursor;
- update();
// It is possible to make it a lot faster still
// just comment out the line below...
} else {
- update();
cutSelection(true, false);
- update();
}
moveCursorUpdate(bv, false);
bv->owner()->view_state_changed();
- bv->switchKeyMap();
break;
case LFUN_DELETE_SKIP:
cur.par()->params().align(),
cur.par()->params().labelWidthString(), 0);
cursorLeft(bv);
- update();
} else {
cursorLeft(bv);
Delete();
selection.cursor = cursor;
}
} else {
- update();
cutSelection(true, false);
}
- update();
+ bv->update();
break;
if (bv->owner()->getIntl().getTransManager().backspace()) {
backspace();
selection.cursor = cursor;
- update();
// It is possible to make it a lot faster still
// just comment out the line below...
}
} else {
- update();
cutSelection(true, false);
- update();
}
bv->owner()->view_state_changed();
bv->switchKeyMap();
+ bv->update();
break;
case LFUN_BACKSPACE_SKIP:
if (!selection.set()) {
LyXCursor cur = cursor;
if (cur.pos() == 0
- && !(cur.par()->params().spaceTop()
- == VSpace (VSpace::NONE))) {
+ && !(cur.par()->params().spaceTop() == VSpace(VSpace::NONE))) {
setParagraph(
cur.par()->params().lineTop(),
cur.par()->params().lineBottom(),
cur.par()->params().pagebreakTop(),
cur.par()->params().pagebreakBottom(),
- VSpace(VSpace::NONE), cur.par()->params().spaceBottom(),
+ VSpace(VSpace::NONE),
+ cur.par()->params().spaceBottom(),
cur.par()->params().spacing(),
cur.par()->params().align(),
cur.par()->params().labelWidthString(), 0);
selection.cursor = cur;
}
} else {
- update();
cutSelection(true, false);
}
- update();
+ bv->update();
break;
case LFUN_BREAKPARAGRAPH:
- bv->beforeChange(this);
+ replaceSelection(bv->getLyXText());
breakParagraph(bv->buffer()->paragraphs, 0);
- update();
+ bv->update();
selection.cursor = cursor;
bv->switchKeyMap();
bv->owner()->view_state_changed();
break;
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
- bv->beforeChange(this);
+ replaceSelection(bv->getLyXText());
breakParagraph(bv->buffer()->paragraphs, 1);
- update();
+ bv->update();
selection.cursor = cursor;
bv->switchKeyMap();
bv->owner()->view_state_changed();
// indentation and add a "defskip" at the top.
// Otherwise, do the same as LFUN_BREAKPARAGRAPH.
LyXCursor cur = cursor;
- bv->beforeChange(this);
+ replaceSelection(bv->getLyXText());
if (cur.pos() == 0) {
if (cur.par()->params().spaceTop() == VSpace(VSpace::NONE)) {
setParagraph(
else {
breakParagraph(bv->buffer()->paragraphs, 0);
}
- update();
+ bv->update();
selection.cursor = cur;
bv->switchKeyMap();
bv->owner()->view_state_changed();
if (cur_spacing != new_spacing || cur_value != new_value) {
pit->params().spacing(Spacing(new_spacing, new_value));
redoParagraph();
- update();
+ bv->update();
}
break;
}
case LFUN_INSET_TOGGLE:
bv->beforeChange(this);
- update();
toggleInset();
- update();
+ bv->update();
bv->switchKeyMap();
break;
case LFUN_SPACE_INSERT:
- if (cursor.par()->layout()->free_spacing) {
+ if (cursor.par()->layout()->free_spacing)
insertChar(' ');
- update();
- } else {
+ else
doInsertInset(this, cmd, false, false);
- }
moveCursorUpdate(bv, false);
break;
case LFUN_MARK_OFF:
bv->beforeChange(this);
- update();
+ bv->update();
selection.cursor = cursor;
cmd.message(N_("Mark off"));
break;
case LFUN_MARK_ON:
bv->beforeChange(this);
selection.mark(true);
- update();
+ bv->update();
selection.cursor = cursor;
cmd.message(N_("Mark on"));
break;
case LFUN_SETMARK:
bv->beforeChange(this);
if (selection.mark()) {
- update();
cmd.message(N_("Mark removed"));
} else {
selection.mark(true);
- update();
cmd.message(N_("Mark set"));
}
selection.cursor = cursor;
+ bv->update();
break;
case LFUN_UPCASE_WORD:
- update();
changeCase(LyXText::text_uppercase);
- if (inset_owner)
- bv->updateInset(inset_owner);
- update();
+ bv->update();
break;
case LFUN_LOWCASE_WORD:
- update();
changeCase(LyXText::text_lowercase);
- if (inset_owner)
- bv->updateInset(inset_owner);
- update();
+ bv->update();
break;
case LFUN_CAPITALIZE_WORD:
- update();
changeCase(LyXText::text_capitalization);
- if (inset_owner)
- bv->updateInset(inset_owner);
- update();
+ bv->update();
break;
case LFUN_TRANSPOSE_CHARS:
- update();
- transposeChars(*this, cursor);
- if (inset_owner)
- bv->updateInset(inset_owner);
- update();
+ recordUndo(bv, Undo::ATOMIC, cursor.par());
+ redoParagraph();
+ bv->update();
break;
case LFUN_PASTE: {
cmd.message(_("Paste"));
- // clear the selection
- bv->toggleSelection();
- clearSelection();
- update();
+ replaceSelection(bv->getLyXText());
size_t sel_index = 0;
string const & arg = cmd.argument;
if (isStrUnsignedInt(arg)) {
}
pasteSelection(sel_index);
clearSelection(); // bug 393
- update();
+ bv->update();
bv->switchKeyMap();
break;
}
case LFUN_CUT:
- update();
cutSelection(true, true);
- update();
cmd.message(_("Cut"));
+ bv->update();
break;
case LFUN_COPY:
case LFUN_BEGINNINGBUFSEL:
if (inset_owner)
return UNDISPATCHED;
- update();
cursorTop();
finishChange(bv, true);
break;
case LFUN_ENDBUFSEL:
if (inset_owner)
return UNDISPATCHED;
- update();
cursorBottom();
finishChange(bv, true);
break;
if (change_layout) {
current_layout = layout;
- update();
setLayout(layout);
bv->owner()->setLayout(layout);
- update();
+ bv->update();
bv->switchKeyMap();
}
break;
}
case LFUN_PASTESELECTION: {
- if (!bv->buffer())
- break;
// this was originally a beforeChange(bv->text), i.e
// the outermost LyXText!
bv->beforeChange(this);
else
insertStringAsLines(clip);
clearSelection();
- update();
+ bv->update();
}
break;
}
case LFUN_GOTOERROR:
- gotoInset(Inset::ERROR_CODE, false);
+ gotoInset(InsetOld::ERROR_CODE, false);
break;
case LFUN_GOTONOTE:
- gotoInset(Inset::NOTE_CODE, false);
+ gotoInset(InsetOld::NOTE_CODE, false);
break;
case LFUN_REFERENCE_GOTO:
{
- vector<Inset::Code> tmp;
- tmp.push_back(Inset::LABEL_CODE);
- tmp.push_back(Inset::REF_CODE);
+ vector<InsetOld::Code> tmp;
+ tmp.push_back(InsetOld::LABEL_CODE);
+ tmp.push_back(InsetOld::REF_CODE);
gotoInset(tmp, true);
break;
}
case LFUN_QUOTE: {
+ replaceSelection(bv->getLyXText());
ParagraphList::iterator pit = cursor.par();
lyx::pos_type pos = cursor.pos();
char c;
}
case LFUN_DATE_INSERT: {
+ replaceSelection(bv->getLyXText());
time_t now_time_t = time(NULL);
struct tm * now_tm = localtime(&now_time_t);
setlocale(LC_TIME, "");
int const datetmp_len =
::strftime(datetmp, 32, arg.c_str(), now_tm);
- for (int i = 0; i < datetmp_len; i++) {
+ for (int i = 0; i < datetmp_len; i++)
insertChar(datetmp[i]);
- update();
- }
+
selection.cursor = cursor;
moveCursorUpdate(bv, false);
break;
if (!isInInset() && bv->theLockingInset())
break;
if (cmd.button() == mouse_button::button1) {
- if (!isInInset()) {
- bv->screen().toggleSelection(this, bv);
- }
cursorHome();
selection.cursor = cursor;
cursorEnd();
setSelection();
- if (!isInInset())
- bv->screen().toggleSelection(this, bv, false);
- update();
+ bv->update();
bv->haveSelection(selection.set());
}
break;
if (!isInInset() && bv->theLockingInset())
break;
if (cmd.button() == mouse_button::button1) {
- if (!isInInset()) {
- bv->screen().toggleSelection(this, bv);
- selectWord(LyXText::WHOLE_WORD_STRICT);
- bv->screen().toggleSelection(this, bv, false);
- } else {
- selectWord(LyXText::WHOLE_WORD_STRICT);
- }
- update();
+ selectWord(lyx::WHOLE_WORD_STRICT);
+ bv->update();
bv->haveSelection(selection.set());
}
break;
// Check for inset locking
if (bv->theLockingInset()) {
- Inset * tli = bv->theLockingInset();
+ InsetOld * tli = bv->theLockingInset();
LyXCursor cursor = bv->text->cursor;
- LyXFont font = bv->text->getFont(bv->buffer(),
- cursor.par(), cursor.pos());
- int width = tli->width(bv, font);
+ LyXFont font = bv->text->getFont(cursor.par(), cursor.pos());
+ int width = tli->width();
int inset_x = font.isVisibleRightToLeft()
- ? cursor.ix() - width : cursor.ix();
+ ? cursor.x() - width : cursor.x();
int start_x = inset_x + tli->scroll();
FuncRequest cmd1 = cmd;
cmd1.x = cmd.x - start_x;
- cmd1.y = cmd.y - cursor.iy() + bv->text->top_y();
+ cmd1.y = cmd.y - cursor.y() + bv->top_y();
tli->localDispatch(cmd1);
break;
}
}
RowList::iterator cursorrow = bv->text->cursorRow();
- bv->text->setCursorFromCoordinates(cmd.x, cmd.y + bv->text->top_y());
+ bv->text->setCursorFromCoordinates(cmd.x, cmd.y + bv->top_y());
#if 0
// sorry for this but I have a strange error that the y value jumps at
// a certain point. This seems like an error in my xforms library or
bv->text->cursorUp(false);
}
- // Maybe an empty line was deleted
- if (!bv->text->selection.set())
- bv->update(BufferView::UPDATE);
bv->text->setSelection();
- bv->screen().toggleToggle(bv->text, bv);
- bv->fitCursor();
+ bv->update();
break;
}
int x = cmd.x;
int y = cmd.y;
- Inset * inset_hit = bv->text->checkInsetHit(x, y);
+ InsetOld * inset_hit = bv->text->checkInsetHit(x, y);
// Middle button press pastes if we have a selection
// We do this here as if the selection was inside an inset
paste_internally = true;
}
- int const screen_first = bv->text->top_y();
+ int const screen_first = bv->top_y();
if (bv->theLockingInset()) {
// We are in inset locking mode
selection_possible = true;
// Clear the selection
- bv->screen().toggleSelection(bv->text, bv);
bv->text->clearSelection();
- bv->text->partialRebreak();
bv->update();
bv->updateScrollbar();
// inset, inset_hit is 0, and inset_x == x, inset_y == y.
int x = cmd.x;
int y = cmd.y;
- Inset * inset_hit = bv->text->checkInsetHit(x, y);
+ InsetOld * inset_hit = bv->text->checkInsetHit(x, y);
if (bv->theLockingInset()) {
// We are in inset locking mode.
// stack. They don't *have* to
// alter the document...
// (Joacim)
- // ...or maybe the SetCursorParUndo()
+ // ...or maybe the recordUndo()
// below isn't necessary at all anylonger?
- if (inset_hit->lyxCode() == Inset::REF_CODE)
- setCursorParUndo(bv);
+ if (inset_hit->lyxCode() == InsetOld::REF_CODE)
+ recordUndo(bv, Undo::ATOMIC);
bv->owner()->message(inset_hit->editMessage());
// true (on).
if (lyxrc.auto_region_delete) {
- if (selection.set()) {
+ if (selection.set())
cutSelection(false, false);
- update();
- }
bv->haveSelection(false);
}
bv->beforeChange(this);
- LyXFont const old_font(real_current_font);
+ LyXFont const old_font = real_current_font;
string::const_iterator cit = cmd.argument.begin();
string::const_iterator end = cmd.argument.end();
bv->owner()->getIntl().getTransManager().
TranslateAndInsert(*cit, this);
- update();
selection.cursor = cursor;
moveCursorUpdate(bv, false);
// update the minibuffer
if (old_font != real_current_font)
bv->owner()->view_state_changed();
+ bv->updateScrollbar();
break;
}
case LFUN_INSET_CAPTION:
#endif
case LFUN_INSERT_NOTE:
+ case LFUN_INSERT_BRANCH:
case LFUN_INSERT_BIBITEM:
case LFUN_INSET_ERT:
case LFUN_INSET_FLOAT: