I don't love this patch.
Other things that need escaping can be added later ... thanks john -- "...life's not a paragraph and death i think is no parenthesis" - e. e. cummings
@@ -3007,6 +3023,7 @@ + idxstring + _(("' indexed."))); InsetCommandParams p("index", idxstring); InsetIndex * inset = new InsetIndex(p); + inset->escapeContents(); if (!insertInset(inset)) delete inset; Index: src/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.425 diff -u -r1.425 ChangeLog --- src/ChangeLog 2001/11/30 16:10:24 1.425 +++ src/ChangeLog 2001/11/30 21:13:40 @@ -1,3 +1,7 @@ +2001-11-30 John Levon <[EMAIL PROTECTED]> + + * BufferView_pimpl.C: escape index entries correctly + 2001-11-30 Juergen Vigna <[EMAIL PROTECTED]> * tabular.C (LyXTabular): add a same_id to set the same id's in the Index: src/frontends/controllers/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ChangeLog,v retrieving revision 1.104 diff -u -r1.104 ChangeLog --- src/frontends/controllers/ChangeLog 2001/11/27 10:56:13 1.104 +++ src/frontends/controllers/ChangeLog 2001/11/30 21:14:42 @@ -1,3 +1,8 @@ +2001-11-30 John Levon <[EMAIL PROTECTED]> + + * ControlIndex.h: + * ControlIndex.C: escape/unescape index as needed + 2001-11-04 John Levon <[EMAIL PROTECTED]> * ControlToc.C: changes for floatlist Index: src/frontends/controllers/ControlIndex.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlIndex.C,v retrieving revision 1.4 diff -u -r1.4 ControlIndex.C --- src/frontends/controllers/ControlIndex.C 2001/06/13 15:11:16 1.4 +++ src/frontends/controllers/ControlIndex.C 2001/11/30 21:14:42 @@ -19,10 +19,13 @@ #include "ViewBase.h" #include "ButtonControllerBase.h" +#include "insets/insetindex.h" #include "ControlIndex.h" #include "buffer.h" #include "Dialogs.h" #include "LyXView.h" +#include "support/lstrings.h" +#include "support/LAssert.h" using SigC::slot; @@ -31,4 +34,25 @@ { d_.showIndex.connect(slot(this, &ControlIndex::showInset)); d_.createIndex.connect(slot(this, &ControlIndex::createInset)); +} + + +string const ControlIndex::getContents() const +{ + string str(params().getContents()); + + str = subst(str, "\\_", "_"); + + return str; +} + + +void ControlIndex::setContents(string const & contents) +{ + params().setContents(contents); + + // escape - ugly + InsetIndex in(params()); + in.escapeContents(); + params().setContents(in.getContents()); } Index: src/frontends/controllers/ControlIndex.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlIndex.h,v retrieving revision 1.2 diff -u -r1.2 ControlIndex.h --- src/frontends/controllers/ControlIndex.h 2001/06/13 14:33:30 1.2 +++ src/frontends/controllers/ControlIndex.h 2001/11/30 21:14:42 @@ -27,6 +27,12 @@ public: /// ControlIndex(LyXView &, Dialogs &); + + /// get unquoted contents + string const getContents() const; + + /// set contents, escaped + void setContents(string const & contents); }; #endif // CONTROLINDEX_H Index: src/frontends/qt2/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/ChangeLog,v retrieving revision 1.68 diff -u -r1.68 ChangeLog --- src/frontends/qt2/ChangeLog 2001/11/06 18:10:55 1.68 +++ src/frontends/qt2/ChangeLog 2001/11/30 21:14:44 @@ -1,3 +1,7 @@ +2001-11-30 John Levon <[EMAIL PROTECTED]> + + * QIndex.C: use escaping code + 2001-11-06 John Levon <[EMAIL PROTECTED]> * Makefile.am: link in new DropDown.lo Index: src/frontends/qt2/QIndex.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QIndex.C,v retrieving revision 1.6 diff -u -r1.6 QIndex.C --- src/frontends/qt2/QIndex.C 2001/08/26 00:29:39 1.6 +++ src/frontends/qt2/QIndex.C 2001/11/30 21:14:44 @@ -37,13 +37,13 @@ void QIndex::update_contents() { - dialog_->keywordED->setText(controller().params().getContents().c_str()); + dialog_->keywordED->setText(controller().getContents().c_str()); } void QIndex::apply() { - controller().params().setContents(dialog_->keywordED->text().latin1()); + controller().setContents(dialog_->keywordED->text().latin1()); } Index: src/frontends/qt2/QParagraphDialog.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QParagraphDialog.h,v retrieving revision 1.1 diff -u -r1.1 QParagraphDialog.h --- src/frontends/qt2/QParagraphDialog.h 2001/08/19 13:25:14 1.1 +++ src/frontends/qt2/QParagraphDialog.h 2001/11/30 21:14:44 @@ -15,6 +15,7 @@ #include "ui/QParagraphDialogBase.h" #include "vspace.h" #include "paragraph.h" +#include "layout.h" class QParagraph; Index: src/frontends/xforms/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/ChangeLog,v retrieving revision 1.203 diff -u -r1.203 ChangeLog --- src/frontends/xforms/ChangeLog 2001/11/29 11:20:56 1.203 +++ src/frontends/xforms/ChangeLog 2001/11/30 21:14:52 @@ -1,3 +1,7 @@ +2001-11-30 John Levon <[EMAIL PROTECTED]> + + * FormIndex.C: use escaping code + 2001-11-29 John Levon <[EMAIL PROTECTED]> * FormParagraph.C: disallow page breaks in insets Index: src/frontends/xforms/FormIndex.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormIndex.C,v retrieving revision 1.23 diff -u -r1.23 FormIndex.C --- src/frontends/xforms/FormIndex.C 2001/06/13 15:11:16 1.23 +++ src/frontends/xforms/FormIndex.C 2001/11/30 21:14:53 @@ -50,11 +50,11 @@ void FormIndex::update() { fl_set_input(dialog_->input_key, - controller().params().getContents().c_str()); + controller().getContents().c_str()); } void FormIndex::apply() { - controller().params().setContents(fl_get_input(dialog_->input_key)); + controller().setContents(fl_get_input(dialog_->input_key)); } Index: src/insets/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v retrieving revision 1.236 diff -u -r1.236 ChangeLog --- src/insets/ChangeLog 2001/11/30 16:10:24 1.236 +++ src/insets/ChangeLog 2001/11/30 21:14:59 @@ -1,3 +1,8 @@ +2001-11-30 John Levon <[EMAIL PROTECTED]> + + * insetindex.h: + * insetindex.C: add code to escape for latex + 2001-11-30 Juergen Vigna <[EMAIL PROTECTED]> * insettabular.C (InsetTabular): use the save_id flag to create also Index: src/insets/insetindex.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetindex.C,v retrieving revision 1.27 diff -u -r1.27 insetindex.C --- src/insets/insetindex.C 2001/11/19 15:34:11 1.27 +++ src/insets/insetindex.C 2001/11/30 21:15:08 @@ -11,6 +11,7 @@ #include "LaTeXFeatures.h" #include "gettext.h" #include "support/LOstream.h" +#include "support/lstrings.h" using std::ostream; @@ -47,6 +48,16 @@ Inset::Code InsetIndex::lyxCode() const { return Inset::INDEX_CODE; +} + + +void InsetIndex::escapeContents() +{ + string str(getContents()); + + str = subst(str, "_", "\\_"); + + setContents(str); } Index: src/insets/insetindex.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetindex.h,v retrieving revision 1.26 diff -u -r1.26 insetindex.h --- src/insets/insetindex.h 2001/11/02 16:11:19 1.26 +++ src/insets/insetindex.h 2001/11/30 21:15:08 @@ -42,6 +42,8 @@ Inset::Code lyxCode() const; /// int docbook(Buffer const *, std::ostream &) const; + /// escape the contents for latex + void escapeContents(); };