]> git.lyx.org Git - features.git/commitdiff
Implemented Search/Replace functionality for Insets. Cleaned up a bit.
authorJürgen Vigna <jug@sad.it>
Fri, 20 Jul 2001 14:18:48 +0000 (14:18 +0000)
committerJürgen Vigna <jug@sad.it>
Fri, 20 Jul 2001 14:18:48 +0000 (14:18 +0000)
Small fixes.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2296 a592a061-630c-0410-9148-cb99ea01b6c8

55 files changed:
src/BufferView_pimpl.C
src/ChangeLog
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlSearch.C
src/frontends/qt2/FormSearch.C
src/insets/ChangeLog
src/insets/figinset.C
src/insets/figinset.h
src/insets/inset.C
src/insets/inset.h
src/insets/insetbib.C
src/insets/insetbib.h
src/insets/insetcite.C
src/insets/insetcite.h
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/inseterror.C
src/insets/inseterror.h
src/insets/insetert.C
src/insets/insetert.h
src/insets/insetexternal.C
src/insets/insetexternal.h
src/insets/insetfloatlist.C
src/insets/insetfloatlist.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/insets/insetindex.C
src/insets/insetindex.h
src/insets/insetinfo.C [new file with mode: 0644]
src/insets/insetinfo.h [new file with mode: 0644]
src/insets/insetlabel.C
src/insets/insetlabel.h
src/insets/insetminipage.C
src/insets/insetparent.C
src/insets/insetparent.h
src/insets/insetref.C
src/insets/insetref.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/insettoc.C
src/insets/insettoc.h
src/insets/inseturl.C
src/insets/inseturl.h
src/lyxfind.C
src/lyxfind.h
src/lyxfunc.C
src/lyxtext.h
src/mathed/formulabase.C
src/mathed/formulabase.h
src/text.C
src/text2.C

index 77ede5b129087bf4ce26a425d04c0025a5cbc592..d0fc903f9ead00da7747b42a45dd0f552d8f60e4 100644 (file)
@@ -256,9 +256,16 @@ bool BufferView::Pimpl::fitCursor(LyXText * text)
 {
        lyx::Assert(screen_.get());
 
-       bv_->owner()->getDialogs()->updateParagraph();
+       bool ret;
+
+       if (bv_->theLockingInset()) {
+               bv_->theLockingInset()->fitInsetCursor(bv_);
+               ret = true;
+       } else {
+               ret = screen_->fitCursor(text, bv_);
+       }
 
-       bool const ret = screen_->fitCursor(text, bv_);
+       bv_->owner()->getDialogs()->updateParagraph();
        if (ret)
            updateScrollbar();
        return ret;
@@ -1004,14 +1011,15 @@ void BufferView::Pimpl::update(LyXText * text, BufferView::UpdateCodes f)
        text->fullRebreak(bv_);
 
        if (text->inset_owner) {
-           text->inset_owner->setUpdateStatus(bv_, InsetText::NONE);
+               text->inset_owner->setUpdateStatus(bv_, InsetText::NONE);
            updateInset(text->inset_owner, true);
-       } else
+       } else {
            update();
-
+       }
+               
        if ((f & FITCUR)) {
                fitCursor(text);
-       }
+       }
 
        if ((f & CHANGE)) {
                buffer_->markDirty();
@@ -1252,15 +1260,23 @@ bool BufferView::Pimpl::belowMouse() const
 
 void BufferView::Pimpl::showCursor()
 {
-       if (screen_.get())
-               screen_->showCursor(bv_->text, bv_);
+       if (screen_.get()) {
+               if (bv_->theLockingInset())
+                       bv_->theLockingInset()->showInsetCursor(bv_);
+               else
+                       screen_->showCursor(bv_->text, bv_);
+       }
 }
 
 
 void BufferView::Pimpl::hideCursor()
 {
-       if (screen_.get())
-               screen_->hideCursor();
+       if (screen_.get()) {
+               if (!bv_->theLockingInset())
+//                     bv_->theLockingInset()->hideInsetCursor(bv_);
+//             else
+                       screen_->hideCursor();
+       }
 }
 
 
@@ -1467,7 +1483,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                } else {
                        // this is need because you don't use a inset->Edit()
                        updateInset(new_inset, true);
-                       new_inset->edit(bv_, 0, 0, 0);
+                       new_inset->edit(bv_);
                }
                break;
        }
@@ -1814,15 +1830,10 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                    && lt->cursor.par()->getInset(lt->cursor.pos())->editable() == Inset::HIGHLY_EDITABLE){
                        Inset * tmpinset = lt->cursor.par()->getInset(lt->cursor.pos());
                        owner_->getLyXFunc()->setMessage(tmpinset->editMessage());
-                       int y = 0;
-                       if (is_rtl) {
-                               LyXFont const font = 
-                                       lt->getFont(buffer_,
-                                                   lt->cursor.par(),
-                                                   lt->cursor.pos());  
-                               y = tmpinset->descent(bv_,font);
-                       }
-                       tmpinset->edit(bv_, 0, y, 0);
+                       if (is_rtl)
+                               tmpinset->edit(bv_, false);
+                       else
+                               tmpinset->edit(bv_);
                        break;
                }
                if (!is_rtl)
@@ -1855,15 +1866,10 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                {
                        Inset * tmpinset = lt->cursor.par()->getInset(lt->cursor.pos());
                        owner_->getLyXFunc()->setMessage(tmpinset->editMessage());
-                       LyXFont const font = lt->getFont(buffer_,
-                                                        lt->cursor.par(),
-                                                        lt->cursor.pos());
-                       int y = is_rtl ? 0 
-                               : tmpinset->descent(bv_,font);
-                       tmpinset->edit(bv_,
-                                      tmpinset->x() +
-                                      tmpinset->width(bv_,font),
-                                      y, 0);
+                       if (is_rtl)
+                               tmpinset->edit(bv_);
+                       else
+                               tmpinset->edit(bv_, false);
                        break;
                }
                if  (is_rtl)
@@ -2686,7 +2692,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        {
                InsetText * new_inset = new InsetText;
                if (insertInset(new_inset))
-                       new_inset->edit(bv_, 0, 0, 0);
+                       new_inset->edit(bv_);
                else
                        delete new_inset;
        }
@@ -2696,7 +2702,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        {
                InsetERT * new_inset = new InsetERT;
                if (insertInset(new_inset))
-                       new_inset->edit(bv_, 0, 0, 0);
+                       new_inset->edit(bv_);
                else
                        delete new_inset;
        }
@@ -2706,7 +2712,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        {
                InsetExternal * new_inset = new InsetExternal;
                if (insertInset(new_inset))
-                       new_inset->edit(bv_, 0, 0, 0);
+                       new_inset->edit(bv_);
                else
                        delete new_inset;
        }
@@ -2716,7 +2722,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        {
                InsetFoot * new_inset = new InsetFoot;
                if (insertInset(new_inset))
-                       new_inset->edit(bv_, 0, 0, 0);
+                       new_inset->edit(bv_);
                else
                        delete new_inset;
        }
@@ -2726,7 +2732,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        {
                InsetMarginal * new_inset = new InsetMarginal;
                if (insertInset(new_inset))
-                       new_inset->edit(bv_, 0, 0, 0);
+                       new_inset->edit(bv_);
                else
                        delete new_inset;
        }
@@ -2736,7 +2742,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        {
                InsetMinipage * new_inset = new InsetMinipage;
                if (insertInset(new_inset))
-                       new_inset->edit(bv_, 0, 0, 0);
+                       new_inset->edit(bv_);
                else
                        delete new_inset;
        }
@@ -2748,7 +2754,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                if (floatList.typeExist(argument)) {
                        InsetFloat * new_inset = new InsetFloat(argument);
                        if (insertInset(new_inset))
-                               new_inset->edit(bv_, 0, 0, 0);
+                               new_inset->edit(bv_);
                        else
                                delete new_inset;
                } else {
@@ -2766,7 +2772,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        InsetFloat * new_inset = new InsetFloat(argument);
                        new_inset->wide(true);
                        if (insertInset(new_inset))
-                               new_inset->edit(bv_, 0, 0, 0);
+                               new_inset->edit(bv_);
                        else
                                delete new_inset;
                } else {
@@ -2781,7 +2787,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        {
                InsetList * new_inset = new InsetList;
                if (insertInset(new_inset))
-                       new_inset->edit(bv_, 0, 0, 0);
+                       new_inset->edit(bv_);
                else
                        delete new_inset;
        }
@@ -2791,7 +2797,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        {
                InsetTheorem * new_inset = new InsetTheorem;
                if (insertInset(new_inset))
-                       new_inset->edit(bv_, 0, 0, 0);
+                       new_inset->edit(bv_);
                else
                        delete new_inset;
        }
@@ -2809,7 +2815,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        new_inset->setDrawFrame(0, InsetText::LOCKED);
                        new_inset->setFrameColor(0, LColor::captionframe);
                        if (insertInset(new_inset))
-                               new_inset->edit(bv_, 0, 0, 0);
+                               new_inset->edit(bv_);
                        else
                                delete new_inset;
                }
@@ -2980,7 +2986,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                
                if (insertInset(inset)) {
                        if (argument.empty())
-                               inset->edit(bv_, 0, 0, 0);
+                               inset->edit(bv_);
                } else
                        delete inset;
        }
@@ -3263,6 +3269,7 @@ void BufferView::Pimpl::protectedBlank(LyXText * lt)
        }
 }
 
+
 void BufferView::Pimpl::specialChar(InsetSpecialChar::Kind kind)
 {
        if (available()) {
@@ -3281,7 +3288,7 @@ void BufferView::Pimpl::insertNote()
 {
        Inset * inset = new InsetNote;
        insertInset(inset);
-       inset->edit(bv_, 0, 0, 0);
+       inset->edit(bv_);
 }
 
 
@@ -3296,11 +3303,7 @@ bool BufferView::Pimpl::open_new_inset(UpdatableInset * new_inset, bool behind)
                delete new_inset;
                return false;
        }
-       if (behind) {
-               LyXFont & font = lt->real_current_font;
-               new_inset->edit(bv_, new_inset->width(bv_, font), 0, 0);
-       } else
-               new_inset->edit(bv_, 0, 0, 0);
+       new_inset->edit(bv_, !behind);
        return true;
 }
 
index 6acf4f1e4f706436198a0f51cad8d260cfb62775..147d69111066241cb4f2950660dc4862f7d5ccc0 100644 (file)
@@ -1,3 +1,29 @@
+2001-07-20  Juergen Vigna  <jug@sad.it>
+
+       * lyxfunc.C (dispatch): use always LyXFind now!
+
+       * text2.C (init): add a reinit flag so that the LyXText can be
+       reinited instead of deleted and reallocated (used in InsetText).
+
+       * BufferView_pimpl.C: use the new Inset::edit(BV, bool) where needed.
+
+       * text.C: ditto
+
+       * text2.C: ditto
+
+2001-07-18  Juergen Vigna  <jug@sad.it>
+
+       * text.C (selectNextWord): handle insets inside inset by calling
+       always the bv->text functions so that we can go up the_locking_inset!
+
+       * BufferView_pimpl.C (show/hideCursor): fixed cursor showing up
+       in strange locations when inside an inset!
+
+       * lyxfind.[Ch]: give all functions a LyXText * parameter and implement
+       handling to include insets.
+
+       * lyxfunc.C (dispatch): changes to calls SearchBackward/Forward.
+
 2001-07-20  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * LyXAction.C (init): 
