From: Lars Gullik Bjønnes Date: Sun, 11 Mar 2001 00:21:13 +0000 (+0000) Subject: remove Last when NEW_INSETS is defined X-Git-Tag: 1.6.10~21487 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=8cb2e519b3975cc643f2c93706137cf2e6a4f4d8;p=features.git remove Last when NEW_INSETS is defined git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1730 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView2.C b/src/BufferView2.C index 710b034ec3..9c26846fb4 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -120,6 +120,10 @@ bool BufferView::removeAutoInsets() } 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 @@ -132,11 +136,11 @@ bool BufferView::removeAutoInsets() } 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; @@ -231,8 +235,12 @@ bool BufferView::insertInset(Inset * inset, string const & lout, 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); diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 336870a8a2..0dcb809505 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -809,6 +809,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, return; } +#ifndef NEW_INSETS // check whether we want to open a float if (bv_->text) { bool hit = false; @@ -818,7 +819,6 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, 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 @@ -829,11 +829,9 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, || 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 @@ -845,18 +843,13 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, 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 @@ -882,8 +875,26 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, 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. @@ -912,7 +923,11 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y, 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()) { @@ -1225,8 +1240,13 @@ void BufferView::Pimpl::restorePosition(unsigned int i) 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)); @@ -1811,7 +1831,11 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) 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()) @@ -1849,7 +1873,11 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) 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()) && @@ -2220,7 +2248,11 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) 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 diff --git a/src/ChangeLog b/src/ChangeLog index 61217f9ed7..2f08f88db4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2001-03-11 Lars Gullik Bjønnes + + * paragraph.C (Last): remove when NEW_INSETS is defined. + + * other file: changes because of the above. + 2001-03-09 Lars Gullik Bjønnes * lyxparagraph.h: rename next to next_, previous to previous_, diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 75e89105f6..6e0c7c117b 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -75,8 +75,13 @@ void DeleteBuffer() 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(); @@ -93,13 +98,22 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, // 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 { @@ -151,10 +165,11 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, 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 @@ -170,8 +185,13 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, 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(); @@ -188,11 +208,20 @@ bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar, // 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 @@ -265,9 +294,14 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, 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; @@ -348,6 +382,7 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, bool paste_the_end = false; +#ifndef NEW_INSETS // open the paragraph for inserting the buf // if necessary if (((*par)->Last() > pos) || !(*par)->next()) { @@ -355,9 +390,7 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, pos); paste_the_end = true; } - // set the end for redoing later -#ifndef NEW_INSETS *endpar = (*par)->ParFromPos(pos)->next_->next(); // paste it! @@ -373,7 +406,34 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, 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! @@ -387,38 +447,26 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, 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; } diff --git a/src/ShareContainer.h b/src/ShareContainer.h index 2454e97f7a..570f411072 100644 --- a/src/ShareContainer.h +++ b/src/ShareContainer.h @@ -21,18 +21,9 @@ public: 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 @@ -43,10 +34,13 @@ public: // 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; } @@ -61,19 +55,19 @@ private: 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 diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index 472e959c8b..734976425b 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -38,8 +38,6 @@ class InsetInfo; class InsetTabular; class InsetCommand; -using std::vector; - #ifdef SIGC_CXX_NAMESPACES using SigC::Signal0; using SigC::Signal1; @@ -83,7 +81,7 @@ public: Put into some sort of alphabetical order */ //@{ /// Do we really have to push this? - Signal1 const &> SetDocumentClassChoice; + Signal1 const &> SetDocumentClassChoice; /// show the key and label of a bibliography entry Signal1 showBibitem; /// show the bibtex dialog @@ -159,7 +157,7 @@ public: //@} private: /// - vector dialogs_; + std::vector dialogs_; }; #endif diff --git a/src/insets/insetbib.C b/src/insets/insetbib.C index 7f396772fd..3696dbbdf2 100644 --- a/src/insets/insetbib.C +++ b/src/insets/insetbib.C @@ -290,7 +290,7 @@ string const bibitemWidest(Buffer const * buffer) bkey = par->bibkey; } } -#ifndef NEW_INSETS# +#ifndef NEW_INSETS par = par->next_; #else par = par->next(); diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 9d414218ba..5de207e79d 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -549,7 +549,7 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button) #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)); @@ -1144,7 +1144,7 @@ InsetText::LocalDispatch(BufferView * bv, #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)); @@ -1325,7 +1325,7 @@ InsetText::moveRightIntern(BufferView * bv, bool behind, #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)) @@ -1788,10 +1788,11 @@ void InsetText::removeNewlines() { #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); } diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 24561bb68f..48eeb99292 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -618,8 +618,12 @@ void FigureApplyCB(FL_OBJECT *, long) 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); diff --git a/src/lyxfind.C b/src/lyxfind.C index 27b9a6a388..70c9de2c51 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -118,7 +118,11 @@ bool IsStringInText(LyXParagraph * par, LyXParagraph::size_type pos, 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))))) @@ -129,7 +133,11 @@ bool IsStringInText(LyXParagraph * par, LyXParagraph::size_type pos, // 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)))) ) ) @@ -148,7 +156,11 @@ bool SearchForward(BufferView * bv, string const & str, 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; @@ -181,7 +193,11 @@ bool SearchBackward(BufferView * bv, string const & str, 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)); diff --git a/src/lyxparagraph.h b/src/lyxparagraph.h index 77df7ac4e9..03876ed56b 100644 --- a/src/lyxparagraph.h +++ b/src/lyxparagraph.h @@ -338,8 +338,10 @@ public: 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 diff --git a/src/paragraph.C b/src/paragraph.C index b342451b87..653a298d2b 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -124,14 +124,9 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os, 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; @@ -1075,20 +1070,17 @@ string const LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const } -#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 @@ -1496,7 +1488,7 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams, 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()); @@ -1624,8 +1616,10 @@ int LyXParagraph::StripLeadingSpaces(LyXTextClassList::size_type tclass) int i = 0; #ifndef NEW_INSETS if (!IsDummy()) { -#endif while (Last() +#else + while (size() +#endif && (IsNewline(0) || IsLineSeparator(0))){ Erase(0); ++i; @@ -1727,7 +1721,7 @@ void LyXParagraph::BreakParagraphConservative(BufferParams const & bparams, // 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; @@ -1757,23 +1751,24 @@ void LyXParagraph::PasteParagraph(BufferParams const & bparams) { // 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; @@ -2385,7 +2380,11 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, // 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) { @@ -2438,7 +2437,13 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, 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; } diff --git a/src/tabular.C b/src/tabular.C index 02cbc7544a..0dc9287192 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -1530,7 +1530,11 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl) 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()) { @@ -1559,7 +1563,11 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl) } } 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(); @@ -2162,7 +2170,11 @@ int LyXTabular::Latex(Buffer const * buf, 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); @@ -2560,7 +2572,7 @@ LyXTabular::BoxType LyXTabular::UseParbox(int cell) const 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; } diff --git a/src/text.C b/src/text.C index cedf1085b0..36ba36c2e9 100644 --- a/src/text.C +++ b/src/text.C @@ -74,7 +74,11 @@ unsigned char LyXText::TransformChar(unsigned char c, LyXParagraph * par, 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; @@ -205,12 +209,21 @@ int LyXText::SingleWidth(BufferView * bview, LyXParagraph * par, // 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 } @@ -719,7 +732,11 @@ int LyXText::LeftMargin(BufferView * bview, Row const * row) const 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 @@ -981,7 +998,11 @@ int LyXText::LabelEnd(BufferView * bview, Row const * row) const == 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 @@ -998,7 +1019,11 @@ LyXText::NextBreakPoint(BufferView * bview, Row const * row, int width) const 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(); @@ -1016,10 +1041,18 @@ LyXText::NextBreakPoint(BufferView * bview, Row const * row, int width) const 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()){ @@ -1029,8 +1062,13 @@ LyXText::NextBreakPoint(BufferView * bview, Row const * row, int width) const } } 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; @@ -1332,8 +1370,12 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const 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); @@ -1556,9 +1598,16 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const /* 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()) @@ -1629,8 +1678,11 @@ void LyXText::AppendParagraph(BufferView * bview, Row * row) const // 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)); @@ -1663,8 +1715,12 @@ void LyXText::BreakAgain(BufferView * bview, Row * row) const /* 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; @@ -1707,8 +1763,12 @@ void LyXText::BreakAgainOneRow(BufferView * bview, Row * row) // 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 */ @@ -1749,29 +1809,33 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout) 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); @@ -1821,8 +1885,12 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout) 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); @@ -2000,7 +2068,11 @@ void LyXText::InsertChar(BufferView * bview, char c) * 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); @@ -2038,8 +2110,12 @@ void LyXText::InsertChar(BufferView * bview, char c) /* 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); @@ -2106,8 +2182,12 @@ void LyXText::InsertChar(BufferView * bview, char c) 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); @@ -2168,7 +2248,11 @@ void LyXText::InsertChar(BufferView * bview, char c) } // 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 { @@ -2327,7 +2411,11 @@ void LyXText::CursorRightOneWord(BufferView * bview) const 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); @@ -2335,7 +2423,11 @@ void LyXText::CursorRightOneWord(BufferView * bview) const 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()) ; @@ -2343,7 +2435,11 @@ void LyXText::CursorRightOneWord(BufferView * bview) const ++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()) ; @@ -2358,11 +2454,19 @@ void LyXText::CursorRightOneWord(BufferView * bview) const 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); @@ -2400,7 +2504,11 @@ void LyXText::CursorLeftOneWord(BufferView * bview) const } 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 && @@ -2424,7 +2532,11 @@ void LyXText::SelectWord(BufferView * bview) // 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); @@ -2442,7 +2554,11 @@ void LyXText::SelectWord(BufferView * bview) 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) @@ -2472,20 +2588,32 @@ string const LyXText::SelectNextWord(BufferView * bview, } #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 @@ -2505,7 +2633,11 @@ string const LyXText::SelectNextWord(BufferView * bview, // 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 @@ -2539,7 +2671,11 @@ void LyXText::SelectSelectedWord(BufferView * bview) 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 @@ -2558,7 +2694,11 @@ void LyXText::SelectSelectedWord(BufferView * bview) /* -------> 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; @@ -2579,7 +2719,11 @@ void LyXText::DeleteWordForward(BufferView * bview) /* -------> 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; @@ -2598,7 +2742,11 @@ void LyXText::DeleteWordBackward(BufferView * bview) /* -------> 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 { @@ -2731,7 +2879,11 @@ void LyXText::Delete(BufferView * bview) 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); @@ -2810,8 +2962,14 @@ void LyXText::Backspace(BufferView * bview) // 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 @@ -2921,8 +3079,14 @@ void LyXText::Backspace(BufferView * bview) } 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); @@ -2945,7 +3109,11 @@ void LyXText::Backspace(BufferView * bview) } // 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())) { @@ -2970,7 +3138,11 @@ void LyXText::Backspace(BufferView * bview) 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; @@ -2996,9 +3168,15 @@ void LyXText::Backspace(BufferView * bview) //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; } @@ -3006,14 +3184,22 @@ void LyXText::Backspace(BufferView * bview) // 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; @@ -3057,7 +3243,11 @@ void LyXText::Backspace(BufferView * bview) 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); @@ -3734,8 +3924,17 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, 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(inset_owner ? x : 0); @@ -3743,10 +3942,17 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, 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 diff --git a/src/text2.C b/src/text2.C index 77287dd1b2..c64bfdf1d0 100644 --- a/src/text2.C +++ b/src/text2.C @@ -526,7 +526,11 @@ void LyXText::MakeFontEntriesLayoutSpecific(Buffer const * buf, 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 @@ -905,10 +909,12 @@ void LyXText::SetFont(BufferView * bview, LyXFont const & font, bool toggleall) #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 @@ -1188,16 +1194,27 @@ string const LyXText::selectionAsString(Buffer const * buffer) const // 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?? } @@ -1226,7 +1243,11 @@ void LyXText::CursorEnd(BufferView * bview) const 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())); @@ -1248,7 +1269,11 @@ void LyXText::CursorBottom(BufferView * bview) const { 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 } @@ -2326,7 +2351,11 @@ void LyXText::CopySelection(BufferView * bview) #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())) @@ -2547,7 +2576,11 @@ bool LyXText::GotoNextInset(BufferView * bview, 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()); @@ -2822,14 +2855,22 @@ void LyXText::SetCurrentFont(BufferView * bview) const --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; } } @@ -2838,7 +2879,11 @@ void LyXText::SetCurrentFont(BufferView * bview) const 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 = @@ -2900,7 +2945,11 @@ void LyXText::CursorLeft(BufferView * bview, bool internal) const 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 } } @@ -2910,7 +2959,11 @@ void LyXText::CursorRight(BufferView * bview, bool internal) const 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())) @@ -2951,7 +3004,11 @@ void LyXText::CursorDownParagraph(BufferView * bview) const 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 } } @@ -2997,7 +3054,11 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, // 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); @@ -3021,13 +3082,18 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, 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