commit d94fedf6da26489bc05294d69b8acd3625d7fdb2
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Wed Jun 4 15:22:23 2025 +0200
Use isActive() instead of counting number of cells
For now this is the same, but it may change. And it is better in terms
of semantics.
---
src/Cursor.cpp | 2 +-
src/mathed/InsetMath.cpp | 2 +-
src/mathed/InsetMathMacro.cpp | 5 +++--
src/mathed/InsetMathNest.cpp | 5 +++--
src/mathed/InsetMathNest.h | 2 +-
src/mathed/MathData.cpp | 2 +-
6 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index 10dc27726c..f190cf0027 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -1807,7 +1807,7 @@ bool Cursor::macroModeClose(bool cancel)
}
// insert remembered selection into first argument of a non-macro
- else if (atomAsNest && atomAsNest->nargs() > 0)
+ else if (atomAsNest && atomAsNest->isActive())
atomAsNest->cell(atomAsNest->firstIdx()).append(selection);
MathWordList const & words = mathedWordList();
diff --git a/src/mathed/InsetMath.cpp b/src/mathed/InsetMath.cpp
index 681602f30c..30f97cd8d0 100644
--- a/src/mathed/InsetMath.cpp
+++ b/src/mathed/InsetMath.cpp
@@ -94,7 +94,7 @@ MathData const & InsetMath::cell(idx_type) const
marker_type InsetMath::marker(BufferView const *) const
{
- return nargs() > 0 ? marker_type::MARKER : marker_type::NO_MARKER;
+ return isActive() ? marker_type::MARKER : marker_type::NO_MARKER;
}
diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index b8665e7068..b3ebf8458c 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -552,7 +552,7 @@ bool InsetMathMacro::editMetrics(BufferView const * bv)
const
marker_type InsetMathMacro::marker(BufferView const * bv) const
{
- if (nargs() == 0)
+ if (!isActive())
return marker_type::NO_MARKER;
switch (d->displayMode_) {
@@ -1010,7 +1010,8 @@ void InsetMathMacro::edit(Cursor & cur, bool front,
EntryDirection entry_from)
Inset * InsetMathMacro::editXY(Cursor & cur, int x, int y)
{
// We may have 0 arguments, but InsetMathNest requires at least one.
- if (nargs() > 0) {
+ if (isActive()) {
+ // FIXME: do we need this? Otherwise the method could go
cur.screenUpdateFlags(Update::SinglePar);
return InsetMathNest::editXY(cur, x, y);
} else
diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index d508822d8d..9b5e0e8b56 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -232,7 +232,7 @@ bool InsetMathNest::idxBackward(Cursor & cur) const
bool InsetMathNest::idxFirst(Cursor & cur) const
{
LASSERT(&cur.inset() == this, return false);
- if (nargs() == 0)
+ if (!isActive())
return false;
cur.idx() = firstIdx();
cur.pos() = 0;
@@ -243,7 +243,7 @@ bool InsetMathNest::idxFirst(Cursor & cur) const
bool InsetMathNest::idxLast(Cursor & cur) const
{
LASSERT(&cur.inset() == this, return false);
- if (nargs() == 0)
+ if (!isActive())
return false;
cur.idx() = lastIdx();
cur.pos() = cur.lastpos();
@@ -337,6 +337,7 @@ void InsetMathNest::write(TeXMathStream & os) const
Changer dummy = os.changeRowEntry(TexRow::mathEntry(id(),i));
os << '{' << cell(i) << '}';
}
+ // FIXME: can this ever happen?
if (nargs() == 0)
os.pendingSpace(true);
if (lock_ && !os.latex()) {
diff --git a/src/mathed/InsetMathNest.h b/src/mathed/InsetMathNest.h
index 42eb6e6067..b1a28d32b8 100644
--- a/src/mathed/InsetMathNest.h
+++ b/src/mathed/InsetMathNest.h
@@ -135,7 +135,7 @@ public:
InsetCode lyxCode() const override { return MATH_NEST_CODE; }
///
- bool confirmDeletion() const override { return nargs() > 0; }
+ bool confirmDeletion() const override { return isActive(); }
/// interpret \p c and insert the result at the current position of
/// of \p cur. Return whether the cursor should stay in the formula.
bool interpretChar(Cursor & cur, char_type c);
diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp
index 2724c8cd31..763b7e238f 100644
--- a/src/mathed/MathData.cpp
+++ b/src/mathed/MathData.cpp
@@ -392,7 +392,7 @@ void MathData::drawSelection(PainterInfo & pi, int const x,
int const y) const
BufferView const * bv = pi.base.bv;
Cursor const & cur = bv->cursor();
InsetMath const * inset = cur.inset().asInsetMath();
- if (!cur.selection() || !inset || inset->nargs() == 0)
+ if (!cur.selection() || !inset || !inset->isActive())
return;
CursorSlice const s1 = cur.selBegin();
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs