#include "lyxscreen.h"
#include "lyxtext.h"
#include "lyxrow.h"
+#include "paragraph.h"
#include "LyXView.h"
#include "commandtags.h"
#include "lyxfunc.h"
#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;
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;
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)));
{
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
#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
///
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);
///
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);
+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
// 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) {
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) {
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);
}
// 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,
++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;
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";
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;
// 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);
Buffer::inset_iterator::inset_iterator(Paragraph * paragraph,
- Paragraph::size_type pos)
+ Paragraph::pos_type pos)
: par(paragraph)
{
it = par->InsetIterator(pos);
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
///
}
///
inset_iterator(Paragraph * paragraph,
- Paragraph::size_type pos);
+ Paragraph::pos_type pos);
///
inset_iterator & operator++() { // prefix ++
if (par) {
///
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,
+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
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);
}
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();
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:
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:
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:
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:
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) {
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
}
-Paragraph::size_type InsetText::cpos(BufferView * bv) const
+Paragraph::pos_type InsetText::cpos(BufferView * bv) const
{
return getLyXText(bv)->cursor.pos();
}
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 {
///
int cy(BufferView *) const;
///
- Paragraph::size_type cpos(BufferView *) const;
+ Paragraph::pos_type cpos(BufferView *) const;
///
Paragraph * cpar(BufferView *) const;
///
///
Paragraph * inset_par;
///
- Paragraph::size_type inset_pos;
+ Paragraph::pos_type inset_pos;
///
bool inset_boundary;
///
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;
}
-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_;
}
#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);
///
/// The paragraph the cursor is in.
Paragraph * par_;
/// The position inside the paragraph
- Paragraph::size_type pos_;
+ pos_type pos_;
///
bool boundary_;
///
/// 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);
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;
// 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)
{
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))
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;
}
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)) {
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)
#include "version.h"
#include "kbmap.h"
#include "lyxfunc.h"
+#include "lyxrow.h"
#include "bufferlist.h"
#include "BufferView.h"
#include "ColorHandler.h"
}
-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_;
}
#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();
///
///
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);
///
///
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_;
#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;
/**
*/
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 {
///
///
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;
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);
/** 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.
///
mutable Row * refresh_row;
///
- Paragraph::size_type refresh_pos;
+ pos_type refresh_pos;
/// give and set the LyXText status
text_status status() 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 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
*/
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;
///
///
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;
///
/// 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;
///
/// 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
/// 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
}
///
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
}
///
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);
}
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;
*/
///
- 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;
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
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();
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
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;
// 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;
}
-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);
}
-bool Paragraph::insertFromMinibuffer(Paragraph::size_type pos)
+bool Paragraph::insertFromMinibuffer(pos_type pos)
{
if (minibuffer_char == Paragraph::META_INSET) {
if (!insetAllowed(minibuffer_inset->lyxCode())) {
}
-void Paragraph::erase(Paragraph::size_type pos)
+void Paragraph::erase(pos_type pos)
{
pimpl_->erase(pos);
}
}
-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);
}
}
-Inset * Paragraph::getInset(Paragraph::size_type pos)
+Inset * Paragraph::getInset(pos_type pos)
{
lyx::Assert(pos < size());
}
-Inset const * Paragraph::getInset(Paragraph::size_type pos) const
+Inset const * Paragraph::getInset(pos_type pos) const
{
lyx::Assert(pos < size());
// 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());
// 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();
/// 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())
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)
}
-void Paragraph::setFont(Paragraph::size_type pos,
+void Paragraph::setFont(pos_type pos,
LyXFont const & font)
{
lyx::Assert(pos <= size());
void Paragraph::breakParagraph(BufferParams const & bparams,
- Paragraph::size_type pos,
+ pos_type pos,
int flag)
{
// create a new paragraph
// 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))
void Paragraph::breakParagraphConservative(BufferParams const & bparams,
- Paragraph::size_type pos)
+ pos_type pos)
{
// create a new paragraph
Paragraph * tmp = new Paragraph(this);
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);
}
}
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;
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;
}
-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));
// 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;
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(),
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
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) {
}
-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))
}
-bool Paragraph::isWord(size_type pos ) const
+bool Paragraph::isWord(pos_type pos ) const
{
return IsWordChar(getChar(pos)) ;
}
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);
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;
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;
}
-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);
}
}
-LyXTextClass::LayoutList::size_type Paragraph::getLayout() const
+Paragraph::layout_type Paragraph::getLayout() const
{
return layout;
}
}
-void Paragraph::setChar(size_type pos, value_type c)
+void Paragraph::setChar(pos_type pos, value_type c)
{
pimpl_->setChar(pos, c);
}
#include "LString.h"
-#include <vector>
-
#include "insets/inset.h" // Just for Inset::Code
#include "layout.h"
+#include "support/types.h"
class ParagraphParameters;
class BufferParams;
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();
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);
///
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);
///
char itemdepth;
- ///
- InsetBibKey * bibkey; // ale970302
+ ///
+ InsetBibKey * bibkey; // ale970302
///
void next(Paragraph *);
///
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;
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
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);
///
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) {}
};
///
///
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;
///
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.
Pimpl * pimpl_;
};
+inline bool isMetaInset(Paragraph const * par, Paragraph::pos_type const pos)
+{
+ return par->getChar(pos) == Paragraph::META_INSET;
+}
+
#endif
}
-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;
}
-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
}
-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());
}
-void Paragraph::Pimpl::insertInset(Paragraph::size_type pos,
+void Paragraph::Pimpl::insertInset(pos_type pos,
Inset * inset, LyXFont const & font)
{
lyx::Assert(inset);
}
-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
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)
{
}
-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())
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;
#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();
}
///
///
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;
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;
}
};
*/
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
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();
}
};
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);
///
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;
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_;
+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
--- /dev/null
+#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
#include <config.h>
#include "lyxtext.h"
+#include "lyxrow.h"
#include "layout.h"
#include "paragraph.h"
#include "lyx_gui_misc.h"
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();
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))
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;
// 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);
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);
// 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;
}
-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()
}
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);
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))
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;
}
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;
// 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;
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
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;
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)) {
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)) {
// 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();
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 */
}
} 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);
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,
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) {
// 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.
--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;
// 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)) {
// 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))
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;
// 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))
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;
}
// 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))
// 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;
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);
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())
// 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;
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()) {
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()) {
* 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);
|| 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()) {
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 ||
// 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);
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())) {
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
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);
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) ||
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())) {
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,
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;
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);
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 ||
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));
/* 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
{
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 &&
// 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;
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();
+}
#include "font.h"
#include "debug.h"
#include "lyxrc.h"
+#include "lyxrow.h"
#include "FloatList.h"
#include "language.h"
#include "ParagraphParameters.h"
// 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);
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();
void LyXText::setCharFont(Buffer const * buf, Paragraph * par,
- Paragraph::size_type pos, LyXFont const & fnt)
+ pos_type pos, LyXFont const & fnt)
{
LyXFont font(fnt);
// 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) {
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
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;
// 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 */
}
-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,
}
// 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());
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);
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
}
int const tmpheight = row->height();
- Paragraph::size_type const tmplast = rowLast(row);
+ pos_type const tmplast = rowLast(row);
refresh_y = y;
refresh_row = row;
void LyXText::setCursor(BufferView * bview, Paragraph * par,
- Paragraph::size_type pos,
+ pos_type pos,
bool setfont, bool boundary) const
{
LyXCursor old_cursor = cursor;
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);
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;
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) {
}
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());
void LyXText::setCurrentFont(BufferView * bview) const
{
- Paragraph::size_type pos = cursor.pos();
+ pos_type pos = cursor.pos();
if (cursor.boundary() && pos > 0)
--pos;
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);