]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView_pimpl.C
fix "make dist" target
[lyx.git] / src / BufferView_pimpl.C
index d1c70ef4ae3f56d7b4636c8d54aa2232e2ccfa2c..4dc9378059f30eba2c71126da0a9c9a243e9dc6b 100644 (file)
@@ -16,7 +16,6 @@
 #include "lyxrow.h"
 #include "LyXView.h"
 #include "commandtags.h"
-#include "lyxfunc.h"
 #include "font.h"
 #include "bufferview_funcs.h"
 #include "TextCache.h"
@@ -41,6 +40,7 @@
 #include "insets/insetref.h"
 #include "insets/insetparent.h"
 #include "insets/insetindex.h"
+#include "insets/insetinfo.h"
 #include "insets/insetinclude.h"
 #include "insets/insetcite.h"
 #include "insets/insetert.h"
@@ -54,6 +54,7 @@
 #include "insets/insettabular.h"
 #include "insets/insettheorem.h"
 #include "insets/insetcaption.h"
+#include "insets/insetfloatlist.h"
 #include "mathed/formulamacro.h"
 #include "gettext.h"
 
@@ -134,8 +135,6 @@ BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
        workarea_.workAreaKeyPress
                .connect(slot(this, &BufferView::Pimpl::workAreaKeyPress));
        
-       //screen_ = 0;
-
        cursor_timeout.timeout.connect(slot(this,
                                            &BufferView::Pimpl::cursorToggle));
        //current_scrollbar_value = 0;
@@ -179,8 +178,6 @@ void BufferView::Pimpl::buffer(Buffer * b)
        // Nuke old image
        // screen is always deleted when the buffer is changed.
        screen_.reset(0);
