case LFUN_MOUSE_MOTION: {
if (!available())
return false;
- FuncRequest cmd1(cmd, bv_);
+ FuncRequest cmd1 = cmd;
UpdatableInset * inset = bv_->fullCursor().innerInset();
DispatchResult res;
if (inset) {
cmd1.x -= inset->x();
cmd1.y -= inset->y();
- res = inset->dispatch(cmd1);
+ res = inset->dispatch(*bv_, cmd1);
} else {
cmd1.y += bv_->top_y();
- res = bv_->fullCursor().innerText()->dispatch(cmd1);
+ res = bv_->fullCursor().innerText()->dispatch(*bv_, cmd1);
}
if (bv_->fitCursor() || res.update()) {
// built temporary path to inset
InsetOld * inset = insetFromCoords(bv_, cmd.x, cmd.y);
- FuncRequest cmd1(cmd, bv_);
DispatchResult res;
// try to dispatch to that inset
if (inset) {
- FuncRequest cmd2 = cmd1;
+ FuncRequest cmd2 = cmd;
lyxerr << "dispatching action " << cmd2.action
<< " to inset " << inset << endl;
cmd2.x -= inset->x();
cmd2.y -= inset->y();
- res = inset->dispatch(cmd2);
+ res = inset->dispatch(*bv_, cmd2);
if (res.update()) {
bv_->update();
bv_->fullCursor().updatePos();
// otherwise set cursor to surrounding LyXText
if (!res.dispatched()) {
lyxerr << "temp cursor is: " << theTempCursor << endl;
- lyxerr << "dispatching " << cmd1
+ lyxerr << "dispatching " << cmd
<< " to surrounding LyXText "
<< theTempCursor.innerText() << endl;
bv_->fullCursor(theTempCursor);
+ FuncRequest cmd1 = cmd;
cmd1.y += bv_->top_y();
- res = bv_->fullCursor().innerText()->dispatch(cmd1);
+ res = bv_->fullCursor().innerText()->dispatch(*bv_, cmd1);
if (bv_->fitCursor() || res.update())
bv_->update();
}
-bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
+bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
{
// Make sure that the cached BufferView is correct.
- FuncRequest ev = ev_in;
- ev.setView(bv_);
-
lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch:"
<< " action[" << ev.action << ']'
<< " arg[" << ev.argument << ']'
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(ev);
+ mathDispatch(*bv_, ev);
break;
case LFUN_INSET_INSERT: {
// Same as above.
BOOST_ASSERT(false);
- InsetOld * inset = createInset(ev);
+ InsetOld * inset = createInset(bv_, ev);
if (!inset || !insertInset(inset))
delete inset;
break;
}
case LFUN_WORD_FIND:
- lyx::find::find(ev);
+ lyx::find::find(bv_, ev);
break;
case LFUN_WORD_REPLACE:
- lyx::find::replace(ev);
+ lyx::find::replace(bv_, ev);
break;
case LFUN_MARK_OFF:
break;
default:
- return bv_->getLyXText()->dispatch(FuncRequest(ev, bv_)).dispatched();
+ return bv_->getLyXText()->dispatch(*bv_, ev).dispatched();
} // end of switch
return true;
+
+2004-01-15 André Pönitz <poenitz@gmx.net>
+
+ * cursor_slice.[Ch]: add a few covienience functions
+
+ * funcrequest.[Ch]: remove BufferView * member
+
+ * BufferView_pimpl.C:
+ * cursor.C:
+ * factory.[Ch]:
+ * lyxfind.[Ch]:
+ * lyxfunc.C:
+ * lyxtext.h:
+ * text3.C:
+ * undo.[Ch]: adjust to this and changed signature of Inset::priv_dispatch()
+
2004-01-14 Alfredo Braunstein <abraunst@lyx.org>
* text.C (getWord): fix getWord (and thus LFUN_WORDSEL)
for (int i = cursor_.size() - 1; i >= 1; --i) {
CursorSlice const & citem = cursor_[i];
lyxerr << "trying to dispatch to inset " << citem.inset_ << endl;
- DispatchResult res = citem.inset_->dispatch(cmd);
+ DispatchResult res = citem.inset_->dispatch(*bv_, cmd);
if (res.dispatched()) {
lyxerr << " successfully dispatched to inset " << citem.inset_ << endl;
return DispatchResult(true, true);
switch (res.val()) {
case FINISHED:
pop(i);
- cmd = FuncRequest(bv_, LFUN_FINISHED_LEFT);
+ cmd = FuncRequest(LFUN_FINISHED_LEFT);
break;
case FINISHED_RIGHT:
pop(i);
- cmd = FuncRequest(bv_, LFUN_FINISHED_RIGHT);
+ cmd = FuncRequest(LFUN_FINISHED_RIGHT);
break;
case FINISHED_UP:
pop(i);
- cmd = FuncRequest(bv_, LFUN_FINISHED_UP);
+ cmd = FuncRequest(LFUN_FINISHED_UP);
break;
case FINISHED_DOWN:
pop(i);
- cmd = FuncRequest(bv_, LFUN_FINISHED_DOWN);
+ cmd = FuncRequest(LFUN_FINISHED_DOWN);
break;
default:
lyxerr << "not handled on level " << i << " val: " << res.val() << endl;
}
}
lyxerr << "trying to dispatch to main text " << bv_->text() << endl;
- DispatchResult res = bv_->text()->dispatch(cmd);
+ DispatchResult res = bv_->text()->dispatch(*bv_, cmd);
lyxerr << " result: " << res.val() << endl;
if (!res.dispatched()) {
}
-void LCursor::push(UpdatableInset * inset)
+void LCursor::push(InsetBase * inset)
{
lyxerr << "LCursor::push() inset: " << inset << endl;
cursor_.push_back(CursorSlice(inset));
// inset->draw() is not called: this doesn't update
// inset.top_baseline, so getCursor() returns an old value.
// Ugly as you like.
- inset->getCursorPos(cursor_.back().idx_, x, y);
- x += inset->x();
- y += cached_y_;
+ if (inset) {
+ inset->getCursorPos(cursor_.back().idx_, x, y);
+ x += inset->x();
+ y += cached_y_;
+ }
}
}
/// dispatch from innermost inset upwards
DispatchResult dispatch(FuncRequest const & cmd);
///
- void push(UpdatableInset * inset);
+ void push(InsetBase * inset);
/// restrict cursor nesting to given size
void pop(int depth);
/// pop one level off the cursor
}
+CursorSlice::idx_type & CursorSlice::idx()
+{
+ return idx_;
+}
+
+
void CursorSlice::par(par_type par)
{
par_ = par;
}
+CursorSlice::par_type & CursorSlice::par()
+{
+ return par_;
+}
+
+
void CursorSlice::pos(pos_type pos)
{
pos_ = pos;
}
+CursorSlice::pos_type & CursorSlice::pos()
+{
+ return pos_;
+}
+
+
+CursorSlice::pos_type CursorSlice::lastpos() const
+{
+ BOOST_ASSERT(inset_);
+#warning implement me for texted, too.
+ return inset_->asMathInset() ? cell().size() : 0;
+}
+
+
void CursorSlice::boundary(bool boundary)
{
boundary_ = boundary;
}
-MathInset * CursorSlice::asMathInset() const
+CursorSlice::row_type CursorSlice::row() const
{
- return inset_ ? inset_->asMathInset() : 0;
+ BOOST_ASSERT(asMathInset());
+ asMathInset()->row(idx_);
}
-UpdatableInset * CursorSlice::asUpdatableInset() const
+CursorSlice::col_type CursorSlice::col() const
{
- return inset_ ? inset_->asUpdatableInset() : 0;
+ BOOST_ASSERT(asMathInset());
+ asMathInset()->col(idx_);
}
-void CursorSlice::cell(CursorSlice::idx_type idx) const
+MathInset * CursorSlice::asMathInset() const
{
- BOOST_ASSERT(asMathInset());
- asMathInset()->cell(idx);
+ return inset_ ? inset_->asMathInset() : 0;
+}
+
+
+UpdatableInset * CursorSlice::asUpdatableInset() const
+{
+ return inset_ ? inset_->asUpdatableInset() : 0;
}
typedef lyx::paroffset_type par_type;
/// type for cursor positions within a cell
typedef lyx::pos_type pos_type;
+ /// type for row indices
+ typedef size_t row_type;
+ /// type for col indices
+ typedef size_t col_type;
///
CursorSlice();
void idx(idx_type idx);
/// return the paragraph this cursor is in
idx_type idx() const;
+ /// return the paragraph this cursor is in
+ idx_type & idx();
/// set the paragraph that contains this cursor
void par(par_type par);
/// return the paragraph this cursor is in
par_type par() const;
+ /// return the paragraph this cursor is in
+ par_type & par();
/// set the position within the paragraph
void pos(pos_type pos);
/// return the position within the paragraph
pos_type pos() const;
+ /// return the position within the paragraph
+ pos_type & pos();
+ /// return the last position within the paragraph
+ pos_type lastpos() const;
+ /// return the grid row of the current cell
+ row_type row() const;
+ /// return the grid row of the current cell
+ col_type col() const;
/// FIXME
void boundary(bool b);
///
/// returns cell corresponding to this position
MathArray & cell() const;
- /// set cell corresponding to this position
- void cell(idx_type idx) const;
/// gets screen position of the thing
void getScreenPos(int & x, int & y) const;
///
using std::string;
-InsetOld * createInset(FuncRequest const & cmd)
+InsetOld * createInset(BufferView * bv, FuncRequest const & cmd)
{
- BufferView * bv = cmd.view();
BufferParams const & params = bv->buffer()->params();
switch (cmd.action) {
if (icp.getContents().empty()) {
lv->getDialogs().show("index", data, 0);
} else {
- lv->dispatch(FuncRequest(bv, LFUN_INSET_APPLY, data));
+ lv->dispatch(FuncRequest(LFUN_INSET_APPLY, data));
}
return 0;
}
return new InsetERT(params, st);
} else if (name == "external") {
- Buffer const & buffer = *cmd.view()->buffer();
+ Buffer const & buffer = *bv->buffer();
InsetExternalParams iep;
InsetExternalMailer::string2params(cmd.argument,
buffer, iep);
return inset.release();
} else if (name == "graphics") {
- Buffer const & buffer = *cmd.view()->buffer();
+ Buffer const & buffer = *bv->buffer();
InsetGraphicsParams igp;
InsetGraphicsMailer::string2params(cmd.argument,
buffer, igp);
#ifndef FACTORY_H
#define FACTORY_H
-class InsetOld;
+class Buffer;
+class BufferView;
class FuncRequest;
+class InsetOld;
class LyXLex;
-class Buffer;
+
/// creates inset according to 'cmd'
-InsetOld * createInset(FuncRequest const & cmd);
+InsetOld * createInset(BufferView * bv, FuncRequest const & cmd);
/// read inset from a file
InsetOld * readInset(LyXLex & lex, Buffer const & buf);
}
-void LyXView::dispatch(FuncRequest const & req)
+void LyXView::dispatch(FuncRequest const & cmd)
{
- // substitute the correct BufferView here
- FuncRequest r = req;
- r.setView(view().get());
- getLyXFunc().dispatch(r);
+ getLyXFunc().dispatch(cmd);
}
void resetAutosaveTimer();
/// dispatch to current BufferView
- void dispatch(FuncRequest const & req);
+ void dispatch(FuncRequest const & cmd);
/** redraw \c inset in all the BufferViews in which it is currently
* visible. If successful return a pointer to the owning Buffer.
string const data =
lyx::find::find2string(search,
casesensitive, matchword, forward);
- FuncRequest const fr(bufferview(), LFUN_WORD_FIND, data);
- lv_.dispatch(fr);
+ lv_.dispatch(FuncRequest(LFUN_WORD_FIND, data));
}
void ControlSearch::replace(string const & search, string const & replace,
- bool casesensitive, bool matchword,
- bool forward, bool all)
+ bool casesensitive, bool matchword, bool forward, bool all)
{
string const data =
lyx::find::replace2string(search, replace,
- casesensitive, matchword,
- all, forward);
- FuncRequest const fr(bufferview(), LFUN_WORD_REPLACE, data);
- lv_.dispatch(fr);
+ casesensitive, matchword, all, forward);
+ lv_.dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
}
true, // match word
false, // all words
true); // forward
- FuncRequest const fr(kernel().bufferview(), LFUN_WORD_REPLACE, data);
- kernel().dispatch(fr);
+ kernel().dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
}
-Thesaurus::Meanings const &
-ControlThesaurus::getMeanings(string const & str)
+Thesaurus::Meanings const & ControlThesaurus::getMeanings(string const & str)
{
if (str != laststr_)
meanings_ = thesaurus.lookup(str);
-
return meanings_;
}
FuncRequest::FuncRequest()
- : view_(0), action(LFUN_NOACTION), x(0), y(0), button_(mouse_button::none)
+ : action(LFUN_NOACTION), x(0), y(0), button_(mouse_button::none)
{}
FuncRequest::FuncRequest(kb_action act)
- : view_(0), action(act), x(0), y(0), button_(mouse_button::none)
+ : action(act), x(0), y(0), button_(mouse_button::none)
{}
FuncRequest::FuncRequest(kb_action act, string const & arg)
- : view_(0), action(act), argument(arg), x(0), y(0), button_(mouse_button::none)
+ : action(act), argument(arg), x(0), y(0), button_(mouse_button::none)
{}
-FuncRequest::FuncRequest
- (kb_action act, int ax, int ay, mouse_button::state button)
- : view_(0), action(act), x(ax), y(ay), button_(button)
-{}
-
-
-FuncRequest::FuncRequest(BufferView * view, kb_action act)
- : view_(view), action(act), x(0), y(0), button_(mouse_button::none)
-{}
-
-
-FuncRequest::FuncRequest(BufferView * view, kb_action act, string const & arg)
- : view_(view), action(act), argument(arg), x(0), y(0), button_(mouse_button::none)
-{}
-
-
-FuncRequest::FuncRequest
- (BufferView * view, kb_action act, int ax, int ay, mouse_button::state but)
- : view_(view), action(act), x(ax), y(ay), button_(but)
+FuncRequest::FuncRequest(kb_action act, int ax, int ay, mouse_button::state but)
+ : action(act), x(ax), y(ay), button_(but)
{}
FuncRequest::FuncRequest(FuncRequest const & cmd, string const & arg)
- : view_(cmd.view_), action(cmd.action), argument(arg),
+ : action(cmd.action), argument(arg),
x(cmd.x), y(cmd.y), button_(cmd.button_)
{}
-FuncRequest::FuncRequest(FuncRequest const & cmd, BufferView * view)
- : view_(view), action(cmd.action), argument(cmd.argument),
- x(cmd.x), y(cmd.y), button_(cmd.button_)
-{}
-
-
-BufferView * FuncRequest::view() const
-{
- return view_;
-}
-
-
-void FuncRequest::setView(BufferView * view)
-{
- view_ = view;
-}
-
-
mouse_button::state FuncRequest::button() const
{
return button_;
void FuncRequest::message(string const & msg) const
{
- if (view_)
- view_->owner()->getLyXFunc().setMessage(msg);
- else
- lyxerr << "Dropping message '" << msg << "'" << endl;
+#warning FIXME
+ //if (view_)
+ // view_->owner()->getLyXFunc().setMessage(msg);
+ //else
+ lyxerr << "Dropping message '" << msg << "'" << endl;
}
void FuncRequest::errorMessage(string const & msg) const
{
- if (view_)
- view_->owner()->getLyXFunc().setErrorMessage(msg);
- else
- lyxerr << "Dropping error message '" << msg << "'" << endl;
+#warning FIXME
+ //if (view_)
+ // view_->owner()->getLyXFunc().setErrorMessage(msg);
+ //else
+ lyxerr << "Dropping error message '" << msg << "'" << endl;
}
#include <string>
#include <iosfwd>
-class BufferView;
-
/**
* This class encapsulates a LyX action and its argument
* in order to pass it around easily.
FuncRequest(kb_action act, int x, int y, mouse_button::state button);
/// actions with extra argument
FuncRequest(kb_action act, std::string const & arg);
- /// actions without extra argument
- FuncRequest(BufferView * bv, kb_action act);
- /// actions with extra argument
- FuncRequest(BufferView * bv, kb_action act, std::string const & arg);
- /// for mouse events
- FuncRequest(BufferView * bv, kb_action act,
- int x, int y, mouse_button::state button);
/// for changing requests a bit
FuncRequest(FuncRequest const & cmd, std::string const & arg);
- /// for changing requests a bit
- FuncRequest(FuncRequest const & cmd, BufferView * bv);
- /// access to the view
- BufferView * view() const;
- /// access to the view
- void setView(BufferView * bv);
/// access to button
mouse_button::state button() const;
/// argument parsing, extract argument i as std::string
std::string getArg(unsigned int i) const;
-private:
- /// the BufferView we are talking to
- BufferView * view_;
-public: // should be private, too...
+public: // should be private
/// the action
kb_action action;
/// the action's std::string argument
+2004-01-15 André Pönitz <poenitz@gmx.net>
+
+ * insetbase.[Ch]:
+ * 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] (priv_dispatch et al): change signature.
+
2004-01-08 André Pönitz <poenitz@gmx.net>
* insetcollapsable.[Ch]:
#include "dispatchresult.h"
-DispatchResult
-InsetBase::dispatch(FuncRequest const & f, idx_type & i, pos_type & p)
-{
- return priv_dispatch(f, i, p);
-}
-
-
-DispatchResult
-InsetBase::dispatch(FuncRequest const & f)
+DispatchResult InsetBase::dispatch(BufferView & bv, FuncRequest const & cmd)
{
- idx_type i = 0;
- pos_type p = 0;
- return priv_dispatch(f, i, p);
+ return priv_dispatch(bv, cmd);
}
DispatchResult
-InsetBase::priv_dispatch(FuncRequest const &, idx_type &, pos_type &)
+InsetBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
return DispatchResult(false);
}
virtual UpdatableInset * asUpdatableInset() { return 0; }
// the real dispatcher
- DispatchResult
- dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
- // the real dispatcher
- DispatchResult dispatch(FuncRequest const & cmd);
+ DispatchResult dispatch(BufferView & bv, FuncRequest const & cmd);
/// cursor enters
virtual void edit(BufferView * bv, bool left);
protected:
// the real dispatcher
virtual
- DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+ DispatchResult priv_dispatch(BufferView & bv, FuncRequest const & cmd);
};
#endif
DispatchResult
-InsetBibitem::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+InsetBibitem::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
switch (cmd.action) {
if (p.getCmdName().empty())
return DispatchResult(true, true);
setParams(p);
- cmd.view()->update();
- cmd.view()->fitCursor();
+ bv.update();
+ bv.fitCursor();
return DispatchResult(true, true);
}
default:
- return InsetCommand::priv_dispatch(cmd, idx, pos);
+ return InsetCommand::priv_dispatch(bv, cmd);
}
}
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
///
int counter;
DispatchResult
-InsetBibtex::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+InsetBibtex::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
- DispatchResult result(false);
-
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetCommandMailer::string2params("bibtex", cmd.argument, p);
if (!p.getCmdName().empty())
setParams(p);
- result.dispatched(true);
- result.update(true);
+ return DispatchResult(true, true);
}
- break;
default:
- result = InsetCommand::priv_dispatch(cmd, idx, pos);
- break;
+ return InsetCommand::priv_dispatch(bv, cmd);
}
-
- return result;
}
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
};
#endif // INSET_BIBTEX_H
DispatchResult
-InsetBox::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+InsetBox::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
- DispatchResult result(false);
- BufferView * bv = cmd.view();
-
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
lyxerr << "InsetBox::dispatch MODIFY" << endl;
InsetBoxMailer::string2params(cmd.argument, params_);
setButtonLabel();
- result.dispatched(true);
- result.update(true);
- return result;
+ return DispatchResult(true, true);
}
case LFUN_INSET_DIALOG_UPDATE:
- InsetBoxMailer(*this).updateDialog(bv);
- result.dispatched(true);
- return result;
+ InsetBoxMailer(*this).updateDialog(&bv);
+ return DispatchResult(true);
case LFUN_MOUSE_RELEASE:
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
- InsetBoxMailer(*this).showDialog(bv);
+ InsetBoxMailer(*this).showDialog(&bv);
return DispatchResult(true);
}
- return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+ return InsetCollapsable::priv_dispatch(bv, cmd);
default:
- return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+ return InsetCollapsable::priv_dispatch(bv, cmd);
}
}
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
friend class InsetBoxParams;
DispatchResult
-InsetBranch::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+InsetBranch::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
- BufferView * bv = cmd.view();
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetBranchParams params;
case LFUN_MOUSE_PRESS:
if (cmd.button() != mouse_button::button3)
- return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+ return InsetCollapsable::priv_dispatch(bv, cmd);
return DispatchResult(false);
case LFUN_INSET_DIALOG_UPDATE:
- InsetBranchMailer(*this).updateDialog(bv);
+ InsetBranchMailer(*this).updateDialog(&bv);
return DispatchResult(true);
case LFUN_MOUSE_RELEASE:
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
- InsetBranchMailer(*this).showDialog(bv);
+ InsetBranchMailer(*this).showDialog(&bv);
return DispatchResult(true);
}
- return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+ return InsetCollapsable::priv_dispatch(bv, cmd);
default:
- return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+ return InsetCollapsable::priv_dispatch(bv, cmd);
}
}
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
friend class InsetBranchParams;
int a = 0;
int d = 0;
font_metrics::rectText(params_.type, font, w, a, d);
- pi.pain.rectText(x + 0.5 * (dim_.wid - w),
+ pi.pain.rectText(x + (dim_.wid - w) / 2,
y + inset.descent() + a,
params_.type, font, LColor::none, LColor::none);
}
DispatchResult
-InsetCharStyle::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+InsetCharStyle::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
setStatus(Inlined);
switch (cmd.action) {
has_label_ = !has_label_;
return DispatchResult(true);
}
- inset.dispatch(cmd);
+ inset.dispatch(bv, cmd);
return DispatchResult(true, true);
- break;
default:
- return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+ return InsetCollapsable::priv_dispatch(bv, cmd);
}
}
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
friend class InsetCharStyleParams;
}
-DispatchResult InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
+DispatchResult
+InsetCollapsable::lfunMouseRelease(BufferView & bv, FuncRequest const & cmd)
{
- BufferView * bv = cmd.view();
-
if (cmd.button() == mouse_button::button3) {
lyxerr << "InsetCollapsable::lfunMouseRelease 0" << endl;
- showInsetDialog(bv);
+ showInsetDialog(&bv);
return DispatchResult(true, true);
}
case Collapsed:
lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
setStatus(Open);
- edit(bv, true);
+ edit(&bv, true);
return DispatchResult(true, true);
case Open:
lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
setStatus(Collapsed);
return DispatchResult(false, FINISHED_RIGHT);
- } else {
- lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
- return inset.dispatch(adjustCommand(cmd));
- }
+ }
+ lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
+ return inset.dispatch(bv, adjustCommand(cmd));
case Inlined:
- return inset.dispatch(cmd);
+ return inset.dispatch(bv, cmd);
}
return DispatchResult(true, true);
DispatchResult
-InsetCollapsable::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
+InsetCollapsable::priv_dispatch(BufferView & bv, 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(cmd);
+ inset.dispatch(bv, cmd);
else if (status_ == Open && cmd.y > button_dim.y2)
- inset.dispatch(adjustCommand(cmd));
+ inset.dispatch(bv, adjustCommand(cmd));
return DispatchResult(true, true);
case LFUN_MOUSE_MOTION:
if (status_ == Inlined)
- inset.dispatch(cmd);
+ inset.dispatch(bv, cmd);
else if (status_ == Open && cmd.y > button_dim.y2)
- inset.dispatch(adjustCommand(cmd));
+ inset.dispatch(bv, adjustCommand(cmd));
return DispatchResult(true, true);
case LFUN_MOUSE_RELEASE:
- return lfunMouseRelease(cmd);
+ return lfunMouseRelease(bv, cmd);
case LFUN_INSET_TOGGLE:
if (inset.text_.toggleInset())
}
default:
- return inset.dispatch(adjustCommand(cmd));
+ return inset.dispatch(bv, adjustCommand(cmd));
}
//lyxerr << "InsetCollapsable::priv_dispatch (end)" << endl;
}
}
-void InsetCollapsable::scroll(BufferView * bv, float sx) const
+void InsetCollapsable::scroll(BufferView & bv, float sx) const
{
UpdatableInset::scroll(bv, sx);
}
-void InsetCollapsable::scroll(BufferView * bv, int offset) const
+void InsetCollapsable::scroll(BufferView & bv, int offset) const
{
UpdatableInset::scroll(bv, offset);
}
///
int scroll(bool recursive=true) const;
///
- void scroll(BufferView *bv, float sx) const;
+ void scroll(BufferView & bv, float sx) const;
///
- void scroll(BufferView *bv, int offset) const;
+ void scroll(BufferView & bv, int offset) const;
///
int numParagraphs() const;
///
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
///
void dimension_collapsed(Dimension &) const;
///
private:
///
- DispatchResult lfunMouseRelease(FuncRequest const &);
+ DispatchResult lfunMouseRelease(BufferView & bv, FuncRequest const &);
///
FuncRequest adjustCommand(FuncRequest const &);
DispatchResult
-InsetCommand::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
+InsetCommand::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetCommandMailer::string2params(mailer_name_, cmd.argument, p);
if (p.getCmdName().empty())
return DispatchResult(false);
-
setParams(p);
- cmd.view()->update();
+ bv.update();
return DispatchResult(true, true);
}
case LFUN_INSET_DIALOG_UPDATE:
- InsetCommandMailer(cmd.argument, *this).updateDialog(cmd.view());
+ InsetCommandMailer(cmd.argument, *this).updateDialog(&bv);
return DispatchResult(true, true);
case LFUN_INSET_DIALOG_SHOW:
case LFUN_MOUSE_RELEASE: {
if (!mailer_name_.empty())
- InsetCommandMailer(mailer_name_, *this).
- showDialog(cmd.view());
+ InsetCommandMailer(mailer_name_, *this).showDialog(&bv);
return DispatchResult(true);
}
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
///
std::string const getCommand() const { return p_.getCommand(); }
///
}
-DispatchResult
-InsetERT::priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
+DispatchResult InsetERT::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
switch (cmd.action) {
- case LFUN_INSET_MODIFY:
- {
- InsetCollapsable::CollapseStatus st;
-
- InsetERTMailer::string2params(cmd.argument, st);
- setStatus(st);
- return DispatchResult(true, true);
- }
+ case LFUN_INSET_MODIFY: {
+ InsetCollapsable::CollapseStatus st;
+ InsetERTMailer::string2params(cmd.argument, st);
+ setStatus(st);
+ return DispatchResult(true, true);
+ }
case LFUN_LAYOUT:
case LFUN_BOLD:
return DispatchResult(true);
default:
- return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+ return InsetCollapsable::priv_dispatch(bv, cmd);
}
}
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
///
void init();
DispatchResult
-InsetExternal::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
+InsetExternal::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
switch (cmd.action) {
case LFUN_EXTERNAL_EDIT: {
- BOOST_ASSERT(cmd.view());
-
- Buffer const & buffer = *cmd.view()->buffer();
+ Buffer const & buffer = *bv.buffer();
InsetExternalParams p;
InsetExternalMailer::string2params(cmd.argument, buffer, p);
external::editExternal(p, buffer);
}
case LFUN_INSET_MODIFY: {
- BOOST_ASSERT(cmd.view());
-
- Buffer const & buffer = *cmd.view()->buffer();
+ Buffer const & buffer = *bv.buffer();
InsetExternalParams p;
InsetExternalMailer::string2params(cmd.argument, buffer, p);
setParams(p, buffer);
- cmd.view()->update();
+ bv.update();
return DispatchResult(true, true);
}
case LFUN_INSET_DIALOG_UPDATE:
- InsetExternalMailer(*this).updateDialog(cmd.view());
+ InsetExternalMailer(*this).updateDialog(&bv);
return DispatchResult(true, true);
case LFUN_MOUSE_RELEASE:
- InsetExternalMailer(*this).showDialog(cmd.view());
+ InsetExternalMailer(*this).showDialog(&bv);
return DispatchResult(true, true);
default:
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
/** This method is connected to the graphics loader, so we are
* informed when the image has been loaded.
DispatchResult
-InsetFloat::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+InsetFloat::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetFloatParams params;
InsetFloatMailer::string2params(cmd.argument, params);
-
params_.placement = params.placement;
params_.wide = params.wide;
-
- wide(params_.wide, cmd.view()->buffer()->params());
- cmd.view()->update();
+ wide(params_.wide, bv.buffer()->params());
+ bv.update();
return DispatchResult(true, true);
}
case LFUN_INSET_DIALOG_UPDATE: {
- InsetFloatMailer(*this).updateDialog(cmd.view());
+ InsetFloatMailer(*this).updateDialog(&bv);
return DispatchResult(true, true);
}
default:
- return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+ return InsetCollapsable::priv_dispatch(bv, cmd);
}
}
protected:
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
///
InsetFloatParams params_;
DispatchResult
-InsetGraphics::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
+InsetGraphics::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
- Buffer const & buffer = *cmd.view()->buffer();
+ Buffer const & buffer = *bv.buffer();
InsetGraphicsParams p;
InsetGraphicsMailer::string2params(cmd.argument, buffer, p);
if (!p.filename.empty()) {
setParams(p);
- cmd.view()->update();
+ bv.update();
}
return DispatchResult(true, true);
}
case LFUN_INSET_DIALOG_UPDATE:
- InsetGraphicsMailer(*this).updateDialog(cmd.view());
+ InsetGraphicsMailer(*this).updateDialog(&bv);
return DispatchResult(true, true);
case LFUN_MOUSE_RELEASE:
- InsetGraphicsMailer(*this).showDialog(cmd.view());
+ InsetGraphicsMailer(*this).showDialog(&bv);
return DispatchResult(true, true);
default:
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
///
friend class InsetGraphicsMailer;
DispatchResult
-InsetInclude::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
+InsetInclude::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
switch (cmd.action) {
InsetCommandParams p;
InsetIncludeMailer::string2params(cmd.argument, p);
if (!p.getCmdName().empty()) {
- set(p, *cmd.view()->buffer());
- cmd.view()->update();
+ set(p, *bv.buffer());
+ bv.update();
}
return DispatchResult(true, true);
}
case LFUN_INSET_DIALOG_UPDATE:
- InsetIncludeMailer(*this).updateDialog(cmd.view());
+ InsetIncludeMailer(*this).updateDialog(&bv);
return DispatchResult(true, true);
case LFUN_MOUSE_RELEASE:
if (button_.box().contains(cmd.x, cmd.y))
- InsetIncludeMailer(*this).showDialog(cmd.view());
+ InsetIncludeMailer(*this).showDialog(&bv);
return DispatchResult(true, true);
case LFUN_INSET_DIALOG_SHOW:
- InsetIncludeMailer(*this).showDialog(cmd.view());
+ InsetIncludeMailer(*this).showDialog(&bv);
return DispatchResult(true, true);
default:
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
/// Slot receiving a signal that the preview is ready to display.
void statusChanged() const;
DispatchResult
-InsetLabel::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+InsetLabel::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
- BOOST_ASSERT(cmd.view());
- BufferView * const bv = cmd.view();
-
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetCommandMailer::string2params("label", cmd.argument, p);
if (p.getCmdName().empty())
return DispatchResult(false);
-
bool clean = true;
- if (bv && p.getContents() != params().getContents()) {
- clean = bv->ChangeRefsIfUnique(params().getContents(),
+ if (p.getContents() != params().getContents())
+ clean = bv.ChangeRefsIfUnique(params().getContents(),
p.getContents());
- }
-
setParams(p);
- bv->update();
+ bv.update();
return DispatchResult(true, true);
}
default:
- return InsetCommand::priv_dispatch(cmd, idx, pos);
+ return InsetCommand::priv_dispatch(bv, cmd);
}
}
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
};
#endif
DispatchResult
-InsetNote::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+InsetNote::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
- BufferView * bv = cmd.view();
-
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetNoteMailer::string2params(cmd.argument, params_);
setButtonLabel();
- bv->update();
+ bv.update();
return DispatchResult(true, true);
}
case LFUN_INSET_DIALOG_UPDATE:
- InsetNoteMailer(*this).updateDialog(bv);
+ InsetNoteMailer(*this).updateDialog(&bv);
return DispatchResult(true, true);
case LFUN_MOUSE_RELEASE:
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
- InsetNoteMailer(*this).showDialog(bv);
+ InsetNoteMailer(*this).showDialog(&bv);
return DispatchResult(true, true);
}
- // fallthrough:
+ return InsetCollapsable::priv_dispatch(bv, cmd);
default:
- return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+ return InsetCollapsable::priv_dispatch(bv, cmd);
}
}
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
friend class InsetNoteParams;
DispatchResult
-InsetRef::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+InsetRef::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
switch (cmd.action) {
case LFUN_MOUSE_PRESS:
// Eventually trigger dialog with button 3 not 1
if (cmd.button() == mouse_button::button3)
- cmd.view()->owner()->
- dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
+ bv.owner()->dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
else
- InsetCommandMailer("ref", *this).showDialog(cmd.view());
+ InsetCommandMailer("ref", *this).showDialog(&bv);
return DispatchResult(true, true);
default:
- return InsetCommand::priv_dispatch(cmd, idx, pos);
+ return InsetCommand::priv_dispatch(bv, cmd);
}
}
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
///
bool isLatex;
}
-void InsetTabular::updateLocal(BufferView * bv) const
+void InsetTabular::updateLocal(BufferView & bv) const
{
- bv->update();
+ bv.update();
resetPos(bv);
}
-void InsetTabular::lfunMousePress(FuncRequest const & cmd)
+void InsetTabular::lfunMousePress(BufferView & bv, FuncRequest const & cmd)
{
if (hasSelection() && cmd.button() == mouse_button::button3)
return;
- BufferView * bv = cmd.view();
-
int cell = getCell(cmd.x + xo_, cmd.y + yo_);
clearSelection();
lyxerr << "# InsetTabular::lfunMousePress cell: " << cell << endl;
if (cell == -1) {
tablemode = true;
- bv->fullCursor(theTempCursor);
- bv->fullCursor().push(this);
- bv->fullCursor().cell(cell);
+ bv.fullCursor(theTempCursor);
+ bv.fullCursor().push(this);
+ bv.fullCursor().cell(cell);
} else {
tablemode = false;
setPos(bv, cmd.x, cmd.y);
- bv->fullCursor(theTempCursor);
- bv->fullCursor().cell(cell);
+ bv.fullCursor(theTempCursor);
+ bv.fullCursor().cell(cell);
}
- lyxerr << bv->cursor() << endl;
+ lyxerr << bv.cursor() << endl;
if (cmd.button() == mouse_button::button2)
- dispatch(FuncRequest(bv, LFUN_PASTESELECTION, "paragraph"));
+ dispatch(bv, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
}
-void InsetTabular::lfunMouseMotion(FuncRequest const & cmd)
+void InsetTabular::lfunMouseMotion(BufferView & bv, FuncRequest const & cmd)
{
- BufferView * bv = cmd.view();
int const actcell = getCell(cmd.x + xo_, cmd.y + yo_);
lyxerr << "# InsetTabular::lfunMouseMotion cell: " << actcell << endl;
setPos(bv, cmd.x, cmd.y);
if (!hasSelection()) {
setSelection(actcell, actcell);
- bv->setSelection();
+ bv.setSelection();
} else {
- bv->cursor().cell(actcell);
+ bv.cursor().idx(actcell);
setSelection(sel_cell_start, actcell);
tablemode = (sel_cell_start != actcell);
}
}
-void InsetTabular::lfunMouseRelease(FuncRequest const & cmd)
+void InsetTabular::lfunMouseRelease(BufferView & bv, 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(cmd.view());
+ InsetTabularMailer(*this).showDialog(&bv);
}
-void InsetTabular::edit(BufferView * bv, bool left)
+void InsetTabular::edit(BufferView * view, bool left)
{
+ BufferView & bv = *view;
lyxerr << "InsetTabular::edit: " << this << endl;
finishUndo();
//tablemode = false;
}
clearSelection();
resetPos(bv);
- bv->fitCursor();
- bv->fullCursor().push(this);
- bv->fullCursor().cell(cell);
- lyxerr << bv->cursor() << endl;
+ bv.fitCursor();
+ bv.fullCursor().push(this);
+ bv.fullCursor().cell(cell);
+ lyxerr << bv.cursor() << endl;
}
<< &tabular.cell_info[0][0].inset << endl;
finishUndo();
- setPos(bv, x, y);
+ setPos(*bv, x, y);
clearSelection();
finishUndo();
//int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell);
DispatchResult
-InsetTabular::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+InsetTabular::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
lyxerr << "# InsetTabular::dispatch: " << cmd
<< " tablemode: " << tablemode << endl;
DispatchResult result(true, true);
- BufferView * bv = cmd.view();
-
switch (cmd.action) {
case LFUN_MOUSE_PRESS:
- lfunMousePress(cmd);
+ lfunMousePress(bv, cmd);
return DispatchResult(true, true);
case LFUN_MOUSE_MOTION:
- lfunMouseMotion(cmd);
+ lfunMouseMotion(bv, cmd);
return DispatchResult(true, true);
case LFUN_MOUSE_RELEASE:
- lfunMouseRelease(cmd);
+ lfunMouseRelease(bv, cmd);
return DispatchResult(true, true);
default:
break;
}
- CursorSlice & cur = bv->cursor();
+ CursorSlice & cur = bv.cursor();
if (!tablemode) {
int cell = cur.idx_;
lyxerr << "# InsetTabular::dispatch: A " << cur << endl;
- result = tabular.getCellInset(cell).dispatch(cmd, idx, pos);
+ result = tabular.getCellInset(cell).dispatch(bv, cmd);
switch (result.val()) {
case FINISHED:
case LFUN_SCROLL_INSET:
if (!cmd.argument.empty()) {
if (cmd.argument.find('.') != cmd.argument.npos)
- scroll(cmd.view(), static_cast<float>(strToDbl(cmd.argument)));
+ scroll(bv, static_cast<float>(strToDbl(cmd.argument)));
else
- scroll(cmd.view(), strToInt(cmd.argument));
- cmd.view()->update();
+ scroll(bv, strToInt(cmd.argument));
+ bv.update();
return DispatchResult(true, true);
}
case LFUN_NEXT: {
if (hasSelection())
clearSelection();
- int actcell = bv->cursor().idx();
+ int actcell = bv.cursor().idx();
int actcol = tabular.column_of_cell(actcell);
int column = actcol;
- if (bv->top_y() + bv->painter().paperHeight()
+ if (bv.top_y() + bv.painter().paperHeight()
< yo_ + tabular.getHeightOfTabular())
{
- bv->scrollDocView(bv->top_y() + bv->painter().paperHeight());
- cur.idx_ = tabular.getCellBelow(first_visible_cell) + column;
+ bv.scrollDocView(bv.top_y() + bv.painter().paperHeight());
+ cur.idx() = tabular.getCellBelow(first_visible_cell) + column;
} else {
- cur.idx_ = tabular.getFirstCellInRow(tabular.rows() - 1) + column;
+ cur.idx() = tabular.getFirstCellInRow(tabular.rows() - 1) + column;
}
resetPos(bv);
break;
case LFUN_PRIOR: {
if (hasSelection())
clearSelection();
- int actcell = bv->cursor().idx();
+ int actcell = bv.cursor().idx();
int actcol = tabular.column_of_cell(actcell);
int column = actcol;
if (yo_ < 0) {
- bv->scrollDocView(bv->top_y() - bv->painter().paperHeight());
+ bv.scrollDocView(bv.top_y() - bv.painter().paperHeight());
if (yo_ > 0)
- cur.idx_ = column;
+ cur.idx() = column;
else
- cur.idx_ = tabular.getCellBelow(first_visible_cell) + column;
+ cur.idx() = tabular.getCellBelow(first_visible_cell) + column;
} else {
- cur.idx_ = column;
+ cur.idx() = column;
}
resetPos(bv);
break;
break;
case LFUN_LAYOUT_TABULAR:
- InsetTabularMailer(*this).showDialog(bv);
+ InsetTabularMailer(*this).showDialog(&bv);
break;
case LFUN_INSET_DIALOG_UPDATE:
- InsetTabularMailer(*this).updateDialog(bv);
+ InsetTabularMailer(*this).updateDialog(&bv);
break;
case LFUN_TABULAR_FEATURE:
// insert file functions
case LFUN_FILE_INSERT_ASCII_PARA:
case LFUN_FILE_INSERT_ASCII: {
- string tmpstr = getContentsOfAsciiFile(bv, cmd.argument, false);
+ string tmpstr = getContentsOfAsciiFile(&bv, cmd.argument, false);
if (!tmpstr.empty() && !insertAsciiString(bv, tmpstr, false))
result = DispatchResult(false);
break;
case LFUN_CUT:
if (copySelection(bv)) {
recordUndo(bv, Undo::DELETE);
- cutSelection(bv->buffer()->params());
+ cutSelection(bv.buffer()->params());
}
break;
case LFUN_DELETE:
recordUndo(bv, Undo::DELETE);
- cutSelection(bv->buffer()->params());
+ cutSelection(bv.buffer()->params());
break;
case LFUN_COPY:
break;
case LFUN_PASTESELECTION: {
- string const clip = bv->getClipboard();
+ string const clip = bv.getClipboard();
if (clip.empty())
break;
if (clip.find('\t') != string::npos) {
maxCols = max(cols, maxCols);
paste_tabular.reset(
- new LyXTabular(bv->buffer()->params(), rows, maxCols));
+ new LyXTabular(bv.buffer()->params(), rows, maxCols));
string::size_type op = 0;
int cell = 0;
}
updateLocal(bv);
- InsetTabularMailer(*this).updateDialog(bv);
+ InsetTabularMailer(*this).updateDialog(&bv);
}
if (cmd.action == LFUN_INSET_TOGGLE) {
}
-void InsetTabular::setPos(BufferView * bv, int x, int y) const
+void InsetTabular::setPos(BufferView & bv, int x, int y) const
{
int const cell = getCell(x + xo_, y + yo_);
lyxerr << "# InsetTabular::setPos() cell: " << cell << endl;
}
-void InsetTabular::resetPos(BufferView *) const
+void InsetTabular::resetPos(BufferView &) const
{
#if 0
#ifdef WITH_WARNINGS
updateLocal(bv);
} else if (cursorx_ - offset > 20 &&
cursorx_ - offset + tabular.getWidthOfColumn(actcell)
- > bv->workWidth() - 20) {
- scroll(bv, - tabular.getWidthOfColumn(actcell) - 20);
+ > bv.workWidth() - 20) {
+ scroll(&bv, - tabular.getWidthOfColumn(actcell) - 20);
updateLocal(bv);
} else if (cursorx_ - offset < 20) {
- scroll(bv, 20 - cursorx_ + offset);
+ scroll(&bv, 20 - cursorx_ + offset);
updateLocal(bv);
} else if (scroll() && xo_ > 20 &&
xo_ + tabular.getWidthOfTabular() > bv->workWidth() - 20) {
- scroll(bv, old_x - cursorx_);
+ scroll(&bv, old_x - cursorx_);
updateLocal(bv);
}
InsetTabularMailer(*this).updateDialog(bv);
}
-bool InsetTabular::moveRight(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveRight(BufferView & bv, CursorSlice & cur)
{
bool moved = isRightToLeft(bv)
? movePrevCell(bv, cur) : moveNextCell(bv, cur);
}
-bool InsetTabular::moveRightLock(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveRightLock(BufferView & bv, CursorSlice & cur)
{
bool moved = isRightToLeft(bv)
? movePrevCell(bv, cur) : moveNextCell(bv, cur);
}
-bool InsetTabular::moveLeft(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveLeft(BufferView & bv, CursorSlice & cur)
{
bool moved = isRightToLeft(bv)
? moveNextCell(bv, cur) : movePrevCell(bv, cur);
}
-bool InsetTabular::moveLeftLock(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveLeftLock(BufferView & bv, CursorSlice & cur)
{
bool moved = isRightToLeft(bv)
? moveNextCell(bv, cur) : movePrevCell(bv, cur);
}
-bool InsetTabular::moveUp(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveUp(BufferView & bv, CursorSlice & cur)
{
if (tabular.row_of_cell(cur.idx_) == 0)
return false;
}
-bool InsetTabular::moveUpLock(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveUpLock(BufferView & bv, CursorSlice & cur)
{
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);
+ activateCellInset(bv, cur.idx_, bv.x_target(), 0);
return true;
}
-bool InsetTabular::moveDown(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveDown(BufferView & bv, CursorSlice & cur)
{
if (tabular.row_of_cell(cur.idx_) == tabular.rows() - 1)
return false;
}
-bool InsetTabular::moveDownLock(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveDownLock(BufferView & bv, CursorSlice & cur)
{
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());
+ activateCellInset(bv, cur.idx_, bv.x_target());
return true;
}
-bool InsetTabular::moveNextCell(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveNextCell(BufferView & bv, CursorSlice & cur)
{
lyxerr << "InsetTabular::moveNextCell 1 cur: " << cur << endl;
if (isRightToLeft(bv)) {
}
-bool InsetTabular::movePrevCell(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::movePrevCell(BufferView & bv, CursorSlice & cur)
{
if (isRightToLeft(bv)) {
if (tabular.isLastCellInRow(cur.idx_)) {
}
-bool InsetTabular::tabularFeatures(BufferView * bv, string const & what)
+bool InsetTabular::tabularFeatures(BufferView & bv, string const & what)
{
LyXTabular::Feature action = LyXTabular::LAST_ACTION;
} // anon namespace
-void InsetTabular::tabularFeatures(BufferView * bv,
+void InsetTabular::tabularFeatures(BufferView & bv,
LyXTabular::Feature feature, string const & value)
{
- int actcell = bv->cursor().idx();
+ int actcell = bv.cursor().idx();
int sel_col_start;
int sel_col_end;
int sel_row_start;
case LyXTabular::APPEND_ROW:
// append the row into the tabular
- tabular.appendRow(bv->buffer()->params(), actcell);
+ tabular.appendRow(bv.buffer()->params(), actcell);
tabular.setOwner(this);
break;
case LyXTabular::APPEND_COLUMN:
// append the column into the tabular
- tabular.appendColumn(bv->buffer()->params(), actcell);
+ tabular.appendColumn(bv.buffer()->params(), actcell);
tabular.setOwner(this);
actcell = tabular.getCellNumber(row, column);
break;
if (tabular.isMultiColumn(actcell))
tabular.unsetMultiColumn(actcell);
else
- tabular.setMultiColumn(bv->buffer(), actcell, 1);
+ tabular.setMultiColumn(bv.buffer(), actcell, 1);
break;
}
// we have a selection so this means we just add all this
s_start = sel_cell_start;
s_end = sel_cell_end;
}
- tabular.setMultiColumn(bv->buffer(), s_start, s_end - s_start + 1);
+ tabular.setMultiColumn(bv.buffer(), s_start, s_end - s_start + 1);
actcell = s_start;
clearSelection();
break;
}
updateLocal(bv);
- InsetTabularMailer(*this).updateDialog(bv);
+ InsetTabularMailer(*this).updateDialog(&bv);
}
-void InsetTabular::activateCellInset(BufferView * bv, int cell, int x, int y)
+void InsetTabular::activateCellInset(BufferView & bv, int cell, int x, int y)
{
- tabular.getCellInset(cell).edit(bv, x, y);
- bv->cursor().cell(cell);
+ tabular.getCellInset(cell).edit(&bv, x, y);
+ bv.cursor().idx(cell);
updateLocal(bv);
}
-void InsetTabular::activateCellInset(BufferView * bv, int cell, bool behind)
+void InsetTabular::activateCellInset(BufferView & bv, int cell, bool behind)
{
- tabular.getCellInset(cell).edit(bv, behind);
- bv->cursor().cell(cell);
+ tabular.getCellInset(cell).edit(&bv, behind);
+ bv.cursor().idx(cell);
updateLocal(bv);
}
}
-bool InsetTabular::copySelection(BufferView * bv)
+bool InsetTabular::copySelection(BufferView & bv)
{
if (!hasSelection())
return false;
ostringstream os;
OutputParams const runparams;
- paste_tabular->plaintext(*bv->buffer(), os, runparams,
- ownerPar(*bv->buffer(), this).params().depth(), true, '\t');
- bv->stuffClipboard(os.str());
+ paste_tabular->plaintext(*bv.buffer(), os, runparams,
+ ownerPar(*bv.buffer(), this).params().depth(), true, '\t');
+ bv.stuffClipboard(os.str());
return true;
}
-bool InsetTabular::pasteSelection(BufferView * bv)
+bool InsetTabular::pasteSelection(BufferView & bv)
{
if (!paste_tabular)
return false;
- int actcell = bv->cursor().idx();
+ int actcell = bv.cursor().idx();
int actcol = tabular.column_of_cell(actcell);
int actrow = tabular.row_of_cell(actcell);
for (int r1 = 0, r2 = actrow;
}
-bool InsetTabular::isRightToLeft(BufferView * bv)
+bool InsetTabular::isRightToLeft(BufferView & bv)
{
- return bv->getParentLanguage(this)->RightToLeft();
+ return bv.getParentLanguage(this)->RightToLeft();
}
}
-bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
+bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf,
bool usePaste)
{
if (buf.length() <= 0)
string::size_type len = buf.length();
string::size_type p = 0;
- int actcell = bv->cursor().idx();
+ int actcell = bv.cursor().idx();
int actcol = tabular.column_of_cell(actcell);
int actrow = tabular.row_of_cell(actcell);
int row = 0;
if (usePaste) {
paste_tabular.reset(
- new LyXTabular(bv->buffer()->params(), rows, maxCols)
- );
-
+ new LyXTabular(bv.buffer()->params(), rows, maxCols));
paste_tabular->setOwner(this);
loctab = paste_tabular.get();
cols = 0;
///
std::string const editMessage() const;
///
- void updateLocal(BufferView *) const;
+ void updateLocal(BufferView & bv) const;
///
bool insetAllowed(InsetOld::Code) const { return true; }
///
/// 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(BufferView & bv, std::string const & what);
///
- void tabularFeatures(BufferView * bv, LyXTabular::Feature feature,
+ void tabularFeatures(BufferView & bv, LyXTabular::Feature feature,
std::string const & val = std::string());
///
void openLayoutDialog(BufferView *) const;
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
///
- void lfunMousePress(FuncRequest const &);
+ void lfunMousePress(BufferView & bv, FuncRequest const & cmd);
///
- void lfunMouseRelease(FuncRequest const &);
+ void lfunMouseRelease(BufferView & bv, FuncRequest const & cmd);
///
- void lfunMouseMotion(FuncRequest const &);
+ void lfunMouseMotion(BufferView & bv, FuncRequest const & cmd);
///
void calculate_dimensions_of_cells(MetricsInfo & mi) const;
///
void drawCellSelection(Painter &, int x, int baseline,
int row, int column, int cell) const;
///
- void setPos(BufferView *, int x, int y) const;
+ void setPos(BufferView &, int x, int y) const;
///
- bool moveRight(BufferView *, CursorSlice & cur);
+ bool moveRight(BufferView &, CursorSlice & cur);
///
- bool moveLeft(BufferView *, CursorSlice & cur);
+ bool moveLeft(BufferView &, CursorSlice & cur);
///
- bool moveUp(BufferView *, CursorSlice & cur);
+ bool moveUp(BufferView &, CursorSlice & cur);
///
- bool moveDown(BufferView *, CursorSlice & cur);
+ bool moveDown(BufferView &, CursorSlice & cur);
///
- bool moveRightLock(BufferView *, CursorSlice & cur);
+ bool moveRightLock(BufferView &, CursorSlice & cur);
///
- bool moveLeftLock(BufferView *, CursorSlice & cur);
+ bool moveLeftLock(BufferView &, CursorSlice & cur);
///
- bool moveUpLock(BufferView *, CursorSlice & cur);
+ bool moveUpLock(BufferView &, CursorSlice & cur);
///
- bool moveDownLock(BufferView *, CursorSlice & cur);
+ bool moveDownLock(BufferView &, CursorSlice & cur);
///
- bool moveNextCell(BufferView *, CursorSlice & cur);
+ bool moveNextCell(BufferView &, CursorSlice & cur);
///
- bool movePrevCell(BufferView *, CursorSlice & cur);
+ bool movePrevCell(BufferView &, CursorSlice & cur);
///
int getCellXPos(int cell) const;
///
- void resetPos(BufferView *) const;
+ void resetPos(BufferView &) const;
///
void removeTabularRow();
///
///
void setSelection(int start, int end) const;
///
- void activateCellInset(BufferView *, int cell, int x, int y);
+ void activateCellInset(BufferView &, int cell, int x, int y);
///
- void activateCellInset(BufferView *, int cell, bool behind);
+ void activateCellInset(BufferView &, int cell, bool behind);
///
bool hasPasteBuffer() const;
///
- bool copySelection(BufferView *);
+ bool copySelection(BufferView &);
///
- bool pasteSelection(BufferView *);
+ bool pasteSelection(BufferView &);
///
bool cutSelection(BufferParams const & bp);
///
- bool isRightToLeft(BufferView *);
+ bool isRightToLeft(BufferView &);
///
void getSelection(int cell,
int & scol, int & ecol, int & srow, int & erow) const;
///
- bool insertAsciiString(BufferView *, std::string const & buf, bool usePaste);
+ bool insertAsciiString(BufferView &, std::string const & buf, bool usePaste);
//
// Private structures and variables
}
-DispatchResult InsetText::priv_dispatch(FuncRequest const & cmd,
- idx_type &, pos_type &)
+DispatchResult
+InsetText::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
//lyxerr << "InsetText::priv_dispatch (begin), act: "
// << cmd.action << " " << endl;
- BufferView * bv = cmd.view();
- setViewCache(bv);
+ setViewCache(&bv);
DispatchResult result;
result.dispatched(true);
switch (cmd.action) {
case LFUN_MOUSE_PRESS:
- bv->fullCursor(theTempCursor);
+ bv.fullCursor(theTempCursor);
// fall through
default:
- result = text_.dispatch(cmd);
+ result = text_.dispatch(bv, cmd);
break;
}
if (!was_empty && paragraphs().begin()->empty() &&
paragraphs().size() == 1) {
LyXFont font(LyXFont::ALL_IGNORE);
- font.setLanguage(bv->getParentLanguage(this));
+ font.setLanguage(bv.getParentLanguage(this));
text_.setFont(font, false);
}
///
int scroll(bool recursive = true) const;
///
- void scroll(BufferView * bv, float sx) const {
+ void scroll(BufferView & bv, float sx) const {
UpdatableInset::scroll(bv, sx);
}
///
- void scroll(BufferView * bv, int offset) const {
+ void scroll(BufferView & bv, int offset) const {
UpdatableInset::scroll(bv, offset);
}
///
private:
///
DispatchResult
- priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
///
void updateLocal(BufferView *);
///
DispatchResult
-InsetVSpace::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+InsetVSpace::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
switch (cmd.action) {
}
case LFUN_MOUSE_PRESS:
- InsetVSpaceMailer(*this).showDialog(cmd.view());
+ InsetVSpaceMailer(*this).showDialog(&bv);
return DispatchResult(true, true);
default:
- return InsetOld::priv_dispatch(cmd, idx, pos);
+ return InsetOld::priv_dispatch(bv, cmd);
}
}
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
///
DispatchResult
-InsetWrap::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+InsetWrap::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
params_.placement = params.placement;
params_.width = params.width;
- cmd.view()->update();
+ bv.update();
return DispatchResult(true, true);
}
case LFUN_INSET_DIALOG_UPDATE:
- InsetWrapMailer(*this).updateDialog(cmd.view());
+ InsetWrapMailer(*this).updateDialog(&bv);
return DispatchResult(true, true);
default:
- return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+ return InsetCollapsable::priv_dispatch(bv, cmd);
}
}
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
///
InsetWrapParams params_;
}
-void UpdatableInset::scroll(BufferView * bv, float s) const
+void UpdatableInset::scroll(BufferView & bv, float s) const
{
if (!s) {
scx = 0;
return;
}
- int const workW = bv->workWidth();
+ int const workW = bv.workWidth();
int const tmp_xo_ = xo_ - scx;
if (tmp_xo_ > 0 && tmp_xo_ + width() < workW)
}
-void UpdatableInset::scroll(BufferView * bv, int offset) const
+void UpdatableInset::scroll(BufferView & bv, int offset) const
{
if (offset > 0) {
if (!scx && xo_ >= 20)
scx += offset;
} else {
#warning metrics?
- if (!scx && xo_ + width() < bv->workWidth() - 20)
+ if (!scx && xo_ + width() < bv.workWidth() - 20)
return;
- if (xo_ - scx + offset + width() < bv->workWidth() - 20) {
- scx += bv->workWidth() - width() - xo_ - 20;
+ if (xo_ - scx + offset + width() < bv.workWidth() - 20) {
+ scx += bv.workWidth() - width() - xo_ - 20;
} else {
scx += offset;
}
/// An updatable inset could handle lyx editing commands
DispatchResult
-UpdatableInset::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
+UpdatableInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
switch (cmd.action) {
case LFUN_MOUSE_RELEASE:
case LFUN_SCROLL_INSET:
if (!cmd.argument.empty()) {
if (cmd.argument.find('.') != cmd.argument.npos)
- scroll(cmd.view(), static_cast<float>(strToDbl(cmd.argument)));
+ scroll(bv, static_cast<float>(strToDbl(cmd.argument)));
else
- scroll(cmd.view(), strToInt(cmd.argument));
- cmd.view()->update();
+ scroll(bv, strToInt(cmd.argument));
+ bv.update();
return DispatchResult(true, true);
}
public:
///
virtual EDITABLE editable() const;
- /// identification as math inset
+ /// identification as text inset in a cursor slice
UpdatableInset * asUpdatableInset() { return this; }
/// return the cursor pos, relative to the inset pos
{ return InsetOld::scroll(recursive); }
///
virtual bool showInsetDialog(BufferView *) const { return false; }
- ///
- virtual void toggleSelection(BufferView *, bool /*kill_selection*/) {}
protected:
/// An updatable inset could handle lyx editing commands
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
/// scrolls to absolute position in bufferview-workwidth * sx units
- void scroll(BufferView *, float sx) const;
+ void scroll(BufferView &, float sx) const;
/// scrolls offset pixels
- void scroll(BufferView *, int offset) const;
+ void scroll(BufferView &, int offset) const;
};
#endif
}
-void find(FuncRequest const & ev)
+void find(BufferView * bv, FuncRequest const & ev)
{
- if (!ev.view() || ev.action != LFUN_WORD_FIND)
+ if (!bv || ev.action != LFUN_WORD_FIND)
return;
// data is of the form
bool matchword = parse_bool(howto);
bool forward = parse_bool(howto);
- BufferView * bv = ev.view();
bool const found = ::find(bv, search,
forward, casesensitive, matchword);
}
-void replace(FuncRequest const & ev)
+void replace(BufferView * bv, FuncRequest const & ev)
{
- if (!ev.view() || ev.action != LFUN_WORD_REPLACE)
+ if (!bv || ev.action != LFUN_WORD_REPLACE)
return;
// data is of the form
bool all = parse_bool(howto);
bool forward = parse_bool(howto);
- BufferView * bv = ev.view();
LyXView * lv = bv->owner();
int const replace_count = all ?
* \c ev.argument and act on it.
* The string is encoded by \c find2string.
*/
-void find(FuncRequest const & ev);
+void find(BufferView * bv, FuncRequest const & ev);
/** Parse the string encoding of the replace request that is found in
* \c ev.argument and act on it.
* The string is encoded by \c replace2string.
*/
-void replace(FuncRequest const &);
+void replace(BufferView * bv, FuncRequest const &);
/// find the next change in the buffer
bool findNextChange(BufferView * bv);
if (encoded_last_key != 0) {
string arg;
arg += encoded_last_key;
-
- dispatch(FuncRequest(view(), LFUN_SELFINSERT, arg));
-
+ dispatch(FuncRequest(LFUN_SELFINSERT, arg));
lyxerr[Debug::KEY] << "SelfInsert arg[`"
<< argument << "']" << endl;
}
bool const fw = action == LFUN_WORDFINDFORWARD;
string const data =
- lyx::find::find2string(searched_string,
- true, false, fw);
- FuncRequest const fr(view(), LFUN_WORD_FIND, data);
- view()->dispatch(fr);
+ lyx::find::find2string(searched_string, true, false, fw);
+ view()->dispatch(FuncRequest(LFUN_WORD_FIND, data));
break;
}
case LFUN_INSET_DIALOG_SHOW: {
InsetOld * inset = view()->getLyXText()->getInset();
if (inset)
- inset->dispatch(FuncRequest(view(), LFUN_INSET_DIALOG_SHOW));
+ inset->dispatch(*view(), FuncRequest(LFUN_INSET_DIALOG_SHOW));
break;
}
// Can only update a dialog connected to an existing inset
InsetBase * inset = owner->getDialogs().getOpenInset(name);
if (inset) {
- FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE,
- func.argument);
- inset->dispatch(fr);
+ FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, func.argument);
+ inset->dispatch(*view(), fr);
} else if (name == "paragraph") {
dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
}
break;
case LFUN_EXTERNAL_EDIT:
- InsetExternal().dispatch(FuncRequest(view(), action, argument));
+ InsetExternal().dispatch(*view(), FuncRequest(action, argument));
break;
- default: {
- DispatchResult result =
- view()->fullCursor().dispatch(FuncRequest(func, view()));
- if (result.dispatched())
- lyxerr << "dispatched by Cursor::dispatch()" << endl;
- else
- lyxerr << "### NOT DISPATCHED BY Cursor::dispatch() ###" << endl;
- break;
- }
+ default:
+ view()->fullCursor().dispatch(FuncRequest(func));
+ break;
}
}
void draw(PainterInfo & pi, int x, int y) const;
/// try to handle that request
- DispatchResult dispatch(FuncRequest const & cmd);
+ DispatchResult dispatch(BufferView & bv, FuncRequest const & cmd);
BufferView * bv();
+
+
+2004-01-15 André Pönitz <poenitz@gmx.net>
+
+ * *.[Ch]: change signature of priv_dispatch to prepare
+ inset unification
+
2003-12-15 Ronald Florence <ron@18james.com>
* math_symbolinset.C: fixed "ugly" patch for Qt/Mac fonts.
DispatchResult
-CommandInset::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+CommandInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
switch (cmd.action) {
default:
- return MathNestInset::priv_dispatch(cmd, idx, pos);
+ return MathNestInset::priv_dispatch(bv, cmd);
}
return DispatchResult(false);
}
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
std::string name_;
mutable bool set_label_;
int first_x;
int first_y;
-bool openNewInset(BufferView * bv, UpdatableInset * inset)
+bool openNewInset(BufferView & bv, UpdatableInset * inset)
{
- if (!bv->insertInset(inset)) {
+ if (!bv.insertInset(inset)) {
delete inset;
return false;
}
- inset->edit(bv, true);
+ inset->edit(&bv, true);
return true;
}
void InsetFormulaBase::handleFont
- (BufferView * bv, string const & arg, string const & font)
+ (BufferView & bv, string const & arg, string const & font)
{
// this whole function is a hack and won't work for incremental font
// changes...
}
-void InsetFormulaBase::handleFont2(BufferView * bv, string const & arg)
+void InsetFormulaBase::handleFont2(BufferView & bv, string const & arg)
{
recordUndo(bv, Undo::ATOMIC);
LyXFont font;
if (mathcursor) {
if (mathcursor->inMacroMode())
mathcursor->macroModeClose();
- releaseMathCursor(bv);
+ releaseMathCursor(*bv);
}
if (bv->buffer())
generatePreview(*bv->buffer());
}
-DispatchResult InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
+DispatchResult InsetFormulaBase::lfunMouseRelease(
+ BufferView & bv, FuncRequest const & cmd)
{
if (!mathcursor)
return DispatchResult(false);
-
- BufferView * bv = cmd.view();
- bv->update();
+ bv.update();
//lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
if (cmd.button() == mouse_button::button3) {
if (!mathcursor->dispatch(cmd).dispatched()) {
// launch math panel for right mouse button
lyxerr << "lfunMouseRelease: undispatched: " << cmd.button() << endl;
- bv->owner()->getDialogs().show("mathpanel");
+ bv.owner()->getDialogs().show("mathpanel");
}
return DispatchResult(true, true);
}
if (cmd.button() == mouse_button::button2) {
MathArray ar;
- asArray(bv->getClipboard(), ar);
+ asArray(bv.getClipboard(), ar);
mathcursor->selClear();
mathcursor->setScreenPos(cmd.x + xo_, cmd.y + yo_);
mathcursor->insert(ar);
- bv->update();
+ bv.update();
return DispatchResult(true, true);
}
if (cmd.button() == mouse_button::button1) {
// try to dispatch to enclosed insets first
mathcursor->dispatch(cmd);
- cmd.view()->stuffClipboard(mathcursor->grabSelection());
+ bv.stuffClipboard(mathcursor->grabSelection());
// try to set the cursor
//delete mathcursor;
- //mathcursor = new MathCursor(this, x == 0);
+ //mathcursor = new MathCursor(bv, this, x == 0);
//metrics(bv);
//mathcursor->setScreenPos(x + xo_, y + yo_);
return DispatchResult(true, true);
}
-DispatchResult InsetFormulaBase::lfunMousePress(FuncRequest const & cmd)
+DispatchResult InsetFormulaBase::lfunMousePress(
+ BufferView & bv, FuncRequest const & cmd)
{
- BufferView * bv = cmd.view();
//lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
if (!mathcursor || mathcursor->formula() != this) {
lyxerr[Debug::MATHED] << "re-create cursor" << endl;
releaseMathCursor(bv);
- mathcursor = new MathCursor(this, cmd.x == 0);
+ mathcursor = new MathCursor(&bv, this, cmd.x == 0);
//metrics(bv);
mathcursor->setScreenPos(cmd.x + xo_, cmd.y + yo_);
}
return DispatchResult(true, true);
}
- bv->update();
+ bv.update();
return DispatchResult(true, true);
}
-DispatchResult InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
+DispatchResult InsetFormulaBase::lfunMouseMotion(
+ BufferView & bv, FuncRequest const & cmd)
{
if (!mathcursor)
return DispatchResult(true, true);
if (!mathcursor->selection())
mathcursor->selStart();
- BufferView * bv = cmd.view();
mathcursor->setScreenPos(cmd.x + xo_, cmd.y + yo_);
- bv->update();
+ bv.update();
return DispatchResult(true, true);
}
void InsetFormulaBase::edit(BufferView * bv, bool left)
{
lyxerr << "Called FormulaBase::edit" << endl;
- releaseMathCursor(bv);
- mathcursor = new MathCursor(this, left);
+ 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
void InsetFormulaBase::edit(BufferView * bv, int x, int y)
{
lyxerr << "Called FormulaBase::EDIT with '" << x << ' ' << y << "'" << endl;
- releaseMathCursor(bv);
- mathcursor = new MathCursor(this, true);
+ releaseMathCursor(*bv);
+ mathcursor = new MathCursor(bv, this, true);
//metrics(bv);
mathcursor->setScreenPos(x + xo_, y + yo_);
bv->fullCursor().push(this);
DispatchResult
-InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
- idx_type &, pos_type &)
+InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
//lyxerr << "InsetFormulaBase::localDispatch: act: " << cmd.action
// << " arg: '" << cmd.argument
// << " y: '" << cmd.y
// << "' button: " << cmd.button() << endl;
- BufferView * bv = cmd.view();
-
// delete empty mathbox (LFUN_BACKSPACE and LFUN_DELETE)
bool remove_inset = false;
switch (cmd.action) {
case LFUN_MOUSE_PRESS:
//lyxerr << "Mouse single press" << endl;
- return lfunMousePress(cmd);
+ return lfunMousePress(bv, cmd);
case LFUN_MOUSE_MOTION:
//lyxerr << "Mouse motion" << endl;
- return lfunMouseMotion(cmd);
+ return lfunMouseMotion(bv, cmd);
case LFUN_MOUSE_RELEASE:
//lyxerr << "Mouse single release" << endl;
- return lfunMouseRelease(cmd);
+ return lfunMouseRelease(bv, cmd);
case LFUN_MOUSE_DOUBLE:
//lyxerr << "Mouse double" << endl;
- return dispatch(FuncRequest(LFUN_WORDSEL));
+ return dispatch(bv, FuncRequest(LFUN_WORDSEL));
default:
break;
}
result = mathcursor->right(sel) ?
DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
//lyxerr << "calling scroll 20" << endl;
- //scroll(bv, 20);
+ //scroll(&bv, 20);
// write something to the minibuffer
- //bv->owner()->message(mathcursor->info());
+ //bv.owner()->message(mathcursor->info());
break;
case LFUN_LEFTSEL:
mathcursor->niceInsert(MathAtom(new MathHullInset("simple")));
else
handleFont(bv, cmd.argument, "textrm");
- //bv->owner()->message(_("math text mode toggled"));
+ //bv.owner()->message(_("math text mode toggled"));
break;
case LFUN_MATH_SIZE:
break;
case LFUN_UNDO:
- bv->owner()->message(_("Invalid action in math mode!"));
+ bv.owner()->message(_("Invalid action in math mode!"));
break;
if (data.empty())
result = DispatchResult(false);
else
- bv->owner()->getDialogs().show(name, data, 0);
+ 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 = bv.owner()->getDialogs().getOpenInset(name);
if (base) {
- FuncRequest fr(bv, LFUN_INSET_MODIFY, cmd.argument);
- result = base->dispatch(fr);
+ FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument);
+ result = base->dispatch(bv, fr);
} else {
MathArray ar;
if (createMathInset_fromDialogStr(cmd.argument, ar)) {
case LFUN_WORD_REPLACE:
case LFUN_WORD_FIND: {
result =
- searchForward(cmd.view(), cmd.getArg(0), false, false)
+ searchForward(&bv, cmd.getArg(0), false, false)
? DispatchResult(true, true) : DispatchResult(false);
break;
}
}
if (result == DispatchResult(true, true))
- bv->update();
+ bv.update();
mathcursor->normalize();
mathcursor->touch();
BOOST_ASSERT(mathcursor);
if (mathcursor->selection() || was_selection)
- toggleInsetSelection(bv);
+ toggleInsetSelection(&bv);
if (result.dispatched()) {
revealCodes(bv);
- cmd.view()->stuffClipboard(mathcursor->grabSelection());
+ bv.stuffClipboard(mathcursor->grabSelection());
} else {
releaseMathCursor(bv);
if (remove_inset)
- bv->owner()->dispatch(FuncRequest(LFUN_DELETE));
+ bv.owner()->dispatch(FuncRequest(LFUN_DELETE));
}
return result; // original version
}
-void InsetFormulaBase::revealCodes(BufferView * bv) const
+void InsetFormulaBase::revealCodes(BufferView & bv) const
{
if (!mathcursor)
return;
- bv->owner()->message(mathcursor->info());
+ bv.owner()->message(mathcursor->info());
#if 0
// write something to the minibuffer
res = res.substr(pos - 30);
if (res.size() > 60)
res = res.substr(0, 60);
- bv->owner()->message(res);
+ bv.owner()->message(res);
#endif
}
MathArray const & a = top.asMathInset()->cell(top.idx_);
if (a.matchpart(ar, top.pos_)) {
delete mathcursor;
- mathcursor = new MathCursor(this, true);
+ mathcursor = new MathCursor(bv, this, true);
//metrics(bv);
mathcursor->setSelection(it, ar.size());
current = it;
/////////////////////////////////////////////////////////////////////
-void mathDispatchCreation(FuncRequest const & cmd, bool display)
+void mathDispatchCreation(BufferView & bv, FuncRequest const & cmd,
+ bool display)
{
- BufferView * bv = cmd.view();
// use selection if available..
//string sel;
//if (action == LFUN_MATH_IMPORT_SELECTION)
// sel = "";
//else
- string sel = bv->getLyXText()->selectionAsString(*bv->buffer(), false);
+ string sel = bv.getLyXText()->selectionAsString(*bv.buffer(), false);
if (sel.empty()) {
- InsetFormula * f = new InsetFormula(bv);
+ InsetFormula * f = new InsetFormula(&bv);
if (openNewInset(bv, f)) {
- bv->fullCursor().innerInset()->
- dispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
+ bv.fullCursor().innerInset()->
+ dispatch(bv, 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(FuncRequest(bv, LFUN_MATH_DISPLAY));
- f->dispatch(FuncRequest(bv, LFUN_INSERT_MATH, cmd.argument));
+ f->dispatch(bv, FuncRequest(LFUN_MATH_DISPLAY));
+ f->dispatch(bv, FuncRequest(LFUN_INSERT_MATH, cmd.argument));
}
} else {
// create a macro if we see "\\newcommand" somewhere, and an ordinary
f = new InsetFormula(sel);
else
f = new InsetFormulaMacro(sel);
- bv->getLyXText()->cutSelection(true, false);
+ bv.getLyXText()->cutSelection(true, false);
openNewInset(bv, f);
}
cmd.message(N_("Math editor mode"));
}
-void mathDispatch(FuncRequest const & cmd)
+void mathDispatch(BufferView & bv, FuncRequest const & cmd)
{
- BufferView * bv = cmd.view();
- if (!bv->available())
+ if (!bv.available())
return;
switch (cmd.action) {
case LFUN_MATH_DISPLAY:
- mathDispatchCreation(cmd, true);
+ mathDispatchCreation(bv, cmd, true);
break;
case LFUN_MATH_MODE:
- mathDispatchCreation(cmd, false);
+ mathDispatchCreation(bv, cmd, false);
break;
case LFUN_MATH_IMPORT_SELECTION:
- mathDispatchCreation(cmd, false);
+ mathDispatchCreation(bv, cmd, false);
break;
case LFUN_MATH_MACRO:
case LFUN_INSERT_MATH:
case LFUN_INSERT_MATRIX:
case LFUN_MATH_DELIM: {
- InsetFormula * f = new InsetFormula(bv);
+ InsetFormula * f = new InsetFormula(&bv);
if (openNewInset(bv, f)) {
- UpdatableInset * inset = bv->fullCursor().innerInset();
- inset->dispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
- inset->dispatch(cmd);
+ UpdatableInset * inset = bv.fullCursor().innerInset();
+ inset->dispatch(bv, FuncRequest(LFUN_MATH_MUTATE, "simple"));
+ inset->dispatch(bv, cmd);
}
break;
}
///
virtual void mutateToText();
///
- virtual void revealCodes(BufferView *) const;
+ virtual void revealCodes(BufferView & bv) const;
///
virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
///
protected:
/// To allow transparent use of math editing functions
virtual
- DispatchResult
- priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+ DispatchResult priv_dispatch(BufferView & bv, 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);
+ void handleAccent(BufferView & bv, std::string const & arg, std::string const & name);
/// lfun handler
- DispatchResult lfunMousePress(FuncRequest const &);
+ DispatchResult lfunMousePress(BufferView &, FuncRequest const &);
///
- DispatchResult lfunMouseRelease(FuncRequest const &);
+ DispatchResult lfunMouseRelease(BufferView &, FuncRequest const &);
///
- DispatchResult lfunMouseMotion(FuncRequest const &);
+ DispatchResult lfunMouseMotion(BufferView &, FuncRequest const &);
protected:
virtual void generatePreview(Buffer const &) const {}
///
- void handleFont(BufferView * bv, std::string const & arg, std::string const & font);
+ void handleFont(BufferView & bv, std::string const & arg, std::string const & font);
///
- void handleFont2(BufferView * bv, std::string const & arg);
+ void handleFont2(BufferView & bv, std::string const & arg);
};
// We don't really mess want around with mathed stuff outside mathed.
// So do it here.
-void mathDispatch(FuncRequest const &);
+void mathDispatch(BufferView & bv, FuncRequest const & cmd);
///
-void releaseMathCursor(BufferView * bv);
+void releaseMathCursor(BufferView & bv);
#endif
#include <config.h>
#include "math_cursor.h"
-#include "lyxrc.h"
-#include "support/limited_stack.h"
-#include "dispatchresult.h"
+#include "BufferView.h"
+#include "cursor.h"
#include "debug.h"
-#include "support/std_sstream.h"
+#include "dispatchresult.h"
#include "formulabase.h"
#include "funcrequest.h"
+#include "lyxrc.h"
#include "math_braceinset.h"
#include "math_commentinset.h"
#include "math_charinset.h"
#include "math_support.h"
#include "math_unknowninset.h"
+#include "support/limited_stack.h"
+#include "support/std_sstream.h"
+
#include <boost/assert.hpp>
//#define FILEDEBUG 1
#endif
using std::min;
using std::swap;
-
using std::ostringstream;
limited_stack<string> theCutBuffer;
-MathCursor::MathCursor(InsetFormulaBase * formula, bool front)
- : formula_(formula), autocorrect_(false), selection_(false), targetx_(-1)
+MathCursor::MathCursor(BufferView * bv, InsetFormulaBase * formula, bool front)
+ : formula_(formula), autocorrect_(false), selection_(false), bv_(bv)
{
front ? first() : last();
- Anchor_ = Cursor_;
}
MathCursor::~MathCursor()
{
// ensure that 'notifyCursorLeave' is called
- while (popLeft())
- ;
+ //while (popLeft())
+ // ;
}
void MathCursor::push(MathAtom & t)
{
- Cursor_.push_back(CursorSlice(t.nucleus()));
+ bv_->fullCursor().push(t.nucleus());
}
{
//lyxerr << "Entering atom " << t << " left" << endl;
push(t);
- t->idxFirst(idx(), pos());
+ t->idxFirst(*bv_);
}
//lyxerr << "Entering atom " << t << " right" << endl;
posLeft();
push(t);
- t->idxLast(idx(), pos());
+ t->idxLast(*bv_);
}
return false;
}
inset()->notifyCursorLeaves(idx());
- Cursor_.pop_back();
+ bv_->fullCursor().pop();
return true;
}
return false;
}
inset()->notifyCursorLeaves(idx());
- Cursor_.pop_back();
+ bv_->fullCursor().pop();
posRight();
return true;
}
#endif
-bool MathCursor::isInside(MathInset const * p) const
+bool MathCursor::isInside(MathInset const *) const
{
+#warning FIXME
+/*
for (unsigned i = 0; i < depth(); ++i)
if (Cursor_[i].asMathInset() == p)
return true;
+*/
return false;
}
if (t->lock())
return false;
+#warning FIXME
+#if 0
if (sel) {
// we can't move into anything new during selection
if (depth() == Anchor_.size())
if (t.operator->() != Anchor_[depth()].asMathInset())
return false;
}
+#else
+ if (sel)
+ return false;
+#endif
+
return true;
}
{
dump("Left 1");
autocorrect_ = false;
- targetx_ = -1; // "no target"
+ bv_->x_target(-1); // "no target"
if (inMacroMode()) {
macroModeClose();
return true;
{
dump("Right 1");
autocorrect_ = false;
- targetx_ = -1; // "no target"
+ bv_->x_target(-1); // "no target"
if (inMacroMode()) {
macroModeClose();
return true;
void MathCursor::first()
{
- Cursor_.clear();
+#warning FIXME
+ //Cursor_.clear();
push(formula_->par());
- inset()->idxFirst(idx(), pos());
+ inset()->idxFirst(*bv_);
+ bv_->resetAnchor();
}
void MathCursor::last()
{
- Cursor_.clear();
+#warning FIXME
+ //Cursor_.clear();
push(formula_->par());
- inset()->idxLast(idx(), pos());
+ inset()->idxLast(*bv_);
+ bv_->resetAnchor();
}
dump("setScreenPos 1.5");
first();
}
- targetx_ = -1; // "no target"
+ bv_->x_target(-1); // "no target"
dump("setScreenPos 2");
}
autocorrect_ = false;
selHandle(sel);
macroModeClose();
- if (!inset()->idxHome(idx(), pos()))
+ if (!inset()->idxHome(*bv_))
return popLeft();
dump("home 2");
- targetx_ = -1; // "no target"
+ bv_->x_target(-1); // "no target"
return true;
}
autocorrect_ = false;
selHandle(sel);
macroModeClose();
- if (!inset()->idxEnd(idx(), pos()))
+ if (!inset()->idxEnd(*bv_))
return popRight();
dump("end 2");
- targetx_ = -1; // "no target"
+ bv_->x_target(-1); // "no target"
return true;
}
dump("up 1");
macroModeClose();
selHandle(sel);
+#warning FIXME
+#if 0
CursorBase save = Cursor_;
if (goUpDown(true))
return true;
Cursor_ = save;
+#endif
autocorrect_ = false;
return selection_;
}
dump("down 1");
macroModeClose();
selHandle(sel);
+#warning FIXME
+#if 0
CursorBase save = Cursor_;
if (goUpDown(false))
return true;
Cursor_ = save;
+#endif
autocorrect_ = false;
return selection_;
}
void MathCursor::selClear()
{
- Anchor_.clear();
- selection_ = false;
+ bv_->resetAnchor();
+ bv_->clearSelection();
}
if (sel == selection_)
return;
//clear();
- Anchor_ = Cursor_;
+ bv_->resetAnchor();
selection_ = sel;
}
{
dump("selStart 1");
//clear();
- Anchor_ = Cursor_;
+ bv_->resetAnchor();
selection_ = true;
dump("selStart 2");
}
int MathCursor::targetX() const
{
- if (targetx_ != -1)
- return targetx_;
+ if (bv_->x_target() != -1)
+ return bv_->x_target();
int x = 0, y = 0;
getScreenPos(x, y);
return x;
void MathCursor::adjust(pos_type from, difference_type diff)
{
+#warning FIXME
+#if 0
if (cursor().pos_ > from)
cursor().pos_ += diff;
if (Anchor_.back().pos_ > from)
// just to be on the safe side
// theoretically unecessary
normalize();
+#endif
}
MathGridInset * MathCursor::enclosingGrid(MathCursor::idx_type & idx) const
{
+#warning FIXME
+#if 0
for (MathInset::difference_type i = depth() - 1; i >= 0; --i) {
MathGridInset * p = Cursor_[i].asMathInset()->asGridInset();
if (p) {
return p;
}
}
+#endif
return 0;
}
void MathCursor::popToHere(MathInset const * p)
{
+#warning FIXME
+#if 0
while (depth() && Cursor_.back().asMathInset() != p)
Cursor_.pop_back();
+#endif
}
void MathCursor::popToEnclosingGrid()
{
+#warning FIXME
+#if 0
while (depth() && !Cursor_.back().asMathInset()->asGridInset())
Cursor_.pop_back();
+#endif
}
void MathCursor::popToEnclosingHull()
{
+#warning FIXME
+#if 0
while (depth() && !Cursor_.back().asMathInset()->asHullInset())
Cursor_.pop_back();
+#endif
}
if (popLeft()) {
plainErase();
array().insert(pos(), a);
- Anchor_ = Cursor_;
+ bv_->resetAnchor();
} else {
formula()->mutateToText();
}
void MathCursor::touch()
{
+#warning
+#if 0
CursorBase::const_iterator it = Cursor_.begin();
CursorBase::const_iterator et = Cursor_.end();
for ( ; it != et; ++it)
it->cell().touch();
+#endif
}
void MathCursor::idxNext()
{
- inset()->idxNext(idx(), pos());
+ inset()->idxNext(*bv_);
}
void MathCursor::idxPrev()
{
- inset()->idxPrev(idx(), pos());
+ inset()->idxPrev(*bv_);
}
CursorSlice & MathCursor::cursor()
{
- BOOST_ASSERT(depth());
- return Cursor_.back();
+ return bv_->cursor();
}
CursorSlice const & MathCursor::cursor() const
{
- BOOST_ASSERT(depth());
- return Cursor_.back();
+ return bv_->cursor();
}
getScreenPos(xo, yo);
// check if we had something else in mind, if not, this is the future goal
- if (targetx_ == -1)
- targetx_ = xo;
+ if (bv_->x_target() == -1)
+ bv_->x_target(xo);
else
- xo = targetx_;
+ xo = bv_->x_target();
// try neigbouring script insets
if (!selection()) {
}
// try current cell for e.g. text insets
- if (inset()->idxUpDown2(idx(), pos(), up, targetx_))
+ if (inset()->idxUpDown2(*bv_, up, bv_->x_target()))
return true;
//xarray().boundingBox(xlow, xhigh, ylow, yhigh);
while (1) {
//lyxerr << "updown: We are in " << inset() << " idx: " << idx() << endl;
// ask inset first
- if (inset()->idxUpDown(idx(), pos(), up, targetx_)) {
+ if (inset()->idxUpDown(*bv_, up, bv_->x_target())) {
// try to find best position within this inset
if (!selection())
bruteFind2(xo, yo);
bool MathCursor::bruteFind
(int x, int y, int xlow, int xhigh, int ylow, int yhigh)
{
+#if 0
CursorBase best_cursor;
double best_dist = 1e10;
increment(it);
}
- if (best_dist < 1e10)
- Cursor_ = best_cursor;
+#warning FIXME
+ //if (best_dist < 1e10)
+ // Cursor_ = best_cursor;
return best_dist < 1e10;
+#endif
+ return 0;
}
void MathCursor::bruteFind2(int x, int y)
{
+#if 0
double best_dist = 1e10;
- CursorBase it = Cursor_;
+ CursorBase it = bv_->fullCursor().cursor_;
it.back().pos(0);
- CursorBase et = Cursor_;
+ CursorBase et = bv_->fullCursor().cursor_;
int n = et.back().asMathInset()->cell(et.back().idx_).size();
et.back().pos(n);
for (int i = 0; ; ++i) {
break;
increment(it);
}
+#endif
}
bool MathCursor::idxLeft()
{
- return inset()->idxLeft(idx(), pos());
+ return inset()->idxLeft(*bv_);
}
bool MathCursor::idxRight()
{
- return inset()->idxRight(idx(), pos());
+ return inset()->idxRight(*bv_);
}
bool MathCursor::interpret(char c)
{
//lyxerr << "interpret 2: '" << c << "'" << endl;
- targetx_ = -1; // "no target"
+ bv_->x_target(-1); // "no target"
if (inMacroArgMode()) {
--pos();
plainErase();
void MathCursor::setSelection(CursorBase const & where, size_type n)
{
+#warning FIXME
+#if 0
selection_ = true;
Anchor_ = where;
Cursor_ = where;
cursor().pos_ += n;
+#endif
}
ostringstream os;
os << "Math editor mode. ";
for (int i = 0, n = depth(); i < n; ++i) {
- Cursor_[i].asMathInset()->infoize(os);
+#warning FIXME
+ //Cursor_[i].asMathInset()->infoize(os);
os << " ";
}
if (hasPrevAtom())
unsigned MathCursor::depth() const
{
- return Cursor_.size();
+ return bv_->fullCursor().cursor_.size();
}
CursorSlice MathCursor::normalAnchor() const
{
+#warning FIXME
+#if 0
if (Anchor_.size() < depth()) {
- Anchor_ = Cursor_;
+ bv_->resetAnchor();
lyxerr << "unusual Anchor size" << endl;
}
//lyx::BOOST_ASSERT(Anchor_.size() >= cursor.depth());
++normal.pos_;
}
return normal;
+#else
+ return cursor();
+#endif
}
DispatchResult MathCursor::dispatch(FuncRequest const & cmd)
{
+/*
// mouse clicks are somewhat special
// check
switch (cmd.action) {
}
for (int i = Cursor_.size() - 1; i >= 0; --i) {
- CursorSlice & pos = Cursor_[i];
- DispatchResult const res =
- pos.asMathInset()->dispatch(cmd, pos.idx_, pos.pos_);
+ CursorBase tmp = bv->Cursor_;
+ bv
+ CursorSlice & pos = tmp.back()
+ DispatchResult const res = pos.asMathInset()->dispatch(bv, cmd);
if (res.dispatched()) {
if (res.val() == FINISHED) {
if (i + 1 < Cursor_.size())
return res;
}
}
+*/
return DispatchResult(false);
}
MathInset::mode_type MathCursor::currentMode() const
{
+#warning FIXME
+#if 0
for (int i = Cursor_.size() - 1; i >= 0; --i) {
MathInset::mode_type res = Cursor_[i].asMathInset()->currentMode();
if (res != MathInset::UNDECIDED_MODE)
return res;
}
+#endif
return MathInset::UNDECIDED_MODE;
}
}
-void releaseMathCursor(BufferView * bv)
+void releaseMathCursor(BufferView & bv)
{
if (mathcursor) {
- InsetFormulaBase * f = mathcursor->formula();
+ InsetFormulaBase * f = mathcursor->formula();
delete mathcursor;
mathcursor = 0;
- f->insetUnlock(bv);
+ f->insetUnlock(&bv);
}
}
#include <string>
-
class InsetFormulaBase;
class BufferView;
class PainterInfo;
typedef size_t col_type;
///
- explicit MathCursor(InsetFormulaBase *, bool left);
+ explicit MathCursor(BufferView *, InsetFormulaBase *, bool left);
///
~MathCursor();
///
/// write access to cursor cell index
idx_type & idx();
- /// path of positions the cursor had to go if it were leaving each inset
- CursorBase Cursor_;
- /// path of positions the anchor had to go if it were leaving each inset
- mutable CursorBase Anchor_;
/// pointer to enclsing LyX inset
InsetFormulaBase * formula_;
// Selection stuff
bool selection_;
/// are we entering a macro name?
bool macromode_;
- /// are we targeting a certain x coordinate, if so, which one?
- int targetx_;
+ ///
+ BufferView * bv_;
};
extern MathCursor * mathcursor;
-void releaseMathCursor(BufferView * bv);
+void releaseMathCursor(BufferView & bv);
#endif
{}
-bool MathFracbaseInset::idxRight(idx_type &, pos_type &) const
+bool MathFracbaseInset::idxRight(BufferView &) const
{
return false;
}
-bool MathFracbaseInset::idxLeft(idx_type &, pos_type &) const
+bool MathFracbaseInset::idxLeft(BufferView &) const
{
return false;
}
-bool MathFracbaseInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
- int targetx) const
+bool MathFracbaseInset::idxUpDown(BufferView & bv, bool up, int targetx) const
{
+ CursorSlice & cur = cursorTip(bv);
MathInset::idx_type target = !up; // up ? 0 : 1, since upper cell has idx 0
- if (idx == target)
+ if (cur.idx() == target)
return false;
- idx = target;
- pos = cell(idx).x2pos(targetx);
+ cur.idx() = target;
+ cur.pos() = cell(target).x2pos(targetx);
return true;
}
///
MathFracbaseInset();
///
- bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
+ bool idxUpDown(BufferView &, bool up, int targetx) const;
///
- bool idxLeft(idx_type & idx, pos_type & pos) const;
+ bool idxLeft(BufferView &) const;
///
- bool idxRight(idx_type & idx, pos_type & pos) const;
+ bool idxRight(BufferView &) const;
};
#endif
}
-bool MathGridInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
- int targetx) const
+bool MathGridInset::idxUpDown(BufferView & bv, bool up, int targetx) const
{
+ CursorSlice & cur = cursorTip(bv);
if (up) {
- if (idx < ncols())
+ if (cur.idx() < ncols())
return false;
- idx -= ncols();
- pos = cell(idx).x2pos(targetx - cell(idx).xo());
- return true;
+ cur.idx() -= ncols();
} else {
- if (idx >= ncols() * (nrows() - 1))
+ if (cur.idx() >= ncols() * (nrows() - 1))
return false;
- idx += ncols();
- pos = cell(idx).x2pos(targetx - cell(idx).xo());
- return true;
+ cur.idx() += ncols();
}
+ cur.pos() = cur.cell().x2pos(targetx - cur.cell().xo());
+ return true;
}
-bool MathGridInset::idxLeft(idx_type & idx, pos_type & pos) const
+bool MathGridInset::idxLeft(BufferView & bv) const
{
// leave matrix if on the left hand edge
- if (col(idx) == 0)
+ CursorSlice & cur = cursorTip(bv);
+ if (cur.col() == 0)
return false;
- --idx;
- pos = cell(idx).size();
+ --cur.idx();
+ cur.pos() = cur.lastpos();
return true;
}
-bool MathGridInset::idxRight(idx_type & idx, pos_type & pos) const
+bool MathGridInset::idxRight(BufferView & bv) const
{
// leave matrix if on the right hand edge
- if (col(idx) + 1 == ncols())
+ CursorSlice & cur = cursorTip(bv);
+ if (cur.col() + 1 == ncols())
return false;
- ++idx;
- pos = 0;
+ ++cur.idx();
+ cur.pos() = 0;
return true;
}
-bool MathGridInset::idxFirst(idx_type & idx, pos_type & pos) const
+bool MathGridInset::idxFirst(BufferView & bv) const
{
+ CursorSlice & cur = cursorTip(bv);
switch (v_align_) {
case 't':
- idx = 0;
+ cur.idx() = 0;
break;
case 'b':
- idx = (nrows() - 1) * ncols();
+ cur.idx() = (nrows() - 1) * ncols();
break;
default:
- idx = ((nrows() - 1) / 2) * ncols();
+ cur.idx() = ((nrows() - 1) / 2) * ncols();
}
- pos = 0;
+ cur.pos() = 0;
return true;
}
-bool MathGridInset::idxLast(idx_type & idx, pos_type & pos) const
+bool MathGridInset::idxLast(BufferView & bv) const
{
+ CursorSlice & cur = cursorTip(bv);
switch (v_align_) {
case 't':
- idx = ncols() - 1;
+ cur.idx() = ncols() - 1;
break;
case 'b':
- idx = nargs() - 1;
+ cur.idx() = nargs() - 1;
break;
default:
- idx = ((nrows() - 1) / 2 + 1) * ncols() - 1;
+ cur.idx() = ((nrows() - 1) / 2 + 1) * ncols() - 1;
}
- pos = cell(idx).size();
+ cur.pos() = cur.lastpos();
return true;
}
-bool MathGridInset::idxHome(idx_type & idx, pos_type & pos) const
+bool MathGridInset::idxHome(BufferView & bv) const
{
- if (pos > 0) {
- pos = 0;
+ CursorSlice & cur = cursorTip(bv);
+ if (cur.pos() > 0) {
+ cur.pos() = 0;
return true;
}
- if (col(idx) > 0) {
- idx -= idx % ncols();
- pos = 0;
+ if (cur.col() > 0) {
+ cur.idx() -= cur.idx() % ncols();
+ cur.pos() = 0;
return true;
}
- if (idx > 0) {
- idx = 0;
- pos = 0;
+ if (cur.idx() > 0) {
+ cur.idx() = 0;
+ cur.pos() = 0;
return true;
}
return false;
}
-bool MathGridInset::idxEnd(idx_type & idx, pos_type & pos) const
+bool MathGridInset::idxEnd(BufferView & bv) const
{
- if (pos < cell(idx).size()) {
- pos = cell(idx).size();
+ CursorSlice & cur = cursorTip(bv);
+ if (cur.pos() < cur.lastpos()) {
+ cur.pos() = cur.lastpos();
return true;
}
- if (col(idx) < ncols() - 1) {
- idx = idx - idx % ncols() + ncols() - 1;
- pos = cell(idx).size();
+ if (cur.col() < ncols() - 1) {
+ cur.idx() = cur.idx() - cur.idx() % ncols() + ncols() - 1;
+ cur.pos() = cur.lastpos();
return true;
}
- if (idx < nargs() - 1) {
- idx = nargs() - 1;
- pos = cell(idx).size();
+ if (cur.idx() < nargs() - 1) {
+ cur.idx() = nargs() - 1;
+ cur.pos() = cur.lastpos();
return true;
}
return false;
}
-void MathGridInset::splitCell(idx_type & idx, pos_type & pos)
+void MathGridInset::splitCell(BufferView & bv)
{
- if (idx + 1 == nargs())
+ CursorSlice & cur = cursorTip(bv);
+ if (cur.idx() + 1 == nargs())
return;
- MathArray ar = cell(idx);
- ar.erase(0, pos);
- cell(idx).erase(pos, cell(idx).size());
- ++idx;
- pos = 0;
- cell(idx).insert(0, ar);
+ MathArray ar = cur.cell();
+ ar.erase(0, cur.pos());
+ cur.cell().erase(cur.pos(), cur.lastpos());
+ ++cur.idx();
+ cur.pos() = 0;
+ cur.cell().insert(0, ar);
}
-DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+DispatchResult
+MathGridInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
+ CursorSlice & cur = cursorTip(bv);
switch (cmd.action) {
case LFUN_MOUSE_RELEASE:
return DispatchResult(false);
case LFUN_INSET_DIALOG_UPDATE:
- GridInsetMailer(*this).updateDialog(cmd.view());
+ GridInsetMailer(*this).updateDialog(&bv);
return DispatchResult(false);
// insert file functions
// return;
//}
if (nrows() > 1)
- delRow(row(idx));
- if (idx >= nargs())
- idx = nargs() - 1;
- if (pos > cell(idx).size())
- pos = cell(idx).size();
+ delRow(cur.row());
+ if (cur.idx() >= nargs())
+ cur.idx() = nargs() - 1;
+ if (cur.pos() > cur.lastpos())
+ cur.pos() = cur.lastpos();
return DispatchResult(true, FINISHED);
case LFUN_CELL_SPLIT:
//recordUndo(bv, Undo::ATOMIC);
- splitCell(idx, pos);
+ splitCell(bv);
return DispatchResult(true, FINISHED);
case LFUN_BREAKLINE: {
//recordUndo(bv, Undo::INSERT);
- row_type const r = row(idx);
+ row_type const r = cur.row();
addRow(r);
// split line
- for (col_type c = col(idx) + 1; c < ncols(); ++c)
+ for (col_type c = col(cur.idx()) + 1; c < ncols(); ++c)
std::swap(cell(index(r, c)), cell(index(r + 1, c)));
// split cell
- splitCell(idx, pos);
- std::swap(cell(idx), cell(idx + ncols() - 1));
- if (idx > 0)
- --idx;
- pos = cell(idx).size();
+ splitCell(bv);
+ std::swap(cell(cur.idx()), cell(cur.idx() + ncols() - 1));
+ if (cur.idx() > 0)
+ --cur.idx();
+ cur.idx() = cur.lastpos();
//mathcursor->normalize();
return DispatchResult(true, FINISHED);
else if (s == "valign-bottom")
valign('b');
else if (s == "align-left")
- halign('l', col(idx));
+ halign('l', col(cur.idx()));
else if (s == "align-right")
- halign('r', col(idx));
+ halign('r', col(cur.idx()));
else if (s == "align-center")
- halign('c', col(idx));
+ halign('c', col(cur.idx()));
else if (s == "append-row")
for (int i = 0, n = extractInt(is); i < n; ++i)
- addRow(row(idx));
+ addRow(cur.row());
else if (s == "delete-row")
for (int i = 0, n = extractInt(is); i < n; ++i) {
- delRow(row(idx));
- if (idx > nargs())
- idx -= ncols();
+ delRow(cur.row());
+ if (cur.idx() > nargs())
+ cur.idx() -= ncols();
}
else if (s == "copy-row")
for (int i = 0, n = extractInt(is); i < n; ++i)
- copyRow(row(idx));
+ copyRow(cur.row());
else if (s == "swap-row")
- swapRow(row(idx));
+ swapRow(cur.row());
else if (s == "append-column")
for (int i = 0, n = extractInt(is); i < n; ++i) {
- row_type r = row(idx);
- col_type c = col(idx);
+ row_type r = cur.row();
+ col_type c = col(cur.idx());
addCol(c);
- idx = index(r, c);
+ cur.idx() = index(r, c);
}
else if (s == "delete-column")
for (int i = 0, n = extractInt(is); i < n; ++i) {
- row_type r = row(idx);
- col_type c = col(idx);
- delCol(col(idx));
- idx = index(r, c);
- if (idx > nargs())
- idx -= ncols();
+ row_type r = cur.row();
+ col_type c = col(cur.idx());
+ delCol(col(cur.idx()));
+ cur.idx() = index(r, c);
+ if (cur.idx() > nargs())
+ cur.idx() -= ncols();
}
else if (s == "copy-column")
- copyCol(col(idx));
+ copyCol(col(cur.idx()));
else if (s == "swap-column")
- swapCol(col(idx));
+ swapCol(col(cur.idx()));
else
return DispatchResult(false);
lyxerr << "returning DispatchResult(true, FINISHED)" << endl;
mathed_parse_normal(grid, cmd.argument);
if (grid.nargs() == 1) {
// single cell/part of cell
- cell(idx).insert(pos, grid.cell(0));
- pos += grid.cell(0).size();
+ cur.cell().insert(cur.pos(), grid.cell(0));
+ cur.pos() += grid.cell(0).size();
} else {
// multiple cells
- col_type const numcols = min(grid.ncols(), ncols() - col(idx));
- row_type const numrows = min(grid.nrows(), nrows() - row(idx));
+ col_type const numcols = min(grid.ncols(), ncols() -
+col(cur.idx()));
+ row_type const numrows = min(grid.nrows(), nrows() -
+cur.row());
for (row_type r = 0; r < numrows; ++r) {
for (col_type c = 0; c < numcols; ++c) {
- idx_type i = index(r + row(idx), c + col(idx));
+ idx_type i = index(r + cur.row(), c + col(cur.idx()));
cell(i).insert(0, grid.cell(grid.index(r, c)));
}
// append the left over horizontal cells to the last column
- idx_type i = index(r + row(idx), ncols() - 1);
+ idx_type i = index(r + cur.row(), ncols() - 1);
for (MathInset::col_type c = numcols; c < grid.ncols(); ++c)
cell(i).append(grid.cell(grid.index(r, c)));
}
}
default:
- return MathNestInset::priv_dispatch(cmd, idx, pos);
+ return MathNestInset::priv_dispatch(bv, cmd);
}
}
row_type row(idx_type idx) const;
///
- bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
+ bool idxUpDown(BufferView &, bool up, int targetx) const;
///
- bool idxLeft(idx_type & idx, pos_type & pos) const;
+ bool idxLeft(BufferView &) const;
///
- bool idxRight(idx_type & idx, pos_type & pos) const;
+ bool idxRight(BufferView &) const;
///
- bool idxFirst(idx_type & idx, pos_type & pos) const;
+ bool idxFirst(BufferView &) const;
///
- bool idxLast(idx_type & idx, pos_type & pos) const;
+ bool idxLast(BufferView &) const;
///
- bool idxHome(idx_type & idx, pos_type & pos) const;
+ bool idxHome(BufferView &) const;
///
- bool idxEnd(idx_type & idx, pos_type & pos) const;
+ bool idxEnd(BufferView &) const;
///
bool idxDelete(idx_type & idx);
/// pulls cell after pressing erase
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
/// returns x offset of cell compared to inset
int cellXOffset(idx_type idx) const;
/// extract number of columns from alignment string
col_type guessColumns(std::string const & halign) const;
/// splits cells and shifts right part to the next cell
- void splitCell(idx_type &, pos_type & pos);
+ void splitCell(BufferView & pos);
public:
/// row info
}
-bool MathHullInset::idxFirst(idx_type & idx, pos_type & pos) const
+bool MathHullInset::idxFirst(BufferView & bv) const
{
- idx = 0;
- pos = 0;
+ CursorSlice & cur = cursorTip(bv);
+ cur.idx() = 0;
+ cur.pos() = 0;
return true;
}
-bool MathHullInset::idxLast(idx_type & idx, pos_type & pos) const
+bool MathHullInset::idxLast(BufferView & bv) const
{
- idx = nargs() - 1;
- pos = cell(idx).size();
+ CursorSlice & cur = cursorTip(bv);
+ cur.idx() = nargs() - 1;
+ cur.pos() = cur.lastpos();
return true;
}
}
-void MathHullInset::doExtern
- (FuncRequest const & func, idx_type & idx, pos_type & pos)
+void MathHullInset::doExtern(FuncRequest const & func, BufferView & bv)
{
+ CursorSlice & cur = cursorTip(bv);
string lang;
string extra;
istringstream iss(func.argument.c_str());
eq.push_back(MathAtom(new MathCharInset('=')));
// go to first item in line
- idx -= idx % ncols();
- pos = 0;
+ cur.idx() -= cur.idx() % ncols();
+ cur.pos() = 0;
if (getType() == "simple") {
- size_type pos = cell(idx).find_last(eq);
+ size_type pos = cur.cell().find_last(eq);
MathArray ar;
if (mathcursor && mathcursor->selection()) {
asArray(mathcursor->grabAndEraseSelection(), ar);
- } else if (pos == cell(idx).size()) {
- ar = cell(idx);
+ } else if (pos == cur.cell().size()) {
+ ar = cur.cell();
lyxerr << "use whole cell: " << ar << endl;
} else {
- ar = MathArray(cell(idx).begin() + pos + 1, cell(idx).end());
+ ar = MathArray(cur.cell().begin() + pos + 1, cur.cell().end());
lyxerr << "use partial cell form pos: " << pos << endl;
}
- cell(idx).append(eq);
- cell(idx).append(pipeThroughExtern(lang, extra, ar));
- pos = cell(idx).size();
+ cur.cell().append(eq);
+ cur.cell().append(pipeThroughExtern(lang, extra, ar));
+ cur.pos() = cur.lastpos();
return;
}
if (getType() == "equation") {
lyxerr << "use equation inset" << endl;
mutate("eqnarray");
- MathArray & ar = cell(idx);
+ MathArray & ar = cur.cell();
lyxerr << "use cell: " << ar << endl;
- cell(idx + 1) = eq;
- cell(idx + 2) = pipeThroughExtern(lang, extra, ar);
+ ++cur.idx();
+ cur.cell() = eq;
+ ++cur.idx();
+ cur.cell() = pipeThroughExtern(lang, extra, ar);
// move to end of line
- idx += 2;
- pos = cell(idx).size();
+ cur.pos() = cur.lastpos();
return;
}
{
lyxerr << "use eqnarray" << endl;
- idx -= idx % ncols();
- idx += 2;
- pos = 0;
- MathArray ar = cell(idx);
+ cur.idx() += 2 - cur.idx() % ncols();
+ cur.pos() = 0;
+ MathArray ar = cur.cell();
lyxerr << "use cell: " << ar << endl;
#ifdef WITH_WARNINGS
#warning temporarily disabled
#endif
- addRow(row(idx));
- cell(idx + 2) = eq;
- cell(idx + 3) = pipeThroughExtern(lang, extra, ar);
- idx += 3;
- pos = cell(idx).size();
+ addRow(cur.row());
+ ++cur.idx();
+ ++cur.idx();
+ cur.cell() = eq;
+ ++cur.idx();
+ cur.cell() = pipeThroughExtern(lang, extra, ar);
+ cur.pos() = cur.lastpos();
}
}
-DispatchResult MathHullInset::priv_dispatch
- (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
+DispatchResult
+MathHullInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
+ CursorSlice & cur = cursorTip(bv);
switch (cmd.action) {
case LFUN_BREAKLINE:
if (type_ == "simple" || type_ == "equation") {
mutate("eqnarray");
- idx = 1;
- pos = 0;
+ cur.idx() = 1;
+ cur.pos() = 0;
return DispatchResult(true, FINISHED);
}
- return MathGridInset::priv_dispatch(cmd, idx, pos);
+ return MathGridInset::priv_dispatch(bv, cmd);
case LFUN_MATH_NUMBER:
//lyxerr << "toggling all numbers" << endl;
case LFUN_MATH_NONUMBER:
if (display()) {
- row_type r = (type_ == "multline") ? nrows() - 1 : row(idx);
+ row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
//recordUndo(bv, Undo::INSERT);
bool old = numbered(r);
//bv->owner()->message(old ? _("No number") : _("Number"));
return DispatchResult(true, true);
case LFUN_INSERT_LABEL: {
- row_type r = (type_ == "multline") ? nrows() - 1 : row(idx);
+ row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
string old_label = label(r);
string new_label = cmd.argument;
}
case LFUN_MATH_EXTERN:
- doExtern(cmd, idx, pos);
+ doExtern(cmd, bv);
return DispatchResult(true, FINISHED);
case LFUN_MATH_MUTATE: {
lyxerr << "Hull: MUTATE: " << cmd.argument << endl;
- row_type r = row(idx);
- col_type c = col(idx);
+ row_type r = cur.row();
+ col_type c = cur.col();
mutate(cmd.argument);
- idx = r * ncols() + c;
- if (idx >= nargs())
- idx = nargs() - 1;
- if (pos > cell(idx).size())
- pos = cell(idx).size();
+ cur.idx() = r * ncols() + c;
+ if (cur.idx() >= nargs())
+ cur.idx() = nargs() - 1;
+ if (cur.pos() > cur.lastpos())
+ cur.pos() = cur.lastpos();
return DispatchResult(true, FINISHED);
}
case LFUN_MATH_DISPLAY: {
mutate(type_ == "simple" ? "equation" : "simple");
- idx = 0;
- pos = cell(idx).size();
+ cur.idx() = 0;
+ cur.pos() = cur.lastpos();
return DispatchResult(true, FINISHED);
}
default:
- return MathGridInset::priv_dispatch(cmd, idx, pos);
+ return MathGridInset::priv_dispatch(bv, cmd);
}
}
///
char defaultColAlign(col_type col);
///
- bool idxFirst(idx_type &, pos_type &) const;
+ bool idxFirst(BufferView &) const;
///
- bool idxLast(idx_type &, pos_type &) const;
+ bool idxLast(BufferView &) const;
///
std::string fileInsetLabel() const;
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
///
std::string eolString(row_type row, bool fragile) const;
///
std::string nicelabel(row_type row) const;
///
- void doExtern(FuncRequest const & func, idx_type & idx, pos_type & pos);
+ void doExtern(FuncRequest const & func, BufferView &);
///
void glueall();
///
{}
-bool MathInset::idxNext(idx_type &, pos_type &) const
+bool MathInset::idxNext(BufferView &) const
{
return false;
}
-bool MathInset::idxRight(idx_type &, pos_type &) const
+bool MathInset::idxRight(BufferView &) const
{
return false;
}
-bool MathInset::idxPrev(idx_type &, pos_type &) const
+bool MathInset::idxPrev(BufferView &) const
{
return false;
}
-bool MathInset::idxLeft(idx_type &, pos_type &) const
+bool MathInset::idxLeft(BufferView &) const
{
return false;
}
-bool MathInset::idxUpDown(idx_type &, pos_type &, bool, int) const
+bool MathInset::idxUpDown(BufferView &, bool, int) const
{
return false;
}
-bool MathInset::idxUpDown2(idx_type &, pos_type &, bool, int) const
+bool MathInset::idxUpDown2(BufferView &, bool, int) const
{
return false;
}
-bool MathInset::idxFirst(idx_type &, pos_type &) const
+bool MathInset::idxFirst(BufferView &) const
{
return false;
}
-bool MathInset::idxLast(idx_type &, pos_type &) const
+bool MathInset::idxLast(BufferView &) const
{
return false;
}
-bool MathInset::idxHome(idx_type &, pos_type &) const
+bool MathInset::idxHome(BufferView &) const
{
return false;
}
-bool MathInset::idxEnd(idx_type &, pos_type &) const
+bool MathInset::idxEnd(BufferView &) const
{
return false;
}
#ifndef MATH_INSET_H
#define MATH_INSET_H
+#include "cursor_slice.h"
#include "insets/insetbase.h"
#include <string>
virtual void drawT(TextPainter &, int x, int y) const;
/// Where should we go when we press the up or down cursor key?
- virtual bool idxUpDown(idx_type & idx, pos_type & pos, bool up,
- int targetx) const;
+ virtual bool idxUpDown(BufferView & bv, bool up, int targetx) const;
/// Where should we go when we press the up or down cursor key?
- virtual bool idxUpDown2(idx_type & idx, pos_type & pos, bool up,
- int targetx) const;
+ virtual bool idxUpDown2(BufferView & bv, bool up, int targetx) const;
/// The left key
- virtual bool idxLeft(idx_type & idx, pos_type & pos) const;
+ virtual bool idxLeft(BufferView & bv) const;
/// The right key
- virtual bool idxRight(idx_type & idx, pos_type & pos) const;
+ virtual bool idxRight(BufferView & bv) const;
/// Move one physical cell up
- virtual bool idxNext(idx_type & idx, pos_type & pos) const;
+ virtual bool idxNext(BufferView & bv) const;
/// Move one physical cell down
- virtual bool idxPrev(idx_type & idx, pos_type & pos) const;
+ virtual bool idxPrev(BufferView & bv) const;
/// Target pos when we enter the inset from the left by pressing "Right"
- virtual bool idxFirst(idx_type & idx, pos_type & pos) const;
+ virtual bool idxFirst(BufferView & bv) const;
/// Target pos when we enter the inset from the right by pressing "Left"
- virtual bool idxLast(idx_type & idx, pos_type & pos) const;
+ virtual bool idxLast(BufferView & bv) const;
/// Where should we go if we press home?
- virtual bool idxHome(idx_type & idx, pos_type & pos) const;
+ virtual bool idxHome(BufferView & bv) const;
/// Where should we go if we press end?
- virtual bool idxEnd(idx_type & idx, pos_type & pos) const;
+ virtual bool idxEnd(BufferView & bv) const;
/// Delete a cell and move cursor
virtual bool idxDelete(idx_type &) { return false; }
}
-bool MathMacro::idxUpDown(idx_type & idx, pos_type &, bool up, int x) const
+bool MathMacro::idxUpDown(BufferView & bv, bool up, int x) const
{
- pos_type pos;
+ CursorSlice & cur = cursorTip(bv);
if (up) {
- if (!MathNestInset::idxLeft(idx, pos))
+ if (!MathNestInset::idxLeft(bv))
return false;
- pos = cell(idx).x2pos(x);
- return true;
} else {
- if (!MathNestInset::idxRight(idx, pos))
+ if (!MathNestInset::idxRight(bv))
return false;
- pos = cell(idx).x2pos(x);
- return true;
}
+ cur.pos() = cur.cell().x2pos(x);
+ return true;
}
-bool MathMacro::idxLeft(idx_type &, pos_type &) const
+bool MathMacro::idxLeft(BufferView &) const
{
return false;
}
-bool MathMacro::idxRight(idx_type &, pos_type &) const
+bool MathMacro::idxRight(BufferView &) const
{
return false;
}
void dump() const;
///
- bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
+ bool idxUpDown(BufferView &, bool up, int targetx) const;
///
- bool idxLeft(idx_type & idx, pos_type & pos) const;
+ bool idxLeft(BufferView &) const;
///
- bool idxRight(idx_type & idx, pos_type & pos) const;
+ bool idxRight(BufferView &) const;
///
void validate(LaTeXFeatures &) const;
}
-bool MathNestInset::idxNext(idx_type & idx, pos_type & pos) const
+bool MathNestInset::idxNext(BufferView & bv) const
{
- if (idx + 1 >= nargs())
+ CursorSlice & cur = cursorTip(bv);
+ if (cur.idx() + 1 >= nargs())
return false;
- ++idx;
- pos = 0;
+ ++cur.idx();
+ cur.pos() = 0;
return true;
}
-bool MathNestInset::idxRight(idx_type & idx, pos_type & pos) const
+bool MathNestInset::idxRight(BufferView & bv) const
{
- return idxNext(idx, pos);
+ return idxNext(bv);
}
-bool MathNestInset::idxPrev(idx_type & idx, pos_type & pos) const
+bool MathNestInset::idxPrev(BufferView & bv) const
{
- if (idx == 0)
+ CursorSlice & cur = cursorTip(bv);
+ if (cur.idx() == 0)
return false;
- --idx;
- pos = cell(idx).size();
+ --cur.idx();
+ cur.pos() = cur.lastpos();
return true;
}
-bool MathNestInset::idxLeft(idx_type & idx, pos_type & pos) const
+bool MathNestInset::idxLeft(BufferView & bv) const
{
- return idxPrev(idx, pos);
+ return idxPrev(bv);
}
-bool MathNestInset::idxFirst(idx_type & idx, pos_type & pos) const
+bool MathNestInset::idxFirst(BufferView & bv) const
{
+ CursorSlice & cur = cursorTip(bv);
if (nargs() == 0)
return false;
- idx = 0;
- pos = 0;
+ cur.idx() = 0;
+ cur.pos() = 0;
return true;
}
-bool MathNestInset::idxLast(idx_type & idx, pos_type & pos) const
+bool MathNestInset::idxLast(BufferView & bv) const
{
+ CursorSlice & cur = cursorTip(bv);
if (nargs() == 0)
return false;
- idx = nargs() - 1;
- pos = cell(idx).size();
+ cur.idx() = nargs() - 1;
+ cur.pos() = cur.lastpos();
return true;
}
-bool MathNestInset::idxHome(idx_type & /* idx */, pos_type & pos) const
+bool MathNestInset::idxHome(BufferView & bv) const
{
- if (pos == 0)
+ CursorSlice & cur = cursorTip(bv);
+ if (cur.pos() == 0)
return false;
- pos = 0;
+ cur.pos() = 0;
return true;
}
-bool MathNestInset::idxEnd(idx_type & idx, pos_type & pos) const
+bool MathNestInset::idxEnd(BufferView & bv) const
{
- pos_type n = cell(idx).size();
- if (pos == n)
+ CursorSlice & cur = cursorTip(bv);
+ if (cur.lastpos() == cur.lastpos())
return false;
- pos = n;
+ cur.pos() = cur.lastpos();
return true;
}
DispatchResult
-MathNestInset::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+MathNestInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
- BufferView * bv = cmd.view();
-
+ CursorSlice & cur = cursorTip(bv);
switch (cmd.action) {
case LFUN_PASTE: {
MathArray ar;
mathed_parse_cell(ar, cmd.argument);
- cell(idx).insert(pos, ar);
- pos += ar.size();
+ cur.cell().insert(cur.pos(), ar);
+ cur.pos() += ar.size();
return DispatchResult(true, true);
}
case LFUN_PASTESELECTION:
- return
- dispatch(
- FuncRequest(bv, LFUN_PASTE, bv->getClipboard()), idx, pos);
+ return dispatch(bv, FuncRequest(LFUN_PASTE, bv.getClipboard()));
case LFUN_MOUSE_PRESS:
if (cmd.button() == mouse_button::button2)
- return priv_dispatch(FuncRequest(bv, LFUN_PASTESELECTION), idx, pos);
+ return priv_dispatch(bv, FuncRequest(LFUN_PASTESELECTION));
return DispatchResult(false);
default:
- return MathInset::priv_dispatch(cmd, idx, pos);
+ return MathInset::priv_dispatch(bv, cmd);
}
}
void getScreenPos(idx_type idx, pos_type pos, int & x, int & y) const;
/// order of movement through the cells when pressing the left key
- bool idxLeft(idx_type & idx, pos_type & pos) const;
+ bool idxLeft(BufferView &) const;
/// order of movement through the cells when pressing the right key
- bool idxRight(idx_type & idx, pos_type & pos) const;
+ bool idxRight(BufferView &) const;
/// move one physical cell up
- bool idxNext(idx_type & idx, pos_type & pos) const;
+ bool idxNext(BufferView &) const;
/// move one physical cell down
- bool idxPrev(idx_type & idx, pos_type & pos) const;
+ bool idxPrev(BufferView &) const;
/// target pos when we enter the inset from the left by pressing "Right"
- bool idxFirst(idx_type & idx, pos_type & pos) const;
+ bool idxFirst(BufferView &) const;
/// target pos when we enter the inset from the right by pressing "Left"
- bool idxLast(idx_type & idx, pos_type & pos) const;
+ bool idxLast(BufferView &) const;
/// where should we go if we press home?
- bool idxHome(idx_type & idx, pos_type & pos) const;
+ bool idxHome(BufferView &) const;
/// where should we go if we press end?
- bool idxEnd(idx_type & idx, pos_type & pos) const;
+ bool idxEnd(BufferView &) const;
/// number of cells currently governed by us
idx_type nargs() const;
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
/// we store the cells in a vector
typedef std::vector<MathArray> cells_type;
}
-bool MathOversetInset::idxFirst(idx_type & i, pos_type & pos) const
+bool MathOversetInset::idxFirst(BufferView & bv) const
{
- i = 1;
- pos = 0;
+ CursorSlice & cur = cursorTip(bv);
+ cur.idx() = 1;
+ cur.pos() = 0;
return true;
}
-bool MathOversetInset::idxLast(idx_type & i, pos_type & pos) const
+bool MathOversetInset::idxLast(BufferView & bv) const
{
- i = 1;
- pos = cell(i).size();
+ CursorSlice & cur = cursorTip(bv);
+ cur.idx() = 1;
+ cur.pos() = cur.lastpos();
return true;
}
///
void draw(PainterInfo & pi, int x, int y) const;
///
- bool idxFirst(idx_type & idx, pos_type & pos) const;
+ bool idxFirst(BufferView &) const;
///
- bool idxLast(idx_type & idx, pos_type & pos) const;
+ bool idxLast(BufferView &) const;
///
void write(WriteStream & os) const;
}
-bool MathRootInset::idxUpDown(idx_type & idx, pos_type & pos, bool up, int) const
+bool MathRootInset::idxUpDown(BufferView & bv, bool up, int) const
{
+ CursorSlice & cur = cursorTip(bv);
bool target = !up; // up ? 0 : 1;
- if (idx == target)
+ if (cur.idx() == target)
return false;
- idx = target;
- pos = target ? 0 : cell(0).size();
+ cur.idx() = target;
+ cur.pos() = up ? cur.lastpos() : 0;
return true;
}
///
virtual std::auto_ptr<InsetBase> clone() const;
///
- bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
+ bool idxUpDown(BufferView &, bool up, int targetx) const;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
}
-bool MathScriptInset::idxFirst(idx_type & idx, pos_type & pos) const
+bool MathScriptInset::idxFirst(BufferView & bv) const
{
- idx = 2;
- pos = 0;
+ CursorSlice & cur = cursorTip(bv);
+ cur.idx() = 2;
+ cur.pos() = 0;
return true;
}
-bool MathScriptInset::idxLast(idx_type & idx, pos_type & pos) const
+bool MathScriptInset::idxLast(BufferView & bv) const
{
- idx = 2;
- pos = nuc().size();
+ CursorSlice & cur = cursorTip(bv);
+ cur.idx() = 2;
+ cur.pos() = nuc().size();
return true;
}
}
-bool MathScriptInset::idxRight(idx_type &, pos_type &) const
+bool MathScriptInset::idxRight(BufferView &) const
{
return false;
}
-bool MathScriptInset::idxLeft(idx_type &, pos_type &) const
+bool MathScriptInset::idxLeft(BufferView &) const
{
return false;
}
-bool MathScriptInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
- int) const
+bool MathScriptInset::idxUpDown(BufferView & bv, bool up, int) const
{
- if (idx == 1) {
+ CursorSlice & cur = cursorTip(bv);
+ if (cur.idx() == 1) {
// if we are 'up' we can't go further up
if (up)
return false;
// otherwise go to last base position
- idx = 2;
- pos = cell(2).size();
+ cur.idx() = 2;
+ cur.pos() = cur.lastpos();
}
- else if (idx == 0) {
+ else if (cur.idx() == 0) {
// if we are 'down' we can't go further down
if (!up)
return false;
- idx = 2;
- pos = cell(2).size();
+ cur.idx() = 2;
+ cur.pos() = cur.lastpos();
}
else {
return false;
// go up/down only if in the last position
// or in the first position of something with displayed limits
- if (pos == cell(2).size() || (pos == 0 && hasLimits())) {
- idx = up;
- pos = 0;
+ if (cur.pos() == cur.lastpos() || (cur.pos() == 0 && hasLimits())) {
+ cur.idx() = up;
+ cur.pos() = 0;
return true;
}
return false;
DispatchResult
-MathScriptInset::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+MathScriptInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
if (cmd.action == LFUN_MATH_LIMITS) {
if (!cmd.argument.empty()) {
return DispatchResult(true, true);
}
- return MathNestInset::priv_dispatch(cmd, idx, pos);
+ return MathNestInset::priv_dispatch(bv, cmd);
}
/// write content as something readable by Octave
void octave(OctaveStream &) const;
/// move cursor left
- bool idxLeft(idx_type &, pos_type &) const;
+ bool idxLeft(BufferView &) const;
/// move cursor right
- bool idxRight(idx_type &, pos_type &) const;
+ bool idxRight(BufferView &) const;
/// move cursor up or down
- bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
+ bool idxUpDown(BufferView &, bool up, int targetx) const;
/// Target pos when we enter the inset from the left by pressing "Right"
- bool idxFirst(idx_type & idx, pos_type & pos) const;
+ bool idxFirst(BufferView &) const;
/// Target pos when we enter the inset from the right by pressing "Left"
- bool idxLast(idx_type & idx, pos_type & pos) const;
+ bool idxLast(BufferView &) const;
/// can we enter this cell?
bool validCell(idx_type i) const { return i == 2 || script_[i]; }
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
private:
/// returns x offset for main part
int dxx() const;
}
-bool MathTextInset::idxUpDown2(idx_type &, pos_type & pos, bool up,
+#if 0
+bool MathTextInset::idxUpDown2(BufferView & pos, bool up,
int /*targetx*/) const
{
// try to move only one screen row up or down if possible
pos = cell2.begin_ + cache_.cell(i).x2pos(x, cell2.glue_);
return true;
}
+#endif
void MathTextInset::metrics(MetricsInfo & mi, Dimension & dim) const
void drawSelection(PainterInfo & pi,
idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
/// moves cursor up or down
- bool idxUpDown2(idx_type &, pos_type & pos, bool up, int targetx) const;
+ //bool idxUpDown2(BufferView & pos, bool up, int targetx) const;
protected:
/// row corresponding to given position
idx_type pos2row(pos_type pos) const;
}
-bool MathUndersetInset::idxFirst(idx_type & i, pos_type & pos) const
+bool MathUndersetInset::idxFirst(BufferView & bv) const
{
- i = 1;
- pos = 0;
+ CursorSlice & cur = cursorTip(bv);
+ cur.idx() = 1;
+ cur.pos() = 0;
return true;
}
-bool MathUndersetInset::idxLast(idx_type & i, pos_type & pos) const
+bool MathUndersetInset::idxLast(BufferView & bv) const
{
- i = 1;
- pos = cell(i).size();
+ CursorSlice & cur = cursorTip(bv);
+ cur.idx() = 1;
+ cur.pos() = cur.lastpos();
return true;
}
-bool MathUndersetInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
- int targetx) const
+bool MathUndersetInset::idxUpDown(BufferView & bv, bool up, int targetx) const
{
+ CursorSlice & cur = cursorTip(bv);
idx_type target = up; // up ? 1 : 0, since upper cell has idx 1
- if (idx == target)
+ if (cur.idx() == target)
return false;
- idx = target;
- pos = cell(idx).x2pos(targetx);
+ cur.idx() = target;
+ cur.pos() = cur.cell().x2pos(targetx);
return true;
}
///
void draw(PainterInfo & pi, int x, int y) const;
///
- bool idxFirst(idx_type & idx, pos_type & pos) const;
+ bool idxFirst(BufferView &) const;
///
- bool idxLast(idx_type & idx, pos_type & pos) const;
+ bool idxLast(BufferView &) const;
///
- bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
+ bool idxUpDown(BufferView &, bool up, int targetx) const;
///
void write(WriteStream & os) const;
///
DispatchResult
-RefInset::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+RefInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
switch (cmd.action) {
case LFUN_INSET_MODIFY:
case LFUN_MOUSE_RELEASE:
if (cmd.button() == mouse_button::button3) {
lyxerr << "trying to goto ref" << cell(0) << endl;
- cmd.view()->dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
+ 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");
- cmd.view()->owner()->getDialogs().
- show("ref", data, this);
+ bv.owner()->getDialogs().show("ref", data, this);
return DispatchResult(true, true);
}
break;
// eat other mouse commands
return DispatchResult(true, true);
default:
- return CommandInset::priv_dispatch(cmd, idx, pos);
+ return CommandInset::priv_dispatch(bv, cmd);
}
// not our business
return DispatchResult(false);
///
virtual
DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+ priv_dispatch(BufferView & bv, FuncRequest const & cmd);
};
#endif
}
-void doInsertInset(FuncRequest const & cmd, bool edit, bool pastesel)
+void doInsertInset(BufferView * bv, FuncRequest const & cmd,
+ bool edit, bool pastesel)
{
- InsetOld * inset = createInset(cmd);
+ InsetOld * inset = createInset(bv, cmd);
if (!inset)
return;
- BufferView * bv = cmd.view();
-
bool gotsel = false;
if (bv->selection().set()) {
bv->owner()->dispatch(FuncRequest(LFUN_CUT));
}
-DispatchResult LyXText::dispatch(FuncRequest const & cmd)
+DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
{
//lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
- BufferView * bv = cmd.view();
+ BufferView * bv = &view;
switch (cmd.action) {
string const name = cmd.getArg(0);
InsetBase * inset = bv->owner()->getDialogs().getOpenInset(name);
if (inset) {
- FuncRequest fr(bv, LFUN_INSET_MODIFY, cmd.argument);
- inset->dispatch(fr);
+ FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument);
+ inset->dispatch(*bv, fr);
} else {
- FuncRequest fr(bv, LFUN_INSET_INSERT, cmd.argument);
- dispatch(fr);
+ FuncRequest fr(LFUN_INSET_INSERT, cmd.argument);
+ dispatch(*bv, fr);
}
break;
}
case LFUN_INSET_INSERT: {
- InsetOld * inset = createInset(cmd);
+ InsetOld * inset = createInset(bv, cmd);
if (inset && !bv->insertInset(inset))
delete inset;
break;
if (cursorPar()->layout()->free_spacing)
insertChar(' ');
else
- doInsertInset(cmd, false, false);
+ doInsertInset(bv, cmd, false, false);
moveCursor(bv, false);
break;
case LFUN_ENVIRONMENT_INSERT:
// Open the inset, and move the current selection
// inside it.
- doInsertInset(cmd, true, true);
+ doInsertInset(bv, cmd, true, true);
break;
case LFUN_INDEX_INSERT:
// Just open the inset
- doInsertInset(cmd, true, false);
+ doInsertInset(bv, cmd, true, false);
break;
case LFUN_INDEX_PRINT:
case LFUN_INSERT_LINE:
case LFUN_INSERT_PAGEBREAK:
// do nothing fancy
- doInsertInset(cmd, false, false);
+ doInsertInset(bv, cmd, false, false);
break;
case LFUN_DEPTH_MIN:
case LFUN_MATH_NUMBER:
case LFUN_MATH_EXTERN:
case LFUN_MATH_SIZE:
- mathDispatch(cmd);
+ mathDispatch(*bv, cmd);
break;
case LFUN_EMPH:
void recordUndo(BufferView * bv, Undo::undo_kind kind)
{
- recordUndo(kind, bv->text(), bv->text()->cursor().par());
+ recordUndo(*bv, kind);
+}
+
+
+void recordUndo(BufferView & bv, Undo::undo_kind kind)
+{
+ recordUndo(kind, bv.text(), bv.text()->cursor().par());
}
/// convienience: prepare undo for the paragraph that contains the cursor
void recordUndo(BufferView *, Undo::undo_kind kind);
+void recordUndo(BufferView &, Undo::undo_kind kind);
/// are we avoiding tracking undos currently?
extern bool undo_frozen;