I'd like to move "text related stuff" from BufferView to LyXText. Attached patch creates a dispatch() for LyXText and moves the handling of LFUN_APPENDIX to LyXText.
Good/bad idea? Other comments? Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)
Index: BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.284 diff -u -p -r1.284 BufferView_pimpl.C --- BufferView_pimpl.C 19 Aug 2002 10:11:10 -0000 1.284 +++ BufferView_pimpl.C 19 Aug 2002 11:35:07 -0000 @@ -143,16 +143,17 @@ boost::signals::connection lostcon; } // anon namespace -BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o, +BufferView::Pimpl::Pimpl(BufferView * bv, LyXView * owner, int xpos, int ypos, int width, int height) - : bv_(b), owner_(o), buffer_(0), cursor_timeout(400), + : bv_(bv), owner_(owner), buffer_(0), cursor_timeout(400), using_xterm_cursor(false) { workarea_.reset(WorkAreaFactory::create(xpos, ypos, width, height)); screen_.reset(LyXScreenFactory::create(workarea())); // Setup the signals - doccon = workarea().scrollDocView.connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1)); + doccon = workarea().scrollDocView + .connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1)); resizecon = workarea().workAreaResize .connect(boost::bind(&BufferView::Pimpl::workAreaResize, this)); bpresscon = workarea().workAreaButtonPress @@ -172,7 +173,8 @@ BufferView::Pimpl::Pimpl(BufferView * b, lostcon = workarea().selectionLost .connect(boost::bind(&BufferView::Pimpl::selectionLost, this)); - timecon = cursor_timeout.timeout.connect(boost::bind(&BufferView::Pimpl::cursorToggle, this)); + timecon = cursor_timeout.timeout + .connect(boost::bind(&BufferView::Pimpl::cursorToggle, this)); cursor_timeout.start(); saved_positions.resize(saved_positions_num); } @@ -214,12 +216,12 @@ void BufferView::Pimpl::buffer(Buffer * bv_->text = 0; } - // Set current buffer + // set current buffer buffer_ = b; if (bufferlist.getState() == BufferList::CLOSING) return; - // If we are closing the buffer, use the first buffer as current + // if we are closing the buffer, use the first buffer as current if (!buffer_) { buffer_ = bufferlist.first(); } @@ -234,7 +236,8 @@ void BufferView::Pimpl::buffer(Buffer * } // FIXME: needed when ? - bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y); + bv_->text->first_y = + screen().topCursorVisible(bv_->text->cursor, +bv_->text->first_y); // Similarly, buffer-dependent dialogs should be updated or // hidden. This should go here because some dialogs (eg ToC) @@ -1499,19 +1502,6 @@ bool BufferView::Pimpl::dispatch(FuncReq LyXTextClass const & tclass = buffer_->params.getLyXTextClass(); switch (ev.action) { - // --- Misc ------------------------------------------- - case LFUN_APPENDIX: - { - if (available()) { - LyXText * lt = bv_->getLyXText(); - lt->toggleAppendix(bv_); - update(lt, - BufferView::SELECT - | BufferView::FITCUR - | BufferView::CHANGE); - } - } - break; case LFUN_TOC_INSERT: { @@ -1524,7 +1514,7 @@ bool BufferView::Pimpl::dispatch(FuncReq } case LFUN_SCROLL_INSET: - // this is not handled here as this funktion is only aktive + // this is not handled here as this function is only active // if we have a locking_inset and that one is (or contains) // a tabular-inset break; @@ -3162,7 +3152,9 @@ bool BufferView::Pimpl::dispatch(FuncReq break; default: - return false; + FuncRequest cmd = ev; + cmd.setView(bv_); + return bv_->getLyXText()->dispatch(cmd); } // end of switch return true; Index: lyxtext.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v retrieving revision 1.121 diff -u -p -r1.121 lyxtext.h --- lyxtext.h 13 Aug 2002 14:40:32 -0000 1.121 +++ lyxtext.h 19 Aug 2002 11:35:08 -0000 @@ -131,8 +131,7 @@ public: paragraphs */ void decDepth(BufferView *); - /** Get the depth at current cursor position - */ + /// get the depth at current cursor position int getDepth() const; /** set font over selection and make a total rebreak of those @@ -170,7 +169,7 @@ public: /// void insertInset(BufferView *, Inset * inset); - /** Completes the insertion with a full rebreak. */ + /// Completes the insertion with a full rebreak void fullRebreak(BufferView *); /// @@ -191,6 +190,9 @@ public: /// void status(BufferView *, text_status) const; + /// + Inset::RESULT dispatch(FuncRequest const & cmd); + private: /** wether the screen needs a refresh, starting with refresh_y @@ -444,8 +446,6 @@ public: /// void checkParagraph(BufferView *, Paragraph * par, lyx::pos_type pos); /// - void toggleAppendix(BufferView *); - /// int workWidth(BufferView *) const; /// int workWidth(BufferView *, Inset * inset) const; @@ -622,6 +622,8 @@ public: private: /// void setCounter(Buffer const *, Paragraph * par) const; + /// + Inset::RESULT lfunAppendix(FuncRequest const & cmd); /* * some low level functions Index: text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.268 diff -u -p -r1.268 text.C --- text.C 18 Aug 2002 17:15:23 -0000 1.268 +++ text.C 19 Aug 2002 11:35:08 -0000 @@ -29,6 +29,7 @@ #include "ParagraphParameters.h" #include "undo_funcs.h" #include "WordLangTuple.h" +#include "funcrequest.h" #include "insets/insetbib.h" #include "insets/insettext.h" @@ -3946,4 +3947,50 @@ Row * LyXText::getRowNearY(int & y) cons int LyXText::getDepth() const { return cursor.par()->getDepth(); +} + + +Inset::RESULT LyXText::lfunAppendix(FuncRequest const & cmd) +{ + BufferView * bv = cmd.view(); + // what is this good for? + if (!bv->available()) + return Inset::UNDISPATCHED; + + Paragraph * par = cursor.par(); + bool start = !par->params().startOfAppendix(); + + // ensure that we have only one start_of_appendix in this document + Paragraph * tmp = ownerParagraph(); + for (; tmp; tmp = tmp->next()) { + tmp->params().startOfAppendix(false); + } + + par->params().startOfAppendix(start); + + // we can set the refreshing parameters now + status(cmd.view(), LyXText::NEED_MORE_REFRESH); + refresh_y = 0; + refresh_row = 0; // not needed for full update + updateCounters(cmd.view()); + setCursor(cmd.view(), cursor.par(), cursor.pos()); + bv->update(this, + BufferView::SELECT + | BufferView::FITCUR + | BufferView::CHANGE); + return Inset::DISPATCHED; +} + + +Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) +{ + switch (cmd.action) { + case LFUN_APPENDIX: + return lfunAppendix(cmd); + + default: + return Inset::UNDISPATCHED; + } + // shut up compiler + return Inset::UNDISPATCHED; } Index: text2.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v retrieving revision 1.247 diff -u -p -r1.247 text2.C --- text2.C 12 Aug 2002 20:24:08 -0000 1.247 +++ text2.C 19 Aug 2002 11:35:08 -0000 @@ -2370,28 +2370,6 @@ bool LyXText::deleteEmptyParagraphMechan } -void LyXText::toggleAppendix(BufferView * bview) -{ - Paragraph * par = cursor.par(); - bool start = !par->params().startOfAppendix(); - - // ensure that we have only one start_of_appendix in this document - Paragraph * tmp = ownerParagraph(); - for (; tmp; tmp = tmp->next()) { - tmp->params().startOfAppendix(false); - } - - par->params().startOfAppendix(start); - - // we can set the refreshing parameters now - status(bview, LyXText::NEED_MORE_REFRESH); - refresh_y = 0; - refresh_row = 0; // not needed for full update - updateCounters(bview); - setCursor(bview, cursor.par(), cursor.pos()); -} - - Paragraph * LyXText::ownerParagraph() const { if (inset_owner) {