-       //delete screen_;
-       //screen_ = 0;
 
        // If we are closing the buffer, use the first buffer as current
        if (!buffer_) {
@@ -252,9 +249,9 @@ void BufferView::Pimpl::redraw()
 
 bool BufferView::Pimpl::fitCursor(LyXText * text)
 {
-       Assert(screen_.get());
+       lyx::Assert(screen_.get());
  
-       bool ret = screen_->FitCursor(text, bv_);
+       bool const ret = screen_->FitCursor(text, bv_);
        if (ret)
            updateScrollbar();
        return ret;
@@ -288,8 +285,7 @@ int BufferView::Pimpl::resizeCurrentBuffer()
 
        ProhibitInput(bv_);
 
-       owner_->getLyXFunc()->Dispatch(LFUN_MESSAGE,
-                                      _("Formatting document..."));
+       owner_->message(_("Formatting document..."));
 
        if (bv_->text) {
                par = bv_->text->cursor.par();
@@ -634,8 +630,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
                UpdatableInset * inset = static_cast<UpdatableInset *>(inset_hit);
                selection_possible = false;
                owner_->updateLayoutChoice();
-               owner_->getLyXFunc()->Dispatch(LFUN_MESSAGE,
-                                              inset->EditMessage());
+               owner_->message(inset->EditMessage());
                inset->InsetButtonPress(bv_, xpos, ypos, button);
                inset->Edit(bv_, xpos, ypos, button);
                return;
@@ -797,8 +792,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
                        bv_->text->SetCursorParUndo(bv_->buffer());
                }
 
-               owner_->getLyXFunc()->Dispatch(LFUN_MESSAGE,
-                                              inset_hit->EditMessage());
+               owner_->message(inset_hit->EditMessage());
 
                if (inset_hit->Editable()==Inset::HIGHLY_EDITABLE) {
                        // Highly editable inset, like math
@@ -811,73 +805,6 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
                return;
        }
 
-#ifndef NEW_INSETS
-       // check whether we want to open a float
-       if (bv_->text) {
-               bool hit = false;
-               char c = ' ';
-               if (bv_->text->cursor.pos() <
-                   bv_->text->cursor.par()->Last()) {
-                       c = bv_->text->cursor.par()->
-                               GetChar(bv_->text->cursor.pos());
-               }
-              if(!bv_->text->selection)
-               if (c == LyXParagraph::META_FOOTNOTE
-                   || c == LyXParagraph::META_MARGIN
-                   || c == LyXParagraph::META_FIG
-                   || c == LyXParagraph::META_TAB
-                   || c == LyXParagraph::META_WIDE_FIG
-                   || c == LyXParagraph::META_WIDE_TAB
-                    || c == LyXParagraph::META_ALGORITHM){
-                       hit = true;
-               } else
-                       if (bv_->text->cursor.pos() - 1 >= 0) {
-                       c = bv_->text->cursor.par()->
-                               GetChar(bv_->text->cursor.pos() - 1);
-                       if (c == LyXParagraph::META_FOOTNOTE
-                           || c == LyXParagraph::META_MARGIN
-                           || c == LyXParagraph::META_FIG
-                           || c == LyXParagraph::META_TAB
-                           || c == LyXParagraph::META_WIDE_FIG 
-                           || c == LyXParagraph::META_WIDE_TAB
-                           || c == LyXParagraph::META_ALGORITHM){
-                               // We are one step too far to the right
-                               bv_->text->CursorLeft(bv_);
-                               hit = true;
-                       }
-               }
-               if (hit == true) {
-                       bv_->toggleFloat();
-                       selection_possible = false;
-                       return;
-               }
-       }
-       // Do we want to close a float? (click on the float-label)
-       if (bv_->text->cursor.row()->par()->footnoteflag == 
-           LyXParagraph::OPEN_FOOTNOTE
-           && bv_->text->cursor.row()->previous() &&
-           bv_->text->cursor.row()->previous()->par()->
-           footnoteflag != LyXParagraph::OPEN_FOOTNOTE){
-               LyXFont font(LyXFont::ALL_SANE);
-               font.setSize(LyXFont::SIZE_FOOTNOTE);
-
-               int box_x = 20; // LYX_PAPER_MARGIN;
-               box_x += lyxfont::width(" wide-tab ", font);
-
-               unsigned int screen_first = bv_->text->first;
-
-               if (x < box_x
-                   && y + screen_first > bv_->text->cursor.y() -
-                   bv_->text->cursor.row()->baseline()
-                   && y + screen_first < bv_->text->cursor.y() -
-                   bv_->text->cursor.row()->baseline()
-                   + lyxfont::maxAscent(font) * 1.2 + lyxfont::maxDescent(font) * 1.2) {
-                       bv_->toggleFloat();
-                       selection_possible = false;
-                       return;
-               }
-       }
-#else
        // check whether we want to open a float
        if (bv_->text) {
                bool hit = false;
@@ -896,7 +823,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
                        return;
                }
        }
-#endif
+
        // Maybe we want to edit a bibitem ale970302
        if (bv_->text->cursor.par()->bibkey && x < 20 + 
            bibitemMaxWidth(bv_, textclasslist.
@@ -927,11 +854,7 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
        text->SetCursor(bv_, cursor, cursor.par(),cursor.pos(),true);
 
 
-#ifndef NEW_INSETS
-       if (cursor.pos() < cursor.par()->Last()
-#else
        if (cursor.pos() < cursor.par()->size()
-#endif
            && cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET
            && cursor.par()->GetInset(cursor.pos())
            && cursor.par()->GetInset(cursor.pos())->Editable()) {
@@ -976,7 +899,8 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
 #if 0
                        if (move_cursor && (tmpinset != bv_->theLockingInset()))
 #endif
-                               text->SetCursor(bv_, cursor.par(),cursor.pos()-1,true);
+                               text->SetCursor(bv_, cursor.par(),
+                                               cursor.pos() - 1, true);
                        x = x - start_x;
                        // The origin of an inset is on the baseline
                        y = y_tmp - (text->cursor.y()); 
@@ -1213,7 +1137,7 @@ void BufferView::Pimpl::savePosition(unsigned int i)
                                      bv_->text->cursor.pos());
        if (i > 0) {
                string const str = _("Saved bookmark") + ' ' + tostr(i);
-               owner_->getLyXFunc()->Dispatch(LFUN_MESSAGE, str);
+               owner_->message(str);
        }
 }
 
@@ -1223,7 +1147,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
        if (i >= saved_positions_num)
                return;
 
-       string fname = saved_positions[i].filename;
+       string const fname = saved_positions[i].filename;
 
        beforeChange(bv_->text);
 
@@ -1238,17 +1162,13 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
        if (!par)
                return;
 
-#ifndef NEW_INSETS
-       bv_->text->SetCursor(bv_, par,
-                            min(par->Last(), saved_positions[i].par_pos));
-#else
        bv_->text->SetCursor(bv_, par,
                             min(par->size(), saved_positions[i].par_pos));
-#endif
+
        update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
        if (i > 0) {
                string const str = _("Moved to bookmark") + ' ' + tostr(i);
-               owner_->getLyXFunc()->Dispatch(LFUN_MESSAGE, str);
+               owner_->message(str);
        }
 }
 
@@ -1432,7 +1352,7 @@ Inset * BufferView::Pimpl::getInsetByCode(Inset::Code code)
                find_if(Buffer::inset_iterator(
                        cursor.par(), cursor.pos()),
                        buffer_->inset_iterator_end(),
-                       compare_memfun(&Inset::LyxCode, code)
+                       lyx::compare_memfun(&Inset::LyxCode, code)
                        );
        return it != buffer_->inset_iterator_end() ? (*it) : 0;
 }
@@ -1467,8 +1387,7 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen)
 
                // check selected filename
                if (filename.empty()) {
-                       owner_->getLyXFunc()->Dispatch(LFUN_MESSAGE,
-                                                      _("Canceled."));
+                       owner_->message(_("Canceled."));
                        return;
                }
        }