index 9d1133d01cf367a3f43ecf91b9b88ce32bdf7b34..5bac989afb65e55fe6dca7736a7881beb655f5b8 100644 (file)
@@ -1,3 +1,7 @@
+2001-07-18  Juergen Vigna  <jug@sad.it>
+
+       * ControlSearch.C (replace): changes to lyxfind.h function calls.
+
 2001-07-19  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * biblio.C (getInfo): add a .c_str() to handle the usual
index 5b6305d8efb48e2e7db90f0ad353e56b53924706..9f03e815acaa54d0d47da742fc2685f497b5e929 100644 (file)
@@ -46,8 +46,8 @@ ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
 void ControlSearch::find(string const & search,
                         bool casesensitive, bool matchword, bool forward) const
 {
-       bool const found = LyXFind(lv_.view(), search, casesensitive,
-                                  matchword, forward);
+       bool const found = LyXFind(lv_.view(), search,
+                                  forward, false, casesensitive, matchword);
    
        if (!found)
                setMinibuffer(&lv_, _("String not found!"));
@@ -58,8 +58,8 @@ void ControlSearch::replace(string const & search, string const & replace,
                            bool casesensitive, bool matchword, bool all) const
 {
        int const replace_count = LyXReplace(lv_.view(),
-                                            search, replace, casesensitive, 
-                                            matchword, true, all);
+                                            search, replace, true, casesensitive, 
+                                            matchword, all);
                                  
        if (replace_count == 0) {
                setMinibuffer(&lv_, _("String not found!"));
index d5646174ddd9ad9f7b588ba81b3b953b868eb88a..5fe95c8752c854737eaf333fd166b7d9c30a7ec2 100644 (file)
@@ -61,8 +61,8 @@ void FormSearch::show()
 void FormSearch::find(string const & searchstr, bool const & casesensitive,
                                bool const & matchword, bool const & searchback)
 {
-       bool found = LyXFind(lv_->view(), searchstr,    casesensitive, matchword,
-                       searchback);
+       bool found = LyXFind(lv_->view(), searchstr, searchback,
+                                                casesensitive, matchword);
        
        if (!found)
                setMinibuffer(lv_, _("String not found!"));
@@ -73,7 +73,7 @@ void FormSearch::replace(string const & searchstr, string const & replacestr,
                         bool const & searchback, bool const & replaceall)
 {
        int replace_count = LyXReplace(lv_->view(), searchstr, replacestr,
-                                 casesensitive, matchword, searchback,
+                                 searchback, casesensitive, matchword,
                                  replaceall);
                                  
        if (replace_count == 0) {
index 5ad07060bf18aa123c2b1c31268892172b508271..250fb1297ff6a18e16b60b9f477029e8d79ae6ab 100644 (file)
@@ -1,3 +1,24 @@
+2001-07-20  Juergen Vigna  <jug@sad.it>
+
+       * insetcollapsable.C (update): recoded hopefully works now!
+
+2001-07-19  Juergen Vigna  <jug@sad.it>
+
+       * most files: implemented the below new introduced function.
+       
+       * inset.h: added new edit(BufferView *, bool front) method to be able
+       to enter an inset from the front/back without knowing x/y positions
+       and baselines inside the inset. So I just can tell the inset activate
+       me and set the cursor on the front/back of yourself.
+
+2001-07-18  Juergen Vigna  <jug@sad.it>
+
+       * insetcollapsable.C (edit): fixed hopefully the y parameter which
+       is givven to the InsetText.
+       (insetButtonPress): ditto
+       (insetButtonRelease): ditto
+       (insetMotionNotify): ditto
+
 2001-07-20  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * insetspecialchar.[Ch]: change HYPHENATION_BREAK to
@@ -63,6 +84,8 @@
 
        * insettabular.C (selectNextWord): fixed spellchecking for the
        first cell of a tabular (wasn't entered!)
+       (getLyXText): changed to enter automatically insettext and return
+       it's LyXText if we're locked.
 
 2001-07-17  Juergen Vigna  <jug@sad.it>
 
index 9fe6941a05b4528e3f04470ba7d07eb3ddf07f89..ece18587a149bd3b775eadbbfc3d4e3e740401e3 100644 (file)
@@ -1240,6 +1240,12 @@ void InsetFig::edit(BufferView * bv, int, int, unsigned int)
 }
 
 
+void InsetFig::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
 Inset * InsetFig::clone(Buffer const & buffer, bool) const
 {
        InsetFig * tmp = new InsetFig(100, 100, buffer);
index daef7707de785e043dd0e677c0dc4f84ff01a591..b17a3b8512e363a73d0001a0f057f1c0f84f5010 100644 (file)
@@ -53,6 +53,8 @@ public:
        ///
        void edit(BufferView *, int, int, unsigned int);
        ///
+       void edit(BufferView * bv, bool front = true);
+       ///
        EDITABLE editable() const;
        ///
        bool deletable() const;
index 28458d27160c72f48b9ded761e8d12c63c720b4c..315cf2444cd3683e51f92d9b78cad6bd8f69d41e 100644 (file)
@@ -65,6 +65,10 @@ void Inset::edit(BufferView *, int, int, unsigned int)
 {}
 
 
+void Inset::edit(BufferView *, bool)
+{}
+
+
 LyXFont const Inset::convertFont(LyXFont const & font) const
 {
        return LyXFont(font);
@@ -150,10 +154,18 @@ void UpdatableInset::hideInsetCursor(BufferView *)
 {}
 
 
+void UpdatableInset::fitInsetCursor(BufferView *) const
+{}
+
+
 void UpdatableInset::edit(BufferView *, int, int, unsigned int)
 {}
 
 
+void UpdatableInset::edit(BufferView *, bool)
+{}
+
+
 void UpdatableInset::draw(BufferView *, LyXFont const &,
                          int /* baseline */, float & x,
                          bool/*cleared*/) const
@@ -266,3 +278,19 @@ string UpdatableInset::selectNextWord(BufferView *bv, float & value) const
        value = 0;
        return string();
 }
+
+bool UpdatableInset::searchForward(BufferView * bv, string const &,
+                                   bool const &, bool const &)
+{
+       // we have to unlock ourself in this function by default!
+       bv->unlockInset(const_cast<UpdatableInset *>(this));
+       return false;
+}
+
+bool UpdatableInset::searchBackward(BufferView * bv, string const &,
+                                    bool const &, bool const &)
+{
+       // we have to unlock ourself in this function by default!
+       bv->unlockInset(const_cast<UpdatableInset *>(this));
+       return false;
+}
index 84625c98e8926df242b97ab746b47949184e1527..b095fab7e64a7ea53e13c92cd2da4b335d7fd219 100644 (file)
@@ -148,6 +148,8 @@ public:
        ///
        virtual void edit(BufferView *, int x, int y, unsigned int button);
        ///
+       virtual void edit(BufferView *, bool front = true);
+       ///
        virtual EDITABLE editable() const;
        /// This is called when the user clicks inside an inset
        virtual void insetButtonPress(BufferView *, int, int, int) {}
@@ -353,6 +355,8 @@ public:
        ///
        virtual void hideInsetCursor(BufferView *);
        ///
+       virtual void fitInsetCursor(BufferView *) const;
+       ///
        virtual void getCursorPos(BufferView *, int &, int &) const {}
        ///
        virtual void insetButtonPress(BufferView *, int x, int y, int button);
@@ -368,6 +372,8 @@ public:
        ///
        virtual void edit(BufferView *, int x, int y, unsigned int button);
        ///
+       virtual void edit(BufferView *, bool front = true);
+       ///
        virtual void draw(BufferView *, LyXFont const &,
                          int baseline, float & x, bool cleared) const;
        ///
@@ -423,6 +429,13 @@ public:
        virtual void toggleSelection(BufferView *, bool /*kill_selection*/) {
                return;
        }
+       ///
+       // needed for search/replace functionality
+       ///
+       virtual bool searchForward(BufferView *, string const &,
+                                  bool const & = true, bool const & = false);
+       virtual bool searchBackward(BufferView *, string const &,
+                                   bool const & = true, bool const & = false);
 
 protected:
        ///
index c1b2226d2e840364b2e7698dbf06a1bfde4831c4..28836d50530b86902787ddab6f01bb0e53b540ab 100644 (file)
@@ -113,6 +113,12 @@ void InsetBibKey::edit(BufferView * bv, int, int, unsigned int)
 }
 
 
+void InsetBibKey::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
 InsetBibtex::InsetBibtex(InsetCommandParams const & p, bool)
        : InsetCommand(p)
 {}
@@ -217,6 +223,12 @@ void InsetBibtex::edit(BufferView * bv, int, int, unsigned int)
 }
 
 
+void InsetBibtex::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
 bool InsetBibtex::addDatabase(string const & db)
 {
        string contents(getContents());
@@ -253,6 +265,7 @@ bool InsetBibtex::delDatabase(string const & db)
 int bibitemMaxWidth(BufferView * bv, LyXFont const & font)
 {
        int w = 0;
+#warning Ha, now we are mainly at 1.2.0 and it is still here (Jug)
        // Does look like a hack? It is! (but will change at 0.13)
        Paragraph * par = bv->buffer()->paragraph;
     
index 4dbd137305f53be11b21b1595db93056f94bd706..f870f636ed246d526f9082fa157dd4a134cc1988 100644 (file)
@@ -42,9 +42,11 @@ public:
        void read(Buffer const *, LyXLex & lex);
        ///
        virtual string const getScreenLabel() const;
-        ///
+       ///
        void edit(BufferView *, int x, int y, unsigned int button);
        ///
+       void edit(BufferView * bv, bool front = true);
+       ///
        EDITABLE editable() const {
                return IS_EDITABLE;
        }
@@ -52,10 +54,10 @@ public:
        bool deletable() const {
                return false;
        }
-        ///
-        void setCounter(int);
-        ///
-        int  getCounter() const { return counter; }
+       ///
+       void setCounter(int);
+       ///
+       int  getCounter() const { return counter; }
        ///
        string const getBibLabel() const;
        ///
@@ -66,7 +68,7 @@ public:
  
 private:
        ///
-        int counter;
+       int counter;
        ///
        Holder holder;
        ///
@@ -94,15 +96,17 @@ public:
        Inset::Code lyxCode() const { return Inset::BIBTEX_CODE; }
        ///
        void edit(BufferView *, int x, int y, unsigned int button);
+       ///
+       void edit(BufferView * bv, bool front = true);
        /// 
        int latex(Buffer const *, std::ostream &,
-                 bool fragile, bool freespace) const;
+                 bool fragile, bool freespace) const;
        ///
        std::vector<std::pair<string,string> > const getKeys(Buffer const *) const;
-        ///
-        bool addDatabase(string const &);
-        ///
-        bool delDatabase(string const &);
+       ///
+       bool addDatabase(string const &);
+       ///
+       bool delDatabase(string const &);
        ///
        bool display() const { return true; } 
        ///
index 591e450bba40914e359746f104c9272c836b18b6..934e463e6065dc9e281e1f11ebb2cd3ccd921620 100644 (file)
@@ -63,6 +63,11 @@ void InsetCitation::edit(BufferView * bv, int, int, unsigned int)
        bv->owner()->getDialogs()->showCitation(this);
 }
 
+void InsetCitation::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
 int InsetCitation::ascii(Buffer const *, std::ostream & os, int) const
 {
         os << "[" << getContents() << "]";
@@ -96,4 +101,3 @@ void InsetCitation::validate(LaTeXFeatures & features) const
        if (getCmdName() != "cite" && features.bufferParams().use_natbib)
                features.natbib = true;
 }
-
index 58a413bafd1284009a994d6985bbbccf3da1af85..75db049ea2e69c7b76379ccb8d67da3f5f9b86fe 100644 (file)
@@ -33,9 +33,11 @@ public:
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
        Inset::Code lyxCode() const { return Inset::CITE_CODE; }
-        ///
+       ///
        void edit(BufferView *, int, int, unsigned int);
        ///
+       void edit(BufferView * bv, bool front = true);
+       ///
        int ascii(Buffer const *, std::ostream &, int linelen) const;
         ///
        int latex(Buffer const *, std::ostream &, bool, bool) const;
index 1b45ec382dbadd4c7faeec39e32c3620f8528332..b99efbb55cb38cd6290c2e0db28e4aa019442bde 100644 (file)
@@ -225,7 +225,7 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
 
 
 void InsetCollapsable::edit(BufferView * bv, int xp, int yp,
-                           unsigned int button)
+                            unsigned int button)
 {
        UpdatableInset::edit(bv, xp, yp, button);
 
@@ -238,7 +238,30 @@ void InsetCollapsable::edit(BufferView * bv, int xp, int yp,
        } else {
                if (!bv->lockInset(this))
                        return;
-               inset.edit(bv, xp, yp + (top_baseline - inset.y()), button);
+               LyXFont font(LyXFont::ALL_SANE);
+               int yy = ascent(bv, font) + yp -
+                   (ascent_collapsed(bv->painter(), font) +
+                    descent_collapsed(bv->painter(), font) +
+                    inset.ascent(bv, font));
+               inset.edit(bv, xp, yy, button);
+       }
+}
+
+
+void InsetCollapsable::edit(BufferView * bv, bool front)
+{
+       UpdatableInset::edit(bv, front);
+
+       if (collapsed_) {
+               collapsed_ = false;
+               if (!bv->lockInset(this))
+                       return;
+               bv->updateInset(this, false);
+               inset.edit(bv, front);
+       } else {
+               if (!bv->lockInset(this))
+                       return;
+               inset.edit(bv, front);
        }
 }
 
@@ -267,8 +290,12 @@ void InsetCollapsable::insetButtonPress(BufferView * bv, int x, int y,
                                        int button)
 {
        if (!collapsed_ && (y > button_bottom_y)) {
-               inset.insetButtonPress(bv, x, y + (top_baseline - inset.y()),
-                                      button);
+               LyXFont font(LyXFont::ALL_SANE);
+               int yy = ascent(bv, font) + y -
+                   (ascent_collapsed(bv->painter(), font) +
+                    descent_collapsed(bv->painter(), font) +
+                    inset.ascent(bv, font));
+               inset.insetButtonPress(bv, x, yy, button);
        }
 }
 
@@ -288,8 +315,12 @@ void InsetCollapsable::insetButtonRelease(BufferView * bv,
                        bv->updateInset(this, false);
                }
        } else if (!collapsed_ && (y > button_top_y)) {
-               inset.insetButtonRelease(bv, x, y + (top_baseline-inset.y()),
-                                        button);
+               LyXFont font(LyXFont::ALL_SANE);
+               int yy = ascent(bv, font) + y -
+                   (ascent_collapsed(bv->painter(), font) +
+                    descent_collapsed(bv->painter(), font) +
+                    inset.ascent(bv, font));
+               inset.insetButtonRelease(bv, x, yy, button);
        }
 }
 
@@ -298,8 +329,12 @@ void InsetCollapsable::insetMotionNotify(BufferView * bv,
                                         int x, int y, int state)
 {
        if (x > button_bottom_y) {
-               inset.insetMotionNotify(bv, x, y + (top_baseline - inset.y()),
-                                       state);
+               LyXFont font(LyXFont::ALL_SANE);
+               int yy = ascent(bv, font) + y -
+                   (ascent_collapsed(bv->painter(), font) +
+                    descent_collapsed(bv->painter(), font) +
+                    inset.ascent(bv, font));
+               inset.insetMotionNotify(bv, x, yy, state);
        }
 }
 
@@ -335,6 +370,7 @@ int InsetCollapsable::getMaxWidth(BufferView * bv,
 void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
                              bool reinit)
 {
+#if 0
        if (reinit) {
                need_update = FULL;
                if (owner())
@@ -359,7 +395,11 @@ void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
                        return;
                }
        }
-       inset.update(bv, font);
+#else
+       if (!widthCollapsed)
+               widthCollapsed = width_collapsed(bv->painter(), font);
+       inset.update(bv, font, reinit);
+#endif
 }
 
 
