From: Jean-Marc Lasgouttes Date: Fri, 23 Nov 2001 10:16:02 +0000 (+0000) Subject: isInset patch from John X-Git-Tag: 1.6.10~20301 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=02e190002b602dedb521a22bae961de358751820;p=features.git isInset patch from John git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3065 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView2.C b/src/BufferView2.C index 8c73c998c2..e927499555 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -417,8 +417,7 @@ void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc) Inset * locking_inset = theLockingInset()->getLockingInset(); if ((cursor.pos() - 1 >= 0) && - (cursor.par()->getChar(cursor.pos() - 1) == - Paragraph::META_INSET) && + cursor.par()->isInset(cursor.pos() - 1) && (cursor.par()->getInset(cursor.pos() - 1) == locking_inset)) text->setCursor(this, cursor, diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 0a9200cfdb..3d4851e509 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -855,7 +855,7 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y, if (cursor.pos() < cursor.par()->size() - && isMetaInset(cursor.par(), cursor.pos()) + && cursor.par()->isInset(cursor.pos()) && isEditableInset(cursor.par()->getInset(cursor.pos()))) { // Check whether the inset really was hit @@ -880,7 +880,7 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y, } if ((cursor.pos() - 1 >= 0) && - isMetaInset(cursor.par(), cursor.pos() - 1) && + cursor.par()->isInset(cursor.pos() - 1) && isEditableInset(cursor.par()->getInset(cursor.pos() - 1))) { Inset * tmpinset = cursor.par()->getInset(cursor.pos()-1); LyXFont font = text->getFont(buffer_, cursor.par(), @@ -1833,7 +1833,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) if (is_rtl) lt->cursorLeft(bv_, false); if (lt->cursor.pos() < lt->cursor.par()->size() - && isMetaInset(lt->cursor.par(), lt->cursor.pos()) + && lt->cursor.par()->isInset(lt->cursor.pos()) && isHighlyEditableInset(lt->cursor.par()->getInset(lt->cursor.pos()))) { Inset * tmpinset = lt->cursor.par()->getInset(lt->cursor.pos()); owner_->getLyXFunc()->setMessage(tmpinset->editMessage()); @@ -1865,7 +1865,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) lt->cursorLeft(bv_, false); if ((is_rtl || cur != lt->cursor) && // only if really moved! lt->cursor.pos() < lt->cursor.par()->size() && - isMetaInset(lt->cursor.par(), lt->cursor.pos()) && + lt->cursor.par()->isInset(lt->cursor.pos()) && isHighlyEditableInset(lt->cursor.par()->getInset(lt->cursor.pos()))) { Inset * tmpinset = lt->cursor.par()->getInset(lt->cursor.pos()); owner_->getLyXFunc()->setMessage(tmpinset->editMessage()); @@ -3410,7 +3410,7 @@ void BufferView::Pimpl::gotoInset(vector const & codes, string contents; if (same_content && - isMetaInset(cursor.par(), cursor.pos())) { + cursor.par()->isInset(cursor.pos())) { Inset const * inset = cursor.par()->getInset(cursor.pos()); if (find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end()) diff --git a/src/ChangeLog b/src/ChangeLog index 965fe0566e..7799c42b9f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2001-11-22 John Levon + + * BufferView2.C: + * BufferView_pimpl.C: + * buffer.C: + * paragraph.h: + * text.C: + * text2.C: use par->isInset() + 2001-11-23 John Levon * paragraph_pimpl.h: diff --git a/src/buffer.C b/src/buffer.C index 38c0739b7d..a47737300f 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -2574,7 +2574,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) par->layout); // treat as a special case for compatibility with old code - if (par->getChar(0) == Paragraph::META_INSET) { + if (par->isInset(0)) { Inset * inset = par->getInset(0); Inset::Code lyx_code = inset->lyxCode(); if (lyx_code == Inset::TOC_CODE){ @@ -3105,7 +3105,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) // treat label as a special case for // more WYSIWYM handling. - if (par->getChar(0) == Paragraph::META_INSET) { + if (par->isInset(0)) { Inset * inset = par->getInset(0); Inset::Code lyx_code = inset->lyxCode(); if (lyx_code == Inset::LABEL_CODE){ diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index ec47b4e42a..6b93fa5635 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2001-11-22 John Levon + + * inset.h: fix comment + + * insettext.C: use par->isInset() + 2001-11-22 Allan Rae * insetcollapsable.h: diff --git a/src/insets/inset.h b/src/insets/inset.h index b05b4f692b..59e2d08c6c 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -539,11 +539,12 @@ inline bool isEditableInset(Inset * i) } /** - * returns true if poiinter argument is valid + * returns true if pointer argument is valid * and points to a highly editable inset */ inline bool isHighlyEditableInset(Inset * i) { return i && i->editable() == Inset::HIGHLY_EDITABLE; } + #endif diff --git a/src/insets/insettext.C b/src/insets/insettext.C index b0a76e3075..3d984c2a30 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -940,7 +940,7 @@ void InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button) x - inset_x, y - inset_y, button); } else { - if (isMetaInset(cpar(bv), cpos(bv))) { + if (cpar(bv)->isInset(cpos(bv))) { inset = static_cast(cpar(bv)->getInset(cpos(bv))); if (isHighlyEditableInset(inset)) { inset->insetButtonRelease(bv, @@ -1744,7 +1744,7 @@ bool InsetText::insertInset(BufferView * bv, Inset * inset) } lt->insertInset(bv, inset); #if 0 - if ((!isMetaInset(cpar(bv), cpos(bv))) || + if ((!cpar(bv)->isInset(cpos(bv))) || (cpar(bv)->getInset(cpos(bv)) != inset)) lt->cursorLeft(bv); #endif @@ -1844,7 +1844,7 @@ void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall, bool InsetText::checkAndActivateInset(BufferView * bv, bool behind) { - if (isMetaInset(cpar(bv), cpos(bv))) { + if (cpar(bv)->isInset(cpos(bv))) { unsigned int x; unsigned int y; Inset * inset = diff --git a/src/paragraph.C b/src/paragraph.C index d52d464f8d..05e1fb71f9 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1781,7 +1781,7 @@ Paragraph * Paragraph::TeXEnvironment(Buffer const * buf, } } - if (style.isEnvironment()){ + if (style.isEnvironment()) { if (style.latextype == LATEX_LIST_ENVIRONMENT) { os << "\\begin{" << style.latexname() << "}{" << params().labelWidthString() << "}\n"; diff --git a/src/paragraph.h b/src/paragraph.h index c1c58ac2bf..604c9f034d 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -415,10 +415,4 @@ private: Pimpl * pimpl_; }; - -inline bool isMetaInset(Paragraph const * par, Paragraph::size_type const pos) -{ - return par->getChar(pos) == Paragraph::META_INSET; -} - #endif diff --git a/src/text.C b/src/text.C index 0a965a0d32..dfbc31359c 100644 --- a/src/text.C +++ b/src/text.C @@ -911,8 +911,8 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const last_separator = i; i = par->size() - 1; // this means break //x = width; - } else if (par->getChar(i) == Paragraph::META_INSET && - par->getInset(i) && par->getInset(i)->display()){ + } else if (par->isInset(i) && par->getInset(i) + && par->getInset(i)->display()) { par->getInset(i)->display(false); } ++i; @@ -1256,7 +1256,7 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const // Check if any insets are larger for (Paragraph::size_type pos = row_ptr->pos(); pos <= pos_end; ++pos) { - if (row_ptr->par()->getChar(pos) == Paragraph::META_INSET) { + if (row_ptr->par()->isInset(pos)) { tmpfont = getFont(bview->buffer(), row_ptr->par(), pos); tmpinset = row_ptr->par()->getInset(pos); if (tmpinset) { @@ -1862,7 +1862,7 @@ void LyXText::insertChar(BufferView * bview, char c) } // the display inset stuff - if (cursor.row()->par()->getChar(cursor.row()->pos()) == Paragraph::META_INSET + if (cursor.row()->par()->isInset(cursor.row()->pos()) && cursor.row()->par()->getInset(cursor.row()->pos()) && (cursor.row()->par()->getInset(cursor.row()->pos())->display() || cursor.row()->par()->getInset(cursor.row()->pos())->needFullRow())) @@ -2068,7 +2068,7 @@ void LyXText::prepareToPrint(BufferView * bview, // center displayed insets Inset * inset; - if (row->par()->getChar(row->pos()) == Paragraph::META_INSET + if (row->par()->isInset(row->pos()) && (inset=row->par()->getInset(row->pos())) && (inset->display())) // || (inset->scroll() < 0))) align = (inset->lyxCode() == Inset::MATHMACRO_CODE) @@ -2079,7 +2079,7 @@ void LyXText::prepareToPrint(BufferView * bview, ns = numberOfSeparators(bview->buffer(), row); if (ns && row->next() && row->next()->par() == row->par() && !(row->next()->par()->isNewline(row->next()->pos() - 1)) - && !(row->next()->par()->getChar(row->next()->pos()) == Paragraph::META_INSET + && !(row->next()->par()->isInset(row->next()->pos()) && row->next()->par()->getInset(row->next()->pos()) && row->next()->par()->getInset(row->next()->pos())->display()) ) @@ -2732,7 +2732,7 @@ void LyXText::backspace(BufferView * bview) false, cursor.boundary()); // some insets are undeletable here - if (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET) { + if (cursor.par()->isInset(cursor.pos())) { if (!cursor.par()->getInset(cursor.pos())->deletable()) return; // force complete redo when erasing display insets @@ -2933,7 +2933,7 @@ bool LyXText::paintRowBackground(DrawRowParams & p) Paragraph::size_type const last = rowLastPrintable(p.row); if (!p.bv->screen()->forceClear() && last == p.row->pos() - && isMetaInset(p.row->par(), p.row->pos())) { + && p.row->par()->isInset(p.row->pos())) { inset = p.row->par()->getInset(p.row->pos()); if (inset) { clear_area = inset->doClearArea(); @@ -3690,7 +3690,7 @@ LyXText::getColumnNearX(BufferView * bview, Row * row, int & x, x = int(tmpx); return c; } - + // returns pointer to a specified row Row * LyXText::getRow(Paragraph * par, diff --git a/src/text2.C b/src/text2.C index 8e3a76773e..2b58afa397 100644 --- a/src/text2.C +++ b/src/text2.C @@ -246,7 +246,7 @@ void LyXText::setCharFont(BufferView * bv, Paragraph * par, LyXFont font = getFont(buf, par, pos); font.update(fnt, buf->params.language, toggleall); // Let the insets convert their font - if (isMetaInset(par, pos)) { + if (par->isInset(pos)) { Inset * inset = par->getInset(pos); if (isEditableInset(inset)) { UpdatableInset * uinset = @@ -443,7 +443,7 @@ Inset * LyXText::getInset() const if (cursor.pos() == 0 && cursor.par()->bibkey) { inset = cursor.par()->bibkey; } else if (cursor.pos() < cursor.par()->size() - && isMetaInset(cursor.par(), cursor.pos())) { + && cursor.par()->isInset(cursor.pos())) { inset = cursor.par()->getInset(cursor.pos()); } return inset; @@ -1959,7 +1959,7 @@ bool LyXText::gotoNextInset(BufferView * bview, } } while (res.par() && - !(isMetaInset(res.par(), res.pos()) + !(res.par()->isInset(res.pos()) && (inset = res.par()->getInset(res.pos())) != 0 && find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end()