mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
remove Row::pit_ member
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7534 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
be00d1f18a
commit
87cab819b4
@ -1,11 +1,24 @@
|
||||
|
||||
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>
|
||||
|
||||
* lyxtext.h (getPar):
|
||||
* text.C: new function
|
||||
|
||||
* Makefile.am:
|
||||
* tracer.[Ch]: remove unneeded files
|
||||
|
||||
2003-08-11 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* InsetList.[Ch]: remove resizeInsetsLyXText()
|
||||
|
||||
* lyxtext.h:
|
||||
|
@ -390,7 +390,8 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
|
||||
if (font.language() != ignore_language ||
|
||||
font.number() != LyXFont::IGNORE) {
|
||||
LyXCursor & cursor = text->cursor;
|
||||
text->computeBidiTables(bv->buffer(), text->cursorRow());
|
||||
text->computeBidiTables(text->cursor.par(), bv->buffer(),
|
||||
text->cursorRow());
|
||||
if (cursor.boundary() !=
|
||||
text->isBoundary(bv->buffer(), *cursor.par(), cursor.pos(),
|
||||
text->real_current_font))
|
||||
|
25
src/lyxrow.C
25
src/lyxrow.C
@ -13,9 +13,6 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "lyxrow.h"
|
||||
#include "paragraph.h"
|
||||
#include "layout.h"
|
||||
#include "lyxlayout.h"
|
||||
#include "debug.h"
|
||||
|
||||
using lyx::pos_type;
|
||||
@ -29,8 +26,8 @@ Row::Row()
|
||||
{}
|
||||
|
||||
|
||||
Row::Row(ParagraphList::iterator pit, pos_type po)
|
||||
: pit_(pit), pos_(po), fill_(0), height_(0), width_(0), y_(0),
|
||||
Row::Row(pos_type po)
|
||||
: pos_(po), fill_(0), height_(0), width_(0), y_(0),
|
||||
ascent_of_text_(0), baseline_(0)
|
||||
{}
|
||||
|
||||
@ -47,30 +44,12 @@ unsigned int Row::y() const
|
||||
}
|
||||
|
||||
|
||||
ParagraphList::iterator Row::par()
|
||||
{
|
||||
return pit_;
|
||||
}
|
||||
|
||||
|
||||
ParagraphList::iterator Row::par() const
|
||||
{
|
||||
return pit_;
|
||||
}
|
||||
|
||||
|
||||
unsigned short Row::height() const
|
||||
{
|
||||
return height_;
|
||||
}
|
||||
|
||||
|
||||
void Row::par(ParagraphList::iterator pit)
|
||||
{
|
||||
pit_ = pit;
|
||||
}
|
||||
|
||||
|
||||
void Row::pos(pos_type p)
|
||||
{
|
||||
pos_ = p;
|
||||
|
11
src/lyxrow.h
11
src/lyxrow.h
@ -15,7 +15,6 @@
|
||||
#ifndef LYXROW_H
|
||||
#define LYXROW_H
|
||||
|
||||
#include "ParagraphList.h"
|
||||
#include "support/types.h"
|
||||
|
||||
///
|
||||
@ -24,13 +23,7 @@ public:
|
||||
///
|
||||
Row();
|
||||
///
|
||||
Row(ParagraphList::iterator pit, lyx::pos_type pos);
|
||||
///
|
||||
void par(ParagraphList::iterator pit);
|
||||
///
|
||||
ParagraphList::iterator par();
|
||||
///
|
||||
ParagraphList::iterator par() const;
|
||||
Row(lyx::pos_type pos);
|
||||
///
|
||||
void pos(lyx::pos_type p);
|
||||
///
|
||||
@ -68,8 +61,6 @@ public:
|
||||
/// current debugging only
|
||||
void dump(const char * = "") const;
|
||||
private:
|
||||
///
|
||||
ParagraphList::iterator pit_;
|
||||
///
|
||||
lyx::pos_type pos_;
|
||||
/** what is missing to a full row. Can be negative.
|
||||
|
@ -9,24 +9,27 @@
|
||||
#include <algorithm>
|
||||
|
||||
using lyx::pos_type;
|
||||
|
||||
using std::max;
|
||||
using std::min;
|
||||
|
||||
|
||||
bool isParEnd(LyXText const & lt, RowList::iterator rit)
|
||||
bool isParEnd(LyXText const & lt,
|
||||
ParagraphList::iterator pit, RowList::iterator rit)
|
||||
{
|
||||
RowList::iterator next_row = boost::next(rit);
|
||||
return next_row == lt.rows().end() || next_row->par() != rit->par();
|
||||
return next_row == lt.rows().end() || lt.getPar(next_row) != pit;
|
||||
}
|
||||
|
||||
|
||||
pos_type lastPos(LyXText const & lt, RowList::iterator rit)
|
||||
pos_type lastPos(LyXText const & lt,
|
||||
ParagraphList::iterator pit, RowList::iterator rit)
|
||||
{
|
||||
if (rit->par()->empty())
|
||||
if (pit->empty())
|
||||
return 0;
|
||||
|
||||
if (isParEnd(lt, rit))
|
||||
return rit->par()->size() - 1;
|
||||
if (isParEnd(lt, pit, rit))
|
||||
return pit->size() - 1;
|
||||
|
||||
return boost::next(rit)->pos() - 1;
|
||||
}
|
||||
@ -34,10 +37,9 @@ pos_type lastPos(LyXText const & lt, RowList::iterator rit)
|
||||
|
||||
namespace {
|
||||
|
||||
bool nextRowIsAllInset(Row const & row, pos_type last)
|
||||
bool nextRowIsAllInset(
|
||||
ParagraphList::iterator pit, RowList::iterator rit, pos_type last)
|
||||
{
|
||||
ParagraphList::iterator pit = row.par();
|
||||
|
||||
if (last + 1 >= pit->size())
|
||||
return false;
|
||||
|
||||
@ -51,27 +53,26 @@ bool nextRowIsAllInset(Row const & row, pos_type last)
|
||||
} // anon namespace
|
||||
|
||||
|
||||
pos_type lastPrintablePos(LyXText const & lt, RowList::iterator rit)
|
||||
pos_type lastPrintablePos(LyXText const & lt,
|
||||
ParagraphList::iterator pit, RowList::iterator rit)
|
||||
{
|
||||
pos_type const last = lastPos(lt, rit);
|
||||
pos_type const last = lastPos(lt, pit, rit);
|
||||
|
||||
// if this row is an end of par, just act like lastPos()
|
||||
if (isParEnd(lt, rit))
|
||||
if (isParEnd(lt, pit, rit))
|
||||
return last;
|
||||
|
||||
bool const nextrownotinset = !nextRowIsAllInset(*rit, last);
|
||||
|
||||
if (nextrownotinset && rit->par()->isSeparator(last))
|
||||
if (!nextRowIsAllInset(pit, rit, last) && pit->isSeparator(last))
|
||||
return last - 1;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
|
||||
int numberOfSeparators(LyXText const & lt, RowList::iterator rit)
|
||||
int numberOfSeparators(LyXText const & lt,
|
||||
ParagraphList::iterator pit, RowList::iterator rit)
|
||||
{
|
||||
pos_type const last = lastPrintablePos(lt, rit);
|
||||
ParagraphList::iterator pit = rit->par();
|
||||
pos_type const last = lastPrintablePos(lt, pit, rit);
|
||||
int n = 0;
|
||||
pos_type p = max(rit->pos(), pit->beginningOfBody());
|
||||
for ( ; p < last; ++p)
|
||||
@ -83,11 +84,11 @@ int numberOfSeparators(LyXText const & lt, RowList::iterator rit)
|
||||
|
||||
// This is called _once_ from LyXText and should at least be moved into
|
||||
// an anonymous namespace there. (Lgb)
|
||||
int numberOfHfills(LyXText const & lt, RowList::iterator rit)
|
||||
int numberOfHfills(LyXText const & lt,
|
||||
ParagraphList::iterator pit, RowList::iterator rit)
|
||||
{
|
||||
pos_type const last = lastPos(lt, rit);
|
||||
pos_type const last = lastPos(lt, pit, rit);
|
||||
pos_type first = rit->pos();
|
||||
ParagraphList::iterator pit = rit->par();
|
||||
|
||||
// hfill *DO* count at the beginning of paragraphs!
|
||||
if (first) {
|
||||
@ -110,11 +111,11 @@ int numberOfHfills(LyXText const & lt, RowList::iterator rit)
|
||||
|
||||
// This is called _once_ from LyXText and should at least be moved into
|
||||
// an anonymous namespace there. (Lgb)
|
||||
int numberOfLabelHfills(LyXText const & lt, RowList::iterator rit)
|
||||
int numberOfLabelHfills(LyXText const & lt,
|
||||
ParagraphList::iterator pit, RowList::iterator rit)
|
||||
{
|
||||
pos_type last = lastPos(lt, rit);
|
||||
pos_type last = lastPos(lt, pit, rit);
|
||||
pos_type first = rit->pos();
|
||||
ParagraphList::iterator pit = rit->par();
|
||||
|
||||
// hfill *DO* count at the beginning of paragraphs!
|
||||
if (first) {
|
||||
@ -134,16 +135,15 @@ int numberOfLabelHfills(LyXText const & lt, RowList::iterator rit)
|
||||
}
|
||||
|
||||
|
||||
bool hfillExpansion(LyXText const & lt, RowList::iterator rit, pos_type pos)
|
||||
bool hfillExpansion(LyXText const & lt,
|
||||
ParagraphList::iterator pit, RowList::iterator rit, pos_type pos)
|
||||
{
|
||||
ParagraphList::iterator pit = rit->par();
|
||||
|
||||
if (!pit->isHfill(pos))
|
||||
return false;
|
||||
|
||||
// at the end of a row it does not count
|
||||
// unless another hfill exists on the line
|
||||
if (pos >= lastPos(lt, rit))
|
||||
if (pos >= lastPos(lt, pit, rit))
|
||||
for (pos_type i = rit->pos(); i < pos && !pit->isHfill(i); ++i)
|
||||
return false;
|
||||
|
||||
|
@ -4,22 +4,31 @@
|
||||
#define LYXROW_FUNCS_H
|
||||
|
||||
#include "RowList.h"
|
||||
#include "ParagraphList.h"
|
||||
|
||||
#include "support/types.h"
|
||||
|
||||
class LyXText;
|
||||
|
||||
bool isParEnd(LyXText const & lt, RowList::iterator rit);
|
||||
bool isParEnd(LyXText const & lt,
|
||||
ParagraphList::iterator pit, RowList::iterator rit);
|
||||
|
||||
lyx::pos_type lastPos(LyXText const & lt, RowList::iterator rit);
|
||||
lyx::pos_type lastPos(LyXText const & lt,
|
||||
ParagraphList::iterator pit, RowList::iterator rit);
|
||||
|
||||
lyx::pos_type lastPrintablePos(LyXText const & lt, RowList::iterator rit);
|
||||
lyx::pos_type lastPrintablePos(LyXText const & lt,
|
||||
ParagraphList::iterator pit, RowList::iterator rit);
|
||||
|
||||
int numberOfSeparators(LyXText const & lt, RowList::iterator rit);
|
||||
int numberOfSeparators(LyXText const & lt,
|
||||
ParagraphList::iterator pit, RowList::iterator rit);
|
||||
|
||||
int numberOfHfills(LyXText const & lt, RowList::iterator rit);
|
||||
int numberOfHfills(LyXText const & lt,
|
||||
ParagraphList::iterator pit, RowList::iterator rit);
|
||||
|
||||
int numberOfLabelHfills(LyXText const & lt, RowList::iterator rit);
|
||||
int numberOfLabelHfills(LyXText const & lt,
|
||||
ParagraphList::iterator pit, RowList::iterator rit);
|
||||
|
||||
bool hfillExpansion(LyXText const & lt, RowList::iterator rit, lyx::pos_type pos);
|
||||
bool hfillExpansion(LyXText const & lt,
|
||||
ParagraphList::iterator pit, RowList::iterator rit, lyx::pos_type pos);
|
||||
|
||||
#endif
|
||||
|
@ -136,8 +136,6 @@ public:
|
||||
void redoParagraph(ParagraphList::iterator pit);
|
||||
/// rebreaks the cursor par
|
||||
void redoParagraph();
|
||||
/// returns first row belongin to some par
|
||||
RowList::iterator firstRow(ParagraphList::iterator pit);
|
||||
|
||||
///
|
||||
void toggleFree(LyXFont const &, bool toggleall = false);
|
||||
@ -196,8 +194,8 @@ public:
|
||||
/** returns the column near the specified x-coordinate of the row
|
||||
x is set to the real beginning of this column
|
||||
*/
|
||||
lyx::pos_type getColumnNearX(RowList::iterator rit,
|
||||
int & x, bool & boundary) const;
|
||||
lyx::pos_type getColumnNearX(ParagraphList::iterator pit,
|
||||
RowList::iterator rit, int & x, bool & boundary) const;
|
||||
|
||||
/** returns a pointer to a specified row. y is set to the beginning
|
||||
of the row
|
||||
@ -369,7 +367,8 @@ public:
|
||||
int workWidth() const;
|
||||
|
||||
///
|
||||
void computeBidiTables(Buffer const *, RowList::iterator row) const;
|
||||
void computeBidiTables(ParagraphList::iterator pit,
|
||||
Buffer const *, RowList::iterator row) const;
|
||||
/// Maps positions in the visual string to positions in logical string.
|
||||
lyx::pos_type log2vis(lyx::pos_type pos) const;
|
||||
/// Maps positions in the logical string to positions in visual string.
|
||||
@ -383,7 +382,8 @@ private:
|
||||
mutable RowList rowlist_;
|
||||
|
||||
///
|
||||
float getCursorX(RowList::iterator rit, lyx::pos_type pos,
|
||||
float getCursorX(ParagraphList::iterator pit,
|
||||
RowList::iterator rit, lyx::pos_type pos,
|
||||
lyx::pos_type last, bool boundary) const;
|
||||
/// used in setlayout
|
||||
void makeFontEntriesLayoutSpecific(BufferParams const &, Paragraph & par);
|
||||
@ -447,13 +447,15 @@ public:
|
||||
* in LaTeX the beginning of the text fits in some cases
|
||||
* (for example sections) exactly the label-width.
|
||||
*/
|
||||
int leftMargin(Row const & row) const;
|
||||
int leftMargin(ParagraphList::iterator pit, Row const & row) const;
|
||||
///
|
||||
int rightMargin(Buffer const &, Row const & row) const;
|
||||
int rightMargin(ParagraphList::iterator pit, Buffer const &, Row const & row) const;
|
||||
|
||||
/** this calculates the specified parameters. needed when setting
|
||||
* the cursor and when creating a visible row */
|
||||
void prepareToPrint(RowList::iterator row, double & x,
|
||||
void prepareToPrint(
|
||||
ParagraphList::iterator pit,
|
||||
RowList::iterator row, double & x,
|
||||
double & fill_separator,
|
||||
double & fill_hfill,
|
||||
double & fill_label_hfill,
|
||||
@ -476,7 +478,8 @@ private:
|
||||
|
||||
/// return the pos value *before* which a row should break.
|
||||
/// for example, the pos at which IsNewLine(pos) == true
|
||||
lyx::pos_type rowBreakPoint(Row const & row) const;
|
||||
lyx::pos_type rowBreakPoint(ParagraphList::iterator pit,
|
||||
Row const & row) const;
|
||||
|
||||
/// returns the minimum space a row needs on the screen in pixel
|
||||
int fill(RowList::iterator row, int workwidth) const;
|
||||
@ -485,10 +488,10 @@ private:
|
||||
* returns the minimum space a manual label needs on the
|
||||
* screen in pixels
|
||||
*/
|
||||
int labelFill(Row const & row) const;
|
||||
int labelFill(ParagraphList::iterator pit, Row const & row) const;
|
||||
|
||||
/// FIXME
|
||||
int labelEnd(Row const & row) const;
|
||||
int labelEnd(ParagraphList::iterator pit, Row const & row) const;
|
||||
|
||||
///
|
||||
mutable std::vector<lyx::pos_type> log2vis_list;
|
||||
@ -512,6 +515,16 @@ public:
|
||||
/// return true if this is owned by an inset.
|
||||
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:
|
||||
/** Cursor related data.
|
||||
Later this variable has to be removed. There should be now internal
|
||||
|
@ -131,7 +131,7 @@ RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
|
||||
RowList::iterator rit,
|
||||
int y_offset, int x_offset, int y)
|
||||
: bv_(bv), pain_(bv_.painter()), text_(text), row_(rit),
|
||||
pit_(rit->par()),
|
||||
pit_(text.getPar(rit)),
|
||||
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
|
||||
{
|
||||
return text_.leftMargin(*row_);
|
||||
return text_.leftMargin(pit_, *row_);
|
||||
}
|
||||
|
||||
|
||||
@ -255,7 +255,7 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos)
|
||||
void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
|
||||
{
|
||||
pos_type pos = text_.vis2log(vpos);
|
||||
pos_type const last = lastPrintablePos(text_, row_);
|
||||
pos_type const last = lastPrintablePos(text_, pit_, row_);
|
||||
LyXFont orig_font = getFont(pos);
|
||||
|
||||
// first character
|
||||
@ -432,7 +432,7 @@ void RowPainter::paintSelection()
|
||||
int(x_), row_->height(), LColor::selection);
|
||||
|
||||
pos_type const body_pos = pit_->beginningOfBody();
|
||||
pos_type const last = lastPrintablePos(text_, row_);
|
||||
pos_type const last = lastPrintablePos(text_, pit_, row_);
|
||||
double tmpx = x_;
|
||||
|
||||
for (pos_type vpos = row_->pos(); vpos <= last; ++vpos) {
|
||||
@ -448,7 +448,7 @@ void RowPainter::paintSelection()
|
||||
tmpx -= singleWidth(body_pos - 1);
|
||||
}
|
||||
|
||||
if (hfillExpansion(text_, row_, pos)) {
|
||||
if (hfillExpansion(text_, pit_, row_, pos)) {
|
||||
tmpx += singleWidth(pos);
|
||||
if (pos >= body_pos)
|
||||
tmpx += hfill_;
|
||||
@ -484,7 +484,7 @@ void RowPainter::paintSelection()
|
||||
void RowPainter::paintChangeBar()
|
||||
{
|
||||
pos_type const start = row_->pos();
|
||||
pos_type const end = lastPrintablePos(text_, row_);
|
||||
pos_type const end = lastPrintablePos(text_, pit_, row_);
|
||||
|
||||
if (!pit_->isChanged(start, end))
|
||||
return;
|
||||
@ -524,12 +524,12 @@ void RowPainter::paintDepthBar()
|
||||
|
||||
Paragraph::depth_type prev_depth = 0;
|
||||
if (row_ != text_.rows().begin())
|
||||
prev_depth = boost::prior(row_)->par()->getDepth();
|
||||
prev_depth = text_.getPar(boost::prior(row_))->getDepth();
|
||||
Paragraph::depth_type next_depth = 0;
|
||||
|
||||
RowList::iterator next_row = boost::next(row_);
|
||||
if (next_row != text_.rows().end())
|
||||
next_depth = next_row->par()->getDepth();
|
||||
next_depth = text_.getPar(next_row)->getDepth();
|
||||
|
||||
for (Paragraph::depth_type i = 1; i <= depth; ++i) {
|
||||
int const w = PAPER_MARGIN / 5;
|
||||
@ -795,7 +795,7 @@ void RowPainter::paintFirst()
|
||||
double x = x_;
|
||||
if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
|
||||
x = ((is_rtl ? leftMargin() : x_)
|
||||
+ ww - text_.rightMargin(*bv_.buffer(), *row_)) / 2;
|
||||
+ ww - text_.rightMargin(pit_, *bv_.buffer(), *row_)) / 2;
|
||||
x -= font_metrics::width(str, font) / 2;
|
||||
} else if (is_rtl) {
|
||||
x = ww - leftMargin() -
|
||||
@ -875,7 +875,7 @@ void RowPainter::paintLast()
|
||||
string const & str = pit_->layout()->endlabelstring();
|
||||
double const x = is_rtl ?
|
||||
x_ - font_metrics::width(str, font)
|
||||
: ww - text_.rightMargin(*bv_.buffer(), *row_) - row_->fill();
|
||||
: ww - text_.rightMargin(pit_, *bv_.buffer(), *row_) - row_->fill();
|
||||
pain_.text(int(x), yo_ + row_->baseline(), str, font);
|
||||
break;
|
||||
}
|
||||
@ -887,7 +887,7 @@ void RowPainter::paintLast()
|
||||
|
||||
void RowPainter::paintText()
|
||||
{
|
||||
pos_type const last = lastPrintablePos(text_, row_);
|
||||
pos_type const last = lastPrintablePos(text_, pit_, row_);
|
||||
pos_type body_pos = pit_->beginningOfBody();
|
||||
if (body_pos > 0 &&
|
||||
(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);
|
||||
|
||||
if (hfillExpansion(text_, row_, pos)) {
|
||||
if (hfillExpansion(text_, pit_, row_, pos)) {
|
||||
int const y2 = (y0 + y1) / 2;
|
||||
|
||||
if (pos >= body_pos) {
|
||||
@ -997,7 +997,7 @@ void RowPainter::paint()
|
||||
|
||||
// FIXME: must be a cleaner way here. Aren't these calculations
|
||||
// belonging to row metrics ?
|
||||
text_.prepareToPrint(row_, x_, separator_, hfill_, label_hfill_);
|
||||
text_.prepareToPrint(pit_, row_, x_, separator_, hfill_, label_hfill_);
|
||||
|
||||
// FIXME: what is this fixing ?
|
||||
if (text_.isInInset() && x_ < 0)
|
||||
@ -1025,7 +1025,7 @@ void RowPainter::paint()
|
||||
if (row_->isParStart())
|
||||
paintFirst();
|
||||
|
||||
if (isParEnd(text_, row_))
|
||||
if (isParEnd(text_, pit_, row_))
|
||||
paintLast();
|
||||
|
||||
// paint text
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "LAssert.h"
|
||||
#include "debug.h"
|
||||
#include "support/lyxlib.h"
|
||||
|
||||
#ifdef ENABLE_ASSERTIONS
|
||||
@ -34,6 +35,17 @@ void emergencyCleanup()
|
||||
|
||||
} // 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)
|
||||
{
|
||||
if (!assertion) {
|
||||
|
@ -18,11 +18,13 @@ namespace support {
|
||||
#ifdef ENABLE_ASSERTIONS
|
||||
|
||||
/** Live assertion.
|
||||
This is a debug tool to ensure that the assertion holds. If it don't hole
|
||||
we run #emergencyCleanup()# and then #lyx::abort".
|
||||
This is a debug tool to ensure that the assertion holds. If it
|
||||
doesn't hold we run #emergencyCleanup()# and then #lyx::abort".
|
||||
@param assertion this should evaluate to true unless you want an abort.
|
||||
*/
|
||||
void Assert(bool assertion);
|
||||
/// same as above, print message before aborting
|
||||
void Assert(bool assertion, const char * message);
|
||||
|
||||
#else
|
||||
|
||||
@ -31,6 +33,8 @@ void Assert(bool assertion);
|
||||
*/
|
||||
inline
|
||||
void Assert(bool /*assertion*/) {}
|
||||
inline
|
||||
void Assert(bool /*assertion*/, const char * /*message*/) {}
|
||||
|
||||
#endif /* ENABLE_ASSERTIONS */
|
||||
|
||||
|
263
src/text.C
263
src/text.C
@ -317,8 +317,8 @@ bool LyXText::bidi_InRange(lyx::pos_type pos) const
|
||||
}
|
||||
|
||||
|
||||
void LyXText::computeBidiTables(Buffer const * buf,
|
||||
RowList::iterator row) const
|
||||
void LyXText::computeBidiTables(ParagraphList::iterator row_par,
|
||||
Buffer const * buf, RowList::iterator row) const
|
||||
{
|
||||
bidi_same_direction = true;
|
||||
if (!lyxrc.rtl_support) {
|
||||
@ -326,8 +326,6 @@ void LyXText::computeBidiTables(Buffer const * buf,
|
||||
return;
|
||||
}
|
||||
|
||||
ParagraphList::iterator row_par = row->par();
|
||||
|
||||
InsetOld * inset = row_par->inInset();
|
||||
if (inset && inset->owner() &&
|
||||
inset->owner()->lyxCode() == InsetOld::ERT_CODE) {
|
||||
@ -336,7 +334,7 @@ void LyXText::computeBidiTables(Buffer const * buf,
|
||||
}
|
||||
|
||||
bidi_start = row->pos();
|
||||
bidi_end = lastPrintablePos(*this, row);
|
||||
bidi_end = lastPrintablePos(*this, row_par, row);
|
||||
|
||||
if (bidi_start > bidi_end) {
|
||||
bidi_start = -1;
|
||||
@ -481,19 +479,19 @@ bool LyXText::isBoundary(Buffer const * buf, Paragraph const & par,
|
||||
}
|
||||
|
||||
|
||||
int LyXText::leftMargin(Row const & row) const
|
||||
int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
|
||||
{
|
||||
InsetOld * ins;
|
||||
|
||||
if (row.pos() < row.par()->size())
|
||||
if (row.par()->getChar(row.pos()) == Paragraph::META_INSET &&
|
||||
(ins = row.par()->getInset(row.pos())) &&
|
||||
if (row.pos() < pit->size())
|
||||
if (pit->getChar(row.pos()) == Paragraph::META_INSET &&
|
||||
(ins = pit->getInset(row.pos())) &&
|
||||
(ins->needFullRow() || ins->display()))
|
||||
return LEFT_MARGIN;
|
||||
|
||||
LyXTextClass const & tclass =
|
||||
bv()->buffer()->params.getLyXTextClass();
|
||||
LyXLayout_ptr const & layout = row.par()->layout();
|
||||
LyXLayout_ptr const & layout = pit->layout();
|
||||
|
||||
string parindent = layout->parindent;
|
||||
|
||||
@ -504,14 +502,14 @@ int LyXText::leftMargin(Row const & row) const
|
||||
// this is the way, LyX handles the LaTeX-Environments.
|
||||
// I have had this idea very late, so it seems to be a
|
||||
// later added hack and this is true
|
||||
if (!row.par()->getDepth()) {
|
||||
if (row.par()->layout() == tclass.defaultLayout()) {
|
||||
if (!pit->getDepth()) {
|
||||
if (pit->layout() == tclass.defaultLayout()) {
|
||||
// find the previous same level paragraph
|
||||
if (row.par() != ownerParagraphs().begin()) {
|
||||
if (pit != ownerParagraphs().begin()) {
|
||||
ParagraphList::iterator newpit =
|
||||
depthHook(row.par(), ownerParagraphs(),
|
||||
row.par()->getDepth());
|
||||
if (newpit == row.par() &&
|
||||
depthHook(pit, ownerParagraphs(),
|
||||
pit->getDepth());
|
||||
if (newpit == pit &&
|
||||
newpit->layout()->nextnoindent)
|
||||
parindent.erase();
|
||||
}
|
||||
@ -519,7 +517,7 @@ int LyXText::leftMargin(Row const & row) const
|
||||
} else {
|
||||
// find the next level paragraph
|
||||
|
||||
ParagraphList::iterator newpar = outerHook(row.par(),
|
||||
ParagraphList::iterator newpar = outerHook(pit,
|
||||
ownerParagraphs());
|
||||
|
||||
// make a corresponding row. Needed to call leftMargin()
|
||||
@ -527,14 +525,11 @@ int LyXText::leftMargin(Row const & row) const
|
||||
// check wether it is a sufficent paragraph
|
||||
if (newpar != ownerParagraphs().end() &&
|
||||
newpar->layout()->isEnvironment()) {
|
||||
Row dummyrow;
|
||||
dummyrow.par(newpar);
|
||||
dummyrow.pos(newpar->size());
|
||||
x = leftMargin(dummyrow);
|
||||
x = leftMargin(newpar, Row(newpar->size()));
|
||||
}
|
||||
|
||||
if (newpar != ownerParagraphs().end() &&
|
||||
row.par()->layout() == tclass.defaultLayout()) {
|
||||
pit->layout() == tclass.defaultLayout()) {
|
||||
if (newpar->params().noindent())
|
||||
parindent.erase();
|
||||
else {
|
||||
@ -544,17 +539,17 @@ int LyXText::leftMargin(Row const & row) const
|
||||
}
|
||||
}
|
||||
|
||||
LyXFont const labelfont = getLabelFont(row.par());
|
||||
LyXFont const labelfont = getLabelFont(pit);
|
||||
switch (layout->margintype) {
|
||||
case MARGIN_DYNAMIC:
|
||||
if (!layout->leftmargin.empty()) {
|
||||
x += font_metrics::signedWidth(layout->leftmargin,
|
||||
tclass.defaultfont());
|
||||
}
|
||||
if (!row.par()->getLabelstring().empty()) {
|
||||
if (!pit->getLabelstring().empty()) {
|
||||
x += font_metrics::signedWidth(layout->labelindent,
|
||||
labelfont);
|
||||
x += font_metrics::width(row.par()->getLabelstring(),
|
||||
x += font_metrics::width(pit->getLabelstring(),
|
||||
labelfont);
|
||||
x += font_metrics::width(layout->labelsep, labelfont);
|
||||
}
|
||||
@ -562,9 +557,9 @@ int LyXText::leftMargin(Row const & row) const
|
||||
case MARGIN_MANUAL:
|
||||
x += font_metrics::signedWidth(layout->labelindent, labelfont);
|
||||
// The width of an empty par, even with manual label, should be 0
|
||||
if (!row.par()->empty() && row.pos() >= row.par()->beginningOfBody()) {
|
||||
if (!row.par()->getLabelWidthString().empty()) {
|
||||
x += font_metrics::width(row.par()->getLabelWidthString(),
|
||||
if (!pit->empty() && row.pos() >= pit->beginningOfBody()) {
|
||||
if (!pit->getLabelWidthString().empty()) {
|
||||
x += font_metrics::width(pit->getLabelWidthString(),
|
||||
labelfont);
|
||||
x += font_metrics::width(layout->labelsep, labelfont);
|
||||
}
|
||||
@ -572,11 +567,11 @@ int LyXText::leftMargin(Row const & row) const
|
||||
break;
|
||||
case MARGIN_STATIC:
|
||||
x += font_metrics::signedWidth(layout->leftmargin, tclass.defaultfont()) * 4
|
||||
/ (row.par()->getDepth() + 4);
|
||||
/ (pit->getDepth() + 4);
|
||||
break;
|
||||
case MARGIN_FIRST_DYNAMIC:
|
||||
if (layout->labeltype == LABEL_MANUAL) {
|
||||
if (row.pos() >= row.par()->beginningOfBody()) {
|
||||
if (row.pos() >= pit->beginningOfBody()) {
|
||||
x += font_metrics::signedWidth(layout->leftmargin,
|
||||
labelfont);
|
||||
} else {
|
||||
@ -588,7 +583,7 @@ int LyXText::leftMargin(Row const & row) const
|
||||
// theorems (JMarc)
|
||||
|| (layout->labeltype == LABEL_STATIC
|
||||
&& layout->latextype == LATEX_ENVIRONMENT
|
||||
&& !isFirstInSequence(row.par(), ownerParagraphs()))) {
|
||||
&& !isFirstInSequence(pit, ownerParagraphs()))) {
|
||||
x += font_metrics::signedWidth(layout->leftmargin,
|
||||
labelfont);
|
||||
} else if (layout->labeltype != LABEL_TOP_ENVIRONMENT
|
||||
@ -598,7 +593,7 @@ int LyXText::leftMargin(Row const & row) const
|
||||
x += font_metrics::signedWidth(layout->labelindent,
|
||||
labelfont);
|
||||
x += font_metrics::width(layout->labelsep, labelfont);
|
||||
x += font_metrics::width(row.par()->getLabelstring(),
|
||||
x += font_metrics::width(pit->getLabelstring(),
|
||||
labelfont);
|
||||
}
|
||||
break;
|
||||
@ -612,12 +607,12 @@ int LyXText::leftMargin(Row const & row) const
|
||||
// find the first row of this paragraph
|
||||
RowList::iterator tmprit = rowlist_.begin();
|
||||
while (tmprit != rowlist_.end()
|
||||
&& tmprit->par() != row.par())
|
||||
&& getPar(tmprit) != pit)
|
||||
++tmprit;
|
||||
|
||||
int minfill = tmprit->fill();
|
||||
while (boost::next(tmprit) != rowlist_.end() &&
|
||||
boost::next(tmprit)->par() == row.par()) {
|
||||
getPar(boost::next(tmprit)) == pit) {
|
||||
++tmprit;
|
||||
if (tmprit->fill() < minfill)
|
||||
minfill = tmprit->fill();
|
||||
@ -630,10 +625,8 @@ int LyXText::leftMargin(Row const & row) const
|
||||
break;
|
||||
}
|
||||
|
||||
if ((workWidth() > 0) &&
|
||||
!row.par()->params().leftIndent().zero())
|
||||
{
|
||||
LyXLength const len = row.par()->params().leftIndent();
|
||||
if (workWidth() > 0 && !pit->params().leftIndent().zero()) {
|
||||
LyXLength const len = pit->params().leftIndent();
|
||||
int const tw = inset_owner ?
|
||||
inset_owner->latexTextWidth(bv()) : workWidth();
|
||||
x += len.inPixels(tw);
|
||||
@ -641,10 +634,10 @@ int LyXText::leftMargin(Row const & row) const
|
||||
|
||||
LyXAlignment align;
|
||||
|
||||
if (row.par()->params().align() == LYX_ALIGN_LAYOUT)
|
||||
if (pit->params().align() == LYX_ALIGN_LAYOUT)
|
||||
align = layout->align;
|
||||
else
|
||||
align = row.par()->params().align();
|
||||
align = pit->params().align();
|
||||
|
||||
// set the correct parindent
|
||||
if (row.pos() == 0) {
|
||||
@ -653,14 +646,14 @@ int LyXText::leftMargin(Row const & row) const
|
||||
|| layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
|
||||
|| (layout->labeltype == LABEL_STATIC
|
||||
&& layout->latextype == LATEX_ENVIRONMENT
|
||||
&& !isFirstInSequence(row.par(), ownerParagraphs())))
|
||||
&& !isFirstInSequence(pit, ownerParagraphs())))
|
||||
&& align == LYX_ALIGN_BLOCK
|
||||
&& !row.par()->params().noindent()
|
||||
&& !pit->params().noindent()
|
||||
// in tabulars and ert paragraphs are never indented!
|
||||
&& (!row.par()->inInset() || !row.par()->inInset()->owner() ||
|
||||
(row.par()->inInset()->owner()->lyxCode() != InsetOld::TABULAR_CODE &&
|
||||
row.par()->inInset()->owner()->lyxCode() != InsetOld::ERT_CODE))
|
||||
&& (row.par()->layout() != tclass.defaultLayout() ||
|
||||
&& (!pit->inInset() || !pit->inInset()->owner() ||
|
||||
(pit->inInset()->owner()->lyxCode() != InsetOld::TABULAR_CODE &&
|
||||
pit->inInset()->owner()->lyxCode() != InsetOld::ERT_CODE))
|
||||
&& (pit->layout() != tclass.defaultLayout() ||
|
||||
bv()->buffer()->params.paragraph_separation ==
|
||||
BufferParams::PARSEP_INDENT)) {
|
||||
x += font_metrics::signedWidth(parindent,
|
||||
@ -675,35 +668,36 @@ int LyXText::leftMargin(Row const & row) const
|
||||
}
|
||||
|
||||
|
||||
int LyXText::rightMargin(Buffer const & buf, Row const & row) const
|
||||
int LyXText::rightMargin(ParagraphList::iterator pit,
|
||||
Buffer const & buf, Row const & row) const
|
||||
{
|
||||
InsetOld * ins;
|
||||
|
||||
if (row.pos() < row.par()->size())
|
||||
if ((row.par()->getChar(row.pos()) == Paragraph::META_INSET) &&
|
||||
(ins = row.par()->getInset(row.pos())) &&
|
||||
if (row.pos() < pit->size())
|
||||
if ((pit->getChar(row.pos()) == Paragraph::META_INSET) &&
|
||||
(ins = pit->getInset(row.pos())) &&
|
||||
(ins->needFullRow() || ins->display()))
|
||||
return PAPER_MARGIN;
|
||||
|
||||
LyXTextClass const & tclass = buf.params.getLyXTextClass();
|
||||
LyXLayout_ptr const & layout = row.par()->layout();
|
||||
LyXLayout_ptr const & layout = pit->layout();
|
||||
|
||||
return PAPER_MARGIN
|
||||
+ font_metrics::signedWidth(tclass.rightmargin(),
|
||||
tclass.defaultfont());
|
||||
+ font_metrics::signedWidth(layout->rightmargin,
|
||||
tclass.defaultfont())
|
||||
* 4 / (row.par()->getDepth() + 4);
|
||||
* 4 / (pit->getDepth() + 4);
|
||||
}
|
||||
|
||||
|
||||
int LyXText::labelEnd(Row const & row) const
|
||||
int LyXText::labelEnd(ParagraphList::iterator pit, Row const & row) const
|
||||
{
|
||||
if (row.par()->layout()->margintype == MARGIN_MANUAL) {
|
||||
if (pit->layout()->margintype == MARGIN_MANUAL) {
|
||||
Row tmprow = row;
|
||||
tmprow.pos(row.par()->size());
|
||||
tmprow.pos(pit->size());
|
||||
// return the beginning of the body
|
||||
return leftMargin(tmprow);
|
||||
return leftMargin(pit, tmprow);
|
||||
}
|
||||
|
||||
// LabelEnd is only needed if the layout
|
||||
@ -728,12 +722,11 @@ pos_type addressBreakPoint(pos_type i, Paragraph const & par)
|
||||
};
|
||||
|
||||
|
||||
pos_type LyXText::rowBreakPoint(Row const & row) const
|
||||
pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit,
|
||||
Row const & row) const
|
||||
{
|
||||
ParagraphList::iterator pit = row.par();
|
||||
|
||||
// maximum pixel width of a row.
|
||||
int width = workWidth() - rightMargin(*bv()->buffer(), row);
|
||||
int width = workWidth() - rightMargin(pit, *bv()->buffer(), row);
|
||||
|
||||
// inset->textWidth() returns -1 via workWidth(),
|
||||
// but why ?
|
||||
@ -757,7 +750,7 @@ pos_type LyXText::rowBreakPoint(Row const & row) const
|
||||
// or the end of the par, then choose the possible break
|
||||
// nearest that.
|
||||
|
||||
int const left = leftMargin(row);
|
||||
int const left = leftMargin(pit, row);
|
||||
int x = left;
|
||||
|
||||
// pixel width since last breakpoint
|
||||
@ -785,7 +778,7 @@ pos_type LyXText::rowBreakPoint(Row const & row) const
|
||||
thiswidth = font_metrics::width(layout->labelsep, getLabelFont(pit));
|
||||
if (pit->isLineSeparator(i - 1))
|
||||
thiswidth -= singleWidth(pit, i - 1);
|
||||
int left_margin = labelEnd(row);
|
||||
int left_margin = labelEnd(pit, row);
|
||||
if (thiswidth + x < left_margin)
|
||||
thiswidth = left_margin - x;
|
||||
thiswidth += singleWidth(pit, i, c);
|
||||
@ -889,19 +882,19 @@ int LyXText::fill(RowList::iterator row, int paper_width) const
|
||||
|
||||
int w;
|
||||
// get the pure distance
|
||||
pos_type const last = lastPrintablePos(*this, row);
|
||||
ParagraphList::iterator pit = getPar(row);
|
||||
pos_type const last = lastPrintablePos(*this, pit, row);
|
||||
|
||||
ParagraphList::iterator pit = row->par();
|
||||
LyXLayout_ptr const & layout = pit->layout();
|
||||
|
||||
// special handling of the right address boxes
|
||||
if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
|
||||
int const tmpfill = row->fill();
|
||||
row->fill(0); // the minfill in MarginLeft()
|
||||
w = leftMargin(*row);
|
||||
w = leftMargin(pit, *row);
|
||||
row->fill(tmpfill);
|
||||
} else
|
||||
w = leftMargin(*row);
|
||||
w = leftMargin(pit, *row);
|
||||
|
||||
pos_type const body_pos = pit->beginningOfBody();
|
||||
pos_type i = row->pos();
|
||||
@ -915,7 +908,7 @@ int LyXText::fill(RowList::iterator row, int paper_width) const
|
||||
w += font_metrics::width(layout->labelsep, getLabelFont(pit));
|
||||
if (pit->isLineSeparator(i - 1))
|
||||
w -= singleWidth(pit, i - 1);
|
||||
int left_margin = labelEnd(*row);
|
||||
int left_margin = labelEnd(pit, *row);
|
||||
if (w < left_margin)
|
||||
w = left_margin;
|
||||
}
|
||||
@ -950,12 +943,12 @@ int LyXText::fill(RowList::iterator row, int paper_width) const
|
||||
w += font_metrics::width(layout->labelsep, getLabelFont(pit));
|
||||
if (last >= 0 && pit->isLineSeparator(last))
|
||||
w -= singleWidth(pit, last);
|
||||
int const left_margin = labelEnd(*row);
|
||||
int const left_margin = labelEnd(pit, *row);
|
||||
if (w < left_margin)
|
||||
w = left_margin;
|
||||
}
|
||||
|
||||
int const fill = paper_width - w - rightMargin(*bv()->buffer(), *row);
|
||||
int const fill = paper_width - w - rightMargin(pit, *bv()->buffer(), *row);
|
||||
|
||||
// If this case happens, it means that our calculation
|
||||
// of the widths of the chars when we do rowBreakPoint()
|
||||
@ -967,17 +960,15 @@ int LyXText::fill(RowList::iterator row, int paper_width) const
|
||||
if (lyxerr.debugging() && fill < 0) {
|
||||
lyxerr[Debug::GUI] << "Eek, fill() was < 0: " << fill
|
||||
<< " w " << w << " paper_width " << paper_width
|
||||
<< " right margin " << rightMargin(*bv()->buffer(), *row) << endl;
|
||||
<< " right margin " << rightMargin(pit, *bv()->buffer(), *row) << endl;
|
||||
}
|
||||
return fill;
|
||||
}
|
||||
|
||||
|
||||
// returns the minimum space a manual label needs on the screen in pixel
|
||||
int LyXText::labelFill(Row const & row) const
|
||||
int LyXText::labelFill(ParagraphList::iterator pit, Row const & row) const
|
||||
{
|
||||
ParagraphList::iterator pit = row.par();
|
||||
|
||||
pos_type last = pit->beginningOfBody();
|
||||
|
||||
Assert(last > 0);
|
||||
@ -1030,7 +1021,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
||||
// ok, let us initialize the maxasc and maxdesc value.
|
||||
// Only the fontsize count. The other properties
|
||||
// are taken from the layoutfont. Nicer on the screen :)
|
||||
ParagraphList::iterator pit = rit->par();
|
||||
ParagraphList::iterator pit = getPar(rit);
|
||||
|
||||
LyXLayout_ptr const & layout = pit->layout();
|
||||
|
||||
@ -1057,7 +1048,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
||||
int maxdesc = int(font_metrics::maxDescent(font) *
|
||||
layout->spacing.getValue() * spacing_val);
|
||||
|
||||
pos_type const pos_end = lastPos(*this, rit);
|
||||
pos_type const pos_end = lastPos(*this, pit, rit);
|
||||
int labeladdon = 0;
|
||||
int maxwidth = 0;
|
||||
|
||||
@ -1236,8 +1227,9 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
||||
} else if (rit != rows().begin()) {
|
||||
tmptop = layout->topsep;
|
||||
|
||||
if (boost::prior(pit)->getDepth() >= pit->getDepth())
|
||||
tmptop -= boost::prior(rit)->par()->layout()->bottomsep;
|
||||
if (boost::prior(pit)->getDepth() >= pit->getDepth()) {
|
||||
tmptop -= getPar(boost::prior(rit))->layout()->bottomsep;
|
||||
}
|
||||
|
||||
if (tmptop > 0)
|
||||
layoutasc = (tmptop * defaultRowHeight());
|
||||
@ -1263,7 +1255,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
||||
|
||||
// is it a bottom line?
|
||||
RowList::iterator next_rit = boost::next(rit);
|
||||
if (next_rit == rows().end() || next_rit->par() != pit) {
|
||||
if (next_rit == rows().end() || getPar(next_rit) != pit) {
|
||||
// the bottom margin
|
||||
ParagraphList::iterator nextpit = boost::next(pit);
|
||||
if (nextpit == ownerParagraphs().end() &&
|
||||
@ -1334,7 +1326,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
||||
// this IS needed
|
||||
rit->width(maxwidth);
|
||||
double dummy;
|
||||
prepareToPrint(rit, x, dummy, dummy, dummy, false);
|
||||
prepareToPrint(pit, rit, x, dummy, dummy, dummy, false);
|
||||
}
|
||||
rit->width(int(maxwidth + x));
|
||||
if (inset_owner) {
|
||||
@ -1403,18 +1395,13 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
|
||||
// This touches only the screen-update. Otherwise we would may have
|
||||
// an empty row on the screen
|
||||
if (cursor.pos() && cursorRow()->pos() == cursor.pos()
|
||||
&& !cursorRow()->par()->isNewline(cursor.pos() - 1))
|
||||
&& !cursor.par()->isNewline(cursor.pos() - 1))
|
||||
{
|
||||
cursorLeft(bv());
|
||||
}
|
||||
|
||||
removeParagraph(cursorRow());
|
||||
|
||||
// set the dimensions of the cursor row
|
||||
cursorRow()->fill(fill(cursorRow(), workWidth()));
|
||||
|
||||
setHeightOfRow(cursorRow());
|
||||
|
||||
#warning Trouble Point! (Lgb)
|
||||
// When ::breakParagraph is called from within an inset we must
|
||||
// ensure that the correct ParagraphList is used. Today that is not
|
||||
@ -1438,7 +1425,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
|
||||
}
|
||||
|
||||
|
||||
// Just a macro to make some thing easier.
|
||||
// convenience function
|
||||
void LyXText::redoParagraph()
|
||||
{
|
||||
clearSelection();
|
||||
@ -1456,8 +1443,8 @@ void LyXText::insertChar(char c)
|
||||
// When the free-spacing option is set for the current layout,
|
||||
// disable the double-space checking
|
||||
|
||||
bool const freeSpacing = cursorRow()->par()->layout()->free_spacing ||
|
||||
cursorRow()->par()->isFreeSpacing();
|
||||
bool const freeSpacing = cursor.par()->layout()->free_spacing ||
|
||||
cursor.par()->isFreeSpacing();
|
||||
|
||||
if (lyxrc.auto_number) {
|
||||
static string const number_operators = "+-/*";
|
||||
@ -1567,7 +1554,8 @@ void LyXText::charInserted()
|
||||
}
|
||||
|
||||
|
||||
void LyXText::prepareToPrint(RowList::iterator rit, double & x,
|
||||
void LyXText::prepareToPrint(ParagraphList::iterator pit,
|
||||
RowList::iterator rit, double & x,
|
||||
double & fill_separator,
|
||||
double & fill_hfill,
|
||||
double & fill_label_hfill,
|
||||
@ -1579,14 +1567,12 @@ void LyXText::prepareToPrint(RowList::iterator rit, double & x,
|
||||
fill_separator = 0;
|
||||
fill_label_hfill = 0;
|
||||
|
||||
ParagraphList::iterator pit = rit->par();
|
||||
|
||||
bool const is_rtl =
|
||||
pit->isRightToLeftPar(bv()->buffer()->params);
|
||||
if (is_rtl)
|
||||
x = workWidth() > 0 ? rightMargin(*bv()->buffer(), *rit) : 0;
|
||||
x = workWidth() > 0 ? rightMargin(pit, *bv()->buffer(), *rit) : 0;
|
||||
else
|
||||
x = workWidth() > 0 ? leftMargin(*rit) : 0;
|
||||
x = workWidth() > 0 ? leftMargin(pit, *rit) : 0;
|
||||
|
||||
// is there a manual margin with a manual label
|
||||
LyXLayout_ptr const & layout = pit->layout();
|
||||
@ -1594,7 +1580,7 @@ void LyXText::prepareToPrint(RowList::iterator rit, double & x,
|
||||
if (layout->margintype == MARGIN_MANUAL
|
||||
&& layout->labeltype == LABEL_MANUAL) {
|
||||
/// We might have real hfills in the label part
|
||||
int nlh = numberOfLabelHfills(*this, rit);
|
||||
int nlh = numberOfLabelHfills(*this, pit, rit);
|
||||
|
||||
// A manual label par (e.g. List) has an auto-hfill
|
||||
// between the label text and the body of the
|
||||
@ -1605,12 +1591,12 @@ void LyXText::prepareToPrint(RowList::iterator rit, double & x,
|
||||
++nlh;
|
||||
|
||||
if (nlh && !pit->getLabelWidthString().empty()) {
|
||||
fill_label_hfill = labelFill(*rit) / double(nlh);
|
||||
fill_label_hfill = labelFill(pit, *rit) / double(nlh);
|
||||
}
|
||||
}
|
||||
|
||||
// are there any hfills in the row?
|
||||
int const nh = numberOfHfills(*this, rit);
|
||||
int const nh = numberOfHfills(*this, pit, rit);
|
||||
|
||||
if (nh) {
|
||||
if (w > 0)
|
||||
@ -1647,12 +1633,12 @@ void LyXText::prepareToPrint(RowList::iterator rit, double & x,
|
||||
switch (align) {
|
||||
case LYX_ALIGN_BLOCK:
|
||||
{
|
||||
int const ns = numberOfSeparators(*this, rit);
|
||||
int const ns = numberOfSeparators(*this, pit, rit);
|
||||
RowList::iterator next_row = boost::next(rit);
|
||||
ParagraphList::iterator next_pit = next_row->par();
|
||||
ParagraphList::iterator next_pit;
|
||||
|
||||
if (ns && next_row != rowlist_.end() &&
|
||||
next_pit == pit &&
|
||||
(next_pit = getPar(next_row)) == pit &&
|
||||
!(next_pit->isNewline(next_row->pos() - 1))
|
||||
&& !(next_pit->isInset(next_row->pos()) &&
|
||||
next_pit->getInset(next_row->pos()) &&
|
||||
@ -1675,10 +1661,10 @@ void LyXText::prepareToPrint(RowList::iterator rit, double & x,
|
||||
if (!bidi)
|
||||
return;
|
||||
|
||||
computeBidiTables(bv()->buffer(), rit);
|
||||
computeBidiTables(pit, bv()->buffer(), rit);
|
||||
if (is_rtl) {
|
||||
pos_type body_pos = pit->beginningOfBody();
|
||||
pos_type last = lastPos(*this, rit);
|
||||
pos_type last = lastPos(*this, pit, rit);
|
||||
|
||||
if (body_pos > 0 &&
|
||||
(body_pos - 1 > last ||
|
||||
@ -1892,7 +1878,7 @@ void LyXText::selectSelectedWord()
|
||||
|
||||
// now find the end of the word
|
||||
while (cursor.pos() < cursor.par()->size()
|
||||
&& (cursor.par()->isLetter(cursor.pos())))
|
||||
&& cursor.par()->isLetter(cursor.pos()))
|
||||
cursor.pos(cursor.pos() + 1);
|
||||
|
||||
setCursor(cursor.par(), cursor.pos());
|
||||
@ -2181,14 +2167,14 @@ LyXText::getRow(ParagraphList::iterator pit, pos_type pos) const
|
||||
// find the first row of the specified paragraph
|
||||
RowList::iterator rit = rowlist_.begin();
|
||||
RowList::iterator end = rowlist_.end();
|
||||
while (boost::next(rit) != end && rit->par() != pit) {
|
||||
while (boost::next(rit) != end && getPar(rit) != pit) {
|
||||
++rit;
|
||||
}
|
||||
|
||||
// now find the wanted row
|
||||
while (rit->pos() < pos
|
||||
&& boost::next(rit) != end
|
||||
&& boost::next(rit)->par() == pit
|
||||
&& getPar(boost::next(rit)) == pit
|
||||
&& boost::next(rit)->pos() <= pos) {
|
||||
++rit;
|
||||
}
|
||||
@ -2209,7 +2195,7 @@ LyXText::getRow(ParagraphList::iterator pit, pos_type pos, int & y) const
|
||||
// find the first row of the specified paragraph
|
||||
RowList::iterator rit = rowlist_.begin();
|
||||
RowList::iterator end = rowlist_.end();
|
||||
while (boost::next(rit) != end && rit->par() != pit) {
|
||||
while (boost::next(rit) != end && getPar(rit) != pit) {
|
||||
y += rit->height();
|
||||
++rit;
|
||||
}
|
||||
@ -2217,7 +2203,7 @@ LyXText::getRow(ParagraphList::iterator pit, pos_type pos, int & y) const
|
||||
// now find the wanted row
|
||||
while (rit->pos() < pos
|
||||
&& boost::next(rit) != end
|
||||
&& boost::next(rit)->par() == pit
|
||||
&& getPar(boost::next(rit)) == pit
|
||||
&& boost::next(rit)->pos() <= pos) {
|
||||
y += rit->height();
|
||||
++rit;
|
||||
@ -2281,3 +2267,68 @@ int LyXText::getDepth() const
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
148
src/text2.C
148
src/text2.C
@ -89,8 +89,7 @@ void LyXText::init(BufferView * bview)
|
||||
current_font = getFont(ownerParagraphs().begin(), 0);
|
||||
|
||||
redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
|
||||
|
||||
setCursorIntern(rowlist_.begin()->par(), 0);
|
||||
setCursorIntern(ownerParagraphs().begin(), 0);
|
||||
selection.cursor = cursor;
|
||||
|
||||
updateCounters();
|
||||
@ -264,10 +263,10 @@ void LyXText::removeRow(RowList::iterator rit)
|
||||
// remove all following rows of the paragraph of the specified row.
|
||||
void LyXText::removeParagraph(RowList::iterator rit)
|
||||
{
|
||||
ParagraphList::iterator tmppit = rit->par();
|
||||
ParagraphList::iterator tmppit = getPar(rit);
|
||||
++rit;
|
||||
|
||||
while (rit != rows().end() && rit->par() == tmppit) {
|
||||
while (rit != rows().end() && getPar(rit) == tmppit) {
|
||||
RowList::iterator tmprit = boost::next(rit);
|
||||
removeRow(rit);
|
||||
rit = tmprit;
|
||||
@ -279,23 +278,21 @@ void LyXText::insertParagraph(ParagraphList::iterator pit,
|
||||
RowList::iterator rit)
|
||||
{
|
||||
// insert a new row, starting at position 0
|
||||
rit = rowlist_.insert(rit, Row(pit, 0));
|
||||
rit = rowlist_.insert(rit, Row(0));
|
||||
|
||||
// and now append the whole paragraph before the new row
|
||||
Assert(rit != rowlist_.end());
|
||||
|
||||
pos_type const last = rit->par()->size();
|
||||
pos_type const last = pit->size();
|
||||
bool done = false;
|
||||
|
||||
do {
|
||||
pos_type z = rowBreakPoint(*rit);
|
||||
pos_type z = rowBreakPoint(pit, *rit);
|
||||
|
||||
RowList::iterator tmprow = rit;
|
||||
|
||||
if (z < last) {
|
||||
++z;
|
||||
Row newrow(rit->par(), z);
|
||||
rit = rowlist_.insert(boost::next(rit), newrow);
|
||||
rit = rowlist_.insert(boost::next(rit), Row(z));
|
||||
} else {
|
||||
done = true;
|
||||
}
|
||||
@ -609,16 +606,6 @@ 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
|
||||
// This function is needed after SetLayout and SetFont etc.
|
||||
void LyXText::redoParagraphs(ParagraphList::iterator start,
|
||||
@ -631,19 +618,18 @@ void LyXText::redoParagraphs(ParagraphList::iterator start,
|
||||
|
||||
void LyXText::redoParagraph(ParagraphList::iterator pit)
|
||||
{
|
||||
RowList::iterator rit = firstRow(pit);
|
||||
RowList::iterator first = beginRow(pit);
|
||||
RowList::iterator last = endRow(first);
|
||||
|
||||
// remove paragraph from rowlist
|
||||
while (rit != rows().end() && rit->par() == pit) {
|
||||
RowList::iterator rit2 = rit++;
|
||||
while (first != last) {
|
||||
RowList::iterator rit2 = first;
|
||||
++first;
|
||||
removeRow(rit2);
|
||||
}
|
||||
|
||||
// reinsert the paragraph
|
||||
insertParagraph(pit, rit);
|
||||
|
||||
// why?
|
||||
setHeightOfRow(rows().begin());
|
||||
insertParagraph(pit, last);
|
||||
}
|
||||
|
||||
|
||||
@ -730,10 +716,10 @@ void LyXText::cursorEnd()
|
||||
|
||||
RowList::iterator rit = cursorRow();
|
||||
RowList::iterator next_rit = boost::next(rit);
|
||||
ParagraphList::iterator pit = rit->par();
|
||||
pos_type last_pos = lastPos(*this, rit);
|
||||
ParagraphList::iterator pit = cursor.par();
|
||||
pos_type last_pos = lastPos(*this, pit, rit);
|
||||
|
||||
if (next_rit == rows().end() || next_rit->par() != pit) {
|
||||
if (next_rit == rows().end() || getPar(next_rit) != pit) {
|
||||
++last_pos;
|
||||
} else {
|
||||
if (pit->empty() ||
|
||||
@ -1420,7 +1406,7 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
|
||||
cur.iy(y + row->baseline());
|
||||
if (row != beg &&
|
||||
pos &&
|
||||
boost::prior(row)->par() == row->par() &&
|
||||
getPar(boost::prior(row)) == getPar(row) &&
|
||||
pos < pit->size() &&
|
||||
pit->getChar(pos) == Paragraph::META_INSET) {
|
||||
InsetOld * ins = pit->getInset(pos);
|
||||
@ -1435,7 +1421,7 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
|
||||
// y is now the cursor baseline
|
||||
cur.y(y);
|
||||
|
||||
pos_type last = lastPrintablePos(*this, old_row);
|
||||
pos_type last = lastPrintablePos(*this, pit, old_row);
|
||||
|
||||
// None of these should happen, but we're scaredy-cats
|
||||
if (pos > pit->size()) {
|
||||
@ -1454,11 +1440,11 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
|
||||
}
|
||||
|
||||
// now get the cursors x position
|
||||
float x = getCursorX(row, pos, last, boundary);
|
||||
float x = getCursorX(pit, row, pos, last, boundary);
|
||||
cur.x(int(x));
|
||||
cur.x_fix(cur.x());
|
||||
if (old_row != row) {
|
||||
x = getCursorX(old_row, pos, last, boundary);
|
||||
x = getCursorX(pit, old_row, pos, last, boundary);
|
||||
cur.ix(int(x));
|
||||
} else
|
||||
cur.ix(cur.x());
|
||||
@ -1476,7 +1462,7 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
|
||||
}
|
||||
|
||||
|
||||
float LyXText::getCursorX(RowList::iterator rit,
|
||||
float LyXText::getCursorX(ParagraphList::iterator pit, RowList::iterator rit,
|
||||
pos_type pos, pos_type last, bool boundary) const
|
||||
{
|
||||
pos_type cursor_vpos = 0;
|
||||
@ -1485,16 +1471,15 @@ float LyXText::getCursorX(RowList::iterator rit,
|
||||
double fill_hfill;
|
||||
double fill_label_hfill;
|
||||
// This call HAS to be here because of the BidiTables!!!
|
||||
prepareToPrint(rit, x, fill_separator, fill_hfill,
|
||||
prepareToPrint(pit, rit, x, fill_separator, fill_hfill,
|
||||
fill_label_hfill);
|
||||
|
||||
ParagraphList::iterator rit_par = rit->par();
|
||||
pos_type const rit_pos = rit->pos();
|
||||
|
||||
if (last < rit_pos)
|
||||
cursor_vpos = rit_pos;
|
||||
else if (pos > last && !boundary)
|
||||
cursor_vpos = (rit_par->isRightToLeftPar(bv()->buffer()->params))
|
||||
cursor_vpos = (pit->isRightToLeftPar(bv()->buffer()->params))
|
||||
? rit_pos : last + 1;
|
||||
else if (pos > rit_pos && (pos > last || boundary))
|
||||
// Place cursor after char at (logical) position pos - 1
|
||||
@ -1505,9 +1490,9 @@ float LyXText::getCursorX(RowList::iterator rit,
|
||||
cursor_vpos = (bidi_level(pos) % 2 == 0)
|
||||
? log2vis(pos) : log2vis(pos) + 1;
|
||||
|
||||
pos_type body_pos = rit_par->beginningOfBody();
|
||||
pos_type body_pos = pit->beginningOfBody();
|
||||
if (body_pos > 0 &&
|
||||
(body_pos - 1 > last || !rit_par->isLineSeparator(body_pos - 1)))
|
||||
(body_pos - 1 > last || !pit->isLineSeparator(body_pos - 1)))
|
||||
body_pos = 0;
|
||||
|
||||
for (pos_type vpos = rit_pos; vpos < cursor_vpos; ++vpos) {
|
||||
@ -1515,23 +1500,23 @@ float LyXText::getCursorX(RowList::iterator rit,
|
||||
if (body_pos > 0 && pos == body_pos - 1) {
|
||||
x += fill_label_hfill +
|
||||
font_metrics::width(
|
||||
rit_par->layout()->labelsep, getLabelFont(rit_par));
|
||||
if (rit_par->isLineSeparator(body_pos - 1))
|
||||
x -= singleWidth(rit_par, body_pos - 1);
|
||||
pit->layout()->labelsep, getLabelFont(pit));
|
||||
if (pit->isLineSeparator(body_pos - 1))
|
||||
x -= singleWidth(pit, body_pos - 1);
|
||||
}
|
||||
|
||||
if (hfillExpansion(*this, rit, pos)) {
|
||||
x += singleWidth(rit_par, pos);
|
||||
if (hfillExpansion(*this, pit, rit, pos)) {
|
||||
x += singleWidth(pit, pos);
|
||||
if (pos >= body_pos)
|
||||
x += fill_hfill;
|
||||
else
|
||||
x += fill_label_hfill;
|
||||
} else if (rit_par->isSeparator(pos)) {
|
||||
x += singleWidth(rit_par, pos);
|
||||
} else if (pit->isSeparator(pos)) {
|
||||
x += singleWidth(pit, pos);
|
||||
if (pos >= body_pos)
|
||||
x += fill_separator;
|
||||
} else
|
||||
x += singleWidth(rit_par, pos);
|
||||
x += singleWidth(pit, pos);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
@ -1586,35 +1571,33 @@ void LyXText::setCurrentFont()
|
||||
|
||||
// returns the column near the specified x-coordinate of the row
|
||||
// x is set to the real beginning of this column
|
||||
pos_type
|
||||
LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
|
||||
pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
|
||||
RowList::iterator rit, int & x, bool & boundary) const
|
||||
{
|
||||
double tmpx = 0;
|
||||
double fill_separator;
|
||||
double fill_hfill;
|
||||
double fill_label_hfill;
|
||||
|
||||
prepareToPrint(rit, tmpx, fill_separator, fill_hfill, fill_label_hfill);
|
||||
prepareToPrint(pit, rit, tmpx, fill_separator, fill_hfill, fill_label_hfill);
|
||||
|
||||
pos_type vc = rit->pos();
|
||||
pos_type last = lastPrintablePos(*this, rit);
|
||||
pos_type last = lastPrintablePos(*this, pit, rit);
|
||||
pos_type c = 0;
|
||||
|
||||
ParagraphList::iterator rit_par = rit->par();
|
||||
LyXLayout_ptr const & layout = rit->par()->layout();
|
||||
LyXLayout_ptr const & layout = pit->layout();
|
||||
|
||||
bool left_side = false;
|
||||
|
||||
pos_type body_pos = rit_par->beginningOfBody();
|
||||
pos_type body_pos = pit->beginningOfBody();
|
||||
double last_tmpx = tmpx;
|
||||
|
||||
if (body_pos > 0 &&
|
||||
(body_pos - 1 > last ||
|
||||
!rit_par->isLineSeparator(body_pos - 1)))
|
||||
!pit->isLineSeparator(body_pos - 1)))
|
||||
body_pos = 0;
|
||||
|
||||
// check for empty row
|
||||
if (!rit_par->size()) {
|
||||
if (!pit->size()) {
|
||||
x = int(tmpx);
|
||||
return 0;
|
||||
}
|
||||
@ -1624,23 +1607,23 @@ LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
|
||||
last_tmpx = tmpx;
|
||||
if (body_pos > 0 && c == body_pos - 1) {
|
||||
tmpx += fill_label_hfill +
|
||||
font_metrics::width(layout->labelsep, getLabelFont(rit_par));
|
||||
if (rit_par->isLineSeparator(body_pos - 1))
|
||||
tmpx -= singleWidth(rit_par, body_pos - 1);
|
||||
font_metrics::width(layout->labelsep, getLabelFont(pit));
|
||||
if (pit->isLineSeparator(body_pos - 1))
|
||||
tmpx -= singleWidth(pit, body_pos - 1);
|
||||
}
|
||||
|
||||
if (hfillExpansion(*this, rit, c)) {
|
||||
tmpx += singleWidth(rit_par, c);
|
||||
if (hfillExpansion(*this, pit, rit, c)) {
|
||||
tmpx += singleWidth(pit, c);
|
||||
if (c >= body_pos)
|
||||
tmpx += fill_hfill;
|
||||
else
|
||||
tmpx += fill_label_hfill;
|
||||
} else if (rit_par->isSeparator(c)) {
|
||||
tmpx += singleWidth(rit_par, c);
|
||||
} else if (pit->isSeparator(c)) {
|
||||
tmpx += singleWidth(pit, c);
|
||||
if (c >= body_pos)
|
||||
tmpx += fill_separator;
|
||||
} else {
|
||||
tmpx += singleWidth(rit_par, c);
|
||||
tmpx += singleWidth(pit, c);
|
||||
}
|
||||
++vc;
|
||||
}
|
||||
@ -1659,13 +1642,12 @@ LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
|
||||
RowList::iterator next_rit = boost::next(rit);
|
||||
|
||||
bool const lastrow = lyxrc.rtl_support &&
|
||||
(next_rit == rowlist_.end() ||
|
||||
next_rit->par() != rit_par);
|
||||
(next_rit == rowlist_.end() || getPar(next_rit) != pit);
|
||||
|
||||
// If lastrow is false, we don't need to compute
|
||||
// the value of rtl.
|
||||
bool const rtl = (lastrow)
|
||||
? rit_par->isRightToLeftPar(bv()->buffer()->params)
|
||||
? pit->isRightToLeftPar(bv()->buffer()->params)
|
||||
: false;
|
||||
if (lastrow &&
|
||||
((rtl && left_side && vc == rit->pos() && x < tmpx - 5) ||
|
||||
@ -1680,16 +1662,15 @@ LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
|
||||
bool const rtl = (bidi_level(c) % 2 == 1);
|
||||
if (left_side == rtl) {
|
||||
++c;
|
||||
boundary = isBoundary(bv()->buffer(), *rit_par, c);
|
||||
boundary = isBoundary(bv()->buffer(), *pit, c);
|
||||
}
|
||||
}
|
||||
|
||||
if (rit->pos() <= last && c > last
|
||||
&& rit_par->isNewline(last)) {
|
||||
if (rit->pos() <= last && c > last && pit->isNewline(last)) {
|
||||
if (bidi_level(last) % 2 == 0)
|
||||
tmpx -= singleWidth(rit_par, last);
|
||||
tmpx -= singleWidth(pit, last);
|
||||
else
|
||||
tmpx += singleWidth(rit_par, last);
|
||||
tmpx += singleWidth(pit, last);
|
||||
c = last;
|
||||
}
|
||||
|
||||
@ -1722,9 +1703,9 @@ namespace {
|
||||
if (boost::next(row) == lt.rows().end())
|
||||
return false;
|
||||
|
||||
Row const & next = *boost::next(row);
|
||||
RowList::iterator next = boost::next(row);
|
||||
|
||||
if (next.pos() != cur.pos() || next.par() != cur.par())
|
||||
if (next->pos() != cur.pos() || lt.getPar(next) != cur.par())
|
||||
return false;
|
||||
|
||||
if (cur.pos() == cur.par()->size()
|
||||
@ -1745,19 +1726,18 @@ void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y)
|
||||
// Get the row first.
|
||||
|
||||
RowList::iterator row = getRowNearY(y);
|
||||
ParagraphList::iterator pit = getPar(row);
|
||||
bool bound = false;
|
||||
pos_type const column = getColumnNearX(row, x, bound);
|
||||
cur.par(row->par());
|
||||
pos_type const column = getColumnNearX(pit, row, x, bound);
|
||||
cur.par(pit);
|
||||
cur.pos(row->pos() + column);
|
||||
cur.x(x);
|
||||
cur.y(y + row->baseline());
|
||||
|
||||
if (beforeFullRowInset(*this, cur)) {
|
||||
pos_type const last = lastPrintablePos(*this, row);
|
||||
pos_type const last = lastPrintablePos(*this, pit, row);
|
||||
RowList::iterator next_row = boost::next(row);
|
||||
|
||||
float x = getCursorX(next_row, cur.pos(), last, bound);
|
||||
cur.ix(int(x));
|
||||
cur.ix(int(getCursorX(pit, next_row, cur.pos(), last, bound)));
|
||||
cur.iy(y + row->height() + next_row->baseline());
|
||||
} else {
|
||||
cur.iy(cur.y());
|
||||
@ -2011,7 +1991,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
|
||||
* there is another layout before */
|
||||
RowList::iterator tmprit = boost::next(prevrow);
|
||||
if (tmprit != rows().end()) {
|
||||
redoParagraph(tmprit->par());
|
||||
redoParagraph(getPar(tmprit));
|
||||
updateCounters();
|
||||
}
|
||||
setHeightOfRow(prevrow);
|
||||
@ -2040,7 +2020,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
|
||||
The next row can change its height, if
|
||||
there is another layout before */
|
||||
if (nextrow != rows().end()) {
|
||||
redoParagraph(nextrow->par());
|
||||
redoParagraph(getPar(nextrow));
|
||||
updateCounters();
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ void LyXText::cursorPrevious()
|
||||
//bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y);
|
||||
if (cursorRow() != rows().begin()) {
|
||||
LyXCursor cur;
|
||||
setCursor(cur, boost::prior(cursorRow())->par(),
|
||||
setCursor(cur, getPar(boost::prior(cursorRow())),
|
||||
boost::prior(cursorRow())->pos(), false);
|
||||
if (cur.y() > top_y()) {
|
||||
cursorUp(true);
|
||||
@ -338,7 +338,7 @@ void LyXText::cursorNext()
|
||||
RowList::iterator next_row = boost::next(cursorRow());
|
||||
if (next_row != rows().end()) {
|
||||
LyXCursor cur;
|
||||
setCursor(cur, next_row->par(), next_row->pos(), false);
|
||||
setCursor(cur, getPar(next_row), next_row->pos(), false);
|
||||
if (cur.y() < top_y() + bv()->workHeight()) {
|
||||
cursorDown(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user