@@ -425,6 +465,18 @@ void InsetCollapsable::toggleInsetCursor(BufferView * bv)
 }
 
 
+void InsetCollapsable::showInsetCursor(BufferView * bv, bool show)
+{
+       inset.showInsetCursor(bv, show);
+}
+
+
+void InsetCollapsable::hideInsetCursor(BufferView * bv)
+{
+       inset.hideInsetCursor(bv);
+}
+
+
 UpdatableInset * InsetCollapsable::getLockingInset() const
 {
        UpdatableInset * in = inset.getLockingInset();
index 3fdd9e2145c8a892df6d6c4c2cfa37906783560e..e672030953e266d19271e696aed98c4c80c68dee 100644 (file)
@@ -60,6 +60,8 @@ public:
        ///
        void edit(BufferView *, int, int, unsigned int);
        ///
+       void edit(BufferView *, bool front = true);
+       ///
        EDITABLE editable() const;
        ///
        bool insertInset(BufferView *, Inset * inset);
@@ -111,6 +113,13 @@ public:
        ///
        void toggleInsetCursor(BufferView *);
        ///
+       void showInsetCursor(BufferView *, bool show = true);
+       ///
+       void hideInsetCursor(BufferView *);
+       ///
+       void fitInsetCursor(BufferView * bv) const {
+               inset.fitInsetCursor(bv);
+       }
        UpdatableInset * getLockingInset() const;
        ///
        UpdatableInset * getFirstLockingInsetOfType(Inset::Code);
@@ -166,6 +175,15 @@ public:
        void toggleSelection(BufferView * bv, bool kill_selection) {
                inset.toggleSelection(bv, kill_selection);
        }
+       ///
+       bool searchForward(BufferView * bv, string const & str,
+                          bool const & cs = true, bool const & mw = false) {
+               return inset.searchForward(bv, str, cs, mw);
+       }
+       bool searchBackward(BufferView * bv, string const & str,
+                           bool const & cs = true, bool const & mw = false) {
+               return inset.searchBackward(bv, str, cs, mw);
+       }
 
 protected:
        ///
index adeec9280fbf87bd9d3669742f8251f47aeb52ba..20810a11ae8b1cbc370173847bcb120c9a6d9477 100644 (file)
@@ -89,3 +89,9 @@ void InsetError::edit(BufferView * bv, int, int, unsigned int)
 {
        bv->owner()->getDialogs()->showError( this );
 }
+
+
+void InsetError::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
index 62f146a6871c9abbf8d80c765be431f78ad8b8fb..71fe69716c1e76500a3e3a3d5b8847eef40c594a 100644 (file)
@@ -59,6 +59,8 @@ public:
        ///
        void edit(BufferView *, int, int, unsigned int);
        ///
+       void edit(BufferView * bv, bool front = true);
+       ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
        Inset * clone(Buffer const &, bool same_id = false) const {
index d81701590edd5b630c1cfead3e04dd75ee45d99e..d6c4542ae0452e952dd275672fab216bc850d5be 100644 (file)
@@ -114,6 +114,12 @@ void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button)
 }
 
 
+void InsetERT::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
 int InsetERT::latex(Buffer const *, std::ostream & os, bool /*fragile*/,
                    bool /*free_spc*/) const
 {
index 8308203ca494cdd2653988dac47bb3bc5dc1c884..9533e8eee03841eec25c2dcbdced13b678206937 100644 (file)
@@ -43,15 +43,17 @@ public:
        virtual bool insetAllowed(Inset::Code) const { return false; }
        ///
        virtual void setFont(BufferView *, LyXFont const &,
-                            bool toggleall = false, bool selectall = false);
+                            bool toggleall = false, bool selectall = false);
        ///
        virtual void edit(BufferView *, int, int, unsigned int);
        ///
+       virtual void edit(BufferView * bv, bool front = true);
+       ///
        virtual int latex(Buffer const *, std::ostream &, bool fragile,
-                         bool free_spc) const;
+                         bool free_spc) const;
        ///
        virtual int ascii(Buffer const *,
-                         std::ostream &, int linelen = 0) const;
+                         std::ostream &, int linelen = 0) const;
        ///
        virtual int linuxdoc(Buffer const *, std::ostream &) const;
        ///
index 408a9ba40ec7efa4fc7aa5597cc7976c019d6a22..51f177de40f5cecb313db0678db8da7dbc454220 100644 (file)
@@ -77,6 +77,12 @@ void InsetExternal::edit(BufferView * bv,
 }
 
 
+void InsetExternal::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
 void InsetExternal::write(Buffer const *, std::ostream & os) const
 {
        os << "External " << params_.templ.lyxName << ",\"" << params_.filename 
index 2bc0a2a152fbc4e10fea5049704f618b26aba77b..fee519ee71d1fcb120e252cea4f469d1360ff905 100644 (file)
@@ -46,6 +46,8 @@ public:
        ///
        virtual void edit(BufferView *, int x, int y, unsigned int button);
        ///
+       virtual void edit(BufferView * bv, bool front = true);
+       ///
        virtual EDITABLE editable() const { return IS_EDITABLE; }
        ///
        virtual void write(Buffer const *, std::ostream &) const;
@@ -59,7 +61,7 @@ public:
         is in a free-spacing paragraph.
         */
        virtual int latex(Buffer const *, std::ostream &, bool fragile,
-                         bool free_spc) const;
+                         bool free_spc) const;
        /// write ASCII output to the ostream
        virtual int ascii(Buffer const *, std::ostream &, int linelen) const;
        /// write LinuxDoc output to the ostream
index 64ab198f3d66fd51acd43dc026e333f5e1d0d829..3cb79a2c25c2d32143ec42d82ea1d10f3f86f5b5 100644 (file)
@@ -68,6 +68,12 @@ void InsetFloatList::edit(BufferView *, int, int, unsigned int)
 }
 
 
