]> git.lyx.org Git - features.git/commitdiff
support for second \cite option.
authorJürgen Spitzmüller <spitz@lyx.org>
Fri, 5 Mar 2004 14:49:10 +0000 (14:49 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Fri, 5 Mar 2004 14:49:10 +0000 (14:49 +0000)
Natbib users can now use the before field.
file format is up to 230.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8479 a592a061-630c-0410-9148-cb99ea01b6c8

19 files changed:
development/FORMAT
lib/lyx2lyx/ChangeLog
lib/lyx2lyx/lyx2lyx
lib/lyx2lyx/lyxconvert_229.py [new file with mode: 0644]
lib/lyx2lyx/lyxrevert_230.py [new file with mode: 0644]
po/POTFILES.in
src/ChangeLog
src/buffer.C
src/frontends/qt2/ChangeLog
src/frontends/qt2/QCitation.C
src/frontends/qt2/ui/QCitationDialogBase.ui
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormCitation.C
src/insets/ChangeLog
src/insets/insetcite.C
src/insets/insetcommand.C
src/insets/insetcommand.h
src/insets/insetcommandparams.C
src/insets/insetcommandparams.h

index f50a4146c291acdcd5dcc84c62a98690a87346cc..9e55641877de884f9b28bc73fb05519bb7694ce5 100644 (file)
@@ -1,6 +1,15 @@
 LyX file-format changes
 -----------------------
 
+2004-02-23  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * format incremented to 230.
+       * Support for a second optional argument in insetcommand.
+       currently, citation uses this to support natbibs second
+       optional argument \cite[before][after]{key}.
+       I think there's nothing to convert upwards. Downwards, the 
+       commands need to be converted to ERT I suppose. 
+
 2003-12-29  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * format incremented to 229.
index 231029c529c19d2074336188d7b5a5f29774b5b0..53115407699c71621b550e756e7570d7fd8a7d79 100644 (file)
@@ -1,3 +1,7 @@
+2004-02-25  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * lyx2lyx: up the format to 230.
+
 2004-02-04  José Matos  <jamatos@lyx.org>
        * lyxconvert_210.py: add two new transforms:
        remove_empty_insets and remove_formula_latex
index d4333283bcf76499ab339213020da8b3b7b758ee..a7d86d6e13188be04ef61aa6f390bdc18e185f23 100755 (executable)
@@ -40,7 +40,7 @@ opt.quiet = 0
 
 format = re.compile(r"(\d)[\.,]?(\d\d)")
 fileformat = re.compile(r"\\lyxformat\s*(\S*)")
-lst_ft = [210, 215, 216, 217,  218, 220, 221, 223, 224, 225, 226, 227, 228, 229]
+lst_ft = [210, 215, 216, 217, 218, 220, 221, 223, 224, 225, 226, 227, 228, 229, 230]
 
 def usage():
     print """Usage: lyx2lyx [options] [file]
diff --git a/lib/lyx2lyx/lyxconvert_229.py b/lib/lyx2lyx/lyxconvert_229.py
new file mode 100644 (file)
index 0000000..22c7fc6
--- /dev/null
@@ -0,0 +1,29 @@
+# This file is part of lyx2lyx
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2003 José Matos <jamatos@fep.up.pt>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+
+
+import sys
+from parser_tools import find_token
+
+
+def convert(header, body):
+    pass
+
+if __name__ == "__main__":
+    pass
diff --git a/lib/lyx2lyx/lyxrevert_230.py b/lib/lyx2lyx/lyxrevert_230.py
new file mode 100644 (file)
index 0000000..22c7fc6
--- /dev/null
@@ -0,0 +1,29 @@
+# This file is part of lyx2lyx
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2003 José Matos <jamatos@fep.up.pt>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+
+
+import sys
+from parser_tools import find_token
+
+
+def convert(header, body):
+    pass
+
+if __name__ == "__main__":
+    pass
index 3a80162074dc83e7d9e34c1b022c8962d066d54f..e2a9c1d57a61aa1c36fc23fddade4b425ff73f46 100644 (file)
@@ -192,6 +192,8 @@ src/paragraph.C
 src/paragraph_funcs.C
 src/rowpainter.C
 src/support/globbing.C
+src/support/path_defines.C
+src/tex2lyx/lengthcommon.C
 src/text.C
 src/text2.C
 src/text3.C
index 61ec77f516b5018e241d1cd1c5d0c4cb6a88fb89..8945585c89440ded8f6660c5752da00d5a65a6b3 100644 (file)
@@ -1,3 +1,7 @@
+2004-03-05  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * buffer.C: increment file format to 230.
+
 2004-03-04  Alfredo Braunstein  <abraunst@lyx.org>
 
        * cursor.C (dispatch): avoid infinite loops
index 567c168afba868e4e850bb23c018eadbc11de217..45672b850a84c36934cda33560e3107e2ba7c5ff 100644 (file)
@@ -133,7 +133,7 @@ extern BufferList bufferlist;
 
 namespace {
 
-const int LYX_FORMAT = 229;
+const int LYX_FORMAT = 230;
 
 } // namespace anon
 
index 0e182c3ec6c5cb1de1efcc199d8d4182d5d89d81..50e2c0e71aeca79df4c10234f3eb1ee6f530f98a 100644 (file)
@@ -1,5 +1,8 @@
 2004-03-05  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
+       * QCitation.C:
+       * ui/QCitationDialogBase.ui: Support second \cite option.
+       
        * QDocumentDialog.C (branches): Don't deselect branch
        after button press.
        * QBranch.C: fix off-by-one-error. 
index 83e86325111df8de4e389b251a9c9b94db5cee29..4c73aecee500e244a250a8a3137059bc12fe9e0d 100644 (file)
@@ -60,6 +60,9 @@ void QCitation::apply()
        controller().params().setCmdName(command);
        controller().params().setContents(getStringFromVector(citekeys));
 
+       string const before = fromqstr(dialog_->textBeforeED->text());
+       controller().params().setSecOptions(before);
+       
        string const after = fromqstr(dialog_->textAfterED->text());
        controller().params().setOptions(after);
        
@@ -95,8 +98,7 @@ void QCitation::build_dialog()
        bcview().addReadOnly(dialog_->citationStyleCO);
        bcview().addReadOnly(dialog_->forceuppercaseCB);
        bcview().addReadOnly(dialog_->fulllistCB);
-       // add when enabled !
-       //bcview().addReadOnly(dialog_->textBeforeED);
+       bcview().addReadOnly(dialog_->textBeforeED);
        bcview().addReadOnly(dialog_->textAfterED);
        
        open_find_ = true;
@@ -143,6 +145,7 @@ void QCitation::updateStyle()
 
        dialog_->fulllistCB->setEnabled(natbib);
        dialog_->forceuppercaseCB->setEnabled(natbib);
+       dialog_->textBeforeED->setEnabled(natbib);
 
        string const & command = controller().params().getCmdName();
 
@@ -185,7 +188,10 @@ void QCitation::update_contents()
        dialog_->infoML->clear();
        dialog_->setButtons();
 
-       dialog_->textAfterED->setText(toqstr(controller().params().getOptions()));
+       dialog_->textBeforeED->setText(
+               toqstr(controller().params().getSecOptions()));
+       dialog_->textAfterED->setText(
+               toqstr(controller().params().getOptions()));
 
        fillStyles();
        updateStyle();
index 6e1110b85637248ca8838ba25a535edf7f927367..4b78a84edc28aa6f2beadcad42f72ee17d44b0c3 100644 (file)
@@ -13,8 +13,8 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>404</width>
-            <height>287</height>
+            <width>400</width>
+            <height>310</height>
         </rect>
     </property>
     <property stdset="1">
                 <string>Citation entry</string>
             </property>
         </widget>
-        <widget row="1"  column="1" >
-            <class>QGroupBox</class>
-            <property stdset="1">
-                <name>name</name>
-                <cstring>GroupBox8</cstring>
-            </property>
-            <property stdset="1">
-                <name>title</name>
-                <string>Style</string>
-            </property>
-            <grid>
-                <property stdset="1">
-                    <name>margin</name>
-                    <number>11</number>
-                </property>
-                <property stdset="1">
-                    <name>spacing</name>
-                    <number>6</number>
-                </property>
-                <widget row="0"  column="0" >
-                    <class>QLabel</class>
-                    <property stdset="1">
-                        <name>name</name>
-                        <cstring>citationStyleLA</cstring>
-                    </property>
-                    <property stdset="1">
-                        <name>text</name>
-                        <string>Citation &amp;style:</string>
-                    </property>
-                    <property>
-                        <name>buddy</name>
-                        <cstring>citationStyleCO</cstring>
-                    </property>
-                </widget>
-                <widget row="1"  column="1" >
-                    <class>QLineEdit</class>
-                    <property stdset="1">
-                        <name>name</name>
-                        <cstring>textAfterED</cstring>
-                    </property>
-                    <property stdset="1">
-                        <name>sizePolicy</name>
-                        <sizepolicy>
-                            <hsizetype>5</hsizetype>
-                            <vsizetype>0</vsizetype>
-                        </sizepolicy>
-                    </property>
-                    <property>
-                        <name>toolTip</name>
-                        <string>Text to place after citation</string>
-                    </property>
-                </widget>
-                <widget row="2"  column="0"  rowspan="1"  colspan="2" >
-                    <class>QCheckBox</class>
-                    <property stdset="1">
-                        <name>name</name>
-                        <cstring>fulllistCB</cstring>
-                    </property>
-                    <property stdset="1">
-                        <name>text</name>
-                        <string>&amp;Full author list</string>
-                    </property>
-                    <property>
-                        <name>toolTip</name>
-                        <string>List all authors</string>
-                    </property>
-                </widget>
-                <widget row="0"  column="1" >
-                    <class>QComboBox</class>
-                    <property stdset="1">
-                        <name>name</name>
-                        <cstring>citationStyleCO</cstring>
-                    </property>
-                    <property stdset="1">
-                        <name>sizePolicy</name>
-                        <sizepolicy>
-                            <hsizetype>3</hsizetype>
-                            <vsizetype>0</vsizetype>
-                        </sizepolicy>
-                    </property>
-                    <property>
-                        <name>toolTip</name>
-                        <string>Natbib citation style to use</string>
-                    </property>
-                </widget>
-                <widget row="1"  column="0" >
-                    <class>QLabel</class>
-                    <property stdset="1">
-                        <name>name</name>
-                        <cstring>textAfterLA</cstring>
-                    </property>
-                    <property stdset="1">
-                        <name>text</name>
-                        <string>&amp;Text after:</string>
-                    </property>
-                    <property>
-                        <name>buddy</name>
-                        <cstring>textAfterED</cstring>
-                    </property>
-                </widget>
-                <widget row="3"  column="0"  rowspan="1"  colspan="2" >
-                    <class>QCheckBox</class>
-                    <property stdset="1">
-                        <name>name</name>
-                        <cstring>forceuppercaseCB</cstring>
-                    </property>
-                    <property stdset="1">
-                        <name>text</name>
-                        <string>Force &amp;upper case</string>
-                    </property>
-                    <property>
-                        <name>toolTip</name>
-                        <string>Force upper case in citation</string>
-                    </property>
-                </widget>
-            </grid>
-        </widget>
         <widget row="0"  column="0"  rowspan="2"  colspan="1" >
             <class>QLayoutWidget</class>
             <property stdset="1">
                 </widget>
             </hbox>
         </widget>
+        <widget row="1"  column="1" >
+            <class>QGroupBox</class>
+            <property stdset="1">
+                <name>name</name>
+                <cstring>GroupBox8</cstring>
+            </property>
+            <property stdset="1">
+                <name>title</name>
+                <string>Style</string>
+            </property>
+            <grid>
+                <property stdset="1">
+                    <name>margin</name>
+                    <number>11</number>
+                </property>
+                <property stdset="1">
+                    <name>spacing</name>
+                    <number>6</number>
+                </property>
+                <widget row="0"  column="0" >
+                    <class>QLabel</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>citationStyleLA</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>text</name>
+                        <string>Citation &amp;style:</string>
+                    </property>
+                    <property>
+                        <name>buddy</name>
+                        <cstring>citationStyleCO</cstring>
+                    </property>
+                </widget>
+                <widget row="0"  column="1" >
+                    <class>QComboBox</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>citationStyleCO</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>sizePolicy</name>
+                        <sizepolicy>
+                            <hsizetype>3</hsizetype>
+                            <vsizetype>0</vsizetype>
+                        </sizepolicy>
+                    </property>
+                    <property>
+                        <name>toolTip</name>
+                        <string>Natbib citation style to use</string>
+                    </property>
+                </widget>
+                <widget row="4"  column="0"  rowspan="1"  colspan="2" >
+                    <class>QCheckBox</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>forceuppercaseCB</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>text</name>
+                        <string>Force &amp;upper case</string>
+                    </property>
+                    <property>
+                        <name>toolTip</name>
+                        <string>Force upper case in citation</string>
+                    </property>
+                </widget>
+                <widget row="2"  column="0" >
+                    <class>QLabel</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>textAfterLA</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>text</name>
+                        <string>&amp;Text after:</string>
+                    </property>
+                    <property>
+                        <name>buddy</name>
+                        <cstring>textAfterED</cstring>
+                    </property>
+                </widget>
+                <widget row="2"  column="1" >
+                    <class>QLineEdit</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>textAfterED</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>sizePolicy</name>
+                        <sizepolicy>
+                            <hsizetype>5</hsizetype>
+                            <vsizetype>0</vsizetype>
+                        </sizepolicy>
+                    </property>
+                    <property>
+                        <name>toolTip</name>
+                        <string>Text to place after citation</string>
+                    </property>
+                </widget>
+                <widget row="1"  column="1" >
+                    <class>QLineEdit</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>textBeforeED</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>sizePolicy</name>
+                        <sizepolicy>
+                            <hsizetype>5</hsizetype>
+                            <vsizetype>0</vsizetype>
+                        </sizepolicy>
+                    </property>
+                    <property>
+                        <name>toolTip</name>
+                        <string>Text to place after citation</string>
+                    </property>
+                </widget>
+                <widget row="1"  column="0" >
+                    <class>QLabel</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>textBeforeLA</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>text</name>
+                        <string>Text &amp;before:</string>
+                    </property>
+                    <property>
+                        <name>buddy</name>
+                        <cstring>textAfterED</cstring>
+                    </property>
+                </widget>
+                <widget row="3"  column="0"  rowspan="1"  colspan="2" >
+                    <class>QCheckBox</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>fulllistCB</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>text</name>
+                        <string>&amp;Full author list</string>
+                    </property>
+                    <property>
+                        <name>toolTip</name>
+                        <string>List all authors</string>
+                    </property>
+                </widget>
+            </grid>
+        </widget>
     </grid>
 </widget>
 <images>
         <receiver>QCitationDialogBase</receiver>
         <slot>changed_adaptor()</slot>
     </connection>
+    <connection>
+        <sender>textBeforeED</sender>
+        <signal>textChanged(const QString&amp;)</signal>
+        <receiver>QCitationDialogBase</receiver>
+        <slot>changed_adaptor()</slot>
+    </connection>
     <connection>
         <sender>textAfterED</sender>
         <signal>textChanged(const QString&amp;)</signal>
     <tabstop>addPB</tabstop>
     <tabstop>deletePB</tabstop>
     <tabstop>citationStyleCO</tabstop>
+    <tabstop>textBeforeED</tabstop>
     <tabstop>textAfterED</tabstop>
     <tabstop>fulllistCB</tabstop>
     <tabstop>forceuppercaseCB</tabstop>
index 7f9995349c6ae25846a3b2db3b191d863609f1b7..bbd95b11edd515d89d38a4d26c94c920a8faf431 100644 (file)
@@ -1,3 +1,7 @@
+2004-03-05  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * FormCitation.C: Support second \cite option.
+
 2004-03-05  Martin Vermeer  <martin.vermeer@hut.fi>
 
        * FormDocument.C: fix user interface to branch activation
index 4cca278c06cd14bccadc61558a0c7896081c65cd..7e59ae279c0bc33f61ffaa20243c40046964c33a 100644 (file)
@@ -115,6 +115,9 @@ void FormCitation::apply()
        controller().params().setCmdName(command);
        controller().params().setContents(getStringFromVector(citekeys));
 
+       string const before  = getString(dialog_->input_before);
+       controller().params().setSecOptions(before);
+       
        string const after  = getString(dialog_->input_after);
        controller().params().setOptions(after);
 }
@@ -450,6 +453,7 @@ void FormCitation::update()
        setEnabled(dialog_->check_full_author_list, natbib);
        setEnabled(dialog_->check_force_uppercase, natbib);
        setEnabled(dialog_->choice_style, natbib);
+       setEnabled(dialog_->input_before, natbib);
 
        // No keys have been selected yet, so...
        fl_clear_browser(dialog_->browser_info);
@@ -457,12 +461,11 @@ void FormCitation::update()
        setCiteButtons(OFF);
 
        // Natbib can have comments before and after the citation.
-       // This is not yet supported. After only.
        fl_set_input(dialog_->input_after,
                     controller().params().getOptions().c_str());
 
-       fl_set_input(dialog_->input_before, _("Not yet supported").c_str());
-       setEnabled(dialog_->input_before, false);
+       fl_set_input(dialog_->input_before, 
+                    controller().params().getSecOptions().c_str());
 }
 
 
index 91b8410b485bcd782a93f4f2de0ae10e8bedfa97..4012f6883a62144b9df7201a0bcd51c8f61621df 100644 (file)
@@ -1,3 +1,10 @@
+2004-03-05  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * insetcite.C: Support second \cite option.
+       
+       * insetcommand.[Ch]:
+       * insetcommandparams.[Ch]: add second optional argument.
+
 2004-03-03  Alfredo Braunstein  <abraunst@lyx.org>
 
        * insetcollapsable.C (lfunMouseRelease): right mouse button only
index bbb874d4f2aa6fb4ee8e9b2eed9823e37a77ebf5..3d755fccbe1b11bd8cbff62b614d91c3c1ea8a5c 100644 (file)
@@ -221,7 +221,7 @@ InsetCitation::InsetCitation(InsetCommandParams const & p)
 
 string const InsetCitation::generateLabel(Buffer const & buffer) const
 {
-       string const before = string();
+       string const before = getSecOptions();
        string const after  = getOptions();
 
        string label;
@@ -275,7 +275,7 @@ string const InsetCitation::getScreenLabel(Buffer const & buffer) const
                return cache.screen_label;
 
        // The label has changed, so we have to re-create it.
-       string const before = string();
+       string const before = getSecOptions();
        string const after  = getOptions();
 
        string const glabel = generateLabel(buffer);
@@ -320,25 +320,13 @@ int InsetCitation::latex(Buffer const & buffer, ostream & os,
        else
                os << "cite";
 
-#warning What is this code supposed to do? (Lgb)
-// my guess is that this is just waiting for when we support before,
-// so it's a oneliner. But this is very silly ! - jbl
-
-#if 1
-       // The current strange code
-
-       string const before = string();
+       string const before = getSecOptions();
        string const after  = getOptions();
        if (!before.empty() && buffer.params().use_natbib)
                os << '[' << before << "][" << after << ']';
        else if (!after.empty())
                os << '[' << after << ']';
-#else
-       // and the cleaned up equvalent, should it just be changed? (Lgb)
-       string const after  = getOptions();
-       if (!after.empty())
-               os << '[' << after << ']';
-#endif
+
        string::const_iterator it  = getContents().begin();
        string::const_iterator end = getContents().end();
        // Paranoia check: make sure that there is no whitespace in here
index dd1f782f48c90a716feedf143b442b07548452be..0bb66e3e2359dd326dbbaa8b78a839d5282cbee7 100644 (file)
@@ -30,7 +30,7 @@ using std::ostringstream;
 
 InsetCommand::InsetCommand(InsetCommandParams const & p,
                           string const & mailer_name)
-       : p_(p.getCmdName(), p.getContents(), p.getOptions()),
+       : p_(p.getCmdName(), p.getContents(), p.getOptions(), p.getSecOptions()),
          mailer_name_(mailer_name),
          set_label_(false)
 {}
index 6bb797ed1e19539f300e9c332abcb1649dd6c1af..4311621fe0396b91e500b60cfed565b0c4b70e79 100644 (file)
@@ -70,6 +70,8 @@ public:
        ///
        std::string const & getOptions() const { return p_.getOptions(); }
        ///
+       std::string const & getSecOptions() const { return p_.getSecOptions(); }
+       ///
        RenderButton & button() const { return button_; }
 
 protected:
@@ -84,6 +86,8 @@ protected:
        ///
        void setOptions(std::string const & o) { p_.setOptions(o); }
        ///
+       void setSecOptions(std::string const & s) { p_.setSecOptions(s); }
+       ///
        void setParams(InsetCommandParams const &);
        /// This should provide the text for the button
        virtual std::string const getScreenLabel(Buffer const &) const = 0;
index 996bf0502a68abfcbae679dd2fd7085ef5f2f09c..b21d050771671d0b7b7ffb977d0f6405175240cd 100644 (file)
@@ -27,30 +27,34 @@ InsetCommandParams::InsetCommandParams()
 
 InsetCommandParams::InsetCommandParams(string const & n,
                                        string const & c,
-                                       string const & o)
-       : cmdname(n), contents(c), options(o), preview_(false)
+                                       string const & o,
+                                       string const & s)
+       : cmdname(n), contents(c), options(o), sec_options(s), 
+       preview_(false)
 {}
 
 
 void InsetCommandParams::scanCommand(string const & cmd)
 {
-       string tcmdname, toptions, tcontents;
+       string tcmdname, toptions, tsecoptions, tcontents;
 
        if (cmd.empty()) return;
-
-       enum { WS, CMDNAME, OPTION, CONTENT } state = WS;
+       
+       enum { WS, CMDNAME, OPTION, SECOPTION, CONTENT } state = WS;
 
        // Used to handle things like \command[foo[bar]]{foo{bar}}
        int nestdepth = 0;
 
        for (string::size_type i = 0; i < cmd.length(); ++i) {
                char c = cmd[i];
+               char b = cmd[i-1];
                if ((state == CMDNAME && c == ' ') ||
                    (state == CMDNAME && c == '[') ||
                    (state == CMDNAME && c == '{')) {
                        state = WS;
                }
                if ((state == OPTION  && c == ']') ||
+                   (state == SECOPTION  && c == ']') ||
                    (state == CONTENT && c == '}')) {
                        if (nestdepth == 0) {
                                state = WS;
@@ -59,19 +63,24 @@ void InsetCommandParams::scanCommand(string const & cmd)
                        }
                }
                if ((state == OPTION  && c == '[') ||
+                   (state == SECOPTION  && c == '[') ||
                    (state == CONTENT && c == '{')) {
                        ++nestdepth;
                }
                switch (state) {
                case CMDNAME:   tcmdname += c; break;
                case OPTION:    toptions += c; break;
+               case SECOPTION: tsecoptions += c; break;
                case CONTENT:   tcontents += c; break;
                case WS:
                        if (c == '\\') {
                                state = CMDNAME;
-                       } else if (c == '[') {
+                       } else if (c == '[' && b != ']') {
                                state = OPTION;
                                nestdepth = 0; // Just to be sure
+                       } else if (c == '[' && b == ']') {
+                               state = SECOPTION;
+                               nestdepth = 0; // Just to be sure
                        } else if (c == '{') {
                                state = CONTENT;
                                nestdepth = 0; // Just to be sure
@@ -83,6 +92,7 @@ void InsetCommandParams::scanCommand(string const & cmd)
        // Don't mess with this.
        if (!tcmdname.empty())  setCmdName(tcmdname);
        if (!toptions.empty())  setOptions(toptions);
+       if (!tsecoptions.empty())  setSecOptions(tsecoptions);
        if (!tcontents.empty()) setContents(tcontents);
 
        if (lyxerr.debugging(Debug::PARSER))
@@ -90,7 +100,8 @@ void InsetCommandParams::scanCommand(string const & cmd)
                       << "> == <" << getCommand()
                       << "> == <" << getCmdName()
                       << '|' << getContents()
-                      << '|' << getOptions() << '>' << endl;
+                      << '|' << getOptions() 
+                      << '|' << getSecOptions() << '>' << endl;
 }
 
 
@@ -133,6 +144,11 @@ string const InsetCommandParams::getCommand() const
        string s;
        if (!getCmdName().empty()) s += '\\' + getCmdName();
        if (!getOptions().empty()) s += '[' + getOptions() + ']';
+       if (!getSecOptions().empty()) {
+               // for cases like \command[][sec_option]{arg}
+               if (getOptions().empty()) s += "[]";
+       s += '[' + getSecOptions() + ']';
+       }
        s += '{' + getContents() + '}';
        return s;
 }
@@ -144,6 +160,7 @@ bool operator==(InsetCommandParams const & o1,
        return o1.getCmdName() == o2.getCmdName()
                && o1.getContents() == o2.getContents()
                && o1.getOptions() == o2.getOptions()
+               && o1.getSecOptions() == o2.getSecOptions()
                && o1.preview() == o2.preview();
 }
 
index e863a3772d570815b507c6aeff2d84c4439ffa47..d6c5b1074814b12523fd03af6f237ea97d31f5d8 100644 (file)
@@ -26,7 +26,8 @@ public:
        ///
        explicit InsetCommandParams(std::string const & n,
                            std::string const & c = std::string(),
-                           std::string const & o = std::string());
+                           std::string const & o = std::string(),
+                           std::string const & s = std::string());
        ///
        void read(LyXLex &);
        /// Parse the command
@@ -40,12 +41,16 @@ public:
        ///
        std::string const & getOptions() const { return options; }
        ///
+       std::string const & getSecOptions() const { return sec_options; }
+       ///
        std::string const & getContents() const { return contents; }
        ///
        void setCmdName(std::string const & n) { cmdname = n; }
        ///
        void setOptions(std::string const & o) { options = o; }
        ///
+       void setSecOptions(std::string const & s) { sec_options = s; }
+       ///
        void setContents(std::string const & c) { contents = c; }
        ///
        bool preview() const { return preview_; }
@@ -60,6 +65,8 @@ private:
        ///
        std::string options;
        ///
+       std::string sec_options;
+       ///
        bool preview_;
 };