+ owner_->getLyXFunc()->setErrorMessage(N_("Unknown function!"));
+ break;
+
+ default:
+ return false;
+ } // end of switch
+
+ return true;
+}
+
+
+void BufferView::Pimpl::newline()
+{
+ if (available()) {
+ LyXText * lt = bv_->getLyXText();
+ hideCursor();
+ update(lt,
+ BufferView::SELECT
+ | BufferView::FITCUR);
+ lt->insertChar(bv_, Paragraph::META_NEWLINE);
+ update(lt,
+ BufferView::SELECT
+ | BufferView::FITCUR
+ | BufferView::CHANGE);
+ }
+}
+
+
+void BufferView::Pimpl::hfill()
+{
+ if (available()) {
+ LyXText * lt = bv_->getLyXText();
+ hideCursor();
+ update(lt,
+ BufferView::SELECT
+ | BufferView::FITCUR);
+ lt->insertChar(bv_, Paragraph::META_HFILL);
+ update(lt,
+ BufferView::SELECT
+ | BufferView::FITCUR
+ | BufferView::CHANGE);
+ }
+}
+
+
+void BufferView::Pimpl::protectedBlank(LyXText * lt)
+{
+ if (available()) {
+ hideCursor();
+ update(lt, BufferView::SELECT|BufferView::FITCUR);
+ InsetSpecialChar * new_inset =
+ new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
+#ifdef WITH_WARNINGS
+#warning Why is this code different from specialChar() below? (JMarc)
+// the code in specialChar is a generic version of what used to exist
+// for other special chars. I did not merge this case because of the
+// call to updateInset(), but what does it do?
+#endif
+ if (!insertInset(new_inset))
+ delete new_inset;
+ else
+ updateInset(new_inset, true);
+ }
+}
+
+
+void BufferView::Pimpl::specialChar(InsetSpecialChar::Kind kind)
+{
+ if (available()) {
+ LyXText * lt = bv_->getLyXText();
+
+ hideCursor();
+ update(lt, BufferView::SELECT|BufferView::FITCUR);
+ InsetSpecialChar * new_inset =
+ new InsetSpecialChar(kind);
+ insertInset(new_inset);
+ // Ok, what happens here if we are unable to insert
+ // the inset? Leak it?
+ }
+}
+
+
+void BufferView::Pimpl::smartQuote()
+{
+ char c;
+ LyXText * lt = bv_->getLyXText();
+
+ if (lt->cursor.pos())
+ c = lt->cursor.par()->getChar(lt->cursor.pos() - 1);
+ else
+ c = ' ';
+
+ hideCursor();
+
+ LyXLayout const & style = textclasslist.Style(
+ bv_->buffer()->params.textclass,
+ lt->cursor.par()->getLayout());
+
+ if (style.pass_thru ||
+ (!insertInset(new InsetQuotes(c, bv_->buffer()->params))))
+ Dispatch(LFUN_SELFINSERT, "\"");
+}
+
+
+void BufferView::Pimpl::insertAndEditInset(Inset * inset)
+{
+ if (insertInset(inset))
+ inset->edit(bv_);
+ else
+ delete inset;
+}
+
+
+// Open and lock an updatable inset
+bool BufferView::Pimpl::open_new_inset(UpdatableInset * new_inset, bool behind)
+{
+ LyXText * lt = bv_->getLyXText();
+
+ beforeChange(lt);
+ finishUndo();
+ if (!insertInset(new_inset)) {
+ delete new_inset;
+ return false;
+ }
+ new_inset->edit(bv_, !behind);
+ return true;
+}
+
+
+bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout)
+{
+ // if we are in a locking inset we should try to insert the
+ // inset there otherwise this is a illegal function now
+ if (bv_->theLockingInset()) {
+ if (bv_->theLockingInset()->insetAllowed(inset))
+ return bv_->theLockingInset()->insertInset(bv_, inset);
+ return false;
+ }
+
+ // not quite sure if we want this...
+ setCursorParUndo(bv_);
+ freezeUndo();
+
+ beforeChange(bv_->text);
+ if (!lout.empty()) {
+ update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
+ bv_->text->breakParagraph(bv_);
+ update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+
+ if (bv_->text->cursor.par()->size()) {
+ bv_->text->cursorLeft(bv_);
+
+ bv_->text->breakParagraph(bv_);
+ update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);