More InsetText/InsetTabular fixes!

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1599 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2001-02-22 14:09:20 +00:00
parent 9715b1d974
commit ff67bee117
18 changed files with 523 additions and 507 deletions

View File

@ -558,7 +558,7 @@ void BufferView::copyEnvironment()
text->copyEnvironmentType(); text->copyEnvironmentType();
// clear the selection, even if mark_set // clear the selection, even if mark_set
toggleSelection(); toggleSelection();
text->ClearSelection(); text->ClearSelection(this);
update(text, BufferView::SELECT|BufferView::FITCUR); update(text, BufferView::SELECT|BufferView::FITCUR);
owner()->getMiniBuffer()->Set(_("Paragraph environment type copied")); owner()->getMiniBuffer()->Set(_("Paragraph environment type copied"));
} }
@ -581,7 +581,7 @@ void BufferView::copy()
text->CopySelection(this); text->CopySelection(this);
// clear the selection, even if mark_set // clear the selection, even if mark_set
toggleSelection(); toggleSelection();
text->ClearSelection(); text->ClearSelection(this);
update(text, BufferView::SELECT|BufferView::FITCUR); update(text, BufferView::SELECT|BufferView::FITCUR);
owner()->getMiniBuffer()->Set(_("Copy")); owner()->getMiniBuffer()->Set(_("Copy"));
} }
@ -607,7 +607,7 @@ void BufferView::paste()
hideCursor(); hideCursor();
// clear the selection // clear the selection
toggleSelection(); toggleSelection();
text->ClearSelection(); text->ClearSelection(this);
update(text, BufferView::SELECT|BufferView::FITCUR); update(text, BufferView::SELECT|BufferView::FITCUR);
// paste // paste
@ -616,7 +616,7 @@ void BufferView::paste()
// clear the selection // clear the selection
toggleSelection(); toggleSelection();
text->ClearSelection(); text->ClearSelection(this);
update(text, BufferView::SELECT|BufferView::FITCUR); update(text, BufferView::SELECT|BufferView::FITCUR);
} }
@ -709,7 +709,7 @@ void BufferView::endOfSpellCheck()
hideCursor(); hideCursor();
beforeChange(text); beforeChange(text);
text->SelectSelectedWord(this); text->SelectSelectedWord(this);
text->ClearSelection(); text->ClearSelection(this);
update(text, BufferView::SELECT|BufferView::FITCUR); update(text, BufferView::SELECT|BufferView::FITCUR);
} }
@ -973,7 +973,7 @@ void BufferView::theLockingInset(UpdatableInset * inset)
LyXText * BufferView::getLyXText() const LyXText * BufferView::getLyXText() const
{ {
if (theLockingInset()) { if (theLockingInset()) {
LyXText * txt = theLockingInset()->getLyXText(this); LyXText * txt = theLockingInset()->getLyXText(this, true);
if (txt) if (txt)
return txt; return txt;
} }

View File

@ -585,7 +585,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
// Clear the selection // Clear the selection
screen_->ToggleSelection(bv_->text, bv_); screen_->ToggleSelection(bv_->text, bv_);
bv_->text->ClearSelection(); bv_->text->ClearSelection(bv_);
bv_->text->FullRebreak(bv_); bv_->text->FullRebreak(bv_);
screen_->Update(bv_->text, bv_); screen_->Update(bv_->text, bv_);
updateScrollbar(); updateScrollbar();
@ -647,10 +647,14 @@ void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button)
return; return;
if (screen_ && button == 1) { if (screen_ && button == 1) {
if (text->bv_owner) {
screen_->HideCursor(); screen_->HideCursor();
screen_->ToggleSelection(text, bv_); screen_->ToggleSelection(text, bv_);
text->SelectWord(bv_); text->SelectWord(bv_);
screen_->ToggleSelection(text, bv_, false); screen_->ToggleSelection(text, bv_, false);
} else {
text->SelectWord(bv_);
}
/* This will fit the cursor on the screen /* This will fit the cursor on the screen
* if necessary */ * if necessary */
update(text, BufferView::SELECT|BufferView::FITCUR); update(text, BufferView::SELECT|BufferView::FITCUR);
@ -1031,7 +1035,7 @@ void BufferView::Pimpl::update(LyXText * text, BufferView::UpdateCodes f)
text->FullRebreak(bv_); text->FullRebreak(bv_);
if (text->inset_owner) { if (text->inset_owner) {
text->inset_owner->SetUpdateStatus(bv_, InsetText::CURSOR_PAR); // text->inset_owner->SetUpdateStatus(bv_, InsetText::CURSOR_PAR);
bv_->updateInset(text->inset_owner, true); bv_->updateInset(text->inset_owner, true);
} else } else
update(); update();
@ -1146,7 +1150,7 @@ bool BufferView::Pimpl::available() const
void BufferView::Pimpl::beforeChange(LyXText * text) void BufferView::Pimpl::beforeChange(LyXText * text)
{ {
toggleSelection(); toggleSelection();
text->ClearSelection(); text->ClearSelection(bv_);
} }

View File

@ -1,3 +1,10 @@
2001-02-20 Juergen Vigna <jug@sad.it>
* text2.C (ClearSelection): added BufferView param for inset_owner call
* lyxfunc.C (TEXT): added this function and use it instead of
directly owner->view()-text of getLyXText().
2001-02-20 Edwin Leuven <leuven@fee.uva.nl> 2001-02-20 Edwin Leuven <leuven@fee.uva.nl>
* src/layout_forms.C: out preamble * src/layout_forms.C: out preamble

View File

@ -1,3 +1,16 @@
2001-02-22 Juergen Vigna <jug@sad.it>
* insettext.C (getLyXText): honor the recursive parameter.
* inset.C (getLyXText): added bool recursive parameter.
* insettext.C (SetUpdateStatus): or the update codes.
(draw): check need_update with &.
(InsetButtonPress): set no_selection to not put a selection when
entering an inset and it is redraws in another spot.
* insettext.h: made need_update an int.
2001-02-20 Baruch Even <baruch@ev-en.org> 2001-02-20 Baruch Even <baruch@ev-en.org>
* insetgraphics.h: * insetgraphics.h:

View File

@ -72,10 +72,10 @@ string const Inset::EditMessage() const
} }
LyXText * Inset::getLyXText(BufferView const * bv) const LyXText * Inset::getLyXText(BufferView const * bv, bool const) const
{ {
if (owner()) if (owner())
return owner()->getLyXText(bv); return owner()->getLyXText(bv, false);
else else
return bv->text; return bv->text;
} }

View File

@ -441,9 +441,9 @@ bool InsetCollapsable::doClearArea() const
} }
LyXText * InsetCollapsable::getLyXText(BufferView const * bv) const LyXText * InsetCollapsable::getLyXText(BufferView const * bv, bool recursive) const
{ {
return inset->getLyXText(bv); return inset->getLyXText(bv, recursive);
} }

