}
-void BufferView::insertInset(InsetBase * inset, string const & lout)
-{
- // not quite sure if we want this...
- text()->recUndo(text()->cursor().par());
- freezeUndo();
-
- cursor().clearSelection();
- if (!lout.empty()) {
- text()->breakParagraph(buffer()->paragraphs());
-
- if (!text()->cursorPar()->empty()) {
- text()->cursorLeft(true);
- text()->breakParagraph(buffer()->paragraphs());
- }
-
- string lres = lout;
- LyXTextClass const & tclass = buffer()->params().getLyXTextClass();
- bool hasLayout = tclass.hasLayout(lres);
-
- text()->setLayout(hasLayout ? lres : tclass.defaultLayoutName());
- text()->setParagraph(Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
- }
- cursor().innerText()->insertInset(inset);
- unFreezeUndo();
-}
-
-
void BufferView::gotoLabel(string const & label)
{
for (Buffer::inset_iterator it = buffer()->inset_iterator_begin();
/// set the cursor based on the given TeX source row
void setCursorFromRow(int row);
- /// Insert an inset into the buffer, in a layout of lout.
- void insertInset(InsetBase * inset,
- std::string const & lout = std::string());
-
/// Inserts a lyx file at cursor position. return false if it fails
bool insertLyXFile(std::string const & file);
case LFUN_FLOAT_LIST:
if (tclass.floats().typeExist(cmd.argument)) {
InsetBase * inset = new InsetFloatList(cmd.argument);
- bv_->insertInset(inset, tclass.defaultLayoutName());
+
+ // not quite sure if we want this...
+ bv_->text()->recUndo(bv_->text()->cursor().par());
+ freezeUndo();
+
+ cur.clearSelection();
+ bv_->text()->breakParagraph(bv_->buffer()->paragraphs());
+
+ if (!bv_->text()->cursorPar()->empty()) {
+ bv_->text()->cursorLeft(true);
+ bv_->text()->breakParagraph(bv_->buffer()->paragraphs());
+ }
+
+ bv_->text()->setLayout(tclass.defaultLayoutName());
+ bv_->text()->setParagraph(Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
+ bv_->getLyXText()->insertInset(inset);
+ unFreezeUndo();
} else {
lyxerr << "Non-existent float type: "
<< cmd.argument << endl;
}
-void InsetFootlike::metrics(MetricsInfo & mi, Dimension & dim) const
-{
- InsetCollapsable::metrics(mi, dim);
- if (isOpen())
- dim.wid = mi.base.textwidth;
- dim_ = dim;
-}
-
-
void InsetFootlike::write(Buffer const & buf, ostream & os) const
{
os << getInsetName() << "\n";
///
InsetFootlike(InsetFootlike const &);
///
- void metrics(MetricsInfo &, Dimension &) const;
- ///
void write(Buffer const & buf, std::ostream & os) const;
///
bool insetAllowed(InsetOld::Code) const;
bool openNewInset(LCursor & cur, InsetBase * inset)
{
- cur.bv().insertInset(inset);
+ cur.bv().getLyXText()->insertInset(inset);
inset->edit(cur, true);
return true;
}
bv()->owner()->dispatch(FuncRequest(LFUN_ENDSEL));
bv()->owner()->dispatch(FuncRequest(LFUN_CUT));
InsetBase * inset = new InsetEnvironment(params, layout);
- bv()->insertInset(inset);
+ insertInset(inset);
//inset->edit(bv());
//bv()->owner()->dispatch(FuncRequest(LFUN_PASTE));
return;
void specialChar(LyXText * text, BufferView * bv, InsetSpecialChar::Kind kind)
{
bv->update();
- InsetSpecialChar * new_inset = new InsetSpecialChar(kind);
replaceSelection(text);
- bv->insertInset(new_inset);
+ text->insertInset(new InsetSpecialChar(kind));
bv->update();
}
-void doInsertInset(BufferView * bv, FuncRequest const & cmd,
+void doInsertInset(LyXText * text, BufferView * bv, FuncRequest const & cmd,
bool edit, bool pastesel)
{
InsetBase * inset = createInset(bv, cmd);
bv->owner()->dispatch(FuncRequest(LFUN_CUT));
gotsel = true;
}
- bv->insertInset(inset);
+ text->insertInset(inset);
if (edit)
inset->edit(bv->cursor(), true);
if (gotsel && pastesel)
case LFUN_INSET_INSERT: {
InsetBase * inset = createInset(bv, cmd);
if (inset)
- bv->insertInset(inset);
+ insertInset(inset);
break;
}
if (cursorPar()->layout()->free_spacing)
insertChar(' ');
else
- doInsertInset(bv, cmd, false, false);
+ doInsertInset(this, bv, cmd, false, false);
moveCursor(cur, false);
break;
BufferParams const & bufparams = bv->buffer()->params();
if (style->pass_thru ||
pit->getFontSettings(bufparams,pos).language()->lang() == "hebrew")
- bv->insertInset(new InsetQuotes(c, bufparams));
+ insertInset(new InsetQuotes(c, bufparams));
else
bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
break;
case LFUN_ENVIRONMENT_INSERT:
// Open the inset, and move the current selection
// inside it.
- doInsertInset(bv, cmd, true, true);
+ doInsertInset(this, bv, cmd, true, true);
break;
case LFUN_INDEX_INSERT:
// Just open the inset
- doInsertInset(bv, cmd, true, false);
+ doInsertInset(this, bv, cmd, true, false);
break;
case LFUN_INDEX_PRINT:
case LFUN_INSERT_LINE:
case LFUN_INSERT_PAGEBREAK:
// do nothing fancy
- doInsertInset(bv, cmd, false, false);
+ doInsertInset(this, bv, cmd, false, false);
break;
case LFUN_DEPTH_MIN: