]> git.lyx.org Git - features.git/commitdiff
Remove unsupported macros from autocompletion
authorGeorg Baum <baum@lyx.org>
Tue, 10 Mar 2015 19:53:56 +0000 (20:53 +0100)
committerGeorg Baum <baum@lyx.org>
Tue, 10 Mar 2015 19:53:56 +0000 (20:53 +0100)
We have some math macros that exist only because LyX can display them easily,
but which require user preamble code. These commands should not appear in
autocompletion, they are only there to make the formulas of users who actually
need thgese symbols and know what to put into the preamble more beautiful.

lib/symbols
src/mathed/InsetMathNest.cpp
src/mathed/MacroTable.cpp
src/mathed/MacroTable.h
src/mathed/MathFactory.cpp
src/mathed/MathParser.h

index d4a9f655420d2fb9d6b5a71af69902a89a1cc93f..1361c9b8b7c2c4ecd5333e66516897540d35a2c4 100644 (file)
@@ -49,7 +49,7 @@ underrightarrow     decoration none       amsmath
 #Do not load automatically, it redefines some other symbols, and we don't
 #have a possibility to turn automatic loading off like for ams
 #undertilde          decoration none       accents
-undertilde          decoration none
+undertilde          decoration none       hiddensymbol
 utilde              decoration none       undertilde
 vec                 decoration none
 widehat             decoration none
@@ -60,7 +60,7 @@ dots              dots        none
 #Do not load automatically, it redefines some other symbols, and we don't
 #have a possibility to turn automatic loading off like for ams
 #adots             dots        none        yhmath
-adots             dots        none
+adots             dots        none        hiddensymbol
 cdots             dots        none
 ddots             dots        none
 dotsb             dots        none        amsmath
@@ -93,12 +93,12 @@ Biggr             big         none
 # packages. No 'm' versions!
 # See lucidabr.dtx for a possible implementation if you want to use these
 # with other fonts.
-biggg             big         none
-bigggl            big         none
-bigggr            big         none
-Biggg             big         none
-Bigggl            big         none
-Bigggr            big         none
+biggg             big         none        hiddensymbol
+bigggl            big         none        hiddensymbol
+bigggr            big         none        hiddensymbol
+Biggg             big         none        hiddensymbol
+Bigggl            big         none        hiddensymbol
+Bigggr            big         none        hiddensymbol
 
 # font changes
 # name           "font"       math/text family  series  shape  color
index dbc0c7692b68c76c3e158ea15a3c5ea1132cb187..392e1ff8e8c389f27f0c31ed6495e160dfc2b034 100644 (file)
@@ -2113,7 +2113,7 @@ MathCompletionList::MathCompletionList(Cursor const & cur)
 
        // fill in global macros
        macros.clear();
