#include "paragraph_funcs.h"
#include "ParagraphParameters.h"
#include "Undo.h"
+#include "TextMetrics.h"
#include "VSpace.h"
#include "WordLangTuple.h"
#include "support/convert.h"
#include <boost/current_function.hpp>
+#include <boost/next_prior.hpp>
#include <sstream>
}
-void Text::breakParagraph(Cursor & cur, bool keep_layout)
+void Text::breakParagraph(Cursor & cur, bool inverse_logic)
{
BOOST_ASSERT(this == cur.text());
cpar.eraseChar(cur.pos(), cur.buffer().params().trackChanges);
// What should the layout for the new paragraph be?
- int preserve_layout = 0;
- if (keep_layout)
- preserve_layout = 2;
- else
- preserve_layout = layout->isEnvironment();
+ bool keep_layout = inverse_logic ?
+ !layout->isEnvironment()
+ : layout->isEnvironment();
// We need to remember this before we break the paragraph, because
// that invalidates the layout variable
bool const isempty = cpar.allowEmpty() && cpar.empty();
lyx::breakParagraph(cur.buffer().params(), paragraphs(), cpit,
- cur.pos(), preserve_layout);
+ cur.pos(), keep_layout);
// After this, neither paragraph contains any rows!
recordUndo(cur, Undo::INSERT);
+ TextMetrics const & tm = cur.bv().textMetrics(this);
Buffer const & buffer = cur.buffer();
Paragraph & par = cur.paragraph();
// try to remove this
!(contains(number_seperators, c) &&
cur.pos() != 0 &&
cur.pos() != cur.lastpos() &&
- getFont(buffer, par, cur.pos()).number() == Font::ON &&
- getFont(buffer, par, cur.pos() - 1).number() == Font::ON)
+ tm.getDisplayFont(pit, cur.pos()).number() == Font::ON &&
+ tm.getDisplayFont(pit, cur.pos() - 1).number() == Font::ON)
)
number(cur); // Set current_font.number to OFF
} else if (isDigit(c) &&
|| par.isSeparator(cur.pos() - 2)
|| par.isNewline(cur.pos() - 2))
) {
- setCharFont(buffer, pit, cur.pos() - 1, cur.current_font);
+ setCharFont(buffer, pit, cur.pos() - 1, cur.current_font,
+ tm.font_);
} else if (contains(number_seperators, c)
&& cur.pos() >= 2
- && getFont(buffer, par, cur.pos() - 2).number() == Font::ON) {
- setCharFont(buffer, pit, cur.pos() - 1, cur.current_font);
+ && tm.getDisplayFont(pit, cur.pos() - 2).number() == Font::ON) {
+ setCharFont(buffer, pit, cur.pos() - 1, cur.current_font,
+ tm.font_);
}
}
}
if ((cur.pos() >= 2) && (par.isLineSeparator(cur.pos() - 1))) {
// get font in front and behind the space in question. But do NOT
// use getFont(cur.pos()) because the character c is not inserted yet
- Font const & pre_space_font = getFont(buffer, par, cur.pos() - 2);
+ Font const & pre_space_font = tm.getDisplayFont(cur.pit(), cur.pos() - 2);
Font const & post_space_font = cur.real_current_font;
bool pre_space_rtl = pre_space_font.isVisibleRightToLeft();
bool post_space_rtl = post_space_font.isVisibleRightToLeft();
// adjacent character whose direction is the paragraph's
// direction; don't touch other properties of the font
Language const * lang =
- (pre_space_rtl == par.isRightToLeftPar(buffer.params())) ?
+ (pre_space_rtl == par.isRTL(buffer.params())) ?
pre_space_font.language() : post_space_font.language();
- Font space_font = getFont(buffer, par, cur.pos() - 1);
+ Font space_font = tm.getDisplayFont(cur.pit(), cur.pos() - 1);
space_font.setLanguage(lang);
par.setFont(cur.pos() - 1, space_font);
}
b.getLanguage());
}
- pasteParagraphList(cur, plist, b.params().getTextClass_ptr(),
+ pasteParagraphList(cur, plist, b.params().getTextClassPtr(),
b.errorList("Paste"));
// restore position
cur.pit() = std::min(cur.lastpit(), spit);
name = from_ascii(layout->latexname());
// for captions, we just take the caption type
- Inset * caption_inset = cur.innerInsetOfType(Inset::CAPTION_CODE);
+ Inset * caption_inset = cur.innerInsetOfType(CAPTION_CODE);
if (caption_inset)
name = from_ascii(static_cast<InsetCaption *>(caption_inset)->type());
// If none of the above worked, we'll see if we're inside various
// types of insets and take our abbreviation from them.
if (name.empty()) {
- Inset::Code const codes[] = {
- Inset::FLOAT_CODE,
- Inset::WRAP_CODE,
- Inset::FOOT_CODE
+ InsetCode const codes[] = {
+ FLOAT_CODE,
+ WRAP_CODE,
+ FOOT_CODE
};
for (unsigned int i = 0; i < (sizeof codes / sizeof codes[0]); ++i) {
Inset * float_inset = cur.innerInsetOfType(codes[i]);