]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
Cmake build: Creating a define for a header file found
[lyx.git] / src / Text3.cpp
index cdc1bd488bc4d0c45f7fe2ae55ccd534050f0b07..fad451c7288007d612f4c4bca479e7e5b328a7b8 100644 (file)
@@ -940,15 +940,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        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;
+               cap::replaceSelection(cur);
+               cur.recordUndo();
                cur.insert(new InsetNewline(inp));
                cur.posForward();
                moveCursor(cur, false);
@@ -1100,7 +1097,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        /*
                        Paragraph & par = pars_[cur.pit()];
                        if (inset->lyxCode() == LABEL_CODE
-                               && par.layout().labeltype == LABEL_COUNTER) {
+                               && !par.layout().counter.empty() {
                                // Go to the end of the paragraph
                                // Warning: Because of Change-Tracking, the last
                                // position is 'size()' and not 'size()-1':
@@ -1391,21 +1388,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_ENVIRONMENT_SPLIT: {
                Paragraph const & para = cur.paragraph();
                docstring const layout = para.layout().name();
-               if (cur.pos() > 0) {
-                       FuncRequest cmd(LFUN_PARAGRAPH_BREAK);
-                       lyx::dispatch(cmd);
-               }
+               if (cur.pos() > 0)
+                       lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK));
                bool const morecont = cur.lastpos() > cur.pos();
-               FuncRequest cmd2(LFUN_LAYOUT, "Separator");
-               lyx::dispatch(cmd2);
-               FuncRequest cmd3(LFUN_PARAGRAPH_BREAK, "inverse");
-               lyx::dispatch(cmd3);
-               if (morecont) {
-                       FuncRequest cmd4(LFUN_DOWN);
-                       lyx::dispatch(cmd4);
-               }
-               FuncRequest cmd5(LFUN_LAYOUT, layout);
-               lyx::dispatch(cmd5);
+               lyx::dispatch(FuncRequest(LFUN_LAYOUT, "Separator"));
+               lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK, "inverse"));
+               if (morecont) 
+                       lyx::dispatch(FuncRequest(LFUN_DOWN));
+               lyx::dispatch(FuncRequest(LFUN_LAYOUT, layout));
 
                break;
        }
@@ -1454,14 +1444,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_QUOTE_INSERT: {
-               // this avoids a double undo
-               // FIXME: should not be needed, ideally
-               if (!cur.selection())
-                       cur.recordUndo();
                cap::replaceSelection(cur);
+               cur.recordUndo();
 
                Paragraph const & par = cur.paragraph();
                pos_type pos = cur.pos();
+               // Ignore deleted text before cursor
+               while (pos > 0 && par.isDeleted(pos - 1))
+                       --pos;
 
                BufferParams const & bufparams = bv->buffer().params();
                bool const hebrew = 
@@ -2535,11 +2525,21 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                }
                break;
        }
-       case LFUN_CAPTION_INSERT:
+       case LFUN_CAPTION_INSERT: {
                code = CAPTION_CODE;
-               // not allowed in description items
-               enable = !inDescriptionItem(cur);
+               bool varia = true;
+               if (cur.depth() > 0) {
+                       if (&cur[cur.depth() - 1].inset()
+                           && !cur[cur.depth() - 1].inset().allowsCaptionVariation())
+                               varia = false;
+               }
+               string arg = cmd.getArg(0);
+               // not allowed in description items,
+               // and in specific insets
+               enable = !inDescriptionItem(cur)
+                       && (varia || arg.empty() || arg == "Standard");
                break;
+       }
        case LFUN_NOTE_INSERT:
                code = NOTE_CODE;
                // in commands (sections etc.) and description items,
@@ -2887,12 +2887,12 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                break;
        
        case LFUN_ENVIRONMENT_SPLIT: {
-               if (!cur.buffer()->params().documentClass().hasLayout(from_ascii("Separator"))
-                   || !cur.paragraph().layout().isEnvironment()) {
-                       enable = false;
+               if (cur.paragraph().layout().isEnvironment()
+                   && cur.buffer()->params().documentClass().hasLayout(from_ascii("Separator"))) {
+                       enable = true;
                        break;
                }
-               enable = true;
+               enable = false;
                break;
        }