-       MacroTable::globalMacros().getMacroNames(macros);
+       MacroTable::globalMacros().getMacroNames(macros, false);
        //lyxerr << "Globals completion macros: ";
        for (it = macros.begin(); it != macros.end(); ++it) {
                //lyxerr << "\\" + *it << " ";
@@ -2198,7 +2198,7 @@ MathCompletionList::MathCompletionList(Cursor const & cur)
        MathWordList::const_iterator it2;
        //lyxerr << "Globals completion commands: ";
        for (it2 = words.begin(); it2 != words.end(); ++it2) {
-               if (it2->second.inset != "macro") {
+               if (it2->second.inset != "macro" && !it2->second.hidden) {
                        // macros are already read from MacroTable::globalMacros()
                        globals.push_back('\\' + it2->first);
                        //lyxerr << '\\' + it2->first << ' ';
index 24c9e07a5eacaef91d41dd9f887d0f78bc60338a..2d29f520e99657d65261c8645d477dd0dc313823 100644 (file)
@@ -119,6 +119,14 @@ string const MacroData::requires() const
 }
 
 
+bool MacroData::hidden() const
+{
+       if (sym_)
+               return sym_->hidden;
+       return false;
+}
+
+
 docstring const MacroData::xmlname() const
 {
        if (sym_)
@@ -242,10 +250,11 @@ MacroTable::insert(Buffer * buf, docstring const & def)
 }
 
 
-void MacroTable::getMacroNames(std::set<docstring> & names) const
+void MacroTable::getMacroNames(std::set<docstring> & names, bool gethidden) const
 {
        for (const_iterator it = begin(); it != end(); ++it)
-               names.insert(it->first);
+               if (gethidden || !it->second.hidden())
+                       names.insert(it->first);
 }
 
 
index 97029a3df00f52a004026668597d952cb63f5ce4..3bd04ea917a54ccef6469b28e4c8271293ebf825 100644 (file)
@@ -62,6 +62,8 @@ public:
        ///
        std::string const requires() const;
        ///
+       bool hidden() const;
+       ///
        docstring const xmlname() const;
        ///
        char const * MathMLtype() const;
@@ -162,7 +164,7 @@ public:
        ///
        void dump();
        ///
-       void getMacroNames(std::set<docstring> & names) const;
+       void getMacroNames(std::set<docstring> & names, bool gethidden) const;
 
        /// the global list
        static MacroTable & globalMacros();
index 34131278b5b52d6c173ca0534830f90d32f54d89..f2e980a2db7b47b0e8164a75cddaa9954c384678 100644 (file)
@@ -185,6 +185,7 @@ void initSymbols()
                        string requires;
                        string extra;
                        string xmlname;
+                       bool hidden = false;
                        is >> macro >> requires;
                        if ((is >> xmlname)) {
                                extra = requires;
@@ -205,7 +206,11 @@ void initSymbols()
                                        tmp.name = it->first;
                                        tmp.extra = from_utf8(extra);
                                        tmp.xmlname = from_utf8(xmlname);
-                                       tmp.requires = requires;
+                                       if (requires == "hiddensymbol") {
+                                               requires = "";
+                                               tmp.hidden = hidden = true;
+                                       } else
+                                               tmp.requires = requires;
                                        theMathWordList[it->first] = tmp;
                                        wit = theMathWordList.find(it->first);
                                        it->second.setSymbol(&(wit->second));
@@ -218,7 +223,8 @@ void initSymbols()
                                << "  draw: 0"
                                << "  extra: " << extra
                                << "  xml: " << xmlname
-                               << "  requires: " << requires << '\'');
+                               << "  requires: " << requires
+                               << "  hidden: " << hidden << '\'');
                        continue;
                }
 
@@ -294,6 +300,12 @@ void initSymbols()
                                              << " used for " << to_utf8(tmp.name));
                }
 
+               if (tmp.requires == "hiddensymbol")
+               {
+                       tmp.requires = "";
+                       tmp.hidden = true;
+               }
+
                if (theMathWordList.find(tmp.name) != theMathWordList.end())
                        LYXERR(Debug::MATHED, "readSymbols: inset " << to_utf8(tmp.name)
                                << " already exists.");
@@ -307,7 +319,8 @@ void initSymbols()
                        << "  draw: " << int(tmp.draw.empty() ? 0 : tmp.draw[0])
                        << "  extra: " << to_utf8(tmp.extra)
                        << "  xml: " << to_utf8(tmp.xmlname)
-                       << "  requires: " << tmp.requires << '\'');
+                       << "  requires: " << tmp.requires
+                       << "  hidden: " << tmp.hidden << '\'');
        }
        string tmp = "cmm";
        string tmp2 = "cmsy";
index c92a8cfb883463525aea84e1e4b79695d09eefd5..9ff6db1a91a2cb9f0f48932a99dfcda0972dc76d 100644 (file)
@@ -30,6 +30,8 @@ class Lexer;
 ///
 class latexkeys {
 public:
+       ///
+       latexkeys() : hidden(false) {}
        ///
        char const * MathMLtype() const;
        /// name of the macro or primitive
@@ -56,6 +58,9 @@ public:
        docstring xmlname;
        /// required LaTeXFeatures
        std::string requires;
+       /// Should this macro be hidden from autocompletion (since it requires
+       /// user preamble code)?
+       bool hidden;
 };