mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Separate caption and label from InsetListingsParams and handle them separately in listings and Include dialog, from Jurgen
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18324 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9b5b7587a3
commit
72e0b87a90
@ -76,3 +76,7 @@ End
|
||||
Counter
|
||||
Name equation
|
||||
End
|
||||
|
||||
Counter
|
||||
Name listing
|
||||
End
|
||||
|
@ -1871,6 +1871,8 @@ docstring Text::getPossibleLabel(Cursor & cur) const
|
||||
name = from_ascii("thm");
|
||||
else if (name == "Foot")
|
||||
name = from_ascii("fn");
|
||||
else if (name == "listing")
|
||||
name = from_ascii("lst");
|
||||
|
||||
if (!name.empty())
|
||||
text = name.substr(0, 3) + ':' + text;
|
||||
|
@ -417,6 +417,8 @@ void setCaptions(Paragraph & par, TextClass const & textclass)
|
||||
// FIXME: are "table" and "Table" the correct type and label?
|
||||
setCaptionLabels(inset, "table", from_ascii("Table"), counters);
|
||||
}
|
||||
else if (inset.lyxCode() == Inset::LISTINGS_CODE)
|
||||
setCaptionLabels(inset, "listing", from_ascii("Listing"), counters);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "support/os.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include "QInclude.h"
|
||||
|
||||
@ -30,9 +31,12 @@
|
||||
#include <QLineEdit>
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
using lyx::support::os::internal_path;
|
||||
|
||||
using lyx::support::prefixIs;
|
||||
using lyx::support::getStringFromVector;
|
||||
using lyx::support::getVectorFromString;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
@ -58,6 +62,8 @@ QIncludeDialog::QIncludeDialog(QInclude * form)
|
||||
connect(typeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
|
||||
connect(typeCO, SIGNAL(activated(int)), this, SLOT(typeChanged(int)));
|
||||
connect(previewCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
||||
connect(captionLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
|
||||
connect(labelLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
|
||||
connect(listingsED, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
|
||||
connect(listingsED, SIGNAL(textChanged()), this, SLOT(validate_listings_params()));
|
||||
|
||||
@ -85,13 +91,11 @@ void QIncludeDialog::validate_listings_params()
|
||||
InsetListingsParams par(fromqstr(listingsED->toPlainText()));
|
||||
if (!isOK) {
|
||||
isOK = true;
|
||||
// listingsTB->setTextColor("black");
|
||||
listingsTB->setPlainText("Input listings parameters below. Enter ? for a list of parameters.");
|
||||
listingsTB->setPlainText("Input listings parameters on the right. Enter ? for a list of parameters.");
|
||||
okPB->setEnabled(true);
|
||||
}
|
||||
} catch (invalidParam & e) {
|
||||
isOK = false;
|
||||
// listingsTB->setTextColor("red");
|
||||
listingsTB->setPlainText(e.what());
|
||||
okPB->setEnabled(false);
|
||||
}
|
||||
@ -115,7 +119,6 @@ void QIncludeDialog::typeChanged(int v)
|
||||
previewCB->setEnabled(false);
|
||||
previewCB->setChecked(false);
|
||||
listingsGB->setEnabled(false);
|
||||
listingsED->setEnabled(false);
|
||||
break;
|
||||
//case Input
|
||||
case 1:
|
||||
@ -123,7 +126,6 @@ void QIncludeDialog::typeChanged(int v)
|
||||
visiblespaceCB->setChecked(false);
|
||||
previewCB->setEnabled(true);
|
||||
listingsGB->setEnabled(false);
|
||||
listingsED->setEnabled(false);
|
||||
break;
|
||||
//case listings
|
||||
case 3:
|
||||
@ -131,7 +133,6 @@ void QIncludeDialog::typeChanged(int v)
|
||||
visiblespaceCB->setChecked(false);
|
||||
previewCB->setEnabled(false);
|
||||
listingsGB->setEnabled(true);
|
||||
listingsED->setEnabled(true);
|
||||
break;
|
||||
//case Verbatim
|
||||
default:
|
||||
@ -139,7 +140,6 @@ void QIncludeDialog::typeChanged(int v)
|
||||
previewCB->setEnabled(false);
|
||||
previewCB->setChecked(false);
|
||||
listingsGB->setEnabled(false);
|
||||
listingsED->setEnabled(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -183,7 +183,7 @@ void QInclude::build_dialog()
|
||||
bcview().addReadOnly(dialog_->visiblespaceCB);
|
||||
bcview().addReadOnly(dialog_->typeCO);
|
||||
bcview().addReadOnly(dialog_->listingsED);
|
||||
dialog_->listingsTB->setPlainText("Input listings parameters below. Enter ? for a list of parameters.");
|
||||
dialog_->listingsTB->setPlainText("Input listings parameters on the right. Enter ? for a list of parameters.");
|
||||
|
||||
addCheckedLineEdit(bcview(), dialog_->filenameED, dialog_->filenameLA);
|
||||
}
|
||||
@ -235,7 +235,29 @@ void QInclude::update_contents()
|
||||
dialog_->listingsGB->setEnabled(true);
|
||||
dialog_->listingsED->setEnabled(true);
|
||||
InsetListingsParams par(params.getOptions());
|
||||
dialog_->listingsED->setPlainText(toqstr(par.separatedParams()));
|
||||
// extract caption and label and put them into their respective editboxes
|
||||
vector<string> pars = getVectorFromString(par.separatedParams(), "\n");
|
||||
for (vector<string>::iterator it = pars.begin();
|
||||
it != pars.end(); ++it) {
|
||||
if (prefixIs(*it, "caption=")) {
|
||||
string cap = it->substr(8);
|
||||
if (cap[0] == '{' && cap[cap.size()-1] == '}')
|
||||
dialog_->captionLE->setText(toqstr(cap.substr(1, cap.size()-2)));
|
||||
else
|
||||
throw invalidParam("caption parameter is not quoted with braces");
|
||||
*it = "";
|
||||
} else if (prefixIs(*it, "label=")) {
|
||||
string lbl = it->substr(6);
|
||||
if (lbl[0] == '{' && lbl[lbl.size()-1] == '}')
|
||||
dialog_->labelLE->setText(toqstr(lbl.substr(1, lbl.size()-2)));
|
||||
else
|
||||
throw invalidParam("label parameter is not quoted with braces");
|
||||
*it = "";
|
||||
}
|
||||
}
|
||||
// the rest is put to the extra edit box.
|
||||
string extra = getStringFromVector(pars);
|
||||
dialog_->listingsED->setPlainText(toqstr(InsetListingsParams(extra).separatedParams()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,7 +279,14 @@ void QInclude::apply()
|
||||
} else if (item == 3) {
|
||||
params.setCmdName("lstinputlisting");
|
||||
// the parameter string should have passed validation
|
||||
params.setOptions(InsetListingsParams(fromqstr(dialog_->listingsED->toPlainText())).params());
|
||||
InsetListingsParams par(fromqstr(dialog_->listingsED->toPlainText()));
|
||||
string caption = fromqstr(dialog_->captionLE->text());
|
||||
string label = fromqstr(dialog_->labelLE->text());
|
||||
if (!caption.empty())
|
||||
par.addParam("caption", "{" + caption + "}");
|
||||
if (!label.empty())
|
||||
par.addParam("label", "{" + label + "}");
|
||||
params.setOptions(par.params());
|
||||
} else {
|
||||
if (dialog_->visiblespaceCB->isChecked())
|
||||
params.setCmdName("verbatiminput*");
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Bo Peng
|
||||
* \author Jürgen Spitzmüller
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -78,8 +79,6 @@ QListingsDialog::QListingsDialog(QListings * form)
|
||||
connect(breaklinesCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
||||
connect(spaceCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
||||
connect(extendedcharsCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
||||
connect(captionLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
|
||||
connect(labelLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
|
||||
|
||||
connect(listingsED, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
|
||||
connect(listingsED, SIGNAL(textChanged()), this, SLOT(validate_listings_params()));
|
||||
@ -108,7 +107,7 @@ string QListingsDialog::construct_params()
|
||||
|
||||
bool left = numberLeftCB->checkState() == Qt::Checked;
|
||||
bool right = numberRightCB->checkState() == Qt::Checked;
|
||||
string step = fromqstr(numberStepLE->text());
|
||||
string stepnumber = fromqstr(numberStepLE->text());
|
||||
string numberfontsize = fromqstr(numberFontSizeCO->currentText());
|
||||
string firstline = fromqstr(firstlineLE->text());
|
||||
string lastline = fromqstr(lastlineLE->text());
|
||||
@ -122,11 +121,7 @@ string QListingsDialog::construct_params()
|
||||
basicstyle += "\\" + fontstyle;
|
||||
bool breakline = breaklinesCB->checkState() == Qt::Checked;
|
||||
bool space = spaceCB->checkState() == Qt::Checked;
|
||||
bool extendedchar = extendedcharsCB->checkState() == Qt::Checked;
|
||||
|
||||
string caption = fromqstr(captionLE->text());
|
||||
string label = fromqstr(labelLE->text());
|
||||
|
||||
bool extendedchars = extendedcharsCB->checkState() == Qt::Checked;
|
||||
string extra = fromqstr(listingsED->toPlainText());
|
||||
|
||||
// compose a string
|
||||
@ -147,18 +142,16 @@ string QListingsDialog::construct_params()
|
||||
par.addParam("firstline", firstline);
|
||||
if (!lastline.empty())
|
||||
par.addParam("lastline", lastline);
|
||||
if (basicstyle != "")
|
||||
if (!stepnumber.empty())
|
||||
par.addParam("stepnumber", stepnumber);
|
||||
if (!basicstyle.empty())
|
||||
par.addParam("basicstyle", basicstyle);
|
||||
if (breakline)
|
||||
par.addParam("breaklines", "true");
|
||||
if (space)
|
||||
par.addParam("showspaces", "true");
|
||||
if (extendedchar)
|
||||
if (extendedchars)
|
||||
par.addParam("extendedchars", "true");
|
||||
if (!caption.empty())
|
||||
par.addParam("caption", "{" + caption + "}");
|
||||
if (!label.empty())
|
||||
par.addParam("label", "{" + label + "}");
|
||||
par.addParams(extra);
|
||||
return par.params();
|
||||
}
|
||||
@ -171,13 +164,11 @@ void QListingsDialog::validate_listings_params()
|
||||
InsetListingsParams par(construct_params());
|
||||
if (!isOK) {
|
||||
isOK = true;
|
||||
// listingsTB->setTextColor("black");
|
||||
listingsTB->setPlainText("Input listings parameters below. Enter ? for a list of parameters.");
|
||||
listingsTB->setPlainText("Input listings parameters on the right. Enter ? for a list of parameters.");
|
||||
okPB->setEnabled(true);
|
||||
}
|
||||
} catch (invalidParam & e) {
|
||||
isOK = false;
|
||||
// listingsTB->setTextColor("red");
|
||||
listingsTB->setPlainText(e.what());
|
||||
okPB->setEnabled(false);
|
||||
}
|
||||
@ -203,7 +194,7 @@ void QListings::build_dialog()
|
||||
|
||||
bcview().setOK(dialog_->okPB);
|
||||
bcview().setCancel(dialog_->closePB);
|
||||
dialog_->listingsTB->setPlainText("Input listings parameters below. Enter ? for a list of parameters.");
|
||||
dialog_->listingsTB->setPlainText("Input listings parameters on the right. Enter ? for a list of parameters.");
|
||||
|
||||
update_contents();
|
||||
}
|
||||
@ -257,7 +248,7 @@ void QListings::update_contents()
|
||||
dialog_->placementLE->setValidator(new QRegExpValidator(QRegExp("[tbph]*"), this));
|
||||
|
||||
//
|
||||
dialog_->listingsTB->setPlainText("Input listings parameters below. Enter ? for a list of parameters.");
|
||||
dialog_->listingsTB->setPlainText("Input listings parameters on the right. Enter ? for a list of parameters.");
|
||||
|
||||
// set values from param string
|
||||
InsetListingsParams & params = controller().params();
|
||||
@ -345,22 +336,6 @@ void QListings::update_contents()
|
||||
} else if (prefixIs(*it, "extendedchars=")) {
|
||||
dialog_->extendedcharsCB->setChecked(contains(*it, "true"));
|
||||
*it = "";
|
||||
} else if (prefixIs(*it, "caption=")) {
|
||||
string cap = it->substr(8);
|
||||
if ((cap[0] == '{' && cap[cap.size()-1] == '}') ||
|
||||
(cap[0] == '"' && cap[cap.size()-1] == '"') )
|
||||
dialog_->captionLE->setText(toqstr(cap.substr(1, cap.size()-2)));
|
||||
else
|
||||
dialog_->captionLE->setText(toqstr(cap));
|
||||
*it = "";
|
||||
} else if (prefixIs(*it, "label=")) {
|
||||
string lbl = it->substr(6);
|
||||
if ((lbl[0] == '{' && lbl[lbl.size()-1] == '}') ||
|
||||
(lbl[0] == '"' && lbl[lbl.size()-1] == '"') )
|
||||
dialog_->labelLE->setText(toqstr(lbl.substr(1, lbl.size()-2)));
|
||||
else
|
||||
dialog_->labelLE->setText(toqstr(lbl));
|
||||
*it = "";
|
||||
}
|
||||
}
|
||||
// parameters that can be handled by widgets are cleared
|
||||
|
@ -5,8 +5,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>389</width>
|
||||
<height>385</height>
|
||||
<width>315</width>
|
||||
<height>379</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
@ -237,51 +237,111 @@
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="listingsTB" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor" >
|
||||
<cursor>0</cursor>
|
||||
</property>
|
||||
<property name="acceptDrops" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth" >
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="acceptRichText" >
|
||||
<bool>false</bool>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="labelLabel" >
|
||||
<property name="text" >
|
||||
<string>Label</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="captionLE" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="captionLabel" >
|
||||
<property name="text" >
|
||||
<string>Caption</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="labelLE" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="listingsED" >
|
||||
<property name="minimumSize" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string>More parameters</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QTextBrowser" name="listingsTB" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor" >
|
||||
<cursor>0</cursor>
|
||||
</property>
|
||||
<property name="acceptDrops" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="acceptRichText" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="listingsED" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -339,6 +399,8 @@
|
||||
<tabstop>loadPB</tabstop>
|
||||
<tabstop>visiblespaceCB</tabstop>
|
||||
<tabstop>previewCB</tabstop>
|
||||
<tabstop>captionLE</tabstop>
|
||||
<tabstop>labelLE</tabstop>
|
||||
<tabstop>listingsTB</tabstop>
|
||||
<tabstop>listingsED</tabstop>
|
||||
</tabstops>
|
||||
|
@ -8,8 +8,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>499</width>
|
||||
<height>355</height>
|
||||
<width>511</width>
|
||||
<height>325</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
@ -213,9 +213,6 @@
|
||||
<property name="wordWrap" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>captionLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2" >
|
||||
@ -404,79 +401,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3" >
|
||||
<widget class="QGroupBox" name="captionGB_3" >
|
||||
<property name="title" >
|
||||
<string>Display</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="labelL_4" >
|
||||
<property name="text" >
|
||||
<string>&Label:</string>
|
||||
</property>
|
||||
<property name="wordWrap" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>labelLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="captionL_4" >
|
||||
<property name="text" >
|
||||
<string>&Caption:</string>
|
||||
</property>
|
||||
<property name="wordWrap" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>captionLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="captionLE" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>A caption for the List of Listings</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="labelLE" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>A Label for the caption</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2" >
|
||||
@ -599,10 +523,11 @@
|
||||
<tabstops>
|
||||
<tabstop>okPB</tabstop>
|
||||
<tabstop>closePB</tabstop>
|
||||
<tabstop>languageCO</tabstop>
|
||||
<tabstop>listingsTW</tabstop>
|
||||
<tabstop>inlineCB</tabstop>
|
||||
<tabstop>floatCB</tabstop>
|
||||
<tabstop>placementLE</tabstop>
|
||||
<tabstop>languageCO</tabstop>
|
||||
<tabstop>numberLeftCB</tabstop>
|
||||
<tabstop>numberRightCB</tabstop>
|
||||
<tabstop>numberStepLE</tabstop>
|
||||
@ -614,8 +539,6 @@
|
||||
<tabstop>breaklinesCB</tabstop>
|
||||
<tabstop>spaceCB</tabstop>
|
||||
<tabstop>extendedcharsCB</tabstop>
|
||||
<tabstop>captionLE</tabstop>
|
||||
<tabstop>labelLE</tabstop>
|
||||
<tabstop>listingsTB</tabstop>
|
||||
<tabstop>listingsED</tabstop>
|
||||
</tabstops>
|
||||
|
@ -278,6 +278,20 @@ int InsetCaption::docbook(Buffer const & buf, odocstream & os,
|
||||
}
|
||||
|
||||
|
||||
int InsetCaption::getArgument(Buffer const & buf, odocstream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
return InsetText::latex(buf, os, runparams);
|
||||
}
|
||||
|
||||
|
||||
int InsetCaption::getOptArg(Buffer const & buf, odocstream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
return latexOptArgInsets(buf, paragraphs()[0], os, runparams, 1);
|
||||
}
|
||||
|
||||
|
||||
void InsetCaption::computeFullLabel(Buffer const & buf) const
|
||||
{
|
||||
if (type_.empty())
|
||||
|
@ -69,6 +69,12 @@ public:
|
||||
///
|
||||
int docbook(Buffer const & buf, odocstream & os,
|
||||
OutputParams const & runparams) const;
|
||||
/// return the mandatory argument (LaTeX format) only
|
||||
int getArgument(Buffer const & buf, odocstream & os,
|
||||
OutputParams const &) const;
|
||||
/// return the optional argument(s) only
|
||||
int getOptArg(Buffer const & buf, odocstream & os,
|
||||
OutputParams const &) const;
|
||||
///
|
||||
void setCount(int c) { counter_ = c; }
|
||||
///
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Bo Peng
|
||||
* \author Jürgen Spitzmüller
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -11,6 +12,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "InsetListings.h"
|
||||
#include "InsetCaption.h"
|
||||
|
||||
#include "Language.h"
|
||||
#include "gettext.h"
|
||||
@ -127,8 +129,8 @@ docstring const InsetListings::editMessage() const
|
||||
}
|
||||
|
||||
|
||||
int InsetListings::latex(Buffer const &, odocstream & os,
|
||||
OutputParams const &) const
|
||||
int InsetListings::latex(Buffer const & buf, odocstream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
string param_string = params().encodedString();
|
||||
// NOTE: I use {} to quote text, which is an experimental feature
|
||||
@ -141,10 +143,18 @@ int InsetListings::latex(Buffer const &, odocstream & os,
|
||||
else
|
||||
os << "\\lstinline[" << from_ascii(param_string) << "]{";
|
||||
} else {
|
||||
if (param_string.empty())
|
||||
docstring const caption = getCaption(buf, runparams);
|
||||
if (param_string.empty() && caption.empty())
|
||||
os << "\n\\begingroup\n\\inputencoding{latin1}\n\\begin{lstlisting}\n";
|
||||
else
|
||||
os << "\n\\begingroup\n\\inputencoding{latin1}\n\\begin{lstlisting}[" << from_ascii(param_string) << "]\n";
|
||||
else {
|
||||
os << "\n\\begingroup\n\\inputencoding{latin1}\n\\begin{lstlisting}[";
|
||||
if (!caption.empty()) {
|
||||
os << "caption={" << caption << '}';
|
||||
if (!param_string.empty())
|
||||
os << ',';
|
||||
}
|
||||
os << from_ascii(param_string) << "]\n";
|
||||
}
|
||||
lines += 4;
|
||||
}
|
||||
ParagraphList::const_iterator par = paragraphs().begin();
|
||||
@ -152,16 +162,19 @@ int InsetListings::latex(Buffer const &, odocstream & os,
|
||||
|
||||
while (par != end) {
|
||||
pos_type siz = par->size();
|
||||
bool captionline = false;
|
||||
for (pos_type i = 0; i < siz; ++i) {
|
||||
// ignore all struck out text
|
||||
if (par->isDeleted(i))
|
||||
if (i == 0 && par->isInset(i) && i + 1 == siz)
|
||||
captionline = true;
|
||||
// ignore all struck out text and (caption) insets
|
||||
if (par->isDeleted(i) || par->isInset(i))
|
||||
continue;
|
||||
os.put(par->getChar(i));
|
||||
}
|
||||
++par;
|
||||
// for the inline case, if there are multiple paragraphs
|
||||
// they are simply joined. Otherwise, expect latex errors.
|
||||
if (par != end && !lstinline) {
|
||||
// they are simply joined. Otherwise, expect latex errors.
|
||||
if (par != end && !lstinline && !captionline) {
|
||||
os << "\n";
|
||||
++lines;
|
||||
}
|
||||
@ -210,6 +223,9 @@ bool InsetListings::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
status.enabled(true);
|
||||
return true;
|
||||
case LFUN_CAPTION_INSERT:
|
||||
status.enabled(!params().isInline());
|
||||
return true;
|
||||
default:
|
||||
return InsetERT::getStatus(cur, cmd, status);
|
||||
}
|
||||
@ -245,6 +261,31 @@ void InsetListings::getDrawFont(Font & font) const
|
||||
}
|
||||
|
||||
|
||||
docstring InsetListings::getCaption(Buffer const & buf,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
if (paragraphs().empty())
|
||||
return docstring();
|
||||
|
||||
ParagraphList::const_iterator pit = paragraphs().begin();
|
||||
for (; pit != paragraphs().end(); ++pit) {
|
||||
InsetList::const_iterator it = pit->insetlist.begin();
|
||||
for (; it != pit->insetlist.end(); ++it) {
|
||||
Inset & inset = *it->inset;
|
||||
if (inset.lyxCode() == Inset::CAPTION_CODE) {
|
||||
odocstringstream ods;
|
||||
InsetCaption * ins =
|
||||
static_cast<InsetCaption *>(it->inset);
|
||||
ins->getOptArg(buf, ods, runparams);
|
||||
ins->getArgument(buf, ods, runparams);
|
||||
return ods.str();
|
||||
}
|
||||
}
|
||||
}
|
||||
return docstring();
|
||||
}
|
||||
|
||||
|
||||
string const InsetListingsMailer::name_("listings");
|
||||
|
||||
InsetListingsMailer::InsetListingsMailer(InsetListings & inset)
|
||||
|
@ -67,6 +67,8 @@ private:
|
||||
///
|
||||
void setButtonLabel();
|
||||
///
|
||||
docstring getCaption(Buffer const &, OutputParams const &) const;
|
||||
///
|
||||
InsetListingsParams params_;
|
||||
};
|
||||
|
||||
|
@ -33,12 +33,12 @@ namespace lyx
|
||||
{
|
||||
|
||||
enum param_type {
|
||||
ALL,
|
||||
TRUEFALSE,
|
||||
INTEGER,
|
||||
LENGTH,
|
||||
ONEOF,
|
||||
SUBSETOF,
|
||||
ALL, // accept all
|
||||
TRUEFALSE, // accept 'true' or 'false'
|
||||
INTEGER, // accept an integer
|
||||
LENGTH, // accept an latex length
|
||||
ONEOF, // accept one of a few values
|
||||
SUBSETOF, // accept a string composed of given characters
|
||||
};
|
||||
|
||||
|
||||
@ -148,8 +148,12 @@ listings_param_info const listings_param_table[] = {
|
||||
{ "name", "", false, ALL, "", "" },
|
||||
{ "thelstnumber", "", false, ALL, "", "" },
|
||||
{ "title", "", false, ALL, "", "" },
|
||||
{ "caption", "", false, ALL, "", "" },
|
||||
{ "label", "", false, ALL, "", "" },
|
||||
// this option is not handled in the parameter box
|
||||
{ "caption", "", false, ALL, "", "This parameter should not be entered here. "
|
||||
"Please use caption editbox (Include dialog) or insert->caption (listings inset)" },
|
||||
// this option is not handled in the parameter box
|
||||
{ "label", "", false, ALL, "", "This parameter should not be entered here."
|
||||
"Please use label editbox (Include dialog) or insert->caption (listings inset)"},
|
||||
{ "nolol", "", false, TRUEFALSE, "", "" },
|
||||
{ "captionpos", "", false, SUBSETOF, "tb", "" },
|
||||
{ "abovecaptionskip", "", false, LENGTH, "", "" },
|
||||
|
Loading…
Reference in New Issue
Block a user