grr.. revert. wrong patch.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7535 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-08-14 08:17:27 +00:00
parent 87cab819b4
commit a9d4d09715
13 changed files with 291 additions and 344 deletions

View File

@ -1,24 +1,11 @@
2003-08-14 André Pönitz <poenitz@gmx.net>
* lyxrow.[Ch]: remove Row::pit_ member and par() accessors
* bufferview_funcs.C:
* lyxrow_funcs.[Ch]:
* lyxtext.h:
* rowpainter.C:
* text.C:
* text2.C:
* text3.C: adjust
2003-08-11 André Pönitz <poenitz@gmx.net> 2003-08-11 André Pönitz <poenitz@gmx.net>
* lyxtext.h (getPar):
* text.C: new function
* Makefile.am: * Makefile.am:
* tracer.[Ch]: remove unneeded files * tracer.[Ch]: remove unneeded files
2003-08-11 André Pönitz <poenitz@gmx.net>
* InsetList.[Ch]: remove resizeInsetsLyXText() * InsetList.[Ch]: remove resizeInsetsLyXText()
* lyxtext.h: * lyxtext.h:

View File

@ -390,8 +390,7 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
if (font.language() != ignore_language || if (font.language() != ignore_language ||
font.number() != LyXFont::IGNORE) { font.number() != LyXFont::IGNORE) {
LyXCursor & cursor = text->cursor; LyXCursor & cursor = text->cursor;
text->computeBidiTables(text->cursor.par(), bv->buffer(), text->computeBidiTables(bv->buffer(), text->cursorRow());
text->cursorRow());
if (cursor.boundary() != if (cursor.boundary() !=
text->isBoundary(bv->buffer(), *cursor.par(), cursor.pos(), text->isBoundary(bv->buffer(), *cursor.par(), cursor.pos(),
text->real_current_font)) text->real_current_font))

View File

@ -13,6 +13,9 @@
#include <config.h> #include <config.h>
#include "lyxrow.h" #include "lyxrow.h"
#include "paragraph.h"
#include "layout.h"
#include "lyxlayout.h"
#include "debug.h" #include "debug.h"
using lyx::pos_type; using lyx::pos_type;
@ -26,8 +29,8 @@ Row::Row()
{} {}
Row::Row(pos_type po) Row::Row(ParagraphList::iterator pit, pos_type po)
: pos_(po), fill_(0), height_(0), width_(0), y_(0), : pit_(pit), pos_(po), fill_(0), height_(0), width_(0), y_(0),
ascent_of_text_(0), baseline_(0) ascent_of_text_(0), baseline_(0)
{} {}
@ -44,12 +47,30 @@ unsigned int Row::y() const
} }
ParagraphList::iterator Row::par()
{
return pit_;
}
ParagraphList::iterator Row::par() const
{
return pit_;
}
unsigned short Row::height() const unsigned short Row::height() const
{ {
return height_; return height_;
} }
void Row::par(ParagraphList::iterator pit)
{
pit_ = pit;
}
void Row::pos(pos_type p) void Row::pos(pos_type p)
{ {
pos_ = p; pos_ = p;

View File

@ -15,6 +15,7 @@
#ifndef LYXROW_H #ifndef LYXROW_H
#define LYXROW_H #define LYXROW_H
#include "ParagraphList.h"
#include "support/types.h" #include "support/types.h"
/// ///
@ -23,7 +24,13 @@ public:
/// ///
Row(); Row();
/// ///
Row(lyx::pos_type pos); Row(ParagraphList::iterator pit, lyx::pos_type pos);
///
void par(ParagraphList::iterator pit);
///
ParagraphList::iterator par();
///
ParagraphList::iterator par() const;
/// ///
void pos(lyx::pos_type p); void pos(lyx::pos_type p);
/// ///
@ -61,6 +68,8 @@ public:
/// current debugging only /// current debugging only
void dump(const char * = "") const; void dump(const char * = "") const;
private: private:
///
ParagraphList::iterator pit_;
/// ///
lyx::pos_type pos_; lyx::pos_type pos_;
/** what is missing to a full row. Can be negative. /** what is missing to a full row. Can be negative.

View File

@ -9,27 +9,24 @@
#include <algorithm> #include <algorithm>
using lyx::pos_type; using lyx::pos_type;
using std::max; using std::max;
using std::min; using std::min;
bool isParEnd(LyXText const & lt, bool isParEnd(LyXText const & lt, RowList::iterator rit)
ParagraphList::iterator pit, RowList::iterator rit)
{ {
RowList::iterator next_row = boost::next(rit); RowList::iterator next_row = boost::next(rit);
return next_row == lt.rows().end() || lt.getPar(next_row) != pit; return next_row == lt.rows().end() || next_row->par() != rit->par();
} }
pos_type lastPos(LyXText const & lt, pos_type lastPos(LyXText const & lt, RowList::iterator rit)
ParagraphList::iterator pit, RowList::iterator rit)
{ {
if (pit->empty()) if (rit->par()->empty())
return 0; return 0;
if (isParEnd(lt, pit, rit)) if (isParEnd(lt, rit))
return pit->size() - 1; return rit->par()->size() - 1;
return boost::next(rit)->pos() - 1; return boost::next(rit)->pos() - 1;
} }
@ -37,9 +34,10 @@ pos_type lastPos(LyXText const & lt,
namespace { namespace {
bool nextRowIsAllInset( bool nextRowIsAllInset(Row const & row, pos_type last)
ParagraphList::iterator pit, RowList::iterator rit, pos_type last)
{ {
ParagraphList::iterator pit = row.par();
if (last + 1 >= pit->size()) if (last + 1 >= pit->size())
return false; return false;
@ -53,26 +51,27 @@ bool nextRowIsAllInset(
} // anon namespace } // anon namespace
pos_type lastPrintablePos(LyXText const & lt, pos_type lastPrintablePos(LyXText const & lt, RowList::iterator rit)
ParagraphList::iterator pit, RowList::iterator rit)
{ {
pos_type const last = lastPos(lt, pit, rit); pos_type const last = lastPos(lt, rit);
// if this row is an end of par, just act like lastPos() // if this row is an end of par, just act like lastPos()
if (isParEnd(lt, pit, rit)) if (isParEnd(lt, rit))
return last; return last;
if (!nextRowIsAllInset(pit, rit, last) && pit->isSeparator(last)) bool const nextrownotinset = !nextRowIsAllInset(*rit, last);
if (nextrownotinset && rit->par()->isSeparator(last))
return last - 1; return last - 1;
return last; return last;
} }
int numberOfSeparators(LyXText const & lt, int numberOfSeparators(LyXText const & lt, RowList::iterator rit)
ParagraphList::iterator pit, RowList::iterator rit)
{ {
pos_type const last = lastPrintablePos(lt, pit, rit); pos_type const last = lastPrintablePos(lt, rit);
ParagraphList::iterator pit = rit->par();
int n = 0; int n = 0;
pos_type p = max(rit->pos(), pit->beginningOfBody()); pos_type p = max(rit->pos(), pit->beginningOfBody());
for ( ; p < last; ++p) for ( ; p < last; ++p)
@ -84,11 +83,11 @@ int numberOfSeparators(LyXText const & lt,
// This is called _once_ from LyXText and should at least be moved into // This is called _once_ from LyXText and should at least be moved into
// an anonymous namespace there. (Lgb) // an anonymous namespace there. (Lgb)
int numberOfHfills(LyXText const & lt, int numberOfHfills(LyXText const & lt, RowList::iterator rit)
ParagraphList::iterator pit, RowList::iterator rit)
{ {
pos_type const last = lastPos(lt, pit, rit); pos_type const last = lastPos(lt, rit);
pos_type first = rit->pos(); pos_type first = rit->pos();
ParagraphList::iterator pit = rit->par();
// hfill *DO* count at the beginning of paragraphs! // hfill *DO* count at the beginning of paragraphs!
if (first) { if (first) {
@ -111,11 +110,11 @@ int numberOfHfills(LyXText const & lt,
// This is called _once_ from LyXText and should at least be moved into // This is called _once_ from LyXText and should at least be moved into
// an anonymous namespace there. (Lgb) // an anonymous namespace there. (Lgb)
int numberOfLabelHfills(LyXText const & lt, int numberOfLabelHfills(LyXText const & lt, RowList::iterator rit)
ParagraphList::iterator pit, RowList::iterator rit)
{ {
pos_type last = lastPos(lt, pit, rit); pos_type last = lastPos(lt, rit);
pos_type first = rit->pos(); pos_type first = rit->pos();
ParagraphList::iterator pit = rit->par();
// hfill *DO* count at the beginning of paragraphs! // hfill *DO* count at the beginning of paragraphs!
if (first) { if (first) {
@ -135,15 +134,16 @@ int numberOfLabelHfills(LyXText const & lt,
} }
bool hfillExpansion(LyXText const & lt, bool hfillExpansion(LyXText const & lt, RowList::iterator rit, pos_type pos)
ParagraphList::iterator pit, RowList::iterator rit, pos_type pos)
{ {
ParagraphList::iterator pit = rit->par();
if (!pit->isHfill(pos)) if (!pit->isHfill(pos))
return false; return false;
// at the end of a row it does not count // at the end of a row it does not count
// unless another hfill exists on the line // unless another hfill exists on the line
if (pos >= lastPos(lt, pit, rit)) if (pos >= lastPos(lt, rit))
for (pos_type i = rit->pos(); i < pos && !pit->isHfill(i); ++i) for (pos_type i = rit->pos(); i < pos && !pit->isHfill(i); ++i)
return false; return false;

View File

@ -4,31 +4,22 @@
#define LYXROW_FUNCS_H #define LYXROW_FUNCS_H
#include "RowList.h" #include "RowList.h"
#include "ParagraphList.h"
#include "support/types.h" #include "support/types.h"
class LyXText; class LyXText;
bool isParEnd(LyXText const & lt, bool isParEnd(LyXText const & lt, RowList::iterator rit);
ParagraphList::iterator pit, RowList::iterator rit);
lyx::pos_type lastPos(LyXText const & lt, lyx::pos_type lastPos(LyXText const & lt, RowList::iterator rit);
ParagraphList::iterator pit, RowList::iterator rit);
lyx::pos_type lastPrintablePos(LyXText const & lt, lyx::pos_type lastPrintablePos(LyXText const & lt, RowList::iterator rit);
ParagraphList::iterator pit, RowList::iterator rit);
int numberOfSeparators(LyXText const & lt, int numberOfSeparators(LyXText const & lt, RowList::iterator rit);
ParagraphList::iterator pit, RowList::iterator rit);
int numberOfHfills(LyXText const & lt, int numberOfHfills(LyXText const & lt, RowList::iterator rit);
ParagraphList::iterator pit, RowList::iterator rit);
int numberOfLabelHfills(LyXText const & lt, int numberOfLabelHfills(LyXText const & lt, RowList::iterator rit);
ParagraphList::iterator pit, RowList::iterator rit);
bool hfillExpansion(LyXText const & lt, bool hfillExpansion(LyXText const & lt, RowList::iterator rit, lyx::pos_type pos);
ParagraphList::iterator pit, RowList::iterator rit, lyx::pos_type pos);
#endif #endif

View File

@ -136,6 +136,8 @@ public:
void redoParagraph(ParagraphList::iterator pit); void redoParagraph(ParagraphList::iterator pit);
/// rebreaks the cursor par /// rebreaks the cursor par
void redoParagraph(); void redoParagraph();
/// returns first row belongin to some par
RowList::iterator firstRow(ParagraphList::iterator pit);
/// ///
void toggleFree(LyXFont const &, bool toggleall = false); void toggleFree(LyXFont const &, bool toggleall = false);
@ -194,8 +196,8 @@ public:
/** returns the column near the specified x-coordinate of the row /** returns the column near the specified x-coordinate of the row
x is set to the real beginning of this column x is set to the real beginning of this column
*/ */
lyx::pos_type getColumnNearX(ParagraphList::iterator pit, lyx::pos_type getColumnNearX(RowList::iterator rit,
RowList::iterator rit, int & x, bool & boundary) const; int & x, bool & boundary) const;
/** returns a pointer to a specified row. y is set to the beginning /** returns a pointer to a specified row. y is set to the beginning
of the row of the row
@ -367,8 +369,7 @@ public:
int workWidth() const; int workWidth() const;
/// ///
void computeBidiTables(ParagraphList::iterator pit, void computeBidiTables(Buffer const *, RowList::iterator row) const;
Buffer const *, RowList::iterator row) const;
/// Maps positions in the visual string to positions in logical string. /// Maps positions in the visual string to positions in logical string.
lyx::pos_type log2vis(lyx::pos_type pos) const; lyx::pos_type log2vis(lyx::pos_type pos) const;
/// Maps positions in the logical string to positions in visual string. /// Maps positions in the logical string to positions in visual string.
@ -382,8 +383,7 @@ private:
mutable RowList rowlist_; mutable RowList rowlist_;
/// ///
float getCursorX(ParagraphList::iterator pit, float getCursorX(RowList::iterator rit, lyx::pos_type pos,
RowList::iterator rit, lyx::pos_type pos,
lyx::pos_type last, bool boundary) const; lyx::pos_type last, bool boundary) const;
/// used in setlayout /// used in setlayout
void makeFontEntriesLayoutSpecific(BufferParams const &, Paragraph & par); void makeFontEntriesLayoutSpecific(BufferParams const &, Paragraph & par);
@ -447,15 +447,13 @@ public:
* in LaTeX the beginning of the text fits in some cases * in LaTeX the beginning of the text fits in some cases
* (for example sections) exactly the label-width. * (for example sections) exactly the label-width.
*/ */
int leftMargin(ParagraphList::iterator pit, Row const & row) const; int leftMargin(Row const & row) const;
/// ///
int rightMargin(ParagraphList::iterator pit, Buffer const &, Row const & row) const; int rightMargin(Buffer const &, Row const & row) const;
/** this calculates the specified parameters. needed when setting /** this calculates the specified parameters. needed when setting
* the cursor and when creating a visible row */ * the cursor and when creating a visible row */
void prepareToPrint( void prepareToPrint(RowList::iterator row, double & x,
ParagraphList::iterator pit,
RowList::iterator row, double & x,
double & fill_separator, double & fill_separator,
double & fill_hfill, double & fill_hfill,
double & fill_label_hfill, double & fill_label_hfill,
@ -478,8 +476,7 @@ private:
/// return the pos value *before* which a row should break. /// return the pos value *before* which a row should break.
/// for example, the pos at which IsNewLine(pos) == true /// for example, the pos at which IsNewLine(pos) == true
lyx::pos_type rowBreakPoint(ParagraphList::iterator pit, lyx::pos_type rowBreakPoint(Row const & row) const;
Row const & row) const;
/// returns the minimum space a row needs on the screen in pixel /// returns the minimum space a row needs on the screen in pixel
int fill(RowList::iterator row, int workwidth) const; int fill(RowList::iterator row, int workwidth) const;
@ -488,10 +485,10 @@ private:
* returns the minimum space a manual label needs on the * returns the minimum space a manual label needs on the
* screen in pixels * screen in pixels
*/ */
int labelFill(ParagraphList::iterator pit, Row const & row) const; int labelFill(Row const & row) const;
/// FIXME /// FIXME
int labelEnd(ParagraphList::iterator pit, Row const & row) const; int labelEnd(Row const & row) const;
/// ///
mutable std::vector<lyx::pos_type> log2vis_list; mutable std::vector<lyx::pos_type> log2vis_list;
@ -515,16 +512,6 @@ public:
/// return true if this is owned by an inset. /// return true if this is owned by an inset.
bool isInInset() const; bool isInInset() const;
/// compute paragraphlist iterator from rowlist iterator
ParagraphList::iterator getPar(RowList::iterator rit) const;
/// return first row of par
RowList::iterator beginRow(ParagraphList::iterator pit) const;
/// return row "behind" last of par
RowList::iterator endRow(ParagraphList::iterator pit) const;
/// return row "behind" last of implizitly given par
RowList::iterator endRow(RowList::iterator rit) const;
private: private:
/** Cursor related data. /** Cursor related data.
Later this variable has to be removed. There should be now internal Later this variable has to be removed. There should be now internal

View File

@ -131,7 +131,7 @@ RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
RowList::iterator rit, RowList::iterator rit,
int y_offset, int x_offset, int y) int y_offset, int x_offset, int y)
: bv_(bv), pain_(bv_.painter()), text_(text), row_(rit), : bv_(bv), pain_(bv_.painter()), text_(text), row_(rit),
pit_(text.getPar(rit)), pit_(rit->par()),
xo_(x_offset), yo_(y_offset), y_(y) xo_(x_offset), yo_(y_offset), y_(y)
{} {}
@ -169,7 +169,7 @@ char const RowPainter::transformChar(char c, lyx::pos_type pos) const
int RowPainter::leftMargin() const int RowPainter::leftMargin() const
{ {
return text_.leftMargin(pit_, *row_); return text_.leftMargin(*row_);
} }
@ -255,7 +255,7 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos)
void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic) void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
{ {
pos_type pos = text_.vis2log(vpos); pos_type pos = text_.vis2log(vpos);
pos_type const last = lastPrintablePos(text_, pit_, row_); pos_type const last = lastPrintablePos(text_, row_);
LyXFont orig_font = getFont(pos); LyXFont orig_font = getFont(pos);
// first character // first character
@ -432,7 +432,7 @@ void RowPainter::paintSelection()
int(x_), row_->height(), LColor::selection); int(x_), row_->height(), LColor::selection);
pos_type const body_pos = pit_->beginningOfBody(); pos_type const body_pos = pit_->beginningOfBody();
pos_type const last = lastPrintablePos(text_, pit_, row_); pos_type const last = lastPrintablePos(text_, row_);
double tmpx = x_; double tmpx = x_;
for (pos_type vpos = row_->pos(); vpos <= last; ++vpos) { for (pos_type vpos = row_->pos(); vpos <= last; ++vpos) {
@ -448,7 +448,7 @@ void RowPainter::paintSelection()
tmpx -= singleWidth(body_pos - 1); tmpx -= singleWidth(body_pos - 1);
} }
if (hfillExpansion(text_, pit_, row_, pos)) { if (hfillExpansion(text_, row_, pos)) {
tmpx += singleWidth(pos); tmpx += singleWidth(pos);
if (pos >= body_pos) if (pos >= body_pos)
tmpx += hfill_; tmpx += hfill_;
@ -484,7 +484,7 @@ void RowPainter::paintSelection()
void RowPainter::paintChangeBar() void RowPainter::paintChangeBar()
{ {
pos_type const start = row_->pos(); pos_type const start = row_->pos();
pos_type const end = lastPrintablePos(text_, pit_, row_); pos_type const end = lastPrintablePos(text_, row_);
if (!pit_->isChanged(start, end)) if (!pit_->isChanged(start, end))
return; return;
@ -524,12 +524,12 @@ void RowPainter::paintDepthBar()
Paragraph::depth_type prev_depth = 0; Paragraph::depth_type prev_depth = 0;
if (row_ != text_.rows().begin()) if (row_ != text_.rows().begin())
prev_depth = text_.getPar(boost::prior(row_))->getDepth(); prev_depth = boost::prior(row_)->par()->getDepth();
Paragraph::depth_type next_depth = 0; Paragraph::depth_type next_depth = 0;
RowList::iterator next_row = boost::next(row_); RowList::iterator next_row = boost::next(row_);
if (next_row != text_.rows().end()) if (next_row != text_.rows().end())
next_depth = text_.getPar(next_row)->getDepth(); next_depth = next_row->par()->getDepth();
for (Paragraph::depth_type i = 1; i <= depth; ++i) { for (Paragraph::depth_type i = 1; i <= depth; ++i) {
int const w = PAPER_MARGIN / 5; int const w = PAPER_MARGIN / 5;
@ -795,7 +795,7 @@ void RowPainter::paintFirst()
double x = x_; double x = x_;
if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) { if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
x = ((is_rtl ? leftMargin() : x_) x = ((is_rtl ? leftMargin() : x_)
+ ww - text_.rightMargin(pit_, *bv_.buffer(), *row_)) / 2; + ww - text_.rightMargin(*bv_.buffer(), *row_)) / 2;
x -= font_metrics::width(str, font) / 2; x -= font_metrics::width(str, font) / 2;
} else if (is_rtl) { } else if (is_rtl) {
x = ww - leftMargin() - x = ww - leftMargin() -
@ -875,7 +875,7 @@ void RowPainter::paintLast()
string const & str = pit_->layout()->endlabelstring(); string const & str = pit_->layout()->endlabelstring();
double const x = is_rtl ? double const x = is_rtl ?
x_ - font_metrics::width(str, font) x_ - font_metrics::width(str, font)
: ww - text_.rightMargin(pit_, *bv_.buffer(), *row_) - row_->fill(); : ww - text_.rightMargin(*bv_.buffer(), *row_) - row_->fill();
pain_.text(int(x), yo_ + row_->baseline(), str, font); pain_.text(int(x), yo_ + row_->baseline(), str, font);
break; break;
} }
@ -887,7 +887,7 @@ void RowPainter::paintLast()
void RowPainter::paintText() void RowPainter::paintText()
{ {
pos_type const last = lastPrintablePos(text_, pit_, row_); pos_type const last = lastPrintablePos(text_, row_);
pos_type body_pos = pit_->beginningOfBody(); pos_type body_pos = pit_->beginningOfBody();
if (body_pos > 0 && if (body_pos > 0 &&
(body_pos - 1 > last || !pit_->isLineSeparator(body_pos - 1))) { (body_pos - 1 > last || !pit_->isLineSeparator(body_pos - 1))) {
@ -952,7 +952,7 @@ void RowPainter::paintText()
pain_.line(int(x_), y1, int(x_), y0, LColor::added_space); pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
if (hfillExpansion(text_, pit_, row_, pos)) { if (hfillExpansion(text_, row_, pos)) {
int const y2 = (y0 + y1) / 2; int const y2 = (y0 + y1) / 2;
if (pos >= body_pos) { if (pos >= body_pos) {
@ -997,7 +997,7 @@ void RowPainter::paint()
// FIXME: must be a cleaner way here. Aren't these calculations // FIXME: must be a cleaner way here. Aren't these calculations
// belonging to row metrics ? // belonging to row metrics ?
text_.prepareToPrint(pit_, row_, x_, separator_, hfill_, label_hfill_); text_.prepareToPrint(row_, x_, separator_, hfill_, label_hfill_);
// FIXME: what is this fixing ? // FIXME: what is this fixing ?
if (text_.isInInset() && x_ < 0) if (text_.isInInset() && x_ < 0)
@ -1025,7 +1025,7 @@ void RowPainter::paint()
if (row_->isParStart()) if (row_->isParStart())
paintFirst(); paintFirst();
if (isParEnd(text_, pit_, row_)) if (isParEnd(text_, row_))
paintLast(); paintLast();
// paint text // paint text

View File

@ -11,7 +11,6 @@
#include <config.h> #include <config.h>
#include "LAssert.h" #include "LAssert.h"
#include "debug.h"
#include "support/lyxlib.h" #include "support/lyxlib.h"
#ifdef ENABLE_ASSERTIONS #ifdef ENABLE_ASSERTIONS
@ -35,17 +34,6 @@ void emergencyCleanup()
} // namespace anon } // namespace anon
void Assert(bool assertion, char const * message)
{
if (!assertion) {
lyxerr << "Assert triggered: " << message << std::endl;
emergencyCleanup();
lyx::support::abort();
}
}
void Assert(bool assertion) void Assert(bool assertion)
{ {
if (!assertion) { if (!assertion) {

View File

@ -18,13 +18,11 @@ namespace support {
#ifdef ENABLE_ASSERTIONS #ifdef ENABLE_ASSERTIONS
/** Live assertion. /** Live assertion.
This is a debug tool to ensure that the assertion holds. If it This is a debug tool to ensure that the assertion holds. If it don't hole
doesn't hold we run #emergencyCleanup()# and then #lyx::abort". we run #emergencyCleanup()# and then #lyx::abort".
@param assertion this should evaluate to true unless you want an abort. @param assertion this should evaluate to true unless you want an abort.
*/ */
void Assert(bool assertion); void Assert(bool assertion);
/// same as above, print message before aborting
void Assert(bool assertion, const char * message);
#else #else
@ -33,8 +31,6 @@ void Assert(bool assertion, const char * message);
*/ */
inline inline
void Assert(bool /*assertion*/) {} void Assert(bool /*assertion*/) {}
inline
void Assert(bool /*assertion*/, const char * /*message*/) {}
#endif /* ENABLE_ASSERTIONS */ #endif /* ENABLE_ASSERTIONS */

View File

@ -317,8 +317,8 @@ bool LyXText::bidi_InRange(lyx::pos_type pos) const
} }
void LyXText::computeBidiTables(ParagraphList::iterator row_par, void LyXText::computeBidiTables(Buffer const * buf,
Buffer const * buf, RowList::iterator row) const RowList::iterator row) const
{ {
bidi_same_direction = true; bidi_same_direction = true;
if (!lyxrc.rtl_support) { if (!lyxrc.rtl_support) {
@ -326,6 +326,8 @@ void LyXText::computeBidiTables(ParagraphList::iterator row_par,
return; return;
} }
ParagraphList::iterator row_par = row->par();
InsetOld * inset = row_par->inInset(); InsetOld * inset = row_par->inInset();
if (inset && inset->owner() && if (inset && inset->owner() &&
inset->owner()->lyxCode() == InsetOld::ERT_CODE) { inset->owner()->lyxCode() == InsetOld::ERT_CODE) {
@ -334,7 +336,7 @@ void LyXText::computeBidiTables(ParagraphList::iterator row_par,
} }
bidi_start = row->pos(); bidi_start = row->pos();
bidi_end = lastPrintablePos(*this, row_par, row); bidi_end = lastPrintablePos(*this, row);
if (bidi_start > bidi_end) { if (bidi_start > bidi_end) {
bidi_start = -1; bidi_start = -1;
@ -479,19 +481,19 @@ bool LyXText::isBoundary(Buffer const * buf, Paragraph const & par,
} }
int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const int LyXText::leftMargin(Row const & row) const
{ {
InsetOld * ins; InsetOld * ins;
if (row.pos() < pit->size()) if (row.pos() < row.par()->size())
if (pit->getChar(row.pos()) == Paragraph::META_INSET && if (row.par()->getChar(row.pos()) == Paragraph::META_INSET &&
(ins = pit->getInset(row.pos())) && (ins = row.par()->getInset(row.pos())) &&
(ins->needFullRow() || ins->display())) (ins->needFullRow() || ins->display()))
return LEFT_MARGIN; return LEFT_MARGIN;
LyXTextClass const & tclass = LyXTextClass const & tclass =
bv()->buffer()->params.getLyXTextClass(); bv()->buffer()->params.getLyXTextClass();
LyXLayout_ptr const & layout = pit->layout(); LyXLayout_ptr const & layout = row.par()->layout();
string parindent = layout->parindent; string parindent = layout->parindent;
@ -502,14 +504,14 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
// this is the way, LyX handles the LaTeX-Environments. // this is the way, LyX handles the LaTeX-Environments.
// I have had this idea very late, so it seems to be a // I have had this idea very late, so it seems to be a
// later added hack and this is true // later added hack and this is true
if (!pit->getDepth()) { if (!row.par()->getDepth()) {
if (pit->layout() == tclass.defaultLayout()) { if (row.par()->layout() == tclass.defaultLayout()) {
// find the previous same level paragraph // find the previous same level paragraph
if (pit != ownerParagraphs().begin()) { if (row.par() != ownerParagraphs().begin()) {
ParagraphList::iterator newpit = ParagraphList::iterator newpit =
depthHook(pit, ownerParagraphs(), depthHook(row.par(), ownerParagraphs(),
pit->getDepth()); row.par()->getDepth());
if (newpit == pit && if (newpit == row.par() &&
newpit->layout()->nextnoindent) newpit->layout()->nextnoindent)
parindent.erase(); parindent.erase();
} }
@ -517,7 +519,7 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
} else { } else {
// find the next level paragraph // find the next level paragraph
ParagraphList::iterator newpar = outerHook(pit, ParagraphList::iterator newpar = outerHook(row.par(),
ownerParagraphs()); ownerParagraphs());
// make a corresponding row. Needed to call leftMargin() // make a corresponding row. Needed to call leftMargin()
@ -525,11 +527,14 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
// check wether it is a sufficent paragraph // check wether it is a sufficent paragraph
if (newpar != ownerParagraphs().end() && if (newpar != ownerParagraphs().end() &&
newpar->layout()->isEnvironment()) { newpar->layout()->isEnvironment()) {
x = leftMargin(newpar, Row(newpar->size())); Row dummyrow;
dummyrow.par(newpar);
dummyrow.pos(newpar->size());
x = leftMargin(dummyrow);
} }
if (newpar != ownerParagraphs().end() && if (newpar != ownerParagraphs().end() &&
pit->layout() == tclass.defaultLayout()) { row.par()->layout() == tclass.defaultLayout()) {
if (newpar->params().noindent()) if (newpar->params().noindent())
parindent.erase(); parindent.erase();
else { else {
@ -539,17 +544,17 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
} }
} }
LyXFont const labelfont = getLabelFont(pit); LyXFont const labelfont = getLabelFont(row.par());
switch (layout->margintype) { switch (layout->margintype) {
case MARGIN_DYNAMIC: case MARGIN_DYNAMIC:
if (!layout->leftmargin.empty()) { if (!layout->leftmargin.empty()) {
x += font_metrics::signedWidth(layout->leftmargin, x += font_metrics::signedWidth(layout->leftmargin,
tclass.defaultfont()); tclass.defaultfont());
} }
if (!pit->getLabelstring().empty()) { if (!row.par()->getLabelstring().empty()) {
x += font_metrics::signedWidth(layout->labelindent, x += font_metrics::signedWidth(layout->labelindent,
labelfont); labelfont);
x += font_metrics::width(pit->getLabelstring(), x += font_metrics::width(row.par()->getLabelstring(),
labelfont); labelfont);
x += font_metrics::width(layout->labelsep, labelfont); x += font_metrics::width(layout->labelsep, labelfont);
} }
@ -557,9 +562,9 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
case MARGIN_MANUAL: case MARGIN_MANUAL:
x += font_metrics::signedWidth(layout->labelindent, labelfont); x += font_metrics::signedWidth(layout->labelindent, labelfont);
// The width of an empty par, even with manual label, should be 0 // The width of an empty par, even with manual label, should be 0
if (!pit->empty() && row.pos() >= pit->beginningOfBody()) { if (!row.par()->empty() && row.pos() >= row.par()->beginningOfBody()) {
if (!pit->getLabelWidthString().empty()) { if (!row.par()->getLabelWidthString().empty()) {
x += font_metrics::width(pit->getLabelWidthString(), x += font_metrics::width(row.par()->getLabelWidthString(),
labelfont); labelfont);
x += font_metrics::width(layout->labelsep, labelfont); x += font_metrics::width(layout->labelsep, labelfont);
} }
@ -567,11 +572,11 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
break; break;
case MARGIN_STATIC: case MARGIN_STATIC:
x += font_metrics::signedWidth(layout->leftmargin, tclass.defaultfont()) * 4 x += font_metrics::signedWidth(layout->leftmargin, tclass.defaultfont()) * 4
/ (pit->getDepth() + 4); / (row.par()->getDepth() + 4);
break; break;
case MARGIN_FIRST_DYNAMIC: case MARGIN_FIRST_DYNAMIC:
if (layout->labeltype == LABEL_MANUAL) { if (layout->labeltype == LABEL_MANUAL) {
if (row.pos() >= pit->beginningOfBody()) { if (row.pos() >= row.par()->beginningOfBody()) {
x += font_metrics::signedWidth(layout->leftmargin, x += font_metrics::signedWidth(layout->leftmargin,
labelfont); labelfont);
} else { } else {
@ -583,7 +588,7 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
// theorems (JMarc) // theorems (JMarc)
|| (layout->labeltype == LABEL_STATIC || (layout->labeltype == LABEL_STATIC
&& layout->latextype == LATEX_ENVIRONMENT && layout->latextype == LATEX_ENVIRONMENT
&& !isFirstInSequence(pit, ownerParagraphs()))) { && !isFirstInSequence(row.par(), ownerParagraphs()))) {
x += font_metrics::signedWidth(layout->leftmargin, x += font_metrics::signedWidth(layout->leftmargin,
labelfont); labelfont);
} else if (layout->labeltype != LABEL_TOP_ENVIRONMENT } else if (layout->labeltype != LABEL_TOP_ENVIRONMENT
@ -593,7 +598,7 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
x += font_metrics::signedWidth(layout->labelindent, x += font_metrics::signedWidth(layout->labelindent,
labelfont); labelfont);
x += font_metrics::width(layout->labelsep, labelfont); x += font_metrics::width(layout->labelsep, labelfont);
x += font_metrics::width(pit->getLabelstring(), x += font_metrics::width(row.par()->getLabelstring(),
labelfont); labelfont);
} }
break; break;
@ -607,12 +612,12 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
// find the first row of this paragraph // find the first row of this paragraph
RowList::iterator tmprit = rowlist_.begin(); RowList::iterator tmprit = rowlist_.begin();
while (tmprit != rowlist_.end() while (tmprit != rowlist_.end()
&& getPar(tmprit) != pit) && tmprit->par() != row.par())
++tmprit; ++tmprit;
int minfill = tmprit->fill(); int minfill = tmprit->fill();
while (boost::next(tmprit) != rowlist_.end() && while (boost::next(tmprit) != rowlist_.end() &&
getPar(boost::next(tmprit)) == pit) { boost::next(tmprit)->par() == row.par()) {
++tmprit; ++tmprit;
if (tmprit->fill() < minfill) if (tmprit->fill() < minfill)
minfill = tmprit->fill(); minfill = tmprit->fill();
@ -625,8 +630,10 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
break; break;
} }
if (workWidth() > 0 && !pit->params().leftIndent().zero()) { if ((workWidth() > 0) &&
LyXLength const len = pit->params().leftIndent(); !row.par()->params().leftIndent().zero())
{
LyXLength const len = row.par()->params().leftIndent();
int const tw = inset_owner ? int const tw = inset_owner ?
inset_owner->latexTextWidth(bv()) : workWidth(); inset_owner->latexTextWidth(bv()) : workWidth();
x += len.inPixels(tw); x += len.inPixels(tw);
@ -634,10 +641,10 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
LyXAlignment align; LyXAlignment align;
if (pit->params().align() == LYX_ALIGN_LAYOUT) if (row.par()->params().align() == LYX_ALIGN_LAYOUT)
align = layout->align; align = layout->align;
else else
align = pit->params().align(); align = row.par()->params().align();
// set the correct parindent // set the correct parindent
if (row.pos() == 0) { if (row.pos() == 0) {
@ -646,14 +653,14 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
|| layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT || layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
|| (layout->labeltype == LABEL_STATIC || (layout->labeltype == LABEL_STATIC
&& layout->latextype == LATEX_ENVIRONMENT && layout->latextype == LATEX_ENVIRONMENT
&& !isFirstInSequence(pit, ownerParagraphs()))) && !isFirstInSequence(row.par(), ownerParagraphs())))
&& align == LYX_ALIGN_BLOCK && align == LYX_ALIGN_BLOCK
&& !pit->params().noindent() && !row.par()->params().noindent()
// in tabulars and ert paragraphs are never indented! // in tabulars and ert paragraphs are never indented!
&& (!pit->inInset() || !pit->inInset()->owner() || && (!row.par()->inInset() || !row.par()->inInset()->owner() ||
(pit->inInset()->owner()->lyxCode() != InsetOld::TABULAR_CODE && (row.par()->inInset()->owner()->lyxCode() != InsetOld::TABULAR_CODE &&
pit->inInset()->owner()->lyxCode() != InsetOld::ERT_CODE)) row.par()->inInset()->owner()->lyxCode() != InsetOld::ERT_CODE))
&& (pit->layout() != tclass.defaultLayout() || && (row.par()->layout() != tclass.defaultLayout() ||
bv()->buffer()->params.paragraph_separation == bv()->buffer()->params.paragraph_separation ==
BufferParams::PARSEP_INDENT)) { BufferParams::PARSEP_INDENT)) {
x += font_metrics::signedWidth(parindent, x += font_metrics::signedWidth(parindent,
@ -668,36 +675,35 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
} }
int LyXText::rightMargin(ParagraphList::iterator pit, int LyXText::rightMargin(Buffer const & buf, Row const & row) const
Buffer const & buf, Row const & row) const
{ {
InsetOld * ins; InsetOld * ins;
if (row.pos() < pit->size()) if (row.pos() < row.par()->size())
if ((pit->getChar(row.pos()) == Paragraph::META_INSET) && if ((row.par()->getChar(row.pos()) == Paragraph::META_INSET) &&
(ins = pit->getInset(row.pos())) && (ins = row.par()->getInset(row.pos())) &&
(ins->needFullRow() || ins->display())) (ins->needFullRow() || ins->display()))
return PAPER_MARGIN; return PAPER_MARGIN;
LyXTextClass const & tclass = buf.params.getLyXTextClass(); LyXTextClass const & tclass = buf.params.getLyXTextClass();
LyXLayout_ptr const & layout = pit->layout(); LyXLayout_ptr const & layout = row.par()->layout();
return PAPER_MARGIN return PAPER_MARGIN
+ font_metrics::signedWidth(tclass.rightmargin(), + font_metrics::signedWidth(tclass.rightmargin(),
tclass.defaultfont()); tclass.defaultfont());
+ font_metrics::signedWidth(layout->rightmargin, + font_metrics::signedWidth(layout->rightmargin,
tclass.defaultfont()) tclass.defaultfont())
* 4 / (pit->getDepth() + 4); * 4 / (row.par()->getDepth() + 4);
} }
int LyXText::labelEnd(ParagraphList::iterator pit, Row const & row) const int LyXText::labelEnd(Row const & row) const
{ {
if (pit->layout()->margintype == MARGIN_MANUAL) { if (row.par()->layout()->margintype == MARGIN_MANUAL) {
Row tmprow = row; Row tmprow = row;
tmprow.pos(pit->size()); tmprow.pos(row.par()->size());
// return the beginning of the body // return the beginning of the body
return leftMargin(pit, tmprow); return leftMargin(tmprow);
} }
// LabelEnd is only needed if the layout // LabelEnd is only needed if the layout
@ -722,11 +728,12 @@ pos_type addressBreakPoint(pos_type i, Paragraph const & par)
}; };
pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit, pos_type LyXText::rowBreakPoint(Row const & row) const
Row const & row) const
{ {
ParagraphList::iterator pit = row.par();
// maximum pixel width of a row. // maximum pixel width of a row.
int width = workWidth() - rightMargin(pit, *bv()->buffer(), row); int width = workWidth() - rightMargin(*bv()->buffer(), row);
// inset->textWidth() returns -1 via workWidth(), // inset->textWidth() returns -1 via workWidth(),
// but why ? // but why ?
@ -750,7 +757,7 @@ pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit,
// or the end of the par, then choose the possible break // or the end of the par, then choose the possible break
// nearest that. // nearest that.
int const left = leftMargin(pit, row); int const left = leftMargin(row);
int x = left; int x = left;
// pixel width since last breakpoint // pixel width since last breakpoint
@ -778,7 +785,7 @@ pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit,
thiswidth = font_metrics::width(layout->labelsep, getLabelFont(pit)); thiswidth = font_metrics::width(layout->labelsep, getLabelFont(pit));
if (pit->isLineSeparator(i - 1)) if (pit->isLineSeparator(i - 1))
thiswidth -= singleWidth(pit, i - 1); thiswidth -= singleWidth(pit, i - 1);
int left_margin = labelEnd(pit, row); int left_margin = labelEnd(row);
if (thiswidth + x < left_margin) if (thiswidth + x < left_margin)
thiswidth = left_margin - x; thiswidth = left_margin - x;
thiswidth += singleWidth(pit, i, c); thiswidth += singleWidth(pit, i, c);
@ -882,19 +889,19 @@ int LyXText::fill(RowList::iterator row, int paper_width) const
int w; int w;
// get the pure distance // get the pure distance
ParagraphList::iterator pit = getPar(row); pos_type const last = lastPrintablePos(*this, row);
pos_type const last = lastPrintablePos(*this, pit, row);
ParagraphList::iterator pit = row->par();
LyXLayout_ptr const & layout = pit->layout(); LyXLayout_ptr const & layout = pit->layout();
// special handling of the right address boxes // special handling of the right address boxes
if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) { if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
int const tmpfill = row->fill(); int const tmpfill = row->fill();
row->fill(0); // the minfill in MarginLeft() row->fill(0); // the minfill in MarginLeft()
w = leftMargin(pit, *row); w = leftMargin(*row);
row->fill(tmpfill); row->fill(tmpfill);
} else } else
w = leftMargin(pit, *row); w = leftMargin(*row);
pos_type const body_pos = pit->beginningOfBody(); pos_type const body_pos = pit->beginningOfBody();
pos_type i = row->pos(); pos_type i = row->pos();
@ -908,7 +915,7 @@ int LyXText::fill(RowList::iterator row, int paper_width) const
w += font_metrics::width(layout->labelsep, getLabelFont(pit)); w += font_metrics::width(layout->labelsep, getLabelFont(pit));
if (pit->isLineSeparator(i - 1)) if (pit->isLineSeparator(i - 1))
w -= singleWidth(pit, i - 1); w -= singleWidth(pit, i - 1);
int left_margin = labelEnd(pit, *row); int left_margin = labelEnd(*row);
if (w < left_margin) if (w < left_margin)
w = left_margin; w = left_margin;
} }
@ -943,12 +950,12 @@ int LyXText::fill(RowList::iterator row, int paper_width) const
w += font_metrics::width(layout->labelsep, getLabelFont(pit)); w += font_metrics::width(layout->labelsep, getLabelFont(pit));
if (last >= 0 && pit->isLineSeparator(last)) if (last >= 0 && pit->isLineSeparator(last))
w -= singleWidth(pit, last); w -= singleWidth(pit, last);
int const left_margin = labelEnd(pit, *row); int const left_margin = labelEnd(*row);
if (w < left_margin) if (w < left_margin)
w = left_margin; w = left_margin;
} }
int const fill = paper_width - w - rightMargin(pit, *bv()->buffer(), *row); int const fill = paper_width - w - rightMargin(*bv()->buffer(), *row);
// If this case happens, it means that our calculation // If this case happens, it means that our calculation
// of the widths of the chars when we do rowBreakPoint() // of the widths of the chars when we do rowBreakPoint()
@ -960,15 +967,17 @@ int LyXText::fill(RowList::iterator row, int paper_width) const
if (lyxerr.debugging() && fill < 0) { if (lyxerr.debugging() && fill < 0) {
lyxerr[Debug::GUI] << "Eek, fill() was < 0: " << fill lyxerr[Debug::GUI] << "Eek, fill() was < 0: " << fill
<< " w " << w << " paper_width " << paper_width << " w " << w << " paper_width " << paper_width
<< " right margin " << rightMargin(pit, *bv()->buffer(), *row) << endl; << " right margin " << rightMargin(*bv()->buffer(), *row) << endl;
} }
return fill; return fill;
} }
// returns the minimum space a manual label needs on the screen in pixel // returns the minimum space a manual label needs on the screen in pixel
int LyXText::labelFill(ParagraphList::iterator pit, Row const & row) const int LyXText::labelFill(Row const & row) const
{ {
ParagraphList::iterator pit = row.par();
pos_type last = pit->beginningOfBody(); pos_type last = pit->beginningOfBody();
Assert(last > 0); Assert(last > 0);
@ -1021,7 +1030,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
// ok, let us initialize the maxasc and maxdesc value. // ok, let us initialize the maxasc and maxdesc value.
// Only the fontsize count. The other properties // Only the fontsize count. The other properties
// are taken from the layoutfont. Nicer on the screen :) // are taken from the layoutfont. Nicer on the screen :)
ParagraphList::iterator pit = getPar(rit); ParagraphList::iterator pit = rit->par();
LyXLayout_ptr const & layout = pit->layout(); LyXLayout_ptr const & layout = pit->layout();
@ -1048,7 +1057,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
int maxdesc = int(font_metrics::maxDescent(font) * int maxdesc = int(font_metrics::maxDescent(font) *
layout->spacing.getValue() * spacing_val); layout->spacing.getValue() * spacing_val);
pos_type const pos_end = lastPos(*this, pit, rit); pos_type const pos_end = lastPos(*this, rit);
int labeladdon = 0; int labeladdon = 0;
int maxwidth = 0; int maxwidth = 0;
@ -1227,9 +1236,8 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
} else if (rit != rows().begin()) { } else if (rit != rows().begin()) {
tmptop = layout->topsep; tmptop = layout->topsep;
if (boost::prior(pit)->getDepth() >= pit->getDepth()) { if (boost::prior(pit)->getDepth() >= pit->getDepth())
tmptop -= getPar(boost::prior(rit))->layout()->bottomsep; tmptop -= boost::prior(rit)->par()->layout()->bottomsep;
}
if (tmptop > 0) if (tmptop > 0)
layoutasc = (tmptop * defaultRowHeight()); layoutasc = (tmptop * defaultRowHeight());
@ -1255,7 +1263,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
// is it a bottom line? // is it a bottom line?
RowList::iterator next_rit = boost::next(rit); RowList::iterator next_rit = boost::next(rit);
if (next_rit == rows().end() || getPar(next_rit) != pit) { if (next_rit == rows().end() || next_rit->par() != pit) {
// the bottom margin // the bottom margin
ParagraphList::iterator nextpit = boost::next(pit); ParagraphList::iterator nextpit = boost::next(pit);
if (nextpit == ownerParagraphs().end() && if (nextpit == ownerParagraphs().end() &&
@ -1326,7 +1334,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
// this IS needed // this IS needed
rit->width(maxwidth); rit->width(maxwidth);
double dummy; double dummy;
prepareToPrint(pit, rit, x, dummy, dummy, dummy, false); prepareToPrint(rit, x, dummy, dummy, dummy, false);
} }
rit->width(int(maxwidth + x)); rit->width(int(maxwidth + x));
if (inset_owner) { if (inset_owner) {
@ -1395,13 +1403,18 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
// This touches only the screen-update. Otherwise we would may have // This touches only the screen-update. Otherwise we would may have
// an empty row on the screen // an empty row on the screen
if (cursor.pos() && cursorRow()->pos() == cursor.pos() if (cursor.pos() && cursorRow()->pos() == cursor.pos()
&& !cursor.par()->isNewline(cursor.pos() - 1)) && !cursorRow()->par()->isNewline(cursor.pos() - 1))
{ {
cursorLeft(bv()); cursorLeft(bv());
} }
removeParagraph(cursorRow()); removeParagraph(cursorRow());
// set the dimensions of the cursor row
cursorRow()->fill(fill(cursorRow(), workWidth()));
setHeightOfRow(cursorRow());
#warning Trouble Point! (Lgb) #warning Trouble Point! (Lgb)
// When ::breakParagraph is called from within an inset we must // When ::breakParagraph is called from within an inset we must
// ensure that the correct ParagraphList is used. Today that is not // ensure that the correct ParagraphList is used. Today that is not
@ -1425,7 +1438,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
} }
// convenience function // Just a macro to make some thing easier.
void LyXText::redoParagraph() void LyXText::redoParagraph()
{ {
clearSelection(); clearSelection();
@ -1443,8 +1456,8 @@ void LyXText::insertChar(char c)
// When the free-spacing option is set for the current layout, // When the free-spacing option is set for the current layout,
// disable the double-space checking // disable the double-space checking
bool const freeSpacing = cursor.par()->layout()->free_spacing || bool const freeSpacing = cursorRow()->par()->layout()->free_spacing ||
cursor.par()->isFreeSpacing(); cursorRow()->par()->isFreeSpacing();
if (lyxrc.auto_number) { if (lyxrc.auto_number) {
static string const number_operators = "+-/*"; static string const number_operators = "+-/*";
@ -1554,8 +1567,7 @@ void LyXText::charInserted()
} }
void LyXText::prepareToPrint(ParagraphList::iterator pit, void LyXText::prepareToPrint(RowList::iterator rit, double & x,
RowList::iterator rit, double & x,
double & fill_separator, double & fill_separator,
double & fill_hfill, double & fill_hfill,
double & fill_label_hfill, double & fill_label_hfill,
@ -1567,12 +1579,14 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
fill_separator = 0; fill_separator = 0;
fill_label_hfill = 0; fill_label_hfill = 0;
ParagraphList::iterator pit = rit->par();
bool const is_rtl = bool const is_rtl =
pit->isRightToLeftPar(bv()->buffer()->params); pit->isRightToLeftPar(bv()->buffer()->params);
if (is_rtl) if (is_rtl)
x = workWidth() > 0 ? rightMargin(pit, *bv()->buffer(), *rit) : 0; x = workWidth() > 0 ? rightMargin(*bv()->buffer(), *rit) : 0;
else else
x = workWidth() > 0 ? leftMargin(pit, *rit) : 0; x = workWidth() > 0 ? leftMargin(*rit) : 0;
// is there a manual margin with a manual label // is there a manual margin with a manual label
LyXLayout_ptr const & layout = pit->layout(); LyXLayout_ptr const & layout = pit->layout();
@ -1580,7 +1594,7 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
if (layout->margintype == MARGIN_MANUAL if (layout->margintype == MARGIN_MANUAL
&& layout->labeltype == LABEL_MANUAL) { && layout->labeltype == LABEL_MANUAL) {
/// We might have real hfills in the label part /// We might have real hfills in the label part
int nlh = numberOfLabelHfills(*this, pit, rit); int nlh = numberOfLabelHfills(*this, rit);
// A manual label par (e.g. List) has an auto-hfill // A manual label par (e.g. List) has an auto-hfill
// between the label text and the body of the // between the label text and the body of the
@ -1591,12 +1605,12 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
++nlh; ++nlh;
if (nlh && !pit->getLabelWidthString().empty()) { if (nlh && !pit->getLabelWidthString().empty()) {
fill_label_hfill = labelFill(pit, *rit) / double(nlh); fill_label_hfill = labelFill(*rit) / double(nlh);
} }
} }
// are there any hfills in the row? // are there any hfills in the row?
int const nh = numberOfHfills(*this, pit, rit); int const nh = numberOfHfills(*this, rit);
if (nh) { if (nh) {
if (w > 0) if (w > 0)
@ -1633,12 +1647,12 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
switch (align) { switch (align) {
case LYX_ALIGN_BLOCK: case LYX_ALIGN_BLOCK:
{ {
int const ns = numberOfSeparators(*this, pit, rit); int const ns = numberOfSeparators(*this, rit);
RowList::iterator next_row = boost::next(rit); RowList::iterator next_row = boost::next(rit);
ParagraphList::iterator next_pit; ParagraphList::iterator next_pit = next_row->par();
if (ns && next_row != rowlist_.end() && if (ns && next_row != rowlist_.end() &&
(next_pit = getPar(next_row)) == pit && next_pit == pit &&
!(next_pit->isNewline(next_row->pos() - 1)) !(next_pit->isNewline(next_row->pos() - 1))
&& !(next_pit->isInset(next_row->pos()) && && !(next_pit->isInset(next_row->pos()) &&
next_pit->getInset(next_row->pos()) && next_pit->getInset(next_row->pos()) &&
@ -1661,10 +1675,10 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
if (!bidi) if (!bidi)
return; return;
computeBidiTables(pit, bv()->buffer(), rit); computeBidiTables(bv()->buffer(), rit);
if (is_rtl) { if (is_rtl) {
pos_type body_pos = pit->beginningOfBody(); pos_type body_pos = pit->beginningOfBody();
pos_type last = lastPos(*this, pit, rit); pos_type last = lastPos(*this, rit);
if (body_pos > 0 && if (body_pos > 0 &&
(body_pos - 1 > last || (body_pos - 1 > last ||
@ -1878,7 +1892,7 @@ void LyXText::selectSelectedWord()
// now find the end of the word // now find the end of the word
while (cursor.pos() < cursor.par()->size() while (cursor.pos() < cursor.par()->size()
&& cursor.par()->isLetter(cursor.pos())) && (cursor.par()->isLetter(cursor.pos())))
cursor.pos(cursor.pos() + 1); cursor.pos(cursor.pos() + 1);
setCursor(cursor.par(), cursor.pos()); setCursor(cursor.par(), cursor.pos());
@ -2167,14 +2181,14 @@ LyXText::getRow(ParagraphList::iterator pit, pos_type pos) const
// find the first row of the specified paragraph // find the first row of the specified paragraph
RowList::iterator rit = rowlist_.begin(); RowList::iterator rit = rowlist_.begin();
RowList::iterator end = rowlist_.end(); RowList::iterator end = rowlist_.end();
while (boost::next(rit) != end && getPar(rit) != pit) { while (boost::next(rit) != end && rit->par() != pit) {
++rit; ++rit;
} }
// now find the wanted row // now find the wanted row
while (rit->pos() < pos while (rit->pos() < pos
&& boost::next(rit) != end && boost::next(rit) != end
&& getPar(boost::next(rit)) == pit && boost::next(rit)->par() == pit
&& boost::next(rit)->pos() <= pos) { && boost::next(rit)->pos() <= pos) {
++rit; ++rit;
} }
@ -2195,7 +2209,7 @@ LyXText::getRow(ParagraphList::iterator pit, pos_type pos, int & y) const
// find the first row of the specified paragraph // find the first row of the specified paragraph
RowList::iterator rit = rowlist_.begin(); RowList::iterator rit = rowlist_.begin();
RowList::iterator end = rowlist_.end(); RowList::iterator end = rowlist_.end();
while (boost::next(rit) != end && getPar(rit) != pit) { while (boost::next(rit) != end && rit->par() != pit) {
y += rit->height(); y += rit->height();
++rit; ++rit;
} }
@ -2203,7 +2217,7 @@ LyXText::getRow(ParagraphList::iterator pit, pos_type pos, int & y) const
// now find the wanted row // now find the wanted row
while (rit->pos() < pos while (rit->pos() < pos
&& boost::next(rit) != end && boost::next(rit) != end
&& getPar(boost::next(rit)) == pit && boost::next(rit)->par() == pit
&& boost::next(rit)->pos() <= pos) { && boost::next(rit)->pos() <= pos) {
y += rit->height(); y += rit->height();
++rit; ++rit;
@ -2267,68 +2281,3 @@ int LyXText::getDepth() const
{ {
return cursor.par()->getDepth(); return cursor.par()->getDepth();
} }
#warning Expensive. Remove before 1.4!
// computes a ParagraphList::iterator from RowList::iterator by
// counting zeros in the sequence of pos values.
ParagraphList::iterator LyXText::getPar(RowList::iterator row) const
{
if (row == rows().end()) {
lyxerr << "getPar() pit at end " << endl;
Assert(false);
}
if (row == rows().begin()) {
return ownerParagraphs().begin();
}
ParagraphList::iterator pit = ownerParagraphs().begin();
RowList::iterator rit = rows().begin();
RowList::iterator rend = rows().end();
for (++rit ; rit != rend; ++rit) {
if (rit->pos() == 0) {
++pit;
if (pit == ownerParagraphs().end()) {
lyxerr << "unexpected in LyXText::getPar()" << endl;
Assert(false);
}
}
if (rit == row) {
return pit;
}
}
lyxerr << "LyXText::getPar: row not found " << endl;
Assert(false);
return ownerParagraphs().end(); // shut up compiler
}
RowList::iterator LyXText::beginRow(ParagraphList::iterator pit) const
{
int n = std::distance(ownerParagraphs().begin(), pit);
RowList::iterator rit = rows().begin();
RowList::iterator end = rows().end();
for ( ; rit != end; ++rit)
if (rit->pos() == 0 && n-- == 0)
return rit;
return rit;
}
RowList::iterator LyXText::endRow(ParagraphList::iterator pit) const
{
return beginRow(boost::next(pit));
}
RowList::iterator LyXText::endRow(RowList::iterator rit) const
{
for (++rit; rit != rows().end() && rit->pos(); ++rit)
;
return rit;
}

View File

@ -89,7 +89,8 @@ void LyXText::init(BufferView * bview)
current_font = getFont(ownerParagraphs().begin(), 0); current_font = getFont(ownerParagraphs().begin(), 0);
redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end()); redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
setCursorIntern(ownerParagraphs().begin(), 0);
setCursorIntern(rowlist_.begin()->par(), 0);
selection.cursor = cursor; selection.cursor = cursor;
updateCounters(); updateCounters();
@ -263,10 +264,10 @@ void LyXText::removeRow(RowList::iterator rit)
// remove all following rows of the paragraph of the specified row. // remove all following rows of the paragraph of the specified row.
void LyXText::removeParagraph(RowList::iterator rit) void LyXText::removeParagraph(RowList::iterator rit)
{ {
ParagraphList::iterator tmppit = getPar(rit); ParagraphList::iterator tmppit = rit->par();
++rit; ++rit;
while (rit != rows().end() && getPar(rit) == tmppit) { while (rit != rows().end() && rit->par() == tmppit) {
RowList::iterator tmprit = boost::next(rit); RowList::iterator tmprit = boost::next(rit);
removeRow(rit); removeRow(rit);
rit = tmprit; rit = tmprit;
@ -278,21 +279,23 @@ void LyXText::insertParagraph(ParagraphList::iterator pit,
RowList::iterator rit) RowList::iterator rit)
{ {
// insert a new row, starting at position 0 // insert a new row, starting at position 0
rit = rowlist_.insert(rit, Row(0)); rit = rowlist_.insert(rit, Row(pit, 0));
// and now append the whole paragraph before the new row // and now append the whole paragraph before the new row
Assert(rit != rowlist_.end());
pos_type const last = pit->size(); pos_type const last = rit->par()->size();
bool done = false; bool done = false;
do { do {
pos_type z = rowBreakPoint(pit, *rit); pos_type z = rowBreakPoint(*rit);
RowList::iterator tmprow = rit; RowList::iterator tmprow = rit;
if (z < last) { if (z < last) {
++z; ++z;
rit = rowlist_.insert(boost::next(rit), Row(z)); Row newrow(rit->par(), z);
rit = rowlist_.insert(boost::next(rit), newrow);
} else { } else {
done = true; done = true;
} }
@ -606,6 +609,16 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
} }
RowList::iterator LyXText::firstRow(ParagraphList::iterator pit)
{
RowList::iterator rit;
for (rit = rows().begin(); rit != rows().end(); ++rit)
if (rit->par() == pit)
break;
return rit;
}
// rebreaks all paragraphs between the specified pars // rebreaks all paragraphs between the specified pars
// This function is needed after SetLayout and SetFont etc. // This function is needed after SetLayout and SetFont etc.
void LyXText::redoParagraphs(ParagraphList::iterator start, void LyXText::redoParagraphs(ParagraphList::iterator start,
@ -618,18 +631,19 @@ void LyXText::redoParagraphs(ParagraphList::iterator start,
void LyXText::redoParagraph(ParagraphList::iterator pit) void LyXText::redoParagraph(ParagraphList::iterator pit)
{ {
RowList::iterator first = beginRow(pit); RowList::iterator rit = firstRow(pit);
RowList::iterator last = endRow(first);
// remove paragraph from rowlist // remove paragraph from rowlist
while (first != last) { while (rit != rows().end() && rit->par() == pit) {
RowList::iterator rit2 = first; RowList::iterator rit2 = rit++;
++first;
removeRow(rit2); removeRow(rit2);
} }
// reinsert the paragraph // reinsert the paragraph
insertParagraph(pit, last); insertParagraph(pit, rit);
// why?
setHeightOfRow(rows().begin());
} }
@ -716,10 +730,10 @@ void LyXText::cursorEnd()
RowList::iterator rit = cursorRow(); RowList::iterator rit = cursorRow();
RowList::iterator next_rit = boost::next(rit); RowList::iterator next_rit = boost::next(rit);
ParagraphList::iterator pit = cursor.par(); ParagraphList::iterator pit = rit->par();
pos_type last_pos = lastPos(*this, pit, rit); pos_type last_pos = lastPos(*this, rit);
if (next_rit == rows().end() || getPar(next_rit) != pit) { if (next_rit == rows().end() || next_rit->par() != pit) {
++last_pos; ++last_pos;
} else { } else {
if (pit->empty() || if (pit->empty() ||
@ -1406,7 +1420,7 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
cur.iy(y + row->baseline()); cur.iy(y + row->baseline());
if (row != beg && if (row != beg &&
pos && pos &&
getPar(boost::prior(row)) == getPar(row) && boost::prior(row)->par() == row->par() &&
pos < pit->size() && pos < pit->size() &&
pit->getChar(pos) == Paragraph::META_INSET) { pit->getChar(pos) == Paragraph::META_INSET) {
InsetOld * ins = pit->getInset(pos); InsetOld * ins = pit->getInset(pos);
@ -1421,7 +1435,7 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
// y is now the cursor baseline // y is now the cursor baseline
cur.y(y); cur.y(y);
pos_type last = lastPrintablePos(*this, pit, old_row); pos_type last = lastPrintablePos(*this, old_row);
// None of these should happen, but we're scaredy-cats // None of these should happen, but we're scaredy-cats
if (pos > pit->size()) { if (pos > pit->size()) {
@ -1440,11 +1454,11 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
} }
// now get the cursors x position // now get the cursors x position
float x = getCursorX(pit, row, pos, last, boundary); float x = getCursorX(row, pos, last, boundary);
cur.x(int(x)); cur.x(int(x));
cur.x_fix(cur.x()); cur.x_fix(cur.x());
if (old_row != row) { if (old_row != row) {
x = getCursorX(pit, old_row, pos, last, boundary); x = getCursorX(old_row, pos, last, boundary);
cur.ix(int(x)); cur.ix(int(x));
} else } else
cur.ix(cur.x()); cur.ix(cur.x());
@ -1462,7 +1476,7 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
} }
float LyXText::getCursorX(ParagraphList::iterator pit, RowList::iterator rit, float LyXText::getCursorX(RowList::iterator rit,
pos_type pos, pos_type last, bool boundary) const pos_type pos, pos_type last, bool boundary) const
{ {
pos_type cursor_vpos = 0; pos_type cursor_vpos = 0;
@ -1471,15 +1485,16 @@ float LyXText::getCursorX(ParagraphList::iterator pit, RowList::iterator rit,
double fill_hfill; double fill_hfill;
double fill_label_hfill; double fill_label_hfill;
// This call HAS to be here because of the BidiTables!!! // This call HAS to be here because of the BidiTables!!!
prepareToPrint(pit, rit, x, fill_separator, fill_hfill, prepareToPrint(rit, x, fill_separator, fill_hfill,
fill_label_hfill); fill_label_hfill);
ParagraphList::iterator rit_par = rit->par();
pos_type const rit_pos = rit->pos(); pos_type const rit_pos = rit->pos();
if (last < rit_pos) if (last < rit_pos)
cursor_vpos = rit_pos; cursor_vpos = rit_pos;
else if (pos > last && !boundary) else if (pos > last && !boundary)
cursor_vpos = (pit->isRightToLeftPar(bv()->buffer()->params)) cursor_vpos = (rit_par->isRightToLeftPar(bv()->buffer()->params))
? rit_pos : last + 1; ? rit_pos : last + 1;
else if (pos > rit_pos && (pos > last || boundary)) else if (pos > rit_pos && (pos > last || boundary))
// Place cursor after char at (logical) position pos - 1 // Place cursor after char at (logical) position pos - 1
@ -1490,9 +1505,9 @@ float LyXText::getCursorX(ParagraphList::iterator pit, RowList::iterator rit,
cursor_vpos = (bidi_level(pos) % 2 == 0) cursor_vpos = (bidi_level(pos) % 2 == 0)
? log2vis(pos) : log2vis(pos) + 1; ? log2vis(pos) : log2vis(pos) + 1;
pos_type body_pos = pit->beginningOfBody(); pos_type body_pos = rit_par->beginningOfBody();
if (body_pos > 0 && if (body_pos > 0 &&
(body_pos - 1 > last || !pit->isLineSeparator(body_pos - 1))) (body_pos - 1 > last || !rit_par->isLineSeparator(body_pos - 1)))
body_pos = 0; body_pos = 0;
for (pos_type vpos = rit_pos; vpos < cursor_vpos; ++vpos) { for (pos_type vpos = rit_pos; vpos < cursor_vpos; ++vpos) {
@ -1500,23 +1515,23 @@ float LyXText::getCursorX(ParagraphList::iterator pit, RowList::iterator rit,
if (body_pos > 0 && pos == body_pos - 1) { if (body_pos > 0 && pos == body_pos - 1) {
x += fill_label_hfill + x += fill_label_hfill +
font_metrics::width( font_metrics::width(
pit->layout()->labelsep, getLabelFont(pit)); rit_par->layout()->labelsep, getLabelFont(rit_par));
if (pit->isLineSeparator(body_pos - 1)) if (rit_par->isLineSeparator(body_pos - 1))
x -= singleWidth(pit, body_pos - 1); x -= singleWidth(rit_par, body_pos - 1);
} }
if (hfillExpansion(*this, pit, rit, pos)) { if (hfillExpansion(*this, rit, pos)) {
x += singleWidth(pit, pos); x += singleWidth(rit_par, pos);
if (pos >= body_pos) if (pos >= body_pos)
x += fill_hfill; x += fill_hfill;
else else
x += fill_label_hfill; x += fill_label_hfill;
} else if (pit->isSeparator(pos)) { } else if (rit_par->isSeparator(pos)) {
x += singleWidth(pit, pos); x += singleWidth(rit_par, pos);
if (pos >= body_pos) if (pos >= body_pos)
x += fill_separator; x += fill_separator;
} else } else
x += singleWidth(pit, pos); x += singleWidth(rit_par, pos);
} }
return x; return x;
} }
@ -1571,33 +1586,35 @@ void LyXText::setCurrentFont()
// returns the column near the specified x-coordinate of the row // returns the column near the specified x-coordinate of the row
// x is set to the real beginning of this column // x is set to the real beginning of this column
pos_type LyXText::getColumnNearX(ParagraphList::iterator pit, pos_type
RowList::iterator rit, int & x, bool & boundary) const LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
{ {
double tmpx = 0; double tmpx = 0;
double fill_separator; double fill_separator;
double fill_hfill; double fill_hfill;
double fill_label_hfill; double fill_label_hfill;
prepareToPrint(pit, rit, tmpx, fill_separator, fill_hfill, fill_label_hfill); prepareToPrint(rit, tmpx, fill_separator, fill_hfill, fill_label_hfill);
pos_type vc = rit->pos(); pos_type vc = rit->pos();
pos_type last = lastPrintablePos(*this, pit, rit); pos_type last = lastPrintablePos(*this, rit);
pos_type c = 0; pos_type c = 0;
LyXLayout_ptr const & layout = pit->layout();
ParagraphList::iterator rit_par = rit->par();
LyXLayout_ptr const & layout = rit->par()->layout();
bool left_side = false; bool left_side = false;
pos_type body_pos = pit->beginningOfBody(); pos_type body_pos = rit_par->beginningOfBody();
double last_tmpx = tmpx; double last_tmpx = tmpx;
if (body_pos > 0 && if (body_pos > 0 &&
(body_pos - 1 > last || (body_pos - 1 > last ||
!pit->isLineSeparator(body_pos - 1))) !rit_par->isLineSeparator(body_pos - 1)))
body_pos = 0; body_pos = 0;
// check for empty row // check for empty row
if (!pit->size()) { if (!rit_par->size()) {
x = int(tmpx); x = int(tmpx);
return 0; return 0;
} }
@ -1607,23 +1624,23 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
last_tmpx = tmpx; last_tmpx = tmpx;
if (body_pos > 0 && c == body_pos - 1) { if (body_pos > 0 && c == body_pos - 1) {
tmpx += fill_label_hfill + tmpx += fill_label_hfill +
font_metrics::width(layout->labelsep, getLabelFont(pit)); font_metrics::width(layout->labelsep, getLabelFont(rit_par));
if (pit->isLineSeparator(body_pos - 1)) if (rit_par->isLineSeparator(body_pos - 1))
tmpx -= singleWidth(pit, body_pos - 1); tmpx -= singleWidth(rit_par, body_pos - 1);
} }
if (hfillExpansion(*this, pit, rit, c)) { if (hfillExpansion(*this, rit, c)) {
tmpx += singleWidth(pit, c); tmpx += singleWidth(rit_par, c);
if (c >= body_pos) if (c >= body_pos)
tmpx += fill_hfill; tmpx += fill_hfill;
else else
tmpx += fill_label_hfill; tmpx += fill_label_hfill;
} else if (pit->isSeparator(c)) { } else if (rit_par->isSeparator(c)) {
tmpx += singleWidth(pit, c); tmpx += singleWidth(rit_par, c);
if (c >= body_pos) if (c >= body_pos)
tmpx += fill_separator; tmpx += fill_separator;
} else { } else {
tmpx += singleWidth(pit, c); tmpx += singleWidth(rit_par, c);
} }
++vc; ++vc;
} }
@ -1642,12 +1659,13 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
RowList::iterator next_rit = boost::next(rit); RowList::iterator next_rit = boost::next(rit);
bool const lastrow = lyxrc.rtl_support && bool const lastrow = lyxrc.rtl_support &&
(next_rit == rowlist_.end() || getPar(next_rit) != pit); (next_rit == rowlist_.end() ||
next_rit->par() != rit_par);
// If lastrow is false, we don't need to compute // If lastrow is false, we don't need to compute
// the value of rtl. // the value of rtl.
bool const rtl = (lastrow) bool const rtl = (lastrow)
? pit->isRightToLeftPar(bv()->buffer()->params) ? rit_par->isRightToLeftPar(bv()->buffer()->params)
: false; : false;
if (lastrow && if (lastrow &&
((rtl && left_side && vc == rit->pos() && x < tmpx - 5) || ((rtl && left_side && vc == rit->pos() && x < tmpx - 5) ||
@ -1662,15 +1680,16 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
bool const rtl = (bidi_level(c) % 2 == 1); bool const rtl = (bidi_level(c) % 2 == 1);
if (left_side == rtl) { if (left_side == rtl) {
++c; ++c;
boundary = isBoundary(bv()->buffer(), *pit, c); boundary = isBoundary(bv()->buffer(), *rit_par, c);
} }
} }
if (rit->pos() <= last && c > last && pit->isNewline(last)) { if (rit->pos() <= last && c > last
&& rit_par->isNewline(last)) {
if (bidi_level(last) % 2 == 0) if (bidi_level(last) % 2 == 0)
tmpx -= singleWidth(pit, last); tmpx -= singleWidth(rit_par, last);
else else
tmpx += singleWidth(pit, last); tmpx += singleWidth(rit_par, last);
c = last; c = last;
} }
@ -1703,9 +1722,9 @@ namespace {
if (boost::next(row) == lt.rows().end()) if (boost::next(row) == lt.rows().end())
return false; return false;
RowList::iterator next = boost::next(row); Row const & next = *boost::next(row);
if (next->pos() != cur.pos() || lt.getPar(next) != cur.par()) if (next.pos() != cur.pos() || next.par() != cur.par())
return false; return false;
if (cur.pos() == cur.par()->size() if (cur.pos() == cur.par()->size()
@ -1726,18 +1745,19 @@ void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y)
// Get the row first. // Get the row first.
RowList::iterator row = getRowNearY(y); RowList::iterator row = getRowNearY(y);
ParagraphList::iterator pit = getPar(row);
bool bound = false; bool bound = false;
pos_type const column = getColumnNearX(pit, row, x, bound); pos_type const column = getColumnNearX(row, x, bound);
cur.par(pit); cur.par(row->par());
cur.pos(row->pos() + column); cur.pos(row->pos() + column);
cur.x(x); cur.x(x);
cur.y(y + row->baseline()); cur.y(y + row->baseline());
if (beforeFullRowInset(*this, cur)) { if (beforeFullRowInset(*this, cur)) {
pos_type const last = lastPrintablePos(*this, pit, row); pos_type const last = lastPrintablePos(*this, row);
RowList::iterator next_row = boost::next(row); RowList::iterator next_row = boost::next(row);
cur.ix(int(getCursorX(pit, next_row, cur.pos(), last, bound)));
float x = getCursorX(next_row, cur.pos(), last, bound);
cur.ix(int(x));
cur.iy(y + row->height() + next_row->baseline()); cur.iy(y + row->height() + next_row->baseline());
} else { } else {
cur.iy(cur.y()); cur.iy(cur.y());
@ -1991,7 +2011,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
* there is another layout before */ * there is another layout before */
RowList::iterator tmprit = boost::next(prevrow); RowList::iterator tmprit = boost::next(prevrow);
if (tmprit != rows().end()) { if (tmprit != rows().end()) {
redoParagraph(getPar(tmprit)); redoParagraph(tmprit->par());
updateCounters(); updateCounters();
} }
setHeightOfRow(prevrow); setHeightOfRow(prevrow);
@ -2020,7 +2040,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
The next row can change its height, if The next row can change its height, if
there is another layout before */ there is another layout before */
if (nextrow != rows().end()) { if (nextrow != rows().end()) {
redoParagraph(getPar(nextrow)); redoParagraph(nextrow->par());
updateCounters(); updateCounters();
} }
} }

View File

@ -275,7 +275,7 @@ void LyXText::cursorPrevious()
//bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y); //bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y);
if (cursorRow() != rows().begin()) { if (cursorRow() != rows().begin()) {
LyXCursor cur; LyXCursor cur;
setCursor(cur, getPar(boost::prior(cursorRow())), setCursor(cur, boost::prior(cursorRow())->par(),
boost::prior(cursorRow())->pos(), false); boost::prior(cursorRow())->pos(), false);
if (cur.y() > top_y()) { if (cur.y() > top_y()) {
cursorUp(true); cursorUp(true);
@ -338,7 +338,7 @@ void LyXText::cursorNext()
RowList::iterator next_row = boost::next(cursorRow()); RowList::iterator next_row = boost::next(cursorRow());
if (next_row != rows().end()) { if (next_row != rows().end()) {
LyXCursor cur; LyXCursor cur;
setCursor(cur, getPar(next_row), next_row->pos(), false); setCursor(cur, next_row->par(), next_row->pos(), false);
if (cur.y() < top_y() + bv()->workHeight()) { if (cur.y() < top_y() + bv()->workHeight()) {
cursorDown(true); cursorDown(true);
} }