mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-30 05:12:40 +00:00
RowList::iterator -> Row &, ParagraphList::iterator -> Paragraph &
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7929 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1684282f8a
commit
7f3eb7cf70
@ -399,8 +399,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(text->cursorPar(), *bv->buffer(),
|
||||
text->cursorRow());
|
||||
text->computeBidiTables(*text->cursorPar(), *bv->buffer(),
|
||||
*text->cursorRow());
|
||||
if (cursor.boundary() !=
|
||||
text->isBoundary(*bv->buffer(), *text->cursorPar(), cursor.pos(),
|
||||
text->real_current_font))
|
||||
@ -411,11 +411,11 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
|
||||
|
||||
|
||||
// deletes a selection during an insertion
|
||||
void replaceSelection(LyXText * lt)
|
||||
void replaceSelection(LyXText * text)
|
||||
{
|
||||
if (lt->selection.set()) {
|
||||
lt->cutSelection(true, false);
|
||||
lt->bv()->update();
|
||||
if (text->selection.set()) {
|
||||
text->cutSelection(true, false);
|
||||
text->bv()->update();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -953,7 +953,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
|
||||
}
|
||||
|
||||
if (result == FINISHED_UP) {
|
||||
RowList::iterator const irow = view()->text->cursorIRow();
|
||||
RowList::iterator const irow = view()->text->cursorRow();
|
||||
if (irow != view()->text->firstRow()) {
|
||||
#if 1
|
||||
view()->text->setCursorFromCoordinates(
|
||||
@ -973,7 +973,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
|
||||
}
|
||||
|
||||
if (result == FINISHED_DOWN) {
|
||||
RowList::iterator const irow = view()->text->cursorIRow();
|
||||
RowList::iterator const irow = view()->text->cursorRow();
|
||||
if (irow != view()->text->lastRow()) {
|
||||
#if 1
|
||||
view()->text->setCursorFromCoordinates(
|
||||
|
@ -15,11 +15,8 @@
|
||||
#include "debug.h"
|
||||
#include "lyxlayout.h"
|
||||
#include "lyxrow.h"
|
||||
#include "lyxtext.h"
|
||||
#include "paragraph.h"
|
||||
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
using lyx::pos_type;
|
||||
|
||||
using std::max;
|
||||
@ -27,51 +24,28 @@ using std::min;
|
||||
using std::endl;
|
||||
|
||||
|
||||
bool isParEnd(Paragraph const & par, RowList::iterator rit)
|
||||
bool isParEnd(Paragraph const & par, Row const & row)
|
||||
{
|
||||
#if 0
|
||||
if ((boost::next(rit) == par.rows.end()) != (rit->end() >= par.size())) {
|
||||
lyxerr << endl;
|
||||
lyxerr << "broken row 1: end: " << rit->end() << " next: "
|
||||
<< boost::next(rit)->pos() << endl;
|
||||
lyxerr << endl;
|
||||
BOOST_ASSERT(false);
|
||||
}
|
||||
#endif
|
||||
return boost::next(rit) == par.rows.end();
|
||||
return row.end() == par.size();
|
||||
}
|
||||
|
||||
#if 1
|
||||
pos_type lastPos(Paragraph const & par, RowList::iterator rit)
|
||||
|
||||
pos_type lastPos(Paragraph const & par, Row const & row)
|
||||
{
|
||||
if (par.empty())
|
||||
return 0;
|
||||
|
||||
if (isParEnd(par, rit))
|
||||
return par.size() - 1;
|
||||
|
||||
if (1 && boost::next(rit)->pos() != rit->end()) {
|
||||
lyxerr << endl;
|
||||
lyxerr << "broken row 2: end: " << rit->end() << " next: "
|
||||
<< boost::next(rit)->pos() << endl;
|
||||
lyxerr << endl;
|
||||
BOOST_ASSERT(false);
|
||||
pos_type pos = row.end() - 1;
|
||||
if (pos == par.size())
|
||||
--pos;
|
||||
return pos;
|
||||
}
|
||||
return boost::next(rit)->pos() - 1;
|
||||
}
|
||||
#else
|
||||
pos_type lastPos(Paragraph const &, RowList::iterator rit)
|
||||
|
||||
|
||||
int numberOfSeparators(Paragraph const & par, Row const & row)
|
||||
{
|
||||
return rit->end() - 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int numberOfSeparators(Paragraph const & par, RowList::iterator rit)
|
||||
{
|
||||
pos_type const last = lastPos(par, rit);
|
||||
pos_type const last = lastPos(par, row);
|
||||
int n = 0;
|
||||
pos_type p = max(rit->pos(), par.beginningOfBody());
|
||||
pos_type p = max(row.pos(), par.beginningOfBody());
|
||||
for ( ; p < last; ++p)
|
||||
if (par.isSeparator(p))
|
||||
++n;
|
||||
@ -81,10 +55,10 @@ int numberOfSeparators(Paragraph const & par, RowList::iterator rit)
|
||||
|
||||
// This is called _once_ from LyXText and should at least be moved into
|
||||
// an anonymous namespace there. (Lgb)
|
||||
int numberOfHfills(Paragraph const & par, RowList::iterator rit)
|
||||
int numberOfHfills(Paragraph const & par, Row const & row)
|
||||
{
|
||||
pos_type const last = lastPos(par, rit);
|
||||
pos_type first = rit->pos();
|
||||
pos_type const last = lastPos(par, row);
|
||||
pos_type first = row.pos();
|
||||
|
||||
// hfill *DO* count at the beginning of paragraphs!
|
||||
if (first) {
|
||||
@ -97,9 +71,10 @@ int numberOfHfills(Paragraph const & par, RowList::iterator rit)
|
||||
int n = 0;
|
||||
|
||||
// last, because the end is ignored!
|
||||
for (pos_type p = first; p < last; ++p)
|
||||
for (pos_type p = first; p < last; ++p) {
|
||||
if (par.isHfill(p))
|
||||
++n;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
@ -107,10 +82,10 @@ int numberOfHfills(Paragraph const & par, RowList::iterator rit)
|
||||
|
||||
// This is called _once_ from LyXText and should at least be moved into
|
||||
// an anonymous namespace there. (Lgb)
|
||||
int numberOfLabelHfills(Paragraph const & par, RowList::iterator rit)
|
||||
int numberOfLabelHfills(Paragraph const & par, Row const & row)
|
||||
{
|
||||
pos_type last = lastPos(par, rit);
|
||||
pos_type first = rit->pos();
|
||||
pos_type last = lastPos(par, row);
|
||||
pos_type first = row.pos();
|
||||
|
||||
// hfill *DO* count at the beginning of paragraphs!
|
||||
if (first) {
|
||||
@ -121,29 +96,30 @@ int numberOfLabelHfills(Paragraph const & par, RowList::iterator rit)
|
||||
last = min(last, par.beginningOfBody());
|
||||
int n = 0;
|
||||
|
||||
// last, because the end is ignored!
|
||||
// last, because the end is ignored
|
||||
for (pos_type p = first; p < last; ++p) {
|
||||
if (par.isHfill(p))
|
||||
++n;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
bool hfillExpansion(Paragraph const & par, RowList::iterator rit, pos_type pos)
|
||||
bool hfillExpansion(Paragraph const & par, Row const & row, pos_type pos)
|
||||
{
|
||||
if (!par.isHfill(pos))
|
||||
return false;
|
||||
|
||||
// at the end of a row it does not count
|
||||
// unless another hfill exists on the line
|
||||
if (pos >= lastPos(par, rit))
|
||||
for (pos_type i = rit->pos(); i < pos && !par.isHfill(i); ++i)
|
||||
if (pos >= lastPos(par, row))
|
||||
for (pos_type i = row.pos(); i < pos && !par.isHfill(i); ++i)
|
||||
return false;
|
||||
|
||||
// at the beginning of a row it does not count, if it is not
|
||||
// the first row of a paragaph
|
||||
if (rit->isParStart())
|
||||
if (row.isParStart())
|
||||
return true;
|
||||
|
||||
// in some labels it does not count
|
||||
@ -154,7 +130,7 @@ bool hfillExpansion(Paragraph const & par, RowList::iterator rit, pos_type pos)
|
||||
// if there is anything between the first char of the row and
|
||||
// the specified position that is not a newline and not a hfill,
|
||||
// the hfill will count, otherwise not
|
||||
pos_type i = rit->pos();
|
||||
pos_type i = row.pos();
|
||||
while (i < pos && (par.isNewline(i) || par.isHfill(i)))
|
||||
++i;
|
||||
|
||||
|
@ -13,22 +13,22 @@
|
||||
#ifndef LYXROW_FUNCS_H
|
||||
#define LYXROW_FUNCS_H
|
||||
|
||||
#include "RowList_fwd.h"
|
||||
#include "support/types.h"
|
||||
|
||||
class Paragraph;
|
||||
class Row;
|
||||
|
||||
bool isParEnd(Paragraph const & par, RowList::iterator rit);
|
||||
bool isParEnd(Paragraph const & par, Row const & row);
|
||||
|
||||
lyx::pos_type lastPos(Paragraph const & par, RowList::iterator rit);
|
||||
lyx::pos_type lastPos(Paragraph const & par, Row const & row);
|
||||
|
||||
int numberOfSeparators(Paragraph const & par, RowList::iterator rit);
|
||||
int numberOfSeparators(Paragraph const & par, Row const & row);
|
||||
|
||||
int numberOfHfills(Paragraph const & par, RowList::iterator rit);
|
||||
int numberOfHfills(Paragraph const & par, Row const & row);
|
||||
|
||||
int numberOfLabelHfills(Paragraph const & par, RowList::iterator rit);
|
||||
int numberOfLabelHfills(Paragraph const & par, Row const & row);
|
||||
|
||||
bool hfillExpansion(Paragraph const & par, RowList::iterator rit,
|
||||
bool hfillExpansion(Paragraph const & par, Row const & row,
|
||||
lyx::pos_type pos);
|
||||
|
||||
#endif
|
||||
|
@ -167,8 +167,7 @@ public:
|
||||
|
||||
private:
|
||||
/// returns a pointer to a specified row.
|
||||
RowList::iterator
|
||||
getRow(ParagraphList::iterator pit, lyx::pos_type pos) const;
|
||||
RowList::iterator getRow(Paragraph & par, lyx::pos_type pos) const;
|
||||
public:
|
||||
/// returns an iterator pointing to a cursor row
|
||||
RowList::iterator getRow(LyXCursor const & cursor) const;
|
||||
@ -182,13 +181,6 @@ public:
|
||||
int parOffset(ParagraphList::iterator pit) const;
|
||||
/// convenience
|
||||
ParagraphList::iterator cursorPar() const;
|
||||
/**
|
||||
* Return the next row, when cursor is at the end of the
|
||||
* previous row, for insets that take a full row.
|
||||
*
|
||||
* FIXME: explain why we need this ? especially for y...
|
||||
*/
|
||||
RowList::iterator cursorIRow() const;
|
||||
|
||||
/** returns a pointer to the row near the specified y-coordinate
|
||||
(relative to the whole text). y is set to the real beginning
|
||||
@ -201,7 +193,7 @@ public:
|
||||
x is set to the real beginning of this column
|
||||
*/
|
||||
lyx::pos_type getColumnNearX(ParagraphList::iterator pit,
|
||||
RowList::iterator rit, int & x, bool & boundary) const;
|
||||
Row const & row, int & x, bool & boundary) const;
|
||||
|
||||
/// need the selection cursor:
|
||||
void setSelection();
|
||||
@ -234,19 +226,14 @@ public:
|
||||
///
|
||||
void setCursor(ParagraphList::iterator pit, lyx::pos_type pos);
|
||||
/// returns true if par was empty and was removed
|
||||
bool setCursor(lyx::paroffset_type par,
|
||||
lyx::pos_type pos,
|
||||
bool setfont = true,
|
||||
bool boundary = false);
|
||||
bool setCursor(lyx::paroffset_type par, lyx::pos_type pos,
|
||||
bool setfont = true, bool boundary = false);
|
||||
///
|
||||
void setCursor(LyXCursor &, lyx::paroffset_type par,
|
||||
lyx::pos_type pos,
|
||||
bool boundary = false);
|
||||
lyx::pos_type pos, bool boundary = false);
|
||||
///
|
||||
void setCursorIntern(lyx::paroffset_type par,
|
||||
lyx::pos_type pos,
|
||||
bool setfont = true,
|
||||
bool boundary = false);
|
||||
void setCursorIntern(lyx::paroffset_type par, lyx::pos_type pos,
|
||||
bool setfont = true, bool boundary = false);
|
||||
///
|
||||
void setCurrentFont();
|
||||
|
||||
@ -255,8 +242,7 @@ public:
|
||||
lyx::pos_type pos) const;
|
||||
///
|
||||
bool isBoundary(Buffer const &, Paragraph const & par,
|
||||
lyx::pos_type pos,
|
||||
LyXFont const & font) const;
|
||||
lyx::pos_type pos, LyXFont const & font) const;
|
||||
|
||||
///
|
||||
void recUndo(lyx::paroffset_type first, lyx::paroffset_type last) const;
|
||||
@ -265,8 +251,7 @@ public:
|
||||
///
|
||||
void setCursorFromCoordinates(int x, int y);
|
||||
///
|
||||
void setCursorFromCoordinates(LyXCursor &,
|
||||
int x, int y);
|
||||
void setCursorFromCoordinates(LyXCursor &, int x, int y);
|
||||
///
|
||||
void cursorUp(bool selecting = false);
|
||||
///
|
||||
@ -368,8 +353,8 @@ public:
|
||||
int workWidth() const;
|
||||
|
||||
///
|
||||
void computeBidiTables(ParagraphList::iterator pit,
|
||||
Buffer const &, RowList::iterator row) const;
|
||||
void computeBidiTables(Paragraph const & par,
|
||||
Buffer const &, Row & 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.
|
||||
@ -381,13 +366,13 @@ public:
|
||||
private:
|
||||
///
|
||||
float getCursorX(ParagraphList::iterator pit,
|
||||
RowList::iterator rit, lyx::pos_type pos,
|
||||
Row const & row, lyx::pos_type pos,
|
||||
lyx::pos_type last, bool boundary) const;
|
||||
/// used in setlayout
|
||||
void makeFontEntriesLayoutSpecific(BufferParams const &, Paragraph & par);
|
||||
|
||||
/// Calculate and set the height of the row
|
||||
void setHeightOfRow(ParagraphList::iterator, RowList::iterator rit);
|
||||
void setHeightOfRow(ParagraphList::iterator, Row & row);
|
||||
|
||||
// fix the cursor `cur' after a characters has been deleted at `where'
|
||||
// position. Called by deleteEmptyParagraphMechanism
|
||||
@ -429,7 +414,7 @@ public:
|
||||
*/
|
||||
int leftMargin(ParagraphList::iterator pit, Row const & row) const;
|
||||
///
|
||||
int rightMargin(ParagraphList::iterator pit, Buffer const &, Row const & row) const;
|
||||
int rightMargin(Paragraph const & par, Buffer const &, Row const & row) const;
|
||||
|
||||
/** this calculates the specified parameters. needed when setting
|
||||
* the cursor and when creating a visible row */
|
||||
@ -446,19 +431,13 @@ private:
|
||||
///
|
||||
void deleteLineForward();
|
||||
|
||||
/*
|
||||
* some low level functions
|
||||
*/
|
||||
|
||||
|
||||
/// sets row.end to the pos value *after* which a row should break.
|
||||
/// for example, the pos after which isNewLine(pos) == true
|
||||
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(ParagraphList::iterator pit,
|
||||
RowList::iterator row, int workwidth) const;
|
||||
int fill(ParagraphList::iterator pit, Row & row, int workwidth) const;
|
||||
|
||||
/**
|
||||
* returns the minimum space a manual label needs on the
|
||||
|
@ -637,7 +637,7 @@ int Paragraph::beginningOfBody() const
|
||||
|
||||
// Unroll the first two cycles of the loop
|
||||
// and remember the previous character to
|
||||
// remove unnecessary GetChar() calls
|
||||
// remove unnecessary getChar() calls
|
||||
pos_type i = 0;
|
||||
if (i < size() && !isNewline(i)) {
|
||||
++i;
|
||||
|
@ -257,7 +257,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 = lastPos(*pit_, row_);
|
||||
pos_type const last = lastPos(*pit_, *row_);
|
||||
LyXFont orig_font = getFont(pos);
|
||||
|
||||
// first character
|
||||
@ -434,7 +434,7 @@ void RowPainter::paintSelection()
|
||||
int(x_), row_->height(), LColor::selection);
|
||||
|
||||
pos_type const body_pos = pit_->beginningOfBody();
|
||||
pos_type const last = lastPos(*pit_, row_);
|
||||
pos_type const last = lastPos(*pit_, *row_);
|
||||
double tmpx = x_;
|
||||
|
||||
for (pos_type vpos = row_->pos(); vpos <= last; ++vpos) {
|
||||
@ -450,7 +450,7 @@ void RowPainter::paintSelection()
|
||||
tmpx -= singleWidth(body_pos - 1);
|
||||
}
|
||||
|
||||
if (hfillExpansion(*pit_, row_, pos)) {
|
||||
if (hfillExpansion(*pit_, *row_, pos)) {
|
||||
tmpx += singleWidth(pos);
|
||||
if (pos >= body_pos)
|
||||
tmpx += hfill_;
|
||||
@ -486,7 +486,7 @@ void RowPainter::paintSelection()
|
||||
void RowPainter::paintChangeBar()
|
||||
{
|
||||
pos_type const start = row_->pos();
|
||||
pos_type const end = lastPos(*pit_, row_);
|
||||
pos_type const end = lastPos(*pit_, *row_);
|
||||
|
||||
if (!pit_->isChanged(start, end))
|
||||
return;
|
||||
@ -809,7 +809,7 @@ void RowPainter::paintFirst()
|
||||
double x = x_;
|
||||
if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
|
||||
x = ((is_rtl ? leftMargin() : x_)
|
||||
+ ww - text_.rightMargin(pit_, *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() -
|
||||
@ -889,7 +889,7 @@ void RowPainter::paintLast()
|
||||
string const & str = pit_->layout()->endlabelstring();
|
||||
double const x = is_rtl ?
|
||||
x_ - font_metrics::width(str, font)
|
||||
: ww - text_.rightMargin(pit_, *bv_.buffer(), *row_) - row_->fill();
|
||||
: ww - text_.rightMargin(*pit_, *bv_.buffer(), *row_) - row_->fill();
|
||||
pain_.text(int(x), yo_ + row_->baseline(), str, font);
|
||||
break;
|
||||
}
|
||||
@ -901,7 +901,7 @@ void RowPainter::paintLast()
|
||||
|
||||
void RowPainter::paintText()
|
||||
{
|
||||
pos_type const last = lastPos(*pit_, row_);
|
||||
pos_type const last = lastPos(*pit_, *row_);
|
||||
pos_type body_pos = pit_->beginningOfBody();
|
||||
if (body_pos > 0 &&
|
||||
(body_pos - 1 > last || !pit_->isLineSeparator(body_pos - 1))) {
|
||||
@ -966,7 +966,7 @@ void RowPainter::paintText()
|
||||
|
||||
pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
|
||||
|
||||
if (hfillExpansion(*pit_, row_, pos)) {
|
||||
if (hfillExpansion(*pit_, *row_, pos)) {
|
||||
int const y2 = (y0 + y1) / 2;
|
||||
|
||||
if (pos >= body_pos) {
|
||||
@ -1039,7 +1039,7 @@ void RowPainter::paint()
|
||||
if (row_->isParStart())
|
||||
paintFirst();
|
||||
|
||||
if (isParEnd(*pit_, row_))
|
||||
if (isParEnd(*pit_, *row_))
|
||||
paintLast();
|
||||
|
||||
// paint text
|
||||
|
263
src/text.C
263
src/text.C
@ -31,6 +31,7 @@
|
||||
#include "lyxrc.h"
|
||||
#include "lyxrow.h"
|
||||
#include "lyxrow_funcs.h"
|
||||
#include "metricsinfo.h"
|
||||
#include "paragraph.h"
|
||||
#include "paragraph_funcs.h"
|
||||
#include "ParagraphParameters.h"
|
||||
@ -265,8 +266,8 @@ bool LyXText::bidi_InRange(lyx::pos_type pos) const
|
||||
}
|
||||
|
||||
|
||||
void LyXText::computeBidiTables(ParagraphList::iterator pit,
|
||||
Buffer const & buf, RowList::iterator row) const
|
||||
void LyXText::computeBidiTables(Paragraph const & par,
|
||||
Buffer const & buf, Row & row) const
|
||||
{
|
||||
bidi_same_direction = true;
|
||||
if (!lyxrc.rtl_support) {
|
||||
@ -274,15 +275,15 @@ void LyXText::computeBidiTables(ParagraphList::iterator pit,
|
||||
return;
|
||||
}
|
||||
|
||||
InsetOld * inset = pit->inInset();
|
||||
InsetOld * inset = par.inInset();
|
||||
if (inset && inset->owner() &&
|
||||
inset->owner()->lyxCode() == InsetOld::ERT_CODE) {
|
||||
bidi_start = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
bidi_start = row->pos();
|
||||
bidi_end = lastPos(*pit, row);
|
||||
bidi_start = row.pos();
|
||||
bidi_end = lastPos(par, row);
|
||||
|
||||
if (bidi_start > bidi_end) {
|
||||
bidi_start = -1;
|
||||
@ -304,26 +305,25 @@ void LyXText::computeBidiTables(ParagraphList::iterator pit,
|
||||
|
||||
BufferParams const & bufparams = buf.params();
|
||||
pos_type stack[2];
|
||||
bool const rtl_par =
|
||||
pit->isRightToLeftPar(bufparams);
|
||||
bool const rtl_par = par.isRightToLeftPar(bufparams);
|
||||
int level = 0;
|
||||
bool rtl = false;
|
||||
bool rtl0 = false;
|
||||
pos_type const body_pos = pit->beginningOfBody();
|
||||
pos_type const body_pos = par.beginningOfBody();
|
||||
|
||||
for (pos_type lpos = bidi_start; lpos <= bidi_end; ++lpos) {
|
||||
bool is_space = pit->isLineSeparator(lpos);
|
||||
bool is_space = par.isLineSeparator(lpos);
|
||||
pos_type const pos =
|
||||
(is_space && lpos + 1 <= bidi_end &&
|
||||
!pit->isLineSeparator(lpos + 1) &&
|
||||
!pit->isNewline(lpos + 1))
|
||||
!par.isLineSeparator(lpos + 1) &&
|
||||
!par.isNewline(lpos + 1))
|
||||
? lpos + 1 : lpos;
|
||||
LyXFont font = pit->getFontSettings(bufparams, pos);
|
||||
LyXFont font = par.getFontSettings(bufparams, pos);
|
||||
if (pos != lpos && 0 < lpos && rtl0 && font.isRightToLeft() &&
|
||||
font.number() == LyXFont::ON &&
|
||||
pit->getFontSettings(bufparams, lpos - 1).number()
|
||||
par.getFontSettings(bufparams, lpos - 1).number()
|
||||
== LyXFont::ON) {
|
||||
font = pit->getFontSettings(bufparams, lpos);
|
||||
font = par.getFontSettings(bufparams, lpos);
|
||||
is_space = false;
|
||||
}
|
||||
|
||||
@ -333,14 +333,15 @@ void LyXText::computeBidiTables(ParagraphList::iterator pit,
|
||||
int new_level;
|
||||
|
||||
if (lpos == body_pos - 1
|
||||
&& row->pos() < body_pos - 1
|
||||
&& row.pos() < body_pos - 1
|
||||
&& is_space) {
|
||||
new_level = (rtl_par) ? 1 : 0;
|
||||
new_rtl = new_rtl0 = rtl_par;
|
||||
new_level = rtl_par ? 1 : 0;
|
||||
new_rtl0 = rtl_par;
|
||||
new_rtl = rtl_par;
|
||||
} else if (new_rtl0)
|
||||
new_level = (new_rtl) ? 1 : 2;
|
||||
new_level = new_rtl ? 1 : 2;
|
||||
else
|
||||
new_level = (rtl_par) ? 2 : 0;
|
||||
new_level = rtl_par ? 2 : 0;
|
||||
|
||||
if (is_space && new_level >= level) {
|
||||
new_level = level;
|
||||
@ -352,13 +353,13 @@ void LyXText::computeBidiTables(ParagraphList::iterator pit,
|
||||
|
||||
if (level == new_level && rtl0 != new_rtl0) {
|
||||
--new_level2;
|
||||
log2vis_list[lpos - bidi_start] = (rtl) ? 1 : -1;
|
||||
log2vis_list[lpos - bidi_start] = rtl ? 1 : -1;
|
||||
} else if (level < new_level) {
|
||||
log2vis_list[lpos - bidi_start] = (rtl) ? -1 : 1;
|
||||
log2vis_list[lpos - bidi_start] = rtl ? -1 : 1;
|
||||
if (new_level > rtl_par)
|
||||
bidi_same_direction = false;
|
||||
} else
|
||||
log2vis_list[lpos - bidi_start] = (new_rtl) ? -1 : 1;
|
||||
log2vis_list[lpos - bidi_start] = new_rtl ? -1 : 1;
|
||||
rtl = new_rtl;
|
||||
rtl0 = new_rtl0;
|
||||
bidi_levels[lpos - bidi_start] = new_level;
|
||||
@ -542,10 +543,7 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
|
||||
case MARGIN_RIGHT_ADDRESS_BOX:
|
||||
{
|
||||
// ok, a terrible hack. The left margin depends on the widest
|
||||
// row in this paragraph. Do not care about footnotes, they
|
||||
// are *NOT* allowed in the LaTeX realisation of this layout.
|
||||
|
||||
// find the first row of this paragraph
|
||||
// row in this paragraph.
|
||||
RowList::iterator rit = pit->rows.begin();
|
||||
RowList::iterator end = pit->rows.end();
|
||||
int minfill = rit->fill();
|
||||
@ -603,18 +601,18 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
|
||||
}
|
||||
|
||||
|
||||
int LyXText::rightMargin(ParagraphList::iterator pit,
|
||||
int LyXText::rightMargin(Paragraph const & par,
|
||||
Buffer const & buf, Row const &) const
|
||||
{
|
||||
LyXTextClass const & tclass = buf.params().getLyXTextClass();
|
||||
LyXLayout_ptr const & layout = pit->layout();
|
||||
LyXLayout_ptr const & layout = par.layout();
|
||||
|
||||
return PAPER_MARGIN
|
||||
+ font_metrics::signedWidth(tclass.rightmargin(),
|
||||
tclass.defaultfont());
|
||||
+ font_metrics::signedWidth(layout->rightmargin,
|
||||
tclass.defaultfont())
|
||||
* 4 / (pit->getDepth() + 4);
|
||||
* 4 / (par.getDepth() + 4);
|
||||
}
|
||||
|
||||
|
||||
@ -638,10 +636,9 @@ namespace {
|
||||
// this needs special handling - only newlines count as a break point
|
||||
pos_type addressBreakPoint(pos_type i, Paragraph const & par)
|
||||
{
|
||||
for (; i < par.size(); ++i) {
|
||||
for (; i < par.size(); ++i)
|
||||
if (par.isNewline(i))
|
||||
return i;
|
||||
}
|
||||
|
||||
return par.size();
|
||||
}
|
||||
@ -653,8 +650,7 @@ pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit,
|
||||
Row const & row) const
|
||||
{
|
||||
// maximum pixel width of a row.
|
||||
int width = workWidth()
|
||||
- rightMargin(pit, *bv()->buffer(), row);
|
||||
int width = workWidth() - rightMargin(*pit, *bv()->buffer(), row);
|
||||
|
||||
// inset->textWidth() returns -1 via workWidth(),
|
||||
// but why ?
|
||||
@ -726,12 +722,8 @@ pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit,
|
||||
// the right of the row
|
||||
if (x >= width) {
|
||||
// if no break before, break here
|
||||
if (point == last || chunkwidth >= (width - left)) {
|
||||
if (pos < i)
|
||||
point = i - 1;
|
||||
else
|
||||
point = i;
|
||||
}
|
||||
if (point == last || chunkwidth >= width - left)
|
||||
point = (pos < i) ? i - 1 : i;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -741,10 +733,7 @@ pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit,
|
||||
point = i;
|
||||
chunkwidth = 0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (point == last && x >= width) {
|
||||
@ -767,8 +756,7 @@ pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit,
|
||||
|
||||
|
||||
// returns the minimum space a row needs on the screen in pixel
|
||||
int LyXText::fill(ParagraphList::iterator pit,
|
||||
RowList::iterator row, int paper_width) const
|
||||
int LyXText::fill(ParagraphList::iterator pit, Row & row, int paper_width) const
|
||||
{
|
||||
if (paper_width < 0)
|
||||
return 0;
|
||||
@ -781,15 +769,15 @@ int LyXText::fill(ParagraphList::iterator pit,
|
||||
|
||||
// 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(pit, *row);
|
||||
row->fill(tmpfill);
|
||||
int const tmpfill = row.fill();
|
||||
row.fill(0); // the minfill in MarginLeft()
|
||||
w = leftMargin(pit, row);
|
||||
row.fill(tmpfill);
|
||||
} else
|
||||
w = leftMargin(pit, *row);
|
||||
w = leftMargin(pit, row);
|
||||
|
||||
pos_type const body_pos = pit->beginningOfBody();
|
||||
pos_type i = row->pos();
|
||||
pos_type i = row.pos();
|
||||
|
||||
if (! pit->empty() && i <= last) {
|
||||
// We re-use the font resolution for the entire span when possible
|
||||
@ -800,7 +788,7 @@ int LyXText::fill(ParagraphList::iterator pit,
|
||||
w += font_metrics::width(layout->labelsep, getLabelFont(pit));
|
||||
if (pit->isLineSeparator(i - 1))
|
||||
w -= singleWidth(pit, i - 1);
|
||||
int left_margin = labelEnd(pit, *row);
|
||||
int left_margin = labelEnd(pit, row);
|
||||
if (w < left_margin)
|
||||
w = left_margin;
|
||||
}
|
||||
@ -818,12 +806,12 @@ int LyXText::fill(ParagraphList::iterator pit,
|
||||
w += font_metrics::width(layout->labelsep, getLabelFont(pit));
|
||||
if (last >= 0 && pit->isLineSeparator(last))
|
||||
w -= singleWidth(pit, last);
|
||||
int const left_margin = labelEnd(pit, *row);
|
||||
int const left_margin = labelEnd(pit, row);
|
||||
if (w < left_margin)
|
||||
w = left_margin;
|
||||
}
|
||||
|
||||
int const fill = paper_width - w - rightMargin(pit, *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()
|
||||
@ -835,7 +823,7 @@ int LyXText::fill(ParagraphList::iterator pit,
|
||||
if (lyxerr.debugging() && fill < 0) {
|
||||
lyxerr[Debug::GUI] << "Eek, fill() was < 0: " << fill
|
||||
<< " w " << w << " paper_width " << paper_width
|
||||
<< " right margin " << rightMargin(pit, *bv()->buffer(), *row) << endl;
|
||||
<< " right margin " << rightMargin(*pit, *bv()->buffer(), row) << endl;
|
||||
}
|
||||
return fill;
|
||||
}
|
||||
@ -884,7 +872,7 @@ LColor_color LyXText::backgroundColor() const
|
||||
}
|
||||
|
||||
|
||||
void LyXText::setHeightOfRow(ParagraphList::iterator pit, RowList::iterator rit)
|
||||
void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
|
||||
{
|
||||
// get the maximum ascent and the maximum descent
|
||||
double layoutasc = 0;
|
||||
@ -899,7 +887,7 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, RowList::iterator rit)
|
||||
// as max get the first character of this row then it can increase but not
|
||||
// decrease the height. Just some point to start with so we don't have to
|
||||
// do the assignment below too often.
|
||||
LyXFont font = getFont(pit, rit->pos());
|
||||
LyXFont font = getFont(pit, row.pos());
|
||||
LyXFont::FONT_SIZE const tmpsize = font.size();
|
||||
font = getLayoutFont(pit);
|
||||
LyXFont::FONT_SIZE const size = font.size();
|
||||
@ -919,20 +907,20 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, RowList::iterator rit)
|
||||
int maxdesc = int(font_metrics::maxDescent(font) *
|
||||
layout->spacing.getValue() * spacing_val);
|
||||
|
||||
pos_type const pos_end = lastPos(*pit, rit);
|
||||
pos_type const pos_end = lastPos(*pit, row);
|
||||
int labeladdon = 0;
|
||||
int maxwidth = 0;
|
||||
|
||||
if (!pit->empty()) {
|
||||
// We re-use the font resolution for the entire font span when possible
|
||||
LyXFont font = getFont(pit, rit->pos());
|
||||
lyx::pos_type endPosOfFontSpan = pit->getEndPosOfFontSpan(rit->pos());
|
||||
LyXFont font = getFont(pit, row.pos());
|
||||
lyx::pos_type endPosOfFontSpan = pit->getEndPosOfFontSpan(row.pos());
|
||||
|
||||
// Optimisation
|
||||
Paragraph const & par = *pit;
|
||||
|
||||
// Check if any insets are larger
|
||||
for (pos_type pos = rit->pos(); pos <= pos_end; ++pos) {
|
||||
for (pos_type pos = row.pos(); pos <= pos_end; ++pos) {
|
||||
// Manual inlined optimised version of common case of
|
||||
// "maxwidth += singleWidth(pit, pos);"
|
||||
char const c = par.getChar(pos);
|
||||
@ -974,7 +962,7 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, RowList::iterator rit)
|
||||
// This is not completely correct, but we can live with the small,
|
||||
// cosmetic error for now.
|
||||
LyXFont::FONT_SIZE maxsize =
|
||||
pit->highestFontInRange(rit->pos(), pos_end, size);
|
||||
pit->highestFontInRange(row.pos(), pos_end, size);
|
||||
if (maxsize > font.size()) {
|
||||
font.setSize(maxsize);
|
||||
maxasc = max(maxasc, font_metrics::maxAscent(font));
|
||||
@ -985,10 +973,10 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, RowList::iterator rit)
|
||||
++maxasc;
|
||||
++maxdesc;
|
||||
|
||||
rit->ascent_of_text(maxasc);
|
||||
row.ascent_of_text(maxasc);
|
||||
|
||||
// is it a top line?
|
||||
if (!rit->pos()) {
|
||||
if (!row.pos()) {
|
||||
BufferParams const & bufparams = bv()->buffer()->params();
|
||||
// some parksips VERY EASY IMPLEMENTATION
|
||||
if (bv()->buffer()->params().paragraph_separation ==
|
||||
@ -1081,12 +1069,10 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, RowList::iterator rit)
|
||||
prev->getLabelWidthString() == pit->getLabelWidthString())
|
||||
{
|
||||
layoutasc = (layout->itemsep * defaultRowHeight());
|
||||
} else if (rit != firstRow()) {
|
||||
// } else if (rit != firstRow()) {
|
||||
} else if (pit != ownerParagraphs().begin() || row.pos() != 0) {
|
||||
tmptop = layout->topsep;
|
||||
|
||||
//if (boost::prior(pit)->getDepth() >= pit->getDepth())
|
||||
// tmptop -= getPar(previousRow(rit))->layout()->bottomsep;
|
||||
|
||||
if (tmptop > 0)
|
||||
layoutasc = (tmptop * defaultRowHeight());
|
||||
} else if (pit->params().lineTop()) {
|
||||
@ -1110,7 +1096,7 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, RowList::iterator rit)
|
||||
}
|
||||
|
||||
// is it a bottom line?
|
||||
if (boost::next(rit) == pit->rows.end()) {
|
||||
if (row.end() == pit->size()) {
|
||||
// the bottom margin
|
||||
ParagraphList::iterator nextpit = boost::next(pit);
|
||||
if (nextpit == ownerParagraphs().end() && !isInInset())
|
||||
@ -1165,12 +1151,11 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, RowList::iterator rit)
|
||||
maxasc += int(layoutasc * 2 / (2 + pit->getDepth()));
|
||||
maxdesc += int(layoutdesc * 2 / (2 + pit->getDepth()));
|
||||
|
||||
rit->height(maxasc + maxdesc + labeladdon);
|
||||
rit->baseline(maxasc + labeladdon);
|
||||
rit->top_of_text(rit->baseline() - font_metrics::maxAscent(font));
|
||||
row.height(maxasc + maxdesc + labeladdon);
|
||||
row.baseline(maxasc + labeladdon);
|
||||
row.top_of_text(row.baseline() - font_metrics::maxAscent(font));
|
||||
|
||||
double x = 0;
|
||||
rit->width(int(maxwidth + x));
|
||||
row.width(maxwidth);
|
||||
if (inset_owner) {
|
||||
width = max(0, workWidth());
|
||||
RowList::iterator rit = firstRow();
|
||||
@ -1408,7 +1393,7 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
|
||||
bool const is_rtl =
|
||||
pit->isRightToLeftPar(bv()->buffer()->params());
|
||||
if (is_rtl)
|
||||
x = workWidth() > 0 ? rightMargin(pit, *bv()->buffer(), *rit) : 0;
|
||||
x = workWidth() > 0 ? rightMargin(*pit, *bv()->buffer(), *rit) : 0;
|
||||
else
|
||||
x = workWidth() > 0 ? leftMargin(pit, *rit) : 0;
|
||||
|
||||
@ -1418,7 +1403,7 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
|
||||
if (layout->margintype == MARGIN_MANUAL
|
||||
&& layout->labeltype == LABEL_MANUAL) {
|
||||
/// We might have real hfills in the label part
|
||||
int nlh = numberOfLabelHfills(*pit, rit);
|
||||
int nlh = numberOfLabelHfills(*pit, *rit);
|
||||
|
||||
// A manual label par (e.g. List) has an auto-hfill
|
||||
// between the label text and the body of the
|
||||
@ -1434,7 +1419,7 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
|
||||
}
|
||||
|
||||
// are there any hfills in the row?
|
||||
int const nh = numberOfHfills(*pit, rit);
|
||||
int const nh = numberOfHfills(*pit, *rit);
|
||||
|
||||
if (nh) {
|
||||
if (w > 0)
|
||||
@ -1463,7 +1448,7 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
|
||||
switch (align) {
|
||||
case LYX_ALIGN_BLOCK:
|
||||
{
|
||||
int const ns = numberOfSeparators(*pit, rit);
|
||||
int const ns = numberOfSeparators(*pit, *rit);
|
||||
RowList::iterator next_row = boost::next(rit);
|
||||
if (ns
|
||||
&& next_row != pit->rows.end()
|
||||
@ -1484,10 +1469,10 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
|
||||
}
|
||||
}
|
||||
|
||||
computeBidiTables(pit, *bv()->buffer(), rit);
|
||||
computeBidiTables(*pit, *bv()->buffer(), *rit);
|
||||
if (is_rtl) {
|
||||
pos_type body_pos = pit->beginningOfBody();
|
||||
pos_type last = lastPos(*pit, rit);
|
||||
pos_type last = lastPos(*pit, *rit);
|
||||
|
||||
if (body_pos > 0 &&
|
||||
(body_pos - 1 > last ||
|
||||
@ -1987,21 +1972,20 @@ ParagraphList::iterator LyXText::getPar(int par) const
|
||||
|
||||
RowList::iterator LyXText::cursorRow() const
|
||||
{
|
||||
return getRow(cursorPar(), cursor.pos());
|
||||
return getRow(*cursorPar(), cursor.pos());
|
||||
}
|
||||
|
||||
|
||||
RowList::iterator LyXText::getRow(LyXCursor const & cur) const
|
||||
{
|
||||
return getRow(getPar(cur), cur.pos());
|
||||
return getRow(*getPar(cur), cur.pos());
|
||||
}
|
||||
|
||||
|
||||
RowList::iterator
|
||||
LyXText::getRow(ParagraphList::iterator pit, pos_type pos) const
|
||||
RowList::iterator LyXText::getRow(Paragraph & par, pos_type pos) const
|
||||
{
|
||||
RowList::iterator rit = boost::prior(pit->rows.end());
|
||||
RowList::iterator const begin = pit->rows.begin();
|
||||
RowList::iterator rit = boost::prior(par.rows.end());
|
||||
RowList::iterator const begin = par.rows.begin();
|
||||
|
||||
while (rit != begin && rit->pos() > pos)
|
||||
--rit;
|
||||
@ -2010,15 +1994,8 @@ LyXText::getRow(ParagraphList::iterator pit, pos_type pos) const
|
||||
}
|
||||
|
||||
|
||||
// returns pointer to some fancy row 'below' specified row
|
||||
RowList::iterator LyXText::cursorIRow() const
|
||||
{
|
||||
return getRow(cursorPar(), cursor.pos());
|
||||
}
|
||||
|
||||
|
||||
RowList::iterator LyXText::getRowNearY(int y, ParagraphList::iterator & pit)
|
||||
const
|
||||
RowList::iterator
|
||||
LyXText::getRowNearY(int y, ParagraphList::iterator & pit) const
|
||||
{
|
||||
//lyxerr << "getRowNearY: y " << y << endl;
|
||||
|
||||
@ -2027,7 +2004,7 @@ RowList::iterator LyXText::getRowNearY(int y, ParagraphList::iterator & pit)
|
||||
RowList::iterator rit = lastRow();
|
||||
RowList::iterator rbegin = firstRow();
|
||||
|
||||
while (rit != rbegin && pit->y + rit->y_offset() > y)
|
||||
while (rit != rbegin && int(pit->y + rit->y_offset()) > y)
|
||||
previousRow(pit, rit);
|
||||
|
||||
return rit;
|
||||
@ -2119,3 +2096,99 @@ int LyXText::parOffset(ParagraphList::iterator pit) const
|
||||
{
|
||||
return std::distance(ownerParagraphs().begin(), pit);
|
||||
}
|
||||
|
||||
|
||||
int LyXText::redoParagraphInternal(ParagraphList::iterator pit)
|
||||
{
|
||||
// remove rows of paragraph, keep track of height changes
|
||||
height -= pit->height;
|
||||
pit->rows.clear();
|
||||
|
||||
// redo insets
|
||||
InsetList::iterator ii = pit->insetlist.begin();
|
||||
InsetList::iterator iend = pit->insetlist.end();
|
||||
for (; ii != iend; ++ii) {
|
||||
Dimension dim;
|
||||
MetricsInfo mi(bv(), getFont(pit, ii->pos), workWidth());
|
||||
ii->inset->metrics(mi, dim);
|
||||
}
|
||||
|
||||
// rebreak the paragraph
|
||||
int par_width = 0;
|
||||
int const ww = workWidth();
|
||||
pit->height = 0;
|
||||
|
||||
for (pos_type z = 0; z < pit->size() + 1; ) {
|
||||
Row row(z);
|
||||
z = rowBreakPoint(pit, row) + 1;
|
||||
row.end(z);
|
||||
pit->rows.push_back(row);
|
||||
}
|
||||
|
||||
RowList::iterator rit = pit->rows.begin();
|
||||
RowList::iterator end = pit->rows.end();
|
||||
for (rit = pit->rows.begin(); rit != end; ++rit) {
|
||||
int const f = fill(pit, *rit, ww);
|
||||
int const w = ww - f;
|
||||
par_width = std::max(par_width, w);
|
||||
rit->fill(f);
|
||||
rit->width(w);
|
||||
prepareToPrint(pit, rit);
|
||||
setHeightOfRow(pit, *rit);
|
||||
rit->y_offset(pit->height);
|
||||
pit->height += rit->height();
|
||||
}
|
||||
height += pit->height;
|
||||
|
||||
//lyxerr << "redoParagraph: " << pit->rows.size() << " rows\n";
|
||||
return par_width;
|
||||
}
|
||||
|
||||
|
||||
int LyXText::redoParagraphs(ParagraphList::iterator start,
|
||||
ParagraphList::iterator end)
|
||||
{
|
||||
int pars_width = 0;
|
||||
for ( ; start != end; ++start) {
|
||||
int par_width = redoParagraphInternal(start);
|
||||
pars_width = std::max(par_width, pars_width);
|
||||
}
|
||||
updateRowPositions();
|
||||
return pars_width;
|
||||
}
|
||||
|
||||
|
||||
void LyXText::redoParagraph(ParagraphList::iterator pit)
|
||||
{
|
||||
redoParagraphInternal(pit);
|
||||
updateRowPositions();
|
||||
}
|
||||
|
||||
|
||||
void LyXText::fullRebreak()
|
||||
{
|
||||
redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
|
||||
redoCursor();
|
||||
selection.cursor = cursor;
|
||||
}
|
||||
|
||||
|
||||
void LyXText::metrics(MetricsInfo & mi, Dimension & dim)
|
||||
{
|
||||
//lyxerr << "LyXText::metrics: width: " << mi.base.textwidth
|
||||
// << " workWidth: " << workWidth() << endl;
|
||||
//BOOST_ASSERT(mi.base.textwidth);
|
||||
|
||||
// rebuild row cache
|
||||
width = 0;
|
||||
///height = 0;
|
||||
|
||||
//anchor_y_ = 0;
|
||||
width = redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
|
||||
|
||||
// final dimension
|
||||
dim.asc = firstRow()->ascent_of_text();
|
||||
dim.des = height - dim.asc;
|
||||
dim.wid = std::max(mi.base.textwidth, int(width));
|
||||
}
|
||||
|
||||
|
171
src/text2.C
171
src/text2.C
@ -38,7 +38,6 @@
|
||||
#include "lyxrc.h"
|
||||
#include "lyxrow.h"
|
||||
#include "lyxrow_funcs.h"
|
||||
#include "metricsinfo.h"
|
||||
#include "paragraph.h"
|
||||
#include "paragraph_funcs.h"
|
||||
#include "ParagraphParameters.h"
|
||||
@ -545,103 +544,6 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
|
||||
}
|
||||
|
||||
|
||||
int LyXText::redoParagraphInternal(ParagraphList::iterator pit)
|
||||
{
|
||||
RowList::iterator rit = pit->rows.begin();
|
||||
RowList::iterator end = pit->rows.end();
|
||||
|
||||
// remove rows of paragraph, keep track of height changes
|
||||
for (int i = 0; rit != end; ++rit, ++i)
|
||||
height -= rit->height();
|
||||
pit->rows.clear();
|
||||
|
||||
// redo insets
|
||||
InsetList::iterator ii = pit->insetlist.begin();
|
||||
InsetList::iterator iend = pit->insetlist.end();
|
||||
for (; ii != iend; ++ii) {
|
||||
Dimension dim;
|
||||
MetricsInfo mi(bv(), getFont(pit, ii->pos), workWidth());
|
||||
ii->inset->metrics(mi, dim);
|
||||
}
|
||||
|
||||
// rebreak the paragraph
|
||||
for (pos_type z = 0; z < pit->size() + 1; ) {
|
||||
Row row(z);
|
||||
z = rowBreakPoint(pit, row) + 1;
|
||||
row.end(z);
|
||||
pit->rows.push_back(row);
|
||||
}
|
||||
|
||||
int par_width = 0;
|
||||
// set height and fill and width of rows
|
||||
int const ww = workWidth();
|
||||
pit->height = 0;
|
||||
for (rit = pit->rows.begin(); rit != end; ++rit) {
|
||||
int const f = fill(pit, rit, ww);
|
||||
int const w = ww - f;
|
||||
par_width = std::max(par_width, w);
|
||||
rit->fill(f);
|
||||
rit->width(w);
|
||||
prepareToPrint(pit, rit);
|
||||
setHeightOfRow(pit, rit);
|
||||
rit->y_offset(pit->height);
|
||||
pit->height += rit->height();
|
||||
}
|
||||
height += pit->height;
|
||||
|
||||
//lyxerr << "redoParagraph: " << pit->rows.size() << " rows\n";
|
||||
return par_width;
|
||||
}
|
||||
|
||||
|
||||
int LyXText::redoParagraphs(ParagraphList::iterator start,
|
||||
ParagraphList::iterator end)
|
||||
{
|
||||
int pars_width = 0;
|
||||
for ( ; start != end; ++start) {
|
||||
int par_width = redoParagraphInternal(start);
|
||||
pars_width = std::max(par_width, pars_width);
|
||||
}
|
||||
updateRowPositions();
|
||||
return pars_width;
|
||||
}
|
||||
|
||||
|
||||
void LyXText::redoParagraph(ParagraphList::iterator pit)
|
||||
{
|
||||
redoParagraphInternal(pit);
|
||||
updateRowPositions();
|
||||
}
|
||||
|
||||
|
||||
void LyXText::fullRebreak()
|
||||
{
|
||||
redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
|
||||
redoCursor();
|
||||
selection.cursor = cursor;
|
||||
}
|
||||
|
||||
|
||||
void LyXText::metrics(MetricsInfo & mi, Dimension & dim)
|
||||
{
|
||||
//lyxerr << "LyXText::metrics: width: " << mi.base.textwidth
|
||||
// << " workWidth: " << workWidth() << endl;
|
||||
//BOOST_ASSERT(mi.base.textwidth);
|
||||
|
||||
// rebuild row cache
|
||||
width = 0;
|
||||
///height = 0;
|
||||
|
||||
//anchor_y_ = 0;
|
||||
width = redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
|
||||
|
||||
// final dimension
|
||||
dim.asc = firstRow()->ascent_of_text();
|
||||
dim.des = height - dim.asc;
|
||||
dim.wid = std::max(mi.base.textwidth, int(width));
|
||||
}
|
||||
|
||||
|
||||
// important for the screen
|
||||
|
||||
|
||||
@ -1406,11 +1308,11 @@ void LyXText::setCursor(LyXCursor & cur, paroffset_type par,
|
||||
// get the cursor y position in text
|
||||
|
||||
ParagraphList::iterator pit = getPar(par);
|
||||
RowList::iterator row = getRow(pit, pos);
|
||||
int y = pit->y + row->y_offset();
|
||||
Row const & row = *getRow(*pit, pos);
|
||||
int y = pit->y + row.y_offset();
|
||||
|
||||
// y is now the beginning of the cursor row
|
||||
y += row->baseline();
|
||||
y += row.baseline();
|
||||
// y is now the cursor baseline
|
||||
cur.y(y);
|
||||
|
||||
@ -1426,9 +1328,9 @@ void LyXText::setCursor(LyXCursor & cur, paroffset_type par,
|
||||
// This shouldn't happen.
|
||||
pos = last + 1;
|
||||
cur.pos(pos);
|
||||
} else if (pos < row->pos()) {
|
||||
} else if (pos < row.pos()) {
|
||||
lyxerr << "dont like 3 please report" << endl;
|
||||
pos = row->pos();
|
||||
pos = row.pos();
|
||||
cur.pos(pos);
|
||||
}
|
||||
|
||||
@ -1439,22 +1341,22 @@ void LyXText::setCursor(LyXCursor & cur, paroffset_type par,
|
||||
}
|
||||
|
||||
|
||||
float LyXText::getCursorX(ParagraphList::iterator pit, RowList::iterator rit,
|
||||
float LyXText::getCursorX(ParagraphList::iterator pit, Row const & row,
|
||||
pos_type pos, pos_type last, bool boundary) const
|
||||
{
|
||||
pos_type cursor_vpos = 0;
|
||||
double x = rit->x();
|
||||
double fill_separator = rit->fill_separator();
|
||||
double fill_hfill = rit->fill_hfill();
|
||||
double fill_label_hfill = rit->fill_label_hfill();
|
||||
pos_type const rit_pos = rit->pos();
|
||||
double x = row.x();
|
||||
double fill_separator = row.fill_separator();
|
||||
double fill_hfill = row.fill_hfill();
|
||||
double fill_label_hfill = row.fill_label_hfill();
|
||||
pos_type const row_pos = row.pos();
|
||||
|
||||
if (last < rit_pos)
|
||||
cursor_vpos = rit_pos;
|
||||
if (last < row_pos)
|
||||
cursor_vpos = row_pos;
|
||||
else if (pos > last && !boundary)
|
||||
cursor_vpos = (pit->isRightToLeftPar(bv()->buffer()->params()))
|
||||
? rit_pos : last + 1;
|
||||
else if (pos > rit_pos && (pos > last || boundary))
|
||||
? row_pos : last + 1;
|
||||
else if (pos > row_pos && (pos > last || boundary))
|
||||
// Place cursor after char at (logical) position pos - 1
|
||||
cursor_vpos = (bidi_level(pos - 1) % 2 == 0)
|
||||
? log2vis(pos - 1) + 1 : log2vis(pos - 1);
|
||||
@ -1468,7 +1370,7 @@ float LyXText::getCursorX(ParagraphList::iterator pit, RowList::iterator rit,
|
||||
(body_pos - 1 > last || !pit->isLineSeparator(body_pos - 1)))
|
||||
body_pos = 0;
|
||||
|
||||
for (pos_type vpos = rit_pos; vpos < cursor_vpos; ++vpos) {
|
||||
for (pos_type vpos = row_pos; vpos < cursor_vpos; ++vpos) {
|
||||
pos_type pos = vis2log(vpos);
|
||||
if (body_pos > 0 && pos == body_pos - 1) {
|
||||
x += fill_label_hfill +
|
||||
@ -1478,7 +1380,7 @@ float LyXText::getCursorX(ParagraphList::iterator pit, RowList::iterator rit,
|
||||
x -= singleWidth(pit, body_pos - 1);
|
||||
}
|
||||
|
||||
if (hfillExpansion(*pit, rit, pos)) {
|
||||
if (hfillExpansion(*pit, row, pos)) {
|
||||
x += singleWidth(pit, pos);
|
||||
if (pos >= body_pos)
|
||||
x += fill_hfill;
|
||||
@ -1546,15 +1448,15 @@ 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(ParagraphList::iterator pit,
|
||||
RowList::iterator rit, int & x, bool & boundary) const
|
||||
Row const & row, int & x, bool & boundary) const
|
||||
{
|
||||
double tmpx = rit->x();
|
||||
double fill_separator = rit->fill_separator();
|
||||
double fill_hfill = rit->fill_hfill();
|
||||
double fill_label_hfill = rit->fill_label_hfill();
|
||||
double tmpx = row.x();
|
||||
double fill_separator = row.fill_separator();
|
||||
double fill_hfill = row.fill_hfill();
|
||||
double fill_label_hfill = row.fill_label_hfill();
|
||||
|
||||
pos_type vc = rit->pos();
|
||||
pos_type last = lastPos(*pit, rit);
|
||||
pos_type vc = row.pos();
|
||||
pos_type last = lastPos(*pit, row);
|
||||
pos_type c = 0;
|
||||
LyXLayout_ptr const & layout = pit->layout();
|
||||
|
||||
@ -1584,7 +1486,7 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
|
||||
tmpx -= singleWidth(pit, body_pos - 1);
|
||||
}
|
||||
|
||||
if (hfillExpansion(*pit, rit, c)) {
|
||||
if (hfillExpansion(*pit, row, c)) {
|
||||
tmpx += singleWidth(pit, c);
|
||||
if (c >= body_pos)
|
||||
tmpx += fill_hfill;
|
||||
@ -1611,8 +1513,7 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
|
||||
boundary = false;
|
||||
// This (rtl_support test) is not needed, but gives
|
||||
// some speedup if rtl_support == false
|
||||
bool const lastrow = lyxrc.rtl_support
|
||||
&& boost::next(rit) == pit->rows.end();
|
||||
bool const lastrow = lyxrc.rtl_support && row.end() == pit->size();
|
||||
|
||||
// If lastrow is false, we don't need to compute
|
||||
// the value of rtl.
|
||||
@ -1620,10 +1521,10 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
|
||||
? pit->isRightToLeftPar(bv()->buffer()->params())
|
||||
: false;
|
||||
if (lastrow &&
|
||||
((rtl && left_side && vc == rit->pos() && x < tmpx - 5) ||
|
||||
((rtl && left_side && vc == row.pos() && x < tmpx - 5) ||
|
||||
(!rtl && !left_side && vc == last + 1 && x > tmpx + 5)))
|
||||
c = last + 1;
|
||||
else if (vc == rit->pos()) {
|
||||
else if (vc == row.pos()) {
|
||||
c = vis2log(vc);
|
||||
if (bidi_level(c) % 2 == 1)
|
||||
++c;
|
||||
@ -1636,7 +1537,7 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
|
||||
}
|
||||
}
|
||||
|
||||
if (rit->pos() <= last && c > last && pit->isNewline(last)) {
|
||||
if (row.pos() <= last && c > last && pit->isNewline(last)) {
|
||||
if (bidi_level(last) % 2 == 0)
|
||||
tmpx -= singleWidth(pit, last);
|
||||
else
|
||||
@ -1644,7 +1545,7 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
|
||||
c = last;
|
||||
}
|
||||
|
||||
c -= rit->pos();
|
||||
c -= row.pos();
|
||||
x = int(tmpx);
|
||||
return c;
|
||||
}
|
||||
@ -1663,15 +1564,15 @@ void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y)
|
||||
{
|
||||
// Get the row first.
|
||||
ParagraphList::iterator pit;
|
||||
RowList::iterator rit = getRowNearY(y, pit);
|
||||
y = pit->y + rit->y_offset();
|
||||
Row const & row = *getRowNearY(y, pit);
|
||||
y = pit->y + row.y_offset();
|
||||
|
||||
bool bound = false;
|
||||
pos_type const column = getColumnNearX(pit, rit, x, bound);
|
||||
pos_type const column = getColumnNearX(pit, row, x, bound);
|
||||
cur.par(parOffset(pit));
|
||||
cur.pos(rit->pos() + column);
|
||||
cur.pos(row.pos() + column);
|
||||
cur.x(x);
|
||||
cur.y(y + rit->baseline());
|
||||
cur.y(y + row.baseline());
|
||||
|
||||
cur.boundary(bound);
|
||||
}
|
||||
@ -1742,7 +1643,7 @@ void LyXText::cursorDown(bool selecting)
|
||||
int x = cursor.x_fix();
|
||||
int y = cursor.y() - cursorRow()->baseline() + cursorRow()->height() + 1;
|
||||
setCursorFromCoordinates(x, y);
|
||||
if (!selecting && cursorRow() == cursorIRow()) {
|
||||
if (!selecting) {
|
||||
int topy = bv_owner->top_y();
|
||||
int y1 = cursor.y() - topy;
|
||||
int y2 = y1;
|
||||
|
@ -313,8 +313,8 @@ void LyXText::cursorNext()
|
||||
}
|
||||
|
||||
ParagraphList::iterator dummypit;
|
||||
RowList::iterator rr = getRowNearY(y, dummypit);
|
||||
y = dummypit->y + rr->y_offset();
|
||||
Row const & rr = *getRowNearY(y, dummypit);
|
||||
y = dummypit->y + rr.y_offset();
|
||||
|
||||
setCursorFromCoordinates(cursor.x_fix(), y);
|
||||
// + bv->workHeight());
|
||||
|
Loading…
Reference in New Issue
Block a user