+void InsetFloatList::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
 int InsetFloatList::latex(Buffer const *, std::ostream & os, bool, bool) const
 {
        FloatList::const_iterator cit = floatList[float_type];
index 83f32e6bfe6113130be6a791a97fb5ac95d282c1..bf50f8ea10e2ce6c3afff6048d09bd648164974c 100644 (file)
@@ -31,11 +31,13 @@ public:
        Inset * clone(Buffer const &, bool = false) const {
                return new InsetFloatList(*this);
        }
-       ///
+       ///
        string const getScreenLabel() const;
        ///
        void edit(BufferView * bv, int, int, unsigned int);
-        ///
+       ///
+       void edit(BufferView * bv, bool front = true);
+       ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
        bool display() const { return true; }
index d5e90bd6d2c73bcf8ec999c598672f04640bef3b..447c643f22336510338da4cb833ca6ec45270e6e 100644 (file)
@@ -316,6 +316,12 @@ void InsetGraphics::edit(BufferView *bv, int, int, unsigned int)
 }
 
 
+void InsetGraphics::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
 Inset::EDITABLE InsetGraphics::editable() const
 {
        return IS_EDITABLE;
index 9db4f94b78041952e6fe4d6791fff4023cc2548b..045995b7649ab51175a09f3b214c3abb5e53714f 100644 (file)
@@ -52,6 +52,8 @@ public:
        ///
        void edit(BufferView *, int, int, unsigned int);
        ///
+       void edit(BufferView * bv, bool front = true);
+       ///
        EDITABLE editable() const;
        ///
        void write(Buffer const *, std::ostream &) const;
index ea25f71c8920fa6962bb74b2989f77ee29b3cd8a..12315f3cc37c096106535b93d34575e46cb88b3c 100644 (file)
@@ -127,6 +127,12 @@ void InsetInclude::edit(BufferView * bv, int, int, unsigned int)
 }
 
 
+void InsetInclude::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
 void InsetInclude::write(Buffer const *, ostream & os) const
 {
        os << "Include " << params_.cparams.getCommand() << "\n";
index 45257ad1eb76d81c615b8091b4b66a9217576b4f..892ed6be2063802e430fe6c2aa0c2f59f5384cee 100644 (file)
@@ -79,17 +79,19 @@ public:
        ///
        void edit(BufferView *, int x, int y, unsigned int button);
        ///
+       void edit(BufferView * bv, bool front = true);
+       ///
        EDITABLE editable() const
        {
                return IS_EDITABLE;
        }
-        /// With lyx3 we won't overload these 3 methods
-        void write(Buffer const *, std::ostream &) const;
-        ///
+       /// With lyx3 we won't overload these 3 methods
+       void write(Buffer const *, std::ostream &) const;
+       ///
        void read(Buffer const *, LyXLex &);
        ///
        int latex(Buffer const *, std::ostream &,
-                 bool fragile, bool free_spc) const;
+                 bool fragile, bool free_spc) const;
        ///
        int ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
index a15c1e23e9d9e90576968b50707a93eb03960d11..eccde8d07c1c9bf1f8e6549dfdfa0a6e7ab4dbc5 100644 (file)
@@ -28,6 +28,12 @@ void InsetIndex::edit(BufferView * bv, int, int, unsigned int)
 }
 
 
+void InsetIndex::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p, bool)
        : InsetCommand(p)
 {}
index 211043d9452086a0ee79c7adfe038dd3e54f8fa2..5182e5684c564cd81cb2598ed1143e56d52cf133 100644 (file)
@@ -36,6 +36,8 @@ public:
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
        void edit(BufferView *, int, int, unsigned int);
+       ///
+       void edit(BufferView * bv, bool front = true);
 };
 
 
@@ -52,6 +54,8 @@ public:
        ///
        void edit(BufferView *, int, int, unsigned int) {}
        ///
+       void edit(BufferView * bv, bool front = true) {}
+       ///
        EDITABLE editable() const{ return NOT_EDITABLE; }
        ///
        bool display() const { return true; }
diff --git a/src/insets/insetinfo.C b/src/insets/insetinfo.C
new file mode 100644 (file)
index 0000000..0a4499a
--- /dev/null
@@ -0,0 +1,261 @@
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *      
+ *         Copyright 1995 Matthias Ettrich
+ *          Copyright 1995-2001 The LyX Team.
+ *
+ * ====================================================== */
+
+#include <config.h>
+
+#include <cctype>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "insetinfo.h"
+#include "paragraph.h"
+#include "debug.h"
+#include "gettext.h"
+#include "lyx_gui_misc.h" // CancelCloseBoxCB
+#include "buffer.h"
+#include "support/lstrings.h"
+#include "Painter.h"
+#include "font.h"
+#include "BufferView.h"
+
+using std::ostream;
+using std::endl;
+
+/* Info, used for the Info boxes */
+
+extern BufferView * current_view;
+
+
+InsetInfo::InsetInfo()
+       : form(0), labelfont(LyXFont::ALL_SANE)
+{
+       labelfont.decSize().decSize()
+               .setColor(LColor::note)
+#ifndef NO_LATEX
+               .setLatex(LyXFont::OFF)
+#endif
+               ;
+}
+
+
+InsetInfo::InsetInfo(string const & str)
+       : contents(str), form(0), labelfont(LyXFont::ALL_SANE)
+{
+       labelfont.decSize().decSize()
+               .setColor(LColor::note)
+#ifndef NO_LATEX
+               .setLatex(LyXFont::OFF)
+#endif
+               ;
+}
+
+
+InsetInfo::~InsetInfo()
+{
+       if (form) {
+               fl_hide_form(form);
+               fl_free_form(form);
+               form = 0;
+       }
+}
+
+
+int InsetInfo::ascent(BufferView *, LyXFont const &) const
+{
+       return lyxfont::maxAscent(labelfont) + 1;
+}
+
+
+int InsetInfo::descent(BufferView *, LyXFont const &) const
+{
+       return lyxfont::maxDescent(labelfont) + 1;
+}
+
+
+int InsetInfo::width(BufferView *, LyXFont const &) const
+{
+       return 6 + lyxfont::width(_("Note"), labelfont);
+}
+
+
+void InsetInfo::draw(BufferView * bv, LyXFont const &,
+                    int baseline, float & x, bool) const
+{
+       Painter & pain = bv->painter();
+
+       // Draw as "Note" in a yellow box
+       x += 1;
+       pain.fillRectangle(int(x), baseline - ascent(bv, labelfont),
+                          width(bv, labelfont) - 2,
+                          ascent(bv, labelfont) + descent(bv, labelfont) - 2,
+                          LColor::notebg);
+       pain.rectangle(int(x), baseline - ascent(bv, labelfont),
+                      width(bv, labelfont) - 2,
+                      ascent(bv, labelfont) + descent(bv, labelfont) - 2,
+                      LColor::noteframe);
+       
+       pain.text(int(x + 2), baseline, _("Note"), labelfont);
+       x +=  width(bv, labelfont) - 1;
+}
+
+
+void InsetInfo::write(Buffer const *, ostream & os) const
+{
+       os << "Info\n" << contents;
+}
+
+
+void InsetInfo::read(Buffer const *, LyXLex & lex)
+{
+       string tmp = lex.GetString(); // should be "Info"
+       if (tmp != "Info")
+               lyxerr << "ERROR (InsetInfo::Read): "
+                       "consistency check 1 failed." << endl;
+
+       while (lex.IsOK()) {
+               if (!lex.EatLine())
+                       // blank line in the file being read
+                       // should we skip blank lines?
+                       continue;
+
+               string const token = strip(lex.GetString());
+               lyxerr[Debug::PARSER] << "Note: " << token << endl;
+               
+               if (token != "\\end_inset") {
+                       contents += token + '\n';
+               }
+               else // token == "\\end_inset"
+                       break;
+       }
+       // now remove the last '\n's
+       contents = strip(contents, '\n');
+}
+      
+
+int InsetInfo::latex(Buffer const *, ostream &,
+                    bool /*fragile*/, bool /*free_spc*/) const
+{
+       return 0;
+}
+
+
+int InsetInfo::ascii(Buffer const *, ostream &, int) const
+{
+       return 0;
+}
+
+
+int InsetInfo::linuxdoc(Buffer const *, ostream &) const
+{
+       return 0;
+}
+
+
+int InsetInfo::docBook(Buffer const *, ostream &) const
+{
+       return 0;
+}
+
+
+Inset::EDITABLE InsetInfo::editable() const
+{
+       return IS_EDITABLE;
+}
+
+
+void InsetInfo::closeInfoCB(FL_OBJECT * ob, long)
+{
+       InsetInfo * inset = static_cast<InsetInfo*>(ob->u_vdata);
+       string tmp = fl_get_input(inset->strobj);
+       Buffer * buffer = current_view->buffer();
+       if (tmp != inset->contents && !(buffer->isReadonly())) {
+               buffer->markDirty();
+               inset->contents = tmp;
+       }
+       if (inset->form) {
+               fl_hide_form(inset->form);
+               fl_free_form(inset->form);
+               inset->form = 0;
+       }
+}
+
+
+// This is just a wrapper.
+extern "C"
+void C_InsetInfo_CloseInfoCB(FL_OBJECT * ob, long data) 
+{
+       InsetInfo::closeInfoCB(ob, data);
+}
+
+
+string const InsetInfo::editMessage() const 
+{
+       return _("Opened note");
+}
+
+
+void InsetInfo::edit(BufferView *bv, int, int, unsigned int)
+{
+       static int ow = -1;
+       static int oh;
+
+       if (bv->buffer()->isReadonly())
+               WarnReadonly(bv->buffer()->fileName());
+       
+       if (!form) {
+               FL_OBJECT *obj;
+               form = fl_bgn_form(FL_UP_BOX, 400, 180);
+               strobj = obj = fl_add_input(FL_MULTILINE_INPUT, 10, 10, 380, 120, "");
+               fl_set_object_color(obj, FL_MCOL, FL_MCOL);
+               fl_set_object_resize(obj, FL_RESIZE_ALL);
+               fl_set_object_gravity(obj, NorthWestGravity, SouthEastGravity);
+               obj = fl_add_button(FL_NORMAL_BUTTON, 130, 140, 120, 30, idex(_("Close|#C^[")));
+               fl_set_object_resize(obj, FL_RESIZE_NONE);
+               fl_set_object_gravity(obj, SouthEastGravity, SouthEastGravity);
+               fl_set_object_callback(obj, C_InsetInfo_CloseInfoCB, 0);
+               obj->u_vdata = this;
+               fl_set_object_shortcut(obj, scex(_("Close|#C^[")), 1);
+               fl_end_form();
+               fl_set_form_atclose(form, CancelCloseBoxCB, 0);
+       }
+       fl_set_input(strobj, contents.c_str());
+       if (form->visible) {
+               fl_raise_form(form);
+       } else {
+               fl_show_form(form,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+                            _("Note"));
+               if (ow < 0) {
+                       ow = form->w;
+                       oh = form->h;
+               }
+               fl_set_form_minsize(form, ow, oh);
+       }
+}
+
+
+void InsetInfo::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
+Inset * InsetInfo::clone(Buffer const &, bool) const
+{
+       return new InsetInfo(contents);
+}
+
+
+Inset::Code InsetInfo::lyxCode() const
+{
+       return Inset::IGNORE_CODE;
+}
diff --git a/src/insets/insetinfo.h b/src/insets/insetinfo.h
new file mode 100644 (file)
index 0000000..f7f0331
--- /dev/null
@@ -0,0 +1,86 @@
+// -*- C++ -*-
+/* This file is part of*
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *      
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2001 the LyX Team.
+ *
+ * ====================================================== */
+
+#ifndef INSET_INFO_H
+#define INSET_INFO_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "inset.h"
+#include FORMS_H_LOCATION
+#include "LString.h"
+#include "lyxfont.h"
+
+/** Info. Handles the note insets.
+  
+  This class handles the note insets. The edit operation bringes up
+  a dialog, where the user can type a note about life or something
+  else of interest. When collapsed, the inset is displayed as "Note"
+  in a yellow box. Currently, the Read-function is a terrible hack. 
+  Some day in the distant future, this will hopefully be obsoleted by 
+  a true comment-environment. */
+class InsetInfo : public Inset {
+public:
+       ///
+       InsetInfo();
+       ///
+       explicit
+       InsetInfo(string const & string);
+       ///
+       ~InsetInfo();
+       ///
+       int ascent(BufferView *, LyXFont const &) const;
+       ///
+       int descent(BufferView *, LyXFont const &) const;
+       ///
+       int width(BufferView *, LyXFont const &) const;
+       ///
+       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
+       ///
+       void write(Buffer const *, std::ostream &) const;
+       ///
+       void read(Buffer const *, LyXLex & lex);
+       ///
+       int latex(Buffer const *, std::ostream &,
+                 bool fragile, bool free_spc) const;
+       ///
+       int ascii(Buffer const *, std::ostream &, int linelen) const;
+       ///
+       int linuxdoc(Buffer const *, std::ostream &) const;
+       ///
+       int docBook(Buffer const *, std::ostream &) const;
+       /// what appears in the minibuffer when opening
+       string const editMessage() const;
+       ///
+       void edit(BufferView *, int, int, unsigned int);
+       ///
+       void edit(BufferView * bv, bool front = true);
+       ///
+       EDITABLE editable() const;
+       ///
+       Inset::Code lyxCode() const;
+       ///
+       virtual Inset * clone(Buffer const &, bool same_id = false) const;
+       ///
+       static void closeInfoCB(FL_OBJECT *, long data);
+private:
+       ///
+       string contents;
+       ///
+       FL_FORM * form;
+       ///
+       FL_OBJECT * strobj;
+       ///
+       LyXFont labelfont;
+};
+#endif
index 026721a0d772b8865ef0d9ab143b9bee17737e44..5e204277eefe29d6d79e7a866ae8879fc5af535f 100644 (file)
@@ -69,6 +69,12 @@ void InsetLabel::edit(BufferView * bv, int, int, unsigned int)
 }
 
 
