/**
- * \file src/text.cpp
+ * \file src/Text.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
#include "Cursor.h"
#include "ParIterator.h"
#include "CutAndPaste.h"
-#include "debug.h"
#include "DispatchResult.h"
#include "Encoding.h"
#include "ErrorList.h"
#include "FuncRequest.h"
#include "factory.h"
#include "FontIterator.h"
-#include "gettext.h"
#include "Language.h"
#include "Length.h"
#include "Lexer.h"
#include "Paragraph.h"
#include "paragraph_funcs.h"
#include "ParagraphParameters.h"
+#include "TextClass.h"
#include "TextMetrics.h"
#include "VSpace.h"
#include "WordLangTuple.h"
#include "insets/InsetHFill.h"
#include "insets/InsetLine.h"
#include "insets/InsetNewline.h"
-#include "insets/InsetPagebreak.h"
+#include "insets/InsetNewpage.h"
#include "insets/InsetOptArg.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 "support/lstrings.h"
#include "support/textutils.h"
-#include "support/convert.h"
-#include <boost/current_function.hpp>
#include <boost/next_prior.hpp>
#include <sstream>
-using std::auto_ptr;
-using std::advance;
-using std::distance;
-using std::max;
-using std::min;
-using std::endl;
-using std::string;
+using namespace std;
+using namespace lyx::support;
namespace lyx {
-using support::bformat;
-using support::contains;
-using support::split;
-
using cap::cutSelection;
using cap::pasteParagraphList;
par.params().read(lex);
} else if (token == "\\end_layout") {
- lyxerr << BOOST_CURRENT_FUNCTION
- << ": Solitary \\end_layout in line "
- << lex.getLineNo() << "\n"
- << "Missing \\begin_layout?.\n";
+ LYXERR0("Solitary \\end_layout in line " << lex.getLineNo() << "\n"
+ << "Missing \\begin_layout ?");
} else if (token == "\\end_inset") {
- lyxerr << BOOST_CURRENT_FUNCTION
- << ": Solitary \\end_inset in line "
- << lex.getLineNo() << "\n"
- << "Missing \\begin_inset?.\n";
+ LYXERR0("Solitary \\end_inset in line " << lex.getLineNo() << "\n"
+ << "Missing \\begin_inset ?");
} else if (token == "\\begin_inset") {
Inset * inset = readInset(lex, buf);
if (inset)
}
} else if (token == "\\backslash") {
par.appendChar('\\', font, change);
+ } else if (token == "\\linebreak") {
+ auto_ptr<Inset> inset(new InsetLinebreak);
+ inset->read(buf, lex);
+ par.insertInset(par.size(), inset.release(), font, change);
} else if (token == "\\newline") {
auto_ptr<Inset> inset(new InsetNewline);
inset->read(buf, lex);
} else if (token == "\\lyxline") {
par.insertInset(par.size(), new InsetLine, font, change);
} else if (token == "\\newpage") {
+ par.insertInset(par.size(), new InsetNewpage, font, change);
+ } else if (token == "\\pagebreak") {
par.insertInset(par.size(), new InsetPagebreak, font, change);
} else if (token == "\\clearpage") {
par.insertInset(par.size(), new InsetClearPage, font, change);
change = Change(Change::UNCHANGED);
} else if (token == "\\change_inserted") {
lex.eatLine();
- std::istringstream is(lex.getString());
+ istringstream is(lex.getString());
unsigned int aid;
- time_type ct;
+ time_t ct;
is >> aid >> ct;
if (aid >= bp.author_map.size()) {
errorList.push_back(ErrorItem(_("Change tracking error"),
change = Change(Change::INSERTED, bp.author_map[aid], ct);
} else if (token == "\\change_deleted") {
lex.eatLine();
- std::istringstream is(lex.getString());
+ istringstream is(lex.getString());
unsigned int aid;
- time_type ct;
+ time_t ct;
is >> aid >> ct;
if (aid >= bp.author_map.size()) {
errorList.push_back(ErrorItem(_("Change tracking error"),
break;
}
- LYXERR(Debug::PARSER) << "Handling paragraph token: `"
- << token << '\'' << endl;
+ LYXERR(Debug::PARSER, "Handling paragraph token: `" << token << '\'');
if (token == "\\begin_layout" || token == "\\end_document"
|| token == "\\end_inset" || token == "\\begin_deeper"
|| token == "\\end_deeper") {
return false;
cur.recordUndoInset();
+ cur.mark() = false;
cur.selHandle(false);
// save position
pos_type spos = cur.pos();
pasteParagraphList(cur, plist, b.params().getTextClassPtr(),
b.errorList("Paste"));
// restore position
- cur.pit() = std::min(cur.lastpit(), spit);
- cur.pos() = std::min(cur.lastpos(), spos);
+ cur.pit() = min(cur.lastpit(), spit);
+ cur.pos() = min(cur.lastpos(), spos);
}
cur.clearSelection();
cur.resetAnchor();
--from.pos();
break;
case NEXT_WORD:
- lyxerr << "Text::getWord: NEXT_WORD not implemented yet"
- << endl;
+ LYXERR0("Text::getWord: NEXT_WORD not implemented yet");
break;
case PARTIAL_WORD:
// no need to move the 'from' cursor
}
-void Text::write(Buffer const & buf, std::ostream & os) const
+void Text::write(Buffer const & buf, ostream & os) const
{
ParagraphList::const_iterator pit = paragraphs().begin();
ParagraphList::const_iterator end = paragraphs().end();
} else if (token == "\\begin_deeper") {
++depth;
} else if (token == "\\end_deeper") {
- if (!depth) {
+ if (!depth)
lex.printError("\\end_deeper: " "depth is already null");
- } else {
+ else
--depth;
- }
} else {
- lyxerr << "Handling unknown body token: `"
- << token << '\'' << endl;
+ LYXERR0("Handling unknown body token: `" << token << '\'');
}
}
return true;
if (!par.empty() && cur.pos() < par.size()) {
// Force output of code point, not character
size_t const c = par.getChar(cur.pos());
- os << _(", Char: 0x") << std::hex << c;
+ os << _(", Char: 0x") << hex << c;
}
os << _(", Boundary: ") << cur.boundary();
// Row & row = cur.textRow();
docstring text;
docstring par_text = pars_[pit].asString(cur.buffer(), false);
+ string piece;
+ // the return string of math matrices might contain linebreaks
+ par_text = subst(par_text, '\n', '-');
for (int i = 0; i < lyxrc.label_init_length; ++i) {
if (par_text.empty())
break;
}
+DocIterator Text::macrocontextPosition() const
+{
+ return macrocontext_position_;
+}
+
+
+void Text::setMacrocontextPosition(DocIterator const & pos)
+{
+ macrocontext_position_ = pos;
+}
+
+
} // namespace lyx