A couple of changing resulting from gcc 3.4 debug mode testing.

Dont copy singular iterators.
Dont compare iterators from different containers.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8121 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-11-22 14:44:59 +00:00
parent e506fc5915
commit 7dd8cd705b
12 changed files with 205 additions and 131 deletions

View File

@ -908,12 +908,12 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
cmd1.y += bv_->top_y();
res = bv_->cursor().innerText()->dispatch(cmd1);
}
if (bv_->fitCursor() || res.update()) {
bv_->update();
bv_->cursor().updatePos();
}
return true;
}
@ -937,14 +937,14 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
// handle this event.
// built temporary path to inset
InsetOld * inset = insetFromCoords(bv_, cmd.x, cmd.y);
InsetOld * inset = insetFromCoords(bv_, cmd.x, cmd.y);
FuncRequest cmd1(cmd, bv_);
DispatchResult res;
// try to dispatch to that inset
if (inset) {
FuncRequest cmd2 = cmd1;
lyxerr << "dispatching action " << cmd2.action
lyxerr << "dispatching action " << cmd2.action
<< " to inset " << inset << endl;
cmd2.x -= inset->x();
cmd2.y -= inset->y();
@ -957,7 +957,7 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
switch (res.val()) {
case FINISHED:
case FINISHED_RIGHT:
case FINISHED_UP:
case FINISHED_UP:
case FINISHED_DOWN:
theTempCursor.pop();
bv_->cursor() = theTempCursor;
@ -982,7 +982,7 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
res = bv_->cursor().innerText()->dispatch(cmd1);
if (bv_->fitCursor() || res.update())
bv_->update();
//return DispatchResult(true, true);
}
// see workAreaKeyPress
@ -1350,5 +1350,3 @@ void BufferView::Pimpl::updateParagraphDialog()
data = "update " + tostr(accept) + '\n' + data;
bv_->owner()->getDialogs().update("paragraph", data);
}

View File

@ -1,3 +1,22 @@
2003-11-22 Lars Gullik Bjonnes <larsbj@gullik.net>
* text3.C (dispatch): [PRIOR] make sure that we do not compare
iterators from different ParagraphList containers.
[NEXT] ditto
* text2.C (LyXText): change order of initialization slightly
(operator=): new function. copy all variables except cache_par_
(moveUp): make sure that we do not compare iterators from
different ParagraphList constainers.
(moveDown): ditto
* text.C (firstPar): new function
(lastPar): new function
(endPar): new function
* lyxtext.h: move things around and group public functions, public
variables, private functions, private variables
2003-11-21 Michael Schmitt <michael.schmitt@teststep.org>
* factory.C: change call to InsetERT constructor to avoid
@ -17,7 +36,7 @@
2003-11-21 Alfredo Braunstein <abraunst@lyx.org>
* lyxtext.h: x0_,y0_ -> xo_,yo_
* lyxtext.h: x0_,y0_ -> xo_,yo_
* text2.C (cursorUp, cursorDown): adjust + some cursorRow use
* text3.C (checkInsetHit): fix coordinates using absolute xo_,yo_
* rowpainter.C (paintRows): paint full paragraphs
@ -67,8 +86,8 @@
2003-11-14 Martin Vermeer <martin.vermeer@hut.fi>
* lyxlayout.[Ch]:
* output_docbook.C: XML sanitation: new layout
* lyxlayout.[Ch]:
* output_docbook.C: XML sanitation: new layout
parameters InnerTag and CommandDepth
2003-11-13 Martin Vermeer <martin.vermeer@hut.fi>
@ -123,7 +142,7 @@
* cursor.[Ch] (updatePos): new function for updating the y
position of the tip inset
* bufferview_funcs.C (put_selection_at):
* bufferview_funcs.C (put_selection_at):
* BufferView_pimpl.C (workAreaDispatch): rationalise update calls
2003-11-11 André Pönitz <poenitz@gmx.net>
@ -182,7 +201,7 @@
2003-11-07 Alfredo Braunstein <abraunst@libero.it>
* PosIterator.[Ch]: replace the stack with a vector, add inset
* PosIterator.[Ch]: replace the stack with a vector, add inset
accesor
* iterators.[C]: adjust
@ -204,9 +223,9 @@
2003-11-05 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* output_linuxdoc.h:
* output_plaintext.h:
* output.h:
* output_linuxdoc.h:
* output_plaintext.h:
* output.h:
* output_docbook.h: add #include statements
2003-11-05 José Matos <jamatos@lyx.org>
@ -232,12 +251,12 @@
* paragraph_pimpl.[Ch]:
* tabular.[Ch]: rename ascii to plaintext
and LatexRunParams to OutputParams.
2003-11-05 Alfredo Braunstein <abraunst@libero.it>
* iterators.[Ch] (text): require bv argument
* undo.C (recordUndo):
* lyxfunc.C (dispatch):
* undo.C (recordUndo):
* lyxfunc.C (dispatch):
* bufferview_funcs.C (put_selection_at): adjust
2003-11-05 João Luis M. Assirati <assirati@fma.if.usp.br>
@ -278,7 +297,7 @@
* BufferView.[Ch]:
* lyxtext.h:
* text.C: remove dead spellcheck code
2003-11-04 Lars Gullik Bjønnes <larsbj@gullik.net>
* dispatchresult.h: add a val setter

