#include "layout.h"
#include "paragraph.h"
#include "support/textutils.h"
+#include "support/LAssert.h"
+#include "support/lstrings.h"
#include "insets/insetbib.h"
#include "insets/insettext.h"
+#include "insets/insetspecialchar.h"
#include "lyx_gui_misc.h"
#include "gettext.h"
#include "bufferparams.h"
#include "BufferView.h"
#include "language.h"
#include "ParagraphParameters.h"
+#include "undo_funcs.h"
+#include "font.h"
using std::max;
using std::min;
LyXFont font = row->par()->getFontSettings(buf->params, pos);
if (pos != lpos && 0 < lpos && rtl0 && font.isRightToLeft() &&
font.number() == LyXFont::ON &&
- row->par()->getFontSettings(buf->params, lpos-1).number()
+ row->par()->getFontSettings(buf->params, lpos - 1).number()
== LyXFont::ON) {
font = row->par()->getFontSettings(buf->params, lpos);
is_space = false;
void LyXText::draw(BufferView * bview, Row const * row,
- Paragraph::size_type & vpos,
- int offset, float & x, bool cleared)
+ Paragraph::size_type & vpos,
+ int offset, float & x, bool cleared)
{
Painter & pain = bview->painter();
tmpinset->update(bview, font, false);
tmpinset->draw(bview, font, offset+row->baseline(), x,
cleared);
-#ifdef SEEMS_TO_BE_NOT_NEEDED
- if (status == CHANGED_IN_DRAW) {
- UpdateInset(bview, tmpinset);
- status = CHANGED_IN_DRAW;
+ if (!need_break_row && !inset_owner &&
+ bview->text->status() == CHANGED_IN_DRAW)
+ {
+ if (row->previous() && row->previous()->par() == row->par())
+ breakAgainOneRow(bview, row->previous());
+ setCursor(bview, cursor.par(), cursor.pos());
+ need_break_row = const_cast<Row *>(row);
}
-#endif
}
++vpos;
if (lyxrc.mark_foreign_language &&
+ font.language() != ignore_language &&
font.language() != bview->buffer()->params.language) {
int const y = offset + row->height() - 1;
- pain.line(int(tmpx), y, int(x), y,
- LColor::language);
+ pain.line(int(tmpx), y, int(x), y, LColor::language);
}
return;
x += lyxfont::width(textstring, font);
}
+#ifdef WITH_WARNINGS
+ if ((font.language() == inherit_language) ||
+ (font.language() == ignore_language))
+ lyxerr << "No this shouldn't happen!\n";
+#endif
if (lyxrc.mark_foreign_language &&
font.language() != bview->buffer()->params.language) {
int const y = offset + row->height() - 1;
}
- LyXFont const labelfont = getFont(bview->buffer(), row->par(), -2);
+ LyXFont const labelfont = getLabelFont(bview->buffer(), row->par());
switch (layout.margintype) {
case MARGIN_DYNAMIC:
if (!layout.leftmargin.empty()) {
.textclass)
.defaultfont());
else if (layout.labeltype == LABEL_BIBLIO) {
- // ale970405 Right width for bibitems
+ // ale970405 Right width for bibitems
x += bibitemMaxWidth(bview,textclasslist
.TextClass(bview->buffer()->params
.textclass)
last_separator = i - 1;
x = width; // this means break
} else {
-#if 0
- last_separator = i;
- x += width;
-#else
x += singleWidth(bview, par, i, c);
-#endif
}
} else {
if (IsLineSeparatorChar(c))
++i;
if (i == main_body) {
x += lyxfont::width(layout.labelsep,
- getFont(bview->buffer(), par, -2));
+ getLabelFont(bview->buffer(), par));
if (par->isLineSeparator(i - 1))
x-= singleWidth(bview, par, i - 1);
int left_margin = labelEnd(bview, row);
while (i <= last) {
if (main_body > 0 && i == main_body) {
- w += lyxfont::width(layout.labelsep, getFont(bview->buffer(), row->par(), -2));
+ w += lyxfont::width(layout.labelsep, getLabelFont(bview->buffer(), row->par()));
if (row->par()->isLineSeparator(i - 1))
w -= singleWidth(bview, row->par(), i - 1);
int left_margin = labelEnd(bview, row);
++i;
}
if (main_body > 0 && main_body > last) {
- w += lyxfont::width(layout.labelsep, getFont(bview->buffer(), row->par(), -2));
+ w += lyxfont::width(layout.labelsep, getLabelFont(bview->buffer(), row->par()));
if (last >= 0 && row->par()->isLineSeparator(last))
w -= singleWidth(bview, row->par(), last);
int const left_margin = labelEnd(bview, row);
int fill = 0;
if (!row->par()->params().labelWidthString().empty()) {
fill = max(lyxfont::width(row->par()->params().labelWidthString(),
- getFont(bview->buffer(), row->par(), -2)) - w,
+ getLabelFont(bview->buffer(), row->par())) - w,
0);
}
}
+LColor::color LyXText::backgroundColor()
+{
+ if (inset_owner)
+ return inset_owner->backgroundColor();
+ else
+ return LColor::background;
+}
+
void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
{
/* get the maximum ascent and the maximum descent */
- int asc = 0;
- int desc = 0;
- float layoutasc = 0;
- float layoutdesc = 0;
- float tmptop = 0;
- LyXFont tmpfont;
- Inset * tmpinset = 0;
-
- /* this must not happen before the currentrow for clear reasons.
- so the trick is just to set the current row onto this row */
- int unused_y;
- getRow(row_ptr->par(), row_ptr->pos(), unused_y);
-
- /* ok , let us initialize the maxasc and maxdesc value.
- * This depends in LaTeX of the font of the last character
- * in the paragraph. The hack below is necessary because
- * of the possibility of open footnotes */
-
- /* Correction: only the fontsize count. The other properties
- are taken from the layoutfont. Nicer on the screen :) */
- Paragraph * par = row_ptr->par();
- Paragraph * firstpar = row_ptr->par();
+ int asc = 0;
+ int desc = 0;
+ float layoutasc = 0;
+ float layoutdesc = 0;
+ float tmptop = 0;
+ LyXFont tmpfont;
+ Inset * tmpinset = 0;
+
+ /* this must not happen before the currentrow for clear reasons.
+ so the trick is just to set the current row onto this row */
+ int unused_y;
+ getRow(row_ptr->par(), row_ptr->pos(), unused_y);
+
+ /* ok , let us initialize the maxasc and maxdesc value.
+ * This depends in LaTeX of the font of the last character
+ * in the paragraph. The hack below is necessary because
+ * of the possibility of open footnotes */
+
+ /* Correction: only the fontsize count. The other properties
+ are taken from the layoutfont. Nicer on the screen :) */
+ Paragraph * par = row_ptr->par();
+ Paragraph * firstpar = row_ptr->par();
- LyXLayout const & layout = textclasslist.Style(bview->buffer()->params.textclass,
- firstpar->getLayout());
-
- LyXFont font = getFont(bview->buffer(), par, par->size() - 1);
- LyXFont::FONT_SIZE const size = font.size();
- font = getFont(bview->buffer(), par, -1);
- font.setSize(size);
-
- LyXFont labelfont = getFont(bview->buffer(), par, -2);
-
- float spacing_val = 1.0;
- if (!row_ptr->par()->params().spacing().isDefault()) {
- spacing_val = row_ptr->par()->params().spacing().getValue();
- } else {
- spacing_val = bview->buffer()->params.spacing.getValue();
- }
- //lyxerr << "spacing_val = " << spacing_val << endl;
+ LyXLayout const & layout = textclasslist.Style(bview->buffer()->params.textclass,
+ firstpar->getLayout());
+
+ // as max get the first character of this row then it can increes but not
+ // decrees the height. Just some point to start with so we don't have to
+ // do the assignment below too often.
+ LyXFont font = getFont(bview->buffer(), par, row_ptr->pos());
+ LyXFont::FONT_SIZE const tmpsize = font.size();
+ font = getLayoutFont(bview->buffer(), par);
+ LyXFont::FONT_SIZE const size = font.size();
+ font.setSize(tmpsize);
+
+ LyXFont labelfont = getLabelFont(bview->buffer(), par);
+
+ float spacing_val = 1.0;
+ if (!row_ptr->par()->params().spacing().isDefault()) {
+ spacing_val = row_ptr->par()->params().spacing().getValue();
+ } else {
+ spacing_val = bview->buffer()->params.spacing.getValue();
+ }
+ //lyxerr << "spacing_val = " << spacing_val << endl;
- int maxasc = int(lyxfont::maxAscent(font) *
- layout.spacing.getValue() *
- spacing_val);
- int maxdesc = int(lyxfont::maxDescent(font) *
- layout.spacing.getValue() *
- spacing_val);
- int const pos_end = rowLast(row_ptr);
- int labeladdon = 0;
- int maxwidth = 0;
-
- // Check if any insets are larger
- for (int pos = row_ptr->pos(); pos <= pos_end; ++pos) {
- if (row_ptr->par()->getChar(pos) == Paragraph::META_INSET) {
- tmpfont = getFont(bview->buffer(), row_ptr->par(), pos);
- tmpinset = row_ptr->par()->getInset(pos);
- if (tmpinset) {
+ int maxasc = int(lyxfont::maxAscent(font) *
+ layout.spacing.getValue() *
+ spacing_val);
+ int maxdesc = int(lyxfont::maxDescent(font) *
+ layout.spacing.getValue() *
+ spacing_val);
+ int const pos_end = rowLast(row_ptr);
+ int labeladdon = 0;
+ int maxwidth = 0;
+
+ // Check if any insets are larger
+ for (int pos = row_ptr->pos(); pos <= pos_end; ++pos) {
+ if (row_ptr->par()->getChar(pos) == Paragraph::META_INSET) {
+ tmpfont = getFont(bview->buffer(), row_ptr->par(), pos);
+ tmpinset = row_ptr->par()->getInset(pos);
+ if (tmpinset) {
#if 1 // this is needed for deep update on initialitation
- tmpinset->update(bview, tmpfont);
+ tmpinset->update(bview, tmpfont);
#endif
- asc = tmpinset->ascent(bview, tmpfont);
- desc = tmpinset->descent(bview, tmpfont);
- maxwidth += tmpinset->width(bview, tmpfont);
- maxasc = max(maxasc, asc);
- maxdesc = max(maxdesc, desc);
- }
- } else {
- maxwidth += singleWidth(bview, row_ptr->par(), pos);
- }
- }
+ asc = tmpinset->ascent(bview, tmpfont);
+ desc = tmpinset->descent(bview, tmpfont);
+ maxwidth += tmpinset->width(bview, tmpfont);
+ maxasc = max(maxasc, asc);
+ maxdesc = max(maxdesc, desc);
+ }
+ } else {
+ maxwidth += singleWidth(bview, row_ptr->par(), pos);
+ }
+ }
- // Check if any custom fonts are larger (Asger)
- // This is not completely correct, but we can live with the small,
- // cosmetic error for now.
- LyXFont::FONT_SIZE const maxsize =
- row_ptr->par()->highestFontInRange(row_ptr->pos(),
- pos_end);
- if (maxsize > font.size()) {
- font.setSize(maxsize);
-
- asc = lyxfont::maxAscent(font);
- desc = lyxfont::maxDescent(font);
- if (asc > maxasc)
- maxasc = asc;
- if (desc > maxdesc)
- maxdesc = desc;
- }
+ // Check if any custom fonts are larger (Asger)
+ // This is not completely correct, but we can live with the small,
+ // cosmetic error for now.
+ LyXFont::FONT_SIZE maxsize =
+ row_ptr->par()->highestFontInRange(row_ptr->pos(), pos_end, size);
+ if (maxsize > font.size()) {
+ font.setSize(maxsize);
+
+ asc = lyxfont::maxAscent(font);
+ desc = lyxfont::maxDescent(font);
+ if (asc > maxasc)
+ maxasc = asc;
+ if (desc > maxdesc)
+ maxdesc = desc;
+ }
- // This is nicer with box insets:
- ++maxasc;
- ++maxdesc;
+ // This is nicer with box insets:
+ ++maxasc;
+ ++maxdesc;
- row_ptr->ascent_of_text(maxasc);
+ row_ptr->ascent_of_text(maxasc);
- // is it a top line?
- if (!row_ptr->pos() && (row_ptr->par() == firstpar)) {
+ // is it a top line?
+ if (!row_ptr->pos() && (row_ptr->par() == firstpar)) {
- // some parksips VERY EASY IMPLEMENTATION
- if (bview->buffer()->params.paragraph_separation ==
- BufferParams::PARSEP_SKIP) {
- if (layout.isParagraph()
- && firstpar->getDepth() == 0
- && firstpar->previous())
- maxasc += bview->buffer()->params.getDefSkip().inPixels(bview);
- else if (firstpar->previous()
- && textclasslist.Style(bview->buffer()->params.textclass,
- firstpar->previous()->getLayout()).isParagraph()
- && firstpar->previous()->getDepth() == 0)
- // is it right to use defskip here too? (AS)
- maxasc += bview->buffer()->params.getDefSkip().inPixels(bview);
- }
+ // some parksips VERY EASY IMPLEMENTATION
+ if (bview->buffer()->params.paragraph_separation ==
+ BufferParams::PARSEP_SKIP)
+ {
+ if (layout.isParagraph()
+ && firstpar->getDepth() == 0
+ && firstpar->previous())
+ {
+ maxasc += bview->buffer()->params.getDefSkip().inPixels(bview);
+ } else if (firstpar->previous() &&
+ textclasslist.Style(bview->buffer()->params.textclass,
+ firstpar->previous()->
+ getLayout()).isParagraph() &&
+ firstpar->previous()->getDepth() == 0)
+ {
+ // is it right to use defskip here too? (AS)
+ maxasc += bview->buffer()->params.getDefSkip().inPixels(bview);
+ }
+ }
- // the paper margins
- if (!row_ptr->par()->previous() && bv_owner)
- maxasc += LYX_PAPER_MARGIN;
+ // the paper margins
+ if (!row_ptr->par()->previous() && bv_owner)
+ maxasc += LYX_PAPER_MARGIN;
- // add the vertical spaces, that the user added
- if (firstpar->params().spaceTop().kind() != VSpace::NONE)
- maxasc += int(firstpar->params().spaceTop().inPixels(bview));
+ // add the vertical spaces, that the user added
+ if (firstpar->params().spaceTop().kind() != VSpace::NONE)
+ maxasc += int(firstpar->params().spaceTop().inPixels(bview));
- // do not forget the DTP-lines!
- // there height depends on the font of the nearest character
- if (firstpar->params().lineTop())
- maxasc += 2 * lyxfont::ascent('x', getFont(bview->buffer(),
- firstpar, 0));
+ // do not forget the DTP-lines!
+ // there height depends on the font of the nearest character
+ if (firstpar->params().lineTop())
+ maxasc += 2 * lyxfont::ascent('x', getFont(bview->buffer(),
+ firstpar, 0));
- // and now the pagebreaks
- if (firstpar->params().pagebreakTop())
- maxasc += 3 * defaultHeight();
+ // and now the pagebreaks
+ if (firstpar->params().pagebreakTop())
+ maxasc += 3 * defaultHeight();
- // This is special code for the chapter, since the label of this
- // layout is printed in an extra row
- if (layout.labeltype == LABEL_COUNTER_CHAPTER
- && bview->buffer()->params.secnumdepth >= 0) {
- float spacing_val = 1.0;
- if (!row_ptr->par()->params().spacing().isDefault()) {
- spacing_val = row_ptr->par()->params().spacing().getValue();
- } else {
- spacing_val = bview->buffer()->params.spacing.getValue();
- }
+ // This is special code for the chapter, since the label of this
+ // layout is printed in an extra row
+ if (layout.labeltype == LABEL_COUNTER_CHAPTER
+ && bview->buffer()->params.secnumdepth >= 0)
+ {
+ float spacing_val = 1.0;
+ if (!row_ptr->par()->params().spacing().isDefault()) {
+ spacing_val = row_ptr->par()->params().spacing().getValue();
+ } else {
+ spacing_val = bview->buffer()->params.spacing.getValue();
+ }
- labeladdon = int(lyxfont::maxDescent(labelfont) *
- layout.spacing.getValue() *
- spacing_val)
- + int(lyxfont::maxAscent(labelfont) *
- layout.spacing.getValue() *
- spacing_val);
- }
+ labeladdon = int(lyxfont::maxDescent(labelfont) *
+ layout.spacing.getValue() *
+ spacing_val)
+ + int(lyxfont::maxAscent(labelfont) *
+ layout.spacing.getValue() *
+ spacing_val);
+ }
- // special code for the top label
- if ((layout.labeltype == LABEL_TOP_ENVIRONMENT
- || layout.labeltype == LABEL_BIBLIO
- || layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
- && row_ptr->par()->isFirstInSequence()
- && !row_ptr->par()->getLabelstring().empty()) {
- float spacing_val = 1.0;
- if (!row_ptr->par()->params().spacing().isDefault()) {
- spacing_val = row_ptr->par()->params().spacing().getValue();
- } else {
- spacing_val = bview->buffer()->params.spacing.getValue();
- }
+ // special code for the top label
+ if ((layout.labeltype == LABEL_TOP_ENVIRONMENT
+ || layout.labeltype == LABEL_BIBLIO
+ || layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
+ && row_ptr->par()->isFirstInSequence()
+ && !row_ptr->par()->getLabelstring().empty())
+ {
+ float spacing_val = 1.0;
+ if (!row_ptr->par()->params().spacing().isDefault()) {
+ spacing_val = row_ptr->par()->params().spacing().getValue();
+ } else {
+ spacing_val = bview->buffer()->params.spacing.getValue();
+ }
- labeladdon = int(
- (lyxfont::maxAscent(labelfont) *
- layout.spacing.getValue() *
- spacing_val)
- +(lyxfont::maxDescent(labelfont) *
- layout.spacing.getValue() *
- spacing_val)
- + layout.topsep * defaultHeight()
- + layout.labelbottomsep * defaultHeight());
- }
+ labeladdon = int(
+ (lyxfont::maxAscent(labelfont) *
+ layout.spacing.getValue() *
+ spacing_val)
+ +(lyxfont::maxDescent(labelfont) *
+ layout.spacing.getValue() *
+ spacing_val)
+ + layout.topsep * defaultHeight()
+ + layout.labelbottomsep * defaultHeight());
+ }
- // and now the layout spaces, for example before and after a section,
- // or between the items of a itemize or enumerate environment
+ // and now the layout spaces, for example before and after a section,
+ // or between the items of a itemize or enumerate environment
- if (!firstpar->params().pagebreakTop()) {
- Paragraph * prev = row_ptr->par()->previous();
- if (prev)
- prev = row_ptr->par()->depthHook(row_ptr->par()->getDepth());
- if (prev && prev->getLayout() == firstpar->getLayout()
- && prev->getDepth() == firstpar->getDepth()
- && prev->getLabelWidthString() == firstpar->getLabelWidthString())
- {
- layoutasc = (layout.itemsep * defaultHeight());
- }
- else if (row_ptr->previous()) {
- tmptop = layout.topsep;
+ if (!firstpar->params().pagebreakTop()) {
+ Paragraph * prev = row_ptr->par()->previous();
+ if (prev)
+ prev = row_ptr->par()->depthHook(row_ptr->par()->getDepth());
+ if (prev && prev->getLayout() == firstpar->getLayout() &&
+ prev->getDepth() == firstpar->getDepth() &&
+ prev->getLabelWidthString() == firstpar->getLabelWidthString())
+ {
+ layoutasc = (layout.itemsep * defaultHeight());
+ } else if (row_ptr->previous()) {
+ tmptop = layout.topsep;
- if (row_ptr->previous()->par()->getDepth() >= row_ptr->par()->getDepth())
- tmptop -= textclasslist.Style(bview->buffer()->params.textclass,
- row_ptr->previous()->par()->
- getLayout()).bottomsep;
+ if (row_ptr->previous()->par()->getDepth() >= row_ptr->par()->getDepth())
+ tmptop -= textclasslist.Style(bview->buffer()->params.textclass,
+ row_ptr->previous()->par()->
+ getLayout()).bottomsep;
- if (tmptop > 0)
- layoutasc = (tmptop * defaultHeight());
- }
- else if (row_ptr->par()->params().lineTop()) {
- tmptop = layout.topsep;
+ if (tmptop > 0)
+ layoutasc = (tmptop * defaultHeight());
+ } else if (row_ptr->par()->params().lineTop()) {
+ tmptop = layout.topsep;
- if (tmptop > 0)
- layoutasc = (tmptop * defaultHeight());
- }
+ if (tmptop > 0)
+ layoutasc = (tmptop * defaultHeight());
+ }
- prev = row_ptr->par()->outerHook();
- if (prev) {
- maxasc += int(textclasslist.Style(bview->buffer()->params.textclass,
- prev->getLayout()).parsep * defaultHeight());
- }
- else {
- if (firstpar->previous()
- && firstpar->previous()->getDepth() == 0
- && firstpar->previous()->getLayout() != firstpar->getLayout()) {
- // avoid parsep
- }
- else if (firstpar->previous()){
- maxasc += int(layout.parsep * defaultHeight());
- }
- }
- }
- }
+ prev = row_ptr->par()->outerHook();
+ if (prev) {
+ maxasc += int(textclasslist.Style(bview->buffer()->params.textclass,
+ prev->getLayout()).parsep * defaultHeight());
+ } else {
+ if (firstpar->previous() &&
+ firstpar->previous()->getDepth() == 0 &&
+ firstpar->previous()->getLayout() !=
+ firstpar->getLayout())
+ {
+ // avoid parsep
+ } else if (firstpar->previous()) {
+ maxasc += int(layout.parsep * defaultHeight());
+ }
+ }
+ }
+ }
- // is it a bottom line?
- if (row_ptr->par() == par
- && (!row_ptr->next() || row_ptr->next()->par() != row_ptr->par())) {
-
- // the paper margins
- if (!par->next() && bv_owner)
- maxdesc += LYX_PAPER_MARGIN;
+ // is it a bottom line?
+ if (row_ptr->par() == par
+ && (!row_ptr->next() || row_ptr->next()->par() != row_ptr->par()))
+ {
+ // the paper margins
+ if (!par->next() && bv_owner)
+ maxdesc += LYX_PAPER_MARGIN;
- // add the vertical spaces, that the user added
- if (firstpar->params().spaceBottom().kind() != VSpace::NONE)
- maxdesc += int(firstpar->params().spaceBottom().inPixels(bview));
+ // add the vertical spaces, that the user added
+ if (firstpar->params().spaceBottom().kind() != VSpace::NONE)
+ maxdesc += int(firstpar->params().spaceBottom().inPixels(bview));
- // do not forget the DTP-lines!
- // there height depends on the font of the nearest character
- if (firstpar->params().lineBottom())
- maxdesc += 2 * lyxfont::ascent('x',
- getFont(bview->buffer(),
- par, par->size() - 1));
+ // do not forget the DTP-lines!
+ // there height depends on the font of the nearest character
+ if (firstpar->params().lineBottom())
+ maxdesc += 2 * lyxfont::ascent('x',
+ getFont(bview->buffer(),
+ par, par->size() - 1));
- // and now the pagebreaks
- if (firstpar->params().pagebreakBottom())
- maxdesc += 3 * defaultHeight();
+ // and now the pagebreaks
+ if (firstpar->params().pagebreakBottom())
+ maxdesc += 3 * defaultHeight();
- // and now the layout spaces, for example before and after
- // a section, or between the items of a itemize or enumerate
- // environment
- if (!firstpar->params().pagebreakBottom() && row_ptr->par()->next()) {
- Paragraph * nextpar = row_ptr->par()->next();
- Paragraph * comparepar = row_ptr->par();
- float usual = 0;
- float unusual = 0;
+ // and now the layout spaces, for example before and after
+ // a section, or between the items of a itemize or enumerate
+ // environment
+ if (!firstpar->params().pagebreakBottom() && row_ptr->par()->next()) {
+ Paragraph * nextpar = row_ptr->par()->next();
+ Paragraph * comparepar = row_ptr->par();
+ float usual = 0;
+ float unusual = 0;
- if (comparepar->getDepth() > nextpar->getDepth()) {
- usual = (textclasslist.Style(bview->buffer()->params.textclass, comparepar->getLayout()).bottomsep * defaultHeight());
- comparepar = comparepar->depthHook(nextpar->getDepth());
- if (comparepar->getLayout()!= nextpar->getLayout()
- || nextpar->getLabelWidthString() !=
- comparepar->getLabelWidthString())
- unusual = (textclasslist.Style(bview->buffer()->params.textclass, comparepar->getLayout()).bottomsep * defaultHeight());
-
- if (unusual > usual)
- layoutdesc = unusual;
- else
- layoutdesc = usual;
- }
- else if (comparepar->getDepth() == nextpar->getDepth()) {
-
- if (comparepar->getLayout()!= nextpar->getLayout()
- || nextpar->getLabelWidthString() !=
- comparepar->getLabelWidthString())
- layoutdesc = int(textclasslist.Style(bview->buffer()->params.textclass, comparepar->getLayout()).bottomsep * defaultHeight());
- }
- }
- }
-
- // incalculate the layout spaces
- maxasc += int(layoutasc * 2 / (2 + firstpar->getDepth()));
- maxdesc += int(layoutdesc * 2 / (2 + firstpar->getDepth()));
-
- // calculate the new height of the text
- height -= row_ptr->height();
-
- row_ptr->height(maxasc + maxdesc + labeladdon);
- row_ptr->baseline(maxasc + labeladdon);
-
- height += row_ptr->height();
- float x;
- float dummy;
- prepareToPrint(bview, row_ptr, x, dummy, dummy, dummy, false);
- row_ptr->width(int(maxwidth + x));
- if (inset_owner) {
- Row * r = firstrow;
- width = max(0,workWidth(bview));
- while(r) {
- if (r->width() > width)
- width = r->width();
- r = r->next();
- }
- }
+ if (comparepar->getDepth() > nextpar->getDepth()) {
+ usual = (textclasslist.Style(bview->buffer()->params.textclass,
+ comparepar->getLayout()).bottomsep * defaultHeight());
+ comparepar = comparepar->depthHook(nextpar->getDepth());
+ if (comparepar->getLayout()!= nextpar->getLayout()
+ || nextpar->getLabelWidthString() !=
+ comparepar->getLabelWidthString())
+ {
+ unusual = (textclasslist.Style(bview->buffer()->params.textclass,
+ comparepar->getLayout()).bottomsep * defaultHeight());
+ }
+ if (unusual > usual)
+ layoutdesc = unusual;
+ else
+ layoutdesc = usual;
+ } else if (comparepar->getDepth() == nextpar->getDepth()) {
+
+ if (comparepar->getLayout()!= nextpar->getLayout()
+ || nextpar->getLabelWidthString() !=
+ comparepar->getLabelWidthString())
+ layoutdesc = int(textclasslist.Style(bview->buffer()->params.textclass,
+ comparepar->getLayout()).bottomsep * defaultHeight());
+ }
+ }
+ }
+
+ // incalculate the layout spaces
+ maxasc += int(layoutasc * 2 / (2 + firstpar->getDepth()));
+ maxdesc += int(layoutdesc * 2 / (2 + firstpar->getDepth()));
+
+ // calculate the new height of the text
+ height -= row_ptr->height();
+
+ row_ptr->height(maxasc + maxdesc + labeladdon);
+ row_ptr->baseline(maxasc + labeladdon);
+
+ height += row_ptr->height();
+ float x;
+ float dummy;
+ prepareToPrint(bview, row_ptr, x, dummy, dummy, dummy, false);
+ row_ptr->width(int(maxwidth + x));
+ if (inset_owner) {
+ Row * r = firstrow;
+ width = max(0,workWidth(bview));
+ while(r) {
+ if (r->width() > width)
+ width = r->width();
+ r = r->next();
+ }
+ }
}
not_ready = false;
// Set the dimensions of the row
+#ifdef WITH_WARNINGS
+#warning Something is rotten here! (Jug)
+#endif
tmprow->fill(fill(bview, tmprow, workWidth(bview)));
setHeightOfRow(bview, tmprow);
&& layout.labeltype!= LABEL_SENSITIVE)
return;
- setUndo(bview->buffer(), Undo::INSERT,
- cursor.par()->previous(),
- cursor.par()->next());
+ setUndo(bview, Undo::INSERT,cursor.par(),cursor.par()->next());
// Always break behind a space
//
cursorLeft(bview);
}
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
refresh_row = cursor.row();
refresh_y = cursor.y() - cursor.row()->baseline();
// Just a macro to make some thing easier.
void LyXText::redoParagraph(BufferView * bview) const
{
- clearSelection(bview);
+ clearSelection();
redoParagraphs(bview, cursor, cursor.par()->next());
setCursorIntern(bview, cursor.par(), cursor.pos());
}
* same Paragraph one to the right and make a rebreak */
void LyXText::insertChar(BufferView * bview, char c)
{
- setUndo(bview->buffer(), Undo::INSERT,
- cursor.par()->previous(),
- cursor.par()->next());
+ setUndo(bview, Undo::INSERT,
+ cursor.par(), cursor.par()->next());
// When the free-spacing option is set for the current layout,
// disable the double-space checking
cursor.pos()).number() == LyXFont::ON &&
getFont(bview->buffer(),
cursor.par(),
- cursor.pos()-1).number() == LyXFont::ON)
+ cursor.pos() - 1).number() == LyXFont::ON)
)
- Number(bview); // Set current_font.number to OFF
+ number(bview); // Set current_font.number to OFF
} else if (isdigit(c) &&
real_current_font.isVisibleRightToLeft()) {
- Number(bview); // Set current_font.number to ON
+ number(bview); // Set current_font.number to ON
if (cursor.pos() > 0) {
char const c = cursor.par()->getChar(cursor.pos() - 1);
cursor.pos() >= 2 &&
getFont(bview->buffer(),
cursor.par(),
- cursor.pos()-2).number() == LyXFont::ON) {
+ cursor.pos() - 2).number() == LyXFont::ON) {
setCharFont(bview->buffer(),
cursor.par(),
cursor.pos() - 1,
y -= row->previous()->height();
refresh_y = y;
refresh_row = row->previous();
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
breakAgainOneRow(bview, row);
refresh_row = row;
refresh_x = cursor.x();
refresh_pos = cursor.pos();
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
breakAgainOneRow(bview, row);
// will the cursor be in another row now?
if (rowLast(row) <= cursor.pos() + 1 && row->next()) {
int const tmpheight = row->height();
setHeightOfRow(bview, row);
if (tmpheight == row->height())
- status = LyXText::NEED_VERY_LITTLE_REFRESH;
+ status(bview, LyXText::NEED_VERY_LITTLE_REFRESH);
else
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
current_font = rawtmpfont;
real_current_font = realtmpfont;
if (row->par()->getChar(row->pos()) == Paragraph::META_INSET
&& (inset=row->par()->getInset(row->pos()))
&& (inset->display())) // || (inset->scroll() < 0)))
- align = (inset->LyxCode() == Inset::MATHMACRO_CODE)
+ align = (inset->lyxCode() == Inset::MATHMACRO_CODE)
? LYX_ALIGN_BLOCK : LYX_ALIGN_CENTER;
switch (align) {
textclasslist.Style(bview->buffer()->params.textclass,
row->par()->getLayout());
x += lyxfont::width(layout.labelsep,
- getFont(bview->buffer(), row->par(), -2));
+ getLabelFont(bview->buffer(), row->par()));
if (main_body-1 <= last)
x += fill_label_hfill;
}
void LyXText::cursorLeftOneWord(BufferView * bview) const
{
- // treat HFills, floats and Insets as words
LyXCursor tmpcursor = cursor;
- while (tmpcursor.pos()
- && (tmpcursor.par()->isSeparator(tmpcursor.pos() - 1)
- || tmpcursor.par()->isKomma(tmpcursor.pos() - 1))
- && !(tmpcursor.par()->isHfill(tmpcursor.pos() - 1)
- || tmpcursor.par()->isInset(tmpcursor.pos() - 1)))
- tmpcursor.pos(tmpcursor.pos() - 1);
-
- if (tmpcursor.pos()
- && (tmpcursor.par()->isInset(tmpcursor.pos() - 1)
- || tmpcursor.par()->isHfill(tmpcursor.pos() - 1))) {
- tmpcursor.pos(tmpcursor.pos() - 1);
- } else if (!tmpcursor.pos()) {
- if (tmpcursor.par()->previous()){
- tmpcursor.par(tmpcursor.par()->previous());
- tmpcursor.pos(tmpcursor.par()->size());
- }
- } else { // Here, tmpcursor != 0
- while (tmpcursor.pos() > 0 &&
- tmpcursor.par()->isWord(tmpcursor.pos()-1) )
- tmpcursor.pos(tmpcursor.pos() - 1);
- }
+ cursorLeftOneWord(tmpcursor);
setCursor(bview, tmpcursor.par(), tmpcursor.pos());
}
-/* -------> Select current word. This depends on behaviour of CursorLeftOneWord(), so it is
- patched as well. */
+void LyXText::cursorLeftOneWord(LyXCursor & cur) const
+{
+ // treat HFills, floats and Insets as words
+ cur = cursor;
+ while (cur.pos()
+ && (cur.par()->isSeparator(cur.pos() - 1)
+ || cur.par()->isKomma(cur.pos() - 1))
+ && !(cur.par()->isHfill(cur.pos() - 1)
+ || cur.par()->isInset(cur.pos() - 1)))
+ cur.pos(cur.pos() - 1);
+
+ if (cur.pos()
+ && (cur.par()->isInset(cur.pos() - 1)
+ || cur.par()->isHfill(cur.pos() - 1))) {
+ cur.pos(cur.pos() - 1);
+ } else if (!cur.pos()) {
+ if (cur.par()->previous()){
+ cur.par(cur.par()->previous());
+ cur.pos(cur.par()->size());
+ }
+ } else { // Here, cur != 0
+ while (cur.pos() > 0 &&
+ cur.par()->isWord(cur.pos()-1) )
+ cur.pos(cur.pos() - 1);
+ }
+}
-void LyXText::selectWord(BufferView * bview)
+/* -------> Select current word. This depends on behaviour of
+CursorLeftOneWord(), so it is patched as well. */
+void LyXText::getWord(LyXCursor & from, LyXCursor & to,
+ word_location const loc) const
{
- // Move cursor to the beginning, when not already there.
- if (cursor.pos()
- && !cursor.par()->isSeparator(cursor.pos() - 1)
- && !cursor.par()->isKomma(cursor.pos() - 1))
- cursorLeftOneWord(bview);
+ // first put the cursor where we wana start to select the word
+ from = cursor;
+ switch(loc) {
+ case WHOLE_WORD_STRICT:
+ if (cursor.pos() == 0 || cursor.pos() == cursor.par()->size()
+ || cursor.par()->isSeparator(cursor.pos())
+ || cursor.par()->isKomma(cursor.pos())
+ || cursor.par()->isSeparator(cursor.pos() -1)
+ || cursor.par()->isKomma(cursor.pos() -1)) {
+ to = from;
+ return;
+ }
+ // no break here, we go to the next
+
+ case WHOLE_WORD:
+ // Move cursor to the beginning, when not already there.
+ if (from.pos() && !from.par()->isSeparator(from.pos() - 1)
+ && !from.par()->isKomma(from.pos() - 1))
+ cursorLeftOneWord(from);
+ break;
+ case PREVIOUS_WORD:
+ // always move the cursor to the beginning of previous word
+ cursorLeftOneWord(from);
+ break;
+ case NEXT_WORD:
+ lyxerr << "LyXText::getWord: NEXT_WORD not implemented yet\n";
+ break;
+ case PARTIAL_WORD:
+ break;
+ }
+ to = from;
+ while (to.pos() < to.par()->size()
+ && !to.par()->isSeparator(to.pos())
+ && !to.par()->isKomma(to.pos())
+ && !to.par()->isHfill(to.pos()) )
+ {
+ to.pos(to.pos() + 1);
+ }
+}
- // set the sel cursor
-#if 0
- sel_cursor = cursor;
-#else
+
+void LyXText::selectWord(BufferView * bview, word_location const loc)
+{
+ LyXCursor from;
+ LyXCursor to;
+ getWord(from, to, loc);
+ if (cursor != from)
+ setCursor(bview, from.par(), from.pos());
+ if (to == from)
+ return;
selection.cursor = cursor;
-#endif
-
- while (cursor.pos() < cursor.par()->size()
- && !cursor.par()->isSeparator(cursor.pos())
- && !cursor.par()->isKomma(cursor.pos()) )
- cursor.pos(cursor.pos() + 1);
- setCursor(bview, cursor.par(), cursor.pos() );
-
- // finally set the selection
+ setCursor(bview, to.par(), to.pos() );
setSelection(bview);
}
-/* -------> Select the word currently under the cursor when:
- 1: no selection is currently set,
- 2: the cursor is not at the borders of the word. */
-
-bool LyXText::selectWordWhenUnderCursor(BufferView * bview)
+/* -------> Select the word currently under the cursor when no
+ selection is currently set */
+bool LyXText::selectWordWhenUnderCursor(BufferView * bview,
+ word_location const loc)
{
-#if 0
- if (!selection &&
-#else
- if (!selection.set() &&
-#endif
- cursor.pos() > 0 && cursor.pos() < cursor.par()->size()
- && !cursor.par()->isSeparator(cursor.pos())
- && !cursor.par()->isKomma(cursor.pos())
- && !cursor.par()->isSeparator(cursor.pos() -1)
- && !cursor.par()->isKomma(cursor.pos() -1)) {
- selectWord(bview);
- return true;
+ if (!selection.set()) {
+ selectWord(bview, loc);
+ return selection.set();
}
return false;
}
string const LyXText::selectNextWord(BufferView * bview,
float & value) const
{
+ if (the_locking_inset) {
+ string str = the_locking_inset->selectNextWord(bview, value);
+ if (!str.empty()) {
+ value += float(cursor.y())/float(height);
+ return str;
+ }
+#warning Dekel please have a look on this one RTL? (Jug)
+ // we have to go on checking so move cusor to the right
+ if (cursor.pos() == cursor.par()->size()) {
+ if (!cursor.par()->next())
+ return str;
+ cursor.par(cursor.par()->next());
+ cursor.pos(0);
+ } else
+ cursor.pos(cursor.pos() + 1);
+ }
Paragraph * tmppar = cursor.par();
// If this is not the very first word, skip rest of
// Now, skip until we have real text (will jump paragraphs)
while ((cursor.par()->size() > cursor.pos()
- && (!cursor.par()->isLetter(cursor.pos())
- || cursor.par()->getFont(bview->buffer()->params, cursor.pos())
- .latex() == LyXFont::ON))
+ && (!cursor.par()->isLetter(cursor.pos()))
+ && (!cursor.par()->isInset(cursor.pos()) ||
+ !cursor.par()->getInset(cursor.pos())->isTextInset()))
|| (cursor.par()->size() == cursor.pos()
- && cursor.par()->next())){
+ && cursor.par()->next()))
+ {
if (cursor.pos() == cursor.par()->size()) {
cursor.par(cursor.par()->next());
cursor.pos(0);
} else
cursor.pos(cursor.pos() + 1);
}
+
+ // now check if we hit an inset so it has to be a inset containing text!
+ if (cursor.pos() < cursor.par()->size() &&
+ cursor.par()->isInset(cursor.pos()))
+ {
+ // lock the inset!
+ cursor.par()->getInset(cursor.pos())->edit(bview);
+ // now call us again to do the above trick
+ // but obviously we have to start from down below ;)
+ return bview->text->selectNextWord(bview, value);
+ }
// Update the value if we changed paragraphs
if (cursor.par() != tmppar){
}
// Start the selection from here
-#if 0
- sel_cursor = cursor;
-#else
selection.cursor = cursor;
-#endif
- std::ostringstream latex;
+ Inset * inset;
// and find the end of the word
// (optional hyphens are part of a word)
while (cursor.pos() < cursor.par()->size()
&& (cursor.par()->isLetter(cursor.pos()))
- || (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET
- && cursor.par()->getInset(cursor.pos()) != 0
- && cursor.par()->getInset(cursor.pos())->Latex(bview->buffer(), latex, false, false) == 0
- && latex.str() == "\\-"
- ))
+ // assignment is intentional here
+ || ((inset = getInset())
+ && inset->lyxCode() == Inset::SPECIALCHAR_CODE
+ && static_cast<InsetSpecialChar *>(inset)->kind()
+ == InsetSpecialChar::HYPHENATION
+ ))
cursor.pos(cursor.pos() + 1);
// Finally, we copy the word to a string and return it
string str;
-#if 0
- if (sel_cursor.pos() < cursor.pos()) {
- Paragraph::size_type i;
- for (i = sel_cursor.pos(); i < cursor.pos(); ++i) {
- if (cursor.par()->getChar(i) != Paragraph::META_INSET)
- str += cursor.par()->getChar(i);
- }
- }
-#else
if (selection.cursor.pos() < cursor.pos()) {
Paragraph::size_type i;
for (i = selection.cursor.pos(); i < cursor.pos(); ++i) {
str += cursor.par()->getChar(i);
}
}
-#endif
return str;
}
// This one is also only for the spellchecker
void LyXText::selectSelectedWord(BufferView * bview)
{
-#if 0
- // move cursor to the beginning
- setCursor(bview, sel_cursor.par(), sel_cursor.pos());
-
- // set the sel cursor
- sel_cursor = cursor;
-#else
+ if (the_locking_inset) {
+ the_locking_inset->selectSelectedWord(bview);
+ return;
+ }
// move cursor to the beginning
setCursor(bview, selection.cursor.par(), selection.cursor.pos());
// set the sel cursor
selection.cursor = cursor;
-#endif
- std::ostringstream latex;
+ Inset * inset;
// now find the end of the word
while (cursor.pos() < cursor.par()->size()
&& (cursor.par()->isLetter(cursor.pos())
- || (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET
- && cursor.par()->getInset(cursor.pos()) != 0
- && cursor.par()->getInset(cursor.pos())->Latex(bview->buffer(), latex, false, false) == 0
- && latex.str() == "\\-"
- )))
+ // assignment is intentional here
+ || ((inset = getInset())
+ && inset->lyxCode() == Inset::SPECIALCHAR_CODE
+ && static_cast<InsetSpecialChar *>(inset)->kind()
+ == InsetSpecialChar::HYPHENATION
+ )))
cursor.pos(cursor.pos() + 1);
setCursor(bview, cursor.par(), cursor.pos());
else {
LyXCursor tmpcursor = cursor;
tmpcursor.row(0); //Â ??
-#if 0
- selection = true; // to avoid deletion
-#else
selection.set(true); // to avoid deletion
-#endif
cursorRightOneWord(bview);
setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
-#if 0
- sel_cursor = cursor;
-#else
selection.cursor = cursor;
-#endif
cursor = tmpcursor;
- setSelection(bview);
+ setSelection(bview);
/* -----> Great, CutSelection() gets rid of multiple spaces. */
- cutSelection(bview);
+ cutSelection(bview, true, false);
}
}
else {
LyXCursor tmpcursor = cursor;
tmpcursor.row(0); // ??
-#if 0
- selection = true; // to avoid deletion
-#else
selection.set(true); // to avoid deletion
-#endif
cursorLeftOneWord(bview);
setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
-#if 0
- sel_cursor = cursor;
-#else
selection.cursor = cursor;
-#endif
cursor = tmpcursor;
setSelection(bview);
- cutSelection(bview);
+ cutSelection(bview, true, false);
}
}
// We can't store the row over a regular setCursor
// so we set it to 0 and reset it afterwards.
tmpcursor.row(0); //Â ??
-#if 0
- selection = true; // to avoid deletion
-#else
selection.set(true); // to avoid deletion
-#endif
cursorEnd(bview);
setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
-#if 0
- sel_cursor = cursor;
-#else
selection.cursor = cursor;
-#endif
cursor = tmpcursor;
setSelection(bview);
// What is this test for ??? (JMarc)
-#if 0
- if (!selection) {
-#else
- if (!selection.set()) {
-#endif
+ if (!selection.set()) {
deleteWordForward(bview);
} else {
- cutSelection(bview);
+ cutSelection(bview, true, false);
}
}
}
// Paragraph, but it will have to change for 1.1 anyway. At least
// it does not access outside of the allocated array as the older
// version did. (JMarc)
-void LyXText::changeWordCase(BufferView * bview, LyXText::TextCase action)
+void LyXText::changeCase(BufferView * bview, LyXText::TextCase action)
{
- Paragraph * tmppar = cursor.par();
+ LyXCursor from;
+ LyXCursor to;
+
+ if (selection.set()) {
+ from = selection.start;
+ to = selection.end;
+ } else {
+ getWord(from, to, PARTIAL_WORD);
+ setCursor(bview, to.par(), to.pos() + 1);
+ }
- setUndo(bview->buffer(),Undo::FINISH,
- tmppar->previous(), tmppar->next());
+ changeRegionCase(bview, from, to, action);
+}
- Paragraph::size_type tmppos = cursor.pos();
- while (tmppos < tmppar->size()) {
- unsigned char c = tmppar->getChar(tmppos);
- if (IsKommaChar(c) || IsLineSeparatorChar(c))
- break;
- if (c != Paragraph::META_INSET) {
+void LyXText::changeRegionCase(BufferView * bview,
+ LyXCursor const & from,
+ LyXCursor const & to,
+ LyXText::TextCase action)
+{
+ lyx::Assert(from <= to);
+
+ setUndo(bview, Undo::FINISH,
+ from.par(), to.par()->next());
+
+ Paragraph::size_type pos = from.pos();
+ Paragraph * par = from.par();
+
+ while (par && (pos != to.pos() || par != to.par())) {
+ unsigned char c = par->getChar(pos);
+ if (!IsInsetChar(c) && !IsHfillChar(c)) {
switch (action) {
case text_lowercase:
c = tolower(c);
break;
}
}
-
- //tmppar->text[tmppos] = c;
- tmppar->setChar(tmppos, c);
- ++tmppos;
+ par->setChar(pos, c);
+ checkParagraph(bview, par, pos);
+
+ ++pos;
+ if (pos == par->size()) {
+ par = par->next();
+ pos = 0;
+ }
+ }
+ if (to.row() != from.row()) {
+ refresh_y = from.y() - from.row()->baseline();
+ refresh_row = from.row();
+ status(bview, LyXText::NEED_MORE_REFRESH);
}
- checkParagraph(bview, tmppar, tmppos);
- cursorRightOneWord(bview);
}
-void LyXText::transposeChars(BufferView const & bview)
+void LyXText::transposeChars(BufferView & bview)
{
Paragraph * tmppar = cursor.par();
- setUndo(bview.buffer(), Undo::FINISH,
- tmppar->previous(), tmppar->next());
+ setUndo(&bview, Undo::FINISH,
+ tmppar, tmppar->next());
Paragraph::size_type tmppos = cursor.pos();
if ((cursor.par()->previous() ? cursor.par()->previous()->id() : 0)
== old_cur_par_prev_id
&& cursor.par()->id() != old_cur_par_id)
+ {
return; // delete-empty-paragraph-mechanism has done it
+ }
// if you had success make a backspace
if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) {
LyXCursor tmpcursor = cursor;
cursor = old_cursor; // to make sure undo gets the right cursor position
- setUndo(bview->buffer(), Undo::DELETE,
- cursor.par()->previous(),
- cursor.par()->next());
+ setUndo(bview, Undo::DELETE,
+ cursor.par(), cursor.par()->next());
cursor = tmpcursor;
backspace(bview);
}
if (cursor.row()->height() != tmpheight) {
refresh_y = cursor.y() - cursor.row()->baseline();
refresh_row = cursor.row();
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
}
return;
}
}
if (cursor.par()->previous()) {
- setUndo(bview->buffer(), Undo::DELETE,
- cursor.par()->previous()->previous(),
- cursor.par()->next());
+ setUndo(bview, Undo::DELETE,
+ cursor.par()->previous(), cursor.par()->next());
}
Paragraph * tmppar = cursor.par();
if (cursor.par()->previous()) {
// steps into the above paragraph.
setCursorIntern(bview, cursor.par()->previous(),
- cursor.par()->previous()->size(),
- false);
+ cursor.par()->previous()->size(),
+ false);
}
/* Pasting is not allowed, if the paragraphs have different
if (cursor.par() != tmppar
&& (cursor.par()->getLayout() == tmppar->getLayout()
|| tmppar->getLayout() == 0 /*standard*/)
- && cursor.par()->getAlign() == tmppar->getAlign()) {
-
+ && cursor.par()->getAlign() == tmppar->getAlign())
+ {
removeParagraph(tmprow);
removeRow(tmprow);
cursor.par()->pasteParagraph(bview->buffer()->params);
if (cursor.pos())
cursor.pos(cursor.pos() - 1);
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
refresh_row = cursor.row();
refresh_y = cursor.y() - cursor.row()->baseline();
} else {
/* this is the code for a normal backspace, not pasting
* any paragraphs */
- setUndo(bview->buffer(), Undo::DELETE,
- cursor.par()->previous(),
- cursor.par()->next());
+ setUndo(bview, Undo::DELETE,
+ cursor.par(), cursor.par()->next());
// We used to do cursorLeftIntern() here, but it is
// not a good idea since it triggers the auto-delete
// mechanism. So we do a cursorLeftIntern()-lite,
// without the dreaded mechanism. (JMarc)
setCursorIntern(bview, cursor.par(), cursor.pos()- 1,
- false, cursor.boundary());
+ false, cursor.boundary());
// some insets are undeletable here
if (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET) {
- if (!cursor.par()->getInset(cursor.pos())->Deletable())
+ if (!cursor.par()->getInset(cursor.pos())->deletable())
return;
// force complete redo when erasing display insets
// this is a cruel method but safe..... Matthias
if (cursor.pos() < rowLast(row) ||
!cursor.par()->isLineSeparator(cursor.pos())) {
row->fill(row->fill() + singleWidth(bview,
- cursor.par(),
- cursor.pos()));
+ cursor.par(),
+ cursor.pos()));
}
/* some special code when deleting a newline. This is similar
refresh_y = y;
refresh_row = tmprow;
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
setCursor(bview, cursor.par(), cursor.pos(),
false, cursor.boundary());
//current_font = rawtmpfont;
refresh_y = y;
refresh_row = row;
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
breakAgainOneRow(bview, row);
// will the cursor be in another row now?
int const tmpheight = row->height();
setHeightOfRow(bview, row);
if (tmpheight == row->height())
- status = LyXText::NEED_VERY_LITTLE_REFRESH;
+ status(bview, LyXText::NEED_VERY_LITTLE_REFRESH);
else
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
refresh_y = y;
refresh_row = row;
setCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary());
if (cleared) {
clear_area = true;
} else if (clear_area) {
-#ifdef WITH_WARNINGS
-#warning Should be fixed with a lyxinset::clear_width(bv, font) function! (Jug)
-#warning Should we not fix this in the Painter, please have a look Lars! (Jug)
-#endif
int const y = y_offset < 0 ? 0 : y_offset;
int const h = y_offset < 0 ?
row_ptr->height() + y_offset : row_ptr->height();
int const w = inset_owner ?
- inset_owner->width(bview, font) - 2 : ww;
+ inset_owner->textWidth(bview, true) : ww;
int const x = x_offset;
- pain.fillRectangle(x, y, w, h);
+ pain.fillRectangle(x, y, w, h, backgroundColor());
} else if (inset != 0) {
int h = row_ptr->baseline() - inset->ascent(bview, font);
+ // first clear the whole row above the inset!
if (h > 0) {
int const w = (inset_owner ?
- inset_owner->width(bview, font) : ww);
- pain.fillRectangle(x_offset, y_offset, w, h);
+ inset_owner->textWidth(bview, true) : ww);
+ pain.fillRectangle(x_offset, y_offset, w, h,
+ backgroundColor());
}
h += inset->ascent(bview, font) + inset->descent(bview, font);
+ // clear the space below the inset!
if ((row_ptr->height() - h) > 0) {
int const w = (inset_owner ?
- inset_owner->width(bview, font) : ww);
+ inset_owner->textWidth(bview, true) : ww);
pain.fillRectangle(x_offset, y_offset + h,
- w, row_ptr->height() - h);
+ w, row_ptr->height() - h,
+ backgroundColor());
}
- if (!inset_owner && !inset->display() && !inset->needFullRow())
- {
- int const w = inset->width(bview, font) + int(x);
- pain.fillRectangle(w, y_offset, ww - w, row_ptr->height());
+ // clear the space behind the inset, if needed
+ if (!inset->display() && !inset->needFullRow()) {
+ int const w = (inset_owner ?
+ inset_owner->textWidth(bview, true) : ww);
+ int const xp = int(x) + inset->width(bview, font);
+ if (w-xp > 0) {
+ pain.fillRectangle(xp, y_offset,
+ w-xp, row_ptr->height(),
+ backgroundColor());
+ }
}
}
if (selection.set()) {
int const w = (inset_owner ?
- inset_owner->width(bview, font) : ww);
+ inset_owner->textWidth(bview, true) : ww);
// selection code
if (bidi_same_direction) {
if (selection.start.row() == row_ptr &&
tmpx += fill_label_hfill +
lyxfont::width(textclasslist.Style(bview->buffer()->params.textclass,
row_ptr->par()->getLayout()).labelsep,
- getFont(bview->buffer(),row_ptr->par(), -2));
+ getLabelFont(bview->buffer(),row_ptr->par()));
if (row_ptr->par()->isLineSeparator(main_body-1))
tmpx -= singleWidth(bview, row_ptr->par(), main_body-1);
}
ww,
y_offset + y_top + 2 * defaultHeight(),
LColor::pagebreak,
- Painter::line_onoffdash)
- .rectText(0,
- 0,
- _("Page Break (top)"),
- pb_font,
- LColor::background,
- LColor::background, false, w, a, d);
+ Painter::line_onoffdash);
+ lyxfont::rectText(_("Page Break (top)"), pb_font,
+ w, a, d);
pain.rectText((ww - w)/2,
y_offset + y_top + 2 * defaultHeight() + d,
_("Page Break (top)"),
pb_font,
- LColor::background,
- LColor::background);
+ backgroundColor(),
+ backgroundColor());
y_top += 3 * defaultHeight();
}
&& (layout.labeltype != LABEL_STATIC
|| layout.latextype != LATEX_ENVIRONMENT
|| row_ptr->par()->isFirstInSequence())) {
- font = getFont(bview->buffer(), row_ptr->par(), -2);
+ font = getLabelFont(bview->buffer(), row_ptr->par());
if (!row_ptr->par()->getLabelstring().empty()) {
tmpx = x;
string const tmpstring =
layout.labeltype == LABEL_BIBLIO ||
layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
if (row_ptr->par()->isFirstInSequence()) {
- font = getFont(bview->buffer(),
- row_ptr->par(), -2);
+ font = getLabelFont(bview->buffer(),
+ row_ptr->par());
if (!row_ptr->par()->getLabelstring().empty()) {
string const tmpstring =
row_ptr->par()->getLabelstring();
}
}
if (layout.labeltype == LABEL_BIBLIO && row_ptr->par()->bibkey) {
- font = getFont(bview->buffer(), row_ptr->par(), -1);
+ font = getLayoutFont(bview->buffer(), row_ptr->par());
if (is_rtl)
tmpx = ww - leftMargin(bview, row_ptr)
+ lyxfont::width(layout.labelsep, font);
pain
.line(0, y_place, ww, y_place,
LColor::pagebreak,
- Painter::line_onoffdash)
- .rectText(0, 0,
- _("Page Break (bottom)"),
- pb_font,
- LColor::background,
- LColor::background, false, w, a, d);
+ Painter::line_onoffdash);
+ lyxfont::rectText(_("Page Break (bottom)"), pb_font,
+ w, a, d);
pain.rectText((ww - w) / 2, y_place + d,
_("Page Break (bottom)"),
pb_font,
- LColor::background,
- LColor::background);
+ backgroundColor(),
+ backgroundColor());
y_bottom -= 3 * defaultHeight();
}
string const tmpstring = textclasslist.
Style(bview->buffer()->params.textclass,
layout).endlabelstring();
- font = getFont(bview->buffer(), row_ptr->par(), -2);
+ font = getLabelFont(bview->buffer(), row_ptr->par());
int const tmpx = is_rtl ?
int(x) - lyxfont::width(tmpstring, font)
: ww - rightMargin(bview->buffer(), row_ptr) - row_ptr->fill();
if (main_body > 0 && pos == main_body - 1) {
x += fill_label_hfill
+ lyxfont::width(layout.labelsep,
- getFont(bview->buffer(),
- row_ptr->par(), -2))
+ getLabelFont(bview->buffer(),
+ row_ptr->par()))
- singleWidth(bview,
row_ptr->par(),
main_body - 1);
float last_tmpx = tmpx;
if (main_body > 0 &&
- (main_body-1 > last ||
+ (main_body - 1 > last ||
!row->par()->isLineSeparator(main_body - 1)))
main_body = 0;
if (main_body > 0 && c == main_body-1) {
tmpx += fill_label_hfill +
lyxfont::width(layout.labelsep,
- getFont(bview->buffer(), row->par(), -2));
+ getLabelFont(bview->buffer(), row->par()));
if (row->par()->isLineSeparator(main_body - 1))
tmpx -= singleWidth(bview, row->par(), main_body-1);
}
++vc;
}
- if (1 || (tmpx + last_tmpx) / 2 > x) {
+ if ((tmpx + last_tmpx) / 2 > x) {
tmpx = last_tmpx;
left_side = true;
}
// returns pointer to a specified row
Row * LyXText::getRow(Paragraph * par,
- Paragraph::size_type pos, int & y) const
+ Paragraph::size_type pos, int & y) const
{
if (!firstrow)
return 0;