Several items:

Also dispatch to InsetCommands (etc) near the temp cursor tip on mouse
events (this means the label dialog is working again)

Lots of BOOST_ASSERTs to bomb early.

Shift some InsetLabel specific code from BufferView*

Shift LFUN_PARAGRAPH_APPLY handling from BV to Text.

Remove a few  LyXText::cursor() calls (the multiple view thingy...)

Andre' 

-- 
Those who desire to give up Freedom in order to gain Security, will not have,
nor do they deserve, either one.     (T. Jefferson or B. Franklin or both...)
Index: BufferView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v
retrieving revision 1.232
diff -u -p -r1.232 BufferView.C
--- BufferView.C        13 Feb 2004 07:30:52 -0000      1.232
+++ BufferView.C        13 Feb 2004 09:46:48 -0000
@@ -330,19 +330,6 @@ void BufferView::hideCursor()
 }
 
 
-bool BufferView::ChangeRefsIfUnique(string const & from, string const & to)
-{
-       // Check if the label 'from' appears more than once
-       vector<string> labels;
-       buffer()->getLabelList(labels);
-
-       if (lyx::count(labels.begin(), labels.end(), from) > 1)
-               return false;
-
-       return pimpl_->ChangeInsets(InsetOld::REF_CODE, from, to);
-}
-
-
 LyXText * BufferView::getLyXText() const
 {
        return cursor().innerText();
Index: BufferView.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.h,v
retrieving revision 1.167
diff -u -p -r1.167 BufferView.h
--- BufferView.h        13 Feb 2004 07:30:52 -0000      1.167
+++ BufferView.h        13 Feb 2004 09:46:48 -0000
@@ -154,9 +154,6 @@ public:
        /// switch between primary and secondary keymaps for RTL entry
        void switchKeyMap();
 
-       /// FIXME
-       bool ChangeRefsIfUnique(std::string const & from, std::string const & to);
-
        /// get the contents of the window system clipboard
        std::string const getClipboard() const;
        /// fill the window system clipboard
Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.508
diff -u -p -r1.508 BufferView_pimpl.C
--- BufferView_pimpl.C  13 Feb 2004 07:30:52 -0000      1.508
+++ BufferView_pimpl.C  13 Feb 2004 09:46:48 -0000
@@ -77,6 +77,7 @@ using lyx::support::strToUnsignedInt;
 using lyx::support::system_lyxdir;
 
 using std::endl;
+using std::istringstream;
 using std::make_pair;
 using std::min;
 using std::string;
@@ -742,31 +743,28 @@ void BufferView::Pimpl::stuffClipboard(s
 
 InsetBase * BufferView::Pimpl::getInsetByCode(InsetBase::Code code)
 {
+#warning Does not work for mathed
        // Ok, this is a little bit too brute force but it
        // should work for now. Better infrastructure is coming. (Lgb)
 
-       Buffer * b = bv_->buffer();
-       LyXText * text = bv_->getLyXText();
-
-       Buffer::inset_iterator beg = b->inset_iterator_begin();
-       Buffer::inset_iterator end = b->inset_iterator_end();
+       Buffer * buf = bv_->buffer();
+       Buffer::inset_iterator beg = buf->inset_iterator_begin();
+       Buffer::inset_iterator end = buf->inset_iterator_end();
 
        bool cursor_par_seen = false;
 
+       LCursor & cur = bv_->cursor();
+       ParagraphList::iterator pit =  bv_->getLyXText()->getPar(cur.par());
+
        for (; beg != end; ++beg) {
-               if (beg.getPar() == text->cursorPar()) {
+               if (beg.getPar() == pit)
                        cursor_par_seen = true;
-               }
                if (cursor_par_seen) {
-                       if (beg.getPar() == text->cursorPar()
-                           && beg.getPos() >= text->cursor().pos()) {
+                       if (beg.getPar() == pit && beg.getPos() >= cur.pos())
                                break;
-                       }
-                       if (beg.getPar() != text->cursorPar()) {
+                       if (beg.getPar() != pit)
                                break;
-                       }
                }
-
        }
        if (beg != end) {
                // Now find the first inset that matches code.
@@ -929,10 +927,18 @@ bool BufferView::Pimpl::workAreaDispatch
                        text->setCursorFromCoordinates(cur.current(), cmd.x, cmd.y);
                lyxerr << "created temp cursor: " << cur << endl;
 
+               // Try to dispatch to an non-editable inset near this position
+               DispatchResult res;
+               InsetBase * inset = cur.nextInset();
+               lyxerr << "next inset: " << inset << endl;
+               if (inset)
+                       res = inset->dispatch(cur, cmd);
+
                // Dispatch to the temp cursor.
                // An inset (or LyXText) can assign this to bv->cursor()
                // if it wishes to do so.
-               DispatchResult res = cur.dispatch(cmd);
+               if (!res.dispatched())
+                       res = cur.dispatch(cmd);
 
                if (fitCursor() || res.update())
                        update();
@@ -1049,10 +1055,6 @@ bool BufferView::Pimpl::dispatch(FuncReq
                break;
        }
 
-       case LFUN_PARAGRAPH_APPLY:
-               setParagraphParams(*bv_, cmd.argument);
-               break;
-
        case LFUN_TRACK_CHANGES:
                trackChanges();
                break;
@@ -1123,42 +1125,4 @@ bool BufferView::Pimpl::dispatch(FuncReq
        }
 
        return true;
-}
-
-
-bool BufferView::Pimpl::ChangeInsets(InsetBase::Code code,
-                                    string const & from, string const & to)
-{
-       bool need_update = false;
-       CursorSlice cur = bv_->text()->cursor();
-
-       ParIterator end = bv_->buffer()->par_iterator_end();
-       for (ParIterator it = bv_->buffer()->par_iterator_begin();
-            it != end; ++it) {
-               bool changed_inset = false;
-               for (InsetList::iterator it2 = it->insetlist.begin();
-                    it2 != it->insetlist.end(); ++it2) {
-                       if (it2->inset->lyxCode() == code) {
-                               InsetCommand * inset = static_cast<InsetCommand 
*>(it2->inset);
-                               if (inset->getContents() == from) {
-                                       inset->setContents(to);
-                                       changed_inset = true;
-                               }
-                       }
-               }
-               if (changed_inset) {
-                       need_update = true;
-
-                       // FIXME
-
-                       // 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(cur.par(), cur.pos());
-       return need_update;
 }
Index: BufferView_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v
retrieving revision 1.117
diff -u -p -r1.117 BufferView_pimpl.h
--- BufferView_pimpl.h  6 Feb 2004 13:59:25 -0000       1.117
+++ BufferView_pimpl.h  13 Feb 2004 09:46:48 -0000
@@ -139,13 +139,6 @@ private:
        /// notify readonly status
        void showReadonly(bool);
 
-       /**
-        * Change all insets with the given code's contents to a new
-        * string. May only be used with InsetCommand-derived insets
-        * Returns true if a screen update is needed.
-        */
-       bool ChangeInsets(InsetBase::Code code, std::string const & from,
-                         std::string const & to);
 
        ///
        friend class BufferView;
Index: ParagraphParameters.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ParagraphParameters.C,v
retrieving revision 1.36
diff -u -p -r1.36 ParagraphParameters.C
--- ParagraphParameters.C       28 Nov 2003 15:53:23 -0000      1.36
+++ ParagraphParameters.C       13 Feb 2004 09:46:49 -0000
@@ -296,27 +296,6 @@ void ParagraphParameters::write(ostream 
 }
 
 
-void setParagraphParams(BufferView & bv, string const & data)
-{
-       istringstream is(data);
-       LyXLex lex(0,0);
-       lex.setStream(is);
-
-       ParagraphParameters params;
-       params.read(lex);
-
-       LyXText * text = bv.getLyXText();
-       text->setParagraph(
-                          params.spacing(),
-                          params.align(),
-                          params.labelWidthString(),
-                          params.noindent());
-
-       bv.update();
-       bv.owner()->message(_("Paragraph layout set"));
-}
-
-
 void params2string(Paragraph const & par, string & data)
 {
        // A local copy
Index: ParagraphParameters.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ParagraphParameters.h,v
retrieving revision 1.22
diff -u -p -r1.22 ParagraphParameters.h
--- ParagraphParameters.h       28 Nov 2003 15:53:23 -0000      1.22
+++ ParagraphParameters.h       13 Feb 2004 09:46:49 -0000
@@ -29,6 +29,7 @@ class Paragraph;
 class ParameterStruct;
 class Spacing;
 
+
 ///
 class ParagraphParameters {
 public:
@@ -98,11 +99,5 @@ private:
     Paragraph dialog.
  */
 void params2string(Paragraph const & par, std::string & data);
-
-/** Given \param data, an encoding of the ParagraphParameters generated
-    in the Paragraph dialog, this function sets the current paragraph
-    appropriately.
- */
-void setParagraphParams(BufferView & bv, std::string const & data);
 
 #endif
Index: bufferview_funcs.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferview_funcs.h,v
retrieving revision 1.31
diff -u -p -r1.31 bufferview_funcs.h
--- bufferview_funcs.h  13 Feb 2004 07:30:53 -0000      1.31
+++ bufferview_funcs.h  13 Feb 2004 09:46:49 -0000
@@ -16,24 +16,19 @@
 
 #include <string>
 
-
-class BufferView;
 class LCursor;
 class LyXFont;
 class LyXText;
-class PosIterator;
 
 
 namespace bv_funcs {
 
-/** Set \param data using \param font and \param toggle.
- *  If successful, returns true.
- */
+/// Set \param data using \param font and \param toggle. Return success.
 bool font2string(LyXFont const & font, bool toggle, std::string & data);
-/** Set \param font and \param toggle using \param data.
- *  If successful, returns true.
- */
+
+/// Set \param font and \param toggle using \param data. Return success.
 bool string2font(std::string const & data, LyXFont & font, bool & toggle);
+
 /** Returns the current freefont, encoded as a std::string to be passed to the
  *  frontends.
  */
@@ -49,6 +44,6 @@ enum DEPTH_CHANGE {
 /// Returns whether something would be changed by changeDepth
 bool changeDepthAllowed(LCursor & cur, LyXText * text, DEPTH_CHANGE);
 
-}; // namespace bv_funcs
+} // namespace bv_funcs
 
 #endif
Index: cursor.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v
retrieving revision 1.56
diff -u -p -r1.56 cursor.C
--- cursor.C    13 Feb 2004 07:30:53 -0000      1.56
+++ cursor.C    13 Feb 2004 09:46:49 -0000
@@ -1928,3 +1928,8 @@ void LCursor::replaceWord(string const &
                t->cursorLeft(*this, true);
 }
 
+
+void LCursor::update()
+{
+       bv().update();
+}
Index: cursor.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.h,v
retrieving revision 1.34
diff -u -p -r1.34 cursor.h
--- cursor.h    13 Feb 2004 07:30:53 -0000      1.34
+++ cursor.h    13 Feb 2004 09:46:49 -0000
@@ -287,6 +287,8 @@ public:
        void reset();
        /// for spellchecking
        void replaceWord(std::string const & replacestring);
+       /// update our view
+       void update();
 
        /// output
        friend std::ostream & operator<<(std::ostream & os, LCursor const & cur);
Index: lyxtext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.290
diff -u -p -r1.290 lyxtext.h
--- lyxtext.h   13 Feb 2004 07:30:54 -0000      1.290
+++ lyxtext.h   13 Feb 2004 09:46:49 -0000
@@ -237,9 +237,9 @@ public:
        /// returns success
        bool toggleInset(LCursor & cur);
        ///
-       void cutSelection(bool doclear = true, bool realcut = true);
+       void cutSelection(LCursor & cur, bool doclear = true, bool realcut = true);
        ///
-       void copySelection();
+       void copySelection(LCursor & cur);
        ///
        void pasteSelection(LCursor & cur, size_t sel_index = 0);
 
@@ -248,7 +248,7 @@ public:
         last. When a paragraph is broken, the top settings rest, the bottom
         settings are given to the new one.
         */
-       void setParagraph(
+       void setParagraph(LCursor & cur,
                          Spacing const & spacing,
                          LyXAlignment align,
                          std::string const & labelwidthstring,
@@ -452,9 +452,9 @@ private:
        ///
        void charInserted();
        /// set 'number' font property
-       void number();
+       void number(LCursor & cur);
        /// is the cursor paragraph right-to-left?
-       bool rtl() const;
+       bool rtl(LCursor & cur) const;
 };
 
 /// return the default height of a row in pixels, considering font zoom
Index: text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.535
diff -u -p -r1.535 text.C
--- text.C      13 Feb 2004 07:30:55 -0000      1.535
+++ text.C      13 Feb 2004 09:46:49 -0000
@@ -758,6 +758,7 @@ void LyXText::setHeightOfRow(ParagraphLi
 
 void LyXText::breakParagraph(LCursor & cur, char keep_layout)
 {
+       BOOST_ASSERT(this == cur.text());
        // allow only if at start or end, or all previous is new text
        Paragraph & cpar = cur.paragraph();
        ParagraphList::iterator cpit = getPar(cur.par());
@@ -840,6 +841,7 @@ void LyXText::breakParagraph(LCursor & c
 // convenience function
 void LyXText::redoParagraph(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        cur.clearSelection();
        redoParagraph(getPar(cur.par()));
        setCursorIntern(cur.par(), cur.pos());
@@ -850,6 +852,7 @@ void LyXText::redoParagraph(LCursor & cu
 // same Paragraph one to the right and make a rebreak
 void LyXText::insertChar(LCursor & cur, char c)
 {
+       BOOST_ASSERT(this == cur.text());
        recordUndo(cur, Undo::INSERT);
 
        Paragraph & par = cur.paragraph();
@@ -872,10 +875,10 @@ void LyXText::insertChar(LCursor & cur, 
                              getFont(pit, cur.pos()).number() == LyXFont::ON &&
                              getFont(pit, cur.pos() - 1).number() == LyXFont::ON)
                           )
-                               number(); // Set current_font.number to OFF
+                               number(cur); // Set current_font.number to OFF
                } else if (IsDigit(c) &&
                           real_current_font.isVisibleRightToLeft()) {
-                       number(); // Set current_font.number to ON
+                       number(cur); // Set current_font.number to ON
 
                        if (cur.pos() != 0) {
                                char const c = par.getChar(cur.pos() - 1);
@@ -1085,6 +1088,7 @@ void LyXText::prepareToPrint(ParagraphLi
 
 void LyXText::cursorRightOneWord(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        if (cur.pos() == cur.lastpos() && cur.par() != cur.lastpar()) {
                ++cur.par();
                cur.pos() = 0;
@@ -1103,6 +1107,7 @@ void LyXText::cursorRightOneWord(LCursor
 
 void LyXText::cursorLeftOneWord(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        if (cur.pos() == 0 && cur.par() != 0) {
                --cur.par();
                cur.pos() = cur.lastpos();
@@ -1121,6 +1126,7 @@ void LyXText::cursorLeftOneWord(LCursor 
 
 void LyXText::selectWord(LCursor & cur, word_location loc)
 {
+       BOOST_ASSERT(this == cur.text());
        CursorSlice from = cur.current();
        CursorSlice to = cur.current();
        getWord(from, to, loc);
@@ -1147,6 +1153,7 @@ bool LyXText::selectWordWhenUnderCursor(
 
 void LyXText::acceptChange(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        if (!cur.selection() && cur.lastpos() != 0)
                return;
 
@@ -1166,6 +1173,7 @@ void LyXText::acceptChange(LCursor & cur
 
 void LyXText::rejectChange(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        if (!cur.selection() && cur.lastpos() != 0)
                return;
 
@@ -1186,6 +1194,7 @@ void LyXText::rejectChange(LCursor & cur
 // Delete from cursor up to the end of the current or next word.
 void LyXText::deleteWordForward(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        if (cur.lastpos() == 0)
                cursorRight(cur, true);
        else {
@@ -1193,7 +1202,7 @@ void LyXText::deleteWordForward(LCursor 
                cur.selection() = true;
                cursorRightOneWord(cur);
                cur.setSelection();
-               cutSelection(true, false);
+               cutSelection(cur, true, false);
        }
 }
 
@@ -1201,6 +1210,7 @@ void LyXText::deleteWordForward(LCursor 
 // Delete from cursor to start of current or prior word.
 void LyXText::deleteWordBackward(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        if (cur.lastpos() == 0)
                cursorLeft(cur, true);
        else {
@@ -1208,7 +1218,7 @@ void LyXText::deleteWordBackward(LCursor
                cur.selection() = true;
                cursorLeftOneWord(cur);
                cur.setSelection();
-               cutSelection(true, false);
+               cutSelection(cur, true, false);
        }
 }
 
@@ -1216,6 +1226,7 @@ void LyXText::deleteWordBackward(LCursor
 // Kill to end of line.
 void LyXText::deleteLineForward(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        if (cur.lastpos() == 0) {
                // Paragraph is empty, so we just go to the right
                cursorRight(cur, true);
@@ -1228,13 +1239,14 @@ void LyXText::deleteLineForward(LCursor 
                if (!cur.selection())
                        deleteWordForward(cur);
                else
-                       cutSelection(true, false);
+                       cutSelection(cur, true, false);
        }
 }
 
 
 void LyXText::changeCase(LCursor & cur, LyXText::TextCase action)
 {
+       BOOST_ASSERT(this == cur.text());
        CursorSlice from;
        CursorSlice to;
 
@@ -1284,6 +1296,7 @@ void LyXText::changeCase(LCursor & cur, 
 
 void LyXText::Delete(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        // this is a very simple implementation
        // just move to the right
        // if you had success make a backspace
@@ -1297,6 +1310,7 @@ void LyXText::Delete(LCursor & cur)
 
 void LyXText::backspace(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        if (cur.pos() == 0) {
                // The cursor is at the beginning of a paragraph, so
                // the the backspace will collapse two paragraphs into
@@ -1595,7 +1609,7 @@ void LyXText::draw(PainterInfo & pi, int
 // only used for inset right now. should also be used for main text
 void LyXText::drawSelection(PainterInfo &, int x, int y) const
 {
-       lyxerr << "LyXText::drawSelection at " << x << " " << y << endl;
+       //lyxerr << "LyXText::drawSelection at " << x << " " << y << endl;
 }
 
 
@@ -1856,9 +1870,10 @@ CursorSlice const & LyXText::cursor() co
 
 void LyXText::replaceSelection(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        if (cur.selection()) {
-               cutSelection(true, false);
-               bv()->update();
+               cutSelection(cur, true, false);
+               cur.update();
        }
 }
 
@@ -1866,6 +1881,7 @@ void LyXText::replaceSelection(LCursor &
 // Returns the current font and depth as a message.
 string LyXText::currentState(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        Buffer * buffer = bv()->buffer();
        Paragraph const & par = cur.paragraph();
        std::ostringstream os;
Index: text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.544
diff -u -p -r1.544 text2.C
--- text2.C     13 Feb 2004 09:43:02 -0000      1.544
+++ text2.C     13 Feb 2004 09:46:49 -0000
@@ -281,6 +281,7 @@ LyXText::setLayout(ParagraphList::iterat
 // set layout over selection and make a total rebreak of those paragraphs
 void LyXText::setLayout(LCursor & cur, string const & layout)
 {
+       BOOST_ASSERT(this == cur.text());
        // special handling of new environment insets
        BufferParams const & params = bv()->buffer()->params();
        LyXLayout_ptr const & lyxlayout = params.getLyXTextClass()[layout];
@@ -342,6 +343,7 @@ bool changeDepthAllowed(bv_funcs::DEPTH_
 
 bool LyXText::changeDepthAllowed(LCursor & cur, bv_funcs::DEPTH_CHANGE type)
 {
+       BOOST_ASSERT(this == cur.text());
        ParagraphList::iterator beg, end; 
        getSelectionSpan(cur, *this, beg, end);
        int max_depth = 0;
@@ -359,6 +361,7 @@ bool LyXText::changeDepthAllowed(LCursor
 
 void LyXText::changeDepth(LCursor & cur, bv_funcs::DEPTH_CHANGE type)
 {
+       BOOST_ASSERT(this == cur.text());
        ParagraphList::iterator beg, end;
        getSelectionSpan(cur, *this, beg, end);
        recordUndoSelection(cur);
@@ -386,6 +389,7 @@ void LyXText::changeDepth(LCursor & cur,
 // set font over selection and make a total rebreak of those paragraphs
 void LyXText::setFont(LCursor & cur, LyXFont const & font, bool toggleall)
 {
+       BOOST_ASSERT(this == cur.text());
        // if there is no selection just set the current_font
        if (!cur.selection()) {
                // Determine basis font
@@ -439,12 +443,14 @@ void LyXText::setFont(LCursor & cur, LyX
 
 void LyXText::cursorHome(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        setCursor(cur.par(), cur.textRow().pos());
 }
 
 
 void LyXText::cursorEnd(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        // if not on the last row of the par, put the cursor before
        // the final space
        pos_type const end = cur.textRow().endpos();
@@ -452,20 +458,23 @@ void LyXText::cursorEnd(LCursor & cur)
 }
 
 
-void LyXText::cursorTop(LCursor &)
+void LyXText::cursorTop(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        setCursor(0, 0);
 }
 
 
 void LyXText::cursorBottom(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        setCursor(cur.lastpar(), boost::prior(paragraphs().end())->size());
 }
 
 
 void LyXText::toggleFree(LCursor & cur, LyXFont const & font, bool toggleall)
 {
+       BOOST_ASSERT(this == cur.text());
        // If the mask is completely neutral, tell user
        if (font == LyXFont(LyXFont::ALL_IGNORE)) {
                // Could only happen with user style
@@ -498,6 +507,7 @@ void LyXText::toggleFree(LCursor & cur, 
 
 string LyXText::getStringToIndex(LCursor & cur)
 {
+       BOOST_ASSERT(this == cur.text());
        // Try implicit word selection
        // If there is a change in the language the implicit word selection
        // is disabled.
@@ -531,10 +541,11 @@ string LyXText::getStringToIndex(LCursor
 // they do not duplicate themself and you cannot play dirty tricks with
 // them!
 
-void LyXText::setParagraph(Spacing const & spacing, LyXAlignment align,
+void LyXText::setParagraph(LCursor & cur,
+       Spacing const & spacing, LyXAlignment align,
        string const & labelwidthstring, bool noindent)
 {
-       LCursor & cur = bv()->cursor();
+       BOOST_ASSERT(cur.text());
        // make sure that the depth behind the selection are restored, too
        ParagraphList::iterator undopit = undoSpan(getPar(cur.selEnd()));
        recUndo(cur.selBegin().par(), parOffset(undopit) - 1);
@@ -856,6 +867,7 @@ void LyXText::updateCounters()
 
 void LyXText::insertInset(LCursor & cur, InsetBase * inset)
 {
+       BOOST_ASSERT(this == cur.text());
        recordUndo(cur);
        freezeUndo();
        cur.paragraph().insertInset(cur.pos(), inset);
@@ -872,9 +884,9 @@ void LyXText::insertInset(LCursor & cur,
 }
 
 
-void LyXText::cutSelection(bool doclear, bool realcut)
+void LyXText::cutSelection(LCursor & cur, bool doclear, bool realcut)
 {
-       LCursor & cur = bv()->cursor();
+       BOOST_ASSERT(this == cur.text());
        // Stuff what we got on the clipboard. Even if there is no selection.
 
        // There is a problem with having the stuffing here in that the
@@ -930,9 +942,9 @@ void LyXText::cutSelection(bool doclear,
 }
 
 
-void LyXText::copySelection()
+void LyXText::copySelection(LCursor & cur)
 {
-       LCursor & cur = bv()->cursor();
+       BOOST_ASSERT(this == cur.text());
        // stuff the selection onto the X clipboard, from an explicit copy request
        bv()->stuffClipboard(cur.selectionAsString(true));
 
@@ -1022,8 +1034,7 @@ void LyXText::replaceSelectionWithString
        }
 
        // Cut the selection
-       cutSelection(true, false);
-
+       cutSelection(cur, true, false);
        unFreezeUndo();
 }
 
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.222
diff -u -p -r1.222 text3.C
--- text3.C     13 Feb 2004 07:30:58 -0000      1.222
+++ text3.C     13 Feb 2004 09:46:49 -0000
@@ -30,6 +30,7 @@
 #include "intl.h"
 #include "language.h"
 #include "lyxfunc.h"
+#include "lyxlex.h"
 #include "lyxrc.h"
 #include "lyxrow.h"
 #include "paragraph.h"
@@ -126,7 +127,8 @@ namespace {
        }
 
 
-       void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
+       void mathDispatch(LCursor & cur, LyXText * text,
+               FuncRequest const & cmd, bool display)
        {
                string sel = cur.selectionAsString(false);
                lyxerr << "selection is: '" << sel << "'" << endl;
@@ -144,7 +146,7 @@ namespace {
                } else {
                        // create a macro if we see "\\newcommand" somewhere, and an 
ordinary
                        // formula otherwise
-                       cur.bv().getLyXText()->cutSelection(true, true);
+                       text->cutSelection(cur, true, true);
                        if (sel.find("\\newcommand") == string::npos &&
                                        sel.find("\\def") == string::npos)
                        {
@@ -325,49 +327,47 @@ void LyXText::cursorNext(LCursor & cur)
 
 namespace {
 
-void specialChar(LCursor & cur, LyXText * text, BufferView * bv,
-       InsetSpecialChar::Kind kind)
+void specialChar(LCursor & cur, LyXText * text, InsetSpecialChar::Kind kind)
 {
-       bv->update();
        text->replaceSelection(cur);
        cur.insert(new InsetSpecialChar(kind));
-       bv->update();
+       cur.update();
 }
 
 
-void doInsertInset(LCursor & cur, LyXText * text, BufferView * bv,
+void doInsertInset(LCursor & cur, LyXText * text,
        FuncRequest const & cmd, bool edit, bool pastesel)
 {
-       InsetBase * inset = createInset(bv, cmd);
+       InsetBase * inset = createInset(&cur.bv(), cmd);
        if (!inset)
                return;
 
        bool gotsel = false;
        if (cur.selection()) {
-               bv->owner()->dispatch(FuncRequest(LFUN_CUT));
+               cur.bv().owner()->dispatch(FuncRequest(LFUN_CUT));
                gotsel = true;
        }
        text->insertInset(cur, inset);
        if (edit)
                inset->edit(cur, true);
        if (gotsel && pastesel)
-               bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
+               cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE));
 }
 
 } // anon namespace
 
 
-void LyXText::number()
+void LyXText::number(LCursor & cur)
 {
        LyXFont font(LyXFont::ALL_IGNORE);
        font.setNumber(LyXFont::TOGGLE);
-       toggleAndShow(bv()->cursor(), this, font);
+       toggleAndShow(cur, this, font);
 }
 
 
-bool LyXText::rtl() const
+bool LyXText::rtl(LCursor & cur) const
 {
-       return cursorPar()->isRightToLeftPar(bv()->buffer()->params());
+       return getPar(cur.par())->isRightToLeftPar(bv()->buffer()->params());
 }
 
 
@@ -403,7 +403,7 @@ DispatchResult LyXText::dispatch(LCursor
                // we can set the refreshing parameters now
                updateCounters();
                redoParagraph(cur);
-               bv->update();
+               cur.update();
                break;
        }
 
@@ -428,7 +428,7 @@ DispatchResult LyXText::dispatch(LCursor
        case LFUN_WORDRIGHT:
                if (!cur.mark())
                        cur.clearSelection();
-               if (rtl())
+               if (rtl(cur))
                        cursorLeftOneWord(cur);
                else
                        cursorRightOneWord(cur);
@@ -438,7 +438,7 @@ DispatchResult LyXText::dispatch(LCursor
        case LFUN_WORDLEFT:
                if (!cur.mark())
                        cur.clearSelection();
-               if (rtl())
+               if (rtl(cur))
                        cursorRightOneWord(cur);
                else
                        cursorLeftOneWord(cur);
@@ -462,7 +462,7 @@ DispatchResult LyXText::dispatch(LCursor
        case LFUN_RIGHTSEL:
                if (!cur.selection())
                        cur.resetAnchor();
-               if (rtl())
+               if (rtl(cur))
                        cursorLeft(cur, true);
                else
                        cursorRight(cur, true);
@@ -472,7 +472,7 @@ DispatchResult LyXText::dispatch(LCursor
        case LFUN_LEFTSEL:
                if (!cur.selection())
                        cur.resetAnchor();
-               if (rtl())
+               if (rtl(cur))
                        cursorRight(cur, true);
                else
                        cursorLeft(cur, true);
@@ -538,7 +538,7 @@ DispatchResult LyXText::dispatch(LCursor
        case LFUN_WORDRIGHTSEL:
                if (!cur.selection())
                        cur.resetAnchor();
-               if (rtl())
+               if (rtl(cur))
                        cursorLeftOneWord(cur);
                else
                        cursorRightOneWord(cur);
@@ -548,7 +548,7 @@ DispatchResult LyXText::dispatch(LCursor
        case LFUN_WORDLEFTSEL:
                if (!cur.selection())
                        cur.resetAnchor();
-               if (rtl())
+               if (rtl(cur))
                        cursorRightOneWord(cur);
                else
                        cursorLeftOneWord(cur);
@@ -641,7 +641,7 @@ DispatchResult LyXText::dispatch(LCursor
                        // It is possible to make it a lot faster still
                        // just comment out the line below...
                } else {
-                       cutSelection(true, false);
+                       cutSelection(cur, true, false);
                }
                moveCursor(cur, false);
                bv->owner()->view_state_changed();
@@ -657,9 +657,9 @@ DispatchResult LyXText::dispatch(LCursor
                        Delete(cur);
                        cur.resetAnchor();
                } else {
-                       cutSelection(true, false);
+                       cutSelection(cur, true, false);
                }
-               bv->update();
+               cur.update();
                break;
 
 
@@ -672,11 +672,11 @@ DispatchResult LyXText::dispatch(LCursor
                                // just comment out the line below...
                        }
                } else {
-                       cutSelection(true, false);
+                       cutSelection(cur, true, false);
                }
                bv->owner()->view_state_changed();
                bv->switchKeyMap();
-               bv->update();
+               cur.update();
                break;
 
        case LFUN_BACKSPACE_SKIP:
@@ -687,15 +687,15 @@ DispatchResult LyXText::dispatch(LCursor
                        backspace(cur);
                        //anchor() = cur;
                } else {
-                       cutSelection(true, false);
+                       cutSelection(cur, true, false);
                }
-               bv->update();
+               cur.update();
                break;
 
        case LFUN_BREAKPARAGRAPH:
                replaceSelection(cur);
                breakParagraph(cur, 0);
-               bv->update();
+               cur.update();
                cur.resetAnchor();
                bv->switchKeyMap();
                bv->owner()->view_state_changed();
@@ -704,7 +704,7 @@ DispatchResult LyXText::dispatch(LCursor
        case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
                replaceSelection(cur);
                breakParagraph(cur, 1);
-               bv->update();
+               cur.update();
                cur.resetAnchor();
                bv->switchKeyMap();
                bv->owner()->view_state_changed();
@@ -714,18 +714,17 @@ DispatchResult LyXText::dispatch(LCursor
                // When at the beginning of a paragraph, remove
                // indentation and add a "defskip" at the top.
                // Otherwise, do the same as LFUN_BREAKPARAGRAPH.
-#warning look here
                replaceSelection(cur);
                if (cur.pos() == 0) {
                        ParagraphParameters & params = cur.paragraph().params();
-                       setParagraph(
+                       setParagraph(cur,
                                        params.spacing(),
                                        params.align(),
                                        params.labelWidthString(), 1);
                } else {
                        breakParagraph(cur, 0);
                }
-               bv->update();
+               cur.update();
 //     anchor() = cur;
                bv->switchKeyMap();
                bv->owner()->view_state_changed();
@@ -769,7 +768,7 @@ DispatchResult LyXText::dispatch(LCursor
                if (cur_spacing != new_spacing || cur_value != new_value) {
                        par.params().spacing(Spacing(new_spacing, new_value));
                        redoParagraph(cur);
-                       bv->update();
+                       cur.update();
                }
                break;
        }
@@ -800,7 +799,7 @@ DispatchResult LyXText::dispatch(LCursor
                cur.clearSelection();
                if (!toggleInset(cur))
                        return DispatchResult(false);
-               bv->update();
+               cur.update();
                bv->switchKeyMap();
                break;
 
@@ -808,49 +807,49 @@ DispatchResult LyXText::dispatch(LCursor
                if (cur.paragraph().layout()->free_spacing)
                        insertChar(cur, ' ');
                else
-                       doInsertInset(cur, this, bv, cmd, false, false);
+                       doInsertInset(cur, this, cmd, false, false);
                moveCursor(cur, false);
                break;
 
        case LFUN_HYPHENATION:
-               specialChar(cur, this, bv, InsetSpecialChar::HYPHENATION);
+               specialChar(cur, this, InsetSpecialChar::HYPHENATION);
                break;
 
        case LFUN_LIGATURE_BREAK:
-               specialChar(cur, this, bv, InsetSpecialChar::LIGATURE_BREAK);
+               specialChar(cur, this, InsetSpecialChar::LIGATURE_BREAK);
                break;
 
        case LFUN_LDOTS:
-               specialChar(cur, this, bv, InsetSpecialChar::LDOTS);
+               specialChar(cur, this, InsetSpecialChar::LDOTS);
                break;
 
        case LFUN_END_OF_SENTENCE:
-               specialChar(cur, this, bv, InsetSpecialChar::END_OF_SENTENCE);
+               specialChar(cur, this, InsetSpecialChar::END_OF_SENTENCE);
                break;
 
        case LFUN_MENU_SEPARATOR:
-               specialChar(cur, this, bv, InsetSpecialChar::MENU_SEPARATOR);
+               specialChar(cur, this, InsetSpecialChar::MENU_SEPARATOR);
                break;
 
        case LFUN_UPCASE_WORD:
                changeCase(cur, LyXText::text_uppercase);
-               bv->update();
+               cur.update();
                break;
 
        case LFUN_LOWCASE_WORD:
                changeCase(cur, LyXText::text_lowercase);
-               bv->update();
+               cur.update();
                break;
 
        case LFUN_CAPITALIZE_WORD:
                changeCase(cur, LyXText::text_capitalization);
-               bv->update();
+               cur.update();
                break;
 
        case LFUN_TRANSPOSE_CHARS:
                recordUndo(cur);
                redoParagraph(cur);
-               bv->update();
+               cur.update();
                break;
 
        case LFUN_PASTE:
@@ -862,19 +861,19 @@ DispatchResult LyXText::dispatch(LCursor
                else
                        pasteSelection(cur, 0);
                cur.clearSelection(); // bug 393
-               bv->update();
+               cur.update();
                bv->switchKeyMap();
                finishUndo();
                break;
 
        case LFUN_CUT:
-               cutSelection(true, true);
+               cutSelection(cur, true, true);
                cur.message(_("Cut"));
-               bv->update();
+               cur.update();
                break;
 
        case LFUN_COPY:
-               copySelection();
+               copySelection(cur);
                cur.message(_("Copy"));
                break;
 
@@ -980,7 +979,7 @@ DispatchResult LyXText::dispatch(LCursor
                        current_layout = layout;
                        setLayout(cur, layout);
                        bv->owner()->setLayout(layout);
-                       bv->update();
+                       cur.update();
                        bv->switchKeyMap();
                }
                break;
@@ -994,7 +993,7 @@ DispatchResult LyXText::dispatch(LCursor
                                insertStringAsParagraphs(cur, clip);
                        else
                                insertStringAsLines(cur, clip);
-                       bv->update();
+                       cur.update();
                }
                break;
        }
@@ -1081,7 +1080,7 @@ DispatchResult LyXText::dispatch(LCursor
 
        case LFUN_MOUSE_MOTION: {
                // Only use motion with button 1
-               //if (ev.button() != mouse_button::button1)
+               //if (cmd.button() != mouse_button::button1)
                //      return false;
                // The test for not selection possible is needed, that
                // only motion events are used, where the bottom press
@@ -1108,7 +1107,6 @@ DispatchResult LyXText::dispatch(LCursor
                // don't set anchor_
                bv->cursor().cursor_ = cur.cursor_;
                bv->cursor().setSelection();
-
                break;
        }
 
@@ -1209,7 +1207,7 @@ DispatchResult LyXText::dispatch(LCursor
 
                if (lyxrc.auto_region_delete) {
                        if (cur.selection())
-                               cutSelection(false, false);
+                               cutSelection(cur, false, false);
                        bv->haveSelection(false);
                }
 
@@ -1276,12 +1274,12 @@ DispatchResult LyXText::dispatch(LCursor
        case LFUN_ENVIRONMENT_INSERT:
                // Open the inset, and move the current selection
                // inside it.
-               doInsertInset(cur, this, bv, cmd, true, true);
+               doInsertInset(cur, this, cmd, true, true);
                break;
 
        case LFUN_INDEX_INSERT:
                // Just open the inset
-               doInsertInset(cur, this, bv, cmd, true, false);
+               doInsertInset(cur, this, cmd, true, false);
                break;
 
        case LFUN_INDEX_PRINT:
@@ -1290,26 +1288,26 @@ DispatchResult LyXText::dispatch(LCursor
        case LFUN_INSERT_LINE:
        case LFUN_INSERT_PAGEBREAK:
                // do nothing fancy
-               doInsertInset(cur, this, bv, cmd, false, false);
+               doInsertInset(cur, this, cmd, false, false);
                break;
 
        case LFUN_DEPTH_MIN:
                changeDepth(cur, bv_funcs::DEC_DEPTH);
-               bv->update();
+               cur.update();
                break;
 
        case LFUN_DEPTH_PLUS:
                changeDepth(cur, bv_funcs::INC_DEPTH);
-               bv->update();
+               cur.update();
                break;
 
        case LFUN_MATH_DISPLAY:
-               mathDispatch(cur, cmd, true);
+               mathDispatch(cur, this, cmd, true);
                break;
 
        case LFUN_MATH_IMPORT_SELECTION:
        case LFUN_MATH_MODE:
-               mathDispatch(cur, cmd, false);
+               mathDispatch(cur, this, cmd, false);
                break;
 
        case LFUN_MATH_MACRO:
@@ -1443,7 +1441,7 @@ DispatchResult LyXText::dispatch(LCursor
        case LFUN_FINISHED_LEFT:
                lyxerr << "handle LFUN_FINISHED_LEFT" << endl;
                cur.pop(cur.currentDepth());
-               if (rtl())
+               if (rtl(cur))
                        cursorLeft(cur, true);
                cur.bv().cursor() = cur;
                break;
@@ -1451,7 +1449,7 @@ DispatchResult LyXText::dispatch(LCursor
        case LFUN_FINISHED_RIGHT:
                lyxerr << "handle LFUN_FINISHED_RIGHT" << endl;
                cur.pop(cur.currentDepth());
-               if (!rtl())
+               if (!rtl(cur))
                        cursorRight(cur, true);
                cur.bv().cursor() = cur;
                break;
@@ -1532,7 +1530,7 @@ DispatchResult LyXText::dispatch(LCursor
                        }
 
                        setLayout(cur, tclass.defaultLayoutName());
-                       setParagraph(Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
+                       setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
                        cur.insert(new InsetFloatList(cmd.argument));
                        unFreezeUndo();
                } else {
@@ -1544,13 +1542,13 @@ DispatchResult LyXText::dispatch(LCursor
 
        case LFUN_ACCEPT_CHANGE: {
                acceptChange(cur);
-               bv->update();
+               cur.update();
                break;
        }
 
        case LFUN_REJECT_CHANGE: {
                rejectChange(cur);
-               bv->update();
+               cur.update();
                break;
        }
 
@@ -1566,6 +1564,25 @@ DispatchResult LyXText::dispatch(LCursor
                        }
                }
                bv->owner()->getDialogs().show("thesaurus", arg);
+               break;
+       }
+
+       case LFUN_PARAGRAPH_APPLY: {
+               // Given data, an encoding of the ParagraphParameters
+               // generated in the Paragraph dialog, this function sets
+               // the current paragraph appropriately.
+               istringstream is(cmd.argument);
+               LyXLex lex(0, 0);
+               lex.setStream(is);
+               ParagraphParameters params;
+               params.read(lex);
+               setParagraph(cur,
+                                        params.spacing(),
+                                        params.align(),
+                                        params.labelWidthString(),
+                                        params.noindent());
+               cur.update();
+               cur.message(_("Paragraph layout set"));
                break;
        }
 
Index: insets/insetcollapsable.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v
retrieving revision 1.236
diff -u -p -r1.236 insetcollapsable.C
--- insets/insetcollapsable.C   13 Feb 2004 07:30:58 -0000      1.236
+++ insets/insetcollapsable.C   13 Feb 2004 09:46:49 -0000
@@ -205,9 +205,7 @@ DispatchResult
 InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
 {
        if (cmd.button() == mouse_button::button3) {
-               lyxerr << "InsetCollapsable::lfunMouseRelease 0" << endl;
                showInsetDialog(&cur.bv());
-               return DispatchResult(true, true);
        }
 
        switch (status_) {
@@ -331,16 +329,14 @@ InsetCollapsable::priv_dispatch(LCursor 
                case LFUN_MOUSE_PRESS:
                        if (status_ == Inlined)
                                inset.dispatch(cur, cmd);
-                       else if (status_ == Open
-                                && cmd.y > button_dim.y2)
+                       else if (status_ == Open && cmd.y > button_dim.y2)
                                inset.dispatch(cur, cmd);
                        return DispatchResult(true, true);
 
                case LFUN_MOUSE_MOTION:
                        if (status_ == Inlined)
                                inset.dispatch(cur, cmd);
-                       else if (status_ == Open
-                                && cmd.y > button_dim.y2)
+                       else if (status_ == Open && cmd.y > button_dim.y2)
                                inset.dispatch(cur, cmd);
                        return DispatchResult(true, true);
 
Index: insets/insetcollapsable.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.h,v
retrieving revision 1.165
diff -u -p -r1.165 insetcollapsable.h
--- insets/insetcollapsable.h   6 Feb 2004 11:12:49 -0000       1.165
+++ insets/insetcollapsable.h   13 Feb 2004 09:46:49 -0000
@@ -85,7 +85,7 @@ public:
        ///
        void setLabel(std::string const & l);
        ///
-       virtual void setButtonLabel() {};
+       virtual void setButtonLabel() {}
        ///
        void setLabelFont(LyXFont & f);
        /// Appends \c list with all labels found within this inset.
Index: insets/insetlabel.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetlabel.C,v
retrieving revision 1.89
diff -u -p -r1.89 insetlabel.C
--- insets/insetlabel.C 20 Jan 2004 14:25:14 -0000      1.89
+++ insets/insetlabel.C 13 Feb 2004 09:46:49 -0000
@@ -12,20 +12,26 @@
 
 #include "insetlabel.h"
 
+#include "buffer.h"
 #include "BufferView.h"
 #include "dispatchresult.h"
 #include "funcrequest.h"
+#include "InsetList.h"
+#include "iterators.h"
+#include "lyxtext.h"
+#include "paragraph.h"
 
 #include "frontends/LyXView.h"
 
 #include "support/lstrings.h"
-
+#include "support/lyxalgo.h"
 #include "support/std_ostream.h"
 
 using lyx::support::escape;
 
 using std::string;
 using std::ostream;
+using std::vector;
 
 
 InsetLabel::InsetLabel(InsetCommandParams const & p)
@@ -51,6 +57,40 @@ string const InsetLabel::getScreenLabel(
 }
 
 
+namespace {
+
+void changeRefsIfUnique(BufferView & bv, string const & from, string const & to)
+{
+       // Check if the label 'from' appears more than once
+       vector<string> labels;
+       bv.buffer()->getLabelList(labels);
+
+       if (lyx::count(labels.begin(), labels.end(), from) > 1)
+               return;
+
+       InsetBase::Code code = InsetBase::REF_CODE;
+
+       ParIterator it = bv.buffer()->par_iterator_begin();
+       ParIterator end = bv.buffer()->par_iterator_end();
+       for ( ; it != end; ++it) {
+               bool changed_inset = false;
+               for (InsetList::iterator it2 = it->insetlist.begin();
+                    it2 != it->insetlist.end(); ++it2) {
+                       if (it2->inset->lyxCode() == code) {
+                               InsetCommand * inset = static_cast<InsetCommand 
*>(it2->inset);
+                               if (inset->getContents() == from) {
+                                       inset->setContents(to);
+                                       //inset->setButtonLabel();
+                                       changed_inset = true;
+                               }
+                       }
+               }
+       }
+}
+
+} // namespace anon
+
+
 DispatchResult
 InsetLabel::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
@@ -61,12 +101,10 @@ InsetLabel::priv_dispatch(LCursor & cur,
                InsetCommandMailer::string2params("label", cmd.argument, p);
                if (p.getCmdName().empty())
                        return DispatchResult(false);
-               bool clean = true;
                if (p.getContents() != params().getContents())
-                       clean = cur.bv().ChangeRefsIfUnique(params().getContents(),
+                       changeRefsIfUnique(cur.bv(), params().getContents(),
                                                       p.getContents());
                setParams(p);
-               cur.bv().update();
                return DispatchResult(true, true);
        }
 
Index: insets/insetref.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetref.C,v
retrieving revision 1.86
diff -u -p -r1.86 insetref.C
--- insets/insetref.C   26 Jan 2004 10:13:12 -0000      1.86
+++ insets/insetref.C   13 Feb 2004 09:46:49 -0000
@@ -40,8 +40,7 @@ InsetRef::InsetRef(InsetRef const & ir)
 {}
 
 
-DispatchResult
-InsetRef::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+DispatchResult InsetRef::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
        case LFUN_MOUSE_PRESS:
@@ -52,6 +51,9 @@ InsetRef::priv_dispatch(LCursor & cur, F
                        InsetCommandMailer("ref", *this).showDialog(&cur.bv());
                return DispatchResult(true, true);
 
+       case LFUN_MOUSE_RELEASE:
+               return DispatchResult(true, true);
+
        default:
                return InsetCommand::priv_dispatch(cur, cmd);
        }
@@ -61,15 +63,15 @@ InsetRef::priv_dispatch(LCursor & cur, F
 string const InsetRef::getScreenLabel(Buffer const &) const
 {
        string temp;
-       for (int i = 0; !types[i].latex_name.empty(); ++ i)
+       for (int i = 0; !types[i].latex_name.empty(); ++i) {
                if (getCmdName() == types[i].latex_name) {
                        temp = _(types[i].short_gui_name);
                        break;
                }
+       }
        temp += getContents();
 
-       if (!isLatex
-          && !getOptions().empty()) {
+       if (!isLatex && !getOptions().empty()) {
                temp += "||";
                temp += getOptions();
        }
Index: insets/insetref.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetref.h,v
retrieving revision 1.62
diff -u -p -r1.62 insetref.h
--- insets/insetref.h   20 Jan 2004 14:25:14 -0000      1.62
+++ insets/insetref.h   13 Feb 2004 09:46:49 -0000
@@ -12,13 +12,10 @@
 #ifndef INSET_REF_H
 #define INSET_REF_H
 
-
 #include "insetcommand.h"
 
-struct LaTeXFeatures;
 
-/** The reference inset
- */
+/// The reference inset
 class InsetRef : public InsetCommand {
 public:
        struct type_info {
@@ -68,9 +65,7 @@ public:
        void validate(LaTeXFeatures & features) const;
 protected:
        ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 private:
        ///
        bool isLatex;

Reply via email to