mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
isInset patch from John
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3065 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0d73b566a1
commit
02e190002b
@ -417,8 +417,7 @@ void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc)
|
||||
Inset * locking_inset = theLockingInset()->getLockingInset();
|
||||
|
||||
if ((cursor.pos() - 1 >= 0) &&
|
||||
(cursor.par()->getChar(cursor.pos() - 1) ==
|
||||
Paragraph::META_INSET) &&
|
||||
cursor.par()->isInset(cursor.pos() - 1) &&
|
||||
(cursor.par()->getInset(cursor.pos() - 1) ==
|
||||
locking_inset))
|
||||
text->setCursor(this, cursor,
|
||||
|
@ -855,7 +855,7 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
|
||||
|
||||
|
||||
if (cursor.pos() < cursor.par()->size()
|
||||
&& isMetaInset(cursor.par(), cursor.pos())
|
||||
&& cursor.par()->isInset(cursor.pos())
|
||||
&& isEditableInset(cursor.par()->getInset(cursor.pos()))) {
|
||||
|
||||
// Check whether the inset really was hit
|
||||
@ -880,7 +880,7 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
|
||||
}
|
||||
|
||||
if ((cursor.pos() - 1 >= 0) &&
|
||||
isMetaInset(cursor.par(), cursor.pos() - 1) &&
|
||||
cursor.par()->isInset(cursor.pos() - 1) &&
|
||||
isEditableInset(cursor.par()->getInset(cursor.pos() - 1))) {
|
||||
Inset * tmpinset = cursor.par()->getInset(cursor.pos()-1);
|
||||
LyXFont font = text->getFont(buffer_, cursor.par(),
|
||||
@ -1833,7 +1833,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
if (is_rtl)
|
||||
lt->cursorLeft(bv_, false);
|
||||
if (lt->cursor.pos() < lt->cursor.par()->size()
|
||||
&& isMetaInset(lt->cursor.par(), lt->cursor.pos())
|
||||
&& lt->cursor.par()->isInset(lt->cursor.pos())
|
||||
&& isHighlyEditableInset(lt->cursor.par()->getInset(lt->cursor.pos()))) {
|
||||
Inset * tmpinset = lt->cursor.par()->getInset(lt->cursor.pos());
|
||||
owner_->getLyXFunc()->setMessage(tmpinset->editMessage());
|
||||
@ -1865,7 +1865,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
lt->cursorLeft(bv_, false);
|
||||
if ((is_rtl || cur != lt->cursor) && // only if really moved!
|
||||
lt->cursor.pos() < lt->cursor.par()->size() &&
|
||||
isMetaInset(lt->cursor.par(), lt->cursor.pos()) &&
|
||||
lt->cursor.par()->isInset(lt->cursor.pos()) &&
|
||||
isHighlyEditableInset(lt->cursor.par()->getInset(lt->cursor.pos()))) {
|
||||
Inset * tmpinset = lt->cursor.par()->getInset(lt->cursor.pos());
|
||||
owner_->getLyXFunc()->setMessage(tmpinset->editMessage());
|
||||
@ -3410,7 +3410,7 @@ void BufferView::Pimpl::gotoInset(vector<Inset::Code> const & codes,
|
||||
|
||||
string contents;
|
||||
if (same_content &&
|
||||
isMetaInset(cursor.par(), cursor.pos())) {
|
||||
cursor.par()->isInset(cursor.pos())) {
|
||||
Inset const * inset = cursor.par()->getInset(cursor.pos());
|
||||
if (find(codes.begin(), codes.end(), inset->lyxCode())
|
||||
!= codes.end())
|
||||
|
@ -1,3 +1,12 @@
|
||||
2001-11-22 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* BufferView2.C:
|
||||
* BufferView_pimpl.C:
|
||||
* buffer.C:
|
||||
* paragraph.h:
|
||||
* text.C:
|
||||
* text2.C: use par->isInset()
|
||||
|
||||
2001-11-23 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* paragraph_pimpl.h:
|
||||
|
@ -2574,7 +2574,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
|
||||
par->layout);
|
||||
|
||||
// treat <toc> as a special case for compatibility with old code
|
||||
if (par->getChar(0) == Paragraph::META_INSET) {
|
||||
if (par->isInset(0)) {
|
||||
Inset * inset = par->getInset(0);
|
||||
Inset::Code lyx_code = inset->lyxCode();
|
||||
if (lyx_code == Inset::TOC_CODE){
|
||||
@ -3105,7 +3105,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
|
||||
|
||||
// treat label as a special case for
|
||||
// more WYSIWYM handling.
|
||||
if (par->getChar(0) == Paragraph::META_INSET) {
|
||||
if (par->isInset(0)) {
|
||||
Inset * inset = par->getInset(0);
|
||||
Inset::Code lyx_code = inset->lyxCode();
|
||||
if (lyx_code == Inset::LABEL_CODE){
|
||||
|
@ -1,3 +1,9 @@
|
||||
2001-11-22 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* inset.h: fix comment
|
||||
|
||||
* insettext.C: use par->isInset()
|
||||
|
||||
2001-11-22 Allan Rae <rae@lyx.org>
|
||||
|
||||
* insetcollapsable.h:
|
||||
|
@ -539,11 +539,12 @@ inline bool isEditableInset(Inset * i)
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true if poiinter argument is valid
|
||||
* returns true if pointer argument is valid
|
||||
* and points to a highly editable inset
|
||||
*/
|
||||
inline bool isHighlyEditableInset(Inset * i)
|
||||
{
|
||||
return i && i->editable() == Inset::HIGHLY_EDITABLE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -940,7 +940,7 @@ void InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button)
|
||||
x - inset_x, y - inset_y,
|
||||
button);
|
||||
} else {
|
||||
if (isMetaInset(cpar(bv), cpos(bv))) {
|
||||
if (cpar(bv)->isInset(cpos(bv))) {
|
||||
inset = static_cast<UpdatableInset*>(cpar(bv)->getInset(cpos(bv)));
|
||||
if (isHighlyEditableInset(inset)) {
|
||||
inset->insetButtonRelease(bv,
|
||||
@ -1744,7 +1744,7 @@ bool InsetText::insertInset(BufferView * bv, Inset * inset)
|
||||
}
|
||||
lt->insertInset(bv, inset);
|
||||
#if 0
|
||||
if ((!isMetaInset(cpar(bv), cpos(bv))) ||
|
||||
if ((!cpar(bv)->isInset(cpos(bv))) ||
|
||||
(cpar(bv)->getInset(cpos(bv)) != inset))
|
||||
lt->cursorLeft(bv);
|
||||
#endif
|
||||
@ -1844,7 +1844,7 @@ void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
|
||||
|
||||
bool InsetText::checkAndActivateInset(BufferView * bv, bool behind)
|
||||
{
|
||||
if (isMetaInset(cpar(bv), cpos(bv))) {
|
||||
if (cpar(bv)->isInset(cpos(bv))) {
|
||||
unsigned int x;
|
||||
unsigned int y;
|
||||
Inset * inset =
|
||||
|
@ -1781,7 +1781,7 @@ Paragraph * Paragraph::TeXEnvironment(Buffer const * buf,
|
||||
}
|
||||
}
|
||||
|
||||
if (style.isEnvironment()){
|
||||
if (style.isEnvironment()) {
|
||||
if (style.latextype == LATEX_LIST_ENVIRONMENT) {
|
||||
os << "\\begin{" << style.latexname() << "}{"
|
||||
<< params().labelWidthString() << "}\n";
|
||||
|
@ -415,10 +415,4 @@ private:
|
||||
Pimpl * pimpl_;
|
||||
};
|
||||
|
||||
|
||||
inline bool isMetaInset(Paragraph const * par, Paragraph::size_type const pos)
|
||||
{
|
||||
return par->getChar(pos) == Paragraph::META_INSET;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
18
src/text.C
18
src/text.C
@ -911,8 +911,8 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
|
||||
last_separator = i;
|
||||
i = par->size() - 1; // this means break
|
||||
//x = width;
|
||||
} else if (par->getChar(i) == Paragraph::META_INSET &&
|
||||
par->getInset(i) && par->getInset(i)->display()){
|
||||
} else if (par->isInset(i) && par->getInset(i)
|
||||
&& par->getInset(i)->display()) {
|
||||
par->getInset(i)->display(false);
|
||||
}
|
||||
++i;
|
||||
@ -1256,7 +1256,7 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
|
||||
|
||||
// Check if any insets are larger
|
||||
for (Paragraph::size_type pos = row_ptr->pos(); pos <= pos_end; ++pos) {
|
||||
if (row_ptr->par()->getChar(pos) == Paragraph::META_INSET) {
|
||||
if (row_ptr->par()->isInset(pos)) {
|
||||
tmpfont = getFont(bview->buffer(), row_ptr->par(), pos);
|
||||
tmpinset = row_ptr->par()->getInset(pos);
|
||||
if (tmpinset) {
|
||||
@ -1862,7 +1862,7 @@ void LyXText::insertChar(BufferView * bview, char c)
|
||||
}
|
||||
|
||||
// the display inset stuff
|
||||
if (cursor.row()->par()->getChar(cursor.row()->pos()) == Paragraph::META_INSET
|
||||
if (cursor.row()->par()->isInset(cursor.row()->pos())
|
||||
&& cursor.row()->par()->getInset(cursor.row()->pos())
|
||||
&& (cursor.row()->par()->getInset(cursor.row()->pos())->display() ||
|
||||
cursor.row()->par()->getInset(cursor.row()->pos())->needFullRow()))
|
||||
@ -2068,7 +2068,7 @@ void LyXText::prepareToPrint(BufferView * bview,
|
||||
|
||||
// center displayed insets
|
||||
Inset * inset;
|
||||
if (row->par()->getChar(row->pos()) == Paragraph::META_INSET
|
||||
if (row->par()->isInset(row->pos())
|
||||
&& (inset=row->par()->getInset(row->pos()))
|
||||
&& (inset->display())) // || (inset->scroll() < 0)))
|
||||
align = (inset->lyxCode() == Inset::MATHMACRO_CODE)
|
||||
@ -2079,7 +2079,7 @@ void LyXText::prepareToPrint(BufferView * bview,
|
||||
ns = numberOfSeparators(bview->buffer(), row);
|
||||
if (ns && row->next() && row->next()->par() == row->par() &&
|
||||
!(row->next()->par()->isNewline(row->next()->pos() - 1))
|
||||
&& !(row->next()->par()->getChar(row->next()->pos()) == Paragraph::META_INSET
|
||||
&& !(row->next()->par()->isInset(row->next()->pos())
|
||||
&& row->next()->par()->getInset(row->next()->pos())
|
||||
&& row->next()->par()->getInset(row->next()->pos())->display())
|
||||
)
|
||||
@ -2732,7 +2732,7 @@ void LyXText::backspace(BufferView * bview)
|
||||
false, cursor.boundary());
|
||||
|
||||
// some insets are undeletable here
|
||||
if (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET) {
|
||||
if (cursor.par()->isInset(cursor.pos())) {
|
||||
if (!cursor.par()->getInset(cursor.pos())->deletable())
|
||||
return;
|
||||
// force complete redo when erasing display insets
|
||||
@ -2933,7 +2933,7 @@ bool LyXText::paintRowBackground(DrawRowParams & p)
|
||||
Paragraph::size_type const last = rowLastPrintable(p.row);
|
||||
|
||||
if (!p.bv->screen()->forceClear() && last == p.row->pos()
|
||||
&& isMetaInset(p.row->par(), p.row->pos())) {
|
||||
&& p.row->par()->isInset(p.row->pos())) {
|
||||
inset = p.row->par()->getInset(p.row->pos());
|
||||
if (inset) {
|
||||
clear_area = inset->doClearArea();
|
||||
@ -3690,7 +3690,7 @@ LyXText::getColumnNearX(BufferView * bview, Row * row, int & x,
|
||||
x = int(tmpx);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// returns pointer to a specified row
|
||||
Row * LyXText::getRow(Paragraph * par,
|
||||
|
@ -246,7 +246,7 @@ void LyXText::setCharFont(BufferView * bv, Paragraph * par,
|
||||
LyXFont font = getFont(buf, par, pos);
|
||||
font.update(fnt, buf->params.language, toggleall);
|
||||
// Let the insets convert their font
|
||||
if (isMetaInset(par, pos)) {
|
||||
if (par->isInset(pos)) {
|
||||
Inset * inset = par->getInset(pos);
|
||||
if (isEditableInset(inset)) {
|
||||
UpdatableInset * uinset =
|
||||
@ -443,7 +443,7 @@ Inset * LyXText::getInset() const
|
||||
if (cursor.pos() == 0 && cursor.par()->bibkey) {
|
||||
inset = cursor.par()->bibkey;
|
||||
} else if (cursor.pos() < cursor.par()->size()
|
||||
&& isMetaInset(cursor.par(), cursor.pos())) {
|
||||
&& cursor.par()->isInset(cursor.pos())) {
|
||||
inset = cursor.par()->getInset(cursor.pos());
|
||||
}
|
||||
return inset;
|
||||
@ -1959,7 +1959,7 @@ bool LyXText::gotoNextInset(BufferView * bview,
|
||||
}
|
||||
|
||||
} while (res.par() &&
|
||||
!(isMetaInset(res.par(), res.pos())
|
||||
!(res.par()->isInset(res.pos())
|
||||
&& (inset = res.par()->getInset(res.pos())) != 0
|
||||
&& find(codes.begin(), codes.end(), inset->lyxCode())
|
||||
!= codes.end()
|
||||
|
Loading…
Reference in New Issue
Block a user