]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
Allow using \binom without amsmath and add support for \brace and \brack
[lyx.git] / src / Text3.cpp
index f9d622cff584184127fbc8d651b8951340dc9ee1..17b86373236de81b595e899cc200599cb1a34502 100644 (file)
@@ -658,36 +658,24 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                break;
        }
 
-       case LFUN_NEW_LINE: {
-               // Not allowed by LaTeX (labels or empty par)
-               if (cur.pos() > cur.paragraph().beginOfBody()) {
-                       // this avoids a double undo
-                       // FIXME: should not be needed, ideally
-                       if (!cur.selection())
-                               cur.recordUndo();
-                       cap::replaceSelection(cur);
-                       cur.insert(new InsetNewline);
-                       cur.posForward();
-                       moveCursor(cur, false);
-               }
+       case LFUN_NEWLINE_INSERT: {
+               InsetNewlineParams inp;
+               docstring arg = cmd.argument();
+               // this avoids a double undo
+               // FIXME: should not be needed, ideally
+               if (!cur.selection())
+                       cur.recordUndo();
+               cap::replaceSelection(cur);
+               if (arg == "linebreak")
+                       inp.kind = InsetNewlineParams::LINEBREAK;
+               else
+                       inp.kind = InsetNewlineParams::NEWLINE;
+               cur.insert(new InsetNewline(inp));
+               cur.posForward();
+               moveCursor(cur, false);
                break;
        }
        
-       case LFUN_LINE_BREAK: {
-               // Not allowed by LaTeX (labels or empty par)
-               if (cur.pos() > cur.paragraph().beginOfBody()) {
-                       // this avoids a double undo
-                       // FIXME: should not be needed, ideally
-                       if (!cur.selection())
-                               cur.recordUndo();
-                       cap::replaceSelection(cur);
-                       cur.insert(new InsetLinebreak);
-                       cur.posForward();
-                       moveCursor(cur, false);
-               }
-               break;
-       }
-
        case LFUN_CHAR_DELETE_FORWARD:
                if (!cur.selection()) {
                        if (cur.pos() == cur.paragraph().size())
@@ -1179,11 +1167,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                }
                        }
                        if (!bv->mouseSetCursor(cur, false)) {
-                               cur.noUpdate();
-                               return;
+                               cur.updateFlags(Update::SinglePar | Update::FitCursor);
+                               break;                  
                        }
-                       return;
-               }
+               default:
+                       break;
+               } // switch (cmd.button())
+               break;
 
        case LFUN_MOUSE_MOTION: {
                // Mouse motion with right or middle mouse do nothing for now.
@@ -1297,7 +1287,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                }
                p["target"] = (cmd.argument().empty()) ?
                        content : cmd.argument();
-               string const data = InsetCommandMailer::params2string("href", p);
+               string const data = InsetCommand::params2string("href", p);
                if (p["target"].empty()) {
                        bv->showDialog("href", data);
                } else {
@@ -1313,7 +1303,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                p["name"] = (cmd.argument().empty()) ?
                        cur.getPossibleLabel() :
                        cmd.argument();
-               string const data = InsetCommandMailer::params2string("label", p);
+               string const data = InsetCommand::params2string("label", p);
 
                if (cmd.argument().empty()) {
                        bv->showDialog("label", data);
@@ -1683,11 +1673,17 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                breakParagraph(cur);
                        }
 
-                       //FIXME Check if this should be emptyLayout()
-                       setLayout(cur, tclass.defaultLayoutName());
+                       docstring const laystr = cur.inset().useEmptyLayout() ?
+                               tclass.emptyLayoutName() :
+                               tclass.defaultLayoutName();
+                       setLayout(cur, laystr);
                        ParagraphParameters p;
                        setParagraphs(cur, p);
-                       insertInset(cur, new InsetFloatList(to_utf8(cmd.argument())));
+                       // FIXME This should be simplified when InsetFloatList takes a 
+                       // Buffer in its constructor.
+                       InsetFloatList * ifl = new InsetFloatList(to_utf8(cmd.argument()));
+                       ifl->setBuffer(bv->buffer());
+                       insertInset(cur, ifl);
                        cur.posForward();
                } else {
                        lyxerr << "Non-existent float type: "
@@ -2120,6 +2116,11 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                enable = (cur.paragraph().layout().toclevel != Layout::NOT_IN_TOC);
                break;
 
+       case LFUN_NEWLINE_INSERT:
+               // LaTeX restrictions (labels or empty par)
+               enable = (cur.pos() > cur.paragraph().beginOfBody());
+               break;
+
        case LFUN_WORD_DELETE_FORWARD:
        case LFUN_WORD_DELETE_BACKWARD:
        case LFUN_LINE_DELETE:
@@ -2151,9 +2152,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
        case LFUN_PARAGRAPH_UP:
        case LFUN_PARAGRAPH_DOWN:
        case LFUN_LINE_BEGIN:
-       case LFUN_LINE_BREAK:
        case LFUN_LINE_END:
-       case LFUN_NEW_LINE:
        case LFUN_CHAR_DELETE_FORWARD:
        case LFUN_DELETE_FORWARD_SKIP:
        case LFUN_CHAR_DELETE_BACKWARD: