mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 22:17:41 +00:00
Compare commits
2 Commits
6701a5d55c
...
629a692ce2
Author | SHA1 | Date | |
---|---|---|---|
|
629a692ce2 | ||
|
d19f4319dc |
@ -1197,8 +1197,7 @@ void Cursor::getSurroundingPos(pos_type & left_pos, pos_type & right_pos) const
|
|||||||
right_pos = -1;
|
right_pos = -1;
|
||||||
|
|
||||||
Row const & row = textRow();
|
Row const & row = textRow();
|
||||||
double dummy = 0;
|
Row::const_iterator cit = row.findElement(pos(), boundary());
|
||||||
Row::const_iterator cit = row.findElement(pos(), boundary(), dummy);
|
|
||||||
// Handle the case of empty row
|
// Handle the case of empty row
|
||||||
if (cit == row.end()) {
|
if (cit == row.end()) {
|
||||||
if (row.isRTL())
|
if (row.isRTL())
|
||||||
@ -2551,6 +2550,8 @@ void Cursor::checkBufferStructure()
|
|||||||
void Cursor::moveToClosestEdge(int const x, bool const edit)
|
void Cursor::moveToClosestEdge(int const x, bool const edit)
|
||||||
{
|
{
|
||||||
if (Inset const * inset = nextInset()) {
|
if (Inset const * inset = nextInset()) {
|
||||||
|
// This is only used in mathed.
|
||||||
|
LATTEST(inset->asInsetMath());
|
||||||
// stay in front of insets for which we want to open the dialog
|
// stay in front of insets for which we want to open the dialog
|
||||||
// (e.g. InsetMathSpace).
|
// (e.g. InsetMathSpace).
|
||||||
if (edit && (inset->hasSettings() || !inset->contextMenuName().empty()))
|
if (edit && (inset->hasSettings() || !inset->contextMenuName().empty()))
|
||||||
|
18
src/Row.cpp
18
src/Row.cpp
@ -753,8 +753,9 @@ void Row::reverseRTL()
|
|||||||
reverse(elements_.begin(), elements_.end());
|
reverse(elements_.begin(), elements_.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Row::const_iterator const
|
Row::const_iterator const
|
||||||
Row::findElement(pos_type const pos, bool const boundary, double & x) const
|
Row::findElementHelper(pos_type const pos, bool const boundary, double & x) const
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* When boundary is true, position i is in the row element (pos, endpos)
|
* When boundary is true, position i is in the row element (pos, endpos)
|
||||||
@ -803,4 +804,19 @@ Row::findElement(pos_type const pos, bool const boundary, double & x) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Row::const_iterator const Row::findElement(pos_type const pos, bool const boundary) const
|
||||||
|
{
|
||||||
|
double dummy;
|
||||||
|
return findElementHelper(pos, boundary, dummy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double Row::pos2x(pos_type const pos, bool const boundary) const
|
||||||
|
{
|
||||||
|
double x;
|
||||||
|
findElementHelper(pos, boundary, x);
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
11
src/Row.h
11
src/Row.h
@ -257,6 +257,10 @@ public:
|
|||||||
* adjusted to the actual pixel position.
|
* adjusted to the actual pixel position.
|
||||||
*/
|
*/
|
||||||
std::pair<pos_type, bool> x2pos(int & x) const;
|
std::pair<pos_type, bool> x2pos(int & x) const;
|
||||||
|
/** Return the pixel position that corresponds to the position and
|
||||||
|
* boundary.
|
||||||
|
*/
|
||||||
|
double pos2x(pos_type const pos, bool const boundary) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
void add(pos_type pos, Inset const * ins, Dimension const & dim,
|
void add(pos_type pos, Inset const * ins, Dimension const & dim,
|
||||||
@ -331,8 +335,8 @@ public:
|
|||||||
///
|
///
|
||||||
void needsChangeBar(bool ncb) { changebar_ = ncb; }
|
void needsChangeBar(bool ncb) { changebar_ = ncb; }
|
||||||
|
|
||||||
/// Find row element that contains \c pos, and compute x offset.
|
/// Find row element that contains \c pos.
|
||||||
const_iterator const findElement(pos_type pos, bool boundary, double & x) const;
|
const_iterator const findElement(pos_type pos, bool boundary) const;
|
||||||
|
|
||||||
friend std::ostream & operator<<(std::ostream & os, Row const & row);
|
friend std::ostream & operator<<(std::ostream & os, Row const & row);
|
||||||
|
|
||||||
@ -372,6 +376,9 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool sameString(Font const & f, Change const & ch) const;
|
bool sameString(Font const & f, Change const & ch) const;
|
||||||
|
|
||||||
|
/// Find row element that contains \c pos, and compute x offset.
|
||||||
|
const_iterator const findElementHelper(pos_type pos, bool boundary, double & x) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
Elements elements_;
|
Elements elements_;
|
||||||
|
|
||||||
|
@ -125,10 +125,9 @@ void RowPainter::paintInset(Row::Element const & e) const
|
|||||||
pi_.selected = pi_selected;
|
pi_.selected = pi_selected;
|
||||||
|
|
||||||
#ifdef DEBUG_METRICS
|
#ifdef DEBUG_METRICS
|
||||||
Dimension const & dim = pi_.base.bv->coordCache().insets().dim(e.inset);
|
int const x2 = x1 + e.dim.wid;
|
||||||
int const x2 = x1 + dim.wid;
|
int const y1 = yo_ + e.dim.des;
|
||||||
int const y1 = yo_ + dim.des;
|
int const y2 = yo_ - e.dim.asc;
|
||||||
int const y2 = yo_ - dim.asc;
|
|
||||||
pi_.pain.line(x1, y1, x1, y2, Color_green);
|
pi_.pain.line(x1, y1, x1, y2, Color_green);
|
||||||
pi_.pain.line(x1, y1, x2, y1, Color_green);
|
pi_.pain.line(x1, y1, x2, y1, Color_green);
|
||||||
pi_.pain.line(x2, y1, x2, y2, Color_green);
|
pi_.pain.line(x2, y1, x2, y2, Color_green);
|
||||||
|
@ -1691,12 +1691,7 @@ int TextMetrics::cursorX(CursorSlice const & sl,
|
|||||||
if (pm.rows().empty())
|
if (pm.rows().empty())
|
||||||
return 0;
|
return 0;
|
||||||
Row const & row = pm.getRow(sl.pos(), boundary);
|
Row const & row = pm.getRow(sl.pos(), boundary);
|
||||||
pos_type const pos = sl.pos();
|
return row.pos2x(sl.pos(), boundary);
|
||||||
|
|
||||||
double x = 0;
|
|
||||||
row.findElement(pos, boundary, x);
|
|
||||||
return int(x);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user