}
par = par->next_;
}
+
+ // avoid forbidden cursor positions caused by error removing
+ if (tmpcursor.pos() > tmpcursor.par()->Last())
+ tmpcursor.pos(tmpcursor.par()->Last());
#else
while (par) {
// this has to be done before the delete
}
par = par->next();
}
-#endif
// avoid forbidden cursor positions caused by error removing
- if (tmpcursor.pos() > tmpcursor.par()->Last())
- tmpcursor.pos(tmpcursor.par()->Last());
+ if (tmpcursor.pos() > tmpcursor.par()->size())
+ tmpcursor.pos(tmpcursor.par()->size());
+#endif
text->SetCursorIntern(this, tmpcursor.par(), tmpcursor.pos());
return a;
update(text, BufferView::SELECT|BufferView::FITCUR);
text->BreakParagraph(this);
update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-
+
+#ifndef NEW_INSETS
if (text->cursor.par()->Last()) {
+#else
+ if (text->cursor.par()->size()) {
+#endif
text->CursorLeft(this);
text->BreakParagraph(this);
return;
}
+#ifndef NEW_INSETS
// check whether we want to open a float
if (bv_->text) {
bool hit = false;
c = bv_->text->cursor.par()->
GetChar(bv_->text->cursor.pos());
}
-#ifndef NEW_INSETS
if(!bv_->text->selection)
if (c == LyXParagraph::META_FOOTNOTE
|| c == LyXParagraph::META_MARGIN
|| c == LyXParagraph::META_ALGORITHM){
hit = true;
} else
-#endif
if (bv_->text->cursor.pos() - 1 >= 0) {
c = bv_->text->cursor.par()->
GetChar(bv_->text->cursor.pos() - 1);
-#ifndef NEW_INSETS
if (c == LyXParagraph::META_FOOTNOTE
|| c == LyXParagraph::META_MARGIN
|| c == LyXParagraph::META_FIG
bv_->text->CursorLeft(bv_);
hit = true;
}
-#endif
}
if (hit == true) {
-#ifndef NEW_INSETS
bv_->toggleFloat();
-#endif
selection_possible = false;
return;
}
}
-
-#ifndef NEW_INSETS
// Do we want to close a float? (click on the float-label)
if (bv_->text->cursor.row()->par()->footnoteflag ==
LyXParagraph::OPEN_FOOTNOTE
return;
}
}
+#else
+ // check whether we want to open a float
+ if (bv_->text) {
+ bool hit = false;
+ char c = ' ';
+ if (bv_->text->cursor.pos() <
+ bv_->text->cursor.par()->size()) {
+ c = bv_->text->cursor.par()->
+ GetChar(bv_->text->cursor.pos());
+ }
+ if (bv_->text->cursor.pos() - 1 >= 0) {
+ c = bv_->text->cursor.par()->
+ GetChar(bv_->text->cursor.pos() - 1);
+ }
+ if (hit == true) {
+ selection_possible = false;
+ return;
+ }
+ }
#endif
-
// Maybe we want to edit a bibitem ale970302
if (bv_->text->cursor.par()->bibkey && x < 20 +
bibitemMaxWidth(bv_, textclasslist.
LyXCursor cursor;
text->SetCursorFromCoordinates(bv_, cursor, x, y_tmp);
+#ifndef NEW_INSETS
if (cursor.pos() < cursor.par()->Last()
+#else
+ if (cursor.pos() < cursor.par()->size()
+#endif
&& cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET
&& cursor.par()->GetInset(cursor.pos())
&& cursor.par()->GetInset(cursor.pos())->Editable()) {
if (!par)
return;
+#ifndef NEW_INSETS
bv_->text->SetCursor(bv_, par,
min(par->Last(), saved_positions[i].par_pos));
+#else
+ bv_->text->SetCursor(bv_, par,
+ min(par->size(), saved_positions[i].par_pos));
+#endif
update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
if (i > 0)
owner_->getMiniBuffer()->Set(_("Moved to bookmark ") + tostr(i));
update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR);
if (is_rtl)
TEXT(bv_)->CursorLeft(bv_, false);
+#ifndef NEW_INSETS
if (TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->Last()
+#else
+ if (TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->size()
+#endif
&& TEXT(bv_)->cursor.par()->GetChar(TEXT(bv_)->cursor.pos())
== LyXParagraph::META_INSET
&& TEXT(bv_)->cursor.par()->GetInset(TEXT(bv_)->cursor.pos())
if (!is_rtl)
TEXT(bv_)->CursorLeft(bv_, false);
if ((is_rtl || cur != TEXT(bv_)->cursor) && // only if really moved!
+#ifndef NEW_INSETS
TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->Last() &&
+#else
+ TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->size() &&
+#endif
(TEXT(bv_)->cursor.par()->GetChar(TEXT(bv_)->cursor.pos()) ==
LyXParagraph::META_INSET) &&
TEXT(bv_)->cursor.par()->GetInset(TEXT(bv_)->cursor.pos()) &&
LyXCursor cursor = TEXT(bv_)->cursor;
if (!TEXT(bv_)->selection) {
+#ifndef NEW_INSETS
if (cursor.pos() == cursor.par()->Last()) {
+#else
+ if (cursor.pos() == cursor.par()->size()) {
+#endif
TEXT(bv_)->CursorRight(bv_);
cursor = TEXT(bv_)->cursor;
if (cursor.pos() == 0
+2001-03-11 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
+
+ * paragraph.C (Last): remove when NEW_INSETS is defined.
+
+ * other file: changes because of the above.
+
2001-03-09 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
* lyxparagraph.h: rename next to next_, previous to previous_,
bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar,
int start, int & end, char tc, bool doclear)
{
+#ifndef NEW_INSETS
if (!startpar || (start > startpar->Last()))
return false;
+#else
+ if (!startpar || (start > startpar->size()))
+ return false;
+#endif
DeleteBuffer();
// only within one paragraph
buf = new LyXParagraph;
LyXParagraph::size_type i = start;
+#ifndef NEW_INSETS
if (end > startpar->Last())
end = startpar->Last();
+#else
+ if (end > startpar->size())
+ end = startpar->size();
+#endif
for (; i < end; ++i) {
startpar->CopyIntoMinibuffer(*current_view->buffer(), start);
startpar->Erase(start);
+#ifndef NEW_INSETS
buf->InsertFromMinibuffer(buf->Last());
+#else
+ buf->InsertFromMinibuffer(buf->size());
+#endif
}
end = start-1;
} else {
startpar->next()->StripLeadingSpaces(textclass);
#ifndef NEW_INSETS
if (startpar->FirstPhysicalPar()->HasSameLayout(startpar->next()) ||
+ !startpar->next()->Last()) {
#else
if (startpar->HasSameLayout(startpar->next()) ||
+ !startpar->next()->size()) {
#endif
- !startpar->next()->Last()) {
#ifndef NEW_INSETS
startpar->ParFromPos(start)->PasteParagraph(current_view->buffer()->params);
#else
bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar,
int start, int end, char tc)
{
+#ifndef NEW_INSETS
if (!startpar || (start > startpar->Last()))
return false;
+#else
+ if (!startpar || (start > startpar->size()))
+ return false;
+#endif
DeleteBuffer();
// only within one paragraph
buf = new LyXParagraph;
LyXParagraph::size_type i = start;
+#ifndef NEW_INSETS
if (end > startpar->Last())
end = startpar->Last();
+#else
+ if (end > startpar->size())
+ end = startpar->size();
+#endif
for (; i < end; ++i) {
startpar->CopyIntoMinibuffer(*current_view->buffer(), i);
+#ifndef NEW_INSETS
buf->InsertFromMinibuffer(buf->Last());
+#else
+ buf->InsertFromMinibuffer(buf->size());
+#endif
}
} else {
// copy more than one paragraph
if (!checkPastePossible(*par, pos))
return false;
+#ifndef NEW_INSETS
if (pos > (*par)->Last())
pos = (*par)->Last();
-
+#else
+ if (pos > (*par)->size())
+ pos = (*par)->size();
+#endif
+
LyXParagraph * tmpbuf;
LyXParagraph * tmppar = *par;
int tmppos = pos;
bool paste_the_end = false;
+#ifndef NEW_INSETS
// open the paragraph for inserting the buf
// if necessary
if (((*par)->Last() > pos) || !(*par)->next()) {
pos);
paste_the_end = true;
}
-
// set the end for redoing later
-#ifndef NEW_INSETS
*endpar = (*par)->ParFromPos(pos)->next_->next();
// paste it!
lastbuffer = *par;
(*par)->ParFromPos(pos)->PasteParagraph(current_view->buffer()->params);
+ // store the new cursor position
+ *par = lastbuffer;
+ pos = lastbuffer->Last();
+ // maybe some pasting
+ if (lastbuffer->next() && paste_the_end) {
+ if (lastbuffer->next()->HasSameLayout(lastbuffer)) {
+ lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
+ } else if (!lastbuffer->next()->Last()) {
+ lastbuffer->next()->MakeSameLayout(lastbuffer);
+ lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
+ } else if (!lastbuffer->Last()) {
+ lastbuffer->MakeSameLayout(lastbuffer->next_);
+ lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
+ } else
+ lastbuffer->next()->StripLeadingSpaces(tc);
+ }
+ // restore the simple cut buffer
+ buf = simple_cut_clone;
+ }
#else
+ // open the paragraph for inserting the buf
+ // if necessary
+ if (((*par)->size() > pos) || !(*par)->next()) {
+ (*par)->BreakParagraphConservative(current_view->buffer()->params,
+ pos);
+ paste_the_end = true;
+ }
+ // set the end for redoing later
*endpar = (*par)->next()->next();
// paste it!
lastbuffer = *par;
(*par)->PasteParagraph(current_view->buffer()->params);
-#endif
// store the new cursor position
*par = lastbuffer;
- pos = lastbuffer->Last();
-
+ pos = lastbuffer->size();
// maybe some pasting
if (lastbuffer->next() && paste_the_end) {
-#ifndef NEW_INSETS
- if (lastbuffer->next()->HasSameLayout(lastbuffer)) {
- lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
- } else if (!lastbuffer->next()->Last()) {
- lastbuffer->next()->MakeSameLayout(lastbuffer);
- lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
- } else if (!lastbuffer->Last()) {
- lastbuffer->MakeSameLayout(lastbuffer->next_);
- lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
-#else
if (lastbuffer->next()->HasSameLayout(lastbuffer)) {
lastbuffer->PasteParagraph(current_view->buffer()->params);
- } else if (!lastbuffer->next()->Last()) {
+ } else if (!lastbuffer->next()->size()) {
lastbuffer->next()->MakeSameLayout(lastbuffer);
lastbuffer->PasteParagraph(current_view->buffer()->params);
- } else if (!lastbuffer->Last()) {
+ } else if (!lastbuffer->size()) {
lastbuffer->MakeSameLayout(lastbuffer->next());
lastbuffer->PasteParagraph(current_view->buffer()->params);
-#endif
} else
lastbuffer->next()->StripLeadingSpaces(tc);
}
// restore the simple cut buffer
buf = simple_cut_clone;
}
+#endif
return true;
}
value_type
get(Share const & ps) const {
// First see if we already have this ps in the container
-#if 0
- Params::iterator it = params.begin();
- Params::iterator end = params.end();
- for (; it != end; ++it) {
- if (ps == *(*it).get())
- break;
- }
-#else
Params::iterator it = std::find_if(params.begin(),
- params.end(),
- isEqual(ps));
-#endif
+ params.end(),
+ isEqual(ps));
value_type tmp;
if (it == params.end()) {
// ok we don't have it so we should
// some (one) unique elemements some times
// but we should gain a lot in speed.
clean();
- std::sort(params.rbegin(), params.rend(), comp());
+ //std::sort(params.rbegin(), params.rend(), comp());
} else {
// yes we have it already
tmp = *it;
+ // move it forward
+ if (it != params.begin())
+ swap(*it, *(it - 1));
}
return tmp;
}
Share const & p_;
};
///
- struct comp {
- int operator()(value_type const & p1,
- value_type const & p2) const {
- return p1.use_count() < p2.use_count();
- }
- };
+ //struct comp {
+ // int operator()(value_type const & p1,
+ // value_type const & p2) const {
+ // return p1.use_count() < p2.use_count();
+ // }
+ //};
///
struct isUnique {
bool operator()(value_type const & p) const {
return p.unique();
}
};
-
+
///
void clean() const {
// Remove all unique items. (i.e. entries that only
class InsetTabular;
class InsetCommand;
-using std::vector;
-
#ifdef SIGC_CXX_NAMESPACES
using SigC::Signal0;
using SigC::Signal1;
Put into some sort of alphabetical order */
//@{
/// Do we really have to push this?
- Signal1<void, vector<string> const &> SetDocumentClassChoice;
+ Signal1<void, std::vector<string> const &> SetDocumentClassChoice;
/// show the key and label of a bibliography entry
Signal1<void, InsetCommand *> showBibitem;
/// show the bibtex dialog
//@}
private:
///
- vector<DialogBase *> dialogs_;
+ std::vector<DialogBase *> dialogs_;
};
#endif
bkey = par->bibkey;
}
}
-#ifndef NEW_INSETS#
+#ifndef NEW_INSETS
par = par->next_;
#else
par = par->next();
#ifndef NEW_INSETS
if (par->Last() == 0 && !par->next_) {
#else#
- if (par->Last() == 0 && !par->next()) {
+ if (par->size() == 0 && !par->next()) {
#endif
LyXFont font(LyXFont::ALL_IGNORE);
font.setLanguage(bv->getParentLanguage(this));
#ifndef NEW_INSETS
if (par->Last() == 0 && !par->next_) {
#else
- if (par->Last() == 0 && !par->next()) {
+ if (par->size() == 0 && !par->next()) {
#endif
LyXFont font(LyXFont::ALL_IGNORE);
font.setLanguage(bv->getParentLanguage(this));
#ifndef NEW_INSETS
if (!cpar(bv)->next_ && (cpos(bv) >= cpar(bv)->Last()))
#else
- if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->Last()))
+ if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->size()))
#endif
return FINISHED;
if (activate_inset && checkAndActivateInset(bv, behind))
{
#ifndef NEW_INSETS
for (LyXParagraph * p = par; p; p = p->next_) {
+ for (int i = 0; i < p->Last(); ++i) {
#else
for (LyXParagraph * p = par; p; p = p->next()) {
+ for (int i = 0; i < p->size(); ++i) {
#endif
- for (int i = 0; i < p->Last(); ++i) {
if (p->GetChar(i) == LyXParagraph::META_NEWLINE)
p->Erase(i);
}
current_view->text->BreakParagraph(current_view);
current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-
+
+#ifndef NEW_INSETS
if (current_view->text->cursor.par()->Last()) {
+#else
+ if (current_view->text->cursor.par()->size()) {
+#endif
current_view->text->CursorLeft(current_view);
current_view->text->BreakParagraph(current_view);
string::size_type size = str.length();
LyXParagraph::size_type i = 0;
+#ifndef NEW_INSETS
while (((pos + i) < par->Last())
+#else
+ while (((pos + i) < par->size())
+#endif
&& (string::size_type(i) < size)
&& (cs ? (str[i] == par->GetChar(pos + i))
: (toupper(str[i]) == toupper(par->GetChar(pos + i)))))
// if necessary, check whether string matches word
if (!mw ||
(mw && ((pos <= 0 || !IsLetterCharOrDigit(par->GetChar(pos - 1)))
+#ifndef NEW_INSETS
&& (pos + size >= par->Last()
+#else
+ && (pos + size >= par->size()
+#endif
|| !IsLetterCharOrDigit(par->GetChar(pos + size))))
)
)
LyXParagraph::size_type pos = bv->text->cursor.pos();
while (par && !IsStringInText(par, pos, str, cs, mw)) {
+#ifndef NEW_INSETS
if (pos < par->Last() - 1)
+#else
+ if (pos < par->size() - 1)
+#endif
++pos;
else {
pos = 0;
do {
par = par->previous();
if (par)
+#ifndef NEW_INSETS
pos = par->Last() - 1;
+#else
+ pos = par->size() - 1;
+#endif
} while (par && pos < 0);
}
} while (par && !IsStringInText(par, pos, str, cs, mw));
LyXTextClass::LayoutList::size_type new_layout);
///
int GetFirstCounter(int i) const;
+#ifndef NEW_INSETS
///
size_type Last() const;
+#endif
///
void Erase(size_type pos);
/** the flag determines wether the layout should be copied
char footflag, char dth) const
{
#ifndef NEW_INSETS
- if (
- footnoteflag != LyXParagraph::NO_FOOTNOTE ||
+ if (footnoteflag != LyXParagraph::NO_FOOTNOTE ||
!previous_
- || previous_->footnoteflag == LyXParagraph::NO_FOOTNOTE
- ) {
-#endif
-
-#ifndef NEW_INSETS
+ || previous_->footnoteflag == LyXParagraph::NO_FOOTNOTE) {
// The beginning or the end of a footnote environment?
if (footflag != footnoteflag) {
footflag = footnoteflag;
}
-#ifdef NEW_INSETS
-#warning Remember to get rid of this one. (Lgb)
-#endif
+#ifndef NEW_INSETS
LyXParagraph::size_type LyXParagraph::Last() const
{
-#ifndef NEW_INSETS
if (next_ && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
return text.size() + NextAfterFootnote()->Last() + 1;
// the 1 is the symbol
// for the footnote
else
-#endif
return text.size();
}
+#endif
#ifndef NEW_INSETS
tmp->params.depth(firstpar->params.depth());
tmp->params.noindent(firstpar->params.noindent());
#else
- if (Last() > pos || !Last() || flag == 2) {
+ if (size() > pos || !size() || flag == 2) {
tmp->SetOnlyLayout(bparams, layout);
tmp->params.align(params.align());
tmp->SetLabelWidthString(params.labelWidthString());
int i = 0;
#ifndef NEW_INSETS
if (!IsDummy()) {
-#endif
while (Last()
+#else
+ while (size()
+#endif
&& (IsNewline(0) || IsLineSeparator(0))){
Erase(0);
++i;
// When can pos > Last()?
// I guess pos == Last() is possible.
- if (Last() > pos) {
+ if (size() > pos) {
// copy everything behind the break-position to the new
// paragraph
size_type pos_end = text.size() - 1;
{
// copy the next paragraph to this one
LyXParagraph * the_next = next();
-#ifndef NEW_INSETS
- LyXParagraph * firstpar = FirstPhysicalPar();
-#endif
// first the DTP-stuff
#ifndef NEW_INSETS
+ LyXParagraph * firstpar = FirstPhysicalPar();
firstpar->params.lineBottom(the_next->params.lineBottom());
firstpar->params.spaceBottom(the_next->params.spaceBottom());
firstpar->params.pagebreakBottom(the_next->params.pagebreakBottom());
+
+ size_type pos_end = the_next->text.size() - 1;
+ size_type pos_insert = Last();
#else
params.lineBottom(the_next->params.lineBottom());
params.spaceBottom(the_next->params.spaceBottom());
params.pagebreakBottom(the_next->params.pagebreakBottom());
-#endif
size_type pos_end = the_next->text.size() - 1;
- size_type pos_insert = Last();
+ size_type pos_insert = size();
+#endif
// ok, now copy the paragraph
size_type i, j;
// Is this really needed ? (Dekel)
// We do not need to use to change the font for the last paragraph
// or for a command.
+#ifndef NEW_INSETS
LyXFont font = getFont(bparams, Last() - 1);
+#else
+ LyXFont font = getFont(bparams, size() - 1);
+#endif
bool is_command = textclasslist.Style(bparams.textclass,
GetLayout()).isCommand();
if (style.resfont.size() != font.size() && next_ && !is_command) {
further_blank_line = false;
if (params.lineBottom()) {
- os << "\\lyxline{\\" << getFont(bparams, Last() - 1).latexSize() << '}';
+#ifndef NEW_INSETS
+ os << "\\lyxline{\\" << getFont(bparams,
+ Last() - 1).latexSize() << '}';
+#else
+ os << "\\lyxline{\\" << getFont(bparams,
+ size() - 1).latexSize() << '}';
+#endif
further_blank_line = true;
}
InsetText * inset = GetCellInset(cell);
int row;
+#ifndef NEW_INSETS
for (int i = 0; i < par->Last(); ++i) {
+#else
+ for (int i = 0; i < par->size(); ++i) {
+#endif
if (par->IsNewline(i)) {
++cell;
if (cell > GetNumberOfCells()) {
}
}
par->CopyIntoMinibuffer(*owner_->BufferOwner(), i);
+#ifndef NEW_INSETS
inset->par->InsertFromMinibuffer(inset->par->Last());
+#else
+ inset->par->InsertFromMinibuffer(inset->par->size());
+#endif
}
delete par;
Reinit();
InsetText * inset = GetCellInset(cell);
bool rtl = inset->par->isRightToLeftPar(buf->params) &&
+#ifndef NEW_INSETS
inset->par->Last() > 0 && GetPWidth(cell).empty();
+#else
+ inset->par->size() > 0 && GetPWidth(cell).empty();
+#endif
if (rtl)
os << "\\R{";
ret += inset->Latex(buf, os, fragile, fp);
LyXParagraph * par = GetCellInset(cell)->par;
for (; par; par = par->next()) {
- for (int i = 0; i < par->Last(); ++i) {
+ for (int i = 0; i < par->size(); ++i) {
if (par->GetChar(i) == LyXParagraph::META_NEWLINE)
return BOX_PARBOX;
}
unsigned char const prev_char = pos > 0 ? par->GetChar(pos-1) : ' ';
unsigned char next_char = ' ';
+#ifndef NEW_INSETS
for (LyXParagraph::size_type i = pos+1; i < par->Last(); ++i)
+#else
+ for (LyXParagraph::size_type i = pos+1; i < par->size(); ++i)
+#endif
if (!Encodings::IsComposeChar_arabic(par->GetChar(i))) {
next_char = par->GetChar(i);
break;
// Returns the paragraph position of the last character in the specified row
LyXParagraph::size_type LyXText::RowLast(Row const * row) const
{
+#ifndef NEW_INSETS
if (row->next() == 0)
return row->par()->Last() - 1;
else if (row->next()->par() != row->par())
return row->par()->Last() - 1;
else
return row->next()->pos() - 1;
+#else
+ if (row->next() == 0)
+ return row->par()->size() - 1;
+ else if (row->next()->par() != row->par())
+ return row->par()->size() - 1;
+ else
+ return row->next()->pos() - 1;
+#endif
}
newpar->GetLayout()).isEnvironment()) {
Row dummyrow;
dummyrow.par(newpar);
+#ifndef NEW_INSETS
dummyrow.pos(newpar->Last());
+#else
+ dummyrow.pos(newpar->size());
+#endif
x = LeftMargin(bview, &dummyrow);
} else {
// this is no longer an error, because this function
== MARGIN_MANUAL) {
Row tmprow;
tmprow = *row;
+#ifndef NEW_INSETS
tmprow.pos(row->par()->Last());
+#else
+ tmprow.pos(row->par()->size());
+#endif
return LeftMargin(bview, &tmprow); /* just the beginning
of the main body */
} else
LyXParagraph * par = row->par();
if (width < 0)
+#ifndef NEW_INSETS
return par->Last();
+#else
+ return par->size();
+#endif
LyXParagraph::size_type const pos = row->pos();
if (layout.margintype == MARGIN_RIGHT_ADDRESS_BOX) {
/* special code for right address boxes, only newlines count */
+#ifndef NEW_INSETS
while (i < par->Last()) {
+#else
+ while (i < par->size()) {
+#endif
if (par->IsNewline(i)) {
last_separator = i;
+#ifndef NEW_INSETS
i = par->Last() - 1; // this means break
+#else
+ i = par->size() - 1; // this means break
+#endif
//x = width;
} else if (par->GetChar(i) == LyXParagraph::META_INSET &&
par->GetInset(i) && par->GetInset(i)->display()){
}
} else {
// Last position is an invariant
+#ifndef NEW_INSETS
LyXParagraph::size_type const last =
par->Last();
+#else
+ LyXParagraph::size_type const last =
+ par->size();
+#endif
// this is the usual handling
int x = LeftMargin(bview, row);
bool doitonetime = true;
LyXLayout const & layout = textclasslist.Style(bview->buffer()->params.textclass,
firstpar->GetLayout());
-
+
+#ifndef NEW_INSETS
LyXFont font = GetFont(bview->buffer(), par, par->Last() - 1);
+#else
+ LyXFont font = GetFont(bview->buffer(), par, par->size() - 1);
+#endif
LyXFont::FONT_SIZE const size = font.size();
font = GetFont(bview->buffer(), par, -1);
font.setSize(size);
/* do not forget the DTP-lines!
* there height depends on the font of the nearest character */
+#ifndef NEW_INSETS
if (firstpar->params.lineBottom())
maxdesc += 2 * lyxfont::ascent('x', GetFont(bview->buffer(),
par, par->Last() - 1));
+#else
+ if (firstpar->params.lineBottom())
+ maxdesc += 2 * lyxfont::ascent('x',
+ GetFont(bview->buffer(),
+ par, par->size() - 1));
+#endif
/* and now the pagebreaks */
if (firstpar->params.pagebreakBottom())
// The last character position of a paragraph is an invariant so we can
// safely get it here. (Asger)
+#ifndef NEW_INSETS
int const lastposition = row->par()->Last();
-
+#else
+ int const lastposition = row->par()->size();
+#endif
do {
// Get the next breakpoint
int z = NextBreakPoint(bview, row, workWidth(bview));
/* get the next breakpoint */
LyXParagraph::size_type z = NextBreakPoint(bview, row, workWidth(bview));
Row * tmprow = row;
-
+
+#ifndef NEW_INSETS
if (z < row->par()->Last()) {
+#else
+ if (z < row->par()->size()) {
+#endif
if (!row->next() || (row->next() && row->next()->par() != row->par())) {
// insert a new row
++z;
// get the next breakpoint
LyXParagraph::size_type z = NextBreakPoint(bview, row, workWidth(bview));
Row * tmprow = row;
-
+
+#ifndef NEW_INSETS
if (z < row->par()->Last()) {
+#else
+ if (z < row->par()->size()) {
+#endif
if (!row->next()
|| (row->next() && row->next()->par() != row->par())) {
/* insert a new row */
cursor.par()->GetLayout());
// this is only allowed, if the current paragraph is not empty or caption
- if ((cursor.par()->Last() <= 0
#ifndef NEW_INSETS
- && !cursor.par()->IsDummy()
-#endif
- )
- &&
- layout.labeltype!= LABEL_SENSITIVE)
- return;
+ if ((cursor.par()->Last() <= 0
+ && !cursor.par()->IsDummy())
+ && layout.labeltype!= LABEL_SENSITIVE)
+ 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())->next_);
#else
+ if ((cursor.par()->size() <= 0)
+ && layout.labeltype!= LABEL_SENSITIVE)
+ return;
+
+ SetUndo(bview->buffer(), Undo::INSERT,
cursor.par()->previous(),
- cursor.par()->next()
+ cursor.par()->next());
#endif
- );
// Always break behind a space
//
// It is better to erase the space (Dekel)
+#ifndef NEW_INSETS
if (cursor.pos() < cursor.par()->Last()
+#else
+ if (cursor.pos() < cursor.par()->size()
+#endif
&& cursor.par()->IsLineSeparator(cursor.pos()))
cursor.par()->Erase(cursor.pos());
// cursor.pos(cursor.pos() + 1);
cursor.row()->fill(Fill(bview, cursor.row(), workWidth(bview)));
SetHeightOfRow(bview, cursor.row());
-
+
+#ifndef NEW_INSETS
while (cursor.par()->next()->Last()
+#else
+ while (cursor.par()->next()->size()
+#endif
&& cursor.par()->next()->IsNewline(0))
cursor.par()->next()->Erase(0);
* current font */
// Get the font that is used to calculate the baselineskip
+#ifndef NEW_INSETS
LyXParagraph::size_type const lastpos = cursor.par()->Last();
+#else
+ LyXParagraph::size_type const lastpos = cursor.par()->size();
+#endif
LyXFont rawparfont = cursor.par()->GetFontSettings(bview->buffer()->params,
lastpos - 1);
/* No newline at first position
* of a paragraph or behind labels.
* TeX does not allow that. */
-
+
+#ifndef NEW_INSETS
if (cursor.pos() < cursor.par()->Last() &&
+#else
+ if (cursor.pos() < cursor.par()->size() &&
+#endif
cursor.par()->IsLineSeparator(cursor.pos()))
// newline always after a blank!
CursorRight(bview);
else
need_break_row = 0;
- // check, wether the last characters font has changed.
+ // check, wether the last characters font has changed.
+#ifndef NEW_INSETS
if (cursor.pos() && cursor.pos() == cursor.par()->Last()
+#else
+ if (cursor.pos() && cursor.pos() == cursor.par()->size()
+#endif
&& rawparfont != rawtmpfont)
RedoHeightOfParagraph(bview, cursor);
}
// check, wether the last characters font has changed.
+#ifndef NEW_INSETS
if (cursor.pos() && cursor.pos() == cursor.par()->Last()
+#else
+ if (cursor.pos() && cursor.pos() == cursor.par()->size()
+#endif
&& rawparfont != rawtmpfont) {
RedoHeightOfParagraph(bview, cursor);
} else {
LyXCursor tmpcursor = cursor;
// CHECK See comment on top of text.C
+#ifndef NEW_INSETS
if (tmpcursor.pos() == tmpcursor.par()->Last()
+#else
+ if (tmpcursor.pos() == tmpcursor.par()->size()
+#endif
&& tmpcursor.par()->next()) {
tmpcursor.par(tmpcursor.par()->next());
tmpcursor.pos(0);
int steps = 0;
// Skip through initial nonword stuff.
+#ifndef NEW_INSETS
while (tmpcursor.pos() < tmpcursor.par()->Last() &&
+#else
+ while (tmpcursor.pos() < tmpcursor.par()->size() &&
+#endif
! tmpcursor.par()->IsWord( tmpcursor.pos() ) )
{
// printf("Current pos1 %d", tmpcursor.pos()) ;
++steps;
}
// Advance through word.
+#ifndef NEW_INSETS
while (tmpcursor.pos() < tmpcursor.par()->Last() &&
+#else
+ while (tmpcursor.pos() < tmpcursor.par()->size() &&
+#endif
tmpcursor.par()->IsWord( tmpcursor.pos() ) )
{
// printf("Current pos2 %d", tmpcursor.pos()) ;
void LyXText::CursorTab(BufferView * bview) const
{
LyXCursor tmpcursor = cursor;
+#ifndef NEW_INSETS
while (tmpcursor.pos() < tmpcursor.par()->Last()
+#else
+ while (tmpcursor.pos() < tmpcursor.par()->size()
+#endif
&& !tmpcursor.par()->IsNewline(tmpcursor.pos()))
tmpcursor.pos(tmpcursor.pos() + 1);
-
+
+#ifndef NEW_INSETS
if (tmpcursor.pos() == tmpcursor.par()->Last()){
+#else
+ if (tmpcursor.pos() == tmpcursor.par()->size()){
+#endif
if (tmpcursor.par()->next()) {
tmpcursor.par(tmpcursor.par()->next());
tmpcursor.pos(0);
} else if (!tmpcursor.pos()) {
if (tmpcursor.par()->previous()){
tmpcursor.par(tmpcursor.par()->previous());
+#ifndef NEW_INSETS
tmpcursor.pos(tmpcursor.par()->Last());
+#else
+ tmpcursor.pos(tmpcursor.par()->size());
+#endif
}
} else { // Here, tmpcursor != 0
while (tmpcursor.pos() > 0 &&
// set the sel cursor
sel_cursor = cursor;
+#ifndef NEW_INSETS
while (cursor.pos() < cursor.par()->Last()
+#else
+ while (cursor.pos() < cursor.par()->size()
+#endif
&& !cursor.par()->IsSeparator(cursor.pos())
&& !cursor.par()->IsKomma(cursor.pos()) )
cursor.pos(cursor.pos() + 1);
bool LyXText::SelectWordWhenUnderCursor(BufferView * bview)
{
if (!selection &&
+#ifndef NEW_INSETS
cursor.pos() > 0 && cursor.pos() < cursor.par()->Last()
+#else
+ cursor.pos() > 0 && cursor.pos() < cursor.par()->size()
+#endif
&& !cursor.par()->IsSeparator(cursor.pos())
&& !cursor.par()->IsKomma(cursor.pos())
&& !cursor.par()->IsSeparator(cursor.pos() -1)
}
#else
if (cursor.pos() || cursor.par()->previous()) {
- while (cursor.pos() < cursor.par()->Last()
+ while (cursor.pos() < cursor.par()->size()
&& cursor.par()->IsLetter(cursor.pos()))
cursor.pos(cursor.pos() + 1);
}
#endif
// Now, skip until we have real text (will jump paragraphs)
+#ifndef NEW_INSETS
while ((cursor.par()->Last() > cursor.pos()
+#else
+ while ((cursor.par()->size() > cursor.pos()
+#endif
&& (!cursor.par()->IsLetter(cursor.pos())
|| cursor.par()->getFont(bview->buffer()->params, cursor.pos())
.latex() == LyXFont::ON))
- || (cursor.par()->Last() == cursor.pos()
+#ifndef NEW_INSETS
+ || (cursor.par()->Last() == cursor.pos()
+#else
+ || (cursor.par()->size() == cursor.pos()
+#endif
&& cursor.par()->next())){
+#ifndef NEW_INSETS
if (cursor.pos() == cursor.par()->Last()) {
+#else
+ if (cursor.pos() == cursor.par()->size()) {
+#endif
cursor.par(cursor.par()->next());
cursor.pos(0);
} else
// and find the end of the word
// (optional hyphens are part of a word)
+#ifndef NEW_INSETS
while (cursor.pos() < cursor.par()->Last()
+#else
+ while (cursor.pos() < cursor.par()->size()
+#endif
&& (cursor.par()->IsLetter(cursor.pos()))
|| (cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET
&& cursor.par()->GetInset(cursor.pos()) != 0
std::ostringstream latex;
// now find the end of the word
+#ifndef NEW_INSETS
while (cursor.pos() < cursor.par()->Last()
+#else
+ while (cursor.pos() < cursor.par()->size()
+#endif
&& (cursor.par()->IsLetter(cursor.pos())
|| (cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET
&& cursor.par()->GetInset(cursor.pos()) != 0
/* -------> Delete from cursor up to the end of the current or next word. */
void LyXText::DeleteWordForward(BufferView * bview)
{
+#ifndef NEW_INSETS
if (!cursor.par()->Last())
+#else
+ if (!cursor.par()->size())
+#endif
CursorRight(bview);
else {
LyXCursor tmpcursor = cursor;
/* -------> Delete from cursor to start of current or prior word. */
void LyXText::DeleteWordBackward(BufferView * bview)
{
+#ifndef NEW_INSETS
if (!cursor.par()->Last())
+#else
+ if (!cursor.par()->size())
+#endif
CursorLeft(bview);
else {
LyXCursor tmpcursor = cursor;
/* -------> Kill to end of line. */
void LyXText::DeleteLineForward(BufferView * bview)
{
+#ifndef NEW_INSETS
if (!cursor.par()->Last())
+#else
+ if (!cursor.par()->size())
+#endif
// Paragraph is empty, so we just go to the right
CursorRight(bview);
else {
void LyXText::Backspace(BufferView * bview)
{
// Get the font that is used to calculate the baselineskip
+#ifndef NEW_INSETS
LyXParagraph::size_type lastpos = cursor.par()->Last();
+#else
+ LyXParagraph::size_type lastpos = cursor.par()->size();
+#endif
LyXFont rawparfont = cursor.par()->GetFontSettings(bview->buffer()->params,
lastpos - 1);
// without the dreaded mechanism. (JMarc)
if (cursor.par()->previous()) {
// steps into the above paragraph.
+#ifndef NEW_INSETS
SetCursorIntern(bview, cursor.par()->previous(),
cursor.par()->previous()->Last(), false);
+#else
+ SetCursorIntern(bview, cursor.par()->previous(),
+ cursor.par()->previous()->size(),
+ false);
+#endif
}
/* Pasting is not allowed, if the paragraphs have different
}
if (cursor.par()->IsLineSeparator(cursor.pos() - 1))
cursor.pos(cursor.pos() - 1);
-
- if (cursor.pos() < cursor.par()->Last() && !cursor.par()->IsSeparator(cursor.pos())) {
+
+#ifndef NEW_INSETS
+ if (cursor.pos() < cursor.par()->Last()
+ && !cursor.par()->IsSeparator(cursor.pos())) {
+#else
+ if (cursor.pos() < cursor.par()->size()
+ && !cursor.par()->IsSeparator(cursor.pos())) {
+#endif
cursor.par()->InsertChar(cursor.pos(), ' ');
SetCharFont(bview->buffer(), cursor.par(),
cursor.pos(), current_font);
}
// delete newlines at the beginning of paragraphs
+#ifndef NEW_INSETS
while (cursor.par()->Last() &&
+#else
+ while (cursor.par()->size() &&
+#endif
cursor.par()->IsNewline(cursor.pos()) &&
cursor.pos() == BeginningOfMainBody(bview->buffer(),
cursor.par())) {
Row * tmprow = row->previous();
// maybe the current row is now empty
+#ifndef NEW_INSETS
if (row->pos() >= row->par()->Last()) {
+#else
+ if (row->pos() >= row->par()->size()) {
+#endif
// remove it
RemoveRow(row);
need_break_row = 0;
//current_font = rawtmpfont;
//real_current_font = realtmpfont;
// check, whether the last character's font has changed.
+#ifndef NEW_INSETS
if (rawparfont !=
cursor.par()->GetFontSettings(bview->buffer()->params,
cursor.par()->Last() - 1))
+#else
+ if (rawparfont !=
+ cursor.par()->GetFontSettings(bview->buffer()->params,
+ cursor.par()->size() - 1))
+#endif
RedoHeightOfParagraph(bview, cursor);
return;
}
// break the cursor row again
if (row->next() && row->next()->par() == row->par() &&
+#ifndef NEW_INSETS
(RowLast(row) == row->par()->Last() - 1 ||
+#else
+ (RowLast(row) == row->par()->size() - 1 ||
+#endif
NextBreakPoint(bview, row, workWidth(bview)) != RowLast(row))) {
/* it can happen that a paragraph loses one row
* without a real breakup. This is when a word
* is to long to be broken. Well, I don t care this
- * hack ;-) */
+ * hack ;-) */
+#ifndef NEW_INSETS
if (RowLast(row) == row->par()->Last() - 1)
+#else
+ if (RowLast(row) == row->par()->size() - 1)
+#endif
RemoveRow(row->next());
refresh_y = y;
SetCursor(bview, cursor.par(), cursor.pos(), false,
!cursor.boundary());
+#ifndef NEW_INSETS
lastpos = cursor.par()->Last();
+#else
+ lastpos = cursor.par()->size();
+#endif
if (cursor.pos() == lastpos)
SetCurrentFont(bview);
if (firstpar->params.lineBottom()) {
/* draw a bottom line */
- y_bottom -= lyxfont::ascent('x', GetFont(bview->buffer(),
- par, par->Last() - 1));
+#ifndef NEW_INSETS
+ y_bottom -= lyxfont::ascent('x',
+ GetFont(bview->buffer(),
+ par,
+ par->Last() - 1));
+#else
+ y_bottom -= lyxfont::ascent('x',
+ GetFont(bview->buffer(),
+ par,
+ par->size() - 1));
+#endif
int const w = (inset_owner ?
inset_owner->width(bview, font) : ww);
int const xp = static_cast<int>(inset_owner ? x : 0);
w, y_offset + y_bottom,
LColor::topline, Painter::line_solid,
Painter::line_thick);
+#ifndef NEW_INSETS
y_bottom -= lyxfont::ascent('x',
GetFont(bview->buffer(),
par,
par->Last() - 1));
+#else
+ y_bottom -= lyxfont::ascent('x',
+ GetFont(bview->buffer(),
+ par,
+ par->size() - 1));
+#endif
}
// draw an endlabel
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
#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
// 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());
while (tmpcur.par() != sel_end_cursor.par()) {
+#ifndef NEW_INSETS
result += tmpcur.par()->String(buffer, 0, tmpcur.par()->Last()) + "\n\n";
+#else
+ result += tmpcur.par()->String(buffer, 0, tmpcur.par()->size()) + "\n\n";
+#endif
tmpcur.par(tmpcur.par()->next()); // Or NextAfterFootnote??
}
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()));
{
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
}
#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()))
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());
--pos;
if (pos > 0) {
+#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 =
SetCursor(bview, cursor.par(), cursor.pos() + 1, true, true);
} 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
}
}
if (!internal && cursor.boundary() &&
!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()))
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);
LyXCursor tmpcursor;
+#ifndef NEW_INSETS
if (old_cursor.par() != cursor.par()) {
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