+void InsetLabel::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
 int InsetLabel::latex(Buffer const *, ostream & os,
                      bool /*fragile*/, bool /*fs*/) const
 {
index b4080df3a6bf1e25b3f4b10ffb1a73c46e2a2946..094965e3c767eabb51d155af57903dc2f38c6add 100644 (file)
@@ -35,10 +35,12 @@ public:
        ///
        void edit(BufferView *, int, int, unsigned int);
        ///
+       void edit(BufferView * bv, bool front = true);
+       ///
        std::vector<string> const getLabelList() const;
        ///
        int latex(Buffer const *, std::ostream &,
-                 bool fragile, bool free_spc) const;
+                 bool fragile, bool free_spc) const;
        ///
        int ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
index fff7461d45e92988c50766bc4ef5e1363f14cc09..c827af9d8c0087272f82a4bc9a2c46ecc847850b 100644 (file)
@@ -329,7 +329,7 @@ void InsetMinipage::width(string const & ll)
 bool InsetMinipage::showInsetDialog(BufferView * bv) const
 {
        if (!inset.showInsetDialog(bv))
-       bv->owner()->getDialogs()->showMinipage(const_cast<InsetMinipage *>(this));
+               bv->owner()->getDialogs()->showMinipage(const_cast<InsetMinipage *>(this));
        return true;
 }
 
@@ -338,8 +338,8 @@ void InsetMinipage::insetButtonRelease(BufferView * bv, int x, int y,
                                       int button)
 {
        if (button == 3) {
-       showInsetDialog(bv);
-       return;
+               showInsetDialog(bv);
+               return;
        }
        InsetCollapsable::insetButtonRelease(bv, x, y, button);
 }
@@ -349,7 +349,7 @@ int InsetMinipage::getMaxWidth(BufferView * bv, UpdatableInset const * inset)
        const
 {
        if (!width_.empty())
-       return VSpace(width_).inPixels(bv);
+               return VSpace(width_).inPixels(bv);
        // this should not happen!
        return InsetCollapsable::getMaxWidth(bv, inset);
 }
index 5df4a8d7eecf99ff261da3f92c1fb63a2db0c43b..26d5cf0cfa6cc148e17ed43066eee8adec8c28f0 100644 (file)
@@ -50,6 +50,12 @@ void InsetParent::edit(BufferView * bv, int, int, unsigned int)
 }
 
 
+void InsetParent::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
 // LaTeX must just ignore this command
 int InsetParent::latex(Buffer const * buf, ostream & os,
                       bool fragile, bool free_spc) const
index 5ae366e530e036422f148ca9a4707c88519e72d5..70e2e2434db2d40ae2cbc96f570f2d011a572f77 100644 (file)
@@ -32,18 +32,20 @@ public:
        virtual Inset * clone(Buffer const & buffer, bool same_id = false) const {
                return new InsetParent(params(), buffer, same_id);
        }
-       ///
+       ///
        string const getScreenLabel() const;
-        ///
+       ///
        EDITABLE editable() const { return IS_EDITABLE; }
-        ///
-        Inset::Code lyxCode() const { return Inset::PARENT_CODE; }
-        ///
+       ///
+       Inset::Code lyxCode() const { return Inset::PARENT_CODE; }
+       ///
        void edit(BufferView *, int, int, unsigned int);
+       ///
+       void edit(BufferView * bv, bool front = true);
        /// 
        int latex(Buffer const *, std::ostream &,
-                 bool fragile, bool free_spc) const;
-        ///
-        void setParent(string fn) { setContents(fn); }
+                 bool fragile, bool free_spc) const;
+       ///
+       void setParent(string fn) { setContents(fn); }
 };
 #endif
index 4624c1d97bbd4906c8fc7c56cb39117daea5754b..ad7321a9b4dc7abadd2fd256eab67ec3332e077d 100644 (file)
@@ -33,6 +33,11 @@ void InsetRef::edit(BufferView * bv, int, int, unsigned int button)
 }
 
 
+void InsetRef::edit(BufferView * bv, bool)
+{
+}
+
+
 string const InsetRef::getScreenLabel() const
 {
        string temp;
index 2a60b2a65510a41284d2f7c838d228bbf16462cd..eec668ea791453c0903249e43573ff171aedd9cf 100644 (file)
@@ -51,11 +51,13 @@ public:
        Inset::Code lyxCode() const { return Inset::REF_CODE; }
        ///
        void edit(BufferView *, int, int, unsigned int);
-        ///
+       ///
+       void edit(BufferView * bv, bool front = true);
+       ///
        bool display() const { return false; }
        ///
        int latex(Buffer const *, std::ostream &,
-                 bool fragile, bool free_spc) const;
+                 bool fragile, bool free_spc) const;
        ///
        int ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
index a1fbaf152c2e851850eb98236e3f6f57f9f1540e..ecd4b885de7067b78c6e60c4ef1ca63f80d5c6fc 100644 (file)
@@ -510,8 +510,28 @@ void InsetTabular::edit(BufferView * bv, int x, int y, unsigned int button)
        if (insetHit(bv, x, y) && (button != 3)) {
                activateCellInsetAbs(bv, x, y, button);
        }
-//    UpdateLocal(bv, NONE, false);
-//    bv->getOwner()->getPopups().updateFormTabular();
+}
+
+
+void InsetTabular::edit(BufferView * bv, bool front)
+{
+       UpdatableInset::edit(bv, front);
+       
+       if (!bv->lockInset(this)) {
+               lyxerr[Debug::INSETS] << "InsetTabular::Cannot lock inset" << endl;
+               return;
+       }
+       locked = true;
+       the_locking_inset = 0;
+       inset_x = 0;
+       inset_y = 0;
+       if (front)
+               actcell = 0;
+       else
+               actcell = tabular->GetNumberOfCells() - 1;
+       sel_cell_start = sel_cell_end = actcell;
+       resetPos(bv);
+       finishUndo();
 }
 
 
@@ -1969,10 +1989,19 @@ void InsetTabular::resizeLyXText(BufferView * bv, bool force) const
 
 
 LyXText * InsetTabular::getLyXText(BufferView const * bv,
-                                  bool const recursive) const
+                                   bool const recursive) const
 {
        if (the_locking_inset)
                return the_locking_inset->getLyXText(bv, recursive);
+#if 0
+       // if we're locked lock the actual insettext and return it's LyXText!!!
+       if (locked) {
+               UpdatableInset * inset =
+                       static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
+               inset->edit(const_cast<BufferView *>(bv), 0,  0, 0);
+               return the_locking_inset->getLyXText(bv, recursive);
+       }
+#endif
        return Inset::getLyXText(bv, recursive);
 }
 
@@ -2498,3 +2527,51 @@ void InsetTabular::toggleSelection(BufferView * bv, bool kill_selection)
                the_locking_inset->toggleSelection(bv, kill_selection);
        }
 }
+
+
+bool InsetTabular::searchForward(BufferView * bv, string const & str,
+                              bool const & cs, bool const & mw)
+{
+       if (the_locking_inset) {
+               if (the_locking_inset->searchForward(bv, str, cs, mw))
+                       return true;
+               if (tabular->IsLastCell(actcell)) {
+                       bv->unlockInset(const_cast<InsetTabular *>(this));
+                       return false;
+               }
+               ++actcell;
+       }
+       nodraw(true);
+       // otherwise we have to lock the next inset and search there
+       UpdatableInset * inset =
+               static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
+       inset->edit(bv);
+       bool res = searchForward(bv, str, cs, mw);
+       updateLocal(bv, NONE, false);
+       nodraw(false);
+       bv->updateInset(const_cast<InsetTabular *>(this), false);
+       return res;
+}
+
+bool InsetTabular::searchBackward(BufferView * bv, string const & str,
+                               bool const & cs, bool const & mw)
+{
+       if (the_locking_inset) {
+               if (the_locking_inset->searchBackward(bv, str, cs, mw))
+                       return true;
+               if (!actcell) { // we are already in the first cell
+                       bv->unlockInset(const_cast<InsetTabular *>(this));
+                       return false;
+               }
+               --actcell;
+       }
+       nodraw(true);
+       // otherwise we have to lock the next inset and search there
+       UpdatableInset * inset =
+               static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
+       inset->edit(bv, false);
+       bool res = searchBackward(bv, str, cs, mw);
+       nodraw(false);
+       bv->updateInset(const_cast<InsetTabular *>(this), false);
+       return res;
+}
index 7736de59839336e4c82ec6287e3b0f8fa1d3e1a1..19f8deca8dd3701a0cba5a2f5494fbed23e90077 100644 (file)
@@ -102,6 +102,8 @@ public:
        ///
        void edit(BufferView *, int x, int y, unsigned int);
        ///
+       void edit(BufferView * bv, bool front = true);
+       ///
        bool doClearArea() const;
        ///
        void insetUnlock(BufferView *);
@@ -213,6 +215,11 @@ public:
        string selectNextWord(BufferView *, float & value) const;
        void selectSelectedWord(BufferView *);
        void toggleSelection(BufferView *, bool kill_selection);
+       ///
+       bool searchForward(BufferView *, string const &,
+                          bool const & = true, bool const & = false);
+       bool searchBackward(BufferView *, string const &,
+                           bool const & = true, bool const & = false);
 
        //
        // Public structures and variables
index 234bb87c766812ebcfad54ae7689ab2add50410b..17f6610888718a878df1ac6efa069750733f932c 100644 (file)
@@ -50,6 +50,7 @@
 #include "lyxfunc.h"
 #include "ParagraphParameters.h"
 #include "undo_funcs.h"
+#include "lyxfind.h"
 
 using std::ostream;
 using std::ifstream;
@@ -540,7 +541,7 @@ void InsetText::setUpdateStatus(BufferView * bv, int what) const
 }
 
 
-void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty)
+void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty) const
 {
        bool clear = false;
        if (!lt) {
@@ -552,7 +553,7 @@ void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty)
        if ((need_update != CURSOR) || (lt->status() != LyXText::UNCHANGED) ||
                lt->selection.set())
        {
-               bv->updateInset(this, mark_dirty);
+               bv->updateInset(const_cast<InsetText *>(this), mark_dirty);
        }
        bv->owner()->showState();
        if (old_par != cpar(bv)) {
@@ -572,7 +573,6 @@ string const InsetText::editMessage() const
 
 void InsetText::edit(BufferView * bv, int x, int y, unsigned int button)
 {
-//    par->SetInsetOwner(this);
        UpdatableInset::edit(bv, x, y, button);
        
        if (!bv->lockInset(this)) {
@@ -595,7 +595,52 @@ void InsetText::edit(BufferView * bv, int x, int y, unsigned int button)
        if (!checkAndActivateInset(bv, x, tmp_y, button))
                lt->setCursorFromCoordinates(bv, x - drawTextXOffset,
                                            y + insetAscent);
-       lt->selection.cursor = lt->cursor;
+       lt->clearSelection(bv);
+       finishUndo();
+       showInsetCursor(bv);
+       updateLocal(bv, CURSOR, false);
+
+       // If the inset is empty set the language of the current font to the
+       // language to the surronding text (if different).
+       if (par->size() == 0 && !par->next() &&
+               bv->getParentLanguage(this) != lt->current_font.language()) {
+               LyXFont font(LyXFont::ALL_IGNORE);
+               font.setLanguage(bv->getParentLanguage(this));
+               setFont(bv, font, false);
+       }
+       if (clear)
+               lt = 0;
+}
+
+
+void InsetText::edit(BufferView * bv, bool front)
+{
+       UpdatableInset::edit(bv, front);
+       
+       if (!bv->lockInset(this)) {
+               lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
+               return;
+       }
+       locked = true;
+       the_locking_inset = 0;
+       inset_pos = inset_x = inset_y = 0;
+       inset_boundary = false;
+       inset_par = 0;
+       old_par = 0;
+       bool clear = false;
+       if (!lt) {
+               lt = getLyXText(bv);
+               clear = true;
+       }
+       if (front)
+               lt->setCursor(bv, par, 0);
+       else {
+               Paragraph * p = par;
+               while(p->next())
+                       p = p->next();
+               lt->setCursor(bv, p, p->size()-1);
+       }
+       lt->clearSelection(bv);
        finishUndo();
        showInsetCursor(bv);
        updateLocal(bv, CURSOR, false);
@@ -1308,7 +1353,7 @@ void InsetText::toggleInsetCursor(BufferView * bv)
 void InsetText::showInsetCursor(BufferView * bv, bool show)
 {
        if (the_locking_inset) {
-               the_locking_inset->showInsetCursor(bv);
+               the_locking_inset->showInsetCursor(bv, show);
                return;
        }
        if (!isCursorVisible()) {
@@ -1337,6 +1382,22 @@ void InsetText::hideInsetCursor(BufferView * bv)
 }
 
 
+void InsetText::fitInsetCursor(BufferView * bv) const
+{
+       if (the_locking_inset) {
+               the_locking_inset->fitInsetCursor(bv);
+               return;
+       }
+       LyXFont const font =
+               getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
+       
+       int const asc = lyxfont::maxAscent(font);
+       int const desc = lyxfont::maxDescent(font);
+
+       bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
+}
+
+
 UpdatableInset::RESULT
 InsetText::moveRight(BufferView * bv, bool activate_inset, bool selecting)
 {
@@ -1791,24 +1852,27 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
        }
        lyx::Assert(it->second.text.get());
 
-       deleteLyXText(bv, (the_locking_inset == 0) || force);
+       LyXText * t = it->second.text.get();
+       saveLyXTextState(t);
+       for (Paragraph * p = par; p; p = p->next()) {
+               p->resizeInsetsLyXText(bv);
+       }
+       t->init(bv, true);
+       restoreLyXTextState(bv, t);
+       if (the_locking_inset) {
+               inset_x = cx(bv) - top_x + drawTextXOffset;
+               inset_y = cy(bv) + drawTextYOffset;
+       }
 
        if (bv->screen()) {
-                       LyXText * t = getLyXText(bv);
                        t->first = bv->screen()->topCursorVisible(t);
        }
-       
+       if (!owner())
+               updateLocal(bv, FULL, false);
+       else
+               need_update = FULL;
        // this will scroll the screen such that the cursor becomes visible 
        bv->updateScrollbar();
-       if (the_locking_inset) {
-               /// then resize all LyXText in text-insets
-               inset_x = cx(bv) - top_x + drawTextXOffset;
-               inset_y = cy(bv) + drawTextYOffset;
-               for (Paragraph * p = par; p; p = p->next()) {
-                       p->resizeInsetsLyXText(bv);
-               }
-       }
-       need_update = FULL;
 }
 
 
@@ -2026,7 +2090,38 @@ void InsetText::toggleSelection(BufferView * bv, bool kill_selection)
        if (y_offset < 0)
                y_offset = y;
        
+       if (need_update & SELECTION)
+               need_update = NONE;
        bv->screen()->toggleSelection(lt, bv, kill_selection, y_offset, x);
        if (clear)
                lt = 0;
 }
+
+
+bool InsetText::searchForward(BufferView * bv, string const & str,
+                              bool const & cs, bool const & mw)
+{
+       if (the_locking_inset)
+               if (the_locking_inset->searchForward(bv, str, cs, mw))
+                       return true;
+       if (LyXFind(bv, str, true, true, cs , mw)) {
+               return true;
+       }
+       // we have to unlock ourself in this function by default!
+       bv->unlockInset(const_cast<InsetText *>(this));
+       return false;
+}
+
+bool InsetText::searchBackward(BufferView * bv, string const & str,
+                               bool const & cs, bool const & mw)
+{
+       if (the_locking_inset)
+               if (the_locking_inset->searchBackward(bv, str, cs, mw))
+                       return true;
+       if (LyXFind(bv, str, false, true, cs, mw)) {
+               return true;
+       }
+       // we have to unlock ourself in this function by default!
+       bv->unlockInset(const_cast<InsetText *>(this));
+       return false;
+}
index 5d11d617fa3e46643277afac22e904aa5b1be2d7..7bb3355b02f6993aa1b55b25328b05dca35db682 100644 (file)
@@ -107,6 +107,8 @@ public:
        ///
        void edit(BufferView *, int, int, unsigned int);
        ///
+       void edit(BufferView *, bool front = true);
+       ///
        bool isTextInset() const { return true; }
        ///
        bool doClearArea() const;
@@ -150,6 +152,12 @@ public:
        ///
        void toggleInsetCursor(BufferView *);
        ///
+       void showInsetCursor(BufferView *, bool show=true);
+       ///
+       void hideInsetCursor(BufferView *);
+       ///
+       void fitInsetCursor(BufferView *) const;
+       ///
        bool insertInset(BufferView *, Inset *);
        ///
        bool insetAllowed(Inset::Code) const;
@@ -221,11 +229,19 @@ public:
        void selectSelectedWord(BufferView *);
        void toggleSelection(BufferView *, bool kill_selection);
        ///
+       bool searchForward(BufferView *, string const &,
+                          bool const & = true, bool const & = false);
+       bool searchBackward(BufferView *, string const &,
+                           bool const & = true, bool const & = false);
+       
+       //
+       // Public structures and variables
+       ///
        mutable int need_update;
 
 protected:
        ///
-       void updateLocal(BufferView *, int what, bool mark_dirty);
+       void updateLocal(BufferView *, int what, bool mark_dirty) const;
        ///
        mutable int drawTextXOffset;
        ///
@@ -251,10 +267,6 @@ private:
        ///
        int beginningOfMainBody(Buffer const *, Paragraph * par) const;
        ///
-       void showInsetCursor(BufferView *, bool show=true);
-       ///
-       void hideInsetCursor(BufferView *);
-       ///
        UpdatableInset::RESULT moveRight(BufferView *,
                                         bool activate_inset = true,
                                         bool selecting = false);
@@ -344,7 +356,7 @@ private:
        ///
        UpdatableInset * the_locking_inset;
        ///
-       Paragraph * old_par;
+       mutable Paragraph * old_par;
        /// The cache.
        mutable Cache cache;
        ///
index 48652ba3d5c5934fed86d1b762637fb3f5aca6f8..32d9560d6b9b54e2399b5a994e81794f4688224b 100644 (file)
@@ -39,6 +39,12 @@ void InsetTOC::edit(BufferView * bv, int, int, unsigned int)
 }
 
 
+void InsetTOC::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
 int InsetTOC::ascii(Buffer const * buffer, std::ostream & os, int) const
 {
        os << getScreenLabel() << "\n\n";
index 01766e77eb96947f79a69a921bad777864cf2f15..4107d128a0b76fbd1f403e31b0cab5c7f27ef1c7 100644 (file)
@@ -29,11 +29,13 @@ public:
        virtual Inset * clone(Buffer const &, bool same_id = false) const {
                return new InsetTOC(params(), same_id);
        }
-       ///
+       ///
        string const getScreenLabel() const;
        ///
        void edit(BufferView * bv, int, int, unsigned int);
-        ///
+       ///
+       void edit(BufferView * bv, bool front = true);
+       ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
        bool display() const { return true; }
index e3758cb2efc542e44c7631c41eb45c4d1f8bb588..241c69fffe65baf599a6847dd8517bffb5f5d30d 100644 (file)
@@ -26,6 +26,12 @@ void InsetUrl::edit(BufferView * bv, int, int, unsigned int)
 }
 
 
+void InsetUrl::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
 string const InsetUrl::getScreenLabel() const
 {
        string temp;
index 095c71143ff0507aed12f462014eda255ae24ed1..4fffbcae6d8606afabe5d912a181f7f82d133445 100644 (file)
@@ -26,7 +26,7 @@ public:
        ///
        explicit
        InsetUrl(InsetCommandParams const &, bool same_id = false);
-        ///
+       ///
        virtual Inset * clone(Buffer const &, bool same_id = false) const {
                return new InsetUrl(params(), same_id);
        }
@@ -40,11 +40,13 @@ public:
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
        void edit(BufferView *, int, int, unsigned int);
-        ///
+       ///
+       void edit(BufferView * bv, bool front = true);
+       ///
        bool display() const { return false; }
        ///
        int latex(Buffer const *, std::ostream &,
-                 bool fragile, bool free_spc) const;
+                 bool fragile, bool free_spc) const;
        ///
        int ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
index 97a2a0756b2e2027b0743c3a8eb981af2423c672..4feec5b0484182f1ccbc3050b813b69276848f9f 100644 (file)
 #include "buffer.h"
 #include "gettext.h"
 
+// declare local prototypes here so they cannot be used without hack
+// externally and also we won't see them in the lyxfind.h file so we
+// know this are internal files!
+
+
+///
+// locally used enum
+///
+enum SearchResult {
+       //
+       SR_NOT_FOUND = 0,
+       //
+       SR_FOUND,
+       //
+       SR_FOUND_NOUPDATE
+};
+
+
+/// returns true if the specified string is at the specified  position
+bool IsStringInText(Paragraph * par, Paragraph::size_type pos,
+                    string const & str, bool const & = true,
+                    bool const & = false);
+
+/// if the string is found: return true and set the cursor to the new position
+SearchResult SearchForward(BufferView *, LyXText * text, string const & str,
+                           bool const & = true, bool const & = false);
+///
+SearchResult SearchBackward(BufferView *, LyXText * text, string const & str,
+                            bool const & = true, bool const & = false);
+
+
 int LyXReplace(BufferView * bv,
-              string const & searchstr,
-              string const & replacestr,
-              bool const & casesens,
-              bool const & matchwrd,
-              bool const & forward,
-              bool const & replaceall)
+               string const & searchstr, string const & replacestr,
+               bool const & forward, bool const & casesens,
+               bool const & matchwrd, bool const & replaceall)
 {
-   int replace_count = 0;
-   if (!bv->available() || bv->buffer()->isReadonly()) 
-     return replace_count;
+       if (!bv->available() || bv->buffer()->isReadonly()) 
+               return 0;
    
-   // CutSelection cannot cut a single space, so we have to stop
-   // in order to avoid endless loop :-(
-   if (searchstr.length() == 0
-       || (searchstr.length() == 1 && searchstr[0] == ' ')) {
-      WriteAlert(_("Sorry!"), _("You cannot replace a single space, "
-                               "nor an empty character."));
-      return replace_count;
-   }
-   // now we can start searching for the first 
-   // start at top if replaceall
-   bool fw = forward;
-   if (replaceall) {
-      bv->text->clearSelection(bv);
-      bv->text->cursorTop(bv);
-      // override search direction because we search top to bottom
-      fw = true;
-   }
-
-   // if nothing selected or selection does not equal search string
-   // search and select next occurance and return if no replaceall
-   if (searchstr!=bv->text->selectionAsString(bv->buffer())) {
-      LyXFind(bv, searchstr, casesens, matchwrd, fw);
-      if (!replaceall)
-       return replace_count;
-   }
+       // CutSelection cannot cut a single space, so we have to stop
+       // in order to avoid endless loop :-(
+       if (searchstr.length() == 0
+               || (searchstr.length() == 1 && searchstr[0] == ' '))
+       {
+               WriteAlert(_("Sorry!"), _("You cannot replace a single space, "
+                                         "nor an empty character."));
+               return 0;
+       }
+       
+       LyXText * text = bv->getLyXText();
+
+       // now we can start searching for the first 
+       // start at top if replaceall
+       bool fw = forward;
+       if (replaceall) {
+               text->clearSelection(bv);
+               if (text->inset_owner) {
+                       bv->unlockInset(bv->theLockingInset());
+                       text = bv->text;
+               }
+               text->cursorTop(bv);
+               // override search direction because we search top to bottom
+               fw = true;
+       }
+       
+       // if nothing selected or selection does not equal search string
+       // search and select next occurance and return if no replaceall
+       if (searchstr!=text->selectionAsString(bv->buffer())) {
+               if (!LyXFind(bv, searchstr, fw, false, casesens, matchwrd) ||
+                       !replaceall)
+               {
+                       return 0;
+               }
+       }
    
-   bool found;
-   do {
-      bv->hideCursor();
-      bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR);
-      bv->toggleSelection(false);
-      bv->text->replaceSelectionWithString(bv, replacestr);
-      bv->text->setSelectionOverString(bv, replacestr);
-      bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-      ++replace_count;
-      found = LyXFind(bv, searchstr, casesens, matchwrd, fw);
-   } while (replaceall && found);
+       bool found;
+       int replace_count = 0;
+       do {
+               bv->hideCursor();
+               bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
+               bv->toggleSelection(false);
+               bv->getLyXText()->replaceSelectionWithString(bv, replacestr);
+               bv->getLyXText()->setSelectionOverString(bv, replacestr);
+               bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+               ++replace_count;
+               found = LyXFind(bv, searchstr, fw, false, casesens, matchwrd);
+       } while (replaceall && found);
    
-   if (bv->focus())
-     bv->showCursor();
-
-   return replace_count;
+       if (bv->focus())
+               bv->showCursor();
+       
+       return replace_count;
 }
 
 bool LyXFind(BufferView * bv,
-            string const & searchstr,
-            bool const & casesens,
-            bool const & matchwrd,
-            bool const & forward)
+             string const & searchstr, bool const & forward,
+                        bool const & frominset,
+             bool const & casesens, bool const & matchwrd)
 {
-   bool found = false;
-   
-   if (!bv->available() || searchstr.empty())
-     return found;
+       if (!bv->available() || searchstr.empty())
+               return false;
+       
+       LyXText * text = bv->getLyXText();
 
-   bv->hideCursor();
-   bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR);
-   
-   LyXText * ltCur = bv->text;
-   if (ltCur->selection.set())
-     ltCur->cursor = forward ? ltCur->selection.end
-            : ltCur->selection.start;
-
-   if (forward 
-       ? SearchForward(bv, searchstr, casesens, matchwrd)
-       : SearchBackward(bv, searchstr, casesens, matchwrd)) {
-      bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR);
-      bv->toggleSelection();
-      bv->text->clearSelection(bv);
-      bv->text->setSelectionOverString(bv, searchstr);
-      bv->toggleSelection(false);
-      found = true;
-   };
+       bv->hideCursor();
+       bv->update(text, BufferView::SELECT|BufferView::FITCUR);
+       
+       if (text->selection.set())
+               text->cursor = forward ?
+                       text->selection.end : text->selection.start;
+
+       SearchResult result = SR_NOT_FOUND;
+
+       if (!frominset && bv->theLockingInset()) {
+               bool found = forward ?
+                       bv->theLockingInset()->searchForward(bv, searchstr, casesens, matchwrd) :
+                       bv->theLockingInset()->searchBackward(bv, searchstr, casesens, matchwrd);
+               if (found)
+                       result = SR_FOUND_NOUPDATE;
+       } else {
+               result = forward ? 
+                       SearchForward(bv, text, searchstr, casesens, matchwrd) :
+                       SearchBackward(bv, text, searchstr, casesens, matchwrd);
+       }
+
+       bool found = true;
+       if (result == SR_FOUND) {
+               // the actual text pointer could have changed!
+               bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
+               bv->toggleSelection();
+               bv->getLyXText()->clearSelection(bv);
+               bv->getLyXText()->setSelectionOverString(bv, searchstr);
+               bv->toggleSelection(false);
+               bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
+       } else if (result == SR_NOT_FOUND)
+               found = false;
    
-   if (bv->focus())
-     bv->showCursor();
+       if (bv->focus())
+               bv->showCursor();
    
-   return found;
+       return found;
 }
 
 
@@ -121,18 +171,20 @@ bool IsStringInText(Paragraph * par, Paragraph::size_type pos,
        while (((pos + i) < par->size())
               && (string::size_type(i) < size)
               && (cs ? (str[i] == par->getChar(pos + i))
-                  : (toupper(str[i]) == toupper(par->getChar(pos + i)))))
+                  : (toupper(str[i]) == toupper(par->getChar(pos + i)))))
        {
                ++i;
        }
        if (size == string::size_type(i)) {
-         // if necessary, check whether string matches word
-         if (!mw || 
-             (mw && ((pos <= 0 || !IsLetterCharOrDigit(par->getChar(pos - 1)))
-                     && (pos + Paragraph::size_type(size) >= par->size()
-                         || !IsLetterCharOrDigit(par->getChar(pos + size))))
-              ))
-           return true;
+               // if necessary, check whether string matches word
+               if (!mw || 
+                   (mw && ((pos <= 0 || !IsLetterCharOrDigit(par->getChar(pos - 1)))
+                            && (pos + Paragraph::size_type(size) >= par->size()
+                                || !IsLetterCharOrDigit(par->getChar(pos + size))))
+                    ))
+               {
+                       return true;
+               }
        }
        return false;
 }
