#include "FloatList.h"
using std::copy;
+using std::find;
using std::endl;
+using std::find;
using std::pair;
void LyXText::init()
{
+ the_locking_inset = 0;
firstrow = 0;
lastrow = 0;
number_of_rows = 0;
current_font = GetFont(bv_owner->buffer(), par, 0);
while (par) {
InsertParagraph(bv_owner, par, lastrow);
- par = par->Next();
+ par = par->next();
}
SetCursor(bv_owner, firstrow->par(), 0);
} else
current_font = GetFont(bview->buffer(), par, 0);
while (par) {
InsertParagraph(bview, par, lastrow);
- par = par->Next();
+ par = par->next();
}
SetCursorIntern(bview, firstrow->par(), 0);
sel_cursor = cursor;
// smaller. (Asger)
// If position is -1, we get the layout font of the paragraph.
// If position is -2, we get the font of the manual label of the paragraph.
-LyXFont LyXText::GetFont(Buffer const * buf, LyXParagraph * par,
+LyXFont const LyXText::GetFont(Buffer const * buf, LyXParagraph * par,
LyXParagraph::size_type pos) const
{
LyXLayout const & layout =
if (layout.labeltype == LABEL_MANUAL
&& pos < BeginningOfMainBody(buf, par)) {
// 1% goes here
- return par->GetFontSettings(buf->params, pos).
- realize(layout.reslabelfont);
- } else
- return par->GetFontSettings(buf->params, pos).
- realize(layout.resfont);
+ LyXFont f = par->GetFontSettings(buf->params,
+ pos);
+ return f.realize(layout.reslabelfont);
+ } else {
+ LyXFont f = par->GetFontSettings(buf->params, pos);
+ return f.realize(layout.resfont);
+ }
+
} else {
// 5% goes here.
// process layoutfont for pos == -1 and labelfont for pos < -1
/* this must not happen before the currentrow for clear reasons.
so the trick is just to set the current row onto the previous
row of this row */
- long unused_y;
+ int unused_y;
GetRow(row->par(), row->pos(), unused_y);
if (row->next())
void LyXText::ToggleFootnote(BufferView * bview)
{
LyXParagraph * par = cursor.par()->ParFromPos(cursor.pos());
- if (par->next
- && par->next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
+ if (par->next_
+ && par->next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
OpenFootnote(bview);
bview->owner()->getMiniBuffer()->Set(_("Opened float"));
} else {
// there is no open footnote in this paragraph, just return.
if (cursor.par()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE) {
- if (!par->next ||
- par->next->footnoteflag != LyXParagraph::OPEN_FOOTNOTE) {
+ if (!par->next_ ||
+ par->next_->footnoteflag != LyXParagraph::OPEN_FOOTNOTE) {
bview->owner()->getMiniBuffer()
->Set(_("Nothing to do"));
return;
tmppar = cursor.par();
while (tmppar->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
// just a little bit faster than movin the cursor
- tmppar = tmppar->Previous();
+ tmppar = tmppar->previous();
}
SetCursor(bview, tmppar, tmppar->Last());
}
refresh_y = cursor.y() - cursor.row()->baseline();
tmppar = cursor.par();
- LyXParagraph * endpar = par->NextAfterFootnote()->Next();
+ LyXParagraph * endpar = par->NextAfterFootnote()->next();
Row * row = cursor.row();
tmppar->CloseFootnote(cursor.pos());
LyXFont layoutfont, tmpfont;
for (LyXParagraph::size_type pos = 0;
+#ifndef NEW_INSETS
pos < par->Last(); ++pos) {
+#else
+ pos < par->size(); ++pos) {
+#endif
if (pos < BeginningOfMainBody(buf, par))
layoutfont = layout.labelfont;
else
LyXTextClass::size_type layout)
{
#ifndef NEW_INSETS
- LyXParagraph * endpar = send_cur.par()->LastPhysicalPar()->Next();
+ LyXParagraph * endpar = send_cur.par()->LastPhysicalPar()->next();
#else
- LyXParagraph * endpar = send_cur.par()->Next();
+ LyXParagraph * endpar = send_cur.par()->next();
#endif
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
#ifndef NEW_INSETS
- endpar = endpar->LastPhysicalPar()->Next();
+ endpar = endpar->LastPhysicalPar()->next();
#else
- endpar = endpar->Next();
+ endpar = endpar->next();
#endif
undoendpar = endpar;
}
} else if (endpar) {
- endpar = endpar->Next(); // because of parindents etc.
+ endpar = endpar->next(); // because of parindents etc.
}
SetUndo(bview->buffer(), Undo::EDIT,
#ifndef NEW_INSETS
- sstart_cur.par()->ParFromPos(sstart_cur.pos())->previous,
+ sstart_cur.par()->ParFromPos(sstart_cur.pos())->previous_,
#else
- sstart_cur.par()->previous,
+ sstart_cur.par()->previous(),
#endif
undoendpar);
#else
LyXParagraph * fppar = cur.par();
#endif
- fppar->added_space_top = lyxlayout.fill_top ?
- VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
- fppar->added_space_bottom = lyxlayout.fill_bottom ?
- VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
+ fppar->params.spaceTop(lyxlayout.fill_top ?
+ VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
+ fppar->params.spaceBottom(lyxlayout.fill_bottom ?
+ VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
if (lyxlayout.margintype == MARGIN_MANUAL)
cur.par()->SetLabelWidthString(lyxlayout.labelstring());
if (lyxlayout.labeltype != LABEL_BIBLIO
#ifndef NEW_INSETS
}
#endif
- cur.par(cur.par()->Next());
+ cur.par(cur.par()->next());
}
#ifndef NEW_INSETS
if (cur.par()->footnoteflag == sstart_cur.par()->footnoteflag) {
#else
LyXParagraph * fppar = cur.par();
#endif
- fppar->added_space_top = lyxlayout.fill_top ?
- VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
- fppar->added_space_bottom = lyxlayout.fill_bottom ?
- VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
+ fppar->params.spaceTop(lyxlayout.fill_top ?
+ VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
+ fppar->params.spaceBottom(lyxlayout.fill_bottom ?
+ VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
if (lyxlayout.margintype == MARGIN_MANUAL)
cur.par()->SetLabelWidthString(lyxlayout.labelstring());
if (lyxlayout.labeltype != LABEL_BIBLIO
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos(),
false);
UpdateCounters(bview, cursor.row());
- ClearSelection();
- SetSelection();
+ ClearSelection(bview);
+ SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true);
}
// We end at the next paragraph with depth 0
LyXParagraph * endpar =
#ifndef NEW_INSETS
- sel_end_cursor.par()->LastPhysicalPar()->Next();
+ sel_end_cursor.par()->LastPhysicalPar()->next();
#else
- sel_end_cursor.par()->Next();
+ sel_end_cursor.par()->next();
#endif
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
#ifndef NEW_INSETS
- endpar = endpar->LastPhysicalPar()->Next();
+ endpar = endpar->LastPhysicalPar()->next();
#else
- endpar = endpar->Next();
+ endpar = endpar->next();
#endif
undoendpar = endpar;
}
}
else if (endpar) {
- endpar = endpar->Next(); // because of parindents etc.
+ endpar = endpar->next(); // because of parindents etc.
}
SetUndo(bview->buffer(), Undo::EDIT,
#ifndef NEW_INSETS
sel_start_cursor
- .par()->ParFromPos(sel_start_cursor.pos())->previous,
+ .par()->ParFromPos(sel_start_cursor.pos())->previous_,
#else
- sel_start_cursor.par()->previous,
+ sel_start_cursor.par()->previous(),
#endif
undoendpar);
).labeltype != LABEL_BIBLIO) {
LyXParagraph * prev =
#ifndef NEW_INSETS
- cursor.par()->FirstPhysicalPar()->Previous();
+ cursor.par()->FirstPhysicalPar()->previous();
#else
- cursor.par()->Previous();
+ cursor.par()->previous();
#endif
if (prev
&& (prev->GetDepth() - cursor.par()->GetDepth() > 0
&& textclasslist.Style(bview->buffer()->params.textclass,
prev->GetLayout()).isEnvironment()))) {
#ifndef NEW_INSETS
- cursor.par()->FirstPhysicalPar()->depth++;
+ cursor.par()->FirstPhysicalPar()->params.depth(cursor.par()->FirstPhysicalPar()->params.depth() + 1);
#else
- cursor.par()->depth++;
+ cursor.par()->params.depth(cursor.par()->params.depth() + 1);
#endif
anything_changed = true;
}
}
if (cursor.par() == sel_end_cursor.par())
break;
- cursor.par(cursor.par()->Next());
+ cursor.par(cursor.par()->next());
}
// if nothing changed set all depth to 0
cursor = sel_start_cursor;
while (cursor.par() != sel_end_cursor.par()) {
#ifndef NEW_INSETS
- cursor.par()->FirstPhysicalPar()->depth = 0;
+ cursor.par()->FirstPhysicalPar()->params.depth(0);
#else
- cursor.par()->depth = 0;
+ cursor.par()->params.depth(0);
#endif
- cursor.par(cursor.par()->Next());
+ cursor.par(cursor.par()->next());
}
#ifndef NEW_INSETS
if (cursor.par()->footnoteflag == sel_start_cursor.par()->footnoteflag)
- cursor.par()->FirstPhysicalPar()->depth = 0;
+ cursor.par()->FirstPhysicalPar()->params.depth(0);
#else
- cursor.par()->depth = 0;
+ cursor.par()->params.depth(0);
#endif
}
sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
UpdateCounters(bview, cursor.row());
- ClearSelection();
- SetSelection();
+ ClearSelection(bview);
+ SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
}
sel_end_cursor = cursor;
}
#ifndef NEW_INSETS
- LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next();
+ LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->next();
#else
- LyXParagraph * endpar = sel_end_cursor.par()->Next();
+ LyXParagraph * endpar = sel_end_cursor.par()->next();
#endif
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
#ifndef NEW_INSETS
- endpar = endpar->LastPhysicalPar()->Next();
+ endpar = endpar->LastPhysicalPar()->next();
#else
- endpar = endpar->Next();
+ endpar = endpar->next();
#endif
undoendpar = endpar;
}
}
else if (endpar) {
- endpar = endpar->Next(); // because of parindents etc.
+ endpar = endpar->next(); // because of parindents etc.
}
SetUndo(bview->buffer(), Undo::EDIT,
#ifndef NEW_INSETS
sel_start_cursor
- .par()->ParFromPos(sel_start_cursor.pos())->previous,
+ .par()->ParFromPos(sel_start_cursor.pos())->previous_,
#else
- sel_start_cursor.par()->previous,
+ sel_start_cursor.par()->previous(),
#endif
undoendpar);
#ifndef NEW_INSETS
if (cursor.par()->footnoteflag ==
sel_start_cursor.par()->footnoteflag) {
- if (cursor.par()->FirstPhysicalPar()->depth)
- cursor.par()->FirstPhysicalPar()->depth--;
+ if (cursor.par()->FirstPhysicalPar()->params.depth())
+ cursor.par()->FirstPhysicalPar()->params.depth(cursor.par()->FirstPhysicalPar()->params.depth() - 1);
}
#else
- if (cursor.par()->depth)
- cursor.par()->depth--;
+ if (cursor.par()->params.depth())
+ cursor.par()->params.depth(cursor.par()->params.depth() - 1);
#endif
if (cursor.par() == sel_end_cursor.par())
break;
- cursor.par(cursor.par()->Next());
+ cursor.par(cursor.par()->next());
}
RedoParagraphs(bview, sel_start_cursor, endpar);
sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
UpdateCounters(bview, cursor.row());
- ClearSelection();
- SetSelection();
+ ClearSelection(bview);
+ SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
}
layoutfont = GetFont(bview->buffer(), cursor.par(),-1);
// Update current font
real_current_font.update(font,
- bview->buffer()->params.language_info,
+ bview->buffer()->params.language,
toggleall);
// Reduce to implicit settings
SetUndo(bview->buffer(), Undo::EDIT,
#ifndef NEW_INSETS
- sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos())->previous,
- sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos())->next
+ sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos())->previous_,
+ sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos())->next_
#else
- sel_start_cursor.par()->previous,
- sel_end_cursor.par()->next
+ sel_start_cursor.par()->previous(),
+ sel_end_cursor.par()->next()
#endif
);
cursor = sel_start_cursor;
#endif
cursor.pos() < sel_end_cursor.pos()))
{
- if (cursor.pos() < cursor.par()->Last()
#ifndef NEW_INSETS
+ if (cursor.pos() < cursor.par()->Last()
&& cursor.par()->footnoteflag
== sel_start_cursor.par()->footnoteflag
+#else
+ if (cursor.pos() < cursor.par()->size()
#endif
) {
// an open footnote should behave
LyXFont newfont = GetFont(bview->buffer(),
cursor.par(), cursor.pos());
newfont.update(font,
- bview->buffer()->params.language_info,
+ bview->buffer()->params.language,
toggleall);
SetCharFont(bview->buffer(),
cursor.par(), cursor.pos(), newfont);
cursor.pos(cursor.pos() + 1);
} else {
cursor.pos(0);
- cursor.par(cursor.par()->Next());
+ cursor.par(cursor.par()->next());
}
}
- RedoParagraphs(bview, sel_start_cursor, sel_end_cursor.par()->Next());
+ RedoParagraphs(bview, sel_start_cursor, sel_end_cursor.par()->next());
// we have to reset the selection, because the
// geometry could have changed
SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos());
sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
- ClearSelection();
- SetSelection();
+ ClearSelection(bview);
+ SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true,
tmpcursor.boundary());
}
void LyXText::RedoHeightOfParagraph(BufferView * bview, LyXCursor const & cur)
{
Row * tmprow = cur.row();
- long y = cur.y() - tmprow->baseline();
+ int y = cur.y() - tmprow->baseline();
SetHeightOfRow(bview, tmprow);
#ifndef NEW_INSETS
{
Row * tmprow = cur.row();
- long y = cur.y() - tmprow->baseline();
+ int y = cur.y() - tmprow->baseline();
SetHeightOfRow(bview, tmprow);
#ifndef NEW_INSETS
LyXParagraph * first_phys_par = tmprow->par()->FirstPhysicalPar();
Row * tmprow = cur.row();
- long y = cur.y() - tmprow->baseline();
+ int y = cur.y() - tmprow->baseline();
if (!tmprow->previous()){
first_phys_par = FirstParagraph(); // a trick/hack for UNDO
tmprow = firstrow;
while (tmprow->next() && tmprow->next()->par() == tmppar)
tmprow = tmprow->next();
- tmppar = tmppar->Next();
+ tmppar = tmppar->next();
}
} while (tmppar != endpar);
* They also delete the corresponding row */
// need the selection cursor:
-void LyXText::SetSelection()
+void LyXText::SetSelection(BufferView * bview)
{
+ const bool lsel = selection;
+
if (!selection) {
last_sel_cursor = sel_cursor;
sel_start_cursor = sel_cursor;
if (sel_start_cursor.par() == sel_end_cursor.par() &&
sel_start_cursor.pos() == sel_end_cursor.pos())
selection = false;
+
+ if (inset_owner && (selection || lsel))
+ inset_owner->SetUpdateStatus(bview, InsetText::SELECTION);
}
-string LyXText::selectionAsString(Buffer const * buffer) const
+string const LyXText::selectionAsString(Buffer const * buffer) const
{
if (!selection) return string();
string result;
// The selection spans more than one paragraph
// First paragraph in selection
+#ifndef NEW_INSETS
result += sel_start_cursor.par()->String(buffer,
sel_start_cursor.pos(),
sel_start_cursor.par()->Last())
+ "\n\n";
+#else
+ result += sel_start_cursor.par()->String(buffer,
+ sel_start_cursor.pos(),
+ sel_start_cursor.par()->size())
+ + "\n\n";
+#endif
// The paragraphs in between (if any)
LyXCursor tmpcur(sel_start_cursor);
- tmpcur.par(tmpcur.par()->Next());
+ tmpcur.par(tmpcur.par()->next());
while (tmpcur.par() != sel_end_cursor.par()) {
+#ifndef NEW_INSETS
result += tmpcur.par()->String(buffer, 0, tmpcur.par()->Last()) + "\n\n";
- tmpcur.par(tmpcur.par()->Next()); // Or NextAfterFootnote??
+#else
+ result += tmpcur.par()->String(buffer, 0, tmpcur.par()->size()) + "\n\n";
+#endif
+ tmpcur.par(tmpcur.par()->next()); // Or NextAfterFootnote??
}
// Last paragraph in selection
}
-void LyXText::ClearSelection() const
+void LyXText::ClearSelection(BufferView * /*bview*/) const
{
selection = false;
mark_set = false;
if (!cursor.row()->next() || cursor.row()->next()->par() != cursor.row()->par())
SetCursor(bview, cursor.par(), RowLast(cursor.row()) + 1);
else {
- if (cursor.par()->Last() &&
+#ifndef NEW_INSETS
+ if (cursor.par()->Last() &&
+#else
+ if (cursor.par()->size() &&
+#endif
(cursor.par()->GetChar(RowLast(cursor.row())) == ' '
|| cursor.par()->IsNewline(RowLast(cursor.row()))))
SetCursor(bview, cursor.par(), RowLast(cursor.row()));
else
SetCursor(bview,cursor.par(), RowLast(cursor.row()) + 1);
}
-#ifndef NEW_TABULAR
- if (cursor.par()->table) {
- int cell = NumberOfCell(cursor.par(), cursor.pos());
- if (cursor.par()->table->RowHasContRow(cell) &&
- cursor.par()->table->CellHasContRow(cell)<0) {
- if (!cursor.row()->next() || cursor.row()->next()->par() != cursor.row()->par())
- SetCursor(bview, cursor.par(), RowLast(cursor.row()) + 1);
- else {
- if (cursor.par()->Last() &&
- (cursor.par()->GetChar(RowLast(cursor.row())) == ' '
- || cursor.par()->IsNewline(RowLast(cursor.row()))))
- SetCursor(bview, cursor.par(), RowLast(cursor.row()));
- else
- SetCursor(bview, cursor.par(), RowLast(cursor.row()) + 1);
- }
- }
- }
-#endif
}
void LyXText::CursorTop(BufferView * bview) const
{
- while (cursor.par()->Previous())
- cursor.par(cursor.par()->Previous());
+ while (cursor.par()->previous())
+ cursor.par(cursor.par()->previous());
SetCursor(bview, cursor.par(), 0);
}
void LyXText::CursorBottom(BufferView * bview) const
{
- while (cursor.par()->Next())
- cursor.par(cursor.par()->Next());
+ while (cursor.par()->next())
+ cursor.par(cursor.par()->next());
+#ifndef NEW_INSETS
SetCursor(bview, cursor.par(), cursor.par()->Last());
+#else
+ SetCursor(bview, cursor.par(), cursor.par()->size());
+#endif
}
/* returns a pointer to the row near the specified y-coordinate
* (relative to the whole text). y is set to the real beginning
* of this row */
-Row * LyXText::GetRowNearY(long & y) const
+Row * LyXText::GetRowNearY(int & y) const
{
Row * tmprow = firstrow;
- long tmpy = 0;
+ int tmpy = 0;
while (tmprow->next() && tmpy + tmprow->height() <= y) {
tmpy += tmprow->height();
// If there is a change in the language the implicit word selection
// is disabled.
LyXCursor resetCursor = cursor;
- bool implicitSelection = (font.language() == ignore_language)
+ bool implicitSelection = (font.language() == ignore_language
+ && font.number() == LyXFont::IGNORE)
? SelectWordWhenUnderCursor(bview) : false;
// Set font
/* Implicit selections are cleared afterwards and cursor is set to the
original position. */
if (implicitSelection) {
- ClearSelection();
+ ClearSelection(bview);
cursor = resetCursor;
SetCursor(bview, cursor.par(), cursor.pos());
sel_cursor = cursor;
}
+ if (inset_owner)
+ inset_owner->SetUpdateStatus(bview, InsetText::CURSOR_PAR);
}
{
LyXParagraph * tmppar, * firsttmppar;
- ClearSelection();
+ ClearSelection(bview);
/* is is only allowed, if the cursor is IN an open footnote.
* Otherwise it is too dangerous */
return;
SetUndo(bview->buffer(), Undo::FINISH,
- cursor.par()->PreviousBeforeFootnote()->previous,
- cursor.par()->NextAfterFootnote()->next);
+ cursor.par()->PreviousBeforeFootnote()->previous_,
+ cursor.par()->NextAfterFootnote()->next_);
/* ok, move to the beginning of the footnote. */
while (cursor.par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE)
- cursor.par(cursor.par()->Previous());
+ cursor.par(cursor.par()->previous());
SetCursor(bview, cursor.par(), cursor.par()->Last());
/* this is just faster than using CursorLeft(); */
tmppar = firsttmppar;
/* tmppar is now the paragraph right before the footnote */
- bool first_footnote_par_is_not_empty = tmppar->next->size();
+ bool first_footnote_par_is_not_empty = tmppar->next_->size();
- while (tmppar->next
- && tmppar->next->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
- tmppar = tmppar->next; /* I use next instead of Next(),
+ while (tmppar->next_
+ && tmppar->next_->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
+ tmppar = tmppar->next_; /* I use next instead of Next(),
* because there cannot be any
* footnotes in a footnote
* environment */
// now we will paste the ex-footnote, if the layouts allow it
// first restore the layout of the paragraph right behind
// the footnote
- if (tmppar->next)
- tmppar->next->MakeSameLayout(cursor.par());
+ if (tmppar->next_)
+ tmppar->next_->MakeSameLayout(cursor.par());
// first the end
- if ((!tmppar->GetLayout() && !tmppar->table)
- || (tmppar->Next()
- && (!tmppar->Next()->Last()
- || tmppar->Next()->HasSameLayout(tmppar)))) {
- if (tmppar->Next()->Last()
- && tmppar->Next()->IsLineSeparator(0))
- tmppar->Next()->Erase(0);
+ if (!tmppar->GetLayout()
+ || (tmppar->next()
+ && (!tmppar->next()->Last()
+ || tmppar->next()->HasSameLayout(tmppar)))) {
+ if (tmppar->next()->Last()
+ && tmppar->next()->IsLineSeparator(0))
+ tmppar->next()->Erase(0);
tmppar->PasteParagraph(bview->buffer()->params);
}
- tmppar = tmppar->Next(); /* make sure tmppar cannot be touched
+ tmppar = tmppar->next(); /* make sure tmppar cannot be touched
* by the pasting of the beginning */
/* then the beginning */
/* if there is no space between the text and the footnote, so we insert
* a blank
* (only if the previous par and the footnotepar are not empty!) */
- if ((!firsttmppar->next->GetLayout() && !firsttmppar->next->table)
- || firsttmppar->HasSameLayout(firsttmppar->next)) {
+ if (!firsttmppar->next_->GetLayout()
+ || firsttmppar->HasSameLayout(firsttmppar->next_)) {
if (firsttmppar->size()
&& !firsttmppar->IsSeparator(firsttmppar->size() - 1)
&& first_footnote_par_is_not_empty) {
- firsttmppar->next->InsertChar(0, ' ');
+ firsttmppar->next_->InsertChar(0, ' ');
}
firsttmppar->PasteParagraph(bview->buffer()->params);
}
UpdateCounters(bview, row);
- ClearSelection();
+ ClearSelection(bview);
}
#endif
// make sure that the depth behind the selection are restored, too
#ifndef NEW_INSETS
- LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next();
+ LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->next();
#else
- LyXParagraph * endpar = sel_end_cursor.par()->Next();
+ LyXParagraph * endpar = sel_end_cursor.par()->next();
#endif
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
#ifndef NEW_INSETS
- endpar = endpar->LastPhysicalPar()->Next();
+ endpar = endpar->LastPhysicalPar()->next();
#else
- endpar = endpar->Next();
+ endpar = endpar->next();
#endif
undoendpar = endpar;
}
}
else if (endpar) {
- endpar = endpar->Next(); // because of parindents etc.
+ endpar = endpar->next(); // because of parindents etc.
}
SetUndo(bview->buffer(), Undo::EDIT,
#ifndef NEW_INSETS
sel_start_cursor
- .par()->ParFromPos(sel_start_cursor.pos())->previous,
+ .par()->ParFromPos(sel_start_cursor.pos())->previous_,
#else
- sel_start_cursor.par()->previous,
+ sel_start_cursor.par()->previous(),
#endif
undoendpar);
LyXParagraph * tmppar = sel_end_cursor.par();
#ifndef NEW_INSETS
- while (tmppar != sel_start_cursor.par()->FirstPhysicalPar()->Previous()) {
+ while (tmppar != sel_start_cursor.par()->FirstPhysicalPar()->previous()) {
SetCursor(bview, tmppar->FirstPhysicalPar(), 0);
#else
- while (tmppar != sel_start_cursor.par()->Previous()) {
+ while (tmppar != sel_start_cursor.par()->previous()) {
SetCursor(bview, tmppar, 0);
#endif
status = LyXText::NEED_MORE_REFRESH;
if (cursor.par()->footnoteflag ==
sel_start_cursor.par()->footnoteflag) {
#endif
- cursor.par()->line_top = line_top;
- cursor.par()->line_bottom = line_bottom;
- cursor.par()->pagebreak_top = pagebreak_top;
- cursor.par()->pagebreak_bottom = pagebreak_bottom;
- cursor.par()->added_space_top = space_top;
- cursor.par()->added_space_bottom = space_bottom;
+ cursor.par()->params.lineTop(line_top);
+ cursor.par()->params.lineBottom(line_bottom);
+ cursor.par()->params.pagebreakTop(pagebreak_top);
+ cursor.par()->params.pagebreakBottom(pagebreak_bottom);
+ cursor.par()->params.spaceTop(space_top);
+ cursor.par()->params.spaceBottom(space_bottom);
// does the layout allow the new alignment?
if (align == LYX_ALIGN_LAYOUT)
align = textclasslist
if (align == textclasslist
.Style(bview->buffer()->params.textclass,
cursor.par()->GetLayout()).align)
- cursor.par()->align = LYX_ALIGN_LAYOUT;
+ cursor.par()->params.align(LYX_ALIGN_LAYOUT);
else
- cursor.par()->align = align;
+ cursor.par()->params.align(align);
}
cursor.par()->SetLabelWidthString(labelwidthstring);
- cursor.par()->noindent = noindent;
+ cursor.par()->params.noindent(noindent);
#ifndef NEW_INSETS
}
- tmppar = cursor.par()->FirstPhysicalPar()->Previous();
+ tmppar = cursor.par()->FirstPhysicalPar()->previous();
#else
- tmppar = cursor.par()->Previous();
+ tmppar = cursor.par()->previous();
#endif
}
RedoParagraphs(bview, sel_start_cursor, endpar);
- ClearSelection();
+ ClearSelection(bview);
SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos());
sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
- SetSelection();
+ SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
if (inset_owner)
bview->updateInset(inset_owner, true);
}
+#ifndef NO_PEXTRA
void LyXText::SetParagraphExtraOpt(BufferView * bview, int type,
- char const * width,
- char const * widthp,
+ string const & width,
+ string const & widthp,
int alignment, bool hfill,
bool start_minipage)
{
// make sure that the depth behind the selection are restored, too
#ifndef NEW_INSETS
- LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next();
+ LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->next();
#else
- LyXParagraph * endpar = sel_end_cursor.par()->Next();
+ LyXParagraph * endpar = sel_end_cursor.par()->next();
#endif
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
#ifndef NEW_INSETS
- endpar = endpar->LastPhysicalPar()->Next();
+ endpar = endpar->LastPhysicalPar()->next();
#else
- endpar = endpar->Next();
+ endpar = endpar->next();
#endif
undoendpar = endpar;
}
}
else if (endpar) {
- endpar = endpar->Next(); // because of parindents etc.
+ endpar = endpar->next(); // because of parindents etc.
}
SetUndo(bview->buffer(), Undo::EDIT,
#ifndef NEW_INSETS
sel_start_cursor
- .par()->ParFromPos(sel_start_cursor.pos())->previous,
+ .par()->ParFromPos(sel_start_cursor.pos())->previous_,
#else
- sel_start_cursor.par()->previous,
+ sel_start_cursor.par()->previous(),
#endif
undoendpar);
tmppar = sel_end_cursor.par();
#ifndef NEW_INSETS
- while(tmppar != sel_start_cursor.par()->FirstPhysicalPar()->Previous()) {
+ while(tmppar != sel_start_cursor.par()->FirstPhysicalPar()->previous()) {
SetCursor(bview, tmppar->FirstPhysicalPar(), 0);
#else
- while(tmppar != sel_start_cursor.par()->Previous()) {
+ while(tmppar != sel_start_cursor.par()->previous()) {
SetCursor(bview, tmppar, 0);
#endif
status = LyXText::NEED_MORE_REFRESH;
if (cursor.par()->footnoteflag ==
sel_start_cursor.par()->footnoteflag) {
#endif
+#ifndef NO_PEXTRA
if (type == LyXParagraph::PEXTRA_NONE) {
- if (cursor.par()->pextra_type != LyXParagraph::PEXTRA_NONE) {
+ if (cursor.par()->params.pextraType() != LyXParagraph::PEXTRA_NONE) {
cursor.par()->UnsetPExtraType(bview->buffer()->params);
- cursor.par()->pextra_type = LyXParagraph::PEXTRA_NONE;
+ cursor.par()->params.pextraType(LyXParagraph::PEXTRA_NONE);
}
} else {
cursor.par()->SetPExtraType(bview->buffer()->params,
type, width, widthp);
- cursor.par()->pextra_hfill = hfill;
- cursor.par()->pextra_start_minipage = start_minipage;
- cursor.par()->pextra_alignment = alignment;
+ cursor.par()->params.pextraHfill(hfill);
+ cursor.par()->params.pextraStartMinipage(start_minipage);
+ cursor.par()->params.pextraAlignment(alignment);
}
+#endif
#ifndef NEW_INSETS
}
- tmppar = cursor.par()->FirstPhysicalPar()->Previous();
+ tmppar = cursor.par()->FirstPhysicalPar()->previous();
#else
- tmppar = cursor.par()->Previous();
+ tmppar = cursor.par()->previous();
#endif
}
RedoParagraphs(bview, sel_start_cursor, endpar);
- ClearSelection();
+ ClearSelection(bview);
SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos());
sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
- SetSelection();
+ SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
}
-
+#endif
+
char loweralphaCounter(int n)
{
}
+namespace {
+
+inline
char alphaCounter(int n)
{
if (n < 1 || n > 26)
}
+inline
char hebrewCounter(int n)
{
static const char hebrew[22] = {
}
-static
-char const * romanCounter(int n)
+inline
+string const romanCounter(int n)
{
static char const * roman[20] = {
"i", "ii", "iii", "iv", "v",
return roman[n-1];
}
+} // namespace anon
+
// set the counter of a paragraph. This includes the labels
void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const
/* copy the prev-counters to this one, unless this is the start of a
footnote or of a bibliography or the very first paragraph */
- if (par->Previous()
+ if (par->previous()
#ifndef NEW_INSETS
- && !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE
+ && !(par->previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE
&& par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE)
#endif
&& !(textclasslist.Style(buf->params.textclass,
- par->Previous()->GetLayout()
+ par->previous()->GetLayout()
).labeltype != LABEL_BIBLIO
&& layout.labeltype == LABEL_BIBLIO)) {
for (int i = 0; i < 10; ++i) {
- par->setCounter(i, par->Previous()->GetFirstCounter(i));
+ par->setCounter(i, par->previous()->GetFirstCounter(i));
}
#ifndef NEW_INSETS
- par->appendix = par->Previous()->FirstPhysicalPar()->appendix;
+ par->params.appendix(par->previous()->FirstPhysicalPar()->params.appendix());
#else
- par->appendix = par->Previous()->appendix;
+ par->params.appendix(par->previous()->params.appendix());
#endif
- if (!par->appendix && par->start_of_appendix){
- par->appendix = true;
+ if (!par->params.appendix() && par->params.startOfAppendix()) {
+ par->params.appendix(true);
for (int i = 0; i < 10; ++i) {
par->setCounter(i, 0);
}
}
#ifndef NEW_INSETS
- par->enumdepth = par->Previous()->FirstPhysicalPar()->enumdepth;
- par->itemdepth = par->Previous()->FirstPhysicalPar()->itemdepth;
+ par->enumdepth = par->previous()->FirstPhysicalPar()->enumdepth;
+ par->itemdepth = par->previous()->FirstPhysicalPar()->itemdepth;
#else
- par->enumdepth = par->Previous()->enumdepth;
- par->itemdepth = par->Previous()->itemdepth;
+ par->enumdepth = par->previous()->enumdepth;
+ par->itemdepth = par->previous()->itemdepth;
#endif
} else {
for (int i = 0; i < 10; ++i) {
par->setCounter(i, 0);
}
- par->appendix = par->start_of_appendix;
+ par->params.appendix(par->params.startOfAppendix());
par->enumdepth = 0;
par->itemdepth = 0;
}
// entry in the marginnote and the enclosing
// environment is an enum/item then correct for the
// LaTeX behaviour (ARRae)
- if(par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
+ if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::MARGIN
- && par->Previous()
- && par->Previous()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE
+ && par->previous()
+ && par->previous()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE
&& (par->PreviousBeforeFootnote()
&& textclasslist.Style(buf->params.textclass,
par->PreviousBeforeFootnote()->GetLayout()
* AND, bibliographies can't have their depth changed ie. they
* are always of depth 0
*/
- if (par->Previous()
- && par->Previous()->GetDepth() < par->GetDepth()
+ if (par->previous()
+ && par->previous()->GetDepth() < par->GetDepth()
&& textclasslist.Style(buf->params.textclass,
- par->Previous()->GetLayout()
+ par->previous()->GetLayout()
).labeltype == LABEL_COUNTER_ENUMI
&& par->enumdepth < 3
#ifndef NEW_INSETS
- && !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE
+ && !(par->previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE
&& par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE)
#endif
}
/* Maybe we have to decrement the enumeration depth, see note above */
- if (par->Previous()
- && par->Previous()->GetDepth() > par->GetDepth()
+ if (par->previous()
+ && par->previous()->GetDepth() > par->GetDepth()
#ifndef NEW_INSETS
- && !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE
+ && !(par->previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE
&& par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE)
#endif
par->setCounter(i, 0);
}
- if (!par->labelstring.empty()) {
- par->labelstring.erase();
+ if (!par->params.labelString().empty()) {
+ par->params.labelString(string());
}
if (layout.margintype == MARGIN_MANUAL) {
- if (par->labelwidthstring.empty()) {
+ if (par->params.labelWidthString().empty()) {
par->SetLabelWidthString(layout.labelstring());
}
} else {
par->incCounter(i); // increment the counter
// Is there a label? Useful for Chapter layout
- if (!par->appendix){
+ if (!par->params.appendix()) {
if (!layout.labelstring().empty())
- par->labelstring = layout.labelstring();
+ par->params.labelString(layout.labelstring());
else
- par->labelstring.erase();
+ par->params.labelString(string());
} else {
if (!layout.labelstring_appendix().empty())
- par->labelstring = layout.labelstring_appendix();
+ par->params.labelString(layout.labelstring_appendix());
else
- par->labelstring.erase();
+ par->params.labelString(string());
}
-#ifdef HAVE_SSTREAM
std::ostringstream s;
-#else
- ostrstream s;
-#endif
- if (!par->appendix) {
+
+ if (!par->params.appendix()) {
switch (2 * LABEL_COUNTER_CHAPTER -
textclass.maxcounter() + i) {
case LABEL_COUNTER_CHAPTER:
break;
}
}
-#ifdef HAVE_SSTREAM
- par->labelstring += s.str().c_str();
+
+ par->params.labelString(par->params.labelString() +s.str().c_str());
// We really want to remove the c_str as soon as
// possible...
-#else
- s << '\0';
- char * tmps = s.str();
- par->labelstring += tmps;
- delete [] tmps;
-#endif
for (i++; i < 10; ++i) {
// reset the following counters
par->incCounter(i + par->enumdepth);
int number = par->getCounter(i + par->enumdepth);
-#ifdef HAVE_SSTREAM
std::ostringstream s;
-#else
- ostrstream s;
-#endif
+
switch (par->enumdepth) {
case 1:
if (par->isRightToLeftPar(buf->params))
s << number << '.';
break;
}
-#ifdef HAVE_SSTREAM
- par->labelstring = s.str().c_str();
+
+ par->params.labelString(s.str().c_str());
// we really want to get rid of that c_str()
-#else
- s << '\0';
- char * tmps = s.str();
- par->labelstring = tmps;
- delete [] tmps;
-#endif
for (i += par->enumdepth + 1; i < 10; ++i)
par->setCounter(i, 0); /* reset the following counters */
int i = LABEL_COUNTER_ENUMI - LABEL_COUNTER_CHAPTER + par->enumdepth;
par->incCounter(i);
int number = par->getCounter(i);
- if (!par->bibkey)
- par->bibkey = new InsetBibKey();
+ if (!par->bibkey) {
+ InsetCommandParams p( "bibitem" );
+ par->bibkey = new InsetBibKey(p);
+ }
par->bibkey->setCounter(number);
- par->labelstring = layout.labelstring();
+ par->params.labelString(layout.labelstring());
// In biblio should't be following counters but...
} else {
Floating const & fl
= floatList.getType(tmp->type());
// We should get the correct number here too.
- s = fl.name + " #:";
+ s = fl.name() + " #:";
} else {
/* par->SetLayout(0);
s = layout->labelstring; */
? " :úåòîùî øñç" : "Senseless: ";
}
}
- par->labelstring = s;
+ par->params.labelString(s);
/* reset the enumeration counter. They are always resetted
* when there is any other layout between */
void LyXText::UpdateCounters(BufferView * bview, Row * row) const
{
LyXParagraph * par;
+#ifndef NEW_INSETS
if (!row) {
row = firstrow;
par = row->par();
+ } else if (row->par()->next_
+ && row->par()->next_->footnoteflag != LyXParagraph::OPEN_FOOTNOTE) {
+ par = row->par()->LastPhysicalPar()->next();
} else {
- if (row->par()->next
-#ifndef NEW_INSETS
- && row->par()->next->footnoteflag != LyXParagraph::OPEN_FOOTNOTE
-#endif
- ) {
-#ifndef NEW_INSETS
- par = row->par()->LastPhysicalPar()->Next();
+ par = row->par()->next_;
+ }
#else
- par = row->par()->Next();
-#endif
- } else {
- par = row->par()->next;
- }
+ if (!row) {
+ row = firstrow;
+ par = row->par();
+ } else {
+ par = row->par()->next();
}
+#endif
while (par) {
while (row->par() != par)
#ifndef NEW_INSETS
/* think about the damned open footnotes! */
- while (par->Next() &&
- (par->Next()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
- || par->Next()->IsDummy())){
- par = par->Next();
+ while (par->next() &&
+ (par->next()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
+ || par->next()->IsDummy())){
+ par = par->next();
if (par->IsDummy()) {
while (row->par() != par)
row = row->next();
#endif
}
#ifndef NEW_INSETS
- par = par->LastPhysicalPar()->Next();
+ par = par->LastPhysicalPar()->next();
#else
- par = par->Next();
+ par = par->next();
#endif
}
return;
SetUndo(bview->buffer(), Undo::INSERT,
#ifndef NEW_INSETS
- cursor.par()->ParFromPos(cursor.pos())->previous,
- cursor.par()->ParFromPos(cursor.pos())->next
+ cursor.par()->ParFromPos(cursor.pos())->previous_,
+ cursor.par()->ParFromPos(cursor.pos())->next_
#else
- cursor.par()->previous,
- cursor.par()->next
+ cursor.par()->previous(),
+ cursor.par()->next()
#endif
);
cursor.par()->InsertInset(cursor.pos(), inset);
InsertChar(bview, LyXParagraph::META_INSET); /* just to rebreak and refresh correctly.
* The character will not be inserted a
* second time */
+#if 1
+ // If we enter a highly editable inset the cursor should be to before
+ // the inset. This couldn't happen before as Undo was not handled inside
+ // inset now after the Undo LyX tries to call inset->Edit(...) again
+ // and cannot do this as the cursor is behind the inset and GetInset
+ // does not return the inset!
+ if (inset->Editable() == Inset::HIGHLY_EDITABLE) {
+ CursorLeft(bview, true);
+ }
+#endif
}
return;
// OK, we have a selection. This is always between sel_start_cursor
- // and sel_end cursor
+ // and sel_end_cursor
#ifndef NEW_INSETS
// Check whether there are half footnotes in the selection
if (sel_start_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE
_("sorry."));
return;
}
- tmppar = tmppar->Next();
- }
- }
-#endif
-#ifndef NEW_TABULAR
- /* table stuff -- begin */
- if (sel_start_cursor.par()->table || sel_end_cursor.par()->table) {
- if ( sel_start_cursor.par() != sel_end_cursor.par()) {
- WriteAlert(_("Impossible operation"),
- _("Don't know what to do with half tables."),
- _("sorry."));
- return;
+ tmppar = tmppar->next();
}
- sel_start_cursor.par()->table->Reinit();
}
- /* table stuff -- end */
#endif
+
// make sure that the depth behind the selection are restored, too
#ifndef NEW_INSETS
- LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next();
+ LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->next();
#else
- LyXParagraph * endpar = sel_end_cursor.par()->Next();
+ LyXParagraph * endpar = sel_end_cursor.par()->next();
#endif
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
#ifndef NEW_INSETS
- endpar = endpar->LastPhysicalPar()->Next();
+ endpar = endpar->LastPhysicalPar()->next();
#else
- endpar = endpar->Next();
+ endpar = endpar->next();
#endif
undoendpar = endpar;
}
} else if (endpar) {
- endpar = endpar->Next(); // because of parindents etc.
+ endpar = endpar->next(); // because of parindents etc.
}
SetUndo(bview->buffer(), Undo::DELETE,
#ifndef NEW_INSETS
sel_start_cursor
- .par()->ParFromPos(sel_start_cursor.pos())->previous,
+ .par()->ParFromPos(sel_start_cursor.pos())->previous_,
#else
- sel_start_cursor.par()->previous,
+ sel_start_cursor.par()->previous(),
#endif
undoendpar);
sel_end_cursor.pos(pos);
cursor.pos(sel_end_cursor.pos());
}
- endpar = endpar->Next();
+ endpar = endpar->next();
// sometimes necessary
if (doclear)
RedoParagraphs(bview, sel_start_cursor, endpar);
- ClearSelection();
+ ClearSelection(bview);
cursor = sel_start_cursor;
SetCursor(bview, cursor.par(), cursor.pos());
sel_cursor = cursor;
_("sorry."));
return;
}
- tmppar = tmppar->Next();
- }
- }
-#endif
-#ifndef NEW_TABULAR
- /* table stuff -- begin */
- if (sel_start_cursor.par()->table || sel_end_cursor.par()->table){
- if ( sel_start_cursor.par() != sel_end_cursor.par()){
- WriteAlert(_("Impossible operation"),
- _("Don't know what to do with half tables."),
- _("sorry."));
- return;
+ tmppar = tmppar->next();
}
}
- /* table stuff -- end */
#endif
// copy behind a space if there is one
+#ifndef NEW_INSETS
while (sel_start_cursor.par()->Last() > sel_start_cursor.pos()
+#else
+ while (sel_start_cursor.par()->size() > sel_start_cursor.pos()
+#endif
&& sel_start_cursor.par()->IsLineSeparator(sel_start_cursor.pos())
&& (sel_start_cursor.par() != sel_end_cursor.par()
|| sel_start_cursor.pos() < sel_end_cursor.pos()))
CutAndPaste cap;
// this does not make sense, if there is nothing to paste
- if (!cap.checkPastePossible(cursor.par(), cursor.pos()))
+ if (!cap.checkPastePossible(cursor.par()))
return;
SetUndo(bview->buffer(), Undo::INSERT,
#ifndef NEW_INSETS
- cursor.par()->ParFromPos(cursor.pos())->previous,
- cursor.par()->ParFromPos(cursor.pos())->next
+ cursor.par()->ParFromPos(cursor.pos())->previous_,
+ cursor.par()->ParFromPos(cursor.pos())->next_
#else
- cursor.par()->previous,
- cursor.par()->next
+ cursor.par()->previous(),
+ cursor.par()->next()
#endif
);
RedoParagraphs(bview, cursor, endpar);
SetCursor(bview, cursor.par(), cursor.pos());
- ClearSelection();
+ ClearSelection(bview);
sel_cursor = cursor;
SetCursor(bview, actpar, pos);
- SetSelection();
+ SetSelection(bview);
UpdateCounters(bview, cursor.row());
}
}
-// returns true if the specified string is at the specified position
-bool LyXText::IsStringInText(LyXParagraph * par,
- LyXParagraph::size_type pos,
- char const * str) const
-{
- if (par) {
- int i = 0;
- while (pos + i < par->Last() && str[i] &&
- str[i] == par->GetChar(pos + i)) {
- ++i;
- }
- if (!str[i])
- return true;
- }
- return false;
-}
-
-
// sets the selection over the number of characters of string, no check!!
-void LyXText::SetSelectionOverString(BufferView * bview, char const * string)
+void LyXText::SetSelectionOverString(BufferView * bview, string const & str)
{
sel_cursor = cursor;
- for (int i = 0; string[i]; ++i)
+ for (int i = 0; str[i]; ++i)
CursorRight(bview);
- SetSelection();
+ SetSelection(bview);
}
// simple replacing. The font of the first selected character is used
-void LyXText::ReplaceSelectionWithString(BufferView * bview, char const * str)
+void LyXText::ReplaceSelectionWithString(BufferView * bview,
+ string const & str)
{
SetCursorParUndo(bview->buffer());
FreezeUndo();
// Get font setting before we cut
LyXParagraph::size_type pos = sel_end_cursor.pos();
- LyXFont font = sel_start_cursor.par()->GetFontSettings(bview->buffer()->params,
- sel_start_cursor.pos());
+ LyXFont const font = sel_start_cursor.par()
+ ->GetFontSettings(bview->buffer()->params,
+ sel_start_cursor.pos());
// Insert the new string
- for (int i = 0; str[i]; ++i) {
- sel_end_cursor.par()->InsertChar(pos, str[i], font);
+ for (string::const_iterator cit = str.begin(); cit != str.end(); ++cit) {
+ sel_end_cursor.par()->InsertChar(pos, (*cit), font);
++pos;
}
-
+
// Cut the selection
CutSelection(bview);
}
-// if the string can be found: return true and set the cursor to
-// the new position
-bool LyXText::SearchForward(BufferView * bview, char const * str) const
-{
- LyXParagraph * par = cursor.par();
- LyXParagraph::size_type pos = cursor.pos();
- while (par && !IsStringInText(par, pos, str)) {
- if (pos < par->Last() - 1)
- ++pos;
- else {
- pos = 0;
- par = par->Next();
- }
- }
- if (par) {
- SetCursor(bview, par, pos);
- return true;
- }
- else
- return false;
-}
-
-
-bool LyXText::SearchBackward(BufferView * bview, char const * string) const
-{
- LyXParagraph * par = cursor.par();
- int pos = cursor.pos();
-
- do {
- if (pos > 0)
- --pos;
- else {
- // We skip empty paragraphs (Asger)
- do {
- par = par->Previous();
- if (par)
- pos = par->Last() - 1;
- } while (par && pos < 0);
- }
- } while (par && !IsStringInText(par, pos, string));
-
- if (par) {
- SetCursor(bview, par, pos);
- return true;
- } else
- return false;
-}
-
-
// needed to insert the selection
void LyXText::InsertStringA(BufferView * bview, string const & str)
{
LyXParagraph * par = cursor.par();
LyXParagraph::size_type pos = cursor.pos();
LyXParagraph::size_type a = 0;
- LyXParagraph * endpar = cursor.par()->Next();
+ LyXParagraph * endpar = cursor.par()->next();
SetCursorParUndo(bview->buffer());
textclasslist.Style(bview->buffer()->params.textclass,
cursor.par()->GetLayout()).isEnvironment();
// only to be sure, should not be neccessary
- ClearSelection();
+ ClearSelection(bview);
// insert the string, don't insert doublespace
string::size_type i = 0;
&& pos && par->GetChar(pos - 1)!= ' ') {
par->InsertChar(pos, ' ', current_font);
++pos;
-#ifndef NEW_TABULAR
- } else if (par->table) {
- if (str[i] == '\t') {
- while((pos < par->size()) &&
- (par->GetChar(pos) != LyXParagraph::META_NEWLINE))
- ++pos;
- if (pos < par->size())
- ++pos;
- else // no more fields to fill skip the rest
- break;
- } else if ((str[i] != 13) &&
- ((str[i] & 127) >= ' ')) {
- par->InsertChar(pos, str[i],
- current_font);
- ++pos;
- }
-#endif
} else if (str[i] == ' ') {
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
++pos;
}
} else {
-#ifndef NEW_TABULAR
- if (par->table) {
- if ((i + 1) >= str.length()) {
- if (pos < par->size())
- ++pos;
- break;
- }
- while((pos < par->size()) &&
- (par->GetChar(pos) != LyXParagraph::META_NEWLINE))
- ++pos;
- ++pos;
- int cell = NumberOfCell(par, pos);
- while((pos < par->size()) &&
- !(par->table->IsFirstCell(cell))) {
-
- while((pos < par->size()) &&
- (par->GetChar(pos) != LyXParagraph::META_NEWLINE))
- ++pos;
- ++pos;
- cell = NumberOfCell(par, pos);
- }
- if (pos >= par->size())
- // no more fields to fill skip the rest
- break;
- } else {
-#endif
- if (!par->size()) { // par is empty
- InsetSpecialChar * new_inset =
- new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
- if (par->InsertInsetAllowed(new_inset)) {
- par->InsertInset(pos,
- new_inset,
- current_font);
- } else {
- delete new_inset;
- }
- ++pos;
- }
- par->BreakParagraph(bview->buffer()->params, pos, flag);
- par = par->Next();
- pos = 0;
-#ifndef NEW_TABULAR
- }
-#endif
+ if (!par->size()) { // par is empty
+ InsetSpecialChar * new_inset =
+ new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
+ if (par->InsertInsetAllowed(new_inset)) {
+ par->InsertInset(pos,
+ new_inset,
+ current_font);
+ } else {
+ delete new_inset;
+ }
+ ++pos;
+ }
+ par->BreakParagraph(bview->buffer()->params, pos, flag);
+ par = par->next();
+ pos = 0;
}
++i;
}
SetCursor(bview, cursor.par(), cursor.pos());
sel_cursor = cursor;
SetCursor(bview, par, pos);
- SetSelection();
+ SetSelection(bview);
}
void LyXText::InsertStringB(BufferView * bview, string const & s)
{
string str(s);
-#ifndef NEW_TABULAR
- LyXParagraph * par = cursor.par();
-#endif
string::size_type i = 1;
while (i < str.length()) {
- if (str[i] == '\t'
-#ifndef NEW_TABULAR
- && !par->table
-#endif
- )
+ if (str[i] == '\t')
str[i] = ' ';
if (str[i] == ' ' && i + 1 < str.length() && str[i + 1] == ' ')
str[i] = 13;
- if (str[i] == '\n' && i + 1 < str.length()
-#ifndef NEW_TABULAR
- && !par->table
-#endif
- ){
+ if (str[i] == '\n' && i + 1 < str.length()) {
if (str[i + 1] != '\n') {
if (str[i - 1] != ' ')
str[i] = ' ';
}
-bool LyXText::GotoNextError(BufferView * bview) const
+bool LyXText::GotoNextInset(BufferView * bview,
+ std::vector<Inset::Code> const & codes,
+ string const & contents) const
{
LyXCursor res = cursor;
+ Inset * inset;
do {
+#ifndef NEW_INSETS
if (res.pos() < res.par()->Last() - 1) {
+#else
+ if (res.pos() < res.par()->size() - 1) {
+#endif
res.pos(res.pos() + 1);
} else {
- res.par(res.par()->Next());
+ res.par(res.par()->next());
res.pos(0);
}
} while (res.par() &&
!(res.par()->GetChar(res.pos()) == LyXParagraph::META_INSET
- && res.par()->GetInset(res.pos())->AutoDelete()));
-
- if (res.par()) {
- SetCursor(bview, res.par(), res.pos());
- return true;
- }
- return false;
-}
-
+ && (inset = res.par()->GetInset(res.pos())) != 0
+ && find(codes.begin(), codes.end(), inset->LyxCode())
+ != codes.end()
+ && (contents.empty() ||
+ static_cast<InsetCommand *>(res.par()->GetInset(res.pos()))->getContents()
+ == contents)));
-bool LyXText::GotoNextNote(BufferView * bview) const
-{
- LyXCursor res = cursor;
- do {
- if (res.pos() < res.par()->Last() - 1) {
- res.pos(res.pos() + 1);
- } else {
- res.par(res.par()->Next());
- res.pos(0);
- }
-
- } while (res.par() &&
- !(res.par()->GetChar(res.pos()) == LyXParagraph::META_INSET
- && res.par()->GetInset(res.pos())->LyxCode() == Inset::IGNORE_CODE));
-
if (res.par()) {
SetCursor(bview, res.par(), res.pos());
return true;
{
LyXCursor tmpcursor;
-#ifndef NEW_TABULAR
- /* table stuff -- begin*/
-
- if (par->table) {
- CheckParagraphInTable(bview, par, pos);
- }
- else {
-#endif
- /* table stuff -- end*/
-
- long y = 0;
- LyXParagraph::size_type z;
- Row * row = GetRow(par, pos, y);
-
- // is there a break one row above
- if (row->previous() && row->previous()->par() == row->par()) {
- z = NextBreakPoint(bview, row->previous(), workWidth(bview));
- if ( z >= row->pos()) {
- // set the dimensions of the row above
- y -= row->previous()->height();
- refresh_y = y;
- refresh_row = row->previous();
- status = LyXText::NEED_MORE_REFRESH;
-
- BreakAgain(bview, row->previous());
-
- // set the cursor again. Otherwise
- // dangling pointers are possible
- SetCursor(bview, cursor.par(), cursor.pos());
- sel_cursor = cursor;
- return;
- }
+ int y = 0;
+ LyXParagraph::size_type z;
+ Row * row = GetRow(par, pos, y);
+
+ // is there a break one row above
+ if (row->previous() && row->previous()->par() == row->par()) {
+ z = NextBreakPoint(bview, row->previous(), workWidth(bview));
+ if (z >= row->pos()) {
+ // set the dimensions of the row above
+ y -= row->previous()->height();
+ refresh_y = y;
+ refresh_row = row->previous();
+ status = LyXText::NEED_MORE_REFRESH;
+
+ BreakAgain(bview, row->previous());
+
+ // set the cursor again. Otherwise
+ // dangling pointers are possible
+ SetCursor(bview, cursor.par(), cursor.pos(),
+ false, cursor.boundary());
+ sel_cursor = cursor;
+ return;
}
+ }
- int tmpheight = row->height();
- LyXParagraph::size_type tmplast = RowLast(row);
- refresh_y = y;
- refresh_row = row;
-
- BreakAgain(bview, row);
- if (row->height() == tmpheight && RowLast(row) == tmplast)
- status = LyXText::NEED_VERY_LITTLE_REFRESH;
- else
- status = LyXText::NEED_MORE_REFRESH;
-
- // check the special right address boxes
- if (textclasslist.Style(bview->buffer()->params.textclass,
- par->GetLayout()).margintype
- == MARGIN_RIGHT_ADDRESS_BOX) {
- tmpcursor.par(par);
- tmpcursor.row(row);
- tmpcursor.y(y);
- tmpcursor.x(0);
- tmpcursor.x_fix(0);
- tmpcursor.pos(pos);
- RedoDrawingOfParagraph(bview, tmpcursor);
- }
-#ifndef NEW_TABULAR
+ int const tmpheight = row->height();
+ LyXParagraph::size_type const tmplast = RowLast(row);
+ refresh_y = y;
+ refresh_row = row;
+
+ BreakAgain(bview, row);
+ if (row->height() == tmpheight && RowLast(row) == tmplast)
+ status = LyXText::NEED_VERY_LITTLE_REFRESH;
+ else
+ status = LyXText::NEED_MORE_REFRESH;
+
+ // check the special right address boxes
+ if (textclasslist.Style(bview->buffer()->params.textclass,
+ par->GetLayout()).margintype
+ == MARGIN_RIGHT_ADDRESS_BOX) {
+ tmpcursor.par(par);
+ tmpcursor.row(row);
+ tmpcursor.y(y);
+ tmpcursor.x(0);
+ tmpcursor.x_fix(0);
+ tmpcursor.pos(pos);
+ RedoDrawingOfParagraph(bview, tmpcursor);
}
-#endif
// set the cursor again. Otherwise dangling pointers are possible
// also set the selection
if (selection) {
tmpcursor = cursor;
- SetCursorIntern(bview, sel_cursor.par(), sel_cursor.pos());
+ SetCursorIntern(bview, sel_cursor.par(), sel_cursor.pos(),
+ false, sel_cursor.boundary());
sel_cursor = cursor;
SetCursorIntern(bview, sel_start_cursor.par(),
- sel_start_cursor.pos());
+ sel_start_cursor.pos(),
+ false, sel_start_cursor.boundary());
sel_start_cursor = cursor;
SetCursorIntern(bview, sel_end_cursor.par(),
- sel_end_cursor.pos());
+ sel_end_cursor.pos(),
+ false, sel_end_cursor.boundary());
sel_end_cursor = cursor;
SetCursorIntern(bview, last_sel_cursor.par(),
- last_sel_cursor.pos());
+ last_sel_cursor.pos(),
+ false, last_sel_cursor.boundary());
last_sel_cursor = cursor;
cursor = tmpcursor;
}
- SetCursorIntern(bview, cursor.par(), cursor.pos());
+ SetCursorIntern(bview, cursor.par(), cursor.pos(),
+ false, cursor.boundary());
}
#ifndef NEW_INSETS
}
#endif
- par = par->Next();
+ par = par->next();
} while (par);
return false;
pos = par->PositionInParFromPos(pos);
par = tmppar;
}
- if (par->IsDummy() && par->previous &&
- par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
- while (par->previous &&
- ((par->previous->IsDummy() &&
- (par->previous->previous->footnoteflag ==
+ if (par->IsDummy() && par->previous_ &&
+ par->previous_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
+ while (par->previous_ &&
+ ((par->previous_->IsDummy() &&
+ (par->previous_->previous_->footnoteflag ==
LyXParagraph::CLOSED_FOOTNOTE)) ||
- (par->previous->footnoteflag ==
+ (par->previous_->footnoteflag ==
LyXParagraph::CLOSED_FOOTNOTE))) {
- par = par->previous ;
+ par = par->previous_;
if (par->IsDummy() &&
- (par->previous->footnoteflag ==
+ (par->previous_->footnoteflag ==
LyXParagraph::CLOSED_FOOTNOTE))
pos += par->size() + 1;
}
- if (par->previous) {
- par = par->previous;
+ if (par->previous_) {
+ par = par->previous_;
}
pos += par->size() + 1;
}
cur.boundary(boundary);
/* get the cursor y position in text */
- long y = 0;
+ int y = 0;
Row * row = GetRow(par, pos, y);
/* y is now the beginning of the cursor row */
y += row->baseline();
cursor_vpos = (row->par()->isRightToLeftPar(bview->buffer()->params))
? row->pos() : last + 1;
else if (pos > row->pos() &&
- (pos > last || boundary
-#ifndef NEW_TABULAR
- || (row->par()->table && row->par()->IsNewline(pos))
-#endif
- ))
+ (pos > last || boundary))
/// Place cursor after char at (logical) position pos - 1
cursor_vpos = (bidi_level(pos - 1) % 2 == 0)
? log2vis(pos - 1) + 1 : log2vis(pos - 1);
/// Place cursor before char at (logical) position pos
cursor_vpos = (bidi_level(pos) % 2 == 0)
? log2vis(pos) : log2vis(pos) + 1;
-
-#ifndef NEW_TABULAR
- /* table stuff -- begin*/
- if (row->par()->table) {
- int cell = NumberOfCell(row->par(), row->pos());
- float x_old = x;
- x += row->par()->table->GetBeginningOfTextInCell(cell);
- for (LyXParagraph::size_type vpos = row->pos();
- vpos < cursor_vpos; ++vpos) {
- pos = vis2log(vpos);
- if (row->par()->IsNewline(pos)) {
- x = x_old + row->par()->table->WidthOfColumn(cell);
- x_old = x;
- ++cell;
- x += row->par()->table->GetBeginningOfTextInCell(cell);
- } else {
- x += SingleWidth(bview, row->par(), pos);
- }
- }
- } else {
- /* table stuff -- end*/
-#endif
- LyXParagraph::size_type main_body =
- BeginningOfMainBody(bview->buffer(), row->par());
- if ((main_body > 0) &&
- ((main_body-1 > last) ||
- !row->par()->IsLineSeparator(main_body-1)))
- main_body = 0;
-
- for (LyXParagraph::size_type vpos = row->pos();
- vpos < cursor_vpos; ++vpos) {
- pos = vis2log(vpos);
- if (main_body > 0 && pos == main_body-1) {
- x += fill_label_hfill +
- lyxfont::width(textclasslist.Style(
- bview->buffer()->params.textclass,
- row->par()->GetLayout())
- .labelsep,
- GetFont(bview->buffer(), row->par(), -2));
- if (row->par()->IsLineSeparator(main_body-1))
- x -= SingleWidth(bview, row->par(),main_body-1);
- }
- if (HfillExpansion(bview->buffer(), row, pos)) {
- x += SingleWidth(bview, row->par(), pos);
- if (pos >= main_body)
- x += fill_hfill;
- else
- x += fill_label_hfill;
- } else if (row->par()->IsSeparator(pos)) {
- x += SingleWidth(bview, row->par(), pos);
- if (pos >= main_body)
- x += fill_separator;
- } else
- x += SingleWidth(bview, row->par(), pos);
- }
-#ifndef NEW_TABULAR
+
+ LyXParagraph::size_type main_body =
+ BeginningOfMainBody(bview->buffer(), row->par());
+ if ((main_body > 0) &&
+ ((main_body-1 > last) ||
+ !row->par()->IsLineSeparator(main_body-1)))
+ main_body = 0;
+
+ for (LyXParagraph::size_type vpos = row->pos();
+ vpos < cursor_vpos; ++vpos) {
+ pos = vis2log(vpos);
+ if (main_body > 0 && pos == main_body - 1) {
+ x += fill_label_hfill +
+ lyxfont::width(textclasslist.Style(
+ bview->buffer()->params.textclass,
+ row->par()->GetLayout())
+ .labelsep,
+ GetFont(bview->buffer(), row->par(), -2));
+ if (row->par()->IsLineSeparator(main_body-1))
+ x -= SingleWidth(bview, row->par(),main_body-1);
+ }
+ if (HfillExpansion(bview->buffer(), row, pos)) {
+ x += SingleWidth(bview, row->par(), pos);
+ if (pos >= main_body)
+ x += fill_hfill;
+ else
+ x += fill_label_hfill;
+ } else if (row->par()->IsSeparator(pos)) {
+ x += SingleWidth(bview, row->par(), pos);
+ if (pos >= main_body)
+ x += fill_separator;
+ } else
+ x += SingleWidth(bview, row->par(), pos);
}
-#endif
-
+
cur.x(int(x));
cur.x_fix(cur.x());
cur.row(row);
SetCurrentFont(bview);
}
+
void LyXText::SetCurrentFont(BufferView * bview) const
{
LyXParagraph::size_type pos = cursor.pos();
--pos;
if (pos > 0) {
- if (pos == cursor.par()->Last()
-#ifndef NEW_TABULAR
- || (cursor.par()->table && cursor.par()->IsNewline(pos))
+#ifndef NEW_INSETS
+ if (pos == cursor.par()->Last())
+#else
+ if (pos == cursor.par()->size())
#endif
- )
--pos;
else if (cursor.par()->IsSeparator(pos)) {
if (pos > cursor.row()->pos() &&
bidi_level(pos) % 2 ==
bidi_level(pos - 1) % 2)
--pos;
+#ifndef NEW_INSETS
else if (pos + 1 < cursor.par()->Last())
+#else
+ else if (pos + 1 < cursor.par()->size())
+#endif
++pos;
}
}
cursor.par()->GetFontSettings(bview->buffer()->params, pos);
real_current_font = GetFont(bview->buffer(), cursor.par(), pos);
+#ifndef NEW_INSETS
if (cursor.pos() == cursor.par()->Last() &&
+#else
+ if (cursor.pos() == cursor.par()->size() &&
+#endif
IsBoundary(bview->buffer(), cursor.par(), cursor.pos()) &&
!cursor.boundary()) {
Language const * lang =
cursor.par()->getParLanguage(bview->buffer()->params);
current_font.setLanguage(lang);
+ current_font.setNumber(LyXFont::OFF);
real_current_font.setLanguage(lang);
+ real_current_font.setNumber(LyXFont::OFF);
}
}
-void LyXText::SetCursorFromCoordinates(BufferView * bview, int x, long y) const
+void LyXText::SetCursorFromCoordinates(BufferView * bview, int x, int y) const
{
LyXCursor old_cursor = cursor;
void LyXText::SetCursorFromCoordinates(BufferView * bview, LyXCursor & cur,
- int x, long y) const
+ int x, int y) const
{
/* get the row first */
void LyXText::CursorLeft(BufferView * bview, bool internal) const
-{
- CursorLeftIntern(bview, internal);
-#ifndef NEW_TABULAR
- if (cursor.par()->table) {
- int cell = NumberOfCell(cursor.par(), cursor.pos());
- if (cursor.par()->table->IsContRow(cell)
- && cursor.par()->table->CellHasContRow(cursor.par()->table->GetCellAbove(cell)) < 0) {
- CursorUp(bview);
- }
- }
-#endif
-}
-
-
-void LyXText::CursorLeftIntern(BufferView * bview, bool internal) const
{
if (cursor.pos() > 0) {
bool boundary = cursor.boundary();
if (!internal && !boundary &&
IsBoundary(bview->buffer(), cursor.par(), cursor.pos() + 1))
SetCursor(bview, cursor.par(), cursor.pos() + 1, true, true);
- } else if (cursor.par()->Previous()) { // steps into the above paragraph.
- LyXParagraph * par = cursor.par()->Previous();
+ } else if (cursor.par()->previous()) { // steps into the above paragraph.
+ LyXParagraph * par = cursor.par()->previous();
+#ifndef NEW_INSETS
SetCursor(bview, par, par->Last());
+#else
+ SetCursor(bview, par, par->size());
+#endif
}
}
void LyXText::CursorRight(BufferView * bview, bool internal) const
-{
- CursorRightIntern(bview, internal);
-#ifndef NEW_TABULAR
- if (cursor.par()->table) {
- int cell = NumberOfCell(cursor.par(), cursor.pos());
- if (cursor.par()->table->IsContRow(cell) &&
- cursor.par()->table->CellHasContRow(cursor.par()->table->GetCellAbove(cell))<0) {
- CursorUp(bview);
- }
- }
-#endif
-}
-
-
-void LyXText::CursorRightIntern(BufferView * bview, bool internal) const
{
if (!internal && cursor.boundary() &&
- (
-#ifndef NEW_TABULAR
- !cursor.par()->table ||
-#endif
- !cursor.par()->IsNewline(cursor.pos())))
+ !cursor.par()->IsNewline(cursor.pos()))
SetCursor(bview, cursor.par(), cursor.pos(), true, false);
+#ifndef NEW_INSETS
else if (cursor.pos() < cursor.par()->Last()) {
+#else
+ else if (cursor.pos() < cursor.par()->size()) {
+#endif
SetCursor(bview, cursor.par(), cursor.pos() + 1, true, false);
if (!internal &&
IsBoundary(bview->buffer(), cursor.par(), cursor.pos()))
SetCursor(bview, cursor.par(), cursor.pos(), true, true);
- } else if (cursor.par()->Next())
- SetCursor(bview, cursor.par()->Next(), 0);
+ } else if (cursor.par()->next())
+ SetCursor(bview, cursor.par()->next(), 0);
}
{
SetCursorFromCoordinates(bview, cursor.x_fix(),
cursor.y() - cursor.row()->baseline() - 1);
-#ifndef NEW_TABULAR
- if (cursor.par()->table) {
- int cell = NumberOfCell(cursor.par(), cursor.pos());
- if (cursor.par()->table->IsContRow(cell) &&
- cursor.par()->table->CellHasContRow(cursor.par()->table->GetCellAbove(cell))<0) {
- CursorUp(bview);
- }
- }
-#endif
}
void LyXText::CursorDown(BufferView * bview) const
{
-#ifndef NEW_TABULAR
- if (cursor.par()->table &&
- cursor.par()->table->ShouldBeVeryLastRow(NumberOfCell(cursor.par(), cursor.pos())) &&
- !cursor.par()->next)
- return;
-#endif
-
SetCursorFromCoordinates(bview, cursor.x_fix(),
cursor.y() - cursor.row()->baseline()
+ cursor.row()->height() + 1);
-#ifndef NEW_TABULAR
- if (cursor.par()->table) {
- int cell = NumberOfCell(cursor.par(), cursor.pos());
- int cell_above = cursor.par()->table->GetCellAbove(cell);
- while(cursor.par()->table &&
- cursor.par()->table->IsContRow(cell) &&
- (cursor.par()->table->CellHasContRow(cell_above)<0)) {
- SetCursorFromCoordinates(bview, cursor.x_fix(),
- cursor.y() - cursor.row()->baseline()
- + cursor.row()->height() + 1);
- if (cursor.par()->table) {
- cell = NumberOfCell(cursor.par(), cursor.pos());
- cell_above = cursor.par()->table->GetCellAbove(cell);
- }
- }
- }
-#endif
}
if (cursor.pos() > 0) {
SetCursor(bview, cursor.par(), 0);
}
- else if (cursor.par()->Previous()) {
- SetCursor(bview, cursor.par()->Previous(), 0);
+ else if (cursor.par()->previous()) {
+ SetCursor(bview, cursor.par()->previous(), 0);
}
}
void LyXText::CursorDownParagraph(BufferView * bview) const
{
- if (cursor.par()->Next()) {
- SetCursor(bview, cursor.par()->Next(), 0);
+ if (cursor.par()->next()) {
+ SetCursor(bview, cursor.par()->next(), 0);
} else {
+#ifndef NEW_INSETS
SetCursor(bview, cursor.par(), cursor.par()->Last());
+#else
+ SetCursor(bview, cursor.par(), cursor.par()->size());
+#endif
}
}
// Only if the cursor has really moved
if (old_cursor.pos() > 0
+#ifndef NEW_INSETS
&& old_cursor.pos() < old_cursor.par()->Last()
+#else
+ && old_cursor.pos() < old_cursor.par()->size()
+#endif
&& old_cursor.par()->IsLineSeparator(old_cursor.pos())
&& old_cursor.par()->IsLineSeparator(old_cursor.pos() - 1)) {
old_cursor.par()->Erase(old_cursor.pos() - 1);
- RedoParagraphs(bview, old_cursor, old_cursor.par()->Next());
+ RedoParagraphs(bview, old_cursor, old_cursor.par()->next());
// correct cursor
if (old_cursor.par() == cursor.par() &&
cursor.pos() > old_cursor.pos()) {
LyXCursor tmpcursor;
+#ifndef NEW_INSETS
if (old_cursor.par() != cursor.par()) {
- if ( (old_cursor.par()->Last() == 0
+ if ((old_cursor.par()->Last() == 0
|| (old_cursor.par()->Last() == 1
&& old_cursor.par()->IsLineSeparator(0)))
-#ifndef NEW_INSETS
&& old_cursor.par()->FirstPhysicalPar()
== old_cursor.par()->LastPhysicalPar()
+#else
+ if (old_cursor.par() != cursor.par()) {
+ if ((old_cursor.par()->size() == 0
+ || (old_cursor.par()->size() == 1
+ && old_cursor.par()->IsLineSeparator(0)))
#endif
) {
// ok, we will delete anything
refresh_y = old_cursor.y() - old_cursor.row()->baseline() - refresh_row->height();
tmpcursor = cursor;
cursor = old_cursor; // that undo can restore the right cursor position
- LyXParagraph * endpar = old_cursor.par()->next;
+#ifndef NEW_INSETS
+ LyXParagraph * endpar = old_cursor.par()->next_;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
-#ifndef NEW_INSETS
- endpar = endpar->LastPhysicalPar()->Next();
+ endpar = endpar->LastPhysicalPar()->next();
+ }
+ }
+ SetUndo(bview->buffer(), Undo::DELETE,
+ old_cursor.par()->previous_,
+ endpar);
+ cursor = tmpcursor;
+
+ // delete old row
+ RemoveRow(old_cursor.row());
+ if (OwnerParagraph() == old_cursor.par()) {
+ OwnerParagraph(OwnerParagraph()->next_);
+ }
#else
- endpar = endpar->Next();
-#endif
+ LyXParagraph * endpar = old_cursor.par()->next();
+ if (endpar && endpar->GetDepth()) {
+ while (endpar && endpar->GetDepth()) {
+ endpar = endpar->next();
}
}
SetUndo(bview->buffer(), Undo::DELETE,
- old_cursor.par()->previous,
+ old_cursor.par()->previous(),
endpar);
cursor = tmpcursor;
// delete old row
RemoveRow(old_cursor.row());
if (OwnerParagraph() == old_cursor.par()) {
- OwnerParagraph(OwnerParagraph()->next);
+ OwnerParagraph(OwnerParagraph()->next());
}
+#endif
// delete old par
delete old_cursor.par();
tmpcursor = cursor;
cursor = old_cursor; // that undo can restore the right cursor position
- LyXParagraph * endpar = old_cursor.par()->next;
+#ifndef NEW_INSETS
+ LyXParagraph * endpar = old_cursor.par()->next_;
if (endpar && endpar->GetDepth()) {
while (endpar && endpar->GetDepth()) {
-#ifndef NEW_INSETS
- endpar = endpar->LastPhysicalPar()->Next();
+ endpar = endpar->LastPhysicalPar()->next();
+ }
+ }
+ SetUndo(bview->buffer(), Undo::DELETE,
+ old_cursor.par()->previous_,
+ endpar);
+ cursor = tmpcursor;
+
+ // delete old row
+ RemoveRow(old_cursor.row());
+ // delete old par
+ if (OwnerParagraph() == old_cursor.par()) {
+ OwnerParagraph(OwnerParagraph()->next_);
+ }
#else
- endpar = endpar->Next();
-#endif
+ LyXParagraph * endpar = old_cursor.par()->next();
+ if (endpar && endpar->GetDepth()) {
+ while (endpar && endpar->GetDepth()) {
+ endpar = endpar->next();
}
}
SetUndo(bview->buffer(), Undo::DELETE,
- old_cursor.par()->previous,
+ old_cursor.par()->previous(),
endpar);
cursor = tmpcursor;
RemoveRow(old_cursor.row());
// delete old par
if (OwnerParagraph() == old_cursor.par()) {
- OwnerParagraph(OwnerParagraph()->next);
+ OwnerParagraph(OwnerParagraph()->next());
}
+#endif
delete old_cursor.par();
/* Breakagain the next par. Needed
}
if (!deleted) {
if (old_cursor.par()->StripLeadingSpaces(bview->buffer()->params.textclass)) {
- RedoParagraphs(bview, old_cursor, old_cursor.par()->Next());
+ RedoParagraphs(bview, old_cursor, old_cursor.par()->next());
// correct cursor y
SetCursorIntern(bview, cursor.par(), cursor.pos());
sel_cursor = cursor;
}
+#ifndef NEW_INSETS
LyXParagraph * LyXText::GetParFromID(int id)
{
LyXParagraph * result = FirstParagraph();
while (result && result->id() != id)
- result = result->next;
+ result = result->next_;
return result;
}
+#else
+LyXParagraph * LyXText::GetParFromID(int id)
+{
+ LyXParagraph * result = FirstParagraph();
+ while (result && result->id() != id)
+ result = result->next();
+ return result;
+}
+#endif
// undo functions
LyXParagraph * tmppar3 = undo->par;
undo->par = 0; // otherwise the undo destructor would delete the paragraph
LyXParagraph * tmppar4 = tmppar3;
- if (tmppar4){
- while (tmppar4->next)
- tmppar4 = tmppar4->next;
+#ifndef NEW_INSETS
+ if (tmppar4) {
+ while (tmppar4->next_)
+ tmppar4 = tmppar4->next_;
+ } // get last undo par
+
+ // now remove the old text if there is any
+ if (before != behind || (!behind && !before)) {
+ if (before)
+ tmppar5 = before->next();
+ else
+ tmppar5 = OwnerParagraph();
+ tmppar2 = tmppar3;
+ while (tmppar5 && tmppar5 != behind) {
+ tmppar = tmppar5;
+ tmppar5 = tmppar5->next();
+ // a memory optimization for edit: Only layout information
+ // is stored in the undo. So restore the text informations.
+ if (undo->kind == Undo::EDIT) {
+ tmppar2->setContentsFromPar(tmppar);
+ tmppar->clearContents();
+ tmppar2 = tmppar2->next();
+ }
+ }
+ }
+
+#else
+ if (tmppar4) {
+ while (tmppar4->next())
+ tmppar4 = tmppar4->next();
} // get last undo par
// now remove the old text if there is any
- if (before != behind || (!behind && !before)){
+ if (before != behind || (!behind && !before)) {
if (before)
- tmppar5 = before->next;
+ tmppar5 = before->next();
else
tmppar5 = OwnerParagraph();
tmppar2 = tmppar3;
- while (tmppar5 && tmppar5 != behind){
+ while (tmppar5 && tmppar5 != behind) {
tmppar = tmppar5;
- tmppar5 = tmppar5->next;
+ tmppar5 = tmppar5->next();
// a memory optimization for edit: Only layout information
// is stored in the undo. So restore the text informations.
if (undo->kind == Undo::EDIT) {
tmppar2->setContentsFromPar(tmppar);
tmppar->clearContents();
- tmppar2 = tmppar2->next;
+ tmppar2 = tmppar2->next();
}
}
}
+#endif
// put the new stuff in the list if there is one
if (tmppar3){
if (before)
- before->next = tmppar3;
+ before->next(tmppar3);
else
OwnerParagraph(tmppar3);
- tmppar3->previous = before;
+ tmppar3->previous(before);
} else {
if (!before)
OwnerParagraph(behind);
}
if (tmppar4) {
- tmppar4->next = behind;
+ tmppar4->next(behind);
if (behind)
- behind->previous = tmppar4;
+ behind->previous(tmppar4);
}
#ifndef NEW_INSETS
// check wether before points to a closed float and open it if necessary
if (before && before->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE
- && before->next && before->next->footnoteflag != LyXParagraph::NO_FOOTNOTE){
+ && before->next_ && before->next_->footnoteflag != LyXParagraph::NO_FOOTNOTE){
tmppar4 = before;
- while (tmppar4->previous &&
- tmppar4->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
- tmppar4 = tmppar4->previous;
+ while (tmppar4->previous_ &&
+ tmppar4->previous_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
+ tmppar4 = tmppar4->previous_;
while (tmppar4 && tmppar4->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE){
tmppar4->footnoteflag = LyXParagraph::OPEN_FOOTNOTE;
- tmppar4 = tmppar4->next;
+ tmppar4 = tmppar4->next_;
}
}
#endif
#ifndef NEW_INSETS
// open a cosed footnote at the end if necessary
- if (behind && behind->previous &&
- behind->previous->footnoteflag != LyXParagraph::NO_FOOTNOTE &&
+ if (behind && behind->previous_ &&
+ behind->previous_->footnoteflag != LyXParagraph::NO_FOOTNOTE &&
behind->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE){
while (behind && behind->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE){
behind->footnoteflag = LyXParagraph::OPEN_FOOTNOTE;
- behind = behind->next;
+ behind = behind->next_;
}
}
#endif
if (behind) {
#ifndef NEW_INSETS
if (behind->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE)
- endpar = behind->LastPhysicalPar()->Next();
+ endpar = behind->LastPhysicalPar()->next();
else
- endpar = behind->NextAfterFootnote()->LastPhysicalPar()->Next();
+ endpar = behind->NextAfterFootnote()->LastPhysicalPar()->next();
#else
- endpar = behind->Next();
+ endpar = behind->next();
#endif
} else
endpar = behind;
LyXParagraph * start = 0;
LyXParagraph * end = 0;
-
+
+#ifndef NEW_INSETS
if (before)
- start = before->next;
+ start = before->next_;
else
start = FirstParagraph();
if (behind)
- end = behind->previous;
+ end = behind->previous_;
else {
end = FirstParagraph();
- while (end->next)
- end = end->next;
+ while (end->next_)
+ end = end->next_;
}
-
- if (start && end
- && start != end->next
- && (before != behind || (!before && !behind))) {
+ if (start && end && (start != end->next_) &&
+ ((before != behind) || (!before && !behind))) {
tmppar = start;
tmppar2 = tmppar->Clone();
tmppar2->id(tmppar->id());
undopar = tmppar2;
- while (tmppar != end && tmppar->next) {
- tmppar = tmppar->next;
- tmppar2->next = tmppar->Clone();
- tmppar2->next->id(tmppar->id());
+ while (tmppar != end && tmppar->next_) {
+ tmppar = tmppar->next_;
+ tmppar2->next(tmppar->Clone());
+ tmppar2->next_->id(tmppar->id());
// a memory optimization: Just store the layout
// information when only edit
if (kind == Undo::EDIT){
//tmppar2->next->text.clear();
tmppar2->clearContents();
}
- tmppar2->next->previous = tmppar2;
- tmppar2 = tmppar2->next;
+ tmppar2->next_->previous(tmppar2);
+ tmppar2 = tmppar2->next_;
}
- tmppar2->next = 0;
+ tmppar2->next(0);
} else
undopar = 0; // nothing to replace (undo of delete maybe)
-#ifndef NEW_INSETS
int cursor_par = cursor.par()->ParFromPos(cursor.pos())->id();
int cursor_pos = cursor.par()->PositionInParFromPos(cursor.pos());
#else
+ if (before)
+ start = const_cast<LyXParagraph*>(before->next());
+ else
+ start = FirstParagraph();
+ if (behind)
+ end = const_cast<LyXParagraph*>(behind->previous());
+ else {
+ end = FirstParagraph();
+ while (end->next())
+ end = end->next();
+ }
+ if (start && end && (start != end->next()) &&
+ ((before != behind) || (!before && !behind))) {
+ tmppar = start;
+ tmppar2 = tmppar->Clone();
+ tmppar2->id(tmppar->id());
+
+ // a memory optimization: Just store the layout information
+ // when only edit
+ if (kind == Undo::EDIT){
+ //tmppar2->text.clear();
+ tmppar2->clearContents();
+ }
+
+ undopar = tmppar2;
+
+ while (tmppar != end && tmppar->next()) {
+ tmppar = tmppar->next();
+ tmppar2->next(tmppar->Clone());
+ tmppar2->next()->id(tmppar->id());
+ // a memory optimization: Just store the layout
+ // information when only edit
+ if (kind == Undo::EDIT){
+ //tmppar2->next->text.clear();
+ tmppar2->clearContents();
+ }
+ tmppar2->next()->previous(tmppar2);
+ tmppar2 = tmppar2->next();
+ }
+ tmppar2->next(0);
+ } else
+ undopar = 0; // nothing to replace (undo of delete maybe)
+
int cursor_par = cursor.par()->id();
int cursor_pos = cursor.pos();
#endif
-
+
Undo * undo = new Undo(kind,
before_number, behind_number,
cursor_par, cursor_pos,
return;
SetUndo(buf, Undo::FINISH,
#ifndef NEW_INSETS
- cursor.par()->ParFromPos(cursor.pos())->previous,
- cursor.par()->ParFromPos(cursor.pos())->next
+ cursor.par()->ParFromPos(cursor.pos())->previous_,
+ cursor.par()->ParFromPos(cursor.pos())->next_
#else
- cursor.par()->previous,
- cursor.par()->next
+ cursor.par()->previous(),
+ cursor.par()->next()
#endif
);
}
-#ifndef NEW_TABULAR
-void LyXText::RemoveTableRow(LyXCursor & cur) const
-{
- int cell = -1;
- int cell_org = 0;
- int ocell = 0;
-
- // move to the previous row
- int cell_act = NumberOfCell(cur.par(), cur.pos());
- if (cell < 0)
- cell = cell_act;
- while (cur.pos() && !cur.par()->IsNewline(cur.pos() - 1))
- cur.pos(cur.pos() - 1);
- while (cur.pos() &&
- !cur.par()->table->IsFirstCell(cell_act)) {
- cur.pos(cur.pos() - 1);
- while (cur.pos() && !cur.par()->IsNewline(cur.pos() - 1))
- cur.pos(cur.pos() - 1);
- --cell;
- --cell_act;
- }
- // now we have to pay attention if the actual table is the
- // main row of TableContRows and if yes to delete all of them
- if (!cell_org)
- cell_org = cell;
- do {
- ocell = cell;
- // delete up to the next row
- while (cur.pos() < cur.par()->Last() &&
- (cell_act == ocell
- || !cur.par()->table->IsFirstCell(cell_act))) {
- while (cur.pos() < cur.par()->Last() &&
- !cur.par()->IsNewline(cur.pos()))
- cur.par()->Erase(cur.pos());
- ++cell;
- ++cell_act;
- if (cur.pos() < cur.par()->Last())
- cur.par()->Erase(cur.pos());
- }
- if (cur.pos() && cur.pos() == cur.par()->Last()) {
- cur.pos(cur.pos() - 1);
- cur.par()->Erase(cur.pos()); // no newline at very end!
- }
- } while (((cell + 1) < cur.par()->table->GetNumberOfCells()) &&
- !cur.par()->table->IsContRow(cell_org) &&
- cur.par()->table->IsContRow(cell));
- cur.par()->table->DeleteRow(cell_org);
- return;
-}
-#endif
-
-
-#ifndef NEW_TABULAR
-bool LyXText::IsEmptyTableCell() const
-{
- LyXParagraph::size_type pos = cursor.pos() - 1;
- while (pos >= 0 && pos < cursor.par()->Last()
- && !cursor.par()->IsNewline(pos))
- --pos;
- return cursor.par()->IsNewline(pos + 1);
-}
-#endif
-
-
void LyXText::toggleAppendix(BufferView * bview)
{
#ifndef NEW_INSETS
#else
LyXParagraph * par = cursor.par();
#endif
- bool start = !par->start_of_appendix;
+ bool start = !par->params.startOfAppendix();
// ensure that we have only one start_of_appendix in this document
LyXParagraph * tmp = FirstParagraph();
- for (; tmp; tmp = tmp->next)
- tmp->start_of_appendix = 0;
- par->start_of_appendix = start;
+#ifndef NEW_INSETS
+ for (; tmp; tmp = tmp->next_)
+ tmp->params.startOfAppendix(false);
+#else
+ for (; tmp; tmp = tmp->next())
+ tmp->params.startOfAppendix(false);
+#endif
+ par->params.startOfAppendix(start);
// we can set the refreshing parameters now
status = LyXText::NEED_MORE_REFRESH;