]> git.lyx.org Git - features.git/commitdiff
* Lexer.{cpp,h}:
authorJürgen Spitzmüller <spitz@lyx.org>
Tue, 25 Nov 2008 14:44:17 +0000 (14:44 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Tue, 25 Nov 2008 14:44:17 +0000 (14:44 +0000)
- implement quoteString for docstring
* Menus.cpp:
- use it for quoting flex argument.

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

src/Lexer.cpp
src/Lexer.h
src/frontends/qt4/Menus.cpp

index b0fabc29ad68ef673fc840e32c1562f8975b228e..546ae0e9e9e865cd7834ebe667421abc30db618b 100644 (file)
@@ -901,6 +901,18 @@ string Lexer::quoteString(string const & arg)
 }
 
 
+// same for docstring
+docstring Lexer::quoteString(docstring const & arg)
+{
+       docstring res;
+       res += '"';
+       res += subst(subst(arg, from_ascii("\\"), from_ascii("\\\\")), 
+                    from_ascii("\""), from_ascii("\\\""));
+       res += '"';
+       return res;
+}
+
+
 Lexer & Lexer::operator>>(char const * required)
 {
        string token;
index 85b8b74600a840a0481c5b87fac89939aa23889e..ba085ed0e426e1528679cf852968da9ca9ca89be 100644 (file)
@@ -193,6 +193,9 @@ public:
        /// Quotes a string so that reading it again with Lexer::next(true)
        /// gets the original string
        static std::string quoteString(std::string const &);
+       /// Quotes a docstring so that reading it again with Lexer::next(true)
+       /// gets the original string
+       static docstring quoteString(docstring const &);
 
 private:
        /// noncopyable
index 934f6dd11e6a8de046fa6f0a1275f2a650dee986..f8c2adbea53227fa9782833f5a0cc621a3fe77e7 100644 (file)
@@ -851,7 +851,7 @@ void MenuDefinition::expandFlexInsert(
                        docstring const label = cit->first;
                        addWithStatusCheck(MenuItem(MenuItem::Command, 
                                toqstr(translateIfPossible(label)),
-                               FuncRequest(LFUN_FLEX_INSERT, '"' + label + '"')));
+                               FuncRequest(LFUN_FLEX_INSERT, Lexer::quoteString(label))));
                }
        }
        // FIXME This is a little clunky.