mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-21 23:09:40 +00:00
Part of IU.
#################################################################### 1.4.0cvs is now NOT fit for any serious use #################################################################### git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8363 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
cc2531f60b
commit
ccc5d55764
162
src/BufferView.C
162
src/BufferView.C
@ -58,8 +58,7 @@ extern BufferList bufferlist;
|
||||
|
||||
BufferView::BufferView(LyXView * owner, int xpos, int ypos,
|
||||
int width, int height)
|
||||
: pimpl_(new Pimpl(*this, owner, xpos, ypos, width, height)),
|
||||
x_target_(0)
|
||||
: pimpl_(new Pimpl(*this, owner, xpos, ypos, width, height))
|
||||
{}
|
||||
|
||||
|
||||
@ -260,7 +259,7 @@ bool BufferView::insertLyXFile(string const & filen)
|
||||
|
||||
string const fname = MakeAbsPath(filen);
|
||||
|
||||
clearSelection();
|
||||
cursor().clearSelection();
|
||||
text()->breakParagraph(buffer()->paragraphs());
|
||||
|
||||
bool res = buffer()->readFile(fname, text()->cursorPar());
|
||||
@ -313,11 +312,11 @@ void BufferView::gotoLabel(string const & label)
|
||||
vector<string> labels;
|
||||
it->getLabelList(*buffer(), labels);
|
||||
if (find(labels.begin(),labels.end(),label) != labels.end()) {
|
||||
clearSelection();
|
||||
cursor().clearSelection();
|
||||
text()->setCursor(
|
||||
std::distance(text()->paragraphs().begin(), it.getPar()),
|
||||
it.getPos());
|
||||
resetAnchor();
|
||||
cursor().resetAnchor();
|
||||
update();
|
||||
return;
|
||||
}
|
||||
@ -331,7 +330,7 @@ void BufferView::undo()
|
||||
return;
|
||||
|
||||
owner()->message(_("Undo"));
|
||||
clearSelection();
|
||||
cursor().clearSelection();
|
||||
if (!textUndo(this))
|
||||
owner()->message(_("No further undo information"));
|
||||
update();
|
||||
@ -345,7 +344,7 @@ void BufferView::redo()
|
||||
return;
|
||||
|
||||
owner()->message(_("Redo"));
|
||||
clearSelection();
|
||||
cursor().clearSelection();
|
||||
if (!textRedo(this))
|
||||
owner()->message(_("No further redo information"));
|
||||
update();
|
||||
@ -392,15 +391,9 @@ bool BufferView::ChangeRefsIfUnique(string const & from, string const & to)
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset * BufferView::innerInset() const
|
||||
{
|
||||
return static_cast<UpdatableInset*>(fullCursor().innerInset());
|
||||
}
|
||||
|
||||
|
||||
LyXText * BufferView::getLyXText() const
|
||||
{
|
||||
return fullCursor().innerText();
|
||||
return cursor().innerText();
|
||||
}
|
||||
|
||||
|
||||
@ -437,72 +430,6 @@ int BufferView::workHeight() const
|
||||
}
|
||||
|
||||
|
||||
void BufferView::fullCursor(LCursor const & cur)
|
||||
{
|
||||
pimpl_->cursor_ = cur;
|
||||
}
|
||||
|
||||
|
||||
LCursor & BufferView::fullCursor()
|
||||
{
|
||||
return pimpl_->cursor_;
|
||||
}
|
||||
|
||||
|
||||
LCursor const & BufferView::fullCursor() const
|
||||
{
|
||||
return pimpl_->cursor_;
|
||||
}
|
||||
|
||||
|
||||
CursorSlice & BufferView::cursor()
|
||||
{
|
||||
return fullCursor().cursor_.back();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice const & BufferView::cursor() const
|
||||
{
|
||||
return fullCursor().cursor_.back();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice & BufferView::anchor()
|
||||
{
|
||||
return fullCursor().anchor_.back();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice const & BufferView::anchor() const
|
||||
{
|
||||
return fullCursor().anchor_.back();
|
||||
}
|
||||
|
||||
|
||||
Selection & BufferView::selection()
|
||||
{
|
||||
return selection_;
|
||||
}
|
||||
|
||||
|
||||
Selection const & BufferView::selection() const
|
||||
{
|
||||
return selection_;
|
||||
}
|
||||
|
||||
|
||||
void BufferView::x_target(int x)
|
||||
{
|
||||
x_target_ = x;
|
||||
}
|
||||
|
||||
|
||||
int BufferView::x_target() const
|
||||
{
|
||||
return x_target_;
|
||||
}
|
||||
|
||||
|
||||
void BufferView::updateParagraphDialog()
|
||||
{
|
||||
pimpl_->updateParagraphDialog();
|
||||
@ -515,62 +442,6 @@ LyXText * BufferView::text() const
|
||||
}
|
||||
|
||||
|
||||
void BufferView::resetAnchor()
|
||||
{
|
||||
return fullCursor().resetAnchor();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice const & BufferView::selStart() const
|
||||
{
|
||||
if (!selection().set())
|
||||
return cursor();
|
||||
// can't use std::min as this creates a new object
|
||||
return anchor() < cursor() ? anchor() : cursor();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice const & BufferView::selEnd() const
|
||||
{
|
||||
if (!selection().set())
|
||||
return cursor();
|
||||
return anchor() > cursor() ? anchor() : cursor();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice & BufferView::selStart()
|
||||
{
|
||||
if (!selection().set())
|
||||
return cursor();
|
||||
return anchor() < cursor() ? anchor() : cursor();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice & BufferView::selEnd()
|
||||
{
|
||||
if (selection().set())
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@ -592,7 +463,7 @@ void BufferView::putSelectionAt(PosIterator const & cur,
|
||||
{
|
||||
ParIterator par(cur);
|
||||
|
||||
clearSelection();
|
||||
cursor().clearSelection();
|
||||
|
||||
LyXText * text = par.text(*buffer());
|
||||
par.lockPath(this);
|
||||
@ -601,13 +472,13 @@ void BufferView::putSelectionAt(PosIterator const & cur,
|
||||
top_y(par.outerPar()->y);
|
||||
update();
|
||||
text->setCursor(cur.pit(), cur.pos());
|
||||
fullCursor().updatePos();
|
||||
cursor().updatePos();
|
||||
|
||||
if (length) {
|
||||
text->setSelectionRange(length);
|
||||
setSelection();
|
||||
cursor().setSelection();
|
||||
if (backwards)
|
||||
std::swap(cursor(), anchor());
|
||||
std::swap(cursor().cursor_, cursor().anchor_);
|
||||
}
|
||||
|
||||
fitCursor();
|
||||
@ -615,7 +486,14 @@ void BufferView::putSelectionAt(PosIterator const & cur,
|
||||
}
|
||||
|
||||
|
||||
CursorSlice & cursorTip(BufferView & bv)
|
||||
LCursor & BufferView::cursor()
|
||||
{
|
||||
return bv.cursor();
|
||||
return pimpl_->cursor_;
|
||||
}
|
||||
|
||||
|
||||
LCursor const & BufferView::cursor() const
|
||||
{
|
||||
return pimpl_->cursor_;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
class Buffer;
|
||||
class Change;
|
||||
class CursorSlice;
|
||||
class Encoding;
|
||||
class ErrorList;
|
||||
class FuncRequest;
|
||||
@ -33,33 +32,9 @@ class LyXScreen;
|
||||
class LyXView;
|
||||
class Painter;
|
||||
class PosIterator;
|
||||
class Selection;
|
||||
class TeXErrors;
|
||||
class UpdatableInset;
|
||||
|
||||
|
||||
// The structure that keeps track of the selections set.
|
||||
struct Selection {
|
||||
Selection()
|
||||
: set_(false), mark_(false)
|
||||
{}
|
||||
bool set() const {
|
||||
return set_;
|
||||
}
|
||||
void set(bool s) {
|
||||
set_ = s;
|
||||
}
|
||||
bool mark() const {
|
||||
return mark_;
|
||||
}
|
||||
void mark(bool m) {
|
||||
mark_ = m;
|
||||
}
|
||||
private:
|
||||
bool set_; // former selection
|
||||
bool mark_; // former mark_set
|
||||
};
|
||||
|
||||
/**
|
||||
* A buffer view encapsulates a view onto a particular
|
||||
* buffer, and allows access to operate upon it. A view
|
||||
@ -204,56 +179,18 @@ public:
|
||||
/// execute the given function
|
||||
bool dispatch(FuncRequest const & argument);
|
||||
|
||||
/// set target x position of cursor
|
||||
void x_target(int x);
|
||||
/// return target x position of cursor
|
||||
int x_target() const;
|
||||
|
||||
/// clear the X selection
|
||||
void unsetXSel();
|
||||
|
||||
/// access to full cursor
|
||||
LCursor & fullCursor();
|
||||
LCursor & cursor();
|
||||
/// access to full cursor
|
||||
void fullCursor(LCursor const &);
|
||||
/// access to full cursor
|
||||
LCursor const & fullCursor() const;
|
||||
/// access to topmost cursor slice
|
||||
CursorSlice & cursor();
|
||||
/// access to topmost cursor slice
|
||||
CursorSlice const & cursor() const;
|
||||
/// access to selection anchor
|
||||
CursorSlice & anchor();
|
||||
/// access to selection anchor
|
||||
CursorSlice const & anchor() const;
|
||||
///
|
||||
UpdatableInset * innerInset() const;
|
||||
LCursor const & cursor() const;
|
||||
///
|
||||
LyXText * text() const;
|
||||
///
|
||||
void resetAnchor();
|
||||
///
|
||||
Selection & selection();
|
||||
///
|
||||
Selection const & selection() const;
|
||||
///
|
||||
CursorSlice & selStart();
|
||||
///
|
||||
CursorSlice const & selStart() const;
|
||||
///
|
||||
CursorSlice & selEnd();
|
||||
///
|
||||
CursorSlice const & selEnd() const;
|
||||
///
|
||||
void setSelection();
|
||||
///
|
||||
void clearSelection();
|
||||
///
|
||||
void putSelectionAt(PosIterator const & cur, int length, bool backwards);
|
||||
|
||||
///
|
||||
Selection selection_;
|
||||
|
||||
private:
|
||||
///
|
||||
struct Pimpl;
|
||||
@ -261,21 +198,6 @@ private:
|
||||
friend struct BufferView::Pimpl;
|
||||
///
|
||||
Pimpl * pimpl_;
|
||||
|
||||
/**
|
||||
* The target x position of the cursor. This is used for when
|
||||
* we have text like :
|
||||
*
|
||||
* blah blah blah blah| blah blah blah
|
||||
* blah blah blah
|
||||
* blah blah blah blah blah blah
|
||||
*
|
||||
* When we move onto row 3, we would like to be vertically aligned
|
||||
* with where we were in row 1, despite the fact that row 2 is
|
||||
* shorter than x()
|
||||
*/
|
||||
int x_target_;
|
||||
|
||||
};
|
||||
|
||||
#endif // BUFFERVIEW_H
|
||||
|
@ -400,33 +400,34 @@ void BufferView::Pimpl::resizeCurrentBuffer()
|
||||
if (!text)
|
||||
return;
|
||||
|
||||
par = bv_->cursor().par();
|
||||
pos = bv_->cursor().pos();
|
||||
selstartpar = bv_->selStart().par();
|
||||
selstartpos = bv_->selStart().pos();
|
||||
selendpar = bv_->selEnd().par();
|
||||
selendpos = bv_->selEnd().pos();
|
||||
sel = bv_->selection().set();
|
||||
mark_set = bv_->selection().mark();
|
||||
LCursor & cur = bv_->cursor();
|
||||
par = cur.par();
|
||||
pos = cur.pos();
|
||||
selstartpar = cur.selStart().par();
|
||||
selstartpos = cur.selStart().pos();
|
||||
selendpar = cur.selEnd().par();
|
||||
selendpos = cur.selEnd().pos();
|
||||
sel = cur.selection();
|
||||
mark_set = cur.mark();
|
||||
text->textwidth_ = bv_->workWidth();
|
||||
text->fullRebreak();
|
||||
update();
|
||||
|
||||
if (par != -1) {
|
||||
bv_->selection().set(true);
|
||||
cur.selection() = true;
|
||||
// At this point just to avoid the Delete-Empty-Paragraph-
|
||||
// Mechanism when setting the cursor.
|
||||
bv_->selection().mark(mark_set);
|
||||
cur.mark() = mark_set;
|
||||
if (sel) {
|
||||
text->setCursor(selstartpar, selstartpos);
|
||||
bv_->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
text->setCursor(selendpar, selendpos);
|
||||
bv_->setSelection();
|
||||
cur.setSelection();
|
||||
text->setCursor(par, pos);
|
||||
} else {
|
||||
text->setCursor(par, pos);
|
||||
bv_->resetAnchor();
|
||||
bv_->selection().set(false);
|
||||
cur.resetAnchor();
|
||||
cur.selection() = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -536,21 +537,21 @@ void BufferView::Pimpl::selectionRequested()
|
||||
if (!available())
|
||||
return;
|
||||
|
||||
LyXText * text = bv_->getLyXText();
|
||||
LCursor & cur = bv_->cursor();
|
||||
|
||||
if (!bv_->selection().set()) {
|
||||
if (!cur.selection()) {
|
||||
xsel_cache_.set = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!xsel_cache_.set ||
|
||||
bv_->cursor() != xsel_cache_.cursor ||
|
||||
bv_->anchor() != xsel_cache_.anchor)
|
||||
cur.cursor_.back() != xsel_cache_.cursor ||
|
||||
cur.anchor_.back() != xsel_cache_.anchor)
|
||||
{
|
||||
xsel_cache_.cursor = bv_->cursor();
|
||||
xsel_cache_.anchor = bv_->anchor();
|
||||
xsel_cache_.set = bv_->selection().set();
|
||||
sel = text->selectionAsString(*bv_->buffer(), false);
|
||||
xsel_cache_.cursor = cur.cursor_.back();
|
||||
xsel_cache_.anchor = cur.anchor_.back();
|
||||
xsel_cache_.set = cur.selection();
|
||||
sel = bv_->getLyXText()->selectionAsString(*bv_->buffer(), false);
|
||||
if (!sel.empty())
|
||||
workarea().putClipboard(sel);
|
||||
}
|
||||
@ -561,7 +562,7 @@ void BufferView::Pimpl::selectionLost()
|
||||
{
|
||||
if (available()) {
|
||||
screen().hideCursor();
|
||||
bv_->clearSelection();
|
||||
bv_->cursor().clearSelection();
|
||||
xsel_cache_.set = false;
|
||||
}
|
||||
}
|
||||
@ -640,12 +641,13 @@ Change const BufferView::Pimpl::getCurrentChange()
|
||||
return Change(Change::UNCHANGED);
|
||||
|
||||
LyXText * text = bv_->getLyXText();
|
||||
LCursor & cur = bv_->cursor();
|
||||
|
||||
if (!bv_->selection().set())
|
||||
if (!cur.selection())
|
||||
return Change(Change::UNCHANGED);
|
||||
|
||||
return text->getPar(bv_->selStart())
|
||||
->lookupChangeFull(bv_->selStart().pos());
|
||||
return text->getPar(cur.selStart())
|
||||
->lookupChangeFull(cur.selStart().pos());
|
||||
}
|
||||
|
||||
|
||||
@ -668,7 +670,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
|
||||
|
||||
string const fname = saved_positions[i].filename;
|
||||
|
||||
bv_->clearSelection();
|
||||
bv_->cursor().clearSelection();
|
||||
|
||||
if (fname != buffer_->fileName()) {
|
||||
Buffer * b = 0;
|
||||
@ -720,7 +722,7 @@ void BufferView::Pimpl::center()
|
||||
{
|
||||
LyXText * text = bv_->text();
|
||||
|
||||
bv_->clearSelection();
|
||||
bv_->cursor().clearSelection();
|
||||
int const half_height = workarea().workHeight() / 2;
|
||||
int new_y = std::max(0, text->cursorY() - half_height);
|
||||
|
||||
@ -879,7 +881,7 @@ void BufferView::Pimpl::trackChanges()
|
||||
}
|
||||
|
||||
#warning remove me
|
||||
LCursor theTempCursor;
|
||||
CursorBase theTempCursor;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -888,7 +890,7 @@ namespace {
|
||||
lyxerr << "insetFromCoords" << endl;
|
||||
LyXText * text = bv->text();
|
||||
InsetOld * inset = 0;
|
||||
theTempCursor = LCursor(*bv);
|
||||
theTempCursor.clear();
|
||||
while (true) {
|
||||
InsetOld * const inset_hit = text->checkInsetHit(x, y);
|
||||
if (!inset_hit) {
|
||||
@ -906,9 +908,9 @@ namespace {
|
||||
text = inset_hit->getText(cell);
|
||||
lyxerr << "Hit inset: " << inset << " at x: " << x
|
||||
<< " text: " << text << " y: " << y << endl;
|
||||
theTempCursor.push(static_cast<UpdatableInset*>(inset));
|
||||
theTempCursor.push_back(CursorSlice(inset));
|
||||
}
|
||||
lyxerr << "theTempCursor: " << theTempCursor << endl;
|
||||
//lyxerr << "theTempCursor: " << theTempCursor << endl;
|
||||
return inset;
|
||||
}
|
||||
|
||||
@ -917,25 +919,26 @@ namespace {
|
||||
|
||||
bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
|
||||
{
|
||||
LCursor & cur = bv_->cursor();
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_MOTION: {
|
||||
if (!available())
|
||||
return false;
|
||||
FuncRequest cmd1 = cmd;
|
||||
UpdatableInset * inset = bv_->fullCursor().innerInset();
|
||||
InsetBase * inset = cur.inset();
|
||||
DispatchResult res;
|
||||
if (inset) {
|
||||
cmd1.x -= inset->x();
|
||||
cmd1.y -= inset->y();
|
||||
res = inset->dispatch(*bv_, cmd1);
|
||||
res = inset->dispatch(cur, cmd1);
|
||||
} else {
|
||||
cmd1.y += bv_->top_y();
|
||||
res = bv_->fullCursor().innerText()->dispatch(*bv_, cmd1);
|
||||
res = cur.innerText()->dispatch(cur, cmd1);
|
||||
}
|
||||
|
||||
if (bv_->fitCursor() || res.update()) {
|
||||
bv_->update();
|
||||
bv_->fullCursor().updatePos();
|
||||
cur.updatePos();
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -971,10 +974,10 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
|
||||
<< " to inset " << inset << endl;
|
||||
cmd2.x -= inset->x();
|
||||
cmd2.y -= inset->y();
|
||||
res = inset->dispatch(*bv_, cmd2);
|
||||
res = inset->dispatch(cur, cmd2);
|
||||
if (res.update()) {
|
||||
bv_->update();
|
||||
bv_->fullCursor().updatePos();
|
||||
cur.updatePos();
|
||||
}
|
||||
res.update(false);
|
||||
switch (res.val()) {
|
||||
@ -982,9 +985,9 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
|
||||
case FINISHED_RIGHT:
|
||||
case FINISHED_UP:
|
||||
case FINISHED_DOWN:
|
||||
theTempCursor.pop();
|
||||
bv_->fullCursor(theTempCursor);
|
||||
bv_->fullCursor().innerText()
|
||||
theTempCursor.pop_back();
|
||||
cur.cursor_ = theTempCursor;
|
||||
cur.innerText()
|
||||
->setCursorFromCoordinates(cmd.x, top_y() + cmd.y);
|
||||
if (bv_->fitCursor())
|
||||
bv_->update();
|
||||
@ -997,14 +1000,14 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
|
||||
|
||||
// otherwise set cursor to surrounding LyXText
|
||||
if (!res.dispatched()) {
|
||||
lyxerr << "temp cursor is: " << theTempCursor << endl;
|
||||
lyxerr << "dispatching " << cmd
|
||||
<< " to surrounding LyXText "
|
||||
<< theTempCursor.innerText() << endl;
|
||||
bv_->fullCursor(theTempCursor);
|
||||
//lyxerr << "temp cursor is: " << theTempCursor << endl;
|
||||
//lyxerr << "dispatching " << cmd
|
||||
// << " to surrounding LyXText "
|
||||
// << theTempCursor.innerText() << endl;
|
||||
cur.cursor_ = theTempCursor;
|
||||
FuncRequest cmd1 = cmd;
|
||||
cmd1.y += bv_->top_y();
|
||||
res = bv_->fullCursor().innerText()->dispatch(*bv_, cmd1);
|
||||
res = cur.innerText()->dispatch(cur, cmd1);
|
||||
if (bv_->fitCursor() || res.update())
|
||||
bv_->update();
|
||||
|
||||
@ -1046,6 +1049,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
|
||||
<< endl;
|
||||
|
||||
LyXTextClass const & tclass = buffer_->params().getLyXTextClass();
|
||||
LCursor & cur = bv_->cursor();
|
||||
|
||||
switch (ev.action) {
|
||||
|
||||
@ -1142,7 +1146,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
|
||||
case LFUN_MATH_IMPORT_SELECTION: // Imports LaTeX from the X selection
|
||||
case LFUN_MATH_DISPLAY: // Open or create a displayed math inset
|
||||
case LFUN_MATH_MODE: // Open or create an inlined math inset
|
||||
mathDispatch(*bv_, ev);
|
||||
mathDispatch(cur, ev);
|
||||
break;
|
||||
|
||||
case LFUN_INSET_INSERT: {
|
||||
@ -1248,29 +1252,29 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
|
||||
break;
|
||||
|
||||
case LFUN_MARK_OFF:
|
||||
bv_->clearSelection();
|
||||
cur.clearSelection();
|
||||
bv_->update();
|
||||
bv_->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
ev.message(N_("Mark off"));
|
||||
break;
|
||||
|
||||
case LFUN_MARK_ON:
|
||||
bv_->clearSelection();
|
||||
bv_->selection().mark(true);
|
||||
cur.clearSelection();
|
||||
cur.mark() = true;
|
||||
bv_->update();
|
||||
bv_->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
ev.message(N_("Mark on"));
|
||||
break;
|
||||
|
||||
case LFUN_SETMARK:
|
||||
bv_->clearSelection();
|
||||
if (bv_->selection().mark()) {
|
||||
cur.clearSelection();
|
||||
if (cur.mark()) {
|
||||
ev.message(N_("Mark removed"));
|
||||
} else {
|
||||
bv_->selection().mark(true);
|
||||
cur.mark() = true;
|
||||
ev.message(N_("Mark set"));
|
||||
}
|
||||
bv_->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
bv_->update();
|
||||
break;
|
||||
|
||||
@ -1279,7 +1283,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
|
||||
break;
|
||||
|
||||
default:
|
||||
return bv_->getLyXText()->dispatch(*bv_, ev).dispatched();
|
||||
return cur.dispatch(ev).dispatched();
|
||||
} // end of switch
|
||||
|
||||
return true;
|
||||
@ -1292,7 +1296,7 @@ bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
|
||||
bv_->text()->recUndo(bv_->text()->cursor().par());
|
||||
freezeUndo();
|
||||
|
||||
bv_->clearSelection();
|
||||
bv_->cursor().clearSelection();
|
||||
if (!lout.empty()) {
|
||||
bv_->text()->breakParagraph(bv_->buffer()->paragraphs());
|
||||
|
||||
@ -1308,7 +1312,7 @@ bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
|
||||
bv_->text()->setLayout(hasLayout ? lres : tclass.defaultLayoutName());
|
||||
bv_->text()->setParagraph(Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
|
||||
}
|
||||
bv_->fullCursor().innerText()->insertInset(inset);
|
||||
bv_->cursor().innerText()->insertInset(inset);
|
||||
unFreezeUndo();
|
||||
return true;
|
||||
}
|
||||
|
@ -1,4 +1,25 @@
|
||||
|
||||
2004-01-20 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* BufferView.[Ch]:
|
||||
* BufferView_pimpl.C:
|
||||
* PosIterator.C:
|
||||
* bufferview_funcs.C:
|
||||
* cursor.[Ch]:
|
||||
* cursor_slice.[Ch]:
|
||||
* factory.C:
|
||||
* iterators.C:
|
||||
* lyx_cb.C:
|
||||
* lyxfind.C:
|
||||
* lyxfunc.C:
|
||||
* lyxtext.h:
|
||||
* rowpainter.C:
|
||||
* text.C:
|
||||
* text2.C:
|
||||
* text3.C:
|
||||
* undo.[Ch]: lots of IU. Shift selection stuff from the BufferView to
|
||||
LCursor and mathcursor parts to LCursor and InsetBase.
|
||||
|
||||
2004-01-15 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* cursor_slice.[Ch]: add a few covienience functions
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "buffer.h"
|
||||
#include "BufferView.h"
|
||||
#include "cursor_slice.h"
|
||||
#include "cursor.h"
|
||||
#include "iterators.h"
|
||||
#include "lyxtext.h"
|
||||
#include "paragraph.h"
|
||||
|
@ -164,13 +164,15 @@ void changeDepth(BufferView * bv, LyXText * text, DEPTH_CHANGE type)
|
||||
// Returns the current font and depth as a message.
|
||||
string const currentState(BufferView * bv)
|
||||
{
|
||||
ostringstream state;
|
||||
|
||||
if (!bv->available())
|
||||
return string();
|
||||
|
||||
if (mathcursor)
|
||||
return mathcursor->info(bv->fullCursor());
|
||||
|
||||
ostringstream state;
|
||||
if (inMathed()) {
|
||||
bv->cursor().info(state);
|
||||
return state.str();
|
||||
}
|
||||
|
||||
LyXText * text = bv->getLyXText();
|
||||
Buffer * buffer = bv->buffer();
|
||||
@ -254,7 +256,7 @@ string const currentState(BufferView * bv)
|
||||
// deletes a selection during an insertion
|
||||
void replaceSelection(LyXText * text)
|
||||
{
|
||||
if (text->bv()->selection().set()) {
|
||||
if (text->bv()->cursor().selection()) {
|
||||
text->cutSelection(true, false);
|
||||
text->bv()->update();
|
||||
}
|
||||
|
327
src/cursor.C
327
src/cursor.C
@ -27,6 +27,7 @@
|
||||
#include "insets/insettext.h"
|
||||
|
||||
#include "mathed/math_data.h"
|
||||
#include "mathed/math_inset.h"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
@ -34,22 +35,10 @@ using std::vector;
|
||||
using std::endl;
|
||||
|
||||
|
||||
std::ostream & operator<<(std::ostream & os, LCursor const & cur)
|
||||
{
|
||||
os << "\n";
|
||||
for (size_t i = 0, n = cur.cursor_.size(); i != n; ++i)
|
||||
os << " (" << cur.cursor_[i] << " | " << cur.anchor_[i] << "\n";
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
LCursor::LCursor()
|
||||
: cursor_(1), anchor_(1), bv_(0)
|
||||
{}
|
||||
|
||||
|
||||
LCursor::LCursor(BufferView & bv)
|
||||
: cursor_(1), anchor_(1), bv_(&bv)
|
||||
: cursor_(1), anchor_(1), bv_(&bv), current_(0),
|
||||
cached_y_(0), x_target_(-1),
|
||||
selection_(false), mark_(false)
|
||||
{}
|
||||
|
||||
|
||||
@ -59,9 +48,10 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
|
||||
FuncRequest cmd = cmd0;
|
||||
|
||||
for (int i = cursor_.size() - 1; i >= 1; --i) {
|
||||
current_ = i;
|
||||
CursorSlice const & citem = cursor_[i];
|
||||
lyxerr << "trying to dispatch to inset " << citem.inset_ << endl;
|
||||
DispatchResult res = citem.inset_->dispatch(*bv_, cmd);
|
||||
DispatchResult res = inset()->dispatch(*this, cmd);
|
||||
if (res.dispatched()) {
|
||||
lyxerr << " successfully dispatched to inset " << citem.inset_ << endl;
|
||||
return DispatchResult(true, true);
|
||||
@ -90,7 +80,7 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
|
||||
}
|
||||
}
|
||||
lyxerr << "trying to dispatch to main text " << bv_->text() << endl;
|
||||
DispatchResult res = bv_->text()->dispatch(*bv_, cmd);
|
||||
DispatchResult res = bv_->text()->dispatch(*this, cmd);
|
||||
lyxerr << " result: " << res.val() << endl;
|
||||
|
||||
if (!res.dispatched()) {
|
||||
@ -109,43 +99,53 @@ void LCursor::push(InsetBase * inset)
|
||||
lyxerr << "LCursor::push() inset: " << inset << endl;
|
||||
cursor_.push_back(CursorSlice(inset));
|
||||
anchor_.push_back(CursorSlice(inset));
|
||||
++current_;
|
||||
updatePos();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LCursor::pop(int depth)
|
||||
{
|
||||
lyxerr << "LCursor::pop() to " << depth << endl;
|
||||
while (cursor_.size() > 1 && depth < cursor_.size()) {
|
||||
lyxerr << "LCursor::pop a level " << endl;
|
||||
cursor_.pop_back();
|
||||
anchor_.pop_back();
|
||||
}
|
||||
lyxerr << "LCursor::pop() to depth " << depth << endl;
|
||||
while (cursor_.size() > depth)
|
||||
pop();
|
||||
}
|
||||
|
||||
|
||||
void LCursor::pop()
|
||||
{
|
||||
lyxerr << "LCursor::pop() " << endl;
|
||||
lyxerr << "LCursor::pop() a level" << endl;
|
||||
//BOOST_ASSERT(!cursor_.empty());
|
||||
if (cursor_.size() <= 1)
|
||||
lyxerr << "### TRYING TO POP FROM EMPTY CURSOR" << endl;
|
||||
else {
|
||||
cursor_.pop_back();
|
||||
anchor_.pop_back();
|
||||
current_ = cursor_.size() - 1;
|
||||
}
|
||||
lyxerr << "LCursor::pop() current now: " << current_ << endl;
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset * LCursor::innerInset() const
|
||||
CursorSlice & LCursor::current()
|
||||
{
|
||||
return cursor_.size() <= 1 ? 0 : cursor_.back().asUpdatableInset();
|
||||
//lyxerr << "accessing cursor slice " << current_
|
||||
// << ": " << cursor_[current_] << endl;
|
||||
return cursor_[current_];
|
||||
}
|
||||
|
||||
|
||||
CursorSlice const & LCursor::current() const
|
||||
{
|
||||
//lyxerr << "accessing cursor slice " << current_
|
||||
// << ": " << cursor_[current_] << endl;
|
||||
return cursor_[current_];
|
||||
}
|
||||
|
||||
|
||||
LyXText * LCursor::innerText() const
|
||||
{
|
||||
//lyxerr << "LCursor::innerText() depth: " << cursor_.size() << endl;
|
||||
if (cursor_.size() > 1) {
|
||||
// go up until first non-0 text is hit
|
||||
// (innermost text is 0 e.g. for mathed and the outer tabular level)
|
||||
@ -173,7 +173,9 @@ void LCursor::getDim(int & asc, int & desc) const
|
||||
asc = row.baseline();
|
||||
desc = row.height() - asc;
|
||||
} else {
|
||||
innerInset()->getCursorDim(asc, desc);
|
||||
asc = 10;
|
||||
desc = 10;
|
||||
//innerInset()->getCursorDim(asc, desc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,37 +187,42 @@ void LCursor::getPos(int & x, int & y) const
|
||||
y = bv_->text()->cursorY();
|
||||
// y -= bv_->top_y();
|
||||
} else {
|
||||
// Would be nice to clean this up to make some understandable sense...
|
||||
UpdatableInset * inset = innerInset();
|
||||
// Non-obvious. The reason we have to have these
|
||||
// extra checks is that the ->getCursor() calls rely
|
||||
// on the inset's own knowledge of its screen position.
|
||||
// If we scroll up or down in a big enough increment, the
|
||||
// inset->draw() is not called: this doesn't update
|
||||
// inset.top_baseline, so getCursor() returns an old value.
|
||||
// Ugly as you like.
|
||||
if (inset) {
|
||||
inset->getCursorPos(cursor_.back().idx_, x, y);
|
||||
x += inset->x();
|
||||
if (inset()->asUpdatableInset()) {
|
||||
// Would be nice to clean this up to make some understandable sense...
|
||||
// Non-obvious. The reason we have to have these
|
||||
// extra checks is that the ->getCursor() calls rely
|
||||
// on the inset's own knowledge of its screen position.
|
||||
// If we scroll up or down in a big enough increment, the
|
||||
// inset->draw() is not called: this doesn't update
|
||||
// inset.top_baseline, so getCursor() returns an old value.
|
||||
// Ugly as you like.
|
||||
inset()->asUpdatableInset()->getCursorPos(cursor_.back().idx_, x, y);
|
||||
x += inset()->asUpdatableInset()->x();
|
||||
y += cached_y_;
|
||||
} else if (inset()->asMathInset()) {
|
||||
#warning FIXME
|
||||
x = 100;
|
||||
y = 100;
|
||||
} else {
|
||||
// this should not happen
|
||||
BOOST_ASSERT(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset * LCursor::innerInsetOfType(int code) const
|
||||
InsetBase * LCursor::innerInsetOfType(int code) const
|
||||
{
|
||||
for (int i = cursor_.size() - 1; i >= 1; --i)
|
||||
if (cursor_[i].asUpdatableInset()->lyxCode() == code)
|
||||
return cursor_[i].asUpdatableInset();
|
||||
if (cursor_[i].inset_->lyxCode() == code)
|
||||
return cursor_[i].inset_;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
InsetTabular * LCursor::innerInsetTabular() const
|
||||
{
|
||||
return static_cast<InsetTabular *>
|
||||
(innerInsetOfType(InsetOld::TABULAR_CODE));
|
||||
return static_cast<InsetTabular *>(innerInsetOfType(InsetBase::TABULAR_CODE));
|
||||
}
|
||||
|
||||
|
||||
@ -275,3 +282,233 @@ bool LCursor::posRight()
|
||||
++pos();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
CursorSlice & LCursor::anchor()
|
||||
{
|
||||
return anchor_.back();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice const & LCursor::anchor() const
|
||||
{
|
||||
return anchor_.back();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice const & LCursor::selStart() const
|
||||
{
|
||||
if (!selection())
|
||||
return cursor_.back();
|
||||
// can't use std::min as this creates a new object
|
||||
return anchor() < cursor_.back() ? anchor() : cursor_.back();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice const & LCursor::selEnd() const
|
||||
{
|
||||
if (!selection())
|
||||
return cursor_.back();
|
||||
return anchor() > cursor_.back() ? anchor() : cursor_.back();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice & LCursor::selStart()
|
||||
{
|
||||
if (!selection())
|
||||
return cursor_.back();
|
||||
return anchor() < cursor_.back() ? anchor() : cursor_.back();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice & LCursor::selEnd()
|
||||
{
|
||||
if (selection())
|
||||
return cursor_.back();
|
||||
return anchor() > cursor_.back() ? anchor() : cursor_.back();
|
||||
}
|
||||
|
||||
|
||||
void LCursor::setSelection()
|
||||
{
|
||||
selection() = true;
|
||||
// a selection with no contents is not a selection
|
||||
if (par() == anchor().par() && pos() == anchor().pos())
|
||||
selection() = false;
|
||||
}
|
||||
|
||||
|
||||
void LCursor::clearSelection()
|
||||
{
|
||||
selection() = false;
|
||||
mark() = false;
|
||||
resetAnchor();
|
||||
bv().unsetXSel();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// CursorBase
|
||||
//
|
||||
|
||||
|
||||
void increment(CursorBase & it)
|
||||
{
|
||||
CursorSlice & top = it.back();
|
||||
MathArray & ar = top.asMathInset()->cell(top.idx_);
|
||||
|
||||
// move into the current inset if possible
|
||||
// it is impossible for pos() == size()!
|
||||
MathInset * n = 0;
|
||||
if (top.pos() != top.lastpos())
|
||||
n = (ar.begin() + top.pos_)->nucleus();
|
||||
if (n && n->isActive()) {
|
||||
it.push_back(CursorSlice(n));
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise move on one cell back if possible
|
||||
if (top.pos() < top.lastpos()) {
|
||||
// pos() == lastpos() is valid!
|
||||
++top.pos_;
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise try to move on one cell if possible
|
||||
while (top.idx_ + 1 < top.asMathInset()->nargs()) {
|
||||
// idx() == nargs() is _not_ valid!
|
||||
++top.idx_;
|
||||
if (top.asMathInset()->validCell(top.idx_)) {
|
||||
top.pos_ = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise leave array, move on one back
|
||||
// this might yield pos() == size(), but that's a ok.
|
||||
it.pop_back();
|
||||
// it certainly invalidates top
|
||||
++it.back().pos_;
|
||||
}
|
||||
|
||||
|
||||
CursorBase ibegin(InsetBase * p)
|
||||
{
|
||||
CursorBase it;
|
||||
it.push_back(CursorSlice(p));
|
||||
return it;
|
||||
}
|
||||
|
||||
|
||||
CursorBase iend(InsetBase * p)
|
||||
{
|
||||
CursorBase it;
|
||||
it.push_back(CursorSlice(p));
|
||||
CursorSlice & top = it.back();
|
||||
top.idx_ = top.asMathInset()->nargs() - 1;
|
||||
top.pos_ = top.asMathInset()->cell(top.idx_).size();
|
||||
return it;
|
||||
}
|
||||
|
||||
|
||||
void LCursor::x_target(int x)
|
||||
{
|
||||
x_target_ = x;
|
||||
}
|
||||
|
||||
|
||||
int LCursor::x_target() const
|
||||
{
|
||||
return x_target_;
|
||||
}
|
||||
|
||||
|
||||
Paragraph & LCursor::paragraph()
|
||||
{
|
||||
return current_ ? current().paragraph() : *bv_->text()->getPar(par());
|
||||
}
|
||||
|
||||
|
||||
Paragraph const & LCursor::paragraph() const
|
||||
{
|
||||
return current_ ? current().paragraph() : *bv_->text()->getPar(par());
|
||||
}
|
||||
|
||||
|
||||
LCursor::pos_type LCursor::lastpos() const
|
||||
{
|
||||
return current_ ? current().lastpos() : bv_->text()->getPar(par())->size();
|
||||
}
|
||||
|
||||
|
||||
size_t LCursor::nargs() const
|
||||
{
|
||||
// assume 1x1 grid for 'plain text'
|
||||
return current_ ? current().nargs() : 1;
|
||||
}
|
||||
|
||||
|
||||
size_t LCursor::ncols() const
|
||||
{
|
||||
// assume 1x1 grid for 'plain text'
|
||||
return current_ ? current().ncols() : 1;
|
||||
}
|
||||
|
||||
|
||||
size_t LCursor::nrows() const
|
||||
{
|
||||
// assume 1x1 grid for 'plain text'
|
||||
return current_ ? current().nrows() : 1;
|
||||
}
|
||||
|
||||
|
||||
LCursor::row_type LCursor::row() const
|
||||
{
|
||||
BOOST_ASSERT(current_ > 0);
|
||||
return current().row();
|
||||
}
|
||||
|
||||
|
||||
LCursor::col_type LCursor::col() const
|
||||
{
|
||||
BOOST_ASSERT(current_ > 0);
|
||||
return current().col();
|
||||
}
|
||||
|
||||
|
||||
MathArray const & LCursor::cell() const
|
||||
{
|
||||
BOOST_ASSERT(current_ > 0);
|
||||
return current().cell();
|
||||
}
|
||||
|
||||
|
||||
MathArray & LCursor::cell()
|
||||
{
|
||||
BOOST_ASSERT(current_ > 0);
|
||||
return current().cell();
|
||||
}
|
||||
|
||||
|
||||
void LCursor::info(std::ostream & os)
|
||||
{
|
||||
for (int i = 1, n = depth(); i < n; ++i) {
|
||||
cursor_[i].inset()->infoize(os);
|
||||
os << " ";
|
||||
}
|
||||
#warning FIXME
|
||||
//if (pos() != 0)
|
||||
// prevAtom()->infoize2(os);
|
||||
// overwite old message
|
||||
os << " ";
|
||||
}
|
||||
|
||||
|
||||
std::ostream & operator<<(std::ostream & os, LCursor const & cur)
|
||||
{
|
||||
os << "\n";
|
||||
for (size_t i = 0, n = cur.cursor_.size(); i != n; ++i)
|
||||
os << " (" << cur.cursor_[i] << " | " << cur.anchor_[i] << "\n";
|
||||
return os;
|
||||
}
|
||||
|
154
src/cursor.h
154
src/cursor.h
@ -22,8 +22,20 @@ class UpdatableInset;
|
||||
class MathAtom;
|
||||
class DispatchResult;
|
||||
class FuncRequest;
|
||||
class LyXText;
|
||||
class InsetTabular;
|
||||
class LyXText;
|
||||
class Paragraph;
|
||||
|
||||
|
||||
|
||||
// this is used for traversing math insets
|
||||
typedef std::vector<CursorSlice> CursorBase;
|
||||
/// move on one step
|
||||
void increment(CursorBase &);
|
||||
///
|
||||
CursorBase ibegin(InsetBase * p);
|
||||
///
|
||||
CursorBase iend(InsetBase * p);
|
||||
|
||||
|
||||
/**
|
||||
@ -43,8 +55,6 @@ public:
|
||||
/// type for col indices
|
||||
typedef CursorSlice::col_type col_type;
|
||||
|
||||
/// create 'empty' cursor. REMOVE ME
|
||||
LCursor();
|
||||
/// create the cursor of a BufferView
|
||||
explicit LCursor(BufferView & bv);
|
||||
/// dispatch from innermost inset upwards
|
||||
@ -55,48 +65,74 @@ public:
|
||||
void pop(int depth);
|
||||
/// pop one level off the cursor
|
||||
void pop();
|
||||
/// access to cursor 'tip'
|
||||
CursorSlice & top() { return cursor_.back(); }
|
||||
/// access to cursor 'tip'
|
||||
CursorSlice const & top() const { return cursor_.back(); }
|
||||
/// access to current cursor slice
|
||||
CursorSlice & current();
|
||||
/// access to current cursor slice
|
||||
CursorSlice const & current() const;
|
||||
/// how many nested insets do we have?
|
||||
size_t depth() const { return cursor_.size(); }
|
||||
|
||||
/// access to the topmost slice
|
||||
//
|
||||
// selection
|
||||
//
|
||||
/// selection active?
|
||||
bool selection() const { return selection_; }
|
||||
/// selection active?
|
||||
bool & selection() { return selection_; }
|
||||
/// did we place the anchor?
|
||||
bool mark() const { return mark_; }
|
||||
/// did we place the anchor?
|
||||
bool & mark() { return mark_; }
|
||||
///
|
||||
void setSelection();
|
||||
///
|
||||
void clearSelection();
|
||||
///
|
||||
CursorSlice & selStart();
|
||||
///
|
||||
CursorSlice const & selStart() const;
|
||||
///
|
||||
CursorSlice & selEnd();
|
||||
///
|
||||
CursorSlice const & selEnd() const;
|
||||
|
||||
//
|
||||
// access to the 'current' cursor slice
|
||||
//
|
||||
/// the current inset
|
||||
InsetBase * inset() const { return top().inset(); }
|
||||
InsetBase * inset() const { return current().inset(); }
|
||||
/// return the text-ed cell this cursor is in
|
||||
idx_type idx() const { return top().idx(); }
|
||||
idx_type idx() const { return current().idx(); }
|
||||
/// return the text-ed cell this cursor is in
|
||||
idx_type & idx() { return top().idx(); }
|
||||
idx_type & idx() { return current().idx(); }
|
||||
/// return the paragraph this cursor is in
|
||||
par_type par() const { return top().par(); }
|
||||
par_type par() const { return current().par(); }
|
||||
/// return the paragraph this cursor is in
|
||||
par_type & par() { return top().par(); }
|
||||
par_type & par() { return current().par(); }
|
||||
/// return the position within the paragraph
|
||||
pos_type pos() const { return top().pos(); }
|
||||
pos_type pos() const { return current().pos(); }
|
||||
/// return the position within the paragraph
|
||||
pos_type & pos() { return top().pos(); }
|
||||
pos_type & pos() { return current().pos(); }
|
||||
/// return the last position within the paragraph
|
||||
pos_type lastpos() const { return top().lastpos(); }
|
||||
pos_type lastpos() const;
|
||||
/// return the number of embedded cells
|
||||
size_t nargs() const { return top().nargs(); }
|
||||
size_t nargs() const;
|
||||
/// return the number of embedded cells
|
||||
size_t ncols() const { return top().ncols(); }
|
||||
size_t ncols() const;
|
||||
/// return the number of embedded cells
|
||||
size_t nrows() const { return top().nrows(); }
|
||||
size_t nrows() const;
|
||||
/// return the grid row of the current cell
|
||||
row_type row() const { return top().row(); }
|
||||
row_type row() const;
|
||||
/// return the grid row of the current cell
|
||||
col_type col() const { return top().col(); }
|
||||
col_type col() const;
|
||||
|
||||
//
|
||||
// math-specific part
|
||||
//
|
||||
/// return the mathed cell this cursor is in
|
||||
MathArray const & cell() const { return top().cell(); }
|
||||
MathArray const & cell() const;
|
||||
/// return the mathed cell this cursor is in
|
||||
MathArray & cell() { return top().cell(); }
|
||||
MathArray & cell();
|
||||
/// the mathatom left of the cursor
|
||||
MathAtom const & prevAtom() const;
|
||||
/// the mathatom left of the cursor
|
||||
@ -105,13 +141,25 @@ public:
|
||||
MathAtom const & nextAtom() const;
|
||||
/// the mathatom right of the cursor
|
||||
MathAtom & nextAtom();
|
||||
/// auto-correct mode
|
||||
bool autocorrect() const { return autocorrect_; }
|
||||
/// auto-correct mode
|
||||
bool & autocorrect() { return autocorrect_; }
|
||||
/// are we entering a macro name?
|
||||
bool macromode() const { return macromode_; }
|
||||
/// are we entering a macro name?
|
||||
bool & macromode() { return macromode_; }
|
||||
|
||||
//
|
||||
// text-specific part
|
||||
///
|
||||
UpdatableInset * innerInset() const;
|
||||
bool boundary() const { return current().boundary(); }
|
||||
///
|
||||
UpdatableInset * innerInsetOfType(int code) const;
|
||||
Paragraph & paragraph();
|
||||
///
|
||||
Paragraph const & paragraph() const;
|
||||
///
|
||||
InsetBase * innerInsetOfType(int code) const;
|
||||
///
|
||||
InsetTabular * innerInsetTabular() const;
|
||||
///
|
||||
@ -129,24 +177,70 @@ public:
|
||||
/// move one step to the right
|
||||
bool posRight();
|
||||
|
||||
/// set target x position of cursor
|
||||
void x_target(int x);
|
||||
/// return target x position of cursor
|
||||
int x_target() const;
|
||||
|
||||
/// access to selection anchor
|
||||
CursorSlice & anchor();
|
||||
/// access to selection anchor
|
||||
CursorSlice const & anchor() const;
|
||||
/// cache the absolute coordinate from the top inset
|
||||
void updatePos();
|
||||
/// sets anchor to cursor position
|
||||
void resetAnchor();
|
||||
/// access to owning BufferView
|
||||
BufferView & bv() const;
|
||||
///
|
||||
friend std::ostream & operator<<(std::ostream &, LCursor const &);
|
||||
/// get some interesting description of current position
|
||||
void info(std::ostream & os);
|
||||
|
||||
/// output
|
||||
friend std::ostream & operator<<(std::ostream & os, LCursor const & cur);
|
||||
public:
|
||||
//private:
|
||||
/// mainly used as stack, but wee need random access
|
||||
std::vector<CursorSlice> cursor_;
|
||||
/// The
|
||||
/// the anchor position
|
||||
std::vector<CursorSlice> anchor_;
|
||||
///
|
||||
BufferView * bv_;
|
||||
|
||||
private:
|
||||
/// don't implement this
|
||||
void operator=(LCursor const &);
|
||||
/// don't implement this
|
||||
LCursor(LCursor const &);
|
||||
|
||||
///
|
||||
BufferView * const bv_;
|
||||
/// current slice
|
||||
int current_;
|
||||
///
|
||||
int cached_y_;
|
||||
/**
|
||||
* The target x position of the cursor. This is used for when
|
||||
* we have text like :
|
||||
*
|
||||
* blah blah blah blah| blah blah blah
|
||||
* blah blah blah
|
||||
* blah blah blah blah blah blah
|
||||
*
|
||||
* When we move onto row 3, we would like to be vertically aligned
|
||||
* with where we were in row 1, despite the fact that row 2 is
|
||||
* shorter than x()
|
||||
*/
|
||||
int x_target_;
|
||||
// do we have a selection?
|
||||
bool selection_;
|
||||
// are we on the way to get one?
|
||||
bool mark_;
|
||||
|
||||
//
|
||||
// math specific stuff that could be promoted to "global" later
|
||||
//
|
||||
/// do we allow autocorrection
|
||||
bool autocorrect_;
|
||||
/// are we entering a macro name?
|
||||
bool macromode_;
|
||||
};
|
||||
|
||||
#endif // LYXCURSOR_H
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
#include "cursor_slice.h"
|
||||
#include "debug.h"
|
||||
#include "lyxtext.h"
|
||||
#include "paragraph.h"
|
||||
|
||||
#include "mathed/math_inset.h"
|
||||
#include "mathed/math_data.h"
|
||||
@ -51,6 +53,12 @@ size_t CursorSlice::nargs() const
|
||||
}
|
||||
|
||||
|
||||
size_t CursorSlice::nrows() const
|
||||
{
|
||||
return inset_->nrows();
|
||||
}
|
||||
|
||||
|
||||
size_t CursorSlice::ncols() const
|
||||
{
|
||||
return inset_->ncols();
|
||||
@ -107,9 +115,7 @@ CursorSlice::pos_type & CursorSlice::pos()
|
||||
|
||||
CursorSlice::pos_type CursorSlice::lastpos() const
|
||||
{
|
||||
BOOST_ASSERT(inset_);
|
||||
#warning implement me for texted, too.
|
||||
return inset_->asMathInset() ? cell().size() : 0;
|
||||
return (inset_ && inset_->asMathInset()) ? cell().size() : paragraph().size();
|
||||
}
|
||||
|
||||
|
||||
@ -171,6 +177,22 @@ LyXText * CursorSlice::text() const
|
||||
}
|
||||
|
||||
|
||||
Paragraph & CursorSlice::paragraph()
|
||||
{
|
||||
// access to the main lyx text must be handled in the cursor
|
||||
BOOST_ASSERT(text());
|
||||
return *text()->getPar(par_);
|
||||
}
|
||||
|
||||
|
||||
Paragraph const & CursorSlice::paragraph() const
|
||||
{
|
||||
// access to the main lyx text must be handled in the cursor
|
||||
BOOST_ASSERT(text());
|
||||
return *text()->getPar(par_);
|
||||
}
|
||||
|
||||
|
||||
bool operator==(CursorSlice const & p, CursorSlice const & q)
|
||||
{
|
||||
return p.inset_ == q.inset_
|
||||
@ -212,8 +234,8 @@ bool operator>(CursorSlice const & p, CursorSlice const & q)
|
||||
|
||||
std::ostream & operator<<(std::ostream & os, CursorSlice const & item)
|
||||
{
|
||||
os << " inset: " << item.inset_
|
||||
<< " text: " << item.text()
|
||||
os << "inset: " << item.inset_
|
||||
// << " text: " << item.text()
|
||||
<< " idx: " << item.idx_
|
||||
<< " par: " << item.par_
|
||||
<< " pos: " << item.pos_
|
||||
@ -222,64 +244,3 @@ std::ostream & operator<<(std::ostream & os, CursorSlice const & item)
|
||||
;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void increment(CursorBase & it)
|
||||
{
|
||||
CursorSlice & top = it.back();
|
||||
MathArray & ar = top.asMathInset()->cell(top.idx_);
|
||||
|
||||
// move into the current inset if possible
|
||||
// it is impossible for pos() == size()!
|
||||
MathInset * n = 0;
|
||||
if (top.pos_ != ar.size())
|
||||
n = (ar.begin() + top.pos_)->nucleus();
|
||||
if (n && n->isActive()) {
|
||||
it.push_back(CursorSlice(n));
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise move on one cell back if possible
|
||||
if (top.pos_ < ar.size()) {
|
||||
// pos() == size() is valid!
|
||||
++top.pos_;
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise try to move on one cell if possible
|
||||
while (top.idx_ + 1 < top.asMathInset()->nargs()) {
|
||||
// idx() == nargs() is _not_ valid!
|
||||
++top.idx_;
|
||||
if (top.asMathInset()->validCell(top.idx_)) {
|
||||
top.pos_ = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise leave array, move on one back
|
||||
// this might yield pos() == size(), but that's a ok.
|
||||
it.pop_back();
|
||||
// it certainly invalidates top
|
||||
++it.back().pos_;
|
||||
}
|
||||
|
||||
|
||||
CursorBase ibegin(InsetBase * p)
|
||||
{
|
||||
CursorBase it;
|
||||
it.push_back(CursorSlice(p));
|
||||
return it;
|
||||
}
|
||||
|
||||
|
||||
CursorBase iend(InsetBase * p)
|
||||
{
|
||||
CursorBase it;
|
||||
it.push_back(CursorSlice(p));
|
||||
CursorSlice & top = it.back();
|
||||
top.idx_ = top.asMathInset()->nargs() - 1;
|
||||
top.pos_ = top.asMathInset()->cell(top.idx_).size();
|
||||
return it;
|
||||
}
|
||||
|
@ -17,8 +17,8 @@
|
||||
#ifndef CURSORSLICE_H
|
||||
#define CURSORSLICE_H
|
||||
|
||||
#include <iosfwd>
|
||||
#include <cstddef>
|
||||
#include <iosfwd>
|
||||
|
||||
#include "support/types.h"
|
||||
|
||||
@ -27,6 +27,7 @@ class InsetBase;
|
||||
class MathInset;
|
||||
class MathArray;
|
||||
class LyXText;
|
||||
class Paragraph;
|
||||
class UpdatableInset;
|
||||
|
||||
|
||||
@ -99,6 +100,10 @@ public:
|
||||
LyXText * text() const;
|
||||
///
|
||||
UpdatableInset * asUpdatableInset() const;
|
||||
///
|
||||
Paragraph & paragraph();
|
||||
///
|
||||
Paragraph const & paragraph() const;
|
||||
|
||||
///
|
||||
/// mathed specific stuff
|
||||
@ -148,20 +153,4 @@ bool operator<(CursorSlice const &, CursorSlice const &);
|
||||
/// test for order
|
||||
bool operator>(CursorSlice const &, CursorSlice const &);
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
// this is used for traversing math insets
|
||||
typedef std::vector<CursorSlice> CursorBase;
|
||||
/// move on one step
|
||||
void increment(CursorBase &);
|
||||
///
|
||||
CursorBase ibegin(InsetBase * p);
|
||||
///
|
||||
CursorBase iend(InsetBase * p);
|
||||
///
|
||||
CursorSlice & cursorTip(BufferView &);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -179,16 +179,19 @@ InsetOld * createInset(BufferView * bv, FuncRequest const & cmd)
|
||||
bv->owner()->getDialogs().show("tabularcreate");
|
||||
return 0;
|
||||
|
||||
case LFUN_INSET_CAPTION:
|
||||
if (!bv->innerInset()) {
|
||||
auto_ptr<InsetCaption> inset(new InsetCaption(params));
|
||||
inset->setOwner(bv->innerInset());
|
||||
inset->setAutoBreakRows(true);
|
||||
inset->setDrawFrame(InsetText::LOCKED);
|
||||
inset->setFrameColor(LColor::captionframe);
|
||||
return inset.release();
|
||||
case LFUN_INSET_CAPTION: {
|
||||
UpdatableInset * up = bv->cursor().inset()
|
||||
? bv->cursor().inset()->asUpdatableInset() : 0;
|
||||
if (!up) {
|
||||
auto_ptr<InsetCaption> inset(new InsetCaption(params));
|
||||
inset->setOwner(up);
|
||||
inset->setAutoBreakRows(true);
|
||||
inset->setDrawFrame(InsetText::LOCKED);
|
||||
inset->setFrameColor(LColor::captionframe);
|
||||
return inset.release();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
||||
case LFUN_INDEX_PRINT:
|
||||
return new InsetPrintIndex(InsetCommandParams("printindex"));
|
||||
|
@ -105,7 +105,7 @@ void LyXView::setLayout(string const & layout)
|
||||
|
||||
void LyXView::updateToolbar()
|
||||
{
|
||||
bool const math = mathcursor;
|
||||
bool const math = inMathed();
|
||||
bool const table =
|
||||
!getLyXFunc().getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).disabled();
|
||||
toolbar_->update(math, table);
|
||||
|
@ -172,7 +172,7 @@ void LyXScreen::showCursor(BufferView & bv)
|
||||
int h = ascent + descent;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
bv.fullCursor().getPos(x, y);
|
||||
bv.cursor().getPos(x, y);
|
||||
y -= ascent + bv.top_y();
|
||||
//lyxerr << "LyXScreen::showCursor x: " << x << " y: " << y << endl;
|
||||
|
||||
@ -211,8 +211,8 @@ bool LyXScreen::fitCursor(BufferView * bv)
|
||||
int newtop = top_y;
|
||||
int x, y, asc, desc;
|
||||
|
||||
bv->fullCursor().getPos(x, y);
|
||||
bv->fullCursor().getDim(asc, desc);
|
||||
bv->cursor().getPos(x, y);
|
||||
bv->cursor().getDim(asc, desc);
|
||||
|
||||
bool const big_row = h / 4 < asc + desc && asc + desc < h;
|
||||
|
||||
|
@ -1,4 +1,30 @@
|
||||
|
||||
2004-01-20 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* inset.h:
|
||||
* insetbase.[Ch]: move stuff from mathcursor here.
|
||||
|
||||
* insetbibitem.[Ch]:
|
||||
* insetbibtex.[Ch]:
|
||||
* insetbox.[Ch]:
|
||||
* insetbranch.[Ch]:
|
||||
* insetcharstyle.[Ch]:
|
||||
* insetcollapsable.[Ch]:
|
||||
* insetcommand.[Ch]:
|
||||
* insetert.[Ch]:
|
||||
* insetexternal.[Ch]:
|
||||
* insetfloat.[Ch]:
|
||||
* insetgraphics.[Ch]:
|
||||
* insetinclude.[Ch]:
|
||||
* insetlabel.[Ch]:
|
||||
* insetnote.[Ch]:
|
||||
* insetref.[Ch]:
|
||||
* insettabular.[Ch]:
|
||||
* insettext.[Ch]:
|
||||
* insetvspace.[Ch]:
|
||||
* insetwrap.[Ch]:
|
||||
* updatableinset.[Ch]: Adjust to IU changes (see comment in src/Changelog)
|
||||
|
||||
2004-01-15 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* insetbase.[Ch]:
|
||||
|
@ -17,8 +17,6 @@
|
||||
|
||||
#include "insetbase.h"
|
||||
#include "dimension.h"
|
||||
#include "ParagraphList_fwd.h"
|
||||
|
||||
|
||||
class Buffer;
|
||||
class LColor_color;
|
||||
@ -37,107 +35,10 @@ namespace graphics {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Insets
|
||||
class InsetOld : public InsetBase {
|
||||
public:
|
||||
/** This is not quite the correct place for this enum. I think
|
||||
the correct would be to let each subclass of Inset declare
|
||||
its own enum code. Actually the notion of an InsetOld::Code
|
||||
should be avoided, but I am not sure how this could be done
|
||||
in a cleaner way. */
|
||||
enum Code {
|
||||
///
|
||||
NO_CODE, // 0
|
||||
///
|
||||
TOC_CODE, // do these insets really need a code? (ale)
|
||||
///
|
||||
QUOTE_CODE,
|
||||
///
|
||||
MARK_CODE,
|
||||
///
|
||||
REF_CODE,
|
||||
///
|
||||
URL_CODE, // 5
|
||||
///
|
||||
HTMLURL_CODE,
|
||||
///
|
||||
SEPARATOR_CODE,
|
||||
///
|
||||
ENDING_CODE,
|
||||
///
|
||||
LABEL_CODE,
|
||||
///
|
||||
NOTE_CODE, // 10
|
||||
///
|
||||
ACCENT_CODE,
|
||||
///
|
||||
MATH_CODE,
|
||||
///
|
||||
INDEX_CODE,
|
||||
///
|
||||
INCLUDE_CODE,
|
||||
///
|
||||
GRAPHICS_CODE, // 15
|
||||
///
|
||||
BIBITEM_CODE,
|
||||
///
|
||||
BIBTEX_CODE,
|
||||
///
|
||||
TEXT_CODE,
|
||||
///
|
||||
ERT_CODE,
|
||||
///
|
||||
FOOT_CODE, // 20
|
||||
///
|
||||
MARGIN_CODE,
|
||||
///
|
||||
FLOAT_CODE,
|
||||
///
|
||||
WRAP_CODE,
|
||||
///
|
||||
SPACE_CODE, // 25
|
||||
///
|
||||
SPECIALCHAR_CODE,
|
||||
///
|
||||
TABULAR_CODE,
|
||||
///
|
||||
EXTERNAL_CODE,
|
||||
#if 0
|
||||
///
|
||||
THEOREM_CODE,
|
||||
#endif
|
||||
///
|
||||
CAPTION_CODE,
|
||||
///
|
||||
MATHMACRO_CODE, // 30
|
||||
///
|
||||
ERROR_CODE,
|
||||
///
|
||||
CITE_CODE,
|
||||
///
|
||||
FLOAT_LIST_CODE,
|
||||
///
|
||||
INDEX_PRINT_CODE,
|
||||
///
|
||||
OPTARG_CODE, // 35
|
||||
///
|
||||
ENVIRONMENT_CODE,
|
||||
///
|
||||
HFILL_CODE,
|
||||
///
|
||||
NEWLINE_CODE,
|
||||
///
|
||||
LINE_CODE,
|
||||
///
|
||||
BRANCH_CODE, // 40
|
||||
///
|
||||
BOX_CODE,
|
||||
///
|
||||
CHARSTYLE_CODE,
|
||||
///
|
||||
VSPACE_CODE
|
||||
};
|
||||
|
||||
///
|
||||
enum {
|
||||
///
|
||||
@ -195,9 +96,6 @@ public:
|
||||
virtual int docbook(Buffer const &, std::ostream &,
|
||||
OutputParams const &) const = 0;
|
||||
|
||||
/// returns LyX code associated with the inset. Used for TOC, ...)
|
||||
virtual InsetOld::Code lyxCode() const { return NO_CODE; }
|
||||
|
||||
/// returns true to override begin and end inset in file
|
||||
virtual bool directWrite() const;
|
||||
|
||||
|
@ -15,27 +15,26 @@
|
||||
#include "dispatchresult.h"
|
||||
|
||||
|
||||
DispatchResult InsetBase::dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
DispatchResult InsetBase::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
return priv_dispatch(bv, cmd);
|
||||
return priv_dispatch(cur, cmd);
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
DispatchResult InsetBase::priv_dispatch(LCursor &, FuncRequest const & cmd)
|
||||
{
|
||||
return DispatchResult(false);
|
||||
}
|
||||
|
||||
|
||||
void InsetBase::edit(BufferView *, bool)
|
||||
void InsetBase::edit(LCursor &, bool)
|
||||
{
|
||||
lyxerr << "InsetBase: edit left/right" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void InsetBase::edit(BufferView * bv, int, int)
|
||||
void InsetBase::edit(LCursor & cur, int, int)
|
||||
{
|
||||
lyxerr << "InsetBase: edit xy" << std::endl;
|
||||
edit(bv, true);
|
||||
edit(cur, true);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ class BufferView;
|
||||
class DispatchResult;
|
||||
class FuncRequest;
|
||||
class LaTeXFeatures;
|
||||
class LCursor;
|
||||
class MathInset;
|
||||
class MetricsInfo;
|
||||
class Dimension;
|
||||
@ -54,23 +55,17 @@ public:
|
||||
virtual UpdatableInset * asUpdatableInset() { return 0; }
|
||||
|
||||
// the real dispatcher
|
||||
DispatchResult dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
DispatchResult dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
|
||||
/// cursor enters
|
||||
virtual void edit(BufferView * bv, bool left);
|
||||
virtual void edit(LCursor & cur, bool left);
|
||||
/// cursor enters
|
||||
virtual void edit(BufferView * bv, int x, int y);
|
||||
virtual void edit(LCursor & cur, int x, int y);
|
||||
|
||||
/// compute the size of the object returned in dim
|
||||
virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
|
||||
/// draw inset and update (xo, yo)-cache
|
||||
virtual void draw(PainterInfo & pi, int x, int y) const = 0;
|
||||
|
||||
/// request "external features"
|
||||
virtual void validate(LaTeXFeatures &) const {}
|
||||
/// Appends \c list with all labels found within this inset.
|
||||
virtual void getLabelList(Buffer const &,
|
||||
std::vector<std::string> & /* list */) const {}
|
||||
/// last drawn position for 'important' insets
|
||||
virtual int x() const { return 0; }
|
||||
/// last drawn position for 'important' insets
|
||||
@ -82,10 +77,125 @@ public:
|
||||
virtual size_t nrows() const { return 0; }
|
||||
/// number of columns in gridlike structures
|
||||
virtual size_t ncols() const { return 0; }
|
||||
|
||||
/// request "external features"
|
||||
virtual void validate(LaTeXFeatures &) const {}
|
||||
/// Appends \c list with all labels found within this inset.
|
||||
virtual void getLabelList(Buffer const &,
|
||||
std::vector<std::string> & /* list */) const {}
|
||||
/// describe content if cursor inside
|
||||
virtual void infoize(std::ostream &) const {}
|
||||
/// describe content if cursor behind
|
||||
virtual void infoize2(std::ostream &) const {}
|
||||
protected:
|
||||
// the real dispatcher
|
||||
virtual
|
||||
DispatchResult priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
public:
|
||||
/** This is not quite the correct place for this enum. I think
|
||||
the correct would be to let each subclass of Inset declare
|
||||
its own enum code. Actually the notion of an InsetOld::Code
|
||||
should be avoided, but I am not sure how this could be done
|
||||
in a cleaner way. */
|
||||
enum Code {
|
||||
///
|
||||
NO_CODE, // 0
|
||||
///
|
||||
TOC_CODE, // do these insets really need a code? (ale)
|
||||
///
|
||||
QUOTE_CODE,
|
||||
///
|
||||
MARK_CODE,
|
||||
///
|
||||
REF_CODE,
|
||||
///
|
||||
URL_CODE, // 5
|
||||
///
|
||||
HTMLURL_CODE,
|
||||
///
|
||||
SEPARATOR_CODE,
|
||||
///
|
||||
ENDING_CODE,
|
||||
///
|
||||
LABEL_CODE,
|
||||
///
|
||||
NOTE_CODE, // 10
|
||||
///
|
||||
ACCENT_CODE,
|
||||
///
|
||||
MATH_CODE,
|
||||
///
|
||||
INDEX_CODE,
|
||||
///
|
||||
INCLUDE_CODE,
|
||||
///
|
||||
GRAPHICS_CODE, // 15
|
||||
///
|
||||
BIBITEM_CODE,
|
||||
///
|
||||
BIBTEX_CODE,
|
||||
///
|
||||
TEXT_CODE,
|
||||
///
|
||||
ERT_CODE,
|
||||
///
|
||||
FOOT_CODE, // 20
|
||||
///
|
||||
MARGIN_CODE,
|
||||
///
|
||||
FLOAT_CODE,
|
||||
///
|
||||
WRAP_CODE,
|
||||
///
|
||||
SPACE_CODE, // 25
|
||||
///
|
||||
SPECIALCHAR_CODE,
|
||||
///
|
||||
TABULAR_CODE,
|
||||
///
|
||||
EXTERNAL_CODE,
|
||||
#if 0
|
||||
///
|
||||
THEOREM_CODE,
|
||||
#endif
|
||||
///
|
||||
CAPTION_CODE,
|
||||
///
|
||||
MATHMACRO_CODE, // 30
|
||||
///
|
||||
ERROR_CODE,
|
||||
///
|
||||
CITE_CODE,
|
||||
///
|
||||
FLOAT_LIST_CODE,
|
||||
///
|
||||
INDEX_PRINT_CODE,
|
||||
///
|
||||
OPTARG_CODE, // 35
|
||||
///
|
||||
ENVIRONMENT_CODE,
|
||||
///
|
||||
HFILL_CODE,
|
||||
///
|
||||
NEWLINE_CODE,
|
||||
///
|
||||
LINE_CODE,
|
||||
///
|
||||
BRANCH_CODE, // 40
|
||||
///
|
||||
BOX_CODE,
|
||||
///
|
||||
CHARSTYLE_CODE,
|
||||
///
|
||||
VSPACE_CODE,
|
||||
///
|
||||
MATHGRID_CODE,
|
||||
///
|
||||
MATHHULL_CODE
|
||||
};
|
||||
/// returns LyX code associated with the inset. Used for TOC, ...)
|
||||
virtual InsetBase::Code lyxCode() const { return NO_CODE; }
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -54,7 +54,7 @@ auto_ptr<InsetBase> InsetBibitem::clone() const
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetBibitem::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetBibitem::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -64,13 +64,13 @@ InsetBibitem::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
if (p.getCmdName().empty())
|
||||
return DispatchResult(true, true);
|
||||
setParams(p);
|
||||
bv.update();
|
||||
bv.fitCursor();
|
||||
cur.bv().update();
|
||||
cur.bv().fitCursor();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
default:
|
||||
return InsetCommand::priv_dispatch(bv, cmd);
|
||||
return InsetCommand::priv_dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
///
|
||||
int counter;
|
||||
|
@ -66,7 +66,7 @@ std::auto_ptr<InsetBase> InsetBibtex::clone() const
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetBibtex::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetBibtex::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -79,7 +79,7 @@ InsetBibtex::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
default:
|
||||
return InsetCommand::priv_dispatch(bv, cmd);
|
||||
return InsetCommand::priv_dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
};
|
||||
|
||||
#endif // INSET_BIBTEX_H
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "insetbox.h"
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "debug.h"
|
||||
#include "funcrequest.h"
|
||||
@ -170,7 +170,7 @@ bool InsetBox::showInsetDialog(BufferView * bv) const
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetBox::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetBox::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -182,18 +182,18 @@ InsetBox::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetBoxMailer(*this).updateDialog(&bv);
|
||||
InsetBoxMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true);
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
|
||||
InsetBoxMailer(*this).showDialog(&bv);
|
||||
InsetBoxMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true);
|
||||
}
|
||||
return InsetCollapsable::priv_dispatch(bv, cmd);
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
|
||||
default:
|
||||
return InsetCollapsable::priv_dispatch(bv, cmd);
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
friend class InsetBoxParams;
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "buffer.h"
|
||||
#include "bufferparams.h"
|
||||
#include "BranchList.h"
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "funcrequest.h"
|
||||
#include "gettext.h"
|
||||
@ -111,7 +111,7 @@ bool InsetBranch::showInsetDialog(BufferView * bv) const
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetBranch::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetBranch::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_INSET_MODIFY: {
|
||||
@ -124,22 +124,22 @@ InsetBranch::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
if (cmd.button() != mouse_button::button3)
|
||||
return InsetCollapsable::priv_dispatch(bv, cmd);
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
return DispatchResult(false);
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetBranchMailer(*this).updateDialog(&bv);
|
||||
InsetBranchMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true);
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
|
||||
InsetBranchMailer(*this).showDialog(&bv);
|
||||
InsetBranchMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true);
|
||||
}
|
||||
return InsetCollapsable::priv_dispatch(bv, cmd);
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
|
||||
default:
|
||||
return InsetCollapsable::priv_dispatch(bv, cmd);
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
friend class InsetBranchParams;
|
||||
|
||||
|
@ -148,7 +148,7 @@ void InsetCharStyle::getDrawFont(LyXFont & font) const
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetCharStyle::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetCharStyle::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
setStatus(Inlined);
|
||||
switch (cmd.action) {
|
||||
@ -157,10 +157,10 @@ InsetCharStyle::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
has_label_ = !has_label_;
|
||||
return DispatchResult(true);
|
||||
}
|
||||
inset.dispatch(bv, cmd);
|
||||
inset.dispatch(cur, cmd);
|
||||
return DispatchResult(true, true);
|
||||
default:
|
||||
return InsetCollapsable::priv_dispatch(bv, cmd);
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ int InsetCharStyle::docbook(Buffer const &, std::ostream & os,
|
||||
|
||||
|
||||
int InsetCharStyle::plaintext(Buffer const &, std::ostream & os,
|
||||
OutputParams const & runparams) const
|
||||
OutputParams const & /*runparams*/) const
|
||||
{
|
||||
return outputVerbatim(os, inset);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
|
||||
private:
|
||||
friend class InsetCharStyleParams;
|
||||
|
@ -214,11 +214,11 @@ FuncRequest InsetCollapsable::adjustCommand(FuncRequest const & cmd)
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetCollapsable::lfunMouseRelease(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
lyxerr << "InsetCollapsable::lfunMouseRelease 0" << endl;
|
||||
showInsetDialog(&bv);
|
||||
showInsetDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ InsetCollapsable::lfunMouseRelease(BufferView & bv, FuncRequest const & cmd)
|
||||
case Collapsed:
|
||||
lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
|
||||
setStatus(Open);
|
||||
edit(&bv, true);
|
||||
edit(cur, true);
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case Open:
|
||||
@ -236,10 +236,10 @@ InsetCollapsable::lfunMouseRelease(BufferView & bv, FuncRequest const & cmd)
|
||||
return DispatchResult(false, FINISHED_RIGHT);
|
||||
}
|
||||
lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
|
||||
return inset.dispatch(bv, adjustCommand(cmd));
|
||||
return inset.dispatch(cur, adjustCommand(cmd));
|
||||
|
||||
case Inlined:
|
||||
return inset.dispatch(bv, cmd);
|
||||
return inset.dispatch(cur, cmd);
|
||||
}
|
||||
|
||||
return DispatchResult(true, true);
|
||||
@ -301,17 +301,18 @@ string const InsetCollapsable::getNewLabel(string const & l) const
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::edit(BufferView * bv, bool left)
|
||||
void InsetCollapsable::edit(LCursor & cur, bool left)
|
||||
{
|
||||
lyxerr << "InsetCollapsable: edit left/right" << endl;
|
||||
inset.edit(bv, left);
|
||||
cur.push(this);
|
||||
inset.edit(cur, left);
|
||||
open();
|
||||
bv->fullCursor().push(this);
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::edit(BufferView * bv, int x, int y)
|
||||
void InsetCollapsable::edit(LCursor & cur, int x, int y)
|
||||
{
|
||||
cur.push(this);
|
||||
lyxerr << "InsetCollapsable: edit xy" << endl;
|
||||
if (status_ == Collapsed) {
|
||||
setStatus(Open);
|
||||
@ -321,33 +322,32 @@ void InsetCollapsable::edit(BufferView * bv, int x, int y)
|
||||
else
|
||||
y += inset.ascent() - height_collapsed();
|
||||
}
|
||||
inset.edit(bv, x, y);
|
||||
bv->fullCursor().push(this);
|
||||
inset.edit(cur, x, y);
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetCollapsable::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
//lyxerr << "\nInsetCollapsable::priv_dispatch (begin): cmd: " << cmd
|
||||
// << " button y: " << button_dim.y2 << endl;
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_PRESS:
|
||||
if (status_ == Inlined)
|
||||
inset.dispatch(bv, cmd);
|
||||
inset.dispatch(cur, cmd);
|
||||
else if (status_ == Open && cmd.y > button_dim.y2)
|
||||
inset.dispatch(bv, adjustCommand(cmd));
|
||||
inset.dispatch(cur, adjustCommand(cmd));
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case LFUN_MOUSE_MOTION:
|
||||
if (status_ == Inlined)
|
||||
inset.dispatch(bv, cmd);
|
||||
inset.dispatch(cur, cmd);
|
||||
else if (status_ == Open && cmd.y > button_dim.y2)
|
||||
inset.dispatch(bv, adjustCommand(cmd));
|
||||
inset.dispatch(cur, adjustCommand(cmd));
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
return lfunMouseRelease(bv, cmd);
|
||||
return lfunMouseRelease(cur, cmd);
|
||||
|
||||
case LFUN_INSET_TOGGLE:
|
||||
if (inset.text_.toggleInset())
|
||||
@ -361,9 +361,8 @@ InsetCollapsable::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
default:
|
||||
return inset.dispatch(bv, adjustCommand(cmd));
|
||||
return inset.dispatch(cur, adjustCommand(cmd));
|
||||
}
|
||||
//lyxerr << "InsetCollapsable::priv_dispatch (end)" << endl;
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,7 +121,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
void dimension_collapsed(Dimension &) const;
|
||||
///
|
||||
@ -133,13 +133,13 @@ protected:
|
||||
///
|
||||
Box const & buttonDim() const;
|
||||
///
|
||||
void edit(BufferView *, bool);
|
||||
void edit(LCursor & cur, bool left);
|
||||
///
|
||||
void edit(BufferView *, int, int);
|
||||
void edit(LCursor & cur, int x, int y);
|
||||
|
||||
private:
|
||||
///
|
||||
DispatchResult lfunMouseRelease(BufferView & bv, FuncRequest const &);
|
||||
DispatchResult lfunMouseRelease(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
FuncRequest adjustCommand(FuncRequest const &);
|
||||
|
||||
|
@ -100,7 +100,7 @@ int InsetCommand::docbook(Buffer const &, ostream &,
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetCommand::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetCommand::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_INSET_MODIFY: {
|
||||
@ -109,18 +109,18 @@ InsetCommand::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
if (p.getCmdName().empty())
|
||||
return DispatchResult(false);
|
||||
setParams(p);
|
||||
bv.update();
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetCommandMailer(cmd.argument, *this).updateDialog(&bv);
|
||||
InsetCommandMailer(cmd.argument, *this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case LFUN_INSET_DIALOG_SHOW:
|
||||
case LFUN_MOUSE_RELEASE: {
|
||||
if (!mailer_name_.empty())
|
||||
InsetCommandMailer(mailer_name_, *this).showDialog(&bv);
|
||||
InsetCommandMailer(mailer_name_, *this).showDialog(&cur.bv());
|
||||
return DispatchResult(true);
|
||||
}
|
||||
|
||||
|
@ -13,11 +13,12 @@
|
||||
#ifndef INSET_LATEXCOMMAND_H
|
||||
#define INSET_LATEXCOMMAND_H
|
||||
|
||||
|
||||
#include "inset.h"
|
||||
#include "insetcommandparams.h"
|
||||
#include "render_button.h"
|
||||
#include "mailinset.h"
|
||||
#include "cursor.h"
|
||||
|
||||
|
||||
// Created by Alejandro 970222
|
||||
/** Used to insert a LaTeX command automatically
|
||||
@ -30,9 +31,7 @@
|
||||
class InsetCommand : public InsetOld {
|
||||
public:
|
||||
///
|
||||
explicit
|
||||
InsetCommand(InsetCommandParams const &,
|
||||
std::string const & mailer_name);
|
||||
InsetCommand(InsetCommandParams const &, std::string const & mailer_name);
|
||||
///
|
||||
~InsetCommand();
|
||||
///
|
||||
@ -77,7 +76,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
std::string const getCommand() const { return p_.getCommand(); }
|
||||
///
|
||||
|
@ -208,7 +208,7 @@ int InsetERT::docbook(Buffer const &, ostream & os,
|
||||
}
|
||||
|
||||
|
||||
DispatchResult InsetERT::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
DispatchResult InsetERT::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -237,7 +237,7 @@ DispatchResult InsetERT::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
return DispatchResult(true);
|
||||
|
||||
default:
|
||||
return InsetCollapsable::priv_dispatch(bv, cmd);
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
///
|
||||
void init();
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "buffer.h"
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "funcrequest.h"
|
||||
@ -41,10 +42,10 @@
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/tostr.h"
|
||||
#include "support/translator.h"
|
||||
#include "support/std_sstream.h"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "support/std_sstream.h"
|
||||
|
||||
namespace support = lyx::support;
|
||||
namespace external = lyx::external;
|
||||
@ -441,12 +442,12 @@ void InsetExternal::statusChanged() const
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetExternal::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetExternal::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_EXTERNAL_EDIT: {
|
||||
Buffer const & buffer = *bv.buffer();
|
||||
Buffer const & buffer = *cur.bv().buffer();
|
||||
InsetExternalParams p;
|
||||
InsetExternalMailer::string2params(cmd.argument, buffer, p);
|
||||
external::editExternal(p, buffer);
|
||||
@ -454,20 +455,20 @@ InsetExternal::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
case LFUN_INSET_MODIFY: {
|
||||
Buffer const & buffer = *bv.buffer();
|
||||
Buffer const & buffer = *cur.bv().buffer();
|
||||
InsetExternalParams p;
|
||||
InsetExternalMailer::string2params(cmd.argument, buffer, p);
|
||||
setParams(p, buffer);
|
||||
bv.update();
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetExternalMailer(*this).updateDialog(&bv);
|
||||
InsetExternalMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
InsetExternalMailer(*this).showDialog(&bv);
|
||||
InsetExternalMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
|
||||
default:
|
||||
@ -476,9 +477,9 @@ InsetExternal::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
|
||||
void InsetExternal::edit(BufferView * bv, bool)
|
||||
void InsetExternal::edit(LCursor & cur, bool)
|
||||
{
|
||||
InsetExternalMailer(*this).showDialog(bv);
|
||||
InsetExternalMailer(*this).showDialog(&cur.bv());
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,13 +146,13 @@ public:
|
||||
///
|
||||
void addPreview(lyx::graphics::PreviewLoader &) const;
|
||||
///
|
||||
void edit(BufferView * bv, bool);
|
||||
void edit(LCursor & cur, bool);
|
||||
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
/** This method is connected to the graphics loader, so we are
|
||||
* informed when the image has been loaded.
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "buffer.h"
|
||||
#include "bufferparams.h"
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "Floating.h"
|
||||
@ -31,7 +32,6 @@
|
||||
|
||||
#include "support/lstrings.h"
|
||||
#include "support/tostr.h"
|
||||
|
||||
#include "support/std_sstream.h"
|
||||
|
||||
using lyx::support::contains;
|
||||
@ -156,7 +156,7 @@ InsetFloat::~InsetFloat()
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetFloat::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetFloat::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -165,18 +165,18 @@ InsetFloat::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetFloatMailer::string2params(cmd.argument, params);
|
||||
params_.placement = params.placement;
|
||||
params_.wide = params.wide;
|
||||
wide(params_.wide, bv.buffer()->params());
|
||||
bv.update();
|
||||
wide(params_.wide, cur.bv().buffer()->params());
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE: {
|
||||
InsetFloatMailer(*this).updateDialog(&bv);
|
||||
InsetFloatMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
default:
|
||||
return InsetCollapsable::priv_dispatch(bv, cmd);
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
protected:
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
///
|
||||
InsetFloatParams params_;
|
||||
|
@ -58,6 +58,7 @@ TODO
|
||||
#include "buffer.h"
|
||||
#include "BufferView.h"
|
||||
#include "converter.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "format.h"
|
||||
@ -79,12 +80,11 @@ TODO
|
||||
#include "support/os.h"
|
||||
#include "support/systemcall.h"
|
||||
#include "support/tostr.h"
|
||||
#include "support/std_sstream.h"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
#include "support/std_sstream.h"
|
||||
|
||||
namespace support = lyx::support;
|
||||
using lyx::support::AbsolutePath;
|
||||
using lyx::support::bformat;
|
||||
@ -192,26 +192,26 @@ void InsetGraphics::statusChanged() const
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetGraphics::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetGraphics::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_INSET_MODIFY: {
|
||||
Buffer const & buffer = *bv.buffer();
|
||||
Buffer const & buffer = *cur.bv().buffer();
|
||||
InsetGraphicsParams p;
|
||||
InsetGraphicsMailer::string2params(cmd.argument, buffer, p);
|
||||
if (!p.filename.empty()) {
|
||||
setParams(p);
|
||||
bv.update();
|
||||
cur.bv().update();
|
||||
}
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetGraphicsMailer(*this).updateDialog(&bv);
|
||||
InsetGraphicsMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
InsetGraphicsMailer(*this).showDialog(&bv);
|
||||
InsetGraphicsMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
|
||||
default:
|
||||
@ -220,9 +220,9 @@ InsetGraphics::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
|
||||
void InsetGraphics::edit(BufferView * bv, bool)
|
||||
void InsetGraphics::edit(LCursor & cur, bool)
|
||||
{
|
||||
InsetGraphicsMailer(*this).showDialog(bv);
|
||||
InsetGraphicsMailer(*this).showDialog(&cur.bv());
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,12 +78,12 @@ public:
|
||||
///
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
void edit(BufferView * bv, bool);
|
||||
void edit(LCursor & cur, bool);
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
///
|
||||
friend class InsetGraphicsMailer;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "bufferlist.h"
|
||||
#include "bufferparams.h"
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "funcrequest.h"
|
||||
@ -108,7 +109,7 @@ InsetInclude::~InsetInclude()
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetInclude::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetInclude::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -116,23 +117,23 @@ InsetInclude::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetCommandParams p;
|
||||
InsetIncludeMailer::string2params(cmd.argument, p);
|
||||
if (!p.getCmdName().empty()) {
|
||||
set(p, *bv.buffer());
|
||||
bv.update();
|
||||
set(p, *cur.bv().buffer());
|
||||
cur.bv().update();
|
||||
}
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetIncludeMailer(*this).updateDialog(&bv);
|
||||
InsetIncludeMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (button_.box().contains(cmd.x, cmd.y))
|
||||
InsetIncludeMailer(*this).showDialog(&bv);
|
||||
InsetIncludeMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case LFUN_INSET_DIALOG_SHOW:
|
||||
InsetIncludeMailer(*this).showDialog(&bv);
|
||||
InsetIncludeMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
|
||||
default:
|
||||
|
@ -85,7 +85,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
/// Slot receiving a signal that the preview is ready to display.
|
||||
void statusChanged() const;
|
||||
|
@ -52,7 +52,7 @@ string const InsetLabel::getScreenLabel(Buffer const &) const
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetLabel::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetLabel::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -63,15 +63,15 @@ InsetLabel::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
return DispatchResult(false);
|
||||
bool clean = true;
|
||||
if (p.getContents() != params().getContents())
|
||||
clean = bv.ChangeRefsIfUnique(params().getContents(),
|
||||
clean = cur.bv().ChangeRefsIfUnique(params().getContents(),
|
||||
p.getContents());
|
||||
setParams(p);
|
||||
bv.update();
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
default:
|
||||
return InsetCommand::priv_dispatch(bv, cmd);
|
||||
return InsetCommand::priv_dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "insetnote.h"
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "funcrequest.h"
|
||||
@ -184,30 +185,30 @@ bool InsetNote::showInsetDialog(BufferView * bv) const
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetNote::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetNote::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_INSET_MODIFY: {
|
||||
InsetNoteMailer::string2params(cmd.argument, params_);
|
||||
setButtonLabel();
|
||||
bv.update();
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetNoteMailer(*this).updateDialog(&bv);
|
||||
InsetNoteMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
|
||||
InsetNoteMailer(*this).showDialog(&bv);
|
||||
InsetNoteMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
return InsetCollapsable::priv_dispatch(bv, cmd);
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
|
||||
default:
|
||||
return InsetCollapsable::priv_dispatch(bv, cmd);
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
friend class InsetNoteParams;
|
||||
|
||||
|
@ -40,19 +40,19 @@ InsetRef::InsetRef(InsetRef const & ir)
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetRef::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetRef::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_PRESS:
|
||||
// Eventually trigger dialog with button 3 not 1
|
||||
if (cmd.button() == mouse_button::button3)
|
||||
bv.owner()->dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
|
||||
cur.bv().owner()->dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
|
||||
else
|
||||
InsetCommandMailer("ref", *this).showDialog(&bv);
|
||||
InsetCommandMailer("ref", *this).showDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
|
||||
default:
|
||||
return InsetCommand::priv_dispatch(bv, cmd);
|
||||
return InsetCommand::priv_dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
///
|
||||
bool isLatex;
|
||||
|
@ -375,17 +375,17 @@ string const InsetTabular::editMessage() const
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::updateLocal(BufferView & bv) const
|
||||
void InsetTabular::updateLocal(LCursor & cur) const
|
||||
{
|
||||
bv.update();
|
||||
resetPos(bv);
|
||||
cur.bv().update();
|
||||
resetPos(cur);
|
||||
}
|
||||
|
||||
extern LCursor theTempCursor;
|
||||
|
||||
extern CursorBase theTempCursor;
|
||||
|
||||
|
||||
|
||||
void InsetTabular::lfunMousePress(BufferView & bv, FuncRequest const & cmd)
|
||||
void InsetTabular::lfunMousePress(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
if (hasSelection() && cmd.button() == mouse_button::button3)
|
||||
return;
|
||||
@ -396,93 +396,92 @@ void InsetTabular::lfunMousePress(BufferView & bv, FuncRequest const & cmd)
|
||||
lyxerr << "# InsetTabular::lfunMousePress cell: " << cell << endl;
|
||||
if (cell == -1) {
|
||||
tablemode = true;
|
||||
bv.fullCursor(theTempCursor);
|
||||
bv.fullCursor().push(this);
|
||||
bv.fullCursor().idx() = cell;
|
||||
cur.cursor_ = theTempCursor;
|
||||
cur.push(this);
|
||||
cur.idx() = cell;
|
||||
} else {
|
||||
tablemode = false;
|
||||
setPos(bv, cmd.x, cmd.y);
|
||||
bv.fullCursor(theTempCursor);
|
||||
bv.fullCursor().idx() = cell;
|
||||
setPos(cur.bv(), cmd.x, cmd.y);
|
||||
cur.cursor_ = theTempCursor;
|
||||
cur.idx() = cell;
|
||||
}
|
||||
lyxerr << bv.cursor() << endl;
|
||||
cur.resetAnchor();
|
||||
lyxerr << cur << endl;
|
||||
|
||||
if (cmd.button() == mouse_button::button2)
|
||||
dispatch(bv, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
|
||||
dispatch(cur, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::lfunMouseMotion(BufferView & bv, FuncRequest const & cmd)
|
||||
void InsetTabular::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
int const actcell = getCell(cmd.x + xo_, cmd.y + yo_);
|
||||
lyxerr << "# InsetTabular::lfunMouseMotion cell: " << actcell << endl;
|
||||
|
||||
setPos(bv, cmd.x, cmd.y);
|
||||
setPos(cur.bv(), cmd.x, cmd.y);
|
||||
if (!hasSelection()) {
|
||||
setSelection(actcell, actcell);
|
||||
bv.setSelection();
|
||||
cur.setSelection();
|
||||
} else {
|
||||
bv.cursor().idx() = actcell;
|
||||
cur.idx() = actcell;
|
||||
setSelection(sel_cell_start, actcell);
|
||||
tablemode = (sel_cell_start != actcell);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::lfunMouseRelease(BufferView & bv, FuncRequest const & cmd)
|
||||
void InsetTabular::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
int const actcell = getCell(cmd.x + xo_, cmd.y + yo_);
|
||||
lyxerr << "# InsetTabular::lfunMouseRelease cell: " << actcell << endl;
|
||||
if (cmd.button() == mouse_button::button3)
|
||||
InsetTabularMailer(*this).showDialog(&bv);
|
||||
InsetTabularMailer(*this).showDialog(&cur.bv());
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::edit(BufferView * view, bool left)
|
||||
void InsetTabular::edit(LCursor & cur, bool left)
|
||||
{
|
||||
BufferView & bv = *view;
|
||||
lyxerr << "InsetTabular::edit: " << this << endl;
|
||||
finishUndo();
|
||||
//tablemode = false;
|
||||
int cell;
|
||||
if (left) {
|
||||
if (isRightToLeft(bv))
|
||||
if (isRightToLeft(cur))
|
||||
cell = tabular.getLastCellInRow(0);
|
||||
else
|
||||
cell = 0;
|
||||
} else {
|
||||
if (isRightToLeft(bv))
|
||||
if (isRightToLeft(cur))
|
||||
cell = tabular.getFirstCellInRow(tabular.rows()-1);
|
||||
else
|
||||
cell = tabular.getNumberOfCells() - 1;
|
||||
}
|
||||
clearSelection();
|
||||
resetPos(bv);
|
||||
bv.fitCursor();
|
||||
bv.fullCursor().push(this);
|
||||
bv.fullCursor().idx() = cell;
|
||||
lyxerr << bv.cursor() << endl;
|
||||
resetPos(cur);
|
||||
cur.bv().fitCursor();
|
||||
cur.push(this);
|
||||
cur.idx() = cell;
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::edit(BufferView * bv, int x, int y)
|
||||
void InsetTabular::edit(LCursor & cur, int x, int y)
|
||||
{
|
||||
lyxerr << "InsetTabular::edit: " << this << " first cell "
|
||||
<< &tabular.cell_info[0][0].inset << endl;
|
||||
|
||||
finishUndo();
|
||||
setPos(*bv, x, y);
|
||||
setPos(cur.bv(), x, y);
|
||||
clearSelection();
|
||||
finishUndo();
|
||||
//int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell);
|
||||
bv->fullCursor().push(this);
|
||||
cur.push(this);
|
||||
//if (x > xx)
|
||||
// activateCellInset(bv, cell, x - xx, y - cursory_);
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetTabular::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetTabular::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
lyxerr << "# InsetTabular::dispatch: " << cmd
|
||||
<< " tablemode: " << tablemode << endl;
|
||||
@ -491,53 +490,51 @@ InsetTabular::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
lfunMousePress(bv, cmd);
|
||||
lfunMousePress(cur, cmd);
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case LFUN_MOUSE_MOTION:
|
||||
lfunMouseMotion(bv, cmd);
|
||||
lfunMouseMotion(cur, cmd);
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
lfunMouseRelease(bv, cmd);
|
||||
lfunMouseRelease(cur, cmd);
|
||||
return DispatchResult(true, true);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
CursorSlice & cur = bv.cursor();
|
||||
|
||||
if (!tablemode) {
|
||||
|
||||
int cell = cur.idx_;
|
||||
int cell = cur.idx();
|
||||
lyxerr << "# InsetTabular::dispatch: A " << cur << endl;
|
||||
result = tabular.getCellInset(cell).dispatch(bv, cmd);
|
||||
result = tabular.getCellInset(cell).dispatch(cur, cmd);
|
||||
|
||||
switch (result.val()) {
|
||||
case FINISHED:
|
||||
if (movePrevCell(bv, cur))
|
||||
if (movePrevCell(cur))
|
||||
result = DispatchResult(true, true);
|
||||
else
|
||||
result = DispatchResult(false, FINISHED);
|
||||
break;
|
||||
|
||||
case FINISHED_RIGHT:
|
||||
if (moveNextCell(bv, cur))
|
||||
if (moveNextCell(cur))
|
||||
result = DispatchResult(true, true);
|
||||
else
|
||||
result = DispatchResult(false, FINISHED_RIGHT);
|
||||
break;
|
||||
|
||||
case FINISHED_UP:
|
||||
if (moveUpLock(bv, cur))
|
||||
if (moveUpLock(cur))
|
||||
result = DispatchResult(true, true);
|
||||
else
|
||||
result = DispatchResult(false, FINISHED_UP);
|
||||
break;
|
||||
|
||||
case FINISHED_DOWN:
|
||||
if (moveDownLock(bv, cur))
|
||||
if (moveDownLock(cur))
|
||||
result = DispatchResult(true, true);
|
||||
else
|
||||
result = DispatchResult(false, FINISHED_UP);
|
||||
@ -557,79 +554,80 @@ InsetTabular::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
case LFUN_CELL_BACKWARD:
|
||||
case LFUN_CELL_FORWARD:
|
||||
if (cmd.action == LFUN_CELL_FORWARD)
|
||||
moveNextCell(bv, cur);
|
||||
moveNextCell(cur);
|
||||
else
|
||||
movePrevCell(bv, cur);
|
||||
movePrevCell(cur);
|
||||
clearSelection();
|
||||
return result;
|
||||
|
||||
case LFUN_SCROLL_INSET:
|
||||
if (!cmd.argument.empty()) {
|
||||
if (cmd.argument.find('.') != cmd.argument.npos)
|
||||
scroll(bv, static_cast<float>(strToDbl(cmd.argument)));
|
||||
scroll(cur.bv(), static_cast<float>(strToDbl(cmd.argument)));
|
||||
else
|
||||
scroll(bv, strToInt(cmd.argument));
|
||||
bv.update();
|
||||
scroll(cur.bv(), strToInt(cmd.argument));
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
case LFUN_RIGHTSEL: {
|
||||
int const start = hasSelection() ? sel_cell_start : cur.idx_;
|
||||
if (tabular.isLastCellInRow(cur.idx_)) {
|
||||
setSelection(start, cur.idx_);
|
||||
int const start = hasSelection() ? sel_cell_start : cur.idx();
|
||||
if (tabular.isLastCellInRow(cur.idx())) {
|
||||
setSelection(start, cur.idx());
|
||||
break;
|
||||
}
|
||||
|
||||
int end = cur.idx_;
|
||||
int end = cur.idx();
|
||||
// if we are starting a selection, only select
|
||||
// the current cell at the beginning
|
||||
if (hasSelection()) {
|
||||
moveRight(bv, cur);
|
||||
end = cur.idx_;
|
||||
moveRight(cur);
|
||||
end = cur.idx();
|
||||
}
|
||||
setSelection(start, end);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_RIGHT:
|
||||
if (!moveRightLock(bv, cur))
|
||||
if (!moveRightLock(cur))
|
||||
result = DispatchResult(false, FINISHED_RIGHT);
|
||||
clearSelection();
|
||||
break;
|
||||
|
||||
case LFUN_LEFTSEL: {
|
||||
int const start = hasSelection() ? sel_cell_start : cur.idx_;
|
||||
if (tabular.isFirstCellInRow(cur.idx_)) {
|
||||
setSelection(start, cur.idx_);
|
||||
int const start = hasSelection() ? sel_cell_start : cur.idx();
|
||||
if (tabular.isFirstCellInRow(cur.idx())) {
|
||||
setSelection(start, cur.idx());
|
||||
break;
|
||||
}
|
||||
|
||||
int end = cur.idx_;
|
||||
int end = cur.idx();
|
||||
// if we are starting a selection, only select
|
||||
// the current cell at the beginning
|
||||
if (hasSelection()) {
|
||||
moveLeft(bv, cur);
|
||||
end = cur.idx_;
|
||||
moveLeft(cur);
|
||||
end = cur.idx();
|
||||
}
|
||||
setSelection(start, end);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_LEFT:
|
||||
if (!moveLeftLock(bv, cur))
|
||||
if (!moveLeftLock(cur))
|
||||
result = DispatchResult(false, FINISHED);
|
||||
clearSelection();
|
||||
break;
|
||||
|
||||
case LFUN_DOWNSEL: {
|
||||
int const start = hasSelection() ? sel_cell_start : cur.idx_;
|
||||
int const ocell = cur.idx_;
|
||||
int const start = hasSelection() ? sel_cell_start : cur.idx();
|
||||
int const ocell = cur.idx();
|
||||
// if we are starting a selection, only select
|
||||
// the current cell at the beginning
|
||||
if (hasSelection()) {
|
||||
moveDown(bv, cur);
|
||||
moveDown(cur);
|
||||
if (ocell == sel_cell_end ||
|
||||
tabular.column_of_cell(ocell) > tabular.column_of_cell(cur.idx_))
|
||||
tabular.column_of_cell(ocell) >
|
||||
tabular.column_of_cell(cur.idx()))
|
||||
setSelection(start, tabular.getCellBelow(sel_cell_end));
|
||||
else
|
||||
setSelection(start, tabular.getLastCellBelow(sel_cell_end));
|
||||
@ -640,20 +638,21 @@ InsetTabular::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
case LFUN_DOWN:
|
||||
if (!moveDown(bv, cur))
|
||||
if (!moveDown(cur))
|
||||
result = DispatchResult(false, FINISHED_DOWN);
|
||||
clearSelection();
|
||||
break;
|
||||
|
||||
case LFUN_UPSEL: {
|
||||
int const start = hasSelection() ? sel_cell_start : cur.idx_;
|
||||
int const ocell = cur.idx_;
|
||||
int const start = hasSelection() ? sel_cell_start : cur.idx();
|
||||
int const ocell = cur.idx();
|
||||
// if we are starting a selection, only select
|
||||
// the current cell at the beginning
|
||||
if (hasSelection()) {
|
||||
moveUp(bv, cur);
|
||||
moveUp(cur);
|
||||
if (ocell == sel_cell_end ||
|
||||
tabular.column_of_cell(ocell) > tabular.column_of_cell(cur.idx_))
|
||||
tabular.column_of_cell(ocell) >
|
||||
tabular.column_of_cell(cur.idx()))
|
||||
setSelection(start, tabular.getCellAbove(sel_cell_end));
|
||||
else
|
||||
setSelection(start, tabular.getLastCellAbove(sel_cell_end));
|
||||
@ -664,7 +663,7 @@ InsetTabular::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
case LFUN_UP:
|
||||
if (!moveUp(bv, cur))
|
||||
if (!moveUp(cur))
|
||||
result = DispatchResult(false, FINISHED_DOWN);
|
||||
clearSelection();
|
||||
break;
|
||||
@ -672,29 +671,29 @@ InsetTabular::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
case LFUN_NEXT: {
|
||||
if (hasSelection())
|
||||
clearSelection();
|
||||
int actcell = bv.cursor().idx();
|
||||
int actcell = cur.idx();
|
||||
int actcol = tabular.column_of_cell(actcell);
|
||||
int column = actcol;
|
||||
if (bv.top_y() + bv.painter().paperHeight()
|
||||
if (cur.bv().top_y() + cur.bv().painter().paperHeight()
|
||||
< yo_ + tabular.getHeightOfTabular())
|
||||
{
|
||||
bv.scrollDocView(bv.top_y() + bv.painter().paperHeight());
|
||||
cur.bv().scrollDocView(
|
||||
cur.bv().top_y() + cur.bv().painter().paperHeight());
|
||||
cur.idx() = tabular.getCellBelow(first_visible_cell) + column;
|
||||
} else {
|
||||
cur.idx() = tabular.getFirstCellInRow(tabular.rows() - 1) + column;
|
||||
}
|
||||
resetPos(bv);
|
||||
resetPos(cur);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_PRIOR: {
|
||||
if (hasSelection())
|
||||
clearSelection();
|
||||
int actcell = bv.cursor().idx();
|
||||
int actcol = tabular.column_of_cell(actcell);
|
||||
int column = actcol;
|
||||
int column = tabular.column_of_cell(cur.idx());
|
||||
if (yo_ < 0) {
|
||||
bv.scrollDocView(bv.top_y() - bv.painter().paperHeight());
|
||||
cur.bv().scrollDocView(
|
||||
cur.bv().top_y() - cur.bv().painter().paperHeight());
|
||||
if (yo_ > 0)
|
||||
cur.idx() = column;
|
||||
else
|
||||
@ -702,7 +701,7 @@ InsetTabular::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
} else {
|
||||
cur.idx() = column;
|
||||
}
|
||||
resetPos(bv);
|
||||
resetPos(cur);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -732,23 +731,23 @@ InsetTabular::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_LAYOUT_TABULAR:
|
||||
InsetTabularMailer(*this).showDialog(&bv);
|
||||
InsetTabularMailer(*this).showDialog(&cur.bv());
|
||||
break;
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetTabularMailer(*this).updateDialog(&bv);
|
||||
InsetTabularMailer(*this).updateDialog(&cur.bv());
|
||||
break;
|
||||
|
||||
case LFUN_TABULAR_FEATURE:
|
||||
if (!tabularFeatures(bv, cmd.argument))
|
||||
if (!tabularFeatures(cur, cmd.argument))
|
||||
result = DispatchResult(false);
|
||||
break;
|
||||
|
||||
// insert file functions
|
||||
case LFUN_FILE_INSERT_ASCII_PARA:
|
||||
case LFUN_FILE_INSERT_ASCII: {
|
||||
string tmpstr = getContentsOfAsciiFile(&bv, cmd.argument, false);
|
||||
if (!tmpstr.empty() && !insertAsciiString(bv, tmpstr, false))
|
||||
string tmpstr = getContentsOfAsciiFile(&cur.bv(), cmd.argument, false);
|
||||
if (!tmpstr.empty() && !insertAsciiString(cur.bv(), tmpstr, false))
|
||||
result = DispatchResult(false);
|
||||
break;
|
||||
}
|
||||
@ -767,26 +766,26 @@ InsetTabular::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_CUT:
|
||||
if (copySelection(bv)) {
|
||||
recordUndo(bv, Undo::DELETE);
|
||||
cutSelection(bv.buffer()->params());
|
||||
if (copySelection(cur.bv())) {
|
||||
recordUndo(cur, Undo::DELETE);
|
||||
cutSelection(cur.bv().buffer()->params());
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_DELETE:
|
||||
recordUndo(bv, Undo::DELETE);
|
||||
cutSelection(bv.buffer()->params());
|
||||
recordUndo(cur, Undo::DELETE);
|
||||
cutSelection(cur.bv().buffer()->params());
|
||||
break;
|
||||
|
||||
case LFUN_COPY:
|
||||
if (!hasSelection())
|
||||
break;
|
||||
finishUndo();
|
||||
copySelection(bv);
|
||||
copySelection(cur.bv());
|
||||
break;
|
||||
|
||||
case LFUN_PASTESELECTION: {
|
||||
string const clip = bv.getClipboard();
|
||||
string const clip = cur.bv().getClipboard();
|
||||
if (clip.empty())
|
||||
break;
|
||||
if (clip.find('\t') != string::npos) {
|
||||
@ -814,7 +813,7 @@ InsetTabular::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
maxCols = max(cols, maxCols);
|
||||
|
||||
paste_tabular.reset(
|
||||
new LyXTabular(bv.buffer()->params(), rows, maxCols));
|
||||
new LyXTabular(cur.bv().buffer()->params(), rows, maxCols));
|
||||
|
||||
string::size_type op = 0;
|
||||
int cell = 0;
|
||||
@ -848,7 +847,7 @@ InsetTabular::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
if (cell < cells && op < len)
|
||||
paste_tabular->getCellInset(cell).
|
||||
setText(clip.substr(op, len-op), font);
|
||||
} else if (!insertAsciiString(bv, clip, true))
|
||||
} else if (!insertAsciiString(cur.bv(), clip, true))
|
||||
{
|
||||
// so that the clipboard is used and it goes on
|
||||
// to default
|
||||
@ -860,8 +859,8 @@ InsetTabular::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
|
||||
case LFUN_PASTE:
|
||||
if (hasPasteBuffer()) {
|
||||
recordUndo(bv, Undo::INSERT);
|
||||
pasteSelection(bv);
|
||||
recordUndo(cur, Undo::INSERT);
|
||||
pasteSelection(cur.bv());
|
||||
break;
|
||||
}
|
||||
// fall through
|
||||
@ -877,8 +876,8 @@ InsetTabular::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
break;
|
||||
}
|
||||
|
||||
updateLocal(bv);
|
||||
InsetTabularMailer(*this).updateDialog(&bv);
|
||||
updateLocal(cur);
|
||||
InsetTabularMailer(*this).updateDialog(&cur.bv());
|
||||
}
|
||||
|
||||
if (cmd.action == LFUN_INSET_TOGGLE) {
|
||||
@ -1013,7 +1012,7 @@ void InsetTabular::setPos(BufferView & bv, int x, int y) const
|
||||
|
||||
cursorx_ = lx - tabular.getWidthOfColumn(actcell) + xo_ + 2;
|
||||
#endif
|
||||
resetPos(bv);
|
||||
resetPos(bv.cursor());
|
||||
}
|
||||
|
||||
|
||||
@ -1031,7 +1030,7 @@ int InsetTabular::getCellXPos(int cell) const
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::resetPos(BufferView &) const
|
||||
void InsetTabular::resetPos(LCursor &) const
|
||||
{
|
||||
#if 0
|
||||
#ifdef WITH_WARNINGS
|
||||
@ -1041,8 +1040,9 @@ void InsetTabular::resetPos(BufferView &) const
|
||||
if (in_reset_pos > 0)
|
||||
return;
|
||||
|
||||
BufferView & bv = cur.bv();
|
||||
int cell = 0;
|
||||
int actcell = bv->cursor().cell();
|
||||
int actcell = cur.cell();
|
||||
int actcol = tabular.column_of_cell(actcell);
|
||||
int actrow = 0;
|
||||
cursory_ = 0;
|
||||
@ -1066,19 +1066,19 @@ void InsetTabular::resetPos(BufferView &) const
|
||||
tabular.getWidthOfTabular() < bv->workWidth()-20)
|
||||
{
|
||||
scroll(bv, 0.0F);
|
||||
updateLocal(bv);
|
||||
updateLocal(cur);
|
||||
} else if (cursorx_ - offset > 20 &&
|
||||
cursorx_ - offset + tabular.getWidthOfColumn(actcell)
|
||||
> bv.workWidth() - 20) {
|
||||
scroll(&bv, - tabular.getWidthOfColumn(actcell) - 20);
|
||||
updateLocal(bv);
|
||||
updateLocal(cur);
|
||||
} else if (cursorx_ - offset < 20) {
|
||||
scroll(&bv, 20 - cursorx_ + offset);
|
||||
updateLocal(bv);
|
||||
updateLocal(cur);
|
||||
} else if (scroll() && xo_ > 20 &&
|
||||
xo_ + tabular.getWidthOfTabular() > bv->workWidth() - 20) {
|
||||
scroll(&bv, old_x - cursorx_);
|
||||
updateLocal(bv);
|
||||
updateLocal(cur);
|
||||
}
|
||||
InsetTabularMailer(*this).updateDialog(bv);
|
||||
in_reset_pos = 0;
|
||||
@ -1086,147 +1086,143 @@ void InsetTabular::resetPos(BufferView &) const
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveRight(BufferView & bv, CursorSlice & cur)
|
||||
bool InsetTabular::moveRight(LCursor & cur)
|
||||
{
|
||||
bool moved = isRightToLeft(bv)
|
||||
? movePrevCell(bv, cur) : moveNextCell(bv, cur);
|
||||
bool moved = isRightToLeft(cur) ? movePrevCell(cur) : moveNextCell(cur);
|
||||
if (!moved)
|
||||
return false;
|
||||
resetPos(bv);
|
||||
resetPos(cur);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveRightLock(BufferView & bv, CursorSlice & cur)
|
||||
bool InsetTabular::moveRightLock(LCursor & cur)
|
||||
{
|
||||
bool moved = isRightToLeft(bv)
|
||||
? movePrevCell(bv, cur) : moveNextCell(bv, cur);
|
||||
bool moved = isRightToLeft(cur) ? movePrevCell(cur) : moveNextCell(cur);
|
||||
if (!moved)
|
||||
return false;
|
||||
activateCellInset(bv, cur.idx_, false);
|
||||
activateCellInset(cur, cur.idx(), false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveLeft(BufferView & bv, CursorSlice & cur)
|
||||
bool InsetTabular::moveLeft(LCursor & cur)
|
||||
{
|
||||
bool moved = isRightToLeft(bv)
|
||||
? moveNextCell(bv, cur) : movePrevCell(bv, cur);
|
||||
bool moved = isRightToLeft(cur) ? moveNextCell(cur) : movePrevCell(cur);
|
||||
if (!moved)
|
||||
return false;
|
||||
resetPos(bv);
|
||||
resetPos(cur);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveLeftLock(BufferView & bv, CursorSlice & cur)
|
||||
bool InsetTabular::moveLeftLock(LCursor & cur)
|
||||
{
|
||||
bool moved = isRightToLeft(bv)
|
||||
? moveNextCell(bv, cur) : movePrevCell(bv, cur);
|
||||
bool moved = isRightToLeft(cur) ? moveNextCell(cur) : movePrevCell(cur);
|
||||
if (!moved)
|
||||
return false;
|
||||
activateCellInset(bv, cur.idx_, true);
|
||||
activateCellInset(cur, cur.idx(), true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveUp(BufferView & bv, CursorSlice & cur)
|
||||
bool InsetTabular::moveUp(LCursor & cur)
|
||||
{
|
||||
if (tabular.row_of_cell(cur.idx_) == 0)
|
||||
if (tabular.row_of_cell(cur.idx()) == 0)
|
||||
return false;
|
||||
cur.idx_ = tabular.getCellAbove(cur.idx_);
|
||||
resetPos(bv);
|
||||
cur.idx() = tabular.getCellAbove(cur.idx());
|
||||
resetPos(cur);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveUpLock(BufferView & bv, CursorSlice & cur)
|
||||
bool InsetTabular::moveUpLock(LCursor & cur)
|
||||
{
|
||||
if (tabular.row_of_cell(cur.idx_) == 0)
|
||||
if (tabular.row_of_cell(cur.idx()) == 0)
|
||||
return false;
|
||||
cur.idx_ = tabular.getCellAbove(cur.idx_);
|
||||
resetPos(bv);
|
||||
activateCellInset(bv, cur.idx_, bv.x_target(), 0);
|
||||
cur.idx() = tabular.getCellAbove(cur.idx());
|
||||
resetPos(cur);
|
||||
activateCellInset(cur, cur.idx(), cur.x_target(), 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveDown(BufferView & bv, CursorSlice & cur)
|
||||
bool InsetTabular::moveDown(LCursor & cur)
|
||||
{
|
||||
if (tabular.row_of_cell(cur.idx_) == tabular.rows() - 1)
|
||||
if (tabular.row_of_cell(cur.idx()) == tabular.rows() - 1)
|
||||
return false;
|
||||
cur.idx_ = tabular.getCellBelow(cur.idx_);
|
||||
resetPos(bv);
|
||||
cur.idx() = tabular.getCellBelow(cur.idx());
|
||||
resetPos(cur);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveDownLock(BufferView & bv, CursorSlice & cur)
|
||||
bool InsetTabular::moveDownLock(LCursor & cur)
|
||||
{
|
||||
if (tabular.row_of_cell(cur.idx_) == tabular.rows() - 1)
|
||||
if (tabular.row_of_cell(cur.idx()) == tabular.rows() - 1)
|
||||
return false;
|
||||
cur.idx_ = tabular.getCellBelow(cur.idx_);
|
||||
resetPos(bv);
|
||||
activateCellInset(bv, cur.idx_, bv.x_target());
|
||||
cur.idx() = tabular.getCellBelow(cur.idx());
|
||||
resetPos(cur);
|
||||
activateCellInset(cur, cur.idx(), cur.x_target());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveNextCell(BufferView & bv, CursorSlice & cur)
|
||||
bool InsetTabular::moveNextCell(LCursor & cur)
|
||||
{
|
||||
lyxerr << "InsetTabular::moveNextCell 1 cur: " << cur << endl;
|
||||
if (isRightToLeft(bv)) {
|
||||
if (tabular.isFirstCellInRow(cur.idx_)) {
|
||||
int row = tabular.row_of_cell(cur.idx_);
|
||||
if (isRightToLeft(cur)) {
|
||||
if (tabular.isFirstCellInRow(cur.idx())) {
|
||||
int row = tabular.row_of_cell(cur.idx());
|
||||
if (row == tabular.rows() - 1)
|
||||
return false;
|
||||
cur.idx_ = tabular.getLastCellInRow(row);
|
||||
cur.idx_ = tabular.getCellBelow(cur.idx_);
|
||||
cur.idx() = tabular.getLastCellInRow(row);
|
||||
cur.idx() = tabular.getCellBelow(cur.idx());
|
||||
} else {
|
||||
if (cur.idx_ == 0)
|
||||
if (cur.idx() == 0)
|
||||
return false;
|
||||
--cur.idx_;
|
||||
--cur.idx();
|
||||
}
|
||||
} else {
|
||||
if (tabular.isLastCell(cur.idx_))
|
||||
if (tabular.isLastCell(cur.idx()))
|
||||
return false;
|
||||
++cur.idx_;
|
||||
++cur.idx();
|
||||
}
|
||||
cur.par_ = 0;
|
||||
cur.pos_ = 0;
|
||||
cur.par() = 0;
|
||||
cur.pos() = 0;
|
||||
lyxerr << "InsetTabular::moveNextCell 2 cur: " << cur << endl;
|
||||
resetPos(bv);
|
||||
resetPos(cur);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::movePrevCell(BufferView & bv, CursorSlice & cur)
|
||||
bool InsetTabular::movePrevCell(LCursor & cur)
|
||||
{
|
||||
if (isRightToLeft(bv)) {
|
||||
if (tabular.isLastCellInRow(cur.idx_)) {
|
||||
int row = tabular.row_of_cell(cur.idx_);
|
||||
if (isRightToLeft(cur)) {
|
||||
if (tabular.isLastCellInRow(cur.idx())) {
|
||||
int row = tabular.row_of_cell(cur.idx());
|
||||
if (row == 0)
|
||||
return false;
|
||||
cur.idx_ = tabular.getFirstCellInRow(row);
|
||||
cur.idx_ = tabular.getCellAbove(cur.idx_);
|
||||
cur.idx() = tabular.getFirstCellInRow(row);
|
||||
cur.idx() = tabular.getCellAbove(cur.idx());
|
||||
} else {
|
||||
if (tabular.isLastCell(cur.idx_))
|
||||
if (tabular.isLastCell(cur.idx()))
|
||||
return false;
|
||||
++cur.idx_;
|
||||
++cur.idx();
|
||||
}
|
||||
} else {
|
||||
if (cur.idx_ == 0) // first cell
|
||||
if (cur.idx() == 0) // first cell
|
||||
return false;
|
||||
--cur.idx_;
|
||||
--cur.idx();
|
||||
}
|
||||
cur.par_ = 0;
|
||||
cur.pos_ = 0;
|
||||
resetPos(bv);
|
||||
cur.par() = 0;
|
||||
cur.pos() = 0;
|
||||
resetPos(cur);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::tabularFeatures(BufferView & bv, string const & what)
|
||||
bool InsetTabular::tabularFeatures(LCursor & cur, std::string const & what)
|
||||
{
|
||||
LyXTabular::Feature action = LyXTabular::LAST_ACTION;
|
||||
|
||||
@ -1246,7 +1242,7 @@ bool InsetTabular::tabularFeatures(BufferView & bv, string const & what)
|
||||
|
||||
string const val =
|
||||
ltrim(what.substr(tabularFeature[i].feature.length()));
|
||||
tabularFeatures(bv, action, val);
|
||||
tabularFeatures(cur, action, val);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1274,10 +1270,11 @@ void checkLongtableSpecial(LyXTabular::ltType & ltt,
|
||||
} // anon namespace
|
||||
|
||||
|
||||
void InsetTabular::tabularFeatures(BufferView & bv,
|
||||
void InsetTabular::tabularFeatures(LCursor & cur,
|
||||
LyXTabular::Feature feature, string const & value)
|
||||
{
|
||||
int actcell = bv.cursor().idx();
|
||||
BufferView & bv = cur.bv();
|
||||
int actcell = cur.idx();
|
||||
int sel_col_start;
|
||||
int sel_col_end;
|
||||
int sel_row_start;
|
||||
@ -1332,7 +1329,7 @@ void InsetTabular::tabularFeatures(BufferView & bv,
|
||||
sel_col_start = sel_col_end = tabular.column_of_cell(actcell);
|
||||
sel_row_start = sel_row_end = tabular.row_of_cell(actcell);
|
||||
}
|
||||
recordUndo(bv, Undo::ATOMIC);
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
|
||||
int row = tabular.row_of_cell(actcell);
|
||||
int column = tabular.column_of_cell(actcell);
|
||||
@ -1346,10 +1343,10 @@ void InsetTabular::tabularFeatures(BufferView & bv,
|
||||
tabular.setColumnPWidth(actcell, len);
|
||||
if (len.zero()
|
||||
&& tabular.getAlignment(actcell, true) == LYX_ALIGN_BLOCK)
|
||||
tabularFeatures(bv, LyXTabular::ALIGN_CENTER, string());
|
||||
tabularFeatures(cur, LyXTabular::ALIGN_CENTER, string());
|
||||
else if (!len.zero()
|
||||
&& tabular.getAlignment(actcell, true) != LYX_ALIGN_BLOCK)
|
||||
tabularFeatures(bv, LyXTabular::ALIGN_BLOCK, string());
|
||||
tabularFeatures(cur, LyXTabular::ALIGN_BLOCK, string());
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1600,24 +1597,24 @@ void InsetTabular::tabularFeatures(BufferView & bv,
|
||||
break;
|
||||
}
|
||||
|
||||
updateLocal(bv);
|
||||
updateLocal(cur);
|
||||
InsetTabularMailer(*this).updateDialog(&bv);
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::activateCellInset(BufferView & bv, int cell, int x, int y)
|
||||
void InsetTabular::activateCellInset(LCursor & cur, int cell, int x, int y)
|
||||
{
|
||||
tabular.getCellInset(cell).edit(&bv, x, y);
|
||||
bv.cursor().idx(cell);
|
||||
updateLocal(bv);
|
||||
tabular.getCellInset(cell).edit(cur, x, y);
|
||||
cur.idx() = cell;
|
||||
updateLocal(cur);
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::activateCellInset(BufferView & bv, int cell, bool behind)
|
||||
void InsetTabular::activateCellInset(LCursor & cur, int cell, bool behind)
|
||||
{
|
||||
tabular.getCellInset(cell).edit(&bv, behind);
|
||||
bv.cursor().idx(cell);
|
||||
updateLocal(bv);
|
||||
tabular.getCellInset(cell).edit(cur, behind);
|
||||
cur.idx() = cell;
|
||||
updateLocal(cur);
|
||||
}
|
||||
|
||||
|
||||
@ -1941,9 +1938,9 @@ bool InsetTabular::cutSelection(BufferParams const & bp)
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::isRightToLeft(BufferView & bv)
|
||||
bool InsetTabular::isRightToLeft(LCursor & cur)
|
||||
{
|
||||
return bv.getParentLanguage(this)->RightToLeft();
|
||||
return cur.bv().getParentLanguage(this)->RightToLeft();
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
///
|
||||
std::string const editMessage() const;
|
||||
///
|
||||
void updateLocal(BufferView & bv) const;
|
||||
void updateLocal(LCursor & cur) const;
|
||||
///
|
||||
bool insetAllowed(InsetOld::Code) const { return true; }
|
||||
///
|
||||
@ -112,9 +112,9 @@ public:
|
||||
/// get the absolute screen x,y of the cursor
|
||||
void getCursorPos(int cell, int & x, int & y) const;
|
||||
///
|
||||
bool tabularFeatures(BufferView & bv, std::string const & what);
|
||||
bool tabularFeatures(LCursor & cur, std::string const & what);
|
||||
///
|
||||
void tabularFeatures(BufferView & bv, LyXTabular::Feature feature,
|
||||
void tabularFeatures(LCursor & cur, LyXTabular::Feature feature,
|
||||
std::string const & val = std::string());
|
||||
///
|
||||
void openLayoutDialog(BufferView *) const;
|
||||
@ -147,9 +147,9 @@ public:
|
||||
/// set the owning buffer
|
||||
void buffer(Buffer * buf);
|
||||
/// lock cell with given index
|
||||
void edit(BufferView * bv, bool);
|
||||
void edit(LCursor & cur, bool);
|
||||
///
|
||||
void edit(BufferView * bv, int, int);
|
||||
void edit(LCursor & cur, int, int);
|
||||
/// can we go further down on mouse click?
|
||||
bool descendable() const { return true; }
|
||||
|
||||
@ -162,14 +162,14 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
///
|
||||
void lfunMousePress(BufferView & bv, FuncRequest const & cmd);
|
||||
void lfunMousePress(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
void lfunMouseRelease(BufferView & bv, FuncRequest const & cmd);
|
||||
void lfunMouseRelease(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
void lfunMouseMotion(BufferView & bv, FuncRequest const & cmd);
|
||||
void lfunMouseMotion(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
void calculate_dimensions_of_cells(MetricsInfo & mi) const;
|
||||
///
|
||||
@ -181,33 +181,33 @@ private:
|
||||
///
|
||||
void setPos(BufferView &, int x, int y) const;
|
||||
///
|
||||
bool moveRight(BufferView &, CursorSlice & cur);
|
||||
bool moveRight(LCursor & cur);
|
||||
///
|
||||
bool moveLeft(BufferView &, CursorSlice & cur);
|
||||
bool moveLeft(LCursor & cur);
|
||||
///
|
||||
bool moveUp(BufferView &, CursorSlice & cur);
|
||||
bool moveUp(LCursor & cur);
|
||||
///
|
||||
bool moveDown(BufferView &, CursorSlice & cur);
|
||||
bool moveDown(LCursor & cur);
|
||||
|
||||
///
|
||||
bool moveRightLock(BufferView &, CursorSlice & cur);
|
||||
bool moveRightLock(LCursor & cur);
|
||||
///
|
||||
bool moveLeftLock(BufferView &, CursorSlice & cur);
|
||||
bool moveLeftLock(LCursor & cur);
|
||||
///
|
||||
bool moveUpLock(BufferView &, CursorSlice & cur);
|
||||
bool moveUpLock(LCursor & cur);
|
||||
///
|
||||
bool moveDownLock(BufferView &, CursorSlice & cur);
|
||||
bool moveDownLock(LCursor & cur);
|
||||
|
||||
///
|
||||
bool moveNextCell(BufferView &, CursorSlice & cur);
|
||||
bool moveNextCell(LCursor & cur);
|
||||
///
|
||||
bool movePrevCell(BufferView &, CursorSlice & cur);
|
||||
bool movePrevCell(LCursor & cur);
|
||||
|
||||
|
||||
///
|
||||
int getCellXPos(int cell) const;
|
||||
///
|
||||
void resetPos(BufferView &) const;
|
||||
void resetPos(LCursor & cur) const;
|
||||
///
|
||||
void removeTabularRow();
|
||||
///
|
||||
@ -215,9 +215,9 @@ private:
|
||||
///
|
||||
void setSelection(int start, int end) const;
|
||||
///
|
||||
void activateCellInset(BufferView &, int cell, int x, int y);
|
||||
void activateCellInset(LCursor &, int cell, int x, int y);
|
||||
///
|
||||
void activateCellInset(BufferView &, int cell, bool behind);
|
||||
void activateCellInset(LCursor &, int cell, bool behind);
|
||||
///
|
||||
bool hasPasteBuffer() const;
|
||||
///
|
||||
@ -227,7 +227,7 @@ private:
|
||||
///
|
||||
bool cutSelection(BufferParams const & bp);
|
||||
///
|
||||
bool isRightToLeft(BufferView &);
|
||||
bool isRightToLeft(LCursor & cur);
|
||||
///
|
||||
void getSelection(int cell,
|
||||
int & scol, int & ecol, int & srow, int & erow) const;
|
||||
|
@ -227,23 +227,37 @@ void InsetText::drawFrame(Painter & pain, int x) const
|
||||
}
|
||||
|
||||
|
||||
void InsetText::updateLocal(BufferView * bv)
|
||||
void InsetText::updateLocal(LCursor & cur)
|
||||
{
|
||||
if (!bv)
|
||||
return;
|
||||
if (!autoBreakRows_ && paragraphs().size() > 1) {
|
||||
// collapseParagraphs
|
||||
while (paragraphs().size() > 1) {
|
||||
ParagraphList::iterator const first = paragraphs().begin();
|
||||
ParagraphList::iterator second = first;
|
||||
++second;
|
||||
size_t const first_par_size = first->size();
|
||||
|
||||
if (!autoBreakRows_ && paragraphs().size() > 1)
|
||||
collapseParagraphs(bv);
|
||||
if (!first->empty() &&
|
||||
!second->empty() &&
|
||||
!first->isSeparator(first_par_size - 1)) {
|
||||
first->insertChar(first_par_size, ' ');
|
||||
}
|
||||
|
||||
if (!bv->selection().set())
|
||||
bv->resetAnchor();
|
||||
cur.clearSelection();
|
||||
mergeParagraph(cur.bv().buffer()->params(), paragraphs(), first);
|
||||
}
|
||||
}
|
||||
|
||||
bv->owner()->view_state_changed();
|
||||
bv->owner()->updateMenubar();
|
||||
bv->owner()->updateToolbar();
|
||||
if (old_par != bv->cursor().par()) {
|
||||
bv->owner()->setLayout(text_.cursorPar()->layout()->name());
|
||||
old_par = bv->cursor().par();
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
|
||||
LyXView * lv = cur.bv().owner();
|
||||
lv->view_state_changed();
|
||||
lv->updateMenubar();
|
||||
lv->updateToolbar();
|
||||
if (old_par != cur.par()) {
|
||||
lv->setLayout(text_.cursorPar()->layout()->name());
|
||||
old_par = cur.par();
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,57 +268,56 @@ string const InsetText::editMessage() const
|
||||
}
|
||||
|
||||
|
||||
void InsetText::sanitizeEmptyText(BufferView * bv)
|
||||
void InsetText::sanitizeEmptyText(BufferView & bv)
|
||||
{
|
||||
if (paragraphs().size() == 1
|
||||
&& paragraphs().begin()->empty()
|
||||
&& bv->getParentLanguage(this) != text_.current_font.language()) {
|
||||
&& bv.getParentLanguage(this) != text_.current_font.language()) {
|
||||
LyXFont font(LyXFont::ALL_IGNORE);
|
||||
font.setLanguage(bv->getParentLanguage(this));
|
||||
font.setLanguage(bv.getParentLanguage(this));
|
||||
text_.setFont(font, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extern LCursor theTempCursor;
|
||||
extern CursorBase theTempCursor;
|
||||
|
||||
|
||||
void InsetText::edit(BufferView * bv, bool left)
|
||||
void InsetText::edit(LCursor & cur, bool left)
|
||||
{
|
||||
lyxerr << "InsetText: edit left/right" << endl;
|
||||
old_par = -1;
|
||||
setViewCache(bv);
|
||||
setViewCache(&cur.bv());
|
||||
int const par = left ? 0 : paragraphs().size() - 1;
|
||||
int const pos = left ? 0 : paragraphs().back().size();
|
||||
text_.setCursor(par, pos);
|
||||
bv->clearSelection();
|
||||
cur.clearSelection();
|
||||
finishUndo();
|
||||
sanitizeEmptyText(bv);
|
||||
updateLocal(bv);
|
||||
bv->updateParagraphDialog();
|
||||
sanitizeEmptyText(cur.bv());
|
||||
updateLocal(cur);
|
||||
cur.bv().updateParagraphDialog();
|
||||
}
|
||||
|
||||
|
||||
void InsetText::edit(BufferView * bv, int x, int y)
|
||||
void InsetText::edit(LCursor & cur, int x, int y)
|
||||
{
|
||||
lyxerr << "InsetText::edit xy" << endl;
|
||||
old_par = -1;
|
||||
text_.setCursorFromCoordinates(x - text_.xo_, y + bv->top_y() - text_.yo_);
|
||||
bv->clearSelection();
|
||||
text_.setCursorFromCoordinates(x - text_.xo_, y + cur.bv().top_y() - text_.yo_);
|
||||
cur.clearSelection();
|
||||
finishUndo();
|
||||
sanitizeEmptyText(bv);
|
||||
updateLocal(bv);
|
||||
bv->updateParagraphDialog();
|
||||
sanitizeEmptyText(cur.bv());
|
||||
updateLocal(cur);
|
||||
cur.bv().updateParagraphDialog();
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetText::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
DispatchResult InsetText::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
//lyxerr << "InsetText::priv_dispatch (begin), act: "
|
||||
// << cmd.action << " " << endl;
|
||||
|
||||
setViewCache(&bv);
|
||||
setViewCache(&cur.bv());
|
||||
|
||||
DispatchResult result;
|
||||
result.dispatched(true);
|
||||
@ -313,10 +326,13 @@ InsetText::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_PRESS:
|
||||
bv.fullCursor(theTempCursor);
|
||||
// fall through
|
||||
cur.cursor_ = theTempCursor;
|
||||
cur.resetAnchor();
|
||||
result = text_.dispatch(cur, cmd);
|
||||
break;
|
||||
|
||||
default:
|
||||
result = text_.dispatch(bv, cmd);
|
||||
result = text_.dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -326,7 +342,7 @@ InsetText::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
if (!was_empty && paragraphs().begin()->empty() &&
|
||||
paragraphs().size() == 1) {
|
||||
LyXFont font(LyXFont::ALL_IGNORE);
|
||||
font.setLanguage(bv.getParentLanguage(this));
|
||||
font.setLanguage(cur.bv().getParentLanguage(this));
|
||||
text_.setFont(font, false);
|
||||
}
|
||||
|
||||
@ -527,26 +543,6 @@ LyXText * InsetText::getText(int i) const
|
||||
}
|
||||
|
||||
|
||||
void InsetText::collapseParagraphs(BufferView * bv)
|
||||
{
|
||||
while (paragraphs().size() > 1) {
|
||||
ParagraphList::iterator const first = paragraphs().begin();
|
||||
ParagraphList::iterator second = first;
|
||||
++second;
|
||||
size_t const first_par_size = first->size();
|
||||
|
||||
if (!first->empty() &&
|
||||
!second->empty() &&
|
||||
!first->isSeparator(first_par_size - 1)) {
|
||||
first->insertChar(first_par_size, ' ');
|
||||
}
|
||||
|
||||
bv->clearSelection();
|
||||
mergeParagraph(bv->buffer()->params(), paragraphs(), first);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist)
|
||||
{
|
||||
#warning FIXME Check if Changes stuff needs changing here. (Lgb)
|
||||
|
@ -144,9 +144,9 @@ public:
|
||||
void addPreview(lyx::graphics::PreviewLoader &) const;
|
||||
|
||||
///
|
||||
void edit(BufferView *, bool);
|
||||
void edit(LCursor & cur, bool);
|
||||
///
|
||||
void edit(BufferView *, int, int);
|
||||
void edit(LCursor & cur, int, int);
|
||||
|
||||
///
|
||||
int numParagraphs() const { return 1; }
|
||||
@ -155,15 +155,14 @@ public:
|
||||
|
||||
private:
|
||||
///
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
void updateLocal(BufferView *);
|
||||
void updateLocal(LCursor &);
|
||||
///
|
||||
void init();
|
||||
// If the inset is empty set the language of the current font to the
|
||||
// language to the surronding text (if different).
|
||||
void sanitizeEmptyText(BufferView *);
|
||||
void sanitizeEmptyText(BufferView &);
|
||||
///
|
||||
void setCharFont(Buffer const &, int pos, LyXFont const & font);
|
||||
///
|
||||
@ -172,8 +171,6 @@ private:
|
||||
void drawFrame(Painter &, int x) const;
|
||||
///
|
||||
void clearInset(Painter &, int x, int y) const;
|
||||
///
|
||||
void collapseParagraphs(BufferView *);
|
||||
|
||||
/* Private structures and variables */
|
||||
///
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "buffer.h"
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "funcrequest.h"
|
||||
#include "gettext.h"
|
||||
@ -60,7 +61,7 @@ std::auto_ptr<InsetBase> InsetVSpace::clone() const
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetVSpace::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetVSpace::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -70,11 +71,11 @@ InsetVSpace::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
InsetVSpaceMailer(*this).showDialog(&bv);
|
||||
InsetVSpaceMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
|
||||
default:
|
||||
return InsetOld::priv_dispatch(bv, cmd);
|
||||
return InsetOld::priv_dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
|
||||
private:
|
||||
///
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "buffer.h"
|
||||
#include "bufferparams.h"
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "Floating.h"
|
||||
@ -80,7 +81,7 @@ InsetWrap::~InsetWrap()
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetWrap::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetWrap::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_INSET_MODIFY: {
|
||||
@ -90,16 +91,16 @@ InsetWrap::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
params_.placement = params.placement;
|
||||
params_.width = params.width;
|
||||
|
||||
bv.update();
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetWrapMailer(*this).updateDialog(&bv);
|
||||
InsetWrapMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
|
||||
default:
|
||||
return InsetCollapsable::priv_dispatch(bv, cmd);
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
///
|
||||
InsetWrapParams params_;
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "updatableinset.h"
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "funcrequest.h"
|
||||
@ -85,7 +86,7 @@ void UpdatableInset::scroll(BufferView & bv, int offset) const
|
||||
|
||||
/// An updatable inset could handle lyx editing commands
|
||||
DispatchResult
|
||||
UpdatableInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
UpdatableInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
@ -94,10 +95,10 @@ UpdatableInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
case LFUN_SCROLL_INSET:
|
||||
if (!cmd.argument.empty()) {
|
||||
if (cmd.argument.find('.') != cmd.argument.npos)
|
||||
scroll(bv, static_cast<float>(strToDbl(cmd.argument)));
|
||||
scroll(cur.bv(), static_cast<float>(strToDbl(cmd.argument)));
|
||||
else
|
||||
scroll(bv, strToInt(cmd.argument));
|
||||
bv.update();
|
||||
scroll(cur.bv(), strToInt(cmd.argument));
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ protected:
|
||||
/// An updatable inset could handle lyx editing commands
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
/// scrolls to absolute position in bufferview-workwidth * sx units
|
||||
void scroll(BufferView &, float sx) const;
|
||||
/// scrolls offset pixels
|
||||
|
@ -401,7 +401,9 @@ ParIterator::ParIterator(PosIterator const & pos)
|
||||
|
||||
void ParIterator::lockPath(BufferView * bv) const
|
||||
{
|
||||
bv->fullCursor() = LCursor(*bv);
|
||||
LCursor & cur = bv->cursor();
|
||||
cur.cursor_.clear();
|
||||
for (int i = 0, last = size() - 1; i < last; ++i)
|
||||
(*pimpl_->positions[i].it)->inset->edit(bv, true);
|
||||
(*pimpl_->positions[i].it)->inset->edit(cur, true);
|
||||
cur.resetAnchor();
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "buffer.h"
|
||||
#include "bufferlist.h"
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "gettext.h"
|
||||
#include "lastfiles.h"
|
||||
@ -358,7 +359,7 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
|
||||
|
||||
// clear the selection
|
||||
if (bv->text() == bv->getLyXText())
|
||||
bv->clearSelection();
|
||||
bv->cursor().clearSelection();
|
||||
if (asParagraph)
|
||||
bv->getLyXText()->insertStringAsParagraphs(tmpstr);
|
||||
else
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "lyxfind.h"
|
||||
|
||||
#include "buffer.h"
|
||||
#include "cursor_slice.h"
|
||||
#include "cursor.h"
|
||||
#include "BufferView.h"
|
||||
#include "debug.h"
|
||||
#include "iterators.h"
|
||||
@ -391,7 +391,7 @@ int replace(BufferView * bv,
|
||||
|
||||
text->replaceSelectionWithString(replacestr);
|
||||
text->setSelectionRange(replacestr.length());
|
||||
bv->cursor() = fw ? bv->selEnd() : bv->selStart();
|
||||
bv->cursor().current() = fw ? bv->cursor().selEnd() : bv->cursor().selStart();
|
||||
bv->buffer()->markDirty();
|
||||
find(bv, searchstr, cs, mw, fw);
|
||||
bv->update();
|
||||
|
@ -157,7 +157,7 @@ void LyXFunc::handleKeyFunc(kb_action action)
|
||||
// actions
|
||||
keyseq.clear();
|
||||
// copied verbatim from do_accent_char
|
||||
view()->resetAnchor();
|
||||
view()->cursor().resetAnchor();
|
||||
view()->update();
|
||||
}
|
||||
|
||||
@ -320,8 +320,9 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
}
|
||||
}
|
||||
|
||||
UpdatableInset * tli = view()->fullCursor().innerInset();
|
||||
InsetTabular * tab = view()->fullCursor().innerInsetTabular();
|
||||
UpdatableInset * tli = view()->cursor().inset()
|
||||
? view()->cursor().inset()->asUpdatableInset() : 0;
|
||||
InsetTabular * tab = view()->cursor().innerInsetTabular();
|
||||
|
||||
// I would really like to avoid having this switch and rather try to
|
||||
// encode this in the function itself.
|
||||
@ -342,7 +343,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
if (tab && tab->hasSelection())
|
||||
disable = false;
|
||||
else
|
||||
disable = !mathcursor && !view()->selection().set();
|
||||
disable = !inMathed() && !view()->cursor().selection();
|
||||
break;
|
||||
|
||||
case LFUN_RUNCHKTEX:
|
||||
@ -354,7 +355,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
break;
|
||||
|
||||
case LFUN_LAYOUT_TABULAR:
|
||||
disable = !view()->fullCursor().innerInsetTabular();
|
||||
disable = !view()->cursor().innerInsetTabular();
|
||||
break;
|
||||
|
||||
case LFUN_DEPTH_MIN:
|
||||
@ -378,10 +379,10 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
|
||||
case LFUN_TABULAR_FEATURE:
|
||||
#if 0
|
||||
if (mathcursor) {
|
||||
if (inMathed()) {
|
||||
// FIXME: check temporarily disabled
|
||||
// valign code
|
||||
char align = mathcursor->valign();
|
||||
char align = mathcursor::valign();
|
||||
if (align == '\0') {
|
||||
disable = true;
|
||||
break;
|
||||
@ -398,7 +399,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
} else {
|
||||
disable = true;
|
||||
|
||||
char align = mathcursor->halign();
|
||||
char align = mathcursor::halign();
|
||||
if (align == '\0') {
|
||||
disable = true;
|
||||
break;
|
||||
@ -413,7 +414,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
}
|
||||
flag.setOnOff(ev.argument[0] == align);
|
||||
|
||||
disable = !mathcursor->halign();
|
||||
disable = !mathcursor::halign();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -469,7 +470,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
|
||||
case LFUN_INSET_SETTINGS: {
|
||||
disable = true;
|
||||
UpdatableInset * inset = view()->fullCursor().innerInset();
|
||||
UpdatableInset * inset = view()->cursor().inset()
|
||||
? view()->cursor().inset()->asUpdatableInset() : 0;
|
||||
|
||||
if (!inset)
|
||||
break;
|
||||
@ -509,8 +511,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
}
|
||||
|
||||
case LFUN_MATH_MUTATE:
|
||||
if (mathcursor)
|
||||
//flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
|
||||
if (inMathed())
|
||||
//flag.setOnOff(mathcursor::formula()->hullType() == ev.argument);
|
||||
flag.setOnOff(false);
|
||||
else
|
||||
disable = true;
|
||||
@ -523,7 +525,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
case LFUN_MATH_NONUMBER:
|
||||
case LFUN_MATH_NUMBER:
|
||||
case LFUN_MATH_EXTERN:
|
||||
disable = !mathcursor;
|
||||
disable = !inMathed();
|
||||
break;
|
||||
|
||||
case LFUN_DIALOG_SHOW: {
|
||||
@ -541,8 +543,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
disable = !Exporter::IsExportable(*buf, "dvi") ||
|
||||
lyxrc.print_command == "none";
|
||||
} else if (name == "character") {
|
||||
UpdatableInset * tli = view()->fullCursor().innerInset();
|
||||
disable = tli && tli->lyxCode() == InsetOld::ERT_CODE;
|
||||
InsetBase * inset = view()->cursor().inset();
|
||||
disable = inset && inset->lyxCode() == InsetOld::ERT_CODE;
|
||||
} else if (name == "vclog") {
|
||||
disable = !buf->lyxvc().inUse();
|
||||
} else if (name == "latexlog") {
|
||||
@ -682,7 +684,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
break;
|
||||
case LFUN_SPACE_INSERT:
|
||||
// slight hack: we know this is allowed in math mode
|
||||
if (!mathcursor)
|
||||
if (!inMathed())
|
||||
code = InsetOld::SPACE_CODE;
|
||||
break;
|
||||
case LFUN_INSET_DIALOG_SHOW: {
|
||||
@ -734,7 +736,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
|
||||
#ifdef LOCK
|
||||
// the font related toggles
|
||||
if (!mathcursor) {
|
||||
if (!inMathed()) {
|
||||
LyXFont const & font = view()->getLyXText()->real_current_font;
|
||||
switch (ev.action) {
|
||||
case LFUN_EMPH:
|
||||
@ -759,7 +761,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
string tc = mathcursor->getLastCode();
|
||||
string tc = mathcursor::getLastCode();
|
||||
switch (ev.action) {
|
||||
case LFUN_BOLD:
|
||||
flag.setOnOff(tc == "mathbf");
|
||||
@ -864,7 +866,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
|
||||
case LFUN_ESCAPE: {
|
||||
if (!view()->available())
|
||||
break;
|
||||
view()->fullCursor().pop();
|
||||
view()->cursor().pop();
|
||||
// Tell the paragraph dialog that we changed paragraph
|
||||
dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
|
||||
break;
|
||||
@ -1097,7 +1099,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
|
||||
break;
|
||||
|
||||
case LFUN_LAYOUT_TABULAR:
|
||||
if (InsetTabular * tab = view()->fullCursor().innerInsetTabular())
|
||||
if (InsetTabular * tab = view()->cursor().innerInsetTabular())
|
||||
tab->openLayoutDialog(view());
|
||||
break;
|
||||
|
||||
@ -1291,7 +1293,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
|
||||
case LFUN_INSET_DIALOG_SHOW: {
|
||||
InsetOld * inset = view()->getLyXText()->getInset();
|
||||
if (inset)
|
||||
inset->dispatch(*view(), FuncRequest(LFUN_INSET_DIALOG_SHOW));
|
||||
inset->dispatch(view()->cursor(), FuncRequest(LFUN_INSET_DIALOG_SHOW));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1301,7 +1303,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
|
||||
InsetBase * inset = owner->getDialogs().getOpenInset(name);
|
||||
if (inset) {
|
||||
FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, func.argument);
|
||||
inset->dispatch(*view(), fr);
|
||||
inset->dispatch(view()->cursor(), fr);
|
||||
} else if (name == "paragraph") {
|
||||
dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
|
||||
}
|
||||
@ -1439,11 +1441,11 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
|
||||
break;
|
||||
|
||||
case LFUN_EXTERNAL_EDIT:
|
||||
InsetExternal().dispatch(*view(), FuncRequest(action, argument));
|
||||
InsetExternal().dispatch(view()->cursor(), FuncRequest(action, argument));
|
||||
break;
|
||||
|
||||
default:
|
||||
view()->fullCursor().dispatch(FuncRequest(func));
|
||||
view()->cursor().dispatch(FuncRequest(func));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1453,7 +1455,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
|
||||
if (view()->available()) {
|
||||
view()->fitCursor();
|
||||
view()->update();
|
||||
view()->fullCursor().updatePos();
|
||||
view()->cursor().updatePos();
|
||||
// if we executed a mutating lfun, mark the buffer as dirty
|
||||
if (!getStatus(func).disabled()
|
||||
&& !lyxaction.funcHasFlag(func.action, LyXAction::NoBuffer)
|
||||
|
@ -122,7 +122,7 @@ public:
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
|
||||
/// try to handle that request
|
||||
DispatchResult dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
DispatchResult dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
|
||||
BufferView * bv();
|
||||
|
||||
|
@ -1,4 +1,8 @@
|
||||
|
||||
2004-01-15 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* *.[Ch]: Part of IU. Shift stuff from MathCursor and InsetFormula
|
||||
to LCursor and InsetBase.
|
||||
|
||||
2004-01-15 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
|
@ -55,7 +55,7 @@ void CommandInset::draw(PainterInfo & pi, int x, int y) const
|
||||
|
||||
|
||||
DispatchResult
|
||||
CommandInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
CommandInset::priv_dispatch(LCursor & bv, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
default:
|
||||
|
@ -42,7 +42,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
std::string name_;
|
||||
mutable bool set_label_;
|
||||
|
@ -42,13 +42,11 @@ using std::auto_ptr;
|
||||
using std::endl;
|
||||
|
||||
|
||||
InsetFormula::InsetFormula(bool chemistry)
|
||||
InsetFormula::InsetFormula()
|
||||
: par_(MathAtom(new MathHullInset)),
|
||||
preview_(new RenderPreview)
|
||||
{
|
||||
preview_->connect(boost::bind(&InsetFormula::statusChanged, this));
|
||||
if (chemistry)
|
||||
mutate("chemistry");
|
||||
}
|
||||
|
||||
|
||||
@ -61,14 +59,6 @@ InsetFormula::InsetFormula(InsetFormula const & other)
|
||||
}
|
||||
|
||||
|
||||
InsetFormula::InsetFormula(BufferView *)
|
||||
: par_(MathAtom(new MathHullInset)),
|
||||
preview_(new RenderPreview)
|
||||
{
|
||||
preview_->connect(boost::bind(&InsetFormula::statusChanged, this));
|
||||
}
|
||||
|
||||
|
||||
InsetFormula::InsetFormula(string const & data)
|
||||
: par_(MathAtom(new MathHullInset)),
|
||||
preview_(new RenderPreview)
|
||||
@ -178,8 +168,8 @@ namespace {
|
||||
|
||||
bool editing_inset(InsetFormula const * inset)
|
||||
{
|
||||
return mathcursor &&
|
||||
(const_cast<InsetFormulaBase const *>(mathcursor->formula()) ==
|
||||
return inMathed() &&
|
||||
(const_cast<InsetFormulaBase const *>(mathcursor::formula()) ==
|
||||
inset);
|
||||
}
|
||||
|
||||
@ -214,7 +204,7 @@ void InsetFormula::draw(PainterInfo & pi, int x, int y) const
|
||||
p.pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
|
||||
|
||||
if (editing_inset(this)) {
|
||||
mathcursor->drawSelection(pi);
|
||||
mathcursor::drawSelection(pi);
|
||||
//p.pain.rectangle(x, y - a, w, h, LColor::mathframe);
|
||||
}
|
||||
|
||||
|
@ -25,9 +25,7 @@ class RenderPreview;
|
||||
class InsetFormula : public InsetFormulaBase {
|
||||
public:
|
||||
///
|
||||
InsetFormula(bool chemistry = false);
|
||||
///
|
||||
explicit InsetFormula(BufferView *);
|
||||
InsetFormula();
|
||||
///
|
||||
explicit InsetFormula(std::string const & data);
|
||||
///
|
||||
|
@ -54,21 +54,19 @@ using std::istringstream;
|
||||
using std::ostringstream;
|
||||
|
||||
|
||||
MathCursor * mathcursor = 0;
|
||||
|
||||
namespace {
|
||||
|
||||
// local global
|
||||
int first_x;
|
||||
int first_y;
|
||||
|
||||
bool openNewInset(BufferView & bv, UpdatableInset * inset)
|
||||
bool openNewInset(LCursor & cur, UpdatableInset * inset)
|
||||
{
|
||||
if (!bv.insertInset(inset)) {
|
||||
if (!cur.bv().insertInset(inset)) {
|
||||
delete inset;
|
||||
return false;
|
||||
}
|
||||
inset->edit(&bv, true);
|
||||
inset->edit(cur, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -115,27 +113,27 @@ void InsetFormulaBase::handleFont
|
||||
{
|
||||
// this whole function is a hack and won't work for incremental font
|
||||
// changes...
|
||||
recordUndo(cur.bv(), Undo::ATOMIC);
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
|
||||
if (cur.inset()->asMathInset()->name() == font)
|
||||
mathcursor->handleFont(cur, font);
|
||||
mathcursor::handleFont(cur, font);
|
||||
else {
|
||||
mathcursor->handleNest(cur, createMathInset(font));
|
||||
mathcursor->insert(cur, arg);
|
||||
mathcursor::handleNest(cur, createMathInset(font));
|
||||
mathcursor::insert(cur, arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetFormulaBase::handleFont2(LCursor & cur, string const & arg)
|
||||
{
|
||||
recordUndo(cur.bv(), Undo::ATOMIC);
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
LyXFont font;
|
||||
bool b;
|
||||
bv_funcs::string2font(arg, font, b);
|
||||
if (font.color() != LColor::inherit) {
|
||||
MathAtom at = createMathInset("color");
|
||||
asArray(lcolor.getGUIName(font.color()), at.nucleus()->cell(0));
|
||||
mathcursor->handleNest(cur, at, 1);
|
||||
mathcursor::handleNest(cur, at, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,10 +151,10 @@ string const InsetFormulaBase::editMessage() const
|
||||
|
||||
void InsetFormulaBase::insetUnlock(BufferView & bv)
|
||||
{
|
||||
if (mathcursor) {
|
||||
if (mathcursor->inMacroMode(bv.fullCursor()))
|
||||
mathcursor->macroModeClose(bv.fullCursor());
|
||||
releaseMathCursor(bv);
|
||||
if (inMathed()) {
|
||||
if (mathcursor::inMacroMode(bv.cursor()))
|
||||
mathcursor::macroModeClose(bv.cursor());
|
||||
releaseMathCursor(bv.cursor());
|
||||
}
|
||||
if (bv.buffer())
|
||||
generatePreview(*bv.buffer());
|
||||
@ -166,9 +164,9 @@ void InsetFormulaBase::insetUnlock(BufferView & bv)
|
||||
|
||||
void InsetFormulaBase::getCursorPos(BufferView & bv, int & x, int & y) const
|
||||
{
|
||||
if (mathcursor) {
|
||||
mathcursor->getScreenPos(bv.fullCursor(), x, y);
|
||||
x = mathcursor->targetX(bv.fullCursor());
|
||||
if (inMathed()) {
|
||||
mathcursor::getScreenPos(bv.cursor(), x, y);
|
||||
x = mathcursor::targetX(bv.cursor());
|
||||
x -= xo_;
|
||||
y -= yo_;
|
||||
lyxerr << "InsetFormulaBase::getCursorPos: " << x << ' ' << y << endl;
|
||||
@ -182,7 +180,7 @@ void InsetFormulaBase::getCursorPos(BufferView & bv, int & x, int & y) const
|
||||
|
||||
void InsetFormulaBase::getCursorDim(int & asc, int & desc) const
|
||||
{
|
||||
if (mathcursor) {
|
||||
if (inMathed()) {
|
||||
asc = 10;
|
||||
desc = 2;
|
||||
//math_font_max_dim(font_, asc, des);
|
||||
@ -191,42 +189,42 @@ void InsetFormulaBase::getCursorDim(int & asc, int & desc) const
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetFormulaBase::lfunMouseRelease(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetFormulaBase::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
if (!mathcursor)
|
||||
if (!inMathed())
|
||||
return DispatchResult(false);
|
||||
bv.update();
|
||||
cur.bv().update();
|
||||
//lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
|
||||
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
// try to dispatch to enclosed insets first
|
||||
if (!mathcursor->dispatch(bv.fullCursor(), cmd).dispatched()) {
|
||||
if (!mathcursor::dispatch(cur, cmd).dispatched()) {
|
||||
// launch math panel for right mouse button
|
||||
lyxerr << "lfunMouseRelease: undispatched: " << cmd.button() << endl;
|
||||
bv.owner()->getDialogs().show("mathpanel");
|
||||
cur.bv().owner()->getDialogs().show("mathpanel");
|
||||
}
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button2) {
|
||||
MathArray ar;
|
||||
asArray(bv.getClipboard(), ar);
|
||||
mathcursor->selClear(bv.fullCursor());
|
||||
mathcursor->setScreenPos(bv.fullCursor(), cmd.x + xo_, cmd.y + yo_);
|
||||
mathcursor->insert(bv.fullCursor(), ar);
|
||||
bv.update();
|
||||
asArray(cur.bv().getClipboard(), ar);
|
||||
mathcursor::selClear(cur);
|
||||
mathcursor::setScreenPos(cur, cmd.x + xo_, cmd.y + yo_);
|
||||
mathcursor::insert(cur, ar);
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
// try to dispatch to enclosed insets first
|
||||
mathcursor->dispatch(bv.fullCursor(), cmd);
|
||||
bv.stuffClipboard(mathcursor->grabSelection(bv.fullCursor()));
|
||||
mathcursor::dispatch(cur, cmd);
|
||||
cur.bv().stuffClipboard(mathcursor::grabSelection(cur));
|
||||
// try to set the cursor
|
||||
//delete mathcursor;
|
||||
//mathcursor = new MathCursor(bv, this, x == 0);
|
||||
//metrics(bv);
|
||||
//mathcursor->setScreenPos(x + xo_, y + yo_);
|
||||
//mathcursor::setScreenPos(x + xo_, y + yo_);
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
@ -235,44 +233,45 @@ InsetFormulaBase::lfunMouseRelease(BufferView & bv, FuncRequest const & cmd)
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetFormulaBase::lfunMousePress(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetFormulaBase::lfunMousePress(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
//lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
|
||||
|
||||
if (!mathcursor || mathcursor->formula() != this) {
|
||||
if (!inMathed() || mathcursor::formula() != this) {
|
||||
lyxerr[Debug::MATHED] << "re-create cursor" << endl;
|
||||
releaseMathCursor(bv);
|
||||
mathcursor = new MathCursor(&bv, this, cmd.x == 0);
|
||||
releaseMathCursor(cur);
|
||||
mathcursor::formula_ = this;
|
||||
cur.idx() = 0;
|
||||
//metrics(bv);
|
||||
mathcursor->setScreenPos(bv.fullCursor(), cmd.x + xo_, cmd.y + yo_);
|
||||
mathcursor::setScreenPos(cur, cmd.x + xo_, cmd.y + yo_);
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
mathcursor->dispatch(bv.fullCursor(), cmd);
|
||||
mathcursor::dispatch(cur, cmd);
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
first_x = cmd.x;
|
||||
first_y = cmd.y;
|
||||
mathcursor->selClear(bv.fullCursor());
|
||||
mathcursor->setScreenPos(bv.fullCursor(), cmd.x + xo_, cmd.y + yo_);
|
||||
mathcursor->dispatch(bv.fullCursor(), cmd);
|
||||
mathcursor::selClear(cur);
|
||||
mathcursor::setScreenPos(cur, cmd.x + xo_, cmd.y + yo_);
|
||||
mathcursor::dispatch(cur, cmd);
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
bv.update();
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetFormulaBase::lfunMouseMotion(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetFormulaBase::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
if (!mathcursor)
|
||||
if (!inMathed())
|
||||
return DispatchResult(true, true);
|
||||
|
||||
if (mathcursor->dispatch(bv.fullCursor(), FuncRequest(cmd)).dispatched())
|
||||
if (mathcursor::dispatch(cur, FuncRequest(cmd)).dispatched())
|
||||
return DispatchResult(true, true);
|
||||
|
||||
// only select with button 1
|
||||
@ -285,81 +284,89 @@ InsetFormulaBase::lfunMouseMotion(BufferView & bv, FuncRequest const & cmd)
|
||||
first_x = cmd.x;
|
||||
first_y = cmd.y;
|
||||
|
||||
if (!mathcursor->selection())
|
||||
mathcursor->selStart(bv.fullCursor());
|
||||
if (!cur.selection())
|
||||
mathcursor::selStart(cur);
|
||||
|
||||
mathcursor->setScreenPos(bv.fullCursor(), cmd.x + xo_, cmd.y + yo_);
|
||||
bv.update();
|
||||
mathcursor::setScreenPos(cur, cmd.x + xo_, cmd.y + yo_);
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
|
||||
void InsetFormulaBase::edit(BufferView * bv, bool left)
|
||||
void InsetFormulaBase::edit(LCursor & cur, bool /*left*/)
|
||||
{
|
||||
lyxerr << "Called FormulaBase::edit" << endl;
|
||||
releaseMathCursor(*bv);
|
||||
mathcursor = new MathCursor(bv, this, left);
|
||||
bv->fullCursor().push(this);
|
||||
// if that is removed, we won't get the magenta box when entering an
|
||||
// inset for the first time
|
||||
bv->update();
|
||||
mathcursor::formula_ = this;
|
||||
cur.push(this);
|
||||
cur.idx() = 0;
|
||||
cur.pos() = 0;
|
||||
#warning FIXME
|
||||
cur.push(par().nucleus()->asHullInset());
|
||||
//cur.idx() = left ? 0 : cur.lastidx();
|
||||
cur.idx() = 0;
|
||||
cur.pos() = 0;
|
||||
cur.resetAnchor();
|
||||
}
|
||||
|
||||
|
||||
void InsetFormulaBase::edit(BufferView * bv, int x, int y)
|
||||
void InsetFormulaBase::edit(LCursor & cur, int x, int y)
|
||||
{
|
||||
lyxerr << "Called FormulaBase::EDIT with '" << x << ' ' << y << "'" << endl;
|
||||
releaseMathCursor(*bv);
|
||||
mathcursor = new MathCursor(bv, this, true);
|
||||
releaseMathCursor(cur);
|
||||
//metrics(bv);
|
||||
mathcursor->setScreenPos(bv->fullCursor(), x + xo_, y + yo_);
|
||||
bv->fullCursor().push(this);
|
||||
cur.push(this);
|
||||
cur.idx() = 0;
|
||||
cur.pos() = 0;
|
||||
mathcursor::setScreenPos(cur, x + xo_, y + yo_);
|
||||
cur.push(par().nucleus()->asHullInset());
|
||||
//cur.idx() = left ? 0 : cur.lastidx();
|
||||
cur.idx() = 0;
|
||||
cur.pos() = 0;
|
||||
// if that is removed, we won't get the magenta box when entering an
|
||||
// inset for the first time
|
||||
bv->update();
|
||||
cur.bv().update();
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
InsetFormulaBase::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
return par().nucleus()->dispatch(cur, cmd);
|
||||
|
||||
//lyxerr << "InsetFormulaBase::localDispatch: act: " << cmd.action
|
||||
// << " arg: '" << cmd.argument
|
||||
// << "' x: '" << cmd.x
|
||||
// << " y: '" << cmd.y
|
||||
// << "' button: " << cmd.button() << endl;
|
||||
|
||||
#if 0
|
||||
// delete empty mathbox (LFUN_BACKSPACE and LFUN_DELETE)
|
||||
bool remove_inset = false;
|
||||
LCursor & cur = bv.fullCursor();
|
||||
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_PRESS:
|
||||
//lyxerr << "Mouse single press" << endl;
|
||||
return lfunMousePress(bv, cmd);
|
||||
return lfunMousePress(cur, cmd);
|
||||
case LFUN_MOUSE_MOTION:
|
||||
//lyxerr << "Mouse motion" << endl;
|
||||
return lfunMouseMotion(bv, cmd);
|
||||
return lfunMouseMotion(cur, cmd);
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
//lyxerr << "Mouse single release" << endl;
|
||||
return lfunMouseRelease(bv, cmd);
|
||||
return lfunMouseRelease(cur, cmd);
|
||||
case LFUN_MOUSE_DOUBLE:
|
||||
//lyxerr << "Mouse double" << endl;
|
||||
return dispatch(bv, FuncRequest(LFUN_WORDSEL));
|
||||
return dispatch(cur, FuncRequest(LFUN_WORDSEL));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!mathcursor)
|
||||
return DispatchResult(false);
|
||||
|
||||
DispatchResult result(true);
|
||||
string argument = cmd.argument;
|
||||
bool sel = false;
|
||||
bool was_macro = mathcursor->inMacroMode(cur);
|
||||
bool was_macro = mathcursor::inMacroMode(cur);
|
||||
|
||||
mathcursor->normalize(cur);
|
||||
mathcursor->touch();
|
||||
mathcursor::normalize(cur);
|
||||
mathcursor::touch();
|
||||
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -375,45 +382,13 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
case LFUN_TABULAR_FEATURE:
|
||||
case LFUN_PASTESELECTION:
|
||||
case LFUN_MATH_LIMITS:
|
||||
recordUndo(bv, Undo::ATOMIC);
|
||||
mathcursor->dispatch(cur, cmd);
|
||||
break;
|
||||
|
||||
case LFUN_RIGHTSEL:
|
||||
sel = true; // fall through...
|
||||
case LFUN_RIGHT:
|
||||
result = mathcursor->right(cur, sel) ?
|
||||
DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
|
||||
//lyxerr << "calling scroll 20" << endl;
|
||||
//scroll(&bv, 20);
|
||||
// write something to the minibuffer
|
||||
//bv.owner()->message(mathcursor->info());
|
||||
break;
|
||||
|
||||
case LFUN_LEFTSEL:
|
||||
sel = true; // fall through
|
||||
case LFUN_LEFT:
|
||||
result = mathcursor->left(cur, sel) ?
|
||||
DispatchResult(true, true) : DispatchResult(false, FINISHED);
|
||||
break;
|
||||
|
||||
case LFUN_UPSEL:
|
||||
sel = true; // fall through
|
||||
case LFUN_UP:
|
||||
result = mathcursor->up(cur, sel) ?
|
||||
DispatchResult(true, true) : DispatchResult(false, FINISHED_UP);
|
||||
break;
|
||||
|
||||
case LFUN_DOWNSEL:
|
||||
sel = true; // fall through
|
||||
case LFUN_DOWN:
|
||||
result = mathcursor->down(cur, sel) ?
|
||||
DispatchResult(true, true) : DispatchResult(false, FINISHED_DOWN);
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
mathcursor::dispatch(cur, cmd);
|
||||
break;
|
||||
|
||||
case LFUN_WORDSEL:
|
||||
mathcursor->home(cur, false);
|
||||
mathcursor->end(cur, true);
|
||||
mathcursor::home(cur, false);
|
||||
mathcursor::end(cur, true);
|
||||
break;
|
||||
|
||||
case LFUN_UP_PARAGRAPHSEL:
|
||||
@ -428,7 +403,7 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
sel = true; // fall through
|
||||
case LFUN_HOME:
|
||||
case LFUN_WORDLEFT:
|
||||
result = mathcursor->home(cur, sel)
|
||||
result = mathcursor::home(cur, sel)
|
||||
? DispatchResult(true, true) : DispatchResult(true, FINISHED);
|
||||
break;
|
||||
|
||||
@ -437,7 +412,7 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
sel = true; // fall through
|
||||
case LFUN_END:
|
||||
case LFUN_WORDRIGHT:
|
||||
result = mathcursor->end(cur, sel)
|
||||
result = mathcursor::end(cur, sel)
|
||||
? DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
|
||||
break;
|
||||
|
||||
@ -456,17 +431,17 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_CELL_FORWARD:
|
||||
mathcursor->idxNext(cur);
|
||||
mathcursor::idxNext(cur);
|
||||
break;
|
||||
|
||||
case LFUN_CELL_BACKWARD:
|
||||
mathcursor->idxPrev(cur);
|
||||
mathcursor::idxPrev(cur);
|
||||
break;
|
||||
|
||||
case LFUN_DELETE_WORD_BACKWARD:
|
||||
case LFUN_BACKSPACE:
|
||||
recordUndo(bv, Undo::ATOMIC);
|
||||
if (!mathcursor->backspace(cur)) {
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
if (!mathcursor::backspace(cur)) {
|
||||
result = DispatchResult(true, FINISHED);
|
||||
remove_inset = true;
|
||||
}
|
||||
@ -474,8 +449,8 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
|
||||
case LFUN_DELETE_WORD_FORWARD:
|
||||
case LFUN_DELETE:
|
||||
recordUndo(bv, Undo::ATOMIC);
|
||||
if (!mathcursor->erase(cur)) {
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
if (!mathcursor::erase(cur)) {
|
||||
result = DispatchResult(true, FINISHED);
|
||||
remove_inset = true;
|
||||
}
|
||||
@ -491,7 +466,7 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
int y = 0;
|
||||
istringstream is(cmd.argument.c_str());
|
||||
is >> x >> y;
|
||||
mathcursor->setScreenPos(cur, x, y);
|
||||
mathcursor::setScreenPos(cur, x, y);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -500,19 +475,19 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
istringstream is(cmd.argument.c_str());
|
||||
is >> n;
|
||||
if (was_macro)
|
||||
mathcursor->macroModeClose(cur);
|
||||
recordUndo(bv, Undo::ATOMIC);
|
||||
mathcursor->selPaste(cur, n);
|
||||
mathcursor::macroModeClose(cur);
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
mathcursor::selPaste(cur, n);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_CUT:
|
||||
recordUndo(bv, Undo::DELETE);
|
||||
mathcursor->selCut(cur);
|
||||
recordUndo(cur, Undo::DELETE);
|
||||
mathcursor::selCut(cur);
|
||||
break;
|
||||
|
||||
case LFUN_COPY:
|
||||
mathcursor->selCopy(cur);
|
||||
mathcursor::selCopy(cur);
|
||||
break;
|
||||
|
||||
|
||||
@ -522,8 +497,8 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
if (cmd.argument.empty()) {
|
||||
// do superscript if LyX handles
|
||||
// deadkeys
|
||||
recordUndo(bv, Undo::ATOMIC);
|
||||
mathcursor->script(cur, true);
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
mathcursor::script(cur, true);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -561,8 +536,8 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
case LFUN_DEFAULT: handleFont(cur, cmd.argument, "textnormal"); break;
|
||||
|
||||
case LFUN_MATH_MODE:
|
||||
if (mathcursor->currentMode(cur) == MathInset::TEXT_MODE)
|
||||
mathcursor->niceInsert(cur, MathAtom(new MathHullInset("simple")));
|
||||
if (mathcursor::currentMode(cur) == MathInset::TEXT_MODE)
|
||||
mathcursor::niceInsert(cur, MathAtom(new MathHullInset("simple")));
|
||||
else
|
||||
handleFont(cur, cmd.argument, "textrm");
|
||||
//cur.owner()->message(_("math text mode toggled"));
|
||||
@ -571,14 +546,14 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
case LFUN_MATH_SIZE:
|
||||
#if 0
|
||||
if (!arg.empty()) {
|
||||
recordUndo(bv, Undo::ATOMIC);
|
||||
mathcursor->setSize(arg);
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
mathcursor::setSize(arg);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case LFUN_INSERT_MATRIX: {
|
||||
recordUndo(bv, Undo::ATOMIC);
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
unsigned int m = 1;
|
||||
unsigned int n = 1;
|
||||
string v_align;
|
||||
@ -588,7 +563,7 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
m = max(1u, m);
|
||||
n = max(1u, n);
|
||||
v_align += 'c';
|
||||
mathcursor->niceInsert(cur,
|
||||
mathcursor::niceInsert(cur,
|
||||
MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
|
||||
break;
|
||||
}
|
||||
@ -602,19 +577,19 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
ls = '(';
|
||||
if (rs.empty())
|
||||
rs = ')';
|
||||
recordUndo(bv, Undo::ATOMIC);
|
||||
mathcursor->handleNest(cur, MathAtom(new MathDelimInset(ls, rs)));
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
mathcursor::handleNest(cur, MathAtom(new MathDelimInset(ls, rs)));
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_SPACE_INSERT:
|
||||
case LFUN_MATH_SPACE:
|
||||
recordUndo(bv, Undo::ATOMIC);
|
||||
mathcursor->insert(cur, MathAtom(new MathSpaceInset(",")));
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
mathcursor::insert(cur, MathAtom(new MathSpaceInset(",")));
|
||||
break;
|
||||
|
||||
case LFUN_UNDO:
|
||||
bv.owner()->message(_("Invalid action in math mode!"));
|
||||
cur.bv().owner()->message(_("Invalid action in math mode!"));
|
||||
break;
|
||||
|
||||
|
||||
@ -624,8 +599,8 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
|
||||
case LFUN_INSET_ERT:
|
||||
// interpret this as if a backslash was typed
|
||||
recordUndo(bv, Undo::ATOMIC);
|
||||
mathcursor->interpret(cur, '\\');
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
mathcursor::interpret(cur, '\\');
|
||||
break;
|
||||
|
||||
case LFUN_BREAKPARAGRAPH:
|
||||
@ -638,31 +613,31 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
// handling such that "self-insert" works on "arbitrary stuff" too, and
|
||||
// math-insert only handles special math things like "matrix".
|
||||
case LFUN_INSERT_MATH:
|
||||
recordUndo(bv, Undo::ATOMIC);
|
||||
mathcursor->niceInsert(cur, argument);
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
mathcursor::niceInsert(cur, argument);
|
||||
break;
|
||||
|
||||
case -1:
|
||||
case LFUN_SELFINSERT:
|
||||
if (!argument.empty()) {
|
||||
recordUndo(bv, Undo::ATOMIC);
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
if (argument.size() == 1)
|
||||
result = mathcursor->interpret(cur, argument[0])
|
||||
result = mathcursor::interpret(cur, argument[0])
|
||||
? DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
|
||||
else
|
||||
mathcursor->insert(cur, argument);
|
||||
mathcursor::insert(cur, argument);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_ESCAPE:
|
||||
if (mathcursor->selection())
|
||||
mathcursor->selClear(cur);
|
||||
if (cur.selection())
|
||||
mathcursor::selClear(cur);
|
||||
else
|
||||
result = DispatchResult(false);
|
||||
break;
|
||||
|
||||
case LFUN_INSET_TOGGLE:
|
||||
mathcursor->insetToggle(cur);
|
||||
mathcursor::insetToggle(cur);
|
||||
break;
|
||||
|
||||
case LFUN_DIALOG_SHOW:
|
||||
@ -680,21 +655,21 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
if (data.empty())
|
||||
result = DispatchResult(false);
|
||||
else
|
||||
bv.owner()->getDialogs().show(name, data, 0);
|
||||
cur.bv().owner()->getDialogs().show(name, data, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSET_APPLY: {
|
||||
string const name = cmd.getArg(0);
|
||||
InsetBase * base = bv.owner()->getDialogs().getOpenInset(name);
|
||||
InsetBase * base = cur.bv().owner()->getDialogs().getOpenInset(name);
|
||||
|
||||
if (base) {
|
||||
FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument);
|
||||
result = base->dispatch(bv, fr);
|
||||
result = base->dispatch(cur, fr);
|
||||
} else {
|
||||
MathArray ar;
|
||||
if (createMathInset_fromDialogStr(cmd.argument, ar)) {
|
||||
mathcursor->insert(cur, ar);
|
||||
mathcursor::insert(cur, ar);
|
||||
result = DispatchResult(true, true);
|
||||
} else {
|
||||
result = DispatchResult(false);
|
||||
@ -706,7 +681,7 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
case LFUN_WORD_REPLACE:
|
||||
case LFUN_WORD_FIND: {
|
||||
result =
|
||||
searchForward(&bv, cmd.getArg(0), false, false)
|
||||
searchForward(&cur.bv(), cmd.getArg(0), false, false)
|
||||
? DispatchResult(true, true) : DispatchResult(false);
|
||||
break;
|
||||
}
|
||||
@ -716,39 +691,42 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
if (result == DispatchResult(true, true))
|
||||
bv.update();
|
||||
cur.bv().update();
|
||||
|
||||
mathcursor->normalize(cur);
|
||||
mathcursor->touch();
|
||||
mathcursor::normalize(cur);
|
||||
mathcursor::touch();
|
||||
|
||||
BOOST_ASSERT(mathcursor);
|
||||
BOOST_ASSERT(inMathed());
|
||||
|
||||
if (result.dispatched()) {
|
||||
revealCodes(bv);
|
||||
bv.stuffClipboard(mathcursor->grabSelection(cur));
|
||||
revealCodes(cur);
|
||||
cur.bv().stuffClipboard(mathcursor::grabSelection(cur));
|
||||
} else {
|
||||
releaseMathCursor(bv);
|
||||
releaseMathCursor(cur);
|
||||
if (remove_inset)
|
||||
bv.owner()->dispatch(FuncRequest(LFUN_DELETE));
|
||||
cur.bv().owner()->dispatch(FuncRequest(LFUN_DELETE));
|
||||
}
|
||||
|
||||
return result; // original version
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void InsetFormulaBase::revealCodes(BufferView & bv) const
|
||||
void InsetFormulaBase::revealCodes(LCursor & cur) const
|
||||
{
|
||||
if (!mathcursor)
|
||||
if (!inMathed())
|
||||
return;
|
||||
bv.owner()->message(mathcursor->info(bv.fullCursor()));
|
||||
ostringstream os;
|
||||
cur.info(os);
|
||||
cur.bv().owner()->message(os.str());
|
||||
/*
|
||||
// write something to the minibuffer
|
||||
// translate to latex
|
||||
mathcursor->markInsert(bv);
|
||||
mathcursor::markInsert(bv);
|
||||
ostringstream os;
|
||||
write(NULL, os);
|
||||
string str = os.str();
|
||||
mathcursor->markErase(bv);
|
||||
mathcursor::markErase(bv);
|
||||
string::size_type pos = 0;
|
||||
string res;
|
||||
for (string::iterator it = str.begin(); it != str.end(); ++it) {
|
||||
@ -806,6 +784,7 @@ int InsetFormulaBase::xhigh() const
|
||||
bool InsetFormulaBase::searchForward(BufferView * bv, string const & str,
|
||||
bool, bool)
|
||||
{
|
||||
return false;
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning pretty ugly
|
||||
#endif
|
||||
@ -830,10 +809,8 @@ bool InsetFormulaBase::searchForward(BufferView * bv, string const & str,
|
||||
CursorSlice & top = it.back();
|
||||
MathArray const & a = top.asMathInset()->cell(top.idx_);
|
||||
if (a.matchpart(ar, top.pos_)) {
|
||||
delete mathcursor;
|
||||
mathcursor = new MathCursor(bv, this, true);
|
||||
//metrics(bv);
|
||||
mathcursor->setSelection(bv->fullCursor(), it, ar.size());
|
||||
mathcursor::formula_ = this;
|
||||
mathcursor::setSelection(bv->cursor(), it, ar.size());
|
||||
current = it;
|
||||
top.pos_ += ar.size();
|
||||
bv->update();
|
||||
@ -863,13 +840,13 @@ bool InsetFormulaBase::display() const
|
||||
|
||||
string InsetFormulaBase::selectionAsString(BufferView & bv) const
|
||||
{
|
||||
return mathcursor ? mathcursor->grabSelection(bv.fullCursor()) : string();
|
||||
return inMathed() ? mathcursor::grabSelection(bv.cursor()) : string();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
void mathDispatchCreation(BufferView & bv, FuncRequest const & cmd,
|
||||
void mathDispatchCreation(LCursor & cur, FuncRequest const & cmd,
|
||||
bool display)
|
||||
{
|
||||
// use selection if available..
|
||||
@ -878,19 +855,19 @@ void mathDispatchCreation(BufferView & bv, FuncRequest const & cmd,
|
||||
// sel = "";
|
||||
//else
|
||||
|
||||
string sel = bv.getLyXText()->selectionAsString(*bv.buffer(), false);
|
||||
string sel =
|
||||
cur.bv().getLyXText()->selectionAsString(*cur.bv().buffer(), false);
|
||||
|
||||
if (sel.empty()) {
|
||||
InsetFormula * f = new InsetFormula(&bv);
|
||||
if (openNewInset(bv, f)) {
|
||||
bv.fullCursor().innerInset()->
|
||||
dispatch(bv, FuncRequest(LFUN_MATH_MUTATE, "simple"));
|
||||
InsetFormula * f = new InsetFormula;
|
||||
if (openNewInset(cur, f)) {
|
||||
cur.inset()->dispatch(cur, FuncRequest(LFUN_MATH_MUTATE, "simple"));
|
||||
// don't do that also for LFUN_MATH_MODE unless you want end up with
|
||||
// always changing to mathrm when opening an inlined inset
|
||||
// -- I really hate "LyXfunc overloading"...
|
||||
if (display)
|
||||
f->dispatch(bv, FuncRequest(LFUN_MATH_DISPLAY));
|
||||
f->dispatch(bv, FuncRequest(LFUN_INSERT_MATH, cmd.argument));
|
||||
f->dispatch(cur, FuncRequest(LFUN_MATH_DISPLAY));
|
||||
f->dispatch(cur, FuncRequest(LFUN_INSERT_MATH, cmd.argument));
|
||||
}
|
||||
} else {
|
||||
// create a macro if we see "\\newcommand" somewhere, and an ordinary
|
||||
@ -901,30 +878,30 @@ void mathDispatchCreation(BufferView & bv, FuncRequest const & cmd,
|
||||
f = new InsetFormula(sel);
|
||||
else
|
||||
f = new InsetFormulaMacro(sel);
|
||||
bv.getLyXText()->cutSelection(true, false);
|
||||
openNewInset(bv, f);
|
||||
cur.bv().getLyXText()->cutSelection(true, false);
|
||||
openNewInset(cur, f);
|
||||
}
|
||||
cmd.message(N_("Math editor mode"));
|
||||
}
|
||||
|
||||
|
||||
void mathDispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
void mathDispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
if (!bv.available())
|
||||
if (!cur.bv().available())
|
||||
return;
|
||||
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_MATH_DISPLAY:
|
||||
mathDispatchCreation(bv, cmd, true);
|
||||
mathDispatchCreation(cur, cmd, true);
|
||||
break;
|
||||
|
||||
case LFUN_MATH_MODE:
|
||||
mathDispatchCreation(bv, cmd, false);
|
||||
mathDispatchCreation(cur, cmd, false);
|
||||
break;
|
||||
|
||||
case LFUN_MATH_IMPORT_SELECTION:
|
||||
mathDispatchCreation(bv, cmd, false);
|
||||
mathDispatchCreation(cur, cmd, false);
|
||||
break;
|
||||
|
||||
case LFUN_MATH_MACRO:
|
||||
@ -936,18 +913,17 @@ void mathDispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
int const nargs = s1.empty() ? 0 : atoi(s1);
|
||||
string const s2 = token(s, ' ', 2);
|
||||
string const type = s2.empty() ? "newcommand" : s2;
|
||||
openNewInset(bv, new InsetFormulaMacro(token(s, ' ', 0), nargs, s2));
|
||||
openNewInset(cur, new InsetFormulaMacro(token(s, ' ', 0), nargs, s2));
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_INSERT_MATH:
|
||||
case LFUN_INSERT_MATRIX:
|
||||
case LFUN_MATH_DELIM: {
|
||||
InsetFormula * f = new InsetFormula(&bv);
|
||||
if (openNewInset(bv, f)) {
|
||||
UpdatableInset * inset = bv.fullCursor().innerInset();
|
||||
inset->dispatch(bv, FuncRequest(LFUN_MATH_MUTATE, "simple"));
|
||||
inset->dispatch(bv, cmd);
|
||||
InsetFormula * f = new InsetFormula;
|
||||
if (openNewInset(cur, f)) {
|
||||
cur.inset()->dispatch(cur, FuncRequest(LFUN_MATH_MUTATE, "simple"));
|
||||
cur.inset()->dispatch(cur, cmd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
///
|
||||
virtual void mutateToText();
|
||||
///
|
||||
virtual void revealCodes(BufferView & bv) const;
|
||||
virtual void revealCodes(LCursor & cur) const;
|
||||
///
|
||||
virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
|
||||
///
|
||||
@ -80,24 +80,23 @@ public:
|
||||
// return the selection as std::string
|
||||
std::string selectionAsString(BufferView & bv) const;
|
||||
///
|
||||
void edit(BufferView * bv, bool);
|
||||
void edit(LCursor & cur, bool);
|
||||
///
|
||||
void edit(BufferView * bv, int, int);
|
||||
void edit(LCursor & cur, int, int);
|
||||
protected:
|
||||
/// To allow transparent use of math editing functions
|
||||
virtual
|
||||
DispatchResult priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
/// unimplemented
|
||||
void operator=(const InsetFormulaBase &);
|
||||
/// common base for handling accents
|
||||
void handleAccent(BufferView & bv, std::string const & arg, std::string const & name);
|
||||
/// lfun handler
|
||||
DispatchResult lfunMousePress(BufferView &, FuncRequest const &);
|
||||
DispatchResult lfunMousePress(LCursor &, FuncRequest const &);
|
||||
///
|
||||
DispatchResult lfunMouseRelease(BufferView &, FuncRequest const &);
|
||||
DispatchResult lfunMouseRelease(LCursor &, FuncRequest const &);
|
||||
///
|
||||
DispatchResult lfunMouseMotion(BufferView &, FuncRequest const &);
|
||||
DispatchResult lfunMouseMotion(LCursor &, FuncRequest const &);
|
||||
|
||||
protected:
|
||||
|
||||
@ -117,9 +116,9 @@ protected:
|
||||
|
||||
// We don't really mess want around with mathed stuff outside mathed.
|
||||
// So do it here.
|
||||
void mathDispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
void mathDispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
|
||||
///
|
||||
void releaseMathCursor(BufferView & bv);
|
||||
void releaseMathCursor(LCursor & cur);
|
||||
|
||||
#endif
|
||||
|
@ -35,9 +35,6 @@ using std::auto_ptr;
|
||||
using std::ostream;
|
||||
|
||||
|
||||
extern MathCursor * mathcursor;
|
||||
|
||||
|
||||
InsetFormulaMacro::InsetFormulaMacro()
|
||||
{
|
||||
// inset name is inherited from Inset
|
||||
@ -173,9 +170,9 @@ void InsetFormulaMacro::draw(PainterInfo & p, int x, int y) const
|
||||
pi.pain.fillRectangle(x, a, w, h, LColor::mathmacrobg);
|
||||
pi.pain.rectangle(x, a, w, h, LColor::mathframe);
|
||||
|
||||
if (mathcursor &&
|
||||
const_cast<InsetFormulaBase const *>(mathcursor->formula()) == this)
|
||||
mathcursor->drawSelection(pi);
|
||||
if (inMathed() &&
|
||||
const_cast<InsetFormulaBase const *>(mathcursor::formula()) == this)
|
||||
mathcursor::drawSelection(pi);
|
||||
|
||||
pi.pain.text(x + 2, y, prefix(), font);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,7 @@
|
||||
#ifndef MATH_CURSOR
|
||||
#define MATH_CURSOR
|
||||
|
||||
#include "cursor_slice.h"
|
||||
#include "cursor.h"
|
||||
#include "math_inset.h"
|
||||
#include "math_data.h"
|
||||
|
||||
@ -36,8 +36,7 @@ this formula's MathHullInset to the current position.
|
||||
*/
|
||||
|
||||
|
||||
class MathCursor {
|
||||
public:
|
||||
namespace mathcursor {
|
||||
/// short of anything else reasonable
|
||||
typedef size_t size_type;
|
||||
/// type for column numbers
|
||||
@ -51,10 +50,6 @@ public:
|
||||
/// type for column numbers
|
||||
typedef size_t col_type;
|
||||
|
||||
///
|
||||
explicit MathCursor(BufferView *, InsetFormulaBase *, bool left);
|
||||
///
|
||||
~MathCursor();
|
||||
///
|
||||
void insert(LCursor & cur, MathAtom const &);
|
||||
///
|
||||
@ -79,10 +74,6 @@ public:
|
||||
bool up(LCursor & cur, bool sel = false);
|
||||
/// called for LFUN_DOWN etc
|
||||
bool down(LCursor & cur, bool sel = false);
|
||||
/// Put the cursor in the first position
|
||||
void first(LCursor & cur);
|
||||
/// Put the cursor in the last position
|
||||
void last(LCursor & cur);
|
||||
/// move to next cell in current inset
|
||||
void idxNext(LCursor & bv);
|
||||
/// move to previous cell in current inset
|
||||
@ -99,11 +90,11 @@ public:
|
||||
/// in pixels from top of screen
|
||||
void setScreenPos(LCursor & cur, int x, int y);
|
||||
/// in pixels from top of screen
|
||||
void getScreenPos(LCursor & cur, int & x, int & y) const;
|
||||
void getScreenPos(LCursor & cur, int & x, int & y);
|
||||
/// in pixels from left of screen
|
||||
int targetX(LCursor & cur) const;
|
||||
int targetX(LCursor & cur);
|
||||
/// return the next enclosing grid inset and the cursor's index in it
|
||||
MathGridInset * enclosingGrid(LCursor & cur, idx_type & idx) const;
|
||||
MathGridInset * enclosingGrid(LCursor & cur, idx_type & idx);
|
||||
/// go up to enclosing grid
|
||||
void popToEnclosingGrid(LCursor & cur);
|
||||
/// go up to the hull inset
|
||||
@ -113,7 +104,7 @@ public:
|
||||
/// adjust anchor position after deletions/insertions
|
||||
void adjust(LCursor & cur, pos_type from, difference_type diff);
|
||||
///
|
||||
InsetFormulaBase * formula() const;
|
||||
InsetFormulaBase * formula();
|
||||
/// current offset in the current cell
|
||||
///
|
||||
bool script(LCursor & cur, bool);
|
||||
@ -122,20 +113,16 @@ public:
|
||||
/// interpret name a name of a macro
|
||||
void macroModeClose(LCursor & cur);
|
||||
/// are we currently typing the name of a macro?
|
||||
bool inMacroMode(LCursor & cur) const;
|
||||
bool inMacroMode(LCursor & cur);
|
||||
/// get access to the macro we are currently typing
|
||||
MathUnknownInset * activeMacro(LCursor & cur);
|
||||
/// get access to the macro we are currently typing
|
||||
MathUnknownInset const * activeMacro(LCursor & cur) const;
|
||||
/// are we currently typing '#1' or '#2' or...?
|
||||
bool inMacroArgMode(LCursor & cur) const;
|
||||
bool inMacroArgMode(LCursor & cur);
|
||||
/// are we in math mode (1), text mode (-1) or unsure?
|
||||
MathInset::mode_type currentMode(LCursor & cur) const;
|
||||
MathInset::mode_type currentMode(LCursor & cur);
|
||||
|
||||
// Local selection methods
|
||||
///
|
||||
bool selection() const;
|
||||
///
|
||||
void selCopy(LCursor & cur);
|
||||
///
|
||||
void selCut(LCursor & cur);
|
||||
@ -152,18 +139,18 @@ public:
|
||||
/// clears or deletes selection depending on lyxrc setting
|
||||
void selClearOrDel(LCursor & cur);
|
||||
/// draws light-blue selection background
|
||||
void drawSelection(PainterInfo & pi) const;
|
||||
void drawSelection(PainterInfo & pi);
|
||||
/// replace selected stuff with at, placing the former
|
||||
// selection in given cell of atom
|
||||
void handleNest(LCursor & cur, MathAtom const & at, int cell = 0);
|
||||
/// remove this as soon as LyXFunc::getStatus is "localized"
|
||||
std::string getLastCode() const { return "mathnormal"; }
|
||||
inline std::string getLastCode() { return "mathnormal"; }
|
||||
///
|
||||
bool isInside(MathInset const *) const;
|
||||
bool isInside(MathInset const *);
|
||||
///
|
||||
char valign(LCursor & cur) const;
|
||||
char valign(LCursor & cur);
|
||||
///
|
||||
char halign(LCursor & cur) const;
|
||||
char halign(LCursor & cur);
|
||||
|
||||
/// make sure cursor position is valid
|
||||
void normalize(LCursor & cur);
|
||||
@ -181,21 +168,17 @@ public:
|
||||
/// leave current MathInset to the left
|
||||
bool popRight(LCursor & cur);
|
||||
|
||||
/// returns the selection
|
||||
void getSelection(LCursor & cur, CursorSlice &, CursorSlice &) const;
|
||||
/// returns the normalized anchor of the selection
|
||||
CursorSlice normalAnchor(LCursor & cur) const;
|
||||
CursorSlice normalAnchor(LCursor & cur);
|
||||
|
||||
/// describe the situation
|
||||
std::string info(LCursor & cur) const;
|
||||
/// dump selection information for debugging
|
||||
void seldump(char const * str) const;
|
||||
void seldump(char const * str);
|
||||
/// dump selection information for debugging
|
||||
void dump(char const * str) const;
|
||||
void dump(char const * str);
|
||||
/// moves on
|
||||
void setSelection(LCursor & cur, CursorBase const & where, size_type n);
|
||||
/// grab selection marked by anchor and current cursor
|
||||
std::string grabSelection(LCursor & cur) const;
|
||||
std::string grabSelection(LCursor & cur);
|
||||
/// guess what
|
||||
std::string grabAndEraseSelection(LCursor & cur);
|
||||
///
|
||||
@ -214,47 +197,13 @@ public:
|
||||
void handleFont(LCursor & cur, std::string const & font);
|
||||
///
|
||||
DispatchResult dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
/// moves cursor index one cell to the left
|
||||
bool idxLeft(LCursor & bv);
|
||||
/// moves cursor index one cell to the right
|
||||
bool idxRight(LCursor & bv);
|
||||
/// moves cursor to end of last cell of current line
|
||||
bool idxLineLast(LCursor & bv);
|
||||
/// moves position somehow up or down
|
||||
bool goUpDown(LCursor & cur, bool up);
|
||||
/// moves position closest to (x, y) in given box
|
||||
bool bruteFind(LCursor & cur,
|
||||
int x, int y, int xlow, int xhigh, int ylow, int yhigh);
|
||||
/// moves position closest to (x, y) in current cell
|
||||
void bruteFind2(LCursor & cur, int x, int y);
|
||||
/// are we in a nucleus of a script inset?
|
||||
bool inNucleus(LCursor & cur) const;
|
||||
|
||||
/// erase the selected part and re-sets the cursor
|
||||
void eraseSelection(LCursor & cur);
|
||||
|
||||
/// the name of the macro we are currently inputting
|
||||
std::string macroName(LCursor & cur) const;
|
||||
/// where in the curent cell does the macro name start?
|
||||
difference_type macroNamePos(LCursor & cur) const;
|
||||
/// can we enter the inset?
|
||||
bool openable(MathAtom const &, bool selection) const;
|
||||
|
||||
/// pointer to enclsing LyX inset
|
||||
InsetFormulaBase * formula_;
|
||||
// Selection stuff
|
||||
/// text code of last char entered
|
||||
//MathTextCodes lastcode_;
|
||||
/// do we allow autocorrection
|
||||
bool autocorrect_;
|
||||
/// do we currently select
|
||||
bool selection_;
|
||||
/// are we entering a macro name?
|
||||
bool macromode_;
|
||||
};
|
||||
extern InsetFormulaBase * formula_;
|
||||
}
|
||||
|
||||
extern MathCursor * mathcursor;
|
||||
void releaseMathCursor(BufferView & bv);
|
||||
void releaseMathCursor(LCursor & cur);
|
||||
|
||||
bool inMathed();
|
||||
|
||||
#endif
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "math_fracbase.h"
|
||||
#include "math_data.h"
|
||||
#include "cursor.h"
|
||||
|
||||
|
||||
MathFracbaseInset::MathFracbaseInset()
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "math_mathmlstream.h"
|
||||
#include "math_streamstr.h"
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "debug.h"
|
||||
#include "funcrequest.h"
|
||||
@ -1043,9 +1044,8 @@ void MathGridInset::splitCell(LCursor & cur)
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathGridInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
LCursor & cur = bv.fullCursor();
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
@ -1056,7 +1056,7 @@ MathGridInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
return DispatchResult(false);
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
GridInsetMailer(*this).updateDialog(&bv);
|
||||
GridInsetMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(false);
|
||||
|
||||
// insert file functions
|
||||
@ -1076,12 +1076,12 @@ MathGridInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
return DispatchResult(true, FINISHED);
|
||||
|
||||
case LFUN_CELL_SPLIT:
|
||||
//recordUndo(bv, Undo::ATOMIC);
|
||||
//recordUndo(cur, Undo::ATOMIC);
|
||||
splitCell(cur);
|
||||
return DispatchResult(true, FINISHED);
|
||||
|
||||
case LFUN_BREAKLINE: {
|
||||
//recordUndo(bv, Undo::INSERT);
|
||||
//recordUndo(cur, Undo::INSERT);
|
||||
row_type const r = cur.row();
|
||||
addRow(r);
|
||||
|
||||
@ -1191,6 +1191,6 @@ cur.row());
|
||||
}
|
||||
|
||||
default:
|
||||
return MathNestInset::priv_dispatch(bv, cmd);
|
||||
return MathNestInset::priv_dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ public:
|
||||
|
||||
protected:
|
||||
///
|
||||
DispatchResult priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
/// returns x offset of cell compared to inset
|
||||
int cellXOffset(idx_type idx) const;
|
||||
/// returns y offset of cell compared to inset
|
||||
|
@ -706,9 +706,9 @@ void MathHullInset::doExtern(LCursor & cur, FuncRequest const & func)
|
||||
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning temporarily disabled
|
||||
//if (selection()) {
|
||||
//if (cur.selection()) {
|
||||
// MathArray ar;
|
||||
// selGet(ar);
|
||||
// selGet(cur.ar);
|
||||
// lyxerr << "use selection: " << ar << endl;
|
||||
// insert(pipeThroughExtern(lang, extra, ar));
|
||||
// return;
|
||||
@ -725,8 +725,8 @@ void MathHullInset::doExtern(LCursor & cur, FuncRequest const & func)
|
||||
if (getType() == "simple") {
|
||||
size_type pos = cur.cell().find_last(eq);
|
||||
MathArray ar;
|
||||
if (mathcursor && mathcursor->selection()) {
|
||||
asArray(mathcursor->grabAndEraseSelection(cur), ar);
|
||||
if (inMathed() && cur.selection()) {
|
||||
asArray(mathcursor::grabAndEraseSelection(cur), ar);
|
||||
} else if (pos == cur.cell().size()) {
|
||||
ar = cur.cell();
|
||||
lyxerr << "use whole cell: " << ar << endl;
|
||||
@ -775,9 +775,8 @@ void MathHullInset::doExtern(LCursor & cur, FuncRequest const & func)
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathHullInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
MathHullInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
CursorSlice & cur = cursorTip(bv);
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_BREAKLINE:
|
||||
@ -787,28 +786,28 @@ MathHullInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
cur.pos() = 0;
|
||||
return DispatchResult(true, FINISHED);
|
||||
}
|
||||
return MathGridInset::priv_dispatch(bv, cmd);
|
||||
return MathGridInset::priv_dispatch(cur, cmd);
|
||||
|
||||
case LFUN_MATH_NUMBER:
|
||||
//lyxerr << "toggling all numbers" << endl;
|
||||
if (display()) {
|
||||
//recordUndo(bv, Undo::INSERT);
|
||||
//recordUndo(cur, Undo::INSERT);
|
||||
bool old = numberedType();
|
||||
if (type_ == "multline")
|
||||
numbered(nrows() - 1, !old);
|
||||
else
|
||||
for (row_type row = 0; row < nrows(); ++row)
|
||||
numbered(row, !old);
|
||||
//bv->owner()->message(old ? _("No number") : _("Number"));
|
||||
//cur.bv()->owner()->message(old ? _("No number") : _("Number"));
|
||||
}
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case LFUN_MATH_NONUMBER:
|
||||
if (display()) {
|
||||
row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
|
||||
//recordUndo(bv, Undo::INSERT);
|
||||
//recordUndo(cur, Undo::INSERT);
|
||||
bool old = numbered(r);
|
||||
//bv->owner()->message(old ? _("No number") : _("Number"));
|
||||
//cur.bv()->owner()->message(old ? _("No number") : _("Number"));
|
||||
numbered(r, !old);
|
||||
}
|
||||
return DispatchResult(true, true);
|
||||
@ -839,7 +838,7 @@ MathHullInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
case LFUN_MATH_EXTERN:
|
||||
doExtern(bv.fullCursor(), cmd);
|
||||
doExtern(cur, cmd);
|
||||
return DispatchResult(true, FINISHED);
|
||||
|
||||
case LFUN_MATH_MUTATE: {
|
||||
@ -863,7 +862,7 @@ MathHullInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
default:
|
||||
return MathGridInset::priv_dispatch(bv, cmd);
|
||||
return MathGridInset::priv_dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
std::string eolString(row_type row, bool fragile) const;
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
#ifndef MATH_INSET_H
|
||||
#define MATH_INSET_H
|
||||
|
||||
#include "cursor.h"
|
||||
#include "insets/insetbase.h"
|
||||
|
||||
#include <string>
|
||||
@ -68,6 +67,7 @@ class MathMacroTemplate;
|
||||
class MathMacro;
|
||||
class MathPosFinder;
|
||||
class Dimension;
|
||||
class LCursor;
|
||||
class TextPainter;
|
||||
class TextMetricsInfo;
|
||||
class ReplaceData;
|
||||
@ -228,10 +228,6 @@ public:
|
||||
virtual void mathmlize(MathMLStream &) const;
|
||||
/// write content as something readable by Octave
|
||||
virtual void octave(OctaveStream &) const;
|
||||
/// describe content if cursor inside
|
||||
virtual void infoize(std::ostream &) const {}
|
||||
/// describe content if cursor behind
|
||||
virtual void infoize2(std::ostream &) const {}
|
||||
/// plain ascii output
|
||||
virtual int plaintext(std::ostream & os, OutputParams const &) const;
|
||||
/// linuxdoc output
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "math_macrotable.h"
|
||||
#include "math_macrotemplate.h"
|
||||
#include "math_mathmlstream.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "debug.h"
|
||||
#include "funcrequest.h"
|
||||
#include "LColor.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
|
||||
@ -214,7 +216,7 @@ bool MathNestInset::contains(MathArray const & ar) const
|
||||
|
||||
bool MathNestInset::editing() const
|
||||
{
|
||||
return mathcursor && mathcursor->isInside(this);
|
||||
return inMathed() && mathcursor::isInside(this);
|
||||
}
|
||||
|
||||
|
||||
@ -239,7 +241,7 @@ bool MathNestInset::isActive() const
|
||||
MathArray MathNestInset::glue() const
|
||||
{
|
||||
MathArray ar;
|
||||
for (unsigned i = 0; i < nargs(); ++i)
|
||||
for (size_t i = 0; i < nargs(); ++i)
|
||||
ar.append(cell(i));
|
||||
return ar;
|
||||
}
|
||||
@ -248,7 +250,7 @@ MathArray MathNestInset::glue() const
|
||||
void MathNestInset::write(WriteStream & os) const
|
||||
{
|
||||
os << '\\' << name().c_str();
|
||||
for (unsigned i = 0; i < nargs(); ++i)
|
||||
for (size_t i = 0; i < nargs(); ++i)
|
||||
os << '{' << cell(i) << '}';
|
||||
if (nargs() == 0)
|
||||
os.pendingSpace(true);
|
||||
@ -262,7 +264,7 @@ void MathNestInset::write(WriteStream & os) const
|
||||
void MathNestInset::normalize(NormalStream & os) const
|
||||
{
|
||||
os << '[' << name().c_str();
|
||||
for (unsigned i = 0; i < nargs(); ++i)
|
||||
for (size_t i = 0; i < nargs(); ++i)
|
||||
os << ' ' << cell(i);
|
||||
os << ']';
|
||||
}
|
||||
@ -275,29 +277,75 @@ void MathNestInset::notifyCursorLeaves(idx_type idx)
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathNestInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
CursorSlice & cur = cursorTip(bv);
|
||||
//lyxerr << "InsetFormulaBase::localDispatch: act: " << cmd.action
|
||||
// << " arg: '" << cmd.argument
|
||||
// << "' x: '" << cmd.x
|
||||
// << " y: '" << cmd.y
|
||||
// << "' button: " << cmd.button() << endl;
|
||||
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_PASTE: {
|
||||
MathArray ar;
|
||||
mathed_parse_cell(ar, cmd.argument);
|
||||
cur.cell().insert(cur.pos(), ar);
|
||||
cur.pos() += ar.size();
|
||||
return DispatchResult(true, true);
|
||||
case LFUN_PASTE: {
|
||||
MathArray ar;
|
||||
mathed_parse_cell(ar, cmd.argument);
|
||||
cur.cell().insert(cur.pos(), ar);
|
||||
cur.pos() += ar.size();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
case LFUN_PASTESELECTION:
|
||||
return dispatch(cur, FuncRequest(LFUN_PASTE, cur.bv().getClipboard()));
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
if (cmd.button() == mouse_button::button2)
|
||||
return priv_dispatch(cur, FuncRequest(LFUN_PASTESELECTION));
|
||||
return DispatchResult(false);
|
||||
|
||||
case LFUN_RIGHTSEL:
|
||||
cur.selection() = true; // fall through...
|
||||
case LFUN_RIGHT:
|
||||
return mathcursor::right(cur, cur.selection()) ?
|
||||
DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
|
||||
//lyxerr << "calling scroll 20" << endl;
|
||||
//scroll(&cur.bv(), 20);
|
||||
// write something to the minibuffer
|
||||
//cur.bv().owner()->message(mathcursor::info());
|
||||
|
||||
case LFUN_LEFTSEL:
|
||||
cur.selection() = true; // fall through
|
||||
case LFUN_LEFT:
|
||||
return mathcursor::left(cur, cur.selection()) ?
|
||||
DispatchResult(true, true) : DispatchResult(false, FINISHED);
|
||||
|
||||
case LFUN_UPSEL:
|
||||
cur.selection() = true; // fall through
|
||||
case LFUN_UP:
|
||||
return mathcursor::up(cur, cur.selection()) ?
|
||||
DispatchResult(true, true) : DispatchResult(false, FINISHED_UP);
|
||||
|
||||
case LFUN_DOWNSEL:
|
||||
cur.selection() = true; // fall through
|
||||
case LFUN_DOWN:
|
||||
return mathcursor::down(cur, cur.selection()) ?
|
||||
DispatchResult(true, true) : DispatchResult(false, FINISHED_DOWN);
|
||||
|
||||
case LFUN_SELFINSERT:
|
||||
if (!cmd.argument.empty()) {
|
||||
recordUndo(cur, Undo::ATOMIC);
|
||||
if (cmd.argument.size() == 1) {
|
||||
if (mathcursor::interpret(cur, cmd.argument[0]))
|
||||
return DispatchResult(true, true);
|
||||
else
|
||||
return DispatchResult(false, FINISHED_RIGHT);
|
||||
}
|
||||
mathcursor::insert(cur, cmd.argument);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_PASTESELECTION:
|
||||
return dispatch(bv, FuncRequest(LFUN_PASTE, bv.getClipboard()));
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
if (cmd.button() == mouse_button::button2)
|
||||
return priv_dispatch(bv, FuncRequest(LFUN_PASTESELECTION));
|
||||
return DispatchResult(false);
|
||||
|
||||
default:
|
||||
return MathInset::priv_dispatch(bv, cmd);
|
||||
default:
|
||||
return MathInset::priv_dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
|
||||
/// we store the cells in a vector
|
||||
typedef std::vector<MathArray> cells_type;
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "math_oversetinset.h"
|
||||
#include "math_data.h"
|
||||
#include "math_mathmlstream.h"
|
||||
|
||||
#include "cursor.h"
|
||||
|
||||
using std::max;
|
||||
using std::auto_ptr;
|
||||
|
@ -14,14 +14,16 @@
|
||||
#include "math_rootinset.h"
|
||||
#include "math_data.h"
|
||||
#include "math_mathmlstream.h"
|
||||
#include "cursor.h"
|
||||
#include "LColor.h"
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
using std::max;
|
||||
using std::auto_ptr;
|
||||
|
||||
|
||||
|
||||
MathRootInset::MathRootInset()
|
||||
: MathNestInset(2)
|
||||
{}
|
||||
|
@ -16,18 +16,19 @@
|
||||
#include "math_support.h"
|
||||
#include "math_symbolinset.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "funcrequest.h"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
|
||||
using std::string;
|
||||
using std::max;
|
||||
using std::auto_ptr;
|
||||
using std::endl;
|
||||
|
||||
|
||||
|
||||
MathScriptInset::MathScriptInset()
|
||||
: MathNestInset(3), limits_(0)
|
||||
{
|
||||
@ -512,7 +513,7 @@ void MathScriptInset::notifyCursorLeaves(idx_type idx)
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathScriptInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
MathScriptInset::priv_dispatch(LCursor & bv, FuncRequest const & cmd)
|
||||
{
|
||||
if (cmd.action == LFUN_MATH_LIMITS) {
|
||||
if (!cmd.argument.empty()) {
|
||||
|
@ -99,7 +99,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
/// returns x offset for main part
|
||||
int dxx() const;
|
||||
|
@ -13,12 +13,13 @@
|
||||
#include "math_undersetinset.h"
|
||||
#include "math_data.h"
|
||||
#include "math_mathmlstream.h"
|
||||
|
||||
#include "cursor.h"
|
||||
|
||||
using std::max;
|
||||
using std::auto_ptr;
|
||||
|
||||
|
||||
|
||||
auto_ptr<InsetBase> MathUndersetInset::clone() const
|
||||
{
|
||||
return auto_ptr<InsetBase>(new MathUndersetInset(*this));
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "math_factory.h"
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "debug.h"
|
||||
#include "funcrequest.h"
|
||||
@ -25,12 +26,12 @@
|
||||
#include "frontends/LyXView.h"
|
||||
#include "frontends/Dialogs.h"
|
||||
|
||||
|
||||
using std::string;
|
||||
using std::auto_ptr;
|
||||
using std::endl;
|
||||
|
||||
|
||||
|
||||
RefInset::RefInset()
|
||||
: CommandInset("ref")
|
||||
{}
|
||||
@ -53,8 +54,7 @@ void RefInset::infoize(std::ostream & os) const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
RefInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
DispatchResult RefInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_INSET_MODIFY:
|
||||
@ -62,35 +62,34 @@ RefInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
MathArray ar;
|
||||
if (!createMathInset_fromDialogStr(cmd.argument, ar))
|
||||
return DispatchResult(false);
|
||||
|
||||
*this = *ar[0].nucleus()->asRefInset();
|
||||
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
break;
|
||||
return DispatchResult(false);
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
lyxerr << "trying to goto ref" << cell(0) << endl;
|
||||
bv.dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
|
||||
cur.bv().dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
// Eventually trigger dialog with button 3
|
||||
// not 1
|
||||
string const data = createDialogStr("ref");
|
||||
bv.owner()->getDialogs().show("ref", data, this);
|
||||
cur.bv().owner()->getDialogs().show("ref", data, this);
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
break;
|
||||
return DispatchResult(false);
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
case LFUN_MOUSE_MOTION:
|
||||
// eat other mouse commands
|
||||
return DispatchResult(true, true);
|
||||
|
||||
default:
|
||||
return CommandInset::priv_dispatch(bv, cmd);
|
||||
return CommandInset::priv_dispatch(cur, cmd);
|
||||
}
|
||||
// not our business
|
||||
return DispatchResult(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(BufferView & bv, FuncRequest const & cmd);
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -132,7 +132,7 @@ RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
|
||||
paintBackground();
|
||||
|
||||
// paint the selection background
|
||||
if (bv_.selection().set() && &text_ == bv_.fullCursor().innerText())
|
||||
if (bv_.cursor().selection() && &text_ == bv_.cursor().innerText())
|
||||
paintSelection();
|
||||
|
||||
// vertical lines for appendix
|
||||
@ -391,14 +391,15 @@ void RowPainter::paintSelection()
|
||||
bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
|
||||
|
||||
// the current selection
|
||||
int const startx = text_.cursorX(bv_.selStart());
|
||||
int const endx = text_.cursorX(bv_.selEnd());
|
||||
int const starty = text_.cursorY(bv_.selStart());
|
||||
int const endy = text_.cursorY(bv_.selEnd());
|
||||
ParagraphList::iterator startpit = text_.getPar(bv_.selStart());
|
||||
ParagraphList::iterator endpit = text_.getPar(bv_.selEnd());
|
||||
RowList::iterator startrow = startpit->getRow(bv_.selStart().pos());
|
||||
RowList::iterator endrow = endpit->getRow(bv_.selEnd().pos());
|
||||
LCursor const & cur = bv_.cursor();
|
||||
int const startx = text_.cursorX(cur.selStart());
|
||||
int const endx = text_.cursorX(cur.selEnd());
|
||||
int const starty = text_.cursorY(cur.selStart());
|
||||
int const endy = text_.cursorY(cur.selEnd());
|
||||
ParagraphList::iterator startpit = text_.getPar(cur.selStart());
|
||||
ParagraphList::iterator endpit = text_.getPar(cur.selEnd());
|
||||
RowList::iterator startrow = startpit->getRow(cur.selStart().pos());
|
||||
RowList::iterator endrow = endpit->getRow(cur.selEnd().pos());
|
||||
int const h = row_.height();
|
||||
|
||||
int const row_y = pit_->y + row_.y_offset();
|
||||
@ -468,9 +469,9 @@ void RowPainter::paintSelection()
|
||||
}
|
||||
|
||||
if (((startpit != pit_ && startrow != rit_)
|
||||
|| bv_.selStart().pos() <= pos) &&
|
||||
|| cur.selStart().pos() <= pos) &&
|
||||
((endpit != pit_ && endrow != rit_)
|
||||
|| pos < bv_.selEnd().pos())) {
|
||||
|| pos < cur.selEnd().pos())) {
|
||||
// Here we do not use x_ as xo_ was added to x_.
|
||||
pain_.fillRectangle(int(old_tmpx), yo_,
|
||||
int(tmpx - old_tmpx + 1), h, LColor::selection);
|
||||
|
94
src/text.C
94
src/text.C
@ -833,7 +833,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
|
||||
// convenience function
|
||||
void LyXText::redoParagraph()
|
||||
{
|
||||
bv()->clearSelection();
|
||||
bv()->cursor().clearSelection();
|
||||
redoParagraph(cursorPar());
|
||||
setCursorIntern(cursor().par(), cursor().pos());
|
||||
}
|
||||
@ -1104,9 +1104,9 @@ void LyXText::selectWord(word_location loc)
|
||||
setCursor(from.par(), from.pos());
|
||||
if (to == from)
|
||||
return;
|
||||
bv()->resetAnchor();
|
||||
bv()->cursor().resetAnchor();
|
||||
setCursor(to.par(), to.pos());
|
||||
bv()->setSelection();
|
||||
bv()->cursor().setSelection();
|
||||
}
|
||||
|
||||
|
||||
@ -1114,26 +1114,26 @@ void LyXText::selectWord(word_location loc)
|
||||
// selection is currently set
|
||||
bool LyXText::selectWordWhenUnderCursor(word_location loc)
|
||||
{
|
||||
if (!bv()->selection().set()) {
|
||||
selectWord(loc);
|
||||
return bv()->selection().set();
|
||||
}
|
||||
return false;
|
||||
if (bv()->cursor().selection())
|
||||
return false;
|
||||
selectWord(loc);
|
||||
return bv()->cursor().selection();
|
||||
}
|
||||
|
||||
|
||||
void LyXText::acceptChange()
|
||||
{
|
||||
if (!bv()->selection().set() && cursorPar()->size())
|
||||
LCursor & cur = bv()->cursor();
|
||||
if (!cur.selection() && cursorPar()->size())
|
||||
return;
|
||||
|
||||
if (bv()->selStart().par() == bv()->selEnd().par()) {
|
||||
CursorSlice const & startc = bv()->selStart();
|
||||
CursorSlice const & endc = bv()->selEnd();
|
||||
if (cur.selStart().par() == cur.par()) {
|
||||
CursorSlice const & startc = cur.selStart();
|
||||
CursorSlice const & endc = cur.selEnd();
|
||||
recordUndo(Undo::INSERT, this, startc.par());
|
||||
getPar(startc)->acceptChange(startc.pos(), endc.pos());
|
||||
finishUndo();
|
||||
bv()->clearSelection();
|
||||
cur.clearSelection();
|
||||
redoParagraph(getPar(startc));
|
||||
setCursorIntern(startc.par(), 0);
|
||||
}
|
||||
@ -1143,16 +1143,17 @@ void LyXText::acceptChange()
|
||||
|
||||
void LyXText::rejectChange()
|
||||
{
|
||||
if (!bv()->selection().set() && cursorPar()->size())
|
||||
LCursor & cur = bv()->cursor();
|
||||
if (!cur.selection() && cursorPar()->size())
|
||||
return;
|
||||
|
||||
if (bv()->selStart().par() == bv()->selEnd().par()) {
|
||||
CursorSlice const & startc = bv()->selStart();
|
||||
CursorSlice const & endc = bv()->selEnd();
|
||||
if (cur.selStart().par() == cur.selEnd().par()) {
|
||||
CursorSlice const & startc = cur.selStart();
|
||||
CursorSlice const & endc = cur.selEnd();
|
||||
recordUndo(Undo::INSERT, this, startc.par());
|
||||
getPar(startc)->rejectChange(startc.pos(), endc.pos());
|
||||
finishUndo();
|
||||
bv()->clearSelection();
|
||||
cur.clearSelection();
|
||||
redoParagraph(getPar(startc));
|
||||
setCursorIntern(startc.par(), 0);
|
||||
}
|
||||
@ -1163,16 +1164,17 @@ void LyXText::rejectChange()
|
||||
// Delete from cursor up to the end of the current or next word.
|
||||
void LyXText::deleteWordForward()
|
||||
{
|
||||
LCursor & cur = bv()->cursor();
|
||||
if (cursorPar()->empty())
|
||||
cursorRight(bv());
|
||||
cursorRight(true);
|
||||
else {
|
||||
CursorSlice tmpcursor = cursor();
|
||||
bv()->selection().set(true); // to avoid deletion
|
||||
cur.selection() = true; // to avoid deletion
|
||||
cursorRightOneWord();
|
||||
setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos());
|
||||
bv()->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
cursor() = tmpcursor;
|
||||
bv()->setSelection();
|
||||
cur.setSelection();
|
||||
cutSelection(true, false);
|
||||
}
|
||||
}
|
||||
@ -1181,16 +1183,17 @@ void LyXText::deleteWordForward()
|
||||
// Delete from cursor to start of current or prior word.
|
||||
void LyXText::deleteWordBackward()
|
||||
{
|
||||
LCursor & cur = bv()->cursor();
|
||||
if (cursorPar()->empty())
|
||||
cursorLeft(bv());
|
||||
cursorLeft(true);
|
||||
else {
|
||||
CursorSlice tmpcursor = cursor();
|
||||
bv()->selection().set(true); // to avoid deletion
|
||||
cur.selection() = true; // to avoid deletion
|
||||
cursorLeftOneWord();
|
||||
setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos());
|
||||
bv()->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
cursor() = tmpcursor;
|
||||
bv()->setSelection();
|
||||
cur.setSelection();
|
||||
cutSelection(true, false);
|
||||
}
|
||||
}
|
||||
@ -1199,19 +1202,20 @@ void LyXText::deleteWordBackward()
|
||||
// Kill to end of line.
|
||||
void LyXText::deleteLineForward()
|
||||
{
|
||||
LCursor & cur = bv()->cursor();
|
||||
if (cursorPar()->empty()) {
|
||||
// Paragraph is empty, so we just go to the right
|
||||
cursorRight(bv());
|
||||
cursorRight(true);
|
||||
} else {
|
||||
CursorSlice tmpcursor = cursor();
|
||||
bv()->selection().set(true); // to avoid deletion
|
||||
cur.selection() = true; // to avoid deletion
|
||||
cursorEnd();
|
||||
setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos());
|
||||
bv()->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
cursor() = tmpcursor;
|
||||
bv()->setSelection();
|
||||
cur.setSelection();
|
||||
// What is this test for ??? (JMarc)
|
||||
if (!bv()->selection().set())
|
||||
if (!cur.selection())
|
||||
deleteWordForward();
|
||||
else
|
||||
cutSelection(true, false);
|
||||
@ -1221,12 +1225,13 @@ void LyXText::deleteLineForward()
|
||||
|
||||
void LyXText::changeCase(LyXText::TextCase action)
|
||||
{
|
||||
LCursor & cur = bv()->cursor();
|
||||
CursorSlice from;
|
||||
CursorSlice to;
|
||||
|
||||
if (bv()->selection().set()) {
|
||||
from = bv()->selStart();
|
||||
to = bv()->selEnd();
|
||||
if (cur.selection()) {
|
||||
from = cur.selStart();
|
||||
to = cur.selEnd();
|
||||
} else {
|
||||
from = cursor();
|
||||
getWord(from, to, lyx::PARTIAL_WORD);
|
||||
@ -1507,14 +1512,15 @@ void LyXText::previousRow(ParagraphList::iterator & pit,
|
||||
|
||||
string LyXText::selectionAsString(Buffer const & buffer, bool label) const
|
||||
{
|
||||
if (!bv()->selection().set())
|
||||
LCursor & cur = bv()->cursor();
|
||||
if (!cur.selection())
|
||||
return string();
|
||||
|
||||
// should be const ...
|
||||
ParagraphList::iterator startpit = getPar(bv()->selStart());
|
||||
ParagraphList::iterator endpit = getPar(bv()->selEnd());
|
||||
size_t const startpos = bv()->selStart().pos();
|
||||
size_t const endpos = bv()->selEnd().pos();
|
||||
ParagraphList::iterator startpit = getPar(cur.selStart());
|
||||
ParagraphList::iterator endpit = getPar(cur.selEnd());
|
||||
size_t const startpos = cur.selStart().pos();
|
||||
size_t const endpos = cur.selEnd().pos();
|
||||
|
||||
if (startpit == endpit)
|
||||
return startpit->asString(buffer, startpos, endpos, label);
|
||||
@ -1601,7 +1607,7 @@ void LyXText::redoParagraph(ParagraphList::iterator pit)
|
||||
void LyXText::fullRebreak()
|
||||
{
|
||||
redoParagraphs(paragraphs().begin(), paragraphs().end());
|
||||
bv()->resetAnchor();
|
||||
bv()->cursor().resetAnchor();
|
||||
}
|
||||
|
||||
|
||||
@ -1937,23 +1943,23 @@ int LyXText::cursorY(CursorSlice const & cur) const
|
||||
|
||||
CursorSlice & LyXText::cursor()
|
||||
{
|
||||
return bv()->cursor();
|
||||
return bv()->cursor().cursor_.back();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice const & LyXText::cursor() const
|
||||
{
|
||||
return bv()->cursor();
|
||||
return bv()->cursor().cursor_.back();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice & LyXText::anchor()
|
||||
{
|
||||
return bv()->anchor();
|
||||
return bv()->cursor().anchor_.back();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice const & LyXText::anchor() const
|
||||
{
|
||||
return bv()->anchor();
|
||||
return bv()->cursor().anchor_.back();
|
||||
}
|
||||
|
209
src/text2.C
209
src/text2.C
@ -95,7 +95,7 @@ void LyXText::init(BufferView * bview)
|
||||
|
||||
redoParagraphs(beg, end);
|
||||
setCursorIntern(0, 0);
|
||||
bv()->resetAnchor();
|
||||
bv()->cursor().resetAnchor();
|
||||
|
||||
updateCounters();
|
||||
}
|
||||
@ -333,8 +333,10 @@ void LyXText::setLayout(string const & layout)
|
||||
return;
|
||||
}
|
||||
|
||||
ParagraphList::iterator start = getPar(bv()->selStart().par());
|
||||
ParagraphList::iterator end = boost::next(getPar(bv()->selEnd().par()));
|
||||
ParagraphList::iterator start =
|
||||
getPar(bv()->cursor().selStart().par());
|
||||
ParagraphList::iterator end =
|
||||
boost::next(getPar(bv()->cursor().selEnd().par()));
|
||||
ParagraphList::iterator endpit = setLayout(start, end, layout);
|
||||
|
||||
redoParagraphs(start, endpit);
|
||||
@ -349,12 +351,12 @@ void getSelectionSpan(LyXText & text,
|
||||
ParagraphList::iterator & beg,
|
||||
ParagraphList::iterator & end)
|
||||
{
|
||||
if (!text.bv()->selection().set()) {
|
||||
if (!text.bv()->cursor().selection()) {
|
||||
beg = text.cursorPar();
|
||||
end = boost::next(beg);
|
||||
} else {
|
||||
beg = text.getPar(text.bv()->selStart());
|
||||
end = boost::next(text.getPar(text.bv()->selEnd()));
|
||||
beg = text.getPar(text.bv()->cursor().selStart());
|
||||
end = boost::next(text.getPar(text.bv()->cursor().selEnd()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -424,8 +426,9 @@ void LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type)
|
||||
// set font over selection and make a total rebreak of those paragraphs
|
||||
void LyXText::setFont(LyXFont const & font, bool toggleall)
|
||||
{
|
||||
LCursor & cur = bv()->cursor();
|
||||
// if there is no selection just set the current_font
|
||||
if (!bv()->selection().set()) {
|
||||
if (!cur.selection()) {
|
||||
// Determine basis font
|
||||
LyXFont layoutfont;
|
||||
if (cursor().pos() < cursorPar()->beginOfBody())
|
||||
@ -448,14 +451,14 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
|
||||
}
|
||||
|
||||
// ok we have a selection.
|
||||
recUndo(bv()->selStart().par(), bv()->selEnd().par());
|
||||
recUndo(cur.selStart().par(), cur.selEnd().par());
|
||||
freezeUndo();
|
||||
|
||||
ParagraphList::iterator beg = getPar(bv()->selStart().par());
|
||||
ParagraphList::iterator end = getPar(bv()->selEnd().par());
|
||||
ParagraphList::iterator beg = getPar(cur.selStart().par());
|
||||
ParagraphList::iterator end = getPar(cur.selEnd().par());
|
||||
|
||||
PosIterator pos(¶graphs(), beg, bv()->selStart().pos());
|
||||
PosIterator posend(¶graphs(), end, bv()->selEnd().pos());
|
||||
PosIterator pos(¶graphs(), beg, cur.selStart().pos());
|
||||
PosIterator posend(¶graphs(), end, cur.selEnd().pos());
|
||||
|
||||
BufferParams const & params = bv()->buffer()->params();
|
||||
|
||||
@ -530,15 +533,16 @@ void LyXText::toggleFree(LyXFont const & font, bool toggleall)
|
||||
// Implicit selections are cleared afterwards
|
||||
//and cursor is set to the original position.
|
||||
if (implicitSelection) {
|
||||
bv()->clearSelection();
|
||||
bv()->cursor().clearSelection();
|
||||
cursor() = resetCursor;
|
||||
bv()->resetAnchor();
|
||||
bv()->cursor().resetAnchor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string LyXText::getStringToIndex()
|
||||
{
|
||||
LCursor & cur = bv()->cursor();
|
||||
// Try implicit word selection
|
||||
// If there is a change in the language the implicit word selection
|
||||
// is disabled.
|
||||
@ -547,20 +551,20 @@ string LyXText::getStringToIndex()
|
||||
selectWordWhenUnderCursor(lyx::PREVIOUS_WORD);
|
||||
|
||||
string idxstring;
|
||||
if (!bv()->selection().set())
|
||||
if (!cur.selection())
|
||||
bv()->owner()->message(_("Nothing to index!"));
|
||||
else if (bv()->selStart().par() != bv()->selEnd().par())
|
||||
else if (cur.selStart().par() != cur.selEnd().par())
|
||||
bv()->owner()->message(_("Cannot index more than one paragraph!"));
|
||||
else
|
||||
idxstring = selectionAsString(*bv()->buffer(), false);
|
||||
|
||||
// Reset cursors to their original position.
|
||||
cursor() = reset_cursor;
|
||||
bv()->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
|
||||
// Clear the implicit selection.
|
||||
if (implicitSelection)
|
||||
bv()->clearSelection();
|
||||
cur.clearSelection();
|
||||
|
||||
return idxstring;
|
||||
}
|
||||
@ -575,12 +579,13 @@ string LyXText::getStringToIndex()
|
||||
void LyXText::setParagraph(Spacing const & spacing, LyXAlignment align,
|
||||
string const & labelwidthstring, bool noindent)
|
||||
{
|
||||
LCursor & cur = bv()->cursor();
|
||||
// make sure that the depth behind the selection are restored, too
|
||||
ParagraphList::iterator undopit = undoSpan(getPar(bv()->selEnd()));
|
||||
recUndo(bv()->selStart().par(), parOffset(undopit) - 1);
|
||||
ParagraphList::iterator undopit = undoSpan(getPar(cur.selEnd()));
|
||||
recUndo(cur.selStart().par(), parOffset(undopit) - 1);
|
||||
|
||||
ParagraphList::reverse_iterator pit(getPar(bv()->selEnd().par()));
|
||||
ParagraphList::reverse_iterator beg(getPar(bv()->selStart().par()));
|
||||
ParagraphList::reverse_iterator pit(getPar(cur.selEnd().par()));
|
||||
ParagraphList::reverse_iterator beg(getPar(cur.selStart().par()));
|
||||
|
||||
for (--pit; pit != beg; ++pit) {
|
||||
ParagraphParameters & params = pit->params();
|
||||
@ -601,7 +606,7 @@ void LyXText::setParagraph(Spacing const & spacing, LyXAlignment align,
|
||||
params.noindent(noindent);
|
||||
}
|
||||
|
||||
redoParagraphs(getPar(bv()->selStart()), undopit);
|
||||
redoParagraphs(getPar(cur.selStart()), undopit);
|
||||
}
|
||||
|
||||
|
||||
@ -918,6 +923,7 @@ void LyXText::insertInset(InsetOld * inset)
|
||||
|
||||
void LyXText::cutSelection(bool doclear, bool realcut)
|
||||
{
|
||||
LCursor & cur = bv()->cursor();
|
||||
// Stuff what we got on the clipboard. Even if there is no selection.
|
||||
|
||||
// There is a problem with having the stuffing here in that the
|
||||
@ -929,32 +935,32 @@ void LyXText::cutSelection(bool doclear, bool realcut)
|
||||
bv()->stuffClipboard(selectionAsString(*bv()->buffer(), true));
|
||||
|
||||
// This doesn't make sense, if there is no selection
|
||||
if (!bv()->selection().set())
|
||||
if (!cur.selection())
|
||||
return;
|
||||
|
||||
// OK, we have a selection. This is always between bv()->selStart()
|
||||
// and bv()->selEnd()
|
||||
// OK, we have a selection. This is always between cur.selStart()
|
||||
// and cur.selEnd()
|
||||
|
||||
// make sure that the depth behind the selection are restored, too
|
||||
ParagraphList::iterator begpit = getPar(bv()->selStart().par());
|
||||
ParagraphList::iterator endpit = getPar(bv()->selEnd().par());
|
||||
ParagraphList::iterator begpit = getPar(cur.selStart().par());
|
||||
ParagraphList::iterator endpit = getPar(cur.selEnd().par());
|
||||
ParagraphList::iterator undopit = undoSpan(endpit);
|
||||
recUndo(bv()->selStart().par(), parOffset(undopit) - 1);
|
||||
recUndo(cur.selStart().par(), parOffset(undopit) - 1);
|
||||
|
||||
int endpos = bv()->selEnd().pos();
|
||||
int endpos = cur.selEnd().pos();
|
||||
|
||||
BufferParams const & bufparams = bv()->buffer()->params();
|
||||
boost::tie(endpit, endpos) = realcut ?
|
||||
CutAndPaste::cutSelection(bufparams,
|
||||
paragraphs(),
|
||||
begpit , endpit,
|
||||
bv()->selStart().pos(), endpos,
|
||||
cur.selStart().pos(), endpos,
|
||||
bufparams.textclass,
|
||||
doclear)
|
||||
: CutAndPaste::eraseSelection(bufparams,
|
||||
paragraphs(),
|
||||
begpit, endpit,
|
||||
bv()->selStart().pos(), endpos,
|
||||
cur.selStart().pos(), endpos,
|
||||
doclear);
|
||||
// sometimes necessary
|
||||
if (doclear)
|
||||
@ -968,40 +974,42 @@ void LyXText::cutSelection(bool doclear, bool realcut)
|
||||
cursor().par(parOffset(endpit));
|
||||
|
||||
// need a valid cursor. (Lgb)
|
||||
bv()->clearSelection();
|
||||
cur.clearSelection();
|
||||
updateCounters();
|
||||
}
|
||||
|
||||
|
||||
void LyXText::copySelection()
|
||||
{
|
||||
LCursor & cur = bv()->cursor();
|
||||
// stuff the selection onto the X clipboard, from an explicit copy request
|
||||
bv()->stuffClipboard(selectionAsString(*bv()->buffer(), true));
|
||||
|
||||
// this doesnt make sense, if there is no selection
|
||||
if (!bv()->selection().set())
|
||||
if (!cur.selection())
|
||||
return;
|
||||
|
||||
// ok we have a selection. This is always between bv()->selStart()
|
||||
// ok we have a selection. This is always between cur.selStart()
|
||||
// and sel_end cursor
|
||||
|
||||
// copy behind a space if there is one
|
||||
while (getPar(bv()->selStart())->size() > bv()->selStart().pos()
|
||||
&& getPar(bv()->selStart())->isLineSeparator(bv()->selStart().pos())
|
||||
&& (bv()->selStart().par() != bv()->selEnd().par()
|
||||
|| bv()->selStart().pos() < bv()->selEnd().pos()))
|
||||
bv()->selStart().pos(bv()->selStart().pos() + 1);
|
||||
while (getPar(cur.selStart())->size() > cur.selStart().pos()
|
||||
&& getPar(cur.selStart())->isLineSeparator(cur.selStart().pos())
|
||||
&& (cur.selStart().par() != cur.selEnd().par()
|
||||
|| cur.selStart().pos() < cur.selEnd().pos()))
|
||||
cur.selStart().pos(cur.selStart().pos() + 1);
|
||||
|
||||
CutAndPaste::copySelection(getPar(bv()->selStart().par()),
|
||||
getPar(bv()->selEnd().par()),
|
||||
bv()->selStart().pos(),
|
||||
bv()->selEnd().pos(),
|
||||
CutAndPaste::copySelection(getPar(cur.selStart().par()),
|
||||
getPar(cur.selEnd().par()),
|
||||
cur.selStart().pos(),
|
||||
cur.selEnd().pos(),
|
||||
bv()->buffer()->params().textclass);
|
||||
}
|
||||
|
||||
|
||||
void LyXText::pasteSelection(size_t sel_index)
|
||||
{
|
||||
LCursor & cur = bv()->cursor();
|
||||
// this does not make sense, if there is nothing to paste
|
||||
if (!CutAndPaste::checkPastePossible())
|
||||
return;
|
||||
@ -1024,10 +1032,10 @@ void LyXText::pasteSelection(size_t sel_index)
|
||||
|
||||
redoParagraphs(cursorPar(), endpit);
|
||||
|
||||
bv()->clearSelection();
|
||||
bv()->resetAnchor();
|
||||
cur.clearSelection();
|
||||
cur.resetAnchor();
|
||||
setCursor(ppp.first, ppp.second);
|
||||
bv()->setSelection();
|
||||
cur.setSelection();
|
||||
updateCounters();
|
||||
}
|
||||
|
||||
@ -1037,30 +1045,32 @@ void LyXText::setSelectionRange(lyx::pos_type length)
|
||||
if (!length)
|
||||
return;
|
||||
|
||||
bv()->resetAnchor();
|
||||
LCursor & cur = bv()->cursor();
|
||||
cur.resetAnchor();
|
||||
while (length--)
|
||||
cursorRight(true);
|
||||
bv()->setSelection();
|
||||
cur.setSelection();
|
||||
}
|
||||
|
||||
|
||||
// simple replacing. The font of the first selected character is used
|
||||
void LyXText::replaceSelectionWithString(string const & str)
|
||||
{
|
||||
recUndo(cursor().par());
|
||||
LCursor & cur = bv()->cursor();
|
||||
recUndo(cur.par());
|
||||
freezeUndo();
|
||||
|
||||
// Get font setting before we cut
|
||||
pos_type pos = bv()->selEnd().pos();
|
||||
LyXFont const font = getPar(bv()->selStart())
|
||||
pos_type pos = cur.selEnd().pos();
|
||||
LyXFont const font = getPar(cur.selStart())
|
||||
->getFontSettings(bv()->buffer()->params(),
|
||||
bv()->selStart().pos());
|
||||
cur.selStart().pos());
|
||||
|
||||
// Insert the new string
|
||||
string::const_iterator cit = str.begin();
|
||||
string::const_iterator end = str.end();
|
||||
for (; cit != end; ++cit) {
|
||||
getPar(bv()->selEnd())->insertChar(pos, (*cit), font);
|
||||
getPar(cur.selEnd())->insertChar(pos, (*cit), font);
|
||||
++pos;
|
||||
}
|
||||
|
||||
@ -1074,6 +1084,7 @@ void LyXText::replaceSelectionWithString(string const & str)
|
||||
// needed to insert the selection
|
||||
void LyXText::insertStringAsLines(string const & str)
|
||||
{
|
||||
LCursor & cur = bv()->cursor();
|
||||
ParagraphList::iterator pit = cursorPar();
|
||||
pos_type pos = cursor().pos();
|
||||
ParagraphList::iterator endpit = boost::next(cursorPar());
|
||||
@ -1081,13 +1092,13 @@ void LyXText::insertStringAsLines(string const & str)
|
||||
recUndo(cursor().par());
|
||||
|
||||
// only to be sure, should not be neccessary
|
||||
bv()->clearSelection();
|
||||
cur.clearSelection();
|
||||
bv()->buffer()->insertStringAsLines(pit, pos, current_font, str);
|
||||
|
||||
redoParagraphs(cursorPar(), endpit);
|
||||
bv()->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
setCursor(pit, pos);
|
||||
bv()->setSelection();
|
||||
cur.setSelection();
|
||||
}
|
||||
|
||||
|
||||
@ -1148,8 +1159,8 @@ void LyXText::setCursor(CursorSlice & cur, paroffset_type par,
|
||||
return;
|
||||
|
||||
// now some strict checking
|
||||
ParagraphList::iterator pit = getPar(par);
|
||||
Row const & row = *pit->getRow(pos);
|
||||
Paragraph & para = *getPar(par);
|
||||
Row const & row = *para.getRow(pos);
|
||||
pos_type const end = row.endpos();
|
||||
|
||||
// None of these should happen, but we're scaredy-cats
|
||||
@ -1158,9 +1169,9 @@ void LyXText::setCursor(CursorSlice & cur, paroffset_type par,
|
||||
pos = 0;
|
||||
cur.pos(0);
|
||||
BOOST_ASSERT(false);
|
||||
} else if (pos > pit->size()) {
|
||||
} else if (pos > para.size()) {
|
||||
lyxerr << "dont like 1, pos: " << pos
|
||||
<< " size: " << pit->size()
|
||||
<< " size: " << para.size()
|
||||
<< " row.pos():" << row.pos()
|
||||
<< " paroffset: " << par << endl;
|
||||
pos = 0;
|
||||
@ -1174,7 +1185,7 @@ void LyXText::setCursor(CursorSlice & cur, paroffset_type par,
|
||||
BOOST_ASSERT(false);
|
||||
} else if (pos < row.pos()) {
|
||||
lyxerr << "dont like 3 please report pos:" << pos
|
||||
<< " size: " << pit->size()
|
||||
<< " size: " << para.size()
|
||||
<< " row.pos():" << row.pos()
|
||||
<< " paroffset: " << par << endl;
|
||||
pos = row.pos();
|
||||
@ -1188,7 +1199,7 @@ void LyXText::setCursorIntern(paroffset_type par,
|
||||
pos_type pos, bool setfont, bool boundary)
|
||||
{
|
||||
setCursor(cursor(), par, pos, boundary);
|
||||
bv()->x_target(cursorX() + xo_);
|
||||
bv()->cursor().x_target(cursorX() + xo_);
|
||||
if (setfont)
|
||||
setCurrentFont();
|
||||
}
|
||||
@ -1196,7 +1207,8 @@ void LyXText::setCursorIntern(paroffset_type par,
|
||||
|
||||
void LyXText::setCurrentFont()
|
||||
{
|
||||
pos_type pos = cursor().pos();
|
||||
LCursor & cur = bv()->cursor();
|
||||
pos_type pos = cur.pos();
|
||||
ParagraphList::iterator pit = cursorPar();
|
||||
|
||||
if (cursor().boundary() && pos > 0)
|
||||
@ -1303,7 +1315,7 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
|
||||
|
||||
// If lastrow is false, we don't need to compute
|
||||
// the value of rtl.
|
||||
bool const rtl = (lastrow)
|
||||
bool const rtl = lastrow
|
||||
? pit->isRightToLeftPar(bv()->buffer()->params())
|
||||
: false;
|
||||
if (lastrow &&
|
||||
@ -1366,7 +1378,7 @@ bool LyXText::checkAndActivateInset(bool front)
|
||||
InsetOld * inset = cursorPar()->getInset(cursor().pos());
|
||||
if (!isHighlyEditableInset(inset))
|
||||
return false;
|
||||
inset->edit(bv(), front);
|
||||
inset->edit(bv()->cursor(), front);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1399,7 +1411,7 @@ DispatchResult LyXText::moveRightIntern(bool front, bool activate_inset, bool se
|
||||
return DispatchResult(true, true);
|
||||
cursorRight(true);
|
||||
if (!selecting)
|
||||
bv()->clearSelection();
|
||||
bv()->cursor().clearSelection();
|
||||
return DispatchResult(true);
|
||||
}
|
||||
|
||||
@ -1411,7 +1423,7 @@ DispatchResult LyXText::moveLeftIntern(bool front,
|
||||
return DispatchResult(false, FINISHED);
|
||||
cursorLeft(true);
|
||||
if (!selecting)
|
||||
bv()->clearSelection();
|
||||
bv()->cursor().clearSelection();
|
||||
if (activate_inset && checkAndActivateInset(front))
|
||||
return DispatchResult(true, true);
|
||||
return DispatchResult(true);
|
||||
@ -1423,35 +1435,37 @@ DispatchResult LyXText::moveUp()
|
||||
if (cursorPar() == firstPar() && cursorRow() == firstRow())
|
||||
return DispatchResult(false, FINISHED_UP);
|
||||
cursorUp(false);
|
||||
bv()->clearSelection();
|
||||
bv()->cursor().clearSelection();
|
||||
return DispatchResult(true);
|
||||
}
|
||||
|
||||
|
||||
DispatchResult LyXText::moveDown()
|
||||
{
|
||||
LCursor & cur = bv()->cursor();
|
||||
if (cursorPar() == lastPar() && cursorRow() == lastRow())
|
||||
return DispatchResult(false, FINISHED_DOWN);
|
||||
cursorDown(false);
|
||||
bv()->clearSelection();
|
||||
cur.clearSelection();
|
||||
return DispatchResult(true);
|
||||
}
|
||||
|
||||
|
||||
bool LyXText::cursorLeft(bool internal)
|
||||
{
|
||||
if (cursor().pos() > 0) {
|
||||
bool boundary = cursor().boundary();
|
||||
setCursor(cursor().par(), cursor().pos() - 1, true, false);
|
||||
LCursor & cur = bv()->cursor();
|
||||
if (cur.pos() > 0) {
|
||||
bool boundary = cur.boundary();
|
||||
setCursor(cur.par(), cur.pos() - 1, true, false);
|
||||
if (!internal && !boundary &&
|
||||
bidi.isBoundary(*bv()->buffer(), *cursorPar(), cursor().pos() + 1))
|
||||
setCursor(cursor().par(), cursor().pos() + 1, true, true);
|
||||
bidi.isBoundary(*bv()->buffer(), cur.paragraph(), cur.pos() + 1))
|
||||
setCursor(cur.par(), cur.pos() + 1, true, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cursor().par() != 0) {
|
||||
if (cur.par() != 0) {
|
||||
// steps into the paragraph above
|
||||
setCursor(cursor().par() - 1, boost::prior(cursorPar())->size());
|
||||
setCursor(cur.par() - 1, boost::prior(cursorPar())->size());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1461,21 +1475,22 @@ bool LyXText::cursorLeft(bool internal)
|
||||
|
||||
bool LyXText::cursorRight(bool internal)
|
||||
{
|
||||
if (!internal && cursor().boundary()) {
|
||||
setCursor(cursor().par(), cursor().pos(), true, false);
|
||||
LCursor & cur = bv()->cursor();
|
||||
if (!internal && cur.boundary()) {
|
||||
setCursor(cur.par(), cur.pos(), true, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cursor().pos() != cursorPar()->size()) {
|
||||
setCursor(cursor().par(), cursor().pos() + 1, true, false);
|
||||
if (!internal && bidi.isBoundary(*bv()->buffer(), *cursorPar(),
|
||||
cursor().pos()))
|
||||
setCursor(cursor().par(), cursor().pos(), true, true);
|
||||
if (cur.pos() != cur.lastpos()) {
|
||||
setCursor(cur.par(), cur.pos() + 1, true, false);
|
||||
if (!internal && bidi.isBoundary(*bv()->buffer(), cur.paragraph(),
|
||||
cur.pos()))
|
||||
setCursor(cur.par(), cur.pos(), true, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cursor().par() + 1 != int(paragraphs().size())) {
|
||||
setCursor(cursor().par() + 1, 0);
|
||||
if (cur.par() + 1 != int(paragraphs().size())) {
|
||||
setCursor(cur.par() + 1, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1485,32 +1500,34 @@ bool LyXText::cursorRight(bool internal)
|
||||
|
||||
void LyXText::cursorUp(bool selecting)
|
||||
{
|
||||
LCursor & cur = bv()->cursor();
|
||||
Row const & row = *cursorRow();
|
||||
int x = bv()->x_target() - xo_;
|
||||
int x = cur.x_target() - xo_;
|
||||
int y = cursorY() - row.baseline() - 1;
|
||||
setCursorFromCoordinates(x, y);
|
||||
|
||||
if (!selecting) {
|
||||
int y_abs = y + yo_ - bv()->top_y();
|
||||
InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y_abs);
|
||||
InsetOld * inset_hit = checkInsetHit(cur.x_target(), y_abs);
|
||||
if (inset_hit && isHighlyEditableInset(inset_hit))
|
||||
inset_hit->edit(bv(), bv()->x_target(), y_abs);
|
||||
inset_hit->edit(cur, cur.x_target(), y_abs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LyXText::cursorDown(bool selecting)
|
||||
{
|
||||
LCursor & cur = bv()->cursor();
|
||||
Row const & row = *cursorRow();
|
||||
int x = bv()->x_target() - xo_;
|
||||
int x = cur.x_target() - xo_;
|
||||
int y = cursorY() - row.baseline() + row.height() + 1;
|
||||
setCursorFromCoordinates(x, y);
|
||||
|
||||
if (!selecting) {
|
||||
int y_abs = y + yo_ - bv()->top_y();
|
||||
InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y_abs);
|
||||
InsetOld * inset_hit = checkInsetHit(cur.x_target(), y_abs);
|
||||
if (inset_hit && isHighlyEditableInset(inset_hit))
|
||||
inset_hit->edit(bv(), bv()->x_target(), y_abs);
|
||||
inset_hit->edit(cur, cur.x_target(), y_abs);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1553,8 +1570,8 @@ void LyXText::fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where)
|
||||
|
||||
// check also if we don't want to set the cursor on a spot behind the
|
||||
// pagragraph because we erased the last character.
|
||||
if (cur.pos() > getPar(cur)->size())
|
||||
cur.pos(getPar(cur)->size());
|
||||
if (cur.pos() > cur.lastpos())
|
||||
cur.pos() = cur.lastpos();
|
||||
}
|
||||
|
||||
|
||||
@ -1564,13 +1581,14 @@ bool LyXText::deleteEmptyParagraphMechanism(CursorSlice const & old_cursor)
|
||||
return false;
|
||||
|
||||
// Would be wrong to delete anything if we have a selection.
|
||||
if (bv()->selection().set())
|
||||
if (bv()->cursor().selection())
|
||||
return false;
|
||||
|
||||
// Don't do anything if the cursor is invalid
|
||||
if (old_cursor.par() == -1)
|
||||
return false;
|
||||
|
||||
#if 0
|
||||
// We allow all kinds of "mumbo-jumbo" when freespacing.
|
||||
ParagraphList::iterator const old_pit = getPar(old_cursor);
|
||||
if (old_pit->isFreeSpacing())
|
||||
@ -1685,6 +1703,7 @@ bool LyXText::deleteEmptyParagraphMechanism(CursorSlice const & old_cursor)
|
||||
bv()->resetAnchor();
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
271
src/text3.C
271
src/text3.C
@ -213,21 +213,20 @@ namespace {
|
||||
}
|
||||
|
||||
|
||||
void moveCursor(BufferView * bv, bool selecting)
|
||||
void moveCursor(LCursor & cur, bool selecting)
|
||||
{
|
||||
if (selecting || bv->selection().mark())
|
||||
bv->setSelection();
|
||||
|
||||
if (!bv->selection().set())
|
||||
bv->haveSelection(false);
|
||||
bv->switchKeyMap();
|
||||
if (selecting || cur.mark())
|
||||
cur.setSelection();
|
||||
if (!cur.selection())
|
||||
cur.bv().haveSelection(false);
|
||||
cur.bv().switchKeyMap();
|
||||
}
|
||||
|
||||
|
||||
void finishChange(BufferView * bv, bool selecting = false)
|
||||
{
|
||||
finishUndo();
|
||||
moveCursor(bv, selecting);
|
||||
moveCursor(bv->cursor(), selecting);
|
||||
bv->owner()->view_state_changed();
|
||||
}
|
||||
|
||||
@ -316,35 +315,36 @@ bool LyXText::gotoNextInset(vector<InsetOld::Code> const & codes,
|
||||
}
|
||||
|
||||
|
||||
void LyXText::gotoInset(vector<InsetOld::Code> const & codes,
|
||||
bool same_content)
|
||||
void LyXText::gotoInset(vector<InsetOld::Code> const & codes, bool same_content)
|
||||
{
|
||||
bv()->clearSelection();
|
||||
LCursor & cur = bv()->cursor();
|
||||
cur.clearSelection();
|
||||
|
||||
string contents;
|
||||
if (same_content && cursor().pos() < cursorPar()->size()
|
||||
&& cursorPar()->isInset(cursor().pos())) {
|
||||
InsetOld const * inset = cursorPar()->getInset(cursor().pos());
|
||||
if (same_content
|
||||
&& cur.pos() < cur.lastpos()
|
||||
&& cur.paragraph().isInset(cur.pos())) {
|
||||
InsetOld const * inset = cur.paragraph().getInset(cur.pos());
|
||||
if (find(codes.begin(), codes.end(), inset->lyxCode())
|
||||
!= codes.end())
|
||||
contents = static_cast<InsetCommand const *>(inset)->getContents();
|
||||
}
|
||||
|
||||
if (!gotoNextInset(codes, contents)) {
|
||||
if (cursor().pos() || cursorPar() != paragraphs().begin()) {
|
||||
if (cur.pos() || cur.par() != 0) {
|
||||
CursorSlice tmp = cursor();
|
||||
cursor().par(0);
|
||||
cursor().pos(0);
|
||||
cur.par() = 0;
|
||||
cur.pos() = 0;
|
||||
if (!gotoNextInset(codes, contents)) {
|
||||
cursor() = tmp;
|
||||
bv()->owner()->message(_("No more insets"));
|
||||
cur.bv().owner()->message(_("No more insets"));
|
||||
}
|
||||
} else {
|
||||
bv()->owner()->message(_("No more insets"));
|
||||
cur.bv().owner()->message(_("No more insets"));
|
||||
}
|
||||
}
|
||||
bv()->update();
|
||||
bv()->resetAnchor();
|
||||
cur.bv().update();
|
||||
cur.resetAnchor();
|
||||
}
|
||||
|
||||
|
||||
@ -356,15 +356,15 @@ void LyXText::gotoInset(InsetOld::Code code, bool same_content)
|
||||
|
||||
void LyXText::cursorPrevious()
|
||||
{
|
||||
|
||||
LCursor & cur = bv()->cursor();
|
||||
RowList::iterator crit = cursorRow();
|
||||
ParagraphList::iterator cpar = cursorPar();
|
||||
lyx::paroffset_type cpar = cur.par();
|
||||
|
||||
int x = bv()->x_target() - xo_;
|
||||
int x = bv()->cursor().x_target() - xo_;
|
||||
int y = bv()->top_y() - yo_;
|
||||
setCursorFromCoordinates(x, y);
|
||||
|
||||
if (cpar == cursorPar() && crit == cursorRow()) {
|
||||
if (cpar == cur.par() && crit == cursorRow()) {
|
||||
// we have a row which is taller than the workarea. The
|
||||
// simplest solution is to move to the previous row instead.
|
||||
cursorUp(true);
|
||||
@ -380,7 +380,7 @@ void LyXText::cursorNext()
|
||||
RowList::iterator crit = cursorRow();
|
||||
ParagraphList::iterator cpar = cursorPar();
|
||||
|
||||
int x = bv()->x_target() - xo_;
|
||||
int x = bv()->cursor().x_target() - xo_;
|
||||
int y = bv()->top_y() + bv()->workHeight() - yo_;
|
||||
setCursorFromCoordinates(x, y);
|
||||
|
||||
@ -417,17 +417,18 @@ void doInsertInset(BufferView * bv, FuncRequest const & cmd,
|
||||
return;
|
||||
|
||||
bool gotsel = false;
|
||||
if (bv->selection().set()) {
|
||||
if (bv->cursor().selection()) {
|
||||
bv->owner()->dispatch(FuncRequest(LFUN_CUT));
|
||||
gotsel = true;
|
||||
}
|
||||
if (bv->insertInset(inset)) {
|
||||
if (edit)
|
||||
inset->edit(bv, true);
|
||||
inset->edit(bv->cursor(), true);
|
||||
if (gotsel && pastesel)
|
||||
bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
|
||||
} else
|
||||
} else {
|
||||
delete inset;
|
||||
}
|
||||
}
|
||||
|
||||
} // anon namespace
|
||||
@ -447,11 +448,11 @@ bool LyXText::rtl() const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
//lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
|
||||
|
||||
BufferView * bv = &view;
|
||||
BufferView * bv = &cur.bv();
|
||||
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -483,26 +484,26 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
case LFUN_DELETE_WORD_FORWARD:
|
||||
bv->clearSelection();
|
||||
cur.clearSelection();
|
||||
deleteWordForward();
|
||||
finishChange(bv);
|
||||
break;
|
||||
|
||||
case LFUN_DELETE_WORD_BACKWARD:
|
||||
bv->clearSelection();
|
||||
cur.clearSelection();
|
||||
deleteWordBackward();
|
||||
finishChange(bv);
|
||||
break;
|
||||
|
||||
case LFUN_DELETE_LINE_FORWARD:
|
||||
bv->clearSelection();
|
||||
cur.clearSelection();
|
||||
deleteLineForward();
|
||||
finishChange(bv);
|
||||
break;
|
||||
|
||||
case LFUN_WORDRIGHT:
|
||||
if (!bv->selection().mark())
|
||||
bv->clearSelection();
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
if (rtl())
|
||||
cursorLeftOneWord();
|
||||
else
|
||||
@ -511,8 +512,8 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_WORDLEFT:
|
||||
if (!bv->selection().mark())
|
||||
bv->clearSelection();
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
if (rtl())
|
||||
cursorRightOneWord();
|
||||
else
|
||||
@ -521,98 +522,98 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_BEGINNINGBUF:
|
||||
if (!bv->selection().mark())
|
||||
bv->clearSelection();
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
cursorTop();
|
||||
finishChange(bv);
|
||||
break;
|
||||
|
||||
case LFUN_ENDBUF:
|
||||
if (bv->selection().mark())
|
||||
bv->clearSelection();
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
cursorBottom();
|
||||
finishChange(bv);
|
||||
break;
|
||||
|
||||
case LFUN_RIGHTSEL:
|
||||
if (!bv->selection().set())
|
||||
bv->resetAnchor();
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
if (rtl())
|
||||
cursorLeft(bv);
|
||||
cursorLeft(true);
|
||||
else
|
||||
cursorRight(bv);
|
||||
cursorRight(true);
|
||||
finishChange(bv, true);
|
||||
break;
|
||||
|
||||
case LFUN_LEFTSEL:
|
||||
if (!bv->selection().set())
|
||||
bv->resetAnchor();
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
if (rtl())
|
||||
cursorRight(bv);
|
||||
cursorRight(true);
|
||||
else
|
||||
cursorLeft(bv);
|
||||
cursorLeft(true);
|
||||
finishChange(bv, true);
|
||||
break;
|
||||
|
||||
case LFUN_UPSEL:
|
||||
if (!bv->selection().set())
|
||||
bv->resetAnchor();
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
cursorUp(true);
|
||||
finishChange(bv, true);
|
||||
break;
|
||||
|
||||
case LFUN_DOWNSEL:
|
||||
if (!bv->selection().set())
|
||||
bv->resetAnchor();
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
cursorDown(true);
|
||||
finishChange(bv, true);
|
||||
break;
|
||||
|
||||
case LFUN_UP_PARAGRAPHSEL:
|
||||
if (!bv->selection().set())
|
||||
bv->resetAnchor();
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
cursorUpParagraph();
|
||||
finishChange(bv, true);
|
||||
break;
|
||||
|
||||
case LFUN_DOWN_PARAGRAPHSEL:
|
||||
if (!bv->selection().set())
|
||||
bv->resetAnchor();
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
cursorDownParagraph();
|
||||
finishChange(bv, true);
|
||||
break;
|
||||
|
||||
case LFUN_PRIORSEL:
|
||||
if (!bv->selection().set())
|
||||
bv->resetAnchor();
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
cursorPrevious();
|
||||
finishChange(bv, true);
|
||||
break;
|
||||
|
||||
case LFUN_NEXTSEL:
|
||||
if (!bv->selection().set())
|
||||
bv->resetAnchor();
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
cursorNext();
|
||||
finishChange(bv, true);
|
||||
break;
|
||||
|
||||
case LFUN_HOMESEL:
|
||||
if (!bv->selection().set())
|
||||
bv->resetAnchor();
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
cursorHome();
|
||||
finishChange(bv, true);
|
||||
break;
|
||||
|
||||
case LFUN_ENDSEL:
|
||||
if (!bv->selection().set())
|
||||
bv->resetAnchor();
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
cursorEnd();
|
||||
finishChange(bv, true);
|
||||
break;
|
||||
|
||||
case LFUN_WORDRIGHTSEL:
|
||||
if (!bv->selection().set())
|
||||
bv->resetAnchor();
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
if (rtl())
|
||||
cursorLeftOneWord();
|
||||
else
|
||||
@ -621,8 +622,8 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_WORDLEFTSEL:
|
||||
if (!bv->selection().set())
|
||||
bv->resetAnchor();
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
if (rtl())
|
||||
cursorRightOneWord();
|
||||
else
|
||||
@ -653,22 +654,22 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
return moveDown();
|
||||
|
||||
case LFUN_UP_PARAGRAPH:
|
||||
if (!bv->selection().mark())
|
||||
bv->clearSelection();
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
cursorUpParagraph();
|
||||
finishChange(bv);
|
||||
break;
|
||||
|
||||
case LFUN_DOWN_PARAGRAPH:
|
||||
if (!bv->selection().mark())
|
||||
bv->clearSelection();
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
cursorDownParagraph();
|
||||
finishChange(bv, false);
|
||||
break;
|
||||
|
||||
case LFUN_PRIOR:
|
||||
if (!bv->selection().mark())
|
||||
bv->clearSelection();
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
finishChange(bv, false);
|
||||
if (cursorPar() == firstPar() && cursorRow() == firstRow())
|
||||
return DispatchResult(false, FINISHED_UP);
|
||||
@ -676,8 +677,8 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_NEXT:
|
||||
if (!bv->selection().mark())
|
||||
bv->clearSelection();
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
finishChange(bv, false);
|
||||
if (cursorPar() == lastPar() && cursorRow() == lastRow())
|
||||
return DispatchResult(false, FINISHED_DOWN);
|
||||
@ -685,15 +686,15 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_HOME:
|
||||
if (!bv->selection().mark())
|
||||
bv->clearSelection();
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
cursorHome();
|
||||
finishChange(bv, false);
|
||||
break;
|
||||
|
||||
case LFUN_END:
|
||||
if (!bv->selection().mark())
|
||||
bv->clearSelection();
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
cursorEnd();
|
||||
finishChange(bv, false);
|
||||
break;
|
||||
@ -707,34 +708,34 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
|
||||
replaceSelection(bv->getLyXText());
|
||||
insertInset(new InsetNewline);
|
||||
moveCursor(bv, false);
|
||||
moveCursor(cur, false);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_DELETE:
|
||||
if (!bv->selection().set()) {
|
||||
if (!cur.selection()) {
|
||||
Delete();
|
||||
bv->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
// It is possible to make it a lot faster still
|
||||
// just comment out the line below...
|
||||
} else {
|
||||
cutSelection(true, false);
|
||||
}
|
||||
moveCursor(bv, false);
|
||||
moveCursor(cur, false);
|
||||
bv->owner()->view_state_changed();
|
||||
break;
|
||||
|
||||
case LFUN_DELETE_SKIP:
|
||||
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
|
||||
if (!bv->selection().set()) {
|
||||
if (!cur.selection()) {
|
||||
if (cursor().pos() == cursorPar()->size()) {
|
||||
cursorRight(bv);
|
||||
cursorLeft(bv);
|
||||
Delete();
|
||||
bv->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
} else {
|
||||
Delete();
|
||||
bv->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
}
|
||||
} else {
|
||||
cutSelection(true, false);
|
||||
@ -744,10 +745,10 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
|
||||
|
||||
case LFUN_BACKSPACE:
|
||||
if (!bv->selection().set()) {
|
||||
if (!cur.selection()) {
|
||||
if (bv->owner()->getIntl().getTransManager().backspace()) {
|
||||
backspace();
|
||||
bv->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
// It is possible to make it a lot faster still
|
||||
// just comment out the line below...
|
||||
}
|
||||
@ -761,7 +762,7 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
|
||||
case LFUN_BACKSPACE_SKIP:
|
||||
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
|
||||
if (!bv->selection().set()) {
|
||||
if (!cur.selection()) {
|
||||
CursorSlice cur = cursor();
|
||||
backspace();
|
||||
anchor() = cur;
|
||||
@ -775,7 +776,7 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
replaceSelection(bv->getLyXText());
|
||||
breakParagraph(bv->buffer()->paragraphs(), 0);
|
||||
bv->update();
|
||||
bv->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
bv->switchKeyMap();
|
||||
bv->owner()->view_state_changed();
|
||||
break;
|
||||
@ -784,7 +785,7 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
replaceSelection(bv->getLyXText());
|
||||
breakParagraph(bv->buffer()->paragraphs(), 1);
|
||||
bv->update();
|
||||
bv->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
bv->switchKeyMap();
|
||||
bv->owner()->view_state_changed();
|
||||
break;
|
||||
@ -856,13 +857,10 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
case LFUN_INSET_APPLY: {
|
||||
string const name = cmd.getArg(0);
|
||||
InsetBase * inset = bv->owner()->getDialogs().getOpenInset(name);
|
||||
if (inset) {
|
||||
FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument);
|
||||
inset->dispatch(*bv, fr);
|
||||
} else {
|
||||
FuncRequest fr(LFUN_INSET_INSERT, cmd.argument);
|
||||
dispatch(*bv, fr);
|
||||
}
|
||||
if (inset)
|
||||
inset->dispatch(cur, FuncRequest(LFUN_INSET_MODIFY, cmd.argument));
|
||||
else
|
||||
dispatch(cur, FuncRequest(LFUN_INSET_INSERT, cmd.argument));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -874,11 +872,12 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
case LFUN_INSET_SETTINGS:
|
||||
bv->fullCursor().innerInset()->showInsetDialog(bv);
|
||||
if (cur.inset() && cur.inset()->asUpdatableInset())
|
||||
cur.inset()->asUpdatableInset()->showInsetDialog(bv);
|
||||
break;
|
||||
|
||||
case LFUN_INSET_TOGGLE:
|
||||
bv->clearSelection();
|
||||
cur.clearSelection();
|
||||
if (!toggleInset())
|
||||
return DispatchResult(false);
|
||||
bv->update();
|
||||
@ -890,7 +889,7 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
insertChar(' ');
|
||||
else
|
||||
doInsertInset(bv, cmd, false, false);
|
||||
moveCursor(bv, false);
|
||||
moveCursor(cur, false);
|
||||
break;
|
||||
|
||||
case LFUN_HYPHENATION:
|
||||
@ -942,7 +941,7 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
pasteSelection(strToUnsignedInt(cmd.argument));
|
||||
else
|
||||
pasteSelection(0);
|
||||
bv->clearSelection(); // bug 393
|
||||
cur.clearSelection(); // bug 393
|
||||
bv->update();
|
||||
bv->switchKeyMap();
|
||||
finishUndo();
|
||||
@ -962,8 +961,8 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
case LFUN_BEGINNINGBUFSEL:
|
||||
if (in_inset_)
|
||||
return DispatchResult(false);
|
||||
if (!bv->selection().set())
|
||||
bv->resetAnchor();
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
cursorTop();
|
||||
finishChange(bv, true);
|
||||
break;
|
||||
@ -971,8 +970,8 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
case LFUN_ENDBUFSEL:
|
||||
if (in_inset_)
|
||||
return DispatchResult(false);
|
||||
if (!bv->selection().set())
|
||||
bv->resetAnchor();
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
cursorBottom();
|
||||
finishChange(bv, true);
|
||||
break;
|
||||
@ -1042,11 +1041,11 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
|
||||
bool change_layout = (current_layout != layout);
|
||||
|
||||
if (!change_layout && bv->selection().set() &&
|
||||
bv->selStart().par() != bv->selEnd().par())
|
||||
if (!change_layout && cur.selection() &&
|
||||
cur.selStart().par() != cur.selEnd().par())
|
||||
{
|
||||
ParagraphList::iterator spit = getPar(bv->selStart());
|
||||
ParagraphList::iterator epit = boost::next(getPar(bv->selEnd()));
|
||||
ParagraphList::iterator spit = getPar(cur.selStart());
|
||||
ParagraphList::iterator epit = boost::next(getPar(cur.selEnd()));
|
||||
while (spit != epit) {
|
||||
if (spit->layout()->name() != current_layout) {
|
||||
change_layout = true;
|
||||
@ -1067,7 +1066,7 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
case LFUN_PASTESELECTION: {
|
||||
bv->clearSelection();
|
||||
cur.clearSelection();
|
||||
string const clip = bv->getClipboard();
|
||||
if (!clip.empty()) {
|
||||
if (cmd.argument == "paragraph")
|
||||
@ -1134,31 +1133,27 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
for (int i = 0; i < datetmp_len; i++)
|
||||
insertChar(datetmp[i]);
|
||||
|
||||
bv->resetAnchor();
|
||||
moveCursor(bv, false);
|
||||
cur.resetAnchor();
|
||||
moveCursor(cur, false);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_MOUSE_TRIPLE:
|
||||
if (!bv->buffer())
|
||||
break;
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
if (bv->buffer() && cmd.button() == mouse_button::button1) {
|
||||
selection_possible = true;
|
||||
cursorHome();
|
||||
bv->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
cursorEnd();
|
||||
bv->setSelection();
|
||||
bv->haveSelection(bv->selection().set());
|
||||
cur.setSelection();
|
||||
bv->haveSelection(cur.selection());
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_DOUBLE:
|
||||
if (!bv->buffer())
|
||||
break;
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
if (bv->buffer() && cmd.button() == mouse_button::button1) {
|
||||
selection_possible = true;
|
||||
selectWord(lyx::WHOLE_WORD_STRICT);
|
||||
bv->haveSelection(bv->selection().set());
|
||||
bv->haveSelection(cur.selection());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1189,7 +1184,7 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
else if (cmd.y - bv->top_y() < 0)
|
||||
cursorUp(true);
|
||||
}
|
||||
bv->setSelection();
|
||||
cur.setSelection();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1216,7 +1211,7 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
// it could get cleared on the unlocking of the inset so
|
||||
// we have to check this first
|
||||
bool paste_internally = false;
|
||||
if (cmd.button() == mouse_button::button2 && bv->selection().set()) {
|
||||
if (cmd.button() == mouse_button::button2 && cur.selection()) {
|
||||
bv->owner()->dispatch(FuncRequest(LFUN_COPY));
|
||||
paste_internally = true;
|
||||
}
|
||||
@ -1224,7 +1219,7 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
selection_possible = true;
|
||||
|
||||
// Clear the selection
|
||||
bv->clearSelection();
|
||||
cur.clearSelection();
|
||||
|
||||
// Right click on a footnote flag opens float menu
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
@ -1233,9 +1228,9 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
setCursorFromCoordinates(cmd.x, cmd.y);
|
||||
bv->resetAnchor();
|
||||
cur.resetAnchor();
|
||||
finishUndo();
|
||||
bv->x_target(cursorX() + xo_);
|
||||
cur.x_target(cursorX() + xo_);
|
||||
|
||||
if (bv->fitCursor())
|
||||
selection_possible = false;
|
||||
@ -1269,7 +1264,7 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
|
||||
// finish selection
|
||||
if (cmd.button() == mouse_button::button1)
|
||||
bv->haveSelection(bv->selection().set());
|
||||
bv->haveSelection(cur.selection());
|
||||
|
||||
bv->switchKeyMap();
|
||||
bv->owner()->view_state_changed();
|
||||
@ -1289,12 +1284,12 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
// true (on).
|
||||
|
||||
if (lyxrc.auto_region_delete) {
|
||||
if (bv->selection().set())
|
||||
if (cur.selection())
|
||||
cutSelection(false, false);
|
||||
bv->haveSelection(false);
|
||||
}
|
||||
|
||||
bv->clearSelection();
|
||||
cur.clearSelection();
|
||||
LyXFont const old_font = real_current_font;
|
||||
|
||||
string::const_iterator cit = cmd.argument.begin();
|
||||
@ -1303,8 +1298,8 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
bv->owner()->getIntl().getTransManager().
|
||||
TranslateAndInsert(*cit, this);
|
||||
|
||||
bv->resetAnchor();
|
||||
moveCursor(bv, false);
|
||||
cur.resetAnchor();
|
||||
moveCursor(cur, false);
|
||||
|
||||
// real_current_font.number can change so we need to
|
||||
// update the minibuffer
|
||||
@ -1397,7 +1392,7 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
case LFUN_MATH_NUMBER:
|
||||
case LFUN_MATH_EXTERN:
|
||||
case LFUN_MATH_SIZE:
|
||||
mathDispatch(*bv, cmd);
|
||||
mathDispatch(cur, cmd);
|
||||
break;
|
||||
|
||||
case LFUN_EMPH:
|
||||
@ -1462,7 +1457,7 @@ DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
|
||||
case LFUN_FINISHED_LEFT:
|
||||
lyxerr << "swallow LFUN_FINISHED_LEFT" << endl;
|
||||
if (rtl())
|
||||
cursorRight(true);
|
||||
cursorLeft(true);
|
||||
break;
|
||||
|
||||
case LFUN_FINISHED_RIGHT:
|
||||
|
17
src/undo.C
17
src/undo.C
@ -17,7 +17,7 @@
|
||||
#include "undo.h"
|
||||
|
||||
#include "buffer.h"
|
||||
#include "cursor_slice.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "BufferView.h"
|
||||
#include "iterators.h"
|
||||
@ -179,12 +179,13 @@ bool performUndoOrRedo(BufferView * bv, Undo const & undo)
|
||||
<< std::endl;
|
||||
|
||||
// set cursor again to force the position to be the right one
|
||||
bv->cursor().par(undo.cursor_par);
|
||||
bv->cursor().pos(undo.cursor_pos);
|
||||
LCursor & cur = bv->cursor();
|
||||
cur.par() = undo.cursor_par;
|
||||
cur.pos() = undo.cursor_pos;
|
||||
|
||||
// clear any selection
|
||||
bv->clearSelection();
|
||||
bv->resetAnchor();
|
||||
cur.clearSelection();
|
||||
cur.resetAnchor();
|
||||
text->updateCounters();
|
||||
|
||||
// rebreak the entire lyxtext
|
||||
@ -293,11 +294,11 @@ void recordUndo(Undo::undo_kind kind, LyXText const * text, paroffset_type par)
|
||||
|
||||
void recordUndo(BufferView * bv, Undo::undo_kind kind)
|
||||
{
|
||||
recordUndo(*bv, kind);
|
||||
recordUndo(bv->cursor(), kind);
|
||||
}
|
||||
|
||||
|
||||
void recordUndo(BufferView & bv, Undo::undo_kind kind)
|
||||
void recordUndo(LCursor & cur, Undo::undo_kind kind)
|
||||
{
|
||||
recordUndo(kind, bv.text(), bv.text()->cursor().par());
|
||||
recordUndo(kind, cur.bv().text(), cur.bv().text()->cursor().par());
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "ParagraphList_fwd.h"
|
||||
#include "support/types.h"
|
||||
|
||||
class LCursor;
|
||||
class LyXText;
|
||||
class BufferView;
|
||||
|
||||
@ -110,7 +111,7 @@ void recordUndo(Undo::undo_kind kind,
|
||||
|
||||
/// convienience: prepare undo for the paragraph that contains the cursor
|
||||
void recordUndo(BufferView *, Undo::undo_kind kind);
|
||||
void recordUndo(BufferView &, Undo::undo_kind kind);
|
||||
void recordUndo(LCursor &, Undo::undo_kind kind);
|
||||
|
||||
/// are we avoiding tracking undos currently?
|
||||
extern bool undo_frozen;
|
||||
|
Loading…
x
Reference in New Issue
Block a user