#include <config.h>
#include "InsetListings.h"
-#include "InsetCaption.h"
#include "Buffer.h"
+#include "BufferView.h"
#include "BufferParams.h"
#include "Counters.h"
#include "Cursor.h"
#include "DispatchResult.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
-#include "support/gettext.h"
+#include "InsetCaption.h"
#include "InsetList.h"
#include "Language.h"
#include "MetricsInfo.h"
#include "TextClass.h"
+#include "support/debug.h"
#include "support/docstream.h"
+#include "support/gettext.h"
#include "support/lstrings.h"
+#include "frontends/Application.h"
+
#include <boost/regex.hpp>
#include <sstream>
InsetListings::~InsetListings()
{
- InsetListingsMailer(*this).hideDialog();
+ hideDialogs("listings", this);
}
{
while (lex.isOK()) {
lex.next();
- string const token = lex.getString();
+ string token = lex.getString();
if (token == "lstparams") {
lex.next();
string const value = lex.getString();
}
}
if (isInline) {
- char const * delimiter = lstinline_delimiters;
+ char const * delimiter = lstinline_delimiters;
for (; delimiter != '\0'; ++delimiter)
if (!contains(code, *delimiter))
break;
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
- InsetListingsMailer::string2params(to_utf8(cmd.argument()), params());
+ InsetListings::string2params(to_utf8(cmd.argument()), params());
break;
}
case LFUN_INSET_DIALOG_UPDATE:
- InsetListingsMailer(*this).updateDialog(&cur.bv());
- break;
- case LFUN_MOUSE_RELEASE: {
- if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
- InsetListingsMailer(*this).showDialog(&cur.bv());
- break;
- }
- InsetCollapsable::doDispatch(cur, cmd);
+ cur.bv().updateDialog("listings", params2string(params()));
break;
- }
default:
InsetCollapsable::doDispatch(cur, cmd);
break;
FuncStatus & status) const
{
switch (cmd.action) {
+ case LFUN_INSET_MODIFY:
case LFUN_INSET_DIALOG_UPDATE:
- status.enabled(true);
+ status.setEnabled(true);
return true;
case LFUN_CAPTION_INSERT:
- status.enabled(!params().isInline());
+ status.setEnabled(!params().isInline());
return true;
default:
return InsetCollapsable::getStatus(cur, cmd, status);
bool InsetListings::showInsetDialog(BufferView * bv) const
{
- InsetListingsMailer(const_cast<InsetListings &>(*this)).showDialog(bv);
+ bv->showDialog("listings", params2string(params()),
+ const_cast<InsetListings *>(this));
return true;
}
}
-string const InsetListingsMailer::name_("listings");
-
-InsetListingsMailer::InsetListingsMailer(InsetListings & inset)
- : inset_(inset)
-{}
-
-
-string const InsetListingsMailer::inset2string(Buffer const &) const
-{
- return params2string(inset_.params());
-}
-
-
-void InsetListingsMailer::string2params(string const & in,
+void InsetListings::string2params(string const & in,
InsetListingsParams & params)
{
params = InsetListingsParams();
if (in.empty())
return;
istringstream data(in);
- Lexer lex(0, 0);
+ Lexer lex;
lex.setStream(data);
// discard "listings", which is only used to determine inset
lex.next();
}
-string const
-InsetListingsMailer::params2string(InsetListingsParams const & params)
+string InsetListings::params2string(InsetListingsParams const & params)
{
ostringstream data;
- data << name_ << " ";
+ data << "listings" << ' ';
params.write(data);
return data.str();
}