remove now unneeded LyXText * argument to save/restoreLyXTextState

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7264 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-07-10 14:44:13 +00:00
parent f3a0435e42
commit 90e2efe06b
2 changed files with 27 additions and 30 deletions

View File

@ -59,7 +59,6 @@
#include <fstream> #include <fstream>
#include <algorithm> #include <algorithm>
#include <cstdlib> #include <cstdlib>
//#include <csignal>
using std::ostream; using std::ostream;
using std::ifstream; using std::ifstream;
@ -80,45 +79,45 @@ namespace grfx = lyx::graphics;
// These functions should probably go into bufferview_funcs somehow (Jug) // These functions should probably go into bufferview_funcs somehow (Jug)
void InsetText::saveLyXTextState(LyXText * t) const void InsetText::saveLyXTextState() const
{ {
// check if my paragraphs are still valid // check if my paragraphs are still valid
ParagraphList::iterator it = const_cast<ParagraphList&>(paragraphs).begin(); ParagraphList::iterator it = const_cast<ParagraphList&>(paragraphs).begin();
ParagraphList::iterator end = const_cast<ParagraphList&>(paragraphs).end(); ParagraphList::iterator end = const_cast<ParagraphList&>(paragraphs).end();
for (; it != end; ++it) { for (; it != end; ++it) {
if (it == t->cursor.par()) if (it == text_.cursor.par())
break; break;
} }
if (it != end && t->cursor.pos() <= it->size()) if (it != end && text_.cursor.pos() <= it->size())
sstate = *t; // slicing intended sstate = text_; // slicing intended
else else
sstate.cursor.par(end); sstate.cursor.par(end);
} }
void InsetText::restoreLyXTextState(LyXText * t) const void InsetText::restoreLyXTextState() const
{ {
if (sstate.cursor.par() == const_cast<ParagraphList&>(paragraphs).end()) if (sstate.cursor.par() == const_cast<ParagraphList&>(paragraphs).end())
return; return;
t->selection.set(true); text_.selection.set(true);
// at this point just to avoid the DEPM when setting the cursor // at this point just to avoid the DEPM when setting the cursor
t->selection.mark(sstate.selection.mark()); text_.selection.mark(sstate.selection.mark());
if (sstate.selection.set()) { if (sstate.selection.set()) {
t->setCursor(sstate.selection.start.par(), text_.setCursor(sstate.selection.start.par(),
sstate.selection.start.pos(), sstate.selection.start.pos(),
true, sstate.selection.start.boundary()); true, sstate.selection.start.boundary());
t->selection.cursor = t->cursor; text_.selection.cursor = text_.cursor;
t->setCursor(sstate.selection.end.par(), sstate.selection.end.pos(), text_.setCursor(sstate.selection.end.par(), sstate.selection.end.pos(),
true, sstate.selection.end.boundary()); true, sstate.selection.end.boundary());
t->setSelection(); text_.setSelection();
t->setCursor(sstate.cursor.par(), sstate.cursor.pos()); text_.setCursor(sstate.cursor.par(), sstate.cursor.pos());
} else { } else {
t->setCursor(sstate.cursor.par(), sstate.cursor.pos(), text_.setCursor(sstate.cursor.par(), sstate.cursor.pos(),
true, sstate.cursor.boundary()); true, sstate.cursor.boundary());
t->selection.cursor = t->cursor; text_.selection.cursor = text_.cursor;
t->selection.set(false); text_.selection.set(false);
} }
} }
@ -2008,9 +2007,9 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
if (paragraphs.size() == 1 && paragraphs.begin()->empty()) { if (paragraphs.size() == 1 && paragraphs.begin()->empty()) {
// no data, resize not neccessary! // no data, resize not neccessary!
// we have to do this as a fixed width may have changed! // we have to do this as a fixed width may have changed!
saveLyXTextState(&text_); saveLyXTextState();
text_.init(bv, true); text_.init(bv, true);
restoreLyXTextState(&text_); restoreLyXTextState();
return; return;
} }
@ -2024,22 +2023,21 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
if (!force && getMaxWidth(bv, this) < 0) if (!force && getMaxWidth(bv, this) < 0)
return; return;
LyXText * t = &text_; saveLyXTextState();
saveLyXTextState(t);
for_each(const_cast<ParagraphList&>(paragraphs).begin(), for_each(const_cast<ParagraphList&>(paragraphs).begin(),
const_cast<ParagraphList&>(paragraphs).end(), const_cast<ParagraphList&>(paragraphs).end(),
boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv)); boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv));
t->init(bv, true); text_.init(bv, true);
restoreLyXTextState(t); restoreLyXTextState();
if (the_locking_inset) { if (the_locking_inset) {
inset_x = cix(bv) - top_x + drawTextXOffset; inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset; inset_y = ciy(bv) + drawTextYOffset;
} }
t->top_y(bv->screen().topCursorVisible(t)); text_.top_y(bv->screen().topCursorVisible(&text_));
if (!owner()) { if (!owner()) {
const_cast<InsetText*>(this)->updateLocal(bv, FULL, false); const_cast<InsetText*>(this)->updateLocal(bv, FULL, false);
// this will scroll the screen such that the cursor becomes visible // this will scroll the screen such that the cursor becomes visible
@ -2052,25 +2050,24 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
void InsetText::reinitLyXText() const void InsetText::reinitLyXText() const
{ {
LyXText * t = &text_;
BufferView * bv = text_.bv_owner; BufferView * bv = text_.bv_owner;
if (!bv) if (!bv)
return; return;
saveLyXTextState(t); saveLyXTextState();
for_each(const_cast<ParagraphList&>(paragraphs).begin(), for_each(const_cast<ParagraphList&>(paragraphs).begin(),
const_cast<ParagraphList&>(paragraphs).end(), const_cast<ParagraphList&>(paragraphs).end(),
boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv)); boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv));
t->init(bv, true); text_.init(bv, true);
restoreLyXTextState(t); restoreLyXTextState();
if (the_locking_inset) { if (the_locking_inset) {
inset_x = cix(bv) - top_x + drawTextXOffset; inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset; inset_y = ciy(bv) + drawTextYOffset;
} }
t->top_y(bv->screen().topCursorVisible(t)); text_.top_y(bv->screen().topCursorVisible(&text_));
if (!owner()) { if (!owner()) {
const_cast<InsetText*>(this)->updateLocal(bv, FULL, false); const_cast<InsetText*>(this)->updateLocal(bv, FULL, false);
// this will scroll the screen such that the cursor becomes visible // this will scroll the screen such that the cursor becomes visible

View File

@ -322,9 +322,9 @@ private:
/// ///
void clearInset(BufferView *, int start_x, int baseline) const; void clearInset(BufferView *, int start_x, int baseline) const;
/// ///
void saveLyXTextState(LyXText *) const; void saveLyXTextState() const;
/// ///
void restoreLyXTextState(LyXText *) const; void restoreLyXTextState() const;
/// ///
void collapseParagraphs(BufferView *); void collapseParagraphs(BufferView *);