Small fix for not signing the doc as changed when entering empyt cells.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_1_6@2898 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2001-10-19 10:29:16 +00:00
parent 22e80547fc
commit c2f327174f
3 changed files with 87 additions and 79 deletions

View File

@ -1,3 +1,9 @@
2001-10-19 Juergen Vigna <jug@sad.it>
* src/insets/insettext.C (SetFont): fixed problem of marking
document "changed" when only changing the font of an empty
paragraph.
2001-10-17 Kayvan A. Sylvan <kayvan@sylvan.com> 2001-10-17 Kayvan A. Sylvan <kayvan@sylvan.com>
* development/lyx.spec.in: overhaul * development/lyx.spec.in: overhaul

View File

@ -487,8 +487,8 @@ void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button)
UpdatableInset::Edit(bv, x, y, button); UpdatableInset::Edit(bv, x, y, button);
if (!bv->lockInset(this)) { if (!bv->lockInset(this)) {
lyxerr[Debug::INSETS] << "InsetTabular::Cannot lock inset" << endl; lyxerr[Debug::INSETS] << "InsetTabular::Cannot lock inset" << endl;
return; return;
} }
locked = true; locked = true;
the_locking_inset = 0; the_locking_inset = 0;
@ -500,7 +500,7 @@ void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button)
sel_cell_start = sel_cell_end = actcell; sel_cell_start = sel_cell_end = actcell;
bv->text->FinishUndo(); bv->text->FinishUndo();
if (InsetHit(bv, x, y) && (button != 3)) { if (InsetHit(bv, x, y) && (button != 3)) {
ActivateCellInset(bv, x, y, button); ActivateCellInset(bv, x, y, button);
} }
// UpdateLocal(bv, NONE, false); // UpdateLocal(bv, NONE, false);
// bv->getOwner()->getPopups().updateFormTabular(); // bv->getOwner()->getPopups().updateFormTabular();
@ -510,21 +510,21 @@ void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button)
void InsetTabular::InsetUnlock(BufferView * bv) void InsetTabular::InsetUnlock(BufferView * bv)
{ {
if (the_locking_inset) { if (the_locking_inset) {
the_locking_inset->InsetUnlock(bv); the_locking_inset->InsetUnlock(bv);
the_locking_inset = 0; the_locking_inset = 0;
} }
HideInsetCursor(bv); HideInsetCursor(bv);
no_selection = false; no_selection = false;
oldcell = -1; oldcell = -1;
locked = false; locked = false;
if (scroll() || hasSelection()) { if (scroll() || hasSelection()) {
if (scroll()) { if (scroll()) {
scroll(bv, 0.0F); scroll(bv, 0.0F);
} else { } else {
sel_pos_start = sel_pos_end = 0; sel_pos_start = sel_pos_end = 0;
sel_cell_start = sel_cell_end = 0; sel_cell_start = sel_cell_end = 0;
} }
UpdateLocal(bv, FULL, false); UpdateLocal(bv, FULL, false);
} }
} }
@ -653,11 +653,11 @@ bool InsetTabular::InsertInset(BufferView * bv, Inset * inset)
void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button) void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
{ {
if (hasSelection() && (button == 3)) if (hasSelection() && (button == 3))
return; return;
if (hasSelection()) { if (hasSelection()) {
clearSelection(); clearSelection();
UpdateLocal(bv, SELECTION, false); UpdateLocal(bv, SELECTION, false);
} }
no_selection = false; no_selection = false;
@ -668,39 +668,39 @@ void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
HideInsetCursor(bv); HideInsetCursor(bv);
setPos(bv, x, y); setPos(bv, x, y);
if (actrow != orow) if (actrow != orow)
UpdateLocal(bv, NONE, false); UpdateLocal(bv, NONE, false);
sel_pos_start = sel_pos_end = cursor.pos(); sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell; sel_cell_start = sel_cell_end = actcell;
if (button == 3) { if (button == 3) {
if ((ocell != actcell) && the_locking_inset) { if ((ocell != actcell) && the_locking_inset) {
the_locking_inset->InsetUnlock(bv); the_locking_inset->InsetUnlock(bv);
the_locking_inset = 0; the_locking_inset = 0;
} }
ShowInsetCursor(bv); ShowInsetCursor(bv);
return; return;
} }
bool const inset_hit = InsetHit(bv, x, y); bool const inset_hit = InsetHit(bv, x, y);
if ((ocell == actcell) && the_locking_inset && inset_hit) { if ((ocell == actcell) && the_locking_inset && inset_hit) {
cursor.pos(0); // always before the inset! cursor.pos(0); // always before the inset!
resetPos(bv); resetPos(bv);
the_locking_inset->InsetButtonPress(bv, the_locking_inset->InsetButtonPress(bv, x - inset_x, y - inset_y,
x - inset_x, y - inset_y, button); button);
return; return;
} else if (the_locking_inset) { } else if (the_locking_inset) {
the_locking_inset->InsetUnlock(bv); the_locking_inset->InsetUnlock(bv);
} }
the_locking_inset = 0; the_locking_inset = 0;
if (button == 2) { if (button == 2) {
LocalDispatch(bv, LFUN_PASTESELECTION, "paragraph"); LocalDispatch(bv, LFUN_PASTESELECTION, "paragraph");
return; return;
} }
if (inset_hit && bv->theLockingInset()) { if (inset_hit && bv->theLockingInset()) {
if (ActivateCellInset(bv, x, y, button)) if (ActivateCellInset(bv, x, y, button))
the_locking_inset->InsetButtonPress(bv, x - inset_x, the_locking_inset->InsetButtonPress(bv, x - inset_x,
y - inset_y, button); y - inset_y, button);
return; return;
} }
ShowInsetCursor(bv); ShowInsetCursor(bv);
} }
@ -710,15 +710,15 @@ void InsetTabular::InsetButtonRelease(BufferView * bv,
int x, int y, int button) int x, int y, int button)
{ {
if (button == 3) { if (button == 3) {
if (the_locking_inset) { if (the_locking_inset) {
UpdatableInset * i; UpdatableInset * i;
if ((i=the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE))) { if ((i=the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE))) {
i->InsetButtonRelease(bv, x, y, button); i->InsetButtonRelease(bv, x, y, button);
return;
}
}
bv->owner()->getDialogs()->showTabular(this);
return; return;
}
}
bv->owner()->getDialogs()->showTabular(this);
return;
} }
if (the_locking_inset) { if (the_locking_inset) {
the_locking_inset->InsetButtonRelease(bv, x-inset_x, y-inset_y,button); the_locking_inset->InsetButtonRelease(bv, x-inset_x, y-inset_y,button);
@ -732,20 +732,20 @@ void InsetTabular::InsetMotionNotify(BufferView * bv, int x, int y, int button)
{ {
if (the_locking_inset) { if (the_locking_inset) {
the_locking_inset->InsetMotionNotify(bv, x - inset_x, the_locking_inset->InsetMotionNotify(bv, x - inset_x,
y - inset_y, button); y - inset_y, button);
return; return;
} }
if (!no_selection) { if (!no_selection) {
HideInsetCursor(bv); HideInsetCursor(bv);
LyXParagraph::size_type const old_pos = sel_pos_end; LyXParagraph::size_type const old_pos = sel_pos_end;
int const old_cell = actcell; int const old_cell = actcell;
setPos(bv, x, y); setPos(bv, x, y);
sel_pos_end = cursor.pos(); sel_pos_end = cursor.pos();
sel_cell_end = actcell; sel_cell_end = actcell;
if ((sel_cell_end != old_cell) || (old_pos != sel_pos_end)) if ((sel_cell_end != old_cell) || (old_pos != sel_pos_end))
UpdateLocal(bv, SELECTION, false); UpdateLocal(bv, SELECTION, false);
ShowInsetCursor(bv); ShowInsetCursor(bv);
} }
no_selection = false; no_selection = false;
} }
@ -1344,16 +1344,16 @@ UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock) UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
{ {
if (cellstart(cursor.pos())) { if (cellstart(cursor.pos())) {
bool moved = isRightToLeft(bv) ? moveNextCell(bv) : movePrevCell(bv); bool moved = isRightToLeft(bv) ? moveNextCell(bv) : movePrevCell(bv);
if (!moved) if (!moved)
return FINISHED; return FINISHED;
cursor.pos(1); cursor.pos(1);
} else if (lock) { // behind the inset } else if (lock) { // behind the inset
cursor.pos(0); cursor.pos(0);
if (ActivateCellInset(bv, 0, 0, 0, true)) if (ActivateCellInset(bv, 0, 0, 0, true))
return DISPATCHED; return DISPATCHED;
} else { } else {
cursor.pos(0); cursor.pos(0);
} }
resetPos(bv); resetPos(bv);
return DISPATCHED_NOUPDATE; return DISPATCHED_NOUPDATE;
@ -1800,26 +1800,24 @@ void InsetTabular::TabularFeatures(BufferView * bv,
bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button, bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button,
bool behind) bool behind)
{ {
// the cursor.pos has to be before the inset so if it isn't now just // the cursor.pos has to be before the inset so if it isn't now just
// reset the curor pos first! // reset the curor pos first!
if (!cellstart(cursor.pos())) { if (!cellstart(cursor.pos())) {
cursor.pos(0); cursor.pos(0);
resetPos(bv); resetPos(bv);
} }
UpdatableInset * inset = UpdatableInset * inset =
static_cast<UpdatableInset*>(tabular->GetCellInset(actcell)); static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
LyXFont font(LyXFont::ALL_SANE); LyXFont font(LyXFont::ALL_SANE);
if (behind) { if (behind) {
x = inset->x() + inset->width(bv, font); x = inset->x() + inset->width(bv, font);
y = inset->descent(bv, font); y = inset->descent(bv, font);
} }
//inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
//inset_y = cursor.y();
inset->Edit(bv, x, y, button); inset->Edit(bv, x, y, button);
if (!the_locking_inset) if (!the_locking_inset)
return false; return false;
UpdateLocal(bv, CELL, false); UpdateLocal(bv, CELL, false);
return (the_locking_inset != 0); return (the_locking_inset != 0);
} }

View File

@ -485,8 +485,8 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button)
UpdatableInset::Edit(bv, x, y, button); UpdatableInset::Edit(bv, x, y, button);
if (!bv->lockInset(this)) { if (!bv->lockInset(this)) {
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl; lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
return; return;
} }
locked = true; locked = true;
the_locking_inset = 0; the_locking_inset = 0;
@ -495,8 +495,8 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button)
inset_par = 0; inset_par = 0;
old_par = 0; old_par = 0;
if (!checkAndActivateInset(bv, x, y, button)) if (!checkAndActivateInset(bv, x, y, button))
TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset, TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
y+insetAscent); y+insetAscent);
TEXT(bv)->sel_cursor = TEXT(bv)->cursor; TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
bv->text->FinishUndo(); bv->text->FinishUndo();
ShowInsetCursor(bv); ShowInsetCursor(bv);
@ -505,9 +505,9 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button)
// If the inset is empty set the language of the current font to the // If the inset is empty set the language of the current font to the
// language to the surronding text. // language to the surronding text.
if (par->Last() == 0 && !par->next) { if (par->Last() == 0 && !par->next) {
LyXFont font(LyXFont::ALL_IGNORE); LyXFont font(LyXFont::ALL_IGNORE);
font.setLanguage(bv->getParentLanguage(this)); font.setLanguage(bv->getParentLanguage(this));
SetFont(bv, font, false); SetFont(bv, font, false);
} }
} }
@ -1364,8 +1364,12 @@ UpdatableInset * InsetText::GetFirstLockingInsetOfType(Inset::Code c)
void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall) void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
{ {
if ((!par->next && !par->size()) || !cpar(bv)->size()) {
TEXT(bv)->SetFont(bv, font, toggleall);
return;
}
if (TEXT(bv)->selection) { if (TEXT(bv)->selection) {
bv->text->SetUndo(bv->buffer(), Undo::EDIT, bv->text->SetUndo(bv->buffer(), Undo::EDIT,
#ifndef NEW_INSETS #ifndef NEW_INSETS
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next
@ -1373,7 +1377,7 @@ void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
bv->text->cursor.par()->previous, bv->text->cursor.par()->previous,
bv->text->cursor.par()->next bv->text->cursor.par()->next
#endif #endif
); );
} }
TEXT(bv)->SetFont(bv, font, toggleall); TEXT(bv)->SetFont(bv, font, toggleall);
bv->fitCursor(TEXT(bv)); bv->fitCursor(TEXT(bv));