@@ -1482,16 +1401,16 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen)
        // Inserts document
        string const s1 = _("Inserting document") + ' '
                + MakeDisplayPath(filename) + " ...";
-       owner_->getLyXFunc()->Dispatch(LFUN_MESSAGE, s1);
+       owner_->message(s1);
        bool const res = bv_->insertLyXFile(filename);
        if (res) {
                string const str = _("Document") + ' '
                        + MakeDisplayPath(filename) + ' ' + _("inserted.");
-               owner_->getLyXFunc()->Dispatch(LFUN_MESSAGE, str);
+               owner_->message(str);
        } else {
                string const str = _("Could not insert document") + ' '
                        + MakeDisplayPath(filename);
-               owner_->getLyXFunc()->Dispatch(LFUN_MESSAGE, str);
+               owner_->message(str);
        }
 }
 
@@ -1508,23 +1427,11 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                break;
 
        case LFUN_TOC_INSERT:
-       case LFUN_LOA_INSERT:
-       case LFUN_LOF_INSERT:
-       case LFUN_LOT_INSERT:
        {
                InsetCommandParams p;
-               
-               if (action == LFUN_TOC_INSERT )
-                       p.setCmdName( "tableofcontents" );
-               else if (action == LFUN_LOA_INSERT )
-                       p.setCmdName( "listofalgorithms" );
-               else if (action == LFUN_LOF_INSERT )
-                       p.setCmdName( "listoffigures" );
-               else
-                       p.setCmdName( "listoftables" );
-
-               Inset * inset = new InsetTOC( p );
-               if (!bv_->insertInset( inset, "Standard", true ) )
+               p.setCmdName("tableofcontents");
+               Inset * inset = new InsetTOC(p);
+               if (!bv_->insertInset(inset, "Standard", true))
                        delete inset;
                break;
        }
@@ -1774,7 +1681,16 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        bv_->updateInset(TEXT(bv_)->inset_owner, true);
                update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                break;
+
+       case LFUN_TRANSPOSE_CHARS:
+               update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR);
+               TEXT(bv_)->TransposeChars(*bv_);
+               if (TEXT(bv_)->inset_owner)
+                       bv_->updateInset(TEXT(bv_)->inset_owner, true);
+               update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+               break;
                
+                                         
        case LFUN_INSERT_LABEL:
                MenuInsertLabel(bv_, argument);
                break;
@@ -1834,11 +1750,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR);
                if (is_rtl)
                        TEXT(bv_)->CursorLeft(bv_, false);
