]> git.lyx.org Git - lyx.git/commitdiff
start reducing header file dependencies
authorAndré Pönitz <poenitz@gmx.net>
Mon, 26 Nov 2001 16:42:04 +0000 (16:42 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Mon, 26 Nov 2001 16:42:04 +0000 (16:42 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3080 a592a061-630c-0410-9148-cb99ea01b6c8

26 files changed:
src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/ChangeLog
src/CutAndPaste.C
src/buffer.C
src/buffer.h
src/insets/ChangeLog
src/insets/insetert.C
src/insets/insetnote.C
src/insets/insettext.C
src/insets/insettext.h
src/lyxcursor.C
src/lyxcursor.h
src/lyxfind.C
src/lyxfunc.C
src/lyxrow.C
src/lyxrow.h
src/lyxtext.h
src/paragraph.C
src/paragraph.h
src/paragraph_pimpl.C
src/paragraph_pimpl.h
src/support/ChangeLog
src/support/types.h [new file with mode: 0644]
src/text.C
src/text2.C

index fdbd79098c30d277606116fd14eae7d9b435c2e9..2a07342ec0019210e670c58295e016658da3285e 100644 (file)
@@ -14,6 +14,7 @@
 #include "lyxscreen.h"
 #include "lyxtext.h"
 #include "lyxrow.h"
+#include "paragraph.h"
 #include "LyXView.h"
 #include "commandtags.h"
 #include "lyxfunc.h"
@@ -67,7 +68,7 @@
 #include "undo_funcs.h"
 #include "mathed/formulabase.h"
 
-extern LyXTextClass::size_type current_layout;
+extern lyx::layout_type current_layout;
 
 using std::vector;
 using std::find_if;
@@ -294,9 +295,9 @@ int BufferView::Pimpl::resizeCurrentBuffer()
        Paragraph * selendpar = 0;
        UpdatableInset * the_locking_inset = 0;
        
-       Paragraph::size_type pos = 0;
-       Paragraph::size_type selstartpos = 0;
-       Paragraph::size_type selendpos = 0;
+       pos_type pos = 0;
+       pos_type selstartpos = 0;
+       pos_type selendpos = 0;
        bool selection = false;
        bool mark_set  = false;
 
@@ -2799,7 +2800,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
 
        case LFUN_CHARATCURSOR:
        {
-               Paragraph::size_type pos = bv_->getLyXText()->cursor.pos();
+               pos_type pos = bv_->getLyXText()->cursor.pos();
                if (pos < bv_->getLyXText()->cursor.par()->size())
                        owner_->getLyXFunc()->setMessage(
                                tostr(bv_->getLyXText()->cursor.par()->getChar(pos)));
@@ -3244,7 +3245,7 @@ void BufferView::Pimpl::smartQuote()
 {
        LyXText const * lt = bv_->getLyXText();
        Paragraph const * par = lt->cursor.par();
-       Paragraph::size_type pos = lt->cursor.pos();
+       pos_type pos = lt->cursor.pos();
        char c;
 
        if (!pos
index ed6062e6b1eec8719351b1839cb16713c0bd74d6..5f43f3334ccc1a7a1ccfcd81acab8e86f7245dd4 100644 (file)
@@ -10,8 +10,8 @@
 #include "commandtags.h"
 #include "frontends/Timeout.h"
 #include "WorkArea.h"
-#include "paragraph.h"
 #include "insets/insetspecialchar.h"
+#include "support/types.h"
 
 #ifdef __GNUG__
 #pragma interface
@@ -23,6 +23,8 @@ class LyXScreen;
 
 ///
 struct BufferView::Pimpl : public SigC::Object {
+       /// position in a paragraph
+       typedef lyx::pos_type pos_type;
        ///
        Pimpl(BufferView * i, LyXView * o,
              int xpos, int ypos, int width, int height);
@@ -172,22 +174,22 @@ private:
        ///
        struct Position {
                /// Filename
-                string filename;
-                /// Cursor paragraph Id
-                int par_id;
-                /// Cursor position
-                Paragraph::size_type par_pos;
+               string filename;
+               /// Cursor paragraph Id
+               int par_id;
+               /// Cursor position
+               pos_type par_pos;
                ///
                Position() : par_id(0), par_pos(0) {}
                ///
-               Position(string const & f, int id, Paragraph::size_type pos)
-                        : filename(f), par_id(id), par_pos(pos) {}
+               Position(string const & f, int id, pos_type pos)
+                       : filename(f), par_id(id), par_pos(pos) {}
        };
        ///
        std::vector<Position> saved_positions;
        ///
        void moveCursorUpdate(bool selecting);
-        /// Get next inset of this class from current cursor position  
+       /// Get next inset of this class from current cursor position  
        Inset * getInsetByCode(Inset::Code code);
        ///
        void MenuInsertLyXFile(string const & filen);
index e6e201d24f2bc7598ec81bd48256550452861bbf..b5ce885c566b218a52ff34a6f4e9cb02ac0b815d 100644 (file)
@@ -1,3 +1,17 @@
+2001-11-26  André Pönitz <poenitz@gmx.net>
+       
+       * BufferView_pimpl.[Ch]:
+       *       CutAndPaste.C:
+       * buffer.[Ch]:
+       * lyxcursor.[Ch]:
+       * lyxfind.C:
+       * lyxfunc.C:
+       * lyxrow.[Ch]:
+       * paragraph.[Ch]:
+       * paragraph_pimpl.[Ch]:
+       * text.C:
+       * text2.C: reduce header dependencies, introduce type for positions
+
 2001-11-23  John Levon  <moz@compsoc.man.ac.uk>
 
        * <various>: change to use Alert.h 
index fbfa1689821e7efea37f047a0f817e834cafb1e7..1d99c703389309ef139b50d2a94e81cb3f55edd7 100644 (file)
@@ -88,7 +88,7 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
                // only within one paragraph
                if (realcut)
                        buf = new Paragraph;
-               Paragraph::size_type i = start;
+               Paragraph::pos_type i = start;
                if (end > startpar->size())
                        end = startpar->size();
                for (; i < end; ++i) {
@@ -155,7 +155,7 @@ bool CutAndPaste::copySelection(Paragraph * startpar, Paragraph * endpar,
            startpar == endpar) {
                // only within one paragraph
                buf = new Paragraph;
-               Paragraph::size_type i = start;
+               Paragraph::pos_type i = start;
                if (end > startpar->size())
                        end = startpar->size();
                for (; i < end; ++i) {
@@ -179,7 +179,7 @@ bool CutAndPaste::copySelection(Paragraph * startpar, Paragraph * endpar,
                tmppar2->next(0);
                
                // the buf paragraph is too big
-               Paragraph::size_type tmpi2 = start;
+               Paragraph::pos_type tmpi2 = start;
                for (; tmpi2; --tmpi2)
                        buf->erase(0);
                
index 3b3ab688d972419c47e597c6e1aad31743c821e8..b78a0842f78af46d84e41ef95b7ccf7e49b3a73f 100644 (file)
@@ -1334,7 +1334,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
 }
 
 // needed to insert the selection
-void Buffer::insertStringAsLines(Paragraph *& par, Paragraph::size_type & pos,
+void Buffer::insertStringAsLines(Paragraph *& par, Paragraph::pos_type & pos,
                                  LyXFont const & fn,string const & str) const
 {
        LyXLayout const & layout = textclasslist.Style(params.textclass, 
@@ -1368,8 +1368,8 @@ void Buffer::insertStringAsLines(Paragraph *& par, Paragraph::size_type & pos,
                                ++pos;
                                space_inserted = true;
                        } else {
-                               const Paragraph::size_type nb = 8 - pos % 8;
-                               for (Paragraph::size_type a = 0; 
+                               const Paragraph::pos_type nb = 8 - pos % 8;
+                               for (Paragraph::pos_type a = 0; 
                                     a < nb ; ++a) {
                                        par->insertChar(pos, ' ', font);
                                        ++pos;
@@ -1808,7 +1808,7 @@ string const Buffer::asciiParagraph(Paragraph const * par,
                lyxerr << "Should this ever happen?" << endl;
        }
 
-       for (Paragraph::size_type i = 0; i < par->size(); ++i) {
+       for (Paragraph::pos_type i = 0; i < par->size(); ++i) {
                if (!i && !noparbreak) {
                        if (linelen > 0)
                                buffer << "\n\n";
@@ -2791,7 +2791,7 @@ void Buffer::simpleLinuxDocOnePar(ostream & os,
 
        stack<PAR_TAG> tag_state;
        // parsing main loop
-       for (Paragraph::size_type i = 0; i < par->size(); ++i) {
+       for (Paragraph::pos_type i = 0; i < par->size(); ++i) {
 
                PAR_TAG tag_close = NONE;
                list < PAR_TAG > tag_open;
@@ -3283,7 +3283,7 @@ void Buffer::simpleDocBookOnePar(ostream & os,
        //      os << string(depth,' ');
 
        // parsing main loop
-       for (Paragraph::size_type i = 0;
+       for (Paragraph::pos_type i = 0;
             i < par->size(); ++i) {
                LyXFont font = par->getFont(params, i);
 
@@ -3694,7 +3694,7 @@ bool Buffer::isMultiLingual()
 
 
 Buffer::inset_iterator::inset_iterator(Paragraph * paragraph,
-                                      Paragraph::size_type pos)
+                                      Paragraph::pos_type pos)
        : par(paragraph)
 {
        it = par->InsetIterator(pos);
index 60cf303775c644c5dbc5e848083f6763999c8c25..5f3e8d9d5b0f67881def40f7cb8cc4c128b6a2d3 100644 (file)
@@ -123,7 +123,7 @@ public:
                                        Paragraph::depth_type & depth, 
                                        LyXFont &);
        ///
-       void insertStringAsLines(Paragraph *&, Paragraph::size_type &,
+       void insertStringAsLines(Paragraph *&, Paragraph::pos_type &,
                                 LyXFont const &, string const &) const;
 #ifndef NO_COMPABILITY
        ///
@@ -372,7 +372,7 @@ public:
                }
                ///
                inset_iterator(Paragraph * paragraph,
-                              Paragraph::size_type pos);
+                              Paragraph::pos_type pos);
                ///
                inset_iterator & operator++() { // prefix ++
                        if (par) {
@@ -402,7 +402,7 @@ public:
                ///
                Paragraph * getPar() { return par; }
                ///
-               Paragraph::size_type getPos() const { return it.getPos(); }
+               Paragraph::pos_type getPos() const { return it.getPos(); }
                ///
                friend
                bool operator==(inset_iterator const & iter1,
index c6909bac7425d8d015c78f8e12a74dde0b360594..322fa445cfaabcdcf3ea33e1978faf224a7e2238 100644 (file)
@@ -1,3 +1,9 @@
+2001-11-26  André Pönitz <poenitz@gmx.net>
+       
+       * insettext.[Ch]:
+       *       insetert.C:
+       *       insetnote.C: reduce header dependencies, introduce type for positions
+
 2001-11-23  John Levon  <moz@compsoc.man.ac.uk>
 
        * various: update for Alert.h
index 4aeb306f0be4ef5bd404b3fdcbe6783e1e8feda7..d4717cd28f450185f53bb425b5e043f1cb3c6387 100644 (file)
@@ -81,7 +81,7 @@ InsetERT::InsetERT(string const & contents, bool collapsed)
        font.setColor(LColor::latex);
        string::const_iterator cit = contents.begin();
        string::const_iterator end = contents.end();
-       Paragraph::size_type pos = 0;
+       Paragraph::pos_type pos = 0;
        for (; cit != end; ++cit) {
                inset.paragraph()->insertChar(pos++, *cit, font);
        }
@@ -149,8 +149,8 @@ void InsetERT::read(Buffer const * buf, LyXLex & lex)
        font.setColor(LColor::latex);
        Paragraph * par = inset.paragraph();
        while (par) {
-               Paragraph::size_type siz = par->size();
-               for (Paragraph::size_type i = 0; i < siz; ++i) {
+               Paragraph::pos_type siz = par->size();
+               for (Paragraph::pos_type i = 0; i < siz; ++i) {
                        par->setFont(i, font);
                }
                par = par->next();
@@ -192,8 +192,8 @@ void InsetERT::write(Buffer const * buf, ostream & os) const
        Paragraph * par = inset.paragraph();
        while (par) {
                os << "\n\\layout " << layout << "\n";
-               Paragraph::size_type siz = par->size();
-               for (Paragraph::size_type i = 0; i < siz; ++i) {
+               Paragraph::pos_type siz = par->size();
+               for (Paragraph::pos_type i = 0; i < siz; ++i) {
                        Paragraph::value_type c = par->getChar(i);
                        switch (c) {
                        case Paragraph::META_INSET:
@@ -310,8 +310,8 @@ int InsetERT::latex(Buffer const *, std::ostream & os, bool /*fragile*/,
        Paragraph * par = inset.paragraph();
        int lines = 0;
        while (par) {
-               Paragraph::size_type siz = par->size();
-               for (Paragraph::size_type i = 0; i < siz; ++i) {
+               Paragraph::pos_type siz = par->size();
+               for (Paragraph::pos_type i = 0; i < siz; ++i) {
                        Paragraph::value_type c = par->getChar(i);
                        switch (c) {
                        case Paragraph::META_NEWLINE:
@@ -346,8 +346,8 @@ int InsetERT::linuxdoc(Buffer const *, std::ostream & os) const
        Paragraph * par = inset.paragraph();
        int lines = 0;
        while (par) {
-               Paragraph::size_type siz = par->size();
-               for (Paragraph::size_type i = 0; i < siz; ++i) {
+               Paragraph::pos_type siz = par->size();
+               for (Paragraph::pos_type i = 0; i < siz; ++i) {
                        Paragraph::value_type c = par->getChar(i);
                        switch (c) {
                        case Paragraph::META_NEWLINE:
@@ -375,8 +375,8 @@ int InsetERT::docbook(Buffer const *, std::ostream & os) const
        Paragraph * par = inset.paragraph();
        int lines = 0;
        while (par) {
-               Paragraph::size_type siz = par->size();
-               for (Paragraph::size_type i = 0; i < siz; ++i) {
+               Paragraph::pos_type siz = par->size();
+               for (Paragraph::pos_type i = 0; i < siz; ++i) {
                        Paragraph::value_type c = par->getChar(i);
                        switch (c) {
                        case Paragraph::META_NEWLINE:
@@ -437,10 +437,10 @@ InsetERT::localDispatch(BufferView * bv, kb_action action, string const & arg)
 string const InsetERT::get_new_label() const
 {
        string la;
-       Paragraph::size_type const max_length = 15;
+       Paragraph::pos_type const max_length = 15;
 
-       Paragraph::size_type const p_siz = inset.paragraph()->size();
-       Paragraph::size_type const n = std::min(max_length, p_siz);
+       Paragraph::pos_type const p_siz = inset.paragraph()->size();
+       Paragraph::pos_type const n = std::min(max_length, p_siz);
        int i = 0;
        int j = 0;
        for(; i < n && j < p_siz; ++j) {
index 476e5595b60634b065ddb035497b112b110a69be..cf94f63b922426e10a4a1834737fd7922a9c100d 100644 (file)
@@ -67,7 +67,7 @@ InsetNote::InsetNote(Buffer const * buf, string const & contents,
        init();
 
        Paragraph * par = inset.paragraph();
-       Paragraph::size_type pos = 0;
+       Paragraph::pos_type pos = 0;
        LyXFont font(LyXFont::ALL_INHERIT, buf->params.language);
 
        // Since XForms doesn't support RTL, we can assume that old notes
index b4f3dbbf35ab5a6b94e9e6e9e02b141c1cf3407e..45b5163613b1cd9e15dd5c326ff300a1a8bf97cd 100644 (file)
@@ -2008,7 +2008,7 @@ int InsetText::cy(BufferView * bv) const
 }
 
 
-Paragraph::size_type InsetText::cpos(BufferView * bv) const
+Paragraph::pos_type InsetText::cpos(BufferView * bv) const
 {
        return getLyXText(bv)->cursor.pos();
 }
@@ -2449,7 +2449,7 @@ bool InsetText::searchForward(BufferView * bv, string const & str,
                        clear = true;
                }
                Paragraph * lpar = lt->cursor.par();
-               Paragraph::size_type pos = lt->cursor.pos();
+               Paragraph::pos_type pos = lt->cursor.pos();
                if (pos < lpar->size() - 1)
                        ++pos;
                else {
index 9e9fc980a81a6abaee9e4a9d7f79d4de0a5a2bff..2a35a2c06358c58c0b59f7f5d330a125841b7bbc 100644 (file)
@@ -308,7 +308,7 @@ private:
        ///
        int cy(BufferView *) const;
        ///
-       Paragraph::size_type cpos(BufferView *) const;
+       Paragraph::pos_type cpos(BufferView *) const;
        ///
        Paragraph * cpar(BufferView *) const;
        ///
@@ -347,7 +347,7 @@ private:
        ///
        Paragraph * inset_par;
        ///
-       Paragraph::size_type inset_pos;
+       Paragraph::pos_type inset_pos;
        ///
        bool inset_boundary;
        ///
@@ -379,9 +379,9 @@ private:
                Paragraph * lpar;
                Paragraph * selstartpar;
                Paragraph * selendpar;
-               Paragraph::size_type pos;
-               Paragraph::size_type selstartpos;
-               Paragraph::size_type selendpos;
+               Paragraph::pos_type pos;
+               Paragraph::pos_type selstartpos;
+               Paragraph::pos_type selendpos;
                bool boundary;
                bool selstartboundary;
                bool selendboundary;
index c2427bddd3422c35a66959e14576fb9971cdc208..fc45d0a0b307602b20da5c144f113d6fba74f41f 100644 (file)
@@ -35,13 +35,13 @@ Paragraph * LyXCursor::par() const
 }
 
 
-void LyXCursor::pos(Paragraph::size_type p)
+void LyXCursor::pos(pos_type p)
 {
        pos_ = p;
 }
 
 
-Paragraph::size_type LyXCursor::pos() const
+LyXCursor::pos_type LyXCursor::pos() const
 {
        return pos_;
 }
index 1032055f0e5006f217dfe3fe6ee165907d9a3214..43cbc0980cb8443f472834820c02c41e1500a042 100644 (file)
 #pragma interface
 #endif
 
-#include "paragraph.h"
+#include "support/types.h"
 
-struct Row;
+class Paragraph;
+class Row;
 
 /** All these variables should be explained. Matthias?
  */
 class LyXCursor {
 public:
+       /// position in a paragraph
+       typedef lyx::pos_type pos_type;
+       ///
        LyXCursor();
        ///
        void par(Paragraph * p);
        ///
        Paragraph * par() const;
        ///
-       void pos(Paragraph::size_type p);
+       void pos(pos_type p);
        ///
-       Paragraph::size_type pos() const;
+       pos_type pos() const;
        ///
        void boundary(bool b);
        ///
@@ -57,7 +61,7 @@ private:
        /// The paragraph the cursor is in.
        Paragraph * par_;
        /// The position inside the paragraph
-       Paragraph::size_type pos_;
+       pos_type pos_;
        ///
        bool boundary_;
        ///
index 777ad3e1011c7cdcefd6e6034256a1831e0a9254..1c52660cbe1927627aaa20eb9bde4e6110397880 100644 (file)
@@ -28,7 +28,7 @@ enum SearchResult {
 
 
 /// returns true if the specified string is at the specified  position
-bool IsStringInText(Paragraph * par, Paragraph::size_type pos,
+bool IsStringInText(Paragraph * par, Paragraph::pos_type pos,
                     string const & str, bool const & = true,
                     bool const & = false);
 
@@ -140,7 +140,7 @@ bool LyXFind(BufferView * bv,
                else {
                        text = bv->getLyXText();
                        Paragraph * par = text->cursor.par();
-                       Paragraph::size_type pos = text->cursor.pos();
+                       Paragraph::pos_type pos = text->cursor.pos();
                        if (forward) {
                                if (pos < par->size() - 1)
                                        ++pos;
@@ -183,7 +183,7 @@ bool LyXFind(BufferView * bv,
 
 
 // returns true if the specified string is at the specified position
-bool IsStringInText(Paragraph * par, Paragraph::size_type pos,
+bool IsStringInText(Paragraph * par, Paragraph::pos_type pos,
                    string const & str, bool const & cs,
                    bool const & mw)
 {
@@ -191,7 +191,7 @@ bool IsStringInText(Paragraph * par, Paragraph::size_type pos,
                return false;
    
        string::size_type size = str.length();
-       Paragraph::size_type i = 0;
+       Paragraph::pos_type i = 0;
        while (((pos + i) < par->size())
               && (string::size_type(i) < size)
               && (cs ? (str[i] == par->getChar(pos + i))
@@ -204,7 +204,7 @@ bool IsStringInText(Paragraph * par, Paragraph::size_type pos,
                if (!mw)
                        return true;
                if ((pos <= 0 || !IsLetterCharOrDigit(par->getChar(pos - 1)))
-                       && (pos + Paragraph::size_type(size) >= par->size()
+                       && (pos + Paragraph::pos_type(size) >= par->size()
                        || !IsLetterCharOrDigit(par->getChar(pos + size)))) {
                        return true;
                }
@@ -219,7 +219,7 @@ SearchResult SearchForward(BufferView * bv, LyXText * text, string const & str,
                            bool const & cs, bool const & mw)
 {
        Paragraph * par = text->cursor.par();
-       Paragraph::size_type pos = text->cursor.pos();
+       Paragraph::pos_type pos = text->cursor.pos();
        UpdatableInset * inset;
 
        while (par && !IsStringInText(par, pos, str, cs, mw)) {
@@ -280,7 +280,7 @@ SearchResult SearchBackward(BufferView * bv, LyXText * text,
                             bool const & cs, bool const & mw)
 {
        Paragraph * par = text->cursor.par();
-       Paragraph::size_type pos = text->cursor.pos();
+       Paragraph::pos_type pos = text->cursor.pos();
 
        do {
                if (pos > 0)
index 360a7a31dfd9b78e8dbe11e129a638f14387bba0..b9330f020153103604cea7d077d4934af86ad469 100644 (file)
@@ -30,6 +30,7 @@
 #include "version.h"
 #include "kbmap.h"
 #include "lyxfunc.h"
+#include "lyxrow.h"
 #include "bufferlist.h"
 #include "BufferView.h"
 #include "ColorHandler.h"
index 8cb91b846556635bc60b671a8f9e2c1d391ddde4..21873a8ae0d7a96c945cda60f0a85d886c9907d8 100644 (file)
@@ -29,13 +29,13 @@ void Row::par(Paragraph * p)
 }
 
 
-void Row::pos(Paragraph::size_type p)
+void Row::pos(pos_type p)
 {
        pos_ = p;
 }
 
 
-Paragraph::size_type Row::pos() const
+Row::pos_type Row::pos() const
 {
        return pos_;
 }
index c28fc04381bd194b1ab3966761bf59caf4792186..b6e036bbf9deb10901c2c457c89995b793f3b6f3 100644 (file)
 #pragma interface
 #endif
 
-#include "paragraph.h"
+#include "support/types.h"
+
+class Paragraph;
 
 ///
 class Row {
 public:
+       /// A position in the row
+       typedef lyx::pos_type pos_type;
        ///
        Row();
        ///
@@ -30,9 +34,9 @@ public:
        ///
        Paragraph * par() const;
        ///
-       void pos(Paragraph::size_type p);
+       void pos(pos_type p);
        ///
-       Paragraph::size_type pos() const;
+       pos_type pos() const;
        ///
        void fill(int f);
        ///
@@ -65,7 +69,7 @@ private:
        ///
        Paragraph * par_;
        ///
-       Paragraph::size_type pos_;
+       pos_type pos_;
        /** what is missing to a full row can be negative.
          Needed for hfills, flushright, block etc. */
        mutable int fill_;
index c61c94a617cc2b44274c565d9719f60a6e57bf4d..243e6eab886b929297a84ace6c4b7ce8c6b6751a 100644 (file)
 
 #include "lyxfont.h"
 #include "lyxcursor.h"
-#include "paragraph.h"
 #include "layout.h"
-#include "lyxrow.h"
-#include "vspace.h"
-#include "Spacing.h"
 #include "LColor.h"
+#include "insets/inset.h"
 
 class Buffer;
 class BufferParams;
 class BufferView;
 class InsetText;
+class Paragraph;
+class Row;
+class Spacing;
+class UpdatableInset;
+class VSpace;
 
 
 /**
@@ -36,6 +38,10 @@ class InsetText;
   */
 class LyXText {
 public:
+       /// a position in the text
+       typedef lyx::pos_type pos_type;
+       /// a layout number
+       typedef lyx::layout_type layout_type;
        ///
        enum text_status {
                ///
@@ -94,18 +100,16 @@ public:
        ///
        int getRealCursorX(BufferView *) const;
        ///
-       LyXFont const getFont(Buffer const *, Paragraph * par,
-                       Paragraph::size_type pos) const;
+       LyXFont const getFont(Buffer const *, Paragraph * par, pos_type pos) const;
        ///
        LyXFont const getLayoutFont(Buffer const *, Paragraph * par) const;
        ///
        LyXFont const getLabelFont(Buffer const *, Paragraph * par) const;
        ///
        void setCharFont(Buffer const *, Paragraph * par,
-                        Paragraph::size_type pos, LyXFont const & font);
+                        pos_type pos, LyXFont const & font);
        void setCharFont(BufferView *, Paragraph * par,
-                        Paragraph::size_type pos,
-                        LyXFont const & font, bool toggleall);
+                        pos_type pos, LyXFont const & font, bool toggleall);
        /// returns a pointer to the very first Paragraph
        Paragraph * firstParagraph() const;
   
@@ -118,8 +122,9 @@ public:
        Paragraph * setLayout(BufferView *, LyXCursor & actual_cursor,
                                 LyXCursor & selection_start,
                                 LyXCursor & selection_end,
-                                LyXTextClass::size_type layout);
-       void setLayout(BufferView *, LyXTextClass::size_type layout);
+                                layout_type layout);
+       ///
+       void setLayout(BufferView *, layout_type layout);
        
        /// used in setlayout
        void makeFontEntriesLayoutSpecific(Buffer const *, Paragraph * par);
@@ -135,7 +140,7 @@ public:
 
        /** Get the depth at current cursor position
         */
-       int getDepth() const { return cursor.par()->getDepth(); }
+       int getDepth() const;
        
        /** set font over selection and make a total rebreak of those
          paragraphs.
@@ -194,7 +199,7 @@ public:
        ///
        mutable Row * refresh_row;
        ///
-       Paragraph::size_type refresh_pos;
+       pos_type refresh_pos;
 
        /// give and set the LyXText status
        text_status status() const;
@@ -217,14 +222,14 @@ public:
        /** returns the column near the specified x-coordinate of the row 
         x is set to the real beginning of this column
         */ 
-       Paragraph::size_type getColumnNearX(BufferView *, Row * row,
+       pos_type getColumnNearX(BufferView *, Row * row,
                                            int & x, bool & boundary) const;
        
        /** returns a pointer to a specified row. y is set to the beginning
         of the row
         */
        Row * getRow(Paragraph * par,
-                    Paragraph::size_type pos, int & y) const;
+                    pos_type pos, int & y) const;
 
        /** returns the height of a default row, needed  for scrollbar
         */
@@ -301,16 +306,16 @@ public:
        void selectSelectedWord(BufferView *);
        ///
        void setCursor(BufferView *, Paragraph * par,
-                      Paragraph::size_type pos,
+                      pos_type pos,
                       bool setfont = true,
                       bool boundary = false) const;
        ///
        void setCursor(BufferView *, LyXCursor &, Paragraph * par,
-                      Paragraph::size_type pos,
+                      pos_type pos,
                       bool boundary = false) const;
        ///
        void setCursorIntern(BufferView *, Paragraph * par,
-                            Paragraph::size_type pos,
+                            pos_type pos,
                             bool setfont = true,
                             bool boundary = false) const;
        ///
@@ -318,10 +323,10 @@ public:
 
        ///
        bool isBoundary(Buffer const *, Paragraph * par,
-                       Paragraph::size_type pos) const;
+                       pos_type pos) const;
        ///
        bool isBoundary(Buffer const *, Paragraph * par,
-                        Paragraph::size_type pos,
+                        pos_type pos,
                         LyXFont const & font) const;
 
        ///
@@ -452,11 +457,9 @@ public:
        /// returns false if inset wasn't found
        bool updateInset(BufferView *, Inset *);
        ///
-       void checkParagraph(BufferView *, Paragraph * par,
-                           Paragraph::size_type pos);
+       void checkParagraph(BufferView *, Paragraph * par, pos_type pos);
        ///
-       int numberOfCell(Paragraph * par,
-                        Paragraph::size_type pos) const;
+       int numberOfCell(Paragraph * par, pos_type pos) const;
        ///
        void removeTableRow(LyXCursor & cursor) const;
        ///
@@ -472,7 +475,7 @@ public:
 
        /// Maps positions in the visual string to positions in logical string.
        inline
-       Paragraph::size_type log2vis(Paragraph::size_type pos) const {
+       pos_type log2vis(pos_type pos) const {
                if (bidi_start == -1)
                        return pos;
                else
@@ -481,7 +484,7 @@ public:
 
        /// Maps positions in the logical string to positions in visual string.
        inline
-       Paragraph::size_type vis2log(Paragraph::size_type pos) const {
+       pos_type vis2log(pos_type pos) const {
                if (bidi_start == -1)
                        return pos;
                else
@@ -489,7 +492,7 @@ public:
        }
        ///
        inline
-       Paragraph::size_type bidi_level(Paragraph::size_type pos) const {
+       pos_type bidi_level(pos_type pos) const {
                if (bidi_start == -1)
                        return 0;
                else
@@ -497,7 +500,7 @@ public:
        }       
        ///
        inline
-       bool bidi_InRange(Paragraph::size_type pos) const {
+       bool bidi_InRange(pos_type pos) const {
                return bidi_start == -1 ||
                        (bidi_start <= pos && pos <= bidi_end);
        }
@@ -511,12 +514,11 @@ private:
          Asger has learned that this should be a buffer-property instead
          Lgb has learned that 'char' is a lousy type for non-characters
          */
-       LyXTextClass::size_type copylayouttype;
+       layout_type copylayouttype;
 
        /** inserts a new row behind the specified row, increments
            the touched counters */
-       void insertRow(Row * row, Paragraph * par,
-                      Paragraph::size_type pos) const;
+       void insertRow(Row * row, Paragraph * par, pos_type pos) const;
        /** removes the row and reset the touched counters */
        void removeRow(Row * row) const;
 
@@ -618,19 +620,15 @@ private:
         */
        
        ///
-       int singleWidth(BufferView *, Paragraph * par,
-                       Paragraph::size_type pos) const;
+       int singleWidth(BufferView *, Paragraph * par, pos_type pos) const;
        ///
-       int singleWidth(BufferView *, Paragraph * par,
-                       Paragraph::size_type pos, char c) const;
+       int singleWidth(BufferView *, Paragraph * par, pos_type pos, char c) const;
        ///
        void draw(BufferView *, Row const * row,
-                 Paragraph::size_type & pos,
-                 int offset, float & x, bool cleared);
+                 pos_type & pos, int offset, float & x, bool cleared);
 
        /// get the next breakpoint in a given paragraph
-       Paragraph::size_type nextBreakPoint(BufferView *, Row const * row,
-                                              int width) const;
+       pos_type nextBreakPoint(BufferView *, Row const * row, int width) const;
        /// returns the minimum space a row needs on the screen in pixel
        int fill(BufferView *, Row * row, int workwidth) const;
        
@@ -639,8 +637,7 @@ private:
        int labelFill(BufferView *, Row const * row) const;
 
        ///
-       Paragraph::size_type
-       beginningOfMainBody(Buffer const *, Paragraph const * par) const;
+       pos_type beginningOfMainBody(Buffer const *, Paragraph const * par) const;
        
        /** Returns the left beginning of the text.
          This information cannot be taken from the layouts-objekt, because
@@ -671,39 +668,39 @@ private:
          LaTeX
          */
        bool hfillExpansion(Buffer const *, Row const * row_ptr,
-                           Paragraph::size_type pos) const;
+                           pos_type pos) const;
        /// 
        LColor::color backgroundColor();
 
 
        ///
-       mutable std::vector<Paragraph::size_type> log2vis_list;
+       mutable std::vector<pos_type> log2vis_list;
 
        ///
-       mutable std::vector<Paragraph::size_type> vis2log_list;
+       mutable std::vector<pos_type> vis2log_list;
 
        ///
-       mutable std::vector<Paragraph::size_type> bidi_levels;
+       mutable std::vector<pos_type> bidi_levels;
 
        ///
-       mutable Paragraph::size_type bidi_start;
+       mutable pos_type bidi_start;
 
        ///
-       mutable Paragraph::size_type bidi_end;
+       mutable pos_type bidi_end;
 
        ///
        mutable bool bidi_same_direction;
 
        ///
        unsigned char transformChar(unsigned char c, Paragraph * par,
-                                   Paragraph::size_type pos) const;
+                                   pos_type pos) const;
 
        /** returns the paragraph position of the last character in the 
          specified row
          */
-       Paragraph::size_type rowLast(Row const * row) const;
+       pos_type rowLast(Row const * row) const;
        ///
-       Paragraph::size_type rowLastPrintable(Row const * row) const;
+       pos_type rowLastPrintable(Row const * row) const;
 
        ///
        void charInserted();
@@ -718,23 +715,4 @@ public:
        void ownerParagraph(int id, Paragraph *) const;
 };
 
-
-/* returns a pointer to the row near the specified y-coordinate
- * (relative to the whole text). y is set to the real beginning
- * of this row */
-inline
-Row * LyXText::getRowNearY(int & y) const
-{
-       // If possible we should optimize this method. (Lgb)
-       Row * tmprow = firstrow;
-       int tmpy = 0;
-       
-       while (tmprow->next() && tmpy + tmprow->height() <= y) {
-               tmpy += tmprow->height();
-               tmprow = tmprow->next();
-       }
-       
-       y = tmpy;   // return the real y
-       return tmprow;
-}
 #endif
index 05e1fb71f93f95f3e22e8ccf71f8d5b65f498b02..733daee2fea70132ed217f09a1b3250c9602ec1a 100644 (file)
@@ -243,7 +243,7 @@ void Paragraph::writeFile(Buffer const * buf, ostream & os,
        LyXFont font1(LyXFont::ALL_INHERIT, bparams.language);
        
        int column = 0;
-       for (size_type i = 0; i < size(); ++i) {
+       for (pos_type i = 0; i < size(); ++i) {
                if (!i) {
                        os << "\n";
                        column = 0;
@@ -398,8 +398,7 @@ void Paragraph::validate(LaTeXFeatures & features) const
 
 
 // First few functions needed for cut and paste and paragraph breaking.
-void Paragraph::copyIntoMinibuffer(Buffer const & buffer,
-                                     Paragraph::size_type pos) const
+void Paragraph::copyIntoMinibuffer(Buffer const & buffer, pos_type pos) const
 {
        BufferParams bparams = buffer.params;
 
@@ -418,8 +417,7 @@ void Paragraph::copyIntoMinibuffer(Buffer const & buffer,
 }
 
 
-void Paragraph::cutIntoMinibuffer(BufferParams const & bparams,
-                                    Paragraph::size_type pos)
+void Paragraph::cutIntoMinibuffer(BufferParams const & bparams, pos_type pos)
 {
        minibuffer_char = getChar(pos);
        minibuffer_font = getFontSettings(bparams, pos);
@@ -450,7 +448,7 @@ void Paragraph::cutIntoMinibuffer(BufferParams const & bparams,
 }
 
 
-bool Paragraph::insertFromMinibuffer(Paragraph::size_type pos)
+bool Paragraph::insertFromMinibuffer(pos_type pos)
 {
        if (minibuffer_char == Paragraph::META_INSET) {
                if (!insetAllowed(minibuffer_inset->lyxCode())) {
@@ -480,7 +478,7 @@ void Paragraph::clear()
 }
 
 
-void Paragraph::erase(Paragraph::size_type pos)
+void Paragraph::erase(pos_type pos)
 {
        pimpl_->erase(pos);
 }
@@ -494,29 +492,28 @@ bool Paragraph::checkInsertChar(LyXFont & font)
 }
 
 
-void Paragraph::insertChar(Paragraph::size_type pos, Paragraph::value_type c)
+void Paragraph::insertChar(pos_type pos, Paragraph::value_type c)
 {
        LyXFont const f(LyXFont::ALL_INHERIT);
        insertChar(pos, c, f);
 }
 
 
-void Paragraph::insertChar(Paragraph::size_type pos, Paragraph::value_type c,
+void Paragraph::insertChar(pos_type pos, Paragraph::value_type c,
                            LyXFont const & font)
 {
        pimpl_->insertChar(pos, c, font);
 }
 
 
-void Paragraph::insertInset(Paragraph::size_type pos, Inset * inset)
+void Paragraph::insertInset(pos_type pos, Inset * inset)
 {
        LyXFont const f(LyXFont::ALL_INHERIT);
        insertInset(pos, inset, f);
 }
 
 
-void Paragraph::insertInset(Paragraph::size_type pos, Inset * inset,
-                            LyXFont const & font)
+void Paragraph::insertInset(pos_type pos, Inset * inset, LyXFont const & font)
 {
        pimpl_->insertInset(pos, inset, font);
 }
@@ -532,7 +529,7 @@ bool Paragraph::insetAllowed(Inset::Code code)
 }
 
 
-Inset * Paragraph::getInset(Paragraph::size_type pos)
+Inset * Paragraph::getInset(pos_type pos)
 {
        lyx::Assert(pos < size());
 
@@ -557,7 +554,7 @@ Inset * Paragraph::getInset(Paragraph::size_type pos)
 }
 
 
-Inset const * Paragraph::getInset(Paragraph::size_type pos) const
+Inset const * Paragraph::getInset(pos_type pos) const
 {
        lyx::Assert(pos < size());
 
@@ -583,7 +580,7 @@ Inset const * Paragraph::getInset(Paragraph::size_type pos) const
 
 // Gets uninstantiated font setting at position.
 LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
-                                         Paragraph::size_type pos) const
+                                         pos_type pos) const
 {
        lyx::Assert(pos <= size());
        
@@ -627,14 +624,14 @@ LyXFont const Paragraph::getFirstFontSettings() const
 // If position is -1, we get the layout font of the paragraph.
 // If position is -2, we get the font of the manual label of the paragraph.
 LyXFont const Paragraph::getFont(BufferParams const & bparams,
-                                Paragraph::size_type pos) const
+                                pos_type pos) const
 {
        lyx::Assert(pos >= 0);
        
        LyXLayout const & layout =
                textclasslist.Style(bparams.textclass, 
                                    getLayout());
-       Paragraph::size_type main_body = 0;
+       pos_type main_body = 0;
        if (layout.labeltype == LABEL_MANUAL)
                main_body = beginningOfMainBody();
 
@@ -682,8 +679,7 @@ LyXFont const Paragraph::getLayoutFont(BufferParams const & bparams) const
 
 /// Returns the height of the highest font in range
 LyXFont::FONT_SIZE
-Paragraph::highestFontInRange(Paragraph::size_type startpos,
-                              Paragraph::size_type endpos,
+Paragraph::highestFontInRange(pos_type startpos, pos_type endpos,
                              LyXFont::FONT_SIZE const def_size) const
 {
        if (pimpl_->fontlist.empty())
@@ -717,7 +713,7 @@ Paragraph::highestFontInRange(Paragraph::size_type startpos,
 
 Paragraph::value_type
 Paragraph::getUChar(BufferParams const & bparams,
-                      Paragraph::size_type pos) const
+                      pos_type pos) const
 {
        value_type c = getChar(pos);
        if (!lyxrc.rtl_support)
@@ -757,7 +753,7 @@ Paragraph::getUChar(BufferParams const & bparams,
 }
 
 
-void Paragraph::setFont(Paragraph::size_type pos,
+void Paragraph::setFont(pos_type pos,
                           LyXFont const & font)
 {
        lyx::Assert(pos <= size());
@@ -859,7 +855,7 @@ Paragraph const * Paragraph::previous() const
 
 
 void Paragraph::breakParagraph(BufferParams const & bparams,
-                                 Paragraph::size_type pos,
+                                 pos_type pos,
                                  int flag)
 {
        // create a new paragraph
@@ -893,9 +889,9 @@ void Paragraph::breakParagraph(BufferParams const & bparams,
                
                // copy everything behind the break-position
                // to the new paragraph
-               size_type pos_end = pimpl_->size() - 1;
-               size_type i = pos;
-               size_type j = pos;
+               pos_type pos_end = pimpl_->size() - 1;
+               pos_type i = pos;
+               pos_type j = pos;
                for (; i <= pos_end; ++i) {
                        cutIntoMinibuffer(bparams, i);
                        if (tmp->insertFromMinibuffer(j - pos))
@@ -956,7 +952,7 @@ bool Paragraph::hasSameLayout(Paragraph const * par) const
 
 
 void Paragraph::breakParagraphConservative(BufferParams const & bparams,
-                                          Paragraph::size_type pos)
+                                          pos_type pos)
 {
        // create a new paragraph
        Paragraph * tmp = new Paragraph(this);
@@ -967,17 +963,17 @@ void Paragraph::breakParagraphConservative(BufferParams const & bparams,
        if (size() > pos) {
                // copy everything behind the break-position to the new
                // paragraph
-               size_type pos_end = pimpl_->size() - 1;
+               pos_type pos_end = pimpl_->size() - 1;
 
-               //size_type i = pos;
-               //size_type j = pos;
-               for (size_type i = pos, j = pos; i <= pos_end; ++i) {
+               //pos_type i = pos;
+               //pos_type j = pos;
+               for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
                        cutIntoMinibuffer(bparams, i);
                        if (tmp->insertFromMinibuffer(j - pos))
                                ++j;
                }
                
-               for (size_type k = pos_end; k >= pos; --k) {
+               for (pos_type k = pos_end; k >= pos; --k) {
                        erase(k);
                }
        }
@@ -997,11 +993,11 @@ void Paragraph::pasteParagraph(BufferParams const & bparams)
        params().spaceBottom(the_next->params().spaceBottom());
        params().pagebreakBottom(the_next->params().pagebreakBottom());
 
-       size_type pos_end = the_next->pimpl_->size() - 1;
-       size_type pos_insert = size();
+       pos_type pos_end = the_next->pimpl_->size() - 1;
+       pos_type pos_insert = size();
 
        // ok, now copy the paragraph
-       for (size_type i = 0, j = 0; i <= pos_end; ++i) {
+       for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
                the_next->cutIntoMinibuffer(bparams, i);
                if (insertFromMinibuffer(pos_insert + j))
                        ++j;
@@ -1020,7 +1016,7 @@ int Paragraph::getEndLabel(BufferParams const & bparams) const
        Paragraph const * par = this;
        depth_type par_depth = getDepth();
        while (par) {
-               LyXTextClass::LayoutList::size_type layout = par->getLayout();
+               Paragraph::layout_type layout = par->getLayout();
                int const endlabeltype =
                        textclasslist.Style(bparams.textclass,
                                            layout).endlabeltype;
@@ -1085,15 +1081,15 @@ void Paragraph::setLabelWidthString(string const & s)
 }
 
 
-void Paragraph::setOnlyLayout(LyXTextClass::size_type new_layout)
+void Paragraph::setOnlyLayout(layout_type new_layout)
 {
        layout = new_layout;
 }
 
 
-void Paragraph::setLayout(LyXTextClass::size_type new_layout)
+void Paragraph::setLayout(layout_type new_layout)
 {
-        layout = new_layout;
+       layout = new_layout;
        params().labelWidthString(string());
        params().align(LYX_ALIGN_LAYOUT);
        params().spaceTop(VSpace(VSpace::NONE));
@@ -1114,7 +1110,7 @@ int Paragraph::beginningOfMainBody() const
        // Unroll the first two cycles of the loop
        // and remember the previous character to
        // remove unnecessary GetChar() calls
-       size_type i = 0;
+       pos_type i = 0;
        if (i < size()
            && getChar(i) != Paragraph::META_NEWLINE) {
                ++i;
@@ -1206,7 +1202,7 @@ int Paragraph::autoDeleteInsets()
 
 
 Paragraph::inset_iterator
-Paragraph::InsetIterator(Paragraph::size_type pos)
+Paragraph::InsetIterator(pos_type pos)
 {
        InsetTable search_inset(pos, 0);
        InsetList::iterator it = lower_bound(insetlist.begin(),
@@ -1458,7 +1454,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
        LyXFont basefont;
 
        // Maybe we have to create a optional argument.
-       size_type main_body;
+       pos_type main_body;
        if (style.labeltype != LABEL_MANUAL)
                main_body = 0;
        else
@@ -1491,7 +1487,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
 
        texrow.start(this, 0);
 
-       for (size_type i = 0; i < size(); ++i) {
+       for (pos_type i = 0; i < size(); ++i) {
                ++column;
                // First char in paragraph or after label?
                if (i == main_body) {
@@ -1838,44 +1834,44 @@ Paragraph * Paragraph::TeXEnvironment(Buffer const * buf,
 }
 
 
-bool Paragraph::isHfill(size_type pos) const
+bool Paragraph::isHfill(pos_type pos) const
 {
        return IsHfillChar(getChar(pos));
 }
 
 
-bool Paragraph::isInset(size_type pos) const
+bool Paragraph::isInset(pos_type pos) const
 {
        return IsInsetChar(getChar(pos));
 }
 
 
-bool Paragraph::isNewline(size_type pos) const
+bool Paragraph::isNewline(pos_type pos) const
 {
        return pos >= 0 && IsNewlineChar(getChar(pos));
 }
 
 
-bool Paragraph::isSeparator(size_type pos) const
+bool Paragraph::isSeparator(pos_type pos) const
 {
        return IsSeparatorChar(getChar(pos));
 }
 
 
-bool Paragraph::isLineSeparator(size_type pos) const
+bool Paragraph::isLineSeparator(pos_type pos) const
 {
        return IsLineSeparatorChar(getChar(pos));
 }
 
 
-bool Paragraph::isKomma(size_type pos) const
+bool Paragraph::isKomma(pos_type pos) const
 {
        return IsKommaChar(getChar(pos));
 }
 
 
 /// Used by the spellchecker
-bool Paragraph::isLetter(Paragraph::size_type pos) const
+bool Paragraph::isLetter(pos_type pos) const
 {
        value_type const c = getChar(pos);
        if (IsLetterChar(c))
@@ -1888,7 +1884,7 @@ bool Paragraph::isLetter(Paragraph::size_type pos) const
 }
  
  
-bool Paragraph::isWord(size_type pos ) const
+bool Paragraph::isWord(pos_type pos ) const
 {
        return IsWordChar(getChar(pos)) ;
 }
@@ -1924,7 +1920,7 @@ bool Paragraph::isRightToLeftPar(BufferParams const & bparams) const
 void Paragraph::changeLanguage(BufferParams const & bparams,
                                  Language const * from, Language const * to)
 {
-       for (size_type i = 0; i < size(); ++i) {
+       for (pos_type i = 0; i < size(); ++i) {
                LyXFont font = getFontSettings(bparams, i);
                if (font.language() == from) {
                        font.setLanguage(to);
@@ -1960,7 +1956,7 @@ string const Paragraph::asString(Buffer const * buffer, bool label)
                s += params().labelString() + ' ';
        string::size_type const len = s.size();
 
-       for (Paragraph::size_type i = 0; i < size(); ++i) {
+       for (pos_type i = 0; i < size(); ++i) {
                value_type c = getChar(i);
                if (IsPrintable(c))
                        s += c;
@@ -1980,16 +1976,14 @@ string const Paragraph::asString(Buffer const * buffer, bool label)
 
 
 string const Paragraph::asString(Buffer const * buffer, 
-                                Paragraph::size_type beg,
-                                Paragraph::size_type end,
-                                bool label)
+                                pos_type beg, pos_type end, bool label)
 {
        ostringstream ost;
 
        if (beg == 0 && label && !params().labelString().empty())
                ost << params().labelString() << ' ';
 
-       for (Paragraph::size_type i = beg; i < end; ++i) {
+       for (pos_type i = beg; i < end; ++i) {
                value_type const c = getUChar(buffer->params, i);
                if (IsPrintable(c))
                        ost << c;
@@ -2054,14 +2048,13 @@ void Paragraph::setContentsFromPar(Paragraph * par)
 }
 
 
-Paragraph::size_type Paragraph::size() const
+Paragraph::pos_type Paragraph::size() const
 {
        return pimpl_->size();
 }
 
 
-Paragraph::value_type
-Paragraph::getChar(Paragraph::size_type pos) const
+Paragraph::value_type Paragraph::getChar(pos_type pos) const
 {
        return pimpl_->getChar(pos);
 }
@@ -2079,7 +2072,7 @@ void  Paragraph::id(int id_arg)
 }
 
 
-LyXTextClass::LayoutList::size_type Paragraph::getLayout() const
+Paragraph::layout_type Paragraph::getLayout() const
 {
        return layout;
 }
@@ -2124,7 +2117,7 @@ void Paragraph::incCounter(int i)
 }
 
 
-void Paragraph::setChar(size_type pos, value_type c)
+void Paragraph::setChar(pos_type pos, value_type c)
 {
        pimpl_->setChar(pos, c);
 }
index 604c9f034dfb02ad0390871933bf9ce28207cc84..220049ec8eb8f725d6b5668c8b83cc916201d067 100644 (file)
 
 #include "LString.h"
 
-#include <vector>
-
 #include "insets/inset.h" // Just for Inset::Code
 #include "layout.h"
+#include "support/types.h"
 
 class ParagraphParameters;
 class BufferParams;
@@ -80,13 +79,10 @@ public:
        typedef char value_type;
        /// The same as ParameterStruct::depth_type 
        typedef unsigned int depth_type;
-       ///
-       typedef std::vector<value_type> TextContainer;
-       ///
-       /* This should be TextContainer::size_type, but we need
-          signed values for now.
-       */
-       typedef TextContainer::difference_type size_type;
+       /// a position in the paragraph
+       typedef lyx::pos_type pos_type;
+       /// a layout number
+       typedef lyx::layout_type layout_type;
 
        ///
        Paragraph();
@@ -111,7 +107,7 @@ public:
 
        string const asString(Buffer const *, bool label);
        ///
-       string const asString(Buffer const *, size_type beg, size_type end,
+       string const asString(Buffer const *, pos_type beg, pos_type end,
                              bool label);
        
        ///
@@ -160,14 +156,14 @@ public:
        void resizeInsetsLyXText(BufferView *);
 
        ///
-       size_type size() const;
+       pos_type size() const;
        ///
        void setContentsFromPar(Paragraph * par);
        ///
        void clearContents();
 
        ///
-       LyXTextClass::LayoutList::size_type layout;
+       layout_type layout;
 
        ///
        void setCounter(int i, int v);
@@ -182,8 +178,8 @@ public:
        ///
        char itemdepth;
 
-        /// 
-        InsetBibKey * bibkey;  // ale970302
+       /// 
+       InsetBibKey * bibkey;  // ale970302
 
        ///
        void next(Paragraph *);
@@ -218,30 +214,30 @@ public:
        ///
        void setLabelWidthString(string const & s);
        ///
-       LyXTextClass::LayoutList::size_type getLayout() const;
+       layout_type getLayout() const;
        ///
        char getAlign() const;
        ///
        depth_type getDepth() const;
        ///
-       void setLayout(LyXTextClass::LayoutList::size_type new_layout);
+       void setLayout(layout_type new_layout);
        ///
-       void setOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
+       void setOnlyLayout(layout_type new_layout);
        ///
        int getFirstCounter(int i) const;
        ///
-       void erase(size_type pos);
+       void erase(pos_type pos);
        /** the flag determines wether the layout should be copied
         */ 
-       void breakParagraph(BufferParams const &, size_type pos, int flag);
+       void breakParagraph(BufferParams const &, pos_type pos, int flag);
        ///
-       void breakParagraphConservative(BufferParams const &, size_type pos);
+       void breakParagraphConservative(BufferParams const &, pos_type pos);
        /** Get unistantiated font setting. Returns the difference
            between the characters font and the layoutfont.
            This is what is stored in the fonttable
        */
        LyXFont const
-       getFontSettings(BufferParams const &, size_type pos) const;
+       getFontSettings(BufferParams const &, pos_type pos) const;
        ///
        LyXFont const getFirstFontSettings() const;
 
@@ -252,62 +248,62 @@ public:
            attributes with values LyXFont::INHERIT, LyXFont::IGNORE or 
            LyXFont::TOGGLE.
        */
-       LyXFont const getFont(BufferParams const &, size_type pos) const;
+       LyXFont const getFont(BufferParams const &, pos_type pos) const;
        LyXFont const getLayoutFont(BufferParams const &) const;
        LyXFont const getLabelFont(BufferParams const &) const;
        ///
-       value_type getChar(size_type pos) const;
+       value_type getChar(pos_type pos) const;
        ///
-       value_type getUChar(BufferParams const &, size_type pos) const;
+       value_type getUChar(BufferParams const &, pos_type pos) const;
        /// The position must already exist.
-       void setChar(size_type pos, value_type c);
+       void setChar(pos_type pos, value_type c);
        ///
-       void setFont(size_type pos, LyXFont const & font);
+       void setFont(pos_type pos, LyXFont const & font);
        /// Returns the height of the highest font in range
-       LyXFont::FONT_SIZE highestFontInRange(size_type startpos,
-                                             size_type endpos,
+       LyXFont::FONT_SIZE highestFontInRange(pos_type startpos,
+                                             pos_type endpos,
                                                                                  LyXFont::FONT_SIZE const def_size) const;
        ///
-       void insertChar(size_type pos, value_type c);
+       void insertChar(pos_type pos, value_type c);
        ///
-       void insertChar(size_type pos, value_type c, LyXFont const &);
+       void insertChar(pos_type pos, value_type c, LyXFont const &);
        ///
        bool checkInsertChar(LyXFont &);
        ///
-       void insertInset(size_type pos, Inset * inset);
+       void insertInset(pos_type pos, Inset * inset);
        ///
-       void insertInset(size_type pos, Inset * inset, LyXFont const &);
+       void insertInset(pos_type pos, Inset * inset, LyXFont const &);
        ///
        bool insetAllowed(Inset::Code code);
        ///
-       Inset * getInset(size_type pos);
+       Inset * getInset(pos_type pos);
        ///
-       Inset const * getInset(size_type pos) const;
+       Inset const * getInset(pos_type pos) const;
        /** important for cut and paste
            Temporary change from BufferParams to Buffer. Will revert when we
            get rid of the argument to Inset::clone(Buffer const &) */
-       void copyIntoMinibuffer(Buffer const &, size_type pos) const;
+       void copyIntoMinibuffer(Buffer const &, pos_type pos) const;
        ///
-       void cutIntoMinibuffer(BufferParams const &, size_type pos);
+       void cutIntoMinibuffer(BufferParams const &, pos_type pos);
        ///
-       bool insertFromMinibuffer(size_type pos);
+       bool insertFromMinibuffer(pos_type pos);
 
        ///
-       bool isHfill(size_type pos) const;
+       bool isHfill(pos_type pos) const;
        ///
-       bool isInset(size_type pos) const;
+       bool isInset(pos_type pos) const;
        ///
-       bool isNewline(size_type pos) const;
+       bool isNewline(pos_type pos) const;
        ///
-       bool isSeparator(size_type pos) const;
+       bool isSeparator(pos_type pos) const;
        ///
-       bool isLineSeparator(size_type pos) const;
+       bool isLineSeparator(pos_type pos) const;
        ///
-       bool isKomma(size_type pos) const;
+       bool isKomma(pos_type pos) const;
        /// Used by the spellchecker
-       bool isLetter(size_type pos) const;
+       bool isLetter(pos_type pos) const;
        /// 
-       bool isWord(size_type pos) const;
+       bool isWord(pos_type pos) const;
 
        /** This one resets all layout and dtp switches but not the font
            of the single characters
@@ -332,13 +328,13 @@ public:
        int stripLeadingSpaces(LyXTextClassList::size_type tclass); 
 
 #ifndef NO_PEXTRA_REALLY
-        /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
-           I have to set it on each of it's elements */
+       /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
+          I have to set it on each of it's elements */
        ///
-        void setPExtraType(BufferParams const &, int type,
+       void setPExtraType(BufferParams const &, int type,
                           string const & width, string const & widthp);
        ///
-        void unsetPExtraType(BufferParams const &);
+       void unsetPExtraType(BufferParams const &);
 #endif
        ///
        bool sgmlConvertChar(char c, string & sgml_string);
@@ -350,11 +346,11 @@ private:
        ///
        struct InsetTable {
                ///
-               size_type pos;
+               pos_type pos;
                ///
                Inset * inset;
                ///
-               InsetTable(size_type p, Inset * i) : pos(p), inset(i) {}
+               InsetTable(pos_type p, Inset * i) : pos(p), inset(i) {}
        };
 
        ///
@@ -377,7 +373,7 @@ public:
                ///
                Inset * operator*() { return it->inset; }
                ///
-               size_type getPos() const {return it->pos; }
+               pos_type getPos() const { return it->pos; }
                ///
                bool operator==(inset_iterator const & iter) const {
                        return it == iter.it;
@@ -398,7 +394,7 @@ public:
        ///
        inset_iterator inset_iterator_end();
        ///
-       inset_iterator InsetIterator(size_type pos);
+       inset_iterator InsetIterator(pos_type pos);
 
 private:
        /// if anything uses this we don't want it to.
@@ -415,4 +411,9 @@ private:
        Pimpl * pimpl_;
 };
 
+inline bool isMetaInset(Paragraph const * par, Paragraph::pos_type const pos)
+{
+       return par->getChar(pos) == Paragraph::META_INSET;
+}
 #endif
index 1c4e244197e09cc8a6977f62d9f0a9aeeeb3179b..e58e0cde49d6efd6a7b165994ced4ccfd78e20ad 100644 (file)
@@ -40,8 +40,7 @@ Paragraph::Pimpl::Pimpl(Paragraph * owner)
 }
 
 
-Paragraph::Pimpl::Pimpl(Paragraph::Pimpl const & p, Paragraph * owner,
-                        bool same_ids)
+Paragraph::Pimpl::Pimpl(Pimpl const & p, Paragraph * owner, bool same_ids)
        : params(p.params), owner_(owner)
 {
        inset_owner = p.inset_owner;
@@ -67,8 +66,7 @@ void Paragraph::Pimpl::setContentsFromPar(Paragraph const * par)
 }
 
 
-Paragraph::value_type
-Paragraph::Pimpl::getChar(Paragraph::size_type pos) const
+Paragraph::value_type Paragraph::Pimpl::getChar(pos_type pos) const
 {
        lyx::Assert(pos <= size());
        // This is stronger, and I belive that this is the assertion
@@ -82,15 +80,13 @@ Paragraph::Pimpl::getChar(Paragraph::size_type pos) const
 }
 
 
-void Paragraph::Pimpl::setChar(Paragraph::size_type pos,
-                               Paragraph::value_type c)
+void Paragraph::Pimpl::setChar(pos_type pos, value_type c)
 {
        text[pos] = c;
 }
 
 
-void Paragraph::Pimpl::insertChar(Paragraph::size_type pos,
-                                  Paragraph::value_type c,
+void Paragraph::Pimpl::insertChar(pos_type pos, value_type c,
                                   LyXFont const & font)
 {
        lyx::Assert(pos <= size());
@@ -120,7 +116,7 @@ void Paragraph::Pimpl::insertChar(Paragraph::size_type pos,
 }
 
 
-void Paragraph::Pimpl::insertInset(Paragraph::size_type pos,
+void Paragraph::Pimpl::insertInset(pos_type pos,
                                   Inset * inset, LyXFont const & font)
 {
        lyx::Assert(inset);
@@ -146,7 +142,7 @@ void Paragraph::Pimpl::insertInset(Paragraph::size_type pos,
 }
 
 
-void Paragraph::Pimpl::erase(Paragraph::size_type pos)
+void Paragraph::Pimpl::erase(pos_type pos)
 {
        lyx::Assert(pos < size());
        // if it is an inset, delete the inset entry 
@@ -208,7 +204,7 @@ void Paragraph::Pimpl::erase(Paragraph::size_type pos)
 
 
 void Paragraph::Pimpl::simpleTeXBlanks(std::ostream & os, TexRow & texrow,
-                                      Paragraph::size_type const i,
+                                      pos_type const i,
                                       int & column, LyXFont const & font,
                                       LyXLayout const & style)
 {
@@ -244,7 +240,7 @@ void Paragraph::Pimpl::simpleTeXBlanks(std::ostream & os, TexRow & texrow,
 }
 
 
-bool Paragraph::Pimpl::isTextAt(string const & str, Paragraph::size_type pos)
+bool Paragraph::Pimpl::isTextAt(string const & str, pos_type pos)
 {
        for (int i=0; i < str.length(); ++i) {
                if (pos + i >= size())
@@ -266,9 +262,9 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
                                             LyXFont & basefont,
                                             bool & open_font,
                                             LyXLayout const & style,
-                                            Paragraph::size_type & i,
+                                            pos_type & i,
                                             int & column,
-                                            Paragraph::value_type const c)
+                                            value_type const c)
 {
        if (style.pass_thru) {
                if (c != '\0') os << c;
index bfc07e8377508c2a1d0df5f8f88a01ba80ecbf87..393a6397e3246b3a9761981f898d719e47a6fc3f 100644 (file)
 #include <boost/array.hpp>
 
 struct Paragraph::Pimpl {
+       ///
+       typedef std::vector<value_type> TextContainer;
+
        ///
        Pimpl(Paragraph * owner);
        /// Copy constructor
        Pimpl(Pimpl const &, Paragraph * owner, bool same_ids = false);
        ///
-       Paragraph::size_type size() const {
+       pos_type size() const {
                return text.size();
        }
        ///
@@ -34,20 +37,15 @@ struct Paragraph::Pimpl {
        ///
        void setContentsFromPar(Paragraph const * par);
        ///
-       Paragraph::value_type
-       getChar(Paragraph::size_type pos) const;
+       value_type getChar(pos_type pos) const;
        ///
-       void setChar(Paragraph::size_type pos, Paragraph::value_type c);
+       void setChar(pos_type pos, value_type c);
        ///
-       void insertChar(Paragraph::size_type pos,
-                       Paragraph::value_type c,
-                       LyXFont const & font);
+       void insertChar(pos_type pos, value_type c, LyXFont const & font);
        ///
-       void insertInset(Paragraph::size_type pos,
-                        Inset * inset,
-                        LyXFont const & font);
+       void insertInset(pos_type pos, Inset * inset, LyXFont const & font);
        ///
-       void erase(Paragraph::size_type pos);
+       void erase(pos_type pos);
        ///
        LyXFont const realizeFont(LyXFont const & font,
                                  BufferParams const & bparams) const;
@@ -62,8 +60,7 @@ struct Paragraph::Pimpl {
        struct matchIT {
                /// used by lower_bound and upper_bound
                inline
-               int operator()(Paragraph::InsetTable const & a,
-                              Paragraph::InsetTable const & b) const {
+               int operator()(InsetTable const & a, InsetTable const & b) const {
                        return a.pos < b.pos;
                }
        };
@@ -80,22 +77,22 @@ struct Paragraph::Pimpl {
        */
        struct FontTable  {
                ///
-               FontTable(size_type p, LyXFont const & f)
+               FontTable(pos_type p, LyXFont const & f)
                        : pos_(p)
                        {
                                font_ = container.get(f);
                        }
                ///
-               size_type pos() const { return pos_; }
+               pos_type pos() const { return pos_; }
                ///
-               void pos(size_type p) { pos_ = p; }
+               void pos(pos_type p) { pos_ = p; }
                ///
                LyXFont const & font() const { return *font_; }
                ///
                void font(LyXFont const & f) { font_ = container.get(f);}
        private:
                /// End position of paragraph this font attribute covers
-               size_type pos_;
+               pos_type pos_;
                /** Font. Interpretation of the font values:
                    If a value is LyXFont::INHERIT_*, it means that the font 
                    attribute is inherited from either the layout of this
@@ -115,8 +112,7 @@ struct Paragraph::Pimpl {
        struct matchFT {
                /// used by lower_bound and upper_bound
                inline
-               int operator()(Paragraph::Pimpl::FontTable const & a,
-                              Paragraph::Pimpl::FontTable const & b) const {
+               int operator()(FontTable const & a, FontTable const & b) const {
                        return a.pos() < b.pos();
                }
        };
@@ -130,7 +126,7 @@ struct Paragraph::Pimpl {
                                 std::ostream &, TexRow & texrow);
        ///
        void simpleTeXBlanks(std::ostream &, TexRow & texrow,
-                            size_type const i,
+                            pos_type const i,
                             int & column, LyXFont const & font,
                             LyXLayout const & style);
        ///
@@ -140,7 +136,7 @@ struct Paragraph::Pimpl {
                                   LyXFont & font, LyXFont & running_font,
                                   LyXFont & basefont, bool & open_font,
                                   LyXLayout const & style,
-                                  size_type & i,
+                                  pos_type & i,
                                   int & column, value_type const c);
        ///
        Paragraph * getParFromID(int id) const;
@@ -152,7 +148,7 @@ struct Paragraph::Pimpl {
        ParagraphParameters params;
 private:
        /// match a string against a particular point in the paragraph
-       bool isTextAt(string const & str, Paragraph::size_type pos);
+       bool isTextAt(string const & str, pos_type pos);
  
        /// Who owns us?
        Paragraph * owner_;
index 37cd8d2d7c033c429e9b4962eb3f4c854104c566..dd67d72291f4a70d092c4b09c28932f6aa939af0 100644 (file)
@@ -1,3 +1,7 @@
+2001-11-26  André Pönitz <poenitz@gmx.net>
+       
+       * types.h: introduce type for paragraph positions and layout numbers
+
 2001-11-04  John Levon  <moz@compsoc.man.ac.uk>
 
        * filetools.C: remove dead code
diff --git a/src/support/types.h b/src/support/types.h
new file mode 100644 (file)
index 0000000..2b3413f
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef LYX_TYPES_H
+#define LYX_TYPES_H
+
+// provide a set of typedefs for commonly used things like sizes and
+// indices whil trying to stay compatible with typse used by the standard
+// containers.
+
+
+// this probably could be improved by using <cstddef>...
+#include <vector>
+
+namespace lyx
+{
+       /// a type for sizes
+       typedef std::vector<char>::size_type         size_type;
+
+       /// a type for positions used in paragraphs
+       // needs to be signed for a while to hold the special value -1 that is
+       // used there...
+       typedef std::vector<char>::difference_type   pos_type;
+
+       /// a type used for numbering layouts   
+       typedef std::vector<char>::size_type         layout_type;
+
+}
+
+#endif
index dfbc31359c0deb4daf8cc1ef1cc1f91d0a99e93a..a7f2cbd330e1cef94814accdc594c751365fa438 100644 (file)
@@ -11,6 +11,7 @@
 #include <config.h>
 
 #include "lyxtext.h"
+#include "lyxrow.h"
 #include "layout.h"
 #include "paragraph.h"
 #include "lyx_gui_misc.h"
@@ -67,7 +68,7 @@ int LyXText::workWidth(BufferView * bview) const
 int LyXText::workWidth(BufferView * bview, Inset * inset) const
 {
        Paragraph * par = 0;
-       Paragraph::size_type pos = 0;
+       pos_type pos = 0;
 
        Buffer::inset_iterator it = bview->buffer()->inset_iterator_begin();
 
@@ -123,7 +124,7 @@ int LyXText::getRealCursorX(BufferView * bview) const
 
 
 unsigned char LyXText::transformChar(unsigned char c, Paragraph * par,
-                       Paragraph::size_type pos) const
+                       pos_type pos) const
 {
        if (!Encodings::is_arabic(c))
                if (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 && isdigit(c))
@@ -134,7 +135,7 @@ unsigned char LyXText::transformChar(unsigned char c, Paragraph * par,
        unsigned char const prev_char = pos > 0 ? par->getChar(pos-1) : ' ';
        unsigned char next_char = ' ';
 
-       for (Paragraph::size_type i = pos+1; i < par->size(); ++i)
+       for (pos_type i = pos+1; i < par->size(); ++i)
                if (!Encodings::IsComposeChar_arabic(par->getChar(i))) {
                        next_char = par->getChar(i);
                        break;
@@ -179,7 +180,7 @@ unsigned char LyXText::transformChar(unsigned char c, Paragraph * par,
 // Lgb
 
 int LyXText::singleWidth(BufferView * bview, Paragraph * par,
-                        Paragraph::size_type pos) const
+                        pos_type pos) const
 {
        char const c = par->getChar(pos);
        return singleWidth(bview, par, pos, c);
@@ -187,7 +188,7 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par,
 
 
 int LyXText::singleWidth(BufferView * bview, Paragraph * par,
-                         Paragraph::size_type pos, char c) const
+                         pos_type pos, char c) const
 {
        LyXFont const font = getFont(bview->buffer(), par, pos);
 
@@ -229,7 +230,7 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par,
 
 
 // Returns the paragraph position of the last character in the specified row
-Paragraph::size_type LyXText::rowLast(Row const * row) const
+LyXText::pos_type LyXText::rowLast(Row const * row) const
 {
        if (row->next() == 0)
                return row->par()->size() - 1;
@@ -240,9 +241,9 @@ Paragraph::size_type LyXText::rowLast(Row const * row) const
 }
 
 
-Paragraph::size_type LyXText::rowLastPrintable(Row const * row) const
+LyXText::pos_type LyXText::rowLastPrintable(Row const * row) const
 {
-       Paragraph::size_type const last = rowLast(row);
+       pos_type const last = rowLast(row);
        if (last >= row->pos()
            && row->next()
            && row->next()->par() == row->par()
@@ -270,8 +271,8 @@ void LyXText::computeBidiTables(Buffer const * buf, Row * row) const
        }
 
        if (bidi_end + 2 - bidi_start >
-           static_cast<Paragraph::size_type>(log2vis_list.size())) {
-               Paragraph::size_type new_size = 
+           static_cast<pos_type>(log2vis_list.size())) {
+               pos_type new_size = 
                        (bidi_end + 2 - bidi_start < 500) ?
                        500 : 2 * (bidi_end + 2 - bidi_start);
                log2vis_list.resize(new_size);
@@ -282,19 +283,18 @@ void LyXText::computeBidiTables(Buffer const * buf, Row * row) const
        vis2log_list[bidi_end + 1 - bidi_start] = -1;
        log2vis_list[bidi_end + 1 - bidi_start] = -1;
 
-       Paragraph::size_type    stack[2];
+       pos_type stack[2];
        bool const rtl_par =
                row->par()->getParLanguage(buf->params)->RightToLeft();
        int level = 0;
        bool rtl = false;
        bool rtl0 = false;
-       Paragraph::size_type const main_body =
-               beginningOfMainBody(buf, row->par());
+       pos_type const main_body = beginningOfMainBody(buf, row->par());
 
-       for (Paragraph::size_type lpos = bidi_start;
+       for (pos_type lpos = bidi_start;
             lpos <= bidi_end; ++lpos) {
                bool is_space = row->par()->isLineSeparator(lpos);
-               Paragraph::size_type const pos =
+               pos_type const pos =
                        (is_space && lpos + 1 <= bidi_end &&
                         !row->par()->isLineSeparator(lpos + 1) &&
                         !row->par()->isNewline(lpos + 1))
@@ -345,8 +345,7 @@ void LyXText::computeBidiTables(Buffer const * buf, Row * row) const
                bidi_levels[lpos - bidi_start] = new_level;
 
                while (level > new_level2) {
-                       Paragraph::size_type old_lpos =
-                               stack[--level];
+                       pos_type old_lpos = stack[--level];
                        int delta = lpos - old_lpos - 1;
                        if (level % 2)
                                delta = -delta;
@@ -358,15 +357,15 @@ void LyXText::computeBidiTables(Buffer const * buf, Row * row) const
        }
 
        while (level > 0) {
-               Paragraph::size_type const old_lpos = stack[--level];
+               pos_type const old_lpos = stack[--level];
                int delta = bidi_end - old_lpos;
                if (level % 2)
                        delta = -delta;
                log2vis_list[old_lpos - bidi_start] += delta;
        }
 
-       Paragraph::size_type vpos = bidi_start - 1;
-       for (Paragraph::size_type lpos = bidi_start;
+       pos_type vpos = bidi_start - 1;
+       for (pos_type lpos = bidi_start;
             lpos <= bidi_end; ++lpos) {
                vpos += log2vis_list[lpos - bidi_start];
                vis2log_list[vpos - bidi_start] = lpos;
@@ -377,7 +376,7 @@ void LyXText::computeBidiTables(Buffer const * buf, Row * row) const
 
 // This method requires a previous call to ComputeBidiTables()
 bool LyXText::isBoundary(Buffer const * buf, Paragraph * par,
-                        Paragraph::size_type pos) const
+                        pos_type pos) const
 {
        if (!lyxrc.rtl_support || pos == 0)
                return false;
@@ -397,8 +396,7 @@ bool LyXText::isBoundary(Buffer const * buf, Paragraph * par,
 
 
 bool LyXText::isBoundary(Buffer const * buf, Paragraph * par,
-                        Paragraph::size_type pos,
-                        LyXFont const & font) const
+                        pos_type pos, LyXFont const & font) const
 {
        if (!lyxrc.rtl_support)
                return false;    // This is just for speedup
@@ -412,12 +410,11 @@ bool LyXText::isBoundary(Buffer const * buf, Paragraph * par,
 
 
 void LyXText::draw(BufferView * bview, Row const * row,
-                   Paragraph::size_type & vpos,
-                   int offset, float & x, bool cleared)
+                   pos_type & vpos, int offset, float & x, bool cleared)
 {
        Painter & pain = bview->painter();
        
-       Paragraph::size_type pos = vis2log(vpos);
+       pos_type pos = vis2log(vpos);
        char c = row->par()->getChar(pos);
        float tmpx = x;
 
@@ -527,13 +524,13 @@ void LyXText::draw(BufferView * bview, Row const * row,
        textstring = c;
        ++vpos;
 
-       Paragraph::size_type const last = rowLastPrintable(row);
+       pos_type const last = rowLastPrintable(row);
 
        if (font.language()->lang() == "hebrew") {
                if (Encodings::IsComposeChar_hebrew(c)) {
                        int const width = lyxfont::width(c, font2);
                        int dx = 0;
-                       for (Paragraph::size_type i = pos-1; i >= 0; --i) {
+                       for (pos_type i = pos-1; i >= 0; --i) {
                                c = row->par()->getChar(i);
                                if (!Encodings::IsComposeChar_hebrew(c)) {
                                        if (IsPrintableNonspace(c)) {
@@ -572,7 +569,7 @@ void LyXText::draw(BufferView * bview, Row const * row,
                        textstring = c;
                        int const width = lyxfont::width(c, font2);
                        int dx = 0;
-                       for (Paragraph::size_type i = pos-1; i >= 0; --i) {
+                       for (pos_type i = pos-1; i >= 0; --i) {
                                c = row->par()->getChar(i);
                                if (!Encodings::IsComposeChar_arabic(c)) {
                                        if (IsPrintableNonspace(c)) {
@@ -881,7 +878,7 @@ int LyXText::labelEnd(BufferView * bview, Row const * row) const
 
 
 // get the next breakpoint in a given paragraph
-Paragraph::size_type
+LyXText::pos_type
 LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
 {
        Paragraph * par = row->par();
@@ -889,20 +886,20 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
        if (width < 0)
                return par->size();
 
-       Paragraph::size_type const pos = row->pos();
+       pos_type const pos = row->pos();
 
 
        // position of the last possible breakpoint 
        // -1 isn't a suitable value, but a flag
-       Paragraph::size_type last_separator = -1;
+       pos_type last_separator = -1;
        width -= rightMargin(bview->buffer(), row);
        
-       Paragraph::size_type const main_body =
+       pos_type const main_body =
                beginningOfMainBody(bview->buffer(), par);
        LyXLayout const & layout =
                textclasslist.Style(bview->buffer()->params.textclass,
                                    par->getLayout());
-       Paragraph::size_type i = pos;
+       pos_type i = pos;
 
        if (layout.margintype == MARGIN_RIGHT_ADDRESS_BOX) {
                /* special code for right address boxes, only newlines count */
@@ -919,7 +916,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
                }
        } else {
                // Last position is an invariant
-               Paragraph::size_type const last = 
+               pos_type const last = 
                        par->size();
                // this is the usual handling
                int x = leftMargin(bview, row);
@@ -1002,7 +999,7 @@ int LyXText::fill(BufferView * bview, Row * row, int paper_width) const
 
        int w;
        // get the pure distance
-       Paragraph::size_type const last = rowLastPrintable(row);
+       pos_type const last = rowLastPrintable(row);
        
        // special handling of the right address boxes
        if (textclasslist.Style(bview->buffer()->params.textclass,
@@ -1018,9 +1015,9 @@ int LyXText::fill(BufferView * bview, Row * row, int paper_width) const
        
        LyXLayout const & layout = textclasslist.Style(bview->buffer()->params.textclass,
                                                       row->par()->getLayout());
-       Paragraph::size_type const main_body = 
+       pos_type const main_body = 
                beginningOfMainBody(bview->buffer(), row->par());
-       Paragraph::size_type i = row->pos();
+       pos_type i = row->pos();
 
        while (i <= last) {
                if (main_body > 0 && i == main_body) {
@@ -1058,7 +1055,7 @@ int LyXText::fill(BufferView * bview, Row * row, int paper_width) const
 // returns the minimum space a manual label needs on the screen in pixel
 int LyXText::labelFill(BufferView * bview, Row const * row) const
 {
-       Paragraph::size_type last = beginningOfMainBody(bview->buffer(), row->par()) - 1;
+       pos_type last = beginningOfMainBody(bview->buffer(), row->par()) - 1;
        // -1 because a label ends either with a space that is in the label, 
        // or with the beginning of a footnote that is outside the label.
 
@@ -1074,7 +1071,7 @@ int LyXText::labelFill(BufferView * bview, Row const * row) const
                --last;
        
        int w = 0;
-       Paragraph::size_type i = row->pos();
+       pos_type i = row->pos();
        while (i <= last) {
                w += singleWidth(bview, row->par(), i);
                ++i;
@@ -1095,9 +1092,8 @@ int LyXText::labelFill(BufferView * bview, Row const * row) const
 // on the very last column doesnt count
 int LyXText::numberOfSeparators(Buffer const * buf, Row const * row) const
 {
-       Paragraph::size_type const last = rowLast(row);
-       Paragraph::size_type p =
-               max(row->pos(), beginningOfMainBody(buf, row->par()));
+       pos_type const last = rowLast(row);
+       pos_type p = max(row->pos(), beginningOfMainBody(buf, row->par()));
        int n = 0;
        for (; p < last; ++p) {
                if (row->par()->isSeparator(p)) {
@@ -1113,8 +1109,8 @@ int LyXText::numberOfSeparators(Buffer const * buf, Row const * row) const
 // ignored. This is *MUCH* more usefull than not to ignore!
 int LyXText::numberOfHfills(Buffer const * buf, Row const * row) const
 {
-       Paragraph::size_type const last = rowLast(row);
-       Paragraph::size_type first = row->pos();
+       pos_type const last = rowLast(row);
+       pos_type first = row->pos();
        if (first) { /* hfill *DO* count at the beginning 
                      * of paragraphs! */
                while(first <= last && row->par()->isHfill(first))
@@ -1123,7 +1119,7 @@ int LyXText::numberOfHfills(Buffer const * buf, Row const * row) const
 
        first = max(first, beginningOfMainBody(buf, row->par()));
        int n = 0;
-       for (Paragraph::size_type p = first; p <= last; ++p) {
+       for (pos_type p = first; p <= last; ++p) {
                // last, because the end is ignored!
                if (row->par()->isHfill(p)) {
                        ++n;
@@ -1136,8 +1132,8 @@ int LyXText::numberOfHfills(Buffer const * buf, Row const * row) const
 // like NumberOfHfills, but only those in the manual label!
 int LyXText::numberOfLabelHfills(Buffer const * buf, Row const * row) const
 {
-       Paragraph::size_type last = rowLast(row);
-       Paragraph::size_type first = row->pos();
+       pos_type last = rowLast(row);
+       pos_type first = row->pos();
        if (first) { /* hfill *DO* count at the beginning 
                      * of paragraphs! */
                while(first < last && row->par()->isHfill(first))
@@ -1146,8 +1142,8 @@ int LyXText::numberOfLabelHfills(Buffer const * buf, Row const * row) const
 
        last = min(last, beginningOfMainBody(buf, row->par()));
        int n = 0;
-       for (Paragraph::size_type p = first;
-            p < last; ++p) {  // last, because the end is ignored!
+       for (pos_type p = first; p < last; ++p) {
+               // last, because the end is ignored!
                if (row->par()->isHfill(p)) {
                        ++n;
                }
@@ -1159,7 +1155,7 @@ int LyXText::numberOfLabelHfills(Buffer const * buf, Row const * row) const
 // returns true, if a expansion is needed.
 // Rules are given by LaTeX
 bool LyXText::hfillExpansion(Buffer const * buf, Row const * row_ptr,
-                             Paragraph::size_type pos) const
+                             pos_type pos) const
 {
        // by the way, is it a hfill?
        if (!row_ptr->par()->isHfill(pos))
@@ -1184,7 +1180,7 @@ bool LyXText::hfillExpansion(Buffer const * buf, Row const * row_ptr,
        // if there is anything between the first char of the row and
        // the sepcified position that is not a newline and not a hfill,
        // the hfill will count, otherwise not
-       Paragraph::size_type i = row_ptr->pos();
+       pos_type i = row_ptr->pos();
        while (i < pos && (row_ptr->par()->isNewline(i)
                           || row_ptr->par()->isHfill(i)))
                ++i;
@@ -1250,12 +1246,12 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
        int maxdesc = int(lyxfont::maxDescent(font) *
                          layout.spacing.getValue() *
                          spacing_val);
-       Paragraph::size_type const pos_end = rowLast(row_ptr);
+       pos_type const pos_end = rowLast(row_ptr);
        int labeladdon = 0;
        int maxwidth = 0;
 
        // Check if any insets are larger
-       for (Paragraph::size_type pos = row_ptr->pos(); pos <= pos_end; ++pos) {
+       for (pos_type pos = row_ptr->pos(); pos <= pos_end; ++pos) {
                if (row_ptr->par()->isInset(pos)) {
                        tmpfont = getFont(bview->buffer(), row_ptr->par(), pos);
                        tmpinset = row_ptr->par()->getInset(pos);
@@ -1447,7 +1443,7 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
                        maxdesc += 2 * lyxfont::ascent('x',
                                                       getFont(bview->buffer(),
                                                               par,
-                                                              max(Paragraph::size_type(0), par->size() - 1)));
+                                                              max(pos_type(0), par->size() - 1)));
          
                // and now the pagebreaks
                if (firstpar->params().pagebreakBottom())
@@ -1525,10 +1521,10 @@ 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)
-   Paragraph::size_type const lastposition = row->par()->size();
+   pos_type const lastposition = row->par()->size();
    do {
       // Get the next breakpoint
-      Paragraph::size_type z = nextBreakPoint(bview, row, workWidth(bview));
+      pos_type z = nextBreakPoint(bview, row, workWidth(bview));
       
       Row * tmprow = row;
 
@@ -1559,7 +1555,7 @@ void LyXText::breakAgain(BufferView * bview, Row * row) const
    
        do  {
                // get the next breakpoint
-               Paragraph::size_type z = nextBreakPoint(bview, row, workWidth(bview));
+               pos_type z = nextBreakPoint(bview, row, workWidth(bview));
                Row * tmprow = row;
 
                if (z < row->par()->size()) {
@@ -1603,7 +1599,7 @@ void LyXText::breakAgain(BufferView * bview, Row * row) const
 void LyXText::breakAgainOneRow(BufferView * bview, Row * row)
 {
        // get the next breakpoint
-       Paragraph::size_type z = nextBreakPoint(bview, row, workWidth(bview));
+       pos_type z = nextBreakPoint(bview, row, workWidth(bview));
        Row * tmprow = row;
 
        if (z < row->par()->size()) {
@@ -1820,7 +1816,7 @@ void LyXText::insertChar(BufferView * bview, char c)
                                     * current font */
 
        // Get the font that is used to calculate the baselineskip
-       Paragraph::size_type const lastpos = cursor.par()->size();
+       pos_type const lastpos = cursor.par()->size();
        LyXFont rawparfont =
                cursor.par()->getFontSettings(bview->buffer()->params,
                                              lastpos - 1);
@@ -1890,7 +1886,7 @@ void LyXText::insertChar(BufferView * bview, char c)
             || cursor.par()->isNewline(cursor.pos())
             || cursor.row()->fill() == -1)
            && row->previous() && row->previous()->par() == row->par()) {
-               Paragraph::size_type z = nextBreakPoint(bview,
+               pos_type z = nextBreakPoint(bview,
                                                           row->previous(),
                                                           workWidth(bview));
                if (z >= row->pos()) {
@@ -2102,9 +2098,9 @@ void LyXText::prepareToPrint(BufferView * bview,
 
        computeBidiTables(bview->buffer(), row);
        if (is_rtl) {
-               Paragraph::size_type main_body = 
+               pos_type main_body = 
                        beginningOfMainBody(bview->buffer(), row->par());
-               Paragraph::size_type last = rowLast(row);
+               pos_type last = rowLast(row);
 
                if (main_body > 0 &&
                    (main_body-1 > last || 
@@ -2365,7 +2361,7 @@ string const LyXText::selectNextWordToSpellcheck(BufferView * bview,
        // Finally, we copy the word to a string and return it
        string str;
        if (selection.cursor.pos() < cursor.pos()) {
-               Paragraph::size_type i;
+               pos_type i;
                for (i = selection.cursor.pos(); i < cursor.pos(); ++i) {
                        if (!cursor.par()->isInset(i))
                                str += cursor.par()->getChar(i);
@@ -2501,7 +2497,7 @@ void LyXText::changeRegionCase(BufferView * bview,
        setUndo(bview, Undo::FINISH,
                from.par(), to.par()->next());
 
-       Paragraph::size_type pos = from.pos();
+       pos_type pos = from.pos();
        Paragraph * par = from.par();
 
        while (par && (pos != to.pos() || par != to.par())) {
@@ -2544,7 +2540,7 @@ void LyXText::transposeChars(BufferView & bview)
        setUndo(&bview, Undo::FINISH,
                tmppar, tmppar->next()); 
 
-       Paragraph::size_type tmppos = cursor.pos();
+       pos_type tmppos = cursor.pos();
 
        // First decide if it is possible to transpose at all
 
@@ -2609,7 +2605,7 @@ void LyXText::Delete(BufferView * bview)
 void LyXText::backspace(BufferView * bview)
 {
        // Get the font that is used to calculate the baselineskip
-       Paragraph::size_type lastpos = cursor.par()->size();
+       pos_type lastpos = cursor.par()->size();
        LyXFont rawparfont =
                cursor.par()->getFontSettings(bview->buffer()->params,
                                              lastpos - 1);
@@ -2747,7 +2743,7 @@ void LyXText::backspace(BufferView * bview)
                
                Row * row = cursor.row();
                int y = cursor.y() - row->baseline();
-               Paragraph::size_type z;
+               pos_type z;
                /* remember that a space at the end of a row doesnt count
                 * when calculating the fill */ 
                if (cursor.pos() < rowLast(row) ||
@@ -2930,7 +2926,7 @@ bool LyXText::paintRowBackground(DrawRowParams & p)
        Inset * inset = 0;
        LyXFont font(LyXFont::ALL_SANE);
 
-       Paragraph::size_type const last = rowLastPrintable(p.row);
+       pos_type const last = rowLastPrintable(p.row);
 
        if (!p.bv->screen()->forceClear() && last == p.row->pos()
                && p.row->par()->isInset(p.row->pos())) {
@@ -3043,11 +3039,11 @@ void LyXText::paintRowSelection(DrawRowParams & p)
  
        Buffer const * buffer = p.bv->buffer();
        Paragraph * par = row->par();
-       Paragraph::size_type main_body = beginningOfMainBody(buffer, par);
-       Paragraph::size_type const last = rowLastPrintable(row);
+       pos_type main_body = beginningOfMainBody(buffer, par);
+       pos_type const last = rowLastPrintable(row);
  
-       for (Paragraph::size_type vpos = row->pos(); vpos <= last; ++vpos)  {
-               Paragraph::size_type pos = vis2log(vpos);
+       for (pos_type vpos = row->pos(); vpos <= last; ++vpos)  {
+               pos_type pos = vis2log(vpos);
                float const old_tmpx = tmpx;
                if (main_body > 0 && pos == main_body - 1) {
                        LyXLayout const & layout = textclasslist.Style(buffer->params.textclass,
@@ -3391,7 +3387,7 @@ void LyXText::paintLastRow(DrawRowParams & p)
                LyXFont font(LyXFont::ALL_SANE);
                int const asc = lyxfont::ascent('x',
                        getFont(buffer, par,
-                       max(Paragraph::size_type(0), par->size() - 1)));
+                       max(pos_type(0), par->size() - 1)));
  
                y_bottom -= asc;
  
@@ -3404,7 +3400,7 @@ void LyXText::paintLastRow(DrawRowParams & p)
                y_bottom -= asc;
        }
 
-       Paragraph::size_type const last = rowLastPrintable(p.row);
+       pos_type const last = rowLastPrintable(p.row);
        bool const is_rtl = p.row->par()->isRightToLeftPar(p.bv->buffer()->params);
        int const endlabel = par->getEndLabel(buffer->params);
  
@@ -3454,8 +3450,8 @@ void LyXText::paintRowText(DrawRowParams & p)
        Paragraph * par = p.row->par();
        Buffer const * buffer = p.bv->buffer(); 
  
-       Paragraph::size_type const last = rowLastPrintable(p.row);
-       Paragraph::size_type main_body = 
+       pos_type const last = rowLastPrintable(p.row);
+       pos_type main_body = 
                beginningOfMainBody(buffer, par);
        if (main_body > 0 && 
                (main_body - 1 > last || 
@@ -3466,9 +3462,9 @@ void LyXText::paintRowText(DrawRowParams & p)
        LyXLayout const & layout =
                textclasslist.Style(buffer->params.textclass, par->getLayout());
 
-       Paragraph::size_type vpos = p.row->pos();
+       pos_type vpos = p.row->pos();
        while (vpos <= last) {
-               Paragraph::size_type pos = vis2log(vpos);
+               pos_type pos = vis2log(vpos);
                if (main_body > 0 && pos == main_body - 1) {
                        int const lwidth = lyxfont::width(layout.labelsep,
                                getLabelFont(buffer, par));
@@ -3585,7 +3581,7 @@ int LyXText::defaultHeight() const
    
 /* returns the column near the specified x-coordinate of the row 
 * x is set to the real beginning of this column  */ 
-Paragraph::size_type
+LyXText::pos_type
 LyXText::getColumnNearX(BufferView * bview, Row * row, int & x,
                        bool & boundary) const
 {
@@ -3597,16 +3593,15 @@ LyXText::getColumnNearX(BufferView * bview, Row * row, int & x,
        prepareToPrint(bview, row, tmpx, fill_separator,
                       fill_hfill, fill_label_hfill);
 
-       Paragraph::size_type vc = row->pos();
-       Paragraph::size_type last = rowLastPrintable(row);
-       Paragraph::size_type c = 0;
+       pos_type vc = row->pos();
+       pos_type last = rowLastPrintable(row);
+       pos_type c = 0;
        LyXLayout const & layout =
                textclasslist.Style(bview->buffer()->params.textclass,
                                    row->par()->getLayout());
        bool left_side = false;
 
-       Paragraph::size_type
-               main_body = beginningOfMainBody(bview->buffer(), row->par());
+       pos_type main_body = beginningOfMainBody(bview->buffer(), row->par());
        float last_tmpx = tmpx;
        
        if (main_body > 0 &&
@@ -3693,8 +3688,7 @@ LyXText::getColumnNearX(BufferView * bview, Row * row, int & x,
  
 
 // returns pointer to a specified row
-Row * LyXText::getRow(Paragraph * par,
-                      Paragraph::size_type pos, int & y) const
+Row * LyXText::getRow(Paragraph * par, pos_type pos, int & y) const
 {
        if (!firstrow)
                return 0;
@@ -3719,3 +3713,25 @@ Row * LyXText::getRow(Paragraph * par,
        
        return tmprow;
 }
+
+
+Row * LyXText::getRowNearY(int & y) const
+{
+       // If possible we should optimize this method. (Lgb)
+       Row * tmprow = firstrow;
+       int tmpy = 0;
+       
+       while (tmprow->next() && tmpy + tmprow->height() <= y) {
+               tmpy += tmprow->height();
+               tmprow = tmprow->next();
+       }
+       
+       y = tmpy;   // return the real y
+       return tmprow;
+}
+
+
+int LyXText::getDepth() const
+{
+       return cursor.par()->getDepth();
+}
index 2b58afa397163f2c9c5d2ecd5e6fed9259671fa7..5d95dc2172ee4320f0b9be0a50ba26f6bd7eff79 100644 (file)
@@ -38,6 +38,7 @@
 #include "font.h"
 #include "debug.h"
 #include "lyxrc.h"
+#include "lyxrow.h"
 #include "FloatList.h"
 #include "language.h"
 #include "ParagraphParameters.h"
@@ -155,7 +156,7 @@ LyXFont const realizeFont(LyXFont const & font,
 // If position is -1, we get the layout font of the paragraph.
 // If position is -2, we get the font of the manual label of the paragraph.
 LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
-                               Paragraph::size_type pos) const
+                               pos_type pos) const
 {
        lyx::Assert(pos >= 0);
        
@@ -239,7 +240,7 @@ LyXFont const LyXText::getLabelFont(Buffer const * buf, Paragraph * par) const
 
 
 void LyXText::setCharFont(BufferView * bv, Paragraph * par,
-                          Paragraph::size_type pos, LyXFont const & fnt,
+                          pos_type pos, LyXFont const & fnt,
                           bool toggleall)
 {
        Buffer const * buf = bv->buffer();
@@ -301,7 +302,7 @@ void LyXText::setCharFont(BufferView * bv, Paragraph * par,
 
 
 void LyXText::setCharFont(Buffer const * buf, Paragraph * par,
-                          Paragraph::size_type pos, LyXFont const & fnt)
+                          pos_type pos, LyXFont const & fnt)
 {
        LyXFont font(fnt);
 
@@ -353,7 +354,7 @@ void LyXText::setCharFont(Buffer const * buf, Paragraph * par,
 // inserts a new row behind the specified row, increments
 // the touched counters
 void LyXText::insertRow(Row * row, Paragraph * par,
-                        Paragraph::size_type pos) const
+                        pos_type pos) const
 {
        Row * tmprow = new Row;
        if (!row) {
@@ -481,7 +482,7 @@ void LyXText::makeFontEntriesLayoutSpecific(Buffer const * buf,
                textclasslist.Style(buf->params.textclass, par->getLayout());
 
        LyXFont layoutfont;
-       for (Paragraph::size_type pos = 0; pos < par->size(); ++pos) {
+       for (pos_type pos = 0; pos < par->size(); ++pos) {
                if (pos < beginningOfMainBody(buf, par))
                        layoutfont = layout.labelfont;
                else
@@ -497,7 +498,7 @@ void LyXText::makeFontEntriesLayoutSpecific(Buffer const * buf,
 Paragraph * LyXText::setLayout(BufferView * bview,
                               LyXCursor & cur, LyXCursor & sstart_cur,
                               LyXCursor & send_cur,
-                              LyXTextClass::size_type layout)
+                              layout_type layout)
 {
        Paragraph * endpar = send_cur.par()->next();
        Paragraph * undoendpar = endpar;
@@ -559,7 +560,7 @@ Paragraph * LyXText::setLayout(BufferView * bview,
 
 
 // set layout over selection and make a total rebreak of those paragraphs
-void LyXText::setLayout(BufferView * bview, LyXTextClass::size_type layout)
+void LyXText::setLayout(BufferView * bview, layout_type layout)
 {
        LyXCursor tmpcursor = cursor;  /* store the current cursor  */
 
@@ -1162,7 +1163,7 @@ string LyXText::getStringToIndex(BufferView * bview)
 }
 
 
-Paragraph::size_type LyXText::beginningOfMainBody(Buffer const * buf,
+LyXText::pos_type LyXText::beginningOfMainBody(Buffer const * buf,
                             Paragraph const * par) const
 {
        if (textclasslist.Style(buf->params.textclass,
@@ -1878,7 +1879,7 @@ void LyXText::replaceSelectionWithString(BufferView * bview,
        }
 
        // Get font setting before we cut
-       Paragraph::size_type pos = selection.end.pos();
+       pos_type pos = selection.end.pos();
        LyXFont const font = selection.start.par()
                ->getFontSettings(bview->buffer()->params,
                                  selection.start.pos());
@@ -1900,7 +1901,7 @@ void LyXText::replaceSelectionWithString(BufferView * bview,
 void LyXText::insertStringAsLines(BufferView * bview, string const & str)
 {
        Paragraph * par = cursor.par();
-       Paragraph::size_type pos = cursor.pos();
+       pos_type pos = cursor.pos();
        Paragraph * endpar = cursor.par()->next();
        
        setCursorParUndo(bview);
@@ -1976,12 +1977,12 @@ bool LyXText::gotoNextInset(BufferView * bview,
 
 
 void LyXText::checkParagraph(BufferView * bview, Paragraph * par,
-                             Paragraph::size_type pos)
+                             pos_type pos)
 {
        LyXCursor tmpcursor;                    
 
        int y = 0;
-       Paragraph::size_type z;
+       pos_type z;
        Row * row = getRow(par, pos, y);
        
        // is there a break one row above
@@ -2006,7 +2007,7 @@ void LyXText::checkParagraph(BufferView * bview, Paragraph * par,
        }
 
        int const tmpheight = row->height();
-       Paragraph::size_type const tmplast = rowLast(row);
+       pos_type const tmplast = rowLast(row);
        refresh_y = y;
        refresh_row = row;
        
@@ -2084,7 +2085,7 @@ bool LyXText::updateInset(BufferView * bview, Inset * inset)
 
 
 void LyXText::setCursor(BufferView * bview, Paragraph * par,
-                        Paragraph::size_type pos, 
+                        pos_type pos, 
                         bool setfont, bool boundary) const
 {
        LyXCursor old_cursor = cursor;
@@ -2094,7 +2095,7 @@ void LyXText::setCursor(BufferView * bview, Paragraph * par,
 
 
 void LyXText::setCursor(BufferView *bview, LyXCursor & cur, Paragraph * par,
-                       Paragraph::size_type pos, bool boundary) const
+                       pos_type pos, bool boundary) const
 {
        cur.par(par);
        cur.pos(pos);
@@ -2115,8 +2116,8 @@ void LyXText::setCursor(BufferView *bview, LyXCursor & cur, Paragraph * par,
        float fill_label_hfill;
        prepareToPrint(bview, row, x, fill_separator, fill_hfill,
                       fill_label_hfill);
-       Paragraph::size_type cursor_vpos = 0;
-       Paragraph::size_type last = rowLastPrintable(row);
+       pos_type cursor_vpos = 0;
+       pos_type last = rowLastPrintable(row);
 
        if (pos > last + 1)   // This shouldn't happen.
                pos = last + 1;
@@ -2138,14 +2139,14 @@ void LyXText::setCursor(BufferView *bview, LyXCursor & cur, Paragraph * par,
                cursor_vpos = (bidi_level(pos) % 2 == 0)
                        ? log2vis(pos) : log2vis(pos) + 1;
        
-       Paragraph::size_type main_body =
+       pos_type main_body =
                beginningOfMainBody(bview->buffer(), row->par());
        if ((main_body > 0) &&
            ((main_body-1 > last) || 
             !row->par()->isLineSeparator(main_body-1)))
                main_body = 0;
        
-       for (Paragraph::size_type vpos = row->pos();
+       for (pos_type vpos = row->pos();
             vpos < cursor_vpos; ++vpos) {
                pos = vis2log(vpos);
                if (main_body > 0 && pos == main_body - 1) {
@@ -2173,13 +2174,13 @@ void LyXText::setCursor(BufferView *bview, LyXCursor & cur, Paragraph * par,
        }
        
        cur.x(int(x));
-       cur.x_fix(cur.x());
+       cur.x_fix(cur.x());
        cur.row(row);
 }
 
 
 void LyXText::setCursorIntern(BufferView * bview, Paragraph * par,
-                             Paragraph::size_type pos,
+                             pos_type pos,
                              bool setfont, bool boundary) const
 {
        InsetText * it = static_cast<InsetText *>(par->inInset());
@@ -2213,7 +2214,7 @@ void LyXText::setCursorIntern(BufferView * bview, Paragraph * par,
 
 void LyXText::setCurrentFont(BufferView * bview) const
 {
-       Paragraph::size_type pos = cursor.pos();
+       pos_type pos = cursor.pos();
        if (cursor.boundary() && pos > 0)
                --pos;
 
@@ -2265,9 +2266,7 @@ void LyXText::setCursorFromCoordinates(BufferView * bview, LyXCursor & cur,
    
        Row * row = getRowNearY(y);
        bool bound = false;
-       Paragraph::size_type const column = getColumnNearX(bview, row, x,
-                                                          bound);
-   
+       pos_type const column = getColumnNearX(bview, row, x, bound);
        cur.par(row->par());
        cur.pos(row->pos() + column);
        cur.x(x);