]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiListings.cpp
Use <cstdint> instead of <boost/cstdint.hpp>
[lyx.git] / src / frontends / qt4 / GuiListings.cpp
index 561022f595423138571d6892426a458cd75addc4..c957cb0b75bf0857e9cef14c3c9a4adce6f2f521 100644 (file)
@@ -47,26 +47,28 @@ namespace frontend {
 
 
 char const * languages_supported[] =
-{ "no language", "ABAP", "ACSL", "Ada", "ALGOL", "Assembler", "Awk", "bash", "Basic", "C",
-  "C++", "Caml", "Clean", "Cobol", "Comal 80", "command.com", "Comsol", "csh", "Delphi",
-  "Eiffel", "Elan", "erlang", "Euphoria", "Fortran", "Gnuplot", "Haskell", "HTML", "IDL", "inform",
-  "Java", "JVMIS", "ksh", "Lingo", "Lisp", "Logo", "make", "Mathematica", "Matlab", "Mercury",
-  "MetaPost", "Miranda", "ML", "Modula-2", "MuPAD", "NASTRAN", "Oberon-2", "OCL", "Octave",
+{ "no language", "ABAP", "ACM", "ACMscript", "ACSL", "Ada", "ALGOL", "Ant", "Assembler", "Awk", "bash", "Basic", "C",
+  "C++", "Caml", "CIL", "Clean", "Cobol", "Comal 80", "command.com", "Comsol", "csh", "Delphi",
+  "Eiffel", "Elan", "elisp", "erlang", "Euphoria", "Fortran", "GAP", "GCL", "Gnuplot", "Go",
+  "hansl", "Haskell", "HTML", "IDL", "inform",
+  "Java", "JVMIS", "ksh", "Lingo", "Lisp", "LLVM", "Logo", "Lua", "make", "Mathematica", "Matlab", "Mercury",
+  "MetaPost", "Miranda", "Mizar", "ML", "Modula-2", "MuPAD", "NASTRAN", "Oberon-2", "OCL", "Octave", "OORexx",
   "Oz", "Pascal", "Perl", "PHP", "PL/I", "Plasm", "PostScript", "POV", "Prolog", "Promela",
-  "PSTricks", "Python", "R", "Reduce", "Rexx", "RSL", "Ruby", "S", "SAS", "Scilab", "sh",
-  "SHELXL", "Simula", "tcl", "SPARQL", "SQL", "tcl", "TeX", "VBScript", "Verilog", "VHDL",
+  "PSTricks", "Python", "R", "Reduce", "Rexx", "RSL", "Ruby", "S", "SAS", "Scala", "Scilab", "sh",
+  "SHELXL", "Simula", "SPARQL", "SQL", "Swift", "tcl", "TeX", "VBScript", "Verilog", "VHDL",
   "VRML", "XML", "XSLT", "" };
 
 
 char const * languages_gui[] =
-{ N_("No language"), "ABAP", "ACSL", "Ada", "ALGOL", "Assembler", "Awk", "bash", "Basic",
-  "C", "C++", "Caml", "Clean", "Cobol", "Comal 80", "command.com", "Comsol", "csh", "Delphi",
-  "Eiffel", "Elan", "Erlang", "Euphoria", "Fortran", "Gnuplot", "Haskell", "HTML", "IDL", "inform",
-  "Java", "JVMIS", "ksh", "Lingo", "Lisp", "Logo", "make", "Mathematica", "Matlab", "Mercury",
-  "MetaPost", "Miranda", "ML", "Modula-2", "MuPAD", "NASTRAN", "Oberon-2", "OCL", "Octave",
+{ N_("No language"), "ABAP", "ACM", "ACMscript", "ACSL", "Ada", "ALGOL", "Ant", "Assembler", "Awk", "bash", "Basic", "C",
+  "C++", "Caml", "CIL", "Clean", "Cobol", "Comal 80", "command.com", "Comsol", "csh", "Delphi",
+  "Eiffel", "Elan", "elisp", "erlang", "Euphoria", "Fortran", "GAP", "GCL", "Gnuplot", "Go",
+  "hansl", "Haskell", "HTML", "IDL", "inform",
+  "Java", "JVMIS", "ksh", "Lingo", "Lisp", "LLVM", "Logo", "Lua", "make", "Mathematica", "Matlab", "Mercury",
+  "MetaPost", "Miranda", "Mizar", "ML", "Modula-2", "MuPAD", "NASTRAN", "Oberon-2", "OCL", "Octave", "OORexx",
   "Oz", "Pascal", "Perl", "PHP", "PL/I", "Plasm", "PostScript", "POV", "Prolog", "Promela",
-  "PSTricks", "Python", "R", "Reduce", "Rexx", "RSL", "Ruby", "S", "SAS", "Scilab", "sh",
-  "SHELXL", "Simula", "tcl", "SPARQL", "SQL", "tcl", "TeX", "VBScript", "Verilog", "VHDL",
+  "PSTricks", "Python", "R", "Reduce", "Rexx", "RSL", "Ruby", "S", "SAS", "Scala", "Scilab", "sh",
+  "SHELXL", "Simula", "SPARQL", "SQL", "Swift", "tcl", "TeX", "VBScript", "Verilog", "VHDL",
   "VRML", "XML", "XSLT", "" };
 
 
@@ -167,9 +169,8 @@ GuiListings::GuiListings(GuiView & lv)
 {
        setupUi(this);
 
-       connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
-       connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
-       connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
+       connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
+               this, SLOT(slotButtonBox(QAbstractButton *)));
 
        connect(languageCO, SIGNAL(currentIndexChanged(int)),
                this, SLOT(change_adaptor()));
@@ -234,9 +235,9 @@ GuiListings::GuiListings(GuiView & lv)
        placementLE->setValidator(new QRegExpValidator(QRegExp("[\\*tbph]*"), this));
 
        bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
-       bc().setOK(okPB);
-       bc().setApply(applyPB);
-       bc().setCancel(closePB);
+       bc().setOK(buttonBox->button(QDialogButtonBox::Ok));
+       bc().setApply(buttonBox->button(QDialogButtonBox::Apply));
+       bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
        listingsTB->setPlainText(
                qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
 
@@ -296,6 +297,9 @@ string GuiListings::construct_params()
        string fontstyle = font_styles[qMax(0, fontstyleCO->currentIndex())];
        string basicstyle;
        string mintedsize;
+       // FIXME: We should not compose listings- or minted-dependant string here
+       //        This breaks if a users switches the backend without opening and
+       //        re-applying all listings insets. Use a backend-abstract syntax!
        bool const use_minted = buffer().params().use_minted;
        if (fontsize != "default") {
                if (use_minted)
@@ -320,9 +324,18 @@ string GuiListings::construct_params()
        InsetListingsParams par;
        par.setMinted(use_minted);
        if (use_minted) {
-               if (language == "no language" && !contains(extra, "language="))
-                       par.addParam("language", "TeX");
-               else
+               if (language == "no language" && !contains(extra, "language=")) {
+                       string const & blp = buffer().params().listings_params;
+                       size_t start = blp.find("language=");
+                       if (start != string::npos) {
+                               start += strlen("language=");
+                               size_t len = blp.find(",", start);
+                               if (len != string::npos)
+                                       len -= start;
+                               par.addParam("language", blp.substr(start, len));
+                       } else
+                               par.addParam("language", "TeX");
+               } else
                        par.addParam("language", language);
        } else if (language != "no language" && !contains(extra, "language=")) {
                if (dialect.empty())
@@ -433,7 +446,8 @@ void GuiListings::on_languageCO_currentIndexChanged(int index)
                }
        }
        dialectCO->setCurrentIndex(default_dialect);
-       dialectCO->setEnabled(dialectCO->count() > 1);
+       dialectCO->setEnabled(dialectCO->count() > 1
+                             && !buffer().params().use_minted);
 }
 
 
@@ -660,9 +674,9 @@ bool GuiListings::isValid()
 }
 
 
-bool GuiListings::initialiseParams(string const & data)
+bool GuiListings::initialiseParams(string const & sdata)
 {
-       InsetListings::string2params(data, params_);
+       InsetListings::string2params(sdata, params_);
        return true;
 }