-#ifndef NEW_INSETS
-               if (TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->Last()
-#else
                if (TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->size()
-#endif
                    && TEXT(bv_)->cursor.par()->GetChar(TEXT(bv_)->cursor.pos())
                    == LyXParagraph::META_INSET
                    && TEXT(bv_)->cursor.par()->GetInset(TEXT(bv_)->cursor.pos())
@@ -1847,10 +1759,10 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        owner_->getLyXFunc()->setMessage(tmpinset->EditMessage());
                        int y = 0;
                        if (is_rtl) {
-                               LyXFont font = 
+                               LyXFont const font = 
                                        TEXT(bv_)->GetFont(buffer_,
-                                                             TEXT(bv_)->cursor.par(),
-                                                             TEXT(bv_)->cursor.pos()); 
+                                                          TEXT(bv_)->cursor.par(),
+                                                          TEXT(bv_)->cursor.pos());    
                                y = tmpinset->descent(bv_,font);
                        }
                        tmpinset->Edit(bv_, 0, y, 0);
@@ -1876,11 +1788,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                if (!is_rtl)
                        TEXT(bv_)->CursorLeft(bv_, false);
                if ((is_rtl || cur != TEXT(bv_)->cursor) && // only if really moved!
-#ifndef NEW_INSETS
-                   TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->Last() &&
-#else
                    TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->size() &&
-#endif
                    (TEXT(bv_)->cursor.par()->GetChar(TEXT(bv_)->cursor.pos()) ==
                     LyXParagraph::META_INSET) &&
                    TEXT(bv_)->cursor.par()->GetInset(TEXT(bv_)->cursor.pos()) &&
@@ -2198,13 +2106,16 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                
        case LFUN_PROTECTEDSPACE:
        {
-               LyXLayout const & style =
-                       textclasslist.Style(buffer_->params.textclass,
-                                           TEXT(bv_)->cursor.par()->GetLayout());
+               LyXLayout const & style = textclasslist
+                       .Style(buffer_->params.textclass,
+                              TEXT(bv_)->cursor.par()->GetLayout());
 
                if (style.free_spacing) {
                        TEXT(bv_)->InsertChar(bv_, ' ');
-                       update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+                       update(TEXT(bv_),
+                              BufferView::SELECT
+                              | BufferView::FITCUR
+                              | BufferView::CHANGE);
                } else {
                        bv_->protectedBlank(TEXT(bv_));
                }
@@ -2215,12 +2126,14 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        case LFUN_SETMARK:
                if (TEXT(bv_)->mark_set) {
                        beforeChange(TEXT(bv_));
-                       update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR);
+                       update(TEXT(bv_),
+                              BufferView::SELECT|BufferView::FITCUR);
                        owner_->getLyXFunc()->setMessage(N_("Mark removed"));
                } else {
                        beforeChange(TEXT(bv_));
                        TEXT(bv_)->mark_set = 1;
-                       update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR);
+                       update(TEXT(bv_),
+                              BufferView::SELECT|BufferView::FITCUR);
                        owner_->getLyXFunc()->setMessage(N_("Mark set"));
                }
                TEXT(bv_)->sel_cursor = TEXT(bv_)->cursor;
@@ -2232,7 +2145,9 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        TEXT(bv_)->sel_cursor = 
                                TEXT(bv_)->cursor;
                        update(TEXT(bv_),
-                              BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+                              BufferView::SELECT
+                              | BufferView::FITCUR
+                              | BufferView::CHANGE);
                        // It is possible to make it a lot faster still
                        // just comment out the line below...
                        showCursor();
@@ -2251,11 +2166,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                LyXCursor cursor = TEXT(bv_)->cursor;
 
                if (!TEXT(bv_)->selection) {
-#ifndef NEW_INSETS
-                       if (cursor.pos() == cursor.par()->Last()) {
-#else
                        if (cursor.pos() == cursor.par()->size()) {
-#endif
                                TEXT(bv_)->CursorRight(bv_);
                                cursor = TEXT(bv_)->cursor;
                                if (cursor.pos() == 0
@@ -2655,7 +2566,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        new InsetTabular(*buffer_, r, c);
                bool rtl =
                        TEXT(bv_)->real_current_font.isRightToLeft();
-               if (!bv_->open_new_inset(new_inset, rtl))
+               if (!open_new_inset(new_inset, rtl))
                        delete new_inset;
        }
        break;
@@ -2734,7 +2645,18 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        case LFUN_HUNG_UMLAUT:
        case LFUN_CIRCLE:
        case LFUN_OGONEK:
-               owner_->getLyXFunc()->handleKeyFunc(action);
+               if (argument.empty()) {
+                       // As always...
+                       owner_->getLyXFunc()->handleKeyFunc(action);
+               } else {
+                       owner_->getLyXFunc()->handleKeyFunc(action);
+                       owner_->getIntl()->getTrans()
+                               .TranslateAndInsert(argument[0], TEXT(bv_));
+                       update(TEXT(bv_),
+                              BufferView::SELECT
+                              | BufferView::FITCUR
+                              | BufferView::CHANGE);
+               }
                break;
        
        // --- insert characters ----------------------------------------
@@ -2743,8 +2665,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        case LFUN_INSERT_MATRIX:
        {          
                if (available()) { 
-                       if (bv_->open_new_inset(new InsetFormula(false)))
-                       {
+                       if (open_new_inset(new InsetFormula(false))) {
                                bv_->theLockingInset()
                                        ->LocalDispatch(bv_, action, argument);
                        }
@@ -2758,7 +2679,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        break;
  
                InsetFormula * f = new InsetFormula(true);
-               bv_->open_new_inset(f);
+               open_new_inset(f);
                f->LocalDispatch(bv_, LFUN_INSERT_MATH, argument);
        }
        break;
@@ -2766,7 +2687,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        case LFUN_MATH_DISPLAY:
        {
                if (available())
-                       bv_->open_new_inset(new InsetFormula(true));
+                       open_new_inset(new InsetFormula(true));
                break;
        }
                    
@@ -2779,7 +2700,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        else {
                                string const s1 = token(s, ' ', 1);
                                int const na = s1.empty() ? 0 : lyx::atoi(s1);
-                               bv_->open_new_inset(new InsetFormulaMacro(token(s, ' ', 0), na));
+                               open_new_inset(new InsetFormulaMacro(token(s, ' ', 0), na));
                        }
                }
        }
@@ -2788,7 +2709,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        case LFUN_MATH_MODE:   // Open or create a math inset
        {               
                if (available())
-                       bv_->open_new_inset(new InsetFormula);
+                       open_new_inset(new InsetFormula);
                owner_->getLyXFunc()->setMessage(N_("Math editor mode"));
        }
        break;
@@ -2951,8 +2872,17 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        }
        break; 
 
+       case LFUN_FLOAT_LIST:
+       {
+               // We should check the argument for validity. (Lgb)
+               Inset * inset = new InsetFloatList(argument);
+               if (!bv_->insertInset(inset, "Standard", true))
+                       delete inset;
+       }
+       break;
+       
        case LFUN_INSERT_NOTE:
-               bv_->insertNote();
+               insertNote();
                break;
 
        case LFUN_SELFINSERT:
@@ -3002,61 +2932,39 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        break;
 
        case LFUN_UNKNOWN_ACTION:
-       {
-               if (!buffer_) {
-                       owner_->getLyXFunc()->setErrorMessage(N_("No document open"));
-                       break;
-               }
-
-               if (buffer_->isReadonly()) {
-                       owner_->getLyXFunc()->setErrorMessage(N_("Document is read only"));
-                       break;
-               }
-               if (!argument.empty()) {
-                       /* Automatically delete the currently selected
-                        * text and replace it with what is being
-                        * typed in now. Depends on lyxrc settings
-                        * "auto_region_delete", which defaults to
-                        * true (on). */
-               
-                       if (lyxrc.auto_region_delete) {
-                               if (TEXT(bv_)->selection){
-                                       TEXT(bv_)->CutSelection(bv_, false);
-                                       update(TEXT(bv_),
-                                              BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-                               }
-                       }
-                       
-                       beforeChange(TEXT(bv_));
-                       LyXFont const old_font(TEXT(bv_)->real_current_font);
-                       for (string::size_type i = 0;
-                            i < argument.length(); ++i) {
-                               if (greek_kb_flag) {
-                                       if (!math_insert_greek(bv_, argument[i]))
-                                               owner_->getIntl()->getTrans().TranslateAndInsert(argument[i], TEXT(bv_));
-                               } else
-                                       owner_->getIntl()->getTrans().TranslateAndInsert(argument[i], TEXT(bv_));
-                       }
-
-                       update(TEXT(bv_),BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-
-                       TEXT(bv_)->sel_cursor = TEXT(bv_)->cursor;
-                       moveCursorUpdate(false);
-
-                       // real_current_font.number can change so we need to
-                       // update the minibuffer
-                       if (old_font != TEXT(bv_)->real_current_font)
-                               owner_->showState();
-               } else {
-                       // if we don't have an argument there was something
-                       // strange going on so we just tell this to someone!
-                       owner_->getLyXFunc()->setErrorMessage(N_("No argument given"));
-               }
+               owner_->getLyXFunc()->setErrorMessage(N_("Unknow function!"));
                break;
-       }
+       
        default:
                return false;
        } // end of switch
 
        return true;
 }
+
+
+void BufferView::Pimpl::insertNote()
+{
+       InsetInfo * new_inset = new InsetInfo();
+       bv_->insertInset(new_inset);
+       new_inset->Edit(bv_, 0, 0, 0);
+}
+
+
+// Open and lock an updatable inset
+bool BufferView::Pimpl::open_new_inset(UpdatableInset * new_inset, bool behind)
+{
+       beforeChange(TEXT(bv_));
+       TEXT(bv_)->FinishUndo();
+       if (!bv_->insertInset(new_inset)) {
+               delete new_inset;
+               return false;
+       }
+       if (behind) {
+               LyXFont & font = bv_->getLyXText()->real_current_font;
+               new_inset->Edit(bv_, new_inset->width(bv_, font), 0, 0);
+       } else
+               new_inset->Edit(bv_, 0, 0, 0);
+       return true;
+}
+