mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
remove cursor::drawSelection() plus some math reorganization (move the
'width' cache from MathAtom) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8383 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a73da74db2
commit
6af06846fd
@ -905,7 +905,7 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
|
|||||||
res = bv_->text()->dispatch(cur, cmd);
|
res = bv_->text()->dispatch(cur, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bv_->fitCursor() || res.update()) {
|
if (fitCursor() || res.update()) {
|
||||||
bv_->update();
|
bv_->update();
|
||||||
cur.updatePos();
|
cur.updatePos();
|
||||||
}
|
}
|
||||||
@ -947,7 +947,7 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
|
|||||||
// if it wishes to do so.
|
// if it wishes to do so.
|
||||||
DispatchResult res = cur.dispatch(cmd);
|
DispatchResult res = cur.dispatch(cmd);
|
||||||
|
|
||||||
if (bv_->fitCursor() || res.update())
|
if (fitCursor() || res.update())
|
||||||
bv_->update();
|
bv_->update();
|
||||||
|
|
||||||
// see workAreaKeyPress
|
// see workAreaKeyPress
|
||||||
|
16
src/cursor.C
16
src/cursor.C
@ -1179,16 +1179,6 @@ string LCursor::macroName()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LCursor::drawSelection(PainterInfo & pi)
|
|
||||||
{
|
|
||||||
if (!selection())
|
|
||||||
return;
|
|
||||||
CursorSlice i1 = selBegin();
|
|
||||||
CursorSlice i2 = selEnd();
|
|
||||||
i1.asMathInset()->drawSelection(pi, i1.idx_, i1.pos_, i2.idx_, i2.pos_);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LCursor::handleNest(MathAtom const & a, int c)
|
void LCursor::handleNest(MathAtom const & a, int c)
|
||||||
{
|
{
|
||||||
MathAtom t = a;
|
MathAtom t = a;
|
||||||
@ -1510,6 +1500,7 @@ bool LCursor::idxRight()
|
|||||||
bool LCursor::script(bool up)
|
bool LCursor::script(bool up)
|
||||||
{
|
{
|
||||||
// Hack to get \\^ and \\_ working
|
// Hack to get \\^ and \\_ working
|
||||||
|
lyxerr << "handling script: up: " << up << endl;
|
||||||
if (inMacroMode() && macroName() == "\\") {
|
if (inMacroMode() && macroName() == "\\") {
|
||||||
if (up)
|
if (up)
|
||||||
niceInsert(createMathInset("mathcircumflex"));
|
niceInsert(createMathInset("mathcircumflex"));
|
||||||
@ -1533,8 +1524,7 @@ bool LCursor::script(bool up)
|
|||||||
pos() = lastpos();
|
pos() = lastpos();
|
||||||
} else if (pos() != 0) {
|
} else if (pos() != 0) {
|
||||||
--pos();
|
--pos();
|
||||||
cell()[pos()]
|
cell()[pos()] = MathAtom(new MathScriptInset(nextAtom(), up));
|
||||||
= MathAtom(new MathScriptInset(nextAtom(), up));
|
|
||||||
push(inset());
|
push(inset());
|
||||||
idx() = up;
|
idx() = up;
|
||||||
pos() = 0;
|
pos() = 0;
|
||||||
@ -1553,7 +1543,7 @@ bool LCursor::script(bool up)
|
|||||||
|
|
||||||
bool LCursor::interpret(char c)
|
bool LCursor::interpret(char c)
|
||||||
{
|
{
|
||||||
//lyxerr << "interpret 2: '" << c << "'" << endl;
|
lyxerr << "interpret 2: '" << c << "'" << endl;
|
||||||
clearTargetX();
|
clearTargetX();
|
||||||
if (inMacroArgMode()) {
|
if (inMacroArgMode()) {
|
||||||
posLeft();
|
posLeft();
|
||||||
|
@ -354,8 +354,6 @@ public:
|
|||||||
/// are we currently typing '#1' or '#2' or...?
|
/// are we currently typing '#1' or '#2' or...?
|
||||||
bool inMacroArgMode() const;
|
bool inMacroArgMode() const;
|
||||||
|
|
||||||
/// draws light-blue selection background
|
|
||||||
void drawSelection(PainterInfo & pi);
|
|
||||||
/// replace selected stuff with at, placing the former
|
/// replace selected stuff with at, placing the former
|
||||||
// selection in given cell of atom
|
// selection in given cell of atom
|
||||||
void handleNest(MathAtom const & at, int cell = 0);
|
void handleNest(MathAtom const & at, int cell = 0);
|
||||||
|
@ -212,8 +212,8 @@ bool LyXScreen::fitCursor(BufferView * bv)
|
|||||||
int x, y, asc, desc;
|
int x, y, asc, desc;
|
||||||
|
|
||||||
bv->cursor().getPos(x, y);
|
bv->cursor().getPos(x, y);
|
||||||
//lyxerr << "LyXScreen::fitCursor: x: " << x << " y: " << y
|
lyxerr << "LyXScreen::fitCursor: x: " << x << " y: " << y
|
||||||
// << " top_y: " << top_y << endl;
|
<< " top_y: " << top_y << endl;
|
||||||
bv->cursor().getDim(asc, desc);
|
bv->cursor().getDim(asc, desc);
|
||||||
|
|
||||||
bool const big_row = h / 4 < asc + desc && asc + desc < h;
|
bool const big_row = h / 4 < asc + desc && asc + desc < h;
|
||||||
|
@ -89,6 +89,7 @@ int InsetOld::scroll(bool recursive) const
|
|||||||
|
|
||||||
void InsetOld::setPosCache(PainterInfo const &, int x, int y) const
|
void InsetOld::setPosCache(PainterInfo const &, int x, int y) const
|
||||||
{
|
{
|
||||||
|
lyxerr << "InsetOld:: position cache to " << x << " " << y << std::endl;
|
||||||
xo_ = x;
|
xo_ = x;
|
||||||
yo_ = y;
|
yo_ = y;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "insetbase.h"
|
#include "insetbase.h"
|
||||||
|
|
||||||
|
#include "buffer.h"
|
||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "LColor.h"
|
#include "LColor.h"
|
||||||
#include "cursor.h"
|
#include "cursor.h"
|
||||||
@ -225,6 +226,13 @@ bool InsetBase::covers(int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InsetBase::dump() const
|
||||||
|
{
|
||||||
|
Buffer buf("foo", 1);
|
||||||
|
write(buf, lyxerr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
|
|
||||||
bool isEditableInset(InsetBase const * inset)
|
bool isEditableInset(InsetBase const * inset)
|
||||||
|
@ -79,6 +79,8 @@ public:
|
|||||||
virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
|
virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
|
||||||
/// draw inset and update (xo, yo)-cache
|
/// draw inset and update (xo, yo)-cache
|
||||||
virtual void draw(PainterInfo & pi, int x, int y) const = 0;
|
virtual void draw(PainterInfo & pi, int x, int y) const = 0;
|
||||||
|
/// draw inset selection if necessary
|
||||||
|
virtual void drawSelection(PainterInfo &, int, int) const {}
|
||||||
///
|
///
|
||||||
virtual bool editing(BufferView * bv) const;
|
virtual bool editing(BufferView * bv) const;
|
||||||
/// draw four angular markers
|
/// draw four angular markers
|
||||||
@ -322,6 +324,8 @@ public:
|
|||||||
virtual bool display() const { return false; }
|
virtual bool display() const { return false; }
|
||||||
// should we break lines after this inset?
|
// should we break lines after this inset?
|
||||||
virtual bool isLineSeparator() const { return false; }
|
virtual bool isLineSeparator() const { return false; }
|
||||||
|
/// dumps content to lyxerr
|
||||||
|
virtual void dump() const;
|
||||||
///
|
///
|
||||||
virtual void write(Buffer const &, std::ostream &) const {}
|
virtual void write(Buffer const &, std::ostream &) const {}
|
||||||
///
|
///
|
||||||
|
@ -170,9 +170,12 @@ void InsetFormulaMacro::draw(PainterInfo & p, int x, int y) const
|
|||||||
pi.pain.fillRectangle(x, a, w, h, LColor::mathmacrobg);
|
pi.pain.fillRectangle(x, a, w, h, LColor::mathmacrobg);
|
||||||
pi.pain.rectangle(x, a, w, h, LColor::mathframe);
|
pi.pain.rectangle(x, a, w, h, LColor::mathframe);
|
||||||
|
|
||||||
|
#warning FIXME
|
||||||
|
#if 0
|
||||||
LCursor & cur = p.base.bv->cursor();
|
LCursor & cur = p.base.bv->cursor();
|
||||||
if (cur.isInside(this))
|
if (cur.isInside(this))
|
||||||
cur.drawSelection(pi);
|
cur.drawSelection(pi);
|
||||||
|
#endif
|
||||||
|
|
||||||
pi.pain.text(x + 2, y, prefix(), font);
|
pi.pain.text(x + 2, y, prefix(), font);
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public:
|
|||||||
MathInset const * operator->() const { return nucleus_; }
|
MathInset const * operator->() const { return nucleus_; }
|
||||||
|
|
||||||
/// width cache. Not nice...
|
/// width cache. Not nice...
|
||||||
mutable int width_;
|
//mutable int width_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
|
@ -84,6 +84,7 @@ void MathCharInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
width_ += 2 * font_metrics::width(' ', font_);
|
width_ += 2 * font_metrics::width(' ', font_);
|
||||||
lyxerr << "MathCharInset::metrics: " << dim << endl;
|
lyxerr << "MathCharInset::metrics: " << dim << endl;
|
||||||
#endif
|
#endif
|
||||||
|
dim_ = dim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,11 +12,12 @@
|
|||||||
#ifndef MATH_CHARINSET_H
|
#ifndef MATH_CHARINSET_H
|
||||||
#define MATH_CHARINSET_H
|
#define MATH_CHARINSET_H
|
||||||
|
|
||||||
#include "math_inset.h"
|
#include "math_diminset.h"
|
||||||
|
|
||||||
|
#warning this should not derive from the fat MathDimInset
|
||||||
|
|
||||||
/// The base character inset.
|
/// The base character inset.
|
||||||
class MathCharInset : public MathInset {
|
class MathCharInset : public MathDimInset {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
explicit MathCharInset(char c);
|
explicit MathCharInset(char c);
|
||||||
@ -30,6 +31,7 @@ public:
|
|||||||
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
|
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
|
||||||
///
|
///
|
||||||
void drawT(TextPainter &, int x, int y) const;
|
void drawT(TextPainter &, int x, int y) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
void write(WriteStream & os) const;
|
void write(WriteStream & os) const;
|
||||||
///
|
///
|
||||||
|
@ -232,7 +232,7 @@ void MathArray::metrics(MetricsInfo & mi) const
|
|||||||
for (const_iterator it = begin(), et = end(); it != et; ++it) {
|
for (const_iterator it = begin(), et = end(); it != et; ++it) {
|
||||||
(*it)->metrics(mi, d);
|
(*it)->metrics(mi, d);
|
||||||
dim_ += d;
|
dim_ += d;
|
||||||
it->width_ = d.wid;
|
//it->width_ = d.wid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,9 +263,9 @@ void MathArray::draw(PainterInfo & pi, int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const_iterator it = begin(), et = end(); it != et; ++it) {
|
for (const_iterator it = begin(), et = end(); it != et; ++it) {
|
||||||
pi.width = it->width_;
|
//pi.width = it->width_;
|
||||||
(*it)->draw(pi, x, y);
|
(*it)->draw(pi, x, y);
|
||||||
x += it->width_;
|
x += (*it)->width();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +294,8 @@ void MathArray::drawT(TextPainter & pain, int x, int y) const
|
|||||||
|
|
||||||
for (const_iterator it = begin(), et = end(); it != et; ++it) {
|
for (const_iterator it = begin(), et = end(); it != et; ++it) {
|
||||||
(*it)->drawT(pain, x, y);
|
(*it)->drawT(pain, x, y);
|
||||||
x += it->width_;
|
//x += (*it->width_;
|
||||||
|
x += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +314,9 @@ int MathArray::pos2x(size_type pos, int glue) const
|
|||||||
const_iterator it = begin() + i;
|
const_iterator it = begin() + i;
|
||||||
if ((*it)->getChar() == ' ')
|
if ((*it)->getChar() == ' ')
|
||||||
x += glue;
|
x += glue;
|
||||||
x += it->width_;
|
lyxerr << "char: " << (*it)->getChar()
|
||||||
|
<< "width: " << (*it)->width() << std::endl;
|
||||||
|
x += (*it)->width();
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
@ -334,7 +337,7 @@ MathArray::size_type MathArray::x2pos(int targetx, int glue) const
|
|||||||
lastx = currx;
|
lastx = currx;
|
||||||
if ((*it)->getChar() == ' ')
|
if ((*it)->getChar() == ' ')
|
||||||
currx += glue;
|
currx += glue;
|
||||||
currx += it->width_;
|
currx += (*it)->width();
|
||||||
}
|
}
|
||||||
if (abs(lastx - targetx) < abs(currx - targetx) && it != begin())
|
if (abs(lastx - targetx) < abs(currx - targetx) && it != begin())
|
||||||
--it;
|
--it;
|
||||||
|
@ -11,8 +11,13 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "math_diminset.h"
|
#include "math_diminset.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
||||||
|
MathDimInset::MathDimInset()
|
||||||
|
: xo_(-3), yo_(-3)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
int MathDimInset::ascent() const
|
int MathDimInset::ascent() const
|
||||||
{
|
{
|
||||||
@ -34,6 +39,7 @@ int MathDimInset::width() const
|
|||||||
|
|
||||||
void MathDimInset::setPosCache(PainterInfo const &, int x, int y) const
|
void MathDimInset::setPosCache(PainterInfo const &, int x, int y) const
|
||||||
{
|
{
|
||||||
|
lyxerr << "MathDimInset:: position cache to " << x << " " << y << std::endl;
|
||||||
xo_ = x;
|
xo_ = x;
|
||||||
yo_ = y;
|
yo_ = y;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,9 @@ class PainterInfo;
|
|||||||
/// things that need the dimension cache
|
/// things that need the dimension cache
|
||||||
class MathDimInset : public MathInset {
|
class MathDimInset : public MathInset {
|
||||||
public:
|
public:
|
||||||
|
///
|
||||||
|
MathDimInset();
|
||||||
|
|
||||||
///
|
///
|
||||||
Dimension dimensions() const { return dim_; }
|
Dimension dimensions() const { return dim_; }
|
||||||
///
|
///
|
||||||
|
@ -72,12 +72,16 @@ MathArray const & MathNestInset::cell(idx_type i) const
|
|||||||
void MathNestInset::getCursorPos(CursorSlice const & cur,
|
void MathNestInset::getCursorPos(CursorSlice const & cur,
|
||||||
int & x, int & y) const
|
int & x, int & y) const
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(cur.inset() == this);
|
||||||
MathArray const & ar = cur.cell();
|
MathArray const & ar = cur.cell();
|
||||||
x = ar.xo() + ar.pos2x(cur.pos());
|
x = ar.xo() + ar.pos2x(cur.pos());
|
||||||
y = ar.yo();
|
y = ar.yo();
|
||||||
// move cursor visually into empty cells ("blue rectangles");
|
// move cursor visually into empty cells ("blue rectangles");
|
||||||
if (cur.cell().empty())
|
if (cur.cell().empty())
|
||||||
x += 2;
|
x += 2;
|
||||||
|
lyxerr << "MathNestInset::getCursorPos: cur: " << cur
|
||||||
|
<< " x: " << x << " y: " << y << endl;
|
||||||
|
BOOST_ASSERT(x < 100000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -98,6 +102,7 @@ void MathNestInset::metrics(MetricsInfo const & mi) const
|
|||||||
|
|
||||||
bool MathNestInset::idxNext(LCursor & cur) const
|
bool MathNestInset::idxNext(LCursor & cur) const
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(cur.inset() == this);
|
||||||
if (cur.idx() + 1 >= nargs())
|
if (cur.idx() + 1 >= nargs())
|
||||||
return false;
|
return false;
|
||||||
++cur.idx();
|
++cur.idx();
|
||||||
@ -114,6 +119,7 @@ bool MathNestInset::idxRight(LCursor & cur) const
|
|||||||
|
|
||||||
bool MathNestInset::idxPrev(LCursor & cur) const
|
bool MathNestInset::idxPrev(LCursor & cur) const
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(cur.inset() == this);
|
||||||
if (cur.idx() == 0)
|
if (cur.idx() == 0)
|
||||||
return false;
|
return false;
|
||||||
--cur.idx();
|
--cur.idx();
|
||||||
@ -130,6 +136,7 @@ bool MathNestInset::idxLeft(LCursor & cur) const
|
|||||||
|
|
||||||
bool MathNestInset::idxFirst(LCursor & cur) const
|
bool MathNestInset::idxFirst(LCursor & cur) const
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(cur.inset() == this);
|
||||||
if (nargs() == 0)
|
if (nargs() == 0)
|
||||||
return false;
|
return false;
|
||||||
cur.idx() = 0;
|
cur.idx() = 0;
|
||||||
@ -140,6 +147,7 @@ bool MathNestInset::idxFirst(LCursor & cur) const
|
|||||||
|
|
||||||
bool MathNestInset::idxLast(LCursor & cur) const
|
bool MathNestInset::idxLast(LCursor & cur) const
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(cur.inset() == this);
|
||||||
if (nargs() == 0)
|
if (nargs() == 0)
|
||||||
return false;
|
return false;
|
||||||
cur.idx() = nargs() - 1;
|
cur.idx() = nargs() - 1;
|
||||||
@ -150,6 +158,7 @@ bool MathNestInset::idxLast(LCursor & cur) const
|
|||||||
|
|
||||||
bool MathNestInset::idxHome(LCursor & cur) const
|
bool MathNestInset::idxHome(LCursor & cur) const
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(cur.inset() == this);
|
||||||
if (cur.pos() == 0)
|
if (cur.pos() == 0)
|
||||||
return false;
|
return false;
|
||||||
cur.pos() = 0;
|
cur.pos() = 0;
|
||||||
@ -159,6 +168,7 @@ bool MathNestInset::idxHome(LCursor & cur) const
|
|||||||
|
|
||||||
bool MathNestInset::idxEnd(LCursor & cur) const
|
bool MathNestInset::idxEnd(LCursor & cur) const
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(cur.inset() == this);
|
||||||
if (cur.lastpos() == cur.lastpos())
|
if (cur.lastpos() == cur.lastpos())
|
||||||
return false;
|
return false;
|
||||||
cur.pos() = cur.lastpos();
|
cur.pos() = cur.lastpos();
|
||||||
@ -189,25 +199,35 @@ void MathNestInset::draw(PainterInfo &, int, int) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathNestInset::drawSelection(PainterInfo & pi,
|
void MathNestInset::drawSelection(PainterInfo & pi, int x, int y) const
|
||||||
idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const
|
|
||||||
{
|
{
|
||||||
if (idx1 == idx2) {
|
// this should use the x/y values given, not the cached values
|
||||||
MathArray const & c = cell(idx1);
|
LCursor & cur = pi.base.bv->cursor();
|
||||||
int x1 = c.xo() + c.pos2x(pos1);
|
if (!cur.selection())
|
||||||
|
return;
|
||||||
|
if (cur.inset() != this)
|
||||||
|
return;
|
||||||
|
CursorSlice & s1 = cur.selBegin();
|
||||||
|
CursorSlice & s2 = cur.selEnd();
|
||||||
|
if (s1.idx() == s2.idx()) {
|
||||||
|
MathArray const & c = s1.cell();
|
||||||
|
lyxerr << "###### c.xo(): " << c.xo() << " c.yo(): " << c.yo() << endl;
|
||||||
|
int x1 = c.xo() + c.pos2x(s1.pos());
|
||||||
int y1 = c.yo() - c.ascent();
|
int y1 = c.yo() - c.ascent();
|
||||||
int x2 = c.xo() + c.pos2x(pos2);
|
int x2 = c.xo() + c.pos2x(s2.pos());
|
||||||
int y2 = c.yo() + c.descent();
|
int y2 = c.yo() + c.descent();
|
||||||
pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
|
//pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
|
||||||
|
pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::red);
|
||||||
} else {
|
} else {
|
||||||
for (idx_type i = 0; i < nargs(); ++i) {
|
for (idx_type i = 0; i < nargs(); ++i) {
|
||||||
if (idxBetween(i, idx1, idx2)) {
|
if (idxBetween(i, s1.idx(), s2.idx())) {
|
||||||
MathArray const & c = cell(i);
|
MathArray const & c = cell(i);
|
||||||
int x1 = c.xo();
|
int x1 = c.xo();
|
||||||
int y1 = c.yo() - c.ascent();
|
int y1 = c.yo() - c.ascent();
|
||||||
int x2 = c.xo() + c.width();
|
int x2 = c.xo() + c.width();
|
||||||
int y2 = c.yo() + c.descent();
|
int y2 = c.yo() + c.descent();
|
||||||
pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
|
//pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
|
||||||
|
pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -779,7 +799,7 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
|
|
||||||
void MathNestInset::edit(LCursor & cur, int x, int y)
|
void MathNestInset::edit(LCursor & cur, int x, int y)
|
||||||
{
|
{
|
||||||
lyxerr << "Called MathHullInset::edit with '" << x << ' ' << y << "'" << endl;
|
lyxerr << "Called MathNestInset::edit with '" << x << ' ' << y << "'" << endl;
|
||||||
cur.push(this);
|
cur.push(this);
|
||||||
int idx_min = 0;
|
int idx_min = 0;
|
||||||
int dist_min = 1000000;
|
int dist_min = 1000000;
|
||||||
|
@ -31,8 +31,7 @@ public:
|
|||||||
/// draw background if locked
|
/// draw background if locked
|
||||||
void draw(PainterInfo & pi, int x, int y) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
/// draw selection background
|
/// draw selection background
|
||||||
void drawSelection(PainterInfo & pi,
|
void drawSelection(PainterInfo & pi, int x, int y) const;
|
||||||
idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
|
|
||||||
/// appends itself with macro arguments substituted
|
/// appends itself with macro arguments substituted
|
||||||
void substitute(MathMacro const & macro);
|
void substitute(MathMacro const & macro);
|
||||||
/// identifies NestInsets
|
/// identifies NestInsets
|
||||||
|
@ -444,13 +444,14 @@ void MathScriptInset::mathematica(MathematicaStream & os) const
|
|||||||
if (u)
|
if (u)
|
||||||
os << "^(" << up() << ')';
|
os << "^(" << up() << ')';
|
||||||
|
|
||||||
if (nuc().size())
|
if (nuc().size()) {
|
||||||
if (d)
|
if (d)
|
||||||
os << ',' << down() << ']';
|
os << ',' << down() << ']';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathScriptInset::mathmlize( MathMLStream & os) const
|
void MathScriptInset::mathmlize(MathMLStream & os) const
|
||||||
{
|
{
|
||||||
bool d = hasDown() && down().size();
|
bool d = hasDown() && down().size();
|
||||||
bool u = hasUp() && up().size();
|
bool u = hasUp() && up().size();
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
/// create inset with single script and given nucleus
|
/// create inset with single script and given nucleus
|
||||||
MathScriptInset(MathAtom const & at, bool up);
|
MathScriptInset(MathAtom const & at, bool up);
|
||||||
///
|
///
|
||||||
virtual std::auto_ptr<InsetBase> clone() const;
|
std::auto_ptr<InsetBase> clone() const;
|
||||||
///
|
///
|
||||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||||
///
|
///
|
||||||
@ -98,9 +98,7 @@ public:
|
|||||||
void infoize2(std::ostream & os) const;
|
void infoize2(std::ostream & os) const;
|
||||||
protected:
|
protected:
|
||||||
///
|
///
|
||||||
virtual
|
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||||
DispatchResult
|
|
||||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
|
||||||
private:
|
private:
|
||||||
/// returns x offset for main part
|
/// returns x offset for main part
|
||||||
int dxx() const;
|
int dxx() const;
|
||||||
|
@ -114,14 +114,14 @@ void MathTextInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
safepos = i;
|
safepos = i;
|
||||||
++spaces;
|
++spaces;
|
||||||
// restart chunk with size of the space
|
// restart chunk with size of the space
|
||||||
curr = cell(0)[i].width_;
|
curr = cell(0)[i]->width();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c != '\n') {
|
if (c != '\n') {
|
||||||
// This is a regular char. Go on if we either don't care for
|
// This is a regular char. Go on if we either don't care for
|
||||||
// the width limit or have not reached that limit.
|
// the width limit or have not reached that limit.
|
||||||
curr += cell(0)[i].width_;
|
curr += cell(0)[i]->width();
|
||||||
if (curr + safe <= mi.base.textwidth)
|
if (curr + safe <= mi.base.textwidth)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -187,8 +187,10 @@ void MathTextInset::draw(PainterInfo & pi, int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
void MathTextInset::drawSelection(PainterInfo & pi,
|
void MathTextInset::drawSelection(PainterInfo & pi,
|
||||||
idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const
|
idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const
|
||||||
{
|
{
|
||||||
cache_.drawSelection(pi, idx1, pos1, idx2, pos2);
|
cache_.drawSelection(pi, idx1, pos1, idx2, pos2);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
@ -30,8 +30,8 @@ public:
|
|||||||
/// draw according to cached metrics
|
/// draw according to cached metrics
|
||||||
void draw(PainterInfo &, int x, int y) const;
|
void draw(PainterInfo &, int x, int y) const;
|
||||||
/// draw selection background
|
/// draw selection background
|
||||||
void drawSelection(PainterInfo & pi,
|
//void drawSelection(PainterInfo & pi,
|
||||||
idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
|
// idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
|
||||||
/// moves cursor up or down
|
/// moves cursor up or down
|
||||||
//bool idxUpDown2(LCursor & pos, bool up) const;
|
//bool idxUpDown2(LCursor & pos, bool up) const;
|
||||||
protected:
|
protected:
|
||||||
|
@ -194,10 +194,11 @@ int RowPainter::leftMargin() const
|
|||||||
|
|
||||||
void RowPainter::paintInset(pos_type const pos)
|
void RowPainter::paintInset(pos_type const pos)
|
||||||
{
|
{
|
||||||
InsetBase * inset = const_cast<InsetBase *>(pit_->getInset(pos));
|
InsetBase const * inset = pit_->getInset(pos);
|
||||||
BOOST_ASSERT(inset);
|
BOOST_ASSERT(inset);
|
||||||
PainterInfo pi(const_cast<BufferView *>(&bv_));
|
PainterInfo pi(const_cast<BufferView *>(&bv_));
|
||||||
pi.base.font = getFont(pos);
|
pi.base.font = getFont(pos);
|
||||||
|
inset->drawSelection(pi, int(x_), yo_ + row_.baseline());
|
||||||
inset->draw(pi, int(x_), yo_ + row_.baseline());
|
inset->draw(pi, int(x_), yo_ + row_.baseline());
|
||||||
x_ += inset->width();
|
x_ += inset->width();
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ void recordUndo(Undo::undo_kind kind,
|
|||||||
ParIterator pit = text2pit(buf, text, textnum);
|
ParIterator pit = text2pit(buf, text, textnum);
|
||||||
stack.push(Undo(kind, textnum, pit.index(),
|
stack.push(Undo(kind, textnum, pit.index(),
|
||||||
first_par, end_par, text->cursor().par(), text->cursor().pos()));
|
first_par, end_par, text->cursor().par(), text->cursor().pos()));
|
||||||
lyxerr << "undo record: " << stack.top() << std::endl;
|
//lyxerr << "undo record: " << stack.top() << std::endl;
|
||||||
|
|
||||||
// record the relevant paragraphs
|
// record the relevant paragraphs
|
||||||
ParagraphList & undo_pars = stack.top().pars;
|
ParagraphList & undo_pars = stack.top().pars;
|
||||||
|
Loading…
Reference in New Issue
Block a user