Yes, it makes sense to me. Make sure that the types were compatible though.
JMarc
Here is the patch.
Yuriy
From 03543d3beaee8002ee516e58bd9dc9cce087a49c Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.ska...@gmail.com>
Date: Sat, 21 Nov 2020 00:06:05 +0200
Subject: [PATCH 4/4] Move several common types to support/types.h
---
src/Buffer.cpp | 4 +--
src/Changes.h | 4 +--
src/CursorSlice.cpp | 4 +--
src/CursorSlice.h | 7 ------
src/CutAndPaste.cpp | 26 ++++++++++----------
src/CutAndPaste.h | 9 ++++---
src/DocIterator.cpp | 8 +++---
src/DocIterator.h | 8 ------
src/TexRow.h | 4 ---
src/Text2.cpp | 2 +-
src/frontends/qt/GuiTabular.cpp | 16 ++++++------
src/insets/Inset.cpp | 2 +-
src/insets/Inset.h | 12 ---------
src/insets/InsetTabular.cpp | 42 ++++++++++++++++----------------
src/insets/InsetTabular.h | 7 +-----
src/mathed/InsetMath.h | 3 ---
src/mathed/InsetMathBig.cpp | 2 +-
src/mathed/InsetMathCancelto.cpp | 2 +-
src/mathed/InsetMathFrac.cpp | 8 +++---
src/mathed/InsetMathGrid.cpp | 16 ++++++------
src/mathed/InsetMathMacro.cpp | 4 +--
src/mathed/InsetMathNest.cpp | 2 +-
src/mathed/InsetMathRoot.cpp | 2 +-
src/mathed/InsetMathScript.cpp | 2 +-
src/mathed/MathParser.cpp | 20 +++++++--------
src/support/types.h | 10 ++++++++
26 files changed, 99 insertions(+), 127 deletions(-)
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 00ca49e392..bed92bc210 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -3882,9 +3882,9 @@ void Buffer::updateMacroInstances(UpdateType utype) const
continue;
// update macro in all cells of the InsetMathNest
- DocIterator::idx_type n = minset->nargs();
+ idx_type n = minset->nargs();
MacroContext mc = MacroContext(this, it);
- for (DocIterator::idx_type i = 0; i < n; ++i) {
+ for (idx_type i = 0; i < n; ++i) {
MathData & data = minset->cell(i);
data.updateMacros(nullptr, mc, utype, 0);
}
diff --git a/src/Changes.h b/src/Changes.h
index 34e2eddbc6..4e7033fb60 100644
--- a/src/Changes.h
+++ b/src/Changes.h
@@ -102,11 +102,11 @@ public:
/// erase the entry at pos and adjust all range bounds past it
/// (assumes that a character was deleted at pos)
- void erase(lyx::pos_type pos);
+ void erase(pos_type pos);
/// insert a new entry at pos and adjust all range bounds past it
/// (assumes that a character was inserted at pos)
- void insert(Change const & change, lyx::pos_type pos);
+ void insert(Change const & change, pos_type pos);
///
diff --git a/src/CursorSlice.cpp b/src/CursorSlice.cpp
index 872a91110e..105df9685b 100644
--- a/src/CursorSlice.cpp
+++ b/src/CursorSlice.cpp
@@ -76,14 +76,14 @@ pit_type CursorSlice::lastpit() const
}
-CursorSlice::row_type CursorSlice::row() const
+row_type CursorSlice::row() const
{
LASSERT(inset_, return 0);
return inset_->row(idx_);
}
-CursorSlice::col_type CursorSlice::col() const
+col_type CursorSlice::col() const
{
LASSERT(inset_, return 0);
return inset_->col(idx_);
diff --git a/src/CursorSlice.h b/src/CursorSlice.h
index 9f91ade9e9..eb865de948 100644
--- a/src/CursorSlice.h
+++ b/src/CursorSlice.h
@@ -44,13 +44,6 @@ public:
friend class StableDocIterator;
//@}
- /// type for cell number in inset
- typedef size_t idx_type;
- /// type for row indices
- typedef size_t row_type;
- /// type for col indices
- typedef size_t col_type;
-
///
CursorSlice();
///
diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp
index ee3418dd65..a1c4de5b35 100644
--- a/src/CutAndPaste.cpp
+++ b/src/CutAndPaste.cpp
@@ -728,8 +728,8 @@ void copySelectionHelper(Buffer const & buf, Text const &
text,
namespace cap {
void region(CursorSlice const & i1, CursorSlice const & i2,
- Inset::row_type & r1, Inset::row_type & r2,
- Inset::col_type & c1, Inset::col_type & c2)
+ row_type & r1, row_type & r2,
+ col_type & c1, col_type & c2)
{
Inset const & p = i1.inset();
c1 = p.col(i1.idx());
@@ -1413,20 +1413,20 @@ void eraseSelection(Cursor & cur)
cur.pos() = cur.lastpos();
} else if (p->nrows() > 0 && p->ncols() > 0) {
// This is a grid, delete a nice square region
- Inset::row_type r1, r2;
- Inset::col_type c1, c2;
+ row_type r1, r2;
+ col_type c1, c2;
region(i1, i2, r1, r2, c1, c2);
- for (Inset::row_type row = r1; row <= r2; ++row)
- for (Inset::col_type col = c1; col <= c2; ++col)
+ for (row_type row = r1; row <= r2; ++row)
+ for (col_type col = c1; col <= c2; ++col)
p->cell(p->index(row, col)).clear();
// We've deleted the whole cell. Only pos 0 is valid.
cur.pos() = 0;
} else {
- Inset::idx_type idx1 = i1.idx();
- Inset::idx_type idx2 = i2.idx();
+ idx_type idx1 = i1.idx();
+ idx_type idx2 = i2.idx();
if (idx1 > idx2)
swap(idx1, idx2);
- for (Inset::idx_type idx = idx1 ; idx <= idx2; ++idx)
+ for (idx_type idx = idx1 ; idx <= idx2; ++idx)
p->cell(idx).clear();
// We've deleted the whole cell. Only pos 0 is valid.
cur.pos() = 0;
@@ -1485,16 +1485,16 @@ docstring grabSelection(CursorData const & cur)
}
}
- Inset::row_type r1, r2;
- Inset::col_type c1, c2;
+ row_type r1, r2;
+ col_type c1, c2;
region(i1, i2, r1, r2, c1, c2);
docstring data;
if (i1.inset().asInsetMath()) {
- for (Inset::row_type row = r1; row <= r2; ++row) {
+ for (row_type row = r1; row <= r2; ++row) {
if (row > r1)
data += "\\\\";
- for (Inset::col_type col = c1; col <= c2; ++col) {
+ for (col_type col = c1; col <= c2; ++col) {
if (col > c1)
data += '&';
data += asString(i1.asInsetMath()->
diff --git a/src/CutAndPaste.h b/src/CutAndPaste.h
index 09fe05215a..13c19a2276 100644
--- a/src/CutAndPaste.h
+++ b/src/CutAndPaste.h
@@ -17,8 +17,7 @@
#include "DocumentClassPtr.h"
#include "support/strfwd.h"
-
-#include "insets/Inset.h"
+#include "support/types.h"
#include "frontends/Clipboard.h"
@@ -27,7 +26,9 @@
namespace lyx {
+class Buffer;
class ErrorList;
+class Inset;
class InsetText;
class Cursor;
class CursorData;
@@ -156,8 +157,8 @@ void selDel(Cursor & cur);
void selClearOrDel(Cursor & cur);
/// Calculate rectangular region of cell between \c i1 and \c i2.
void region(CursorSlice const & i1, CursorSlice const & i2,
- Inset::row_type & r1, Inset::row_type & r2,
- Inset::col_type & c1, Inset::col_type & c2);
+ row_type & r1, row_type & r2,
+ col_type & c1, col_type & c2);
/** Tabular has its own paste stack for multiple cells
* but it needs to know whether there is a more recent
* ordinary paste. Therefore which one is newer.
diff --git a/src/DocIterator.cpp b/src/DocIterator.cpp
index 6eba5a792e..b49fc2e9ad 100644
--- a/src/DocIterator.cpp
+++ b/src/DocIterator.cpp
@@ -271,7 +271,7 @@ pos_type DocIterator::lastpos() const
}
-DocIterator::idx_type DocIterator::lastidx() const
+idx_type DocIterator::lastidx() const
{
return top().lastidx();
}
@@ -298,13 +298,13 @@ size_t DocIterator::nrows() const
}
-DocIterator::row_type DocIterator::row() const
+row_type DocIterator::row() const
{
return top().row();
}
-DocIterator::col_type DocIterator::col() const
+col_type DocIterator::col() const
{
return top().col();
}
@@ -723,7 +723,7 @@ void DocIterator::append(vector<CursorSlice> const & x)
}
-void DocIterator::append(DocIterator::idx_type idx, pos_type pos)
+void DocIterator::append(idx_type idx, pos_type pos)
{
slices_.push_back(CursorSlice());
top().idx() = idx;
diff --git a/src/DocIterator.h b/src/DocIterator.h
index 344445b149..ca687570f9 100644
--- a/src/DocIterator.h
+++ b/src/DocIterator.h
@@ -34,14 +34,6 @@ DocIterator doc_iterator_end(Buffer const * buf, Inset const
* inset = 0);
class DocIterator
{
-public:
- /// type for cell number in inset
- typedef CursorSlice::idx_type idx_type;
- /// type for row indices
- typedef CursorSlice::row_type row_type;
- /// type for col indices
- typedef CursorSlice::col_type col_type;
-
public:
///
DocIterator();
diff --git a/src/TexRow.h b/src/TexRow.h
index 2ca14d4c24..e40867d7b1 100644
--- a/src/TexRow.h
+++ b/src/TexRow.h
@@ -42,10 +42,6 @@ class DocIterator;
class docstring_list;
class FuncRequest;
-/// types for cells and math insets
-typedef void const * uid_type;
-typedef size_t idx_type;
-
/// Represents the correspondence between paragraphs and the generated
/// LaTeX file
diff --git a/src/Text2.cpp b/src/Text2.cpp
index cf687f9e09..7e30ecd7d0 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -145,7 +145,7 @@ void Text::setInsetFont(BufferView const & bv, pit_type pit,
Inset * const inset = pars_[pit].getInset(pos);
LASSERT(inset && inset->resetFontEdit(), return);
- CursorSlice::idx_type endidx = inset->nargs();
+ idx_type endidx = inset->nargs();
for (CursorSlice cs(*inset); cs.idx() != endidx; ++cs.idx()) {
Text * text = cs.text();
if (text) {
diff --git a/src/frontends/qt/GuiTabular.cpp b/src/frontends/qt/GuiTabular.cpp
index ce28491b34..d32bfa077b 100644
--- a/src/frontends/qt/GuiTabular.cpp
+++ b/src/frontends/qt/GuiTabular.cpp
@@ -825,8 +825,8 @@ void GuiTabular::paramsToDialog(Inset const * inset)
BufferView const * bv = guiApp->currentView()->currentBufferView();
size_t const cell = bv->cursor().idx();
- Tabular::row_type const row = tabular.cellRow(cell);
- Tabular::col_type const col = tabular.cellColumn(cell);
+ row_type const row = tabular.cellRow(cell);
+ col_type const col = tabular.cellColumn(cell);
tabularRowED->setText(QString::number(row + 1));
tabularColumnED->setText(QString::number(col + 1));
@@ -870,16 +870,16 @@ void GuiTabular::paramsToDialog(Inset const * inset)
CursorSlice const & beg = bv->cursor().selBegin();
CursorSlice const & end = bv->cursor().selEnd();
if (beg != end) {
- Tabular::col_type cs = tabular.cellColumn(beg.idx());
- Tabular::col_type ce = tabular.cellColumn(end.idx());
+ col_type cs = tabular.cellColumn(beg.idx());
+ col_type ce = tabular.cellColumn(end.idx());
if (cs > ce)
swap(cs, ce);
- Tabular::row_type rs = tabular.cellRow(beg.idx());
- Tabular::row_type re = tabular.cellRow(end.idx());
+ row_type rs = tabular.cellRow(beg.idx());
+ row_type re = tabular.cellRow(end.idx());
if (rs > re)
swap(rs, re);
- for (Tabular::row_type r = rs; r <= re; ++r)
- for (Tabular::col_type c = cs; c <= ce; ++c) {
+ for (row_type r = rs; r <= re; ++r)
+ for (col_type c = cs; c <= ce; ++c) {
idx_type const cc = tabular.cellIndex(r, c);
ltop = borderState(ltop, tabular.topLine(cc));
lbottom = borderState(lbottom,
tabular.bottomLine(cc));
diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp
index 91bcdec843..7fe114d4a1 100644
--- a/src/insets/Inset.cpp
+++ b/src/insets/Inset.cpp
@@ -445,7 +445,7 @@ Inset * Inset::editXY(Cursor &, int x, int y)
}
-Inset::idx_type Inset::index(row_type row, col_type col) const
+idx_type Inset::index(row_type row, col_type col) const
{
if (row != 0)
LYXERR0("illegal row: " << row);
diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index 2837c2438f..d7ce4f4ecc 100644
--- a/src/insets/Inset.h
+++ b/src/insets/Inset.h
@@ -93,18 +93,6 @@ public:
ENTRY_DIRECTION_RIGHT,
ENTRY_DIRECTION_LEFT
};
- ///
- typedef ptrdiff_t difference_type;
- /// short of anything else reasonable
- typedef size_t size_type;
- /// type for cell indices
- typedef size_t idx_type;
- /// type for cursor positions
- typedef ptrdiff_t pos_type;
- /// type for row numbers
- typedef size_t row_type;
- /// type for column numbers
- typedef size_t col_type;
/// virtual base class destructor
virtual ~Inset() {}
diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 35ebf38fe3..1237b57847 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -561,7 +561,7 @@ string const write_attribute(string const & name, int const
& i)
template <>
-string const write_attribute(string const & name, Tabular::idx_type const & i)
+string const write_attribute(string const & name, idx_type const & i)
{
// we write only true attribute values so we remove a bit of the
// file format bloat for tabulars.
@@ -1041,7 +1041,7 @@ void Tabular::updateIndexes()
}
-Tabular::idx_type Tabular::numberOfCellsInRow(row_type const row) const
+idx_type Tabular::numberOfCellsInRow(row_type const row) const
{
idx_type result = 0;
for (col_type c = 0; c < ncols(); ++c)
@@ -1649,7 +1649,7 @@ int Tabular::textVOffset(idx_type cell) const
}
-Tabular::idx_type Tabular::getFirstCellInRow(row_type row, bool const ct) const
+idx_type Tabular::getFirstCellInRow(row_type row, bool const ct) const
{
col_type c = 0;
idx_type const numcells = numberOfCellsInRow(row);
@@ -1665,7 +1665,7 @@ Tabular::idx_type Tabular::getFirstCellInRow(row_type
row, bool const ct) const
}
-Tabular::idx_type Tabular::getLastCellInRow(row_type row, bool const ct) const
+idx_type Tabular::getLastCellInRow(row_type row, bool const ct) const
{
col_type c = ncols() - 1;
// of course we check against 0 so we don't crash. but we have the same
@@ -1680,7 +1680,7 @@ Tabular::idx_type Tabular::getLastCellInRow(row_type row,
bool const ct) const
}
-Tabular::row_type Tabular::getFirstRow(bool const ct) const
+row_type Tabular::getFirstRow(bool const ct) const
{
row_type r = 0;
if (!ct)
@@ -1692,7 +1692,7 @@ Tabular::row_type Tabular::getFirstRow(bool const ct)
const
}
-Tabular::row_type Tabular::getLastRow(bool const ct) const
+row_type Tabular::getLastRow(bool const ct) const
{
row_type r = nrows() - 1;
if (!ct)
@@ -1704,7 +1704,7 @@ Tabular::row_type Tabular::getLastRow(bool const ct) const
}
-Tabular::row_type Tabular::cellRow(idx_type cell) const
+row_type Tabular::cellRow(idx_type cell) const
{
if (cell >= numberofcells)
return nrows() - 1;
@@ -1714,7 +1714,7 @@ Tabular::row_type Tabular::cellRow(idx_type cell) const
}
-Tabular::col_type Tabular::cellColumn(idx_type cell) const
+col_type Tabular::cellColumn(idx_type cell) const
{
if (cell >= numberofcells)
return ncols() - 1;
@@ -2005,7 +2005,7 @@ Tabular::CellData & Tabular::cellInfo(idx_type cell)
}
-Tabular::idx_type Tabular::setMultiColumn(Cursor & cur, idx_type cell,
idx_type number,
+idx_type Tabular::setMultiColumn(Cursor & cur, idx_type cell, idx_type number,
bool const right_border)
{
idx_type const col = cellColumn(cell);
@@ -2056,7 +2056,7 @@ bool Tabular::hasMultiRow(row_type r) const
return false;
}
-Tabular::idx_type Tabular::setMultiRow(Cursor & cur, idx_type cell, idx_type
number,
+idx_type Tabular::setMultiRow(Cursor & cur, idx_type cell, idx_type number,
bool const bottom_border,
LyXAlignment const halign)
{
@@ -2102,7 +2102,7 @@ Tabular::idx_type Tabular::setMultiRow(Cursor & cur,
idx_type cell, idx_type num
}
-Tabular::idx_type Tabular::columnSpan(idx_type cell) const
+idx_type Tabular::columnSpan(idx_type cell) const
{
row_type const row = cellRow(cell);
col_type const col = cellColumn(cell);
@@ -2114,7 +2114,7 @@ Tabular::idx_type Tabular::columnSpan(idx_type cell) const
}
-Tabular::idx_type Tabular::rowSpan(idx_type cell) const
+idx_type Tabular::rowSpan(idx_type cell) const
{
col_type const column = cellColumn(cell);
col_type row = cellRow(cell) + 1;
@@ -2194,7 +2194,7 @@ bool Tabular::isLastCell(idx_type cell) const
}
-Tabular::idx_type Tabular::cellAbove(idx_type cell) const
+idx_type Tabular::cellAbove(idx_type cell) const
{
if (cellRow(cell) == 0)
return cell;
@@ -2208,7 +2208,7 @@ Tabular::idx_type Tabular::cellAbove(idx_type cell) const
}
-Tabular::idx_type Tabular::cellBelow(idx_type cell) const
+idx_type Tabular::cellBelow(idx_type cell) const
{
row_type const nextrow = cellRow(cell) + rowSpan(cell);
if (nextrow < nrows())
@@ -2217,7 +2217,7 @@ Tabular::idx_type Tabular::cellBelow(idx_type cell) const
}
-Tabular::idx_type Tabular::cellIndex(row_type row, col_type column) const
+idx_type Tabular::cellIndex(row_type row, col_type column) const
{
LASSERT(column != npos && column < ncols(), column = 0);
LASSERT(row != npos && row < nrows(), row = 0);
@@ -2368,7 +2368,7 @@ bool Tabular::haveLTLastFoot(bool withcaptions) const
}
-Tabular::idx_type Tabular::setLTCaption(Cursor & cur, row_type row, bool what)
+idx_type Tabular::setLTCaption(Cursor & cur, row_type row, bool what)
{
idx_type i = getFirstCellInRow(row);
if (what) {
@@ -4366,8 +4366,8 @@ bool InsetTabular::insetAllowed(InsetCode code) const
bool InsetTabular::allowMultiPar() const
{
- for (Tabular::col_type c = 0; c < tabular.ncols(); ++c) {
- for (Tabular::row_type r = 0; r < tabular.nrows(); ++r) {
+ for (col_type c = 0; c < tabular.ncols(); ++c) {
+ for (row_type r = 0; r < tabular.nrows(); ++r) {
if (tabular.cellInset(r,c)->allowMultiPar())
return true;
}
@@ -6226,7 +6226,7 @@ void InsetTabular::setCursorFromCoordinates(Cursor & cur,
int x, int y) const
}
-InsetTabular::idx_type InsetTabular::getNearestCell(BufferView & bv, int x,
int y) const
+idx_type InsetTabular::getNearestCell(BufferView & bv, int x, int y) const
{
idx_type idx_min = 0;
int dist_min = numeric_limits<int>::max();
@@ -7661,8 +7661,8 @@ string InsetTabular::params2string(InsetTabular const &
inset)
void InsetTabular::setLayoutForHiddenCells(DocumentClass const & dc)
{
- for (Tabular::col_type c = 0; c < tabular.ncols(); ++c) {
- for (Tabular::row_type r = 0; r < tabular.nrows(); ++r) {
+ for (col_type c = 0; c < tabular.ncols(); ++c) {
+ for (row_type r = 0; r < tabular.nrows(); ++r) {
if (!tabular.isPartOfMultiColumn(r,c) &&
!tabular.isPartOfMultiRow(r,c))
continue;
diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h
index cbd29eab47..6cfe03c14f 100644
--- a/src/insets/InsetTabular.h
+++ b/src/insets/InsetTabular.h
@@ -27,6 +27,7 @@
#include "InsetText.h"
#include "support/Length.h"
+#include "support/types.h"
#include <climits>
#include <iosfwd>
@@ -419,12 +420,6 @@ public:
bool empty;
};
- /// type for row numbers
- typedef size_t row_type;
- /// type for column numbers
- typedef size_t col_type;
- /// type for cell indices
- typedef size_t idx_type;
/// index indicating an invalid position
static const idx_type npos = static_cast<idx_type>(-1);
diff --git a/src/mathed/InsetMath.h b/src/mathed/InsetMath.h
index 3eae9295a4..9a970c5839 100644
--- a/src/mathed/InsetMath.h
+++ b/src/mathed/InsetMath.h
@@ -106,9 +106,6 @@ class TextPainter;
class TextMetricsInfo;
class ReplaceData;
-/// Type of unique identifiers for math insets (used in TexRow)
-typedef void const * uid_type;
-
class InsetMath : public Inset {
public:
diff --git a/src/mathed/InsetMathBig.cpp b/src/mathed/InsetMathBig.cpp
index aeb1ee5f8c..265e159bf2 100644
--- a/src/mathed/InsetMathBig.cpp
+++ b/src/mathed/InsetMathBig.cpp
@@ -64,7 +64,7 @@ Inset * InsetMathBig::clone() const
}
-InsetMathBig::size_type InsetMathBig::size() const
+size_type InsetMathBig::size() const
{
// order: big Big bigg Bigg biggg Biggg
// 0 1 2 3 4 5
diff --git a/src/mathed/InsetMathCancelto.cpp b/src/mathed/InsetMathCancelto.cpp
index cf6b006d44..b6e7ed0686 100644
--- a/src/mathed/InsetMathCancelto.cpp
+++ b/src/mathed/InsetMathCancelto.cpp
@@ -102,7 +102,7 @@ void InsetMathCancelto::normalize(NormalStream & os) const
bool InsetMathCancelto::idxUpDown(Cursor & cur, bool up) const
{
- Cursor::idx_type const target = up ? 1 : 0;
+ idx_type const target = up ? 1 : 0;
if (cur.idx() == target)
return false;
cur.idx() = target;
diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp
index 4870743b48..8a79214021 100644
--- a/src/mathed/InsetMathFrac.cpp
+++ b/src/mathed/InsetMathFrac.cpp
@@ -50,7 +50,7 @@ bool InsetMathFracBase::idxUpDown(Cursor & cur, bool up) const
{
// If we only have one cell, target = 0, otherwise
// target = up ? 0 : 1, since upper cell has idx 0
- InsetMath::idx_type target = nargs() > 1 ? !up : 0;
+ idx_type target = nargs() > 1 ? !up : 0;
if (cur.idx() == target)
return false;
cur.idx() = target;
@@ -67,7 +67,7 @@ bool InsetMathFracBase::idxUpDown(Cursor & cur, bool up) const
/////////////////////////////////////////////////////////////////////
-InsetMathFrac::InsetMathFrac(Buffer * buf, Kind kind, InsetMath::idx_type
ncells)
+InsetMathFrac::InsetMathFrac(Buffer * buf, Kind kind, idx_type ncells)
: InsetMathFracBase(buf, ncells), kind_(kind)
{}
@@ -92,7 +92,7 @@ InsetMathFrac const * InsetMathFrac::asFracInset() const
bool InsetMathFrac::idxForward(Cursor & cur) const
{
- InsetMath::idx_type target = 0;
+ idx_type target = 0;
if (kind_ == UNIT || (kind_ == UNITFRAC && nargs() == 3)) {
if (nargs() == 3)
target = 0;
@@ -110,7 +110,7 @@ bool InsetMathFrac::idxForward(Cursor & cur) const
bool InsetMathFrac::idxBackward(Cursor & cur) const
{
- InsetMath::idx_type target = 0;
+ idx_type target = 0;
if (kind_ == UNIT || (kind_ == UNITFRAC && nargs() == 3)) {
if (nargs() == 3)
target = 2;
diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index 783e374f62..ba3bda6d95 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -158,7 +158,7 @@ Inset * InsetMathGrid::clone() const
}
-InsetMath::idx_type InsetMathGrid::index(row_type row, col_type col) const
+idx_type InsetMathGrid::index(row_type row, col_type col) const
{
return col + ncols() * row;
}
@@ -278,7 +278,7 @@ void InsetMathGrid::setHorizontalAlignments(docstring const
& hh)
}
-InsetMathGrid::col_type InsetMathGrid::guessColumns(docstring const & hh)
+col_type InsetMathGrid::guessColumns(docstring const & hh)
{
col_type col = 0;
for (char_type const c : hh)
@@ -339,31 +339,31 @@ char InsetMathGrid::verticalAlignment() const
}
-InsetMathGrid::col_type InsetMathGrid::ncols() const
+col_type InsetMathGrid::ncols() const
{
return colinfo_.size() - 1;
}
-InsetMathGrid::row_type InsetMathGrid::nrows() const
+row_type InsetMathGrid::nrows() const
{
return rowinfo_.size() - 1;
}
-InsetMathGrid::col_type InsetMathGrid::col(idx_type idx) const
+col_type InsetMathGrid::col(idx_type idx) const
{
return idx % ncols();
}
-InsetMathGrid::row_type InsetMathGrid::row(idx_type idx) const
+row_type InsetMathGrid::row(idx_type idx) const
{
return idx / ncols();
}
-InsetMathGrid::col_type InsetMathGrid::ncellcols(idx_type idx) const
+col_type InsetMathGrid::ncellcols(idx_type idx) const
{
col_type cols = 1;
if (cellinfo_[idx].multi == CELL_NORMAL)
@@ -1647,7 +1647,7 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest
& cmd)
}
}
// append columns for the left over horizontal
cells
- for (InsetMath::col_type c = numcols; c <
grid.ncols(); ++c) {
+ for (col_type c = numcols; c < grid.ncols();
++c) {
addCol(c + startcol);
idx_type i = index(r + startrow, min(c
+ startcol, ncols() - 1));
cell(i).append(grid.cell(grid.index(r,
c)));
diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index 2ecef18a52..881a3c8194 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -1000,7 +1000,7 @@ Inset * InsetMathMacro::editXY(Cursor & cur, int x, int y)
}
-void InsetMathMacro::removeArgument(Inset::pos_type pos) {
+void InsetMathMacro::removeArgument(pos_type pos) {
if (d->displayMode_ == DISPLAY_NORMAL) {
LASSERT(size_t(pos) < cells_.size(), return);
cells_.erase(cells_.begin() + pos);
@@ -1015,7 +1015,7 @@ void InsetMathMacro::removeArgument(Inset::pos_type pos) {
}
-void InsetMathMacro::insertArgument(Inset::pos_type pos) {
+void InsetMathMacro::insertArgument(pos_type pos) {
if (d->displayMode_ == DISPLAY_NORMAL) {
LASSERT(size_t(pos) <= cells_.size(), return);
cells_.insert(cells_.begin() + pos, MathData());
diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 95fba5395f..c085439017 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -122,7 +122,7 @@ void InsetMathNest::setBuffer(Buffer & buffer)
}
-InsetMath::idx_type InsetMathNest::nargs() const
+idx_type InsetMathNest::nargs() const
{
return cells_.size();
}
diff --git a/src/mathed/InsetMathRoot.cpp b/src/mathed/InsetMathRoot.cpp
index b4420e98e2..9e7253668f 100644
--- a/src/mathed/InsetMathRoot.cpp
+++ b/src/mathed/InsetMathRoot.cpp
@@ -154,7 +154,7 @@ void InsetMathRoot::normalize(NormalStream & os) const
bool InsetMathRoot::idxUpDown(Cursor & cur, bool up) const
{
- Cursor::idx_type const target = up; //up ? 1 : 0;
+ idx_type const target = up; //up ? 1 : 0;
if (cur.idx() == target)
return false;
cur.idx() = target;
diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp
index e40db4f164..d88025b0b5 100644
--- a/src/mathed/InsetMathScript.cpp
+++ b/src/mathed/InsetMathScript.cpp
@@ -421,7 +421,7 @@ bool InsetMathScript::hasDown() const
}
-Inset::idx_type InsetMathScript::idxOfScript(bool up) const
+idx_type InsetMathScript::idxOfScript(bool up) const
{
if (nargs() == 1)
return 0;
diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp
index 332d2a1454..dd43dd9eac 100644
--- a/src/mathed/MathParser.cpp
+++ b/src/mathed/MathParser.cpp
@@ -160,7 +160,7 @@ docstring escapeSpecialChars(docstring const & str, bool
textmode)
* \returns whether the row could be added. Adding a row can fail for
* environments like "equation" that have a fixed number of rows.
*/
-bool addRow(InsetMathGrid & grid, InsetMathGrid::row_type & cellrow,
+bool addRow(InsetMathGrid & grid, row_type & cellrow,
docstring const & vskip, bool allow_newpage = true)
{
++cellrow;
@@ -195,7 +195,7 @@ bool addRow(InsetMathGrid & grid, InsetMathGrid::row_type &
cellrow,
* \returns whether the column could be added. Adding a column can fail for
* environments like "eqnarray" that have a fixed number of columns.
*/
-bool addCol(InsetMathGrid & grid, InsetMathGrid::col_type & cellcol)
+bool addCol(InsetMathGrid & grid, col_type & cellcol)
{
++cellcol;
if (cellcol == grid.ncols()) {
@@ -236,9 +236,9 @@ bool addCol(InsetMathGrid & grid, InsetMathGrid::col_type &
cellcol)
*/
void delEmptyLastRow(InsetMathGrid & grid)
{
- InsetMathGrid::row_type const row = grid.nrows() - 1;
- for (InsetMathGrid::col_type col = 0; col < grid.ncols(); ++col) {
- InsetMathGrid::idx_type const idx = grid.index(row, col);
+ row_type const row = grid.nrows() - 1;
+ for (col_type col = 0; col < grid.ncols(); ++col) {
+ idx_type const idx = grid.index(row, col);
if (!grid.cell(idx).empty() ||
grid.cellinfo(idx).multi != InsetMathGrid::CELL_NORMAL)
return;
@@ -796,8 +796,8 @@ void Parser::parse2(MathAtom & at, const unsigned flags,
const mode_type mode,
bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
const mode_type mode, const bool numbered)
{
- InsetMathGrid::row_type cellrow = 0;
- InsetMathGrid::col_type cellcol = 0;
+ row_type cellrow = 0;
+ col_type cellcol = 0;
MathData * cell = &grid.cell(grid.index(cellrow, cellcol));
Buffer * buf = buffer_;
@@ -2035,7 +2035,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
else {
MathAtom at = createInsetMath(t.cs(),
buf);
- for (InsetMath::idx_type i = 0; i <
at->nargs(); ++i)
+ for (idx_type i = 0; i < at->nargs();
++i)
parse(at.nucleus()->cell(i),
FLAG_ITEM, asMode(mode,
l->extra));
cell->push_back(at);
@@ -2107,7 +2107,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
if (at->currentMode() !=
InsetMath::UNDECIDED_MODE)
m = at->currentMode();
//lyxerr << "default creation: m2: " <<
m << endl;
- InsetMath::idx_type start = 0;
+ idx_type start = 0;
// this fails on \bigg[...\bigg]
//MathData opt;
//parse(opt, FLAG_OPTION,
InsetMath::VERBATIM_MODE);
@@ -2115,7 +2115,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
// start = 1;
// at.nucleus()->cell(0) = opt;
//}
- for (InsetMath::idx_type i = start; i <
at->nargs(); ++i) {
+ for (idx_type i = start; i <
at->nargs(); ++i) {
parse(at.nucleus()->cell(i),
FLAG_ITEM, m);
if (mode ==
InsetMath::MATH_MODE)
skipSpaces();
diff --git a/src/support/types.h b/src/support/types.h
index d8b1bc2b21..99f53c8f1b 100644
--- a/src/support/types.h
+++ b/src/support/types.h
@@ -45,6 +45,16 @@ namespace lyx {
/// a type for the nesting depth of a paragraph
typedef size_t depth_type;
+ /// type for cell indices in inset
+ typedef size_t idx_type;
+ /// type for row indices
+ typedef size_t row_type;
+ /// type for col indices
+ typedef size_t col_type;
+
+ /// type for cells and math insets
+ typedef void const * uid_type;
+
// set this to '0' if you want to have really safe types
#if 1
--
2.28.0.windows.1
--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel