mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Move several common types to support/types.h
This commit is contained in:
parent
4b15d64f51
commit
6a21ec854b
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
///
|
||||
|
||||
|
@ -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_);
|
||||
|
@ -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();
|
||||
///
|
||||
|
@ -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()->
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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() {}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)));
|
||||
|
@ -1004,7 +1004,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);
|
||||
@ -1019,7 +1019,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());
|
||||
|
@ -126,7 +126,7 @@ void InsetMathNest::setBuffer(Buffer & buffer)
|
||||
}
|
||||
|
||||
|
||||
InsetMath::idx_type InsetMathNest::nargs() const
|
||||
idx_type InsetMathNest::nargs() const
|
||||
{
|
||||
return cells_.size();
|
||||
}
|
||||
|
@ -147,7 +147,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;
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user