mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Add option to Argument to let it be inserted with a copy of the co-text.
This is useful for classic "Short Titles", where one might want to start with the full title in the inset. Addresses: #4745
This commit is contained in:
parent
be040c4469
commit
760b7cf2b6
@ -11391,12 +11391,54 @@ status collapsed
|
|||||||
, this argument is automatically inserted when the respective style is selected.
|
, this argument is automatically inserted when the respective style is selected.
|
||||||
Currently, only one argument per style\SpecialChar breakableslash
|
Currently, only one argument per style\SpecialChar breakableslash
|
||||||
layout can be automatically inserted.
|
layout can be automatically inserted.
|
||||||
\change_inserted -712698321 1431070519
|
\change_inserted -712698321 1431166542
|
||||||
|
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Itemize
|
\begin_layout Itemize
|
||||||
|
|
||||||
|
\change_inserted -712698321 1431166604
|
||||||
|
\begin_inset Flex Code
|
||||||
|
status collapsed
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\change_inserted -712698321 1431166548
|
||||||
|
InsertCotext
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
|
\begin_inset Flex Code
|
||||||
|
status collapsed
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\change_inserted -712698321 1431166543
|
||||||
|
[int=0]
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
If this is set to
|
||||||
|
\begin_inset Flex Code
|
||||||
|
status collapsed
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\change_inserted -712698321 1431166543
|
||||||
|
1
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
, this argument will bei inserted with a copy of the co-text (either selected
|
||||||
|
text or the whole paragraph) as content.
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Itemize
|
||||||
|
|
||||||
\change_inserted -712698321 1431070588
|
\change_inserted -712698321 1431070588
|
||||||
|
|
||||||
\lang ngerman
|
\lang ngerman
|
||||||
|
@ -936,6 +936,7 @@ void Layout::readArgument(Lexer & lex)
|
|||||||
// writeArgument() makes use of these default values
|
// writeArgument() makes use of these default values
|
||||||
arg.mandatory = false;
|
arg.mandatory = false;
|
||||||
arg.autoinsert = false;
|
arg.autoinsert = false;
|
||||||
|
arg.insertcotext = false;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
arg.font = inherit_font;
|
arg.font = inherit_font;
|
||||||
@ -965,6 +966,9 @@ void Layout::readArgument(Lexer & lex)
|
|||||||
} else if (tok == "autoinsert") {
|
} else if (tok == "autoinsert") {
|
||||||
lex.next();
|
lex.next();
|
||||||
arg.autoinsert = lex.getBool();
|
arg.autoinsert = lex.getBool();
|
||||||
|
} else if (tok == "insertcotext") {
|
||||||
|
lex.next();
|
||||||
|
arg.insertcotext = lex.getBool();
|
||||||
} else if (tok == "leftdelim") {
|
} else if (tok == "leftdelim") {
|
||||||
lex.next();
|
lex.next();
|
||||||
arg.ldelim = lex.getDocString();
|
arg.ldelim = lex.getDocString();
|
||||||
@ -1024,6 +1028,8 @@ void writeArgument(ostream & os, string const & id, Layout::latexarg const & arg
|
|||||||
os << "\t\tMandatory " << arg.mandatory << '\n';
|
os << "\t\tMandatory " << arg.mandatory << '\n';
|
||||||
if (arg.autoinsert)
|
if (arg.autoinsert)
|
||||||
os << "\t\tAutoinsert " << arg.autoinsert << '\n';
|
os << "\t\tAutoinsert " << arg.autoinsert << '\n';
|
||||||
|
if (arg.insertcotext)
|
||||||
|
os << "\t\tInsertCotext " << arg.insertcotext << '\n';
|
||||||
if (!arg.ldelim.empty())
|
if (!arg.ldelim.empty())
|
||||||
os << "\t\tLeftDelim \""
|
os << "\t\tLeftDelim \""
|
||||||
<< to_utf8(subst(arg.ldelim, from_ascii("\n"), from_ascii("<br/>")))
|
<< to_utf8(subst(arg.ldelim, from_ascii("\n"), from_ascii("<br/>")))
|
||||||
|
@ -104,6 +104,7 @@ public:
|
|||||||
FontInfo font;
|
FontInfo font;
|
||||||
FontInfo labelfont;
|
FontInfo labelfont;
|
||||||
bool autoinsert;
|
bool autoinsert;
|
||||||
|
bool insertcotext;
|
||||||
docstring pass_thru_chars;
|
docstring pass_thru_chars;
|
||||||
};
|
};
|
||||||
///
|
///
|
||||||
|
@ -266,6 +266,35 @@ static bool doInsertInset(Cursor & cur, Text * text,
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (cmd.action() == LFUN_ARGUMENT_INSERT) {
|
||||||
|
bool cotextinsert = false;
|
||||||
|
InsetArgument const * const ia = static_cast<InsetArgument const *>(inset);
|
||||||
|
Layout const & lay = cur.paragraph().layout();
|
||||||
|
Layout::LaTeXArgMap args = lay.args();
|
||||||
|
Layout::LaTeXArgMap::const_iterator const lait = args.find(ia->name());
|
||||||
|
if (lait != args.end())
|
||||||
|
cotextinsert = (*lait).second.insertcotext;
|
||||||
|
// The argument requests to insert a copy of the co-text to the inset
|
||||||
|
if (cotextinsert) {
|
||||||
|
docstring ds;
|
||||||
|
// If we have a selection within a paragraph, use this
|
||||||
|
if (cur.selection() && cur.selBegin().pit() == cur.selEnd().pit())
|
||||||
|
ds = cur.selectionAsString(false);
|
||||||
|
// else use the whole paragraph
|
||||||
|
else
|
||||||
|
ds = cur.paragraph().asString();
|
||||||
|
text->insertInset(cur, inset);
|
||||||
|
if (edit)
|
||||||
|
inset->edit(cur, true);
|
||||||
|
// Now put co-text into inset
|
||||||
|
Font const f(inherit_font, cur.current_font.language());
|
||||||
|
if (!ds.empty()) {
|
||||||
|
cur.text()->insertStringAsLines(cur, ds, f);
|
||||||
|
cur.leaveInset(*inset);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool gotsel = false;
|
bool gotsel = false;
|
||||||
if (cur.selection()) {
|
if (cur.selection()) {
|
||||||
|
@ -564,6 +564,7 @@ void InsetLayout::readArgument(Lexer & lex)
|
|||||||
Layout::latexarg arg;
|
Layout::latexarg arg;
|
||||||
arg.mandatory = false;
|
arg.mandatory = false;
|
||||||
arg.autoinsert = false;
|
arg.autoinsert = false;
|
||||||
|
arg.insertcotext = false;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
arg.font = inherit_font;
|
arg.font = inherit_font;
|
||||||
@ -591,6 +592,9 @@ void InsetLayout::readArgument(Lexer & lex)
|
|||||||
} else if (tok == "autoinsert") {
|
} else if (tok == "autoinsert") {
|
||||||
lex.next();
|
lex.next();
|
||||||
arg.autoinsert = lex.getBool();
|
arg.autoinsert = lex.getBool();
|
||||||
|
} else if (tok == "insertcotext") {
|
||||||
|
lex.next();
|
||||||
|
arg.insertcotext = lex.getBool();
|
||||||
} else if (tok == "leftdelim") {
|
} else if (tok == "leftdelim") {
|
||||||
lex.next();
|
lex.next();
|
||||||
arg.ldelim = lex.getDocString();
|
arg.ldelim = lex.getDocString();
|
||||||
|
Loading…
Reference in New Issue
Block a user