#include "BufferView.h"
#include "bufferview_funcs.h"
#include "Bullet.h"
+#include "Color.h"
#include "CoordCache.h"
#include "Cursor.h"
#include "CutAndPaste.h"
#include "FuncRequest.h"
#include "gettext.h"
#include "Language.h"
-#include "Color.h"
+#include "Lexer.h"
#include "LyXFunc.h"
#include "LyXRC.h"
#include "Row.h"
using std::string;
using std::max;
using std::min;
-
+using std::istringstream;
Text::Text()
: current_font(Font::ALL_INHERIT),
pars_[pit].getInset(pos)->noFontChange());
Inset * const inset = pars_[pit].getInset(pos);
- DocIterator dit = doc_iterator_begin(*inset);
- // start of the last cell
- DocIterator end = dit;
- end.idx() = end.lastidx();
-
- while (true) {
- Text * text = dit.text();
- Inset * cell = dit.realInset();
- if (text && cell) {
- DocIterator cellbegin = doc_iterator_begin(*cell);
+ CursorSlice::idx_type endidx = inset->nargs();
+ for (CursorSlice cs(*inset); cs.idx() != endidx; ++cs.idx()) {
+ Text * text = cs.text();
+ if (text) {
// last position of the cell
- DocIterator cellend = cellbegin;
+ CursorSlice cellend = cs;
cellend.pit() = cellend.lastpit();
cellend.pos() = cellend.lastpos();
- text->setFont(buffer, cellbegin.top(), cellend.top(), font, toggleall);
+ text->setFont(buffer, cs, cellend, font, toggleall);
}
- if (dit == end)
- break;
- dit.forwardIdx();
}
}
BOOST_ASSERT(this == cur.text());
// special handling of new environment insets
BufferView & bv = cur.bv();
- BufferParams const & params = bv.buffer()->params();
+ BufferParams const & params = bv.buffer().params();
Layout_ptr const & lyxlayout = params.getTextClass()[layout];
if (lyxlayout->is_environment) {
// move everything in a new environment inset
}
-void Text::setParagraph(Cursor & cur,
- Spacing const & spacing, LyXAlignment align,
- docstring const & labelwidthstring, bool noindent)
+void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
{
BOOST_ASSERT(cur.text());
// make sure that the depth behind the selection are restored, too
for (pit_type pit = cur.selBegin().pit(), end = cur.selEnd().pit();
pit <= end; ++pit) {
Paragraph & par = pars_[pit];
- ParagraphParameters & params = par.params();
- params.spacing(spacing);
-
- // does the layout allow the new alignment?
- if (align & par.layout()->alignpossible)
- params.align(align);
- par.setLabelWidthString(labelwidthstring);
- params.noindent(noindent);
+ ParagraphParameters params = par.params();
+ params.read(to_utf8(arg), merge);
+ Layout const & layout = *(par.layout());
+ par.params().apply(params, layout);
}
}
+//FIXME This is a little redundant now, but it's probably worth keeping,
+//especially if we're going to go away from using serialization internally
+//quite so much.
+void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p)
+{
+ BOOST_ASSERT(cur.text());
+ // make sure that the depth behind the selection are restored, too
+ pit_type undopit = undoSpan(cur.selEnd().pit());
+ recUndo(cur, cur.selBegin().pit(), undopit - 1);
+
+ for (pit_type pit = cur.selBegin().pit(), end = cur.selEnd().pit();
+ pit <= end; ++pit) {
+ Paragraph & par = pars_[pit];
+ Layout const & layout = *(par.layout());
+ par.params().apply(p, layout);
+ }
+}
+
+
// this really should just insert the inset and not move the cursor.
void Text::insertInset(Cursor & cur, Inset * inset)
{