View File

@ -120,7 +120,7 @@ public:
/// ///
int getMaxWidth(Painter & pain, UpdatableInset const *) const; int getMaxWidth(Painter & pain, UpdatableInset const *) const;
/// ///
LyXText * getLyXText(BufferView const *) const; LyXText * getLyXText(BufferView const *, bool const recursive) const;
/// ///
void deleteLyXText(BufferView *, bool recursive=true) const; void deleteLyXText(BufferView *, bool recursive=true) const;
/// ///

View File

@ -1241,7 +1241,6 @@ void InsetTabular::resetPos(BufferView * bv) const
(tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20)) (tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20))
{ {
int xx = cursor.x() - offset + bv->text->GetRealCursorX(bv); int xx = cursor.x() - offset + bv->text->GetRealCursorX(bv);
printf("%d\n", xx);
if (xx > (bv->workWidth()-20)) if (xx > (bv->workWidth()-20))
scroll(bv, -(xx - bv->workWidth() + 60)); scroll(bv, -(xx - bv->workWidth() + 60));
else if (xx < 20) { else if (xx < 20) {
@ -1828,11 +1827,11 @@ void InsetTabular::resizeLyXText(BufferView *) const
} }
LyXText * InsetTabular::getLyXText(BufferView const * bv) const LyXText * InsetTabular::getLyXText(BufferView const * bv, bool const recursive) const
{ {
if (the_locking_inset) if (the_locking_inset)
return the_locking_inset->getLyXText(bv); return the_locking_inset->getLyXText(bv, recursive);
return Inset::getLyXText(bv); return Inset::getLyXText(bv, recursive);
} }

View File

@ -166,7 +166,7 @@ public:
/// ///
Buffer * BufferOwner() const { return const_cast<Buffer *>(buffer); } Buffer * BufferOwner() const { return const_cast<Buffer *>(buffer); }
/// ///
LyXText * getLyXText(BufferView const *) const; LyXText * getLyXText(BufferView const *, bool const recursive = false) const;
/// ///
void resizeLyXText(BufferView *) const; void resizeLyXText(BufferView *) const;
/// ///

View File

@ -313,7 +313,6 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
return; return;
if (top_x != int(x)) { if (top_x != int(x)) {
// printf("InsetText::draw1 -> INIT(%d)\n",insetWidth);
need_update = INIT; need_update = INIT;
top_x = int(x); top_x = int(x);
bv->text->status = LyXText::CHANGED_IN_DRAW; bv->text->status = LyXText::CHANGED_IN_DRAW;
@ -350,7 +349,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
if (y_offset < 0) if (y_offset < 0)
y_offset = y; y_offset = y;
TEXT(bv)->first = first; TEXT(bv)->first = first;
if (cleared || !locked || (need_update==FULL) || (need_update==INIT)) { if (cleared || !locked || (need_update&FULL) || (need_update&INIT)) {
int yf = y_offset; int yf = y_offset;
y = 0; y = 0;
while ((row != 0) && (yf < ph)) { while ((row != 0) && (yf < ph)) {
@ -360,13 +359,13 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
yf += row->height(); yf += row->height();
row = row->next(); row = row->next();
} }
} else if (need_update == SELECTION) {
bv->screen()->ToggleToggle(TEXT(bv), bv, y_offset, int(x));
} else { } else {
locked = false; locked = false;
if (need_update == CURSOR) { if (need_update & SELECTION)
bv->screen()->ToggleToggle(TEXT(bv), bv, y_offset, int(x));
else if (need_update & CURSOR) {
bv->screen()->ToggleSelection(TEXT(bv), bv, true, y_offset,int(x)); bv->screen()->ToggleSelection(TEXT(bv), bv, true, y_offset,int(x));
TEXT(bv)->ClearSelection(); TEXT(bv)->ClearSelection(bv);
TEXT(bv)->sel_cursor = TEXT(bv)->cursor; TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
} }
bv->screen()->Update(TEXT(bv), bv, y_offset, int(x)); bv->screen()->Update(TEXT(bv), bv, y_offset, int(x));
@ -381,18 +380,15 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
pain.rectangle(top_x + 1, baseline - insetAscent + 1, pain.rectangle(top_x + 1, baseline - insetAscent + 1,
width(bv, f) - 1, insetAscent + insetDescent - 1, width(bv, f) - 1, insetAscent + insetDescent - 1,
frame_color); frame_color);
} else if (need_update == CLEAR_FRAME) { } else if (need_update & CLEAR_FRAME) {
pain.rectangle(top_x + 1, baseline - insetAscent + 1, pain.rectangle(top_x + 1, baseline - insetAscent + 1,
width(bv, f) - 1, insetAscent + insetDescent - 1, width(bv, f) - 1, insetAscent + insetDescent - 1,
LColor::background); LColor::background);
} }
x += width(bv, f) - TEXT_TO_INSET_OFFSET; x += width(bv, f) - TEXT_TO_INSET_OFFSET;
if (bv->text->status==LyXText::CHANGED_IN_DRAW) if (bv->text->status==LyXText::CHANGED_IN_DRAW) {
{
need_update = INIT; need_update = INIT;
// printf("InsetText::draw2 -> INIT(%d)\n",insetWidth); } else if (need_update != INIT)
}
else if (need_update != INIT)
need_update = NONE; need_update = NONE;
} }
@ -450,25 +446,20 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
TEXT_TO_INSET_OFFSET; TEXT_TO_INSET_OFFSET;
} }
void InsetText::SetUpdateStatus(BufferView * bv, UpdateCodes what) void InsetText::SetUpdateStatus(BufferView * bv, int what)
{ {
need_update |= what;
if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH) if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
need_update = FULL; need_update |= FULL;
if (what > need_update) // this to not draw a selection when we redraw all of it!
need_update = what; if ((need_update & (INIT|FULL)) && (need_update & CURSOR))
TEXT(bv)->ClearSelection(bv);
} }
void InsetText::UpdateLocal(BufferView * bv, UpdateCodes what, bool mark_dirty) void InsetText::UpdateLocal(BufferView * bv, int what, bool mark_dirty)
{ {
// if (what == INIT)
// printf("InsetText::UpdateLocal -> INIT(%d)\n",insetWidth);
TEXT(bv)->FullRebreak(bv); TEXT(bv)->FullRebreak(bv);
if (need_update != INIT) { SetUpdateStatus(bv, what);
if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
need_update = FULL;
else if (!the_locking_inset || (what != CURSOR))
need_update = what;
}
if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED) || if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED) ||
TEXT(bv)->selection) TEXT(bv)->selection)
bv->updateInset(this, mark_dirty); bv->updateInset(this, mark_dirty);
@ -528,8 +519,7 @@ void InsetText::InsetUnlock(BufferView * bv)
HideInsetCursor(bv); HideInsetCursor(bv);
no_selection = false; no_selection = false;
locked = false; locked = false;
TEXT(bv)->selection = 0; UpdateLocal(bv, CLEAR_FRAME|CURSOR, false);
UpdateLocal(bv, CLEAR_FRAME, false);
if (owner()) if (owner())
bv->owner()->setLayout(owner()->getLyXText(bv) bv->owner()->setLayout(owner()->getLyXText(bv)
->cursor.par()->GetLayout()); ->cursor.par()->GetLayout());
@ -551,7 +541,13 @@ bool InsetText::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
inset_pos = cpos(bv); inset_pos = cpos(bv);
inset_par = cpar(bv); inset_par = cpar(bv);
inset_boundary = cboundary(bv); inset_boundary = cboundary(bv);
#if 0
TEXT(bv)->ClearSelection(bv);
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
TEXT(bv)->UpdateInset(bv, the_locking_inset); TEXT(bv)->UpdateInset(bv, the_locking_inset);
#else
UpdateLocal(bv, CURSOR, false);
#endif
return true; return true;
} else if (the_locking_inset && (the_locking_inset == inset)) { } else if (the_locking_inset && (the_locking_inset == inset)) {
if (cpar(bv) == inset_par && cpos(bv) == inset_pos) { if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
@ -595,7 +591,7 @@ bool InsetText::UpdateInsetInInset(BufferView * bv, Inset * inset)
return false; return false;
if (the_locking_inset != inset) { if (the_locking_inset != inset) {
TEXT(bv)->UpdateInset(bv, the_locking_inset); TEXT(bv)->UpdateInset(bv, the_locking_inset);
need_update = CURSOR_PAR; SetUpdateStatus(bv, CURSOR_PAR);
return the_locking_inset->UpdateInsetInInset(bv, inset); return the_locking_inset->UpdateInsetInInset(bv, inset);
} }
// UpdateLocal(bv, FULL, false); // UpdateLocal(bv, FULL, false);
@ -611,7 +607,7 @@ bool InsetText::UpdateInsetInInset(BufferView * bv, Inset * inset)
void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button) void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
{ {
no_selection = false; no_selection = true;
int tmp_x = x - drawTextXOffset; int tmp_x = x - drawTextXOffset;
int tmp_y = y + insetAscent - TEXT(bv)->first; int tmp_y = y + insetAscent - TEXT(bv)->first;
@ -621,6 +617,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
if (the_locking_inset) { if (the_locking_inset) {
if (the_locking_inset == inset) { if (the_locking_inset == inset) {
the_locking_inset->InsetButtonPress(bv,x-inset_x,y-inset_y,button); the_locking_inset->InsetButtonPress(bv,x-inset_x,y-inset_y,button);
no_selection = false;
return; return;
} else if (inset) { } else if (inset) {
// otherwise unlock the_locking_inset and lock the new inset // otherwise unlock the_locking_inset and lock the new inset
@ -630,9 +627,9 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
the_locking_inset = static_cast<UpdatableInset*>(inset); the_locking_inset = static_cast<UpdatableInset*>(inset);
inset->InsetButtonPress(bv, x - inset_x, y - inset_y, button); inset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
inset->Edit(bv, x - inset_x, y - inset_y, button); inset->Edit(bv, x - inset_x, y - inset_y, button);
if (the_locking_inset) { if (the_locking_inset)
UpdateLocal(bv, CURSOR_PAR, false); UpdateLocal(bv, CURSOR, false);
} no_selection = false;
return; return;
} }
// otherwise only unlock the_locking_inset // otherwise only unlock the_locking_inset
@ -650,10 +647,9 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
the_locking_inset = uinset; the_locking_inset = uinset;
uinset->InsetButtonPress(bv, x - inset_x, y - inset_y, button); uinset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
uinset->Edit(bv, x - inset_x, y - inset_y, 0); uinset->Edit(bv, x - inset_x, y - inset_y, 0);
// TEXT(bv)->ClearSelection(); if (the_locking_inset)
if (the_locking_inset) { UpdateLocal(bv, CURSOR, false);
UpdateLocal(bv, CURSOR_PAR, false); no_selection = false;
}
return; return;
} }
} }
@ -680,6 +676,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
} }
} }
ShowInsetCursor(bv); ShowInsetCursor(bv);
no_selection = false;
} }
@ -711,12 +708,13 @@ void InsetText::InsetButtonRelease(BufferView * bv, int x, int y, int button)
void InsetText::InsetMotionNotify(BufferView * bv, int x, int y, int state) void InsetText::InsetMotionNotify(BufferView * bv, int x, int y, int state)
{ {
if (no_selection)
return;
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,state); y - inset_y,state);
return; return;
} }
if (!no_selection) {
HideInsetCursor(bv); HideInsetCursor(bv);
TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset, TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
y+insetAscent); y+insetAscent);
@ -725,8 +723,6 @@ void InsetText::InsetMotionNotify(BufferView * bv, int x, int y, int state)
TEXT(bv)->toggle_cursor.pos()!=TEXT(bv)->toggle_end_cursor.pos()) TEXT(bv)->toggle_cursor.pos()!=TEXT(bv)->toggle_end_cursor.pos())
UpdateLocal(bv, SELECTION, false); UpdateLocal(bv, SELECTION, false);
ShowInsetCursor(bv); ShowInsetCursor(bv);
}
no_selection = false;
} }
@ -815,7 +811,8 @@ InsetText::LocalDispatch(BufferView * bv,
TEXT(bv)->CutSelection(bv, false); TEXT(bv)->CutSelection(bv, false);
} }
} }
TEXT(bv)->ClearSelection(); TEXT(bv)->ClearSelection(bv);
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
for (string::size_type i = 0; i < arg.length(); ++i) { for (string::size_type i = 0; i < arg.length(); ++i) {
if (greek_kb_flag) { if (greek_kb_flag) {
if (!math_insert_greek(bv, arg[i])) { if (!math_insert_greek(bv, arg[i])) {
@ -841,7 +838,6 @@ InsetText::LocalDispatch(BufferView * bv,
case LFUN_RIGHT: case LFUN_RIGHT:
result = moveRight(bv); result = moveRight(bv);
bv->text->FinishUndo(); bv->text->FinishUndo();
TEXT(bv)->ClearSelection();
UpdateLocal(bv, CURSOR, false); UpdateLocal(bv, CURSOR, false);
break; break;
case LFUN_LEFTSEL: case LFUN_LEFTSEL:
@ -853,7 +849,6 @@ InsetText::LocalDispatch(BufferView * bv,
case LFUN_LEFT: case LFUN_LEFT:
bv->text->FinishUndo(); bv->text->FinishUndo();
result = moveLeft(bv); result = moveLeft(bv);
TEXT(bv)->ClearSelection();
UpdateLocal(bv, CURSOR, false); UpdateLocal(bv, CURSOR, false);
break; break;
case LFUN_DOWNSEL: case LFUN_DOWNSEL:
@ -865,8 +860,6 @@ InsetText::LocalDispatch(BufferView * bv,
case LFUN_DOWN: case LFUN_DOWN:
bv->text->FinishUndo(); bv->text->FinishUndo();
result = moveDown(bv); result = moveDown(bv);
TEXT(bv)->ClearSelection();
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR, false); UpdateLocal(bv, CURSOR, false);
break; break;
case LFUN_UPSEL: case LFUN_UPSEL:
@ -878,21 +871,15 @@ InsetText::LocalDispatch(BufferView * bv,
case LFUN_UP: case LFUN_UP:
bv->text->FinishUndo(); bv->text->FinishUndo();
result = moveUp(bv); result = moveUp(bv);
TEXT(bv)->ClearSelection();
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR, false); UpdateLocal(bv, CURSOR, false);
break; break;
case LFUN_HOME: case LFUN_HOME:
bv->text->FinishUndo(); bv->text->FinishUndo();
TEXT(bv)->CursorHome(bv); TEXT(bv)->CursorHome(bv);
TEXT(bv)->ClearSelection();
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR, false); UpdateLocal(bv, CURSOR, false);
break; break;
case LFUN_END: case LFUN_END:
TEXT(bv)->CursorEnd(bv); TEXT(bv)->CursorEnd(bv);
TEXT(bv)->ClearSelection();
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR, false); UpdateLocal(bv, CURSOR, false);
break; break;
case LFUN_BACKSPACE: case LFUN_BACKSPACE:
@ -1338,9 +1325,8 @@ bool InsetText::InsertInset(BufferView * bv, Inset * inset)
(cpar(bv)->GetInset(cpos(bv)) != inset)) (cpar(bv)->GetInset(cpos(bv)) != inset))
TEXT(bv)->CursorLeft(bv); TEXT(bv)->CursorLeft(bv);
#endif #endif
TEXT(bv)->selection = 0;
bv->fitCursor(TEXT(bv)); bv->fitCursor(TEXT(bv));
UpdateLocal(bv, CURSOR_PAR, true); UpdateLocal(bv, CURSOR_PAR|CURSOR, true);
ShowInsetCursor(bv); ShowInsetCursor(bv);
return true; return true;
} }
@ -1573,18 +1559,23 @@ Row * InsetText::crow(BufferView * bv) const
} }
LyXText * InsetText::getLyXText(BufferView const * lbv) const LyXText * InsetText::getLyXText(BufferView const * lbv, bool const recursive) const
{ {
// Super UGLY! (Lgb) // Super UGLY! (Lgb)
BufferView * bv = const_cast<BufferView *>(lbv); BufferView * bv = const_cast<BufferView *>(lbv);
if ((cache.find(bv) != cache.end()) && cache[bv]) if ((cache.find(bv) != cache.end()) && cache[bv]) {
if (recursive && the_locking_inset)
return the_locking_inset->getLyXText(bv);
return cache[bv]; return cache[bv];
}
LyXText * lt = new LyXText(const_cast<InsetText *>(this)); LyXText * lt = new LyXText(const_cast<InsetText *>(this));
lt->init(bv); lt->init(bv);
cache[bv] = lt; cache[bv] = lt;
if (the_locking_inset) { if (the_locking_inset) {
lt->SetCursor(bv, inset_par, inset_pos, true, inset_boundary); lt->SetCursor(bv, inset_par, inset_pos, true, inset_boundary);
if (recursive)
return the_locking_inset->getLyXText(bv);
} }
return lt; return lt;
} }

