+2005-07-06 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * cursor_slice.h, dociterator.h: add some documentation
+ * cursor_slice.h, dociterator.h (idxSave, idxLoad): remove
+
2005-07-06 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* text.C (leftMargin): do not add identation to display() style
idx_type idx() const { return idx_; }
/// return the cell this cursor is in
idx_type & idx() { return idx_; }
- /// Save current cursor idx as row, col
- void idxSave() { col_ = idx_ % ncols(); row_ = idx_ / ncols(); }
- /// update idx to correspond to row, col
- void idxLoad() { idx_ = col_ + ncols() * row_; }
/// return the last cell in this inset
idx_type lastidx() const { return nargs() - 1; }
/// return the offset of the paragraph this cursor is in
pos_type lastpos() const;
/// return the number of embedded cells
size_t nargs() const;
- /// return the number of columns
+ /*!
+ * \return the number of columns.
+ * This does only make sense in grid like insets.
+ */
size_t ncols() const;
- /// return the number of rows
+ /*!
+ * \return the number of rows.
+ * This does only make sense in grid like insets.
+ */
size_t nrows() const;
- /// return the grid row of the current cell
+ /*!
+ * \return the grid row of the current cell.
+ * This does only make sense in grid like insets.
+ */
row_type row() const;
- /// return the grid column of the current cell
+ /*!
+ * \return the grid column of the current cell.
+ * This does only make sense in grid like insets.
+ */
col_type col() const;
///
/// texted specific stuff
///
- /// see comment for the member
+ /// \sa boundary_
bool boundary() const { return boundary_; }
- /// see comment for the member
+ /// \sa boundary_
bool & boundary() { return boundary_; }
- ///
+ /// returns text corresponding to this position
LyXText * text();
- ///
+ /// returns text corresponding to this position
LyXText const * text() const;
- ///
+ /// returns the owning inset if it is an UpdatableInset, else 0
UpdatableInset * asUpdatableInset() const;
- ///
+ /// paragraph in this cell
Paragraph & paragraph();
- ///
+ /// paragraph in this cell
Paragraph const & paragraph() const;
///
///
/// returns cell corresponding to this position
MathArray & cell() const;
- ///
+ /// returns the owning inset if it is a MathInset, else 0
MathInset * asMathInset() const;
- ///
+ /// write some debug information to \p os
friend std::ostream & operator<<(std::ostream &, CursorSlice const &);
public:
/// pointer to 'owning' inset. This is some kind of cache.
InsetBase * inset_;
private:
- /// cell index of a position in this inset
+ /*!
+ * Cell index of a position in this inset.
+ * This is the primary cell information also for grid like insets,
+ * although we have the convenience functions row() and col() for
+ * those.
+ * This means that the corresponding idx_ of a cell in a given row
+ * and column changes every time the number of columns or number of
+ * rows changes. Normally the cursor should stay in the same cell,
+ * so these changes should typically be performed like the following:
+ * \code
+ * row_type const r = cur.row();
+ * col_type const c = cur.col();
+ * // change nrows() and/or ncols()
+ * cur.idx = index(r, c);
+ * \endcode
+ */
idx_type idx_;
- /// row position in inset
- row_type row_;
- /// column position in inset
- col_type col_;
/// paragraph in this cell (used by texted)
pit_type pit_;
- /// true of 'pit' was properly initialized
+ /// true if 'pit' was properly initialized
bool pit_valid_;
/// position in this cell
pos_type pos_;
/**
- * When the cursor position is i, is the cursor is after the i-th char
+ * When the cursor position is i, is the cursor after the i-th char
* or before the i+1-th char ? Normally, these two interpretations are
* equivalent, except when the fonts of the i-th and i+1-th char
* differ.
///
explicit DocIterator(InsetBase & inset);
+ /// access slice at position \p i
CursorSlice const & operator[](size_t i) const {
return slices_[i];
}
+ /// access slice at position \p i
CursorSlice & operator[](size_t i) {
return slices_[i];
}
/// is this iterator invalid?
bool operator!() const { return empty(); }
+ /// does this iterator have any content?
bool empty() const { return slices_.empty(); }
//
CursorSlice const & top() const { return slices_.back(); }
/// access to outermost slice
CursorSlice & bottom() { return slices_.front(); }
- /// access to outermost slicetip
+ /// access to outermost slice
CursorSlice const & bottom() const { return slices_.front(); }
/// how many nested insets do we have?
size_t depth() const { return slices_.size(); }
idx_type idx() const { return top().idx(); }
/// return the cell of the inset this cursor is in
idx_type & idx() { return top().idx(); }
- ///
- void idxSave() { top().idxSave(); }
- ///
- void idxLoad() { top().idxLoad(); }
/// return the last possible cell in this inset
idx_type lastidx() const;
/// return the paragraph this cursor is in
//
// text-specific part
//
- /// see comment for boundary_ below
+ /// \sa boundary_
bool boundary() const { return top().boundary(); }
- /// see comment for boundary_ below
+ /// \sa boundary_
bool & boundary() { return top().boundary(); }
/// the paragraph we're in
Paragraph & paragraph();
+2005-07-06 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * insettabular.C (tabularFeatures): adjust cursor after adding a column
+
2005-07-05 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* insetbranch.C (setButtonLabel): Make label prefix translatable.
case LyXTabular::APPEND_COLUMN:
// append the column into the tabular
tabular.appendColumn(bv.buffer()->params(), cur.idx());
+ cur.idx() = tabular.getCellNumber(row, column);
break;
case LyXTabular::DELETE_ROW:
+2005-07-06 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * math_gridinset.C (doDispatch): better fix for the assertion
2005-06-29 Martin Vermeer <martin.vermeer@hut.fi>
return false;
cur.idx() -= ncols();
} else {
- if (cur.idx() >= ncols() * (nrows() - 1))
+ if (cur.row() >= nrows())
return false;
cur.idx() += ncols();
}
else if (s == "copy-row") {
// Here (as later) we save the cursor col/row
// in order to restore it after operation.
- cur.idxSave();
+ row_type const r = cur.row();
+ col_type const c = cur.col();
for (int i = 0, n = extractInt(is); i < n; ++i)
copyRow(cur.row());
- cur.idxLoad();
- }
+ cur.idx() = index(r, c);
+ }
else if (s == "swap-row") {
swapRow(cur.row());
// Trick to suppress same-idx-means-different-cell
// assertion crash:
cur.pos() = 0;
- }
+ }
else if (s == "add-hline-above")
rowinfo_[cur.row()].lines_++;
else if (s == "add-hline-below")
rowinfo_[cur.row()].lines_--;
else if (s == "delete-hline-below")
rowinfo_[cur.row()+1].lines_--;
- else if (s == "append-column")
- for (int i = 0, n = extractInt(is); i < n; ++i) {
- cur.idxSave();
+ else if (s == "append-column") {
+ row_type const r = cur.row();
+ col_type const c = cur.col();
+ for (int i = 0, n = extractInt(is); i < n; ++i)
addCol(cur.col());
- cur.idxLoad();
- }
- else if (s == "delete-column")
- for (int i = 0, n = extractInt(is); i < n; ++i) {
- cur.idxSave();
+ cur.idx() = index(r, c);
+ }
+ else if (s == "delete-column") {
+ row_type const r = cur.row();
+ col_type const c = cur.col();
+ for (int i = 0, n = extractInt(is); i < n; ++i)
delCol(col(cur.idx()));
- cur.idxLoad();
- if (cur.idx() > nargs())
- cur.idx() -= ncols();
- }
+ cur.idx() = index(r, min(c, cur.ncols() - 1));
+ }
else if (s == "copy-column") {
- cur.idxSave();
+ row_type const r = cur.row();
+ col_type const c = cur.col();
copyCol(cur.col());
- cur.idxLoad();
- }
+ cur.idx() = index(r, c);
+ }
else if (s == "swap-column") {
swapCol(cur.col());
cur.pos() = 0; // trick, see above
- }
+ }
else if (s == "add-vline-left")
colinfo_[cur.col()].lines_++;
else if (s == "add-vline-right")