mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
* BufferView.[Ch] (insertInset):
* BufferView_pimpl.[Ch] (insertInset): remove unneeded return value * text2.C: * text3.C: adjust git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8400 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
982344dc61
commit
ccd12088c5
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "bufferlist.h"
|
#include "bufferlist.h"
|
||||||
|
#include "bufferparams.h"
|
||||||
#include "BufferView_pimpl.h"
|
#include "BufferView_pimpl.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "funcrequest.h"
|
#include "funcrequest.h"
|
||||||
@ -26,6 +27,7 @@
|
|||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "lyxlayout.h"
|
#include "lyxlayout.h"
|
||||||
#include "lyxtext.h"
|
#include "lyxtext.h"
|
||||||
|
#include "lyxtextclass.h"
|
||||||
#include "paragraph.h"
|
#include "paragraph.h"
|
||||||
#include "paragraph_funcs.h"
|
#include "paragraph_funcs.h"
|
||||||
#include "PosIterator.h"
|
#include "PosIterator.h"
|
||||||
@ -301,9 +303,30 @@ void BufferView::setCursorFromRow(int row)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool BufferView::insertInset(InsetBase * inset, string const & lout)
|
void BufferView::insertInset(InsetBase * inset, string const & lout)
|
||||||
{
|
{
|
||||||
return pimpl_->insertInset(inset, 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,11 +140,9 @@ public:
|
|||||||
/// set the cursor based on the given TeX source row
|
/// set the cursor based on the given TeX source row
|
||||||
void setCursorFromRow(int row);
|
void setCursorFromRow(int row);
|
||||||
|
|
||||||
/**
|
/// Insert an inset into the buffer, in a layout of lout.
|
||||||
* Insert an inset into the buffer.
|
void insertInset(InsetBase * inset,
|
||||||
* Place it in a layout of lout,
|
std::string const & lout = std::string());
|
||||||
*/
|
|
||||||
bool insertInset(InsetBase * inset, std::string const & lout = std::string());
|
|
||||||
|
|
||||||
/// Inserts a lyx file at cursor position. return false if it fails
|
/// Inserts a lyx file at cursor position. return false if it fails
|
||||||
bool insertLyXFile(std::string const & file);
|
bool insertLyXFile(std::string const & file);
|
||||||
|
@ -1077,20 +1077,10 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_INSET_INSERT: {
|
|
||||||
// Same as above.
|
|
||||||
BOOST_ASSERT(false);
|
|
||||||
InsetBase * inset = createInset(bv_, cmd);
|
|
||||||
if (!inset || !insertInset(inset))
|
|
||||||
delete inset;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case LFUN_FLOAT_LIST:
|
case LFUN_FLOAT_LIST:
|
||||||
if (tclass.floats().typeExist(cmd.argument)) {
|
if (tclass.floats().typeExist(cmd.argument)) {
|
||||||
InsetBase * inset = new InsetFloatList(cmd.argument);
|
InsetBase * inset = new InsetFloatList(cmd.argument);
|
||||||
if (!insertInset(inset, tclass.defaultLayoutName()))
|
bv_->insertInset(inset, tclass.defaultLayoutName());
|
||||||
delete inset;
|
|
||||||
} else {
|
} else {
|
||||||
lyxerr << "Non-existent float type: "
|
lyxerr << "Non-existent float type: "
|
||||||
<< cmd.argument << endl;
|
<< cmd.argument << endl;
|
||||||
@ -1218,34 +1208,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool BufferView::Pimpl::insertInset(InsetBase * inset, string const & lout)
|
|
||||||
{
|
|
||||||
// not quite sure if we want this...
|
|
||||||
bv_->text()->recUndo(bv_->text()->cursor().par());
|
|
||||||
freezeUndo();
|
|
||||||
|
|
||||||
bv_->cursor().clearSelection();
|
|
||||||
if (!lout.empty()) {
|
|
||||||
bv_->text()->breakParagraph(bv_->buffer()->paragraphs());
|
|
||||||
|
|
||||||
if (!bv_->text()->cursorPar()->empty()) {
|
|
||||||
bv_->text()->cursorLeft(bv_);
|
|
||||||
bv_->text()->breakParagraph(bv_->buffer()->paragraphs());
|
|
||||||
}
|
|
||||||
|
|
||||||
string lres = lout;
|
|
||||||
LyXTextClass const & tclass = buffer_->params().getLyXTextClass();
|
|
||||||
bool hasLayout = tclass.hasLayout(lres);
|
|
||||||
|
|
||||||
bv_->text()->setLayout(hasLayout ? lres : tclass.defaultLayoutName());
|
|
||||||
bv_->text()->setParagraph(Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
|
|
||||||
}
|
|
||||||
bv_->cursor().innerText()->insertInset(inset);
|
|
||||||
unFreezeUndo();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool BufferView::Pimpl::ChangeInsets(InsetBase::Code code,
|
bool BufferView::Pimpl::ChangeInsets(InsetBase::Code code,
|
||||||
string const & from, string const & to)
|
string const & from, string const & to)
|
||||||
{
|
{
|
||||||
|
@ -101,8 +101,6 @@ struct BufferView::Pimpl : public boost::signals::trackable {
|
|||||||
void switchKeyMap();
|
void switchKeyMap();
|
||||||
///
|
///
|
||||||
void center();
|
void center();
|
||||||
///
|
|
||||||
bool insertInset(InsetBase * inset, std::string const & lout = std::string());
|
|
||||||
/// a function should be executed from the workarea
|
/// a function should be executed from the workarea
|
||||||
bool workAreaDispatch(FuncRequest const & ev);
|
bool workAreaDispatch(FuncRequest const & ev);
|
||||||
/// a function should be executed
|
/// a function should be executed
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
|
|
||||||
|
2004-02-04 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
* BufferView.[Ch] (insertInset):
|
||||||
|
* BufferView_pimpl.[Ch] (insertInset): remove unneeded return value
|
||||||
|
|
||||||
|
* text2.C:
|
||||||
|
* text3.C: adjust
|
||||||
|
|
||||||
2004-02-03 Alfredo Braunstein <abraunst@lyx.org>
|
2004-02-03 Alfredo Braunstein <abraunst@lyx.org>
|
||||||
|
|
||||||
* BufferView_pimpl.C (dispatch): remove call to LCursor::dispatch
|
* BufferView_pimpl.C (dispatch): remove call to LCursor::dispatch
|
||||||
|
@ -1328,10 +1328,7 @@ namespace {
|
|||||||
|
|
||||||
bool openNewInset(LCursor & cur, InsetBase * inset)
|
bool openNewInset(LCursor & cur, InsetBase * inset)
|
||||||
{
|
{
|
||||||
if (!cur.bv().insertInset(inset)) {
|
cur.bv().insertInset(inset);
|
||||||
delete inset;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
inset->edit(cur, true);
|
inset->edit(cur, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -291,11 +291,9 @@ void LyXText::setLayout(string const & layout)
|
|||||||
bv()->owner()->dispatch(FuncRequest(LFUN_ENDSEL));
|
bv()->owner()->dispatch(FuncRequest(LFUN_ENDSEL));
|
||||||
bv()->owner()->dispatch(FuncRequest(LFUN_CUT));
|
bv()->owner()->dispatch(FuncRequest(LFUN_CUT));
|
||||||
InsetBase * inset = new InsetEnvironment(params, layout);
|
InsetBase * inset = new InsetEnvironment(params, layout);
|
||||||
if (bv()->insertInset(inset)) {
|
bv()->insertInset(inset);
|
||||||
//inset->edit(bv());
|
//inset->edit(bv());
|
||||||
//bv()->owner()->dispatch(FuncRequest(LFUN_PASTE));
|
//bv()->owner()->dispatch(FuncRequest(LFUN_PASTE));
|
||||||
} else
|
|
||||||
delete inset;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
28
src/text3.C
28
src/text3.C
@ -400,10 +400,8 @@ void specialChar(LyXText * text, BufferView * bv, InsetSpecialChar::Kind kind)
|
|||||||
bv->update();
|
bv->update();
|
||||||
InsetSpecialChar * new_inset = new InsetSpecialChar(kind);
|
InsetSpecialChar * new_inset = new InsetSpecialChar(kind);
|
||||||
replaceSelection(text);
|
replaceSelection(text);
|
||||||
if (!bv->insertInset(new_inset))
|
bv->insertInset(new_inset);
|
||||||
delete new_inset;
|
bv->update();
|
||||||
else
|
|
||||||
bv->update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -419,14 +417,11 @@ void doInsertInset(BufferView * bv, FuncRequest const & cmd,
|
|||||||
bv->owner()->dispatch(FuncRequest(LFUN_CUT));
|
bv->owner()->dispatch(FuncRequest(LFUN_CUT));
|
||||||
gotsel = true;
|
gotsel = true;
|
||||||
}
|
}
|
||||||
if (bv->insertInset(inset)) {
|
bv->insertInset(inset);
|
||||||
if (edit)
|
if (edit)
|
||||||
inset->edit(bv->cursor(), true);
|
inset->edit(bv->cursor(), true);
|
||||||
if (gotsel && pastesel)
|
if (gotsel && pastesel)
|
||||||
bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
|
bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
|
||||||
} else {
|
|
||||||
delete inset;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anon namespace
|
} // anon namespace
|
||||||
@ -867,8 +862,8 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
|
|
||||||
case LFUN_INSET_INSERT: {
|
case LFUN_INSET_INSERT: {
|
||||||
InsetBase * inset = createInset(bv, cmd);
|
InsetBase * inset = createInset(bv, cmd);
|
||||||
if (inset && !bv->insertInset(inset))
|
if (inset)
|
||||||
delete inset;
|
bv->insertInset(inset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1112,8 +1107,9 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
|
|
||||||
BufferParams const & bufparams = bv->buffer()->params();
|
BufferParams const & bufparams = bv->buffer()->params();
|
||||||
if (style->pass_thru ||
|
if (style->pass_thru ||
|
||||||
pit->getFontSettings(bufparams,pos).language()->lang() == "hebrew" ||
|
pit->getFontSettings(bufparams,pos).language()->lang() == "hebrew")
|
||||||
!bv->insertInset(new InsetQuotes(c, bufparams)))
|
bv->insertInset(new InsetQuotes(c, bufparams));
|
||||||
|
else
|
||||||
bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
|
bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user