mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-28 06:49:43 +00:00
InsetListings: Rewrite C-ism in C++ and fix terminator bug.
The rewriting is completely done by JMarc. The terminator bug fix has been added to that by me. Fixes: #8985
This commit is contained in:
parent
abc4c663ca
commit
8e6d367f94
@ -50,9 +50,6 @@ using namespace lyx::support;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
|
||||||
char const lstinline_delimiters[] =
|
|
||||||
"!*()-=+|;:'\"`,<.>/?QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm";
|
|
||||||
|
|
||||||
InsetListings::InsetListings(Buffer * buf, InsetListingsParams const & par)
|
InsetListings::InsetListings(Buffer * buf, InsetListingsParams const & par)
|
||||||
: InsetCollapsable(buf)
|
: InsetCollapsable(buf)
|
||||||
{
|
{
|
||||||
@ -202,17 +199,18 @@ void InsetListings::latex(otexstream & os, OutputParams const & runparams) const
|
|||||||
code += "\n";
|
code += "\n";
|
||||||
}
|
}
|
||||||
if (isInline) {
|
if (isInline) {
|
||||||
char const * delimiter = lstinline_delimiters;
|
static const docstring delimiters =
|
||||||
for (; *delimiter != '\0'; ++delimiter)
|
from_utf8("!*()-=+|;:'\"`,<.>/?QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm");
|
||||||
if (!contains(code, *delimiter))
|
|
||||||
break;
|
size_t pos = delimiters.find_first_not_of(code);
|
||||||
|
|
||||||
// This code piece contains all possible special character? !!!
|
// This code piece contains all possible special character? !!!
|
||||||
// Replace ! with a warning message and use ! as delimiter.
|
// Replace ! with a warning message and use ! as delimiter.
|
||||||
if (*delimiter == '\0') {
|
if (pos == string::npos) {
|
||||||
docstring delim_error = "<" + _("LyX Warning: ")
|
docstring delim_error = "<" + _("LyX Warning: ")
|
||||||
+ _("no more lstline delimiters available") + ">";
|
+ _("no more lstline delimiters available") + ">";
|
||||||
code = subst(code, from_ascii("!"), delim_error);
|
code = subst(code, from_ascii("!"), delim_error);
|
||||||
delimiter = lstinline_delimiters;
|
pos = 0;
|
||||||
if (!runparams.dryrun && !runparams.silent) {
|
if (!runparams.dryrun && !runparams.silent) {
|
||||||
// FIXME: warning should be passed to the error dialog
|
// FIXME: warning should be passed to the error dialog
|
||||||
frontend::Alert::warning(_("Running out of delimiters"),
|
frontend::Alert::warning(_("Running out of delimiters"),
|
||||||
@ -223,12 +221,14 @@ void InsetListings::latex(otexstream & os, OutputParams const & runparams) const
|
|||||||
"must investigate!"));
|
"must investigate!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (param_string.empty())
|
docstring const delim(1, delimiters[pos]);
|
||||||
os << "\\lstinline" << *delimiter;
|
os << "\\lstinline";
|
||||||
else
|
if (!param_string.empty())
|
||||||
os << "\\lstinline[" << from_utf8(param_string) << "]" << *delimiter;
|
os << "[" << from_utf8(param_string) << "]";
|
||||||
os << code
|
else if (pos >= delimiters.find('Q'))
|
||||||
<< *delimiter;
|
// We need to terminate the command before the delimiter
|
||||||
|
os << " ";
|
||||||
|
os << delim << code << delim;
|
||||||
} else {
|
} else {
|
||||||
OutputParams rp = runparams;
|
OutputParams rp = runparams;
|
||||||
rp.moving_arg = true;
|
rp.moving_arg = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user