mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 13:48:59 +00:00
Provide option to force a local language switch where a global is not allowed (fixes #8033)
This commit is contained in:
parent
9b589ba9d9
commit
a7f8fb8c5f
@ -1,5 +1,5 @@
|
||||
#LyX 2.1 created this file. For more info see http://www.lyx.org/
|
||||
\lyxformat 446
|
||||
\lyxformat 448
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass scrbook
|
||||
@ -140,6 +140,7 @@ End
|
||||
\author -712698321 "Jürgen Spitzmüller"
|
||||
\author -195340706 "Georg Baum"
|
||||
\author 5863208 "ab"
|
||||
\author 155139281 "Jrgen Spitzmller"
|
||||
\author 1082167584 "Kayvan Sylvan" kayvan@sylvan.com
|
||||
\author 1414654397 "Richard Heck"
|
||||
\author 2090807402 "usti"
|
||||
@ -15960,6 +15961,81 @@ LabelFont
|
||||
\end_inset
|
||||
|
||||
later if you want them to be different.
|
||||
\change_inserted 155139281 1354130923
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\change_inserted 155139281 1354130923
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 155139281 1354130923
|
||||
ForceLocalFontSwitch
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
[
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 155139281 1354130923
|
||||
|
||||
\emph on
|
||||
0
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
,
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 155139281 1354130923
|
||||
1
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
] When using babel, always use a local font switch (
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 155139281 1354130923
|
||||
|
||||
\backslash
|
||||
foreignlanguage
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
), never a global one (such as
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 155139281 1354130923
|
||||
|
||||
\backslash
|
||||
selectlanguage
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
).
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
@ -16670,7 +16746,7 @@ string
|
||||
\end_inset
|
||||
|
||||
] A string that is put at the beginning of the layout content.
|
||||
\change_unchanged
|
||||
\change_inserted 155139281 1354130509
|
||||
|
||||
\end_layout
|
||||
|
||||
|
@ -406,6 +406,7 @@ InsetLayout Argument
|
||||
Size Small
|
||||
EndFont
|
||||
MultiPar false
|
||||
ForceLocalFontSwitch 1
|
||||
End
|
||||
|
||||
InsetLayout Info
|
||||
|
@ -41,7 +41,7 @@ InsetLayout::InsetLayout() :
|
||||
passthru_(false), parbreakisnewline_(false), freespacing_(false),
|
||||
keepempty_(false), forceltr_(false),
|
||||
needprotect_(false), intoc_(false), spellcheck_(true),
|
||||
resetsfont_(true), display_(true)
|
||||
resetsfont_(true), display_(true), forcelocalfontswitch_(false)
|
||||
{
|
||||
labelfont_.setColor(Color_error);
|
||||
}
|
||||
@ -87,6 +87,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
||||
IL_DECORATION,
|
||||
IL_DISPLAY,
|
||||
IL_FONT,
|
||||
IL_FORCE_LOCAL_FONT_SWITCH,
|
||||
IL_FORCELTR,
|
||||
IL_FORCEPLAIN,
|
||||
IL_FREESPACING,
|
||||
@ -135,6 +136,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
||||
{ "display", IL_DISPLAY },
|
||||
{ "end", IL_END },
|
||||
{ "font", IL_FONT },
|
||||
{ "forcelocalfontswitch", IL_FORCE_LOCAL_FONT_SWITCH },
|
||||
{ "forceltr", IL_FORCELTR },
|
||||
{ "forceplain", IL_FORCEPLAIN },
|
||||
{ "freespacing", IL_FREESPACING },
|
||||
@ -236,6 +238,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
||||
case IL_LEFTDELIM:
|
||||
lex >> leftdelim_;
|
||||
break;
|
||||
case IL_FORCE_LOCAL_FONT_SWITCH:
|
||||
lex >> forcelocalfontswitch_;
|
||||
break;
|
||||
case IL_RIGHTDELIM:
|
||||
lex >> rightdelim_;
|
||||
break;
|
||||
|
@ -162,6 +162,8 @@ public:
|
||||
bool resetsFont() const { return resetsfont_; }
|
||||
///
|
||||
bool isDisplay() const { return display_; }
|
||||
///
|
||||
bool forcelocalfontswitch() const { return forcelocalfontswitch_; }
|
||||
private:
|
||||
///
|
||||
void makeDefaultCSS() const;
|
||||
@ -263,6 +265,8 @@ private:
|
||||
///
|
||||
bool display_;
|
||||
///
|
||||
bool forcelocalfontswitch_;
|
||||
///
|
||||
Layout::LaTeXArgMap latexargs_;
|
||||
};
|
||||
|
||||
|
@ -551,10 +551,21 @@ void TeXOnePar(Buffer const & buf,
|
||||
getPolyglossiaEnvName(doc_language) : doc_language->babel();
|
||||
string const outer_lang = use_polyglossia ?
|
||||
getPolyglossiaEnvName(outer_language) : outer_language->babel();
|
||||
string const lang_begin_command = use_polyglossia ?
|
||||
string lang_begin_command = use_polyglossia ?
|
||||
"\\begin{$$lang}" : lyxrc.language_command_begin;
|
||||
string const lang_end_command = use_polyglossia ?
|
||||
string lang_end_command = use_polyglossia ?
|
||||
"\\end{$$lang}" : lyxrc.language_command_end;
|
||||
// the '%' is necessary to prevent unwanted whitespace
|
||||
string lang_command_termination = "%\n";
|
||||
|
||||
// In some insets (such as Arguments), we cannot use \selectlanguage
|
||||
bool const localswitch = !use_polyglossia
|
||||
&& text.inset().getLayout().forcelocalfontswitch();
|
||||
if (localswitch) {
|
||||
lang_begin_command = lyxrc.language_command_local;
|
||||
lang_end_command = "}";
|
||||
lang_command_termination.clear();
|
||||
}
|
||||
|
||||
if (par_lang != prev_lang
|
||||
// check if we already put language command in TeXEnvironment()
|
||||
@ -570,8 +581,7 @@ void TeXOnePar(Buffer const & buf,
|
||||
os << from_ascii(subst(lang_end_command,
|
||||
"$$lang",
|
||||
prev_lang))
|
||||
// the '%' is necessary to prevent unwanted whitespace
|
||||
<< "%\n";
|
||||
<< lang_command_termination;
|
||||
}
|
||||
|
||||
// We need to open a new language if we couldn't close the previous
|
||||
@ -629,8 +639,7 @@ void TeXOnePar(Buffer const & buf,
|
||||
os << "["
|
||||
<< from_ascii(par_language->polyglossiaOpts())
|
||||
<< "]";
|
||||
// the '%' is necessary to prevent unwanted whitespace
|
||||
os << "%\n";
|
||||
os << lang_command_termination;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -686,8 +695,7 @@ void TeXOnePar(Buffer const & buf,
|
||||
lang_begin_command,
|
||||
"$$lang",
|
||||
par_lang))
|
||||
// the '%' is necessary to prevent unwanted whitespace
|
||||
<< "%\n";
|
||||
<< lang_command_termination;
|
||||
}
|
||||
runparams.encoding = encoding;
|
||||
}
|
||||
@ -830,16 +838,16 @@ void TeXOnePar(Buffer const & buf,
|
||||
lang_begin_command,
|
||||
"$$lang",
|
||||
current_lang));
|
||||
pending_newline = true;
|
||||
unskip_newline = true;
|
||||
pending_newline = !localswitch;
|
||||
unskip_newline = !localswitch;
|
||||
}
|
||||
} else if (!par_lang.empty()) {
|
||||
os << from_ascii(subst(
|
||||
lang_end_command,
|
||||
"$$lang",
|
||||
par_lang));
|
||||
pending_newline = true;
|
||||
unskip_newline = true;
|
||||
pending_newline = !localswitch;
|
||||
unskip_newline = !localswitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user