#include "CutAndPaste.h"
#include "DispatchResult.h"
#include "ErrorList.h"
-#include "FuncRequest.h"
#include "Language.h"
#include "Layout.h"
#include "Lexer.h"
-#include "LyXFunc.h"
+#include "LyX.h"
#include "LyXRC.h"
#include "Paragraph.h"
-#include "paragraph_funcs.h"
#include "ParagraphParameters.h"
#include "TextClass.h"
#include "TextMetrics.h"
FontInfo font = layout.font;
// Realize with the fonts of lesser depth.
- //font.realize(outerFont(pit, paragraphs()));
+ //font.realize(outerFont(pit));
font.realize(owner_->buffer().params().getFont().fontInfo());
return font;
while (!layoutfont.resolved() &&
tp != pit_type(paragraphs().size()) &&
pars_[tp].getDepth()) {
- tp = outerHook(tp, paragraphs());
+ tp = outerHook(tp);
if (tp != pit_type(paragraphs().size()))
layoutfont.realize(pars_[tp].layout().font);
}
pit_type undopit = undoSpan(end - 1);
recUndo(cur, start, undopit - 1);
setLayout(start, end, layout);
- cur.buffer()->updateLabels();
+ cur.forceBufferUpdate();
}
}
// this handles the counter labels, and also fixes up
// depth values for follow-on (child) paragraphs
- cur.buffer()->updateLabels();
+ cur.forceBufferUpdate();
}
Font f = tm.displayFont(pit, pos);
f.update(font, language, toggleall);
setCharFont(pit, pos, f, tm.font_);
+ // font change may change language...
+ // spell checker has to know that
+ pars_[pit].requestSpellCheck(pos);
}
}
}
+void Text::setLabelWidthStringToSequence(pit_type const par_offset,
+ docstring const & s)
+{
+ pit_type offset = par_offset;
+ // Find first of same layout in sequence
+ while (!isFirstInSequence(offset)) {
+ offset = depthHook(offset, pars_[offset].getDepth());
+ }
+
+ // now apply label width string to every par
+ // in sequence
+ pit_type const end = pars_.size();
+ depth_type const depth = pars_[offset].getDepth();
+ Layout const & layout = pars_[offset].layout();
+ for (pit_type pit = offset; pit != end; ++pit) {
+ while (pars_[pit].getDepth() > depth)
+ ++pit;
+ if (pars_[pit].getDepth() < depth)
+ return;
+ if (pars_[pit].layout() != layout)
+ return;
+ pars_[pit].setLabelWidthString(s);
+ }
+}
+
+
void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
{
LASSERT(cur.text(), /**/);
// Do this only once for a selected range of paragraphs
// of the same layout and depth.
if (par.getDepth() != priordepth || par.layout() != priorlayout)
- setLabelWidthStringToSequence(pit, pars_,
- params.labelWidthString());
+ setLabelWidthStringToSequence(pit, params.labelWidthString());
par.params().apply(params, par.layout());
priordepth = par.getDepth();
priorlayout = par.layout();
// Do this only once for a selected range of paragraphs
// of the same layout and depth.
if (par.getDepth() != priordepth || par.layout() != priorlayout)
- setLabelWidthStringToSequence(pit, pars_,
- par.params().labelWidthString());
+ setLabelWidthStringToSequence(pit,
+ par.params().labelWidthString());
par.params().apply(p, par.layout());
priordepth = par.getDepth();
priorlayout = par.layout();
}
-// needed to insert the selection
-void Text::insertStringAsLines(DocIterator const & dit, docstring const & str,
- Font const & font)
-{
- BufferParams const & bparams = owner_->buffer().params();
- pit_type pit = dit.pit();
- pos_type pos = dit.pos();
-
- // insert the string, don't insert doublespace
- bool space_inserted = true;
- for (docstring::const_iterator cit = str.begin();
- cit != str.end(); ++cit) {
- Paragraph & par = pars_[pit];
- if (*cit == '\n') {
- if (autoBreakRows_ && (!par.empty() || par.allowEmpty())) {
- lyx::breakParagraph(bparams, pars_, pit, pos,
- par.layout().isEnvironment());
- ++pit;
- pos = 0;
- space_inserted = true;
- } else {
- continue;
- }
- // do not insert consecutive spaces if !free_spacing
- } else if ((*cit == ' ' || *cit == '\t') &&
- space_inserted && !par.isFreeSpacing()) {
- continue;
- } else if (*cit == '\t') {
- if (!par.isFreeSpacing()) {
- // tabs are like spaces here
- par.insertChar(pos, ' ', font, bparams.trackChanges);
- ++pos;
- space_inserted = true;
- } else {
- par.insertChar(pos, *cit, font, bparams.trackChanges);
- ++pos;
- space_inserted = true;
- }
- } else if (!isPrintable(*cit)) {
- // Ignore unprintables
- continue;
- } else {
- // just insert the character
- par.insertChar(pos, *cit, font, bparams.trackChanges);
- ++pos;
- space_inserted = (*cit == ' ');
- }
- }
-}
-
-
-// turn double CR to single CR, others are converted into one
-// blank. Then insertStringAsLines is called
-void Text::insertStringAsParagraphs(DocIterator const & dit, docstring const & str,
- Font const & font)
-{
- docstring linestr = str;
- bool newline_inserted = false;
-
- for (string::size_type i = 0, siz = linestr.size(); i < siz; ++i) {
- if (linestr[i] == '\n') {
- if (newline_inserted) {
- // we know that \r will be ignored by
- // insertStringAsLines. Of course, it is a dirty
- // trick, but it works...
- linestr[i - 1] = '\r';
- linestr[i] = '\n';
- } else {
- linestr[i] = ' ';
- newline_inserted = true;
- }
- } else if (isPrintable(linestr[i])) {
- newline_inserted = false;
- }
- }
- insertStringAsLines(dit, linestr, font);
-}
-
-
bool Text::setCursor(Cursor & cur, pit_type par, pos_type pos,
bool setfont, bool boundary)
{
// None of these should happen, but we're scaredy-cats
if (pos < 0) {
- lyxerr << "dont like -1" << endl;
+ lyxerr << "don't like -1" << endl;
LASSERT(false, /**/);
}
if (pos > para.size()) {
- lyxerr << "dont like 1, pos: " << pos
+ lyxerr << "don't like 1, pos: " << pos
<< " size: " << para.size()
<< " par: " << par << endl;
LASSERT(false, /**/);
bool Text::cursorBackward(Cursor & cur)
{
// Tell BufferView to test for FitCursor in any case!
- cur.updateFlags(Update::FitCursor);
+ cur.screenUpdateFlags(Update::FitCursor);
// not at paragraph start?
if (cur.pos() > 0) {
bool Text::cursorForward(Cursor & cur)
{
// Tell BufferView to test for FitCursor in any case!
- cur.updateFlags(Update::FitCursor);
+ cur.screenUpdateFlags(Update::FitCursor);
// not at paragraph end?
if (cur.pos() != cur.lastpos()) {