mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-23 08:44:01 +00:00
Small fixes to various InsetText problems.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2903 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0f3b5ab991
commit
b08d44b58f
@ -1,3 +1,8 @@
|
|||||||
|
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>
|
2001-10-19 John Levon <moz@compsoc.man.ac.uk>
|
||||||
|
|
||||||
* lyxserver.h:
|
* lyxserver.h:
|
||||||
|
@ -324,7 +324,6 @@ int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const
|
|||||||
if ((w - ((2 * TEXT_TO_INSET_OFFSET) + 5)) >= 0)
|
if ((w - ((2 * TEXT_TO_INSET_OFFSET) + 5)) >= 0)
|
||||||
w -= (2 * TEXT_TO_INSET_OFFSET) + 5;
|
w -= (2 * TEXT_TO_INSET_OFFSET) + 5;
|
||||||
if (topx_set && owner()) {
|
if (topx_set && owner()) {
|
||||||
lyxerr << "topx_set && owner()\n";
|
|
||||||
w -= top_x;
|
w -= top_x;
|
||||||
w += owner()->x();
|
w += owner()->x();
|
||||||
}
|
}
|
||||||
|
@ -291,6 +291,10 @@ public:
|
|||||||
/// we need this here because collapsed insets are only EDITABLE
|
/// we need this here because collapsed insets are only EDITABLE
|
||||||
virtual void setFont(BufferView *, LyXFont const &,
|
virtual void setFont(BufferView *, LyXFont const &,
|
||||||
bool toggleall = false, bool selectall = false);
|
bool toggleall = false, bool selectall = false);
|
||||||
|
///
|
||||||
|
// needed for spellchecking text
|
||||||
|
///
|
||||||
|
virtual bool allowSpellcheck() { return false; }
|
||||||
protected:
|
protected:
|
||||||
///
|
///
|
||||||
mutable int top_x;
|
mutable int top_x;
|
||||||
@ -471,6 +475,8 @@ public:
|
|||||||
///
|
///
|
||||||
// needed for spellchecking text
|
// needed for spellchecking text
|
||||||
///
|
///
|
||||||
|
virtual bool allowSpellcheck() { return false; }
|
||||||
|
///
|
||||||
virtual string const selectNextWordToSpellcheck(BufferView *, float & value) const;
|
virtual string const selectNextWordToSpellcheck(BufferView *, float & value) const;
|
||||||
///
|
///
|
||||||
virtual void selectSelectedWord(BufferView *) { return; }
|
virtual void selectSelectedWord(BufferView *) { return; }
|
||||||
|
@ -175,6 +175,7 @@ public:
|
|||||||
///
|
///
|
||||||
void close(BufferView *) const;
|
void close(BufferView *) const;
|
||||||
///
|
///
|
||||||
|
bool allowSpellcheck() { return inset.allowSpellcheck(); }
|
||||||
string const selectNextWordToSpellcheck(BufferView *, float &) const;
|
string const selectNextWordToSpellcheck(BufferView *, float &) const;
|
||||||
|
|
||||||
void selectSelectedWord(BufferView * bv) {
|
void selectSelectedWord(BufferView * bv) {
|
||||||
|
@ -97,6 +97,7 @@ public:
|
|||||||
///
|
///
|
||||||
void close(BufferView *) const;
|
void close(BufferView *) const;
|
||||||
///
|
///
|
||||||
|
bool allowSpellcheck() { return false; }
|
||||||
string const selectNextWordToSpellcheck(BufferView *, float &) const;
|
string const selectNextWordToSpellcheck(BufferView *, float &) const;
|
||||||
///
|
///
|
||||||
bool inlined() const { return status_ == Inlined; }
|
bool inlined() const { return status_ == Inlined; }
|
||||||
|
@ -229,6 +229,7 @@ public:
|
|||||||
///
|
///
|
||||||
void paragraph(Paragraph *);
|
void paragraph(Paragraph *);
|
||||||
///
|
///
|
||||||
|
bool allowSpellcheck() { return true; }
|
||||||
string const selectNextWordToSpellcheck(BufferView *, float & value) const;
|
string const selectNextWordToSpellcheck(BufferView *, float & value) const;
|
||||||
void selectSelectedWord(BufferView *);
|
void selectSelectedWord(BufferView *);
|
||||||
void toggleSelection(BufferView *, bool kill_selection);
|
void toggleSelection(BufferView *, bool kill_selection);
|
||||||
|
@ -77,7 +77,6 @@ void MathMacroTable::builtinMacros()
|
|||||||
|
|
||||||
built = true;
|
built = true;
|
||||||
//lyxerr[Debug::MATHED] << "Building macros\n";
|
//lyxerr[Debug::MATHED] << "Building macros\n";
|
||||||
D
|
|
||||||
//create("emptyset", 0, "\\not0");
|
//create("emptyset", 0, "\\not0");
|
||||||
create("notin", 0, "\\not\\in");
|
create("notin", 0, "\\not\\in");
|
||||||
create("slash", 0, "/");
|
create("slash", 0, "/");
|
||||||
|
@ -492,32 +492,29 @@ bool Paragraph::checkInsertChar(LyXFont & font)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Paragraph::insertChar(Paragraph::size_type pos,
|
void Paragraph::insertChar(Paragraph::size_type pos, Paragraph::value_type c)
|
||||||
Paragraph::value_type c)
|
|
||||||
{
|
{
|
||||||
LyXFont const f(LyXFont::ALL_INHERIT);
|
LyXFont const f(LyXFont::ALL_INHERIT);
|
||||||
insertChar(pos, c, f);
|
insertChar(pos, c, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Paragraph::insertChar(Paragraph::size_type pos,
|
void Paragraph::insertChar(Paragraph::size_type pos, Paragraph::value_type c,
|
||||||
Paragraph::value_type c,
|
LyXFont const & font)
|
||||||
LyXFont const & font)
|
|
||||||
{
|
{
|
||||||
pimpl_->insertChar(pos, c, font);
|
pimpl_->insertChar(pos, c, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Paragraph::insertInset(Paragraph::size_type pos,
|
void Paragraph::insertInset(Paragraph::size_type pos, Inset * inset)
|
||||||
Inset * inset)
|
|
||||||
{
|
{
|
||||||
LyXFont const f(LyXFont::ALL_INHERIT);
|
LyXFont const f(LyXFont::ALL_INHERIT);
|
||||||
insertInset(pos, inset, f);
|
insertInset(pos, inset, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Paragraph::insertInset(Paragraph::size_type pos,
|
void Paragraph::insertInset(Paragraph::size_type pos, Inset * inset,
|
||||||
Inset * inset, LyXFont const & font)
|
LyXFont const & font)
|
||||||
{
|
{
|
||||||
pimpl_->insertInset(pos, inset, font);
|
pimpl_->insertInset(pos, inset, font);
|
||||||
}
|
}
|
||||||
|
@ -83,15 +83,15 @@ Paragraph::Pimpl::getChar(Paragraph::size_type pos) const
|
|||||||
|
|
||||||
|
|
||||||
void Paragraph::Pimpl::setChar(Paragraph::size_type pos,
|
void Paragraph::Pimpl::setChar(Paragraph::size_type pos,
|
||||||
Paragraph::value_type c)
|
Paragraph::value_type c)
|
||||||
{
|
{
|
||||||
text[pos] = c;
|
text[pos] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Paragraph::Pimpl::insertChar(Paragraph::size_type pos,
|
void Paragraph::Pimpl::insertChar(Paragraph::size_type pos,
|
||||||
Paragraph::value_type c,
|
Paragraph::value_type c,
|
||||||
LyXFont const & font)
|
LyXFont const & font)
|
||||||
{
|
{
|
||||||
lyx::Assert(pos <= size());
|
lyx::Assert(pos <= size());
|
||||||
|
|
||||||
@ -100,19 +100,22 @@ void Paragraph::Pimpl::insertChar(Paragraph::size_type pos,
|
|||||||
// Update the font table.
|
// Update the font table.
|
||||||
FontTable search_font(pos, LyXFont());
|
FontTable search_font(pos, LyXFont());
|
||||||
for (FontList::iterator it = std::lower_bound(fontlist.begin(),
|
for (FontList::iterator it = std::lower_bound(fontlist.begin(),
|
||||||
fontlist.end(),
|
fontlist.end(),
|
||||||
search_font, matchFT());
|
search_font, matchFT());
|
||||||
it != fontlist.end(); ++it)
|
it != fontlist.end(); ++it)
|
||||||
|
{
|
||||||
it->pos(it->pos() + 1);
|
it->pos(it->pos() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Update the inset table.
|
// Update the inset table.
|
||||||
InsetTable search_inset(pos, 0);
|
InsetTable search_inset(pos, 0);
|
||||||
for (InsetList::iterator it = std::lower_bound(owner_->insetlist.begin(),
|
for (InsetList::iterator it = std::lower_bound(owner_->insetlist.begin(),
|
||||||
owner_->insetlist.end(),
|
owner_->insetlist.end(),
|
||||||
search_inset, matchIT());
|
search_inset, matchIT());
|
||||||
it != owner_->insetlist.end(); ++it)
|
it != owner_->insetlist.end(); ++it)
|
||||||
|
{
|
||||||
++it->pos;
|
++it->pos;
|
||||||
|
}
|
||||||
owner_->setFont(pos, font);
|
owner_->setFont(pos, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
45
src/text.C
45
src/text.C
@ -80,9 +80,7 @@ int LyXText::workWidth(BufferView * bview, Inset * inset) const
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!par) {
|
if (!par) {
|
||||||
lyxerr << "LyXText::workWidth: cannot find inset!" <<endl;
|
|
||||||
return workWidth(bview);
|
return workWidth(bview);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,19 +97,19 @@ int LyXText::workWidth(BufferView * bview, Inset * inset) const
|
|||||||
dummyrow.pos(pos);
|
dummyrow.pos(pos);
|
||||||
return workWidth(bview) - leftMargin(bview, &dummyrow);
|
return workWidth(bview) - leftMargin(bview, &dummyrow);
|
||||||
} else {
|
} else {
|
||||||
Row * row = firstrow;
|
int dummy_y;
|
||||||
for(; row; row = row->next()) {
|
Row * row = getRow(par, pos, dummy_y);
|
||||||
if ((row->par() == par && row->pos() >= pos)) {
|
Row * frow = row;
|
||||||
if (!row->next())
|
while(frow->previous() && frow->par() == frow->previous()->par())
|
||||||
break;
|
frow = frow->previous();
|
||||||
else if ((row->next()->par() == par) &&
|
int maxw = 0;
|
||||||
(row->next()->pos() >= pos))
|
while(frow->next() && frow->par() == frow->next()->par()) {
|
||||||
continue;
|
if ((frow != row) && (maxw < frow->width()))
|
||||||
}
|
maxw = frow->width();
|
||||||
|
frow = frow->next();
|
||||||
}
|
}
|
||||||
if (row) {
|
if (maxw)
|
||||||
return workWidth(bview) - leftMargin(bview, row);
|
return maxw;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return workWidth(bview);
|
return workWidth(bview);
|
||||||
}
|
}
|
||||||
@ -681,8 +679,8 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
|
|||||||
// make a corresponding row. Needed to call LeftMargin()
|
// make a corresponding row. Needed to call LeftMargin()
|
||||||
|
|
||||||
// check wether it is a sufficent paragraph
|
// check wether it is a sufficent paragraph
|
||||||
if (newpar
|
if (newpar && tclass[newpar->getLayout()].isEnvironment())
|
||||||
&& tclass[newpar->getLayout()].isEnvironment()) {
|
{
|
||||||
Row dummyrow;
|
Row dummyrow;
|
||||||
dummyrow.par(newpar);
|
dummyrow.par(newpar);
|
||||||
dummyrow.pos(newpar->size());
|
dummyrow.pos(newpar->size());
|
||||||
@ -1011,7 +1009,8 @@ int LyXText::fill(BufferView * bview, Row * row, int paper_width) const
|
|||||||
// special handling of the right address boxes
|
// special handling of the right address boxes
|
||||||
if (textclasslist.Style(bview->buffer()->params.textclass,
|
if (textclasslist.Style(bview->buffer()->params.textclass,
|
||||||
row->par()->getLayout()).margintype
|
row->par()->getLayout()).margintype
|
||||||
== MARGIN_RIGHT_ADDRESS_BOX) {
|
== MARGIN_RIGHT_ADDRESS_BOX)
|
||||||
|
{
|
||||||
int const tmpfill = row->fill();
|
int const tmpfill = row->fill();
|
||||||
row->fill(0); // the minfill in MarginLeft()
|
row->fill(0); // the minfill in MarginLeft()
|
||||||
w = leftMargin(bview, row);
|
w = leftMargin(bview, row);
|
||||||
@ -1507,9 +1506,11 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
|
|||||||
row_ptr->baseline(maxasc + labeladdon);
|
row_ptr->baseline(maxasc + labeladdon);
|
||||||
|
|
||||||
height += row_ptr->height();
|
height += row_ptr->height();
|
||||||
float x;
|
float x = 0;
|
||||||
float dummy;
|
if (layout.margintype != MARGIN_RIGHT_ADDRESS_BOX) {
|
||||||
prepareToPrint(bview, row_ptr, x, dummy, dummy, dummy, false);
|
float dummy;
|
||||||
|
prepareToPrint(bview, row_ptr, x, dummy, dummy, dummy, false);
|
||||||
|
}
|
||||||
row_ptr->width(int(maxwidth + x));
|
row_ptr->width(int(maxwidth + x));
|
||||||
if (inset_owner) {
|
if (inset_owner) {
|
||||||
Row * r = firstrow;
|
Row * r = firstrow;
|
||||||
@ -2297,7 +2298,7 @@ bool LyXText::selectWordWhenUnderCursor(BufferView * bview,
|
|||||||
// This function is only used by the spellchecker for NextWord().
|
// This function is only used by the spellchecker for NextWord().
|
||||||
// It doesn't handle LYX_ACCENTs and probably never will.
|
// It doesn't handle LYX_ACCENTs and probably never will.
|
||||||
string const LyXText::selectNextWordToSpellcheck(BufferView * bview,
|
string const LyXText::selectNextWordToSpellcheck(BufferView * bview,
|
||||||
float & value) const
|
float & value) const
|
||||||
{
|
{
|
||||||
if (the_locking_inset) {
|
if (the_locking_inset) {
|
||||||
string str = the_locking_inset->selectNextWordToSpellcheck(bview, value);
|
string str = the_locking_inset->selectNextWordToSpellcheck(bview, value);
|
||||||
@ -2331,7 +2332,7 @@ string const LyXText::selectNextWordToSpellcheck(BufferView * bview,
|
|||||||
while ((cursor.par()->size() > cursor.pos()
|
while ((cursor.par()->size() > cursor.pos()
|
||||||
&& (!cursor.par()->isLetter(cursor.pos()))
|
&& (!cursor.par()->isLetter(cursor.pos()))
|
||||||
&& (!cursor.par()->isInset(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()->size() == cursor.pos()
|
||||||
&& cursor.par()->next()))
|
&& cursor.par()->next()))
|
||||||
{
|
{
|
||||||
|
@ -1984,7 +1984,7 @@ bool LyXText::gotoNextInset(BufferView * bview,
|
|||||||
|
|
||||||
|
|
||||||
void LyXText::checkParagraph(BufferView * bview, Paragraph * par,
|
void LyXText::checkParagraph(BufferView * bview, Paragraph * par,
|
||||||
Paragraph::size_type pos)
|
Paragraph::size_type pos)
|
||||||
{
|
{
|
||||||
LyXCursor tmpcursor;
|
LyXCursor tmpcursor;
|
||||||
|
|
||||||
@ -2027,7 +2027,8 @@ void LyXText::checkParagraph(BufferView * bview, Paragraph * par,
|
|||||||
// check the special right address boxes
|
// check the special right address boxes
|
||||||
if (textclasslist.Style(bview->buffer()->params.textclass,
|
if (textclasslist.Style(bview->buffer()->params.textclass,
|
||||||
par->getLayout()).margintype
|
par->getLayout()).margintype
|
||||||
== MARGIN_RIGHT_ADDRESS_BOX) {
|
== MARGIN_RIGHT_ADDRESS_BOX)
|
||||||
|
{
|
||||||
tmpcursor.par(par);
|
tmpcursor.par(par);
|
||||||
tmpcursor.row(row);
|
tmpcursor.row(row);
|
||||||
tmpcursor.y(y);
|
tmpcursor.y(y);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user