-----------------------
+2024-08-12 Jürgen Spitzmüller <spitz@lyx.org>
+ * Format incremented to 627: Transform nomenclature inset to
+ collapsible.
+
2024-07-21 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 626: Support for manuel longest label in
\printnomencl (via new param option set_width "textwidth").
installed.
You find it in the \SpecialChar TeX
- catalogue,
+ catalog
+\change_deleted -712698321 1723454635
+ue
+\change_unchanged
+,
\begin_inset CommandInset citation
LatexCommand cite
\end_inset
or in the package manager of your \SpecialChar LaTeX
--system.
+
+\change_inserted -712698321 1723454632
+
+\change_deleted -712698321 1723454632
+-
+\change_unchanged
+system.
\end_layout
\begin_layout Standard
\end_inset
.
- A gray box labeled
+ A
+\change_deleted -712698321 1723454657
+gray box
+\change_inserted -712698321 1723454660
+collapsible inset
+\change_unchanged
+ labeled
\begin_inset Quotes eld
\end_inset
\begin_inset Quotes erd
\end_inset
- is inserted and a window pops up asking for the nomenclature entry.
+ is inserted
+\change_deleted -712698321 1723454685
+ and a window pops up asking for the nomenclature entry
+\change_unchanged
+.
+
+\change_inserted -712698321 1723454710
+ If the cursor is after a word,
+ this is copied into the inset.
+\change_unchanged
+
\end_layout
\begin_layout Standard
Description
\family default
of the term or symbol.
+
+\change_inserted -712698321 1723454817
+ The former is inserted into the collapsible inset directly,
+ the latter into the
+\family sans
+Description
+\family default
+ sub-inset which is automatically inserted or can be inserted via the
+\family sans
+Insert
+\family default
+ menu.
+\change_unchanged
+
\end_layout
\begin_layout Standard
+
+\change_deleted -712698321 1723454741
\begin_inset Note Greyedout
status open
\end_inset
+\change_unchanged
+
\end_layout
\begin_layout Subsection
\end_layout
\begin_layout Standard
+
+\change_inserted -712698321 1723454941
+Within the nomenclature inset,
+ you can use math and formatting as usual.
+\change_deleted -712698321 1723454925
If you have symbols in formulas,
you have to define them in the
\family sans
\end_layout
\begin_layout Standard
+
+\change_deleted -712698321 1723454925
(A short introduction to the \SpecialChar LaTeX
syntax is given in section
\begin_inset space ~
\end_layout
\begin_layout Standard
+
+\change_deleted -712698321 1723454925
You cannot use the
\family sans
Text
emph
\series default
.
+\change_unchanged
+
\end_layout
\begin_layout Standard
\end_layout
\begin_layout Standard
+
+\change_deleted -712698321 1723454959
If the characters |
\begin_inset space \space{}
\end_inset
\end_inset
+\change_unchanged
+
\end_layout
\begin_layout Subsection
\begin_layout Standard
The nomenclature entries are sorted alphabetically by the \SpecialChar LaTeX
--code of the symbol definition.
- This leads to undesired results when you,
+
+\change_deleted -712698321 1723454966
+-
+\change_inserted -712698321 1723454966
+
+\change_unchanged
+code of the symbol definition.
+ This leads to undesired results
+\change_deleted -712698321 1723454971
+when
+\change_inserted -712698321 1723454971
+if
+\change_unchanged
+ you,
for example,
have symbols in formulas.
Suppose you have nomenclature entries for the symbols
\begin_layout Standard
To control the sort order,
- you can edit the
+ you can
+\change_deleted -712698321 1723454992
+edit the
\family sans
Sort
\begin_inset space ~
as
\family default
- field of the nomenclature dialog.
+ field of the nomenclature dialog
+\change_inserted -712698321 1723455033
+use the
+\family sans
+Sort as
+\family default
+ subinset which is to be found in the
+\family sans
+Insert
+\family default
+ menu
+\change_unchanged
+.
Then the nomenclature entry will be sorted by this entry and not the symbol definition.
For the example given,
you can insert
installiert sein.
Sie finden es im \SpecialChar TeX
--Katalog,
-
+-Katalog
\begin_inset CommandInset citation
LatexCommand cite
key "TeX-Katalog"
\end_inset
wählen.
- Ein graues Kästchen mit der Aufschrift
+ Eine aufklappbare Einfügung mit der Aufschrift
\family sans
Nom
\family default
- wird eingefügt und ein Dialogfenster geöffnet.
+ wird eingefügt.
+ Falls der Cursor direkt hinter einem Wort steht,
+ wird dieses hineinkopiert.
Ein Nomenklatur-Eintrag besteht aus zwei Hauptteilen:
das
\family sans
Beschreibung
\family default
.
-\end_layout
-
-\begin_layout Standard
-\begin_inset Note Greyedout
-status open
-
-\begin_layout Plain Layout
-
-\series bold
-Achtung:
-
-\series default
- Um \SpecialChar TeX
--Code für Nomenklatureinträge verwenden zu können,
- muss die Option
+ Ersteres wird direkt in die Einfügung geschrieben,
+ letzteres in die Untereinfügung
\family sans
-Unformatiert
+Beschreibung
\family default
- im Nomenklatur-Dialog aktiviert sein.
-\end_layout
-
-\end_inset
-
-
+.
\end_layout
\begin_layout Subsection
\end_layout
\begin_layout Standard
-Wenn Sie Symbole in Formeln haben,
- müssen diese im
-\family sans
-Symbol
-\family default
- Feld als \SpecialChar LaTeX
--Formel eingegeben werden.
- Um z.
-\begin_inset space \thinspace{}
-\end_inset
-
-B.
- „
-\begin_inset Formula $\sigma$
-\end_inset
-
-“ zu bekommen,
- fügt man dies ein:
-\begin_inset Newline newline
-\end_inset
-
-
-\series bold
-$
-\backslash
-sigma$
-\begin_inset Newline newline
-\end_inset
-
-
-\series default
-Das Zeichen '$' beginnt/beendet die Formel.
- Der \SpecialChar LaTeX
--Befehl für den griechischen Buchstaben ist dessen Name beginnend mit einem umgekehrten Schrägstrich '
-\backslash
-'.
- Für große griechische Buchstaben beginnt der Befehl mit einem Großbuchstaben:
-
-\series bold
-
-\backslash
-Sigma
-\series default
-.
-\end_layout
-
-\begin_layout Standard
-(Eine kurze Einführung in die \SpecialChar LaTeX
--Syntax ist in Abschnitt
-\begin_inset space ~
-\end_inset
-
-
-\begin_inset CommandInset ref
-LatexCommand ref
-reference "subsec:LaTeX-Syntax"
-nolink "false"
-
-\end_inset
-
- zu finden.)
-\end_layout
-
-\begin_layout Standard
-Man kann den
-\family sans
-Textstil
-\family default
- Dialog nicht verwenden,
- um den Beschreibungstext zu formatieren,
- sondern man muss \SpecialChar LaTeX
--Befehle verwenden.
- Zum Beispiel lautet die Beschreibung für den Nomenklatureintrag für „
-\begin_inset Formula $\sigma$
-\end_inset
-
-“ in diesem Dokument:
-\begin_inset Newline newline
-\end_inset
-
-
-\series bold
-Sinnsloseintrag für das Zeichen
-\backslash
-textsf{sigma}
-\series default
-
-\begin_inset Newline newline
-\end_inset
-
-Der Befehl
-\series bold
-
-\backslash
-textsf
-\series default
- setzt die Schrift auf
-\family sans
-serifenlos
-\family default
-.
- Für
-\series bold
-fett
-\series default
- verwenden Sie den Befehl
-\series bold
-
-\backslash
-textbf
-\series default
-,
- für
-\family typewriter
-Schreibmaschine
-\family default
-
-\series bold
-
-\backslash
-texttt
-\series default
-,
- für
-\emph on
-hervorgehoben
-\series bold
-\emph default
-
-\backslash
-emph
-\series default
-.
+Innerhalb der Nomenklatur-Einfügung können Sie wie üblich Text formatieren und den Mathe-Modus verwenden.
\end_layout
\begin_layout Standard
.
\end_layout
-\begin_layout Standard
-Sollen die Zeichen |
-\begin_inset space \space{}
-\end_inset
-
-,
-\begin_inset space \space{}
-\end_inset
-
-!
-\begin_inset space \space{}
-\end_inset
-
-,
- @ und
-\begin_inset space \space{}
-\end_inset
-
-"
-\begin_inset space \space{}
-\end_inset
-
-in Nomenklatureinträgen mit \SpecialChar TeX
--Code erscheinen,
- müssen sie geschützt werden.
- indem man ein Prozentzeichen davor setzt.
- Um zu verhindern,
- dass das Anführungszeichen nachfolgende Zeichen beeinflusst,
- wird es mit einem leeren \SpecialChar TeX
--Klammerpaar abgeschlossen:
- %"{}
-\begin_inset CommandInset nomenclature
-LatexCommand nomenclature
-symbol "%@, %|, %!, %\"{}"
-description "Sonderzeichen im Nomenklatur-Kontext, denen für literale Ausgabe ,\\%` vorangestellt werden muss "
-literal "true"
-
-\end_inset
-
-
-\end_layout
-
\begin_layout Subsection
Nomenklatur-Einträge sortieren
\begin_inset Index idx
\begin_layout Standard
Um das zu ändern,
- können Sie etwas ins Feld
+ verwenden Sie die Untereinfügung
\family sans
-Einsortieren
-\begin_inset space \space{}
-\end_inset
-
-als
+Sortieren als
\family default
- schreiben,
- zum Beispiel
-\family typewriter
-sigma
+,
+ die Sie im Menü
+\family sans
+Einfügen
\family default
- bei
-\begin_inset Formula $\sigma$
-\end_inset
-
- .
+ finden.
Dann stimmt die Sortierreihenfolge wieder.
\end_layout
LabelString "Subentry"
End
+InsetLayout Nomenclature
+ LabelString Nom
+ LatexType command
+ LatexName nomenclature
+ Decoration classic
+ Font
+ Size Small
+ EndFont
+ LabelFont
+ Color nomlabel
+ Size Small
+ EndFont
+ MultiPar false
+ CustomPars false
+ ForcePlain true
+ ContentAsLabel true
+ AddToToc nomencl
+ Argument 1
+ LabelString "Sort as"
+ Tooltip "Sort this entry as specified in the inset"
+ EndArgument
+ Argument post:1
+ LabelString "Description"
+ Tooltip "Description of the entry"
+ AutoInsert 1
+ Mandatory 1
+ EscapeChars %!@|
+ EndArgument
+ EscapeChars %!@|
+End
+
InsetLayout Box
InheritFont false
LabelFont
content = ""
ert_end = 0
- note_end = 0
+ note_end = -1
hspace = ""
for curline in range(len(lines)):
# Uncomment only what you need to import, please (lyx2lyx_tools):
# convert_info_insets, get_ert, hex2ratio, insert_to_preamble,
-# length_in_bp, lyx2latex, lyx2verbatim,
+# length_in_bp, lyx2verbatim,
# revert_flex_inset, revert_flex_inset, revert_font_attrs,
# revert_language, str2bool
from lyx2lyx_tools import (
add_to_preamble,
latex_length,
+ lyx2latex,
put_cmd_in_ert
)
# Uncomment only what you need to import, please (parser_tools):
# check_token, count_pars_in_inset, del_complete_lines,
-# del_value, find_complete_lines, find_end_of, find_end_of_layout,
+# del_value, find_complete_lines, find_end_of,
# find_re, find_substring, find_token_backwards, find_token_exact,
# find_tokens, get_bool_value, get_containing_inset,
# get_containing_layout, get_option_value,
from parser_tools import (
del_token,
find_end_of_inset,
+ find_end_of_layout,
find_re,
find_token,
get_quoted_value,
i = j
+def convert_nomencl(document):
+ """Convert nomencl inset to collapsible."""
+
+ i = 0
+ while True:
+ i = find_token(document.body, "\\begin_inset CommandInset nomenclature", i)
+ if i == -1:
+ return
+
+ j = find_end_of_inset(document.body, i)
+ if j == -1:
+ document.warning(
+ "Malformed LyX document: Can't find end of command inset at line %d" % i
+ )
+ i += 1
+ continue
+
+ literal = get_quoted_value(document.body, "literal", i, j)
+ prefix = get_quoted_value(document.body, "prefix", i, j)
+ symbol = get_quoted_value(document.body, "symbol", i, j)
+ description = get_quoted_value(document.body, "description", i, j)
+
+ newins = ["\\begin_inset Nomenclature", "status open", "", "\\begin_layout Plain Layout"]
+ if prefix:
+ newins += ["\\begin_inset Argument 1",
+ "status open",
+ "",
+ "\\begin_layout Plain Layout",
+ prefix,
+ "\\end_layout",
+ "",
+ "\\end_inset",
+ ""]
+ if literal == "true":
+ newins += put_cmd_in_ert(symbol.replace("\\\\", "\\").replace("\\\"", "\""))
+ else:
+ newins += [symbol.replace("\\\"", "\"")]
+ if description:
+ newins += ["\\begin_inset Argument post:1",
+ "status open",
+ "",
+ "\\begin_layout Plain Layout"]
+ if literal == "true":
+ newins += put_cmd_in_ert(description.replace("\\\\", "\\").replace("\\\"", "\""))
+ else:
+ newins += [description.replace("\\\"", "\"")]
+ newins += ["\\end_layout",
+ "",
+ "\\end_inset",
+ ""]
+ newins += ["\\end_layout",
+ "",
+ "\\end_inset"]
+ document.body[i : j + 1] = newins
+
+
+def revert_nomencl(document):
+ """Revert nomencl inset to InsetCommand."""
+
+ i = 0
+ while True:
+ i = find_token(document.body, "\\begin_inset Nomenclature", i)
+ if i == -1:
+ return
+
+ j = find_end_of_inset(document.body, i)
+ if j == -1:
+ document.warning(
+ "Malformed LyX document: Can't find end of command inset at line %d" % i
+ )
+ i += 1
+ continue
+
+ arg = find_token(document.body, "\\begin_inset Argument 1", i, j)
+ prefix = []
+ if arg != -1:
+ endarg = find_end_of_inset(document.body, arg)
+ argbeginPlain = find_token(
+ document.body, "\\begin_layout Plain Layout", arg, endarg
+ )
+ if argbeginPlain == -1:
+ document.warning("Malformed LyX document: Can't find optarg plain Layout")
+ continue
+ argendPlain = find_end_of_inset(document.body, argbeginPlain)
+ prefix = document.body[argbeginPlain + 1 : argendPlain - 2]
+
+ # remove Arg insets and paragraph, if it only contains this inset
+ if (
+ document.body[arg - 1] == "\\begin_layout Plain Layout"
+ and find_end_of_layout(document.body, arg - 1) == endarg + 3
+ ):
+ del document.body[arg - 1 : endarg + 4]
+ else:
+ del document.body[arg : endarg + 1]
+
+ arg = find_token(document.body, "\\begin_inset Argument post:1", i, j)
+ description = []
+ if arg != -1:
+ endarg = find_end_of_inset(document.body, arg)
+ argbeginPlain = find_token(
+ document.body, "\\begin_layout Plain Layout", arg, endarg
+ )
+ if argbeginPlain == -1:
+ document.warning("Malformed LyX document: Can't find arg 1 plain Layout")
+ continue
+ argendPlain = find_end_of_inset(document.body, argbeginPlain)
+ description = document.body[argbeginPlain + 1 : argendPlain - 2]
+
+ # remove Arg insets and paragraph, if it only contains this inset
+ if (
+ document.body[arg - 1] == "\\begin_layout Plain Layout"
+ and find_end_of_layout(document.body, arg - 1) == endarg + 3
+ ):
+ del document.body[arg - 1 : endarg + 4]
+ else:
+ del document.body[arg : endarg + 1]
+
+ beginPlain = find_token(document.body, "\\begin_layout Plain Layout", i)
+ endPlain = find_end_of_layout(document.body, beginPlain)
+ symbol = document.body[beginPlain + 1 : endPlain]
+ literal = "false"
+ if "\\begin_inset ERT" in symbol or "\\begin_inset ERT" in description:
+ literal = "true"
+
+ newins = ["\\begin_inset CommandInset nomenclature", "LatexCommand nomenclature"]
+ if prefix:
+ newins += ["prefix \"" + lyx2latex(document, prefix) + "\""]
+ if symbol:
+ newins += ["symbol \"" + lyx2latex(document, symbol) + "\""]
+ if description:
+ newins += ["description \"" + lyx2latex(document, description) + "\""]
+ newins += ["literal \"" + literal + "\""]
+
+ j = find_end_of_inset(document.body, i)
+ document.body[i : j] = newins
+
+ i += 1
+
+
##
# Conversion hub
#
[623, [convert_he_letter]],
[624, [convert_biblatex_chicago]],
[625, []],
- [626, []]
+ [626, []],
+ [627, [convert_nomencl]]
]
revert = [
+ [626, [revert_nomencl]],
[625, [revert_nomencl_textwidth]],
[624, [revert_nptextcite]],
[623, [revert_biblatex_chicago]],
Captions
Indices
OptSubmenu "Index Properties" "index_properties"
- Item "Nomenclature Entry...|y" "nomencl-insert"
+ Item "Nomenclature Entry|y" "nomencl-insert"
Separator
Item "Table...|T" "tabular-insert"
Item "Graphics...|G" "dialog-show-new-inset graphics"
{ Color_footlabel, N_("footnote label"), "footlabel", "#00aaff", blue, "footlabel" },
{ Color_indexlabel, N_("index label"), "indexlabel", Green, teal, "indexlabel" },
{ Color_marginlabel, N_("margin note label"), "marginlabel", "#aa55ff", violet, "marginlabel" },
+ { Color_nomlabel, N_("nomenclature label"), "nomlabel", "#ff6d2f", "#ff6d2f", "nomlabel" },
{ Color_urllabel, N_("URL label"), "urllabel", blue, blue, "urllabel" },
{ Color_urltext, N_("URL text"), "urltext", blue, "#86a4ff", "urltext" },
{ Color_depthbar, N_("depth bar"), "depthbar", IndianRed, IndianRed, "depthbar" },
Color_indexlabel,
/// Label color for margin notes
Color_marginlabel,
+ /// Label color for nomenclature insets
+ Color_nomlabel,
/// Text color for phantom insets
Color_phantomtext,
/// Label color for URL insets
bool gotsel = false;
bool move_layout = false;
+ bool const copy_cotext = cmd.action() == LFUN_INDEX_INSERT
+ || cmd.action() == LFUN_NOMENCL_INSERT;
if (cur.selection()) {
- if (cmd.action() == LFUN_INDEX_INSERT)
+ if (copy_cotext)
copySelectionToTemp(cur);
else {
cutSelectionToTemp(cur, pastesel);
}
cur.clearSelection();
gotsel = true;
- } else if (cmd.action() == LFUN_INDEX_INSERT) {
+ } else if (copy_cotext) {
gotsel = text->selectWordWhenUnderCursor(cur, WHOLE_WORD);
copySelectionToTemp(cur);
cur.clearSelection();
*/
if (!move_layout)
cur.paragraph().setPlainOrDefaultLayout(bparams.documentClass());
- // FIXME: what does this do?
- if (cmd.action() == LFUN_FLEX_INSERT)
- return true;
+ // Insert auto-insert arguments
+ bool autoargs = false, inautoarg = false;
+ Layout::LaTeXArgMap args = cur.inset().getLayout().args();
+ for (auto const & argt : args) {
+ Layout::latexarg arg = argt.second;
+ if (!inautoarg && arg.insertonnewline && cur.pos() > 0) {
+ FuncRequest cmd2(LFUN_PARAGRAPH_BREAK);
+ lyx::dispatch(cmd2);
+ }
+ if (arg.autoinsert) {
+ // The cursor might have been invalidated by the replaceSelection.
+ cur.buffer()->changed(true);
+ // If we had already inserted an arg automatically,
+ // leave this now in order to insert the next one.
+ if (inautoarg) {
+ cur.leaveInset(cur.inset());
+ cur.setCurrentFont();
+ cur.posForward();
+ if (arg.insertonnewline && cur.pos() > 0) {
+ FuncRequest cmd2(LFUN_PARAGRAPH_BREAK);
+ lyx::dispatch(cmd2);
+ }
+ }
+ if (prefixIs(argt.first, "post:"))
+ cur.pos() = cur.paragraph().size();
+ else
+ cur.pos() = 0;
+ FuncRequest cmd2(LFUN_ARGUMENT_INSERT, argt.first);
+ lyx::dispatch(cmd2);
+ autoargs = true;
+ inautoarg = true;
+ }
+ }
Cursor old = cur;
- cur.leaveInset(*inset);
+ if (!autoargs)
+ cur.leaveInset(*inset);
if (cmd.action() == LFUN_PREVIEW_INSERT
|| cmd.action() == LFUN_IPA_INSERT)
// trigger preview
case LFUN_BOX_INSERT:
case LFUN_BRANCH_INSERT:
case LFUN_PHANTOM_INSERT:
+ case LFUN_FLEX_INSERT:
case LFUN_ERT_INSERT:
case LFUN_INDEXMACRO_INSERT:
case LFUN_LISTING_INSERT:
case LFUN_MARGINALNOTE_INSERT:
case LFUN_ARGUMENT_INSERT:
case LFUN_INDEX_INSERT:
+ case LFUN_NOMENCL_INSERT:
case LFUN_PREVIEW_INSERT:
case LFUN_SCRIPT_INSERT:
case LFUN_IPA_INSERT: {
- // Indexes reset font formatting (#11961)
- bool const resetfont = cmd.action() == LFUN_INDEX_INSERT;
+ // Indexes and Nomencl reset font formatting (#11961)
+ bool const resetfont = cmd.action() == LFUN_INDEX_INSERT
+ || cmd.action() == LFUN_NOMENCL_INSERT;
// Open the inset, and move the current selection
// inside it.
doInsertInset(cur, this, cmd, true, true, resetfont);
break;
}
- case LFUN_FLEX_INSERT: {
- // Open the inset, and move the current selection
- // inside it.
- bool const sel = cur.selection();
- doInsertInset(cur, this, cmd, true, true);
- // Insert auto-insert arguments
- bool autoargs = false, inautoarg = false;
- Layout::LaTeXArgMap args = cur.inset().getLayout().args();
- for (auto const & argt : args) {
- Layout::latexarg arg = argt.second;
- if (!inautoarg && arg.insertonnewline && cur.pos() > 0) {
- FuncRequest cmd2(LFUN_PARAGRAPH_BREAK);
- lyx::dispatch(cmd2);
- }
- if (arg.autoinsert) {
- // The cursor might have been invalidated by the replaceSelection.
- cur.buffer()->changed(true);
- // If we had already inserted an arg automatically,
- // leave this now in order to insert the next one.
- if (inautoarg) {
- cur.leaveInset(cur.inset());
- cur.setCurrentFont();
- cur.posForward();
- if (arg.insertonnewline && cur.pos() > 0) {
- FuncRequest cmd2(LFUN_PARAGRAPH_BREAK);
- lyx::dispatch(cmd2);
- }
- }
- FuncRequest cmd2(LFUN_ARGUMENT_INSERT, argt.first);
- lyx::dispatch(cmd2);
- autoargs = true;
- inautoarg = true;
- }
- }
- if (!autoargs) {
- if (sel)
- cur.leaveInset(cur.inset());
- cur.posForward();
- }
- // Some insets are numbered, others are shown in the outline pane so
- // let's update the labels and the toc backend.
- cur.forceBufferUpdate();
- break;
- }
-
case LFUN_TABULAR_INSERT: {
// if there were no arguments, just open the dialog
if (cmd.argument().empty()) {
break;
}
- case LFUN_NOMENCL_INSERT: {
- InsetCommandParams p(NOMENCL_CODE);
- if (cmd.argument().empty()) {
- p["symbol"] =
- bv->cursor().innerText()->getStringForDialog(bv->cursor());
- cur.clearSelection();
- } else
- p["symbol"] = cmd.argument();
- string const data = InsetCommand::params2string(p);
- bv->showDialog("nomenclature", data);
- break;
- }
-
case LFUN_INDEX_PRINT: {
InsetCommandParams p(INDEX_PRINT_CODE);
if (cmd.argument().empty())
case LFUN_IPA_INSERT:
return new InsetIPA(buf);
- case LFUN_NOMENCL_INSERT: {
- InsetCommandParams icp(NOMENCL_CODE);
- icp["symbol"] = cmd.argument();
- return new InsetNomencl(buf, icp);
- }
+ case LFUN_NOMENCL_INSERT:
+ return new InsetNomencl(buf);
case LFUN_TABULAR_INSERT: {
if (cmd.argument().empty())
return new InsetListings(buf, par);
}
- case NOMENCL_CODE: {
- InsetCommandParams icp(code);
- InsetCommand::string2params(to_utf8(cmd.argument()), icp);
- return new InsetNomencl(buf, icp);
- }
+ case NOMENCL_CODE:
+ return new InsetNomencl(buf);
case REF_CODE: {
InsetCommandParams icp(code);
case LINE_CODE:
inset.reset(new InsetLine(buf, inscmd));
break;
- case NOMENCL_CODE:
- inset.reset(new InsetNomencl(buf, inscmd));
- break;
case NOMENCL_PRINT_CODE:
inset.reset(new InsetPrintNomencl(buf, inscmd));
break;
inset.reset(new InsetIPA(buf));
} else if (tmptok == "IPADeco") {
inset.reset(new InsetIPADeco(buf, tmptok));
+ } else if (tmptok == "Nomenclature") {
+ inset.reset(new InsetNomencl(buf));
} else if (tmptok == "Preview") {
inset.reset(new InsetPreview(buf));
} else {
#include "GuiLog.h"
#include "GuiLyXFiles.h"
#include "GuiMathMatrix.h"
-#include "GuiNomenclature.h"
#include "GuiNote.h"
#include "GuiParagraph.h"
#include "GuiPhantom.h"
case MATH_SPACE_CODE:
widget = new GuiHSpace(true);
break;
- case NOMENCL_CODE:
- widget = new GuiNomenclature;
- break;
case NOMENCL_PRINT_CODE:
widget = new GuiPrintNomencl;
break;
+++ /dev/null
-/**
- * \file GuiNomencl.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author O. U. Baran
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "GuiNomenclature.h"
-
-#include "qt_helpers.h"
-
-#include "insets/InsetNomencl.h"
-
-using namespace std;
-
-namespace lyx {
-namespace frontend {
-
-GuiNomenclature::GuiNomenclature(QWidget * parent) : InsetParamsWidget(parent)
-{
- setupUi(this);
- connect(symbolED, SIGNAL(textChanged(QString)),
- this, SIGNAL(changed()));
- connect(descriptionTE, SIGNAL(textChanged()),
- this, SIGNAL(changed()));
- connect(literalCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
-
- setFocusProxy(descriptionTE);
-}
-
-
-void GuiNomenclature::paramsToDialog(Inset const * inset)
-{
- InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
- InsetCommandParams const & params = nomencl->params();
-
- prefixED->setText(toqstr(params["prefix"]));
- symbolED->setText(toqstr(params["symbol"]));
- literalCB->setChecked(params["literal"] == "true");
- QString description = toqstr(params["description"]);
- description.replace("\\\\","\n");
- descriptionTE->setPlainText(description);
- descriptionTE->setFocus();
-}
-
-
-docstring GuiNomenclature::dialogToParams() const
-{
- InsetCommandParams params(insetCode());
- params["prefix"] = qstring_to_ucs4(prefixED->text());
- params["symbol"] = qstring_to_ucs4(symbolED->text());
- QString description = descriptionTE->toPlainText();
- description.replace('\n',"\\\\");
- params["description"] = qstring_to_ucs4(description);
- params["literal"] = literalCB->isChecked()
- ? from_ascii("true") : from_ascii("false");
- return from_utf8(InsetNomencl::params2string(params));
-}
-
-
-bool GuiNomenclature::initialiseParams(std::string const & sdata)
-{
- InsetCommandParams p(insetCode());
- if (!InsetCommand::string2params(sdata, p))
- return false;
- symbolED->setText(toqstr(p["symbol"]));
- return true;
-}
-
-
-bool GuiNomenclature::checkWidgets(bool readonly) const
-{
- symbolED->setReadOnly(readonly);
- descriptionTE->setReadOnly(readonly);
- if (!InsetParamsWidget::checkWidgets())
- return false;
- QString const description = descriptionTE->toPlainText();
- return !symbolED->text().isEmpty() && !description.isEmpty();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "moc_GuiNomenclature.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file GuiNomenclature.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Kalle Dalheimer
- * \author O. U. Baran
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef GUINOMENCLATURE_H
-#define GUINOMENCLATURE_H
-
-#include "ui_NomenclUi.h"
-
-#include "InsetParamsWidget.h"
-
-namespace lyx {
-namespace frontend {
-
-class GuiNomenclature : public InsetParamsWidget, public Ui::NomenclUi
-{
- Q_OBJECT
-
-public:
- GuiNomenclature(QWidget * parent = 0);
-
-private:
- /// \name InsetParamsWidget inherited methods
- //@{
- InsetCode insetCode() const override { return NOMENCL_CODE; }
- FuncCode creationCode() const override { return LFUN_INSET_INSERT; }
- QString dialogTitle() const override { return qt_("Nomenclature Settings"); }
- void paramsToDialog(Inset const *) override;
- docstring dialogToParams() const override;
- bool checkWidgets(bool readonly) const override;
- bool initialiseParams(std::string const &) override;
- //@}
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // GUINOMENCLATURE_H
void GuiPrintNomencl::paramsToDialog(Inset const * inset)
{
- InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
+ InsetPrintNomencl const * nomencl = static_cast<InsetPrintNomencl const *>(inset);
paramsToDialog(nomencl->params());
}
else if (set_width == from_ascii("textwidth"))
width = qstring_to_ucs4(valueLE->text());
params["width"] = width;
- return from_ascii(InsetNomencl::params2string(params));
+ return from_ascii(InsetPrintNomencl::params2string(params));
}
#include "GuiInfo.h"
#include "GuiLabel.h"
#include "GuiLine.h"
-#include "GuiNomenclature.h"
#include "GuiPrintNomencl.h"
#include "GuiTabular.h"
#include "GuiVSpace.h"
GuiLog.cpp \
GuiLyXFiles.cpp \
GuiMathMatrix.cpp \
- GuiNomenclature.cpp \
GuiNote.cpp \
GuiPainter.cpp \
GuiParagraph.cpp \
GuiLog.h \
GuiLyXFiles.h \
GuiMathMatrix.h \
- GuiNomenclature.h \
GuiNote.h \
GuiParagraph.h \
GuiPhantom.h \
MathMatrixUi.ui \
MathsUi.ui \
ModulesUi.ui \
- NomenclUi.ui \
NoteUi.ui \
NumberingUi.ui \
OutputUi.ui \
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>NomenclUi</class>
- <widget class="QWidget" name="NomenclUi">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>319</width>
- <height>223</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Nomenclature</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="symbolLA">
- <property name="text">
- <string>Sy&mbol:</string>
- </property>
- <property name="buddy">
- <cstring>symbolED</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="symbolED">
- <property name="toolTip">
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="descrLA">
- <property name="text">
- <string>Des&cription:</string>
- </property>
- <property name="buddy">
- <cstring>descriptionTE</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QTextEdit" name="descriptionTE">
- <property name="acceptRichText">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="prefixLA">
- <property name="text">
- <string>Sort &as:</string>
- </property>
- <property name="buddy">
- <cstring>prefixED</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLineEdit" name="prefixED"/>
- </item>
- <item row="3" column="1">
- <widget class="QCheckBox" name="literalCB">
- <property name="toolTip">
- <string>Pass content of the `Symbol' and `Description' fields literally to LaTeX. Check this if you want to enter LaTeX code.</string>
- </property>
- <property name="text">
- <string>Li&teral</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <tabstops>
- <tabstop>symbolED</tabstop>
- <tabstop>descriptionTE</tabstop>
- <tabstop>prefixED</tabstop>
- </tabstops>
- <includes>
- <include location="local">qt_i18n.h</include>
- </includes>
- <resources/>
- <connections/>
-</ui>
class InsetLayout;
class InsetList;
class InsetMath;
+class InsetNomencl;
class InsetTabular;
class InsetText;
class Language;
virtual InsetArgument const * asInsetArgument() const { return nullptr; }
/// is this inset based on the InsetIndex class?
virtual InsetIndex const * asInsetIndex() const { return nullptr; }
+ /// is this inset based on the InsetNomencl class?
+ virtual InsetNomencl const * asInsetNomencl() const { return nullptr; }
/// is this inset based on the InsetGraphics class?
virtual InsetGraphics * asInsetGraphics() { return nullptr; }
/// is this inset based on the InsetGraphics class?
return InsetLabel::findInfo(cmdName);
case LINE_CODE:
return InsetLine::findInfo(cmdName);
- case NOMENCL_CODE:
- return InsetNomencl::findInfo(cmdName);
case NOMENCL_PRINT_CODE:
return InsetPrintNomencl::findInfo(cmdName);
case REF_CODE:
return InsetLabel::defaultCommand();
case LINE_CODE:
return InsetLine::defaultCommand();
- case NOMENCL_CODE:
- return InsetNomencl::defaultCommand();
case NOMENCL_PRINT_CODE:
return InsetPrintNomencl::defaultCommand();
case REF_CODE:
return InsetLabel::isCompatibleCommand(s);
case LINE_CODE:
return InsetLine::isCompatibleCommand(s);
- case NOMENCL_CODE:
- return InsetNomencl::isCompatibleCommand(s);
case NOMENCL_PRINT_CODE:
return InsetPrintNomencl::isCompatibleCommand(s);
case REF_CODE:
#include <config.h>
#include "InsetNomencl.h"
-#include "InsetNote.h"
+#include "InsetArgument.h"
#include "Buffer.h"
#include "Cursor.h"
//
/////////////////////////////////////////////////////////////////////
-InsetNomencl::InsetNomencl(Buffer * buf, InsetCommandParams const & p)
- : InsetCommand(buf, p)
+InsetNomencl::InsetNomencl(Buffer * buf)
+ : InsetCollapsible(buf)
{}
-ParamInfo const & InsetNomencl::findInfo(string const & /* cmdName */)
+docstring InsetNomencl::toolTip(BufferView const & /*bv*/, int /*x*/, int /*y*/) const
{
- static ParamInfo param_info_;
- if (param_info_.empty()) {
- param_info_.add("prefix", ParamInfo::LATEX_OPTIONAL);
- param_info_.add("symbol", ParamInfo::LATEX_REQUIRED,
- ParamInfo::ParamHandling(ParamInfo::HANDLING_LATEXIFY
- | ParamInfo::HANDLING_INDEX_ESCAPE));
- param_info_.add("description", ParamInfo::LATEX_REQUIRED,
- ParamInfo::ParamHandling(ParamInfo::HANDLING_LATEXIFY
- | ParamInfo::HANDLING_INDEX_ESCAPE));
- param_info_.add("literal", ParamInfo::LYX_INTERNAL);
- }
- return param_info_;
+ docstring tip = _("Nomenclature Symbol: ") + getSymbol();
+ docstring const desc = getDescription();
+ if (!desc.empty())
+ tip += "\n" + _("Description: ") + "\t" + getDescription();
+ docstring const prefix = getPrefix();
+ if (!prefix.empty())
+ tip += "\n" + _("Sorting: ") + prefix;
+ return tip;
}
-docstring InsetNomencl::screenLabel() const
+void InsetNomencl::write(ostream & os) const
{
- size_t const maxLabelChars = 25;
- docstring label = _("Nom: ") + getParam("symbol");
- support::truncateWithEllipsis(label, maxLabelChars);
- return label;
+ os << to_utf8(layoutName()) << endl;
+ InsetCollapsible::write(os);
}
-docstring InsetNomencl::toolTip(BufferView const & /*bv*/, int /*x*/, int /*y*/) const
+docstring InsetNomencl::getSymbol() const
{
- docstring tip = _("Nomenclature Symbol: ") + getParam("symbol") + "\n";
- tip += _("Description: ") + "\t"
- + subst(getParam("description"), from_ascii("\\\\"), from_ascii("\n\t"));
- if (!getParam("prefix").empty())
- tip += "\n" + _("Sorting: ") + getParam("prefix");
- return tip;
+ return text().asString();
+}
+
+
+docstring InsetNomencl::getPrefix() const
+{
+ docstring res;
+ for (auto const & elem : paragraphs()[0].insetList()) {
+ if (InsetArgument const * x = elem.inset->asInsetArgument())
+ if (x->name() == "1")
+ res = x->text().asString(AS_STR_INSETS);
+ }
+ return res;
+}
+
+
+docstring InsetNomencl::getDescription() const
+{
+ docstring res;
+ for (auto const & elem : paragraphs()[0].insetList()) {
+ if (InsetArgument const * x = elem.inset->asInsetArgument())
+ if (x->name() == "post:1")
+ res = x->text().asString(AS_STR_INSETS);
+ }
+ return res;
}
int InsetNomencl::plaintext(odocstringstream & os,
- OutputParams const &, size_t) const
+ OutputParams const & rp, size_t) const
{
- docstring s = "[" + getParam("symbol") + ": " + getParam("description") + "]";
- os << s;
- return s.size();
+ docstring const desc = getDescription();
+ os << "[";
+ InsetText::plaintext(os, rp);
+ if (!desc.empty())
+ os << ": " << desc;
+ os << "]";
+ return os.str().size();
}
void InsetNomencl::docbook(XMLStream & xs, OutputParams const &) const
{
- docstring attr = "linkend=\"" + xml::cleanID(from_ascii("nomen") + getParam("symbol")) + "\"";
+ docstring const symbol = getSymbol();
+ docstring attr = "linkend=\"" + xml::cleanID(from_ascii("nomen") + symbol) + "\"";
xs << xml::StartTag("glossterm", attr);
- xs << xml::escapeString(getParam("symbol"));
+ xs << xml::escapeString(symbol);
xs << xml::EndTag("glossterm");
}
void InsetNomencl::validate(LaTeXFeatures & features) const
{
features.require("nomencl");
- InsetCommand::validate(features);
+ InsetCollapsible::validate(features);
}
void InsetNomencl::addToToc(DocIterator const & cpit, bool output_active,
- UpdateType, TocBackend & backend) const
+ UpdateType, TocBackend & backend) const
{
- docstring const str = getParam("symbol");
TocBuilder & b = backend.builder("nomencl");
- b.pushItem(cpit, str, output_active);
+ b.pushItem(cpit, getSymbol(), output_active);
b.pop();
}
Inset const * inset = par.getInset(dit.top().pos());
if (!inset)
return;
- InsetCommand const * ic = inset->asInsetCommand();
- if (!ic)
+ InsetNomencl const * in = inset->asInsetNomencl();
+ if (!in)
return;
// FIXME We need a link to the paragraph here, so we
// need some kind of struct.
- docstring const symbol = ic->getParam("symbol");
- docstring const desc = ic->getParam("description");
- docstring const prefix = ic->getParam("prefix");
- docstring const sortas = prefix.empty() ? symbol : prefix;
+ docstring const symbol = in->getSymbol();
+ docstring const desc = in->getDescription();
+ docstring const prefix = in->getPrefix();
+ // lowercase sortkey since map is case sensitive
+ docstring sortas = prefix.empty() ? lowercase(symbol) : lowercase(prefix);
+ // assure key uniqueness
+ while (entries.find(sortas) != entries.end())
+ sortas += "a";
entries[sortas] = NomenclEntry(symbol, desc, &par);
}
namespace {
-docstring nomenclWidest(Buffer const & buffer, OutputParams const & runparams)
+docstring nomenclWidest(Buffer const & buffer)
{
// nomenclWidest() determines and returns the widest used
// nomenclature symbol in the document
nomencl = static_cast<InsetNomencl const *>(inset);
// Use proper formatting. We do not escape makeindex chars here
docstring symbol = nomencl ?
- nomencl->params().prepareCommand(runparams, nomencl->getParam("symbol"),
- ParamInfo::HANDLING_LATEXIFY)
- : docstring();
+ nomencl->getSymbol()
+ : docstring();
// strip out % characters which are used as escape in nomencl
// but act as comment in our context here
symbol = subst(symbol, from_ascii("%"), docstring());
OutputParams runparams = runparams_in;
bool const autowidth = getParam("set_width") == "auto";
if (autowidth || getParam("set_width") == "textwidth") {
- docstring widest = autowidth ? nomenclWidest(buffer(), runparams)
+ docstring widest = autowidth ? nomenclWidest(buffer())
: getParam("width");
// Set the label width via nomencl's command \nomlabelwidth.
// This must be output before the command \printnomenclature
#ifndef INSET_NOMENCL_H
#define INSET_NOMENCL_H
-
+#include "InsetCollapsible.h"
#include "InsetCommand.h"
/** Used to insert nomenclature entries
*/
-class InsetNomencl : public InsetCommand {
+class InsetNomencl : public InsetCollapsible {
public:
///
- InsetNomencl(Buffer * buf, InsetCommandParams const &);
+ InsetNomencl(Buffer * buf);
/// \name Public functions inherited from Inset class
//@{
void validate(LaTeXFeatures & features) const override;
///
void addToToc(DocIterator const & di, bool output_active,
- UpdateType utype, TocBackend & backend) const override;
+ UpdateType utype, TocBackend & backend) const override;
///
InsetCode lyxCode() const override { return NOMENCL_CODE; }
///
void docbook(XMLStream &, OutputParams const &) const override;
/// Does nothing at the moment.
docstring xhtml(XMLStream &, OutputParams const &) const override;
+ ///
+ InsetNomencl const * asInsetNomencl() const override { return this; }
//@}
-
- /// \name Static public methods obligated for InsetCommand derived classes
- //@{
///
- static ParamInfo const & findInfo(std::string const &);
+ docstring getSymbol() const;
///
- static std::string defaultCommand() { return "nomenclature"; }
+ docstring getDescription() const;
///
- static bool isCompatibleCommand(std::string const & s)
- { return s == "nomenclature"; }
- //@}
+ docstring getPrefix() const;
private:
/// \name Private functions inherited from Inset class
Inset * clone() const override { return new InsetNomencl(*this); }
//@}
- /// \name Private functions inherited from InsetCommand class
+ /// \name Private functions inherited from InsetCollapsible class
//@{
///
- docstring screenLabel() const override;
+ docstring layoutName() const override { return from_ascii("Nomenclature"); }
+ ///
+ void write(std::ostream & os) const override;
//@}
};
if (t.cs() == "nomenclature") {
context.check_layout(os);
- begin_command_inset(os, "nomenclature", "nomenclature");
- string prefix = convert_literate_command_inset_arg(p.getArg('[', ']'));
- if (!prefix.empty())
- os << "prefix " << '"' << prefix << '"' << "\n";
- // nomencl activates %
- CatCode savecc = p.catcode('%');
- p.setCatcode('%', catActive);
- string symbol = p.verbatim_item();
- p.setCatcode('%', savecc);
- // escape quotation marks
- symbol = subst(symbol, "\"", "\\\"");
- pair<bool, string> sym = convert_latexed_command_inset_arg(symbol);
- bool literal = !sym.first;
- string description = p.verbatim_item();
- // escape quotation marks
- description = subst(description, "\"", "\\\"");
- pair<bool, string> desc = convert_latexed_command_inset_arg(description);
- literal |= !desc.first;
- if (literal) {
- symbol = subst(symbol, "\n", " ");
- description = subst(description, "\n", " ");
- } else {
- symbol = sym.second;
- description = desc.second;
- }
- string lit = literal ? "\"true\"" : "\"false\"";
- os << "symbol " << '"' << symbol;
- os << "\"\ndescription \""
- << description << "\"\n"
- << "literal " << lit << "\n";
+ begin_inset(os, "Nomenclature\n");
+ os << "status open\n";
+ set<string> pass_thru_cmds = context.pass_thru_cmds;
+ // These commands have special meanings in Nomenclature
+ context.pass_thru_cmds.insert("%");
+ parse_text_in_inset(p, os, FLAG_ITEM, outer, context, "Nomenclature");
+ context.pass_thru_cmds = pass_thru_cmds;
end_inset(os);
preamble.registerAutomaticallyLoadedPackage("nomencl");
continue;
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 626 // spitz: printnomencl setwidth
-#define LYX_FORMAT_TEX2LYX 626
+#define LYX_FORMAT_LYX 627 // spitz: nomencl collapsible
+#define LYX_FORMAT_TEX2LYX 627
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER