bool BufferView::removeAutoInsets()
{
// keep track of which pos and par the cursor was on
- Paragraph * cursor_par = text->cursor.par();
+ Paragraph * cursor_par = &*text->cursor.par();
Paragraph * cursor_par_prev = cursor_par ? cursor_par->previous() : 0;
Paragraph * cursor_par_next = cursor_par ? cursor_par->next() : 0;
pos_type cursor_pos = text->cursor.pos();
if (!theLockingInset()) {
// first check if it's the inset under the cursor we want lock
// should be most of the time
- if (text->cursor.pos() < text->cursor.par()->size()
+ if (text->cursor.pos() < text->cursor.par()->size()
&& text->cursor.par()->getChar(text->cursor.pos()) ==
Paragraph::META_INSET) {
Inset * in = text->cursor.par()->getInset(text->cursor.pos());
if (kind == Undo::EDIT) // in this case insets would not be stored!
kind = Undo::FINISH;
setUndo(this, kind,
- text->cursor.par(),
+ &*text->cursor.par(),
text->cursor.par()->next());
}
owner_->message(_("Formatting document..."));
if (bv_->text) {
- par = bv_->text->cursor.par();
+ par = &*bv_->text->cursor.par();
pos = bv_->text->cursor.pos();
- selstartpar = bv_->text->selection.start.par();
+ selstartpar = &*bv_->text->selection.start.par();
selstartpos = bv_->text->selection.start.pos();
- selendpar = bv_->text->selection.end.par();
+ selendpar = &*bv_->text->selection.end.par();
selendpos = bv_->text->selection.end.pos();
selection = bv_->text->selection.set();
mark_set = bv_->text->selection.mark();
break;
case LFUN_LAYOUT_PARAGRAPH: {
- Paragraph const * par = bv_->getLyXText()->cursor.par();
+ Paragraph const * par = &*bv_->getLyXText()->cursor.par();
if (!par)
break;
}
case LFUN_PARAGRAPH_UPDATE: {
- Paragraph const * par = bv_->getLyXText()->cursor.par();
+ Paragraph const * par = &*bv_->getLyXText()->cursor.par();
if (!par)
break;
+2003-04-09 Lars Gullik Bjønnes <larsbj@gullik.net>
+
+ * undo_funcs.C (setCursorParUndo): adjust
+
+ * text_funcs.C (transposeChars): adjust
+
+ * text3.C (gotoNextInset): adjust
+ (dispatch): adjust
+
+ * text2.C (setLayout): adjust
+ (changeDepth): adjust
+ (setFont): adjust
+ (redoParagraphs): adjust
+ (selectionAsString): adjust
+ (setParagraph): adjust
+ (insertInset): adjust
+ (cutSelection): adjust
+ (copySelection): adjust
+ (pasteSelection): adjust
+ (insertStringAsLines): adjust
+ (updateInset): adjust
+ (setCursor): change to take a ParagraphList::iterator parameter
+ (setCursorIntern): change to take a ParagraphList::iterator parameter
+ (setCurrentFont): adjust
+ (cursorLeft): adjust
+ (cursorRight): adjust
+ (deleteEmptyParagraphMechanism): adjust
+
+ * text.C (breakParagraph): adjust
+ (insertChar): adjust
+ (acceptChange): adjust
+ (rejectChange): adjust
+ (selectNextWordToSpellcheck): adjust
+ (changeCase): adjust
+ (Delete): adjust
+ (backspace): adjust
+
+ * lyxfind.C (SearchForward): adjust
+ (SearchBackward): adjust
+ (nextChange): adjust
+
+ * lyxcursor.C (par): adjust
+
+ * lyxcursor.h: store a ParagraphList::iterator instead of a
+ Paragraph*
+
+ * lyx_cb.C (getPossibleLabel): adjust
+
+ * bufferview_funcs.C (toggleAndShow): adjust
+
+ * BufferView_pimpl.C (resizeCurrentBuffer): adjust
+ (dispatch): adjust
+
+ * BufferView.C (removeAutoInsets): adjust
+ (lockedInsetStoreUndo): adjust
+
2003-04-09 John Levon <levon@movementarian.org>
* ToolbarBackend.C: try icon without argument
* text2.C (changeDepth): do not setUndo on test_only (make undo work
again)
-
+
2003-04-05 Alfredo Braunstein <abraunst@libero.it>
* lyxfind.C (searchForward, searchBackwards): bug 782
* lyxrow.h: store a ParagraphList::iterator instead of a
Paragraph* and adjust other class functions to suit.
-
+
* lyxrow_funcs.C, text.C, text2.C, text3.C: adjust because of the
above.
-
+
2003-04-01 Alfredo Braunstein <abraunst@libero.it>
* text2.C (setCursor): do not anchor to cursor row for the time being
LyXCursor & cursor = text->cursor;
text->computeBidiTables(bv->buffer(), cursor.row());
if (cursor.boundary() !=
- text->isBoundary(bv->buffer(), cursor.par(), cursor.pos(),
+ text->isBoundary(bv->buffer(), &*cursor.par(), cursor.pos(),
text->real_current_font))
text->setCursor(cursor.par(), cursor.pos(),
false, !cursor.boundary());
+2003-04-09 Lars Gullik Bjønnes <larsbj@gullik.net>
+
+ * insettext.C (saveLyXTextState): adjust
+ (localDispatch): adjust
+ (setFont): adjust
+ (cx): adjust
+ (cix): adjust
+ (cpar): adjust
+
+ * insettabular.C (localDispatch): adjust
+ (setFont): adjust
+ (tabularFeatures): adjust
+
2003-04-05 Alfredo Braunstein <abraunst@libero.it>
-
+
* insettabular.C (searchForward,searchBackward): fix bug 782
2003-04-07 John Levon <levon@movementarian.org>
// no break here!
case LFUN_DELETE:
setUndo(bv, Undo::DELETE,
- bv->text->cursor.par(),
- bv->text->cursor.par()->next());
+ &*bv->text->cursor.par(),
+ &*boost::next(bv->text->cursor.par()));
cutSelection(bv->buffer()->params);
updateLocal(bv, INIT);
break;
case LFUN_PASTE:
if (hasPasteBuffer()) {
setUndo(bv, Undo::INSERT,
- bv->text->cursor.par(),
- bv->text->cursor.par()->next());
+ &*bv->text->cursor.par(),
+ &*boost::next(bv->text->cursor.par()));
pasteSelection(bv);
updateLocal(bv, INIT);
break;
}
if (hasSelection()) {
setUndo(bv, Undo::EDIT,
- bv->text->cursor.par(),
- bv->text->cursor.par()->next());
+ &*bv->text->cursor.par(),
+ &*boost::next(bv->text->cursor.par()));
bool const frozen = undo_frozen;
if (!frozen)
freezeUndo();
sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
}
setUndo(bv, Undo::FINISH,
- bv->text->cursor.par(),
- bv->text->cursor.par()->next());
+ &*bv->text->cursor.par(),
+ &*boost::next(bv->text->cursor.par()));
int row = tabular->row_of_cell(actcell);
int column = tabular->column_of_cell(actcell);
}
if (it != end && t->cursor.pos() <= it->size()) {
- sstate.lpar = t->cursor.par();
+ sstate.lpar = &*t->cursor.par();
sstate.pos = t->cursor.pos();
sstate.boundary = t->cursor.boundary();
- sstate.selstartpar = t->selection.start.par();
+ sstate.selstartpar = &*t->selection.start.par();
sstate.selstartpos = t->selection.start.pos();
sstate.selstartboundary = t->selection.start.boundary();
- sstate.selendpar = t->selection.end.par();
+ sstate.selendpar = &*t->selection.end.par();
sstate.selendpos = t->selection.end.pos();
sstate.selendboundary = t->selection.end.boundary();
sstate.selection = t->selection.set();
// inherit bufferparams/paragraphparams in a strange way. (Lgb)
// FIXME: how old is this comment ? ...
{
- Paragraph * par = lt->cursor.par();
- Spacing::Space cur_spacing = par->params().spacing().getSpace();
+ ParagraphList::iterator pit = lt->cursor.par();
+ Spacing::Space cur_spacing = pit->params().spacing().getSpace();
float cur_value = 1.0;
if (cur_spacing == Spacing::Other) {
- cur_value = par->params().spacing().getValue();
+ cur_value = pit->params().spacing().getValue();
}
istringstream istr(ev.argument.c_str());
<< ev.argument << endl;
}
if (cur_spacing != new_spacing || cur_value != new_value) {
- par->params().spacing(Spacing(new_spacing, new_value));
+ pit->params().spacing(Spacing(new_spacing, new_value));
updwhat = CURSOR_PAR;
updflag = true;
}
clear = true;
}
if (lt->selection.set()) {
- setUndo(bv, Undo::EDIT, lt->cursor.par(), lt->cursor.par()->next());
+ setUndo(bv, Undo::EDIT, &*lt->cursor.par(), lt->cursor.par()->next());
}
if (selectall)
selectAll(bv);
LyXText * llt = getLyXText(bv);
int x = llt->cursor.x() + top_x + TEXT_TO_INSET_OFFSET;
if (the_locking_inset) {
- LyXFont font = llt->getFont(bv->buffer(), llt->cursor.par(),
+ LyXFont font = llt->getFont(bv->buffer(), &*llt->cursor.par(),
llt->cursor.pos());
if (font.isVisibleRightToLeft())
x -= the_locking_inset->width(bv, font);
LyXText * llt = getLyXText(bv);
int x = llt->cursor.ix() + top_x + TEXT_TO_INSET_OFFSET;
if (the_locking_inset) {
- LyXFont font = llt->getFont(bv->buffer(), llt->cursor.par(),
+ LyXFont font = llt->getFont(bv->buffer(), &*llt->cursor.par(),
llt->cursor.pos());
if (font.isVisibleRightToLeft())
x -= the_locking_inset->width(bv, font);
Paragraph * InsetText::cpar(BufferView * bv) const
{
- return getLyXText(bv)->cursor.par();
+ return &*getLyXText(bv)->cursor.par();
}
string const getPossibleLabel(BufferView const & bv)
{
- Paragraph * par = bv.getLyXText()->cursor.par();
+ Paragraph * par = &*bv.getLyXText()->cursor.par();
LyXLayout_ptr layout = par->layout();
if (layout->latextype == LATEX_PARAGRAPH && par->previous()) {
Paragraph * par2 = par->previous();
{}
-void LyXCursor::par(Paragraph * p)
+void LyXCursor::par(ParagraphList::iterator pit)
{
- par_ = p;
+ par_ = pit;
}
-Paragraph * LyXCursor::par() const
+ParagraphList::iterator LyXCursor::par() const
{
return par_;
}
#define LYXCURSOR_H
#include "RowList.h"
+#include "ParagraphList.h"
#include "support/types.h"
-class Paragraph;
-
/**
* The cursor class describes the position of a cursor within a document.
* Several cursors exist within LyX; for example, when locking an inset,
public:
LyXCursor();
/// set the paragraph that contains this cursor
- void par(Paragraph * p);
+ void par(ParagraphList::iterator pit);
/// return the paragraph this cursor is in
- Paragraph * par() const;
+ ParagraphList::iterator par() const;
/// set the position within the paragraph
void pos(lyx::pos_type p);
/// return the position within the paragraph
RowList::iterator irow() const;
private:
/// The paragraph the cursor is in.
- Paragraph * par_;
+ ParagraphList::iterator par_;
/// The position inside the paragraph
lyx::pos_type pos_;
/**
SearchResult SearchForward(BufferView * bv, LyXText * text, string const & str,
bool const & cs, bool const & mw)
{
- Paragraph * par = text->cursor.par();
+ Paragraph * par = &*text->cursor.par();
pos_type pos = text->cursor.pos();
UpdatableInset * inset;
while (par && !IsStringInText(par, pos, str, cs, mw)) {
- if (pos < par->size()
- && par->isInset(pos)
- && (inset = (UpdatableInset *)par->getInset(pos))
+ if (pos < par->size()
+ && par->isInset(pos)
+ && (inset = (UpdatableInset *)par->getInset(pos))
&& inset->isTextInset()
&& inset->searchForward(bv, str, cs, mw))
return SR_FOUND_NOUPDATE;
string const & str,
bool const & cs, bool const & mw)
{
- Paragraph * par = text->cursor.par();
+ Paragraph * par = &*text->cursor.par();
pos_type pos = text->cursor.pos();
do {
} while (par && pos < 0);
}
UpdatableInset * inset;
- if (par && par->isInset(pos)
- && (inset = (UpdatableInset *)par->getInset(pos))
+ if (par && par->isInset(pos)
+ && (inset = (UpdatableInset *)par->getInset(pos))
&& inset->isTextInset()
&& inset->searchBackward(bv, str, cs, mw))
return SR_FOUND_NOUPDATE;
SearchResult nextChange(BufferView * bv, LyXText * text, pos_type & length)
{
- Paragraph * par = text->cursor.par();
+ Paragraph * par = &*text->cursor.par();
pos_type pos = text->cursor.pos();
Paragraph * prev_par = par;
UpdatableInset * inset;
///
void selectSelectedWord();
/// returns true if par was empty and was removed
- bool setCursor(Paragraph * par,
+ bool setCursor(ParagraphList::iterator pit,
lyx::pos_type pos,
bool setfont = true,
bool boundary = false);
///
- void setCursor(LyXCursor &, Paragraph * par,
+ void setCursor(LyXCursor &, ParagraphList::iterator pit,
lyx::pos_type pos,
bool boundary = false);
///
- void setCursorIntern(Paragraph * par,
+ void setCursorIntern(ParagraphList::iterator pit,
lyx::pos_type pos,
bool setfont = true,
bool boundary = false);
anchor_row_ = rit;
anchor_row_offset_ = old_y - top_y();
lyxerr[Debug::GUI] << "anchor_row(): changing reference to row: "
- << &*anchor_row_ << " offset: "
+ << &*anchor_row_ << " offset: "
<< anchor_row_offset_ << endl;
}
pos_type i = pos;
for (; i < last; ++i) {
-
if (pit->isNewline(i)) {
point = i;
break;
&& !layout->keepempty)
return;
- setUndo(bv(), Undo::FINISH, cursor.par(), cursor.par()->next());
+ setUndo(bv(), Undo::FINISH, &*cursor.par(), &*boost::next(cursor.par()));
// Always break behind a space
//
// same Paragraph one to the right and make a rebreak
void LyXText::insertChar(char c)
{
- setUndo(bv(), Undo::INSERT, cursor.par(), cursor.par()->next());
+ setUndo(bv(), Undo::INSERT, &*cursor.par(), &*boost::next(cursor.par()));
// When the free-spacing option is set for the current layout,
// disable the double-space checking
cursor.pos() >= 1 &&
cursor.pos() < cursor.par()->size() &&
getFont(bv()->buffer(),
- cursor.par(),
+ &*cursor.par(),
cursor.pos()).number() == LyXFont::ON &&
getFont(bv()->buffer(),
- cursor.par(),
+ &*cursor.par(),
cursor.pos() - 1).number() == LyXFont::ON)
)
number(bv()); // Set current_font.number to OFF
cursor.par()->isNewline(cursor.pos() - 2))
) {
setCharFont(bv()->buffer(),
- cursor.par(),
+ &*cursor.par(),
cursor.pos() - 1,
current_font);
} else if (contains(number_seperators, c) &&
cursor.pos() >= 2 &&
getFont(bv()->buffer(),
- cursor.par(),
+ &*cursor.par(),
cursor.pos() - 2).number() == LyXFont::ON) {
setCharFont(bv()->buffer(),
- cursor.par(),
+ &*cursor.par(),
cursor.pos() - 1,
current_font);
}
// Here case LyXText::InsertInset already insertet the character
cursor.par()->insertChar(cursor.pos(), c);
}
- setCharFont(bv()->buffer(), cursor.par(), cursor.pos(), rawtmpfont);
+ setCharFont(bv()->buffer(), &*cursor.par(), cursor.pos(), rawtmpfont);
if (!jumped_over_space) {
// refresh the positions
setCursor(cursor.par(), cursor.pos() + 1, false,
cursor.boundary());
- if (isBoundary(bv()->buffer(), cursor.par(), cursor.pos())
+ if (isBoundary(bv()->buffer(), &*cursor.par(), cursor.pos())
!= cursor.boundary())
setCursor(cursor.par(), cursor.pos(), false,
!cursor.boundary());
if (selection.start.par() == selection.end.par()) {
LyXCursor & startc = selection.start;
LyXCursor & endc = selection.end;
- setUndo(bv(), Undo::INSERT, startc.par(), startc.par()->next());
+ setUndo(bv(), Undo::INSERT, &*startc.par(), &*boost::next(startc.par()));
startc.par()->acceptChange(startc.pos(), endc.pos());
finishUndo();
clearSelection();
if (selection.start.par() == selection.end.par()) {
LyXCursor & startc = selection.start;
LyXCursor & endc = selection.end;
- setUndo(bv(), Undo::INSERT, startc.par(), startc.par()->next());
+ setUndo(bv(), Undo::INSERT, &*startc.par(),
+ &*boost::next(startc.par()));
startc.par()->rejectChange(startc.pos(), endc.pos());
finishUndo();
clearSelection();
} else
cursor.pos(cursor.pos() + 1);
}
- Paragraph * tmppar = cursor.par();
+ ParagraphList::iterator tmppit = cursor.par();
// If this is not the very first word, skip rest of
// current word because we are probably in the middle
}
// Now, skip until we have real text (will jump paragraphs)
- while (1) {
- Paragraph * cpar(cursor.par());
+ while (true) {
+ ParagraphList::iterator cpit = cursor.par();
pos_type const cpos(cursor.pos());
- if (cpos == cpar->size()) {
- if (cpar->next()) {
- cursor.par(cpar->next());
+ if (cpos == cpit->size()) {
+ if (boost::next(cpit) != ownerParagraphs().end()) {
+ cursor.par(boost::next(cpit));
cursor.pos(0);
continue;
}
break;
}
- bool const is_bad_inset(cpar->isInset(cpos)
- && !cpar->getInset(cpos)->allowSpellcheck());
+ bool const is_bad_inset(cpit->isInset(cpos)
+ && !cpit->getInset(cpos)->allowSpellcheck());
- if (cpar->isLetter(cpos) && !isDeletedText(*cpar, cpos)
+ if (cpit->isLetter(cpos) && !isDeletedText(*cpit, cpos)
&& !is_bad_inset)
break;
}
// Update the value if we changed paragraphs
- if (cursor.par() != tmppar) {
+ if (cursor.par() != tmppit) {
setCursor(cursor.par(), cursor.pos());
value = float(cursor.y())/float(height);
}
selection.cursor = cursor;
string lang_code(
- getFont(bv()->buffer(), cursor.par(), cursor.pos())
+ getFont(bv()->buffer(), &*cursor.par(), cursor.pos())
.language()->code());
// and find the end of the word (insets like optional hyphens
// and ligature break are part of a word)
lyx::Assert(from <= to);
- setUndo(bv(), Undo::FINISH, from.par(), to.par()->next());
+ setUndo(bv(), Undo::FINISH, &*from.par(), &*boost::next(to.par()));
pos_type pos = from.pos();
- Paragraph * par = from.par();
+ ParagraphList::iterator pit = from.par();
- while (par && (pos != to.pos() || par != to.par())) {
- if (pos == par->size()) {
- par = par->next();
+ while (pit != ownerParagraphs().end() &&
+ (pos != to.pos() || pit != to.par())) {
+ if (pos == pit->size()) {
+ ++pit;
pos = 0;
continue;
}
- unsigned char c = par->getChar(pos);
+ unsigned char c = pit->getChar(pos);
if (!IsInsetChar(c)) {
switch (action) {
case text_lowercase:
}
}
#warning changes
- par->setChar(pos, c);
- checkParagraph(par, pos);
+ pit->setChar(pos, c);
+ checkParagraph(&*pit, pos);
++pos;
}
// to make sure undo gets the right cursor position
cursor = old_cursor;
setUndo(bv(), Undo::DELETE,
- cursor.par(), cursor.par()->next());
+ &*cursor.par(), &*boost::next(cursor.par()));
cursor = tmpcursor;
backspace();
}
cursor.par()->previous(), cursor.par()->next());
}
- Paragraph * tmppar = cursor.par();
+ ParagraphList::iterator tmppit = cursor.par();
RowList::iterator tmprow = cursor.row();
// We used to do cursorLeftIntern() here, but it is
// not a good idea since it triggers the auto-delete
// mechanism. So we do a cursorLeftIntern()-lite,
// without the dreaded mechanism. (JMarc)
- if (cursor.par()->previous()) {
+ if (cursor.par() != ownerParagraphs().begin()) {
// steps into the above paragraph.
- setCursorIntern(cursor.par()->previous(),
- cursor.par()->previous()->size(),
+ setCursorIntern(boost::prior(cursor.par()),
+ boost::prior(cursor.par())->size(),
false);
}
LyXTextClass const & tclass =
bv()->buffer()->params.getLyXTextClass();
- if (cursor.par() != tmppar
- && (cursor.par()->layout() == tmppar->layout()
- || tmppar->layout() == tclass.defaultLayout())
- && cursor.par()->getAlign() == tmppar->getAlign()) {
+ if (cursor.par() != tmppit
+ && (cursor.par()->layout() == tmppit->layout()
+ || tmppit->layout() == tclass.defaultLayout())
+ && cursor.par()->getAlign() == tmppit->getAlign()) {
removeParagraph(tmprow);
removeRow(tmprow);
mergeParagraph(bv()->buffer()->params, bv()->buffer()->paragraphs, cursor.par());
// this is the code for a normal backspace, not pasting
// any paragraphs
setUndo(bv(), Undo::DELETE,
- cursor.par(), cursor.par()->next());
+ &*cursor.par(), &*boost::next(cursor.par()));
// We used to do cursorLeftIntern() here, but it is
// not a good idea since it triggers the auto-delete
// mechanism. So we do a cursorLeftIntern()-lite,
if (cursor.pos() < lastPos(*this, row) ||
!cursor.par()->isLineSeparator(cursor.pos())) {
row->fill(row->fill() + singleWidth(
- cursor.par(),
+ &*cursor.par(),
cursor.pos()));
}
if (cursor.pos() < cursor.par()->size()
&& !cursor.par()->isSeparator(cursor.pos())) {
cursor.par()->insertChar(cursor.pos(), ' ');
- setCharFont(bv()->buffer(), cursor.par(),
+ setCharFont(bv()->buffer(), &*cursor.par(),
cursor.pos(), current_font);
// refresh the positions
tmprow = row;
// current_font = rawtmpfont;
// real_current_font = realtmpfont;
- if (isBoundary(bv()->buffer(), cursor.par(), cursor.pos())
+ if (isBoundary(bv()->buffer(), &*cursor.par(), cursor.pos())
!= cursor.boundary())
setCursor(cursor.par(), cursor.pos(), false,
!cursor.boundary());
endpar = endpar->next(); // because of parindents etc.
}
- setUndo(bv(), Undo::EDIT, sstart_cur.par(), undoendpar);
+ setUndo(bv(), Undo::EDIT, &*sstart_cur.par(), undoendpar);
// ok we have a selection. This is always between sstart_cur
// and sel_end cursor
cur = sstart_cur;
- Paragraph * par = sstart_cur.par();
- Paragraph * epar = send_cur.par()->next();
+ ParagraphList::iterator pit = sstart_cur.par();
+ ParagraphList::iterator epit = boost::next(send_cur.par());
LyXLayout_ptr const & lyxlayout =
bv()->buffer()->params.getLyXTextClass()[layout];
do {
- par->applyLayout(lyxlayout);
- makeFontEntriesLayoutSpecific(*bv()->buffer(), *par);
- Paragraph * fppar = par;
- fppar->params().spaceTop(lyxlayout->fill_top ?
+ pit->applyLayout(lyxlayout);
+ makeFontEntriesLayoutSpecific(*bv()->buffer(), *pit);
+ ParagraphList::iterator fppit = pit;
+ fppit->params().spaceTop(lyxlayout->fill_top ?
VSpace(VSpace::VFILL)
: VSpace(VSpace::NONE));
- fppar->params().spaceBottom(lyxlayout->fill_bottom ?
+ fppit->params().spaceBottom(lyxlayout->fill_bottom ?
VSpace(VSpace::VFILL)
: VSpace(VSpace::NONE));
if (lyxlayout->margintype == MARGIN_MANUAL)
- par->setLabelWidthString(lyxlayout->labelstring());
- cur.par(par);
- par = par->next();
- } while (par != epar);
+ pit->setLabelWidthString(lyxlayout->labelstring());
+ cur.par(pit);
+ ++pit;
+ } while (pit != epit);
return endpar;
}
start = pit;
}
- ParagraphList::iterator pastend = end;
- ++pastend;
+ ParagraphList::iterator pastend = boost::next(end);
+
if (!test_only)
setUndo(bv(), Undo::EDIT, &(*start), &(*pastend));
int prev_after_depth = 0;
#warning parlist ... could be nicer ?
- if (start != ownerParagraphs().begin())
+ if (start != ownerParagraphs().begin()) {
prev_after_depth = boost::prior(start)->getMaxDepthAfter();
+ }
while (true) {
int const depth = pit->params().depth();
if (depth < prev_after_depth
&& pit->layout()->labeltype != LABEL_BIBLIO) {
changed = true;
- if (!test_only)
+ if (!test_only) {
pit->params().depth(depth + 1);
+ }
+
}
} else if (depth) {
changed = true;
prev_after_depth = pit->getMaxDepthAfter();
- if (pit == end)
+ if (pit == end) {
break;
+ }
++pit;
}
// Wow, redoParagraphs is stupid.
LyXCursor tmpcursor;
setCursor(tmpcursor, &(*start), 0);
+
+ //redoParagraphs(tmpcursor, &(*pastend));
redoParagraphs(tmpcursor, &(*pastend));
// We need to actually move the text->cursor. I don't
LyXFont layoutfont;
if (cursor.pos() < cursor.par()->beginningOfBody()) {
layoutfont = getLabelFont(bv()->buffer(),
- cursor.par());
+ &*cursor.par());
} else {
layoutfont = getLayoutFont(bv()->buffer(),
- cursor.par());
+ &*cursor.par());
}
// Update current font
real_current_font.update(font,
// and sel_end cursor
setUndo(bv(), Undo::EDIT,
- selection.start.par(), selection.end.par()->next());
+ &*selection.start.par(), &*boost::next(selection.end.par()));
freezeUndo();
cursor = selection.start;
while (cursor.par() != selection.end.par() ||
{
if (cursor.pos() < cursor.par()->size()) {
// an open footnote should behave like a closed one
- setCharFont(cursor.par(), cursor.pos(),
+ setCharFont(&*cursor.par(), cursor.pos(),
font, toggleall);
cursor.pos(cursor.pos() + 1);
} else {
Paragraph const * ep)
{
RowList::iterator tmprit = cur.row();
+ ParagraphList::iterator begpit = cur.row()->par();
ParagraphList::iterator endpit(const_cast<Paragraph*>(ep));
int y = cur.y() - tmprit->baseline();
}
if (tmprit != rows().end())
setHeightOfRow(tmprit);
+
updateCounters();
}
if (!selection.set()) return string();
// should be const ...
- Paragraph * startpar(selection.start.par());
- Paragraph * endpar(selection.end.par());
+ ParagraphList::iterator startpit = selection.start.par();
+ ParagraphList::iterator endpit = selection.end.par();
pos_type const startpos(selection.start.pos());
pos_type const endpos(selection.end.pos());
- if (startpar == endpar) {
- return startpar->asString(buffer, startpos, endpos, label);
+ if (startpit == endpit) {
+ return startpit->asString(buffer, startpos, endpos, label);
}
string result;
// First paragraph in selection
- result += startpar->asString(buffer, startpos, startpar->size(), label) + "\n\n";
+ result += startpit->asString(buffer, startpos, startpit->size(), label) + "\n\n";
// The paragraphs in between (if any)
+#warning FIXME Why isnt ParagraphList::iterator used here?
+ // as loop variable.
LyXCursor tmpcur(selection.start);
tmpcur.par(tmpcur.par()->next());
- while (tmpcur.par() != endpar) {
+ while (tmpcur.par() != endpit) {
result += tmpcur.par()->asString(buffer, 0,
tmpcur.par()->size(),
label) + "\n\n";
- tmpcur.par(tmpcur.par()->next());
+ tmpcur.par(boost::next(tmpcur.par()));
}
// Last paragraph in selection
- result += endpar->asString(buffer, 0, endpos, label);
+ result += endpit->asString(buffer, 0, endpos, label);
return result;
}
endpar = endpar->next();
}
- setUndo(bv(), Undo::EDIT, selection.start.par(), undoendpar);
+ setUndo(bv(), Undo::EDIT, &*selection.start.par(), undoendpar);
- Paragraph * tmppar = selection.end.par();
+ ParagraphList::iterator tmppit = selection.end.par();
- while (tmppar != selection.start.par()->previous()) {
- setCursor(tmppar, 0);
+ while (tmppit != boost::prior(selection.start.par())) {
+ setCursor(tmppit, 0);
postPaint(cursor.y() - cursor.row()->baseline());
cursor.par()->params().lineTop(line_top);
cursor.par()->params().lineBottom(line_bottom);
}
cursor.par()->setLabelWidthString(labelwidthstring);
cursor.par()->params().noindent(noindent);
- tmppar = cursor.par()->previous();
+ tmppit = boost::prior(cursor.par());
}
redoParagraphs(selection.start, endpar);
{
if (!cursor.par()->insetAllowed(inset->lyxCode()))
return;
- setUndo(bv(), Undo::FINISH, cursor.par(), cursor.par()->next());
+ setUndo(bv(), Undo::FINISH, &*cursor.par(),
+ &*boost::next(cursor.par()));
freezeUndo();
cursor.par()->insertInset(cursor.pos(), inset);
// Just to rebreak and refresh correctly.
}
setUndo(bv(), Undo::DELETE,
- selection.start.par(), undoendpar);
+ &*selection.start.par(), undoendpar);
// there are two cases: cut only within one paragraph or
// more than one paragraph
if (selection.start.par() == selection.end.par()) {
// only within one paragraph
- endpar = selection.end.par();
+ endpar = &*selection.end.par();
int pos = selection.end.pos();
- CutAndPaste::cutSelection(selection.start.par(), &endpar,
+ CutAndPaste::cutSelection(&*selection.start.par(), &endpar,
selection.start.pos(), pos,
bv()->buffer()->params.textclass,
doclear, realcut);
selection.end.pos(pos);
} else {
- endpar = selection.end.par();
+ endpar = &*selection.end.par();
int pos = selection.end.pos();
- CutAndPaste::cutSelection(selection.start.par(), &endpar,
+ CutAndPaste::cutSelection(&*selection.start.par(), &endpar,
selection.start.pos(), pos,
bv()->buffer()->params.textclass,
doclear, realcut);
|| selection.start.pos() < selection.end.pos()))
selection.start.pos(selection.start.pos() + 1);
- CutAndPaste::copySelection(selection.start.par(), selection.end.par(),
+ CutAndPaste::copySelection(&*selection.start.par(),
+ &*selection.end.par(),
selection.start.pos(), selection.end.pos(),
bv()->buffer()->params.textclass);
}
return;
setUndo(bv(), Undo::INSERT,
- cursor.par(), cursor.par()->next());
+ &*cursor.par(), &*boost::next(cursor.par()));
Paragraph * endpar;
- Paragraph * actpar = cursor.par();
+ ParagraphList::iterator actpit = cursor.par();
int pos = cursor.pos();
+ Paragraph * actpar = &*actpit;
CutAndPaste::pasteSelection(&actpar, &endpar, pos,
bv()->buffer()->params.textclass);
clearSelection();
selection.cursor = cursor;
- setCursor(actpar, pos);
+ setCursor(actpit, pos);
setSelection();
updateCounters();
}
// needed to insert the selection
void LyXText::insertStringAsLines(string const & str)
{
- Paragraph * par = cursor.par();
+ ParagraphList::iterator pit = cursor.par();
pos_type pos = cursor.pos();
- Paragraph * endpar = cursor.par()->next();
+ ParagraphList::iterator endpit = boost::next(cursor.par());
setCursorParUndo(bv());
// only to be sure, should not be neccessary
clearSelection();
+ Paragraph * par = &*pit;
bv()->buffer()->insertStringAsLines(par, pos, current_font, str);
- redoParagraphs(cursor, endpar);
+ redoParagraphs(cursor, &*endpit);
setCursor(cursor.par(), cursor.pos());
selection.cursor = cursor;
- setCursor(par, pos);
+ setCursor(pit, pos);
setSelection();
}
// first check the current paragraph
int pos = cursor.par()->getPositionOfInset(inset);
if (pos != -1) {
- checkParagraph(cursor.par(), pos);
+ checkParagraph(&*cursor.par(), pos);
return true;
}
}
-bool LyXText::setCursor(Paragraph * par,
+bool LyXText::setCursor(ParagraphList::iterator pit,
pos_type pos,
bool setfont, bool boundary)
{
LyXCursor old_cursor = cursor;
- setCursorIntern(par, pos, setfont, boundary);
+ setCursorIntern(pit, pos, setfont, boundary);
return deleteEmptyParagraphMechanism(old_cursor);
}
-void LyXText::setCursor(LyXCursor & cur, Paragraph * par,
+void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
pos_type pos, bool boundary)
{
- lyx::Assert(par);
+ lyx::Assert(pit != ownerParagraphs().end());
- cur.par(par);
+ cur.par(pit);
cur.pos(pos);
cur.boundary(boundary);
// get the cursor y position in text
int y = 0;
- RowList::iterator row = getRow(par, pos, y);
+ RowList::iterator row = getRow(&*pit, pos, y);
RowList::iterator beg = rows().begin();
RowList::iterator old_row = row;
Inset * ins;
if (row != beg && pos &&
boost::prior(row)->par() == row->par() &&
- pos < par->size() &&
- par->getChar(pos) == Paragraph::META_INSET &&
- (ins = par->getInset(pos)) && (ins->needFullRow() || ins->display()))
+ pos < pit->size() &&
+ pit->getChar(pos) == Paragraph::META_INSET &&
+ (ins = pit->getInset(pos)) && (ins->needFullRow() || ins->display()))
{
--row;
y -= row->height();
pos_type last = lastPrintablePos(*this, old_row);
// None of these should happen, but we're scaredy-cats
- if (pos > par->size()) {
+ if (pos > pit->size()) {
lyxerr << "dont like 1 please report" << endl;
pos = 0;
cur.pos(0);
cur.ix(int(x));
} else
cur.ix(cur.x());
-/* We take out this for the time being because 1) the redraw code is not
+/* We take out this for the time being because 1) the redraw code is not
prepared to this yet and 2) because some good policy has yet to be decided
while editting: for instance how to act on rows being created/deleted
because of DEPM.
-*/
+*/
#if 0
//if the cursor is in a visible row, anchor to it
int topy = top_y();
}
-void LyXText::setCursorIntern(Paragraph * par,
+void LyXText::setCursorIntern(ParagraphList::iterator pit,
pos_type pos, bool setfont, bool boundary)
{
- InsetText * it = static_cast<InsetText *>(par->inInset());
+ InsetText * it = static_cast<InsetText *>(pit->inInset());
if (it) {
if (it != inset_owner) {
lyxerr[Debug::INSETS] << "InsetText is " << it
}
}
- setCursor(cursor, par, pos, boundary);
+ setCursor(cursor, pit, pos, boundary);
if (setfont)
setCurrentFont();
}
current_font =
cursor.par()->getFontSettings(bv()->buffer()->params, pos);
- real_current_font = getFont(bv()->buffer(), cursor.par(), pos);
+ real_current_font = getFont(bv()->buffer(), &*cursor.par(), pos);
if (cursor.pos() == cursor.par()->size() &&
- isBoundary(bv()->buffer(), cursor.par(), cursor.pos()) &&
+ isBoundary(bv()->buffer(), &*cursor.par(), cursor.pos()) &&
!cursor.boundary()) {
Language const * lang =
cursor.par()->getParLanguage(bv()->buffer()->params);
bool boundary = cursor.boundary();
setCursor(cursor.par(), cursor.pos() - 1, true, false);
if (!internal && !boundary &&
- isBoundary(bv()->buffer(), cursor.par(), cursor.pos() + 1))
+ isBoundary(bv()->buffer(), &*cursor.par(), cursor.pos() + 1))
setCursor(cursor.par(), cursor.pos() + 1, true, true);
} else if (cursor.par()->previous()) { // steps into the above paragraph.
Paragraph * par = cursor.par()->previous();
else if (cursor.pos() < cursor.par()->size()) {
setCursor(cursor.par(), cursor.pos() + 1, true, false);
if (!internal &&
- isBoundary(bv()->buffer(), cursor.par(), cursor.pos()))
+ isBoundary(bv()->buffer(), &*cursor.par(), cursor.pos()))
setCursor(cursor.par(), cursor.pos(), true, true);
} else if (cursor.par()->next())
setCursor(cursor.par()->next(), 0);
deleted = true;
if (old_cursor.row() != rows().begin()) {
- RowList::iterator
+ RowList::iterator
prevrow = boost::prior(old_cursor.row());
const_cast<LyXText *>(this)->postPaint(old_cursor.y() - old_cursor.row()->baseline() - prevrow->height());
tmpcursor = cursor;
endpar = endpar->next();
}
}
- setUndo(bv(), Undo::DELETE, old_cursor.par(), endpar);
+ setUndo(bv(), Undo::DELETE, &*old_cursor.par(), endpar);
cursor = tmpcursor;
// delete old row
if (ownerParagraphs().begin() == old_cursor.par()) {
ownerParagraph(&*boost::next(ownerParagraphs().begin()));
}
+#warning FIXME Do the proper ParagraphList operation here (Lgb)
// delete old par
- delete old_cursor.par();
+ delete &*old_cursor.par();
/* Breakagain the next par. Needed because of
* the parindent that can occur or dissappear.
endpar = endpar->next();
}
}
- setUndo(bv(), Undo::DELETE, old_cursor.par(), endpar);
+ setUndo(bv(), Undo::DELETE, &*old_cursor.par(), endpar);
cursor = tmpcursor;
// delete old row
if (ownerParagraphs().begin() == old_cursor.par()) {
ownerParagraph(&*boost::next(ownerParagraphs().begin()));
}
-
- delete old_cursor.par();
+#warning FIXME Do the proper ParagraphList operations here. (Lgb)
+ delete &*old_cursor.par();
/* Breakagain the next par. Needed because of
the parindent that can occur or dissappear.
if (res.pos() < res.par()->size() - 1) {
res.pos(res.pos() + 1);
} else {
- res.par(res.par()->next());
+ res.par(boost::next(res.par()));
res.pos(0);
}
- } while (res.par() &&
+ } while (res.par() != ownerParagraphs().end()&&
!(res.par()->isInset(res.pos())
&& (inset = res.par()->getInset(res.pos())) != 0
&& find(codes.begin(), codes.end(), inset->lyxCode())
res.par()->getInset(res.pos()))->getContents()
== contents)));
- if (res.par()) {
+ if (res.par() != ownerParagraphs().end()) {
setCursor(res.par(), res.pos(), false);
return true;
}
switch (cmd.action) {
case LFUN_APPENDIX: {
- Paragraph * par = cursor.par();
- bool start = !par->params().startOfAppendix();
+ ParagraphList::iterator pit = cursor.par();
+ bool start = !pit->params().startOfAppendix();
// ensure that we have only one start_of_appendix in this document
ParagraphList::iterator tmp = ownerParagraphs().begin();
}
}
- setUndo(bv, Undo::EDIT, par, par->next());
- par->params().startOfAppendix(start);
+ setUndo(bv, Undo::EDIT, &*pit, &*boost::next(pit));
+ pit->params().startOfAppendix(start);
// we can set the refreshing parameters now
updateCounters();
}
case LFUN_PARAGRAPH_SPACING: {
- Paragraph * par = cursor.par();
- Spacing::Space cur_spacing = par->params().spacing().getSpace();
+ ParagraphList::iterator pit = cursor.par();
+ Spacing::Space cur_spacing = pit->params().spacing().getSpace();
float cur_value = 1.0;
if (cur_spacing == Spacing::Other)
- cur_value = par->params().spacing().getValue();
+ cur_value = pit->params().spacing().getValue();
istringstream is(cmd.argument.c_str());
string tmp;
<< cmd.argument << endl;
}
if (cur_spacing != new_spacing || cur_value != new_value) {
- par->params().spacing(Spacing(new_spacing, new_value));
+ pit->params().spacing(Spacing(new_spacing, new_value));
redoParagraph();
update();
}
if (!change_layout && selection.set() &&
selection.start.par() != selection.end.par())
{
- Paragraph * spar = selection.start.par();
- Paragraph * epar = selection.end.par()->next();
- while (spar != epar) {
- if (spar->layout()->name() != current_layout) {
+ ParagraphList::iterator spit = selection.start.par();
+ ParagraphList::iterator epit = boost::next(selection.end.par());
+ while (spit != epit) {
+ if (spit->layout()->name() != current_layout) {
change_layout = true;
break;
}
- spar = spar->next();
+ ++spit;
}
}
if (change_layout) {
}
case LFUN_QUOTE: {
- Paragraph const * par = cursor.par();
+ ParagraphList::iterator pit = cursor.par();
lyx::pos_type pos = cursor.pos();
char c;
if (!pos)
c = ' ';
- else if (par->isInset(pos - 1) && par->getInset(pos - 1)->isSpace())
+ else if (pit->isInset(pos - 1) && pit->getInset(pos - 1)->isSpace())
c = ' ';
else
- c = par->getChar(pos - 1);
+ c = pit->getChar(pos - 1);
bv->hideCursor();
- LyXLayout_ptr const & style = par->layout();
+ LyXLayout_ptr const & style = pit->layout();
if (style->pass_thru ||
- par->getFontSettings(bv->buffer()->params,
+ pit->getFontSettings(bv->buffer()->params,
pos).language()->lang() == "hebrew" ||
(!bv->insertInset(new InsetQuotes(c, bv->buffer()->params))))
bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
Inset * tli = bv->theLockingInset();
LyXCursor cursor = bv->text->cursor;
LyXFont font = bv->text->getFont(bv->buffer(),
- cursor.par(), cursor.pos());
+ &*cursor.par(), cursor.pos());
int width = tli->width(bv, font);
int inset_x = font.isVisibleRightToLeft()
? cursor.ix() - width : cursor.ix();
* Full author contact details are available in file CREDITS
*
* This file contains some utility functions for actually mutating
- * the text contents of a document
+ * the text contents of a document
*/
#include <config.h>
void transposeChars(LyXText & text, LyXCursor const & cursor)
{
- Paragraph * tmppar = cursor.par();
+ Paragraph * tmppar = &*cursor.par();
setUndo(text.bv(), Undo::FINISH, tmppar, tmppar->next());
void setCursorParUndo(BufferView * bv)
{
- setUndo(bv, Undo::FINISH, bv->text->cursor.par(),
+ setUndo(bv, Undo::FINISH, &*bv->text->cursor.par(),
bv->text->cursor.par()->next());
}