commit 0702580ce2532ca7fb2f79b6ae6f40f30bbabf8f
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Mon Apr 28 13:38:17 2025 +0200
Finish MathArray->MathData transition (1/4): rename CoordCache::arrays to
cells
This is a follow-up of to commit 31059d17 from 2007. At that time,
the class MathArray was renamed to MathData, but a lot of code was
kept, which is now confusing.
The first idea was to rename to CoodCache::mathData (or mathDatas),
but it did not sound right.
---
src/CoordCache.cpp | 2 +-
src/CoordCache.h | 8 ++++----
src/mathed/InsetMathGrid.cpp | 2 +-
src/mathed/InsetMathMacro.cpp | 4 ++--
src/mathed/InsetMathNest.cpp | 6 +++---
src/mathed/MathData.cpp | 20 ++++++++++----------
src/mathed/MathRow.cpp | 4 ++--
7 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/src/CoordCache.cpp b/src/CoordCache.cpp
index 316cd0959a..fa36091b02 100644
--- a/src/CoordCache.cpp
+++ b/src/CoordCache.cpp
@@ -28,7 +28,7 @@ void lyxbreaker(void const * data, const char * hint, int
size)
void CoordCache::clear()
{
- arrays_.clear();
+ cells_.clear();
insets_.clear();
}
diff --git a/src/CoordCache.h b/src/CoordCache.h
index 62ea34ec30..8893aebe48 100644
--- a/src/CoordCache.h
+++ b/src/CoordCache.h
@@ -199,9 +199,9 @@ public:
void clear();
/// A map from MathData to position on the screen
- typedef CoordCacheBase<MathData> Arrays;
- Arrays & arrays() { return arrays_; }
- Arrays const & arrays() const { return arrays_; }
+ typedef CoordCacheBase<MathData> Cells;
+ Cells & cells() { return cells_; }
+ Cells const & cells() const { return cells_; }
/// A map from insets to positions on the screen
typedef CoordCacheBase<Inset> Insets;
Insets & insets() { return insets_; }
@@ -212,7 +212,7 @@ public:
private:
/// MathDatas
- Arrays arrays_;
+ Cells cells_;
// All insets
Insets insets_;
};
diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index f48d1eeeb9..ff56df0f10 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -967,7 +967,7 @@ bool InsetMathGrid::idxUpDown(Cursor & cur, bool up) const
// FIXME: this is only a workaround to avoid a crash if the inset
// in not in coord cache. The best would be to force a FitCursor
// operation.
- CoordCache::Arrays const & arraysCache = cur.bv().coordCache().arrays();
+ CoordCache::Arrays const & arraysCache = cur.bv().coordCache().cells();
if (arraysCache.has(&cur.cell()))
cur.pos() = cur.cell().x2pos(&cur.bv(), cur.x_target() -
cur.cell().xo(cur.bv()));
else
diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index 30ddaac9a3..99193e44c7 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -782,7 +782,7 @@ void InsetMathMacro::draw(PainterInfo & pi, int x, int y)
const
// draw definition
d->definition_.draw(pi, x, y);
- Dimension const & defDim = coords.arrays().dim(&d->definition_);
+ Dimension const & defDim = coords.cells().dim(&d->definition_);
y += max(fontDim.des, defDim.des);
// draw parameters
@@ -792,7 +792,7 @@ void InsetMathMacro::draw(PainterInfo & pi, int x, int y)
const
for (idx_type i = 0; i < nargs(); ++i) {
// position of label
- Dimension const & cdim = coords.arrays().dim(&cell(i));
+ Dimension const & cdim = coords.cells().dim(&cell(i));
x = expx + 1;
y += max(fontDim.asc, cdim.asc) + 1;
diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 078723fcf4..249db56643 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -148,7 +148,7 @@ void InsetMathNest::cursorPos(BufferView const & bv,
LASSERT(&sl.inset() == this, return);
MathData const & ar = sl.cell();
CoordCache const & coord_cache = bv.coordCache();
- if (!coord_cache.arrays().has(&ar)) {
+ if (!coord_cache.cells().has(&ar)) {
// this can (semi-)legally happen if we just created this cell
// and it never has been drawn before. So don't ASSERT.
//lyxerr << "no cached data for array " << &ar << endl;
@@ -156,7 +156,7 @@ void InsetMathNest::cursorPos(BufferView const & bv,
y = 0;
return;
}
- Point const pt = coord_cache.arrays().xy(&ar);
+ Point const pt = coord_cache.cells().xy(&ar);
if (!coord_cache.insets().has(this)) {
// same as above
//lyxerr << "no cached data for inset " << this << endl;
@@ -174,7 +174,7 @@ void InsetMathNest::cursorPos(BufferView const & bv,
// << " ar.asc: " << ar.ascent() << " ar.des: " << ar.descent() <<
endl;
// move cursor visually into empty cells ("blue rectangles");
if (ar.empty() && bv.inputMethod()->preeditString().empty()) {
- Dimension const dim = coord_cache.arrays().dim(&ar);
+ Dimension const dim = coord_cache.cells().dim(&ar);
x += dim.wid / 3;
}
}
diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp
index 6f3faec86d..9a3bea4348 100644
--- a/src/mathed/MathData.cpp
+++ b/src/mathed/MathData.cpp
@@ -378,7 +378,7 @@ void MathData::metrics(MetricsInfo & mi, Dimension & dim,
bool tight) const
// Cache row and dimension.
bv->setMathRow(this, mrow);
- bv->coordCache().arrays().add(this, dim);
+ bv->coordCache().cells().add(this, dim);
}
@@ -396,7 +396,7 @@ void MathData::drawSelection(PainterInfo & pi, int const x,
int const y) const
if (s1.idx() == s2.idx() && &c1 == this) {
// selection inside cell
- Dimension const dim = bv->coordCache().arrays().dim(&c1);
+ Dimension const dim = bv->coordCache().cells().dim(&c1);
int const beg = c1.pos2x(bv, s1.pos());
int const end = c1.pos2x(bv, s2.pos());
pi.pain.fillRectangle(x + beg, y - dim.ascent(),
@@ -406,7 +406,7 @@ void MathData::drawSelection(PainterInfo & pi, int const x,
int const y) const
MathData const & c = inset->cell(i);
if (&c == this && inset->idxBetween(i, s1.idx(),
s2.idx())) {
// The whole cell is selected
- Dimension const dim =
bv->coordCache().arrays().dim(&c);
+ Dimension const dim =
bv->coordCache().cells().dim(&c);
pi.pain.fillRectangle(x, y - dim.ascent(),
dim.width(), dim.height(),
Color_selection);
@@ -984,26 +984,26 @@ MathData::size_type MathData::x2pos(BufferView const *
bv, int targetx) const
int MathData::dist(BufferView const & bv, int x, int y) const
{
- return bv.coordCache().arrays().squareDistance(this, x, y);
+ return bv.coordCache().cells().squareDistance(this, x, y);
}
void MathData::setXY(BufferView & bv, int x, int y) const
{
//lyxerr << "setting position cache for MathData " << this << endl;
- bv.coordCache().arrays().add(this, x, y);
+ bv.coordCache().cells().add(this, x, y);
}
Dimension const & MathData::dimension(BufferView const & bv) const
{
- return bv.coordCache().arrays().dim(this);
+ return bv.coordCache().cells().dim(this);
}
int MathData::xm(BufferView const & bv) const
{
- Geometry const & g = bv.coordCache().arrays().geometry(this);
+ Geometry const & g = bv.coordCache().cells().geometry(this);
return g.pos.x + g.dim.wid / 2;
}
@@ -1011,7 +1011,7 @@ int MathData::xm(BufferView const & bv) const
int MathData::ym(BufferView const & bv) const
{
- Geometry const & g = bv.coordCache().arrays().geometry(this);
+ Geometry const & g = bv.coordCache().cells().geometry(this);
return g.pos.y + (g.dim.des - g.dim.asc) / 2;
}
@@ -1019,13 +1019,13 @@ int MathData::ym(BufferView const & bv) const
int MathData::xo(BufferView const & bv) const
{
- return bv.coordCache().arrays().x(this);
+ return bv.coordCache().cells().x(this);
}
int MathData::yo(BufferView const & bv) const
{
- return bv.coordCache().arrays().y(this);
+ return bv.coordCache().cells().y(this);
}
diff --git a/src/mathed/MathRow.cpp b/src/mathed/MathRow.cpp
index 1327660061..fd01754f12 100644
--- a/src/mathed/MathRow.cpp
+++ b/src/mathed/MathRow.cpp
@@ -290,7 +290,7 @@ void MathRow::metrics(MetricsInfo & mi, Dimension & dim)
}
if (e.ar) {
LATTEST(dim_arrays.back().first == e.ar);
- coords.arrays().add(e.ar,
dim_arrays.back().second);
+ coords.cells().add(e.ar,
dim_arrays.back().second);
dim_arrays.pop_back();
}
break;
@@ -354,7 +354,7 @@ void MathRow::draw(PainterInfo & pi, int x, int const y)
const
}
case BEGIN:
if (e.ar) {
- coords.arrays().add(e.ar, x, y);
+ coords.cells().add(e.ar, x, y);
e.ar->drawSelection(pi, x, y);
}
if (e.inset) {
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs