From: André Pönitz Date: Tue, 27 Nov 2001 10:34:16 +0000 (+0000) Subject: whitespace changes; X-Git-Tag: 1.6.10~20287 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=10f096880fec5afc402fc0910ff44220de0398c9;p=lyx.git whitespace changes; change *::pos_type into lyx::pos_type git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3087 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 2a07342ec0..b7d44616bd 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -78,6 +78,7 @@ using std::endl; using std::make_pair; using std::min; using SigC::slot; +using lyx::pos_type; /* the selection possible is needed, that only motion events are * used, where the bottom press event was on the drawing area too */ diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index 5f43f3334c..320c7d18a7 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -23,8 +23,6 @@ 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); @@ -178,11 +176,11 @@ private: /// Cursor paragraph Id int par_id; /// Cursor position - pos_type par_pos; + lyx::pos_type par_pos; /// Position() : par_id(0), par_pos(0) {} /// - Position(string const & f, int id, pos_type pos) + Position(string const & f, int id, lyx::pos_type pos) : filename(f), par_id(id), par_pos(pos) {} }; /// diff --git a/src/ChangeLog b/src/ChangeLog index e8c5828ff6..11179e0840 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ + +2001-11-28 André Pönitz + + * paragraph.C: whitespace changes + * files form the 26th: change *::pos_type into lyx::pos_type + + 2001-11-27 Dekel Tsur * buffer.C (parseSingleLyXformat2Token): Set the language to the diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 1d99c70338..058ee2d6a4 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -23,6 +23,7 @@ #endif using std::pair; +using lyx::pos_type; extern BufferView * current_view; @@ -88,7 +89,7 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar, // only within one paragraph if (realcut) buf = new Paragraph; - Paragraph::pos_type i = start; + pos_type i = start; if (end > startpar->size()) end = startpar->size(); for (; i < end; ++i) { @@ -151,11 +152,10 @@ bool CutAndPaste::copySelection(Paragraph * startpar, Paragraph * endpar, textclass = tc; - if (!endpar || - startpar == endpar) { + if (!endpar || startpar == endpar) { // only within one paragraph buf = new Paragraph; - Paragraph::pos_type i = start; + 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::pos_type tmpi2 = start; + pos_type tmpi2 = start; for (; tmpi2; --tmpi2) buf->erase(0); diff --git a/src/buffer.C b/src/buffer.C index ac4a50196a..d58ef540ab 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -123,6 +123,8 @@ using std::set; using std::stack; using std::list; +using lyx::pos_type; + // all these externs should eventually be removed. extern BufferList bufferlist; @@ -1338,7 +1340,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par, } // needed to insert the selection -void Buffer::insertStringAsLines(Paragraph *& par, Paragraph::pos_type & pos, +void Buffer::insertStringAsLines(Paragraph *& par, pos_type & pos, LyXFont const & fn,string const & str) const { LyXLayout const & layout = textclasslist.Style(params.textclass, @@ -1372,9 +1374,8 @@ void Buffer::insertStringAsLines(Paragraph *& par, Paragraph::pos_type & pos, ++pos; space_inserted = true; } else { - const Paragraph::pos_type nb = 8 - pos % 8; - for (Paragraph::pos_type a = 0; - a < nb ; ++a) { + const pos_type nb = 8 - pos % 8; + for (pos_type a = 0; a < nb ; ++a) { par->insertChar(pos, ' ', font); ++pos; } @@ -1812,7 +1813,7 @@ string const Buffer::asciiParagraph(Paragraph const * par, lyxerr << "Should this ever happen?" << endl; } - for (Paragraph::pos_type i = 0; i < par->size(); ++i) { + for (pos_type i = 0; i < par->size(); ++i) { if (!i && !noparbreak) { if (linelen > 0) buffer << "\n\n"; @@ -2795,7 +2796,7 @@ void Buffer::simpleLinuxDocOnePar(ostream & os, stack tag_state; // parsing main loop - for (Paragraph::pos_type i = 0; i < par->size(); ++i) { + for (pos_type i = 0; i < par->size(); ++i) { PAR_TAG tag_close = NONE; list < PAR_TAG > tag_open; @@ -3288,8 +3289,7 @@ void Buffer::simpleDocBookOnePar(ostream & os, // os << string(depth,' '); // parsing main loop - for (Paragraph::pos_type i = 0; - i < par->size(); ++i) { + for (pos_type i = 0; i < par->size(); ++i) { LyXFont font = par->getFont(params, i); // handle tag @@ -3698,8 +3698,7 @@ bool Buffer::isMultiLingual() } -Buffer::inset_iterator::inset_iterator(Paragraph * paragraph, - Paragraph::pos_type pos) +Buffer::inset_iterator::inset_iterator(Paragraph * paragraph, pos_type pos) : par(paragraph) { it = par->InsetIterator(pos); diff --git a/src/buffer.h b/src/buffer.h index 5f3e8d9d5b..9d097efc5a 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -123,7 +123,7 @@ public: Paragraph::depth_type & depth, LyXFont &); /// - void insertStringAsLines(Paragraph *&, Paragraph::pos_type &, + void insertStringAsLines(Paragraph *&, lyx::pos_type &, LyXFont const &, string const &) const; #ifndef NO_COMPABILITY /// @@ -371,8 +371,7 @@ public: setParagraph(); } /// - inset_iterator(Paragraph * paragraph, - Paragraph::pos_type pos); + inset_iterator(Paragraph * paragraph, lyx::pos_type pos); /// inset_iterator & operator++() { // prefix ++ if (par) { @@ -402,7 +401,7 @@ public: /// Paragraph * getPar() { return par; } /// - Paragraph::pos_type getPos() const { return it.getPos(); } + lyx::pos_type getPos() const { return it.getPos(); } /// friend bool operator==(inset_iterator const & iter1, diff --git a/src/insets/insetert.C b/src/insets/insetert.C index ba42a7a12d..ce143c7ca4 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -29,6 +29,8 @@ #include "debug.h" using std::ostream; +using lyx::pos_type; + void InsetERT::init() { @@ -38,7 +40,6 @@ void InsetERT::init() labelfont.decSize(); labelfont.setColor(LColor::latex); setInsetName("ERT"); - } @@ -82,7 +83,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::pos_type pos = 0; + pos_type pos = 0; for (; cit != end; ++cit) { inset.paragraph()->insertChar(pos++, *cit, font); } @@ -150,8 +151,8 @@ void InsetERT::read(Buffer const * buf, LyXLex & lex) font.setColor(LColor::latex); Paragraph * par = inset.paragraph(); while (par) { - Paragraph::pos_type siz = par->size(); - for (Paragraph::pos_type i = 0; i < siz; ++i) { + pos_type siz = par->size(); + for (pos_type i = 0; i < siz; ++i) { par->setFont(i, font); } par = par->next(); @@ -193,8 +194,8 @@ void InsetERT::write(Buffer const * buf, ostream & os) const Paragraph * par = inset.paragraph(); while (par) { os << "\n\\layout " << layout << "\n"; - Paragraph::pos_type siz = par->size(); - for (Paragraph::pos_type i = 0; i < siz; ++i) { + pos_type siz = par->size(); + for (pos_type i = 0; i < siz; ++i) { Paragraph::value_type c = par->getChar(i); switch (c) { case Paragraph::META_INSET: @@ -311,8 +312,8 @@ int InsetERT::latex(Buffer const *, std::ostream & os, bool /*fragile*/, Paragraph * par = inset.paragraph(); int lines = 0; while (par) { - Paragraph::pos_type siz = par->size(); - for (Paragraph::pos_type i = 0; i < siz; ++i) { + pos_type siz = par->size(); + for (pos_type i = 0; i < siz; ++i) { Paragraph::value_type c = par->getChar(i); switch (c) { case Paragraph::META_NEWLINE: @@ -347,8 +348,8 @@ int InsetERT::linuxdoc(Buffer const *, std::ostream & os) const Paragraph * par = inset.paragraph(); int lines = 0; while (par) { - Paragraph::pos_type siz = par->size(); - for (Paragraph::pos_type i = 0; i < siz; ++i) { + pos_type siz = par->size(); + for (pos_type i = 0; i < siz; ++i) { Paragraph::value_type c = par->getChar(i); switch (c) { case Paragraph::META_NEWLINE: @@ -376,8 +377,8 @@ int InsetERT::docbook(Buffer const *, std::ostream & os) const Paragraph * par = inset.paragraph(); int lines = 0; while (par) { - Paragraph::pos_type siz = par->size(); - for (Paragraph::pos_type i = 0; i < siz; ++i) { + pos_type siz = par->size(); + for (pos_type i = 0; i < siz; ++i) { Paragraph::value_type c = par->getChar(i); switch (c) { case Paragraph::META_NEWLINE: @@ -438,10 +439,9 @@ InsetERT::localDispatch(BufferView * bv, kb_action action, string const & arg) string const InsetERT::get_new_label() const { string la; - Paragraph::pos_type const max_length = 15; - - Paragraph::pos_type const p_siz = inset.paragraph()->size(); - Paragraph::pos_type const n = std::min(max_length, p_siz); + pos_type const max_length = 15; + pos_type const p_siz = inset.paragraph()->size(); + pos_type const n = std::min(max_length, p_siz); int i = 0; int j = 0; for(; i < n && j < p_siz; ++j) { diff --git a/src/insets/insetnote.C b/src/insets/insetnote.C index f07462f0f3..d4a1f7797e 100644 --- a/src/insets/insetnote.C +++ b/src/insets/insetnote.C @@ -28,6 +28,7 @@ using std::ostream; + void InsetNote::init() { LyXFont font(LyXFont::ALL_SANE); @@ -68,7 +69,6 @@ InsetNote::InsetNote(Buffer const * buf, string const & contents, init(); Paragraph * par = inset.paragraph(); - 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 @@ -76,6 +76,7 @@ InsetNote::InsetNote(Buffer const * buf, string const & contents, if (font.language()->RightToLeft()) font.setLanguage(default_language); + lyx::pos_type pos; buf->insertStringAsLines(par, pos, font, strip(contents, '\n')); } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 45b5163613..536601011b 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -61,6 +61,8 @@ using std::max; using std::make_pair; using std::vector; +using lyx::pos_type; + extern unsigned char getCurrentTextClass(Buffer *); extern bool math_insert_greek(BufferView *, char); extern int greek_kb_flag; @@ -2008,7 +2010,7 @@ int InsetText::cy(BufferView * bv) const } -Paragraph::pos_type InsetText::cpos(BufferView * bv) const +pos_type InsetText::cpos(BufferView * bv) const { return getLyXText(bv)->cursor.pos(); } @@ -2449,7 +2451,7 @@ bool InsetText::searchForward(BufferView * bv, string const & str, clear = true; } Paragraph * lpar = lt->cursor.par(); - Paragraph::pos_type pos = lt->cursor.pos(); + pos_type pos = lt->cursor.pos(); if (pos < lpar->size() - 1) ++pos; else { diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 2a35a2c063..e96360f2a9 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -308,7 +308,7 @@ private: /// int cy(BufferView *) const; /// - Paragraph::pos_type cpos(BufferView *) const; + lyx::pos_type cpos(BufferView *) const; /// Paragraph * cpar(BufferView *) const; /// @@ -347,7 +347,7 @@ private: /// Paragraph * inset_par; /// - Paragraph::pos_type inset_pos; + lyx::pos_type inset_pos; /// bool inset_boundary; /// @@ -379,9 +379,9 @@ private: Paragraph * lpar; Paragraph * selstartpar; Paragraph * selendpar; - Paragraph::pos_type pos; - Paragraph::pos_type selstartpos; - Paragraph::pos_type selendpos; + lyx::pos_type pos; + lyx::pos_type selstartpos; + lyx::pos_type selendpos; bool boundary; bool selstartboundary; bool selendboundary; diff --git a/src/lyxcursor.C b/src/lyxcursor.C index fc45d0a0b3..12afbd3df9 100644 --- a/src/lyxcursor.C +++ b/src/lyxcursor.C @@ -35,13 +35,13 @@ Paragraph * LyXCursor::par() const } -void LyXCursor::pos(pos_type p) +void LyXCursor::pos(lyx::pos_type p) { pos_ = p; } -LyXCursor::pos_type LyXCursor::pos() const +lyx::pos_type LyXCursor::pos() const { return pos_; } diff --git a/src/lyxcursor.h b/src/lyxcursor.h index 43cbc0980c..cc7cb9ef90 100644 --- a/src/lyxcursor.h +++ b/src/lyxcursor.h @@ -25,8 +25,6 @@ class Row; */ class LyXCursor { public: - /// position in a paragraph - typedef lyx::pos_type pos_type; /// LyXCursor(); /// @@ -34,9 +32,9 @@ public: /// Paragraph * par() const; /// - void pos(pos_type p); + void pos(lyx::pos_type p); /// - pos_type pos() const; + lyx::pos_type pos() const; /// void boundary(bool b); /// @@ -61,7 +59,7 @@ private: /// The paragraph the cursor is in. Paragraph * par_; /// The position inside the paragraph - pos_type pos_; + lyx::pos_type pos_; /// bool boundary_; /// diff --git a/src/lyxfind.C b/src/lyxfind.C index 1c52660cbe..93af1df390 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -14,6 +14,9 @@ #include "buffer.h" #include "gettext.h" +using lyx::pos_type; + + /// // locally used enum /// @@ -28,7 +31,7 @@ enum SearchResult { /// returns true if the specified string is at the specified position -bool IsStringInText(Paragraph * par, Paragraph::pos_type pos, +bool IsStringInText(Paragraph * par, pos_type pos, string const & str, bool const & = true, bool const & = false); @@ -140,7 +143,7 @@ bool LyXFind(BufferView * bv, else { text = bv->getLyXText(); Paragraph * par = text->cursor.par(); - Paragraph::pos_type pos = text->cursor.pos(); + pos_type pos = text->cursor.pos(); if (forward) { if (pos < par->size() - 1) ++pos; @@ -183,7 +186,7 @@ bool LyXFind(BufferView * bv, // returns true if the specified string is at the specified position -bool IsStringInText(Paragraph * par, Paragraph::pos_type pos, +bool IsStringInText(Paragraph * par, pos_type pos, string const & str, bool const & cs, bool const & mw) { @@ -191,7 +194,7 @@ bool IsStringInText(Paragraph * par, Paragraph::pos_type pos, return false; string::size_type size = str.length(); - Paragraph::pos_type i = 0; + pos_type i = 0; while (((pos + i) < par->size()) && (string::size_type(i) < size) && (cs ? (str[i] == par->getChar(pos + i)) @@ -204,7 +207,7 @@ bool IsStringInText(Paragraph * par, Paragraph::pos_type pos, if (!mw) return true; if ((pos <= 0 || !IsLetterCharOrDigit(par->getChar(pos - 1))) - && (pos + Paragraph::pos_type(size) >= par->size() + && (pos + pos_type(size) >= par->size() || !IsLetterCharOrDigit(par->getChar(pos + size)))) { return true; } @@ -219,7 +222,7 @@ SearchResult SearchForward(BufferView * bv, LyXText * text, string const & str, bool const & cs, bool const & mw) { Paragraph * par = text->cursor.par(); - Paragraph::pos_type pos = text->cursor.pos(); + pos_type pos = text->cursor.pos(); UpdatableInset * inset; while (par && !IsStringInText(par, pos, str, cs, mw)) { @@ -280,7 +283,7 @@ SearchResult SearchBackward(BufferView * bv, LyXText * text, bool const & cs, bool const & mw) { Paragraph * par = text->cursor.par(); - Paragraph::pos_type pos = text->cursor.pos(); + pos_type pos = text->cursor.pos(); do { if (pos > 0) diff --git a/src/lyxrow.C b/src/lyxrow.C index 21873a8ae0..d043dcfbf7 100644 --- a/src/lyxrow.C +++ b/src/lyxrow.C @@ -29,13 +29,13 @@ void Row::par(Paragraph * p) } -void Row::pos(pos_type p) +void Row::pos(lyx::pos_type p) { pos_ = p; } -Row::pos_type Row::pos() const +lyx::pos_type Row::pos() const { return pos_; } diff --git a/src/lyxrow.h b/src/lyxrow.h index b6e036bbf9..ac71a2d661 100644 --- a/src/lyxrow.h +++ b/src/lyxrow.h @@ -23,8 +23,6 @@ class Paragraph; /// class Row { public: - /// A position in the row - typedef lyx::pos_type pos_type; /// Row(); /// @@ -34,9 +32,9 @@ public: /// Paragraph * par() const; /// - void pos(pos_type p); + void pos(lyx::pos_type p); /// - pos_type pos() const; + lyx::pos_type pos() const; /// void fill(int f); /// @@ -69,7 +67,7 @@ private: /// Paragraph * par_; /// - pos_type pos_; + lyx::pos_type pos_; /** what is missing to a full row can be negative. Needed for hfills, flushright, block etc. */ mutable int fill_; diff --git a/src/lyxtext.h b/src/lyxtext.h index 243e6eab88..1701d75811 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -38,10 +38,6 @@ class VSpace; */ 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 { /// @@ -100,16 +96,17 @@ public: /// int getRealCursorX(BufferView *) const; /// - LyXFont const getFont(Buffer const *, Paragraph * par, pos_type pos) const; + LyXFont const getFont(Buffer const *, Paragraph * par, + lyx::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, - pos_type pos, LyXFont const & font); + lyx::pos_type pos, LyXFont const & font); void setCharFont(BufferView *, Paragraph * par, - pos_type pos, LyXFont const & font, bool toggleall); + lyx::pos_type pos, LyXFont const & font, bool toggleall); /// returns a pointer to the very first Paragraph Paragraph * firstParagraph() const; @@ -122,9 +119,9 @@ public: Paragraph * setLayout(BufferView *, LyXCursor & actual_cursor, LyXCursor & selection_start, LyXCursor & selection_end, - layout_type layout); + lyx::layout_type layout); /// - void setLayout(BufferView *, layout_type layout); + void setLayout(BufferView *, lyx::layout_type layout); /// used in setlayout void makeFontEntriesLayoutSpecific(Buffer const *, Paragraph * par); @@ -199,7 +196,7 @@ public: /// mutable Row * refresh_row; /// - pos_type refresh_pos; + lyx::pos_type refresh_pos; /// give and set the LyXText status text_status status() const; @@ -222,14 +219,14 @@ public: /** returns the column near the specified x-coordinate of the row x is set to the real beginning of this column */ - pos_type getColumnNearX(BufferView *, Row * row, + lyx::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, - pos_type pos, int & y) const; + lyx::pos_type pos, int & y) const; /** returns the height of a default row, needed for scrollbar */ @@ -306,16 +303,16 @@ public: void selectSelectedWord(BufferView *); /// void setCursor(BufferView *, Paragraph * par, - pos_type pos, + lyx::pos_type pos, bool setfont = true, bool boundary = false) const; /// void setCursor(BufferView *, LyXCursor &, Paragraph * par, - pos_type pos, + lyx::pos_type pos, bool boundary = false) const; /// void setCursorIntern(BufferView *, Paragraph * par, - pos_type pos, + lyx::pos_type pos, bool setfont = true, bool boundary = false) const; /// @@ -323,10 +320,10 @@ public: /// bool isBoundary(Buffer const *, Paragraph * par, - pos_type pos) const; + lyx::pos_type pos) const; /// bool isBoundary(Buffer const *, Paragraph * par, - pos_type pos, + lyx::pos_type pos, LyXFont const & font) const; /// @@ -457,9 +454,9 @@ public: /// returns false if inset wasn't found bool updateInset(BufferView *, Inset *); /// - void checkParagraph(BufferView *, Paragraph * par, pos_type pos); + void checkParagraph(BufferView *, Paragraph * par, lyx::pos_type pos); /// - int numberOfCell(Paragraph * par, pos_type pos) const; + int numberOfCell(Paragraph * par, lyx::pos_type pos) const; /// void removeTableRow(LyXCursor & cursor) const; /// @@ -475,7 +472,7 @@ public: /// Maps positions in the visual string to positions in logical string. inline - pos_type log2vis(pos_type pos) const { + lyx::pos_type log2vis(lyx::pos_type pos) const { if (bidi_start == -1) return pos; else @@ -484,7 +481,7 @@ public: /// Maps positions in the logical string to positions in visual string. inline - pos_type vis2log(pos_type pos) const { + lyx::pos_type vis2log(lyx::pos_type pos) const { if (bidi_start == -1) return pos; else @@ -492,7 +489,7 @@ public: } /// inline - pos_type bidi_level(pos_type pos) const { + lyx::pos_type bidi_level(lyx::pos_type pos) const { if (bidi_start == -1) return 0; else @@ -500,7 +497,7 @@ public: } /// inline - bool bidi_InRange(pos_type pos) const { + bool bidi_InRange(lyx::pos_type pos) const { return bidi_start == -1 || (bidi_start <= pos && pos <= bidi_end); } @@ -514,11 +511,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 */ - layout_type copylayouttype; + lyx::layout_type copylayouttype; /** inserts a new row behind the specified row, increments the touched counters */ - void insertRow(Row * row, Paragraph * par, pos_type pos) const; + void insertRow(Row * row, Paragraph * par, lyx::pos_type pos) const; /** removes the row and reset the touched counters */ void removeRow(Row * row) const; @@ -620,15 +617,17 @@ private: */ /// - int singleWidth(BufferView *, Paragraph * par, pos_type pos) const; + int singleWidth(BufferView *, Paragraph * par, + lyx::pos_type pos) const; /// - int singleWidth(BufferView *, Paragraph * par, pos_type pos, char c) const; + int singleWidth(BufferView *, Paragraph * par, + lyx::pos_type pos, char c) const; /// void draw(BufferView *, Row const * row, - pos_type & pos, int offset, float & x, bool cleared); + lyx::pos_type & pos, int offset, float & x, bool cleared); /// get the next breakpoint in a given paragraph - pos_type nextBreakPoint(BufferView *, Row const * row, int width) const; + lyx::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; @@ -637,7 +636,7 @@ private: int labelFill(BufferView *, Row const * row) const; /// - pos_type beginningOfMainBody(Buffer const *, Paragraph const * par) const; + lyx::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 @@ -668,39 +667,39 @@ private: LaTeX */ bool hfillExpansion(Buffer const *, Row const * row_ptr, - pos_type pos) const; + lyx::pos_type pos) const; /// LColor::color backgroundColor(); /// - mutable std::vector log2vis_list; + mutable std::vector log2vis_list; /// - mutable std::vector vis2log_list; + mutable std::vector vis2log_list; /// - mutable std::vector bidi_levels; + mutable std::vector bidi_levels; /// - mutable pos_type bidi_start; + mutable lyx::pos_type bidi_start; /// - mutable pos_type bidi_end; + mutable lyx::pos_type bidi_end; /// mutable bool bidi_same_direction; /// unsigned char transformChar(unsigned char c, Paragraph * par, - pos_type pos) const; + lyx::pos_type pos) const; /** returns the paragraph position of the last character in the specified row */ - pos_type rowLast(Row const * row) const; + lyx::pos_type rowLast(Row const * row) const; /// - pos_type rowLastPrintable(Row const * row) const; + lyx::pos_type rowLastPrintable(Row const * row) const; /// void charInserted(); diff --git a/src/paragraph.C b/src/paragraph.C index 733daee2fe..df3964ccc4 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -52,6 +52,9 @@ using std::lower_bound; using std::upper_bound; using std::reverse; +using lyx::pos_type; +using lyx::layout_type; + int tex_code_break_column = 72; // needs non-zero initialization. set later. // this is a bad idea, but how can Paragraph find its buffer to get // parameters? (JMarc) @@ -80,7 +83,7 @@ Paragraph::Paragraph() previous_ = 0; enumdepth = 0; itemdepth = 0; - bibkey = 0; // ale970302 + bibkey = 0; // ale970302 clear(); } @@ -102,8 +105,8 @@ Paragraph::Paragraph(Paragraph * par) previous_->next_ = this; // end - bibkey = 0; // ale970302 - + bibkey = 0; // ale970302 + clear(); } @@ -112,17 +115,17 @@ Paragraph::Paragraph(Paragraph const & lp, bool same_ids) : pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids)) { for (int i = 0; i < 10; ++i) - setCounter(i , 0); + setCounter(i, 0); enumdepth = 0; itemdepth = 0; - next_ = 0; + next_ = 0; previous_ = 0; // this is because of the dummy layout of the paragraphs that // follow footnotes layout = lp.layout; - // ale970302 + // ale970302 if (lp.bibkey) { bibkey = static_cast (lp.bibkey->clone(*current_view->buffer())); @@ -131,7 +134,6 @@ Paragraph::Paragraph(Paragraph const & lp, bool same_ids) } // copy everything behind the break-position to the new paragraph - insetlist = lp.insetlist; for (InsetList::iterator it = insetlist.begin(); it != insetlist.end(); ++it) @@ -154,7 +156,7 @@ Paragraph::~Paragraph() delete it->inset; } - // ale970302 + // ale970302 delete bibkey; delete pimpl_; @@ -382,8 +384,7 @@ void Paragraph::validate(LaTeXFeatures & features) const // then the insets LyXLayout const & layout = - textclasslist.Style(bparams.textclass, - getLayout()); + textclasslist.Style(bparams.textclass, getLayout()); for (InsetList::const_iterator cit = insetlist.begin(); cit != insetlist.end(); ++cit) { @@ -607,10 +608,8 @@ LyXFont const Paragraph::getFontSettings(BufferParams const & bparams, // Gets uninstantiated font setting at position 0 LyXFont const Paragraph::getFirstFontSettings() const { - if (size() > 0) { - if (!pimpl_->fontlist.empty()) - return pimpl_->fontlist[0].font(); - } + if (size() > 0 && !pimpl_->fontlist.empty()) + return pimpl_->fontlist[0].font(); return LyXFont(LyXFont::ALL_INHERIT); } @@ -978,7 +977,7 @@ void Paragraph::breakParagraphConservative(BufferParams const & bparams, } } } - + // Be carefull, this does not make any check at all. // This method has wrong name, it combined this par with the next par. @@ -987,7 +986,7 @@ void Paragraph::pasteParagraph(BufferParams const & bparams) { // copy the next paragraph to this one Paragraph * the_next = next(); - + // first the DTP-stuff params().lineBottom(the_next->params().lineBottom()); params().spaceBottom(the_next->params().spaceBottom()); @@ -1002,7 +1001,7 @@ void Paragraph::pasteParagraph(BufferParams const & bparams) if (insertFromMinibuffer(pos_insert + j)) ++j; } - + // delete the next paragraph Paragraph * ppar = the_next->previous_; Paragraph * npar = the_next->next_; @@ -1016,7 +1015,7 @@ int Paragraph::getEndLabel(BufferParams const & bparams) const Paragraph const * par = this; depth_type par_depth = getDepth(); while (par) { - Paragraph::layout_type layout = par->getLayout(); + layout_type layout = par->getLayout(); int const endlabeltype = textclasslist.Style(bparams.textclass, layout).endlabeltype; @@ -1136,11 +1135,11 @@ int Paragraph::beginningOfMainBody() const Paragraph * Paragraph::depthHook(depth_type depth) { Paragraph * newpar = this; - + do { newpar = newpar->previous(); } while (newpar && newpar->getDepth() > depth); - + if (!newpar) { if (previous() || getDepth()) lyxerr << "ERROR (Paragraph::DepthHook): " @@ -1155,11 +1154,11 @@ Paragraph * Paragraph::depthHook(depth_type depth) Paragraph const * Paragraph::depthHook(depth_type depth) const { Paragraph const * newpar = this; - + do { newpar = newpar->previous(); } while (newpar && newpar->getDepth() > depth); - + if (!newpar) { if (previous() || getDepth()) lyxerr << "ERROR (Paragraph::DepthHook): " @@ -1265,7 +1264,7 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf, os << params().spaceTop().asLatexCommand(bparams); further_blank_line = true; } - + if (params().lineTop()) { os << "\\lyxline{\\" << getFont(bparams, 0).latexSize() << '}' << "\\vspace{-1\\parskip}"; @@ -1362,10 +1361,10 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf, switch (style.latextype) { case LATEX_ITEM_ENVIRONMENT: case LATEX_LIST_ENVIRONMENT: - if (next_ && (params().depth() < next_->params().depth())) { - os << '\n'; - texrow.newline(); - } + if (next_ && (params().depth() < next_->params().depth())) { + os << '\n'; + texrow.newline(); + } break; case LATEX_ENVIRONMENT: // if its the last paragraph of the current environment @@ -1374,6 +1373,7 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf, && (next_->layout != layout || next_->params().depth() != params().depth())) break; + // fall through possible default: // we don't need it for the last paragraph!!! if (next_) { @@ -1392,7 +1392,7 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf, os << params().spaceBottom().asLatexCommand(bparams); further_blank_line = true; } - + if (params().pagebreakBottom()) { os << "\\newpage"; further_blank_line = true; @@ -2048,7 +2048,7 @@ void Paragraph::setContentsFromPar(Paragraph * par) } -Paragraph::pos_type Paragraph::size() const +lyx::pos_type Paragraph::size() const { return pimpl_->size(); } @@ -2072,7 +2072,7 @@ void Paragraph::id(int id_arg) } -Paragraph::layout_type Paragraph::getLayout() const +layout_type Paragraph::getLayout() const { return layout; } diff --git a/src/paragraph.h b/src/paragraph.h index d7b098f5fb..d97b8c62a4 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -79,10 +79,6 @@ public: typedef char value_type; /// The same as ParameterStruct::depth_type typedef unsigned int depth_type; - /// a position in the paragraph - typedef lyx::pos_type pos_type; - /// a layout number - typedef lyx::layout_type layout_type; /// Paragraph(); @@ -107,7 +103,7 @@ public: /// string const asString(Buffer const *, bool label); /// - string const asString(Buffer const *, pos_type beg, pos_type end, + string const asString(Buffer const *, lyx::pos_type beg, lyx::pos_type end, bool label); /// @@ -156,14 +152,14 @@ public: void resizeInsetsLyXText(BufferView *); /// - pos_type size() const; + lyx::pos_type size() const; /// void setContentsFromPar(Paragraph * par); /// void clearContents(); /// - layout_type layout; + lyx::layout_type layout; /// void setCounter(int i, int v); @@ -214,30 +210,30 @@ public: /// void setLabelWidthString(string const & s); /// - layout_type getLayout() const; + lyx::layout_type getLayout() const; /// char getAlign() const; /// depth_type getDepth() const; /// - void setLayout(layout_type new_layout); + void setLayout(lyx::layout_type new_layout); /// - void setOnlyLayout(layout_type new_layout); + void setOnlyLayout(lyx::layout_type new_layout); /// int getFirstCounter(int i) const; /// - void erase(pos_type pos); + void erase(lyx::pos_type pos); /** the flag determines wether the layout should be copied */ - void breakParagraph(BufferParams const &, pos_type pos, int flag); + void breakParagraph(BufferParams const &, lyx::pos_type pos, int flag); /// - void breakParagraphConservative(BufferParams const &, pos_type pos); + void breakParagraphConservative(BufferParams const &, lyx::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 &, pos_type pos) const; + getFontSettings(BufferParams const &, lyx::pos_type pos) const; /// LyXFont const getFirstFontSettings() const; @@ -248,62 +244,62 @@ public: attributes with values LyXFont::INHERIT, LyXFont::IGNORE or LyXFont::TOGGLE. */ - LyXFont const getFont(BufferParams const &, pos_type pos) const; + LyXFont const getFont(BufferParams const &, lyx::pos_type pos) const; LyXFont const getLayoutFont(BufferParams const &) const; LyXFont const getLabelFont(BufferParams const &) const; /// - value_type getChar(pos_type pos) const; + value_type getChar(lyx::pos_type pos) const; /// - value_type getUChar(BufferParams const &, pos_type pos) const; + value_type getUChar(BufferParams const &, lyx::pos_type pos) const; /// The position must already exist. - void setChar(pos_type pos, value_type c); + void setChar(lyx::pos_type pos, value_type c); /// - void setFont(pos_type pos, LyXFont const & font); + void setFont(lyx::pos_type pos, LyXFont const & font); /// Returns the height of the highest font in range - LyXFont::FONT_SIZE highestFontInRange(pos_type startpos, - pos_type endpos, + LyXFont::FONT_SIZE highestFontInRange(lyx::pos_type startpos, + lyx::pos_type endpos, LyXFont::FONT_SIZE const def_size) const; /// - void insertChar(pos_type pos, value_type c); + void insertChar(lyx::pos_type pos, value_type c); /// - void insertChar(pos_type pos, value_type c, LyXFont const &); + void insertChar(lyx::pos_type pos, value_type c, LyXFont const &); /// bool checkInsertChar(LyXFont &); /// - void insertInset(pos_type pos, Inset * inset); + void insertInset(lyx::pos_type pos, Inset * inset); /// - void insertInset(pos_type pos, Inset * inset, LyXFont const &); + void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const &); /// bool insetAllowed(Inset::Code code); /// - Inset * getInset(pos_type pos); + Inset * getInset(lyx::pos_type pos); /// - Inset const * getInset(pos_type pos) const; + Inset const * getInset(lyx::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 &, pos_type pos) const; + void copyIntoMinibuffer(Buffer const &, lyx::pos_type pos) const; /// - void cutIntoMinibuffer(BufferParams const &, pos_type pos); + void cutIntoMinibuffer(BufferParams const &, lyx::pos_type pos); /// - bool insertFromMinibuffer(pos_type pos); + bool insertFromMinibuffer(lyx::pos_type pos); /// - bool isHfill(pos_type pos) const; + bool isHfill(lyx::pos_type pos) const; /// - bool isInset(pos_type pos) const; + bool isInset(lyx::pos_type pos) const; /// - bool isNewline(pos_type pos) const; + bool isNewline(lyx::pos_type pos) const; /// - bool isSeparator(pos_type pos) const; + bool isSeparator(lyx::pos_type pos) const; /// - bool isLineSeparator(pos_type pos) const; + bool isLineSeparator(lyx::pos_type pos) const; /// - bool isKomma(pos_type pos) const; + bool isKomma(lyx::pos_type pos) const; /// Used by the spellchecker - bool isLetter(pos_type pos) const; + bool isLetter(lyx::pos_type pos) const; /// - bool isWord(pos_type pos) const; + bool isWord(lyx::pos_type pos) const; /** This one resets all layout and dtp switches but not the font of the single characters @@ -346,11 +342,11 @@ private: /// struct InsetTable { /// - pos_type pos; + lyx::pos_type pos; /// Inset * inset; /// - InsetTable(pos_type p, Inset * i) : pos(p), inset(i) {} + InsetTable(lyx::pos_type p, Inset * i) : pos(p), inset(i) {} }; /// @@ -373,7 +369,7 @@ public: /// Inset * operator*() { return it->inset; } /// - pos_type getPos() const { return it->pos; } + lyx::pos_type getPos() const { return it->pos; } /// bool operator==(inset_iterator const & iter) const { return it == iter.it; @@ -394,7 +390,7 @@ public: /// inset_iterator inset_iterator_end(); /// - inset_iterator InsetIterator(pos_type pos); + inset_iterator InsetIterator(lyx::pos_type pos); private: /// if anything uses this we don't want it to. diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index 5722b55b5c..7ee64a70d8 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -23,6 +23,8 @@ #include "debug.h" #include "support/LAssert.h" +using lyx::pos_type; + extern int tex_code_break_column; diff --git a/src/paragraph_pimpl.h b/src/paragraph_pimpl.h index 393a6397e3..38c29bcbef 100644 --- a/src/paragraph_pimpl.h +++ b/src/paragraph_pimpl.h @@ -29,7 +29,7 @@ struct Paragraph::Pimpl { /// Copy constructor Pimpl(Pimpl const &, Paragraph * owner, bool same_ids = false); /// - pos_type size() const { + lyx::pos_type size() const { return text.size(); } /// @@ -37,15 +37,15 @@ struct Paragraph::Pimpl { /// void setContentsFromPar(Paragraph const * par); /// - value_type getChar(pos_type pos) const; + value_type getChar(lyx::pos_type pos) const; /// - void setChar(pos_type pos, value_type c); + void setChar(lyx::pos_type pos, value_type c); /// - void insertChar(pos_type pos, value_type c, LyXFont const & font); + void insertChar(lyx::pos_type pos, value_type c, LyXFont const & font); /// - void insertInset(pos_type pos, Inset * inset, LyXFont const & font); + void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const & font); /// - void erase(pos_type pos); + void erase(lyx::pos_type pos); /// LyXFont const realizeFont(LyXFont const & font, BufferParams const & bparams) const; @@ -77,22 +77,22 @@ struct Paragraph::Pimpl { */ struct FontTable { /// - FontTable(pos_type p, LyXFont const & f) + FontTable(lyx::pos_type p, LyXFont const & f) : pos_(p) { font_ = container.get(f); } /// - pos_type pos() const { return pos_; } + lyx::pos_type pos() const { return pos_; } /// - void pos(pos_type p) { pos_ = p; } + void pos(lyx::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 - pos_type pos_; + lyx::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 @@ -126,7 +126,7 @@ struct Paragraph::Pimpl { std::ostream &, TexRow & texrow); /// void simpleTeXBlanks(std::ostream &, TexRow & texrow, - pos_type const i, + lyx::pos_type const i, int & column, LyXFont const & font, LyXLayout const & style); /// @@ -136,7 +136,7 @@ struct Paragraph::Pimpl { LyXFont & font, LyXFont & running_font, LyXFont & basefont, bool & open_font, LyXLayout const & style, - pos_type & i, + lyx::pos_type & i, int & column, value_type const c); /// Paragraph * getParFromID(int id) const; @@ -148,7 +148,7 @@ struct Paragraph::Pimpl { ParagraphParameters params; private: /// match a string against a particular point in the paragraph - bool isTextAt(string const & str, pos_type pos); + bool isTextAt(string const & str, lyx::pos_type pos); /// Who owns us? Paragraph * owner_; diff --git a/src/text.C b/src/text.C index a7f2cbd330..fab24b2585 100644 --- a/src/text.C +++ b/src/text.C @@ -46,6 +46,7 @@ using std::max; using std::min; using std::endl; using std::pair; +using lyx::pos_type; namespace { @@ -230,7 +231,7 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par, // Returns the paragraph position of the last character in the specified row -LyXText::pos_type LyXText::rowLast(Row const * row) const +pos_type LyXText::rowLast(Row const * row) const { if (row->next() == 0) return row->par()->size() - 1; @@ -241,7 +242,7 @@ LyXText::pos_type LyXText::rowLast(Row const * row) const } -LyXText::pos_type LyXText::rowLastPrintable(Row const * row) const +pos_type LyXText::rowLastPrintable(Row const * row) const { pos_type const last = rowLast(row); if (last >= row->pos() @@ -878,7 +879,7 @@ int LyXText::labelEnd(BufferView * bview, Row const * row) const // get the next breakpoint in a given paragraph -LyXText::pos_type +pos_type LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const { Paragraph * par = row->par(); @@ -888,7 +889,6 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const pos_type const pos = row->pos(); - // position of the last possible breakpoint // -1 isn't a suitable value, but a flag pos_type last_separator = -1; @@ -3581,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 */ -LyXText::pos_type +pos_type LyXText::getColumnNearX(BufferView * bview, Row * row, int & x, bool & boundary) const { diff --git a/src/text2.C b/src/text2.C index 5d95dc2172..abde4bd529 100644 --- a/src/text2.C +++ b/src/text2.C @@ -49,6 +49,7 @@ using std::find; using std::endl; using std::find; using std::pair; +using lyx::pos_type; LyXText::LyXText(BufferView * bv) @@ -498,7 +499,7 @@ void LyXText::makeFontEntriesLayoutSpecific(Buffer const * buf, Paragraph * LyXText::setLayout(BufferView * bview, LyXCursor & cur, LyXCursor & sstart_cur, LyXCursor & send_cur, - layout_type layout) + lyx::layout_type layout) { Paragraph * endpar = send_cur.par()->next(); Paragraph * undoendpar = endpar; @@ -560,7 +561,7 @@ Paragraph * LyXText::setLayout(BufferView * bview, // set layout over selection and make a total rebreak of those paragraphs -void LyXText::setLayout(BufferView * bview, layout_type layout) +void LyXText::setLayout(BufferView * bview, lyx::layout_type layout) { LyXCursor tmpcursor = cursor; /* store the current cursor */ @@ -1163,7 +1164,7 @@ string LyXText::getStringToIndex(BufferView * bview) } -LyXText::pos_type LyXText::beginningOfMainBody(Buffer const * buf, +pos_type LyXText::beginningOfMainBody(Buffer const * buf, Paragraph const * par) const { if (textclasslist.Style(buf->params.textclass,