This changes public BufferView::text into a private BufferView::text_ and removes a bit of unused code from the insets (insetInInsetY, InsetText::textwidth_/cpos/cpar/crow)
Should be uncontroversial. Andre'
? .lyxlayout.C.swp ? 0.diff ? 1.diff ? 2.diff ? frontends/controllers/ControlVSpace.C ? frontends/controllers/ControlVSpace.h ? frontends/xforms/FormVSpace.C ? frontends/xforms/FormVSpace.h ? frontends/xforms/forms/form_vspace.fd ? insets/2 ? insets/insetvspace.C ? insets/insetvspace.h Index: BufferView.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v retrieving revision 1.210 diff -u -p -r1.210 BufferView.C --- BufferView.C 13 Nov 2003 13:43:35 -0000 1.210 +++ BufferView.C 28 Nov 2003 08:25:56 -0000 @@ -60,13 +60,13 @@ BufferView::BufferView(LyXView * owner, : pimpl_(new Pimpl(this, owner, xpos, ypos, width, height)), x_target_(0) { - text = 0; + text_ = 0; } BufferView::~BufferView() { - delete text; + delete text_; delete pimpl_; } @@ -256,10 +256,10 @@ bool BufferView::insertLyXFile(string co string const fname = MakeAbsPath(filen); - text->clearSelection(); - text->breakParagraph(buffer()->paragraphs()); + text_->clearSelection(); + text_->breakParagraph(buffer()->paragraphs()); - bool res = buffer()->readFile(fname, text->cursorPar()); + bool res = buffer()->readFile(fname, text_->cursorPar()); resize(); return res; } @@ -290,9 +290,9 @@ void BufferView::setCursorFromRow(int ro buffer()->texrow().getIdFromRow(row, tmpid, tmppos); if (tmpid == -1) - text->setCursor(0, 0); + text_->setCursor(0, 0); else - text->setCursor(buffer()->getParFromID(tmpid).pit(), tmppos); + text_->setCursor(buffer()->getParFromID(tmpid).pit(), tmppos); } @@ -309,11 +309,11 @@ void BufferView::gotoLabel(string const vector<string> labels; it->getLabelList(*buffer(), labels); if (find(labels.begin(),labels.end(),label) != labels.end()) { - text->clearSelection(); - text->setCursor( - std::distance(text->ownerParagraphs().begin(), it.getPar()), + text_->clearSelection(); + text_->setCursor( + std::distance(text_->ownerParagraphs().begin(), it.getPar()), it.getPos()); - text->selection.cursor = text->cursor; + text_->selection.cursor = text_->cursor; update(); return; } @@ -327,7 +327,7 @@ void BufferView::undo() return; owner()->message(_("Undo")); - text->clearSelection(); + text_->clearSelection(); if (!textUndo(this)) owner()->message(_("No further undo information")); update(); @@ -341,7 +341,7 @@ void BufferView::redo() return; owner()->message(_("Redo")); - text->clearSelection(); + text_->clearSelection(); if (!textRedo(this)) owner()->message(_("No further redo information")); update(); @@ -354,14 +354,14 @@ void BufferView::replaceWord(string cons if (!available()) return; - LyXText * text = getLyXText(); + LyXText * t = getLyXText(); - text->replaceSelectionWithString(replacestring); - text->setSelectionRange(replacestring.length()); + t->replaceSelectionWithString(replacestring); + t->setSelectionRange(replacestring.length()); // Go back so that replacement string is also spellchecked for (string::size_type i = 0; i < replacestring.length() + 1; ++i) - text->cursorLeft(this); + t->cursorLeft(this); // FIXME: should be done through LFUN buffer()->markDirty(); @@ -410,13 +410,13 @@ Language const * BufferView::getParentLa Encoding const * BufferView::getEncoding() const { - LyXText * text = getLyXText(); - if (!text) + LyXText * t = getLyXText(); + if (!t) return 0; - return text->cursorPar()->getFont( + return t->cursorPar()->getFont( buffer()->params(), - text->cursor.pos(), - outerFont(text->cursorPar(), text->ownerParagraphs()) + t->cursor.pos(), + outerFont(t->cursorPar(), t->ownerParagraphs()) ).language()->encoding(); } Index: BufferView.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.h,v retrieving revision 1.152 diff -u -p -r1.152 BufferView.h --- BufferView.h 10 Nov 2003 13:23:08 -0000 1.152 +++ BufferView.h 28 Nov 2003 08:25:56 -0000 @@ -104,11 +104,6 @@ public: /// return the current change at the cursor Change const getCurrentChange(); - /** - * This holds the mapping between buffer paragraphs and screen rows. - * This should be private...but not yet. (Lgb) - */ - LyXText * text; /// return the lyxtext we are using LyXText * getLyXText() const; @@ -193,12 +188,21 @@ public: LCursor const & cursor() const; /// UpdatableInset * innerInset() const; + /// + LyXText * text() const { return text_; } + /// + void setText(LyXText * t) { text_ = t; } private: + /// struct Pimpl; + /// friend struct BufferView::Pimpl; - + /// Pimpl * pimpl_; + + /// This holds the mapping between buffer paragraphs and screen rows. + LyXText * text_; /** * The target x position of the cursor. This is used for when Index: BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.468 diff -u -p -r1.468 BufferView_pimpl.C --- BufferView_pimpl.C 22 Nov 2003 14:44:54 -0000 1.468 +++ BufferView_pimpl.C 28 Nov 2003 08:25:56 -0000 @@ -287,8 +287,8 @@ void BufferView::Pimpl::buffer(Buffer * << b << ')' << endl; if (buffer_) { disconnectBuffer(); - delete bv_->text; - bv_->text = 0; + delete bv_->text(); + bv_->setText(0); } // set current buffer @@ -309,7 +309,7 @@ void BufferView::Pimpl::buffer(Buffer * connectBuffer(*buffer_); // If we don't have a text object for this, we make one - if (bv_->text == 0) + if (bv_->text() == 0) resizeCurrentBuffer(); // FIXME: needed when ? @@ -333,7 +333,7 @@ void BufferView::Pimpl::buffer(Buffer * // Don't forget to update the Layout if (buffer_) - owner_->setLayout(bv_->text->cursorPar()->layout()->name()); + owner_->setLayout(bv_->text()->cursorPar()->layout()->name()); if (lyx::graphics::Previews::activated() && buffer_) lyx::graphics::Previews::get().generateBufferPreviews(*buffer_); @@ -354,7 +354,7 @@ bool BufferView::Pimpl::fitCursor() void BufferView::Pimpl::redoCurrentBuffer() { lyxerr[Debug::INFO] << "BufferView::redoCurrentBuffer" << endl; - if (buffer_ && bv_->text) { + if (buffer_ && bv_->text()) { resizeCurrentBuffer(); updateScrollbar(); owner_->updateLayoutChoice(); @@ -380,37 +380,37 @@ void BufferView::Pimpl::resizeCurrentBuf owner_->message(_("Formatting document...")); - if (bv_->text) { - par = bv_->text->cursor.par(); - pos = bv_->text->cursor.pos(); - selstartpar = bv_->text->selection.start.par(); - selstartpos = bv_->text->selection.start.pos(); - selendpar = bv_->text->selection.end.par(); - selendpos = bv_->text->selection.end.pos(); - selection = bv_->text->selection.set(); - mark_set = bv_->text->selection.mark(); - bv_->text->fullRebreak(); + if (bv_->text()) { + par = bv_->text()->cursor.par(); + pos = bv_->text()->cursor.pos(); + selstartpar = bv_->text()->selection.start.par(); + selstartpos = bv_->text()->selection.start.pos(); + selendpar = bv_->text()->selection.end.par(); + selendpos = bv_->text()->selection.end.pos(); + selection = bv_->text()->selection.set(); + mark_set = bv_->text()->selection.mark(); + bv_->text()->fullRebreak(); update(); } else { - bv_->text = new LyXText(bv_, 0, false, bv_->buffer()->paragraphs()); - bv_->text->init(bv_); + bv_->setText(new LyXText(bv_, 0, false, bv_->buffer()->paragraphs())); + bv_->text()->init(bv_); } if (par != -1) { - bv_->text->selection.set(true); + bv_->text()->selection.set(true); // At this point just to avoid the Delete-Empty-Paragraph- // Mechanism when setting the cursor. - bv_->text->selection.mark(mark_set); + bv_->text()->selection.mark(mark_set); if (selection) { - bv_->text->setCursor(selstartpar, selstartpos); - bv_->text->selection.cursor = bv_->text->cursor; - bv_->text->setCursor(selendpar, selendpos); - bv_->text->setSelection(); - bv_->text->setCursor(par, pos); + bv_->text()->setCursor(selstartpar, selstartpos); + bv_->text()->selection.cursor = bv_->text()->cursor; + bv_->text()->setCursor(selendpar, selendpos); + bv_->text()->setSelection(); + bv_->text()->setCursor(par, pos); } else { - bv_->text->setCursor(par, pos); - bv_->text->selection.cursor = bv_->text->cursor; - bv_->text->selection.set(false); + bv_->text()->setCursor(par, pos); + bv_->text()->selection.cursor = bv_->text()->cursor; + bv_->text()->selection.set(false); } } @@ -428,13 +428,13 @@ void BufferView::Pimpl::resizeCurrentBuf void BufferView::Pimpl::updateScrollbar() { - if (!bv_->text) { + if (!bv_->text()) { lyxerr[Debug::GUI] << "no text in updateScrollbar" << endl; workarea().setScrollbarParams(0, 0, 0); return; } - LyXText const & t = *bv_->text; + LyXText const & t = *bv_->text(); lyxerr[Debug::GUI] << "Updating scrollbar: h " << t.height << ", top_y() " << top_y() << ", default height " << defaultRowHeight() << endl; @@ -462,7 +462,7 @@ void BufferView::Pimpl::scrollDocView(in int const first = top_y() + height; int const last = top_y() + workarea().workHeight() - height; - LyXText * text = bv_->text; + LyXText * text = bv_->text(); if (text->cursor.y() < first) text->setCursorFromCoordinates(0, first); else if (text->cursor.y() > last) @@ -477,7 +477,7 @@ void BufferView::Pimpl::scroll(int lines if (!buffer_) return; - LyXText const * t = bv_->text; + LyXText const * t = bv_->text(); int const line_height = defaultRowHeight(); // The new absolute coordinate @@ -523,15 +523,15 @@ void BufferView::Pimpl::selectionRequest LyXText * text = bv_->getLyXText(); if (text->selection.set() && - (!bv_->text->xsel_cache.set() || - text->selection.start != bv_->text->xsel_cache.start || - text->selection.end != bv_->text->xsel_cache.end)) + (!bv_->text()->xsel_cache.set() || + text->selection.start != bv_->text()->xsel_cache.start || + text->selection.end != bv_->text()->xsel_cache.end)) { - bv_->text->xsel_cache = text->selection; + bv_->text()->xsel_cache = text->selection; sel = text->selectionAsString(*bv_->buffer(), false); } else if (!text->selection.set()) { sel = string(); - bv_->text->xsel_cache.set(false); + bv_->text()->xsel_cache.set(false); } if (!sel.empty()) { workarea().putClipboard(sel); @@ -544,7 +544,7 @@ void BufferView::Pimpl::selectionLost() if (available()) { screen().hideCursor(); bv_->getLyXText()->clearSelection(); - bv_->text->xsel_cache.set(false); + bv_->text()->xsel_cache.set(false); } } @@ -590,7 +590,7 @@ void BufferView::Pimpl::update() getParsInRange(buffer_->paragraphs(), top_y(), top_y() + workarea().workHeight(), beg, end); - bv_->text->redoParagraphs(beg, end); + bv_->text()->redoParagraphs(beg, end); bv_->getLyXText()->redoCursor(); updateScrollbar(); } @@ -613,7 +613,7 @@ void BufferView::Pimpl::cursorToggle() bool BufferView::Pimpl::available() const { - return buffer_ && bv_->text; + return buffer_ && bv_->text(); } @@ -637,8 +637,8 @@ void BufferView::Pimpl::savePosition(uns if (i >= saved_positions_num) return; saved_positions[i] = Position(buffer_->fileName(), - bv_->text->cursorPar()->id(), - bv_->text->cursor.pos()); + bv_->text()->cursorPar()->id(), + bv_->text()->cursor.pos()); if (i > 0) owner_->message(bformat(_("Saved bookmark %1$s"), tostr(i))); } @@ -651,7 +651,7 @@ void BufferView::Pimpl::restorePosition( string const fname = saved_positions[i].filename; - bv_->text->clearSelection(); + bv_->text()->clearSelection(); if (fname != buffer_->fileName()) { Buffer * b = 0; @@ -669,7 +669,7 @@ void BufferView::Pimpl::restorePosition( if (par == buffer_->par_iterator_end()) return; - bv_->text->setCursor(par.pit(), + bv_->text()->setCursor(par.pit(), min(par->size(), saved_positions[i].par_pos)); if (i > 0) @@ -701,7 +701,7 @@ void BufferView::Pimpl::switchKeyMap() void BufferView::Pimpl::center() { - LyXText * text = bv_->text; + LyXText * text = bv_->text(); text->clearSelection(); int const half_height = workarea().workHeight() / 2; @@ -843,7 +843,7 @@ void BufferView::Pimpl::trackChanges() buf->undostack().clear(); } else { update(); - bv_->text->setCursor(0, 0); + bv_->text()->setCursor(0, 0); #warning changes FIXME bool found = lyx::find::findNextChange(bv_); if (found) { @@ -867,7 +867,7 @@ namespace { InsetOld * insetFromCoords(BufferView * bv, int x, int y) { - LyXText * text = bv->text; + LyXText * text = bv->text(); InsetOld * inset = 0; theTempCursor = LCursor(bv); while (true) { @@ -1208,7 +1208,7 @@ bool BufferView::Pimpl::dispatch(FuncReq break; case LFUN_ACCEPT_ALL_CHANGES: { - bv_->text->setCursor(0, 0); + bv_->text()->setCursor(0, 0); #warning FIXME changes while (lyx::find::findNextChange(bv_)) bv_->getLyXText()->acceptChange(); @@ -1217,7 +1217,7 @@ bool BufferView::Pimpl::dispatch(FuncReq } case LFUN_REJECT_ALL_CHANGES: { - bv_->text->setCursor(0, 0); + bv_->text()->setCursor(0, 0); #warning FIXME changes while (lyx::find::findNextChange(bv_)) bv_->getLyXText()->rejectChange(); @@ -1262,25 +1262,25 @@ bool BufferView::Pimpl::insertInset(Inse #endif // not quite sure if we want this... - bv_->text->recUndo(bv_->text->cursor.par()); + bv_->text()->recUndo(bv_->text()->cursor.par()); freezeUndo(); - bv_->text->clearSelection(); + bv_->text()->clearSelection(); if (!lout.empty()) { - bv_->text->breakParagraph(bv_->buffer()->paragraphs()); + bv_->text()->breakParagraph(bv_->buffer()->paragraphs()); - if (!bv_->text->cursorPar()->empty()) { - bv_->text->cursorLeft(bv_); - bv_->text->breakParagraph(bv_->buffer()->paragraphs()); + if (!bv_->text()->cursorPar()->empty()) { + bv_->text()->cursorLeft(bv_); + bv_->text()->breakParagraph(bv_->buffer()->paragraphs()); } string lres = lout; LyXTextClass const & tclass = buffer_->params().getLyXTextClass(); bool hasLayout = tclass.hasLayout(lres); - bv_->text->setLayout(hasLayout ? lres : tclass.defaultLayoutName()); + bv_->text()->setLayout(hasLayout ? lres : tclass.defaultLayoutName()); - bv_->text->setParagraph( + bv_->text()->setParagraph( VSpace(VSpace::NONE), VSpace(VSpace::NONE), Spacing(), LYX_ALIGN_LAYOUT, @@ -1297,7 +1297,7 @@ bool BufferView::Pimpl::ChangeInsets(Ins string const & from, string const & to) { bool need_update = false; - LyXCursor cursor = bv_->text->cursor; + LyXCursor cursor = bv_->text()->cursor; LyXCursor tmpcursor = cursor; cursor.par(tmpcursor.par()); cursor.pos(tmpcursor.pos()); @@ -1324,12 +1324,12 @@ bool BufferView::Pimpl::ChangeInsets(Ins // The test it.size()==1 was needed to prevent crashes. // How to set the cursor correctly when it.size()>1 ?? if (it.size() == 1) { - bv_->text->setCursorIntern(bv_->text->parOffset(it.pit()), 0); - bv_->text->redoParagraph(bv_->text->cursorPar()); + bv_->text()->setCursorIntern(bv_->text()->parOffset(it.pit()), 0); + bv_->text()->redoParagraph(bv_->text()->cursorPar()); } } } - bv_->text->setCursorIntern(cursor.par(), cursor.pos()); + bv_->text()->setCursorIntern(cursor.par(), cursor.pos()); return need_update; } Index: cursor.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v retrieving revision 1.25 diff -u -p -r1.25 cursor.C --- cursor.C 22 Nov 2003 14:44:55 -0000 1.25 +++ cursor.C 28 Nov 2003 08:25:56 -0000 @@ -101,8 +101,8 @@ DispatchResult LCursor::dispatch(FuncReq break; } } - lyxerr << "trying to dispatch to main text " << bv_->text << endl; - DispatchResult res = bv_->text->dispatch(cmd); + lyxerr << "trying to dispatch to main text " << bv_->text() << endl; + DispatchResult res = bv_->text()->dispatch(cmd); lyxerr << " result: " << res.val() << endl; if (!res.dispatched()) { @@ -160,7 +160,7 @@ LyXText * LCursor::innerText() const if (data_[i].text()) return data_[i].text(); } - return bv_->text; + return bv_->text(); } @@ -187,8 +187,8 @@ void LCursor::getDim(int & asc, int & de void LCursor::getPos(int & x, int & y) const { if (data_.empty()) { - x = bv_->text->cursor.x(); - y = bv_->text->cursor.y(); + x = bv_->text()->cursor.x(); + y = bv_->text()->cursor.y(); // y -= bv_->top_y(); } else { // Would be nice to clean this up to make some understandable sense... @@ -201,7 +201,6 @@ void LCursor::getPos(int & x, int & y) c // inset.top_baseline, so getCursor() returns an old value. // Ugly as you like. //inset->getCursorPos(bv_, x, y); - //y = inset->insetInInsetY() + bv_->text->cursor.y(); inset->getCursorPos(x, y); x += inset->x(); y += cached_y_; Index: iterators.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/iterators.C,v retrieving revision 1.32 diff -u -p -r1.32 iterators.C --- iterators.C 22 Nov 2003 14:44:55 -0000 1.32 +++ iterators.C 28 Nov 2003 08:25:56 -0000 @@ -153,7 +153,7 @@ LyXText * ParIterator::text(BufferView * { //lyxerr << "positions.size: " << pimpl_->positions.size() << std::endl; if (pimpl_->positions.size() <= 1) - return bv->text; + return bv->text(); ParPosition const & pos = pimpl_->positions[pimpl_->positions.size() - 2]; return (*pos.it)->inset->getText(*pos.index); Index: lyx_cb.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.C,v retrieving revision 1.231 diff -u -p -r1.231 lyx_cb.C --- lyx_cb.C 10 Nov 2003 09:06:34 -0000 1.231 +++ lyx_cb.C 28 Nov 2003 08:25:57 -0000 @@ -353,8 +353,8 @@ void InsertAsciiFile(BufferView * bv, st return; // clear the selection - if (bv->text == bv->getLyXText()) - bv->text->clearSelection(); + if (bv->text() == bv->getLyXText()) + bv->text()->clearSelection(); if (asParagraph) bv->getLyXText()->insertStringAsParagraphs(tmpstr); else Index: lyxfind.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfind.C,v retrieving revision 1.59 diff -u -p -r1.59 lyxfind.C --- lyxfind.C 24 Nov 2003 20:03:47 -0000 1.59 +++ lyxfind.C 28 Nov 2003 08:25:57 -0000 @@ -159,8 +159,7 @@ int replaceAll(BufferView * bv, if (!searchAllowed(bv, searchstr) || buf.isReadonly()) return 0; - recordUndo(Undo::ATOMIC, bv->text, 0, - buf.paragraphs().size() - 1); + recordUndo(Undo::ATOMIC, bv->text(), 0, buf.paragraphs().size() - 1); PosIterator cur = buf.pos_iterator_begin(); PosIterator const end = buf.pos_iterator_end(); @@ -181,7 +180,7 @@ int replaceAll(BufferView * bv, } PosIterator beg = buf.pos_iterator_begin(); - bv->text->init(bv); + bv->text()->init(bv); put_selection_at(bv, beg, 0, false); if (num) buf.markDirty(); @@ -201,8 +200,7 @@ bool stringSelected(BufferView * bv, string const & str1 = searchstr; string const str2 = text->selectionAsString(*bv->buffer(), false); - if ((cs && str1 != str2) - || lowercase(str1) != lowercase(str2)) { + if ((cs && str1 != str2) || lowercase(str1) != lowercase(str2)) { find(bv, searchstr, cs, mw, fw); return false; } Index: lyxtext.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v retrieving revision 1.262 diff -u -p -r1.262 lyxtext.h --- lyxtext.h 26 Nov 2003 09:48:19 -0000 1.262 +++ lyxtext.h 28 Nov 2003 08:25:57 -0000 @@ -128,6 +128,8 @@ public: void fullRebreak(); /// compute text metrics void metrics(MetricsInfo & mi, Dimension & dim); + /// draw text (only used for insets) + void draw(PainterInfo & pi, int x, int y) const; /// DispatchResult dispatch(FuncRequest const & cmd); @@ -418,8 +420,8 @@ public: ParagraphList * paragraphs_; /// absolute document pixel coordinates of this LyXText - int xo_; - int yo_; + mutable int xo_; + mutable int yo_; private: Index: output_plaintext.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/output_plaintext.C,v retrieving revision 1.1 diff -u -p -r1.1 output_plaintext.C --- output_plaintext.C 5 Nov 2003 12:06:03 -0000 1.1 +++ output_plaintext.C 28 Nov 2003 08:25:57 -0000 @@ -144,7 +144,7 @@ void asciiParagraph(Buffer const & buf, //-- // we should probably change to the paragraph language in the - // gettext here (if possible) so that strings are outputted in + // gettext here (if possible) so that strings are output in // the correct language! (20012712 Jug) //-- switch (ltype) { @@ -152,6 +152,7 @@ void asciiParagraph(Buffer const & buf, case 4: // (Sub)Paragraph case 5: // Description break; + case 6: // Abstract if (runparams.linelen > 0) { os << _("Abstract") << "\n\n"; @@ -162,6 +163,7 @@ void asciiParagraph(Buffer const & buf, currlinelen += abst.length(); } break; + case 7: // Bibliography if (!ref_printed) { if (runparams.linelen > 0) { @@ -172,17 +174,16 @@ void asciiParagraph(Buffer const & buf, os << refs; currlinelen += refs.length(); } - ref_printed = true; } break; - default: - { - string const parlab = par.params().labelString(); - os << parlab << ' '; - currlinelen += parlab.length() + 1; + + default: { + string const label = par.params().labelString(); + os << label << ' '; + currlinelen += label.length() + 1; + break; } - break; } } @@ -202,59 +203,52 @@ void asciiParagraph(Buffer const & buf, for (pos_type i = 0; i < par.size(); ++i) { char c = par.getUChar(buf.params(), i); switch (c) { - case Paragraph::META_INSET: - { + case Paragraph::META_INSET: { InsetOld const * inset = par.getInset(i); - if (inset) { - if (runparams.linelen > 0) { - os << word; - currlinelen += word.length(); - word.erase(); - } - if (inset->plaintext(buf, os, runparams)) { - // to be sure it breaks paragraph - currlinelen += runparams.linelen; - } + if (runparams.linelen > 0) { + os << word; + currlinelen += word.length(); + word.erase(); } + if (inset->plaintext(buf, os, runparams)) { + // to be sure it breaks paragraph + currlinelen += runparams.linelen; + } + break; } - break; - default: - if (c == ' ') { - if (runparams.linelen > 0 && - currlinelen + word.length() > runparams.linelen - 10) { - os << "\n"; - pair<int, string> p = addDepth(depth, ltype_depth); - os << p.second; - currlinelen = p.first; - } + case ' ': + if (runparams.linelen > 0 && + currlinelen + word.length() > runparams.linelen - 10) { + os << "\n"; + pair<int, string> p = addDepth(depth, ltype_depth); + os << p.second; + currlinelen = p.first; + } - os << word << ' '; - currlinelen += word.length() + 1; - word.erase(); + os << word << ' '; + currlinelen += word.length() + 1; + word.erase(); + break; - } else { - if (c != '\0') { - word += c; - } else { - lyxerr[Debug::INFO] << - "writeAsciiFile: NULL char in structure." << endl; - } - if ((runparams.linelen > 0) && - (currlinelen + word.length()) > runparams.linelen) - { - os << "\n"; - - pair<int, string> p = - addDepth(depth, ltype_depth); - os << p.second; - currlinelen = p.first; - } + + case '\0': + lyxerr[Debug::INFO] << + "writeAsciiFile: NULL char in structure." << endl; + break; + + default: + word += c; + if (runparams.linelen > 0 && + currlinelen + word.length() > runparams.linelen) + { + os << "\n"; + pair<int, string> p = addDepth(depth, ltype_depth); + os << p.second; + currlinelen = p.first; } break; } } os << word; } - - Index: rowpainter.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v retrieving revision 1.100 diff -u -p -r1.100 rowpainter.C --- rowpainter.C 25 Nov 2003 11:17:23 -0000 1.100 +++ rowpainter.C 28 Nov 2003 08:25:57 -0000 @@ -129,7 +129,7 @@ RowPainter::RowPainter(BufferView const x_ += xo_; // background has already been cleared. - if (&text_ == bv_.text) + if (&text_ == bv_.text()) paintBackground(); // paint the selection background @@ -960,15 +960,15 @@ int paintPars(BufferView const & bv, LyX } // namespace anon -int paintText(BufferView & bv) +int paintText(BufferView const & bv) { ParagraphList::iterator pit; - bv.text->getRowNearY(bv.top_y(), pit); - return paintPars(bv, *bv.text, pit, 0, 0, pit->y); + bv.text()->getRowNearY(bv.top_y(), pit); + return paintPars(bv, *bv.text(), pit, 0, 0, pit->y); } -void paintTextInset(BufferView & bv, LyXText & text, int xo, int yo) +void paintTextInset(BufferView const & bv, LyXText const & text, int xo, int yo) { paintPars(bv, text, text.ownerParagraphs().begin(), xo, yo, 0); } Index: rowpainter.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.h,v retrieving revision 1.15 diff -u -p -r1.15 rowpainter.h --- rowpainter.h 27 Aug 2003 14:55:17 -0000 1.15 +++ rowpainter.h 28 Nov 2003 08:25:57 -0000 @@ -21,9 +21,9 @@ class VSpace; int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp); /// paint the rows of the main text, return last drawn y value -int paintText(BufferView & bv); +int paintText(BufferView const & bv); /// paint the rows of a text inset -void paintTextInset(BufferView & bv, LyXText & text, int x, int y); +void paintTextInset(BufferView const & bv, LyXText const & text, int x, int y); #endif // ROWPAINTER_H Index: text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.500 diff -u -p -r1.500 text.C --- text.C 27 Nov 2003 09:22:38 -0000 1.500 +++ text.C 28 Nov 2003 08:25:58 -0000 @@ -1641,6 +1641,15 @@ void LyXText::metrics(MetricsInfo & mi, } +// only used for inset right now. should also be used for main text +void LyXText::draw(PainterInfo & pi, int x, int y) const +{ + xo_ = x; + yo_ = y; + paintTextInset(*bv(), *this, x, y); +} + + bool LyXText::isLastRow(ParagraphList::iterator pit, Row const & row) const { return row.endpos() >= pit->size() Index: text2.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v retrieving revision 1.514 diff -u -p -r1.514 text2.C --- text2.C 27 Nov 2003 09:22:39 -0000 1.514 +++ text2.C 28 Nov 2003 08:25:58 -0000 @@ -506,8 +506,8 @@ void LyXText::clearSelection() TextCursor::clearSelection(); // reset this in the bv()! - if (bv() && bv()->text) - bv()->text->xsel_cache.set(false); + if (bv() && bv()->text()) + bv()->text()->xsel_cache.set(false); } Index: undo.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/undo.C,v retrieving revision 1.29 diff -u -p -r1.29 undo.C --- undo.C 10 Nov 2003 09:06:37 -0000 1.29 +++ undo.C 28 Nov 2003 08:25:58 -0000 @@ -188,7 +188,7 @@ bool performUndoOrRedo(BufferView * bv, text->updateCounters(); // rebreak the entire lyxtext - bv->text->fullRebreak(); + bv->text()->fullRebreak(); pit.lockPath(bv); @@ -292,5 +292,5 @@ void recordUndo(Undo::undo_kind kind, Ly void recordUndo(BufferView * bv, Undo::undo_kind kind) { - recordUndo(kind, bv->text, bv->text->cursor.par()); + recordUndo(kind, bv->text(), bv->text()->cursor.par()); } Index: frontends/screen.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/screen.C,v retrieving revision 1.81 diff -u -p -r1.81 screen.C --- frontends/screen.C 13 Nov 2003 08:50:24 -0000 1.81 +++ frontends/screen.C 28 Nov 2003 08:25:58 -0000 @@ -242,7 +242,7 @@ bool LyXScreen::fitCursor(BufferView * b void LyXScreen::redraw(BufferView & bv) { - greyed_out_ = !bv.text; + greyed_out_ = !bv.text(); if (greyed_out_) { greyOut(); @@ -257,7 +257,7 @@ void LyXScreen::redraw(BufferView & bv) // maybe we have to clear the screen at the bottom int const y2 = workarea().workHeight(); - if (y < y2 && !bv.text->isInInset()) { + if (y < y2 && !bv.text()->isInInset()) { workarea().getPainter().fillRectangle(0, y, workarea().workWidth(), y2 - y, LColor::bottomarea); Index: insets/insetcollapsable.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v retrieving revision 1.215 diff -u -p -r1.215 insetcollapsable.C --- insets/insetcollapsable.C 27 Nov 2003 09:22:40 -0000 1.215 +++ insets/insetcollapsable.C 28 Nov 2003 08:25:58 -0000 @@ -318,12 +318,6 @@ InsetCollapsable::priv_dispatch(FuncRequ } -int InsetCollapsable::insetInInsetY() const -{ - return inset.y() - yo_ + inset.insetInInsetY(); -} - - void InsetCollapsable::validate(LaTeXFeatures & features) const { inset.validate(features); Index: insets/insetcollapsable.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.h,v retrieving revision 1.151 diff -u -p -r1.151 insetcollapsable.h --- insets/insetcollapsable.h 27 Nov 2003 09:22:40 -0000 1.151 +++ insets/insetcollapsable.h 28 Nov 2003 08:25:58 -0000 @@ -61,8 +61,6 @@ public: /// bool isTextInset() const { return true; } /// - int insetInInsetY() const; - /// int latex(Buffer const &, std::ostream &, OutputParams const &) const; /// Index: insets/insetnewline.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetnewline.C,v retrieving revision 1.20 diff -u -p -r1.20 insetnewline.C --- insets/insetnewline.C 5 Nov 2003 12:06:16 -0000 1.20 +++ insets/insetnewline.C 28 Nov 2003 08:25:58 -0000 @@ -89,7 +89,7 @@ void InsetNewline::draw(PainterInfo & pi // hack, and highly dubious lyx::pos_type pos = ownerPar(*pi.base.bv->buffer(), this) .getPositionOfInset(this); - bool const ltr_pos = (pi.base.bv->text->bidi.level(pos) % 2 == 0); + bool const ltr_pos = (pi.base.bv->text()->bidi.level(pos) % 2 == 0); int xp[3]; int yp[3]; Index: insets/insettabular.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v retrieving revision 1.381 diff -u -p -r1.381 insettabular.C --- insets/insettabular.C 27 Nov 2003 09:22:40 -0000 1.381 +++ insets/insettabular.C 28 Nov 2003 08:25:58 -0000 @@ -388,14 +388,6 @@ void InsetTabular::updateLocal(BufferVie } -int InsetTabular::insetInInsetY() const -{ - if (the_locking_inset) - return cursory_ + the_locking_inset->insetInInsetY(); - return 0; -} - - bool InsetTabular::insertInset(BufferView * bv, InsetOld * inset) { return the_locking_inset && the_locking_inset->insertInset(bv, inset); Index: insets/insettabular.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.h,v retrieving revision 1.170 diff -u -p -r1.170 insettabular.h --- insets/insettabular.h 27 Nov 2003 09:22:41 -0000 1.170 +++ insets/insettabular.h 28 Nov 2003 08:25:59 -0000 @@ -80,8 +80,6 @@ public: /// void updateLocal(BufferView *) const; /// - int insetInInsetY() const; - /// bool insertInset(BufferView *, InsetOld *); /// bool insetAllowed(InsetOld::Code code) const; Index: insets/insettext.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v retrieving revision 1.555 diff -u -p -r1.555 insettext.C --- insets/insettext.C 27 Nov 2003 09:22:41 -0000 1.555 +++ insets/insettext.C 28 Nov 2003 08:25:59 -0000 @@ -78,7 +78,6 @@ InsetText::InsetText(BufferParams const frame_color_(LColor::insetframe), text_(0, this, true, paragraphs) { - textwidth_ = 0; // broken paragraphs.begin()->layout(bp.getLyXTextClass().defaultLayout()); if (bp.tracking_changes) paragraphs.begin()->trackChanges(); @@ -102,7 +101,6 @@ void InsetText::operator=(InsetText cons autoBreakRows_ = in.autoBreakRows_; drawFrame_ = in.drawFrame_; frame_color_ = in.frame_color_; - textwidth_ = in.textwidth_; text_ = LyXText(in.text_.bv_owner, this, true, paragraphs); init(); } @@ -218,7 +216,6 @@ void InsetText::read(Buffer const & buf, void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const { //lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << endl; - textwidth_ = mi.base.textwidth; mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET; setViewCache(mi.base.bv); text_.metrics(mi, dim); @@ -236,24 +233,21 @@ void InsetText::draw(PainterInfo & pi, i xo_ = x; yo_ = y; - BufferView * bv = pi.base.bv; Painter & pain = pi.pain; // repaint the background if needed + x += TEXT_TO_INSET_OFFSET; if (backgroundColor() != LColor::background) - clearInset(bv, xo_ + TEXT_TO_INSET_OFFSET, y); + clearInset(pain, x, y); + BufferView * bv = pi.base.bv; bv->hideCursor(); if (!owner()) x += scroll(); - - x += TEXT_TO_INSET_OFFSET; y += bv->top_y() - text_.firstRow()->ascent_of_text(); - text_.xo_ = x; - text_.yo_ = y; - paintTextInset(*bv, text_, x, y); + text_.draw(pi, x, y); if (drawFrame_ == ALWAYS || drawFrame_ == LOCKED) drawFrame(pain, xo_); @@ -271,7 +265,7 @@ void InsetText::drawFrame(Painter & pain } -void InsetText::updateLocal(BufferView * bv, bool /*mark_dirty*/) +void InsetText::updateLocal(BufferView * bv) { if (!bv) return; @@ -286,7 +280,7 @@ void InsetText::updateLocal(BufferView * bv->owner()->updateMenubar(); bv->owner()->updateToolbar(); if (old_par != text_.cursor.par()) { - bv->owner()->setLayout(cpar()->layout()->name()); + bv->owner()->setLayout(text_.cursorPar()->layout()->name()); old_par = text_.cursor.par(); } } @@ -326,7 +320,7 @@ void InsetText::edit(BufferView * bv, bo text_.setCursor(paragraphs.size() - 1, paragraphs.back().size()); sanitizeEmptyText(bv); - updateLocal(bv, false); + updateLocal(bv); bv->updateParagraphDialog(); } @@ -341,7 +335,7 @@ void InsetText::edit(BufferView * bv, in text_.clearSelection(); finishUndo(); - updateLocal(bv, false); + updateLocal(bv); bv->updateParagraphDialog(); } @@ -437,17 +431,12 @@ void InsetText::getCursorPos(int & x, in } -int InsetText::insetInInsetY() const -{ - return 0; -} - - bool InsetText::insertInset(BufferView * bv, InsetOld * inset) { inset->setOwner(this); text_.insertInset(inset); - updateLocal(bv, true); + updateLocal(bv); +#warning should we mark the buffer dirty? return true; } @@ -540,24 +529,6 @@ void InsetText::setFrameColor(LColor_col } -pos_type InsetText::cpos() const -{ - return text_.cursor.pos(); -} - - -ParagraphList::iterator InsetText::cpar() const -{ - return text_.cursorPar(); -} - - -RowList::iterator InsetText::crow() const -{ - return cpar()->getRow(cpos()); -} - - void InsetText::setViewCache(BufferView const * bv) const { if (bv && bv != text_.bv_owner) { @@ -585,15 +556,8 @@ int InsetText::scroll(bool /*recursive*/ } -void InsetText::clearSelection(BufferView *) -{ - text_.clearSelection(); -} - - -void InsetText::clearInset(BufferView * bv, int x, int y) const +void InsetText::clearInset(Painter & pain, int x, int y) const { - Painter & pain = bv->painter(); int w = dim_.wid; int h = dim_.asc + dim_.des; int ty = y - dim_.asc; Index: insets/insettext.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.h,v retrieving revision 1.234 diff -u -p -r1.234 insettext.h --- insets/insettext.h 25 Nov 2003 11:17:27 -0000 1.234 +++ insets/insettext.h 28 Nov 2003 08:25:59 -0000 @@ -59,11 +59,11 @@ public: /// empty inset to empty par, or just mark as erased void clear(bool just_mark_erased); /// - void read(Buffer const &, LyXLex &); + void read(Buffer const & buf, LyXLex & lex); /// - void write(Buffer const &, std::ostream &) const; + void write(Buffer const & buf, std::ostream & os) const; /// - void metrics(MetricsInfo &, Dimension &) const; + void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// @@ -89,8 +89,6 @@ public: /// FIXME, document void getCursorPos(int & x, int & y) const; /// - int insetInInsetY() const; - /// bool insertInset(BufferView *, InsetOld *); /// bool insetAllowed(InsetOld::Code) const; @@ -129,8 +127,6 @@ public: UpdatableInset::scroll(bv, offset); } /// - void clearSelection(BufferView * bv); - /// ParagraphList * getParagraphs(int) const; /// LyXText * getText(int) const; @@ -165,14 +161,12 @@ public: int numParagraphs() const { return 1; } /// mutable ParagraphList paragraphs; -protected: +private: /// DispatchResult priv_dispatch(FuncRequest const &, idx_type &, pos_type &); /// - void updateLocal(BufferView *, bool mark_dirty); - -private: + void updateLocal(BufferView *); /// void init(); // If the inset is empty set the language of the current font to the @@ -183,15 +177,9 @@ private: /// void removeNewlines(); /// - lyx::pos_type cpos() const; - /// - ParagraphList::iterator cpar() const; - /// - RowList::iterator crow() const; - /// void drawFrame(Painter &, int x) const; /// - void clearInset(BufferView *, int start_x, int baseline) const; + void clearInset(Painter &, int x, int y) const; /// void collapseParagraphs(BufferView *); @@ -205,8 +193,6 @@ private: */ int frame_color_; /// - bool no_selection; - /// mutable lyx::paroffset_type old_par; /** to remember old painted frame dimensions to clear it on @@ -216,7 +202,5 @@ private: public: /// mutable LyXText text_; - /// - mutable int textwidth_; }; #endif Index: insets/updatableinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/updatableinset.h,v retrieving revision 1.26 diff -u -p -r1.26 updatableinset.h --- insets/updatableinset.h 21 Nov 2003 14:59:24 -0000 1.26 +++ insets/updatableinset.h 28 Nov 2003 08:25:59 -0000 @@ -35,8 +35,6 @@ public: virtual void getCursorDim(int &, int &) const; /// virtual bool insertInset(BufferView *, InsetOld *) { return false; } - /// - virtual int insetInInsetY() const { return 0; } // We need this method to not clobber the real method in Inset int scroll(bool recursive = true) const { return InsetOld::scroll(recursive); }