View File

@ -50,15 +50,15 @@ public:
/// ///
CLEAR_FRAME = 2, CLEAR_FRAME = 2,
/// ///
DRAW_FRAME = 3, DRAW_FRAME = 4,
/// ///
SELECTION = 4, SELECTION = 8,
/// ///
CURSOR_PAR = 5, CURSOR_PAR = 16,
/// ///
FULL = 6, FULL = 32,
/// ///
INIT = 7 INIT = 64
}; };
/// ///
enum DrawFrame { enum DrawFrame {
@ -99,7 +99,7 @@ public:
/// ///
void update(BufferView *, LyXFont const &, bool =false); void update(BufferView *, LyXFont const &, bool =false);
/// ///
void SetUpdateStatus(BufferView *, UpdateCodes); void SetUpdateStatus(BufferView *, int what);
/// ///
string const EditMessage() const; string const EditMessage() const;
/// ///
@ -170,7 +170,7 @@ public:
/// ///
void SetFrameColor(BufferView *, LColor::color); void SetFrameColor(BufferView *, LColor::color);
/// ///
LyXText * getLyXText(BufferView const *) const; LyXText * getLyXText(BufferView const *, bool const recursive=false) const;
/// ///
void deleteLyXText(BufferView *, bool recursive=true) const; void deleteLyXText(BufferView *, bool recursive=true) const;
/// ///
@ -178,11 +178,11 @@ public:
/// ///
LyXParagraph * par; LyXParagraph * par;
/// ///
mutable UpdateCodes need_update; mutable int need_update;
protected: protected:
/// ///
void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty); void UpdateLocal(BufferView *, int what, bool mark_dirty);
/// ///
mutable int drawTextXOffset; mutable int drawTextXOffset;
/// ///

View File

@ -227,7 +227,7 @@ public:
// because we could have fake text insets and have to call this // because we could have fake text insets and have to call this
// inside them without cast!!! // inside them without cast!!!
/// ///
virtual LyXText * getLyXText(BufferView const *) const; virtual LyXText * getLyXText(BufferView const *, bool const recursive=false) const;
/// ///
virtual void deleteLyXText(BufferView *, bool = true) const {} virtual void deleteLyXText(BufferView *, bool = true) const {}
/// ///

View File

@ -168,7 +168,7 @@ void LyXFindReplace::SearchReplaceAllCB()
bv->hideCursor(); bv->hideCursor();
// start at top // start at top
bv->text->ClearSelection(); bv->text->ClearSelection(bv);
bv->text->CursorTop(bv); bv->text->CursorTop(bv);
int replace_count = 0; int replace_count = 0;
@ -226,7 +226,7 @@ bool LyXFindReplace::SearchCB(bool fForward)
// clear the selection (if there is any) // clear the selection (if there is any)
bv->toggleSelection(); bv->toggleSelection();
bv->text->ClearSelection(); bv->text->ClearSelection(bv);
// set the new selection // set the new selection
SetSelectionOverLenChars(bv, iLenSelected); SetSelectionOverLenChars(bv, iLenSelected);

File diff suppressed because it is too large Load Diff

View File

@ -94,7 +94,7 @@ private:
/// ///
unsigned meta_fake_bit; unsigned meta_fake_bit;
/// ///
void moveCursorUpdate(LyXText *, bool selecting = false); void moveCursorUpdate(bool flag = true, bool selecting = false);
/// ///
void setupLocalKeymap(); void setupLocalKeymap();
/// ///
@ -128,7 +128,12 @@ private:
void CloseBuffer(); void CloseBuffer();
/// ///
void reloadBuffer(); void reloadBuffer();
/// This is the same for all lyxfunc objects ///
// This return or directly text (default) of getLyXText()
///
LyXText * TEXT(bool) const;
///
// This is the same for all lyxfunc objects
static bool show_sc; static bool show_sc;
}; };

