]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
Patch from Peter.
[lyx.git] / src / Text3.cpp
index c7392600e161d6e8f1cb2701c6dd99f53338af26..dc0025fd097ac5c042e200dcafd26ac15bbea591 100644 (file)
@@ -335,7 +335,7 @@ static void outline(OutlineOp mode, Cursor & cur)
 
        // Do we need to set insets' buffer_ members, because we copied
        // some stuff? We'll assume we do and reset it otherwise.
-       bool setBuffers = true;
+       bool set_buffers = true;
 
        switch (mode) {
                case OutlineUp: {
@@ -406,7 +406,7 @@ static void outline(OutlineOp mode, Cursor & cur)
                                        }
                                }
                        }
-                       setBuffers = false;
+                       set_buffers = false;
                        break;
                }
                case OutlineOut: {
@@ -426,11 +426,11 @@ static void outline(OutlineOp mode, Cursor & cur)
                                        }
                                }
                        }
-                       setBuffers = false;
+                       set_buffers = false;
                        break;
                }
        }
-       if (setBuffers)
+       if (set_buffers)
                // FIXME This only really needs doing for the newly introduced 
                // paragraphs. Something like:
                //      pit_type const numpars = distance(start, finish);
@@ -607,6 +607,19 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                && cur.boundary() == oldBoundary) {
                        cur.undispatched();
                        cmd = FuncRequest(LFUN_FINISHED_FORWARD);
+               
+                       // we will probably be moving out the inset, so we should execute
+                       // the depm-mechanism, but only when the cursor has a place to 
+                       // go outside this inset, i.e. in a slice above.
+                       if (cur.depth() > 1 && cur.pos() == cur.lastpos() 
+                                 && cur.pit() == cur.lastpit()) {
+                               // The cursor hasn't changed yet. To give the 
+                               // DEPM the possibility of doing something we must
+                               // provide it with two different cursors.
+                               Cursor dummy = cur;
+                               dummy.pos() = dummy.pit() = 0;
+                               cur.bv().checkDepm(dummy, cur);
+                       }
                }
                break;
 
@@ -620,6 +633,19 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        && cur.boundary() == oldBoundary) {
                        cur.undispatched();
                        cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
+
+                       // we will probably be moving out the inset, so we should execute
+                       // the depm-mechanism, but only when the cursor has a place to 
+                       // go outside this inset, i.e. in a slice above.
+                       if (cur.depth() > 1 && cur.pos() == 0 && cur.pit() == 0) {
+                               // The cursor hasn't changed yet. To give the 
+                               // DEPM the possibility of doing something we must
+                               // provide it with two different cursors.
+                               Cursor dummy = cur;
+                               dummy.pos() = cur.lastpos();
+                               dummy.pit() = cur.lastpit();
+                               cur.bv().checkDepm(dummy, cur);
+                       }
                }
                break;
 
@@ -1497,6 +1523,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                }
                if (!inset)
                        break;
+               cur.recordUndo();
                insertInset(cur, inset);
                cur.posForward();
                break;
@@ -2071,8 +2098,11 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
        case LFUN_DIALOG_SHOW_NEW_INSET:
                if (cmd.argument() == "bibitem")
                        code = BIBITEM_CODE;
-               else if (cmd.argument() == "bibtex")
+               else if (cmd.argument() == "bibtex") {
                        code = BIBTEX_CODE;
+                       // not allowed in description items
+                       enable = !inDescriptionItem(cur);
+               }
                else if (cmd.argument() == "box")
                        code = BOX_CODE;
                else if (cmd.argument() == "branch")
@@ -2147,6 +2177,8 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                break;
        case LFUN_FLOAT_LIST_INSERT:
                code = FLOAT_LIST_CODE;
+               // not allowed in description items
+               enable = !inDescriptionItem(cur);
                break;
        case LFUN_CAPTION_INSERT:
                code = CAPTION_CODE;
@@ -2201,6 +2233,8 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                break;
        case LFUN_INDEX_PRINT:
                code = INDEX_PRINT_CODE;
+               // not allowed in description items
+               enable = !inDescriptionItem(cur);
                break;
        case LFUN_NOMENCL_INSERT:
                if (cur.selIsMultiCell() || cur.selIsMultiLine()) {
@@ -2211,9 +2245,13 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                break;
        case LFUN_NOMENCL_PRINT:
                code = NOMENCL_PRINT_CODE;
+               // not allowed in description items
+               enable = !inDescriptionItem(cur);
                break;
        case LFUN_TOC_INSERT:
                code = TOC_CODE;
+               // not allowed in description items
+               enable = !inDescriptionItem(cur);
                break;
        case LFUN_HYPERLINK_INSERT:
                if (cur.selIsMultiCell() || cur.selIsMultiLine()) {