two bug fixes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8401 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2004-02-04 11:23:25 +00:00
parent ccd12088c5
commit 281047c2bf
8 changed files with 28 additions and 55 deletions

View File

@ -303,33 +303,6 @@ void BufferView::setCursorFromRow(int row)
}
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();

View File

@ -140,10 +140,6 @@ public:
/// 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);

View File

@ -1080,7 +1080,23 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
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;

View File

@ -42,15 +42,6 @@ InsetFootlike::InsetFootlike(InsetFootlike const & in)
}
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";

View File

@ -24,8 +24,6 @@ public:
///
InsetFootlike(InsetFootlike const &);
///
void metrics(MetricsInfo &, Dimension &) const;
///
void write(Buffer const & buf, std::ostream & os) const;
///
bool insetAllowed(InsetOld::Code) const;

View File

@ -1328,7 +1328,7 @@ namespace {
bool openNewInset(LCursor & cur, InsetBase * inset)
{
cur.bv().insertInset(inset);
cur.bv().getLyXText()->insertInset(inset);
inset->edit(cur, true);
return true;
}

View File

@ -291,7 +291,7 @@ void LyXText::setLayout(string const & layout)
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;

View File

@ -398,14 +398,13 @@ namespace {
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);
@ -417,7 +416,7 @@ void doInsertInset(BufferView * bv, FuncRequest const & 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)
@ -863,7 +862,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
case LFUN_INSET_INSERT: {
InsetBase * inset = createInset(bv, cmd);
if (inset)
bv->insertInset(inset);
insertInset(inset);
break;
}
@ -884,7 +883,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
if (cursorPar()->layout()->free_spacing)
insertChar(' ');
else
doInsertInset(bv, cmd, false, false);
doInsertInset(this, bv, cmd, false, false);
moveCursor(cur, false);
break;
@ -1108,7 +1107,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
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;
@ -1357,12 +1356,12 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
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:
@ -1371,7 +1370,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
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: