From 799f3049d1a8ed881387104a318c475c82460a23 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Mon, 19 Aug 2002 15:39:25 +0000 Subject: [PATCH] move handling of LFUN_APPENDIX to LyXText git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5025 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 36 +++++++++++++------------------- src/ChangeLog | 8 +++++++ src/lyxtext.h | 12 ++++++----- src/text.C | 47 ++++++++++++++++++++++++++++++++++++++++++ src/text2.C | 22 -------------------- 5 files changed, 76 insertions(+), 49 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 02e44f21b3..0c2ad46841 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -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, LyXView * o, 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 * b) 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 * b) } // 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(FuncRequest const & ev) 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(FuncRequest const & ev) } 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(FuncRequest const & ev) break; default: - return false; + FuncRequest cmd = ev; + cmd.setView(bv_); + return bv_->getLyXText()->dispatch(cmd); } // end of switch return true; diff --git a/src/ChangeLog b/src/ChangeLog index 2b3820c394..0e86b7cb0b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ + +2002-08-19 André Pönitz + + * lyxtext.h: + * text.C: new LyXText::dispatch() + + * BufferView_pimpl.C: move handling of LFUN_APPENDIX to LyXText + 2002-08-18 Dekel Tsur * text.C (paintRowSelection): Fix code for rows with both RTL & LTR text. diff --git a/src/lyxtext.h b/src/lyxtext.h index ba127439e7..96de949c3d 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -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 diff --git a/src/text.C b/src/text.C index e29788c31c..4568a03107 100644 --- a/src/text.C +++ b/src/text.C @@ -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" @@ -3947,3 +3948,49 @@ 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; +} diff --git a/src/text2.C b/src/text2.C index e8aafd7744..afd3351592 100644 --- a/src/text2.C +++ b/src/text2.C @@ -2370,28 +2370,6 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview, } -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) { -- 2.39.5