+2001-10-19 Juergen Vigna <jug@sad.it>
+
+ * text.C (workWidth): use getRow instead of wrong algorithm.
+ (setHeightOfRow): fix for MARGIN_RIGHT_ADDRESS_BOX
+
2001-10-19 John Levon <moz@compsoc.man.ac.uk>
* lyxserver.h:
if ((w - ((2 * TEXT_TO_INSET_OFFSET) + 5)) >= 0)
w -= (2 * TEXT_TO_INSET_OFFSET) + 5;
if (topx_set && owner()) {
- lyxerr << "topx_set && owner()\n";
w -= top_x;
w += owner()->x();
}
/// we need this here because collapsed insets are only EDITABLE
virtual void setFont(BufferView *, LyXFont const &,
bool toggleall = false, bool selectall = false);
+ ///
+ // needed for spellchecking text
+ ///
+ virtual bool allowSpellcheck() { return false; }
protected:
///
mutable int top_x;
///
// needed for spellchecking text
///
+ virtual bool allowSpellcheck() { return false; }
+ ///
virtual string const selectNextWordToSpellcheck(BufferView *, float & value) const;
///
virtual void selectSelectedWord(BufferView *) { return; }
///
void close(BufferView *) const;
///
+ bool allowSpellcheck() { return inset.allowSpellcheck(); }
string const selectNextWordToSpellcheck(BufferView *, float &) const;
void selectSelectedWord(BufferView * bv) {
///
void close(BufferView *) const;
///
+ bool allowSpellcheck() { return false; }
string const selectNextWordToSpellcheck(BufferView *, float &) const;
///
bool inlined() const { return status_ == Inlined; }
///
void paragraph(Paragraph *);
///
+ bool allowSpellcheck() { return true; }
string const selectNextWordToSpellcheck(BufferView *, float & value) const;
void selectSelectedWord(BufferView *);
void toggleSelection(BufferView *, bool kill_selection);
built = true;
//lyxerr[Debug::MATHED] << "Building macros\n";
-D
//create("emptyset", 0, "\\not0");
create("notin", 0, "\\not\\in");
create("slash", 0, "/");
}
-void Paragraph::insertChar(Paragraph::size_type pos,
- Paragraph::value_type c)
+void Paragraph::insertChar(Paragraph::size_type pos, Paragraph::value_type c)
{
LyXFont const f(LyXFont::ALL_INHERIT);
insertChar(pos, c, f);
}
-void Paragraph::insertChar(Paragraph::size_type pos,
- Paragraph::value_type c,
- LyXFont const & font)
+void Paragraph::insertChar(Paragraph::size_type pos, Paragraph::value_type c,
+ LyXFont const & font)
{
pimpl_->insertChar(pos, c, font);
}
-void Paragraph::insertInset(Paragraph::size_type pos,
- Inset * inset)
+void Paragraph::insertInset(Paragraph::size_type pos, Inset * inset)
{
LyXFont const f(LyXFont::ALL_INHERIT);
insertInset(pos, inset, f);
}
-void Paragraph::insertInset(Paragraph::size_type pos,
- Inset * inset, LyXFont const & font)
+void Paragraph::insertInset(Paragraph::size_type pos, Inset * inset,
+ LyXFont const & font)
{
pimpl_->insertInset(pos, inset, font);
}
void Paragraph::Pimpl::setChar(Paragraph::size_type pos,
- Paragraph::value_type c)
+ Paragraph::value_type c)
{
text[pos] = c;
}
void Paragraph::Pimpl::insertChar(Paragraph::size_type pos,
- Paragraph::value_type c,
- LyXFont const & font)
+ Paragraph::value_type c,
+ LyXFont const & font)
{
lyx::Assert(pos <= size());
// Update the font table.
FontTable search_font(pos, LyXFont());
for (FontList::iterator it = std::lower_bound(fontlist.begin(),
- fontlist.end(),
- search_font, matchFT());
+ fontlist.end(),
+ search_font, matchFT());
it != fontlist.end(); ++it)
+ {
it->pos(it->pos() + 1);
+ }
// Update the inset table.
InsetTable search_inset(pos, 0);
for (InsetList::iterator it = std::lower_bound(owner_->insetlist.begin(),
- owner_->insetlist.end(),
- search_inset, matchIT());
+ owner_->insetlist.end(),
+ search_inset, matchIT());
it != owner_->insetlist.end(); ++it)
+ {
++it->pos;
-
+ }
owner_->setFont(pos, font);
}
break;
}
}
-
if (!par) {
- lyxerr << "LyXText::workWidth: cannot find inset!" <<endl;
return workWidth(bview);
}
dummyrow.pos(pos);
return workWidth(bview) - leftMargin(bview, &dummyrow);
} else {
- Row * row = firstrow;
- for(; row; row = row->next()) {
- if ((row->par() == par && row->pos() >= pos)) {
- if (!row->next())
- break;
- else if ((row->next()->par() == par) &&
- (row->next()->pos() >= pos))
- continue;
- }
- }
- if (row) {
- return workWidth(bview) - leftMargin(bview, row);
- }
+ int dummy_y;
+ Row * row = getRow(par, pos, dummy_y);
+ Row * frow = row;
+ while(frow->previous() && frow->par() == frow->previous()->par())
+ frow = frow->previous();
+ int maxw = 0;
+ while(frow->next() && frow->par() == frow->next()->par()) {
+ if ((frow != row) && (maxw < frow->width()))
+ maxw = frow->width();
+ frow = frow->next();
+ }
+ if (maxw)
+ return maxw;
}
return workWidth(bview);
}
// make a corresponding row. Needed to call LeftMargin()
// check wether it is a sufficent paragraph
- if (newpar
- && tclass[newpar->getLayout()].isEnvironment()) {
+ if (newpar && tclass[newpar->getLayout()].isEnvironment())
+ {
Row dummyrow;
dummyrow.par(newpar);
dummyrow.pos(newpar->size());
// special handling of the right address boxes
if (textclasslist.Style(bview->buffer()->params.textclass,
row->par()->getLayout()).margintype
- == MARGIN_RIGHT_ADDRESS_BOX) {
+ == MARGIN_RIGHT_ADDRESS_BOX)
+ {
int const tmpfill = row->fill();
row->fill(0); // the minfill in MarginLeft()
w = leftMargin(bview, row);
row_ptr->baseline(maxasc + labeladdon);
height += row_ptr->height();
- float x;
- float dummy;
- prepareToPrint(bview, row_ptr, x, dummy, dummy, dummy, false);
+ float x = 0;
+ if (layout.margintype != MARGIN_RIGHT_ADDRESS_BOX) {
+ float dummy;
+ prepareToPrint(bview, row_ptr, x, dummy, dummy, dummy, false);
+ }
row_ptr->width(int(maxwidth + x));
if (inset_owner) {
Row * r = firstrow;
// This function is only used by the spellchecker for NextWord().
// It doesn't handle LYX_ACCENTs and probably never will.
string const LyXText::selectNextWordToSpellcheck(BufferView * bview,
- float & value) const
+ float & value) const
{
if (the_locking_inset) {
string str = the_locking_inset->selectNextWordToSpellcheck(bview, value);
while ((cursor.par()->size() > cursor.pos()
&& (!cursor.par()->isLetter(cursor.pos()))
&& (!cursor.par()->isInset(cursor.pos()) ||
- !cursor.par()->getInset(cursor.pos())->isTextInset()))
+ !cursor.par()->getInset(cursor.pos())->allowSpellcheck()))
|| (cursor.par()->size() == cursor.pos()
&& cursor.par()->next()))
{
void LyXText::checkParagraph(BufferView * bview, Paragraph * par,
- Paragraph::size_type pos)
+ Paragraph::size_type pos)
{
LyXCursor tmpcursor;
// check the special right address boxes
if (textclasslist.Style(bview->buffer()->params.textclass,
par->getLayout()).margintype
- == MARGIN_RIGHT_ADDRESS_BOX) {
+ == MARGIN_RIGHT_ADDRESS_BOX)
+ {
tmpcursor.par(par);
tmpcursor.row(row);
tmpcursor.y(y);