mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
corrected_env: use breakln instead of hardcoded linebreak
This commit is contained in:
parent
9a84737d5b
commit
e5e8bff75b
@ -2208,36 +2208,37 @@ string correction(string const & orig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string const corrected_env(string const & suffix, string const & env,
|
bool corrected_env(otexstream & os, string const & suffix, string const & env,
|
||||||
InsetCode code, bool const lastpar)
|
InsetCode code, bool const lastpar, int & col)
|
||||||
{
|
{
|
||||||
string output = suffix + "{";
|
string macro = suffix + "{";
|
||||||
if (noTrivlistCentering(code)) {
|
if (noTrivlistCentering(code)) {
|
||||||
if (lastpar) {
|
if (lastpar) {
|
||||||
// the last paragraph in non-trivlist-aligned
|
// the last paragraph in non-trivlist-aligned
|
||||||
// context is special (to avoid unwanted whitespace)
|
// context is special (to avoid unwanted whitespace)
|
||||||
if (suffix == "\\begin")
|
if (suffix == "\\begin") {
|
||||||
return "\\" + correction(env) + "{}";
|
macro = "\\" + correction(env) + "{}";
|
||||||
return string();
|
os << from_ascii(macro);
|
||||||
|
col += macro.size();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
output += correction(env);
|
macro += correction(env);
|
||||||
} else
|
} else
|
||||||
output += env;
|
macro += env;
|
||||||
output += "}";
|
macro += "}";
|
||||||
if (suffix == "\\begin")
|
if (suffix == "\\par\\end") {
|
||||||
output += "\n";
|
os << breakln;
|
||||||
return output;
|
col = 0;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void adjust_column(string const & str, int & column)
|
|
||||||
{
|
|
||||||
if (!contains(str, "\n"))
|
|
||||||
column += str.size();
|
|
||||||
else {
|
|
||||||
string tmp;
|
|
||||||
column = rsplit(str, tmp, '\n').size();
|
|
||||||
}
|
}
|
||||||
|
os << from_ascii(macro);
|
||||||
|
col += macro.size();
|
||||||
|
if (suffix == "\\begin") {
|
||||||
|
os << breakln;
|
||||||
|
col = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace anon
|
} // namespace anon
|
||||||
@ -2288,28 +2289,20 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
|
|||||||
case LYX_ALIGN_DECIMAL:
|
case LYX_ALIGN_DECIMAL:
|
||||||
break;
|
break;
|
||||||
case LYX_ALIGN_LEFT: {
|
case LYX_ALIGN_LEFT: {
|
||||||
string output;
|
|
||||||
if (owner_->getParLanguage(bparams)->babel() != "hebrew")
|
if (owner_->getParLanguage(bparams)->babel() != "hebrew")
|
||||||
output = corrected_env(begin_tag, "flushleft", code, lastpar);
|
corrected_env(os, begin_tag, "flushleft", code, lastpar, column);
|
||||||
else
|
else
|
||||||
output = corrected_env(begin_tag, "flushright", code, lastpar);
|
corrected_env(os, begin_tag, "flushright", code, lastpar, column);
|
||||||
os << from_ascii(output);
|
|
||||||
adjust_column(output, column);
|
|
||||||
break;
|
break;
|
||||||
} case LYX_ALIGN_RIGHT: {
|
} case LYX_ALIGN_RIGHT: {
|
||||||
string output;
|
string output;
|
||||||
if (owner_->getParLanguage(bparams)->babel() != "hebrew")
|
if (owner_->getParLanguage(bparams)->babel() != "hebrew")
|
||||||
output = corrected_env(begin_tag, "flushright", code, lastpar);
|
corrected_env(os, begin_tag, "flushright", code, lastpar, column);
|
||||||
else
|
else
|
||||||
output = corrected_env(begin_tag, "flushleft", code, lastpar);
|
corrected_env(os, begin_tag, "flushleft", code, lastpar, column);
|
||||||
os << from_ascii(output);
|
|
||||||
adjust_column(output, column);
|
|
||||||
break;
|
break;
|
||||||
} case LYX_ALIGN_CENTER: {
|
} case LYX_ALIGN_CENTER: {
|
||||||
string output;
|
corrected_env(os, begin_tag, "center", code, lastpar, column);
|
||||||
output = corrected_env(begin_tag, "center", code, lastpar);
|
|
||||||
os << from_ascii(output);
|
|
||||||
adjust_column(output, column);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2341,8 +2334,9 @@ bool Paragraph::Private::endTeXParParams(BufferParams const & bparams,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
string output;
|
bool output = false;
|
||||||
string const end_tag = "\n\\par\\end";
|
int col = 0;
|
||||||
|
string const end_tag = "\\par\\end";
|
||||||
InsetCode code = ownerCode();
|
InsetCode code = ownerCode();
|
||||||
bool const lastpar = runparams.isLastPar;
|
bool const lastpar = runparams.isLastPar;
|
||||||
|
|
||||||
@ -2355,26 +2349,23 @@ bool Paragraph::Private::endTeXParParams(BufferParams const & bparams,
|
|||||||
break;
|
break;
|
||||||
case LYX_ALIGN_LEFT: {
|
case LYX_ALIGN_LEFT: {
|
||||||
if (owner_->getParLanguage(bparams)->babel() != "hebrew")
|
if (owner_->getParLanguage(bparams)->babel() != "hebrew")
|
||||||
output = corrected_env(end_tag, "flushleft", code, lastpar);
|
output = corrected_env(os, end_tag, "flushleft", code, lastpar, col);
|
||||||
else
|
else
|
||||||
output = corrected_env(end_tag, "flushright", code, lastpar);
|
output = corrected_env(os, end_tag, "flushright", code, lastpar, col);
|
||||||
os << from_ascii(output);
|
|
||||||
break;
|
break;
|
||||||
} case LYX_ALIGN_RIGHT: {
|
} case LYX_ALIGN_RIGHT: {
|
||||||
if (owner_->getParLanguage(bparams)->babel() != "hebrew")
|
if (owner_->getParLanguage(bparams)->babel() != "hebrew")
|
||||||
output = corrected_env(end_tag, "flushright", code, lastpar);
|
output = corrected_env(os, end_tag, "flushright", code, lastpar, col);
|
||||||
else
|
else
|
||||||
output = corrected_env(end_tag, "flushleft", code, lastpar);
|
output = corrected_env(os, end_tag, "flushleft", code, lastpar, col);
|
||||||
os << from_ascii(output);
|
|
||||||
break;
|
break;
|
||||||
} case LYX_ALIGN_CENTER: {
|
} case LYX_ALIGN_CENTER: {
|
||||||
output = corrected_env(end_tag, "center", code, lastpar);
|
corrected_env(os, end_tag, "center", code, lastpar, col);
|
||||||
os << from_ascii(output);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return !output.empty() || lastpar;
|
return output || lastpar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user