#include "ParIterator.h"
#include "TexRow.h"
#include "Text.h"
+#include "Encoding.h"
#include "frontends/Application.h"
#include "frontends/alert.h"
static docstring buffer_to_latex(Buffer & buffer)
{
- OutputParams runparams(&buffer.params().encoding());
+ //OutputParams runparams(&buffer.params().encoding());
+ OutputParams runparams(encodings.fromLyXName("utf8"));
odocstringstream ods;
otexstream os(ods);
runparams.nice = true;
if (!opt.ignoreformat) {
str = buffer_to_latex(buffer);
} else {
- OutputParams runparams(&buffer.params().encoding());
+ // OutputParams runparams(&buffer.params().encoding());
+ OutputParams runparams(encodings.fromLyXName("utf8"));
runparams.nice = true;
runparams.flavor = OutputParams::XETEX;
runparams.linelen = 10000; //lyxrc.plaintext_linelen;
static void buildAccentsMap()
{
accents["imath"] = "ı";
- accents["ddot{\\imath}"] = "ï";
- accents["acute{\\imath}"] = "í";
- accents["tilde{\\imath}"] = "ĩ";
accents["jmath"] = "ȷ";
- accents["hat{\\jmath}"] = "ĵ";
accents["lyxmathsym{ß}"] = "ß";
- buildaccent("ddot", "aeouyAEOUY", "äëöüÿÄËÖÜŸ"); // umlaut
- buildaccent("dot", "aeoyzAEOYZ", "ȧėȯẏżȦĖȮẎŻ");
- buildaccent("acute", "aAcCeElLoOnNrRsSuUyYzZI", "áÁćĆéÉĺĹóÓńŃŕŔśŚúÚýÝźŹÍ");
- /*
- buildaccent("dacute", "oOuU", "őŐűŰ");
- buildaccent("H", "oOuU", "őŐűŰ"); // dacute in text
- */
+ accents["ddot{\\imath}"] = "ï";
+ buildaccent("ddot", "aAeEIoOuUyY",
+ "äÄëËÏöÖüÜÿŸ"); // umlaut
+ buildaccent("dot|.", "cCeEgGIzZaAoObBdDfFyY",
+ "ċĊėĖġĠİżŻȧȦȯȮḃḂḋḊḟḞẏẎ");
+ accents["acute{\\imath}"] = "í";
+ buildaccent("acute", "aAcCeElLoOnNrRsSuUyYzZI",
+ "áÁćĆéÉĺĹóÓńŃŕŔśŚúÚýÝźŹÍ");
+ buildaccent("dacute|H|h", "oOuU", "őŐűŰ"); // double acute
buildaccent("mathring|r", "uU", "ůŮ");
- buildaccent("check", "cCdDeElLnNrRsSTzZ", "čČďĎěĚľĽňŇřŘšŠŤžŽ"); // caron
- buildaccent("hat", "cCgGhHJsSwWyYoOgG", "ĉĈĝĜĥĤĴŝŜŵŴŷŶôÔĝĜ"); // circ
- buildaccent("bar|=", "aAeEoOuU", "āĀēĒōŌūŪ"); // macron
- buildaccent("tilde", "I", "Ĩ"); // macron
+ accents["check{\\imath}"] = "ǐ";
+ accents["check{\\jmath}"] = "ǰ";
+ buildaccent("check|v", "cCdDaAeEIoOuUgGkKhHlLnNrRsSTzZ",
+ "čČďĎǎǍěĚǏǒǑǔǓǧǦǩǨȟȞľĽňŇřŘšŠŤžŽ"); // caron
+ accents["hat{\\imath}"] = "î";
+ accents["hat{\\jmath}"] = "ĵ";
+ buildaccent("hat|^", "aAeEiIcCgGhHJsSwWyYzZoOuU",
+ "âÂêÊîÎĉĈĝĜĥĤĴŝŜŵŴŷŶẑẐôÔûÛ"); // circ
+ accents["bar{\\imath}"] = "ī";
+ buildaccent("bar|=", "aAeEIoOuUyY",
+ "āĀēĒĪōŌūŪȳȲ"); // macron
+ accents["tilde{\\imath}"] = "ĩ";
+ buildaccent("tilde", "aAnNoOIuU",
+ "ãÃñÑõÕĨũŨ"); // tilde
}
/*
{
if (accents.empty())
buildAccentsMap();
- static regex const accre("\\\\((lyxmathsym|ddot|dot|acute|mathring|r|check|check|hat|bar|=)\\{[^\\{\\}]+\\}|imath|jmath)");
+ static regex const accre("\\\\((lyxmathsym|ddot|dot|.|acute|dacute|h|H|mathring|r|check|v|hat|^|bar|=|tilde)\\{[^\\{\\}]+\\}|imath|jmath)");
smatch sub;
for (sregex_iterator itacc(par.begin(), par.end(), accre), end; itacc != end; ++itacc) {
sub = *itacc;
par[pos+i] = val[i];
}
addIntervall(pos+val.size(), pos + sub.str(0).size());
+ for (size_t i = pos+val.size(); i < pos + sub.str(0).size(); i++) {
+ // remove any remaining parentheses
+ par[i] = ' ';
+ }
}
else {
LYXERR0("Not added accent for \"" << key << "\"");
// TODO Try adding a AS_STR_INSERTS as last arg
pos_type end = ( len == -1 || cur.pos() + len > int(par.size()) ) ?
int(par.size()) : cur.pos() + len;
- OutputParams runparams(&cur.buffer()->params().encoding());
+ // OutputParams runparams(&cur.buffer()->params().encoding());
+ OutputParams runparams(encodings.fromLyXName("utf8"));
runparams.nice = true;
runparams.flavor = OutputParams::XETEX;
runparams.linelen = 10000; //lyxrc.plaintext_linelen;
odocstringstream ods;
otexstream os(ods);
- OutputParams runparams(&buf.params().encoding());
+ //OutputParams runparams(&buf.params().encoding());
+ OutputParams runparams(encodings.fromLyXName("utf8"));
runparams.nice = false;
runparams.flavor = OutputParams::XETEX;
runparams.linelen = 8000; //lyxrc.plaintext_linelen;
DocIterator old_cur = cur;
for (int i = 0; i < increment && cur; cur.forwardPos(), i++) {
}
- if (! cur) {
+ if (! cur || (cur.pit() > old_cur.pit())) {
+ // Are we outside of the paragraph?
+ // This can happen if moving past some UTF8-encoded chars
cur = old_cur;
increment /= 2;
}
} else if (cur.inMathed()) {
odocstringstream ods;
otexstream os(ods);
- OutputParams runparams(&repl_buffer.params().encoding());
+ // OutputParams runparams(&repl_buffer.params().encoding());
+ OutputParams runparams(encodings.fromLyXName("utf8"));
runparams.nice = false;
runparams.flavor = OutputParams::XETEX;
runparams.linelen = 8000; //lyxrc.plaintext_linelen;