]> git.lyx.org Git - lyx.git/commitdiff
isInset patch from John
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 23 Nov 2001 10:16:02 +0000 (10:16 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 23 Nov 2001 10:16:02 +0000 (10:16 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3065 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView2.C
src/BufferView_pimpl.C
src/ChangeLog
src/buffer.C
src/insets/ChangeLog
src/insets/inset.h
src/insets/insettext.C
src/paragraph.C
src/paragraph.h
src/text.C
src/text2.C

index 8c73c998c2346c4f2f5fae506ecc9451df2d828b..e9274995557b6aa9ebdcb987124a013cea92e630 100644 (file)
@@ -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,
index 0a9200cfdb50c1737459db1ef4a57467874a7927..3d4851e5099c29cbe7e80422527b0d1663e10260 100644 (file)
@@ -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<Inset::Code> 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())
index 965fe0566eb6a9f93a4e320202692e2268d4a40d..7799c42b9f6192bb7060316c612f962a3721a1c8 100644 (file)
@@ -1,3 +1,12 @@
+2001-11-22  John Levon  <moz@compsoc.man.ac.uk>
+
+       * BufferView2.C:
+       * BufferView_pimpl.C:
+       * buffer.C:
+       * paragraph.h:
+       * text.C: 
+       * text2.C: use par->isInset()
+        
 2001-11-23  John Levon  <moz@compsoc.man.ac.uk>
 
        * paragraph_pimpl.h:
index 38c0739b7d5d51715e574162907f03849cdfd482..a47737300f49ed20e8268f6e320f9c9fb9306f24 100644 (file)
@@ -2574,7 +2574,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
                                            par->layout);
 
                // treat <toc> 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){
index ec47b4e42abc1d2d0be547ca993774ffc645ffb7..6b93fa563589b91b5e62a4f9b60e980c48b1f904 100644 (file)
@@ -1,3 +1,9 @@
+2001-11-22  John Levon  <moz@compsoc.man.ac.uk>
+
+       * inset.h: fix comment
+       * insettext.C: use par->isInset()
+
 2001-11-22  Allan Rae  <rae@lyx.org>
 
        * insetcollapsable.h: 
index b05b4f692b6a472778e7546237911619784c854a..59e2d08c6ce1b35faf82a6e40d1f1d94a43d7247 100644 (file)
@@ -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
index b0a76e3075fd1fda7808a305afd021d0880a8ff3..3d984c2a30ec7d7e7454c8ca13d4e233deb8df43 100644 (file)
@@ -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<UpdatableInset*>(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 =
index d52d464f8d6e7cb80a5c77bef1a41664f9d39dde..05e1fb71f93f95f3e22e8ccf71f8d5b65f498b02 100644 (file)
@@ -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";
index c1c58ac2bf508aa5e0e5a8b0ccd5acdfcfcc051d..604c9f034dfb02ad0390871933bf9ce28207cc84 100644 (file)
@@ -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
index 0a965a0d32052bbc49945177706df79d4f9469bb..dfbc31359c0deb4daf8cc1ef1cc1f91d0a99e93a 100644 (file)
@@ -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,
index 8e3a76773e14cfbe8711ad5155b4dc6a1b8b95bf..2b58afa397163f2c9c5d2ecd5e6fed9259671fa7 100644 (file)
@@ -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()