lots of small stuff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7995 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-10-28 11:18:40 +00:00
parent 410847bd70
commit 4588bb075a
15 changed files with 370 additions and 420 deletions

View File

@ -1,3 +1,13 @@
2003-10-28 André Pönitz <poenitz@gmx.net>
* lyxtext.h:
* metricsinfo.C:
* paragraph_funcs.C:
* rowpainter.C:
* text.C:
* text2.C: general cleanup (lots of small stuff)
2003-10-28 Alfredo Braunstein <abraunst@libero.it>
* text2.C (cursorEnd): simple fix to the "end key goes to one

View File

@ -46,14 +46,26 @@ namespace font_metrics {
int maxAscent(LyXFont const & f);
/// return the maximum descent of the font
int maxDescent(LyXFont const & f);
/// return the maximum descent of the font
inline int maxHeight(LyXFont const & f) {
return maxAscent(f) + maxDescent(f);
}
/// return the ascent of the char in the font
int ascent(char c, LyXFont const & f);
/// return the descent of the char in the font
int descent(char c, LyXFont const & f);
/// return the descent of the char in the font
inline int height(char c, LyXFont const & f) {
return ascent(c, f) + descent(c, f);
}
/// return the left bearing of the char in the font
int lbearing(char c, LyXFont const & f);
/// return the right bearing of the char in the font
int rbearing(char c, LyXFont const & f);
/// return the inner width of the char in the font
inline int center(char c, LyXFont const & f) {
return (rbearing(c, f) - lbearing(c, f)) / 2;
}
/// return the width of the string in the font
int width(char const * s, size_t n, LyXFont const & f);
/// return the width of the char in the font
@ -62,8 +74,7 @@ namespace font_metrics {
}
/// return the width of the string in the font
inline int width(std::string const & s, LyXFont const & f) {
if (s.empty()) return 0;
return width(s.data(), s.length(), f);
return s.empty() ? 0 : width(s.data(), s.length(), f);
}
/// FIXME ??
int signedWidth(std::string const & s, LyXFont const & f);

View File

@ -22,6 +22,27 @@ InsetHFill::InsetHFill()
{}
std::auto_ptr<InsetBase> InsetHFill::clone() const
{
return std::auto_ptr<InsetBase>(new InsetHFill);
}
void InsetHFill::metrics(MetricsInfo &, Dimension & dim) const
{
dim.wid = 3;
dim.asc = 3;
dim.des = 3;
dim_ = dim;
}
std::string const InsetHFill::getScreenLabel(Buffer const &) const
{
return getContents();
}
int InsetHFill::latex(Buffer const &, ostream & os,
LatexRunParams const &) const
{
@ -50,6 +71,7 @@ int InsetHFill::docbook(Buffer const &, std::ostream & os, bool) const
return 0;
}
void InsetHFill::write(Buffer const &, ostream & os) const
{
os << "\n\\hfill \n";

View File

@ -20,11 +20,11 @@ public:
///
InsetHFill();
///
virtual std::auto_ptr<InsetBase> clone() const {
return std::auto_ptr<InsetBase>(new InsetHFill);
}
void metrics(MetricsInfo &, Dimension &) const;
///
std::string const getScreenLabel(Buffer const &) const { return getContents(); }
std::auto_ptr<InsetBase> clone() const;
///
std::string const getScreenLabel(Buffer const &) const;
///
InsetOld::Code lyxCode() const { return InsetOld::HFILL_CODE; }
///
@ -40,6 +40,7 @@ public:
void write(Buffer const & buf, std::ostream & os) const;
/// We don't need \begin_inset and \end_inset
bool directWrite() const { return true; }
};
#endif

View File

@ -49,6 +49,12 @@ InsetLatexAccent::InsetLatexAccent(string const & str)
}
auto_ptr<InsetBase> InsetLatexAccent::clone() const
{
return auto_ptr<InsetBase>(new InsetLatexAccent(contents));
}
void InsetLatexAccent::checkContents()
// check, if we know the modifier and can display it ok on screen
{
@ -319,37 +325,58 @@ bool InsetLatexAccent::displayISO8859_9(PainterInfo & pi, int x, int y) const
unsigned char tmpic = ic;
switch (modtype) {
case CEDILLA:
{
case CEDILLA: {
if (ic == 'c') tmpic = 0xe7;
if (ic == 'C') tmpic = 0xc7;
if (ic == 's') tmpic = 0xfe;
if (ic == 'S') tmpic = 0xde;
break;
}
case BREVE:
{ if (ic == 'g') tmpic = 0xf0;
if (ic == 'G') tmpic = 0xd0;
break;
case BREVE: {
if (ic == 'g') tmpic = 0xf0;
if (ic == 'G') tmpic = 0xd0;
break;
}
case UMLAUT:
{
case UMLAUT: {
if (ic == 'o') tmpic = 0xf6;
if (ic == 'O') tmpic = 0xd6;
if (ic == 'u') tmpic = 0xfc;
if (ic == 'U') tmpic = 0xdc;
break;
}
case DOT: if (ic == 'I') tmpic = 0xdd; break;
case DOT_LESS_I: tmpic = 0xfd; break;
default: return false;
}
if (tmpic != ic) {
pi.pain.text(x, y, char(tmpic), pi.base.font);
return true;
}
else
case DOT:
if (ic == 'I') tmpic = 0xdd;
break;
case DOT_LESS_I:
tmpic = 0xfd;
break;
default:
return false;
}
if (tmpic == ic)
return false;
pi.pain.text(x, y, char(tmpic), pi.base.font);
return true;
}
void InsetLatexAccent::drawAccent(PainterInfo const & pi, int x, int y,
char accent) const
{
LyXFont const & font = pi.base.font;
x -= font_metrics::center(accent, font);
y -= font_metrics::ascent(ic, font);
y -= font_metrics::descent(accent, font);
y -= font_metrics::height(accent, font) / 2;
pi.pain.text(x, y, accent, font);
}
@ -359,7 +386,6 @@ void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const
if (displayISO8859_9(pi, x, baseline))
return;
/* draw it! */
// All the manually drawn accents in this function could use an
// overhaul. Different ways of drawing (what metrics to use)
// should also be considered.
@ -369,23 +395,22 @@ void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const
font.setLanguage(english_language);
if (candisp) {
float x2 = x + (rbearing(font) - lbearing(font)) / 2.0;
float hg;
int x2 = int(x + (rbearing(font) - lbearing(font)) / 2);
int hg;
int y;
if (plusasc) {
// mark at the top
hg = font_metrics::maxDescent(font);
y = baseline - dim_.asc;
if (font.shape() == LyXFont::ITALIC_SHAPE)
x2 += (4.0 * hg) / 5.0; // italic
x2 += int(0.8 * hg); // italic
} else {
// at the bottom
hg = dim_.des;
y = baseline;
}
float hg35 = float(hg * 3.0) / 5.0;
double hg35 = hg * 0.6;
// display with proper accent mark
// first the letter
@ -413,107 +438,72 @@ void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const
ic = tmpic; // set the orig ic back
y = baseline - asc; // update to new y coord.
}
// now the rest - draw within (x, y, x+wid, y+hg)
// now the rest - draw within (x, y, x + wid, y + hg)
switch (modtype) {
case ACUTE: // acute 0xB4
{
pi.pain.text(int(x2 - (font_metrics::rbearing(0xB4, font)
- font_metrics::lbearing(0xB4, font)) / 2),
baseline - font_metrics::ascent(ic, font)
- font_metrics::descent(0xB4, font)
- (font_metrics::ascent(0xB4, font)
+ font_metrics::descent(0xB4, font)) / 2,
char(0xB4), font);
case ACUTE:
drawAccent(pi, x2, baseline, char(0xB4));
break;
}
case GRAVE: // grave 0x60
{
pi.pain.text(int(x2 - (font_metrics::rbearing(0x60, font) - font_metrics::lbearing(0x60, font)) / 2),
int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0x60, font) - (font_metrics::ascent(0x60, font) + font_metrics::descent(0x60, font)) / 2.0),
char(0x60), font);
case GRAVE:
drawAccent(pi, x2, baseline, char(0x60));
break;
}
case MACRON: // macron
{
pi.pain.text(int(x2 - (font_metrics::rbearing(0xAF, font) - font_metrics::lbearing(0xAF, font)) / 2),
baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xAF, font) - (font_metrics::ascent(0xAF, font) + font_metrics::descent(0xAF, font)),
char(0xAF), font);
case MACRON:
drawAccent(pi, x2, baseline, char(0xAF));
break;
}
case TILDE: // tilde
{
pi.pain.text(int(x2 - (font_metrics::rbearing('~', font) - font_metrics::lbearing('~', font)) / 2),
baseline - font_metrics::ascent(ic, font) - font_metrics::descent('~', font) - (font_metrics::ascent('~', font) + font_metrics::descent('~', font)) / 2,
'~', font);
case TILDE:
drawAccent(pi, x2, baseline, '~');
break;
}
case UNDERBAR: // underbar 0x5F
{
pi.pain.text(int(x2 - (font_metrics::rbearing(0x5F, font) - font_metrics::lbearing(0x5F, font)) / 2), baseline,
pi.pain.text(x2 - font_metrics::center(0x5F, font), baseline,
char(0x5F), font);
break;
}
case CEDILLA: // cedilla
{
pi.pain.text(int(x2 - (font_metrics::rbearing(0xB8, font) - font_metrics::lbearing(0xB8, font)) / 2), baseline,
case CEDILLA:
pi.pain.text(x2 - font_metrics::center(0xB8, font), baseline,
char(0xB8), font);
break;
}
case UNDERDOT: // underdot
{
pi.pain.text(int(x2 - (font_metrics::rbearing('.', font) - font_metrics::lbearing('.', font)) / 2.0),
int(baseline + 3.0 / 2.0 * (font_metrics::ascent('.', font) + font_metrics::descent('.', font))),
case UNDERDOT:
pi.pain.text(x2 - font_metrics::center('.', font),
int(baseline + 1.5 * font_metrics::height('.', font)),
'.', font);
break;
}
case DOT: // dot
{
pi.pain.text(int(x2 - (font_metrics::rbearing('.', font) - font_metrics::lbearing('.', font)) / 2.0),
baseline - font_metrics::ascent(ic, font) - font_metrics::descent('.', font) - (font_metrics::ascent('.', font) + font_metrics::descent('.', font)) / 2,
'.', font);
case DOT:
drawAccent(pi, x2, baseline, '.');
break;
}
case CIRCLE: // circle
{
LyXFont tmpf = font;
tmpf.decSize().decSize();
pi.pain.text(int(x2 - (font_metrics::rbearing(0xB0, tmpf) - font_metrics::lbearing(0xB0, tmpf)) / 2.0),
int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xB0, tmpf) - (font_metrics::ascent(0xB0, tmpf) + font_metrics::descent(0xB0, tmpf)) / 3.0),
char(0xB0), tmpf);
case CIRCLE:
drawAccent(pi, x2, baseline, char(0xB0));
break;
}
case TIE: // tie
{
pi.pain.arc(int(x2 + hg35), int(y + hg / 2.0),
int(2 * hg), int(hg), 0, 360 * 32,
case TIE:
pi.pain.arc(int(x2 + hg35), y + hg / 2, 2 * hg, hg, 0, 360 * 32,
LColor::foreground);
break;
}
case BREVE: // breve
{
pi.pain.arc(int(x2 - (hg / 2.0)), y,
int(hg), int(hg), 0, -360*32,
case BREVE:
pi.pain.arc(int(x2 - hg / 2), y, hg, hg, 0, -360*32,
LColor::foreground);
break;
}
case CARON: // caron
{
case CARON: {
int xp[3], yp[3];
xp[0] = int(x2 - hg35); yp[0] = int(y + hg35);
xp[1] = int(x2); yp[1] = int(y + hg);
xp[2] = int(x2 + hg35); yp[2] = int(y + hg35);
xp[0] = int(x2 - hg35); yp[0] = int(y + hg35);
xp[1] = int(x2); yp[1] = int(y + hg);
xp[2] = int(x2 + hg35); yp[2] = int(y + hg35);
pi.pain.lines(xp, yp, 3, LColor::foreground);
break;
}
case SPECIAL_CARON: // special caron
{
case SPECIAL_CARON: {
switch (ic) {
case 'L': dim_.wid = int(4.0 * dim_.wid / 5.0); break;
case 't': y -= int(hg35 / 2.0); break;
case 'L': dim_.wid = int(4.0 * dim_.wid / 5.0); break;
case 't': y -= int(hg35 / 2.0); break;
}
int xp[3], yp[3];
xp[0] = int(x + dim_.wid);
@ -528,74 +518,61 @@ void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const
pi.pain.lines(xp, yp, 3, LColor::foreground);
break;
}
case HUNGARIAN_UMLAUT: // hung. umlaut
{
pi.pain.text(int(x2 - (font_metrics::rbearing('´', font) - font_metrics::lbearing('´', font))),
baseline - font_metrics::ascent(ic, font) - font_metrics::descent('´', font) - (font_metrics::ascent('´', font) + font_metrics::descent('´', font)) / 2,
'´', font);
pi.pain.text(int(x2),
baseline - font_metrics::ascent(ic, font) - font_metrics::descent('´', font) - (font_metrics::ascent('´', font) + font_metrics::descent('´', font)) / 2,
'´', font);
case HUNGARIAN_UMLAUT:
drawAccent(pi, x2 - font_metrics::center('´', font), baseline, '´');
drawAccent(pi, x2 + font_metrics::center('´', font), baseline, '´');
break;
}
case UMLAUT: // umlaut
{
pi.pain.text(int(x2 - (font_metrics::rbearing('¨', font) - font_metrics::lbearing('¨', font)) / 2),
baseline - font_metrics::ascent(ic, font) - font_metrics::descent('¨', font) - (font_metrics::ascent('¨', font) + font_metrics::descent('¨', font)) / 2,
'¨', font);
case UMLAUT:
drawAccent(pi, x2, baseline, '"');
break;
}
case CIRCUMFLEX: // circumflex
{
LyXFont tmpf(font);
tmpf.decSize().decSize().decSize();
pi.pain.text(int(x2 - (font_metrics::rbearing(0x5E, tmpf) - font_metrics::lbearing(0x5E, tmpf)) / 2),
int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0x5E, tmpf) - (font_metrics::ascent(0x5E, tmpf) + font_metrics::descent(0x5E, tmpf)) / 3.0),
char(0x5E), tmpf);
case CIRCUMFLEX:
drawAccent(pi, x2, baseline, 0x5E);
break;
}
case OGONEK: // ogonek
{
case OGONEK: {
// this does probably not look like an ogonek, so
// it should certainly be refined
int xp[4], yp[4];
xp[0] = int(x2);
xp[0] = x2;
yp[0] = y;
xp[1] = int(x2);
xp[1] = x2;
yp[1] = y + int(hg35);
xp[2] = int(x2 - hg35);
yp[2] = y + int(hg / 2.0);
yp[2] = y + hg / 2;
xp[3] = int(x2 + hg / 4.0);
xp[3] = x2 + hg / 4;
yp[3] = y + int(hg);
pi.pain.lines(xp, yp, 4, LColor::foreground);
break;
}
case lSLASH:
case LSLASH:
{
case LSLASH: {
int xp[2], yp[2];
xp[0] = int(x);
yp[0] = y + int(3.0 * hg);
xp[0] = x;
yp[0] = y + int(3 * hg);
xp[1] = int(x + float(dim_.wid) * 0.75);
xp[1] = int(x + dim_.wid * 0.75);
yp[1] = y + int(hg);
pi.pain.lines(xp, yp, 2, LColor::foreground);
break;
}
case DOT_LESS_I: // dotless-i
case DOT_LESS_J: // dotless-j
{
// nothing to do for these
break;
}
}
} else {
pi.pain.fillRectangle(x + 1,
baseline - dim_.asc + 1, dim_.wid - 2,
@ -658,12 +635,6 @@ bool InsetLatexAccent::directWrite() const
}
auto_ptr<InsetBase> InsetLatexAccent::clone() const
{
return auto_ptr<InsetBase>(new InsetLatexAccent(contents));
}
InsetOld::Code InsetLatexAccent::lyxCode() const
{
return InsetOld::ACCENT_CODE;

View File

@ -116,6 +116,8 @@ private:
/// Check if we know the modifier and can display it ok on screen.
void checkContents();
///
void drawAccent(PainterInfo const & pi, int x, int y, char accent) const;
///
std::string contents;
/// can display as proper char
bool candisp;

View File

@ -7,6 +7,7 @@
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "insettoc.h"
@ -22,6 +23,7 @@ using std::string;
using std::ostream;
InsetTOC::InsetTOC(InsetCommandParams const & p)
: InsetCommand(p)
{}
@ -29,16 +31,19 @@ InsetTOC::InsetTOC(InsetCommandParams const & p)
InsetTOC::~InsetTOC()
{
InsetCommandMailer mailer("toc", *this);
mailer.hideDialog();
InsetCommandMailer("toc", *this).hideDialog();
}
std::auto_ptr<InsetBase> InsetTOC::clone() const
{
return std::auto_ptr<InsetBase>(new InsetTOC(*this));
}
string const InsetTOC::getScreenLabel(Buffer const &) const
{
string const cmdname(getCmdName());
if (cmdname == "tableofcontents")
if (getCmdName() == "tableofcontents")
return _("Table of Contents");
return _("Unknown toc list");
}
@ -46,8 +51,7 @@ string const InsetTOC::getScreenLabel(Buffer const &) const
InsetOld::Code InsetTOC::lyxCode() const
{
string const cmdname(getCmdName());
if (cmdname == "tableofcontents")
if (getCmdName() == "tableofcontents")
return InsetOld::TOC_CODE;
return InsetOld::NO_CODE;
}
@ -56,10 +60,8 @@ InsetOld::Code InsetTOC::lyxCode() const
void InsetTOC::metrics(MetricsInfo & mi, Dimension & dim) const
{
InsetCommand::metrics(mi, dim);
int center_indent = (mi.base.textwidth - dim.wid) / 2;
Box b(center_indent, center_indent + dim.wid, -dim.asc, dim.des);
button().setBox(b);
int const x1 = (mi.base.textwidth - dim.wid) / 2;
button().setBox(Box(x1, x1 + dim.wid, -dim.asc, dim.des));
dim.wid = mi.base.textwidth;
dim_ = dim;
}
@ -67,13 +69,12 @@ void InsetTOC::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetTOC::draw(PainterInfo & pi, int x, int y) const
{
InsetCommand::draw(pi, x + button().box().x1, y);
InsetCommand::draw(pi, button().box().x1, y);
}
dispatch_result
InsetTOC::priv_dispatch(FuncRequest const & cmd,
idx_type & idx, pos_type & pos)
InsetTOC::priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
{
switch (cmd.action) {
case LFUN_MOUSE_RELEASE:

View File

@ -23,13 +23,11 @@ class MetricsInfo;
class InsetTOC : public InsetCommand {
public:
///
InsetTOC(InsetCommandParams const &);
explicit InsetTOC(InsetCommandParams const &);
///
~InsetTOC();
///
virtual std::auto_ptr<InsetBase> clone() const {
return std::auto_ptr<InsetBase>(new InsetTOC(params()));
}
std::auto_ptr<InsetBase> clone() const;
///
void metrics(MetricsInfo &, Dimension &) const;
///

View File

@ -66,17 +66,13 @@ public:
LyXFont real_current_font;
/// our buffer's default layout font
LyXFont defaultfont_;
private:
/// offset of drawn area to document start.
int anchor_y_;
public:
/// update all cached row positions
void updateRowPositions();
///
InsetText * inset_owner;
///
UpdatableInset * the_locking_inset;
/// update all cached row positions
void updateRowPositions();
///
int getRealCursorX() const;
///
@ -382,7 +378,7 @@ public:
*/
int leftMargin(ParagraphList::iterator pit, Row const & row) const;
///
int rightMargin(Paragraph const & par, Buffer const &, Row const & row) const;
int rightMargin(Paragraph const & par, Buffer const &) const;
/** this calculates the specified parameters. needed when setting
* the cursor and when creating a visible row */
@ -452,6 +448,8 @@ public:
///
std::string selectionAsString(Buffer const & buffer, bool label) const;
///
double spacing(Paragraph const &) const;
private:
/** Cursor related data.
Later this variable has to be removed. There should be now internal

View File

@ -161,7 +161,7 @@ WidthChanger::WidthChanger(MetricsBase & mb, int w)
: Changer<MetricsBase>(mb)
{
save_ = mb;
mb.textwidth = w;
mb.textwidth = w;
}

View File

@ -494,7 +494,9 @@ TeXOnePar(Buffer const & buf,
}
if (!pit->params().spacing().isDefault()
&& (pit == const_cast<ParagraphList&>(paragraphs).begin() || !boost::prior(pit)->hasSameLayout(*pit))) {
&& (pit == const_cast<ParagraphList&>(paragraphs).begin()
|| !boost::prior(pit)->hasSameLayout(*pit)))
{
os << pit->params().spacing().writeEnvirBegin() << '\n';
texrow.newline();
}
@ -660,7 +662,9 @@ TeXOnePar(Buffer const & buf,
}
if (!pit->params().spacing().isDefault()
&& (boost::next(pit) == const_cast<ParagraphList&>(paragraphs).end()|| !boost::next(pit)->hasSameLayout(*pit))) {
&& (boost::next(pit) == const_cast<ParagraphList&>(paragraphs).end()
|| !boost::next(pit)->hasSameLayout(*pit)))
{
os << pit->params().spacing().writeEnvirEnd() << '\n';
texrow.newline();
}

View File

@ -761,7 +761,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())) / 2;
x -= font_metrics::width(str, font) / 2;
} else if (is_rtl) {
x = ww - leftMargin() -
@ -797,11 +797,10 @@ void RowPainter::paintLast()
// draw an endlabel
switch (endlabel) {
case END_LABEL_BOX:
case END_LABEL_FILLED_BOX:
{
case END_LABEL_FILLED_BOX: {
LyXFont const font = getLabelFont();
int const size = int(0.75 * font_metrics::maxAscent(font));
int const y = (yo_ + row_.baseline()) - size;
int const y = yo_ + row_.baseline() - size;
int x = is_rtl ? LEFT_MARGIN : ww - PAPER_MARGIN - size;
if (row_.fill() <= size)
@ -813,16 +812,17 @@ void RowPainter::paintLast()
pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
break;
}
case END_LABEL_STATIC:
{
case END_LABEL_STATIC: {
LyXFont font = getLabelFont();
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_.fill();
pain_.text(int(x), yo_ + row_.baseline(), str, font);
break;
}
case END_LABEL_NO_LABEL:
break;
}
@ -1043,9 +1043,7 @@ int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
LyXFont font;
font.decSize();
int const min_size = max(3 * arrow_size,
font_metrics::maxAscent(font)
+ font_metrics::maxDescent(font));
int const min_size = max(3 * arrow_size, font_metrics::maxHeight(font));
if (vsp.length().len().value() < 0.0)
return min_size;

View File

@ -19,7 +19,7 @@
inline
bool IsSeparatorChar(char c)
{
return (c == ' ');
return c == ' ';
}
@ -27,7 +27,7 @@ bool IsSeparatorChar(char c)
inline
bool IsLineSeparatorChar(char c)
{
return (c == ' ');
return c == ' ';
}
@ -35,7 +35,7 @@ bool IsLineSeparatorChar(char c)
inline
bool IsKommaChar(char c)
{
return (c == ','
return c == ','
|| c == '('
|| c == ')'
|| c == '['
@ -57,8 +57,7 @@ bool IsKommaChar(char c)
|| c == '%'
|| c == '^'
|| c == '/'
|| c == '\\'
);
|| c == '\\';
}
@ -66,9 +65,9 @@ bool IsKommaChar(char c)
inline
bool IsLetterChar(unsigned char c)
{
return ((c >= 'A' && c <= 'Z')
return (c >= 'A' && c <= 'Z')
|| (c >= 'a' && c <= 'z')
|| (c >= 192)); // in iso-8859-x these are accented chars
|| (c >= 192); // in iso-8859-x these are accented chars
}
@ -76,7 +75,7 @@ bool IsLetterChar(unsigned char c)
inline
bool IsPrintable(unsigned char c)
{
return ((c & 127) >= ' ');
return (c & 127) >= ' ';
}
@ -84,7 +83,7 @@ bool IsPrintable(unsigned char c)
inline
bool IsPrintableNonspace(unsigned char c)
{
return IsPrintable(c) && (c != ' ');
return IsPrintable(c) && c != ' ';
}

View File

@ -97,6 +97,14 @@ BufferView * LyXText::bv()
}
double LyXText::spacing(Paragraph const & par) const
{
if (par.params().spacing().isDefault())
return bv()->buffer()->params().spacing().getValue();
return par.params().spacing().getValue();
}
BufferView * LyXText::bv() const
{
BOOST_ASSERT(bv_owner != 0);
@ -175,7 +183,6 @@ int LyXText::singleWidth(ParagraphList::iterator pit,
return 0;
}
// The most common case is handled first (Asger)
if (IsPrintable(c)) {
if (!font.language()->RightToLeft()) {
@ -193,15 +200,8 @@ int LyXText::singleWidth(ParagraphList::iterator pit,
return font_metrics::width(c, font);
}
if (c == Paragraph::META_INSET) {
InsetOld * tmpinset = pit->getInset(pos);
BOOST_ASSERT(tmpinset);
if (tmpinset->lyxCode() == InsetOld::HFILL_CODE) {
// Because of the representation as vertical lines
return 3;
}
return tmpinset->width();
}
if (c == Paragraph::META_INSET)
return pit->getInset(pos)->width();
if (IsSeparatorChar(c))
c = ' ';
@ -224,50 +224,43 @@ int LyXText::leftMargin(ParagraphList::iterator pit, 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 (!pit->getDepth()) {
if (pit->getDepth() == 0) {
if (pit->layout() == tclass.defaultLayout()) {
// find the previous same level paragraph
if (pit != ownerParagraphs().begin()) {
ParagraphList::iterator newpit =
depthHook(pit, ownerParagraphs(),
pit->getDepth());
if (newpit == pit &&
newpit->layout()->nextnoindent)
depthHook(pit, ownerParagraphs(), pit->getDepth());
if (newpit == pit && newpit->layout()->nextnoindent)
parindent.erase();
}
}
} else {
// find the next level paragraph
ParagraphList::iterator newpar = outerHook(pit,
ownerParagraphs());
ParagraphList::iterator newpar =
outerHook(pit, ownerParagraphs());
// make a corresponding row. Needed to call leftMargin()
// check wether it is a sufficent paragraph
if (newpar != ownerParagraphs().end() &&
newpar->layout()->isEnvironment()) {
if (newpar != ownerParagraphs().end()
&& newpar->layout()->isEnvironment()) {
x = leftMargin(newpar, Row(newpar->size()));
}
if (newpar != ownerParagraphs().end() &&
pit->layout() == tclass.defaultLayout()) {
if (newpar != ownerParagraphs().end()
&& pit->layout() == tclass.defaultLayout()) {
if (newpar->params().noindent())
parindent.erase();
else {
else
parindent = newpar->layout()->parindent;
}
}
}
LyXFont const labelfont = getLabelFont(pit);
switch (layout->margintype) {
case MARGIN_DYNAMIC:
if (!layout->leftmargin.empty()) {
if (!layout->leftmargin.empty())
x += font_metrics::signedWidth(layout->leftmargin,
tclass.defaultfont());
}
if (!pit->getLabelstring().empty()) {
x += font_metrics::signedWidth(layout->labelindent,
labelfont);
@ -276,6 +269,7 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
x += font_metrics::width(layout->labelsep, labelfont);
}
break;
case MARGIN_MANUAL:
x += font_metrics::signedWidth(layout->labelindent, labelfont);
// The width of an empty par, even with manual label, should be 0
@ -287,10 +281,12 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
}
}
break;
case MARGIN_STATIC:
x += font_metrics::signedWidth(layout->leftmargin, tclass.defaultfont()) * 4
/ (pit->getDepth() + 4);
break;
case MARGIN_FIRST_DYNAMIC:
if (layout->labeltype == LABEL_MANUAL) {
if (row.pos() >= pit->beginningOfBody()) {
@ -320,8 +316,7 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
}
break;
case MARGIN_RIGHT_ADDRESS_BOX:
{
case MARGIN_RIGHT_ADDRESS_BOX: {
// ok, a terrible hack. The left margin depends on the widest
// row in this paragraph.
RowList::iterator rit = pit->rows.begin();
@ -381,8 +376,7 @@ int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
}
int LyXText::rightMargin(Paragraph const & par,
Buffer const & buf, Row const &) const
int LyXText::rightMargin(Paragraph const & par, Buffer const & buf) const
{
LyXTextClass const & tclass = buf.params().getLyXTextClass();
LyXLayout_ptr const & layout = par.layout();
@ -398,16 +392,14 @@ int LyXText::rightMargin(Paragraph const & par,
int LyXText::labelEnd(ParagraphList::iterator pit, Row const & row) const
{
if (pit->layout()->margintype == MARGIN_MANUAL) {
Row tmprow = row;
tmprow.pos(pit->size());
// return the beginning of the body
return leftMargin(pit, tmprow);
}
// labelEnd is only needed if the layout fills a flushleft label.
if (pit->layout()->margintype != MARGIN_MANUAL)
return 0;
// LabelEnd is only needed if the layout
// fills a flushleft label.
return 0;
Row tmprow = row;
tmprow.pos(pit->size());
// return the beginning of the body
return leftMargin(pit, tmprow);
}
@ -438,8 +430,7 @@ void LyXText::rowBreakPoint(ParagraphList::iterator pit, Row & row) const
}
// maximum pixel width of a row.
int width = workWidth()
- rightMargin(*pit, *bv()->buffer(), row);
int width = workWidth() - rightMargin(*pit, *bv()->buffer());
// - leftMargin(pit, row);
// inset->textWidth() returns -1 via workWidth(),
@ -568,28 +559,13 @@ void LyXText::rowBreakPoint(ParagraphList::iterator pit, Row & row) const
// returns the minimum space a row needs on the screen in pixel
void LyXText::fill(ParagraphList::iterator pit, Row & row, int paper_width) const
void LyXText::fill(ParagraphList::iterator pit, Row & row, int workwidth) const
{
int w;
// get the pure distance
pos_type const end = row.endpos();
LyXLayout_ptr const & layout = pit->layout();
// special handling of the right address boxes
#if 0
//this is not working anymore
if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
int const tmpfill = row.fill();
row.fill(0); // the minfill in leftMargin()
w = leftMargin(pit, row);
row.fill(tmpfill);
} else {
w = leftMargin(pit, row);
}
#else
w = leftMargin(pit, row);
#endif
int w = leftMargin(pit, row);
pos_type const body_pos = pit->beginningOfBody();
pos_type i = row.pos();
@ -598,14 +574,12 @@ void LyXText::fill(ParagraphList::iterator pit, Row & row, int paper_width) cons
// We re-use the font resolution for the entire span when possible
LyXFont font = getFont(pit, i);
lyx::pos_type endPosOfFontSpan = pit->getEndPosOfFontSpan(i);
while (i < end) {
for ( ; i < end; ++i) {
if (body_pos > 0 && i == body_pos) {
w += font_metrics::width(layout->labelsep, getLabelFont(pit));
if (pit->isLineSeparator(i - 1))
w -= singleWidth(pit, i - 1);
int left_margin = labelEnd(pit, row);
if (w < left_margin)
w = left_margin;
w = max(w, labelEnd(pit, row));
}
char const c = pit->getChar(i);
if (IsPrintable(c) && i > endPosOfFontSpan) {
@ -614,21 +588,19 @@ void LyXText::fill(ParagraphList::iterator pit, Row & row, int paper_width) cons
endPosOfFontSpan = pit->getEndPosOfFontSpan(i);
}
w += singleWidth(pit, i, c, font);
++i;
}
}
if (body_pos > 0 && body_pos >= end) {
w += font_metrics::width(layout->labelsep, getLabelFont(pit));
if (end > 0 && pit->isLineSeparator(end - 1))
w -= singleWidth(pit, end - 1);
int const left_margin = labelEnd(pit, row);
if (w < left_margin)
w = left_margin;
w = max(w, labelEnd(pit, row));
}
int const fill = paper_width - w - rightMargin(*pit, *bv()->buffer(), row);
int const fill = workwidth - w - rightMargin(*pit, *bv()->buffer());
row.fill(fill);
row.width(paper_width - fill);
row.width(workwidth - fill);
}
@ -650,15 +622,11 @@ int LyXText::labelFill(ParagraphList::iterator pit, Row const & row) const
for (pos_type i = row.pos(); i <= last; ++i)
w += singleWidth(pit, i);
int fill = 0;
string const & labwidstr = pit->params().labelWidthString();
if (!labwidstr.empty()) {
LyXFont const labfont = getLabelFont(pit);
int const labwidth = font_metrics::width(labwidstr, labfont);
fill = max(labwidth - w, 0);
}
string const & label = pit->params().labelWidthString();
if (label.empty())
return 0;
return fill;
return max(0, font_metrics::width(label, getLabelFont(pit)) - w);
}
@ -666,8 +634,7 @@ LColor_color LyXText::backgroundColor() const
{
if (inset_owner)
return inset_owner->backgroundColor();
else
return LColor::background;
return LColor::background;
}
@ -676,7 +643,7 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
// get the maximum ascent and the maximum descent
double layoutasc = 0;
double layoutdesc = 0;
double tmptop = 0;
double const dh = defaultRowHeight();
// ok, let us initialize the maxasc and maxdesc value.
// Only the fontsize count. The other properties
@ -694,25 +661,18 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
LyXFont labelfont = getLabelFont(pit);
double spacing_val = 1.0;
if (!pit->params().spacing().isDefault())
spacing_val = pit->params().spacing().getValue();
else
spacing_val = bv()->buffer()->params().spacing().getValue();
//lyxerr << "spacing_val = " << spacing_val << endl;
// these are minimum values
int maxasc = int(font_metrics::maxAscent(font) *
layout->spacing.getValue() * spacing_val);
int maxdesc = int(font_metrics::maxDescent(font) *
layout->spacing.getValue() * spacing_val);
double const spacing_val = layout->spacing.getValue() * spacing(*pit);
//lyxerr << "spacing_val = " << spacing_val << endl;
int maxasc = int(font_metrics::maxAscent(font) * spacing_val);
int maxdesc = int(font_metrics::maxDescent(font) * spacing_val);
// insets may be taller
InsetList::iterator ii = pit->insetlist.begin();
InsetList::iterator iend = pit->insetlist.end();
for ( ; ii != iend; ++ii) {
if (ii->pos >= row.pos() && ii->pos < row.endpos()) {
maxasc = max(maxasc, ii->inset->ascent());
maxasc = max(maxasc, ii->inset->ascent());
maxdesc = max(maxdesc, ii->inset->descent());
}
}
@ -727,7 +687,7 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
pit->highestFontInRange(row.pos(), pos_end, size);
if (maxsize > font.size()) {
font.setSize(maxsize);
maxasc = max(maxasc, font_metrics::maxAscent(font));
maxasc = max(maxasc, font_metrics::maxAscent(font));
maxdesc = max(maxdesc, font_metrics::maxDescent(font));
}
@ -738,52 +698,34 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
row.ascent_of_text(maxasc);
// is it a top line?
if (!row.pos()) {
if (row.pos() == 0) {
BufferParams const & bufparams = bv()->buffer()->params();
// some parksips VERY EASY IMPLEMENTATION
if (bv()->buffer()->params().paragraph_separation ==
BufferParams::PARSEP_SKIP)
if (bv()->buffer()->params().paragraph_separation
== BufferParams::PARSEP_SKIP
&& pit != ownerParagraphs().begin()
&& ((layout->isParagraph() && pit->getDepth() == 0)
|| (boost::prior(pit)->layout()->isParagraph()
&& boost::prior(pit)->getDepth() == 0)))
{
if (layout->isParagraph()
&& pit->getDepth() == 0
&& pit != ownerParagraphs().begin())
{
maxasc += bufparams.getDefSkip().inPixels(*bv());
} else if (pit != ownerParagraphs().begin() &&
boost::prior(pit)->layout()->isParagraph() &&
boost::prior(pit)->getDepth() == 0)
{
// is it right to use defskip here too? (AS)
maxasc += bufparams.getDefSkip().inPixels(*bv());
}
}
// the top margin
if (pit == ownerParagraphs().begin() && !isInInset())
maxasc += PAPER_MARGIN;
// add the vertical spaces, that the user added
// add user added vertical space
maxasc += getLengthMarkerHeight(*bv(), pit->params().spaceTop());
if (pit->params().startOfAppendix())
maxasc += 3 * defaultRowHeight();
maxasc += int(3 * dh);
// This is special code for the chapter, since the label of this
// layout is printed in an extra row
if (layout->counter == "chapter" && bufparams.secnumdepth >= 0) {
float spacing_val = 1.0;
if (!pit->params().spacing().isDefault()) {
spacing_val = pit->params().spacing().getValue();
} else {
spacing_val = bufparams.spacing().getValue();
}
labeladdon = int(font_metrics::maxDescent(labelfont) *
layout->spacing.getValue() *
spacing_val)
+ int(font_metrics::maxAscent(labelfont) *
layout->spacing.getValue() *
spacing_val);
labeladdon = int(font_metrics::maxHeight(labelfont)
* layout->spacing.getValue() * spacing(*pit));
}
// special code for the top label
@ -793,20 +735,11 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
&& isFirstInSequence(pit, ownerParagraphs())
&& !pit->getLabelstring().empty())
{
float spacing_val = 1.0;
if (!pit->params().spacing().isDefault()) {
spacing_val = pit->params().spacing().getValue();
} else {
spacing_val = bufparams.spacing().getValue();
}
labeladdon = int(
(font_metrics::maxAscent(labelfont) +
font_metrics::maxDescent(labelfont)) *
layout->spacing.getValue() *
spacing_val
+ layout->topsep * defaultRowHeight()
+ layout->labelbottomsep * defaultRowHeight());
font_metrics::maxHeight(labelfont)
* layout->spacing.getValue()
* spacing(*pit)
+ (layout->topsep + layout->labelbottomsep) * dh);
}
// And now the layout spaces, for example before and after
@ -814,28 +747,26 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
// environment.
ParagraphList::iterator prev =
depthHook(pit, ownerParagraphs(),
pit->getDepth());
if (prev != pit && prev->layout() == layout &&
prev->getDepth() == pit->getDepth() &&
prev->getLabelWidthString() == pit->getLabelWidthString())
depthHook(pit, ownerParagraphs(), pit->getDepth());
if (prev != pit
&& prev->layout() == layout
&& prev->getDepth() == pit->getDepth()
&& prev->getLabelWidthString() == pit->getLabelWidthString())
{
layoutasc = (layout->itemsep * defaultRowHeight());
layoutasc = layout->itemsep * dh;
} else if (pit != ownerParagraphs().begin() || row.pos() != 0) {
tmptop = layout->topsep;
if (tmptop > 0)
layoutasc = (tmptop * defaultRowHeight());
if (layout->topsep > 0)
layoutasc = layout->topsep * dh;
}
prev = outerHook(pit, ownerParagraphs());
if (prev != ownerParagraphs().end()) {
maxasc += int(prev->layout()->parsep * defaultRowHeight());
if (prev != ownerParagraphs().end()) {
maxasc += int(prev->layout()->parsep * dh);
} else if (pit != ownerParagraphs().begin()) {
ParagraphList::iterator prior_pit = boost::prior(pit);
if (prior_pit->getDepth() != 0 ||
prior_pit->layout() == layout) {
maxasc += int(layout->parsep * defaultRowHeight());
maxasc += int(layout->parsep * dh);
}
}
}
@ -854,35 +785,29 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
// a section, or between the items of a itemize or enumerate
// environment
if (nextpit != ownerParagraphs().end()) {
ParagraphList::iterator comparepit = pit;
float usual = 0;
float unusual = 0;
ParagraphList::iterator cpit = pit;
double usual = 0;
double unusual = 0;
if (comparepit->getDepth() > nextpit->getDepth()) {
usual = (comparepit->layout()->bottomsep * defaultRowHeight());
comparepit = depthHook(comparepit, ownerParagraphs(), nextpit->getDepth());
if (comparepit->layout()!= nextpit->layout()
|| nextpit->getLabelWidthString() !=
comparepit->getLabelWidthString())
if (cpit->getDepth() > nextpit->getDepth()) {
usual = cpit->layout()->bottomsep * dh;
cpit = depthHook(cpit, ownerParagraphs(), nextpit->getDepth());
if (cpit->layout() != nextpit->layout()
|| nextpit->getLabelWidthString() != cpit->getLabelWidthString())
{
unusual = (comparepit->layout()->bottomsep * defaultRowHeight());
unusual = cpit->layout()->bottomsep * dh;
}
if (unusual > usual)
layoutdesc = unusual;
else
layoutdesc = usual;
} else if (comparepit->getDepth() == nextpit->getDepth()) {
if (comparepit->layout() != nextpit->layout()
|| nextpit->getLabelWidthString() !=
comparepit->getLabelWidthString())
layoutdesc = int(comparepit->layout()->bottomsep * defaultRowHeight());
layoutdesc = max(unusual, usual);
} else if (cpit->getDepth() == nextpit->getDepth()) {
if (cpit->layout() != nextpit->layout()
|| nextpit->getLabelWidthString() != cpit->getLabelWidthString())
layoutdesc = int(cpit->layout()->bottomsep * dh);
}
}
}
// incalculate the layout spaces
maxasc += int(layoutasc * 2 / (2 + pit->getDepth()));
maxasc += int(layoutasc * 2 / (2 + pit->getDepth()));
maxdesc += int(layoutdesc * 2 / (2 + pit->getDepth()));
row.height(maxasc + maxdesc + labeladdon);
@ -1039,7 +964,6 @@ void LyXText::insertChar(char c)
}
}
// First check, if there will be two blanks together or a blank at
// the beginning of a paragraph.
// I decided to handle blanks like normal characters, the main
@ -1115,7 +1039,7 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit, Row & row) const
bool const is_rtl =
pit->isRightToLeftPar(bv()->buffer()->params());
if (is_rtl)
x = workWidth() > 0 ? rightMargin(*pit, *bv()->buffer(), row) : 0;
x = workWidth() > 0 ? rightMargin(*pit, *bv()->buffer()) : 0;
else
x = workWidth() > 0 ? leftMargin(pit, row) : 0;
@ -1177,33 +1101,32 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit, Row & row) const
}
switch (align) {
case LYX_ALIGN_BLOCK:
{
int const ns = numberOfSeparators(*pit, row);
bool disp_inset = false;
if (row.endpos() < pit->size()) {
InsetOld * in = pit->getInset(row.endpos());
if (in)
disp_inset = in->display();
case LYX_ALIGN_BLOCK: {
int const ns = numberOfSeparators(*pit, row);
bool disp_inset = false;
if (row.endpos() < pit->size()) {
InsetOld * in = pit->getInset(row.endpos());
if (in)
disp_inset = in->display();
}
// If we have separators, this is not the last row of a
// par, does not end in newline, and is not row above a
// display inset... then stretch it
if (ns
&& row.endpos() < pit->size()
&& !pit->isNewline(row.endpos() - 1)
&& !disp_inset
) {
fill_separator = w / ns;
} else if (is_rtl) {
x += w;
}
break;
}
// If we have separators, this is not the last row of a
// par, does not end in newline, and is not row above a
// display inset... then stretch it
if (ns
&& row.endpos() < pit->size()
&& !pit->isNewline(row.endpos() - 1)
&& !disp_inset
) {
fill_separator = w / ns;
} else if (is_rtl) {
x += w;
}
break;
}
case LYX_ALIGN_RIGHT:
case LYX_ALIGN_RIGHT:
x += w;
break;
case LYX_ALIGN_CENTER:
case LYX_ALIGN_CENTER:
x += w / 2;
break;
}
@ -1214,9 +1137,9 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit, Row & row) const
pos_type body_pos = pit->beginningOfBody();
pos_type end = row.endpos();
if (body_pos > 0 &&
(body_pos > end ||
!pit->isLineSeparator(body_pos - 1))) {
if (body_pos > 0
&& (body_pos > end || !pit->isLineSeparator(body_pos - 1)))
{
x += font_metrics::width(layout->labelsep, getLabelFont(pit));
if (body_pos <= end)
x += fill_label_hfill;
@ -1646,18 +1569,18 @@ void LyXText::backspace()
Buffer & buf = *bv()->buffer();
BufferParams const & bufparams = buf.params();
LyXTextClass const & tclass = bufparams.getLyXTextClass();
ParagraphList::iterator const cpit = cursorPar();
if (cursorPar() != tmppit
&& (cursorPar()->layout() == tmppit->layout()
|| tmppit->layout() == tclass.defaultLayout())
&& cursorPar()->getAlign() == tmppit->getAlign()) {
mergeParagraph(bufparams,
buf.paragraphs(), cursorPar());
if (cpit != tmppit
&& (cpit->layout() == tmppit->layout()
|| tmppit->layout() == tclass.defaultLayout())
&& cpit->getAlign() == tmppit->getAlign()) {
mergeParagraph(bufparams, buf.paragraphs(), cpit);
if (cursor.pos() && cursorPar()->isSeparator(cursor.pos() - 1))
if (cursor.pos() && cpit->isSeparator(cursor.pos() - 1))
cursor.pos(cursor.pos() - 1);
// the row may have changed, block, hfills etc.
// the counters may have changed
updateCounters();
setCursor(cursor.par(), cursor.pos(), false);
}
@ -1719,7 +1642,19 @@ RowList::iterator
LyXText::getRowNearY(int y, ParagraphList::iterator & pit) const
{
//lyxerr << "getRowNearY: y " << y << endl;
#if 0
ParagraphList::iterator const pend = ownerParagraphs().end();
pit = ownerParagraphs().begin();
while (int(pit->y + pit->height) < y && pit != pend)
++pit;
RowList::iterator rit = pit->rows.begin();
RowList::iterator const rend = pit->rows.end();
while (int(pit->y + rit->y_offset()) < y && rit != rend)
++rit;
return rit;
#else
pit = boost::prior(ownerParagraphs().end());
RowList::iterator rit = lastRow();
@ -1729,6 +1664,7 @@ LyXText::getRowNearY(int y, ParagraphList::iterator & pit) const
previousRow(pit, rit);
return rit;
#endif
}
@ -1888,7 +1824,6 @@ void LyXText::metrics(MetricsInfo & mi, Dimension & dim)
//lyxerr << "LyXText::metrics: width: " << mi.base.textwidth
// << " workWidth: " << workWidth() << "\nfont: " << mi.base.font << endl;
//BOOST_ASSERT(mi.base.textwidth);
//anchor_y_ = 0;
// rebuild row cache. This recomputes height as well.
redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());

View File

@ -70,7 +70,7 @@ using std::string;
LyXText::LyXText(BufferView * bv, InsetText * inset, bool ininset,
ParagraphList & paragraphs)
: height(0), width(0), anchor_y_(0),
: height(0), width(0),
inset_owner(inset), the_locking_inset(0), bv_owner(bv),
in_inset_(ininset), paragraphs_(&paragraphs),
cache_pos_(-1)
@ -89,8 +89,6 @@ void LyXText::init(BufferView * bview)
width = 0;
height = 0;
anchor_y_ = 0;
cache_pos_ = -1;
current_font = getFont(beg, 0);
@ -604,9 +602,10 @@ void LyXText::toggleFree(LyXFont const & font, bool toggleall)
// If there is a change in the language the implicit word selection
// is disabled.
LyXCursor resetCursor = cursor;
bool implicitSelection = (font.language() == ignore_language
&& font.number() == LyXFont::IGNORE)
? selectWordWhenUnderCursor(lyx::WHOLE_WORD_STRICT) : false;
bool implicitSelection =
font.language() == ignore_language
&& font.number() == LyXFont::IGNORE
&& selectWordWhenUnderCursor(lyx::WHOLE_WORD_STRICT);
// Set font
setFont(font, toggleall);
@ -1798,8 +1797,8 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
// we can't possibly have deleted a paragraph before this point
bool deleted = false;
if (old_pit->empty() ||
(old_pit->size() == 1 && old_pit->isLineSeparator(0))) {
if (old_pit->empty()
|| (old_pit->size() == 1 && old_pit->isLineSeparator(0))) {
// ok, we will delete something
LyXCursor tmpcursor;
@ -1831,15 +1830,17 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
selection.cursor = cursor;
}
}
if (!deleted) {
if (old_pit->stripLeadingSpaces()) {
redoParagraph(old_pit);
// correct cursor y
setCursorIntern(cursor.par(), cursor.pos());
selection.cursor = cursor;
}
if (deleted)
return true;
if (old_pit->stripLeadingSpaces()) {
redoParagraph(old_pit);
// correct cursor y
setCursorIntern(cursor.par(), cursor.pos());
selection.cursor = cursor;
}
return deleted;
return false;
}
@ -1871,6 +1872,5 @@ bool LyXText::isInInset() const
int defaultRowHeight()
{
LyXFont const font(LyXFont::ALL_SANE);
return int(font_metrics::maxAscent(font)
+ font_metrics::maxDescent(font) * 1.5);
return int(font_metrics::maxHeight(font) * 1.2);
}