};
-void LyXText::rowBreakPoint(Buffer const & buffer, pit_type const pit,
- Row & row) const
+void LyXText::rowBreakPoint(Buffer const & buffer, int right_margin,
+ pit_type const pit, Row & row) const
{
Paragraph const & par = pars_[pit];
pos_type const end = par.size();
}
// maximum pixel width of a row
- int width = maxwidth_ - rightMargin(buffer, par); // - leftMargin(buffer, pit, row);
+ int width = maxwidth_ - right_margin; // - leftMargin(buffer, pit, row);
if (width < 0) {
row.endpos(end);
return;
Change(Change::INSERTED));
}
+ // FIXME: Breaking a paragraph has nothing to do with setting a cursor.
+ // Because of the mix between the model (the paragraph contents) and the
+ // view (the paragraph breaking in rows, we have to do this here before
+ // the setCursor() call below.
+ redoParagraph(cur.bv(), cpit);
+ redoParagraph(cur.bv(), cpit + 1);
+
// This check is necessary. Otherwise the new empty paragraph will
// be deleted automatically. And it is more friendly for the user!
if (cur.pos() != 0 || isempty)
}
par.insertChar(cur.pos(), c, current_font, cur.buffer().params().trackChanges);
+
+ // FIXME: Inserting a character has nothing to do with setting a cursor.
+ // Because of the mix between the model (the paragraph contents) and the
+ // view (the paragraph breaking in rows, we have to do this here.
+ redoParagraph(cur.bv(), cur.pit());
setCursor(cur, cur.pit(), cur.pos() + 1, false, cur.boundary());
charInserted();
}
needsUpdate = dissolveInset(cur);
// Make sure the cursor is correct. Is this really needed?
- if (needsUpdate)
+ // FIXME: Inserting characters has nothing to do with setting a cursor.
+ // Because of the mix between the model (the paragraph contents)
+ // and the view (the paragraph breaking in rows, we have to do this
+ // here before the setCursorIntern() call.
+ if (needsUpdate) {
+ redoParagraph(cur.bv(), cur.pit());
setCursorIntern(cur, cur.pit(), cur.pos());
+ }
return needsUpdate;
}
if (cur.pos() == cur.lastpos())
setCurrentFont(cur);
+ // FIXME: Backspacing has nothing to do with setting a cursor.
+ // Because of the mix between the model (the paragraph contents)
+ // and the view (the paragraph breaking in rows, we have to do this
+ // here before the setCursor() call.
+ redoParagraph(cur.bv(), cur.pit());
setCursor(cur, cur.pit(), cur.pos(), false, cur.boundary());
return needsUpdate;
if (isMainText(*cur.bv().buffer()) || cur.inset().nargs() != 1)
return false;
+ bool const in_ert = cur.inset().lyxCode() == InsetBase::ERT_CODE;
recordUndoInset(cur);
cur.selHandle(false);
// save position
// FIXME: change tracking (MG)
cur.paragraph().eraseChar(cur.pos(), b.params().trackChanges);
if (!plist.empty()) {
+ if (in_ert) {
+ // ERT paragraphs have the Language latex_language.
+ // This is invalid outside of ERT, so we need to
+ // change it to the buffer language.
+ ParagraphList::iterator it = plist.begin();
+ ParagraphList::iterator it_end = plist.end();
+ for (; it != it_end; it++) {
+ it->changeLanguage(b.params(),
+ latex_language,
+ b.getLanguage());
+ }
+ }
+
pasteParagraphList(cur, plist, b.params().textclass,
b.errorList("Paste"));
// restore position
}
}
+ // Optimisation: this is used in the next two loops
+ // so better to calculate that once here.
+ int right_margin = rightMargin(buffer, par);
+
// redo insets
// FIXME: We should always use getFont(), see documentation of
// noFontChange() in insetbase.h.
for (; ii != iend; ++ii) {
Dimension dim;
int const w = maxwidth_ - leftMargin(buffer, pit, ii->pos)
- - rightMargin(buffer, par);
+ - right_margin;
LyXFont const & font = ii->inset->noFontChange() ?
bufferfont :
getFont(buffer, par, ii->pos);
pos_type z = 0;
do {
Row row(z);
- rowBreakPoint(buffer, pit, row);
+ rowBreakPoint(buffer, right_margin, pit, row);
setRowWidth(buffer, pit, row);
setHeightOfRow(bv, pit, row);
par.rows().push_back(row);
}
-string LyXText::getPossibleLabel(LCursor & cur) const
+docstring LyXText::getPossibleLabel(LCursor & cur) const
{
pit_type pit = cur.pit();
}
}
- string name = layout->latexname();
+ docstring name = from_ascii(layout->latexname());
// for captions, we want the abbreviation of the float type
if (layout->labeltype == LABEL_SENSITIVE) {
InsetBase * const in = &cur[i].inset();
if (in->lyxCode() == InsetBase::FLOAT_CODE
|| in->lyxCode() == InsetBase::WRAP_CODE) {
- name = to_utf8(in->getInsetName());
+ name = in->getInsetName();
break;
}
}
}
- string text = name.substr(0, 3);
+ docstring text = name.substr(0, 3);
if (name == "theorem")
- text = "thm"; // Create a correct prefix for prettyref
+ text = from_ascii("thm"); // Create a correct prefix for prettyref
text += ':';
if (layout->latextype == LATEX_PARAGRAPH || lyxrc.label_init_length < 0)
text.erase();
- // FIXME UNICODE
- string par_text = to_utf8(pars_[pit].asString(cur.buffer(), false));
+ docstring par_text = pars_[pit].asString(cur.buffer(), false);
for (int i = 0; i < lyxrc.label_init_length; ++i) {
if (par_text.empty())
break;
- string head;
+ docstring head;
par_text = split(par_text, head, ' ');
// Is it legal to use spaces in labels ?
if (i > 0)