]> git.lyx.org Git - features.git/commitdiff
- Fix math editing
authorAsger Ottar Alstrup <alstrup@lyx.org>
Thu, 19 Oct 2006 16:38:13 +0000 (16:38 +0000)
committerAsger Ottar Alstrup <alstrup@lyx.org>
Thu, 19 Oct 2006 16:38:13 +0000 (16:38 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15377 a592a061-630c-0410-9148-cb99ea01b6c8

src/converter.C
src/cursor.C
src/mathed/InsetMathNest.C
src/mathed/InsetMathNest.h

index 1463e6e79274daf3833dd13596d62415f4c5593e..9f9433dc30ca198beb90d442a2e44a45f62f3c63 100644 (file)
@@ -322,7 +322,7 @@ bool Converters::convert(Buffer const * buffer,
                Alert::error(_("Cannot convert file"),
                             bformat(_("No information for converting %1$s "
                                                    "format files to %2$s.\n"
-                                                   "Define a convertor in the preferences."),
+                                                   "Define a converter in the preferences."),
                                                        lyx::from_ascii(from_format), lyx::from_ascii(to_format)));
                return false;
        }
index 2583ab12a8c16260bcefc5d4bee87ad06cf6eae5..8bf0a5788bcc8c8b9785754d874667535dcfe4f0 100644 (file)
@@ -864,7 +864,7 @@ bool LCursor::macroModeClose()
                lyxerr << "can't enter recursive macro" << endl;
 
        InsetMathNest * const in = inset().asInsetMath()->asNestInset();
-       if (in && in->interpret(*this, s))
+       if (in && in->interpretString(*this, s))
                return true;
        plainInsert(createInsetMath(name));
        return true;
index 37db10add0045cf1b2e5409ef9bbae070c74a1ab..ccda9eb5493c75088c5be0a1e756a9098a8d1206 100644 (file)
@@ -675,7 +675,7 @@ void InsetMathNest::doDispatch(LCursor & cur, FuncRequest & cmd)
                if (cmd.argument().size() != 1) {
                        recordUndo(cur);
                        string const arg = lyx::to_utf8(cmd.argument());
-                       if (!interpret(cur, arg))
+                       if (!interpretString(cur, arg))
                                cur.insert(arg);
                        break;
                }
@@ -705,9 +705,12 @@ void InsetMathNest::doDispatch(LCursor & cur, FuncRequest & cmd)
                // FIXME: Change to
                // } else if (!interpret(cur, cmd.argument()[0])) {
                // when interpret accepts UCS4 characters
-               } else if (!interpret(cur, lyx::to_utf8(cmd.argument()))) {
-                       cmd = FuncRequest(LFUN_FINISHED_RIGHT);
-                       cur.undispatched();
+               } else {
+                       std::string arg0 = lyx::to_utf8(docstring(1, cmd.argument()[0]));
+                       if (!interpretChar(cur, arg0[0])) {
+                               cmd = FuncRequest(LFUN_FINISHED_RIGHT);
+                               cur.undispatched();
+                       }
                }
                break;
 
@@ -913,19 +916,19 @@ void InsetMathNest::doDispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_ERT_INSERT:
                // interpret this as if a backslash was typed
                recordUndo(cur, Undo::ATOMIC);
-               interpret(cur, '\\');
+               interpretChar(cur, '\\');
                break;
 
        case LFUN_MATH_SUBSCRIPT:
                // interpret this as if a _ was typed
                recordUndo(cur, Undo::ATOMIC);
-               interpret(cur, '_');
+               interpretChar(cur, '_');
                break;
 
        case LFUN_MATH_SUPERSCRIPT:
                // interpret this as if a ^ was typed
                recordUndo(cur, Undo::ATOMIC);
-               interpret(cur, '^');
+               interpretChar(cur, '^');
                break;
 
 // FIXME: We probably should swap parts of "math-insert" and "self-insert"
@@ -933,9 +936,10 @@ void InsetMathNest::doDispatch(LCursor & cur, FuncRequest & cmd)
 // math-insert only handles special math things like "matrix".
        case LFUN_MATH_INSERT: {
                recordUndo(cur, Undo::ATOMIC);
-               if (cmd.argument() == "^" || cmd.argument() == "_")
-                       interpret(cur, cmd.argument()[0]);
-               else
+               if (cmd.argument() == "^" || cmd.argument() == "_") {
+                       std::string arg0 = lyx::to_utf8(docstring(1, cmd.argument()[0]));
+                       interpretChar(cur, arg0[0]);
+               } else
                        cur.niceInsert(lyx::to_utf8(cmd.argument()));
                break;
                }
@@ -1162,7 +1166,7 @@ void InsetMathNest::lfunMouseRelease(LCursor & cur, FuncRequest & cmd)
 }
 
 
-bool InsetMathNest::interpret(LCursor & cur, char c)
+bool InsetMathNest::interpretChar(LCursor & cur, char c)
 {
        //lyxerr << "interpret 2: '" << c << "'" << endl;
        string save_selection;
@@ -1249,7 +1253,7 @@ bool InsetMathNest::interpret(LCursor & cur, char c)
                if (c == '{')
                        cur.niceInsert(MathAtom(new InsetMathBrace));
                else if (c != ' ')
-                       interpret(cur, c);
+                       interpretChar(cur, c);
                return true;
        }
 
@@ -1338,7 +1342,7 @@ bool InsetMathNest::interpret(LCursor & cur, char c)
 }
 
 
-bool InsetMathNest::interpret(LCursor & cur, string const & str)
+bool InsetMathNest::interpretString(LCursor & cur, string const & str)
 {
        // Create a InsetMathBig from cur.cell()[cur.pos() - 1] and t if
        // possible
@@ -1370,7 +1374,7 @@ bool InsetMathNest::script(LCursor & cur, bool up, string const &
                if (up)
                        cur.niceInsert(createInsetMath("mathcircumflex"));
                else
-                       interpret(cur, '_');
+                       interpretChar(cur, '_');
                return true;
        }
 
index 74908c31cf730537754249499bc3c2dd62f984df..f00db9781325bfb641ef74cd98631ce51627d1e7 100644 (file)
@@ -110,7 +110,7 @@ protected:
 
        /// interpret \p c and insert the result at the current position of
        /// of \p cur. Return whether the cursor should stay in the formula.
-       bool interpret(LCursor & cur, char c);
+       bool interpretChar(LCursor & cur, char c);
        ///
        bool script(LCursor & cur, bool,
                std::string const & save_selection = std::string());
@@ -119,7 +119,7 @@ public:
        /// interpret \p str and insert the result at the current position of
        /// \p cur if it is something known. Return whether \p cur was
        /// inserted.
-       bool interpret(LCursor & cur, std::string const & str);
+       bool interpretString(LCursor & cur, std::string const & str);
 
 private:
        /// lfun handler