From 064714a10232d49de3d1dd46f6903b6ab5d27c48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Mon, 17 Mar 2003 16:25:00 +0000 Subject: [PATCH] Remove the BufferView* arg from almost all LyXText class functions. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6519 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 4 +- src/BufferView.C | 48 +- src/BufferView_pimpl.C | 64 +-- src/ChangeLog | 22 +- src/CutAndPaste.C | 34 +- src/ParagraphParameters.C | 3 +- src/buffer.C | 6 +- src/bufferview_funcs.C | 8 +- src/factory.C | 6 +- src/frontends/ChangeLog | 8 +- src/frontends/controllers/ControlError.C | 1 - src/frontends/screen.C | 17 +- src/insets/ChangeLog | 6 +- src/insets/inset.h | 2 +- src/insets/insetert.C | 4 +- src/insets/insettabular.C | 2 +- src/insets/insettext.C | 142 +++--- src/insets/insettext.h | 2 +- src/insets/updatableinset.C | 4 +- src/lyx_cb.C | 4 +- src/lyxfind.C | 26 +- src/lyxfunc.C | 32 +- src/lyxtext.h | 210 ++++----- src/mathed/math_hullinset.C | 2 +- src/mathed/math_parser.C | 2 +- src/rowpainter.C | 16 +- src/tex2lyx/tex2lyx.C | 109 ++--- src/text.C | 523 +++++++++++---------- src/text2.C | 570 +++++++++++------------ src/text3.C | 402 ++++++++-------- src/trans_mgr.C | 4 +- src/undo_funcs.C | 24 +- 32 files changed, 1155 insertions(+), 1152 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 701bbdf17c..083b4939ad 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -13,12 +13,10 @@ src/frontends/controllers/biblio.C src/frontends/controllers/character.C src/frontends/controllers/ControlAboutlyx.C src/frontends/controllers/ControlBibtex.C -src/frontends/controllers/ControlCharacter.C src/frontends/controllers/ControlDocument.C src/frontends/controllers/ControlExternal.C src/frontends/controllers/ControlGraphics.C src/frontends/controllers/ControlInclude.C -src/frontends/controllers/ControlParagraph.C src/frontends/controllers/ControlPreamble.C src/frontends/controllers/ControlPrefs.C src/frontends/controllers/ControlPrint.C @@ -135,6 +133,7 @@ src/importer.C src/insets/insetbibtex.C src/insets/inset.C src/insets/insetcaption.C +src/insets/insetenv.C src/insets/inseterror.C src/insets/insetert.C src/insets/insetexternal.C @@ -180,6 +179,7 @@ src/mathed/ref_inset.C src/MenuBackend.C src/paragraph.C src/paragraph_funcs.C +src/ParagraphParameters.C src/rowpainter.C src/support/filetools.C src/tabular.C diff --git a/src/BufferView.C b/src/BufferView.C index cfbf33f1e1..50b493990e 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -349,7 +349,7 @@ bool BufferView::removeAutoInsets() // loop once at most. However for safety we iterate rather than just // make this an if () conditional. while ((cursor_par_prev || cursor_par_next) - && text->setCursor(this, + && text->setCursor( cursor_par_prev ? cursor_par_prev : cursor_par_next, 0)) { // We just removed cursor_par so have to fix the "cursor" @@ -379,7 +379,7 @@ bool BufferView::removeAutoInsets() Paragraph * par_prev = par ? par->previous() : 0; bool removed = false; - if (text->setCursor(this, par, 0) + if (text->setCursor(par, 0) && cursor_par == par_prev) { // The previous setCursor line was deleted and that // was the cursor_par line. This can only happen if an @@ -443,14 +443,14 @@ bool BufferView::removeAutoInsets() } if (removed) { found = true; - text->redoParagraph(this); + text->redoParagraph(); } } // It is possible that the last line is empty if it was cursor_par // and/or only had an error inset on it. So we set the cursor to the // start of the doc to force its removal and ensure a valid saved cursor - if (text->setCursor(this, text->ownerParagraph(), 0) + if (text->setCursor(text->ownerParagraph(), 0) && 0 == cursor_par_next) { cursor_par = cursor_par_prev; cursor_pos = cursor_par->size(); @@ -463,7 +463,7 @@ bool BufferView::removeAutoInsets() } // restore the original cursor in its corrected location. - text->setCursorIntern(this, cursor_par, cursor_pos); + text->setCursorIntern(cursor_par, cursor_pos); return found; } @@ -504,13 +504,13 @@ void BufferView::insertErrors(TeXErrors & terr) freezeUndo(); InsetError * new_inset = new InsetError(msgtxt); - text->setCursorIntern(this, texrowpar, tmppos); - text->insertInset(this, new_inset); - text->fullRebreak(this); + text->setCursorIntern(texrowpar, tmppos); + text->insertInset(new_inset); + text->fullRebreak(); unFreezeUndo(); } // Restore the cursor position - text->setCursorIntern(this, cursor.par(), cursor.pos()); + text->setCursorIntern(cursor.par(), cursor.pos()); } @@ -529,7 +529,7 @@ void BufferView::setCursorFromRow(int row) } else { texrowpar = buffer()->getParFromID(tmpid); } - text->setCursor(this, texrowpar, tmppos); + text->setCursor(texrowpar, tmppos); } @@ -552,7 +552,7 @@ bool BufferView::gotoLabel(string const & label) if (find(labels.begin(),labels.end(),label) != labels.end()) { beforeChange(text); - text->setCursor(this, it.getPar(), it.getPos()); + text->setCursor(it.getPar(), it.getPos()); text->selection.cursor = text->cursor; update(text, BufferView::SELECT|BufferView::FITCUR); return true; @@ -608,7 +608,7 @@ void BufferView::copyEnvironment() void BufferView::pasteEnvironment() { if (available()) { - text->pasteEnvironmentType(this); + text->pasteEnvironmentType(); owner()->message(_("Paragraph environment type set")); update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } @@ -623,7 +623,7 @@ WordLangTuple const BufferView::nextWord(float & value) return WordLangTuple(); } - return text->selectNextWordToSpellcheck(this, value); + return text->selectNextWordToSpellcheck(value); } @@ -636,7 +636,7 @@ void BufferView::selectLastWord() hideCursor(); beforeChange(text); text->selection.cursor = cur; - text->selectSelectedWord(this); + text->selectSelectedWord(); toggleSelection(false); update(text, BufferView::SELECT|BufferView::FITCUR); } @@ -648,7 +648,7 @@ void BufferView::endOfSpellCheck() hideCursor(); beforeChange(text); - text->selectSelectedWord(this); + text->selectSelectedWord(); text->clearSelection(); update(text, BufferView::SELECT|BufferView::FITCUR); } @@ -669,9 +669,9 @@ void BufferView::replaceWord(string const & replacestring) // clear the selection (if there is any) toggleSelection(false); - tt->replaceSelectionWithString(this, replacestring); + tt->replaceSelectionWithString(replacestring); - tt->setSelectionRange(this, replacestring.length()); + tt->setSelectionRange(replacestring.length()); // Go back so that replacement string is also spellchecked for (string::size_type i = 0; i < replacestring.length() + 1; ++i) { @@ -709,12 +709,12 @@ bool BufferView::lockInset(UpdatableInset * inset) InsetList::iterator end = pit->insetlist.end(); for (; it != end; ++it) { if (it.getInset() == inset) { - text->setCursorIntern(this, &*pit, it.getPos()); + text->setCursorIntern(&*pit, it.getPos()); theLockingInset(inset); return true; } if (it.getInset()->getInsetFromID(id)) { - text->setCursorIntern(this, &*pit, it.getPos()); + text->setCursorIntern(&*pit, it.getPos()); it.getInset()->edit(this); return theLockingInset()->lockInsetInInset(this, inset); } @@ -736,7 +736,7 @@ void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc) cursor.par()->isInset(cursor.pos() - 1) && (cursor.par()->getInset(cursor.pos() - 1) == locking_inset)) - text->setCursor(this, cursor, + text->setCursor(cursor, cursor.par(), cursor.pos() - 1); LyXScreen::Cursor_Shape shape = LyXScreen::BAR_SHAPE; LyXText * txt = getLyXText(); @@ -852,14 +852,14 @@ bool BufferView::ChangeInsets(Inset::Code code, // The test it.size()==1 was needed to prevent crashes. // How to set the cursor corretly when it.size()>1 ?? if (it.size() == 1) { - text->setCursorIntern(this, par, 0); - text->redoParagraphs(this, text->cursor, + text->setCursorIntern(par, 0); + text->redoParagraphs(text->cursor, text->cursor.par()->next()); - text->fullRebreak(this); + text->fullRebreak(); } } } - text->setCursorIntern(this, cursor.par(), cursor.pos()); + text->setCursorIntern(cursor.par(), cursor.pos()); return need_update; } diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index c9489f0395..2613df3d5d 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -308,13 +308,13 @@ int BufferView::Pimpl::resizeCurrentBuffer() // Mechanism when setting the cursor. bv_->text->selection.mark(mark_set); if (selection) { - bv_->text->setCursor(bv_, selstartpar, selstartpos); + bv_->text->setCursor(selstartpar, selstartpos); bv_->text->selection.cursor = bv_->text->cursor; - bv_->text->setCursor(bv_, selendpar, selendpos); - bv_->text->setSelection(bv_); - bv_->text->setCursor(bv_, par, pos); + bv_->text->setCursor(selendpar, selendpos); + bv_->text->setSelection(); + bv_->text->setCursor(par, pos); } else { - bv_->text->setCursor(bv_, par, pos); + bv_->text->setCursor(par, pos); bv_->text->selection.cursor = bv_->text->cursor; bv_->text->selection.set(false); } @@ -376,9 +376,9 @@ void BufferView::Pimpl::scrollDocView(int value) int const last = static_cast((bv_->text->top_y() + workarea().workHeight() - height)); if (vbt->cursor.y() < first) - vbt->setCursorFromCoordinates(bv_, 0, first); + vbt->setCursorFromCoordinates(0, first); else if (vbt->cursor.y() > last) - vbt->setCursorFromCoordinates(bv_, 0, last); + vbt->setCursorFromCoordinates(0, last); } @@ -503,19 +503,19 @@ void BufferView::Pimpl::update() screen().update(*bv_); bool fitc = false; while (bv_->text->status() == LyXText::CHANGED_IN_DRAW) { - bv_->text->fullRebreak(bv_); - bv_->text->setCursor(bv_, bv_->text->cursor.par(), + bv_->text->fullRebreak(); + bv_->text->setCursor(bv_->text->cursor.par(), bv_->text->cursor.pos()); if (bv_->text->selection.set()) { - bv_->text->setCursor(bv_, bv_->text->selection.start, + bv_->text->setCursor(bv_->text->selection.start, bv_->text->selection.start.par(), bv_->text->selection.start.pos()); - bv_->text->setCursor(bv_, bv_->text->selection.end, + bv_->text->setCursor(bv_->text->selection.end, bv_->text->selection.end.par(), bv_->text->selection.end.pos()); } fitc = true; - bv_->text->postPaint(*bv_, 0); + bv_->text->postPaint(0); screen().update(*bv_); } @@ -574,7 +574,7 @@ void BufferView::Pimpl::update(LyXText * text, BufferView::UpdateCodes f) text->selection.cursor = text->cursor; } - text->fullRebreak(bv_); + text->fullRebreak(); if (text->inset_owner) { text->inset_owner->setUpdateStatus(bv_, InsetText::NONE); @@ -680,7 +680,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i) if (!par) return; - bv_->text->setCursor(bv_, par, + bv_->text->setCursor(par, min(par->size(), saved_positions[i].par_pos)); update(bv_->text, BufferView::SELECT | BufferView::FITCUR); @@ -940,7 +940,7 @@ void BufferView::Pimpl::trackChanges() buf->undostack.clear(); } else { bv_->update(bv_->text, BufferView::SELECT | BufferView::FITCUR); - bv_->text->setCursor(bv_, &(*buf->paragraphs.begin()), 0); + bv_->text->setCursor(&(*buf->paragraphs.begin()), 0); #warning changes FIXME //moveCursorUpdate(false); @@ -1224,7 +1224,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in) case LFUN_PARAGRAPH_APPLY: setParagraphParams(*bv_, ev.argument); break; - + case LFUN_THESAURUS_ENTRY: { string arg = ev.argument; @@ -1236,7 +1236,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in) // FIXME if (arg.size() > 100 || arg.empty()) { // Get word or selection - bv_->getLyXText()->selectWordWhenUnderCursor(bv_, LyXText::WHOLE_WORD); + bv_->getLyXText()->selectWordWhenUnderCursor(LyXText::WHOLE_WORD); arg = bv_->getLyXText()->selectionAsString(buffer_, false); // FIXME: where is getLyXText()->unselect(bv_) ? } @@ -1256,12 +1256,12 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in) case LFUN_ACCEPT_ALL_CHANGES: { bv_->update(bv_->text, BufferView::SELECT | BufferView::FITCUR); - bv_->text->setCursor(bv_, &(*bv_->buffer()->paragraphs.begin()), 0); + bv_->text->setCursor(&(*bv_->buffer()->paragraphs.begin()), 0); #warning FIXME changes //moveCursorUpdate(false); while (lyxfind::findNextChange(bv_)) { - bv_->getLyXText()->acceptChange(bv_); + bv_->getLyXText()->acceptChange(); } update(bv_->text, BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); @@ -1270,12 +1270,12 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in) case LFUN_REJECT_ALL_CHANGES: { bv_->update(bv_->text, BufferView::SELECT | BufferView::FITCUR); - bv_->text->setCursor(bv_, &(*bv_->buffer()->paragraphs.begin()), 0); + bv_->text->setCursor(&(*bv_->buffer()->paragraphs.begin()), 0); #warning FIXME changes //moveCursorUpdate(false); while (lyxfind::findNextChange(bv_)) { - bv_->getLyXText()->rejectChange(bv_); + bv_->getLyXText()->rejectChange(); } update(bv_->text, BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); @@ -1283,14 +1283,14 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in) } case LFUN_ACCEPT_CHANGE: { - bv_->getLyXText()->acceptChange(bv_); + bv_->getLyXText()->acceptChange(); update(bv_->text, BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); break; } case LFUN_REJECT_CHANGE: { - bv_->getLyXText()->rejectChange(bv_); + bv_->getLyXText()->rejectChange(); update(bv_->text, BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); break; @@ -1325,13 +1325,13 @@ bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout) beforeChange(bv_->text); if (!lout.empty()) { update(bv_->text, BufferView::SELECT|BufferView::FITCUR); - bv_->text->breakParagraph(bv_, bv_->buffer()->paragraphs); + bv_->text->breakParagraph(bv_->buffer()->paragraphs); update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); if (!bv_->text->cursor.par()->empty()) { bv_->text->cursorLeft(bv_); - bv_->text->breakParagraph(bv_, bv_->buffer()->paragraphs); + bv_->text->breakParagraph(bv_->buffer()->paragraphs); update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } @@ -1349,9 +1349,9 @@ bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout) lay = tclass.defaultLayoutName(); } - bv_->text->setLayout(bv_, lay); + bv_->text->setLayout(lay); - bv_->text->setParagraph(bv_, 0, 0, + bv_->text->setParagraph(0, 0, 0, 0, VSpace(VSpace::NONE), VSpace(VSpace::NONE), Spacing(), @@ -1361,7 +1361,7 @@ bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout) update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } - bv_->text->insertInset(bv_, inset); + bv_->text->insertInset(inset); update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); unFreezeUndo(); @@ -1377,7 +1377,7 @@ void BufferView::Pimpl::updateInset(Inset * inset, bool mark_dirty) // first check for locking insets if (bv_->theLockingInset()) { if (bv_->theLockingInset() == inset) { - if (bv_->text->updateInset(bv_, inset)) { + if (bv_->text->updateInset(inset)) { update(); if (mark_dirty) { buffer_->markDirty(); @@ -1386,7 +1386,7 @@ void BufferView::Pimpl::updateInset(Inset * inset, bool mark_dirty) return; } } else if (bv_->theLockingInset()->updateInsetInInset(bv_, inset)) { - if (bv_->text->updateInset(bv_, bv_->theLockingInset())) { + if (bv_->text->updateInset(bv_->theLockingInset())) { update(); if (mark_dirty) { buffer_->markDirty(); @@ -1406,7 +1406,7 @@ void BufferView::Pimpl::updateInset(Inset * inset, bool mark_dirty) hideCursor(); if (tl_inset == inset) { update(bv_->text, BufferView::UPDATE); - if (bv_->text->updateInset(bv_, inset)) { + if (bv_->text->updateInset(inset)) { if (mark_dirty) { update(bv_->text, BufferView::SELECT @@ -1420,7 +1420,7 @@ void BufferView::Pimpl::updateInset(Inset * inset, bool mark_dirty) } else if (static_cast(tl_inset) ->updateInsetInInset(bv_, inset)) { - if (bv_->text->updateInset(bv_, tl_inset)) { + if (bv_->text->updateInset(tl_inset)) { update(); updateScrollbar(); } diff --git a/src/ChangeLog b/src/ChangeLog index 133e85f568..ca18ae6bc9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2003-03-17 Lars Gullik Bjønnes + + * lyxtext.h: remove BufferView* as first arg from almost all class + functions. + * other files: adjust. + 2003-03-17 John Levon * lyxtext.h: @@ -17,11 +23,11 @@ * text3.C: add helper functions for setting refresh_row/y 2003-03-14 Kayvan Sylvan - - * paragraph_pimpl.C (simpleTeXSpecialChars): Added fix for the - newline inset which *can* get inserted in the pass_thru layouts. - This is primarily for literate documents. - + + * paragraph_pimpl.C (simpleTeXSpecialChars): Added fix for the + newline inset which *can* get inserted in the pass_thru layouts. + This is primarily for literate documents. + 2003-03-14 Dekel Tsur * buffer.C: increment LYX_FORMAT to 223 @@ -73,7 +79,7 @@ Probably only temporary. Let's see how things pan out. * BufferView.C (unlockInset): - * BufferView_pimpl.C (fitCursor): + * BufferView_pimpl.C (fitCursor): replace Dialogs::updateParagraph with dispatch(LFUN_PARAGRAPH_UPDATE). * BufferView_pimpl.C (dispatch): code for LFUNs LAYOUT_PARAGRAPH, @@ -90,8 +96,8 @@ * lyxfunc.C: * text3.C: - * factory.C: make it aware of InsetEnv - + * factory.C: make it aware of InsetEnv + 2003-03-13 Lars Gullik Bjønnes * text2.C (setCursor): never ask for one past last diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 57ab044cdb..c5c6a20824 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -224,11 +224,11 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar, pos = (*par)->size(); // many paragraphs - + // make a copy of the simple cut_buffer #if 1 ParagraphList::iterator it = paragraphs.begin(); - + ParagraphList simple_cut_clone; simple_cut_clone.insert(simple_cut_clone.begin(), new Paragraph(*it, false)); @@ -251,13 +251,13 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar, // Temporary set *par as previous of tmpbuf as we might have // to realize the font. tmpbuf->previous(*par); - + // make sure there is no class difference SwitchLayoutsBetweenClasses(textclass, tc, &*tmpbuf, current_view->buffer()->params); - + Paragraph::depth_type max_depth = (*par)->getMaxDepthAfter(); - + while (tmpbuf != paragraphs.end()) { // If we have a negative jump so that the depth would // go below 0 depth then we have to redo the delta to @@ -300,14 +300,14 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar, // make the buf exactly the same layout than // the cursor paragraph paragraphs.begin()->makeSameLayout(*par); - + // find the end of the buffer ParagraphList::iterator lastbuffer = paragraphs.begin(); while (boost::next(lastbuffer) != paragraphs.end()) ++lastbuffer; - + bool paste_the_end = false; - + // open the paragraph for inserting the buf // if necessary if (((*par)->size() > pos) || !(*par)->next()) { @@ -317,17 +317,17 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar, } // set the end for redoing later *endpar = (*par)->next()->next(); - + // paste it! lastbuffer->next((*par)->next()); (*par)->next()->previous(&*lastbuffer); - + (*par)->next(&*paragraphs.begin()); paragraphs.begin()->previous(*par); - + if ((*par)->next() == lastbuffer) lastbuffer = *par; - + mergeParagraph(current_view->buffer()->params, current_view->buffer()->paragraphs, *par); // store the new cursor position @@ -350,7 +350,7 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar, } // restore the simple cut buffer paragraphs = simple_cut_clone; - + return true; } @@ -408,10 +408,10 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1, InsetError * new_inset = new InsetError(s); LyXText * txt = current_view->getLyXText(); LyXCursor cur = txt->cursor; - txt->setCursorIntern(current_view, par, 0); - txt->insertInset(current_view, new_inset); - txt->fullRebreak(current_view); - txt->setCursorIntern(current_view, cur.par(), cur.pos()); + txt->setCursorIntern(par, 0); + txt->insertInset(new_inset); + txt->fullRebreak(); + txt->setCursorIntern(cur.par(), cur.pos()); unFreezeUndo(); } } diff --git a/src/ParagraphParameters.C b/src/ParagraphParameters.C index 70b002cfe6..b24aae0fd5 100644 --- a/src/ParagraphParameters.C +++ b/src/ParagraphParameters.C @@ -426,8 +426,7 @@ void setParagraphParams(BufferView & bv, string const & data) params.read(lex); LyXText * text = bv.getLyXText(); - text->setParagraph(&bv, - params.lineTop(), + text->setParagraph(params.lineTop(), params.lineBottom(), params.pagebreakTop(), params.pagebreakBottom(), diff --git a/src/buffer.C b/src/buffer.C index 52595e0130..358f27bc53 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -337,7 +337,7 @@ bool Buffer::readBody(LyXLex & lex, ParagraphList::iterator pit) } } else { // We are inserting into an existing document - users->text->breakParagraph(users, paragraphs); + users->text->breakParagraph(paragraphs); markDirty(); // We don't want to adopt the parameters from the @@ -406,8 +406,8 @@ bool Buffer::readBody(LyXLex & lex, ParagraphList::iterator pit) int Buffer::readParagraph(LyXLex & lex, string const & token, - ParagraphList & pars, ParagraphList::iterator & pit, - Paragraph::depth_type & depth) + ParagraphList & pars, ParagraphList::iterator & pit, + Paragraph::depth_type & depth) { static Change current_change; int unknown = 0; diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index feec11d5e8..d4e7acb404 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -236,9 +236,9 @@ void changeDepth(BufferView * bv, LyXText * text, int decInc) bv->hideCursor(); bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR); if (decInc >= 0) - text->incDepth(bv); + text->incDepth(); else - text->decDepth(bv); + text->decDepth(); if (text->inset_owner) bv->updateInset((Inset *)text->inset_owner, true); bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); @@ -398,7 +398,7 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall) bv->hideCursor(); bv->update(text, BufferView::SELECT | BufferView::FITCUR); - text->toggleFree(bv, font, toggleall); + text->toggleFree(font, toggleall); bv->update(text, BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); if (font.language() != ignore_language || @@ -408,7 +408,7 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall) if (cursor.boundary() != text->isBoundary(bv->buffer(), cursor.par(), cursor.pos(), text->real_current_font)) - text->setCursor(bv, cursor.par(), cursor.pos(), + text->setCursor(cursor.par(), cursor.pos(), false, !cursor.boundary()); } } diff --git a/src/factory.C b/src/factory.C index 3c2a1d52d9..c61872dd1a 100644 --- a/src/factory.C +++ b/src/factory.C @@ -112,7 +112,7 @@ Inset * createInset(FuncRequest const & cmd) // Try and generate a valid index entry. InsetCommandParams icp("index"); string const contents = cmd.argument.empty() ? - bv->getLyXText()->getStringToIndex(bv) : + bv->getLyXText()->getStringToIndex() : cmd.argument; icp.setContents(contents); @@ -200,14 +200,14 @@ Inset * createInset(FuncRequest const & cmd) return inset; } else if (name == "external") { - InsetExternal::Params iep; + InsetExternal::Params iep; InsetExternalMailer::string2params(cmd.argument, iep); InsetExternal * inset = new InsetExternal; inset->setFromParams(iep); return inset; } else if (name == "graphics") { - InsetGraphicsParams igp; + InsetGraphicsParams igp; InsetGraphicsMailer::string2params(cmd.argument, igp); InsetGraphics * inset = new InsetGraphics; string const fpath = cmd.view()->buffer()->filePath(); diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index ad046b787e..89657fd61e 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,7 @@ +2003-03-17 Lars Gullik Bjønnes + + * adjust for BufferView* arg removal from lyxtext. + 2003-03-17 John Levon * screen.h: @@ -8,7 +12,7 @@ * Dialogs.h: remove showParagraph and updateParagraph. * guiapi.[Ch]: remove gui_ShowParagraph and gui_UpdateParagraph. - + 2003-03-12 Angus Leeming * Dialogs.[Ch] (hide): rejig as a static method. Hide the signal @@ -101,7 +105,7 @@ * guiapi.[Ch]: provide a C-interface to the new Dialogs::show method. Retire the old functions that called dead Dialogs methods. - + 2003-02-21 Angus Leeming * Timeout.[Ch]: define a Timeout::Impl abstract base class from diff --git a/src/frontends/controllers/ControlError.C b/src/frontends/controllers/ControlError.C index fc9075e117..66857f6b66 100644 --- a/src/frontends/controllers/ControlError.C +++ b/src/frontends/controllers/ControlError.C @@ -28,4 +28,3 @@ void ControlError::clearParams() { params_.erase(); } - diff --git a/src/frontends/screen.C b/src/frontends/screen.C index 57be406c3d..65198c7f6f 100644 --- a/src/frontends/screen.C +++ b/src/frontends/screen.C @@ -357,7 +357,7 @@ void LyXScreen::redraw(LyXText * text, BufferView * bv) return; } - + workarea().getPainter().start(); @@ -434,24 +434,25 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv, RowPainter rp(*bv, *text, *row); if (rp.paint(y + yo, xo, y + text->top_y())) - text->markChangeInDraw(bv, row, prev); + text->markChangeInDraw(row, prev); internal = internal && (st != LyXText::CHANGED_IN_DRAW); while (internal && text->status() == LyXText::CHANGED_IN_DRAW) { - text->fullRebreak(bv); - text->setCursor(bv, text->cursor.par(), text->cursor.pos()); - text->postPaint(*bv, 0); + text->fullRebreak(); + text->setCursor(text->cursor.par(), + text->cursor.pos()); + text->postPaint(0); Row * prev = row->previous(); RowPainter rp(*bv, *text, *row); if (rp.paint(y + yo, xo, y + text->top_y())) - text->markChangeInDraw(bv, row, prev); + text->markChangeInDraw(row, prev); } y += row->height(); row = row->next(); } // maybe we have to clear the screen at the bottom - if ((y < y2) && text->isTopLevel()) { + if ((y < y2) && !text->isInInset()) { workarea().getPainter().fillRectangle(0, y, workarea().workWidth(), y2 - y, LColor::bottomarea); @@ -469,6 +470,6 @@ void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row, Row * prev = row->previous(); RowPainter rp(*bv, *text, *row); if (rp.paint(y, xo, y + text->top_y())) - text->markChangeInDraw(bv, row, prev); + text->markChangeInDraw(row, prev); } } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index f37aaed00c..3464d298e2 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,6 +1,10 @@ +2003-03-17 Lars Gullik Bjønnes + + * adjust for BufferView* arg removal from lyxtext. + 2003-03-17 John Levon - * most files: remove the "cleared" parameter + * most files: remove the "cleared" parameter to draw in favour of always clearing. Associated code removal. diff --git a/src/insets/inset.h b/src/insets/inset.h index 2ba03068fc..0f4815037a 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -323,7 +323,7 @@ public: /// mark the inset contents as erased (for change tracking) virtual void markErased() {} - + /** Adds a LaTeX snippet to the Preview Loader for transformation * into a bitmap image. Does not start the laoding process. * diff --git a/src/insets/insetert.C b/src/insets/insetert.C index b109121e6c..8513b19e8c 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -355,7 +355,7 @@ int InsetERT::latex(Buffer const *, ostream & os, bool /*fragile*/, // ignore all struck out text if (isDeletedText(*par, i)) continue; - + if (par->isNewline(i)) { os << '\n'; ++lines; @@ -449,7 +449,7 @@ Inset::RESULT InsetERT::localDispatch(FuncRequest const & cmd) result = DISPATCHED; } break; - + case LFUN_MOUSE_PRESS: lfunMousePress(cmd); result = DISPATCHED; diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index ece2cab22c..b0fface25d 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -1505,7 +1505,7 @@ void InsetTabular::resetPos(BufferView * bv) const } else if (the_locking_inset && (tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20)) { - int xx = cursor_.x() - offset + bv->text->getRealCursorX(bv); + int xx = cursor_.x() - offset + bv->text->getRealCursorX(); if (xx > (bv->workWidth()-20)) { scroll(bv, -(xx - bv->workWidth() + 60)); updateLocal(bv, FULL, false); diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 4b2d82fa9d..cf899f5f27 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -106,7 +106,7 @@ void InsetText::saveLyXTextState(LyXText * t) const } -void InsetText::restoreLyXTextState(BufferView * bv, LyXText * t) const +void InsetText::restoreLyXTextState(LyXText * t) const { if (!sstate.lpar) return; @@ -115,15 +115,15 @@ void InsetText::restoreLyXTextState(BufferView * bv, LyXText * t) const /* at this point just to avoid the DEPM when setting the cursor */ t->selection.mark(sstate.mark_set); if (sstate.selection) { - t->setCursor(bv, sstate.selstartpar, sstate.selstartpos, + t->setCursor(sstate.selstartpar, sstate.selstartpos, true, sstate.selstartboundary); t->selection.cursor = t->cursor; - t->setCursor(bv, sstate.selendpar, sstate.selendpos, + t->setCursor(sstate.selendpar, sstate.selendpos, true, sstate.selendboundary); - t->setSelection(bv); - t->setCursor(bv, sstate.lpar, sstate.pos); + t->setSelection(); + t->setCursor(sstate.lpar, sstate.pos); } else { - t->setCursor(bv, sstate.lpar, sstate.pos, true, sstate.boundary); + t->setCursor(sstate.lpar, sstate.pos, true, sstate.boundary); t->selection.cursor = t->cursor; t->selection.set(false); } @@ -434,17 +434,17 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, Row * prev = row->previous(); RowPainter rp(*bv, *lt, *row); if (rp.paint(y + y_offset + first, int(x), y + lt->top_y())) - lt->markChangeInDraw(bv, row, prev); + lt->markChangeInDraw(row, prev); if (bv->text->status() == LyXText::CHANGED_IN_DRAW) { lt->need_break_row = row; - lt->fullRebreak(bv); - lt->setCursor(bv, lt->cursor.par(), + lt->fullRebreak(); + lt->setCursor(lt->cursor.par(), lt->cursor.pos()); if (lt->selection.set()) { - lt->setCursor(bv, lt->selection.start, + lt->setCursor(lt->selection.start, lt->selection.start.par(), lt->selection.start.pos()); - lt->setCursor(bv, lt->selection.end, + lt->setCursor(lt->selection.end, lt->selection.end.par(), lt->selection.end.pos()); } @@ -522,7 +522,7 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit) if ((need_update & CURSOR_PAR) && (lt->status() == LyXText::UNCHANGED) && the_locking_inset) { - lt->updateInset(bv, the_locking_inset); + lt->updateInset(the_locking_inset); } if (lt->status() == LyXText::NEED_MORE_REFRESH) need_update |= FULL; @@ -567,7 +567,7 @@ void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty) lt = getLyXText(bv); clear = true; } - lt->fullRebreak(bv); + lt->fullRebreak(); setUpdateStatus(bv, what); bool flag = mark_dirty || (((need_update != CURSOR) && (need_update != NONE)) || @@ -631,7 +631,7 @@ void InsetText::edit(BufferView * bv, int x, int y, mouse_button::state button) // cycle hopefully (Jug 20020509) // FIXME: GUII I've changed this to none: probably WRONG if (!checkAndActivateInset(bv, x, tmp_y, mouse_button::none)) { - lt->setCursorFromCoordinates(bv, x - drawTextXOffset, + lt->setCursorFromCoordinates(x - drawTextXOffset, y + insetAscent); lt->cursor.x_fix(lt->cursor.x()); } @@ -680,14 +680,14 @@ void InsetText::edit(BufferView * bv, bool front) clear = true; } if (front) - lt->setCursor(bv, &*(paragraphs.begin()), 0); + lt->setCursor(&*(paragraphs.begin()), 0); else { ParagraphList::iterator it = paragraphs.begin(); ParagraphList::iterator end = paragraphs.end(); while (boost::next(it) != end) ++it; // int const pos = (p->size() ? p->size()-1 : p->size()); - lt->setCursor(bv, &*it, it->size()); + lt->setCursor(&*it, it->size()); } lt->clearSelection(); finishUndo(); @@ -736,9 +736,9 @@ void InsetText::insetUnlock(BufferView * bv) bv->owner()->setLayout(bv->text->cursor.par()->layout()->name()); // hack for deleteEmptyParMech if (!paragraphs.begin()->empty()) { - lt->setCursor(bv, &*(paragraphs.begin()), 0); + lt->setCursor(&*(paragraphs.begin()), 0); } else if (paragraphs.begin()->next()) { - lt->setCursor(bv, paragraphs.begin()->next(), 0); + lt->setCursor(paragraphs.begin()->next(), 0); } if (clear) lt = 0; @@ -764,7 +764,7 @@ void InsetText::lockInset(BufferView * bv) lt = getLyXText(bv); clear = true; } - lt->setCursor(bv, &*(paragraphs.begin()), 0); + lt->setCursor(&*(paragraphs.begin()), 0); lt->clearSelection(); finishUndo(); // If the inset is empty set the language of the current font to the @@ -812,12 +812,12 @@ bool InsetText::lockInsetInInset(BufferView * bv, UpdatableInset * inset) p->insetlist.end(); for (; it != end; ++it) { if (it.getInset() == inset) { - getLyXText(bv)->setCursorIntern(bv, p, it.getPos()); + getLyXText(bv)->setCursorIntern(p, it.getPos()); lockInset(bv, inset); return true; } if (it.getInset()->getInsetFromID(id)) { - getLyXText(bv)->setCursorIntern(bv, p, it.getPos()); + getLyXText(bv)->setCursorIntern(p, it.getPos()); it.getInset()->edit(bv); return the_locking_inset->lockInsetInInset(bv, inset); } @@ -854,7 +854,7 @@ bool InsetText::unlockInsetInInset(BufferView * bv, UpdatableInset * inset, return false; if (the_locking_inset == inset) { the_locking_inset->insetUnlock(bv); - getLyXText(bv)->updateInset(bv, inset); + getLyXText(bv)->updateInset(inset); the_locking_inset = 0; if (lr) moveRightIntern(bv, true, false); @@ -896,14 +896,14 @@ bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset) ustat = FULL; } if (found) - lt->updateInset(bv, tl_inset); + lt->updateInset(tl_inset); if (clear) lt = 0; if (found) setUpdateStatus(bv, ustat); return found; } - bool found = lt->updateInset(bv, inset); + bool found = lt->updateInset(inset); if (clear) lt = 0; if (found) { @@ -936,7 +936,7 @@ void InsetText::lfunMousePress(FuncRequest const & cmd) int tmp_x = cmd.x - drawTextXOffset; int tmp_y = cmd.y + insetAscent - getLyXText(bv)->top_y(); - Inset * inset = getLyXText(bv)->checkInsetHit(bv, tmp_x, tmp_y); + Inset * inset = getLyXText(bv)->checkInsetHit(tmp_x, tmp_y); hideInsetCursor(bv); if (the_locking_inset) { @@ -992,7 +992,7 @@ void InsetText::lfunMousePress(FuncRequest const & cmd) } int old_top_y = lt->top_y(); - lt->setCursorFromCoordinates(bv, cmd.x - drawTextXOffset, + lt->setCursorFromCoordinates(cmd.x - drawTextXOffset, cmd.y + insetAscent); // set the selection cursor! lt->selection.cursor = lt->cursor; @@ -1045,7 +1045,7 @@ bool InsetText::lfunMouseRelease(FuncRequest const & cmd) int tmp_x = cmd.x - drawTextXOffset; int tmp_y = cmd.y + insetAscent - getLyXText(bv)->top_y(); - Inset * inset = getLyXText(bv)->checkInsetHit(bv, tmp_x, tmp_y); + Inset * inset = getLyXText(bv)->checkInsetHit(tmp_x, tmp_y); bool ret = false; if (inset) { if (isHighlyEditableInset(inset)) @@ -1089,14 +1089,14 @@ void InsetText::lfunMouseMotion(FuncRequest const & cmd) hideInsetCursor(bv); LyXCursor cur = lt->cursor; lt->setCursorFromCoordinates - (bv, cmd.x - drawTextXOffset, cmd.y + insetAscent); + (cmd.x - drawTextXOffset, cmd.y + insetAscent); lt->cursor.x_fix(lt->cursor.x()); if (cur == lt->cursor) { if (clear) lt = 0; return; } - lt->setSelection(bv); + lt->setSelection(); bool flag = (lt->toggle_cursor.par() != lt->toggle_end_cursor.par() || lt->toggle_cursor.pos() != lt->toggle_end_cursor.pos()); if (clear) @@ -1198,7 +1198,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) bv->switchKeyMap(); if (lyxrc.auto_region_delete) { if (lt->selection.set()) { - lt->cutSelection(bv, false, false); + lt->cutSelection(false, false); } } lt->clearSelection(); @@ -1216,7 +1216,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) case LFUN_RIGHTSEL: finishUndo(); moveRight(bv, false, true); - lt->setSelection(bv); + lt->setSelection(); updwhat = SELECTION; break; case LFUN_RIGHT: @@ -1227,7 +1227,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) case LFUN_LEFTSEL: finishUndo(); moveLeft(bv, false, true); - lt->setSelection(bv); + lt->setSelection(); updwhat = SELECTION; break; case LFUN_LEFT: @@ -1238,7 +1238,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) case LFUN_DOWNSEL: finishUndo(); moveDown(bv); - lt->setSelection(bv); + lt->setSelection(); updwhat = SELECTION; break; case LFUN_DOWN: @@ -1249,7 +1249,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) case LFUN_UPSEL: finishUndo(); moveUp(bv); - lt->setSelection(bv); + lt->setSelection(); updwhat = SELECTION; break; case LFUN_UP: @@ -1259,18 +1259,18 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) break; case LFUN_HOME: finishUndo(); - lt->cursorHome(bv); + lt->cursorHome(); updwhat = CURSOR; break; case LFUN_END: - lt->cursorEnd(bv); + lt->cursorEnd(); updwhat = CURSOR; break; case LFUN_PRIOR: if (!crow(bv)->previous()) result = FINISHED_UP; else { - lt->cursorPrevious(bv); + lt->cursorPrevious(); result = DISPATCHED_NOUPDATE; } updwhat = CURSOR; @@ -1279,16 +1279,16 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) if (!crow(bv)->next()) result = FINISHED_DOWN; else { - lt->cursorNext(bv); + lt->cursorNext(); result = DISPATCHED_NOUPDATE; } updwhat = CURSOR; break; case LFUN_BACKSPACE: { if (lt->selection.set()) - lt->cutSelection(bv, true, false); + lt->cutSelection(true, false); else - lt->backspace(bv); + lt->backspace(); updwhat = CURSOR_PAR; updflag = true; } @@ -1296,9 +1296,9 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) case LFUN_DELETE: { if (lt->selection.set()) { - lt->cutSelection(bv, true, false); + lt->cutSelection(true, false); } else { - lt->Delete(bv); + lt->Delete(); } updwhat = CURSOR_PAR; updflag = true; @@ -1314,7 +1314,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) case LFUN_COPY: finishUndo(); - lt->copySelection(bv); + lt->copySelection(); updwhat = CURSOR_PAR; break; case LFUN_PASTESELECTION: @@ -1324,9 +1324,9 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) if (clip.empty()) break; if (ev.argument == "paragraph") { - lt->insertStringAsParagraphs(bv, clip); + lt->insertStringAsParagraphs(clip); } else { - lt->insertStringAsLines(bv, clip); + lt->insertStringAsLines(clip); } // bug 393 lt->clearSelection(); @@ -1350,7 +1350,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) setUndo(bv, Undo::INSERT, lt->cursor.par(), lt->cursor.par()->next()); #endif - lt->pasteSelection(bv); + lt->pasteSelection(); // bug 393 lt->clearSelection(); updwhat = CURSOR_PAR; @@ -1363,7 +1363,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) result = DISPATCHED; break; } - lt->breakParagraph(bv, paragraphs, 0); + lt->breakParagraph(paragraphs, 0); updwhat = CURSOR | FULL; updflag = true; break; @@ -1372,7 +1372,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) result = DISPATCHED; break; } - lt->breakParagraph(bv, paragraphs, 1); + lt->breakParagraph(paragraphs, 1); updwhat = CURSOR | FULL; updflag = true; break; @@ -1387,7 +1387,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) setUndo(bv, Undo::INSERT, lt->cursor.par(), lt->cursor.par()->next()); #endif - lt->insertInset(bv, new InsetNewline); + lt->insertInset(new InsetNewline); updwhat = CURSOR | CURSOR_PAR; updflag = true; } @@ -1422,7 +1422,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) if (cur_layout != layout) { cur_layout = layout; - lt->setLayout(bv, layout); + lt->setLayout(layout); bv->owner()->setLayout(cpar(bv)->layout()->name()); updwhat = CURSOR_PAR; updflag = true; @@ -1859,7 +1859,7 @@ bool InsetText::insertInset(BufferView * bv, Inset * inset) } inset->setOwner(this); hideInsetCursor(bv); - getLyXText(bv)->insertInset(bv, inset); + getLyXText(bv)->insertInset(inset); bv->fitCursor(); updateLocal(bv, CURSOR_PAR|CURSOR, true); return true; @@ -1936,7 +1936,7 @@ void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall, return; } if ((!paragraphs.begin()->next() && paragraphs.begin()->empty()) || cpar(bv)->empty()) { - getLyXText(bv)->setFont(bv, font, toggleall); + getLyXText(bv)->setFont(font, toggleall); return; } bool clear = false; @@ -1949,7 +1949,7 @@ void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall, } if (selectall) selectAll(bv); - lt->toggleFree(bv, font, toggleall); + lt->toggleFree(font, toggleall); if (selectall) lt->clearSelection(); bv->fitCursor(); @@ -1986,7 +1986,7 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y, x -= drawTextXOffset; int dummyx = x; int dummyy = y + insetAscent; - Inset * inset = getLyXText(bv)->checkInsetHit(bv, dummyx, dummyy); + Inset * inset = getLyXText(bv)->checkInsetHit(dummyx, dummyy); // we only do the edit() call if the inset was hit by the mouse // or if it is a highly editable inset. So we should call this // function from our own edit with button < 0. @@ -2215,7 +2215,7 @@ LyXText * InsetText::getLyXText(BufferView const * lbv, // when we have to reinit the existing LyXText! // it->second.text->init(bv); - restoreLyXTextState(bv, it->second.text.get()); + restoreLyXTextState(it->second.text.get()); it->second.remove = false; } cached_text = it->second.text; @@ -2227,9 +2227,9 @@ LyXText * InsetText::getLyXText(BufferView const * lbv, /// // we are here only if we don't have a BufferView * in the cache!!! /// - cached_text.reset(new LyXText(const_cast(this))); + cached_text.reset(new LyXText(bv, const_cast(this))); cached_text->init(bv); - restoreLyXTextState(bv, cached_text.get()); + restoreLyXTextState(cached_text.get()); cache.insert(make_pair(bv, cached_text)); @@ -2276,7 +2276,7 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const LyXText * t = getLyXText(bv); saveLyXTextState(t); t->init(bv, true); - restoreLyXTextState(bv, t); + restoreLyXTextState(t); return; } // one endless line, resize normally not necessary @@ -2296,7 +2296,7 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv)); t->init(bv, true); - restoreLyXTextState(bv, t); + restoreLyXTextState(t); if (the_locking_inset) { inset_x = cix(bv) - top_x + drawTextXOffset; inset_y = ciy(bv) + drawTextYOffset; @@ -2336,7 +2336,7 @@ void InsetText::reinitLyXText() const boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv)); t->init(bv, true); - restoreLyXTextState(bv, t); + restoreLyXTextState(t); if (the_locking_inset) { inset_x = cix(bv) - top_x + drawTextXOffset; inset_y = ciy(bv) + drawTextYOffset; @@ -2393,10 +2393,10 @@ int InsetText::scroll(bool recursive) const void InsetText::selectAll(BufferView * bv) { - getLyXText(bv)->cursorTop(bv); + getLyXText(bv)->cursorTop(); getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor; - getLyXText(bv)->cursorBottom(bv); - getLyXText(bv)->setSelection(bv); + getLyXText(bv)->cursorBottom(); + getLyXText(bv)->setSelection(); } @@ -2519,7 +2519,7 @@ InsetText::selectNextWordToSpellcheck(BufferView * bv, // we have to go on checking so move cursor to the next char lt->cursor.pos(lt->cursor.pos() + 1); } - word = lt->selectNextWordToSpellcheck(bv, value); + word = lt->selectNextWordToSpellcheck(value); if (word.word().empty()) bv->unlockInset(const_cast(this)); else @@ -2536,7 +2536,7 @@ void InsetText::selectSelectedWord(BufferView * bv) the_locking_inset->selectSelectedWord(bv); return; } - getLyXText(bv)->selectSelectedWord(bv); + getLyXText(bv)->selectSelectedWord(); updateLocal(bv, SELECTION, false); } @@ -2582,7 +2582,7 @@ bool InsetText::nextChange(BufferView * bv, lyx::pos_type & length) if (the_locking_inset) { if (the_locking_inset->nextChange(bv, length)) return true; - lt->cursorRight(bv, true); + lt->cursorRight(true); } lyxfind::SearchResult result = lyxfind::findNextChange(bv, lt, length); @@ -2593,7 +2593,7 @@ bool InsetText::nextChange(BufferView * bv, lyx::pos_type & length) if (bv->lockInset(this)) locked = true; lt->cursor = cur; - lt->setSelectionRange(bv, length); + lt->setSelectionRange(length); updateLocal(bv, SELECTION, false); } if (clear) @@ -2613,7 +2613,7 @@ bool InsetText::searchForward(BufferView * bv, string const & str, if (the_locking_inset) { if (the_locking_inset->searchForward(bv, str, cs, mw)) return true; - lt->cursorRight(bv, true); + lt->cursorRight(true); } lyxfind::SearchResult result = lyxfind::LyXFind(bv, lt, str, true, cs, mw); @@ -2624,7 +2624,7 @@ bool InsetText::searchForward(BufferView * bv, string const & str, if (bv->lockInset(this)) locked = true; lt->cursor = cur; - lt->setSelectionRange(bv, str.length()); + lt->setSelectionRange(str.length()); updateLocal(bv, SELECTION, false); } if (clear) @@ -2648,7 +2648,7 @@ bool InsetText::searchBackward(BufferView * bv, string const & str, Paragraph * p = &*(paragraphs.begin()); while (p->next()) p = p->next(); - lt->setCursor(bv, p, p->size()); + lt->setCursor(p, p->size()); } lyxfind::SearchResult result = lyxfind::LyXFind(bv, lt, str, false, cs, mw); @@ -2659,7 +2659,7 @@ bool InsetText::searchBackward(BufferView * bv, string const & str, if (bv->lockInset(this)) locked = true; lt->cursor = cur; - lt->setSelectionRange(bv, str.length()); + lt->setSelectionRange(str.length()); updateLocal(bv, SELECTION, false); } if (clear) diff --git a/src/insets/insettext.h b/src/insets/insettext.h index ee332ec2d5..c6a199386f 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -348,7 +348,7 @@ private: /// void saveLyXTextState(LyXText *) const; /// - void restoreLyXTextState(BufferView *, LyXText *) const; + void restoreLyXTextState(LyXText *) const; /// void reinitLyXText() const; /// diff --git a/src/insets/updatableinset.C b/src/insets/updatableinset.C index b7c7eafee8..783f3c5dd0 100644 --- a/src/insets/updatableinset.C +++ b/src/insets/updatableinset.C @@ -167,7 +167,7 @@ int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const w = static_cast (owner())->getMaxWidth(bv, this); } else { - w = bv->text->workWidth(*bv, const_cast(this)); + w = bv->text->workWidth(const_cast(this)); } if (w < 0) { return -1; @@ -216,7 +216,7 @@ bool UpdatableInset::nextChange(BufferView * bv, lyx::pos_type &) return false; } - + bool UpdatableInset::searchForward(BufferView * bv, string const &, bool, bool) { diff --git a/src/lyx_cb.C b/src/lyx_cb.C index c1ea6d4fdd..9c9c0c014f 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -404,9 +404,9 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph) if (flag) bv->beforeChange(bv->text); if (!asParagraph) - bv->getLyXText()->insertStringAsLines(bv, tmpstr); + bv->getLyXText()->insertStringAsLines(tmpstr); else - bv->getLyXText()->insertStringAsParagraphs(bv, tmpstr); + bv->getLyXText()->insertStringAsParagraphs(tmpstr); if (flag) bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); diff --git a/src/lyxfind.C b/src/lyxfind.C index 781377babf..4615582731 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -57,7 +57,7 @@ int LyXReplace(BufferView * bv, text->clearSelection(); bv->unlockInset(bv->theLockingInset()); text = bv->text; - text->cursorTop(bv); + text->cursorTop(); // override search direction because we search top to bottom fw = true; } @@ -94,8 +94,8 @@ int LyXReplace(BufferView * bv, bv->hideCursor(); bv->update(text, BufferView::SELECT|BufferView::FITCUR); bv->toggleSelection(false); - text->replaceSelectionWithString(bv, replacestr); - text->setSelectionRange(bv, replacestr.length()); + text->replaceSelectionWithString(replacestr); + text->setSelectionRange(replacestr.length()); bv->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); ++replace_count; } @@ -128,7 +128,7 @@ bool LyXFind(BufferView * bv, // We now are in the main text but if we did a forward // search we have to put the cursor behind the inset. if (forward) { - bv->text->cursorRight(bv, true); + bv->text->cursorRight(true); } } // If we arrive here we are in the main text again so we @@ -154,7 +154,7 @@ bool LyXFind(BufferView * bv, if (result == SR_FOUND) { bv->unlockInset(bv->theLockingInset()); bv->update(text, BufferView::SELECT|BufferView::FITCUR); - text->setSelectionRange(bv, searchstr.length()); + text->setSelectionRange(searchstr.length()); bv->toggleSelection(false); bv->update(text, BufferView::SELECT|BufferView::FITCUR); } else if (result == SR_NOT_FOUND) { @@ -251,12 +251,12 @@ SearchResult SearchForward(BufferView * bv, LyXText * text, string const & str, } if (par) { - text->setCursor(bv, par, pos); + text->setCursor(par, pos); return SR_FOUND; } else { // make sure we end up at the end of the text, // not the start point of the last search - text->setCursor(bv, prev_par, prev_par->size()); + text->setCursor(prev_par, prev_par->size()); return SR_NOT_FOUND; } } @@ -301,11 +301,11 @@ SearchResult SearchBackward(BufferView * bv, LyXText * text, } while (par && !IsStringInText(par, pos, str, cs, mw)); if (par) { - text->setCursor(bv, par, pos); + text->setCursor(par, pos); return SR_FOUND; } else { // go to the last part of the unsuccessful search - text->setCursor(bv, prev_par, 0); + text->setCursor(prev_par, 0); return SR_NOT_FOUND; } } @@ -340,7 +340,7 @@ SearchResult nextChange(BufferView * bv, LyXText * text, pos_type & length) } if (par) { - text->setCursor(bv, par, pos); + text->setCursor(par, pos); Change orig_change = par->lookupChangeFull(pos); pos_type end = pos; @@ -359,7 +359,7 @@ SearchResult nextChange(BufferView * bv, LyXText * text, pos_type & length) } else { // make sure we end up at the end of the text, // not the start point of the last search - text->setCursor(bv, prev_par, prev_par->size()); + text->setCursor(prev_par, prev_par->size()); return SR_NOT_FOUND; } } @@ -397,7 +397,7 @@ bool findNextChange(BufferView * bv) // We now are in the main text but if we did a forward // search we have to put the cursor behind the inset. - bv->text->cursorRight(bv, true); + bv->text->cursorRight(true); } // If we arrive here we are in the main text again so we // just start searching from the root LyXText at the position @@ -422,7 +422,7 @@ bool findNextChange(BufferView * bv) if (result == SR_FOUND) { bv->unlockInset(bv->theLockingInset()); bv->update(text, BufferView::SELECT|BufferView::FITCUR); - text->setSelectionRange(bv, length); + text->setSelectionRange(length); bv->toggleSelection(false); bv->update(text, BufferView::SELECT|BufferView::FITCUR); } else if (result == SR_NOT_FOUND) { diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 7f85a24070..c45dfcd7d3 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -121,8 +121,8 @@ inline void LyXFunc::moveCursorUpdate(bool flag, bool selecting) { if (selecting || TEXT(flag)->selection.mark()) { - TEXT(flag)->setSelection(view()); - if (TEXT(flag)->isTopLevel()) + TEXT(flag)->setSelection(); + if (!TEXT(flag)->isInInset()) view()->toggleToggle(); } view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR); @@ -825,7 +825,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) if (TEXT()->cursor.irow()->previous()) { #if 1 TEXT()->setCursorFromCoordinates( - view(), TEXT()->cursor.ix() + inset_x, + TEXT()->cursor.ix() + inset_x, TEXT()->cursor.iy() - TEXT()->cursor.irow()->baseline() - 1); TEXT()->cursor.x_fix(TEXT()->cursor.x()); @@ -842,7 +842,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) if (TEXT()->cursor.irow()->next()) { #if 1 TEXT()->setCursorFromCoordinates( - view(), TEXT()->cursor.ix() + inset_x, + TEXT()->cursor.ix() + inset_x, TEXT()->cursor.iy() - TEXT()->cursor.irow()->baseline() + TEXT()->cursor.irow()->height() + 1); @@ -1105,12 +1105,12 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) break; case LFUN_FREEFONT_APPLY: - apply_freefont(view()); - break; + apply_freefont(view()); + break; - case LFUN_FREEFONT_UPDATE: - update_and_apply_freefont(view(), argument); - break; + case LFUN_FREEFONT_UPDATE: + update_and_apply_freefont(view(), argument); + break; case LFUN_RECONFIGURE: Reconfigure(view()); @@ -1235,12 +1235,12 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) owner->getDialogs().showDocument(); break; - case LFUN_LAYOUT_CHARACTER: { - string data = freefont2string(); - if (!data.empty()) - owner->getDialogs().show("character", data); - break; - } + case LFUN_LAYOUT_CHARACTER: { + string data = freefont2string(); + if (!data.empty()) + owner->getDialogs().show("character", data); + break; + } case LFUN_LAYOUT_TABULAR: if (view()->theLockingInset()) { @@ -1336,7 +1336,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) par->inInset()->edit(view()); } // Set the cursor - view()->getLyXText()->setCursor(view(), par, 0); + view()->getLyXText()->setCursor(par, 0); view()->switchKeyMap(); owner->view_state_changed(); diff --git a/src/lyxtext.h b/src/lyxtext.h index 8efa06d90b..bdf8fe980b 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -69,7 +69,7 @@ public: /// Constructor LyXText(BufferView *); /// sets inset as owner - LyXText(InsetText *); + LyXText(BufferView *, InsetText *); /// Destructor ~LyXText(); @@ -88,7 +88,7 @@ private: * declared mutable because removeRow is const */ mutable Row * top_row_; - /** the pixel offset with respect to this row of top_y + /** the pixel offset with respect to this row of top_y * declared mutable because removeRow is const */ mutable int top_row_offset_; @@ -103,7 +103,7 @@ public: UpdatableInset * the_locking_inset; /// - int getRealCursorX(BufferView *) const; + int getRealCursorX() const; /// LyXFont const getFont(Buffer const *, Paragraph * par, lyx::pos_type pos) const; @@ -114,35 +114,34 @@ public: /// void setCharFont(Buffer const *, Paragraph * par, lyx::pos_type pos, LyXFont const & font); - void setCharFont(BufferView *, Paragraph * par, + void setCharFont(Paragraph * par, lyx::pos_type pos, LyXFont const & font, bool toggleall); /// return true if the row changed - void markChangeInDraw(BufferView * bv, Row * row, Row * next); + void markChangeInDraw(Row * row, Row * next); /// - void breakAgainOneRow(BufferView *, Row * row); + void breakAgainOneRow(Row * row); /// what you expect when pressing at cursor position - void breakParagraph(BufferView *, - ParagraphList & paragraphs, char keep_layout = 0); + void breakParagraph(ParagraphList & paragraphs, char keep_layout = 0); /** set layout over selection and make a total rebreak of those paragraphs */ - Paragraph * setLayout(BufferView *, LyXCursor & actual_cursor, + Paragraph * setLayout(LyXCursor & actual_cursor, LyXCursor & selection_start, LyXCursor & selection_end, string const & layout); /// - void setLayout(BufferView *, string const & layout); + void setLayout(string const & layout); /** increment depth over selection and make a total rebreak of those paragraphs */ - void incDepth(BufferView *); + void incDepth(); /** decrement depth over selection and make a total rebreak of those paragraphs */ - void decDepth(BufferView *); + void decDepth(); /// get the depth at current cursor position int getDepth() const; @@ -151,39 +150,39 @@ public: paragraphs. toggleall defaults to false. */ - void setFont(BufferView *, LyXFont const &, bool toggleall = false); + void setFont(LyXFont const &, bool toggleall = false); /** deletes and inserts again all paragaphs between the cursor and the specified par. The Cursor is needed to set the refreshing parameters. This function is needed after SetLayout and SetFont etc. */ - void redoParagraphs(BufferView *, LyXCursor const & cursor, + void redoParagraphs(LyXCursor const & cursor, Paragraph const * end_par) const; /// - void redoParagraph(BufferView *) const; + void redoParagraph() const; /// - void toggleFree(BufferView *, LyXFont const &, bool toggleall = false); + void toggleFree(LyXFont const &, bool toggleall = false); /// - string getStringToIndex(BufferView *); + string getStringToIndex(); /** recalculates the heights of all previous rows of the specified paragraph. needed, if the last characters font has changed. */ - void redoHeightOfParagraph(BufferView *); + void redoHeightOfParagraph(); /** insert a character, moves all the following breaks in the same Paragraph one to the right and make a little rebreak */ - void insertChar(BufferView *, char c); + void insertChar(char c); /// - void insertInset(BufferView *, Inset * inset); + void insertInset(Inset * inset); /// Completes the insertion with a full rebreak - void fullRebreak(BufferView *); + void fullRebreak(); /// mutable Row * need_break_row; @@ -197,16 +196,20 @@ public: /** * Mark position y as the starting point for a repaint */ - void postPaint(BufferView & bv, int start_y); + void postPaint(int start_y); /** * Mark the given row at position y as needing a repaint. */ - void postRowPaint(BufferView & bv, Row * row, int start_y); + void postRowPaint(Row * row, int start_y); /// Inset::RESULT dispatch(FuncRequest const & cmd); + BufferView * bv(); + + BufferView * bv() const; + friend class LyXScreen; /** @@ -247,7 +250,7 @@ public: /** returns the column near the specified x-coordinate of the row x is set to the real beginning of this column */ - lyx::pos_type getColumnNearX(BufferView *, Row * row, + lyx::pos_type getColumnNearX(Row * row, int & x, bool & boundary) const; /** returns a pointer to a specified row. y is set to the beginning @@ -309,7 +312,7 @@ public: mutable LyXCursor toggle_end_cursor; /// need the selection cursor: - void setSelection(BufferView *); + void setSelection(); /// void clearSelection() const; /// @@ -319,40 +322,40 @@ public: void getWord(LyXCursor & from, LyXCursor & to, word_location const) const; /// just selects the word the cursor is in - void selectWord(BufferView *, word_location const); + void selectWord(word_location const); /// returns the inset at cursor (if it exists), 0 otherwise Inset * getInset() const; /// accept selected change - void acceptChange(BufferView * bv); + void acceptChange(); /// reject selected change - void rejectChange(BufferView * bv); + void rejectChange(); /** 'selects" the next word, where the cursor is not in and returns this word as string. THe cursor will be moved to the beginning of this word. With SelectSelectedWord can this be highlighted really */ - WordLangTuple const selectNextWordToSpellcheck(BufferView *, float & value) const; + WordLangTuple const selectNextWordToSpellcheck(float & value) const; /// - void selectSelectedWord(BufferView *); + void selectSelectedWord(); /// returns true if par was empty and was removed - bool setCursor(BufferView *, Paragraph * par, + bool setCursor(Paragraph * par, lyx::pos_type pos, bool setfont = true, bool boundary = false) const; /// - void setCursor(BufferView *, LyXCursor &, Paragraph * par, + void setCursor(LyXCursor &, Paragraph * par, lyx::pos_type pos, bool boundary = false) const; /// - void setCursorIntern(BufferView *, Paragraph * par, + void setCursorIntern(Paragraph * par, lyx::pos_type pos, bool setfont = true, bool boundary = false) const; /// - void setCurrentFont(BufferView *) const; + void setCurrentFont() const; /// bool isBoundary(Buffer const *, Paragraph * par, @@ -363,47 +366,46 @@ public: LyXFont const & font) const; /// - void setCursorFromCoordinates(BufferView *, int x, int y) const; + void setCursorFromCoordinates(int x, int y) const; /// - void setCursorFromCoordinates(BufferView *, LyXCursor &, + void setCursorFromCoordinates(LyXCursor &, int x, int y) const; /// - void cursorUp(BufferView *, bool selecting = false) const; + void cursorUp(bool selecting = false) const; /// - void cursorDown(BufferView *, bool selecting = false) const; + void cursorDown(bool selecting = false) const; /// - void cursorLeft(BufferView *, bool internal = true) const; + void cursorLeft(bool internal = true) const; /// - void cursorRight(BufferView *, bool internal = true) const; + void cursorRight(bool internal = true) const; /// - void cursorLeftOneWord(BufferView *) const; + void cursorLeftOneWord() const; /// - void cursorRightOneWord(BufferView *) const; + void cursorRightOneWord() const; /// - void cursorUpParagraph(BufferView *) const; + void cursorUpParagraph() const; /// - void cursorDownParagraph(BufferView *) const; + void cursorDownParagraph() const; /// - void cursorHome(BufferView *) const; + void cursorHome() const; /// - void cursorEnd(BufferView *) const; + void cursorEnd() const; /// - void cursorPrevious(BufferView * bv); + void cursorPrevious(); /// - void cursorNext(BufferView * bv); + void cursorNext(); /// - void cursorTab(BufferView *) const; + void cursorTab() const; /// - void cursorTop(BufferView *) const; + void cursorTop() const; /// - void cursorBottom(BufferView *) const; + void cursorBottom() const; /// - void Delete(BufferView *); + void Delete(); /// - void backspace(BufferView *); + void backspace(); /// - bool selectWordWhenUnderCursor(BufferView *, - word_location const); + bool selectWordWhenUnderCursor(word_location); /// enum TextCase { /// @@ -414,22 +416,22 @@ public: text_uppercase = 2 }; /// Change the case of the word at cursor position. - void changeCase(BufferView &, TextCase action); + void changeCase(TextCase action); /// - void transposeChars(BufferView &); + void transposeChars(); /// - void toggleInset(BufferView *); + void toggleInset(); /// - void cutSelection(BufferView *, bool doclear = true, bool realcut = true); + void cutSelection(bool doclear = true, bool realcut = true); /// - void copySelection(BufferView *); + void copySelection(); /// - void pasteSelection(BufferView *); + void pasteSelection(); /// void copyEnvironmentType(); /// - void pasteEnvironmentType(BufferView *); + void pasteEnvironmentType(); /** the DTP switches for paragraphs. LyX will store the top settings always in the first physical paragraph, the bottom settings in the @@ -437,14 +439,13 @@ public: settings are given to the new one. So I can make shure, they do not duplicate themself (and you cannnot make dirty things with them! ) */ - void setParagraph(BufferView *, - bool line_top, bool line_bottom, + void setParagraph(bool line_top, bool line_bottom, bool pagebreak_top, bool pagebreak_bottom, VSpace const & space_top, VSpace const & space_bottom, Spacing const & spacing, LyXAlignment align, - string labelwidthstring, + string const & labelwidthstring, bool noindent); /* these things are for search and replace */ @@ -453,38 +454,38 @@ public: * Sets the selection from the current cursor position to length * characters to the right. No safety checks. */ - void setSelectionRange(BufferView *, lyx::pos_type length); + void setSelectionRange(lyx::pos_type length); /** simple replacing. The font of the first selected character is used */ - void replaceSelectionWithString(BufferView *, string const & str); + void replaceSelectionWithString(string const & str); /// needed to insert the selection - void insertStringAsLines(BufferView *, string const & str); + void insertStringAsLines(string const & str); /// needed to insert the selection - void insertStringAsParagraphs(BufferView *, string const & str); + void insertStringAsParagraphs(string const & str); /// Find next inset of some specified type. - bool gotoNextInset(BufferView *, std::vector const & codes, + bool gotoNextInset(std::vector const & codes, string const & contents = string()) const; /// - void gotoInset(BufferView * bv, std::vector const & codes, - bool same_content); + void gotoInset(std::vector const & codes, + bool same_content); /// - void gotoInset(BufferView * bv, Inset::Code code, bool same_content); + void gotoInset(Inset::Code code, bool same_content); /// /* for the greater insets */ /// returns false if inset wasn't found - bool updateInset(BufferView *, Inset *); + bool updateInset(Inset *); /// - void checkParagraph(BufferView *, Paragraph * par, lyx::pos_type pos); + void checkParagraph(Paragraph * par, lyx::pos_type pos); /// - int workWidth(BufferView &) const; + int workWidth() const; /// - int workWidth(BufferView &, Inset * inset) const; + int workWidth(Inset * inset) const; /// void computeBidiTables(Buffer const *, Row * row) const; @@ -529,15 +530,15 @@ private: void cursorLeftOneWord(LyXCursor &) const; /// - float getCursorX(BufferView *, Row *, lyx::pos_type pos, - lyx::pos_type last, bool boundary) const; + float getCursorX(Row *, lyx::pos_type pos, + lyx::pos_type last, bool boundary) const; /// used in setlayout void makeFontEntriesLayoutSpecific(Buffer const &, Paragraph & par); /** forces the redrawing of a paragraph. Needed when manipulating a right address box */ - void redoDrawingOfParagraph(BufferView *, LyXCursor const & cursor); + void redoDrawingOfParagraph(LyXCursor const & cursor); /** Copybuffer for copy environment type. Asger has learned that this should be a buffer-property instead @@ -555,45 +556,42 @@ private: void removeParagraph(Row * row) const; /// insert the specified paragraph behind the specified row - void insertParagraph(BufferView *, - Paragraph * par, Row * row) const; + void insertParagraph(Paragraph * par, Row * row) const; /** appends the implizit specified paragraph behind the specified row, * start at the implizit given position */ - void appendParagraph(BufferView *, Row * row) const; + void appendParagraph(Row * row) const; /// - void breakAgain(BufferView *, Row * row) const; + void breakAgain(Row * row) const; /// Calculate and set the height of the row - void setHeightOfRow(BufferView *, Row * row_ptr) const; + void setHeightOfRow(Row * row_ptr) const; // fix the cursor `cur' after a characters has been deleted at `where' // position. Called by deleteEmptyParagraphMechanism - void fixCursorAfterDelete(BufferView * bv, - LyXCursor & cur, + void fixCursorAfterDelete(LyXCursor & cur, LyXCursor const & where) const; /// delete double space (false) or empty paragraphs (true) around old_cursor - bool deleteEmptyParagraphMechanism(BufferView *, - LyXCursor const & old_cursor) const; + bool deleteEmptyParagraphMechanism(LyXCursor const & old_cursor) const; public: /** Updates all counters starting BEHIND the row. Changed paragraphs * with a dynamic left margin will be rebroken. */ - void updateCounters(BufferView *) const; + void updateCounters() const; /// - void update(BufferView * bv, bool changed = true); + void update(bool changed = true); /** * Returns an inset if inset was hit, or 0 if not. * If hit, the coordinates are changed relative to the inset. */ - Inset * checkInsetHit(BufferView * bv, int & x, int & y) const; + Inset * checkInsetHit(int & x, int & y) const; /// - int singleWidth(BufferView *, Paragraph * par, + int singleWidth(Paragraph * par, lyx::pos_type pos) const; /// - int singleWidth(BufferView *, Paragraph * par, + int singleWidth(Paragraph * par, lyx::pos_type pos, char c) const; /// return the color of the canvas @@ -611,13 +609,13 @@ public: * in LaTeX the beginning of the text fits in some cases * (for example sections) exactly the label-width. */ - int leftMargin(BufferView *, Row const * row) const; + int leftMargin(Row const * row) const; /// int rightMargin(Buffer const &, Row const & row) const; /** this calculates the specified parameters. needed when setting * the cursor and when creating a visible row */ - void prepareToPrint(BufferView *, Row * row, float & x, + void prepareToPrint(Row * row, float & x, float & fill_separator, float & fill_hfill, float & fill_label_hfill, @@ -627,11 +625,11 @@ private: /// void setCounter(Buffer const *, Paragraph * par) const; /// - void deleteWordForward(BufferView *); + void deleteWordForward(); /// - void deleteWordBackward(BufferView *); + void deleteWordBackward(); /// - void deleteLineForward(BufferView *); + void deleteLineForward(); /* * some low level functions @@ -640,19 +638,19 @@ private: /// return the pos value *before* which a row should break. /// for example, the pos at which IsNewLine(pos) == true - lyx::pos_type rowBreakPoint(BufferView &, Row const & row) const; + lyx::pos_type rowBreakPoint(Row const & row) const; /// returns the minimum space a row needs on the screen in pixel - int fill(BufferView &, Row & row, int workwidth) const; + int fill(Row & row, int workwidth) const; /** * returns the minimum space a manual label needs on the * screen in pixels */ - int labelFill(BufferView &, Row const & row) const; + int labelFill(Row const & row) const; /// FIXME - int labelEnd(BufferView &, Row const & row) const; + int labelEnd(Row const & row) const; /// mutable std::vector log2vis_list; @@ -681,11 +679,7 @@ public: // set it searching first for the right owner using the paragraph id void ownerParagraph(int id, Paragraph *) const; - /// return true if this is the outer-most lyxtext - bool isTopLevel() const; - - /// return true if this is owned by an inset. FIXME: why the difference - /// with isTopLevel() ?? + /// return true if this is owned by an inset. bool isInInset() const; }; diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 489bd8d95b..056d3bef3a 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -391,7 +391,7 @@ void MathHullInset::footer_write(WriteStream & os) const else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign" || type_ == "alignat" || type_ == "xalignat" || type_ == "gather" || type_ == "multline") - os << "\\end{" << type_ << star(n) << "}\n"; + os << "\\end{" << type_ << star(n) << "}\n"; else if (type_ == "xxalignat") os << "\\end{" << type_ << "}\n"; diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index ecaea5d0c5..44071e9001 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -967,7 +967,7 @@ void Parser::parse1(MathGridInset & grid, unsigned flags, parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode); } - else if (t.cs() == "ref" || t.cs() == "prettyref" || + else if (t.cs() == "ref" || t.cs() == "prettyref" || t.cs() == "pageref" || t.cs() == "vpageref" || t.cs() == "vref") { cell->push_back(MathAtom(new RefInset(t.cs()))); parse(cell->back().nucleus()->cell(1), FLAG_OPTION, mode); diff --git a/src/rowpainter.C b/src/rowpainter.C index db2cc8135a..f283598386 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -69,17 +69,15 @@ LyXFont const RowPainter::getFont(pos_type pos) const int RowPainter::singleWidth(lyx::pos_type pos) const { - BufferView * bv(perv(bv_)); Paragraph * par(const_cast(&par_)); - return text_.singleWidth(bv, par, pos); + return text_.singleWidth(par, pos); } int RowPainter::singleWidth(lyx::pos_type pos, char c) const { - BufferView * bv(perv(bv_)); Paragraph * par(const_cast(&par_)); - return text_.singleWidth(bv, par, pos, c); + return text_.singleWidth(par, pos, c); } @@ -99,9 +97,8 @@ char const RowPainter::transformChar(char c, lyx::pos_type pos) const int RowPainter::leftMargin() const { - BufferView * bv(perv(bv_)); Row * row(const_cast(&row_)); - return text_.leftMargin(bv, row); + return text_.leftMargin(row); } @@ -631,7 +628,7 @@ void RowPainter::paintFirst() } // the top margin - if (!row_.previous() && text_.isTopLevel()) + if (!row_.previous() && !text_.isInInset()) y_top += PAPER_MARGIN; // draw a top pagebreak @@ -778,7 +775,7 @@ void RowPainter::paintLast() int y_bottom = row_.height() - 1; // the bottom margin - if (!row_.next() && text_.isTopLevel()) + if (!row_.next() && !text_.isInInset()) y_bottom -= PAPER_MARGIN; int const ww = bv_.workWidth(); @@ -980,9 +977,8 @@ bool RowPainter::paint(int y_offset, int x_offset, int y) // FIXME: must be a cleaner way here. Aren't these calculations // belonging to row metrics ? - BufferView * bv(const_cast(&bv_)); Row * row(const_cast(&row_)); - text_.prepareToPrint(bv, row, x_, separator_, hfill_, label_hfill_); + text_.prepareToPrint(row, x_, separator_, hfill_, label_hfill_); // FIXME: what is this fixing ? if (text_.isInInset() && (x_ < 0)) diff --git a/src/tex2lyx/tex2lyx.C b/src/tex2lyx/tex2lyx.C index 100bf14c3a..f808f0f102 100644 --- a/src/tex2lyx/tex2lyx.C +++ b/src/tex2lyx/tex2lyx.C @@ -46,19 +46,20 @@ void parse(Parser & p, ostream & os, unsigned flags, const mode_type mode); char const OPEN = '<'; char const CLOSE = '>'; -// rather brutish way to code table structure in a string: -// -// \begin{tabular}{ccc} -// 1 & 2 & 3\\ \hline -// \multicolumn{2}{c}{4} & 5\\ -// 6 & 7 \\ -// \end{tabular} -// -// gets "translated" to: -// -// 1 TAB 2 TAB 3 LINE -// HLINE 2 MULT c MULT 4 TAB 5 LINE -// 5 TAB 7 LINE +/* rather brutish way to code table structure in a string: + + \begin{tabular}{ccc} + 1 & 2 & 3\\ \hline + \multicolumn{2}{c}{4} & 5 // + 6 & 7 \\ + \end{tabular} + + gets "translated" to: + + 1 TAB 2 TAB 3 LINE + HLINE 2 MULT c MULT 4 TAB 5 LINE + 5 TAB 7 LINE +*/ char const TAB = '\001'; char const LINE = '\002'; @@ -158,7 +159,7 @@ string const trim(string const & a, char const * p = " \t\n\r") void split(string const & s, vector & result, char delim = ',') { - istringstream is(s); + istringstream is(s); string t; while (getline(is, t, delim)) result.push_back(t); @@ -174,7 +175,7 @@ map split_map(string const & s) for (size_t i = 0; i < v.size(); ++i) { size_t const pos = v[i].find('='); string const index = v[i].substr(0, pos); - string const value = v[i].substr(pos + 1, string::npos); + string const value = v[i].substr(pos + 1, string::npos); res[trim(index)] = trim(value); } return res; @@ -186,8 +187,8 @@ string join(vector const & input, char const * delim) ostringstream os; for (size_t i = 0; i != input.size(); ++i) { if (i) - os << delim; - os << input[i]; + os << delim; + os << input[i]; } return os.str(); } @@ -266,7 +267,7 @@ void handle_par(ostream & os) return; os << "\n\\layout "; string s = curr_env(); - if (s == "document" || s == "table") + if (s == "document" || s == "table") os << "Standard\n\n"; else if (s == "lyxcode") os << "LyX-Code\n\n"; @@ -285,23 +286,23 @@ void handle_package(string const & name, string const & options) if (name == "a4wide") { h_papersize = "a4paper"; h_paperpackage = "widemarginsa4"; - } else if (name == "ae") + } else if (name == "ae") h_fontscheme = "ae"; - else if (name == "aecompl") + else if (name == "aecompl") h_fontscheme = "ae"; - else if (name == "amsmath") + else if (name == "amsmath") h_use_amsmath = "1"; - else if (name == "amssymb") + else if (name == "amssymb") h_use_amsmath = "1"; - else if (name == "babel") + else if (name == "babel") ; // ignore this - else if (name == "fontenc") + else if (name == "fontenc") ; // ignore this - else if (name == "inputenc") + else if (name == "inputenc") h_inputencoding = options; - else if (name == "makeidx") + else if (name == "makeidx") ; // ignore this - else if (name == "verbatim") + else if (name == "verbatim") ; // ignore this else if (is_known(name, known_languages)) { h_language = name; @@ -373,7 +374,7 @@ void handle_tabular(Parser & p, ostream & os, mode_type mode) cells.push_back(string()); os << "\n"; for (size_t c = 0; c < cols; ++c) { os << "\n"; } os << "\n"; - end_inset(os); + end_inset(os); } @@ -457,7 +458,7 @@ void parse_preamble(Parser & p, ostream & os) // cat codes // if (t.cat() == catLetter || - t.cat() == catSpace || + t.cat() == catSpace || t.cat() == catSuper || t.cat() == catSub || t.cat() == catOther || @@ -489,7 +490,7 @@ void parse_preamble(Parser & p, ostream & os) p.setCatCode('@', catLetter); h_preamble << "\\makeatletter\n"; } - + else if (t.cs() == "makeatother") { p.setCatCode('@', catOther); h_preamble << "\\makeatother\n"; @@ -526,8 +527,8 @@ void parse_preamble(Parser & p, ostream & os) else if (t.cs() == "documentclass") { vector opts; split(p.getArg('[', ']'), opts, ','); - handle_opt(opts, known_languages, h_language); - handle_opt(opts, known_fontsizes, h_paperfontsize); + handle_opt(opts, known_languages, h_language); + handle_opt(opts, known_fontsizes, h_paperfontsize); h_quotes_language = h_language; h_options = join(opts, ","); h_textclass = p.getArg('{', '}'); @@ -572,9 +573,9 @@ void parse_preamble(Parser & p, ostream & os) else if (t.cs() == "setcounter") { string const name = p.getArg('{', '}'); string const content = p.getArg('{', '}'); - if (name == "secnumdepth") + if (name == "secnumdepth") h_secnumdepth = content; - else if (name == "tocdepth") + else if (name == "tocdepth") h_tocdepth = content; else h_preamble << "\\setcounter{" << name << "}{" << content << "}\n"; @@ -587,10 +588,10 @@ void parse_preamble(Parser & p, ostream & os) h_paragraph_separation = "skip"; else if (name == "parindent") h_paragraph_separation = "skip"; - else + else h_preamble << "\\setlength{" + name + "}{" + content + "}\n"; } - + else if (t.cs() == "par") h_preamble << '\n'; @@ -701,8 +702,8 @@ void parse(Parser & p, ostream & os, unsigned flags, const mode_type mode) } else if (t.cat() == catLetter || - t.cat() == catSpace || - t.cat() == catSuper || + t.cat() == catSpace || + t.cat() == catSuper || t.cat() == catSub || t.cat() == catOther || t.cat() == catParameter) @@ -717,7 +718,7 @@ void parse(Parser & p, ostream & os, unsigned flags, const mode_type mode) os << ' '; else if (mode == TEXT_MODE) os << "\\SpecialChar ~\n"; - else + else os << '~'; } else os << t.character(); @@ -793,7 +794,7 @@ void parse(Parser & p, ostream & os, unsigned flags, const mode_type mode) p.setCatCode('@', catLetter); handle_ert(os, "\\makeatletter\n"); } - + else if (t.cs() == "makeatother") { p.setCatCode('@', catOther); handle_ert(os, "\\makeatother\n"); @@ -860,13 +861,13 @@ void parse(Parser & p, ostream & os, unsigned flags, const mode_type mode) handle_par(os); parse(p, os, FLAG_END, mode); } else if (is_math_env(name)) { - begin_inset(os, "Formula "); + begin_inset(os, "Formula "); os << "\\begin{" << name << "}"; parse(p, os, FLAG_END, MATH_MODE); os << "\\end{" << name << "}"; - end_inset(os); + end_inset(os); } else if (name == "tabular") { - if (mode == TEXT_MODE) + if (mode == TEXT_MODE) handle_tabular(p, os, mode); else { os << "\\begin{" << name << "}"; @@ -883,7 +884,7 @@ void parse(Parser & p, ostream & os, unsigned flags, const mode_type mode) << "\n" << "\\layout Standard\n"; parse(p, os, FLAG_END, mode); - end_inset(os); + end_inset(os); } else if (name == "thebibliography") { p.verbatimItem(); // swallow next arg parse(p, os, FLAG_END, mode); @@ -928,8 +929,8 @@ void parse(Parser & p, ostream & os, unsigned flags, const mode_type mode) else if (t.cs() == "documentclass") { vector opts; split(p.getArg('[', ']'), opts, ','); - handle_opt(opts, known_languages, h_language); - handle_opt(opts, known_fontsizes, h_paperfontsize); + handle_opt(opts, known_languages, h_language); + handle_opt(opts, known_fontsizes, h_paperfontsize); h_quotes_language = h_language; h_options = join(opts, ","); h_textclass = p.getArg('{', '}'); @@ -1001,14 +1002,14 @@ void parse(Parser & p, ostream & os, unsigned flags, const mode_type mode) else if (t.cs() == "multicolumn" && mode == TEXT_MODE) { // brutish... - parse(p, os, FLAG_ITEM, mode); + parse(p, os, FLAG_ITEM, mode); os << MULT; - parse(p, os, FLAG_ITEM, mode); + parse(p, os, FLAG_ITEM, mode); os << MULT; - parse(p, os, FLAG_ITEM, mode); + parse(p, os, FLAG_ITEM, mode); } - else if (t.cs() == "hline" && mode == TEXT_MODE) + else if (t.cs() == "hline" && mode == TEXT_MODE) os << HLINE; else if (t.cs() == "textrm") { @@ -1151,7 +1152,7 @@ void parse(Parser & p, ostream & os, unsigned flags, const mode_type mode) else handle_ert(os, "\"{" + name + "}"); } - else if (t.cs() == "ss") + else if (t.cs() == "ss") os << "ß"; else if (t.cs() == "input") @@ -1213,7 +1214,7 @@ int main(int argc, char * argv[]) parse(p, cout, FLAG_END, TEXT_MODE); cout << "\n\\the_end"; - return 0; -} + return 0; +} // }]) diff --git a/src/text.C b/src/text.C index c179a22ac5..cb3d88c800 100644 --- a/src/text.C +++ b/src/text.C @@ -58,6 +58,20 @@ extern int const LEFT_MARGIN = PAPER_MARGIN + CHANGEBAR_MARGIN; extern int bibitemMaxWidth(BufferView *, LyXFont const &); +BufferView * LyXText::bv() +{ + lyx::Assert(bv_owner != 0); + return bv_owner; +} + + +BufferView * LyXText::bv() const +{ + lyx::Assert(bv_owner != 0); + return bv_owner; +} + + int LyXText::top_y() const { if (!top_row_) @@ -85,17 +99,17 @@ void LyXText::top_y(int newy) } -int LyXText::workWidth(BufferView & bview) const +int LyXText::workWidth() const { if (inset_owner) { // FIXME: pass (const ?) ref - return inset_owner->textWidth(&bview); + return inset_owner->textWidth(bv()); } - return bview.workWidth(); + return bv()->workWidth(); } -int LyXText::workWidth(BufferView & bview, Inset * inset) const +int LyXText::workWidth(Inset * inset) const { Paragraph * par = inset->parOwner(); lyx::Assert(par); @@ -112,7 +126,7 @@ int LyXText::workWidth(BufferView & bview, Inset * inset) const Row dummyrow; dummyrow.par(par); dummyrow.pos(pos); - return workWidth(bview) - leftMargin(&bview, &dummyrow); + return workWidth() - leftMargin(&dummyrow); } else { int dummy_y; Row * row = getRow(par, pos, dummy_y); @@ -132,15 +146,15 @@ int LyXText::workWidth(BufferView & bview, Inset * inset) const return maxw; } - return workWidth(bview); + return workWidth(); } -int LyXText::getRealCursorX(BufferView * bview) const +int LyXText::getRealCursorX() const { int x = cursor.x(); - if (the_locking_inset && (the_locking_inset->getLyXText(bview)!=this)) - x = the_locking_inset->getLyXText(bview)->getRealCursorX(bview); + if (the_locking_inset && (the_locking_inset->getLyXText(bv())!= this)) + x = the_locking_inset->getLyXText(bv())->getRealCursorX(); return x; } @@ -203,24 +217,24 @@ unsigned char LyXText::transformChar(unsigned char c, Paragraph * par, // // Lgb -int LyXText::singleWidth(BufferView * bview, Paragraph * par, +int LyXText::singleWidth(Paragraph * par, pos_type pos) const { if (pos >= par->size()) return 0; char const c = par->getChar(pos); - return singleWidth(bview, par, pos, c); + return singleWidth(par, pos, c); } -int LyXText::singleWidth(BufferView * bview, Paragraph * par, +int LyXText::singleWidth(Paragraph * par, pos_type pos, char c) const { if (pos >= par->size()) return 0; - LyXFont const font = getFont(bview->buffer(), par, pos); + LyXFont const font = getFont(bv()->buffer(), par, pos); // The most common case is handled first (Asger) if (IsPrintable(c)) { @@ -251,9 +265,9 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par, // this IS needed otherwise on initialitation we don't get the fill // of the row right (ONLY on initialization if we read a file!) // should be changed! (Jug 20011204) - tmpinset->update(bview, font); + tmpinset->update(bv(), font); #endif - return tmpinset->width(bview, font); + return tmpinset->width(bv(), font); } return 0; } @@ -425,7 +439,7 @@ bool LyXText::isBoundary(Buffer const * buf, Paragraph * par, } -int LyXText::leftMargin(BufferView * bview, Row const * row) const +int LyXText::leftMargin(Row const * row) const { Inset * ins; @@ -436,7 +450,7 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const return LEFT_MARGIN; LyXTextClass const & tclass = - bview->buffer()->params.getLyXTextClass(); + bv()->buffer()->params.getLyXTextClass(); LyXLayout_ptr const & layout = row->par()->layout(); string parindent = layout->parindent; @@ -471,7 +485,7 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const Row dummyrow; dummyrow.par(newpar); dummyrow.pos(newpar->size()); - x = leftMargin(bview, &dummyrow); + x = leftMargin(&dummyrow); } else { // this is no longer an error, because this function // is used to clear impossible depths after changing @@ -490,7 +504,7 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const } } - LyXFont const labelfont = getLabelFont(bview->buffer(), row->par()); + LyXFont const labelfont = getLabelFont(bv()->buffer(), row->par()); switch (layout->margintype) { case MARGIN_DYNAMIC: if (!layout->leftmargin.empty()) { @@ -575,12 +589,12 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const break; } - if ((workWidth(*bview) > 0) && + if ((workWidth() > 0) && !row->par()->params().leftIndent().zero()) { LyXLength const len = row->par()->params().leftIndent(); int const tw = inset_owner ? - inset_owner->latexTextWidth(bview) : workWidth(*bview); + inset_owner->latexTextWidth(bv()) : workWidth(); x += len.inPixels(tw); } @@ -606,13 +620,13 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const (row->par()->inInset()->owner()->lyxCode() != Inset::TABULAR_CODE && row->par()->inInset()->owner()->lyxCode() != Inset::ERT_CODE)) && (row->par()->layout() != tclass.defaultLayout() || - bview->buffer()->params.paragraph_separation == + bv()->buffer()->params.paragraph_separation == BufferParams::PARSEP_INDENT)) { x += font_metrics::signedWidth(parindent, tclass.defaultfont()); } else if (layout->labeltype == LABEL_BIBLIO) { // ale970405 Right width for bibitems - x += bibitemMaxWidth(bview, tclass.defaultfont()); + x += bibitemMaxWidth(bv(), tclass.defaultfont()); } } @@ -675,13 +689,13 @@ int LyXText::rightMargin(Buffer const & buf, Row const & row) const } -int LyXText::labelEnd(BufferView & bview, Row const & row) const +int LyXText::labelEnd(Row const & row) const { if (row.par()->layout()->margintype == MARGIN_MANUAL) { Row tmprow = row; tmprow.pos(row.par()->size()); // return the beginning of the body - return leftMargin(&bview, &tmprow); + return leftMargin(&tmprow); } // LabelEnd is only needed if the layout @@ -711,12 +725,12 @@ pos_type addressBreakPoint(pos_type i, Paragraph * par) pos_type -LyXText::rowBreakPoint(BufferView & bv, Row const & row) const +LyXText::rowBreakPoint(Row const & row) const { Paragraph * par = row.par(); // maximum pixel width of a row. - int width = workWidth(bv) - rightMargin(*bv.buffer(), row); + int width = workWidth() - rightMargin(*bv()->buffer(), row); // inset->textWidth() returns -1 via workWidth(), // but why ? @@ -740,7 +754,7 @@ LyXText::rowBreakPoint(BufferView & bv, Row const & row) const // or the end of the par, then choose the possible break // nearest that. - int const left = leftMargin(&bv, &row); + int const left = leftMargin(&row); int x = left; // pixel width since last breakpoint @@ -756,15 +770,15 @@ LyXText::rowBreakPoint(BufferView & bv, Row const & row) const char const c = par->getChar(i); - int thiswidth = singleWidth(&bv, par, i, c); + int thiswidth = singleWidth(par, i, c); // add the auto-hfill from label end to the body if (body_pos && i == body_pos) { thiswidth += font_metrics::width(layout->labelsep, - getLabelFont(bv.buffer(), par)); + getLabelFont(bv()->buffer(), par)); if (par->isLineSeparator(i - 1)) - thiswidth -= singleWidth(&bv, par, i - 1); - int left_margin = labelEnd(bv, row); + thiswidth -= singleWidth(par, i - 1); + int left_margin = labelEnd(row); if (thiswidth < left_margin) thiswidth = left_margin; } @@ -843,7 +857,7 @@ LyXText::rowBreakPoint(BufferView & bv, Row const & row) const // returns the minimum space a row needs on the screen in pixel -int LyXText::fill(BufferView & bview, Row & row, int paper_width) const +int LyXText::fill(Row & row, int paper_width) const { if (paper_width < 0) return 0; @@ -856,10 +870,10 @@ int LyXText::fill(BufferView & bview, Row & row, int paper_width) const if (row.par()->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) { int const tmpfill = row.fill(); row.fill(0); // the minfill in MarginLeft() - w = leftMargin(&bview, &row); + w = leftMargin(&row); row.fill(tmpfill); } else - w = leftMargin(&bview, &row); + w = leftMargin(&row); Paragraph * par = row.par(); LyXLayout_ptr const & layout = par->layout(); @@ -869,32 +883,32 @@ int LyXText::fill(BufferView & bview, Row & row, int paper_width) const while (i <= last) { if (body_pos > 0 && i == body_pos) { - w += font_metrics::width(layout->labelsep, getLabelFont(bview.buffer(), par)); + w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), par)); if (par->isLineSeparator(i - 1)) - w -= singleWidth(&bview, par, i - 1); - int left_margin = labelEnd(bview, row); + w -= singleWidth(par, i - 1); + int left_margin = labelEnd(row); if (w < left_margin) w = left_margin; } - w += singleWidth(&bview, par, i); + w += singleWidth(par, i); ++i; } if (body_pos > 0 && body_pos > last) { - w += font_metrics::width(layout->labelsep, getLabelFont(bview.buffer(), par)); + w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), par)); if (last >= 0 && par->isLineSeparator(last)) - w -= singleWidth(&bview, par, last); - int const left_margin = labelEnd(bview, row); + w -= singleWidth(par, last); + int const left_margin = labelEnd(row); if (w < left_margin) w = left_margin; } - int const fill = paper_width - w - rightMargin(*bview.buffer(), row); + int const fill = paper_width - w - rightMargin(*bv()->buffer(), row); return fill; } // returns the minimum space a manual label needs on the screen in pixel -int LyXText::labelFill(BufferView & bview, Row const & row) const +int LyXText::labelFill(Row const & row) const { pos_type last = row.par()->beginningOfBody(); @@ -911,14 +925,14 @@ int LyXText::labelFill(BufferView & bview, Row const & row) const int w = 0; pos_type i = row.pos(); while (i <= last) { - w += singleWidth(&bview, row.par(), i); + w += singleWidth(row.par(), i); ++i; } int fill = 0; string const & labwidstr = row.par()->params().labelWidthString(); if (!labwidstr.empty()) { - LyXFont const labfont = getLabelFont(bview.buffer(), row.par()); + LyXFont const labfont = getLabelFont(bv()->buffer(), row.par()); int const labwidth = font_metrics::width(labwidstr, labfont); fill = max(labwidth - w, 0); } @@ -935,7 +949,7 @@ LColor::color LyXText::backgroundColor() const return LColor::background; } -void LyXText::setHeightOfRow(BufferView * bview, Row * row) const +void LyXText::setHeightOfRow(Row * row) const { // get the maximum ascent and the maximum descent int asc = 0; @@ -961,19 +975,19 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row) const // as max get the first character of this row then it can increase but not // decrease the height. Just some point to start with so we don't have to // do the assignment below too often. - LyXFont font = getFont(bview->buffer(), par, row->pos()); + LyXFont font = getFont(bv()->buffer(), par, row->pos()); LyXFont::FONT_SIZE const tmpsize = font.size(); - font = getLayoutFont(bview->buffer(), par); + font = getLayoutFont(bv()->buffer(), par); LyXFont::FONT_SIZE const size = font.size(); font.setSize(tmpsize); - LyXFont labelfont = getLabelFont(bview->buffer(), par); + LyXFont labelfont = getLabelFont(bv()->buffer(), par); float spacing_val = 1.0; if (!row->par()->params().spacing().isDefault()) { spacing_val = row->par()->params().spacing().getValue(); } else { - spacing_val = bview->buffer()->params.spacing.getValue(); + spacing_val = bv()->buffer()->params.spacing.getValue(); } //lyxerr << "spacing_val = " << spacing_val << endl; @@ -992,20 +1006,20 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row) const // Check if any insets are larger for (pos_type pos = row->pos(); pos <= pos_end; ++pos) { if (row->par()->isInset(pos)) { - tmpfont = getFont(bview->buffer(), row->par(), pos); + tmpfont = getFont(bv()->buffer(), row->par(), pos); tmpinset = row->par()->getInset(pos); if (tmpinset) { #if 1 // this is needed for deep update on initialitation - tmpinset->update(bview, tmpfont); + tmpinset->update(bv(), tmpfont); #endif - asc = tmpinset->ascent(bview, tmpfont); - desc = tmpinset->descent(bview, tmpfont); - maxwidth += tmpinset->width(bview, tmpfont); + asc = tmpinset->ascent(bv(), tmpfont); + desc = tmpinset->descent(bv(), tmpfont); + maxwidth += tmpinset->width(bv(), tmpfont); maxasc = max(maxasc, asc); maxdesc = max(maxdesc, desc); } } else { - maxwidth += singleWidth(bview, row->par(), pos); + maxwidth += singleWidth(row->par(), pos); } } } @@ -1036,35 +1050,35 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row) const if (!row->pos() && (row->par() == firstpar)) { // some parksips VERY EASY IMPLEMENTATION - if (bview->buffer()->params.paragraph_separation == + if (bv()->buffer()->params.paragraph_separation == BufferParams::PARSEP_SKIP) { if (layout->isParagraph() && firstpar->getDepth() == 0 && firstpar->previous()) { - maxasc += bview->buffer()->params.getDefSkip().inPixels(*bview); + maxasc += bv()->buffer()->params.getDefSkip().inPixels(*bv()); } else if (firstpar->previous() && firstpar->previous()->layout()->isParagraph() && firstpar->previous()->getDepth() == 0) { // is it right to use defskip here too? (AS) - maxasc += bview->buffer()->params.getDefSkip().inPixels(*bview); + maxasc += bv()->buffer()->params.getDefSkip().inPixels(*bv()); } } // the top margin - if (!row->par()->previous() && isTopLevel()) + if (!row->par()->previous() && !isInInset()) maxasc += PAPER_MARGIN; // add the vertical spaces, that the user added - maxasc += getLengthMarkerHeight(*bview, firstpar->params().spaceTop()); + maxasc += getLengthMarkerHeight(*bv(), firstpar->params().spaceTop()); // do not forget the DTP-lines! // there height depends on the font of the nearest character if (firstpar->params().lineTop()) - maxasc += 2 * font_metrics::ascent('x', getFont(bview->buffer(), + maxasc += 2 * font_metrics::ascent('x', getFont(bv()->buffer(), firstpar, 0)); // and now the pagebreaks if (firstpar->params().pagebreakTop()) @@ -1076,13 +1090,13 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row) const // This is special code for the chapter, since the label of this // layout is printed in an extra row if (layout->labeltype == LABEL_COUNTER_CHAPTER - && bview->buffer()->params.secnumdepth >= 0) + && bv()->buffer()->params.secnumdepth >= 0) { float spacing_val = 1.0; if (!row->par()->params().spacing().isDefault()) { spacing_val = row->par()->params().spacing().getValue(); } else { - spacing_val = bview->buffer()->params.spacing.getValue(); + spacing_val = bv()->buffer()->params.spacing.getValue(); } labeladdon = int(font_metrics::maxDescent(labelfont) * @@ -1104,7 +1118,7 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row) const if (!row->par()->params().spacing().isDefault()) { spacing_val = row->par()->params().spacing().getValue(); } else { - spacing_val = bview->buffer()->params.spacing.getValue(); + spacing_val = bv()->buffer()->params.spacing.getValue(); } labeladdon = int( @@ -1166,17 +1180,17 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row) const if (row->par() == par && (!row->next() || row->next()->par() != row->par())) { // the bottom margin - if (!par->next() && isTopLevel()) + if (!par->next() && !isInInset()) maxdesc += PAPER_MARGIN; // add the vertical spaces, that the user added - maxdesc += getLengthMarkerHeight(*bview, firstpar->params().spaceBottom()); + maxdesc += getLengthMarkerHeight(*bv(), firstpar->params().spaceBottom()); // do not forget the DTP-lines! // there height depends on the font of the nearest character if (firstpar->params().lineBottom()) maxdesc += 2 * font_metrics::ascent('x', - getFont(bview->buffer(), + getFont(bv()->buffer(), par, max(pos_type(0), par->size() - 1))); @@ -1236,12 +1250,12 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row) const float dummy; // this IS needed row->width(maxwidth); - prepareToPrint(bview, row, x, dummy, dummy, dummy, false); + prepareToPrint(row, x, dummy, dummy, dummy, false); } row->width(int(maxwidth + x)); if (inset_owner) { Row * r = firstrow; - width = max(0, workWidth(*bview)); + width = max(0, workWidth()); while (r) { if (r->width() > width) width = r->width(); @@ -1253,13 +1267,13 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row) const // Appends the implicit specified paragraph before the specified row, // start at the implicit given position -void LyXText::appendParagraph(BufferView * bview, Row * row) const +void LyXText::appendParagraph(Row * row) const { pos_type const last = row->par()->size(); bool done = false; do { - pos_type z = rowBreakPoint(*bview, *row); + pos_type z = rowBreakPoint(*row); Row * tmprow = row; @@ -1275,8 +1289,8 @@ void LyXText::appendParagraph(BufferView * bview, Row * row) const // Set the dimensions of the row // fixed fill setting now by calling inset->update() in // SingleWidth when needed! - tmprow->fill(fill(*bview, *tmprow, workWidth(*bview))); - setHeightOfRow(bview, tmprow); + tmprow->fill(fill(*tmprow, workWidth())); + setHeightOfRow(tmprow); } while (!done); } @@ -1285,10 +1299,10 @@ void LyXText::appendParagraph(BufferView * bview, Row * row) const // Do we even need this at all ? Code that uses RowPainter *already* // sets need_break_row when it sees a CHANGED_IN_DRAW, though not // quite like this -void LyXText::markChangeInDraw(BufferView * bv, Row * row, Row * prev) +void LyXText::markChangeInDraw(Row * row, Row * prev) { if (prev && prev->par() == row->par()) { - breakAgainOneRow(bv, prev); + breakAgainOneRow(prev); if (prev->next() != row) { // breakAgainOneRow() has removed row_ need_break_row = prev; @@ -1300,17 +1314,17 @@ void LyXText::markChangeInDraw(BufferView * bv, Row * row, Row * prev) } else { need_break_row = prev->next(); } - setCursor(bv, cursor.par(), cursor.pos()); + setCursor(cursor.par(), cursor.pos()); /* FIXME */ } -void LyXText::breakAgain(BufferView * bview, Row * row) const +void LyXText::breakAgain(Row * row) const { bool not_ready = true; do { - pos_type z = rowBreakPoint(*bview, *row); + pos_type z = rowBreakPoint(*row); Row * tmprow = row; if (z < row->par()->size()) { @@ -1324,7 +1338,7 @@ void LyXText::breakAgain(BufferView * bview, Row * row) const row = row->next(); ++z; if (row->pos() == z) - not_ready = false; // the rest will not change + not_ready = false; // the rest will not change else { row->pos(z); } @@ -1344,16 +1358,16 @@ void LyXText::breakAgain(BufferView * bview, Row * row) const } // set the dimensions of the row - tmprow->fill(fill(*bview, *tmprow, workWidth(*bview))); - setHeightOfRow(bview, tmprow); + tmprow->fill(fill(*tmprow, workWidth())); + setHeightOfRow(tmprow); } while (not_ready); } // this is just a little changed version of break again -void LyXText::breakAgainOneRow(BufferView * bview, Row * row) +void LyXText::breakAgainOneRow(Row * row) { - pos_type z = rowBreakPoint(*bview, *row); + pos_type z = rowBreakPoint(*row); Row * tmprow = row; if (z < row->par()->size()) { @@ -1385,13 +1399,12 @@ void LyXText::breakAgainOneRow(BufferView * bview, Row * row) } // set the dimensions of the row - tmprow->fill(fill(*bview, *tmprow, workWidth(*bview))); - setHeightOfRow(bview, tmprow); + tmprow->fill(fill(*tmprow, workWidth())); + setHeightOfRow(tmprow); } -void LyXText::breakParagraph(BufferView * bview, - ParagraphList & paragraphs, char keep_layout) +void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout) { // allow only if at start or end, or all previous is new text if (cursor.pos() && cursor.pos() != cursor.par()->size() @@ -1399,7 +1412,7 @@ void LyXText::breakParagraph(BufferView * bview, return; LyXTextClass const & tclass = - bview->buffer()->params.getLyXTextClass(); + bv()->buffer()->params.getLyXTextClass(); LyXLayout_ptr const & layout = cursor.par()->layout(); // this is only allowed, if the current paragraph is not empty or caption @@ -1409,7 +1422,7 @@ void LyXText::breakParagraph(BufferView * bview, && !layout->keepempty) return; - setUndo(bview, Undo::FINISH, cursor.par(), cursor.par()->next()); + setUndo(bv(), Undo::FINISH, cursor.par(), cursor.par()->next()); // Always break behind a space // @@ -1430,7 +1443,7 @@ void LyXText::breakParagraph(BufferView * bview, // paragraph before or behind and we should react on that one // but we can fix this in 1.3.0 (Jug 20020509) bool const isempty = (layout->keepempty && cursor.par()->empty()); - ::breakParagraph(bview->buffer()->params, paragraphs, cursor.par(), cursor.pos(), + ::breakParagraph(bv()->buffer()->params, paragraphs, cursor.par(), cursor.pos(), keep_layout); // well this is the caption hack since one caption is really enough @@ -1450,7 +1463,7 @@ void LyXText::breakParagraph(BufferView * bview, if (cursor.pos() && !cursor.row()->par()->isNewline(cursor.row()->pos() - 1) && cursor.row()->pos() == cursor.pos()) { - cursorLeft(bview); + cursorLeft(bv()); } int y = cursor.y() - cursor.row()->baseline(); @@ -1464,14 +1477,14 @@ void LyXText::breakParagraph(BufferView * bview, } } - postPaint(*bview, y); + postPaint(y); removeParagraph(cursor.row()); // set the dimensions of the cursor row - cursor.row()->fill(fill(*bview, *cursor.row(), workWidth(*bview))); + cursor.row()->fill(fill(*cursor.row(), workWidth())); - setHeightOfRow(bview, cursor.row()); + setHeightOfRow(cursor.row()); #warning Trouble Point! (Lgb) // When ::breakParagraph is called from within an inset we must @@ -1481,38 +1494,38 @@ void LyXText::breakParagraph(BufferView * bview, && cursor.par()->next()->isNewline(0)) cursor.par()->next()->erase(0); - insertParagraph(bview, cursor.par()->next(), cursor.row()); + insertParagraph(cursor.par()->next(), cursor.row()); - updateCounters(bview); + updateCounters(); // This check is necessary. Otherwise the new empty paragraph will // be deleted automatically. And it is more friendly for the user! if (cursor.pos() || isempty) - setCursor(bview, cursor.par()->next(), 0); + setCursor(cursor.par()->next(), 0); else - setCursor(bview, cursor.par(), 0); + setCursor(cursor.par(), 0); if (cursor.row()->next()) - breakAgain(bview, cursor.row()->next()); + breakAgain(cursor.row()->next()); need_break_row = 0; } // Just a macro to make some thing easier. -void LyXText::redoParagraph(BufferView * bview) const +void LyXText::redoParagraph() const { clearSelection(); - redoParagraphs(bview, cursor, cursor.par()->next()); - setCursorIntern(bview, cursor.par(), cursor.pos()); + redoParagraphs(cursor, cursor.par()->next()); + setCursorIntern(cursor.par(), cursor.pos()); } // insert a character, moves all the following breaks in the // same Paragraph one to the right and make a rebreak -void LyXText::insertChar(BufferView * bview, char c) +void LyXText::insertChar(char c) { - setUndo(bview, Undo::INSERT, cursor.par(), cursor.par()->next()); + setUndo(bv(), Undo::INSERT, cursor.par(), cursor.par()->next()); // When the free-spacing option is set for the current layout, // disable the double-space checking @@ -1530,17 +1543,17 @@ void LyXText::insertChar(BufferView * bview, char c) !(contains(number_seperators, c) && cursor.pos() >= 1 && cursor.pos() < cursor.par()->size() && - getFont(bview->buffer(), + getFont(bv()->buffer(), cursor.par(), cursor.pos()).number() == LyXFont::ON && - getFont(bview->buffer(), + getFont(bv()->buffer(), cursor.par(), cursor.pos() - 1).number() == LyXFont::ON) ) - number(bview); // Set current_font.number to OFF + number(bv()); // Set current_font.number to OFF } else if (IsDigit(c) && real_current_font.isVisibleRightToLeft()) { - number(bview); // Set current_font.number to ON + number(bv()); // Set current_font.number to ON if (cursor.pos() > 0) { char const c = cursor.par()->getChar(cursor.pos() - 1); @@ -1549,16 +1562,16 @@ void LyXText::insertChar(BufferView * bview, char c) cursor.par()->isSeparator(cursor.pos() - 2) || cursor.par()->isNewline(cursor.pos() - 2)) ) { - setCharFont(bview->buffer(), + setCharFont(bv()->buffer(), cursor.par(), cursor.pos() - 1, current_font); } else if (contains(number_seperators, c) && cursor.pos() >= 2 && - getFont(bview->buffer(), + getFont(bv()->buffer(), cursor.par(), cursor.pos() - 2).number() == LyXFont::ON) { - setCharFont(bview->buffer(), + setCharFont(bv()->buffer(), cursor.par(), cursor.pos() - 1, current_font); @@ -1587,7 +1600,7 @@ void LyXText::insertChar(BufferView * bview, char c) // Get the font that is used to calculate the baselineskip pos_type const lastpos = cursor.par()->size(); LyXFont rawparfont = - cursor.par()->getFontSettings(bview->buffer()->params, + cursor.par()->getFontSettings(bv()->buffer()->params, lastpos - 1); bool jumped_over_space = false; @@ -1601,9 +1614,9 @@ void LyXText::insertChar(BufferView * bview, char c) static bool sent_space_message = false; if (!sent_space_message) { if (cursor.pos() == 0) - bview->owner()->message(_("You cannot insert a space at the beginning of a paragraph. Please read the Tutorial.")); + bv()->owner()->message(_("You cannot insert a space at the beginning of a paragraph. Please read the Tutorial.")); else - bview->owner()->message(_("You cannot type two spaces this way. Please read the Tutorial.")); + bv()->owner()->message(_("You cannot type two spaces this way. Please read the Tutorial.")); sent_space_message = true; } charInserted(); @@ -1628,7 +1641,7 @@ void LyXText::insertChar(BufferView * bview, char c) // Here case LyXText::InsertInset already insertet the character cursor.par()->insertChar(cursor.pos(), c); } - setCharFont(bview->buffer(), cursor.par(), cursor.pos(), rawtmpfont); + setCharFont(bv()->buffer(), cursor.par(), cursor.pos(), rawtmpfont); if (!jumped_over_space) { // refresh the positions @@ -1647,27 +1660,27 @@ void LyXText::insertChar(BufferView * bview, char c) cursor.par()->isInset(cursor.pos()+1)) || cursor.row()->fill() == -1)) { - pos_type z = rowBreakPoint(*bview, *row->previous()); + pos_type z = rowBreakPoint(*row->previous()); if (z >= row->pos()) { row->pos(z + 1); // set the dimensions of the row above - row->previous()->fill(fill(*bview, + row->previous()->fill(fill( *row->previous(), - workWidth(*bview))); + workWidth())); - setHeightOfRow(bview, row->previous()); + setHeightOfRow(row->previous()); y -= row->previous()->height(); - postPaint(*bview, y); + postPaint(y); - breakAgainOneRow(bview, row); + breakAgainOneRow(row); current_font = rawtmpfont; real_current_font = realtmpfont; - setCursor(bview, cursor.par(), cursor.pos() + 1, + setCursor(cursor.par(), cursor.pos() + 1, false, cursor.boundary()); // cursor MUST be in row now. @@ -1679,7 +1692,7 @@ void LyXText::insertChar(BufferView * bview, char c) // check, wether the last characters font has changed. if (cursor.pos() && cursor.pos() == cursor.par()->size() && rawparfont != rawtmpfont) - redoHeightOfParagraph(bview); + redoHeightOfParagraph(); charInserted(); return; @@ -1690,27 +1703,27 @@ void LyXText::insertChar(BufferView * bview, char c) if (row->fill() >= 0) { // needed because a newline will set fill to -1. Otherwise // we would not get a rebreak! - row->fill(fill(*bview, *row, workWidth(*bview))); + row->fill(fill(*row, workWidth())); } if (c == Paragraph::META_INSET || row->fill() < 0) { - postPaint(*bview, y); - breakAgainOneRow(bview, row); + postPaint(y); + breakAgainOneRow(row); // will the cursor be in another row now? if (row->lastPos() <= cursor.pos() + 1 && row->next()) { if (row->next() && row->next()->par() == row->par()) // this should always be true row = row->next(); - breakAgainOneRow(bview, row); + breakAgainOneRow(row); } current_font = rawtmpfont; real_current_font = realtmpfont; - setCursor(bview, cursor.par(), cursor.pos() + 1, false, + setCursor(cursor.par(), cursor.pos() + 1, false, cursor.boundary()); - if (isBoundary(bview->buffer(), cursor.par(), cursor.pos()) + if (isBoundary(bv()->buffer(), cursor.par(), cursor.pos()) != cursor.boundary()) - setCursor(bview, cursor.par(), cursor.pos(), false, + setCursor(cursor.par(), cursor.pos(), false, !cursor.boundary()); if (row->next() && row->next()->par() == row->par()) need_break_row = row->next(); @@ -1720,29 +1733,29 @@ void LyXText::insertChar(BufferView * bview, char c) // FIXME: similar code is duplicated all over - make resetHeightOfRow int const tmpheight = row->height(); - setHeightOfRow(bview, row); + setHeightOfRow(row); if (tmpheight == row->height()) { - postRowPaint(*bview, row, y); + postRowPaint(row, y); } else { - postPaint(*bview, y); + postPaint(y); } current_font = rawtmpfont; real_current_font = realtmpfont; - setCursor(bview, cursor.par(), cursor.pos() + 1, false, + setCursor(cursor.par(), cursor.pos() + 1, false, cursor.boundary()); } // check, wether the last characters font has changed. if (cursor.pos() && cursor.pos() == cursor.par()->size() && rawparfont != rawtmpfont) { - redoHeightOfParagraph(bview); + redoHeightOfParagraph(); } else { // now the special right address boxes if (cursor.par()->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) { - redoDrawingOfParagraph(bview, cursor); + redoDrawingOfParagraph(cursor); } } @@ -1764,8 +1777,7 @@ void LyXText::charInserted() } -void LyXText::prepareToPrint(BufferView * bview, - Row * row, float & x, +void LyXText::prepareToPrint(Row * row, float & x, float & fill_separator, float & fill_hfill, float & fill_label_hfill, @@ -1781,13 +1793,13 @@ void LyXText::prepareToPrint(BufferView * bview, fill_label_hfill = 0; bool const is_rtl = - row->par()->isRightToLeftPar(bview->buffer()->params); + row->par()->isRightToLeftPar(bv()->buffer()->params); if (is_rtl) { - x = (workWidth(*bview) > 0) - ? rightMargin(*bview->buffer(), *row) : 0; + x = (workWidth() > 0) + ? rightMargin(*bv()->buffer(), *row) : 0; } else - x = (workWidth(*bview) > 0) - ? leftMargin(bview, row) : 0; + x = (workWidth() > 0) + ? leftMargin(row) : 0; // is there a manual margin with a manual label LyXLayout_ptr const & layout = row->par()->layout(); @@ -1806,7 +1818,7 @@ void LyXText::prepareToPrint(BufferView * bview, ++nlh; if (nlh && !row->par()->getLabelWidthString().empty()) { - fill_label_hfill = labelFill(*bview, *row) / nlh; + fill_label_hfill = labelFill(*row) / nlh; } } @@ -1819,7 +1831,7 @@ void LyXText::prepareToPrint(BufferView * bview, // we don't have to look at the alignment if it is ALIGN_LEFT and // if the row is already larger then the permitted width as then // we force the LEFT_ALIGN'edness! - } else if (static_cast(row->width()) < workWidth(*bview)) { + } else if (static_cast(row->width()) < workWidth()) { // is it block, flushleft or flushright? // set x how you need it int align; @@ -1871,7 +1883,7 @@ void LyXText::prepareToPrint(BufferView * bview, if (!bidi) return; - computeBidiTables(bview->buffer(), row); + computeBidiTables(bv()->buffer(), row); if (is_rtl) { pos_type body_pos = row->par()->beginningOfBody(); pos_type last = row->lastPos(); @@ -1880,7 +1892,7 @@ void LyXText::prepareToPrint(BufferView * bview, (body_pos - 1 > last || !row->par()->isLineSeparator(body_pos - 1))) { x += font_metrics::width(layout->labelsep, - getLabelFont(bview->buffer(), row->par())); + getLabelFont(bv()->buffer(), row->par())); if (body_pos - 1 <= last) x += fill_label_hfill; } @@ -1895,7 +1907,7 @@ void LyXText::prepareToPrint(BufferView * bview, // realize, that you left an empty paragraph, they will delete it. // They also delete the corresponding row -void LyXText::cursorRightOneWord(BufferView * bview) const +void LyXText::cursorRightOneWord() const { // treat floats, HFills and Insets as words LyXCursor tmpcursor = cursor; @@ -1923,11 +1935,11 @@ void LyXText::cursorRightOneWord(BufferView * bview) const ++steps; } } - setCursor(bview, tmpcursor.par(), tmpcursor.pos()); + setCursor(tmpcursor.par(), tmpcursor.pos()); } -void LyXText::cursorTab(BufferView * bview) const +void LyXText::cursorTab() const { LyXCursor tmpcursor = cursor; while (tmpcursor.pos() < tmpcursor.par()->size() @@ -1941,17 +1953,17 @@ void LyXText::cursorTab(BufferView * bview) const } } else tmpcursor.pos(tmpcursor.pos() + 1); - setCursor(bview, tmpcursor.par(), tmpcursor.pos()); + setCursor(tmpcursor.par(), tmpcursor.pos()); } // Skip initial whitespace at end of word and move cursor to *start* // of prior word, not to end of next prior word. -void LyXText::cursorLeftOneWord(BufferView * bview) const +void LyXText::cursorLeftOneWord() const { LyXCursor tmpcursor = cursor; cursorLeftOneWord(tmpcursor); - setCursor(bview, tmpcursor.par(), tmpcursor.pos()); + setCursor(tmpcursor.par(), tmpcursor.pos()); } @@ -2035,71 +2047,70 @@ void LyXText::getWord(LyXCursor & from, LyXCursor & to, } -void LyXText::selectWord(BufferView * bview, word_location const loc) +void LyXText::selectWord(word_location loc) { LyXCursor from; LyXCursor to; getWord(from, to, loc); if (cursor != from) - setCursor(bview, from.par(), from.pos()); + setCursor(from.par(), from.pos()); if (to == from) return; selection.cursor = cursor; - setCursor(bview, to.par(), to.pos()); - setSelection(bview); + setCursor(to.par(), to.pos()); + setSelection(); } // Select the word currently under the cursor when no // selection is currently set -bool LyXText::selectWordWhenUnderCursor(BufferView * bview, - word_location const loc) +bool LyXText::selectWordWhenUnderCursor(word_location loc) { if (!selection.set()) { - selectWord(bview, loc); + selectWord(loc); return selection.set(); } return false; } -void LyXText::acceptChange(BufferView * bv) +void LyXText::acceptChange() { if (!selection.set() && cursor.par()->size()) return; - bv->hideCursor(); + bv()->hideCursor(); if (selection.start.par() == selection.end.par()) { LyXCursor & startc = selection.start; LyXCursor & endc = selection.end; - setUndo(bv, Undo::INSERT, startc.par(), startc.par()->next()); + setUndo(bv(), Undo::INSERT, startc.par(), startc.par()->next()); startc.par()->acceptChange(startc.pos(), endc.pos()); finishUndo(); clearSelection(); - redoParagraphs(bv, startc, startc.par()->next()); - setCursorIntern(bv, startc.par(), 0); + redoParagraphs(startc, startc.par()->next()); + setCursorIntern(startc.par(), 0); } #warning handle multi par selection } -void LyXText::rejectChange(BufferView * bv) +void LyXText::rejectChange() { if (!selection.set() && cursor.par()->size()) return; - bv->hideCursor(); + bv()->hideCursor(); if (selection.start.par() == selection.end.par()) { LyXCursor & startc = selection.start; LyXCursor & endc = selection.end; - setUndo(bv, Undo::INSERT, startc.par(), startc.par()->next()); + setUndo(bv(), Undo::INSERT, startc.par(), startc.par()->next()); startc.par()->rejectChange(startc.pos(), endc.pos()); finishUndo(); clearSelection(); - redoParagraphs(bv, startc, startc.par()->next()); - setCursorIntern(bv, startc.par(), 0); + redoParagraphs(startc, startc.par()->next()); + setCursorIntern(startc.par(), 0); } #warning handle multi par selection } @@ -2108,10 +2119,10 @@ void LyXText::rejectChange(BufferView * bv) // This function is only used by the spellchecker for NextWord(). // It doesn't handle LYX_ACCENTs and probably never will. WordLangTuple const -LyXText::selectNextWordToSpellcheck(BufferView * bview, float & value) const +LyXText::selectNextWordToSpellcheck(float & value) const { if (the_locking_inset) { - WordLangTuple word = the_locking_inset->selectNextWordToSpellcheck(bview, value); + WordLangTuple word = the_locking_inset->selectNextWordToSpellcheck(bv(), value); if (!word.word().empty()) { value += float(cursor.y()); value /= float(height); @@ -2165,15 +2176,15 @@ LyXText::selectNextWordToSpellcheck(BufferView * bview, float & value) const if (cursor.pos() < cursor.par()->size() && cursor.par()->isInset(cursor.pos())) { // lock the inset! - cursor.par()->getInset(cursor.pos())->edit(bview); + cursor.par()->getInset(cursor.pos())->edit(bv()); // now call us again to do the above trick // but obviously we have to start from down below ;) - return bview->text->selectNextWordToSpellcheck(bview, value); + return bv()->text->selectNextWordToSpellcheck(value); } // Update the value if we changed paragraphs if (cursor.par() != tmppar) { - setCursor(bview, cursor.par(), cursor.pos()); + setCursor(cursor.par(), cursor.pos()); value = float(cursor.y())/float(height); } @@ -2181,7 +2192,7 @@ LyXText::selectNextWordToSpellcheck(BufferView * bview, float & value) const selection.cursor = cursor; string lang_code( - getFont(bview->buffer(), cursor.par(), cursor.pos()) + getFont(bv()->buffer(), cursor.par(), cursor.pos()) .language()->code()); // and find the end of the word (insets like optional hyphens // and ligature break are part of a word) @@ -2204,14 +2215,14 @@ LyXText::selectNextWordToSpellcheck(BufferView * bview, float & value) const // This one is also only for the spellchecker -void LyXText::selectSelectedWord(BufferView * bview) +void LyXText::selectSelectedWord() { if (the_locking_inset) { - the_locking_inset->selectSelectedWord(bview); + the_locking_inset->selectSelectedWord(bv()); return; } // move cursor to the beginning - setCursor(bview, selection.cursor.par(), selection.cursor.pos()); + setCursor(selection.cursor.par(), selection.cursor.pos()); // set the sel cursor selection.cursor = cursor; @@ -2221,81 +2232,81 @@ void LyXText::selectSelectedWord(BufferView * bview) && (cursor.par()->isLetter(cursor.pos()))) cursor.pos(cursor.pos() + 1); - setCursor(bview, cursor.par(), cursor.pos()); + setCursor(cursor.par(), cursor.pos()); // finally set the selection - setSelection(bview); + setSelection(); } // Delete from cursor up to the end of the current or next word. -void LyXText::deleteWordForward(BufferView * bview) +void LyXText::deleteWordForward() { if (cursor.par()->empty()) - cursorRight(bview); + cursorRight(bv()); else { LyXCursor tmpcursor = cursor; tmpcursor.row(0); // ?? selection.set(true); // to avoid deletion - cursorRightOneWord(bview); - setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos()); + cursorRightOneWord(); + setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos()); selection.cursor = cursor; cursor = tmpcursor; - setSelection(bview); + setSelection(); // Great, CutSelection() gets rid of multiple spaces. - cutSelection(bview, true, false); + cutSelection(true, false); } } // Delete from cursor to start of current or prior word. -void LyXText::deleteWordBackward(BufferView * bview) +void LyXText::deleteWordBackward() { if (cursor.par()->empty()) - cursorLeft(bview); + cursorLeft(bv()); else { LyXCursor tmpcursor = cursor; tmpcursor.row(0); // ?? selection.set(true); // to avoid deletion - cursorLeftOneWord(bview); - setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos()); + cursorLeftOneWord(); + setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos()); selection.cursor = cursor; cursor = tmpcursor; - setSelection(bview); - cutSelection(bview, true, false); + setSelection(); + cutSelection(true, false); } } // Kill to end of line. -void LyXText::deleteLineForward(BufferView * bview) +void LyXText::deleteLineForward() { if (cursor.par()->empty()) // Paragraph is empty, so we just go to the right - cursorRight(bview); + cursorRight(bv()); else { LyXCursor tmpcursor = cursor; // We can't store the row over a regular setCursor // so we set it to 0 and reset it afterwards. tmpcursor.row(0); // ?? selection.set(true); // to avoid deletion - cursorEnd(bview); - setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos()); + cursorEnd(); + setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos()); selection.cursor = cursor; cursor = tmpcursor; - setSelection(bview); + setSelection(); // What is this test for ??? (JMarc) if (!selection.set()) { - deleteWordForward(bview); + deleteWordForward(); } else { - cutSelection(bview, true, false); + cutSelection(true, false); } } } -void LyXText::changeCase(BufferView & bview, LyXText::TextCase action) +void LyXText::changeCase(LyXText::TextCase action) { LyXCursor from; LyXCursor to; @@ -2305,12 +2316,12 @@ void LyXText::changeCase(BufferView & bview, LyXText::TextCase action) to = selection.end; } else { getWord(from, to, PARTIAL_WORD); - setCursor(&bview, to.par(), to.pos() + 1); + setCursor(to.par(), to.pos() + 1); } lyx::Assert(from <= to); - setUndo(&bview, Undo::FINISH, from.par(), to.par()->next()); + setUndo(bv(), Undo::FINISH, from.par(), to.par()->next()); pos_type pos = from.pos(); Paragraph * par = from.par(); @@ -2338,21 +2349,21 @@ void LyXText::changeCase(BufferView & bview, LyXText::TextCase action) } #warning changes par->setChar(pos, c); - checkParagraph(&bview, par, pos); + checkParagraph(par, pos); ++pos; } if (to.row() != from.row()) - postPaint(bview, from.y() - from.row()->baseline()); + postPaint(from.y() - from.row()->baseline()); } -void LyXText::transposeChars(BufferView & bview) +void LyXText::transposeChars() { Paragraph * tmppar = cursor.par(); - setUndo(&bview, Undo::FINISH, tmppar, tmppar->next()); + setUndo(bv(), Undo::FINISH, tmppar, tmppar->next()); pos_type tmppos = cursor.pos(); @@ -2379,11 +2390,11 @@ void LyXText::transposeChars(BufferView & bview) tmppar->insertChar(ipos, c1); tmppar->insertChar(ipos + 1, c2); - checkParagraph(&bview, tmppar, tmppos); + checkParagraph(tmppar, tmppos); } -void LyXText::Delete(BufferView * bview) +void LyXText::Delete() { // this is a very easy implementation @@ -2393,7 +2404,7 @@ void LyXText::Delete(BufferView * bview) old_cursor.par()->previous()->id() : -1; // just move to the right - cursorRight(bview); + cursorRight(bv()); // CHECK Look at the comment here. // This check is not very good... @@ -2413,20 +2424,20 @@ void LyXText::Delete(BufferView * bview) LyXCursor tmpcursor = cursor; // to make sure undo gets the right cursor position cursor = old_cursor; - setUndo(bview, Undo::DELETE, + setUndo(bv(), Undo::DELETE, cursor.par(), cursor.par()->next()); cursor = tmpcursor; - backspace(bview); + backspace(); } } -void LyXText::backspace(BufferView * bview) +void LyXText::backspace() { // Get the font that is used to calculate the baselineskip pos_type lastpos = cursor.par()->size(); LyXFont rawparfont = - cursor.par()->getFontSettings(bview->buffer()->params, + cursor.par()->getFontSettings(bv()->buffer()->params, lastpos - 1); if (cursor.pos() == 0) { @@ -2458,20 +2469,20 @@ void LyXText::backspace(BufferView * bview) tmppar->params().pagebreakBottom(cursor.par()->params().pagebreakBottom()); } - cursorLeft(bview); + cursorLeft(bv()); // the layout things can change the height of a row ! int const tmpheight = cursor.row()->height(); - setHeightOfRow(bview, cursor.row()); + setHeightOfRow(cursor.row()); if (cursor.row()->height() != tmpheight) { - postPaint(*bview, cursor.y() - cursor.row()->baseline()); + postPaint(cursor.y() - cursor.row()->baseline()); } return; } } if (cursor.par()->previous()) { - setUndo(bview, Undo::DELETE, + setUndo(bv(), Undo::DELETE, cursor.par()->previous(), cursor.par()->next()); } @@ -2484,7 +2495,7 @@ void LyXText::backspace(BufferView * bview) // without the dreaded mechanism. (JMarc) if (cursor.par()->previous()) { // steps into the above paragraph. - setCursorIntern(bview, cursor.par()->previous(), + setCursorIntern(cursor.par()->previous(), cursor.par()->previous()->size(), false); } @@ -2499,7 +2510,7 @@ void LyXText::backspace(BufferView * bview) // Correction: Pasting is always allowed with standard-layout LyXTextClass const & tclass = - bview->buffer()->params.getLyXTextClass(); + bv()->buffer()->params.getLyXTextClass(); if (cursor.par() != tmppar && (cursor.par()->layout() == tmppar->layout() @@ -2507,7 +2518,7 @@ void LyXText::backspace(BufferView * bview) && cursor.par()->getAlign() == tmppar->getAlign()) { removeParagraph(tmprow); removeRow(tmprow); - mergeParagraph(bview->buffer()->params, bview->buffer()->paragraphs, cursor.par()); + mergeParagraph(bv()->buffer()->params, bv()->buffer()->paragraphs, cursor.par()); if (!cursor.pos() || !cursor.par()->isSeparator(cursor.pos() - 1)) ; //cursor.par()->insertChar(cursor.pos(), ' '); @@ -2518,7 +2529,7 @@ void LyXText::backspace(BufferView * bview) if (cursor.pos()) cursor.pos(cursor.pos() - 1); - postPaint(*bview, cursor.y() - cursor.row()->baseline()); + postPaint(cursor.y() - cursor.row()->baseline()); // remove the lost paragraph // This one is not safe, since the paragraph that the tmprow and the @@ -2529,22 +2540,22 @@ void LyXText::backspace(BufferView * bview) //RemoveRow(tmprow); // This rebuilds the rows. - appendParagraph(bview, cursor.row()); - updateCounters(bview); + appendParagraph(cursor.row()); + updateCounters(); // the row may have changed, block, hfills etc. - setCursor(bview, cursor.par(), cursor.pos(), false); + setCursor(cursor.par(), cursor.pos(), false); } } else { // this is the code for a normal backspace, not pasting // any paragraphs - setUndo(bview, Undo::DELETE, + setUndo(bv(), Undo::DELETE, cursor.par(), cursor.par()->next()); // We used to do cursorLeftIntern() here, but it is // not a good idea since it triggers the auto-delete // mechanism. So we do a cursorLeftIntern()-lite, // without the dreaded mechanism. (JMarc) - setCursorIntern(bview, cursor.par(), cursor.pos()- 1, + setCursorIntern(cursor.par(), cursor.pos()- 1, false, cursor.boundary()); if (cursor.par()->isInset(cursor.pos())) { @@ -2553,7 +2564,7 @@ void LyXText::backspace(BufferView * bview) if (cursor.par()->getInset(cursor.pos())->display() || cursor.par()->getInset(cursor.pos())->needFullRow()) { cursor.par()->erase(cursor.pos()); - redoParagraph(bview); + redoParagraph(); return; } } @@ -2565,7 +2576,7 @@ void LyXText::backspace(BufferView * bview) // when calculating the fill if (cursor.pos() < row->lastPos() || !cursor.par()->isLineSeparator(cursor.pos())) { - row->fill(row->fill() + singleWidth(bview, + row->fill(row->fill() + singleWidth( cursor.par(), cursor.pos())); } @@ -2586,7 +2597,7 @@ void LyXText::backspace(BufferView * bview) if (cursor.pos() < cursor.par()->size() && !cursor.par()->isSeparator(cursor.pos())) { cursor.par()->insertChar(cursor.pos(), ' '); - setCharFont(bview->buffer(), cursor.par(), + setCharFont(bv()->buffer(), cursor.par(), cursor.pos(), current_font); // refresh the positions tmprow = row; @@ -2623,7 +2634,7 @@ void LyXText::backspace(BufferView * bview) // is there a break one row above if (row->previous() && row->previous()->par() == row->par()) { - z = rowBreakPoint(*bview, *row->previous()); + z = rowBreakPoint(*row->previous()); if (z >= row->pos()) { row->pos(z + 1); @@ -2635,7 +2646,7 @@ void LyXText::backspace(BufferView * bview) removeRow(row); need_break_row = 0; } else { - breakAgainOneRow(bview, row); + breakAgainOneRow(row); if (row->next() && row->next()->par() == row->par()) need_break_row = row->next(); else @@ -2644,20 +2655,20 @@ void LyXText::backspace(BufferView * bview) // set the dimensions of the row above y -= tmprow->height(); - tmprow->fill(fill(*bview, *tmprow, workWidth(*bview))); - setHeightOfRow(bview, tmprow); + tmprow->fill(fill(*tmprow, workWidth())); + setHeightOfRow(tmprow); - postPaint(*bview, y); + postPaint(y); - setCursor(bview, cursor.par(), cursor.pos(), + setCursor(cursor.par(), cursor.pos(), false, cursor.boundary()); //current_font = rawtmpfont; //real_current_font = realtmpfont; // check, whether the last character's font has changed. if (rawparfont != - cursor.par()->getFontSettings(bview->buffer()->params, + cursor.par()->getFontSettings(bv()->buffer()->params, cursor.par()->size() - 1)) - redoHeightOfParagraph(bview); + redoHeightOfParagraph(); return; } } @@ -2665,7 +2676,7 @@ void LyXText::backspace(BufferView * bview) // break the cursor row again if (row->next() && row->next()->par() == row->par() && (row->lastPos() == row->par()->size() - 1 || - rowBreakPoint(*bview, *row) != row->lastPos())) { + rowBreakPoint(*row) != row->lastPos())) { // it can happen that a paragraph loses one row // without a real breakup. This is when a word @@ -2674,17 +2685,17 @@ void LyXText::backspace(BufferView * bview) if (row->lastPos() == row->par()->size() - 1) removeRow(row->next()); - postPaint(*bview, y); + postPaint(y); - breakAgainOneRow(bview, row); + breakAgainOneRow(row); // will the cursor be in another row now? if (row->next() && row->next()->par() == row->par() && row->lastPos() <= cursor.pos()) { row = row->next(); - breakAgainOneRow(bview, row); + breakAgainOneRow(row); } - setCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary()); + setCursor(cursor.par(), cursor.pos(), false, cursor.boundary()); if (row->next() && row->next()->par() == row->par()) need_break_row = row->next(); @@ -2692,39 +2703,39 @@ void LyXText::backspace(BufferView * bview) need_break_row = 0; } else { // set the dimensions of the row - row->fill(fill(*bview, *row, workWidth(*bview))); + row->fill(fill(*row, workWidth())); int const tmpheight = row->height(); - setHeightOfRow(bview, row); + setHeightOfRow(row); if (tmpheight == row->height()) { - postRowPaint(*bview, row, y); + postRowPaint(row, y); } else { - postPaint(*bview, y); + postPaint(y); } - setCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary()); + setCursor(cursor.par(), cursor.pos(), false, cursor.boundary()); } } // current_font = rawtmpfont; // real_current_font = realtmpfont; - if (isBoundary(bview->buffer(), cursor.par(), cursor.pos()) + if (isBoundary(bv()->buffer(), cursor.par(), cursor.pos()) != cursor.boundary()) - setCursor(bview, cursor.par(), cursor.pos(), false, + setCursor(cursor.par(), cursor.pos(), false, !cursor.boundary()); lastpos = cursor.par()->size(); if (cursor.pos() == lastpos) - setCurrentFont(bview); + setCurrentFont(); // check, whether the last characters font has changed. if (rawparfont != - cursor.par()->getFontSettings(bview->buffer()->params, lastpos - 1)) { - redoHeightOfParagraph(bview); + cursor.par()->getFontSettings(bv()->buffer()->params, lastpos - 1)) { + redoHeightOfParagraph(); } else { // now the special right address boxes if (cursor.par()->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) { - redoDrawingOfParagraph(bview, cursor); + redoDrawingOfParagraph(cursor); } } } diff --git a/src/text2.C b/src/text2.C index da9940a808..a5f2721dd5 100644 --- a/src/text2.C +++ b/src/text2.C @@ -60,10 +60,10 @@ LyXText::LyXText(BufferView * bv) } -LyXText::LyXText(InsetText * inset) +LyXText::LyXText(BufferView * bv, InsetText * inset) : height(0), width(0), top_row_(0), top_row_offset_(0), inset_owner(inset), the_locking_inset(0), need_break_row(0), - bv_owner(0), firstrow(0), lastrow(0) + bv_owner(bv), firstrow(0), lastrow(0) { clearPaint(); } @@ -93,13 +93,13 @@ void LyXText::init(BufferView * bview, bool reinit) current_font = getFont(bview->buffer(), par, 0); while (par) { - insertParagraph(bview, par, lastrow); + insertParagraph(par, lastrow); par = par->next(); } - setCursorIntern(bview, firstrow->par(), 0); + setCursorIntern(firstrow->par(), 0); selection.cursor = cursor; - updateCounters(bview); + updateCounters(); } @@ -219,11 +219,11 @@ LyXFont const LyXText::getLabelFont(Buffer const * buf, Paragraph * par) const } -void LyXText::setCharFont(BufferView * bv, Paragraph * par, +void LyXText::setCharFont(Paragraph * par, pos_type pos, LyXFont const & fnt, bool toggleall) { - Buffer const * buf = bv->buffer(); + Buffer const * buf = bv()->buffer(); LyXFont font = getFont(buf, par, pos); font.update(fnt, buf->params.language, toggleall); // Let the insets convert their font @@ -232,7 +232,7 @@ void LyXText::setCharFont(BufferView * bv, Paragraph * par, if (isEditableInset(inset)) { UpdatableInset * uinset = static_cast(inset); - uinset->setFont(bv, fnt, toggleall, true); + uinset->setFont(bv(), fnt, toggleall, true); } } @@ -363,7 +363,7 @@ void LyXText::removeParagraph(Row * row) const // insert the specified paragraph behind the specified row -void LyXText::insertParagraph(BufferView * bview, Paragraph * par, +void LyXText::insertParagraph(Paragraph * par, Row * row) const { // insert a new row, starting at position 0 @@ -372,10 +372,10 @@ void LyXText::insertParagraph(BufferView * bview, Paragraph * par, // and now append the whole paragraph before the new row if (!row) { firstrow->height(0); - appendParagraph(bview, firstrow); + appendParagraph(firstrow); } else { row->next()->height(0); - appendParagraph(bview, row->next()); + appendParagraph(row->next()); } } @@ -390,7 +390,7 @@ Inset * LyXText::getInset() const } -void LyXText::toggleInset(BufferView * bview) +void LyXText::toggleInset() { Inset * inset = getInset(); // is there an editable inset at cursor position? @@ -398,25 +398,25 @@ void LyXText::toggleInset(BufferView * bview) // No, try to see if we are inside a collapsable inset if (inset_owner && inset_owner->owner() && inset_owner->owner()->isOpen()) { - bview->unlockInset(static_cast(inset_owner->owner())); - inset_owner->owner()->close(bview); - bview->getLyXText()->cursorRight(bview); + bv()->unlockInset(static_cast(inset_owner->owner())); + inset_owner->owner()->close(bv()); + bv()->getLyXText()->cursorRight(bv()); } return; } - //bview->owner()->message(inset->editMessage()); + //bv()->owner()->message(inset->editMessage()); // do we want to keep this?? (JMarc) if (!isHighlyEditableInset(inset)) - setCursorParUndo(bview); + setCursorParUndo(bv()); if (inset->isOpen()) { - inset->close(bview); + inset->close(bv()); } else { - inset->open(bview); + inset->open(bv()); } #if 0 - inset->open(bview, !inset->isOpen()); + inset->open(bv(), !inset->isOpen()); #endif } @@ -442,8 +442,7 @@ void LyXText::makeFontEntriesLayoutSpecific(Buffer const & buf, } -Paragraph * LyXText::setLayout(BufferView * bview, - LyXCursor & cur, LyXCursor & sstart_cur, +Paragraph * LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur, LyXCursor & send_cur, string const & layout) { @@ -459,7 +458,7 @@ Paragraph * LyXText::setLayout(BufferView * bview, endpar = endpar->next(); // because of parindents etc. } - setUndo(bview, Undo::EDIT, sstart_cur.par(), undoendpar); + setUndo(bv(), Undo::EDIT, sstart_cur.par(), undoendpar); // ok we have a selection. This is always between sstart_cur // and sel_end cursor @@ -468,11 +467,11 @@ Paragraph * LyXText::setLayout(BufferView * bview, Paragraph * epar = send_cur.par()->next(); LyXLayout_ptr const & lyxlayout = - bview->buffer()->params.getLyXTextClass()[layout]; + bv()->buffer()->params.getLyXTextClass()[layout]; do { par->applyLayout(lyxlayout); - makeFontEntriesLayoutSpecific(*bview->buffer(), *par); + makeFontEntriesLayoutSpecific(*bv()->buffer(), *par); Paragraph * fppar = par; fppar->params().spaceTop(lyxlayout->fill_top ? VSpace(VSpace::VFILL) @@ -491,7 +490,7 @@ Paragraph * LyXText::setLayout(BufferView * bview, // set layout over selection and make a total rebreak of those paragraphs -void LyXText::setLayout(BufferView * bview, string const & layout) +void LyXText::setLayout(string const & layout) { LyXCursor tmpcursor = cursor; /* store the current cursor */ @@ -501,26 +500,26 @@ void LyXText::setLayout(BufferView * bview, string const & layout) selection.start = cursor; // dummy selection selection.end = cursor; } - Paragraph * endpar = setLayout(bview, cursor, selection.start, + Paragraph * endpar = setLayout(cursor, selection.start, selection.end, layout); - redoParagraphs(bview, selection.start, endpar); + redoParagraphs(selection.start, endpar); // we have to reset the selection, because the // geometry could have changed - setCursor(bview, selection.start.par(), + setCursor(selection.start.par(), selection.start.pos(), false); selection.cursor = cursor; - setCursor(bview, selection.end.par(), selection.end.pos(), false); - updateCounters(bview); + setCursor(selection.end.par(), selection.end.pos(), false); + updateCounters(); clearSelection(); - setSelection(bview); - setCursor(bview, tmpcursor.par(), tmpcursor.pos(), true); + setSelection(); + setCursor(tmpcursor.par(), tmpcursor.pos(), true); } // increment depth over selection and // make a total rebreak of those paragraphs -void LyXText::incDepth(BufferView * bview) +void LyXText::incDepth() { // If there is no selection, just use the current paragraph if (!selection.set()) { @@ -542,7 +541,7 @@ void LyXText::incDepth(BufferView * bview) endpar = endpar->next(); // because of parindents etc. } - setUndo(bview, Undo::EDIT, + setUndo(bv(), Undo::EDIT, selection.start.par(), undoendpar); LyXCursor tmpcursor = cursor; // store the current cursor @@ -568,23 +567,23 @@ void LyXText::incDepth(BufferView * bview) cursor.par(cursor.par()->next()); } - redoParagraphs(bview, selection.start, endpar); + redoParagraphs(selection.start, endpar); // we have to reset the selection, because the // geometry could have changed - setCursor(bview, selection.start.par(), selection.start.pos()); + setCursor(selection.start.par(), selection.start.pos()); selection.cursor = cursor; - setCursor(bview, selection.end.par(), selection.end.pos()); - updateCounters(bview); + setCursor(selection.end.par(), selection.end.pos()); + updateCounters(); clearSelection(); - setSelection(bview); - setCursor(bview, tmpcursor.par(), tmpcursor.pos()); + setSelection(); + setCursor(tmpcursor.par(), tmpcursor.pos()); } // decrement depth over selection and // make a total rebreak of those paragraphs -void LyXText::decDepth(BufferView * bview) +void LyXText::decDepth() { // if there is no selection just set the layout // of the current paragraph @@ -604,7 +603,7 @@ void LyXText::decDepth(BufferView * bview) endpar = endpar->next(); // because of parindents etc. } - setUndo(bview, Undo::EDIT, + setUndo(bv(), Undo::EDIT, selection.start.par(), undoendpar); LyXCursor tmpcursor = cursor; // store the current cursor @@ -624,38 +623,38 @@ void LyXText::decDepth(BufferView * bview) cursor.par(cursor.par()->next()); } - redoParagraphs(bview, selection.start, endpar); + redoParagraphs(selection.start, endpar); // we have to reset the selection, because the // geometry could have changed - setCursor(bview, selection.start.par(), + setCursor(selection.start.par(), selection.start.pos()); selection.cursor = cursor; - setCursor(bview, selection.end.par(), selection.end.pos()); - updateCounters(bview); + setCursor(selection.end.par(), selection.end.pos()); + updateCounters(); clearSelection(); - setSelection(bview); - setCursor(bview, tmpcursor.par(), tmpcursor.pos()); + setSelection(); + setCursor(tmpcursor.par(), tmpcursor.pos()); } // set font over selection and make a total rebreak of those paragraphs -void LyXText::setFont(BufferView * bview, LyXFont const & font, bool toggleall) +void LyXText::setFont(LyXFont const & font, bool toggleall) { // if there is no selection just set the current_font if (!selection.set()) { // Determine basis font LyXFont layoutfont; if (cursor.pos() < cursor.par()->beginningOfBody()) { - layoutfont = getLabelFont(bview->buffer(), + layoutfont = getLabelFont(bv()->buffer(), cursor.par()); } else { - layoutfont = getLayoutFont(bview->buffer(), + layoutfont = getLayoutFont(bv()->buffer(), cursor.par()); } // Update current font real_current_font.update(font, - bview->buffer()->params.language, + bv()->buffer()->params.language, toggleall); // Reduce to implicit settings @@ -672,7 +671,7 @@ void LyXText::setFont(BufferView * bview, LyXFont const & font, bool toggleall) // ok we have a selection. This is always between sel_start_cursor // and sel_end cursor - setUndo(bview, Undo::EDIT, + setUndo(bv(), Undo::EDIT, selection.start.par(), selection.end.par()->next()); freezeUndo(); cursor = selection.start; @@ -681,7 +680,7 @@ void LyXText::setFont(BufferView * bview, LyXFont const & font, bool toggleall) { if (cursor.pos() < cursor.par()->size()) { // an open footnote should behave like a closed one - setCharFont(bview, cursor.par(), cursor.pos(), + setCharFont(cursor.par(), cursor.pos(), font, toggleall); cursor.pos(cursor.pos() + 1); } else { @@ -691,46 +690,46 @@ void LyXText::setFont(BufferView * bview, LyXFont const & font, bool toggleall) } unFreezeUndo(); - redoParagraphs(bview, selection.start, selection.end.par()->next()); + redoParagraphs(selection.start, selection.end.par()->next()); // we have to reset the selection, because the // geometry could have changed, but we keep // it for user convenience - setCursor(bview, selection.start.par(), selection.start.pos()); + setCursor(selection.start.par(), selection.start.pos()); selection.cursor = cursor; - setCursor(bview, selection.end.par(), selection.end.pos()); - setSelection(bview); - setCursor(bview, tmpcursor.par(), tmpcursor.pos(), true, + setCursor(selection.end.par(), selection.end.pos()); + setSelection(); + setCursor(tmpcursor.par(), tmpcursor.pos(), true, tmpcursor.boundary()); } -void LyXText::redoHeightOfParagraph(BufferView * bview) +void LyXText::redoHeightOfParagraph() { Row * tmprow = cursor.row(); int y = cursor.y() - tmprow->baseline(); - setHeightOfRow(bview, tmprow); + setHeightOfRow(tmprow); while (tmprow->previous() && tmprow->previous()->par() == tmprow->par()) { tmprow = tmprow->previous(); y -= tmprow->height(); - setHeightOfRow(bview, tmprow); + setHeightOfRow(tmprow); } - postPaint(*bview, y); + postPaint(y); - setCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary()); + setCursor(cursor.par(), cursor.pos(), false, cursor.boundary()); } -void LyXText::redoDrawingOfParagraph(BufferView * bview, LyXCursor const & cur) +void LyXText::redoDrawingOfParagraph(LyXCursor const & cur) { Row * tmprow = cur.row(); int y = cur.y() - tmprow->baseline(); - setHeightOfRow(bview, tmprow); + setHeightOfRow(tmprow); while (tmprow->previous() && tmprow->previous()->par() == tmprow->par()) { @@ -738,15 +737,15 @@ void LyXText::redoDrawingOfParagraph(BufferView * bview, LyXCursor const & cur) y -= tmprow->height(); } - postPaint(*bview, y); - setCursor(bview, cur.par(), cur.pos()); + postPaint(y); + setCursor(cur.par(), cur.pos()); } // deletes and inserts again all paragaphs between the cursor // and the specified par // This function is needed after SetLayout and SetFont etc. -void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur, +void LyXText::redoParagraphs(LyXCursor const & cur, Paragraph const * endpar) const { Row * tmprow2; @@ -799,7 +798,7 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur, do { if (tmppar) { - insertParagraph(bview, tmppar, tmprow); + insertParagraph(tmppar, tmprow); if (!tmprow) { tmprow = firstrow; } @@ -813,27 +812,27 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur, // this is because of layout changes if (prevrow) { - setHeightOfRow(bview, prevrow); - const_cast(this)->postPaint(*bview, y - prevrow->height()); + setHeightOfRow(prevrow); + const_cast(this)->postPaint(y - prevrow->height()); } else { - setHeightOfRow(bview, firstrow); - const_cast(this)->postPaint(*bview, 0); + setHeightOfRow(firstrow); + const_cast(this)->postPaint(0); } if (tmprow && tmprow->next()) - setHeightOfRow(bview, tmprow->next()); - updateCounters(bview); + setHeightOfRow(tmprow->next()); + updateCounters(); } -void LyXText::fullRebreak(BufferView * bview) +void LyXText::fullRebreak() { if (!firstrow) { - init(bview); + init(bv()); return; } if (need_break_row) { - breakAgain(bview, need_break_row); + breakAgain(need_break_row); need_break_row = 0; return; } @@ -848,7 +847,7 @@ void LyXText::fullRebreak(BufferView * bview) // They also delete the corresponding row // need the selection cursor: -void LyXText::setSelection(BufferView * bview) +void LyXText::setSelection() { bool const lsel = selection.set(); @@ -900,7 +899,7 @@ void LyXText::setSelection(BufferView * bview) selection.set(false); if (inset_owner && (selection.set() || lsel)) - inset_owner->setUpdateStatus(bview, InsetText::SELECTION); + inset_owner->setUpdateStatus(bv(), InsetText::SELECTION); } @@ -952,53 +951,52 @@ void LyXText::clearSelection() const } -void LyXText::cursorHome(BufferView * bview) const +void LyXText::cursorHome() const { - setCursor(bview, cursor.par(), cursor.row()->pos()); + setCursor(cursor.par(), cursor.row()->pos()); } -void LyXText::cursorEnd(BufferView * bview) const +void LyXText::cursorEnd() const { if (!cursor.row()->next() || cursor.row()->next()->par() != cursor.row()->par()) { - setCursor(bview, cursor.par(), cursor.row()->lastPos() + 1); + setCursor(cursor.par(), cursor.row()->lastPos() + 1); } else { if (!cursor.par()->empty() && (cursor.par()->getChar(cursor.row()->lastPos()) == ' ' || cursor.par()->isNewline(cursor.row()->lastPos()))) { - setCursor(bview, cursor.par(), cursor.row()->lastPos()); + setCursor(cursor.par(), cursor.row()->lastPos()); } else { - setCursor(bview,cursor.par(), + setCursor(cursor.par(), cursor.row()->lastPos() + 1); } } } -void LyXText::cursorTop(BufferView * bview) const +void LyXText::cursorTop() const { while (cursor.par()->previous()) cursor.par(cursor.par()->previous()); - setCursor(bview, cursor.par(), 0); + setCursor(cursor.par(), 0); } -void LyXText::cursorBottom(BufferView * bview) const +void LyXText::cursorBottom() const { while (cursor.par()->next()) cursor.par(cursor.par()->next()); - setCursor(bview, cursor.par(), cursor.par()->size()); + setCursor(cursor.par(), cursor.par()->size()); } -void LyXText::toggleFree(BufferView * bview, - LyXFont const & font, bool toggleall) +void LyXText::toggleFree(LyXFont const & font, bool toggleall) { // If the mask is completely neutral, tell user if (font == LyXFont(LyXFont::ALL_IGNORE)) { // Could only happen with user style - bview->owner()->message(_("No font change defined. Use Character under the Layout menu to define font change.")); + bv()->owner()->message(_("No font change defined. Use Character under the Layout menu to define font change.")); return; } @@ -1008,43 +1006,43 @@ void LyXText::toggleFree(BufferView * bview, LyXCursor resetCursor = cursor; bool implicitSelection = (font.language() == ignore_language && font.number() == LyXFont::IGNORE) - ? selectWordWhenUnderCursor(bview, WHOLE_WORD_STRICT) : false; + ? selectWordWhenUnderCursor(WHOLE_WORD_STRICT) : false; // Set font - setFont(bview, font, toggleall); + setFont(font, toggleall); // Implicit selections are cleared afterwards //and cursor is set to the original position. if (implicitSelection) { clearSelection(); cursor = resetCursor; - setCursor(bview, cursor.par(), cursor.pos()); + setCursor(cursor.par(), cursor.pos()); selection.cursor = cursor; } if (inset_owner) - inset_owner->setUpdateStatus(bview, InsetText::CURSOR_PAR); + inset_owner->setUpdateStatus(bv(), InsetText::CURSOR_PAR); } -string LyXText::getStringToIndex(BufferView * bview) +string LyXText::getStringToIndex() { // Try implicit word selection // If there is a change in the language the implicit word selection // is disabled. LyXCursor const reset_cursor = cursor; - bool const implicitSelection = selectWordWhenUnderCursor(bview, PREVIOUS_WORD); + bool const implicitSelection = selectWordWhenUnderCursor(PREVIOUS_WORD); string idxstring; if (!selection.set()) - bview->owner()->message(_("Nothing to index!")); + bv()->owner()->message(_("Nothing to index!")); else if (selection.start.par() != selection.end.par()) - bview->owner()->message(_("Cannot index more than one paragraph!")); + bv()->owner()->message(_("Cannot index more than one paragraph!")); else - idxstring = selectionAsString(bview->buffer(), false); + idxstring = selectionAsString(bv()->buffer(), false); // Reset cursors to their original position. cursor = reset_cursor; - setCursor(bview, cursor.par(), cursor.pos()); + setCursor(cursor.par(), cursor.pos()); selection.cursor = cursor; // Clear the implicit selection. @@ -1061,14 +1059,13 @@ string LyXText::getStringToIndex(BufferView * bview) // they do not duplicate themself and you cannnot make dirty things with // them! -void LyXText::setParagraph(BufferView * bview, - bool line_top, bool line_bottom, +void LyXText::setParagraph(bool line_top, bool line_bottom, bool pagebreak_top, bool pagebreak_bottom, VSpace const & space_top, VSpace const & space_bottom, Spacing const & spacing, LyXAlignment align, - string labelwidthstring, + string const & labelwidthstring, bool noindent) { LyXCursor tmpcursor = cursor; @@ -1092,14 +1089,14 @@ void LyXText::setParagraph(BufferView * bview, endpar = endpar->next(); } - setUndo(bview, Undo::EDIT, selection.start.par(), undoendpar); + setUndo(bv(), Undo::EDIT, selection.start.par(), undoendpar); Paragraph * tmppar = selection.end.par(); while (tmppar != selection.start.par()->previous()) { - setCursor(bview, tmppar, 0); - postPaint(*bview, cursor.y() - cursor.row()->baseline()); + setCursor(tmppar, 0); + postPaint(cursor.y() - cursor.row()->baseline()); cursor.par()->params().lineTop(line_top); cursor.par()->params().lineBottom(line_bottom); cursor.par()->params().pagebreakTop(pagebreak_top); @@ -1123,16 +1120,16 @@ void LyXText::setParagraph(BufferView * bview, tmppar = cursor.par()->previous(); } - redoParagraphs(bview, selection.start, endpar); + redoParagraphs(selection.start, endpar); clearSelection(); - setCursor(bview, selection.start.par(), selection.start.pos()); + setCursor(selection.start.par(), selection.start.pos()); selection.cursor = cursor; - setCursor(bview, selection.end.par(), selection.end.pos()); - setSelection(bview); - setCursor(bview, tmpcursor.par(), tmpcursor.pos()); + setCursor(selection.end.par(), selection.end.pos()); + setSelection(); + setCursor(tmpcursor.par(), tmpcursor.pos()); if (inset_owner) - bview->updateInset(inset_owner, true); + bv()->updateInset(inset_owner, true); } @@ -1334,13 +1331,13 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const // Updates all counters. Paragraphs with changed label string will be rebroken -void LyXText::updateCounters(BufferView * bview) const +void LyXText::updateCounters() const { Row * row = firstrow; Paragraph * par = row->par(); // CHECK if this is really needed. (Lgb) - bview->buffer()->params.getLyXTextClass().counters().reset(); + bv()->buffer()->params.getLyXTextClass().counters().reset(); while (par) { while (row->par() != par) @@ -1349,13 +1346,13 @@ void LyXText::updateCounters(BufferView * bview) const string const oldLabel = par->params().labelString(); // setCounter can potentially change the labelString. - setCounter(bview->buffer(), par); + setCounter(bv()->buffer(), par); string const & newLabel = par->params().labelString(); if (oldLabel.empty() && !newLabel.empty()) { removeParagraph(row); - appendParagraph(bview, row); + appendParagraph(row); } par = par->next(); @@ -1363,23 +1360,23 @@ void LyXText::updateCounters(BufferView * bview) const } -void LyXText::insertInset(BufferView * bview, Inset * inset) +void LyXText::insertInset(Inset * inset) { if (!cursor.par()->insetAllowed(inset->lyxCode())) return; - setUndo(bview, Undo::FINISH, cursor.par(), cursor.par()->next()); + setUndo(bv(), Undo::FINISH, cursor.par(), cursor.par()->next()); freezeUndo(); cursor.par()->insertInset(cursor.pos(), inset); // Just to rebreak and refresh correctly. // The character will not be inserted a second time - insertChar(bview, Paragraph::META_INSET); + insertChar(Paragraph::META_INSET); // If we enter a highly editable inset the cursor should be to before // the inset. This couldn't happen before as Undo was not handled inside // inset now after the Undo LyX tries to call inset->Edit(...) again // and cannot do this as the cursor is behind the inset and GetInset // does not return the inset! if (isHighlyEditableInset(inset)) { - cursorLeft(bview, true); + cursorLeft(true); } unFreezeUndo(); } @@ -1391,15 +1388,15 @@ void LyXText::copyEnvironmentType() } -void LyXText::pasteEnvironmentType(BufferView * bview) +void LyXText::pasteEnvironmentType() { // do nothing if there has been no previous copyEnvironmentType() if (!copylayouttype.empty()) - setLayout(bview, copylayouttype); + setLayout(copylayouttype); } -void LyXText::cutSelection(BufferView * bview, bool doclear, bool realcut) +void LyXText::cutSelection(bool doclear, bool realcut) { // Stuff what we got on the clipboard. Even if there is no selection. @@ -1409,7 +1406,7 @@ void LyXText::cutSelection(BufferView * bview, bool doclear, bool realcut) // finished. The solution used currently just works, to make it // faster we need to be more clever and probably also have more // calls to stuffClipboard. (Lgb) - bview->stuffClipboard(selectionAsString(bview->buffer(), true)); + bv()->stuffClipboard(selectionAsString(bv()->buffer(), true)); // This doesn't make sense, if there is no selection if (!selection.set()) @@ -1431,7 +1428,7 @@ void LyXText::cutSelection(BufferView * bview, bool doclear, bool realcut) endpar = endpar->next(); // because of parindents etc. } - setUndo(bview, Undo::DELETE, + setUndo(bv(), Undo::DELETE, selection.start.par(), undoendpar); // there are two cases: cut only within one paragraph or @@ -1442,7 +1439,7 @@ void LyXText::cutSelection(BufferView * bview, bool doclear, bool realcut) int pos = selection.end.pos(); CutAndPaste::cutSelection(selection.start.par(), &endpar, selection.start.pos(), pos, - bview->buffer()->params.textclass, + bv()->buffer()->params.textclass, doclear, realcut); selection.end.pos(pos); } else { @@ -1450,7 +1447,7 @@ void LyXText::cutSelection(BufferView * bview, bool doclear, bool realcut) int pos = selection.end.pos(); CutAndPaste::cutSelection(selection.start.par(), &endpar, selection.start.pos(), pos, - bview->buffer()->params.textclass, + bv()->buffer()->params.textclass, doclear, realcut); cursor.par(endpar); selection.end.par(endpar); @@ -1463,7 +1460,7 @@ void LyXText::cutSelection(BufferView * bview, bool doclear, bool realcut) if (doclear) selection.start.par()->stripLeadingSpaces(); - redoParagraphs(bview, selection.start, endpar); + redoParagraphs(selection.start, endpar); // cutSelection can invalidate the cursor so we need to set // it anew. (Lgb) @@ -1473,16 +1470,16 @@ void LyXText::cutSelection(BufferView * bview, bool doclear, bool realcut) // need a valid cursor. (Lgb) clearSelection(); - setCursor(bview, cursor.par(), cursor.pos()); + setCursor(cursor.par(), cursor.pos()); selection.cursor = cursor; - updateCounters(bview); + updateCounters(); } -void LyXText::copySelection(BufferView * bview) +void LyXText::copySelection() { // stuff the selection onto the X clipboard, from an explicit copy request - bview->stuffClipboard(selectionAsString(bview->buffer(), true)); + bv()->stuffClipboard(selectionAsString(bv()->buffer(), true)); // this doesnt make sense, if there is no selection if (!selection.set()) @@ -1500,17 +1497,17 @@ void LyXText::copySelection(BufferView * bview) CutAndPaste::copySelection(selection.start.par(), selection.end.par(), selection.start.pos(), selection.end.pos(), - bview->buffer()->params.textclass); + bv()->buffer()->params.textclass); } -void LyXText::pasteSelection(BufferView * bview) +void LyXText::pasteSelection() { // this does not make sense, if there is nothing to paste if (!CutAndPaste::checkPastePossible()) return; - setUndo(bview, Undo::INSERT, + setUndo(bv(), Undo::INSERT, cursor.par(), cursor.par()->next()); Paragraph * endpar; @@ -1518,37 +1515,36 @@ void LyXText::pasteSelection(BufferView * bview) int pos = cursor.pos(); CutAndPaste::pasteSelection(&actpar, &endpar, pos, - bview->buffer()->params.textclass); + bv()->buffer()->params.textclass); - redoParagraphs(bview, cursor, endpar); + redoParagraphs(cursor, endpar); - setCursor(bview, cursor.par(), cursor.pos()); + setCursor(cursor.par(), cursor.pos()); clearSelection(); selection.cursor = cursor; - setCursor(bview, actpar, pos); - setSelection(bview); - updateCounters(bview); + setCursor(actpar, pos); + setSelection(); + updateCounters(); } -void LyXText::setSelectionRange(BufferView * bview, lyx::pos_type length) +void LyXText::setSelectionRange(lyx::pos_type length) { if (!length) return; selection.cursor = cursor; while (length--) - cursorRight(bview); - setSelection(bview); + cursorRight(bv()); + setSelection(); } // simple replacing. The font of the first selected character is used -void LyXText::replaceSelectionWithString(BufferView * bview, - string const & str) +void LyXText::replaceSelectionWithString(string const & str) { - setCursorParUndo(bview); + setCursorParUndo(bv()); freezeUndo(); if (!selection.set()) { // create a dummy selection @@ -1559,7 +1555,7 @@ void LyXText::replaceSelectionWithString(BufferView * bview, // Get font setting before we cut pos_type pos = selection.end.pos(); LyXFont const font = selection.start.par() - ->getFontSettings(bview->buffer()->params, + ->getFontSettings(bv()->buffer()->params, selection.start.pos()); // Insert the new string @@ -1569,37 +1565,37 @@ void LyXText::replaceSelectionWithString(BufferView * bview, } // Cut the selection - cutSelection(bview, true, false); + cutSelection(true, false); unFreezeUndo(); } // needed to insert the selection -void LyXText::insertStringAsLines(BufferView * bview, string const & str) +void LyXText::insertStringAsLines(string const & str) { Paragraph * par = cursor.par(); pos_type pos = cursor.pos(); Paragraph * endpar = cursor.par()->next(); - setCursorParUndo(bview); + setCursorParUndo(bv()); // only to be sure, should not be neccessary clearSelection(); - bview->buffer()->insertStringAsLines(par, pos, current_font, str); + bv()->buffer()->insertStringAsLines(par, pos, current_font, str); - redoParagraphs(bview, cursor, endpar); - setCursor(bview, cursor.par(), cursor.pos()); + redoParagraphs(cursor, endpar); + setCursor(cursor.par(), cursor.pos()); selection.cursor = cursor; - setCursor(bview, par, pos); - setSelection(bview); + setCursor(par, pos); + setSelection(); } // turns double-CR to single CR, others where converted into one // blank. Then InsertStringAsLines is called -void LyXText::insertStringAsParagraphs(BufferView * bview, string const & str) +void LyXText::insertStringAsParagraphs(string const & str) { string linestr(str); bool newline_inserted = false; @@ -1619,11 +1615,11 @@ void LyXText::insertStringAsParagraphs(BufferView * bview, string const & str) newline_inserted = false; } } - insertStringAsLines(bview, linestr); + insertStringAsLines(linestr); } -void LyXText::checkParagraph(BufferView * bview, Paragraph * par, +void LyXText::checkParagraph(Paragraph * par, pos_type pos) { LyXCursor tmpcursor; @@ -1634,17 +1630,17 @@ void LyXText::checkParagraph(BufferView * bview, Paragraph * par, // is there a break one row above if (row->previous() && row->previous()->par() == row->par()) { - z = rowBreakPoint(*bview, *row->previous()); + z = rowBreakPoint(*row->previous()); if (z >= row->pos()) { // set the dimensions of the row above y -= row->previous()->height(); - postPaint(*bview, y); + postPaint(y); - breakAgain(bview, row->previous()); + breakAgain(row->previous()); // set the cursor again. Otherwise // dangling pointers are possible - setCursor(bview, cursor.par(), cursor.pos(), + setCursor(cursor.par(), cursor.pos(), false, cursor.boundary()); selection.cursor = cursor; return; @@ -1654,11 +1650,11 @@ void LyXText::checkParagraph(BufferView * bview, Paragraph * par, int const tmpheight = row->height(); pos_type const tmplast = row->lastPos(); - breakAgain(bview, row); + breakAgain(row); if (row->height() == tmpheight && row->lastPos() == tmplast) { - postRowPaint(*bview, row, y); + postRowPaint(row, y); } else { - postPaint(*bview, y); + postPaint(y); } // check the special right address boxes @@ -1669,7 +1665,7 @@ void LyXText::checkParagraph(BufferView * bview, Paragraph * par, tmpcursor.x(0); tmpcursor.x_fix(0); tmpcursor.pos(pos); - redoDrawingOfParagraph(bview, tmpcursor); + redoDrawingOfParagraph(tmpcursor); } // set the cursor again. Otherwise dangling pointers are possible @@ -1677,35 +1673,35 @@ void LyXText::checkParagraph(BufferView * bview, Paragraph * par, if (selection.set()) { tmpcursor = cursor; - setCursorIntern(bview, selection.cursor.par(), selection.cursor.pos(), + setCursorIntern(selection.cursor.par(), selection.cursor.pos(), false, selection.cursor.boundary()); selection.cursor = cursor; - setCursorIntern(bview, selection.start.par(), + setCursorIntern(selection.start.par(), selection.start.pos(), false, selection.start.boundary()); selection.start = cursor; - setCursorIntern(bview, selection.end.par(), + setCursorIntern(selection.end.par(), selection.end.pos(), false, selection.end.boundary()); selection.end = cursor; - setCursorIntern(bview, last_sel_cursor.par(), + setCursorIntern(last_sel_cursor.par(), last_sel_cursor.pos(), false, last_sel_cursor.boundary()); last_sel_cursor = cursor; cursor = tmpcursor; } - setCursorIntern(bview, cursor.par(), cursor.pos(), + setCursorIntern(cursor.par(), cursor.pos(), false, cursor.boundary()); } // returns false if inset wasn't found -bool LyXText::updateInset(BufferView * bview, Inset * inset) +bool LyXText::updateInset(Inset * inset) { // first check the current paragraph int pos = cursor.par()->getPositionOfInset(inset); if (pos != -1) { - checkParagraph(bview, cursor.par(), pos); + checkParagraph(cursor.par(), pos); return true; } @@ -1715,7 +1711,7 @@ bool LyXText::updateInset(BufferView * bview, Inset * inset) do { pos = par->getPositionOfInset(inset); if (pos != -1) { - checkParagraph(bview, par, pos); + checkParagraph(par, pos); return true; } par = par->next(); @@ -1725,21 +1721,20 @@ bool LyXText::updateInset(BufferView * bview, Inset * inset) } -bool LyXText::setCursor(BufferView * bview, Paragraph * par, +bool LyXText::setCursor(Paragraph * par, pos_type pos, bool setfont, bool boundary) const { LyXCursor old_cursor = cursor; - setCursorIntern(bview, par, pos, setfont, boundary); - return deleteEmptyParagraphMechanism(bview, old_cursor); + setCursorIntern(par, pos, setfont, boundary); + return deleteEmptyParagraphMechanism(old_cursor); } -void LyXText::setCursor(BufferView * bview, LyXCursor & cur, Paragraph * par, +void LyXText::setCursor(LyXCursor & cur, Paragraph * par, pos_type pos, bool boundary) const { lyx::Assert(par); - lyx::Assert(bview); cur.par(par); cur.pos(pos); @@ -1790,19 +1785,19 @@ void LyXText::setCursor(BufferView * bview, LyXCursor & cur, Paragraph * par, } // now get the cursors x position - float x = getCursorX(bview, row, pos, last, boundary); + float x = getCursorX(row, pos, last, boundary); cur.x(int(x)); cur.x_fix(cur.x()); if (old_row != row) { - x = getCursorX(bview, old_row, pos, last, boundary); + x = getCursorX(old_row, pos, last, boundary); cur.ix(int(x)); } else cur.ix(cur.x()); } -float LyXText::getCursorX(BufferView * bview, Row * row, - pos_type pos, pos_type last, bool boundary) const +float LyXText::getCursorX(Row * row, + pos_type pos, pos_type last, bool boundary) const { pos_type cursor_vpos = 0; float x; @@ -1810,13 +1805,13 @@ float LyXText::getCursorX(BufferView * bview, Row * row, float fill_hfill; float fill_label_hfill; // This call HAS to be here because of the BidiTables!!! - prepareToPrint(bview, row, x, fill_separator, fill_hfill, + prepareToPrint(row, x, fill_separator, fill_hfill, fill_label_hfill); if (last < row->pos()) cursor_vpos = row->pos(); else if (pos > last && !boundary) - cursor_vpos = (row->par()->isRightToLeftPar(bview->buffer()->params)) + cursor_vpos = (row->par()->isRightToLeftPar(bv()->buffer()->params)) ? row->pos() : last + 1; else if (pos > row->pos() && (pos > last || boundary)) @@ -1831,7 +1826,7 @@ float LyXText::getCursorX(BufferView * bview, Row * row, pos_type body_pos = row->par()->beginningOfBody(); if ((body_pos > 0) && ((body_pos-1 > last) || - !row->par()->isLineSeparator(body_pos-1))) + !row->par()->isLineSeparator(body_pos - 1))) body_pos = 0; for (pos_type vpos = row->pos(); vpos < cursor_vpos; ++vpos) { @@ -1840,30 +1835,30 @@ float LyXText::getCursorX(BufferView * bview, Row * row, x += fill_label_hfill + font_metrics::width( row->par()->layout()->labelsep, - getLabelFont(bview->buffer(), + getLabelFont(bv()->buffer(), row->par())); if (row->par()->isLineSeparator(body_pos - 1)) - x -= singleWidth(bview, + x -= singleWidth( row->par(), body_pos - 1); } if (row->hfillExpansion(pos)) { - x += singleWidth(bview, row->par(), pos); + x += singleWidth(row->par(), pos); if (pos >= body_pos) x += fill_hfill; else x += fill_label_hfill; } else if (row->par()->isSeparator(pos)) { - x += singleWidth(bview, row->par(), pos); + x += singleWidth(row->par(), pos); if (pos >= body_pos) x += fill_separator; } else - x += singleWidth(bview, row->par(), pos); + x += singleWidth(row->par(), pos); } return x; } -void LyXText::setCursorIntern(BufferView * bview, Paragraph * par, +void LyXText::setCursorIntern(Paragraph * par, pos_type pos, bool setfont, bool boundary) const { InsetText * it = static_cast(par->inInset()); @@ -1887,18 +1882,18 @@ void LyXText::setCursorIntern(BufferView * bview, Paragraph * par, // I moved the lyxerr stuff in here so we can see if // this is actually really needed and where! // (Jug) - // it->getLyXText(bview)->setCursorIntern(bview, par, pos, setfont, boundary); + // it->getLyXText(bv())->setCursorIntern(bv(), par, pos, setfont, boundary); return; } } - setCursor(bview, cursor, par, pos, boundary); + setCursor(cursor, par, pos, boundary); if (setfont) - setCurrentFont(bview); + setCurrentFont(); } -void LyXText::setCurrentFont(BufferView * bview) const +void LyXText::setCurrentFont() const { pos_type pos = cursor.pos(); if (cursor.boundary() && pos > 0) @@ -1919,14 +1914,14 @@ void LyXText::setCurrentFont(BufferView * bview) const } current_font = - cursor.par()->getFontSettings(bview->buffer()->params, pos); - real_current_font = getFont(bview->buffer(), cursor.par(), pos); + cursor.par()->getFontSettings(bv()->buffer()->params, pos); + real_current_font = getFont(bv()->buffer(), cursor.par(), pos); if (cursor.pos() == cursor.par()->size() && - isBoundary(bview->buffer(), cursor.par(), cursor.pos()) && + isBoundary(bv()->buffer(), cursor.par(), cursor.pos()) && !cursor.boundary()) { Language const * lang = - cursor.par()->getParLanguage(bview->buffer()->params); + cursor.par()->getParLanguage(bv()->buffer()->params); current_font.setLanguage(lang); current_font.setNumber(LyXFont::OFF); real_current_font.setLanguage(lang); @@ -1938,7 +1933,7 @@ void LyXText::setCurrentFont(BufferView * bview) const // returns the column near the specified x-coordinate of the row // x is set to the real beginning of this column pos_type -LyXText::getColumnNearX(BufferView * bview, Row * row, int & x, +LyXText::getColumnNearX(Row * row, int & x, bool & boundary) const { float tmpx = 0.0; @@ -1946,7 +1941,7 @@ LyXText::getColumnNearX(BufferView * bview, Row * row, int & x, float fill_hfill; float fill_label_hfill; - prepareToPrint(bview, row, tmpx, fill_separator, + prepareToPrint(row, tmpx, fill_separator, fill_hfill, fill_label_hfill); pos_type vc = row->pos(); @@ -1977,23 +1972,23 @@ LyXText::getColumnNearX(BufferView * bview, Row * row, int & x, if (body_pos > 0 && c == body_pos-1) { tmpx += fill_label_hfill + font_metrics::width(layout->labelsep, - getLabelFont(bview->buffer(), row->par())); + getLabelFont(bv()->buffer(), row->par())); if (row->par()->isLineSeparator(body_pos - 1)) - tmpx -= singleWidth(bview, row->par(), body_pos-1); + tmpx -= singleWidth(row->par(), body_pos-1); } if (row->hfillExpansion(c)) { - tmpx += singleWidth(bview, row->par(), c); + tmpx += singleWidth(row->par(), c); if (c >= body_pos) tmpx += fill_hfill; else tmpx += fill_label_hfill; } else if (row->par()->isSeparator(c)) { - tmpx += singleWidth(bview, row->par(), c); + tmpx += singleWidth(row->par(), c); if (c >= body_pos) tmpx+= fill_separator; } else { - tmpx += singleWidth(bview, row->par(), c); + tmpx += singleWidth(row->par(), c); } ++vc; } @@ -2011,7 +2006,7 @@ LyXText::getColumnNearX(BufferView * bview, Row * row, int & x, // some speedup if rtl_support=false && (!row->next() || row->next()->par() != row->par()); bool const rtl = (lastrow) - ? row->par()->isRightToLeftPar(bview->buffer()->params) + ? row->par()->isRightToLeftPar(bv()->buffer()->params) : false; // If lastrow is false, we don't need to compute // the value of rtl. @@ -2028,16 +2023,16 @@ LyXText::getColumnNearX(BufferView * bview, Row * row, int & x, bool const rtl = (bidi_level(c) % 2 == 1); if (left_side == rtl) { ++c; - boundary = isBoundary(bview->buffer(), row->par(), c); + boundary = isBoundary(bv()->buffer(), row->par(), c); } } if (row->pos() <= last && c > last && row->par()->isNewline(last)) { if (bidi_level(last) % 2 == 0) - tmpx -= singleWidth(bview, row->par(), last); + tmpx -= singleWidth(row->par(), last); else - tmpx += singleWidth(bview, row->par(), last); + tmpx += singleWidth(row->par(), last); c = last; } @@ -2047,13 +2042,13 @@ LyXText::getColumnNearX(BufferView * bview, Row * row, int & x, } -void LyXText::setCursorFromCoordinates(BufferView * bview, int x, int y) const +void LyXText::setCursorFromCoordinates(int x, int y) const { LyXCursor old_cursor = cursor; - setCursorFromCoordinates(bview, cursor, x, y); - setCurrentFont(bview); - deleteEmptyParagraphMechanism(bview, old_cursor); + setCursorFromCoordinates(cursor, x, y); + setCurrentFont(); + deleteEmptyParagraphMechanism(old_cursor); } @@ -2081,14 +2076,14 @@ namespace { } -void LyXText::setCursorFromCoordinates(BufferView * bview, LyXCursor & cur, +void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y) const { // Get the row first. Row * row = getRowNearY(y); bool bound = false; - pos_type const column = getColumnNearX(bview, row, x, bound); + pos_type const column = getColumnNearX(row, x, bound); cur.par(row->par()); cur.pos(row->pos() + column); cur.x(x); @@ -2097,7 +2092,7 @@ void LyXText::setCursorFromCoordinates(BufferView * bview, LyXCursor & cur, if (beforeFullRowInset(*row, cur)) { pos_type last = row->lastPrintablePos(); - float x = getCursorX(bview, row->next(), cur.pos(), last, bound); + float x = getCursorX(row->next(), cur.pos(), last, bound); cur.ix(int(x)); cur.iy(y + row->height() + row->next()->baseline()); cur.irow(row->next()); @@ -2110,108 +2105,107 @@ void LyXText::setCursorFromCoordinates(BufferView * bview, LyXCursor & cur, } -void LyXText::cursorLeft(BufferView * bview, bool internal) const +void LyXText::cursorLeft(bool internal) const { if (cursor.pos() > 0) { bool boundary = cursor.boundary(); - setCursor(bview, cursor.par(), cursor.pos() - 1, true, false); + setCursor(cursor.par(), cursor.pos() - 1, true, false); if (!internal && !boundary && - isBoundary(bview->buffer(), cursor.par(), cursor.pos() + 1)) - setCursor(bview, cursor.par(), cursor.pos() + 1, true, true); + isBoundary(bv()->buffer(), cursor.par(), cursor.pos() + 1)) + setCursor(cursor.par(), cursor.pos() + 1, true, true); } else if (cursor.par()->previous()) { // steps into the above paragraph. Paragraph * par = cursor.par()->previous(); - setCursor(bview, par, par->size()); + setCursor(par, par->size()); } } -void LyXText::cursorRight(BufferView * bview, bool internal) const +void LyXText::cursorRight(bool internal) const { if (!internal && cursor.boundary() && !cursor.par()->isNewline(cursor.pos())) - setCursor(bview, cursor.par(), cursor.pos(), true, false); + setCursor(cursor.par(), cursor.pos(), true, false); else if (cursor.pos() < cursor.par()->size()) { - setCursor(bview, cursor.par(), cursor.pos() + 1, true, false); + setCursor(cursor.par(), cursor.pos() + 1, true, false); if (!internal && - isBoundary(bview->buffer(), cursor.par(), cursor.pos())) - setCursor(bview, cursor.par(), cursor.pos(), true, true); + isBoundary(bv()->buffer(), cursor.par(), cursor.pos())) + setCursor(cursor.par(), cursor.pos(), true, true); } else if (cursor.par()->next()) - setCursor(bview, cursor.par()->next(), 0); + setCursor(cursor.par()->next(), 0); } -void LyXText::cursorUp(BufferView * bview, bool selecting) const +void LyXText::cursorUp(bool selecting) const { #if 1 int x = cursor.x_fix(); int y = cursor.y() - cursor.row()->baseline() - 1; - setCursorFromCoordinates(bview, x, y); + setCursorFromCoordinates(x, y); if (!selecting) { int topy = top_y(); int y1 = cursor.iy() - topy; int y2 = y1; y -= topy; - Inset * inset_hit = checkInsetHit(bview, x, y1); + Inset * inset_hit = checkInsetHit(x, y1); if (inset_hit && isHighlyEditableInset(inset_hit)) { - inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none); + inset_hit->edit(bv(), x, y - (y2 - y1), mouse_button::none); } } #else - setCursorFromCoordinates(bview, cursor.x_fix(), + setCursorFromCoordinates(bv(), cursor.x_fix(), cursor.y() - cursor.row()->baseline() - 1); #endif } -void LyXText::cursorDown(BufferView * bview, bool selecting) const +void LyXText::cursorDown(bool selecting) const { #if 1 int x = cursor.x_fix(); int y = cursor.y() - cursor.row()->baseline() + cursor.row()->height() + 1; - setCursorFromCoordinates(bview, x, y); + setCursorFromCoordinates(x, y); if (!selecting && cursor.row() == cursor.irow()) { int topy = top_y(); int y1 = cursor.iy() - topy; int y2 = y1; y -= topy; - Inset * inset_hit = checkInsetHit(bview, x, y1); + Inset * inset_hit = checkInsetHit(x, y1); if (inset_hit && isHighlyEditableInset(inset_hit)) { - inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none); + inset_hit->edit(bv(), x, y - (y2 - y1), mouse_button::none); } } #else - setCursorFromCoordinates(bview, cursor.x_fix(), + setCursorFromCoordinates(bv(), cursor.x_fix(), cursor.y() - cursor.row()->baseline() + cursor.row()->height() + 1); #endif } -void LyXText::cursorUpParagraph(BufferView * bview) const +void LyXText::cursorUpParagraph() const { if (cursor.pos() > 0) { - setCursor(bview, cursor.par(), 0); + setCursor(cursor.par(), 0); } else if (cursor.par()->previous()) { - setCursor(bview, cursor.par()->previous(), 0); + setCursor(cursor.par()->previous(), 0); } } -void LyXText::cursorDownParagraph(BufferView * bview) const +void LyXText::cursorDownParagraph() const { if (cursor.par()->next()) { - setCursor(bview, cursor.par()->next(), 0); + setCursor(cursor.par()->next(), 0); } else { - setCursor(bview, cursor.par(), cursor.par()->size()); + setCursor(cursor.par(), cursor.par()->size()); } } // fix the cursor `cur' after a characters has been deleted at `where' // position. Called by deleteEmptyParagraphMechanism -void LyXText::fixCursorAfterDelete(BufferView * bview, - LyXCursor & cur, +void LyXText::fixCursorAfterDelete(LyXCursor & cur, LyXCursor const & where) const { // if cursor is not in the paragraph where the delete occured, @@ -2230,12 +2224,11 @@ void LyXText::fixCursorAfterDelete(BufferView * bview, cur.pos(cur.par()->size()); // recompute row et al. for this cursor - setCursor(bview, cur, cur.par(), cur.pos(), cur.boundary()); + setCursor(cur, cur.par(), cur.pos(), cur.boundary()); } -bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview, - LyXCursor const & old_cursor) const +bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor) const { // Would be wrong to delete anything if we have a selection. if (selection.set()) @@ -2280,7 +2273,7 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview, && old_cursor.par()->isLineSeparator(old_cursor.pos()) && old_cursor.par()->isLineSeparator(old_cursor.pos() - 1)) { old_cursor.par()->erase(old_cursor.pos() - 1); - redoParagraphs(bview, old_cursor, old_cursor.par()->next()); + redoParagraphs(old_cursor, old_cursor.par()->next()); #ifdef WITH_WARNINGS #warning This will not work anymore when we have multiple views of the same buffer @@ -2289,16 +2282,16 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview, // automated way in LyXCursor code. (JMarc 26/09/2001) #endif // correct all cursors held by the LyXText - fixCursorAfterDelete(bview, cursor, old_cursor); - fixCursorAfterDelete(bview, selection.cursor, + fixCursorAfterDelete(cursor, old_cursor); + fixCursorAfterDelete(selection.cursor, old_cursor); - fixCursorAfterDelete(bview, selection.start, + fixCursorAfterDelete(selection.start, old_cursor); - fixCursorAfterDelete(bview, selection.end, old_cursor); - fixCursorAfterDelete(bview, last_sel_cursor, + fixCursorAfterDelete(selection.end, old_cursor); + fixCursorAfterDelete(last_sel_cursor, old_cursor); - fixCursorAfterDelete(bview, toggle_cursor, old_cursor); - fixCursorAfterDelete(bview, toggle_end_cursor, + fixCursorAfterDelete(toggle_cursor, old_cursor); + fixCursorAfterDelete(toggle_end_cursor, old_cursor); return false; } @@ -2329,8 +2322,8 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview, deleted = true; if (old_cursor.row()->previous()) { - const_cast(this)->postPaint(*bview, old_cursor.y() - old_cursor.row()->baseline() - - old_cursor.row()->previous()->height()); + const_cast(this)->postPaint(old_cursor.y() - old_cursor.row()->baseline() + - old_cursor.row()->previous()->height()); tmpcursor = cursor; cursor = old_cursor; // that undo can restore the right cursor position Paragraph * endpar = old_cursor.par()->next(); @@ -2339,7 +2332,7 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview, endpar = endpar->next(); } } - setUndo(bview, Undo::DELETE, old_cursor.par(), endpar); + setUndo(bv(), Undo::DELETE, old_cursor.par(), endpar); cursor = tmpcursor; // delete old row @@ -2355,13 +2348,13 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview, * The next row can change its height, if * there is another layout before */ if (refresh_row->next()) { - breakAgain(bview, refresh_row->next()); - updateCounters(bview); + breakAgain(refresh_row->next()); + updateCounters(); } - setHeightOfRow(bview, refresh_row); + setHeightOfRow(refresh_row); } else { Row * nextrow = old_cursor.row()->next(); - const_cast(this)->postPaint(*bview, + const_cast(this)->postPaint( old_cursor.y() - old_cursor.row()->baseline()); tmpcursor = cursor; @@ -2372,7 +2365,7 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview, endpar = endpar->next(); } } - setUndo(bview, Undo::DELETE, old_cursor.par(), endpar); + setUndo(bv(), Undo::DELETE, old_cursor.par(), endpar); cursor = tmpcursor; // delete old row @@ -2389,13 +2382,13 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview, The next row can change its height, if there is another layout before */ if (nextrow) { - breakAgain(bview, nextrow); - updateCounters(bview); + breakAgain(nextrow); + updateCounters(); } } // correct cursor y - setCursorIntern(bview, cursor.par(), cursor.pos()); + setCursorIntern(cursor.par(), cursor.pos()); if (selection.cursor.par() == old_cursor.par() && selection.cursor.pos() == old_cursor.pos()) { @@ -2405,10 +2398,10 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview, } if (!deleted) { if (old_cursor.par()->stripLeadingSpaces()) { - redoParagraphs(bview, old_cursor, + redoParagraphs(old_cursor, old_cursor.par()->next()); // correct cursor y - setCursorIntern(bview, cursor.par(), cursor.pos()); + setCursorIntern(cursor.par(), cursor.pos()); selection.cursor = cursor; } } @@ -2466,7 +2459,7 @@ void LyXText::postChangedInDraw() } -void LyXText::postPaint(BufferView & bv, int start_y) +void LyXText::postPaint(int start_y) { text_status old = status_; @@ -2482,11 +2475,11 @@ void LyXText::postPaint(BufferView & bv, int start_y) if (!inset_owner) return; - + // We are an inset's lyxtext. Tell the top-level lyxtext // it needs to update the row we're in. - LyXText * t = bv.text; + LyXText * t = bv()->text; // FIXME: but what if this row is below ? if (!t->refresh_row) { @@ -2498,7 +2491,7 @@ void LyXText::postPaint(BufferView & bv, int start_y) // FIXME: we should probably remove this y parameter, // make refresh_y be 0, and use row->y etc. -void LyXText::postRowPaint(BufferView & bv, Row * row, int start_y) +void LyXText::postRowPaint(Row * row, int start_y) { if (status_ != UNCHANGED && refresh_y < start_y) { lyxerr << "Paint already pending from above" << endl; @@ -2515,11 +2508,11 @@ void LyXText::postRowPaint(BufferView & bv, Row * row, int start_y) if (!inset_owner) return; - + // We are an inset's lyxtext. Tell the top-level lyxtext // it needs to update the row we're in. - LyXText * t = bv.text; + LyXText * t = bv()->text; // FIXME: but what if this new row is above ? // Why the !t->refresh_row at all ? @@ -2530,16 +2523,11 @@ void LyXText::postRowPaint(BufferView & bv, Row * row, int start_y) } -bool LyXText::isTopLevel() const -{ - /// only the top-level lyxtext has a non-null bv owner - return bv_owner; -} - - bool LyXText::isInInset() const { - return inset_owner; + // Sub-level has non-null bv owner and + // non-null inset owner. + return inset_owner != 0 && bv_owner != 0; } diff --git a/src/text3.C b/src/text3.C index 1c904840a6..5c03f2f820 100644 --- a/src/text3.C +++ b/src/text3.C @@ -58,13 +58,13 @@ namespace { LyXText * lt = bv->getLyXText(); if (selecting || lt->selection.mark()) { - lt->setSelection(bv); - if (lt->isTopLevel()) - bv->toggleToggle(); - else + lt->setSelection(); + if (lt->isInInset()) bv->updateInset(lt->inset_owner, false); + else + bv->toggleToggle(); } - if (lt->isTopLevel()) { + if (!lt->isInInset()) { //if (fitcur) // bv->update(lt, BufferView::SELECT|BufferView::FITCUR); //else @@ -130,7 +130,7 @@ namespace { return 0; } - text.setCursor(bv, &par, pos, true); + text.setCursor(&par, pos, true); x -= b.x1; // The origin of an inset is on the baseline @@ -142,14 +142,14 @@ namespace { } // anon namespace -Inset * LyXText::checkInsetHit(BufferView * bv, int & x, int & y) const +Inset * LyXText::checkInsetHit(int & x, int & y) const { int y_tmp = y + top_y(); LyXCursor cur; - setCursorFromCoordinates(bv, cur, x, y_tmp); + setCursorFromCoordinates(cur, x, y_tmp); - Inset * inset = checkInset(bv, *this, cur, x, y_tmp); + Inset * inset = checkInset(bv(), *this, cur, x, y_tmp); if (inset) { y = y_tmp; return inset; @@ -160,17 +160,17 @@ Inset * LyXText::checkInsetHit(BufferView * bv, int & x, int & y) const return 0; // move back one - setCursor(bv, cur, cur.par(), cur.pos() - 1, true); + setCursor(cur, cur.par(), cur.pos() - 1, true); - inset = checkInset(bv, *this, cur, x, y_tmp); + inset = checkInset(bv(), *this, cur, x, y_tmp); if (inset) y = y_tmp; return inset; } -bool LyXText::gotoNextInset(BufferView * bv, - vector const & codes, string const & contents) const +bool LyXText::gotoNextInset(vector const & codes, + string const & contents) const { LyXCursor res = cursor; Inset * inset; @@ -193,19 +193,19 @@ bool LyXText::gotoNextInset(BufferView * bv, == contents))); if (res.par()) { - setCursor(bv, res.par(), res.pos(), false); + setCursor(res.par(), res.pos(), false); return true; } return false; } -void LyXText::gotoInset(BufferView * bv, vector const & codes, +void LyXText::gotoInset(vector const & codes, bool same_content) { - bv->hideCursor(); - bv->beforeChange(this); - update(bv, false); + bv()->hideCursor(); + bv()->beforeChange(this); + update(false); string contents; if (same_content && cursor.par()->isInset(cursor.pos())) { @@ -215,37 +215,37 @@ void LyXText::gotoInset(BufferView * bv, vector const & codes, contents = static_cast(inset)->getContents(); } - if (!gotoNextInset(bv, codes, contents)) { + if (!gotoNextInset(codes, contents)) { if (cursor.pos() || cursor.par() != ownerParagraph()) { LyXCursor tmp = cursor; cursor.par(ownerParagraph()); cursor.pos(0); - if (!gotoNextInset(bv, codes, contents)) { + if (!gotoNextInset(codes, contents)) { cursor = tmp; - bv->owner()->message(_("No more insets")); + bv()->owner()->message(_("No more insets")); } } else { - bv->owner()->message(_("No more insets")); + bv()->owner()->message(_("No more insets")); } } - update(bv, false); + update(false); selection.cursor = cursor; } -void LyXText::gotoInset(BufferView * bv, Inset::Code code, bool same_content) +void LyXText::gotoInset(Inset::Code code, bool same_content) { - gotoInset(bv, vector(1, code), same_content); + gotoInset(vector(1, code), same_content); } -void LyXText::cursorPrevious(BufferView * bv) +void LyXText::cursorPrevious() { if (!cursor.row()->previous()) { if (top_y() > 0) { - int new_y = bv->text->top_y() - bv->workHeight(); - bv->screen().draw(bv->text, bv, new_y < 0 ? 0 : new_y); - bv->updateScrollbar(); + int new_y = bv()->text->top_y() - bv()->workHeight(); + bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y); + bv()->updateScrollbar(); } return; } @@ -253,14 +253,14 @@ void LyXText::cursorPrevious(BufferView * bv) int y = top_y(); Row * cursorrow = cursor.row(); - setCursorFromCoordinates(bv, cursor.x_fix(), y); + setCursorFromCoordinates(cursor.x_fix(), y); finishUndo(); int new_y; - if (cursorrow == bv->text->cursor.row()) { + if (cursorrow == bv()->text->cursor.row()) { // we have a row which is taller than the workarea. The // simplest solution is to move to the previous row instead. - cursorUp(bv, true); + cursorUp(true); return; // This is what we used to do, so we wouldn't skip right past // tall rows, but it's not working right now. @@ -269,61 +269,61 @@ void LyXText::cursorPrevious(BufferView * bv) #endif } else { if (inset_owner) { - new_y = bv->text->cursor.iy() - + bv->theLockingInset()->insetInInsetY() + y + new_y = bv()->text->cursor.iy() + + bv()->theLockingInset()->insetInInsetY() + y + cursor.row()->height() - - bv->workHeight() + 1; + - bv()->workHeight() + 1; } else { new_y = cursor.y() - cursor.row()->baseline() + cursor.row()->height() - - bv->workHeight() + 1; + - bv()->workHeight() + 1; } } - bv->screen().draw(bv->text, bv, new_y < 0 ? 0 : new_y); + bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y); if (cursor.row()->previous()) { LyXCursor cur; - setCursor(bv, cur, cursor.row()->previous()->par(), - cursor.row()->previous()->pos(), false); + setCursor(cur, cursor.row()->previous()->par(), + cursor.row()->previous()->pos(), false); if (cur.y() > top_y()) { - cursorUp(bv, true); + cursorUp(true); } } - bv->updateScrollbar(); + bv()->updateScrollbar(); } -void LyXText::cursorNext(BufferView * bv) +void LyXText::cursorNext() { if (!cursor.row()->next()) { int y = cursor.y() - cursor.row()->baseline() + cursor.row()->height(); - if (y > top_y() + bv->workHeight()) { - bv->screen().draw(bv->text, bv, bv->text->top_y() + bv->workHeight()); - bv->updateScrollbar(); + if (y > top_y() + bv()->workHeight()) { + bv()->screen().draw(bv()->text, bv(), bv()->text->top_y() + bv()->workHeight()); + bv()->updateScrollbar(); } return; } - int y = top_y() + bv->workHeight(); + int y = top_y() + bv()->workHeight(); if (inset_owner && !top_y()) { - y -= (bv->text->cursor.iy() - - bv->text->top_y() - + bv->theLockingInset()->insetInInsetY()); + y -= (bv()->text->cursor.iy() + - bv()->text->top_y() + + bv()->theLockingInset()->insetInInsetY()); } getRowNearY(y); Row * cursorrow = cursor.row(); - setCursorFromCoordinates(bv, cursor.x_fix(), y); + setCursorFromCoordinates(cursor.x_fix(), y); // + bv->workHeight()); finishUndo(); int new_y; - if (cursorrow == bv->text->cursor.row()) { + if (cursorrow == bv()->text->cursor.row()) { // we have a row which is taller than the workarea. The // simplest solution is to move to the next row instead. - cursorDown(bv, true); + cursorDown(true); return; // This is what we used to do, so we wouldn't skip right past // tall rows, but it's not working right now. @@ -332,33 +332,33 @@ void LyXText::cursorNext(BufferView * bv) #endif } else { if (inset_owner) { - new_y = bv->text->cursor.iy() - + bv->theLockingInset()->insetInInsetY() + new_y = bv()->text->cursor.iy() + + bv()->theLockingInset()->insetInInsetY() + y - cursor.row()->baseline(); } else { new_y = cursor.y() - cursor.row()->baseline(); } } - bv->screen().draw(bv->text, bv, new_y); + bv()->screen().draw(bv()->text, bv(), new_y); if (cursor.row()->next()) { LyXCursor cur; - setCursor(bv, cur, cursor.row()->next()->par(), + setCursor(cur, cursor.row()->next()->par(), cursor.row()->next()->pos(), false); - if (cur.y() < top_y() + bv->workHeight()) { - cursorDown(bv, true); + if (cur.y() < top_y() + bv()->workHeight()) { + cursorDown(true); } } - bv->updateScrollbar(); + bv()->updateScrollbar(); } -void LyXText::update(BufferView * bv, bool changed) +void LyXText::update(bool changed) { BufferView::UpdateCodes c = BufferView::SELECT | BufferView::FITCUR; if (changed) - bv->update(this, c | BufferView::CHANGE); + bv()->update(this, c | BufferView::CHANGE); else - bv->update(this, c); + bv()->update(this, c); } namespace { @@ -384,7 +384,7 @@ void doInsertInset(LyXText * lt, FuncRequest const & cmd, if (inset) { bool gotsel = false; if (lt->selection.set()) { - lt->cutSelection(bv, true, false); + lt->cutSelection(true, false); gotsel = true; } if (bv->insertInset(inset)) { @@ -420,7 +420,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) setUndo(bv, Undo::EDIT, tmp, tmp->next()); tmp->params().startOfAppendix(false); int tmpy; - setHeightOfRow(bv, getRow(tmp, 0, tmpy)); + setHeightOfRow(getRow(tmp, 0, tmpy)); break; } } @@ -429,35 +429,35 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) par->params().startOfAppendix(start); // we can set the refreshing parameters now - updateCounters(cmd.view()); - redoHeightOfParagraph(bv); - postPaint(*cmd.view(), 0); - setCursor(cmd.view(), cursor.par(), cursor.pos()); + updateCounters(); + redoHeightOfParagraph(); + postPaint(0); + setCursor(cursor.par(), cursor.pos()); update(bv); break; } case LFUN_DELETE_WORD_FORWARD: bv->beforeChange(this); - update(bv, false); - deleteWordForward(bv); + update(false); + deleteWordForward(); update(bv); finishChange(bv); break; case LFUN_DELETE_WORD_BACKWARD: bv->beforeChange(this); - update(bv, false); - deleteWordBackward(bv); - update(bv, true); + update(false); + deleteWordBackward(); + update(true); finishChange(bv); break; case LFUN_DELETE_LINE_FORWARD: bv->beforeChange(this); - update(bv, false); - deleteLineForward(bv); - update(bv); + update(false); + deleteLineForward(); + update(); finishChange(bv); break; @@ -465,51 +465,51 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_TAB: if (!selection.mark()) bv->beforeChange(this); - update(bv, false); - cursorTab(bv); + update(false); + cursorTab(); finishChange(bv); break; case LFUN_WORDRIGHT: if (!selection.mark()) bv->beforeChange(this); - update(bv, false); + update(false); if (cursor.par()->isRightToLeftPar(bv->buffer()->params)) - cursorLeftOneWord(bv); + cursorLeftOneWord(); else - cursorRightOneWord(bv); + cursorRightOneWord(); finishChange(bv); break; case LFUN_WORDLEFT: if (!selection.mark()) bv->beforeChange(this); - update(bv, false); + update(false); if (cursor.par()->isRightToLeftPar(bv->buffer()->params)) - cursorRightOneWord(bv); + cursorRightOneWord(); else - cursorLeftOneWord(bv); + cursorLeftOneWord(); finishChange(bv); break; case LFUN_BEGINNINGBUF: if (!selection.mark()) bv->beforeChange(this); - update(bv, false); - cursorTop(bv); + update(false); + cursorTop(); finishChange(bv); break; case LFUN_ENDBUF: if (selection.mark()) bv->beforeChange(this); - update(bv, false); - cursorBottom(bv); + update(false); + cursorBottom(); finishChange(bv); break; case LFUN_RIGHTSEL: - update(bv, false); + update(false); if (cursor.par()->isRightToLeftPar(bv->buffer()->params)) cursorLeft(bv); else @@ -518,7 +518,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) break; case LFUN_LEFTSEL: - update(bv, false); + update(false); if (cursor.par()->isRightToLeftPar(bv->buffer()->params)) cursorRight(bv); else @@ -527,79 +527,79 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) break; case LFUN_UPSEL: - update(bv, false); - cursorUp(bv, true); + update(false); + cursorUp(true); finishChange(bv, true); break; case LFUN_DOWNSEL: - update(bv, false); - cursorDown(bv, true); + update(false); + cursorDown(true); finishChange(bv, true); break; case LFUN_UP_PARAGRAPHSEL: - update(bv, false); - cursorUpParagraph(bv); + update(false); + cursorUpParagraph(); finishChange(bv, true); break; case LFUN_DOWN_PARAGRAPHSEL: - update(bv, false); - cursorDownParagraph(bv); + update(false); + cursorDownParagraph(); finishChange(bv, true); break; case LFUN_PRIORSEL: - update(bv, false); - cursorPrevious(bv); + update(false); + cursorPrevious(); finishChange(bv, true); break; case LFUN_NEXTSEL: - update(bv, false); - cursorNext(bv); + update(false); + cursorNext(); finishChange(bv, true); break; case LFUN_HOMESEL: - update(bv, false); - cursorHome(bv); + update(false); + cursorHome(); finishChange(bv, true); break; case LFUN_ENDSEL: - update(bv, false); - cursorEnd(bv); + update(false); + cursorEnd(); finishChange(bv, true); break; case LFUN_WORDRIGHTSEL: - update(bv, false); + update(false); if (cursor.par()->isRightToLeftPar(bv->buffer()->params)) - cursorLeftOneWord(bv); + cursorLeftOneWord(); else - cursorRightOneWord(bv); + cursorRightOneWord(); finishChange(bv, true); break; case LFUN_WORDLEFTSEL: - update(bv, false); + update(false); if (cursor.par()->isRightToLeftPar(bv->buffer()->params)) - cursorRightOneWord(bv); + cursorRightOneWord(); else - cursorLeftOneWord(bv); + cursorLeftOneWord(); finishChange(bv, true); break; case LFUN_WORDSEL: { - update(bv, false); + update(false); LyXCursor cur1; LyXCursor cur2; getWord(cur1, cur2, WHOLE_WORD); - setCursor(bv, cur1.par(), cur1.pos()); + setCursor(cur1.par(), cur1.pos()); bv->beforeChange(this); - setCursor(bv, cur2.par(), cur2.pos()); + setCursor(cur2.par(), cur2.pos()); finishChange(bv, true); break; } @@ -608,9 +608,9 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) bool is_rtl = cursor.par()->isRightToLeftPar(bv->buffer()->params); if (!selection.mark()) bv->beforeChange(this); - update(bv, false); + update(false); if (is_rtl) - cursorLeft(bv, false); + cursorLeft(false); if (cursor.pos() < cursor.par()->size() && cursor.par()->isInset(cursor.pos()) && isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) { @@ -620,7 +620,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) break; } if (!is_rtl) - cursorRight(bv, false); + cursorRight(false); finishChange(bv); break; } @@ -631,10 +631,10 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) bool const is_rtl = cursor.par()->isRightToLeftPar(bv->buffer()->params); if (!selection.mark()) bv->beforeChange(this); - update(bv, false); + update(false); LyXCursor const cur = cursor; if (!is_rtl) - cursorLeft(bv, false); + cursorLeft(false); if ((is_rtl || cur != cursor) && // only if really moved! cursor.pos() < cursor.par()->size() && cursor.par()->isInset(cursor.pos()) && @@ -645,7 +645,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) break; } if (is_rtl) - cursorRight(bv, false); + cursorRight(false); finishChange(bv); break; } @@ -670,7 +670,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) if (!selection.mark()) bv->beforeChange(this); bv->update(this, BufferView::UPDATE); - cursorUpParagraph(bv); + cursorUpParagraph(); finishChange(bv); break; @@ -678,7 +678,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) if (!selection.mark()) bv->beforeChange(this); bv->update(this, BufferView::UPDATE); - cursorDownParagraph(bv); + cursorDownParagraph(); finishChange(bv, false); break; @@ -686,7 +686,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) if (!selection.mark()) bv->beforeChange(this); bv->update(this, BufferView::UPDATE); - cursorPrevious(bv); + cursorPrevious(); finishChange(bv, false); // was: // finishUndo(); @@ -698,7 +698,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) if (!selection.mark()) bv->beforeChange(this); bv->update(this, BufferView::UPDATE); - cursorNext(bv); + cursorNext(); finishChange(bv, false); break; @@ -706,7 +706,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) if (!selection.mark()) bv->beforeChange(this); update(bv); - cursorHome(bv); + cursorHome(); finishChange(bv, false); break; @@ -714,7 +714,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) if (!selection.mark()) bv->beforeChange(this); update(bv); - cursorEnd(bv); + cursorEnd(); finishChange(bv, false); break; @@ -726,23 +726,23 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) break; bv->beforeChange(this); - insertInset(bv, new InsetNewline); - update(bv, true); - setCursor(bv, cursor.par(), cursor.pos()); + insertInset(new InsetNewline); + update(true); + setCursor(cursor.par(), cursor.pos()); moveCursorUpdate(bv, false); break; } case LFUN_DELETE: if (!selection.set()) { - Delete(bv); + Delete(); selection.cursor = cursor; update(bv); // It is possible to make it a lot faster still // just comment out the line below... bv->showCursor(); } else { - update(bv, false); + update(false); cutSelection(bv, true); update(bv); } @@ -761,7 +761,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) if (cur.pos() == 0 && !(cur.par()->params().spaceTop() == VSpace (VSpace::NONE))) { - setParagraph(bv, + setParagraph( cur.par()->params().lineTop(), cur.par()->params().lineBottom(), cur.par()->params().pagebreakTop(), @@ -775,15 +775,15 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) update(bv); } else { cursorLeft(bv); - Delete(bv); + Delete(); selection.cursor = cursor; } } else { - Delete(bv); + Delete(); selection.cursor = cursor; } } else { - update(bv, false); + update(false); cutSelection(bv, true); } update(bv); @@ -793,7 +793,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_BACKSPACE: if (!selection.set()) { if (bv->owner()->getIntl().getTransManager().backspace()) { - backspace(bv); + backspace(); selection.cursor = cursor; update(bv); // It is possible to make it a lot faster still @@ -801,7 +801,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) bv->showCursor(); } } else { - update(bv, false); + update(false); cutSelection(bv, true); update(bv); } @@ -816,7 +816,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) if (cur.pos() == 0 && !(cur.par()->params().spaceTop() == VSpace (VSpace::NONE))) { - setParagraph(bv, + setParagraph( cur.par()->params().lineTop(), cur.par()->params().lineBottom(), cur.par()->params().pagebreakTop(), @@ -826,11 +826,11 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) cur.par()->params().align(), cur.par()->params().labelWidthString(), 0); } else { - backspace(bv); + backspace(); selection.cursor = cur; } } else { - update(bv, false); + update(false); cutSelection(bv, true); } update(bv); @@ -838,7 +838,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_BREAKPARAGRAPH: bv->beforeChange(this); - breakParagraph(bv, bv->buffer()->paragraphs, 0); + breakParagraph(bv->buffer()->paragraphs, 0); update(bv); selection.cursor = cursor; bv->switchKeyMap(); @@ -847,7 +847,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_BREAKPARAGRAPHKEEPLAYOUT: bv->beforeChange(this); - breakParagraph(bv, bv->buffer()->paragraphs, 1); + breakParagraph(bv->buffer()->paragraphs, 1); update(bv); selection.cursor = cursor; bv->switchKeyMap(); @@ -862,7 +862,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) bv->beforeChange(this); if (cur.pos() == 0) { if (cur.par()->params().spaceTop() == VSpace(VSpace::NONE)) { - setParagraph(bv, + setParagraph( cur.par()->params().lineTop(), cur.par()->params().lineBottom(), cur.par()->params().pagebreakTop(), @@ -875,7 +875,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) } } else { - breakParagraph(bv, bv->buffer()->paragraphs, 0); + breakParagraph(bv->buffer()->paragraphs, 0); //update(bv); } update(bv); @@ -921,7 +921,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) } if (cur_spacing != new_spacing || cur_value != new_value) { par->params().spacing(Spacing(new_spacing, new_value)); - redoParagraph(bv); + redoParagraph(); update(bv); } break; @@ -930,15 +930,15 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_INSET_TOGGLE: bv->hideCursor(); bv->beforeChange(this); - update(bv, false); - toggleInset(bv); - update(bv, false); + update(false); + toggleInset(); + update(false); bv->switchKeyMap(); break; case LFUN_PROTECTEDSPACE: if (cursor.par()->layout()->free_spacing) { - insertChar(bv, ' '); + insertChar(' '); update(bv); } else { specialChar(this, bv, InsetSpecialChar::PROTECTED_SEPARATOR); @@ -968,7 +968,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_MARK_OFF: bv->beforeChange(this); - update(bv, false); + update(false); selection.cursor = cursor; cmd.message(N_("Mark off")); break; @@ -976,7 +976,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_MARK_ON: bv->beforeChange(this); selection.mark(true); - update(bv, false); + update(false); selection.cursor = cursor; cmd.message(N_("Mark on")); break; @@ -995,32 +995,32 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) break; case LFUN_UPCASE_WORD: - update(bv, false); - changeCase(*bv, LyXText::text_uppercase); + update(false); + changeCase(LyXText::text_uppercase); if (inset_owner) bv->updateInset(inset_owner, true); update(bv); break; case LFUN_LOWCASE_WORD: - update(bv, false); - changeCase(*bv, LyXText::text_lowercase); + update(false); + changeCase(LyXText::text_lowercase); if (inset_owner) bv->updateInset(inset_owner, true); - update(bv); + update(); break; case LFUN_CAPITALIZE_WORD: - update(bv, false); - changeCase(*bv, LyXText::text_capitalization); + update(false); + changeCase(LyXText::text_capitalization); if (inset_owner) bv->updateInset(inset_owner, true); update(bv); break; case LFUN_TRANSPOSE_CHARS: - update(bv, false); - transposeChars(*bv); + update(false); + transposeChars(); if (inset_owner) bv->updateInset(inset_owner, true); update(bv); @@ -1032,40 +1032,40 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) // clear the selection bv->toggleSelection(); clearSelection(); - update(bv, false); - pasteSelection(bv); + update(false); + pasteSelection(); clearSelection(); // bug 393 - update(bv, false); + update(false); update(bv); bv->switchKeyMap(); break; case LFUN_CUT: bv->hideCursor(); - update(bv, false); + update(false); cutSelection(bv, true); update(bv); cmd.message(_("Cut")); break; case LFUN_COPY: - copySelection(bv); + copySelection(); cmd.message(_("Copy")); break; case LFUN_BEGINNINGBUFSEL: if (inset_owner) return UNDISPATCHED; - update(bv, false); - cursorTop(bv); + update(false); + cursorTop(); finishChange(bv, true); break; case LFUN_ENDBUFSEL: if (inset_owner) return UNDISPATCHED; - update(bv, false); - cursorBottom(bv); + update(false); + cursorBottom(); finishChange(bv, true); break; @@ -1082,7 +1082,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) lyxerr << "SETXY: Could not parse coordinates in '" << cmd.argument << std::endl; else - setCursorFromCoordinates(bv, x, y); + setCursorFromCoordinates(x, y); break; } @@ -1149,8 +1149,8 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) if (change_layout) { bv->hideCursor(); current_layout = layout; - update(bv, false); - setLayout(bv, layout); + update(false); + setLayout(layout); bv->owner()->setLayout(layout); update(bv); bv->switchKeyMap(); @@ -1168,9 +1168,9 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) string const clip = bv->getClipboard(); if (!clip.empty()) { if (cmd.argument == "paragraph") - insertStringAsParagraphs(bv, clip); + insertStringAsParagraphs(clip); else - insertStringAsLines(bv, clip); + insertStringAsLines(clip); clearSelection(); update(bv); } @@ -1178,11 +1178,11 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) } case LFUN_GOTOERROR: - gotoInset(bv, Inset::ERROR_CODE, false); + gotoInset(Inset::ERROR_CODE, false); break; case LFUN_GOTONOTE: - gotoInset(bv, Inset::NOTE_CODE, false); + gotoInset(Inset::NOTE_CODE, false); break; case LFUN_REFERENCE_GOTO: @@ -1190,7 +1190,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) vector tmp; tmp.push_back(Inset::LABEL_CODE); tmp.push_back(Inset::REF_CODE); - gotoInset(bv, tmp, true); + gotoInset(tmp, true); break; } @@ -1230,8 +1230,8 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) ::strftime(datetmp, 32, arg.c_str(), now_tm); for (int i = 0; i < datetmp_len; i++) { - insertChar(bv, datetmp[i]); - update(bv, true); + insertChar(datetmp[i]); + update(true); } selection.cursor = cursor; moveCursorUpdate(bv, false); @@ -1241,20 +1241,20 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_MOUSE_TRIPLE: if (!bv->buffer()) break; - if (isTopLevel() && bv->theLockingInset()) + if (!isInInset() && bv->theLockingInset()) break; if (cmd.button() == mouse_button::button1) { - if (isTopLevel()) { + if (!isInInset()) { bv->screen().hideCursor(); bv->screen().toggleSelection(this, bv); } - cursorHome(bv); + cursorHome(); selection.cursor = cursor; - cursorEnd(bv); - setSelection(bv); - if (isTopLevel()) + cursorEnd(); + setSelection(); + if (!isInInset()) bv->screen().toggleSelection(this, bv, false); - update(bv, false); + update(false); bv->haveSelection(selection.set()); } break; @@ -1262,18 +1262,18 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_MOUSE_DOUBLE: if (!bv->buffer()) break; - if (isTopLevel() && bv->theLockingInset()) + if (!isInInset() && bv->theLockingInset()) break; if (cmd.button() == mouse_button::button1) { - if (isTopLevel()) { + if (!isInInset()) { bv->screen().hideCursor(); bv->screen().toggleSelection(this, bv); - selectWord(bv, LyXText::WHOLE_WORD_STRICT); + selectWord(LyXText::WHOLE_WORD_STRICT); bv->screen().toggleSelection(this, bv, false); } else { - selectWord(bv, LyXText::WHOLE_WORD_STRICT); + selectWord(LyXText::WHOLE_WORD_STRICT); } - update(bv, false); + update(false); bv->haveSelection(selection.set()); } break; @@ -1316,7 +1316,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) bv->screen().hideCursor(); Row * cursorrow = bv->text->cursor.row(); - bv->text->setCursorFromCoordinates(bv, cmd.x, cmd.y + bv->text->top_y()); + bv->text->setCursorFromCoordinates(cmd.x, cmd.y + bv->text->top_y()); #if 0 // sorry for this but I have a strange error that the y value jumps at // a certain point. This seems like an error in my xforms library or @@ -1329,15 +1329,15 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) // This is to allow jumping over large insets if (cursorrow == bv->text->cursor.row()) { if (cmd.y >= bv->workHeight()) - bv->text->cursorDown(bv, false); + bv->text->cursorDown(false); else if (cmd.y < 0) - bv->text->cursorUp(bv, false); + bv->text->cursorUp(false); } // Maybe an empty line was deleted if (!bv->text->selection.set()) bv->update(bv->text, BufferView::UPDATE); - bv->text->setSelection(bv); + bv->text->setSelection(); bv->screen().toggleToggle(bv->text, bv); bv->fitCursor(); bv->showCursor(); @@ -1365,7 +1365,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) int x = cmd.x; int y = cmd.y; - Inset * inset_hit = bv->text->checkInsetHit(bv, x, y); + Inset * inset_hit = bv->text->checkInsetHit(x, y); // Middle button press pastes if we have a selection // We do this here as if the selection was inside an inset @@ -1399,7 +1399,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) // Clear the selection bv->screen().toggleSelection(bv->text, bv); bv->text->clearSelection(); - bv->text->fullRebreak(bv); + bv->text->fullRebreak(); bv->update(); bv->updateScrollbar(); @@ -1428,7 +1428,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) } if (!inset_hit) // otherwise it was already set in checkInsetHit(...) - bv->text->setCursorFromCoordinates(bv, x, y + screen_first); + bv->text->setCursorFromCoordinates(x, y + screen_first); finishUndo(); bv->text->selection.cursor = bv->text->cursor; bv->text->cursor.x_fix(bv->text->cursor.x()); @@ -1465,7 +1465,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) // inset, inset_hit is 0, and inset_x == x, inset_y == y. int x = cmd.x; int y = cmd.y; - Inset * inset_hit = bv->text->checkInsetHit(bv, x, y); + Inset * inset_hit = bv->text->checkInsetHit(x, y); if (bv->theLockingInset()) { // We are in inset locking mode. @@ -1549,7 +1549,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) if (lyxrc.auto_region_delete) { if (selection.set()) { - cutSelection(bv, false, false); + cutSelection(false, false); update(bv); } bv->haveSelection(false); diff --git a/src/trans_mgr.C b/src/trans_mgr.C index 13561a04ff..4ea10090b0 100644 --- a/src/trans_mgr.C +++ b/src/trans_mgr.C @@ -255,7 +255,7 @@ void TransManager::insertVerbatim(string const & str, LyXText * text) string::size_type const l = str.length(); for (string::size_type i = 0; i < l; ++i) { - text->insertChar(current_view, str[i]); + text->insertChar(str[i]); } } @@ -274,7 +274,7 @@ void TransManager::insert(string const & str, LyXText * text) // Could not find an encoding InsetLatexAccent ins(str); if (ins.canDisplay()) { - text->insertInset(current_view, + text->insertInset( new InsetLatexAccent(ins)); } else { insertVerbatim(str, text); diff --git a/src/undo_funcs.C b/src/undo_funcs.C index 1f4243789f..c61b888e4f 100644 --- a/src/undo_funcs.C +++ b/src/undo_funcs.C @@ -66,7 +66,7 @@ void finishNoUndo(BufferView * bv) freezeUndo(); bv->unlockInset(bv->theLockingInset()); finishUndo(); - bv->text->postPaint(*bv, 0); + bv->text->postPaint(0); unFreezeUndo(); } @@ -96,7 +96,7 @@ bool textHandleUndo(BufferView * bv, Undo & undo) num = -1; } } - t->setCursorIntern(bv, firstUndoParagraph(bv, num), 0); + t->setCursorIntern(firstUndoParagraph(bv, num), 0); } // replace the paragraphs with the undo informations @@ -186,9 +186,9 @@ bool textHandleUndo(BufferView * bv, Undo & undo) if (before) { // if we have a par before the undopar Inset * it = before->inInset(); if (it) - it->getLyXText(bv)->setCursorIntern(bv, before, 0); + it->getLyXText(bv)->setCursorIntern(before, 0); else - bv->text->setCursorIntern(bv, before, 0); + bv->text->setCursorIntern(before, 0); } // we are not ready for this we cannot set the cursor for a paragraph // which is not already in a row of LyXText!!! @@ -212,7 +212,7 @@ bool textHandleUndo(BufferView * bv, Undo & undo) if (undopar) it = static_cast(undopar->inInset()); if (it) { - it->getLyXText(bv)->redoParagraphs(bv, + it->getLyXText(bv)->redoParagraphs( it->getLyXText(bv)->cursor, endpar); if (tmppar) { @@ -224,19 +224,19 @@ bool textHandleUndo(BufferView * bv, Undo & undo) } else { t = bv->text; } - t->setCursorIntern(bv, tmppar, undo.cursor_pos); + t->setCursorIntern(tmppar, undo.cursor_pos); // clear any selection and set the selection cursor // for an evt. new selection. t->clearSelection(); t->selection.cursor = t->cursor; - t->updateCounters(bv); + t->updateCounters(); bv->fitCursor(); } bv->updateInset(it, false); - bv->text->setCursorIntern(bv, bv->text->cursor.par(), + bv->text->setCursorIntern(bv->text->cursor.par(), bv->text->cursor.pos()); } else { - bv->text->redoParagraphs(bv, bv->text->cursor, endpar); + bv->text->redoParagraphs(bv->text->cursor, endpar); if (tmppar) { LyXText * t; Inset * it = tmppar->inInset(); @@ -246,12 +246,12 @@ bool textHandleUndo(BufferView * bv, Undo & undo) } else { t = bv->text; } - t->setCursorIntern(bv, tmppar, undo.cursor_pos); + t->setCursorIntern(tmppar, undo.cursor_pos); // clear any selection and set the selection cursor // for an evt. new selection. t->clearSelection(); t->selection.cursor = t->cursor; - t->updateCounters(bv); + t->updateCounters(); } } @@ -266,7 +266,7 @@ bool textHandleUndo(BufferView * bv, Undo & undo) } finishUndo(); - bv->text->postPaint(*bv, 0); + bv->text->postPaint(0); return true; }