View File

@ -88,7 +88,7 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
pop(i);
cmd = FuncRequest(bv_, LFUN_FINISHED_RIGHT);
break;
case FINISHED_UP:
case FINISHED_UP:
pop(i);
cmd = FuncRequest(bv_, LFUN_FINISHED_UP);
break;
@ -174,7 +174,7 @@ void LCursor::updatePos()
void LCursor::getDim(int & asc, int & desc) const
{
LyXText * txt = innerText();
if (txt) {
Row const & row = *txt->cursorRow();
asc = row.baseline();
@ -217,7 +217,7 @@ UpdatableInset * LCursor::innerInsetOfType(int code) const
return 0;
}
InsetTabular * LCursor::innerInsetTabular() const
{
return static_cast<InsetTabular *>

View File

@ -42,7 +42,7 @@ void InsetCharStyle::init()
}
InsetCharStyle::InsetCharStyle(BufferParams const & bp,
InsetCharStyle::InsetCharStyle(BufferParams const & bp,
CharStyles::iterator cs)
: InsetCollapsable(bp)
{
@ -212,4 +212,3 @@ void InsetCharStyleParams::read(LyXLex & lex)
type = lex.getString();
}
}

View File

@ -445,7 +445,7 @@ void InsetTabular::lfunMouseMotion(FuncRequest const & cmd)
void InsetTabular::edit(BufferView * bv, bool left)
{
lyxerr << "InsetTabular::edit: " << this
<< " first text: " << tabular.cell_info[0][0].inset.getText(0)
<< " first text: " << tabular.cell_info[0][0].inset.getText(0)
<< " first cell: " << &tabular.cell_info[0][0].inset << endl;
finishUndo();
@ -1897,7 +1897,7 @@ bool InsetTabular::copySelection(BufferView * bv)
true, true);
ostringstream os;
OutputParams const runparams;
OutputParams const runparams;
paste_tabular->plaintext(*bv->buffer(), os, runparams,
ownerPar(*bv->buffer(), this).params().depth(), true, '\t');
bv->stuffClipboard(os.str());

View File

@ -261,7 +261,7 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
text_.xo_ = x;
text_.yo_ = y + bv->top_y();
paintTextInset(*bv, text_, x, y);
if (drawFrame_ == ALWAYS || drawFrame_ == LOCKED)
@ -310,7 +310,7 @@ string const InsetText::editMessage() const
void InsetText::sanitizeEmptyText(BufferView * bv)
{
if (paragraphs.size() == 1
&& paragraphs.begin()->empty()
&& paragraphs.begin()->empty()
&& bv->getParentLanguage(this) != text_.current_font.language()) {
LyXFont font(LyXFont::ALL_IGNORE);
font.setLanguage(bv->getParentLanguage(this));
@ -360,7 +360,7 @@ DispatchResult InsetText::priv_dispatch(FuncRequest const & cmd,
{
lyxerr << "InsetText::priv_dispatch (begin), act: "
<< cmd.action << " " << endl;
BufferView * bv = cmd.view();
setViewCache(bv);

View File

@ -368,7 +368,7 @@ ParIterator::ParIterator(PosIterator const & pos)
: pimpl_(new Pimpl)
{
int const size = pos.stack_.size();
for (int i = 0; i < size; ++i) {
PosIteratorItem const & it = pos.stack_[i];
ParPosition pp(it.pit, *it.pl);

View File

@ -49,23 +49,16 @@ class VSpace;
// The inheritance from TextCursor should go. It's just there to ease
// transition...
class LyXText : public TextCursor {
// Public Functions
public:
/// Constructor
LyXText(BufferView *, InsetText *, bool ininset, ParagraphList & plist);
// Copy assignment
LyXText & operator=(LyXText const &);
void init(BufferView *);
///
int height;
///
unsigned int width;
/// the current font settings
LyXFont current_font;
/// the current font
LyXFont real_current_font;
/// our buffer's default layout font
LyXFont defaultfont_;
///
InsetText * inset_owner;
/// update all cached row positions
void updateRowPositions();
@ -120,10 +113,6 @@ public:
/// rebreaks the cursor par
void redoParagraph();
private:
/// rebreaks the given par
void redoParagraphInternal(ParagraphList::iterator pit);
public:
///
void toggleFree(LyXFont const &, bool toggleall = false);
@ -152,10 +141,6 @@ public:
friend class LyXScreen;
public:
/// only the top-level LyXText has this non-zero
BufferView * bv_owner;
/// returns an iterator pointing to a cursor paragraph
ParagraphList::iterator getPar(LyXCursor const & cursor) const;
///
@ -320,24 +305,6 @@ public:
///
int workWidth() const;
private:
///
float getCursorX(ParagraphList::iterator pit,
Row const & row, lyx::pos_type pos, bool boundary) const;
/// used in setlayout
void makeFontEntriesLayoutSpecific(BufferParams const &, Paragraph & par);
/// Calculate and set the height of the row
void setHeightOfRow(ParagraphList::iterator, Row & row);
// fix the cursor `cur' after a characters has been deleted at `where'
// position. Called by deleteEmptyParagraphMechanism
void fixCursorAfterDelete(LyXCursor & cur, LyXCursor const & where);
/// delete double space (false) or empty paragraphs (true) around old_cursor
bool deleteEmptyParagraphMechanism(LyXCursor const & old_cursor);
public:
/** Updates all counters starting BEHIND the row. Changed paragraphs
* with a dynamic left margin will be rebroken. */
void updateCounters();
@ -369,46 +336,6 @@ public:
* the cursor and when creating a visible row */
void prepareToPrint(ParagraphList::iterator pit, Row & row) const;
private:
///
void setCounter(Buffer const &, ParagraphList::iterator pit);
///
void deleteWordForward();
///
void deleteWordBackward();
///
void deleteLineForward();
/// sets row.end to the pos value *after* which a row should break.
/// for example, the pos after which isNewLine(pos) == true
void rowBreakPoint(ParagraphList::iterator pit, Row & row) const;
/// sets row.witdh to the minimum space a row needs on the screen in pixel
void fill(ParagraphList::iterator pit, Row & row, int workwidth) const;
/**
* returns the minimum space a manual label needs on the
* screen in pixels
*/
int labelFill(ParagraphList::iterator pit, Row const & row) const;
/// FIXME
int labelEnd(ParagraphList::iterator pit, Row const & row) const;
///
void charInserted();
/// set 'number' font property
void number();
/// is the cursor paragraph right-to-left?
bool rtl() const;
public:
///
mutable Bidi bidi;
///
bool in_inset_;
///
ParagraphList * paragraphs_;
//
// special owner functions
///
@ -417,6 +344,13 @@ public:
/// return true if this is owned by an inset.
bool isInInset() const;
///
ParagraphList::iterator firstPar() const;
///
ParagraphList::iterator lastPar() const;
///
ParagraphList::iterator endPar() const;
/// return first row of text
RowList::iterator firstRow() const;
/// return last row of text
@ -461,6 +395,91 @@ public:
///
bool checkAndActivateInset(bool front);
// Public Variables
public:
///
int height;
///
unsigned int width;
/// the current font settings
LyXFont current_font;
/// the current font
LyXFont real_current_font;
/// our buffer's default layout font
LyXFont defaultfont_;
///
InsetText * inset_owner;
/// only the top-level LyXText has this non-zero
BufferView * bv_owner;
///
mutable Bidi bidi;
///
bool in_inset_;
///
ParagraphList * paragraphs_;
/// absolute document pixel coordinates of this LyXText
int xo_;
int yo_;
// Private Functions
private:
/// rebreaks the given par
void redoParagraphInternal(ParagraphList::iterator pit);
///
float getCursorX(ParagraphList::iterator pit,
Row const & row, lyx::pos_type pos, bool boundary) const;
/// used in setlayout
void makeFontEntriesLayoutSpecific(BufferParams const &, Paragraph & par);
/// Calculate and set the height of the row
void setHeightOfRow(ParagraphList::iterator, Row & row);
// fix the cursor `cur' after a characters has been deleted at `where'
// position. Called by deleteEmptyParagraphMechanism
void fixCursorAfterDelete(LyXCursor & cur, LyXCursor const & where);
/// delete double space (false) or empty paragraphs (true) around old_cursor
bool deleteEmptyParagraphMechanism(LyXCursor const & old_cursor);
///
void setCounter(Buffer const &, ParagraphList::iterator pit);
///
void deleteWordForward();
///
void deleteWordBackward();
///
void deleteLineForward();
/// sets row.end to the pos value *after* which a row should break.
/// for example, the pos after which isNewLine(pos) == true
void rowBreakPoint(ParagraphList::iterator pit, Row & row) const;
/// sets row.witdh to the minimum space a row needs on the screen in pixel
void fill(ParagraphList::iterator pit, Row & row, int workwidth) const;
/**
* returns the minimum space a manual label needs on the
* screen in pixels
*/
int labelFill(ParagraphList::iterator pit, Row const & row) const;
/// FIXME
int labelEnd(ParagraphList::iterator pit, Row const & row) const;
///
void charInserted();
/// set 'number' font property
void number();
/// is the cursor paragraph right-to-left?
bool rtl() const;
// Private Variables
private:
/// prohibit this as long as there are back pointers...
@ -469,11 +488,6 @@ private:
// cache for cursorPar()
mutable ParagraphList::iterator cache_par_;
mutable int cache_pos_;
public:
/// absolute document pixel coordinates of this LyXText
int xo_;
int yo_;
};
/// return the default height of a row in pixels, considering font zoom

View File

@ -313,7 +313,7 @@ void InsetFormulaBase::edit(BufferView * bv, bool left)
lyxerr << "Called FormulaBase::edit" << endl;
releaseMathCursor(bv);
mathcursor = new MathCursor(this, left);
bv->cursor().push(this);
bv->cursor().push(this);
// if that is removed, we won't get the magenta box when entering an
// inset for the first time
bv->update();
@ -327,7 +327,7 @@ void InsetFormulaBase::edit(BufferView * bv, int x, int y)
mathcursor = new MathCursor(this, true);
//metrics(bv);
mathcursor->setPos(x + xo_, y + yo_);
bv->cursor().push(this);
bv->cursor().push(this);
// if that is removed, we won't get the magenta box when entering an
// inset for the first time
bv->update();

View File

@ -1479,7 +1479,7 @@ LyXText::getRowNearY(int y, ParagraphList::iterator & pit) const
do {
--rit;
} while (rit != rbegin && int(pit->y + rit->y_offset()) > y);
return rit;
#else
pit = boost::prior(ownerParagraphs().end());
@ -1507,18 +1507,36 @@ RowList::iterator LyXText::firstRow() const
}
ParagraphList::iterator LyXText::firstPar() const
{
return ownerParagraphs().begin();
}
RowList::iterator LyXText::lastRow() const
{
return boost::prior(endRow());
}
ParagraphList::iterator LyXText::lastPar() const
{
return boost::prior(endPar());
}
RowList::iterator LyXText::endRow() const
{
return ownerParagraphs().back().rows.end();
}
ParagraphList::iterator LyXText::endPar() const
{
return ownerParagraphs().end();
}
void LyXText::nextRow(ParagraphList::iterator & pit,
RowList::iterator & rit) const
{

View File

@ -73,11 +73,37 @@ using std::string;
LyXText::LyXText(BufferView * bv, InsetText * inset, bool ininset,
ParagraphList & paragraphs)
: height(0), width(0), inset_owner(inset), bv_owner(bv),
in_inset_(ininset), paragraphs_(&paragraphs),
cache_pos_(-1), xo_(0), yo_(0)
in_inset_(ininset), paragraphs_(&paragraphs), xo_(0), yo_(0),
cache_pos_(-1)
{}
LyXText & LyXText::operator=(LyXText const & lt)
{
// Copy all public variables
height = lt.height;
width = lt.width;
current_font = lt.current_font;
real_current_font = lt.real_current_font;
defaultfont_ = lt.defaultfont_;
inset_owner = lt.inset_owner;
bv_owner = lt.bv_owner;
bidi = lt.bidi;
in_inset_ = lt.in_inset_;
paragraphs_ = lt.paragraphs_;
xo_ = lt.xo_;
yo_ = lt.yo_;
// Copy all the private variables
// we cannot initailize a iterator with a singular iterator.
//cache_par_ = lt.cache_par_;
cache_pos_ = lt.cache_pos_;
return *this;
}
void LyXText::init(BufferView * bview)
{
bv_owner = bview;
@ -275,7 +301,7 @@ void LyXText::toggleInset()
}
// used in setLayout
// used in setLayout
// Asger is not sure we want to do this...
void LyXText::makeFontEntriesLayoutSpecific(BufferParams const & params,
Paragraph & par)
@ -1029,7 +1055,7 @@ void LyXText::insertInset(InsetOld * inset)
// does not return the inset!
if (isHighlyEditableInset(inset))
cursorLeft(true);
unFreezeUndo();
}
@ -1642,7 +1668,7 @@ DispatchResult LyXText::moveLeftIntern(bool front,
DispatchResult LyXText::moveUp()
{
if (cursorRow() == firstRow())
if (cursorPar() == firstPar() && cursorRow() == firstRow())
return DispatchResult(false, FINISHED_UP);
cursorUp(false);
clearSelection();
@ -1652,7 +1678,7 @@ DispatchResult LyXText::moveUp()
DispatchResult LyXText::moveDown()
{
if (cursorRow() == lastRow())
if (cursorPar() == lastPar() && cursorRow() == lastRow())
return DispatchResult(false, FINISHED_DOWN);
cursorDown(false);
clearSelection();
@ -1711,7 +1737,7 @@ void LyXText::cursorUp(bool selecting)
int x = bv()->x_target() - xo_;
int y = cursor.y() - row.baseline() - 1;
setCursorFromCoordinates(x, y);
if (!selecting) {
int y_abs = y + yo_ - bv()->top_y();
InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y_abs);

View File

@ -263,7 +263,7 @@ InsetOld * LyXText::checkInsetHit(int x, int y)
bv()->top_y() - yo_,
bv()->top_y() - yo_ + bv()->workHeight(),
pit, end);
lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
for ( ; pit != end; ++pit) {
InsetList::iterator iit = pit->insetlist.begin();
@ -394,7 +394,7 @@ void LyXText::cursorNext()
// simplest solution is to move to the next row instead.
cursorDown(true);
}
bv()->updateScrollbar();
finishUndo();
}
@ -679,7 +679,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
if (!selection.mark())
clearSelection();
finishChange(bv, false);
if (cursorRow() == firstRow())
if (cursorPar() == firstPar() && cursorRow() == firstRow())
return DispatchResult(false, FINISHED_UP);
cursorPrevious();
break;
@ -688,7 +688,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
if (!selection.mark())
clearSelection();
finishChange(bv, false);
if (cursorRow() == lastRow())
if (cursorPar() == lastPar() && cursorRow() == lastRow())
return DispatchResult(false, FINISHED_DOWN);
cursorNext();
break;
@ -1285,7 +1285,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
// Clear the selection
clearSelection();
// Right click on a footnote flag opens float menu
if (cmd.button() == mouse_button::button3) {
selection_possible = false;
@ -1323,7 +1323,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
return DispatchResult(true, false);
selection_possible = false;
if (cmd.button() == mouse_button::button2)
break;
@ -1521,7 +1521,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_FREEFONT_UPDATE:
update_and_apply_freefont(bv, this, cmd.argument);
break;
case LFUN_FINISHED_LEFT:
lyxerr << "swallow LFUN_FINISHED_LEFT" << endl;
if (rtl())