View File

@ -235,7 +235,7 @@ public:
/// need the selection cursor: /// need the selection cursor:
void SetSelection(BufferView *); void SetSelection(BufferView *);
/// ///
void ClearSelection() const; void ClearSelection(BufferView *) const;
/// ///
string const selectionAsString(Buffer const *) const; string const selectionAsString(Buffer const *) const;

View File

@ -1895,7 +1895,7 @@ void LyXText::OpenFootnote(BufferView * bview)
// Just a macro to make some thing easier. // Just a macro to make some thing easier.
void LyXText::RedoParagraph(BufferView * bview) const void LyXText::RedoParagraph(BufferView * bview) const
{ {
ClearSelection(); ClearSelection(bview);
RedoParagraphs(bview, cursor, cursor.par()->Next()); RedoParagraphs(bview, cursor, cursor.par()->Next());
SetCursorIntern(bview, cursor.par(), cursor.pos()); SetCursorIntern(bview, cursor.par(), cursor.pos());
} }
@ -4091,7 +4091,7 @@ void LyXText::InsertFootnoteEnvironment(BufferView * bview,
SetCursor(bview, sel_start_cursor.par()->Next(), 0); SetCursor(bview, sel_start_cursor.par()->Next(), 0);
ClearSelection(); ClearSelection(bview);
} }
#endif #endif