@@ -140,13 +192,25 @@ bool IsStringInText(Paragraph * par, Paragraph::size_type pos,
 // forward search:
 // if the string can be found: return true and set the cursor to
 // the new position, cs = casesensitive, mw = matchword
-bool SearchForward(BufferView * bv, string const & str,
-                  bool const & cs, bool const & mw)
+SearchResult SearchForward(BufferView * bv, LyXText * text, string const & str,
+                           bool const & cs, bool const & mw)
 {
-       Paragraph * par = bv->text->cursor.par();
-       Paragraph::size_type pos = bv->text->cursor.pos();
-   
+       Paragraph * par = text->cursor.par();
+       Paragraph::size_type pos = text->cursor.pos();
+       UpdatableInset * inset;
+
        while (par && !IsStringInText(par, pos, str, cs, mw)) {
+               if (par->isInset(pos) &&
+                       (inset = (UpdatableInset *)par->getInset(pos)) &&
+                       (inset->isTextInset()))
+               {
+                       // lock the inset!
+                       text->setCursor(bv, par, pos);
+                       inset->edit(bv);
+                       if (inset->searchForward(bv, str, cs, mw))
+                               return SR_FOUND_NOUPDATE;
+                       text = bv->getLyXText();
+               }
                if (pos < par->size() - 1)
                        ++pos;
                else {
@@ -155,22 +219,39 @@ bool SearchForward(BufferView * bv, string const & str,
                }
        }
        if (par) {
-               bv->text->setCursor(bv, par, pos);
-               return true;
-       }
-       else
-               return false;
+               text->setCursor(bv, par, pos);
+               return SR_FOUND;
+       } else if (text->inset_owner) {
+               // test if we're inside an inset if yes unlock the inset
+               // and recall us with the outside LyXText!
+               bv->unlockInset((UpdatableInset *)text->inset_owner);
+               text = bv->getLyXText();
+               par = text->cursor.par();
+               pos = text->cursor.pos();
+               if (pos < par->size() - 1)
+                       ++pos;
+               else {
+                       pos = 0;
+                       par = par->next();
+               }
+               if (!par)
+                       return SR_NOT_FOUND;
+               text->setCursor(bv, par, pos);
+               return SearchForward(bv, text, str, cs, mw);
+       } else
+               return SR_NOT_FOUND;
 }
 
 
 // backward search:
 // if the string can be found: return true and set the cursor to
 // the new position, cs = casesensitive, mw = matchword
-bool SearchBackward(BufferView * bv, string const & str,
-                   bool const & cs, bool const & mw)
+SearchResult SearchBackward(BufferView * bv, LyXText * text,
+                            string const & str,
+                            bool const & cs, bool const & mw)
 {
-       Paragraph * par = bv->text->cursor.par();
-       Paragraph::size_type pos = bv->text->cursor.pos();
+       Paragraph * par = text->cursor.par();
+       Paragraph::size_type pos = text->cursor.pos();
 
        do {
                if (pos > 0)
@@ -183,12 +264,30 @@ bool SearchBackward(BufferView * bv, string const & str,
                                        pos = par->size() - 1;
                        } while (par && pos < 0);
                }
+               UpdatableInset * inset;
+               if (par && par->isInset(pos) &&
+                       (inset = (UpdatableInset *)par->getInset(pos)) &&
+                       (inset->isTextInset()))
+               {
+                       // lock the inset!
+                       text->setCursor(bv, par, pos);
+                       inset->edit(bv, false);
+                       if (inset->searchBackward(bv, str, cs, mw))
+                               return SR_FOUND_NOUPDATE;
+                       text = bv->getLyXText();
+               }               
        } while (par && !IsStringInText(par, pos, str, cs, mw));
   
        if (par) {
-               bv->text->setCursor(bv, par, pos);
-               return true;
-       } else
-               return false;
+               text->setCursor(bv, par, pos);
+               return SR_FOUND;
+       } else if (text->inset_owner) {
+               // test if we're inside an inset if yes unlock the inset
+               // and recall us with the outside LyXText!
+               bv->unlockInset((UpdatableInset *)text->inset_owner);
+               return SearchBackward(bv, bv->getLyXText(), str, cs, mw);
+       } else {
+               return SR_NOT_FOUND;
+       }
 }
 
index 59e25534587102e9c36184d93299540c3bb6d61f..4bbae181ac9eeaf9ab13a25b3b34c429ac5058ba 100644 (file)
 class BufferView;
 
 int LyXReplace(BufferView * bv, string const &, string const &,
-              bool const &, bool const &, bool const &, bool const & = false);
-
-bool LyXFind(BufferView * bv, string const &, bool const &, bool const &,
-            bool const &);
-
-/// returns true if the specified string is at the specified  position
-bool IsStringInText(Paragraph * par, Paragraph::size_type pos,
-                   string const & str, bool const & = true,
-                   bool const & = false);
-
-/// if the string is found: return true and set the cursor to the new position
-bool SearchForward(BufferView *, string const & str, bool const & = true, 
-                  bool const & = false);
-///
-bool SearchBackward(BufferView *, string const & str, bool const & = true, 
-                   bool const & = false);
+               bool const &, bool const & = true, bool const & = false,
+               bool const & = false);
 
+bool LyXFind(BufferView *,
+             string const & searchstr, bool const & forward,
+                        bool const & frominset = false,
+             bool const & casesens = true, bool const & matchwrd = false);
 
 #endif
index 537ce1aeec2b70f240aac4f934b949721136f68a..2d706ca101659a6dd497426450fd3f5aa0a3d67f 100644 (file)
@@ -918,34 +918,11 @@ string const LyXFunc::dispatch(int ac,
                } else {
                        searched_string = last_search;
                }
-
-               if (!searched_string.empty() &&
-                   ((action == LFUN_WORDFINDBACKWARD) ? 
-                    SearchBackward(owner->view(), searched_string) :
-                    SearchForward(owner->view(), searched_string))) {
-
-                       // ??? What is that ???
-                       owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR);
-
-                       // ??? Needed ???
-                       // clear the selection (if there is any) 
-                       owner->view()->toggleSelection();
-                       TEXT()->clearSelection(owner->view());
-
-                       // Move cursor so that successive C-s 's will not stand in place. 
-                       if (action == LFUN_WORDFINDFORWARD ) 
-                               TEXT()->cursorRightOneWord(owner->view());
-                       finishUndo();
-                       moveCursorUpdate(true, false);
-
-                       // ??? Needed ???
-                       // set the new selection 
-                       // SetSelectionOverLenChars(owner->view()->currentBuffer()->text, iLenSelected);
-                       owner->view()->toggleSelection(false);
+               bool fw = (action == LFUN_WORDFINDBACKWARD);
+               if (!searched_string.empty()) {
+                       LyXFind(owner->view(), searched_string, fw);
                }
-        
-               // REMOVED : if (owner->view()->getWorkArea()->focus)
-               owner->view()->showCursor();
+//             owner->view()->showCursor();
        }
        break;
                
index 95b61730c0d5cd04b90cf370e8fcfaf564825d51..e6d29ca8f430c534b8e3505b892033e86ef3ee26 100644 (file)
@@ -63,7 +63,7 @@ public:
        /// Destructor
        ~LyXText();
 
-       void init(BufferView *);
+       void init(BufferView *, bool reinit = false);
        ///
        mutable int number_of_rows;
        ///
index f1903192e4719e2e96ba164da0ae37817c184c00..3e9159bf14eddc376aa2e46c2ba651f402a513c8 100644 (file)
@@ -318,6 +318,13 @@ void InsetFormulaBase::edit(BufferView * bv, int x, int /*y*/, unsigned int)
 }
 
 
+void InsetFormulaBase::edit(BufferView * bv, bool front)
+{
+#warning Please have a look if this is right (Jug)
+       edit(bv, front ? 0 : 1, 0, 0);
+}
+
+
 void InsetFormulaBase::insetUnlock(BufferView * bv)
 {
        if (mathcursor) {
index 343efb40ab162d1106d58e0504cf586b2b8834bf..aa85a3b06c856c9163cd870ea3abfad576997664 100644 (file)
@@ -87,6 +87,7 @@ public:
        virtual string const editMessage() const;
        ///
        virtual void edit(BufferView *, int x, int y, unsigned int button);
+       virtual void edit(BufferView *, bool front = true);
        ///
        virtual void toggleInsetCursor(BufferView *);
        ///
index a49c9c155a90b5a21bc207b03e9da0e521ba4eaa..7e69df5421bac2e69f88ab65e1b86253d5dff002 100644 (file)
@@ -763,7 +763,7 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
                                                             .textclass)
                                                  .defaultfont());
                else if (layout.labeltype == LABEL_BIBLIO) {
-                       // ale970405 Right width for bibitems
+                       // ale970405 Right width for bibitems
                        x += bibitemMaxWidth(bview,textclasslist
                                             .TextClass(bview->buffer()->params
                                                        .textclass)
@@ -2276,9 +2276,10 @@ string const LyXText::selectNextWord(BufferView * bview,
                cursor.par()->isInset(cursor.pos()))
        {
                // lock the inset!
-               cursor.par()->getInset(cursor.pos())->edit(bview, 0, 0, 0);
+               cursor.par()->getInset(cursor.pos())->edit(bview);
                // now call us again to do the above trick
-               return selectNextWord(bview, value);
+               // but obviously we have to start from down below ;)
+               return bview->text->selectNextWord(bview, value);
        }               
   
        // Update the value if we changed paragraphs
@@ -3626,7 +3627,7 @@ int LyXText::getColumnNearX(BufferView * bview, Row * row, int & x,
 
 // returns pointer to a specified row
 Row * LyXText::getRow(Paragraph * par,
-                     Paragraph::size_type pos, int & y) const
+                      Paragraph::size_type pos, int & y) const
 {
        if (!firstrow)
                return 0;
index 99497d055529a6e1f79872f7cefe5806f5f12223..33bd234118688bd174b894735bc2e98bcefc6f9f 100644 (file)
@@ -65,9 +65,21 @@ LyXText::LyXText(InsetText * inset)
           copylayouttype(0)
 {}
 
-void LyXText::init(BufferView * bview)
-{
-       if (firstrow)
+void LyXText::init(BufferView * bview, bool reinit)
+{
+       if (reinit) {
+               // Delete all rows, this does not touch the paragraphs!
+               Row * tmprow = firstrow;
+               while (firstrow) {
+                       tmprow = firstrow->next();
+                       delete firstrow;
+                       firstrow = tmprow;
+               }
+               lastrow = refresh_row = need_break_row = 0;
+               width = height = copylayouttype = 0;
+               number_of_rows = first = refresh_y = 0;
+               status_ = LyXText::UNCHANGED;
+       } else if (firstrow)
                return;
 
        Paragraph * par = ownerParagraph();
@@ -271,7 +283,7 @@ void LyXText::setCharFont(Buffer const * buf, Paragraph * par,
 // inserts a new row behind the specified row, increments
 // the touched counters
 void LyXText::insertRow(Row * row, Paragraph * par,
-                       Paragraph::size_type pos) const
+                        Paragraph::size_type pos) const
 {
        Row * tmprow = new Row;
        if (!row) {
@@ -343,10 +355,10 @@ void LyXText::removeParagraph(Row * row) const
 
 // insert the specified paragraph behind the specified row
 void LyXText::insertParagraph(BufferView * bview, Paragraph * par,
-                             Row * row) const
+                              Row * row) const
 {
-       insertRow(row, par, 0);        /* insert a new row, starting 
-                                       * at postition 0 */
+       insertRow(row, par, 0);            /* insert a new row, starting 
+                                           * at postition 0 */
 
        setCounter(bview->buffer(), par);  // set the counters
    
@@ -363,7 +375,7 @@ void LyXText::insertParagraph(BufferView * bview, Paragraph * par,
 Inset * LyXText::getInset() const
 {
        Inset * inset = 0;
-       if (cursor.pos() == 0 && cursor.par()->bibkey){
+       if (cursor.pos() == 0 && cursor.par()->bibkey) {
                inset = cursor.par()->bibkey;
        } else if (cursor.pos() < cursor.par()->size() 
                   && cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET) {
@@ -953,7 +965,7 @@ void LyXText::clearSelection(BufferView * /*bview*/) const
 {
        selection.set(false);
        selection.mark(false);
-       selection.end = selection.start = cursor;
+       selection.end = selection.start = selection.cursor = cursor;
 }