+ 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::specialChar(InsetSpecialChar::Kind kind)
+{
+ if (available()) {
+ LyXText * lt = bv_->getLyXText();
+
+ hideCursor();
+ update(lt, BufferView::SELECT|BufferView::FITCUR);
+ InsetSpecialChar * new_inset =
+ new InsetSpecialChar(kind);
+ if (!insertInset(new_inset))
+ delete new_inset;
+ else
+ updateInset(new_inset, true);
+ }
+}
+
+
+void BufferView::Pimpl::smartQuote()
+{
+ LyXText const * lt = bv_->getLyXText();
+ Paragraph const * par = lt->cursor.par();
+ pos_type pos = lt->cursor.pos();
+ char c;
+
+ if (!pos
+ || (par->isInset(pos - 1)
+ && par->getInset(pos - 1)->isSpace()))
+ c = ' ';
+ else
+ c = par->getChar(pos - 1);
+
+
+ hideCursor();
+
+ LyXLayout const & style =
+ textclasslist[bv_->buffer()->params.textclass][par->layout()];
+
+ if (style.pass_thru ||
+ (!insertInset(new InsetQuotes(c, bv_->buffer()->params))))
+ bv_->owner()->getLyXFunc()->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);