mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
* insettabular.[Ch]: remove remains of the 'update' mechanism,
simplify cursor moving function, re-enable horizontal scrolling for large tables * insetbase.C: * insetbase.[Ch]: remove explicit 'DispatchResult' return type and implicitly assume 'DispatchResult(true, true) with exception of InsetBase::priv_dispatch which does the equivalent of 'retrun DispatchResult(false)' * inset*.[Ch] (priv_dispatch): adjust git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8435 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
61189bef79
commit
357a3741c0
@ -925,12 +925,12 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
|
||||
// built temporary path to inset
|
||||
InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y);
|
||||
lyxerr << "hit inset at tip: " << inset << endl;
|
||||
lyxerr << "created temp cursor: " << cur << endl;
|
||||
lyxerr << "created temp cursor:\n" << cur << endl;
|
||||
|
||||
// Try to dispatch to an non-editable inset near this position
|
||||
DispatchResult res;
|
||||
if (inset)
|
||||
res = inset->dispatch(cur, cmd);
|
||||
inset->dispatch(cur, cmd);
|
||||
|
||||
// Dispatch to the temp cursor.
|
||||
// An inset (or LyXText) can assign this to bv->cursor()
|
||||
|
@ -1,3 +1,19 @@
|
||||
2004-02-16 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* cursor.[Ch]: use new '_void_ dispatch(...)' signature (see
|
||||
insets/ChangeLog)
|
||||
|
||||
* cursor_slice.[Ch]: remove unneeded acessor function
|
||||
|
||||
* lyxtext.h: rename rtl() to isRTL()
|
||||
|
||||
* rowpainter.C:
|
||||
* tabular.C:
|
||||
* text.C:
|
||||
* text2.C:
|
||||
* text3.C: adjust
|
||||
|
||||
|
||||
2004-02-16 Alfredo Braunstein <abraunst@lyx.org>
|
||||
|
||||
* rowpainter.C (paintSelection): coord fix
|
||||
|
@ -119,7 +119,7 @@ PosIterator & PosIterator::operator--()
|
||||
--p.pos;
|
||||
InsetBase * inset = p.pit->getInset(p.pos);
|
||||
if (inset)
|
||||
p.index = inset->numParagraphs();
|
||||
p.index = inset->nargs();
|
||||
} else {
|
||||
if (p.pit == p.pl->begin()) {
|
||||
if (stack_.size() == 1)
|
||||
|
54
src/cursor.C
54
src/cursor.C
@ -81,18 +81,22 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
|
||||
{
|
||||
lyxerr << "\nLCursor::dispatch: cmd: " << cmd0 << endl << *this << endl;
|
||||
FuncRequest cmd = cmd0;
|
||||
disp_.update(true);
|
||||
disp_.val(NONE);
|
||||
for (current_ = cursor_.size() - 1; current_ >= 1; --current_) {
|
||||
DispatchResult res = inset()->dispatch(*this, cmd);
|
||||
if (res.dispatched()) {
|
||||
current_ = cursor_.size() - 1;
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
// the inset's dispatch() is supposed to reset the update and
|
||||
// val flags if necessary
|
||||
inset()->dispatch(*this, cmd);
|
||||
|
||||
|
||||
// "Mutate" the request for semi-handled requests that need
|
||||
// additional handling in outer levels.
|
||||
switch (res.val()) {
|
||||
switch (disp_.val()) {
|
||||
case NONE:
|
||||
// the inset handled the event fully
|
||||
current_ = cursor_.size() - 1;
|
||||
return DispatchResult(true, true);
|
||||
case FINISHED:
|
||||
// the inset handled the event partially
|
||||
cmd = FuncRequest(LFUN_FINISHED_LEFT);
|
||||
break;
|
||||
case FINISHED_RIGHT:
|
||||
@ -106,15 +110,15 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
|
||||
break;
|
||||
default:
|
||||
//lyxerr << "not handled on level " << current_
|
||||
// << " val: " << res.val() << endl;
|
||||
// << " val: " << disp_.val() << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
BOOST_ASSERT(current_ == 0);
|
||||
DispatchResult res = bv_->text()->dispatch(*this, cmd);
|
||||
bv_->text()->dispatch(*this, cmd);
|
||||
//lyxerr << " result: " << res.val() << endl;
|
||||
current_ = cursor_.size() - 1;
|
||||
return res;
|
||||
return disp_;
|
||||
}
|
||||
|
||||
|
||||
@ -1356,9 +1360,10 @@ char LCursor::halign()
|
||||
|
||||
bool LCursor::goUpDown(bool up)
|
||||
{
|
||||
// Be warned: The 'logic' implemented in this function is highly fragile.
|
||||
// A distance of one pixel or a '<' vs '<=' _really_ matters.
|
||||
// So fiddle around with it only if you know what you are doing!
|
||||
// Be warned: The 'logic' implemented in this function is highly
|
||||
// fragile. A distance of one pixel or a '<' vs '<=' _really
|
||||
// matters. So fiddle around with it only if you think you know
|
||||
// what you are doing!
|
||||
int xo = 0;
|
||||
int yo = 0;
|
||||
getPos(xo, yo);
|
||||
@ -1484,10 +1489,9 @@ void LCursor::bruteFind2(int x, int y)
|
||||
double best_dist = 1e10;
|
||||
|
||||
CursorBase it = cursor_;
|
||||
it.back().pos(0);
|
||||
it.back().pos() = 0;
|
||||
CursorBase et = cursor_;
|
||||
int n = et.back().asMathInset()->cell(et.back().idx_).size();
|
||||
et.back().pos(n);
|
||||
et.back().pos() = et.back().asMathInset()->cell(et.back().idx_).size();
|
||||
for (int i = 0; ; ++i) {
|
||||
int xo, yo;
|
||||
CursorSlice & cur = it.back();
|
||||
@ -1936,3 +1940,21 @@ string LCursor::getPossibleLabel()
|
||||
{
|
||||
return inMathed() ? "eq:" : text()->getPossibleLabel(*this);
|
||||
}
|
||||
|
||||
|
||||
void LCursor::notdispatched()
|
||||
{
|
||||
disp_.dispatched(false);
|
||||
}
|
||||
|
||||
|
||||
void LCursor::dispatched(dispatch_result_t res)
|
||||
{
|
||||
disp_.val(res);
|
||||
}
|
||||
|
||||
|
||||
void LCursor::noupdate()
|
||||
{
|
||||
disp_.update(false);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#define CURSOR_H
|
||||
|
||||
#include "cursor_slice.h"
|
||||
#include "dispatchresult.h"
|
||||
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
@ -289,6 +290,10 @@ public:
|
||||
void replaceWord(std::string const & replacestring);
|
||||
/// update our view
|
||||
void update();
|
||||
///
|
||||
void dispatched(dispatch_result_t res);
|
||||
void notdispatched();
|
||||
void noupdate();
|
||||
|
||||
/// output
|
||||
friend std::ostream & operator<<(std::ostream & os, LCursor const & cur);
|
||||
@ -298,6 +303,9 @@ public:
|
||||
std::vector<CursorSlice> cursor_;
|
||||
/// the anchor position
|
||||
std::vector<CursorSlice> anchor_;
|
||||
|
||||
///
|
||||
DispatchResult disp_;
|
||||
|
||||
private:
|
||||
///
|
||||
|
@ -41,12 +41,6 @@ CursorSlice::CursorSlice(InsetBase * p)
|
||||
}
|
||||
|
||||
|
||||
void CursorSlice::idx(idx_type idx)
|
||||
{
|
||||
idx_ = idx;
|
||||
}
|
||||
|
||||
|
||||
size_t CursorSlice::nargs() const
|
||||
{
|
||||
return inset_->nargs();
|
||||
@ -77,12 +71,6 @@ CursorSlice::idx_type & CursorSlice::idx()
|
||||
}
|
||||
|
||||
|
||||
void CursorSlice::par(par_type par)
|
||||
{
|
||||
par_ = par;
|
||||
}
|
||||
|
||||
|
||||
CursorSlice::par_type CursorSlice::par() const
|
||||
{
|
||||
return par_;
|
||||
@ -95,12 +83,6 @@ CursorSlice::par_type & CursorSlice::par()
|
||||
}
|
||||
|
||||
|
||||
void CursorSlice::pos(pos_type pos)
|
||||
{
|
||||
pos_ = pos;
|
||||
}
|
||||
|
||||
|
||||
CursorSlice::pos_type CursorSlice::pos() const
|
||||
{
|
||||
return pos_;
|
||||
@ -119,12 +101,6 @@ CursorSlice::pos_type CursorSlice::lastpos() const
|
||||
}
|
||||
|
||||
|
||||
void CursorSlice::boundary(bool boundary)
|
||||
{
|
||||
boundary_ = boundary;
|
||||
}
|
||||
|
||||
|
||||
bool CursorSlice::boundary() const
|
||||
{
|
||||
return boundary_;
|
||||
@ -233,8 +209,9 @@ bool operator>(CursorSlice const & p, CursorSlice const & q)
|
||||
|
||||
std::ostream & operator<<(std::ostream & os, CursorSlice const & item)
|
||||
{
|
||||
os << "inset: " << item.inset_
|
||||
<< " text: " << item.text()
|
||||
os
|
||||
// << "inset: " << item.inset_
|
||||
// << " text: " << item.text()
|
||||
<< " idx: " << item.idx_
|
||||
<< " par: " << item.par_
|
||||
<< " pos: " << item.pos_
|
||||
|
@ -58,22 +58,16 @@ public:
|
||||
|
||||
/// the current inset
|
||||
InsetBase * inset() const { return inset_; }
|
||||
/// set the paragraph that contains this cursor
|
||||
void idx(idx_type idx);
|
||||
/// return the cell this cursor is in
|
||||
idx_type idx() const;
|
||||
/// return the cell this cursor is in
|
||||
idx_type & idx();
|
||||
/// return the last cell in this inset
|
||||
idx_type lastidx() const { return nargs() - 1; }
|
||||
/// 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
|
||||
@ -95,8 +89,6 @@ public:
|
||||
/// texted specific stuff
|
||||
///
|
||||
/// see comment for the member
|
||||
void boundary(bool b);
|
||||
/// see comment for the member
|
||||
bool boundary() const;
|
||||
/// see comment for the member
|
||||
bool & boundary();
|
||||
|
@ -1,4 +1,18 @@
|
||||
|
||||
2004-02-16 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* insetbase.C:
|
||||
* insetbase.[Ch]: remove explicit 'DispatchResult' return type and
|
||||
implicitly assume 'DispatchResult(true, true) with exception of
|
||||
InsetBase::priv_dispatch which does the equivalent of
|
||||
'retrun DispatchResult(false)'
|
||||
|
||||
* inset*.[Ch] (priv_dispatch): adjust
|
||||
|
||||
* insettabular.[Ch]: remove remains of the 'update' mechanism,
|
||||
simplify cursor moving function,
|
||||
re-enable horizontal scrolling for large tables
|
||||
|
||||
2004-02-13 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* insettabular.[Ch]: some work after IU
|
||||
|
@ -27,16 +27,16 @@
|
||||
|
||||
|
||||
|
||||
DispatchResult InsetBase::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetBase::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
return priv_dispatch(cur, cmd);
|
||||
priv_dispatch(cur, cmd);
|
||||
}
|
||||
|
||||
|
||||
DispatchResult InsetBase::priv_dispatch(LCursor &, FuncRequest const &)
|
||||
void InsetBase::priv_dispatch(LCursor & cur, FuncRequest const &)
|
||||
{
|
||||
lyxerr << "InsetBase::priv_dispatch" << std::endl;
|
||||
return DispatchResult(false);
|
||||
cur.noupdate();
|
||||
cur.notdispatched();
|
||||
}
|
||||
|
||||
|
||||
@ -46,9 +46,9 @@ void InsetBase::edit(LCursor &, bool)
|
||||
}
|
||||
|
||||
|
||||
InsetBase * InsetBase::editXY(LCursor & cur, int, int)
|
||||
InsetBase * InsetBase::editXY(LCursor &, int x, int y)
|
||||
{
|
||||
lyxerr << "InsetBase: edit xy" << std::endl;
|
||||
lyxerr << "InsetBase: editXY x:" << x << " y: " << y << std::endl;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -133,29 +133,6 @@ std::string const & InsetBase::getInsetName() const
|
||||
}
|
||||
|
||||
|
||||
int InsetBase::getCell(int x, int y) const
|
||||
{
|
||||
for (int i = 0, n = numParagraphs(); i < n; ++i) {
|
||||
LyXText * text = getText(i);
|
||||
//lyxerr << "### text: " << text << " i: " << i
|
||||
// << " xo: " << text->xo_ << "..." << text->xo_ + text->width
|
||||
// << " yo: " << text->yo_
|
||||
// << " yo: " << text->yo_ - text->ascent() << "..."
|
||||
// << text->yo_ + text->descent()
|
||||
// << std::endl;
|
||||
if (x >= text->xo_
|
||||
&& x <= text->xo_ + text->width
|
||||
&& y >= text->yo_
|
||||
&& y <= text->yo_ + text->height)
|
||||
{
|
||||
lyxerr << "### found text # " << i << std::endl;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void InsetBase::markErased()
|
||||
{}
|
||||
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
virtual UpdatableInset * asUpdatableInset() { return 0; }
|
||||
|
||||
// the real dispatcher
|
||||
DispatchResult dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
void dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
|
||||
/// cursor enters
|
||||
virtual void edit(LCursor & cur, bool left);
|
||||
@ -340,10 +340,6 @@ public:
|
||||
|
||||
/// if this insets owns text cells (e.g. InsetText) return cell num
|
||||
virtual LyXText * getText(int /*num*/) const { return 0; }
|
||||
///
|
||||
virtual int numParagraphs() const { return 0; }
|
||||
/// returns cell covering position (x,y), -1 if none exists
|
||||
virtual int getCell(int x, int y) const;
|
||||
|
||||
/** Adds a LaTeX snippet to the Preview Loader for transformation
|
||||
* into a bitmap image. Does not start the laoding process.
|
||||
@ -354,8 +350,7 @@ public:
|
||||
virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
|
||||
protected:
|
||||
// the real dispatcher
|
||||
virtual
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
public:
|
||||
/// returns LyX code associated with the inset. Used for TOC, ...)
|
||||
virtual Code lyxCode() const { return NO_CODE; }
|
||||
|
@ -53,8 +53,7 @@ auto_ptr<InsetBase> InsetBibitem::clone() const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetBibitem::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetBibitem::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -62,15 +61,16 @@ InsetBibitem::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
InsetCommandParams p;
|
||||
InsetCommandMailer::string2params("bibitem", cmd.argument, p);
|
||||
if (p.getCmdName().empty())
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
setParams(p);
|
||||
cur.bv().update();
|
||||
cur.bv().fitCursor();
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return InsetCommand::priv_dispatch(cur, cmd);
|
||||
InsetCommand::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,9 +50,7 @@ public:
|
||||
std::string const getBibLabel() const;
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
///
|
||||
int counter;
|
||||
|
@ -65,8 +65,7 @@ std::auto_ptr<InsetBase> InsetBibtex::clone() const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetBibtex::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetBibtex::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -75,11 +74,12 @@ InsetBibtex::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
InsetCommandMailer::string2params("bibtex", cmd.argument, p);
|
||||
if (!p.getCmdName().empty())
|
||||
setParams(p);
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return InsetCommand::priv_dispatch(cur, cmd);
|
||||
InsetCommand::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,9 +46,7 @@ public:
|
||||
bool delDatabase(std::string const &);
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
};
|
||||
|
||||
#endif // INSET_BIBTEX_H
|
||||
|
@ -169,8 +169,7 @@ bool InsetBox::showInsetDialog(BufferView * bv) const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetBox::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetBox::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -178,22 +177,24 @@ InsetBox::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
lyxerr << "InsetBox::dispatch MODIFY" << endl;
|
||||
InsetBoxMailer::string2params(cmd.argument, params_);
|
||||
setButtonLabel();
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetBoxMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true);
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
|
||||
InsetBoxMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true);
|
||||
break;
|
||||
}
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
|
||||
default:
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,9 +105,7 @@ public:
|
||||
};
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
friend class InsetBoxParams;
|
||||
|
||||
|
@ -110,8 +110,7 @@ bool InsetBranch::showInsetDialog(BufferView * bv) const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetBranch::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetBranch::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_INSET_MODIFY: {
|
||||
@ -119,27 +118,30 @@ InsetBranch::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
InsetBranchMailer::string2params(cmd.argument, params);
|
||||
params_.branch = params.branch;
|
||||
setButtonLabel();
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
if (cmd.button() != mouse_button::button3)
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
return DispatchResult(false);
|
||||
InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
else
|
||||
cur.notdispatched();
|
||||
break;
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetBranchMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true);
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
|
||||
if (cmd.button() == mouse_button::button3 && hitButton(cmd))
|
||||
InsetBranchMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true);
|
||||
}
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
else
|
||||
InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
|
||||
default:
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,9 +81,7 @@ public:
|
||||
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
friend class InsetBranchParams;
|
||||
|
||||
|
@ -146,20 +146,20 @@ void InsetCharStyle::getDrawFont(LyXFont & font) const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetCharStyle::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetCharStyle::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
setStatus(Inlined);
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_PRESS:
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
if (cmd.button() == mouse_button::button3)
|
||||
has_label_ = !has_label_;
|
||||
return DispatchResult(true);
|
||||
}
|
||||
inset.dispatch(cur, cmd);
|
||||
return DispatchResult(true, true);
|
||||
else
|
||||
inset.dispatch(cur, cmd);
|
||||
break;
|
||||
|
||||
default:
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,9 +85,7 @@ public:
|
||||
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
|
||||
private:
|
||||
friend class InsetCharStyleParams;
|
||||
|
@ -201,19 +201,18 @@ bool InsetCollapsable::descendable() const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
if (cmd.button() == mouse_button::button3)
|
||||
showInsetDialog(&cur.bv());
|
||||
}
|
||||
|
||||
switch (status_) {
|
||||
|
||||
case Collapsed:
|
||||
lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
|
||||
setStatus(Open);
|
||||
edit(cur, true);
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case Open: {
|
||||
FuncRequest cmd1 = cmd;
|
||||
@ -221,17 +220,18 @@ InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
||||
if (hitButton(cmd1)) {
|
||||
lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
|
||||
setStatus(Collapsed);
|
||||
return DispatchResult(false, FINISHED_RIGHT);
|
||||
cur.dispatched(FINISHED_RIGHT);
|
||||
break;
|
||||
}
|
||||
lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
|
||||
return inset.dispatch(cur, cmd);
|
||||
inset.dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
|
||||
case Inlined:
|
||||
return inset.dispatch(cur, cmd);
|
||||
inset.dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
BOOST_ASSERT(false);
|
||||
// shut up compiler
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
|
||||
@ -320,8 +320,7 @@ InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y)
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
//lyxerr << "\nInsetCollapsable::priv_dispatch (begin): cmd: " << cmd
|
||||
// << " button y: " << button_dim.y2 << endl;
|
||||
@ -331,30 +330,33 @@ InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
inset.dispatch(cur, cmd);
|
||||
else if (status_ == Open && cmd.y > button_dim.y2)
|
||||
inset.dispatch(cur, cmd);
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_MOTION:
|
||||
if (status_ == Inlined)
|
||||
inset.dispatch(cur, cmd);
|
||||
else if (status_ == Open && cmd.y > button_dim.y2)
|
||||
inset.dispatch(cur, cmd);
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
return lfunMouseRelease(cur, cmd);
|
||||
lfunMouseRelease(cur, cmd);
|
||||
break;
|
||||
|
||||
case LFUN_INSET_TOGGLE:
|
||||
if (inset.text_.toggleInset(cur))
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
if (status_ == Open) {
|
||||
setStatus(Inlined);
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
setStatus(Collapsed);
|
||||
return DispatchResult(false, FINISHED_RIGHT);
|
||||
cur.dispatched(FINISHED_RIGHT);
|
||||
break;
|
||||
|
||||
default:
|
||||
return inset.dispatch(cur, cmd);
|
||||
inset.dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,9 +392,9 @@ int InsetCollapsable::scroll(bool recursive) const
|
||||
}
|
||||
|
||||
|
||||
int InsetCollapsable::numParagraphs() const
|
||||
size_t InsetCollapsable::nargs() const
|
||||
{
|
||||
return inset.numParagraphs();
|
||||
return inset.nargs();
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,7 +97,7 @@ public:
|
||||
///
|
||||
void scroll(BufferView & bv, int offset) const;
|
||||
///
|
||||
int numParagraphs() const;
|
||||
size_t nargs() const;
|
||||
///
|
||||
LyXText * getText(int) const;
|
||||
///
|
||||
@ -123,7 +123,7 @@ public:
|
||||
|
||||
protected:
|
||||
///
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
void dimension_collapsed(Dimension &) const;
|
||||
///
|
||||
@ -141,7 +141,7 @@ protected:
|
||||
|
||||
private:
|
||||
///
|
||||
DispatchResult lfunMouseRelease(LCursor & cur, FuncRequest const & cmd);
|
||||
void lfunMouseRelease(LCursor & cur, FuncRequest const & cmd);
|
||||
|
||||
public:
|
||||
///
|
||||
|
@ -98,33 +98,35 @@ int InsetCommand::docbook(Buffer const &, ostream &,
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetCommand::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetCommand::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_INSET_MODIFY: {
|
||||
InsetCommandParams p;
|
||||
InsetCommandMailer::string2params(mailer_name_, cmd.argument, p);
|
||||
if (p.getCmdName().empty())
|
||||
return DispatchResult(false);
|
||||
setParams(p);
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
if (p.getCmdName().empty()) {
|
||||
cur.notdispatched();
|
||||
} else {
|
||||
setParams(p);
|
||||
cur.bv().update();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetCommandMailer(cmd.argument, *this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_INSET_DIALOG_SHOW:
|
||||
case LFUN_MOUSE_RELEASE: {
|
||||
if (!mailer_name_.empty())
|
||||
InsetCommandMailer(mailer_name_, *this).showDialog(&cur.bv());
|
||||
return DispatchResult(true);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return DispatchResult(false);
|
||||
InsetOld::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -74,9 +74,7 @@ public:
|
||||
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
std::string const getCommand() const { return p_.getCommand(); }
|
||||
///
|
||||
|
@ -24,8 +24,7 @@ public:
|
||||
///
|
||||
InsetCommandParams();
|
||||
///
|
||||
explicit
|
||||
InsetCommandParams(std::string const & n,
|
||||
explicit InsetCommandParams(std::string const & n,
|
||||
std::string const & c = std::string(),
|
||||
std::string const & o = std::string());
|
||||
///
|
||||
|
@ -208,7 +208,7 @@ int InsetERT::docbook(Buffer const &, ostream & os,
|
||||
}
|
||||
|
||||
|
||||
DispatchResult InsetERT::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetERT::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
//lyxerr << "\nInsetERT::priv_dispatch (begin): cmd: " << cmd << endl;
|
||||
switch (cmd.action) {
|
||||
@ -217,9 +217,10 @@ DispatchResult InsetERT::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
InsetCollapsable::CollapseStatus st;
|
||||
InsetERTMailer::string2params(cmd.argument, st);
|
||||
setStatus(st);
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
// suppress these
|
||||
case LFUN_LAYOUT:
|
||||
case LFUN_BOLD:
|
||||
case LFUN_CODE:
|
||||
@ -235,10 +236,11 @@ DispatchResult InsetERT::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
case LFUN_FONT_SIZE:
|
||||
case LFUN_FONT_STATE:
|
||||
case LFUN_UNDERLINE:
|
||||
return DispatchResult(true);
|
||||
break;
|
||||
|
||||
default:
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,9 +74,7 @@ public:
|
||||
bool forceDefaultParagraphs(InsetBase const *) const { return true; }
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
///
|
||||
void init();
|
||||
|
@ -441,8 +441,7 @@ void InsetExternal::statusChanged() const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetExternal::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetExternal::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -451,7 +450,7 @@ InsetExternal::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
InsetExternalParams p;
|
||||
InsetExternalMailer::string2params(cmd.argument, buffer, p);
|
||||
external::editExternal(p, buffer);
|
||||
return DispatchResult(true);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSET_MODIFY: {
|
||||
@ -460,19 +459,19 @@ InsetExternal::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
InsetExternalMailer::string2params(cmd.argument, buffer, p);
|
||||
setParams(p, buffer);
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetExternalMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
InsetExternalMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DispatchResult(false);
|
||||
InsetOld::dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,9 +151,7 @@ public:
|
||||
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
/** This method is connected to the graphics loader, so we are
|
||||
* informed when the image has been loaded.
|
||||
|
@ -155,8 +155,7 @@ InsetFloat::~InsetFloat()
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetFloat::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetFloat::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -167,16 +166,17 @@ InsetFloat::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
params_.wide = params.wide;
|
||||
wide(params_.wide, cur.bv().buffer()->params());
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE: {
|
||||
InsetFloatMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,9 +78,7 @@ public:
|
||||
///
|
||||
InsetFloatParams const & params() const { return params_; }
|
||||
protected:
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
///
|
||||
InsetFloatParams params_;
|
||||
|
@ -191,8 +191,7 @@ void InsetGraphics::statusChanged() const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetGraphics::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetGraphics::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_INSET_MODIFY: {
|
||||
@ -203,19 +202,20 @@ InsetGraphics::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
setParams(p);
|
||||
cur.bv().update();
|
||||
}
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetGraphicsMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
InsetGraphicsMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DispatchResult(false);
|
||||
InsetOld::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
void edit(LCursor & cur, bool left);
|
||||
protected:
|
||||
///
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
///
|
||||
friend class InsetGraphicsMailer;
|
||||
|
@ -108,8 +108,7 @@ InsetInclude::~InsetInclude()
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetInclude::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetInclude::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -120,24 +119,25 @@ InsetInclude::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
set(p, *cur.bv().buffer());
|
||||
cur.bv().update();
|
||||
}
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetIncludeMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (button_.box().contains(cmd.x, cmd.y))
|
||||
InsetIncludeMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_INSET_DIALOG_SHOW:
|
||||
InsetIncludeMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DispatchResult(false);
|
||||
InsetOld::dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,9 +83,7 @@ public:
|
||||
void addPreview(lyx::graphics::PreviewLoader &) const;
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
/// Slot receiving a signal that the preview is ready to display.
|
||||
void statusChanged() const;
|
||||
|
@ -91,25 +91,27 @@ void changeRefsIfUnique(BufferView & bv, string const & from, string const & to)
|
||||
} // namespace anon
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetLabel::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetLabel::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_INSET_MODIFY: {
|
||||
InsetCommandParams p;
|
||||
InsetCommandMailer::string2params("label", cmd.argument, p);
|
||||
if (p.getCmdName().empty())
|
||||
return DispatchResult(false);
|
||||
if (p.getCmdName().empty()) {
|
||||
cur.notdispatched();
|
||||
break;
|
||||
}
|
||||
if (p.getContents() != params().getContents())
|
||||
changeRefsIfUnique(cur.bv(), params().getContents(),
|
||||
p.getContents());
|
||||
setParams(p);
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return InsetCommand::priv_dispatch(cur, cmd);
|
||||
InsetCommand::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,9 +42,7 @@ public:
|
||||
OutputParams const &) const;
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -30,8 +30,7 @@ public:
|
||||
///
|
||||
InsetLatexAccent();
|
||||
///
|
||||
explicit
|
||||
InsetLatexAccent(std::string const & str);
|
||||
explicit InsetLatexAccent(std::string const & str);
|
||||
///
|
||||
void metrics(MetricsInfo &, Dimension &) const;
|
||||
///
|
||||
|
@ -184,31 +184,30 @@ bool InsetNote::showInsetDialog(BufferView * bv) const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetNote::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetNote::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_INSET_MODIFY: {
|
||||
case LFUN_INSET_MODIFY:
|
||||
InsetNoteMailer::string2params(cmd.argument, params_);
|
||||
setButtonLabel();
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetNoteMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
|
||||
if (cmd.button() == mouse_button::button3 && hitButton(cmd))
|
||||
InsetNoteMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
else
|
||||
InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
|
||||
default:
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,9 +75,7 @@ public:
|
||||
InsetNoteParams const & params() const { return params_; }
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
friend class InsetNoteParams;
|
||||
|
||||
|
@ -40,7 +40,7 @@ InsetRef::InsetRef(InsetRef const & ir)
|
||||
{}
|
||||
|
||||
|
||||
DispatchResult InsetRef::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetRef::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_PRESS:
|
||||
@ -49,10 +49,10 @@ DispatchResult InsetRef::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
cur.bv().owner()->dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
|
||||
else
|
||||
InsetCommandMailer("ref", *this).showDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
return;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
return DispatchResult(true, true);
|
||||
return;
|
||||
|
||||
default:
|
||||
return InsetCommand::priv_dispatch(cur, cmd);
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
void validate(LaTeXFeatures & features) const;
|
||||
protected:
|
||||
///
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
///
|
||||
bool isLatex;
|
||||
|
@ -155,19 +155,17 @@ bool InsetTabular::hasPasteBuffer() const
|
||||
|
||||
InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
|
||||
: tabular(buf.params(), max(rows, 1), max(columns, 1)),
|
||||
buffer_(&buf), cursorx_(0), cursory_(0)
|
||||
buffer_(&buf), cursorx_(0)
|
||||
{
|
||||
tabular.setOwner(this);
|
||||
in_reset_pos = 0;
|
||||
}
|
||||
|
||||
|
||||
InsetTabular::InsetTabular(InsetTabular const & tab)
|
||||
: UpdatableInset(tab), tabular(tab.tabular),
|
||||
buffer_(tab.buffer_), cursorx_(0), cursory_(0)
|
||||
buffer_(tab.buffer_), cursorx_(0)
|
||||
{
|
||||
tabular.setOwner(this);
|
||||
in_reset_pos = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -233,7 +231,25 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
BOOST_ASSERT(false);
|
||||
}
|
||||
|
||||
calculate_dimensions_of_cells(mi);
|
||||
for (int i = 0, cell = -1; i < tabular.rows(); ++i) {
|
||||
int maxAsc = 0;
|
||||
int maxDesc = 0;
|
||||
for (int j = 0; j < tabular.columns(); ++j) {
|
||||
if (tabular.isPartOfMultiColumn(i, j))
|
||||
continue;
|
||||
++cell;
|
||||
Dimension dim;
|
||||
MetricsInfo m = mi;
|
||||
m.base.textwidth =
|
||||
tabular.column_info[j].p_width.inPixels(mi.base.textwidth);
|
||||
tabular.getCellInset(cell).metrics(m, dim);
|
||||
maxAsc = max(maxAsc, dim.asc);
|
||||
maxDesc = max(maxDesc, dim.des);
|
||||
tabular.setWidthOfCell(cell, dim.wid);
|
||||
}
|
||||
tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT);
|
||||
tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT);
|
||||
}
|
||||
|
||||
dim.asc = tabular.getAscentOfRow(0);
|
||||
dim.des = tabular.getHeightOfTabular() - tabular.getAscentOfRow(0) + 1;
|
||||
@ -254,11 +270,11 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
||||
|
||||
x += ADD_TO_TABULAR_WIDTH;
|
||||
|
||||
int cell = 0;
|
||||
int idx = 0;
|
||||
first_visible_cell = -1;
|
||||
for (int i = 0; i < tabular.rows(); ++i) {
|
||||
int nx = x;
|
||||
cell = tabular.getCellNumber(i, 0);
|
||||
idx = tabular.getCellNumber(i, 0);
|
||||
if (y + tabular.getDescentOfRow(i) <= 0 &&
|
||||
y - tabular.getAscentOfRow(i) < pi.pain.paperHeight())
|
||||
{
|
||||
@ -273,15 +289,15 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
||||
if (tabular.isPartOfMultiColumn(i, j))
|
||||
continue;
|
||||
if (first_visible_cell < 0)
|
||||
first_visible_cell = cell;
|
||||
first_visible_cell = idx;
|
||||
if (bv->cursor().selection())
|
||||
drawCellSelection(pi, nx, y, i, j, cell);
|
||||
drawCellSelection(pi, nx, y, i, j, idx);
|
||||
|
||||
int const cx = nx + tabular.getBeginningOfTextInCell(cell);
|
||||
tabular.getCellInset(cell).draw(pi, cx, y);
|
||||
drawCellLines(pi.pain, nx, y, i, cell);
|
||||
nx += tabular.getWidthOfColumn(cell);
|
||||
++cell;
|
||||
int const cx = nx + tabular.getBeginningOfTextInCell(idx);
|
||||
cell(idx).draw(pi, cx, y);
|
||||
drawCellLines(pi.pain, nx, y, i, idx);
|
||||
nx += tabular.getWidthOfColumn(idx);
|
||||
++idx;
|
||||
}
|
||||
|
||||
// Would be nice, but for some completely unfathomable reason,
|
||||
@ -361,48 +377,6 @@ string const InsetTabular::editMessage() const
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::updateLocal(LCursor & cur) const
|
||||
{
|
||||
cur.bv().update();
|
||||
resetPos(cur);
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::lfunMousePress(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
if (cmd.button() == mouse_button::button3)
|
||||
return;
|
||||
|
||||
int cell = getCell(cmd.x + xo_, cmd.y + yo_);
|
||||
cur.selection() = false;
|
||||
|
||||
lyxerr << "# InsetTabular::lfunMousePress cell: " << cell << endl;
|
||||
if (cell == -1) {
|
||||
//cur.cursor_ = theTempCursor;
|
||||
cur.push(this);
|
||||
cur.idx() = cell;
|
||||
} else {
|
||||
setPos(cur, cmd.x, cmd.y);
|
||||
//cur.cursor_ = theTempCursor;
|
||||
cur.idx() = cell;
|
||||
}
|
||||
cur.resetAnchor();
|
||||
lyxerr << cur << endl;
|
||||
|
||||
if (cmd.button() == mouse_button::button2)
|
||||
dispatch(cur, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
int const actcell = getCell(cmd.x + xo_, cmd.y + yo_);
|
||||
lyxerr << "# InsetTabular::lfunMouseRelease cell: " << actcell << endl;
|
||||
if (cmd.button() == mouse_button::button3)
|
||||
InsetTabularMailer(*this).showDialog(&cur.bv());
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::edit(LCursor & cur, bool left)
|
||||
{
|
||||
lyxerr << "InsetTabular::edit: " << this << endl;
|
||||
@ -429,185 +403,110 @@ void InsetTabular::edit(LCursor & cur, bool left)
|
||||
|
||||
InsetBase * InsetTabular::editXY(LCursor & cur, int x, int y)
|
||||
{
|
||||
lyxerr << "InsetTabular::edit: " << this << endl;
|
||||
//lyxerr << "InsetTabular::editXY: " << this << endl;
|
||||
cur.selection() = false;
|
||||
cur.push(this);
|
||||
return setPos(cur, x, y);
|
||||
//int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell);
|
||||
//if (x > xx)
|
||||
// activateCellInset(bv, cell, x - xx, y - cursory_);
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
int const actcell = getCell(cmd.x + xo_, cmd.y + yo_);
|
||||
cur.idx() = actcell;
|
||||
lyxerr << "# InsetTabular::lfunMouseMotion cell: " << actcell << endl;
|
||||
lyxerr << "# InsetTabular::dispatch: cmd: " << cmd << endl;
|
||||
//lyxerr << " cur:\n" << cur << endl;
|
||||
CursorSlice sl = cur.current();
|
||||
|
||||
setPos(cur, cmd.x, cmd.y);
|
||||
/*
|
||||
if (!hasSelection()) {
|
||||
setSelection(actcell, actcell);
|
||||
cur.setSelection();
|
||||
} else {
|
||||
setSelection(sel_cell_start, actcell);
|
||||
tablemode = (sel_cell_start != actcell);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetTabular::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
lyxerr << "# InsetTabular::dispatch: " << cmd << endl;
|
||||
|
||||
InsetText & cell = tabular.getCellInset(cur.idx());
|
||||
|
||||
DispatchResult result(true, true);
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
// we'll pop up the table dialog on release
|
||||
if (cmd.button() == mouse_button::button3)
|
||||
DispatchResult(true, true);
|
||||
break;
|
||||
cur.selection() = false;
|
||||
setPos(cur, cmd.x, cmd.y);
|
||||
cur.resetAnchor();
|
||||
cur.bv().cursor() = cur;
|
||||
//if (cmd.button() == mouse_button::button2)
|
||||
// dispatch(cur, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
|
||||
//lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_MOTION:
|
||||
lfunMouseMotion(cur, cmd);
|
||||
return DispatchResult(true, true);
|
||||
if (cmd.button() != mouse_button::button1)
|
||||
break;
|
||||
setPos(cur, cmd.x, cmd.y);
|
||||
cur.bv().cursor().cursor_ = cur.cursor_;
|
||||
cur.bv().cursor().selection() = true;
|
||||
//lyxerr << "# InsetTabular::MouseMotion\n" << cur.bv().cursor() << endl;
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
lfunMouseRelease(cur, cmd);
|
||||
return DispatchResult(true, true);
|
||||
|
||||
#if 0
|
||||
int const cell = cur.idx();
|
||||
lyxerr << "# InsetTabular::dispatch: A " << cur << endl;
|
||||
result = cell.dispatch(cur, cmd);
|
||||
|
||||
switch (result.val()) {
|
||||
case FINISHED:
|
||||
if (movePrevCell(cur))
|
||||
result = DispatchResult(true, true);
|
||||
else
|
||||
result = DispatchResult(false, FINISHED);
|
||||
//lyxerr << "# InsetTabular::MouseRelease\n" << cur.bv().cursor() << endl;
|
||||
if (cmd.button() == mouse_button::button3)
|
||||
InsetTabularMailer(*this).showDialog(&cur.bv());
|
||||
break;
|
||||
|
||||
case FINISHED_RIGHT:
|
||||
if (moveNextCell(cur))
|
||||
result = DispatchResult(true, true);
|
||||
else
|
||||
result = DispatchResult(false, FINISHED_RIGHT);
|
||||
break;
|
||||
|
||||
case FINISHED_UP:
|
||||
if (moveUpLock(cur))
|
||||
result = DispatchResult(true, true);
|
||||
else
|
||||
result = DispatchResult(false, FINISHED_UP);
|
||||
break;
|
||||
|
||||
case FINISHED_DOWN:
|
||||
if (moveDownLock(cur))
|
||||
result = DispatchResult(true, true);
|
||||
else
|
||||
result = DispatchResult(false, FINISHED_UP);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case LFUN_CELL_BACKWARD:
|
||||
case LFUN_CELL_FORWARD:
|
||||
if (cmd.action == LFUN_CELL_FORWARD)
|
||||
moveNextCell(cur);
|
||||
else
|
||||
movePrevCell(cur);
|
||||
movePrevCell(cur);
|
||||
cur.selection() = false;
|
||||
return result;
|
||||
break;
|
||||
|
||||
case LFUN_CELL_FORWARD:
|
||||
moveNextCell(cur);
|
||||
cur.selection() = false;
|
||||
break;
|
||||
|
||||
case LFUN_SCROLL_INSET:
|
||||
if (!cmd.argument.empty()) {
|
||||
if (cmd.argument.find('.') != cmd.argument.npos)
|
||||
scroll(cur.bv(), static_cast<float>(strToDbl(cmd.argument)));
|
||||
else
|
||||
scroll(cur.bv(), strToInt(cmd.argument));
|
||||
cur.update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
if (cmd.argument.empty())
|
||||
break;
|
||||
if (cmd.argument.find('.') != cmd.argument.npos)
|
||||
scroll(cur.bv(), static_cast<float>(strToDbl(cmd.argument)));
|
||||
else
|
||||
scroll(cur.bv(), strToInt(cmd.argument));
|
||||
cur.update();
|
||||
break;
|
||||
|
||||
case LFUN_RIGHTSEL:
|
||||
case LFUN_RIGHT: {
|
||||
CursorSlice sl = cur.current();
|
||||
cell.dispatch(cur, cmd);
|
||||
case LFUN_RIGHT:
|
||||
cell(cur.idx()).dispatch(cur, cmd);
|
||||
if (sl == cur.current())
|
||||
isRightToLeft(cur) ? movePrevCell(cur) : moveNextCell(cur);
|
||||
if (sl == cur.current())
|
||||
result = DispatchResult(true, true);
|
||||
cur.dispatched(FINISHED_RIGHT);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_LEFTSEL:
|
||||
case LFUN_LEFT: {
|
||||
CursorSlice sl = cur.current();
|
||||
cell.dispatch(cur, cmd);
|
||||
case LFUN_LEFT:
|
||||
cell(cur.idx()).dispatch(cur, cmd);
|
||||
if (sl == cur.current())
|
||||
isRightToLeft(cur) ? moveNextCell(cur) : movePrevCell(cur);
|
||||
if (sl == cur.current())
|
||||
result = DispatchResult(true, true);
|
||||
cur.dispatched(FINISHED);
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
case LFUN_DOWNSEL: {
|
||||
int const start = hasSelection() ? sel_cell_start : cur.idx();
|
||||
int const ocell = cur.idx();
|
||||
// if we are starting a selection, only select
|
||||
// the current cell at the beginning
|
||||
if (hasSelection()) {
|
||||
moveDown(cur);
|
||||
if (ocell == sel_cell_end ||
|
||||
tabular.column_of_cell(ocell) >
|
||||
tabular.column_of_cell(cur.idx()))
|
||||
//setSelection(start, tabular.getCellBelow(sel_cell_end));
|
||||
else
|
||||
//setSelection(start, tabular.getLastCellBelow(sel_cell_end));
|
||||
} else {
|
||||
//setSelection(start, start);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
case LFUN_DOWNSEL:
|
||||
case LFUN_DOWN:
|
||||
if (!moveDown(cur))
|
||||
result = DispatchResult(false, FINISHED_DOWN);
|
||||
cur.selection() = false;
|
||||
cell(cur.idx()).dispatch(cur, cmd);
|
||||
if (sl == cur.current())
|
||||
if (tabular.row_of_cell(cur.idx()) != tabular.rows() - 1) {
|
||||
cur.idx() = tabular.getCellBelow(cur.idx());
|
||||
resetPos(cur);
|
||||
}
|
||||
if (sl == cur.current())
|
||||
cur.dispatched(FINISHED_DOWN);
|
||||
break;
|
||||
|
||||
#if 0
|
||||
case LFUN_UPSEL: {
|
||||
int const start = hasSelection() ? sel_cell_start : cur.idx();
|
||||
int const ocell = cur.idx();
|
||||
// if we are starting a selection, only select
|
||||
// the current cell at the beginning
|
||||
if (hasSelection()) {
|
||||
moveUp(cur);
|
||||
if (ocell == sel_cell_end ||
|
||||
tabular.column_of_cell(ocell) >
|
||||
tabular.column_of_cell(cur.idx()))
|
||||
//setSelection(start, tabular.getCellAbove(sel_cell_end));
|
||||
else
|
||||
//setSelection(start, tabular.getLastCellAbove(sel_cell_end));
|
||||
} else {
|
||||
//setSelection(start, start);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
case LFUN_UPSEL:
|
||||
case LFUN_UP:
|
||||
if (!moveUp(cur))
|
||||
result = DispatchResult(false, FINISHED_DOWN);
|
||||
cur.selection() = false;
|
||||
cell(cur.idx()).dispatch(cur, cmd);
|
||||
if (sl == cur.current())
|
||||
if (tabular.row_of_cell(cur.idx()) != 0) {
|
||||
cur.idx() = tabular.getCellAbove(cur.idx());
|
||||
resetPos(cur);
|
||||
}
|
||||
if (sl == cur.current())
|
||||
cur.dispatched(FINISHED_UP);
|
||||
break;
|
||||
|
||||
case LFUN_NEXT: {
|
||||
@ -657,7 +556,7 @@ tabular.column_of_cell(cur.idx()))
|
||||
|
||||
case LFUN_TABULAR_FEATURE:
|
||||
if (!tabularFeatures(cur, cmd.argument))
|
||||
result = DispatchResult(false);
|
||||
cur.notdispatched();
|
||||
break;
|
||||
|
||||
// insert file functions
|
||||
@ -665,7 +564,7 @@ tabular.column_of_cell(cur.idx()))
|
||||
case LFUN_FILE_INSERT_ASCII: {
|
||||
string tmpstr = getContentsOfAsciiFile(&cur.bv(), cmd.argument, false);
|
||||
if (!tmpstr.empty() && !insertAsciiString(cur.bv(), tmpstr, false))
|
||||
result = DispatchResult(false);
|
||||
cur.notdispatched();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -695,7 +594,7 @@ tabular.column_of_cell(cur.idx()))
|
||||
if (tablemode(cur))
|
||||
cutSelection(cur);
|
||||
else
|
||||
cell.dispatch(cur, cmd);
|
||||
cell(cur.idx()).dispatch(cur, cmd);
|
||||
break;
|
||||
|
||||
case LFUN_COPY:
|
||||
@ -713,11 +612,11 @@ tabular.column_of_cell(cur.idx()))
|
||||
int cols = 1;
|
||||
int rows = 1;
|
||||
int maxCols = 1;
|
||||
string::size_type len = clip.length();
|
||||
string::size_type p = 0;
|
||||
|
||||
while (p < len &&
|
||||
(p = clip.find_first_of("\t\n", p)) != string::npos) {
|
||||
size_t len = clip.length();
|
||||
for (size_t p = 0; p < len; ++p) {
|
||||
p = clip.find_first_of("\t\n", p);
|
||||
if (p == string::npos)
|
||||
break;
|
||||
switch (clip[p]) {
|
||||
case '\t':
|
||||
++cols;
|
||||
@ -729,7 +628,6 @@ tabular.column_of_cell(cur.idx()))
|
||||
cols = 1;
|
||||
break;
|
||||
}
|
||||
++p;
|
||||
}
|
||||
maxCols = max(cols, maxCols);
|
||||
|
||||
@ -739,37 +637,34 @@ tabular.column_of_cell(cur.idx()))
|
||||
string::size_type op = 0;
|
||||
int cell = 0;
|
||||
int cells = paste_tabular->getNumberOfCells();
|
||||
p = 0;
|
||||
cols = 0;
|
||||
LyXFont font;
|
||||
while (cell < cells && p < len &&
|
||||
(p = clip.find_first_of("\t\n", p)) != string::npos) {
|
||||
if (p >= len)
|
||||
for (size_t p = 0; cell < cells && p < len; ++p) {
|
||||
p = clip.find_first_of("\t\n", p);
|
||||
if (p == string::npos || p >= len)
|
||||
break;
|
||||
switch (clip[p]) {
|
||||
case '\t':
|
||||
paste_tabular->getCellInset(cell).
|
||||
setText(clip.substr(op, p-op), font);
|
||||
setText(clip.substr(op, p - op), font);
|
||||
++cols;
|
||||
++cell;
|
||||
break;
|
||||
case '\n':
|
||||
paste_tabular->getCellInset(cell).
|
||||
setText(clip.substr(op, p-op), font);
|
||||
setText(clip.substr(op, p - op), font);
|
||||
while (cols++ < maxCols)
|
||||
++cell;
|
||||
cols = 0;
|
||||
break;
|
||||
}
|
||||
++p;
|
||||
op = p;
|
||||
op = p + 1;
|
||||
}
|
||||
// check for the last cell if there is no trailing '\n'
|
||||
if (cell < cells && op < len)
|
||||
paste_tabular->getCellInset(cell).
|
||||
setText(clip.substr(op, len-op), font);
|
||||
} else if (!insertAsciiString(cur.bv(), clip, true))
|
||||
{
|
||||
setText(clip.substr(op, len - op), font);
|
||||
} else if (!insertAsciiString(cur.bv(), clip, true)) {
|
||||
// so that the clipboard is used and it goes on
|
||||
// to default
|
||||
// and executes LFUN_PASTESELECTION in insettext!
|
||||
@ -784,23 +679,16 @@ tabular.column_of_cell(cur.idx()))
|
||||
pasteSelection(cur);
|
||||
break;
|
||||
}
|
||||
// fall through
|
||||
|
||||
// ATTENTION: the function above has to be PASTE and PASTESELECTION!!!
|
||||
cell(cur.idx()).dispatch(cur, cmd);
|
||||
break;
|
||||
|
||||
default:
|
||||
// handle font changing stuff on selection before we lock the inset
|
||||
// in the default part!
|
||||
result = cell.dispatch(cur, cmd);
|
||||
// we try to activate the actual inset and put this event down to
|
||||
// the insets dispatch function.
|
||||
// we try to handle this event in the insets dispatch function.
|
||||
cell(cur.idx()).dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
|
||||
updateLocal(cur);
|
||||
InsetTabularMailer(*this).updateDialog(&cur.bv());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -861,41 +749,38 @@ void InsetTabular::validate(LaTeXFeatures & features) const
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::calculate_dimensions_of_cells(MetricsInfo & mi) const
|
||||
InsetText const & InsetTabular::cell(int idx) const
|
||||
{
|
||||
for (int i = 0, cell = -1; i < tabular.rows(); ++i) {
|
||||
int maxAsc = 0;
|
||||
int maxDesc = 0;
|
||||
for (int j = 0; j < tabular.columns(); ++j) {
|
||||
if (tabular.isPartOfMultiColumn(i, j))
|
||||
continue;
|
||||
++cell;
|
||||
Dimension dim;
|
||||
MetricsInfo m = mi;
|
||||
m.base.textwidth =
|
||||
tabular.column_info[j].p_width.inPixels(mi.base.textwidth);
|
||||
tabular.getCellInset(cell).metrics(m, dim);
|
||||
maxAsc = max(maxAsc, dim.asc);
|
||||
maxDesc = max(maxDesc, dim.des);
|
||||
tabular.setWidthOfCell(cell, dim.wid);
|
||||
}
|
||||
tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT);
|
||||
tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT);
|
||||
}
|
||||
return tabular.getCellInset(idx);
|
||||
}
|
||||
|
||||
|
||||
InsetText & InsetTabular::cell(int idx)
|
||||
{
|
||||
return tabular.getCellInset(idx);
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::getCursorPos(CursorSlice const & cur, int & x, int & y) const
|
||||
{
|
||||
tabular.getCellInset(cur.idx()).getCursorPos(cur, x, y);
|
||||
cell(cur.idx()).getCursorPos(cur, x, y);
|
||||
}
|
||||
|
||||
|
||||
InsetBase * InsetTabular::setPos(LCursor & cur, int x, int y) const
|
||||
{
|
||||
cur.idx() = getCell(x, y);
|
||||
InsetBase * inset = tabular.getCellInset(cur.idx()).text_.editXY(cur, x, y);
|
||||
lyxerr << "# InsetTabular::setPos() cursor: " << cur << endl;
|
||||
int idx_min = 0;
|
||||
int dist_min = 1000000;
|
||||
for (idx_type i = 0; i < nargs(); ++i) {
|
||||
int d = getText(i)->dist(x, y);
|
||||
if (d < dist_min) {
|
||||
dist_min = d;
|
||||
idx_min = i;
|
||||
}
|
||||
}
|
||||
cur.idx() = idx_min;
|
||||
InsetBase * inset = cell(cur.idx()).text_.editXY(cur, x, y);
|
||||
//lyxerr << "# InsetTabular::setPos()\n" << cur << endl;
|
||||
return inset;
|
||||
}
|
||||
|
||||
@ -914,33 +799,12 @@ int InsetTabular::getCellXPos(int cell) const
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::resetPos(LCursor &) const
|
||||
void InsetTabular::resetPos(LCursor & cur) const
|
||||
{
|
||||
#if 0
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning This should be fixed in the right manner (20011128 Jug)
|
||||
#endif
|
||||
// fast hack to fix infinite repaintings!
|
||||
if (in_reset_pos > 0)
|
||||
return;
|
||||
|
||||
BufferView & bv = cur.bv();
|
||||
int cell = 0;
|
||||
int actcell = cur.idx();
|
||||
int actcol = tabular.column_of_cell(actcell);
|
||||
int actrow = 0;
|
||||
cursory_ = 0;
|
||||
for (; cell < actcell && !tabular.isLastRow(cell); ++cell) {
|
||||
if (tabular.isLastCellInRow(cell)) {
|
||||
cursory_ += tabular.getDescentOfRow(actrow) +
|
||||
tabular.getAscentOfRow(actrow + 1) +
|
||||
tabular.getAdditionalHeight(actrow + 1);
|
||||
++actrow;
|
||||
}
|
||||
}
|
||||
|
||||
// we need this only from here on!!!
|
||||
++in_reset_pos;
|
||||
int const offset = ADD_TO_TABULAR_WIDTH + 2;
|
||||
int new_x = getCellXPos(actcell) + offset;
|
||||
int old_x = cursorx_;
|
||||
@ -950,149 +814,70 @@ void InsetTabular::resetPos(LCursor &) const
|
||||
tabular.getWidthOfTabular() < bv.workWidth()-20)
|
||||
{
|
||||
scroll(bv, 0.0F);
|
||||
updateLocal(cur);
|
||||
} else if (cursorx_ - offset > 20 &&
|
||||
cursorx_ - offset + tabular.getWidthOfColumn(actcell)
|
||||
> bv.workWidth() - 20) {
|
||||
scroll(bv, - tabular.getWidthOfColumn(actcell) - 20);
|
||||
updateLocal(cur);
|
||||
} else if (cursorx_ - offset < 20) {
|
||||
scroll(bv, 20 - cursorx_ + offset);
|
||||
updateLocal(cur);
|
||||
} else if (scroll() && xo_ > 20 &&
|
||||
xo_ + tabular.getWidthOfTabular() > bv.workWidth() - 20) {
|
||||
scroll(bv, old_x - cursorx_);
|
||||
updateLocal(cur);
|
||||
}
|
||||
|
||||
InsetTabularMailer(*this).updateDialog(&bv);
|
||||
in_reset_pos = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveRight(LCursor & cur)
|
||||
{
|
||||
bool moved = isRightToLeft(cur) ? movePrevCell(cur) : moveNextCell(cur);
|
||||
if (!moved)
|
||||
return false;
|
||||
resetPos(cur);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveLeft(LCursor & cur)
|
||||
{
|
||||
bool moved = isRightToLeft(cur) ? moveNextCell(cur) : movePrevCell(cur);
|
||||
if (!moved)
|
||||
return false;
|
||||
resetPos(cur);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveLeftLock(LCursor & cur)
|
||||
{
|
||||
bool moved = isRightToLeft(cur) ? moveNextCell(cur) : movePrevCell(cur);
|
||||
if (!moved)
|
||||
return false;
|
||||
activateCellInset(cur, cur.idx(), true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveUp(LCursor & cur)
|
||||
{
|
||||
if (tabular.row_of_cell(cur.idx()) == 0)
|
||||
return false;
|
||||
cur.idx() = tabular.getCellAbove(cur.idx());
|
||||
resetPos(cur);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveUpLock(LCursor & cur)
|
||||
{
|
||||
if (tabular.row_of_cell(cur.idx()) == 0)
|
||||
return false;
|
||||
cur.idx() = tabular.getCellAbove(cur.idx());
|
||||
resetPos(cur);
|
||||
activateCellInset(cur, cur.idx(), cur.x_target(), 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveDown(LCursor & cur)
|
||||
{
|
||||
if (tabular.row_of_cell(cur.idx()) == tabular.rows() - 1)
|
||||
return false;
|
||||
cur.idx() = tabular.getCellBelow(cur.idx());
|
||||
resetPos(cur);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveDownLock(LCursor & cur)
|
||||
{
|
||||
if (tabular.row_of_cell(cur.idx()) == tabular.rows() - 1)
|
||||
return false;
|
||||
cur.idx() = tabular.getCellBelow(cur.idx());
|
||||
resetPos(cur);
|
||||
activateCellInset(cur, cur.idx(), cur.x_target());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::moveNextCell(LCursor & cur)
|
||||
void InsetTabular::moveNextCell(LCursor & cur)
|
||||
{
|
||||
lyxerr << "InsetTabular::moveNextCell 1 cur: " << cur << endl;
|
||||
if (isRightToLeft(cur)) {
|
||||
if (tabular.isFirstCellInRow(cur.idx())) {
|
||||
int row = tabular.row_of_cell(cur.idx());
|
||||
if (row == tabular.rows() - 1)
|
||||
return false;
|
||||
return;
|
||||
cur.idx() = tabular.getLastCellInRow(row);
|
||||
cur.idx() = tabular.getCellBelow(cur.idx());
|
||||
} else {
|
||||
if (cur.idx() == 0)
|
||||
return false;
|
||||
return;
|
||||
--cur.idx();
|
||||
}
|
||||
} else {
|
||||
if (tabular.isLastCell(cur.idx()))
|
||||
return false;
|
||||
return;
|
||||
++cur.idx();
|
||||
}
|
||||
cur.par() = 0;
|
||||
cur.pos() = 0;
|
||||
lyxerr << "InsetTabular::moveNextCell 2 cur: " << cur << endl;
|
||||
resetPos(cur);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::movePrevCell(LCursor & cur)
|
||||
void InsetTabular::movePrevCell(LCursor & cur)
|
||||
{
|
||||
if (isRightToLeft(cur)) {
|
||||
if (tabular.isLastCellInRow(cur.idx())) {
|
||||
int row = tabular.row_of_cell(cur.idx());
|
||||
if (row == 0)
|
||||
return false;
|
||||
return;
|
||||
cur.idx() = tabular.getFirstCellInRow(row);
|
||||
cur.idx() = tabular.getCellAbove(cur.idx());
|
||||
} else {
|
||||
if (tabular.isLastCell(cur.idx()))
|
||||
return false;
|
||||
return;
|
||||
++cur.idx();
|
||||
}
|
||||
} else {
|
||||
if (cur.idx() == 0) // first cell
|
||||
return false;
|
||||
return;
|
||||
--cur.idx();
|
||||
}
|
||||
cur.par() = 0;
|
||||
cur.pos() = 0;
|
||||
resetPos(cur);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -1470,27 +1255,10 @@ void InsetTabular::tabularFeatures(LCursor & cur,
|
||||
break;
|
||||
}
|
||||
|
||||
updateLocal(cur);
|
||||
InsetTabularMailer(*this).updateDialog(&bv);
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::activateCellInset(LCursor & cur, int cell, int x, int y)
|
||||
{
|
||||
cur.idx() = cell;
|
||||
tabular.getCellInset(cell).editXY(cur, x, y);
|
||||
updateLocal(cur);
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::activateCellInset(LCursor & cur, int cell, bool behind)
|
||||
{
|
||||
cur.idx() = cell;
|
||||
tabular.getCellInset(cell).edit(cur, behind);
|
||||
updateLocal(cur);
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::showInsetDialog(BufferView * bv) const
|
||||
{
|
||||
InsetTabularMailer(*this).showDialog(bv);
|
||||
@ -1777,7 +1545,7 @@ void InsetTabular::cutSelection(LCursor & cur)
|
||||
getSelection(cur, rs, re, cs, ce);
|
||||
for (int i = rs; i <= re; ++i)
|
||||
for (int j = cs; j <= ce; ++j)
|
||||
tabular.getCellInset(tabular.getCellNumber(i, j)).clear(track);
|
||||
cell(tabular.getCellNumber(i, j)).clear(track);
|
||||
}
|
||||
|
||||
|
||||
@ -1808,24 +1576,22 @@ void InsetTabular::getSelection(LCursor & cur,
|
||||
}
|
||||
|
||||
|
||||
int InsetTabular::numParagraphs() const
|
||||
size_t InsetTabular::nargs() const
|
||||
{
|
||||
return tabular.getNumberOfCells();
|
||||
}
|
||||
|
||||
|
||||
LyXText * InsetTabular::getText(int i) const
|
||||
LyXText * InsetTabular::getText(int idx) const
|
||||
{
|
||||
return i < tabular.getNumberOfCells()
|
||||
? tabular.getCellInset(i).getText(0)
|
||||
: 0;
|
||||
return size_t(idx) < nargs() ? cell(idx).getText(0) : 0;
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::markErased()
|
||||
{
|
||||
for (int cell = 0; cell < tabular.getNumberOfCells(); ++cell)
|
||||
tabular.getCellInset(cell).markErased();
|
||||
for (idx_type idx = 0; idx < nargs(); ++idx)
|
||||
cell(idx).markErased();
|
||||
}
|
||||
|
||||
|
||||
@ -1966,6 +1732,9 @@ bool InsetTabular::tablemode(LCursor & cur) const
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
string const InsetTabularMailer::name_("tabular");
|
||||
|
||||
InsetTabularMailer::InsetTabularMailer(InsetTabular const & inset)
|
||||
|
@ -8,21 +8,14 @@
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
|
||||
// This is the rewrite of the tabular (table) support.
|
||||
|
||||
// It will probably be a lot of work.
|
||||
|
||||
// One first goal could be to make the inset read the old table format
|
||||
// and just output it again... no viewing at all.
|
||||
|
||||
// When making the internal structure of tabular support I really think
|
||||
// that STL containers should be used. This will separate the container from
|
||||
// the rest of the code, which is a good thing.
|
||||
|
||||
// Ideally the tabular support should do as the mathed and use
|
||||
// LaTeX in the .lyx file too.
|
||||
|
||||
// Things to think of when desingning the new tabular support:
|
||||
// Things to think of when designing the new tabular support:
|
||||
// - color support (colortbl, color)
|
||||
// - decimal alignment (dcloumn)
|
||||
// - custom lines (hhline)
|
||||
@ -48,9 +41,6 @@
|
||||
#include "inset.h"
|
||||
#include "tabular.h"
|
||||
|
||||
#include "frontends/mouse_state.h"
|
||||
|
||||
|
||||
class FuncStatus;
|
||||
class LyXLex;
|
||||
class Painter;
|
||||
@ -82,8 +72,6 @@ public:
|
||||
///
|
||||
std::string const editMessage() const;
|
||||
///
|
||||
void updateLocal(LCursor & cur) const;
|
||||
///
|
||||
bool insetAllowed(InsetOld::Code) const { return true; }
|
||||
///
|
||||
bool isTextInset() const { return true; }
|
||||
@ -125,8 +113,12 @@ public:
|
||||
std::string const & argument, int cell) const;
|
||||
/// Appends \c list with all labels found within this inset.
|
||||
void getLabelList(Buffer const &, std::vector<std::string> & list) const;
|
||||
/// number of cells
|
||||
size_t nargs() const;
|
||||
///
|
||||
int numParagraphs() const;
|
||||
InsetText const & cell(int) const;
|
||||
///
|
||||
InsetText & cell(int);
|
||||
///
|
||||
LyXText * getText(int) const;
|
||||
|
||||
@ -159,48 +151,21 @@ public:
|
||||
|
||||
protected:
|
||||
///
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
///
|
||||
void lfunMousePress(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
void lfunMouseRelease(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
void lfunMouseMotion(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
void calculate_dimensions_of_cells(MetricsInfo & mi) const;
|
||||
///
|
||||
void drawCellLines(Painter &, int x, int baseline,
|
||||
int row, int cell) const;
|
||||
int row, int cell) const;
|
||||
///
|
||||
void drawCellSelection(PainterInfo &, int x, int baseline,
|
||||
int row, int column, int cell) const;
|
||||
int row, int column, int cell) const;
|
||||
///
|
||||
InsetBase * setPos(LCursor & cur, int x, int y) const;
|
||||
///
|
||||
bool moveRight(LCursor & cur);
|
||||
///
|
||||
bool moveLeft(LCursor & cur);
|
||||
///
|
||||
bool moveUp(LCursor & cur);
|
||||
///
|
||||
bool moveDown(LCursor & cur);
|
||||
|
||||
///
|
||||
bool moveRightLock(LCursor & cur);
|
||||
void moveNextCell(LCursor & cur);
|
||||
///
|
||||
bool moveLeftLock(LCursor & cur);
|
||||
///
|
||||
bool moveUpLock(LCursor & cur);
|
||||
///
|
||||
bool moveDownLock(LCursor & cur);
|
||||
|
||||
///
|
||||
bool moveNextCell(LCursor & cur);
|
||||
///
|
||||
bool movePrevCell(LCursor & cur);
|
||||
|
||||
|
||||
void movePrevCell(LCursor & cur);
|
||||
///
|
||||
int getCellXPos(int cell) const;
|
||||
///
|
||||
@ -208,14 +173,6 @@ private:
|
||||
///
|
||||
void removeTabularRow();
|
||||
///
|
||||
//void clearSelection() const;
|
||||
///
|
||||
//void setSelection(int start, int end) const;
|
||||
///
|
||||
void activateCellInset(LCursor &, int cell, int x, int y);
|
||||
///
|
||||
void activateCellInset(LCursor &, int cell, bool behind);
|
||||
///
|
||||
bool hasPasteBuffer() const;
|
||||
///
|
||||
bool copySelection(LCursor & cur);
|
||||
@ -230,28 +187,15 @@ private:
|
||||
int & rs, int & re, int & cs, int & ce) const;
|
||||
///
|
||||
bool insertAsciiString(BufferView &, std::string const & buf, bool usePaste);
|
||||
|
||||
/// are we operating on several cells?
|
||||
bool tablemode(LCursor & cur) const;
|
||||
|
||||
//
|
||||
// Private structures and variables
|
||||
///
|
||||
Buffer const * buffer_;
|
||||
///
|
||||
mutable int cursorx_;
|
||||
///
|
||||
mutable int cursory_;
|
||||
/// true if a set of cells are selected
|
||||
//mutable bool has_selection;
|
||||
/// the starting cell selection nr
|
||||
//mutable int sel_cell_start;
|
||||
/// the ending cell selection nr
|
||||
//mutable int sel_cell_end;
|
||||
///
|
||||
mutable int first_visible_cell;
|
||||
///
|
||||
mutable int in_reset_pos;
|
||||
};
|
||||
|
||||
|
||||
|
@ -309,7 +309,7 @@ InsetBase * InsetText::editXY(LCursor & cur, int x, int y)
|
||||
}
|
||||
|
||||
|
||||
DispatchResult InsetText::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetText::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
//lyxerr << "InsetText::priv_dispatch (begin), act: "
|
||||
// << cmd.action << " " << endl;
|
||||
@ -317,7 +317,7 @@ DispatchResult InsetText::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
setViewCache(&cur.bv());
|
||||
|
||||
bool was_empty = paragraphs().begin()->empty() && paragraphs().size() == 1;
|
||||
DispatchResult result = text_.dispatch(cur, cmd);
|
||||
text_.dispatch(cur, cmd);
|
||||
|
||||
// If the action has deleted all text in the inset, we need
|
||||
// to change the language to the language of the surronding
|
||||
@ -331,7 +331,6 @@ DispatchResult InsetText::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
//lyxerr << "InsetText::priv_dispatch (end)" << endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -150,14 +150,14 @@ public:
|
||||
///
|
||||
InsetBase * editXY(LCursor & cur, int x, int y);
|
||||
|
||||
///
|
||||
int numParagraphs() const { return 1; }
|
||||
/// number of cells in this inset
|
||||
size_t nargs() const { return 1; }
|
||||
///
|
||||
ParagraphList & paragraphs() const;
|
||||
|
||||
private:
|
||||
///
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
void updateLocal(LCursor &);
|
||||
///
|
||||
|
@ -60,22 +60,22 @@ std::auto_ptr<InsetBase> InsetVSpace::clone() const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetVSpace::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetVSpace::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_INSET_MODIFY: {
|
||||
InsetVSpaceMailer::string2params(cmd.argument, space_);
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
InsetVSpaceMailer(*this).showDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
return InsetOld::priv_dispatch(cur, cmd);
|
||||
InsetOld::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,9 +54,7 @@ public:
|
||||
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
|
||||
private:
|
||||
///
|
||||
|
@ -80,27 +80,25 @@ InsetWrap::~InsetWrap()
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetWrap::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void InsetWrap::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_INSET_MODIFY: {
|
||||
InsetWrapParams params;
|
||||
InsetWrapMailer::string2params(cmd.argument, params);
|
||||
|
||||
params_.placement = params.placement;
|
||||
params_.width = params.width;
|
||||
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetWrapMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
return InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
InsetCollapsable::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,9 +68,7 @@ public:
|
||||
InsetWrapParams const & params() const { return params_; }
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
///
|
||||
InsetWrapParams params_;
|
||||
|
@ -84,26 +84,24 @@ void UpdatableInset::scroll(BufferView & bv, int offset) const
|
||||
}
|
||||
|
||||
|
||||
/// An updatable inset could handle lyx editing commands
|
||||
DispatchResult
|
||||
UpdatableInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void UpdatableInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
return DispatchResult(editable() == IS_EDITABLE);
|
||||
//case LFUN_MOUSE_RELEASE:
|
||||
// return DispatchResult(editable() == IS_EDITABLE);
|
||||
|
||||
case LFUN_SCROLL_INSET:
|
||||
if (!cmd.argument.empty()) {
|
||||
if (cmd.argument.empty()) {
|
||||
if (cmd.argument.find('.') != cmd.argument.npos)
|
||||
scroll(cur.bv(), static_cast<float>(strToDbl(cmd.argument)));
|
||||
else
|
||||
scroll(cur.bv(), strToInt(cmd.argument));
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return DispatchResult(false);
|
||||
InsetOld::dispatch(cur, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,9 +38,7 @@ public:
|
||||
|
||||
protected:
|
||||
/// An updatable inset could handle lyx editing commands
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
/// scrolls to absolute position in bufferview-workwidth * sx units
|
||||
void scroll(BufferView &, float sx) const;
|
||||
/// scrolls offset pixels
|
||||
|
@ -124,6 +124,9 @@ public:
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
/// draw textselection
|
||||
void drawSelection(PainterInfo & pi, int x, int y) const;
|
||||
/// returns distance of this cell to the point given by x and y
|
||||
// assumes valid position and size cache
|
||||
int dist(int x, int y) const;
|
||||
|
||||
/// try to handle that request
|
||||
DispatchResult dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
@ -342,6 +345,8 @@ public:
|
||||
double spacing(Paragraph const & par) const;
|
||||
/// make a suggestion for a label
|
||||
std::string getPossibleLabel(LCursor & cur) const;
|
||||
/// is this paragraph right-to-left?
|
||||
bool isRTL(Paragraph const & par) const;
|
||||
|
||||
///
|
||||
DispatchResult moveRight(LCursor & cur);
|
||||
@ -460,8 +465,6 @@ private:
|
||||
void charInserted();
|
||||
/// set 'number' font property
|
||||
void number(LCursor & cur);
|
||||
/// is the cursor paragraph right-to-left?
|
||||
bool rtl(LCursor & cur) const;
|
||||
};
|
||||
|
||||
/// return the default height of a row in pixels, considering font zoom
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
2004-02-04 Martin Vermeer <martin.vermeer@hut.fi>
|
||||
|
||||
* math_nestinset.C: workaround gcc 2.95 pointer comparison bug,
|
||||
|
@ -54,17 +54,6 @@ void CommandInset::draw(PainterInfo & pi, int x, int y) const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
CommandInset::priv_dispatch(LCursor & bv, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
default:
|
||||
return MathNestInset::priv_dispatch(bv, cmd);
|
||||
}
|
||||
return DispatchResult(false);
|
||||
}
|
||||
|
||||
|
||||
void CommandInset::write(WriteStream & os) const
|
||||
{
|
||||
os << '\\' << name_.c_str();
|
||||
|
@ -14,6 +14,7 @@
|
||||
#define COMMAND_INSET_H
|
||||
|
||||
#include "math_nestinset.h"
|
||||
|
||||
#include "insets/render_button.h"
|
||||
|
||||
|
||||
@ -38,11 +39,6 @@ public:
|
||||
std::string const createDialogStr(std::string const & name) const;
|
||||
|
||||
std::string const & commandname() const { return name_; }
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
std::string name_;
|
||||
mutable bool set_label_;
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "debug.h"
|
||||
#include "funcrequest.h"
|
||||
#include "gettext.h"
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "math_streamstr.h"
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "debug.h"
|
||||
#include "funcrequest.h"
|
||||
#include "LColor.h"
|
||||
@ -1043,8 +1042,7 @@ void MathGridInset::splitCell(LCursor & cur)
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
//lyxerr << "*** MathGridInset: request: " << cmd << endl;
|
||||
switch (cmd.action) {
|
||||
@ -1054,11 +1052,12 @@ MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
// GridInsetMailer(*this).showDialog();
|
||||
// return DispatchResult(true, true);
|
||||
//}
|
||||
return MathNestInset::priv_dispatch(cur, cmd);
|
||||
MathNestInset::priv_dispatch(cur, cmd);
|
||||
return;
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
GridInsetMailer(*this).updateDialog(&cur.bv());
|
||||
return DispatchResult(false);
|
||||
return;
|
||||
|
||||
// insert file functions
|
||||
case LFUN_DELETE_LINE_FORWARD:
|
||||
@ -1074,12 +1073,12 @@ MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
cur.idx() = cur.lastidx();
|
||||
if (cur.pos() > cur.lastpos())
|
||||
cur.pos() = cur.lastpos();
|
||||
return DispatchResult(true, FINISHED);
|
||||
return;
|
||||
|
||||
case LFUN_CELL_SPLIT:
|
||||
////recordUndo(cur, Undo::ATOMIC);
|
||||
splitCell(cur);
|
||||
return DispatchResult(true, FINISHED);
|
||||
return;
|
||||
|
||||
case LFUN_BREAKLINE: {
|
||||
////recordUndo(cur, Undo::INSERT);
|
||||
@ -1098,7 +1097,8 @@ MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
cur.idx() = cur.lastpos();
|
||||
|
||||
//mathcursor->normalize();
|
||||
return DispatchResult(true, FINISHED);
|
||||
cur.dispatched(FINISHED);
|
||||
return;
|
||||
}
|
||||
|
||||
case LFUN_TABULAR_FEATURE: {
|
||||
@ -1152,10 +1152,12 @@ MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
copyCol(col(cur.idx()));
|
||||
else if (s == "swap-column")
|
||||
swapCol(col(cur.idx()));
|
||||
else
|
||||
return DispatchResult(false);
|
||||
else {
|
||||
cur.notdispatched();
|
||||
return;
|
||||
}
|
||||
lyxerr << "returning DispatchResult(true, FINISHED)" << endl;
|
||||
return DispatchResult(true, FINISHED);
|
||||
return;
|
||||
}
|
||||
|
||||
case LFUN_PASTE: {
|
||||
@ -1168,10 +1170,10 @@ MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
cur.pos() += grid.cell(0).size();
|
||||
} else {
|
||||
// multiple cells
|
||||
col_type const numcols = min(grid.ncols(), ncols() -
|
||||
col(cur.idx()));
|
||||
row_type const numrows = min(grid.nrows(), nrows() -
|
||||
cur.row());
|
||||
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 + cur.row(), c + col(cur.idx()));
|
||||
@ -1188,10 +1190,11 @@ cur.row());
|
||||
for (col_type c = 0; c < grid.ncols(); ++c)
|
||||
cell(i).append(grid.cell(grid.index(r, c)));
|
||||
}
|
||||
return DispatchResult(true, FINISHED);
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
return MathNestInset::priv_dispatch(cur, cmd);
|
||||
MathNestInset::priv_dispatch(cur, cmd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ public:
|
||||
|
||||
protected:
|
||||
///
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
/// returns x offset of cell compared to inset
|
||||
int cellXOffset(idx_type idx) const;
|
||||
/// returns y offset of cell compared to inset
|
||||
|
@ -784,96 +784,96 @@ void MathHullInset::doExtern(LCursor & cur, FuncRequest const & func)
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathHullInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void MathHullInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
//lyxerr << "*** MathHullInset: request: " << cmd << endl;
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_BREAKLINE:
|
||||
if (type_ == "simple" || type_ == "equation") {
|
||||
mutate("eqnarray");
|
||||
cur.idx() = 1;
|
||||
cur.pos() = 0;
|
||||
return DispatchResult(true, FINISHED);
|
||||
}
|
||||
return MathGridInset::priv_dispatch(cur, cmd);
|
||||
case LFUN_BREAKLINE:
|
||||
if (type_ == "simple" || type_ == "equation") {
|
||||
mutate("eqnarray");
|
||||
cur.idx() = 1;
|
||||
cur.pos() = 0;
|
||||
//cur.dispatched(FINISHED);
|
||||
return;
|
||||
}
|
||||
MathGridInset::priv_dispatch(cur, cmd);
|
||||
return;
|
||||
|
||||
case LFUN_MATH_NUMBER:
|
||||
//lyxerr << "toggling all numbers" << endl;
|
||||
if (display()) {
|
||||
////recordUndo(cur, Undo::INSERT);
|
||||
bool old = numberedType();
|
||||
if (type_ == "multline")
|
||||
numbered(nrows() - 1, !old);
|
||||
else
|
||||
for (row_type row = 0; row < nrows(); ++row)
|
||||
numbered(row, !old);
|
||||
cur.message(old ? _("No number") : _("Number"));
|
||||
}
|
||||
return DispatchResult(true, true);
|
||||
case LFUN_MATH_NUMBER:
|
||||
//lyxerr << "toggling all numbers" << endl;
|
||||
if (display()) {
|
||||
////recordUndo(cur, Undo::INSERT);
|
||||
bool old = numberedType();
|
||||
if (type_ == "multline")
|
||||
numbered(nrows() - 1, !old);
|
||||
else
|
||||
for (row_type row = 0; row < nrows(); ++row)
|
||||
numbered(row, !old);
|
||||
cur.message(old ? _("No number") : _("Number"));
|
||||
}
|
||||
return;
|
||||
|
||||
case LFUN_MATH_NONUMBER:
|
||||
if (display()) {
|
||||
row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
|
||||
////recordUndo(cur, Undo::INSERT);
|
||||
bool old = numbered(r);
|
||||
cur.message(old ? _("No number") : _("Number"));
|
||||
numbered(r, !old);
|
||||
}
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case LFUN_INSERT_LABEL: {
|
||||
case LFUN_MATH_NONUMBER:
|
||||
if (display()) {
|
||||
row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
|
||||
string old_label = label(r);
|
||||
string new_label = cmd.argument;
|
||||
////recordUndo(cur, Undo::INSERT);
|
||||
bool old = numbered(r);
|
||||
cur.message(old ? _("No number") : _("Number"));
|
||||
numbered(r, !old);
|
||||
}
|
||||
return;
|
||||
|
||||
if (new_label.empty()) {
|
||||
string const default_label =
|
||||
(lyxrc.label_init_length >= 0) ? "eq:" : "";
|
||||
pair<bool, string> const res = old_label.empty()
|
||||
? Alert::askForText(_("Enter new label to insert:"), default_label)
|
||||
: Alert::askForText(_("Enter label:"), old_label);
|
||||
if (!res.first)
|
||||
return DispatchResult(false);
|
||||
new_label = lyx::support::trim(res.second);
|
||||
}
|
||||
case LFUN_INSERT_LABEL: {
|
||||
row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
|
||||
string old_label = label(r);
|
||||
string new_label = cmd.argument;
|
||||
|
||||
//if (new_label == old_label)
|
||||
// break; // Nothing to do
|
||||
|
||||
if (!new_label.empty())
|
||||
numbered(r, true);
|
||||
label(r, new_label);
|
||||
return DispatchResult(true, true);
|
||||
if (new_label.empty()) {
|
||||
string const default_label =
|
||||
(lyxrc.label_init_length >= 0) ? "eq:" : "";
|
||||
pair<bool, string> const res = old_label.empty()
|
||||
? Alert::askForText(_("Enter new label to insert:"), default_label)
|
||||
: Alert::askForText(_("Enter label:"), old_label);
|
||||
new_label = lyx::support::trim(res.second);
|
||||
}
|
||||
|
||||
case LFUN_MATH_EXTERN:
|
||||
doExtern(cur, cmd);
|
||||
return DispatchResult(true, FINISHED);
|
||||
if (!new_label.empty())
|
||||
numbered(r, true);
|
||||
label(r, new_label);
|
||||
return;
|
||||
}
|
||||
|
||||
case LFUN_MATH_MUTATE: {
|
||||
lyxerr << "Hull: MUTATE: " << cmd.argument << endl;
|
||||
row_type r = cur.row();
|
||||
col_type c = cur.col();
|
||||
mutate(cmd.argument);
|
||||
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_EXTERN:
|
||||
doExtern(cur, cmd);
|
||||
//cur.dispatched(FINISHED);
|
||||
return;
|
||||
|
||||
case LFUN_MATH_DISPLAY: {
|
||||
mutate(type_ == "simple" ? "equation" : "simple");
|
||||
cur.idx() = 0;
|
||||
case LFUN_MATH_MUTATE: {
|
||||
lyxerr << "Hull: MUTATE: " << cmd.argument << endl;
|
||||
row_type r = cur.row();
|
||||
col_type c = cur.col();
|
||||
mutate(cmd.argument);
|
||||
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);
|
||||
}
|
||||
//cur.dispatched(FINISHED);
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
return MathGridInset::priv_dispatch(cur, cmd);
|
||||
case LFUN_MATH_DISPLAY: {
|
||||
mutate(type_ == "simple" ? "equation" : "simple");
|
||||
cur.idx() = 0;
|
||||
cur.pos() = cur.lastpos();
|
||||
//cur.dispatched(FINISHED);
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
MathGridInset::priv_dispatch(cur, cmd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ public:
|
||||
|
||||
protected:
|
||||
///
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
std::string eolString(row_type row, bool fragile) const;
|
||||
|
||||
|
@ -64,9 +64,9 @@ void MathMBoxInset::write(WriteStream & os) const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult MathMBoxInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void MathMBoxInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
return text_.dispatch(cur, cmd);
|
||||
text_.dispatch(cur, cmd);
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
/// draw according to cached metrics
|
||||
void draw(PainterInfo &, int x, int y) const;
|
||||
///
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
|
||||
///
|
||||
void write(WriteStream & os) const;
|
||||
|
@ -348,8 +348,7 @@ void MathNestInset::handleFont2(LCursor & cur, string const & arg)
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
lyxerr << "MathNestInset: request: " << cmd << std::endl;
|
||||
|
||||
@ -362,7 +361,7 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
cur.cell().insert(cur.pos(), ar);
|
||||
cur.pos() += ar.size();
|
||||
}
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
/*
|
||||
case LFUN_PASTE: {
|
||||
size_t n = 0;
|
||||
@ -372,141 +371,184 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
cur.macroModeClose();
|
||||
//recordUndo(cur, Undo::ATOMIC);
|
||||
cur.selPaste(n);
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
case LFUN_PASTESELECTION:
|
||||
return dispatch(cur, FuncRequest(LFUN_PASTE, cur.bv().getClipboard()));
|
||||
dispatch(cur, FuncRequest(LFUN_PASTE, cur.bv().getClipboard()));
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
return lfunMousePress(cur, cmd);
|
||||
lfunMousePress(cur, cmd);
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_MOTION:
|
||||
return lfunMouseMotion(cur, cmd);
|
||||
lfunMouseMotion(cur, cmd);
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
return lfunMouseRelease(cur, cmd);
|
||||
lfunMouseRelease(cur, cmd);
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_DOUBLE:
|
||||
case LFUN_MOUSE_TRIPLE:
|
||||
//lyxerr << "Mouse double" << endl;
|
||||
//lyxerr << "Mouse triple" << endl;
|
||||
return dispatch(cur, FuncRequest(LFUN_WORDSEL));
|
||||
dispatch(cur, FuncRequest(LFUN_WORDSEL));
|
||||
break;
|
||||
|
||||
case LFUN_FINISHED_LEFT:
|
||||
cur.pop(cur.currentDepth());
|
||||
cur.bv().cursor() = cur;
|
||||
break;
|
||||
|
||||
case LFUN_FINISHED_RIGHT:
|
||||
cur.pop(cur.currentDepth());
|
||||
++cur.pos();
|
||||
cur.bv().cursor() = cur;
|
||||
break;
|
||||
|
||||
case LFUN_FINISHED_UP:
|
||||
cur.pop(cur.currentDepth());
|
||||
//idxUpDown(cur, true);
|
||||
cur.bv().cursor() = cur;
|
||||
break;
|
||||
|
||||
case LFUN_FINISHED_DOWN:
|
||||
cur.pop(cur.currentDepth());
|
||||
//idxUpDown(cur, false);
|
||||
cur.bv().cursor() = cur;
|
||||
break;
|
||||
|
||||
case LFUN_RIGHTSEL:
|
||||
case LFUN_RIGHT:
|
||||
cur.selHandle(cmd.action == LFUN_RIGHTSEL);
|
||||
return cur.right() ?
|
||||
DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
|
||||
if (!cur.right())
|
||||
cur.dispatched(FINISHED_RIGHT);
|
||||
break;
|
||||
|
||||
case LFUN_LEFTSEL:
|
||||
case LFUN_LEFT:
|
||||
cur.selHandle(cmd.action == LFUN_LEFTSEL);
|
||||
return cur.left() ?
|
||||
DispatchResult(true, true) : DispatchResult(false, FINISHED);
|
||||
if (!cur.left())
|
||||
cur.dispatched(FINISHED);
|
||||
break;
|
||||
|
||||
case LFUN_UPSEL:
|
||||
case LFUN_UP:
|
||||
cur.selHandle(cmd.action == LFUN_UPSEL);
|
||||
return cur.up() ?
|
||||
DispatchResult(true, true) : DispatchResult(false, FINISHED_UP);
|
||||
if (!cur.up())
|
||||
cur.dispatched(FINISHED_UP);
|
||||
break;
|
||||
|
||||
case LFUN_DOWNSEL:
|
||||
case LFUN_DOWN:
|
||||
cur.selHandle(cmd.action == LFUN_DOWNSEL);
|
||||
return cur.down() ?
|
||||
DispatchResult(true, true) : DispatchResult(false, FINISHED_DOWN);
|
||||
if (!cur.down())
|
||||
cur.dispatched(FINISHED_DOWN);
|
||||
break;
|
||||
|
||||
case LFUN_WORDSEL:
|
||||
cur.home();
|
||||
cur.resetAnchor();
|
||||
cur.selection() = true;
|
||||
cur.end();
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_UP_PARAGRAPHSEL:
|
||||
case LFUN_UP_PARAGRAPH:
|
||||
case LFUN_DOWN_PARAGRAPHSEL:
|
||||
case LFUN_DOWN_PARAGRAPH:
|
||||
return DispatchResult(true, FINISHED);
|
||||
break;
|
||||
|
||||
case LFUN_WORDLEFTSEL:
|
||||
case LFUN_WORDLEFT:
|
||||
cur.selHandle(cmd.action == LFUN_WORDLEFTSEL);
|
||||
return cur.home()
|
||||
? DispatchResult(true, true) : DispatchResult(true, FINISHED);
|
||||
if (!cur.home())
|
||||
cur.dispatched(FINISHED);
|
||||
break;
|
||||
|
||||
case LFUN_WORDRIGHTSEL:
|
||||
case LFUN_WORDRIGHT:
|
||||
cur.selHandle(cmd.action == LFUN_WORDRIGHTSEL);
|
||||
return cur.end()
|
||||
? DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
|
||||
if (!cur.end())
|
||||
cur.dispatched(FINISHED_RIGHT);
|
||||
break;
|
||||
|
||||
case LFUN_HOMESEL:
|
||||
case LFUN_HOME:
|
||||
cur.selHandle(cmd.action == LFUN_HOMESEL);
|
||||
return cur.home()
|
||||
? DispatchResult(true, true) : DispatchResult(true, FINISHED);
|
||||
if (!cur.home())
|
||||
cur.dispatched(FINISHED_RIGHT);
|
||||
break;
|
||||
|
||||
case LFUN_ENDSEL:
|
||||
case LFUN_END:
|
||||
cur.selHandle(cmd.action == LFUN_ENDSEL);
|
||||
return cur.end()
|
||||
? DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
|
||||
if (!cur.end())
|
||||
cur.dispatched(FINISHED_RIGHT);
|
||||
break;
|
||||
|
||||
case LFUN_PRIORSEL:
|
||||
case LFUN_PRIOR:
|
||||
case LFUN_BEGINNINGBUFSEL:
|
||||
case LFUN_BEGINNINGBUF:
|
||||
return DispatchResult(true, FINISHED);
|
||||
cur.dispatched(FINISHED);
|
||||
break;
|
||||
|
||||
case LFUN_NEXTSEL:
|
||||
case LFUN_NEXT:
|
||||
case LFUN_ENDBUFSEL:
|
||||
case LFUN_ENDBUF:
|
||||
return DispatchResult(false, FINISHED_RIGHT);
|
||||
cur.dispatched(FINISHED_RIGHT);
|
||||
break;
|
||||
|
||||
case LFUN_CELL_FORWARD:
|
||||
cur.inset()->idxNext(cur);
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_CELL_BACKWARD:
|
||||
cur.inset()->idxPrev(cur);
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_DELETE_WORD_BACKWARD:
|
||||
case LFUN_BACKSPACE:
|
||||
//recordUndo(cur, Undo::ATOMIC);
|
||||
cur.backspace();
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_DELETE_WORD_FORWARD:
|
||||
case LFUN_DELETE:
|
||||
//recordUndo(cur, Undo::ATOMIC);
|
||||
cur.erase();
|
||||
return DispatchResult(true, FINISHED);
|
||||
cur.dispatched(FINISHED);
|
||||
break;
|
||||
|
||||
case LFUN_ESCAPE:
|
||||
if (!cur.selection())
|
||||
return DispatchResult(true, true);
|
||||
cur.selClear();
|
||||
return DispatchResult(false);
|
||||
if (cur.selection())
|
||||
cur.selClear();
|
||||
else
|
||||
cur.dispatched(FINISHED);
|
||||
break;
|
||||
|
||||
case LFUN_INSET_TOGGLE:
|
||||
cur.lockToggle();
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_SELFINSERT:
|
||||
if (!cmd.argument.empty()) {
|
||||
//recordUndo(cur, Undo::ATOMIC);
|
||||
if (cmd.argument.size() == 1) {
|
||||
if (cur.interpret(cmd.argument[0]))
|
||||
return DispatchResult(true, true);
|
||||
else
|
||||
return DispatchResult(false, FINISHED_RIGHT);
|
||||
}
|
||||
cur.insert(cmd.argument);
|
||||
if (cmd.argument.empty()) {
|
||||
cur.dispatched(FINISHED_RIGHT);
|
||||
break;
|
||||
}
|
||||
return DispatchResult(false, FINISHED_RIGHT);
|
||||
|
||||
//recordUndo(cur, Undo::ATOMIC);
|
||||
if (cmd.argument.size() != 1) {
|
||||
cur.insert(cmd.argument);
|
||||
break;
|
||||
}
|
||||
if (!cur.interpret(cmd.argument[0]))
|
||||
cur.dispatched(FINISHED_RIGHT);
|
||||
break;
|
||||
|
||||
#if 0
|
||||
//
|
||||
@ -533,18 +575,17 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
istringstream is(cmd.argument.c_str());
|
||||
is >> x >> y;
|
||||
cur.setScreenPos(x, y);
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_CUT:
|
||||
//recordUndo(cur, Undo::DELETE);
|
||||
cur.selCut();
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_COPY:
|
||||
cur.selCopy();
|
||||
return DispatchResult(true, true);
|
||||
|
||||
break;
|
||||
|
||||
// Special casing for superscript in case of LyX handling
|
||||
// dead-keys:
|
||||
@ -555,7 +596,7 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
//recordUndo(cur, Undo::ATOMIC);
|
||||
cur.script(true);
|
||||
}
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_UMLAUT:
|
||||
case LFUN_ACUTE:
|
||||
@ -571,44 +612,44 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
case LFUN_TIE:
|
||||
case LFUN_OGONEK:
|
||||
case LFUN_HUNG_UMLAUT:
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
// Math fonts
|
||||
case LFUN_FREEFONT_APPLY:
|
||||
case LFUN_FREEFONT_UPDATE:
|
||||
handleFont2(cur, cmd.argument);
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_BOLD:
|
||||
handleFont(cur, cmd.argument, "mathbf");
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
case LFUN_SANS:
|
||||
handleFont(cur, cmd.argument, "mathsf");
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
case LFUN_EMPH:
|
||||
handleFont(cur, cmd.argument, "mathcal");
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
case LFUN_ROMAN:
|
||||
handleFont(cur, cmd.argument, "mathrm");
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
case LFUN_CODE:
|
||||
handleFont(cur, cmd.argument, "texttt");
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
case LFUN_FRAK:
|
||||
handleFont(cur, cmd.argument, "mathfrak");
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
case LFUN_ITAL:
|
||||
handleFont(cur, cmd.argument, "mathit");
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
case LFUN_NOUN:
|
||||
handleFont(cur, cmd.argument, "mathbb");
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
//case LFUN_FREEFONT_APPLY:
|
||||
handleFont(cur, cmd.argument, "textrm");
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
case LFUN_DEFAULT:
|
||||
handleFont(cur, cmd.argument, "textnormal");
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_MATH_MODE:
|
||||
#if 1
|
||||
@ -624,7 +665,7 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
handleFont(cur, cmd.argument, "textrm");
|
||||
//cur.owner()->message(_("math text mode toggled"));
|
||||
#endif
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_MATH_SIZE:
|
||||
#if 0
|
||||
@ -633,7 +674,7 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
cur.setSize(arg);
|
||||
}
|
||||
#endif
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_INSERT_MATRIX: {
|
||||
//recordUndo(cur, Undo::ATOMIC);
|
||||
@ -650,7 +691,7 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
v_align += 'c';
|
||||
cur.niceInsert(
|
||||
MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_MATH_DELIM: {
|
||||
@ -664,25 +705,25 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
rs = ')';
|
||||
//recordUndo(cur, Undo::ATOMIC);
|
||||
cur.handleNest(MathAtom(new MathDelimInset(ls, rs)));
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_SPACE_INSERT:
|
||||
case LFUN_MATH_SPACE:
|
||||
//recordUndo(cur, Undo::ATOMIC);
|
||||
cur.insert(MathAtom(new MathSpaceInset(",")));
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_UNDO:
|
||||
#warning look here
|
||||
//cur.bv().owner()->message(_("Invalid action in math mode!"));
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
case LFUN_INSET_ERT:
|
||||
// interpret this as if a backslash was typed
|
||||
//recordUndo(cur, Undo::ATOMIC);
|
||||
cur.interpret('\\');
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
|
||||
// FIXME: We probably should swap parts of "math-insert" and "self-insert"
|
||||
// handling such that "self-insert" works on "arbitrary stuff" too, and
|
||||
@ -690,10 +731,7 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
case LFUN_INSERT_MATH:
|
||||
//recordUndo(cur, Undo::ATOMIC);
|
||||
cur.niceInsert(cmd.argument);
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case LFUN_DIALOG_SHOW:
|
||||
return DispatchResult(false);
|
||||
break;
|
||||
|
||||
case LFUN_DIALOG_SHOW_NEW_INSET: {
|
||||
string const & name = cmd.argument;
|
||||
@ -704,10 +742,8 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
data = tmp.createDialogStr(name);
|
||||
}
|
||||
#endif
|
||||
if (data.empty())
|
||||
return DispatchResult(false);
|
||||
cur.bv().owner()->getDialogs().show(name, data, 0);
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSET_APPLY: {
|
||||
@ -715,15 +751,16 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
InsetBase * base = cur.bv().owner()->getDialogs().getOpenInset(name);
|
||||
|
||||
if (base) {
|
||||
FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument);
|
||||
return base->dispatch(cur, fr);
|
||||
base->dispatch(cur, FuncRequest(LFUN_INSET_MODIFY, cmd.argument));
|
||||
break;
|
||||
}
|
||||
MathArray ar;
|
||||
if (createMathInset_fromDialogStr(cmd.argument, ar)) {
|
||||
cur.insert(ar);
|
||||
return DispatchResult(true, true);
|
||||
break;
|
||||
}
|
||||
return DispatchResult(false);
|
||||
cur.notdispatched();
|
||||
break;
|
||||
}
|
||||
|
||||
#warning look here
|
||||
@ -731,9 +768,9 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
|
||||
case LFUN_WORD_REPLACE:
|
||||
case LFUN_WORD_FIND:
|
||||
return
|
||||
searchForward(&cur.bv(), cmd.getArg(0), false, false)
|
||||
? DispatchResult(true, true) : DispatchResult(false);
|
||||
if (!searchForward(&cur.bv(), cmd.getArg(0), false, false))
|
||||
cur.notdispatched();
|
||||
break;
|
||||
|
||||
cur.normalize();
|
||||
cur.touch();
|
||||
@ -747,12 +784,12 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
if (remove_inset)
|
||||
cur.bv().owner()->dispatch(FuncRequest(LFUN_DELETE));
|
||||
}
|
||||
|
||||
return result; // original version
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
return MathDimInset::priv_dispatch(cur, cmd);
|
||||
MathDimInset::priv_dispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -792,15 +829,14 @@ InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y)
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
||||
void MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
//lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
|
||||
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
// try to dispatch to enclosed insets first
|
||||
//cur.bv().stuffClipboard(cur.grabSelection());
|
||||
return DispatchResult(true, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button2) {
|
||||
@ -810,21 +846,20 @@ MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
||||
cur.setScreenPos(cmd.x, cmd.y);
|
||||
cur.insert(ar);
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
// try to dispatch to enclosed insets first
|
||||
cur.bv().owner()->getDialogs().show("mathpanel");
|
||||
return DispatchResult(true, true);
|
||||
return;
|
||||
}
|
||||
|
||||
return DispatchResult(false);
|
||||
cur.notdispatched();
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathNestInset::lfunMousePress(LCursor & cur, FuncRequest const & cmd)
|
||||
void MathNestInset::lfunMousePress(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
@ -834,30 +869,22 @@ MathNestInset::lfunMousePress(LCursor & cur, FuncRequest const & cmd)
|
||||
//cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
|
||||
lyxerr << "lfunMousePress: setting cursor to: " << cur << endl;
|
||||
cur.bv().cursor() = cur;
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button2) {
|
||||
return priv_dispatch(cur, FuncRequest(LFUN_PASTESELECTION));
|
||||
priv_dispatch(cur, FuncRequest(LFUN_PASTESELECTION));
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathNestInset::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
|
||||
void MathNestInset::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
// only select with button 1
|
||||
if (cmd.button() != mouse_button::button1)
|
||||
return DispatchResult(true, true);
|
||||
return;
|
||||
|
||||
if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2)
|
||||
return DispatchResult(true, true);
|
||||
return;
|
||||
|
||||
first_x = cmd.x;
|
||||
first_y = cmd.y;
|
||||
@ -868,5 +895,5 @@ MathNestInset::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
|
||||
//cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
|
||||
cur.bv().cursor().cursor_ = cur.cursor_;
|
||||
cur.bv().cursor().selection() = true;
|
||||
return DispatchResult(true, true);
|
||||
return;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public:
|
||||
|
||||
protected:
|
||||
///
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
///
|
||||
void handleFont(LCursor & cur,
|
||||
std::string const & arg, std::string const & font);
|
||||
@ -111,11 +111,11 @@ protected:
|
||||
|
||||
private:
|
||||
/// lfun handler
|
||||
DispatchResult lfunMousePress(LCursor &, FuncRequest const &);
|
||||
void lfunMousePress(LCursor &, FuncRequest const &);
|
||||
///
|
||||
DispatchResult lfunMouseRelease(LCursor &, FuncRequest const &);
|
||||
void lfunMouseRelease(LCursor &, FuncRequest const &);
|
||||
///
|
||||
DispatchResult lfunMouseMotion(LCursor &, FuncRequest const &);
|
||||
void lfunMouseMotion(LCursor &, FuncRequest const &);
|
||||
|
||||
protected:
|
||||
/// we store the cells in a vector
|
||||
|
@ -513,10 +513,9 @@ void MathScriptInset::notifyCursorLeaves(idx_type idx)
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathScriptInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void MathScriptInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
lyxerr << "MathScriptInset: request: " << cmd << std::endl;
|
||||
//lyxerr << "MathScriptInset: request: " << cmd << std::endl;
|
||||
|
||||
if (cmd.action == LFUN_MATH_LIMITS) {
|
||||
if (!cmd.argument.empty()) {
|
||||
@ -530,8 +529,8 @@ MathScriptInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
limits_ = hasLimits() ? -1 : 1;
|
||||
else
|
||||
limits_ = 0;
|
||||
return DispatchResult(true, true);
|
||||
return;
|
||||
}
|
||||
|
||||
return MathNestInset::priv_dispatch(cur, cmd);
|
||||
MathNestInset::priv_dispatch(cur, cmd);
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
void infoize2(std::ostream & os) const;
|
||||
protected:
|
||||
///
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
private:
|
||||
/// returns x offset for main part
|
||||
int dxx() const;
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "debug.h"
|
||||
#include "funcrequest.h"
|
||||
#include "math_support.h"
|
||||
@ -54,41 +53,44 @@ void RefInset::infoize(std::ostream & os) const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult RefInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
void RefInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_INSET_MODIFY:
|
||||
if (cmd.getArg(0) == "ref") {
|
||||
MathArray ar;
|
||||
if (!createMathInset_fromDialogStr(cmd.argument, ar))
|
||||
return DispatchResult(false);
|
||||
*this = *ar[0].nucleus()->asRefInset();
|
||||
return DispatchResult(true, true);
|
||||
if (createMathInset_fromDialogStr(cmd.argument, ar)) {
|
||||
*this = *ar[0].nucleus()->asRefInset();
|
||||
return;
|
||||
}
|
||||
}
|
||||
return DispatchResult(false);
|
||||
cur.notdispatched();
|
||||
return;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
lyxerr << "trying to goto ref" << cell(0) << endl;
|
||||
cur.bv().dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
|
||||
return DispatchResult(true, true);
|
||||
return;
|
||||
}
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
// Eventually trigger dialog with button 3
|
||||
// not 1
|
||||
string const data = createDialogStr("ref");
|
||||
cur.bv().owner()->getDialogs().show("ref", data, this);
|
||||
return DispatchResult(true, true);
|
||||
return;
|
||||
}
|
||||
return DispatchResult(false);
|
||||
cur.notdispatched();
|
||||
return;
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
case LFUN_MOUSE_MOTION:
|
||||
// eat other mouse commands
|
||||
return DispatchResult(true, true);
|
||||
return;
|
||||
|
||||
default:
|
||||
return CommandInset::priv_dispatch(cur, cmd);
|
||||
CommandInset::priv_dispatch(cur, cmd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,9 +60,7 @@ public:
|
||||
static std::string const & getName(int type);
|
||||
protected:
|
||||
///
|
||||
virtual
|
||||
DispatchResult
|
||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -391,7 +391,7 @@ void RowPainter::paintBackground()
|
||||
|
||||
void RowPainter::paintSelection()
|
||||
{
|
||||
bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
|
||||
bool const is_rtl = text_.isRTL(*pit_);
|
||||
|
||||
// the current selection
|
||||
LCursor const & cur = bv_.cursor();
|
||||
@ -621,7 +621,7 @@ void RowPainter::paintFirst()
|
||||
|
||||
int const ww = bv_.workWidth();
|
||||
|
||||
bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
|
||||
bool const is_rtl = text_.isRTL(*pit_);
|
||||
bool const is_seq = isFirstInSequence(pit_, text_.paragraphs());
|
||||
//lyxerr << "paintFirst: " << pit_->id() << " is_seq: " << is_seq << std::endl;
|
||||
|
||||
@ -715,7 +715,7 @@ void RowPainter::paintFirst()
|
||||
void RowPainter::paintLast()
|
||||
{
|
||||
int const ww = bv_.workWidth();
|
||||
bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
|
||||
bool const is_rtl = text_.isRTL(*pit_);
|
||||
int const endlabel = getEndLabel(pit_, text_.paragraphs());
|
||||
|
||||
// draw an endlabel
|
||||
|
@ -2008,8 +2008,9 @@ int LyXTabular::TeXRow(ostream & os, int i, Buffer const & buf,
|
||||
ret += TeXCellPreamble(os, cell);
|
||||
InsetText & inset = getCellInset(cell);
|
||||
|
||||
bool rtl = inset.paragraphs().begin()->isRightToLeftPar(bufferparams) &&
|
||||
!inset.paragraphs().begin()->empty() && getPWidth(cell).zero();
|
||||
bool rtl = inset.text_.isRTL(inset.paragraphs().front())
|
||||
&& !inset.paragraphs().begin()->empty()
|
||||
&& getPWidth(cell).zero();
|
||||
|
||||
if (rtl)
|
||||
os << "\\R{";
|
||||
|
28
src/text.C
28
src/text.C
@ -1032,8 +1032,7 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit, Row & row) const
|
||||
double fill_separator = 0;
|
||||
double x = 0;
|
||||
|
||||
bool const is_rtl =
|
||||
pit->isRightToLeftPar(bv()->buffer()->params());
|
||||
bool const is_rtl = isRTL(*pit);
|
||||
if (is_rtl)
|
||||
x = rightMargin(*pit);
|
||||
else
|
||||
@ -1851,8 +1850,7 @@ int LyXText::cursorX(CursorSlice const & cur) const
|
||||
if (end <= row_pos)
|
||||
cursor_vpos = row_pos;
|
||||
else if (pos >= end)
|
||||
cursor_vpos = (pit->isRightToLeftPar(bv()->buffer()->params()))
|
||||
? row_pos : end;
|
||||
cursor_vpos = isRTL(*pit) ? row_pos : end;
|
||||
else if (pos > row_pos && pos >= end)
|
||||
// Place cursor after char at (logical) position pos - 1
|
||||
cursor_vpos = (bidi.level(pos - 1) % 2 == 0)
|
||||
@ -2038,8 +2036,7 @@ string LyXText::getPossibleLabel(LCursor & cur) const
|
||||
text = "thm"; // Create a correct prefix for prettyref
|
||||
|
||||
text += ':';
|
||||
if (layout->latextype == LATEX_PARAGRAPH ||
|
||||
lyxrc.label_init_length < 0)
|
||||
if (layout->latextype == LATEX_PARAGRAPH || lyxrc.label_init_length < 0)
|
||||
text.erase();
|
||||
|
||||
string par_text = pit->asString(*cur.bv().buffer(), false);
|
||||
@ -2056,3 +2053,22 @@ string LyXText::getPossibleLabel(LCursor & cur) const
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
int LyXText::dist(int x, int y) const
|
||||
{
|
||||
int xx = 0;
|
||||
int yy = 0;
|
||||
|
||||
if (x < xo_)
|
||||
xx = xo_ - x;
|
||||
else if (x > xo_ + width)
|
||||
xx = x - xo_ - width;
|
||||
|
||||
if (y < yo_ - ascent())
|
||||
yy = yo_ - ascent() - y;
|
||||
else if (y > yo_ + descent())
|
||||
yy = y - yo_ - descent();
|
||||
|
||||
return xx + yy;
|
||||
}
|
||||
|
36
src/text2.C
36
src/text2.C
@ -959,7 +959,7 @@ void LyXText::copySelection(LCursor & cur)
|
||||
&& getPar(cur.selBegin())->isLineSeparator(cur.selBegin().pos())
|
||||
&& (cur.selBegin().par() != cur.selEnd().par()
|
||||
|| cur.selBegin().pos() < cur.selEnd().pos()))
|
||||
cur.selBegin().pos(cur.selBegin().pos() + 1);
|
||||
++cur.selBegin().pos();
|
||||
|
||||
CutAndPaste::copySelection(getPar(cur.selBegin().par()),
|
||||
getPar(cur.selEnd().par()),
|
||||
@ -1098,9 +1098,9 @@ void LyXText::setCursor(CursorSlice & cur, par_type par,
|
||||
{
|
||||
BOOST_ASSERT(par != int(paragraphs().size()));
|
||||
|
||||
cur.par(par);
|
||||
cur.pos(pos);
|
||||
cur.boundary(boundary);
|
||||
cur.par() = par;
|
||||
cur.pos() = pos;
|
||||
cur.boundary() = boundary;
|
||||
|
||||
// no rows, no fun...
|
||||
if (paragraphs().begin()->rows.empty())
|
||||
@ -1114,30 +1114,28 @@ void LyXText::setCursor(CursorSlice & cur, par_type par,
|
||||
// None of these should happen, but we're scaredy-cats
|
||||
if (pos < 0) {
|
||||
lyxerr << "dont like -1" << endl;
|
||||
pos = 0;
|
||||
cur.pos(0);
|
||||
BOOST_ASSERT(false);
|
||||
} else if (pos > para.size()) {
|
||||
}
|
||||
|
||||
if (pos > para.size()) {
|
||||
lyxerr << "dont like 1, pos: " << pos
|
||||
<< " size: " << para.size()
|
||||
<< " row.pos():" << row.pos()
|
||||
<< " par: " << par << endl;
|
||||
pos = 0;
|
||||
cur.pos(0);
|
||||
BOOST_ASSERT(false);
|
||||
} else if (pos > end) {
|
||||
}
|
||||
|
||||
if (pos > end) {
|
||||
lyxerr << "dont like 2 please report" << endl;
|
||||
// This shouldn't happen.
|
||||
pos = end;
|
||||
cur.pos(pos);
|
||||
BOOST_ASSERT(false);
|
||||
} else if (pos < row.pos()) {
|
||||
}
|
||||
|
||||
if (pos < row.pos()) {
|
||||
lyxerr << "dont like 3 please report pos:" << pos
|
||||
<< " size: " << para.size()
|
||||
<< " row.pos():" << row.pos()
|
||||
<< " par: " << par << endl;
|
||||
pos = row.pos();
|
||||
cur.pos(pos);
|
||||
BOOST_ASSERT(false);
|
||||
}
|
||||
}
|
||||
@ -1264,9 +1262,7 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
|
||||
|
||||
// If lastrow is false, we don't need to compute
|
||||
// the value of rtl.
|
||||
bool const rtl = lastrow
|
||||
? pit->isRightToLeftPar(bv()->buffer()->params())
|
||||
: false;
|
||||
bool const rtl = lastrow ? isRTL(*pit) : false;
|
||||
if (lastrow &&
|
||||
((rtl && left_side && vc == row.pos() && x < tmpx - 5) ||
|
||||
(!rtl && !left_side && vc == end && x > tmpx + 5)))
|
||||
@ -1358,7 +1354,7 @@ bool LyXText::checkAndActivateInset(LCursor & cur, bool front)
|
||||
|
||||
DispatchResult LyXText::moveRight(LCursor & cur)
|
||||
{
|
||||
if (rtl(cur))
|
||||
if (isRTL(cur.paragraph()))
|
||||
return moveLeftIntern(cur, false, true, false);
|
||||
else
|
||||
return moveRightIntern(cur, true, true, false);
|
||||
@ -1367,7 +1363,7 @@ DispatchResult LyXText::moveRight(LCursor & cur)
|
||||
|
||||
DispatchResult LyXText::moveLeft(LCursor & cur)
|
||||
{
|
||||
if (rtl(cur))
|
||||
if (isRTL(cur.paragraph()))
|
||||
return moveRightIntern(cur, true, true, false);
|
||||
else
|
||||
return moveLeftIntern(cur, false, true, false);
|
||||
|
20
src/text3.C
20
src/text3.C
@ -366,9 +366,9 @@ void LyXText::number(LCursor & cur)
|
||||
}
|
||||
|
||||
|
||||
bool LyXText::rtl(LCursor & cur) const
|
||||
bool LyXText::isRTL(Paragraph const & par) const
|
||||
{
|
||||
return cur.paragraph().isRightToLeftPar(bv()->buffer()->params());
|
||||
return par.isRightToLeftPar(bv()->buffer()->params());
|
||||
}
|
||||
|
||||
|
||||
@ -429,7 +429,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
case LFUN_WORDRIGHT:
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
if (rtl(cur))
|
||||
if (isRTL(cur.paragraph()))
|
||||
cursorLeftOneWord(cur);
|
||||
else
|
||||
cursorRightOneWord(cur);
|
||||
@ -439,7 +439,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
case LFUN_WORDLEFT:
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
if (rtl(cur))
|
||||
if (isRTL(cur.paragraph()))
|
||||
cursorRightOneWord(cur);
|
||||
else
|
||||
cursorLeftOneWord(cur);
|
||||
@ -463,7 +463,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
case LFUN_RIGHTSEL:
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
if (rtl(cur))
|
||||
if (isRTL(cur.paragraph()))
|
||||
cursorLeft(cur, true);
|
||||
else
|
||||
cursorRight(cur, true);
|
||||
@ -473,7 +473,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
case LFUN_LEFTSEL:
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
if (rtl(cur))
|
||||
if (isRTL(cur.paragraph()))
|
||||
cursorRight(cur, true);
|
||||
else
|
||||
cursorLeft(cur, true);
|
||||
@ -539,7 +539,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
case LFUN_WORDRIGHTSEL:
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
if (rtl(cur))
|
||||
if (isRTL(cur.paragraph()))
|
||||
cursorLeftOneWord(cur);
|
||||
else
|
||||
cursorRightOneWord(cur);
|
||||
@ -549,7 +549,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
case LFUN_WORDLEFTSEL:
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
if (rtl(cur))
|
||||
if (isRTL(cur.paragraph()))
|
||||
cursorRightOneWord(cur);
|
||||
else
|
||||
cursorLeftOneWord(cur);
|
||||
@ -1439,7 +1439,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
case LFUN_FINISHED_LEFT:
|
||||
lyxerr << "handle LFUN_FINISHED_LEFT" << endl;
|
||||
cur.pop(cur.currentDepth());
|
||||
if (rtl(cur))
|
||||
if (isRTL(cur.paragraph()))
|
||||
cursorLeft(cur, true);
|
||||
cur.bv().cursor() = cur;
|
||||
break;
|
||||
@ -1447,7 +1447,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
case LFUN_FINISHED_RIGHT:
|
||||
lyxerr << "handle LFUN_FINISHED_RIGHT" << endl;
|
||||
cur.pop(cur.currentDepth());
|
||||
if (!rtl(cur))
|
||||
if (!isRTL(cur.paragraph()))
|
||||
cursorRight(cur, true);
|
||||
cur.bv().cursor() = cur;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user