View File

@ -657,7 +657,7 @@ void LyXText::SetLayout(BufferView * bview, LyXTextClass::size_type layout)
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos(), SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos(),
false); false);
UpdateCounters(bview, cursor.row()); UpdateCounters(bview, cursor.row());
ClearSelection(); ClearSelection(bview);
SetSelection(bview); SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true); SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true);
} }
@ -775,7 +775,7 @@ void LyXText::IncDepth(BufferView * bview)
sel_cursor = cursor; sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos()); SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
UpdateCounters(bview, cursor.row()); UpdateCounters(bview, cursor.row());
ClearSelection(); ClearSelection(bview);
SetSelection(bview); SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos()); SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
} }
@ -852,7 +852,7 @@ void LyXText::DecDepth(BufferView * bview)
sel_cursor = cursor; sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos()); SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
UpdateCounters(bview, cursor.row()); UpdateCounters(bview, cursor.row());
ClearSelection(); ClearSelection(bview);
SetSelection(bview); SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos()); SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
} }
@ -934,7 +934,7 @@ void LyXText::SetFont(BufferView * bview, LyXFont const & font, bool toggleall)
SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos()); SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos());
sel_cursor = cursor; sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos()); SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
ClearSelection(); ClearSelection(bview);
SetSelection(bview); SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true, SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true,
tmpcursor.boundary()); tmpcursor.boundary());
@ -1208,10 +1208,8 @@ string const LyXText::selectionAsString(Buffer const * buffer) const
} }
void LyXText::ClearSelection() const void LyXText::ClearSelection(BufferView * bview) const
{ {
if (selection)
status = LyXText::NEED_MORE_REFRESH;
selection = false; selection = false;
mark_set = false; mark_set = false;
} }
@ -1298,7 +1296,7 @@ void LyXText::ToggleFree(BufferView * bview,
/* Implicit selections are cleared afterwards and cursor is set to the /* Implicit selections are cleared afterwards and cursor is set to the
original position. */ original position. */
if (implicitSelection) { if (implicitSelection) {
ClearSelection(); ClearSelection(bview);
cursor = resetCursor; cursor = resetCursor;
SetCursor(bview, cursor.par(), cursor.pos()); SetCursor(bview, cursor.par(), cursor.pos());
sel_cursor = cursor; sel_cursor = cursor;
@ -1327,7 +1325,7 @@ void LyXText::MeltFootnoteEnvironment(BufferView * bview)
{ {
LyXParagraph * tmppar, * firsttmppar; LyXParagraph * tmppar, * firsttmppar;
ClearSelection(); ClearSelection(bview);
/* is is only allowed, if the cursor is IN an open footnote. /* is is only allowed, if the cursor is IN an open footnote.
* Otherwise it is too dangerous */ * Otherwise it is too dangerous */
@ -1413,7 +1411,7 @@ void LyXText::MeltFootnoteEnvironment(BufferView * bview)
UpdateCounters(bview, row); UpdateCounters(bview, row);
ClearSelection(); ClearSelection(bview);
} }
#endif #endif
@ -1520,7 +1518,7 @@ void LyXText::SetParagraph(BufferView * bview,
RedoParagraphs(bview, sel_start_cursor, endpar); RedoParagraphs(bview, sel_start_cursor, endpar);
ClearSelection(); ClearSelection(bview);
SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos()); SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos());
sel_cursor = cursor; sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos()); SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
@ -1610,7 +1608,7 @@ void LyXText::SetParagraphExtraOpt(BufferView * bview, int type,
#endif #endif
} }
RedoParagraphs(bview, sel_start_cursor, endpar); RedoParagraphs(bview, sel_start_cursor, endpar);
ClearSelection(); ClearSelection(bview);
SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos()); SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos());
sel_cursor = cursor; sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos()); SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
@ -2281,7 +2279,7 @@ void LyXText::CutSelection(BufferView * bview, bool doclear)
RedoParagraphs(bview, sel_start_cursor, endpar); RedoParagraphs(bview, sel_start_cursor, endpar);
ClearSelection(); ClearSelection(bview);
cursor = sel_start_cursor; cursor = sel_start_cursor;
SetCursor(bview, cursor.par(), cursor.pos()); SetCursor(bview, cursor.par(), cursor.pos());
sel_cursor = cursor; sel_cursor = cursor;
@ -2369,7 +2367,7 @@ void LyXText::PasteSelection(BufferView * bview)
RedoParagraphs(bview, cursor, endpar); RedoParagraphs(bview, cursor, endpar);
SetCursor(bview, cursor.par(), cursor.pos()); SetCursor(bview, cursor.par(), cursor.pos());
ClearSelection(); ClearSelection(bview);
sel_cursor = cursor; sel_cursor = cursor;
SetCursor(bview, actpar, pos); SetCursor(bview, actpar, pos);
@ -2509,7 +2507,7 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
textclasslist.Style(bview->buffer()->params.textclass, textclasslist.Style(bview->buffer()->params.textclass,
cursor.par()->GetLayout()).isEnvironment(); cursor.par()->GetLayout()).isEnvironment();
// only to be sure, should not be neccessary // only to be sure, should not be neccessary
ClearSelection(); ClearSelection(bview);
// insert the string, don't insert doublespace // insert the string, don't insert doublespace
string::size_type i = 0; string::size_type i = 0;