On Fri, Nov 23, 2001 at 10:49:03AM +0100, Jean-Marc Lasgouttes wrote:
> I'll apply it, but it could be improved by changing isTextAt to return
> true only if there is no font change. This would fix the bug we have
> with _L_aTeX (where L is underlined).
ah, cool, forgotten about that bug. I'll look.
> PS: could you send again the isInset patch? I deleted it by mistake.
good, I forgot to remove isMetaInset() in the last one.
attached.
thanks
john
--
"By the way, it's not binaries, it's Perl code. Sometimes they look confusingly
similar."
- Pavel Roskin
Index: src/BufferView2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView2.C,v
retrieving revision 1.95
diff -u -r1.95 BufferView2.C
--- src/BufferView2.C 2001/10/01 15:31:57 1.95
+++ src/BufferView2.C 2001/11/22 02:01:45
@@ -415,8 +415,7 @@
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,
Index: src/BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.173
diff -u -r1.173 BufferView_pimpl.C
--- src/BufferView_pimpl.C 2001/11/13 14:47:32 1.173
+++ src/BufferView_pimpl.C 2001/11/22 02:01:57
@@ -855,7 +855,7 @@
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 @@
}
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 @@
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 @@
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 @@
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())
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.397
diff -u -r1.397 ChangeLog
--- src/ChangeLog 2001/11/20 08:54:09 1.397
+++ src/ChangeLog 2001/11/22 02:02:12
@@ -1,3 +1,12 @@
+2001-11-22 John Levon <[EMAIL PROTECTED]>
+
+ * BufferView2.C:
+ * BufferView_pimpl.C:
+ * buffer.C:
+ * paragraph.h:
+ * text.C:
+ * text2.C: use par->isInset()
+
2001-11-20 Allan Rae <[EMAIL PROTECTED]>
* paragraph.C (insertFromMinibuffer): Fix for inset related crashes.
Index: src/buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.264
diff -u -r1.264 buffer.C
--- src/buffer.C 2001/11/19 15:34:09 1.264
+++ src/buffer.C 2001/11/22 02:02:25
@@ -2574,7 +2574,7 @@
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 @@
// 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){
Index: src/paragraph.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v
retrieving revision 1.172
diff -u -r1.172 paragraph.C
--- src/paragraph.C 2001/11/20 08:54:10 1.172
+++ src/paragraph.C 2001/11/22 02:02:34
@@ -1781,7 +1781,7 @@
}
}
- if (style.isEnvironment()){
+ if (style.isEnvironment()) {
if (style.latextype == LATEX_LIST_ENVIRONMENT) {
os << "\\begin{" << style.latexname() << "}{"
<< params().labelWidthString() << "}\n";
Index: src/text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.196
diff -u -r1.196 text.C
--- src/text.C 2001/11/15 00:39:11 1.196
+++ src/text.C 2001/11/22 02:02:47
@@ -911,8 +911,8 @@
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;
@@ -1261,7 +1261,7 @@
// 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) {
@@ -1867,7 +1867,7 @@
}
// 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()))
@@ -2073,7 +2073,7 @@
// 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)
@@ -2084,7 +2084,7 @@
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())
)
@@ -2737,7 +2737,7 @@
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
@@ -2938,7 +2938,7 @@
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();
@@ -3695,7 +3695,7 @@
x = int(tmpx);
return c;
}
-
+
// returns pointer to a specified row
Row * LyXText::getRow(Paragraph * par,
Index: src/text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.174
diff -u -r1.174 text2.C
--- src/text2.C 2001/11/09 13:44:45 1.174
+++ src/text2.C 2001/11/22 02:02:57
@@ -246,7 +246,7 @@
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 =
@@ -449,7 +449,7 @@
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;
@@ -1965,7 +1965,7 @@
}
} 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()
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.223
diff -u -r1.223 ChangeLog
--- src/insets/ChangeLog 2001/11/19 15:34:11 1.223
+++ src/insets/ChangeLog 2001/11/22 02:03:09
@@ -1,3 +1,9 @@
+2001-11-22 John Levon <[EMAIL PROTECTED]>
+
+ * inset.h: fix comment
+
+ * insettext.C: use par->isInset()
+
2001-11-11 Michael A. Koziarski <[EMAIL PROTECTED]>
* various: updated to use the new LaTeXFeatures
Index: src/insets/inset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inset.h,v
retrieving revision 1.29
diff -u -r1.29 inset.h
--- src/insets/inset.h 2001/11/13 14:47:35 1.29
+++ src/insets/inset.h 2001/11/22 02:03:09
@@ -530,11 +531,12 @@
}
/**
- * 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
Index: src/insets/insettext.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.214
diff -u -r1.214 insettext.C
--- src/insets/insettext.C 2001/11/14 09:46:05 1.214
+++ src/insets/insettext.C 2001/11/22 02:03:13
@@ -940,7 +940,7 @@
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 @@
}
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 @@
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 =
Index: paragraph.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.h,v
retrieving revision 1.17
diff -u -r1.17 paragraph.h
--- paragraph.h 2001/11/09 13:44:44 1.17
+++ paragraph.h 2001/11/23 09:54:50
@@ -415,10 +415,4 @@
Pimpl * pimpl_;
};
-
-inline bool isMetaInset(Paragraph const * par, Paragraph::size_type const pos)
-{
- return par->getChar(pos) == Paragraph::META_INSET;
-}
-
#endif