From e35725d5c0bfef496ebdb18b23539f7f78a336ff Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sat, 4 Nov 2006 17:55:36 +0000 Subject: [PATCH] New nomenclature inset from Ugras * src/LyXAction.C (LyXAction::init): Add LFUN_NOMENCL_INSERT and LFUN_NOMENCL_PRINT * src/insets/insetbase.C (build_translator): ditto * src/LaTeXFeatures.C (LaTeXFeatures::getPackages): Add nomencl * src/insets/insetnomencl.[Ch]: new insets InsetNomencl and InsetPrintNomencl * src/insets/insetbase.h: Add NOMENCL_CODE and NOMENCL_PRINT_CODE * src/insets/insetcommandparams.C (InsetCommandParams::findInfo): Add nomenclature and printnomenclature (InsetCommandParams::getCommand): Extend end of command protection to cover commands with only optional arguments like printnomenclature * src/insets/insetert.C (InsetERT::getStatus): disable LFUN_NOMENCL_INSERT and LFUN_NOMENCL_PRINT * src/insets/Makefile.am: Add new files * src/frontends/qt4/Makefile.dialogs: ditto * src/frontends/qt4/Makefile.am: ditto * src/factory.C (createInset): Handle InsetNomencl and InsetPrintNomencl (readInset): ditto * src/buffer.C (LYX_FORMAT): increase * src/lyxfunc.C (LyXFunc::dispatch): Handle nomenclature * src/LaTeX.C (LaTeX::deleteFilesOnError): Delete .nls file (LaTeX::run): Run makeindex for nomenclature (LaTeX::runMakeIndex): handle nomenclature options (LaTeX::deplog): Recognize nomenclature file * src/frontends/qt4/QNomenclDialog.[Ch]: new * src/frontends/qt4/QNomencl.[Ch]: ditto * src/frontends/qt4/ui/QNomenclUi.ui: ditto * src/frontends/qt4/Dialogs.C (Dialogs::build): handle nomenclature dialog * src/text3.C (LyXText::dispatch): Handle LFUN_NOMENCL_INSERT and LFUN_NOMENCL_PRINT (LyXText::getStatus): Ditto * src/lfuns.h (kb_action): Add LFUN_NOMENCL_INSERT and LFUN_NOMENCL_PRINT * lib/lyx2lyx/LyX.py (format_relation): Update 1.5 format range * lib/lyx2lyx/lyx_1_5.py (revert_nomenclature): New (revert_printnomenclature): ditto * lib/chkconfig.ltx: Test for nomencl package * lib/doc/LaTeXConfig.lyx.in: Add nomencl package * lib/doc/Extended.lyx: Add documentation for nomencl * lib/ui/stdtoolbars.ui (Toolbar "extra" "Extra"): Add nomencl-insert * lib/ui/classic.ui: Add nomencl-insert and nomencl-print * lib/ui/stdmenus.ui: ditto * development/scons/scons_manifest.py: Add new files * development/FORMAT: Describe new format git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15739 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/FORMAT | 8 +- development/scons/scons_manifest.py | 9 + lib/chkconfig.ltx | 1 + lib/doc/Extended.lyx | 295 +++++++++++++++++++++++++++- lib/doc/LaTeXConfig.lyx.in | 22 +++ lib/lyx2lyx/LyX.py | 2 +- lib/lyx2lyx/lyx_1_5.py | 102 +++++++++- lib/ui/classic.ui | 2 + lib/ui/stdmenus.ui | 2 + lib/ui/stdtoolbars.ui | 1 + src/LaTeX.C | 33 +++- src/LaTeX.h | 3 +- src/LaTeXFeatures.C | 5 + src/LyXAction.C | 4 +- src/buffer.C | 2 +- src/factory.C | 22 +++ src/frontends/qt4/Dialogs.C | 9 +- src/frontends/qt4/Makefile.am | 1 + src/frontends/qt4/Makefile.dialogs | 2 + src/frontends/qt4/QNomencl.C | 76 +++++++ src/frontends/qt4/QNomencl.h | 47 +++++ src/frontends/qt4/QNomenclDialog.C | 70 +++++++ src/frontends/qt4/QNomenclDialog.h | 43 ++++ src/frontends/qt4/ui/QNomenclUi.ui | 150 ++++++++++++++ src/insets/Makefile.am | 2 + src/insets/insetbase.C | 2 + src/insets/insetbase.h | 6 +- src/insets/insetcommandparams.C | 28 ++- src/insets/insetert.C | 2 + src/insets/insetnomencl.C | 99 ++++++++++ src/insets/insetnomencl.h | 78 ++++++++ src/lfuns.h | 4 +- src/lyxfunc.C | 1 + src/text3.C | 17 +- 34 files changed, 1130 insertions(+), 20 deletions(-) create mode 100644 src/frontends/qt4/QNomencl.C create mode 100644 src/frontends/qt4/QNomencl.h create mode 100644 src/frontends/qt4/QNomenclDialog.C create mode 100644 src/frontends/qt4/QNomenclDialog.h create mode 100644 src/frontends/qt4/ui/QNomenclUi.ui create mode 100644 src/insets/insetnomencl.C create mode 100644 src/insets/insetnomencl.h diff --git a/development/FORMAT b/development/FORMAT index 724c4ed3e8..b5a7414990 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,6 +1,13 @@ LyX file-format changes -----------------------§ +2006-10-18 Georg Baum + + * format incremented to 253: new nomenclature and printnomenclature + insets. These are standard InsetCommand with the following parameters: + \nomenclature[prefix]{symbol}{description} + \printnomenclature[labelwidth] + 2006-10-15 Georg Baum * format incremented to 252: changed command inset syntax @@ -28,7 +35,6 @@ LyX file-format changes The order of the parameters and for each parameter the name and optional/required bit is now stored in InsetCommandParams. - 2006-10-03 Jürgen Spitzmüller * format incremented to 251: save show_label param for charstyles. diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index 696c519850..5d48281b5b 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -350,6 +350,7 @@ src_insets_header_files = Split(''' insetline.h insetmarginal.h insetnewline.h + insetnomencl.h insetnote.h insetoptarg.h insetpagebreak.h @@ -405,6 +406,7 @@ src_insets_files = Split(''' insetline.C insetmarginal.C insetnewline.C + insetnomencl.C insetnote.C insetoptarg.C insetpagebreak.C @@ -627,6 +629,7 @@ src_frontends_qt4_ui_files = Split(''' QLogUi.ui QMathMatrixUi.ui QMathUi.ui + QNomenclUi.ui QNoteUi.ui QParagraphUi.ui QPrefAsciiUi.ui @@ -706,6 +709,8 @@ src_frontends_qt4_moc_files = Split(''' QLPrintDialog.C QMathDialog.C QMathMatrixDialog.C + QNomencl.C + QNomenclDialog.C QNoteDialog.C QParagraphDialog.C QPrefsDialog.C @@ -798,6 +803,8 @@ src_frontends_qt4_header_files = Split(''' QMath.h QMathDialog.h QMathMatrixDialog.h + QNomencl.h + QNomenclDialog.h QNote.h QNoteDialog.h QParagraph.h @@ -918,6 +925,8 @@ src_frontends_qt4_files = Split(''' QMath.C QMathDialog.C QMathMatrixDialog.C + QNomencl.C + QNomenclDialog.C QNote.C QNoteDialog.C QParagraph.C diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx index 7a59958f70..ac3db36603 100644 --- a/lib/chkconfig.ltx +++ b/lib/chkconfig.ltx @@ -223,6 +223,7 @@ \TestPackage{latex8} \TestPackage{longtable} \TestPackage{natbib} +\TestPackage{nomencl} \TestPackage{prettyref} \TestPackage{preview} \TestPackage{rotating} diff --git a/lib/doc/Extended.lyx b/lib/doc/Extended.lyx index a54ce59d79..d7cb91659a 100644 --- a/lib/doc/Extended.lyx +++ b/lib/doc/Extended.lyx @@ -1,4 +1,4 @@ -#LyX 1.4.2svn created this file. For more info see http://www.lyx.org/ +#LyX 1.4.3 created this file. For more info see http://www.lyx.org/ \lyxformat 245 \begin_document \begin_header @@ -2668,6 +2668,299 @@ Be careful not to put spaces between the word in the text and the index marker; apparently the wrong page number can be produced if this happens. \end_layout +\begin_layout Section +Notation Lists +\end_layout + +\begin_layout Standard +by +\noun on +Özgür U\i \~{g} +ra\i \c{s} + Baram +\end_layout + +\begin_layout Standard +Sometimes you need to compile a list of symbols that are mentioned in your + document with a brief explanation of them. + A LaTeX package named +\family typewriter +nomencl +\family default + provides an easy way of compiling such lists. + +\family typewriter +nomencl +\family default + is included in most standard Linux distributions. + If your distribution doesn't contain it, you should download it from a + CTAN mirror and install the package in order to use this feature of LyX. +\end_layout + +\begin_layout Standard +A notation entry is created if you place the cursor after a symbol entry + and then use the menu +\family sans +Insert\SpecialChar \menuseparator +Notation\InsetSpace ~ +Entry +\family default +. + A gray box labeled +\begin_inset Quotes eld +\end_inset + + +\family sans +Not +\family default + +\begin_inset Quotes erd +\end_inset + + is inserted and a window pops up asking for the notation entry. + A notation entry consists of two main entries. + The first is the symbol that you want to refer to. + You should enter a valid LaTeX code for the corresponding field in the + notation dialog. + The second is the description of the symbol. + You should fill the corresponding field to complete the notation entry. +\end_layout + +\begin_layout Subsection +Sort Order of Notation Entries +\end_layout + +\begin_layout Standard +Suppose you have two notation entries for the symbols +\begin_inset Formula $a$ +\end_inset + + and +\begin_inset Formula $\sigma$ +\end_inset + +. + The +\family typewriter +nomencl +\family default + package automatically sorts these two entries considering the symbol entry, + while printing the Notation List. + However, this can lead to an undesired sort order. + For the example given, the first entry appears as +\family typewriter +$a$ +\family default +, while the second is +\family typewriter +$ +\backslash +sigma$ +\family default +. + Note that, in this case +\begin_inset Formula $\sigma$ +\end_inset + + is located in front of the +\begin_inset Formula $a$ +\end_inset + +, since the character +\begin_inset Quotes eld +\end_inset + + +\backslash + +\begin_inset Quotes erd +\end_inset + + is considered in sorting. + In order to control the sort order, you can edit the +\family sans +Sort\InsetSpace ~ +as +\family default + field of the notation dialog. + For the given example, you can edit this field as +\family typewriter +a +\family default + and +\family typewriter +sigma +\family default +correspondingly. + Then, these entries will be effective in the sort ordering and +\begin_inset Formula $a$ +\end_inset + + will be located before +\begin_inset Formula $\sigma$ +\end_inset + +. +\end_layout + +\begin_layout Standard +This feature provides exciting ways of ordering the entries. + For subgrouping and tips for using sort entries see the official nomencl + documentation. +\end_layout + +\begin_layout Subsection +Referencing +\end_layout + +\begin_layout Standard +You can turn on referencing to the equations and pages in the notation entries. + For this purpose, you should add referencing options commands at the end + of description field. + There are six referencing options in nomencl package: +\end_layout + +\begin_layout Paragraph* + +\backslash +refeq: +\end_layout + +\begin_layout Standard +Adds reference to the equation by adding the phrase +\begin_inset Quotes eld +\end_inset + +, see equation (#) +\begin_inset Quotes erd +\end_inset + + +\end_layout + +\begin_layout Paragraph* + +\backslash +refpage: +\end_layout + +\begin_layout Standard +Adds reference to the page by adding the phrase +\begin_inset Quotes eld +\end_inset + +, page (#) +\begin_inset Quotes erd +\end_inset + + +\end_layout + +\begin_layout Paragraph* + +\backslash +refeqpage: +\end_layout + +\begin_layout Standard +Is the short notation of +\backslash +refeq +\backslash +refpage. +\end_layout + +\begin_layout Paragraph* + +\backslash +norefeq, +\backslash +norefpag, +\backslash +norefeqpage: +\end_layout + +\begin_layout Standard +Turns off corresponding referencing options if they are turned on globally + (see reference documentation of nomencl). +\end_layout + +\begin_layout Subsection +Printing Notation List +\end_layout + +\begin_layout Standard +You can insert the notation list with the menu +\family sans +Insert\SpecialChar \menuseparator +Lists\InsetSpace ~ +&TOC\SpecialChar \menuseparator +Notation\InsetSpace ~ +List +\family default +. + A light blue box labeled +\begin_inset Quotes eld +\end_inset + + +\family sans +Notation +\family default + +\begin_inset Quotes erd +\end_inset + + will show the place where the index is printed in the output. + The index list box is not clickable like other LyX-boxes. + In the printed output the title of the notation list appears as +\series bold +Nomenclature +\series default + +\begin_inset Foot +status collapsed + +\begin_layout Standard +This is translated to the document language for a small number of languages, + amongst others French and German +\end_layout + +\end_inset + +. + If you are not happy with the title, you can change it by re-defining the + command +\family typewriter + +\backslash +nomname +\family default + in the preamble. + For example, in order to change the title +\emph on +List of Symbols +\emph default + for the +\emph on +Notation List +\emph default + add the following line to the preamble. +\end_layout + +\begin_layout LyX-Code + +\backslash +renewcommand{ +\backslash +nomname}{List of Symbols} +\end_layout + +\begin_layout LyX-Code + +\end_layout + \begin_layout Section Multipart Documents \end_layout diff --git a/lib/doc/LaTeXConfig.lyx.in b/lib/doc/LaTeXConfig.lyx.in index e19dc1a3ff..4bea192efd 100644 --- a/lib/doc/LaTeXConfig.lyx.in +++ b/lib/doc/LaTeXConfig.lyx.in @@ -2839,6 +2839,28 @@ jurabib instead). \end_layout +\begin_layout Subsection +nomencl +\end_layout + +\begin_layout Description +Found: @chk_nomencl@ +\end_layout + +\begin_layout Description +CTAN: +\family typewriter +macros/latex/contrib/nomencl/ +\end_layout + +\begin_layout Description +Notes: The package +\family sans +nomencl +\family default + is needed by LyX to produce a notation list. +\end_layout + \begin_layout Subsection prettyref \end_layout diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index fab9b56302..6241fc5ff2 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -73,7 +73,7 @@ format_relation = [("0_06", [200], generate_minor_versions("0.6" , 4)), ("1_2", [220], generate_minor_versions("1.2" , 4)), ("1_3", [221], generate_minor_versions("1.3" , 7)), ("1_4", range(222,246), generate_minor_versions("1.4" , 3)), - ("1_5", range(246,253), generate_minor_versions("1.5" , 0))] + ("1_5", range(246,254), generate_minor_versions("1.5" , 0))] def formats_list(): diff --git a/lib/lyx2lyx/lyx_1_5.py b/lib/lyx2lyx/lyx_1_5.py index 17f9f2d5e3..d7cc7cbef9 100644 --- a/lib/lyx2lyx/lyx_1_5.py +++ b/lib/lyx2lyx/lyx_1_5.py @@ -488,6 +488,102 @@ def revert_commandparams(document): i = j + 1 +def revert_nomenclature(document): + " Convert nomenclature entry to ERT. " + regex = re.compile(r'(\S+)\s+(.+)') + i = 0 + use_nomencl = 0 + while 1: + i = find_token(document.body, "\\begin_inset LatexCommand nomenclature", i) + if i == -1: + break + use_nomencl = 1 + j = find_end_of_inset(document.body, i + 1) + preview_line = "" + symbol = "" + description = "" + prefix = "" + for k in range(i + 1, j): + match = re.match(regex, document.body[k]) + if match: + name = match.group(1) + value = match.group(2) + if name == "preview": + preview_line = document.body[k] + elif name == "symbol": + symbol = value.strip('"').replace('\\"', '"') + elif name == "description": + description = value.strip('"').replace('\\"', '"') + elif name == "prefix": + prefix = value.strip('"').replace('\\"', '"') + elif document.body[k].strip() != "": + document.warning("Ignoring unknown contents `%s' in nomenclature inset." % document.body[k]) + if prefix == "": + command = 'nomenclature{%s}{%s}' % (symbol, description) + else: + command = 'nomenclature[%s]{%s}{%s}' % (prefix, symbol, description) + document.body[i:j+1] = ['\\begin_inset ERT', + 'status collapsed', + '', + '\\begin_layout %s' % document.default_layout, + '', + '', + '\\backslash', + command, + '\\end_layout', + '', + '\\end_inset'] + i = i + 11 + if use_nomencl and find_token(document.preamble, '\\usepackage{nomencl}[2005/09/22]', 0) == -1: + document.preamble.append('\\usepackage{nomencl}[2005/09/22]') + document.preamble.append('\\makenomenclature') + + +def revert_printnomenclature(document): + " Convert printnomenclature to ERT. " + regex = re.compile(r'(\S+)\s+(.+)') + i = 0 + use_nomencl = 0 + while 1: + i = find_token(document.body, "\\begin_inset LatexCommand printnomenclature", i) + if i == -1: + break + use_nomencl = 1 + j = find_end_of_inset(document.body, i + 1) + preview_line = "" + labelwidth = "" + for k in range(i + 1, j): + match = re.match(regex, document.body[k]) + if match: + name = match.group(1) + value = match.group(2) + if name == "preview": + preview_line = document.body[k] + elif name == "labelwidth": + labelwidth = value.strip('"').replace('\\"', '"') + elif document.body[k].strip() != "": + document.warning("Ignoring unknown contents `%s' in printnomenclature inset." % document.body[k]) + if labelwidth == "": + command = 'nomenclature{}' + else: + command = 'nomenclature[%s]' % labelwidth + document.body[i:j+1] = ['\\begin_inset ERT', + 'status collapsed', + '', + '\\begin_layout %s' % document.default_layout, + '', + '', + '\\backslash', + command, + '\\end_layout', + '', + '\\end_inset'] + i = i + 11 + if use_nomencl and find_token(document.preamble, '\\usepackage{nomencl}[2005/09/22]', 0) == -1: + document.preamble.append('\\usepackage{nomencl}[2005/09/22]') + document.preamble.append('\\makenomenclature') + + ## # Conversion hub # @@ -499,9 +595,11 @@ convert = [[246, []], [249, [convert_utf8]], [250, []], [251, []], - [252, [convert_commandparams, convert_bibitem]]] + [252, [convert_commandparams, convert_bibitem]], + [253, []]] -revert = [[251, [revert_commandparams]], +revert = [[252, [revert_nomenclature, revert_printnomenclature]], + [251, [revert_commandparams]], [250, [revert_cs_label]], [249, []], [248, [revert_utf8]], diff --git a/lib/ui/classic.ui b/lib/ui/classic.ui index 7e15d76f79..b9c1e5efe4 100644 --- a/lib/ui/classic.ui +++ b/lib/ui/classic.ui @@ -221,6 +221,7 @@ Menuset Item "Marginal Note|M" "marginalnote-insert" Item "Short Title" "optional-insert" Item "Index Entry|I" "index-insert" + Item "Notation Entry" "nomencl-insert" Item "URL...|U" "url-insert" Item "Note|N" "note-insert" Submenu "Lists & TOC|O" "insert_toc" @@ -310,6 +311,7 @@ Menuset Item "Table of Contents|C" "toc-insert" FloatListInsert Item "Index List|I" "index-print" + Item "Notation List|N" "nomencl-print" Item "BibTeX Bibliography...|B" "dialog-show-new-inset bibtex" End diff --git a/lib/ui/stdmenus.ui b/lib/ui/stdmenus.ui index 3e39c970f2..30d36b952d 100644 --- a/lib/ui/stdmenus.ui +++ b/lib/ui/stdmenus.ui @@ -299,6 +299,7 @@ Menuset Item "Cross-reference...|r" "dialog-show-new-inset ref" Item "Label...|L" "label-insert" Item "Index Entry|d" "index-insert" + Item "Notation Entry" "nomencl-insert" Item "Date" "date-insert" # I'm going to kill this dumb dialog, but for now ... Separator @@ -368,6 +369,7 @@ Menuset Item "Table of Contents|C" "toc-insert" FloatListInsert Item "Index List|I" "index-print" + Item "Notation List" "nomencl-print" Item "BibTeX Bibliography...|B" "dialog-show-new-inset bibtex" End diff --git a/lib/ui/stdtoolbars.ui b/lib/ui/stdtoolbars.ui index 243abf6203..e6aafcb339 100644 --- a/lib/ui/stdtoolbars.ui +++ b/lib/ui/stdtoolbars.ui @@ -76,6 +76,7 @@ Toolbar "extra" "Extra" Item "Insert cross-reference" "dialog-show-new-inset ref" Item "Insert citation" "dialog-show-new-inset citation" Item "Insert index entry" "index-insert" + Item "Insert notation entry" "nomencl-insert" Separator Item "Insert footnote" "footnote-insert" Item "Insert margin note" "marginalnote-insert" diff --git a/src/LaTeX.C b/src/LaTeX.C index 934b233ffb..8cbb27f2fe 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -158,6 +158,10 @@ void LaTeX::deleteFilesOnError() const string const ind = changeExtension(ofname, ".ind"); unlink(ind); + // nomencl file + string const nls = changeExtension(ofname, ".nls"); + unlink(nls); + // Also remove the aux file string const aux = changeExtension(ofname, ".aux"); unlink(aux); @@ -283,6 +287,12 @@ int LaTeX::run(TeXErrors & terr) message(_("Running MakeIndex.")); rerun |= runMakeIndex(onlyFilename(changeExtension(file, ".idx")), runparams); } + if (head.haschanged(onlyFilename(changeExtension(file, ".nlo")))) { + lyxerr[Debug::LATEX] << "Running MakeIndex for nomencl." << endl; + message(_("Running Makeindex for nomencl.")); + string const nomenclstr = " -s nomencl.ist -o " + changeExtension(file, ".nls"); + rerun |= runMakeIndex(onlyFilename(changeExtension(file, ".nlo")), runparams, nomenclstr); + } // run bibtex // if (scanres & UNDEF_CIT || scanres & RERUN || run_bibtex) @@ -352,6 +362,14 @@ int LaTeX::run(TeXErrors & terr) rerun = runMakeIndex(onlyFilename(changeExtension(file, ".idx")), runparams); } + // I am not pretty sure if need this twice. + if (head.haschanged(onlyFilename(changeExtension(file, ".nlo")))) { + lyxerr[Debug::LATEX] << "Running MakeIndex for nomencl." << endl; + message(_("Running Makeindex for nomencl. ")); + string nomenclstr = " -s nomencl.ist -o " + changeExtension(file, ".nls"); + rerun |= runMakeIndex(onlyFilename(changeExtension(file, ".nlo")), runparams, nomenclstr); + } + // 2 // we will only run latex more if the log file asks for it. // or if the sumchange() is true. @@ -396,13 +414,17 @@ int LaTeX::startscript() } -bool LaTeX::runMakeIndex(string const & f, OutputParams const & runparams) +bool LaTeX::runMakeIndex(string const & f, OutputParams const & runparams, + string const & params) { - lyxerr[Debug::LATEX] << "idx file has been made," - " running makeindex on file " << f << endl; - string tmp = lyxrc.index_command + " "; + lyxerr[Debug::LATEX] + << "idx file has been made, running makeindex on file " + << f << endl; + string tmp = lyxrc.index_command + ' '; + tmp = subst(tmp, "$$lang", runparams.document_language); tmp += quoteName(f); + tmp += params; Systemcall one; one.startscript(Systemcall::Wait, tmp); return true; @@ -761,6 +783,7 @@ void LaTeX::deplog(DepTable & head) // but instead only a line like this into the log: // Writing index file sample.idx static regex reg5("Writing index file ([^ ]+).*"); + static regex regnomencl("Writing nomenclature file ([^ ]+).*"); // If a toc should be created, MikTex does not write a line like // \openout# = `sample.toc'. // but only a line like this into the log: @@ -809,6 +832,8 @@ void LaTeX::deplog(DepTable & head) handleFoundFile(sub.str(1), head); else if (regex_match(token, sub, reg5)) handleFoundFile(sub.str(1), head); + else if (regex_match(token, sub, regnomencl)) + handleFoundFile(sub.str(1), head); else if (regex_match(token, sub, miktexTocReg)) handleFoundFile(changeExtension(file, ".toc"), head); } diff --git a/src/LaTeX.h b/src/LaTeX.h index eae822d8e6..1f52dab188 100644 --- a/src/LaTeX.h +++ b/src/LaTeX.h @@ -161,7 +161,8 @@ private: void deplog(DepTable & head); /// - bool runMakeIndex(std::string const &, OutputParams const &); + bool runMakeIndex(std::string const &, OutputParams const &, + std::string const & = std::string()); /// std::vector const scanAuxFiles(std::string const &); diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index 09806e090b..81309285f5 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -386,6 +386,11 @@ string const LaTeXFeatures::getPackages() const if (isRequired("xy")) packages << "\\usepackage[all]{xy}\n"; + if (isRequired("nomencl")) { + packages << "\\usepackage{nomencl}[2005/09/22]\n" + << "\\makenomenclature\n"; + } + return packages.str(); } diff --git a/src/LyXAction.C b/src/LyXAction.C index 6f503f3818..b3b12158f9 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -367,7 +367,9 @@ void LyXAction::init() { LFUN_WINDOW_CLOSE, "window-close", NoBuffer }, { LFUN_UNICODE_INSERT, "unicode-insert", Noop }, { LFUN_TOOLBAR_TOGGLE_STATE, "", NoBuffer }, - + { LFUN_NOMENCL_INSERT, "nomencl-insert", Noop }, + { LFUN_NOMENCL_PRINT, "nomencl-print", Noop }, + { LFUN_NOACTION, "", Noop } }; diff --git a/src/buffer.C b/src/buffer.C index 3702aa5eeb..261bc0b144 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -142,7 +142,7 @@ using std::string; namespace { -int const LYX_FORMAT = 252; +int const LYX_FORMAT = 253; } // namespace anon diff --git a/src/factory.C b/src/factory.C index e0211221e1..05576e3302 100644 --- a/src/factory.C +++ b/src/factory.C @@ -37,6 +37,7 @@ #include "insets/insethfill.h" #include "insets/insetinclude.h" #include "insets/insetindex.h" +#include "insets/insetnomencl.h" #include "insets/insetlabel.h" #include "insets/insetline.h" #include "insets/insetmarginal.h" @@ -171,6 +172,14 @@ InsetBase * createInset(BufferView * bv, FuncRequest const & cmd) return new InsetIndex(icp); } + case LFUN_NOMENCL_INSERT: { + InsetCommandParams icp("nomenclature"); + icp["symbol"] = cmd.argument().empty() ? + bv->getLyXText()->getStringToIndex(bv->cursor()) : + cmd.argument(); + return new InsetNomencl(icp); + } + case LFUN_TABULAR_INSERT: { if (cmd.argument().empty()) return 0; @@ -195,6 +204,9 @@ InsetBase * createInset(BufferView * bv, FuncRequest const & cmd) case LFUN_INDEX_PRINT: return new InsetPrintIndex(InsetCommandParams("printindex")); + case LFUN_NOMENCL_PRINT: + return new InsetPrintNomencl(InsetCommandParams("printnomenclature")); + case LFUN_TOC_INSERT: return new InsetTOC(InsetCommandParams("tableofcontents")); @@ -264,6 +276,12 @@ InsetBase * createInset(BufferView * bv, FuncRequest const & cmd) icp); return new InsetIndex(icp); + } else if (name == "nomenclature") { + InsetCommandParams icp(name); + InsetCommandMailer::string2params(name, lyx::to_utf8(cmd.argument()), + icp); + return new InsetNomencl(icp); + } else if (name == "label") { InsetCommandParams icp(name); InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), @@ -369,6 +387,8 @@ InsetBase * readInset(LyXLex & lex, Buffer const & buf) inset.reset(new InsetBibtex(inscmd)); } else if (cmdName == "index") { inset.reset(new InsetIndex(inscmd)); + } else if (cmdName == "nomenclature") { + inset.reset(new InsetNomencl(inscmd)); } else if (cmdName == "include") { inset.reset(new InsetInclude(inscmd)); } else if (cmdName == "label") { @@ -396,6 +416,8 @@ InsetBase * readInset(LyXLex & lex, Buffer const & buf) inset.reset(new InsetFloatList("table")); } else if (cmdName == "printindex") { inset.reset(new InsetPrintIndex(inscmd)); + } else if (cmdName == "printnomenclature") { + inset.reset(new InsetPrintNomencl(inscmd)); } else { lyxerr << "unknown CommandInset '" << cmdName << "'" << std::endl; diff --git a/src/frontends/qt4/Dialogs.C b/src/frontends/qt4/Dialogs.C index 388578ed49..9dc0d5b283 100644 --- a/src/frontends/qt4/Dialogs.C +++ b/src/frontends/qt4/Dialogs.C @@ -61,6 +61,7 @@ #include "QGraphics.h" #include "QInclude.h" #include "QIndex.h" +#include "QNomencl.h" #include "QLog.h" #include "QViewSource.h" #include "QMath.h" @@ -101,7 +102,7 @@ namespace { char const * const dialognames[] = { "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character", "citation", "document", "errorlist", "ert", "external", "file", -"findreplace", "float", "graphics", "include", "index", "label", "log", "view-source", +"findreplace", "float", "graphics", "include", "index", "nomenclature", "label", "log", "mathpanel", "mathdelimiter", "mathmatrix", "note", "paragraph", "prefs", "print", "ref", "sendto", "spellchecker","tabular", "tabularcreate", @@ -109,7 +110,7 @@ char const * const dialognames[] = { "thesaurus", #endif -"texinfo", "toc", "url", "vspace", "wrap" }; +"texinfo", "toc", "url", "view-source", "vspace", "wrap" }; char const * const * const end_dialognames = dialognames + (sizeof(dialognames) / sizeof(char *)); @@ -219,6 +220,10 @@ Dialogs::DialogPtr Dialogs::build(string const & name) _("Index Entry"), qt_("&Keyword:"))); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); + } else if (name == "nomenclature") { + dialog->setController(new ControlCommand(*dialog, name, name)); + dialog->setView(new QNomencl(*dialog, _("Notation Entry"))); + dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "label") { dialog->setController(new ControlCommand(*dialog, name, name)); dialog->setView(new QIndex(*dialog, diff --git a/src/frontends/qt4/Makefile.am b/src/frontends/qt4/Makefile.am index 150c7cc914..4d5b35e0dc 100644 --- a/src/frontends/qt4/Makefile.am +++ b/src/frontends/qt4/Makefile.am @@ -64,6 +64,7 @@ libqt4_la_SOURCES = \ QLPainter.C QLPainter.h \ QLyXKeySym.C QLyXKeySym.h \ QMath.C QMath.h \ + QNomencl.C QNomencl.h \ QNote.C QNote.h \ QParagraph.C QParagraph.h \ QPrefs.C QPrefs.h \ diff --git a/src/frontends/qt4/Makefile.dialogs b/src/frontends/qt4/Makefile.dialogs index 831d112c15..0518515fdf 100644 --- a/src/frontends/qt4/Makefile.dialogs +++ b/src/frontends/qt4/Makefile.dialogs @@ -37,6 +37,7 @@ UIFILES = \ QViewSourceUi.ui \ QMathUi.ui \ QMathMatrixUi.ui \ + QNomenclUi.ui \ QNoteUi.ui \ QParagraphUi.ui \ QPrefAsciiUi.ui \ @@ -114,6 +115,7 @@ MOCFILES = \ QLPrintDialog.C QLPrintDialog.h \ QMathDialog.C QMathDialog.h \ QMathMatrixDialog.C QMathMatrixDialog.h \ + QNomenclDialog.C QNomenclDialog.h \ QNoteDialog.C QNoteDialog.h \ QParagraphDialog.C QParagraphDialog.h \ QPrefsDialog.C QPrefsDialog.h \ diff --git a/src/frontends/qt4/QNomencl.C b/src/frontends/qt4/QNomencl.C new file mode 100644 index 0000000000..1ece965b41 --- /dev/null +++ b/src/frontends/qt4/QNomencl.C @@ -0,0 +1,76 @@ +/** + * \file QNomencl.C + * 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 + +#include "debug.h" +#include "ControlCommand.h" +#include "qt_helpers.h" + +#include "QNomenclDialog.h" +#include "QNomencl.h" +#include "Qt2BC.h" +#include "ButtonController.h" +#include +#include +#include + +using std::string; + +namespace lyx { +namespace frontend { + +typedef QController > base_class; + + +QNomencl::QNomencl(Dialog & parent, docstring const & title) + : base_class(parent, title) +{ +} + + +void QNomencl::build_dialog() +{ + dialog_.reset(new QNomenclDialog(this)); + + bcview().setOK(dialog_->okPB); + bcview().setCancel(dialog_->closePB); + bcview().addReadOnly(dialog_->symbolED); + bcview().addReadOnly(dialog_->descrED); + bcview().addReadOnly(dialog_->prefixED); +} + + +void QNomencl::update_contents() +{ + dialog_->prefixED->setText(toqstr(controller().params()["prefix"])); + dialog_->symbolED->setText(toqstr(controller().params()["symbol"])); + dialog_->descrED->setText(toqstr(controller().params()["description"])); + + bc().valid(isValid()); +} + + +void QNomencl::apply() +{ + controller().params()["prefix"] = qstring_to_ucs4(dialog_->prefixED->text()); + controller().params()["symbol"] = qstring_to_ucs4(dialog_->symbolED->text()); + controller().params()["description"] = qstring_to_ucs4(dialog_->descrED->text()); +} + + +bool QNomencl::isValid() +{ + return (!dialog_->symbolED->text().isEmpty() && !dialog_->descrED->text().isEmpty()); +} + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/qt4/QNomencl.h b/src/frontends/qt4/QNomencl.h new file mode 100644 index 0000000000..408bd1f5a5 --- /dev/null +++ b/src/frontends/qt4/QNomencl.h @@ -0,0 +1,47 @@ +// -*- C++ -*- +/** + * \file QNomencl.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 QNOMENCL_H +#define QNOMENCL_H + +#include "QDialogView.h" + +namespace lyx { +namespace frontend { + +class ControlCommand; +class QNomenclDialog; + + +class QNomencl : + public QController > +{ +public: + friend class QNomenclDialog; + + QNomencl(Dialog &, docstring const & title); +protected: + virtual bool isValid(); +private: + /// Apply changes + virtual void apply(); + /// update + virtual void update_contents(); + /// build the dialog + virtual void build_dialog(); +}; + +} // namespace frontend +} // namespace lyx + +#endif // QNOMENCL_H diff --git a/src/frontends/qt4/QNomenclDialog.C b/src/frontends/qt4/QNomenclDialog.C new file mode 100644 index 0000000000..664d124452 --- /dev/null +++ b/src/frontends/qt4/QNomenclDialog.C @@ -0,0 +1,70 @@ +/** + * \file QNomenclDialog.C + * 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 + +#include "qt_helpers.h" + +#include "QNomencl.h" +#include "QNomenclDialog.h" + +#include +#include +#include +#include + +namespace lyx { +namespace frontend { + +QNomenclDialog::QNomenclDialog(QNomencl * form) + : form_(form) +{ + setupUi(this); + + connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK())); + connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose())); + connect(symbolED, SIGNAL(textChanged(const QString&)), + this, SLOT(change_adaptor())); + connect(descrED, SIGNAL(textChanged(const QString&)), + this, SLOT(change_adaptor())); + +} + + +void QNomenclDialog::show() +{ + QDialog::show(); + symbolED->setFocus(); +} + + +void QNomenclDialog::change_adaptor() +{ + form_->changed(); +} + + +void QNomenclDialog::reject() +{ + form_->slotClose(); +} + + +void QNomenclDialog::closeEvent(QCloseEvent * e) +{ + form_->slotWMHide(); + e->accept(); +} + +} // namespace frontend +} // namespace lyx + +#include "QNomenclDialog_moc.cpp" diff --git a/src/frontends/qt4/QNomenclDialog.h b/src/frontends/qt4/QNomenclDialog.h new file mode 100644 index 0000000000..62acdb7ab5 --- /dev/null +++ b/src/frontends/qt4/QNomenclDialog.h @@ -0,0 +1,43 @@ +// -*- C++ -*- +/** + * \file QNomenclDialog.h + * 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. + */ + +#ifndef QNOMENCLDIALOG_H +#define QNOMENCLDIALOG_H + +#include "ui/QNomenclUi.h" + +#include +#include + +namespace lyx { +namespace frontend { + +class QNomencl; + +class QNomenclDialog : public QDialog, public Ui::QNomenclUi { + Q_OBJECT +public: + QNomenclDialog(QNomencl * form); + virtual void show(); +protected Q_SLOTS: + virtual void change_adaptor(); + virtual void reject(); +protected: + virtual void closeEvent(QCloseEvent * e); +private: + QNomencl * form_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // QNOMENCLDIALOG_H diff --git a/src/frontends/qt4/ui/QNomenclUi.ui b/src/frontends/qt4/ui/QNomenclUi.ui new file mode 100644 index 0000000000..72cae117c2 --- /dev/null +++ b/src/frontends/qt4/ui/QNomenclUi.ui @@ -0,0 +1,150 @@ + + + + + QNomenclUi + + + + 0 + 0 + 260 + 170 + + + + + + + true + + + + + 10 + 11 + 240 + 149 + + + + + 0 + + + 6 + + + + + 0 + + + 6 + + + + + Symbol: + + + + + + + Description: + + + + + + + Sort as: + + + + + + + + + + + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 16 + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + + + &OK + + + Alt+O + + + true + + + + + + + Cancel + + + + + + + + + + + + + diff --git a/src/insets/Makefile.am b/src/insets/Makefile.am index 2a19b87f60..f5030b4dc9 100644 --- a/src/insets/Makefile.am +++ b/src/insets/Makefile.am @@ -85,6 +85,8 @@ libinsets_la_SOURCES = \ insetmarginal.C \ insetnewline.C \ insetnewline.h \ + insetnomencl.C \ + insetnomencl.h \ insetnote.C \ insetnote.h \ insetoptarg.C \ diff --git a/src/insets/insetbase.C b/src/insets/insetbase.C index c7c53d090c..41d7de106f 100644 --- a/src/insets/insetbase.C +++ b/src/insets/insetbase.C @@ -63,6 +63,7 @@ static TranslatorMap const build_translator() InsetName("accent", InsetBase::ACCENT_CODE), InsetName("math", InsetBase::MATH_CODE), InsetName("index", InsetBase::INDEX_CODE), + InsetName("nomenclature", InsetBase::NOMENCL_CODE), InsetName("include", InsetBase::INCLUDE_CODE), InsetName("graphics", InsetBase::GRAPHICS_CODE), InsetName("bibitem", InsetBase::BIBITEM_CODE), @@ -81,6 +82,7 @@ static TranslatorMap const build_translator() InsetName("cite", InsetBase::CITE_CODE), InsetName("float_list", InsetBase::FLOAT_LIST_CODE), InsetName("index_print", InsetBase::INDEX_PRINT_CODE), + InsetName("nomencl_print", InsetBase::NOMENCL_PRINT_CODE), InsetName("optarg", InsetBase::OPTARG_CODE), InsetName("environment", InsetBase::ENVIRONMENT_CODE), InsetName("hfill", InsetBase::HFILL_CODE), diff --git a/src/insets/insetbase.h b/src/insets/insetbase.h index 7ee3d24f17..6839547064 100644 --- a/src/insets/insetbase.h +++ b/src/insets/insetbase.h @@ -322,7 +322,11 @@ public: /// VSPACE_CODE, /// - MATHMACROARG_CODE + MATHMACROARG_CODE, + /// + NOMENCL_CODE, // 45 + /// + NOMENCL_PRINT_CODE }; /** returns the Code corresponding to the \c name. diff --git a/src/insets/insetcommandparams.C b/src/insets/insetcommandparams.C index 8c7805db85..bd0c208ef2 100644 --- a/src/insets/insetcommandparams.C +++ b/src/insets/insetcommandparams.C @@ -117,6 +117,22 @@ InsetCommandParams::findInfo(std::string const & name) return &info; } + // InsetNomencl + if (name == "nomenclature") { + static const char * const paramnames[] = {"prefix", "symbol", "description", ""}; + static const bool isoptional[] = {true, false, false}; + static const CommandInfo info = {3, paramnames, isoptional}; + return &info; + } + + // InsetPrintNomencl + if (name == "printnomenclature") { + static const char * const paramnames[] = {"labelwidth", ""}; + static const bool isoptional[] = {true}; + static const CommandInfo info = {1, paramnames, isoptional}; + return &info; + } + // InsetRef if (name == "eqref" || name == "pageref" || name == "vpageref" || name == "vref" || name == "prettyref" || name == "ref") { @@ -288,6 +304,7 @@ void InsetCommandParams::write(ostream & os) const docstring const InsetCommandParams::getCommand() const { docstring s = '\\' + from_ascii(name_); + bool noparam = true; for (size_t i = 0; i < info_->n; ++i) { if (info_->optional[i]) { if (params_[i].empty()) { @@ -299,15 +316,20 @@ docstring const InsetCommandParams::getCommand() const break; if (!params_[j].empty()) { s += "[]"; + noparam = false; break; } } - } else + } else { s += '[' + params_[i] + ']'; - } else + noparam = false; + } + } else { s += '{' + params_[i] + '}'; + noparam = false; + } } - if (info_->n == 0) + if (noparam) // Make sure that following stuff does not change the // command name. s += "{}"; diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 26d82f1168..b10d3d5c63 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -352,6 +352,8 @@ bool InsetERT::getStatus(LCursor & cur, FuncRequest const & cmd, case LFUN_INSET_INSERT: case LFUN_PARAGRAPH_PARAMS_APPLY: case LFUN_PARAGRAPH_UPDATE: + case LFUN_NOMENCL_INSERT: + case LFUN_NOMENCL_PRINT: case LFUN_NOACTION: status.enabled(false); return true; diff --git a/src/insets/insetnomencl.C b/src/insets/insetnomencl.C new file mode 100644 index 0000000000..b694e12f4c --- /dev/null +++ b/src/insets/insetnomencl.C @@ -0,0 +1,99 @@ +/** + * \file insetnomencl.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Lars Gullik Bjønnes + * \author O. U. Baran + * + * Full author contact details are available in file CREDITS. + */ +#include + +#include "insetnomencl.h" + +#include "dispatchresult.h" +#include "funcrequest.h" +#include "gettext.h" +#include "LaTeXFeatures.h" +#include "metricsinfo.h" +#include "sgml.h" + + +namespace lyx { + +using std::string; + + +InsetNomencl::InsetNomencl(InsetCommandParams const & p) + : InsetCommand(p, "nomenclature") +{} + + +docstring const InsetNomencl::getScreenLabel(Buffer const &) const +{ + return _("Not"); +} + + +int InsetNomencl::docbook(Buffer const &, odocstream & os, + OutputParams const &) const +{ + // FIXME: This does not work, because the entry needs to be put + // in the glossary. +#if 0 + os << "" + << sgml::escapeString(getParam("symbol")) + << "" + << sgml::escapeString(getParam("description")) + << ""; +#endif + return 0; +} + + +void InsetNomencl::validate(LaTeXFeatures & features) const +{ + features.require("nomencl"); +} + + +InsetBase::Code InsetNomencl::lyxCode() const +{ + return InsetBase::NOMENCL_CODE; +} + + +InsetPrintNomencl::InsetPrintNomencl(InsetCommandParams const & p) + : InsetCommand(p, string()) +{} + + +docstring const InsetPrintNomencl::getScreenLabel(Buffer const &) const +{ + return _("Notation"); +} + + +int InsetPrintNomencl::docbook(Buffer const &, odocstream & os, + OutputParams const &) const +{ + // FIXME This does not work, we need to define the entries here. + //os << ""; + return 0; +} + + +void InsetPrintNomencl::validate(LaTeXFeatures & features) const +{ + features.require("nomencl"); +} + + +InsetBase::Code InsetPrintNomencl::lyxCode() const +{ + return InsetBase::NOMENCL_PRINT_CODE; +} + + +} // namespace lyx diff --git a/src/insets/insetnomencl.h b/src/insets/insetnomencl.h new file mode 100644 index 0000000000..f706a116a3 --- /dev/null +++ b/src/insets/insetnomencl.h @@ -0,0 +1,78 @@ +// -*- C++ -*- +/** + * \file insetnomencl.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Lars Gullik Bjønnes + * \author O. U. Baran + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef INSET_NOMENCL_H +#define INSET_NOMENCL_H + + +#include "insetcommand.h" + + +namespace lyx { + +class LaTeXFeatures; + +/** Used to insert notation labels + */ +class InsetNomencl : public InsetCommand { +public: + /// + InsetNomencl(InsetCommandParams const &); + /// + docstring const getScreenLabel(Buffer const &) const; + /// + EDITABLE editable() const { return IS_EDITABLE; } + /// Updates needed features for this inset. + void validate(LaTeXFeatures & features) const; + /// + InsetBase::Code lyxCode() const; + /// + int docbook(Buffer const &, odocstream &, + OutputParams const &) const; +private: + virtual std::auto_ptr doClone() const { + return std::auto_ptr(new InsetNomencl(params())); + } +}; + + +class InsetPrintNomencl : public InsetCommand { +public: + /// + InsetPrintNomencl(InsetCommandParams const &); + /// Updates needed features for this inset. + void validate(LaTeXFeatures & features) const; + // FIXME: This should be editable to set the label width (stored + // in params_["labelwidth"]). + // Currently the width can be read from file and written, but not + // changed. + /// + EDITABLE editable() const { return NOT_EDITABLE; } + /// + int docbook(Buffer const &, odocstream &, + OutputParams const &) const; + /// + InsetBase::Code lyxCode() const; + /// + bool display() const { return true; } + /// + docstring const getScreenLabel(Buffer const &) const; +private: + virtual std::auto_ptr doClone() const { + return std::auto_ptr(new InsetPrintNomencl(params())); + } +}; + + +} // namespace lyx + +#endif diff --git a/src/lfuns.h b/src/lfuns.h index f2baf18079..486c51b879 100644 --- a/src/lfuns.h +++ b/src/lfuns.h @@ -375,7 +375,9 @@ enum kb_action { // 285 LFUN_BOOKMARK_CLEAR, // bpeng 20061031 LFUN_TOOLBAR_TOGGLE_STATE, // bpeng 20061101 - + LFUN_NOMENCL_INSERT, // Ugras + LFUN_NOMENCL_PRINT, // Ugras + LFUN_LASTACTION // end of the table }; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index ed16fc23ec..2804687157 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1252,6 +1252,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) name == "bibtex" || name == "index" || name == "label" || + name == "nomenclature" || name == "ref" || name == "toc" || name == "url") { diff --git a/src/text3.C b/src/text3.C index 6210304ad6..2ebf885a66 100644 --- a/src/text3.C +++ b/src/text3.C @@ -1160,7 +1160,8 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption")); break; - case LFUN_INDEX_INSERT: { + case LFUN_INDEX_INSERT: + case LFUN_NOMENCL_INSERT: { InsetBase * inset = createInset(&cur.bv(), cmd); if (!inset) break; @@ -1169,11 +1170,17 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) cur.clearSelection(); insertInset(cur, inset); inset->edit(cur, true); + // Show the dialog for the nomenclature entry, since the + // description entry still needs to be filled in. + if (cmd.action == LFUN_NOMENCL_INSERT) + InsetCommandMailer("nomenclature", + *reinterpret_cast(inset)).showDialog(&cur.bv()); cur.posRight(); break; } case LFUN_INDEX_PRINT: + case LFUN_NOMENCL_PRINT: case LFUN_TOC_INSERT: case LFUN_HFILL_INSERT: case LFUN_LINE_INSERT: @@ -1550,6 +1557,8 @@ bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd, code = InsetBase::INCLUDE_CODE; else if (cmd.argument() == "index") code = InsetBase::INDEX_CODE; + else if (cmd.argument() == "nomenclature") + code = InsetBase::NOMENCL_CODE; else if (cmd.argument() == "label") code = InsetBase::LABEL_CODE; else if (cmd.argument() == "note") @@ -1632,6 +1641,12 @@ bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd, case LFUN_INDEX_PRINT: code = InsetBase::INDEX_PRINT_CODE; break; + case LFUN_NOMENCL_INSERT: + code = InsetBase::NOMENCL_CODE; + break; + case LFUN_NOMENCL_PRINT: + code = InsetBase::NOMENCL_PRINT_CODE; + break; case LFUN_TOC_INSERT: code = InsetBase::TOC_CODE; break;