#include "ParIterator.h"
#include "TextClass.h"
#include "TextMetrics.h"
-#include "VSpace.h"
#include "WordLangTuple.h"
#include "WordList.h"
#include "insets/InsetNewline.h"
#include "insets/InsetNewpage.h"
#include "insets/InsetArgument.h"
+#include "insets/InsetIPAMacro.h"
#include "insets/InsetSpace.h"
#include "insets/InsetSpecialChar.h"
#include "insets/InsetTabular.h"
+#include "support/convert.h"
#include "support/debug.h"
#include "support/docstream.h"
#include "support/gettext.h"
#include <boost/next_prior.hpp>
+#include <limits>
#include <sstream>
+
+// TODO: replace if in Text::readParToken() with compile time switch
+#if 0
+
+#include "support/metahash.h"
+
+typedef boost::mpl::string<'\\end','_lay','out'> end_layout;
+typedef boost::mpl::string<'\\end','in','set'> end_inset;
+
+void foo()
+{
+ std::string token = "\\end_layout";
+
+ switch (boost::hash_value(token)) {
+ case lyx::support::hash_string<end_layout>::value:
+ return;
+ case lyx::support::hash_string<end_inset>::value:
+ return;
+ default: ;
+ };
+
+}
+#endif
+
+
using namespace std;
using namespace lyx::support;
{
depth_type par_depth = pars_[par_offset].getDepth();
FontInfo tmpfont = inherit_font;
-
+ depth_type prev_par_depth = 0;
// Resolve against environment font information
while (par_offset != pit_type(pars_.size())
+ && par_depth != prev_par_depth
&& par_depth
&& !tmpfont.resolved()) {
+ prev_par_depth = par_depth;
par_offset = outerHook(par_offset);
if (par_offset != pit_type(pars_.size())) {
tmpfont.realize(pars_[par_offset].layout().font);
}
+
void Text::readParToken(Paragraph & par, Lexer & lex,
string const & token, Font & font, Change & change, ErrorList & errorList)
{
inset->read(lex);
inset->setBuffer(*buf);
par.insertInset(par.size(), inset.release(), font, change);
+ } else if (token == "\\IPAChar") {
+ auto_ptr<Inset> inset;
+ inset.reset(new InsetIPAChar);
+ inset->read(lex);
+ inset->setBuffer(*buf);
+ par.insertInset(par.size(), inset.release(), font, change);
} else if (token == "\\backslash") {
par.appendChar('\\', font, change);
} else if (token == "\\LyXTable") {
return;
}
- // a layout change may affect also the following paragraph
- recUndo(cur, cur.pit(), undoSpan(cur.pit()) - 1);
+ cur.recordUndo();
// Always break behind a space
// It is better to erase the space (Dekel)
// needed to insert the selection
-void Text::insertStringAsLines(DocIterator const & dit, docstring const & str,
+void Text::insertStringAsLines(Cursor & cur, docstring const & str,
Font const & font)
{
BufferParams const & bparams = owner_->buffer().params();
- pit_type pit = dit.pit();
- pos_type pos = dit.pos();
+ pit_type pit = cur.pit();
+ pos_type pos = cur.pos();
// insert the string, don't insert doublespace
bool space_inserted = true;
space_inserted = (*cit == ' ');
}
}
+ setCursor(cur, pit, pos);
}
// 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,
+void Text::insertStringAsParagraphs(Cursor & cur, docstring const & str,
Font const & font)
{
docstring linestr = str;
newline_inserted = false;
}
}
- insertStringAsLines(dit, linestr, font);
+ insertStringAsLines(cur, linestr, font);
}
// change it to the buffer language.
ParagraphList::iterator it = plist.begin();
ParagraphList::iterator it_end = plist.end();
- for (; it != it_end; it++)
+ for (; it != it_end; ++it)
it->changeLanguage(b.params(), latex_language, b.language());
pasteParagraphList(cur, plist, b.params().documentClassPtr(),
return res;
}
+
// Returns the current font and depth as a message.
docstring Text::currentState(Cursor const & cur) const
{
if (!name.empty())
text = name + ':' + text;
- return text;
+ // We need a unique label
+ docstring label = text;
+ int i = 1;
+ while (cur.buffer()->insetLabel(label)) {
+ label = text + '-' + convert<docstring>(i);
+ ++i;
+ }
+
+ return label;
}
void Text::forToc(docstring & os, size_t maxlen, bool shorten) const
{
- LASSERT(maxlen > 10, maxlen = 30);
+ if (maxlen == 0)
+ maxlen = std::numeric_limits<std::size_t>::max();
+ else
+ LASSERT(maxlen >= 8, maxlen = TOC_ENTRY_LENGTH);
for (size_t i = 0; i != pars_.size() && os.length() < maxlen; ++i)
pars_[i].forToc(os, maxlen);
if (shorten && os.length() >= maxlen)