]> git.lyx.org Git - features.git/commitdiff
partial inset toggling ; insetAllowed stuff
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 19 Jul 2001 08:52:59 +0000 (08:52 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 19 Jul 2001 08:52:59 +0000 (08:52 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2277 a592a061-630c-0410-9148-cb99ea01b6c8

29 files changed:
lib/ChangeLog
lib/bind/cua.bind
lib/bind/emacs.bind
lib/bind/sciword.bind
lib/bind/xemacs.bind
lib/ui/default.ui
src/BufferView_pimpl.C
src/ChangeLog
src/LyXAction.C
src/commandtags.h
src/insets/ChangeLog
src/insets/inset.h
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetert.h
src/insets/insetfloat.C
src/insets/insetfloat.h
src/insets/insetfootlike.C
src/insets/insetfootlike.h
src/insets/insetminipage.C
src/insets/insetminipage.h
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/lyxfunc.C
src/lyxtext.h
src/paragraph.C
src/paragraph.h
src/text2.C

index 1d48e0a5658358b7bd95a834ed4bed18b200531e..edfdc04c9dcb2b2375a95342a63a99ff7c50cd16 100644 (file)
@@ -1,3 +1,11 @@
+2001-07-19  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * bind/xemacs.bind: 
+       * bind/sciword.bind: 
+       * bind/emacs.bind: 
+       * bind/cua.bind: 
+       * ui/default.ui: use inset-toggle instead of open-stuff
+
 2001-07-12  Kayvan A. Sylvan  <kayvan@camel.internal.sylvan.com>
 
        * layouts/literate-scrap.inc: Added PassThru tag
index 42be18c81f5f9ce29736dc451582e939a6febffb..a25f28128b481509f17e3f4c47cbbc48b308aa27 100644 (file)
@@ -55,7 +55,7 @@
 
 \bind "C-f"                    "find-replace"
 \bind "C-g"                    "error-next"
-\bind "C-i"                    "open-stuff"            # 'i' for Inset
+\bind "C-i"                    "inset-toggle"          # 'i' for Inset
 
 \bind "C-c"                    "copy"
 \bind "C-x"                    "cut"
index 962b869e949e536a4f2a6a0478286e46a8b62e40..2156723b903221ef0432483726ff3c21003c1899 100644 (file)
@@ -38,7 +38,7 @@
 \bind "C-l"                    "screen-recenter"
 \bind "C-m"                    "mark-toggle"
 \bind "C-n"                    "down"
-\bind "C-o"                    "open-stuff"
+\bind "C-o"                    "inset-toggle"
 \bind "C-p"                    "up"
 
 # this is "quoted-insert" a total different meaning from "quote-insert"
index e730b692dfea4d2ee9614d5e17b183a87a6203fa..e8314db6aa1c10e62360739287fd8daa982cab88 100644 (file)
@@ -42,7 +42,7 @@
 # Numbering equations. Should perhaps simplify math-number and math-nonumber into one command since they are used in very different contexts. This and also math-macro stuff should be available in the Lyx menus!
 \bind "C-n"    "math-number"
 \bind "S-C-n" "math-nonumber"
-\bind "C-o"    "open-stuff"
+\bind "C-o"    "inset-toggle"
 
 # Insert a quote character. Do I need this?
 \bind "C-q"    "quote-insert"
index eee2260474a813773d5dfa6e6a4e5e732be8291f..4a0a79cf49e6237151f73f8f2072b6e58b27253f 100644 (file)
@@ -39,7 +39,7 @@
 \bind "C-l"                    "screen-recenter"
 \bind "C-m"                    "mark-toggle"
 \bind "C-n"                    "down"
-\bind "C-o"                    "open-stuff"
+\bind "C-o"                    "inset-toggle"
 \bind "C-p"                    "up"
 
 # this is "quoted-insert" a total different meaning from "quote-insert"
index 7238604144b49e8303f8fcbde2d3fe9630e94594..abbeafc1f2c2f13f3630db9f441172ced5dc4fd2 100644 (file)
@@ -114,7 +114,7 @@ Menuset
     End
 
     Menu "edit_floats"
-       Item "Open/Close|O" "open-stuff"
+       Item "Open/Close|O" "inset-toggle"
 #      Item "Melt|M" "melt"
 #      Item "Open All Figures/Tables|F" "floats-operate openfig"
 #      Item "Close All Figures/Tables|T" "floats-operate closefig"
index e56cc687f07e66cf50a32d672f425a130ef9aa12..f0c6fc86c0ae4636fd558733850dbed11e9ed5af 100644 (file)
@@ -2637,13 +2637,13 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        }
        break;
        
-       case LFUN_OPENSTUFF:
+       case LFUN_INSET_TOGGLE:
        {
                LyXText * lt = bv_->getLyXText();
                hideCursor();
                beforeChange(lt);
                update(lt, BufferView::SELECT|BufferView::FITCUR);
-               lt->openStuff(bv_);
+               lt->toggleInset(bv_);
                update(lt, BufferView::SELECT|BufferView::FITCUR);
                setState();
        }       
@@ -3343,7 +3343,7 @@ bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout)
        // if we are in a locking inset we should try to insert the
        // inset there otherwise this is a illegal function now
        if (bv_->theLockingInset()) {
-               if (bv_->theLockingInset()->insertInsetAllowed(inset))
+               if (bv_->theLockingInset()->insetAllowed(inset))
                    return bv_->theLockingInset()->insertInset(bv_, inset);
                return false;
        }
index 2c0119a3aab0c95b6ef57c27f45ccf22fd8f1395..e51590b368d827f82c537df0afa01b9135ffd28c 100644 (file)
@@ -1,3 +1,26 @@
+2001-07-19  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * lyxfunc.C (getStatus): add support for all the inset insertion
+       commands.
+
+       * text2.C (insertInset): 
+       * paragraph.C (insetAllowed): 
+       * BufferView_pimpl.C (insertInset): update to take in account the
+       renaming of insertInsetAllowed
+
+       * lyxfunc.C (getStatus): add support for LFUN_INSET_TOGGLE.
+
+       * text2.C (getInset): new method. returns inset at cursor position. 
+
+       * BufferView_pimpl.C (Dispatch): changes because of this.
+
+       * LyXAction.C (init): rename open-stuff to inset-toggle.
+
+       * commandtags.h: rename LFUN_OPENSTUFF to LFUN_INSET_TOGGLE.
+
+       * text2.C (toggleInset): renamed from openStuff; use
+       Inset::open().
+
 2001-07-13  Yves Bastide  <stid@libd-pc11.univ-bpclermont.fr>
 
        * lyxrc.C (set_font_norm_type): recognise ISO_8859_15.
index e2d123d13c7782a52a41266f9457015d42001c4e..7ad41699161076ce0630d8951080e2a1b9e58262 100644 (file)
@@ -310,7 +310,8 @@ void LyXAction::init()
                { LFUN_INSET_MINIPAGE, "minipage-insert", "", Noop },
                { LFUN_INSERT_NOTE, "note-insert", "", Noop },
                { LFUN_GOTONOTE, "note-next", "", ReadOnly },
-               { LFUN_OPENSTUFF, "open-stuff", "", ReadOnly },
+               { LFUN_INSET_TOGGLE, "inset-toggle", 
+                 N_("toggle inset"), ReadOnly },
                { LFUN_DOWN_PARAGRAPH, "paragraph-down",
                  N_("Go one paragraph down"), ReadOnly },
                { LFUN_DOWN_PARAGRAPHSEL, "paragraph-down-select",
index 0908881e363c0266eeb559e5e80990115f3488ad..f422a7e67317474a819d9f2230b4971974e33e13 100644 (file)
@@ -49,7 +49,7 @@ enum kb_action {
        LFUN_COPY,
        LFUN_GOTOERROR,
        LFUN_GOTONOTE,
-       LFUN_OPENSTUFF,
+       LFUN_INSET_TOGGLE,
        LFUN_HYPHENATION,
        LFUN_HFILL,
        LFUN_DEPTH,
@@ -233,7 +233,10 @@ enum kb_action {
        LFUN_VC_UNDO,                   // Lgb 97-07-01
        LFUN_VC_HISTORY,                // Lgb 97-07-01
        LFUN_EXPORT,                    // Lgb 97-07-29
+#if 0
        LFUN_INSERTFOOTNOTE,            // Bernhard 97-08-07
+// schedule for deletion
+#endif
        LFUN_REF_GOTO, // 200           // Ale 970806
        //LFUN_REF_BACK,                  // Ale 970806
        LFUN_PARENTINSERT,              // Ale 970813
index a47d2c98fbb78f646291891113a7ac5cde4bf263..64e55b4823b5d8a8befb81764dcaa2dc2a003221 100644 (file)
@@ -1,3 +1,17 @@
+2001-07-18  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * many files: update to match the change below
+
+       * inset.h (insetAllowed): renamed from insertInsetAllowed;
+       implement the version which takes an inset here.
+
+       * insetcollapsable.[Ch]: implement open and isOpen
+
+       * inset.h: remove insertInsetAllowed from Inset
+       (open): new method, to open or close an inset
+       (isOpen): returns the status of an inset
+       (isCollapsable, colapse): removed
+
 2001-07-13  Yves Bastide  <stid@libd-pc11.univ-bpclermont.fr>
 
        * insetquotes.C (dispString): display french guillemets when using
index 33b8f7ad7f52b745b3c882f4d80ca07b49b06fe2..84625c98e8926df242b97ab746b47949184e1527 100644 (file)
@@ -161,6 +161,12 @@ public:
        virtual bool doClearArea() const { return true; }
        ///
        virtual bool autoDelete() const;
+       /// returns true the inset can hold an inset of given type
+       virtual bool insetAllowed(Inset::Code) const { return false; }
+       /// wrapper around the above
+       bool insetAllowed(Inset * in) const { 
+               return insetAllowed(in->lyxCode()); 
+       }
        ///
        virtual void write(Buffer const *, std::ostream &) const = 0;
        ///
@@ -207,8 +213,6 @@ public:
        ///
        virtual bool needFullRow() const { return false; }
        ///
-       virtual bool insertInsetAllowed(Inset *) const { return false; }
-       ///
        void setInsetName(string const & s) { name = s; }
        ///
        string const getInsetName() const { return name; }
@@ -258,6 +262,11 @@ public:
        int id() const;
        void id(int id_arg);
 
+       /// used to toggle insets
+       // is the inset open?
+       virtual bool isOpen() const { return false; }
+       // open or close the inset, depending on the bool
+       virtual void open(BufferView *, bool) {}
 protected:
        ///
        mutable int top_x;
@@ -367,9 +376,6 @@ public:
        ///
        virtual bool insertInset(BufferView *, Inset *) { return false; }
        ///
-       virtual bool insertInsetAllowed(Inset *) const { return false; }
-       virtual bool insertInsetAllowed(Inset::Code) const { return false; }
-       ///
        virtual UpdatableInset * getLockingInset() const {
                return const_cast<UpdatableInset *>(this);
        }
@@ -410,11 +416,6 @@ public:
                return block_drawing_;
        }
        ///
-       virtual bool isCollapsable() const { return false; }
-       ///
-       virtual bool collapsed() const { return false; }
-       virtual void collapsed(BufferView *, bool) {}
-       ///
        // needed for spellchecking text
        ///
        virtual string selectNextWord(BufferView *, float & value) const;
index 622dc4f14a089e1201e89f521ee7b7f7d123c0ce..1b45ec382dbadd4c7faeec39e32c3620f8528332 100644 (file)
@@ -51,7 +51,7 @@ InsetCollapsable::InsetCollapsable()
 
 bool InsetCollapsable::insertInset(BufferView * bv, Inset * in)
 {
-       if (!insertInsetAllowed(in)) {
+       if (!insetAllowed(in->lyxCode())) {
                lyxerr << "InsetCollapsable::InsertInset: "
                        "Unable to insert inset." << endl;
                return false;
@@ -524,10 +524,10 @@ Inset * InsetCollapsable::getInsetFromID(int id_arg) const
        return inset.getInsetFromID(id_arg);
 }
 
-void InsetCollapsable::collapsed(BufferView * bv, bool flag)
+void InsetCollapsable::open(BufferView * bv, bool flag)
 {
-       if (flag == collapsed_)
+       if (flag == !collapsed_)
                return;
-       collapsed_ = flag;
+       collapsed_ = !flag;
        bv->updateInset(this, false);
 }
index 73f892c962aa52816385837a84b1c60a5f8b33bb..3fdd9e2145c8a892df6d6c4c2cfa37906783560e 100644 (file)
@@ -64,11 +64,8 @@ public:
        ///
        bool insertInset(BufferView *, Inset * inset);
        ///
-       bool insertInsetAllowed(Inset * in) const {
-               return inset.insertInsetAllowed(in);
-       }
-       bool insertInsetAllowed(Inset::Code code) const {
-               return inset.insertInsetAllowed(code);
+       bool insetAllowed(Inset::Code code) const {
+               return inset.insetAllowed(code);
        }
        ///
        bool isTextInset() const { return true; }
@@ -157,9 +154,8 @@ public:
        ///
        LyXCursor const & cursor(BufferView *) const;
        ///
-       bool isCollapsable() const { return true; }
-       bool collapsed() const { return collapsed_; }
-       void collapsed(BufferView *, bool);
+       bool isOpen() const { return !collapsed_; }
+       void open(BufferView *, bool);
        ///
        string selectNextWord(BufferView * bv, float & value) const {
                return inset.selectNextWord(bv, value);
index dbb7f8e80ca5e1c4d6b171abaf3c5fe7fb4bfadc..8308203ca494cdd2653988dac47bb3bc5dc1c884 100644 (file)
@@ -40,7 +40,7 @@ public:
        ///
        virtual bool insertInset(BufferView *, Inset *);
        ///
-       virtual bool insertInsetAllowed(Inset *) const { return false; }
+       virtual bool insetAllowed(Inset::Code) const { return false; }
        ///
        virtual void setFont(BufferView *, LyXFont const &,
                             bool toggleall = false, bool selectall = false);
index 551407e8d70b323051b058fc0aa4b3d59a2ceb2b..eef703a5f545ac86890497448bce4118698a7eb9 100644 (file)
@@ -234,18 +234,12 @@ int InsetFloat::docBook(Buffer const * buf, ostream & os) const
 }
 
 
-bool InsetFloat::insertInsetAllowed(Inset * in) const
-{
-       return insertInsetAllowed(in->lyxCode());
-}
-
-
-bool InsetFloat::insertInsetAllowed(Inset::Code code) const
+bool InsetFloat::insetAllowed(Inset::Code code) const
 {
        if (code == Inset::FLOAT_CODE)
                return false;
        if (inset.getLockingInset() != const_cast<InsetFloat *>(this))
-               return inset.insertInsetAllowed(code);
+               return inset.insetAllowed(code);
        if ((code == Inset::FOOT_CODE) || (code == Inset::MARGIN_CODE))
                return false;
        return true;
index d7ec169fbc7ba5950c6d8ecdddeadc1f6c21a054..c92569fe2e017978fa5dcf3114a767d829a35fa1 100644 (file)
@@ -44,8 +44,7 @@ public:
        ///
        string const editMessage() const;
        ///
-       bool insertInsetAllowed(Inset * inset) const;
-       bool insertInsetAllowed(Inset::Code) const;
+       bool insetAllowed(Inset::Code) const;
        ///
        void insetButtonRelease(BufferView * bv, int x, int y, int button);
        ///
index 141cde152d6d2efe459210d0895c77d8767c72f2..75dd3ad5816a80593c1d1ecda4f33a5515bd2541 100644 (file)
@@ -40,14 +40,9 @@ void InsetFootlike::write(Buffer const * buf, std::ostream & os) const
 }
 
 
-bool InsetFootlike::insertInsetAllowed(Inset * in) const
-{
-       return insertInsetAllowed(in->lyxCode());
-}
-
-bool InsetFootlike::insertInsetAllowed(Inset::Code code) const
+bool InsetFootlike::insetAllowed(Inset::Code code) const
 {
        if ((code == Inset::FOOT_CODE) || (code == Inset::MARGIN_CODE))
                return false;
-       return InsetCollapsable::insertInsetAllowed(code);
+       return InsetCollapsable::insetAllowed(code);
 }
index b6b2b54a713ea07c0e53cec9d88dee4626626972..d41829b8e3ef40ba9285a19b03d9f74d66a72610 100644 (file)
@@ -32,8 +32,7 @@ public:
        ///
        void write(Buffer const * buf, std::ostream & os) const;
        ///
-       bool insertInsetAllowed(Inset * inset) const;
-       bool insertInsetAllowed(Inset::Code) const;
+       bool insetAllowed(Inset::Code) const;
 };
 
 #endif
index f425b2be1d174bd8e1c79f47ed499b7d335a9fc6..fff7461d45e92988c50766bc4ef5e1363f14cc09 100644 (file)
@@ -269,17 +269,12 @@ int InsetMinipage::latex(Buffer const * buf,
 }
 
 
-bool InsetMinipage::insertInsetAllowed(Inset * in) const
-{
-       return insertInsetAllowed(in->lyxCode());
-}
-
-bool InsetMinipage::insertInsetAllowed(Inset::Code code) const
+bool InsetMinipage::insetAllowed(Inset::Code code) const
 {
        if ((code == Inset::FLOAT_CODE) || (code == Inset::MARGIN_CODE))
                return false;
 
-       return InsetCollapsable::insertInsetAllowed(code);
+       return InsetCollapsable::insetAllowed(code);
 }
 
 
index 246696d83838d854e4365c12b56283f4e08852de..0f89a757e42582632e72972fdc61ca1bcb390932 100644 (file)
@@ -59,8 +59,7 @@ public:
        ///
        string const editMessage() const;
        ///
-       bool insertInsetAllowed(Inset * inset) const;
-       bool insertInsetAllowed(Inset::Code) const;
+       bool insetAllowed(Inset::Code) const;
        ///
        Position pos() const;
        ///
index 10ec2bf72a9fa8e00775e58f5fbc1b543889a121..7736de59839336e4c82ec6287e3b0f8fa1d3e1a1 100644 (file)
@@ -123,7 +123,7 @@ public:
        ///
        bool insertInset(BufferView *, Inset *);
        ///
-       bool insertInsetAllowed(Inset *) const {
+       bool insetAllowed(Inset::Code) const {
                return the_locking_inset != 0;
        }
        ///
index a17efbd2aea1d2275169292c75f2f8e0a7f107f6..234bb87c766812ebcfad54ae7689ab2add50410b 100644 (file)
@@ -1410,7 +1410,7 @@ InsetText::moveDown(BufferView * bv)
 bool InsetText::insertInset(BufferView * bv, Inset * inset)
 {
        if (the_locking_inset) {
-               if (the_locking_inset->insertInsetAllowed(inset))
+               if (the_locking_inset->insetAllowed(inset))
                        return the_locking_inset->insertInset(bv, inset);
                return false;
        }
@@ -1435,17 +1435,10 @@ bool InsetText::insertInset(BufferView * bv, Inset * inset)
 }
 
 
-bool InsetText::insertInsetAllowed(Inset * in) const
+bool InsetText::insetAllowed(Inset::Code code) const
 {
        if (the_locking_inset)
-               return the_locking_inset->insertInsetAllowed(in);
-       return true;
-}
-
-bool InsetText::insertInsetAllowed(Inset::Code code) const
-{
-       if (the_locking_inset)
-               return the_locking_inset->insertInsetAllowed(code);
+               return the_locking_inset->insetAllowed(code);
        return true;
 }
 
index 1c6a448b6e046bf5b16c914286308508593e658c..5d11d617fa3e46643277afac22e904aa5b1be2d7 100644 (file)
@@ -152,8 +152,7 @@ public:
        ///
        bool insertInset(BufferView *, Inset *);
        ///
-       bool insertInsetAllowed(Inset *) const;
-       bool insertInsetAllowed(Inset::Code) const;
+       bool insetAllowed(Inset::Code) const;
        ///
        UpdatableInset * getLockingInset() const;
        ///
index 9a6fbe629a1847622d0f6d76eb0509bd2af27e98..537ce1aeec2b70f240aac4f934b949721136f68a 100644 (file)
@@ -428,15 +428,6 @@ func_status::value_type LyXFunc::getStatus(int ac,
                disable = !Exporter::IsExportable(buf, "program");
                break;
 
-       case LFUN_INSERTFOOTNOTE:
-               // Disable insertion of floats in a tabular.
-               disable = false;
-               if (owner->view()->theLockingInset()) {
-                       disable = (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) ||
-                               owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
-               }
-               break;
-
        case LFUN_LAYOUT_TABULAR:
                disable = true;
                if (owner->view()->theLockingInset()) {
@@ -490,6 +481,12 @@ func_status::value_type LyXFunc::getStatus(int ac,
        case LFUN_BOOKMARK_GOTO:
                disable =  !owner->view()->
                        isSavedPosition(strToUnsignedInt(argument));
+               break;
+
+
+       case LFUN_INSET_TOGGLE:
+               disable = (TEXT(false)->getInset() == 0);
+               break;
 
        case LFUN_MATH_VALIGN: {
     // I think this test can be simplified (Andre')
@@ -592,43 +589,127 @@ func_status::value_type LyXFunc::getStatus(int ac,
 
        default:
                break;
-        }
-        if (disable)
-                flag |= func_status::Disabled;
-
-       if (buf) {
-               func_status::value_type box = func_status::ToggleOff;
-               LyXFont const & font =
-                       TEXT(false)->real_current_font;
-               switch (action) {
-               case LFUN_EMPH:
-                       if (font.emph() == LyXFont::ON)
-                               box = func_status::ToggleOn;
-                       break;
-               case LFUN_NOUN:
-                       if (font.noun() == LyXFont::ON)
-                               box = func_status::ToggleOn;
-                       break;
-               case LFUN_BOLD:
-                       if (font.series() == LyXFont::BOLD_SERIES)
-                               box = func_status::ToggleOn;
-                       break;
+       }
+
+       // the functions which insert insets
+       Inset::Code code = Inset::NO_CODE;
+       switch (action) {
+       case LFUN_INSET_TEXT:
+               code = Inset::TEXT_CODE;
+               break;
+       case LFUN_INSET_ERT:
+               code = Inset::ERT_CODE;         
+               break;
+       case LFUN_INSET_GRAPHICS:
+               code = Inset::GRAPHICS_CODE;
+               break;
+       case LFUN_INSET_FOOTNOTE:
+               code = Inset::FOOT_CODE;
+               break;
+       case LFUN_INSET_TABULAR:
+               code = Inset::TABULAR_CODE;
+               break;
+       case LFUN_INSET_EXTERNAL:
+               code = Inset::EXTERNAL_CODE;
+               break;
+       case LFUN_INSET_MARGINAL:
+               code = Inset::MARGIN_CODE;
+               break;
+       case LFUN_INSET_MINIPAGE:
+               code = Inset::MINIPAGE_CODE;
+               break;
+       case LFUN_INSET_FLOAT:
+       case LFUN_INSET_WIDE_FLOAT:
+               code = Inset::FLOAT_CODE;
+               break;
+#if 0
+       case LFUN_INSET_LIST:
+               code = Inset::LIST_CODE;
+               break;
+#endif
+       case LFUN_INSET_THEOREM:
+               code = Inset::THEOREM_CODE;
+               break;
+       case LFUN_INSET_CAPTION:
+               code = Inset::CAPTION_CODE;
+               break;
+       case LFUN_INSERT_NOTE:
+               code = Inset::IGNORE_CODE;
+               break;
+       case LFUN_INSERT_LABEL:
+               code = Inset::LABEL_CODE;
+               break;
+       case LFUN_REF_INSERT:
+               code = Inset::REF_CODE;
+               break;
+       case LFUN_CITATION_INSERT:
+               code = Inset::CITE_CODE;
+               break;
+       case LFUN_INSERT_BIBTEX:
+               code = Inset::BIBTEX_CODE;
+               break;
+       case LFUN_INDEX_INSERT:
+       case LFUN_INDEX_INSERT_LAST:
+               code = Inset::INDEX_CODE;
+               break;
+#if 0
+       case LFUN_CHILD_INSERT:
+               code = Inset::CHILD_CODE;
+               break;
+#endif
+       case LFUN_TOC_INSERT:
+               code = Inset::TOC_CODE;
+               break;
+       case LFUN_PARENTINSERT:
+               code = Inset::PARENT_CODE;
+               break;
+       case LFUN_INSERT_URL:
+               code = Inset::URL_CODE;
+               break;
+       default:
+               break;
+       }
+       if (code != Inset::NO_CODE 
+           && owner->view()->theLockingInset()
+           && !owner->view()->theLockingInset()->insetAllowed(code)) {
+               disable = true;
+       }
+
+       if (disable)
+               flag |= func_status::Disabled;
+       
+       // the font related functions
+       func_status::value_type box = func_status::ToggleOff;
+       LyXFont const & font =
+               TEXT(false)->real_current_font;
+       switch (action) {
+       case LFUN_EMPH:
+               if (font.emph() == LyXFont::ON)
+                       box = func_status::ToggleOn;
+               break;
+       case LFUN_NOUN:
+               if (font.noun() == LyXFont::ON)
+                       box = func_status::ToggleOn;
+               break;
+       case LFUN_BOLD:
+               if (font.series() == LyXFont::BOLD_SERIES)
+                       box = func_status::ToggleOn;
+               break;
 #ifndef NO_LATEX
-               case LFUN_TEX:
-                       if (font.latex() == LyXFont::ON)
-                               box = func_status::ToggleOn;
-                       break;
+       case LFUN_TEX:
+               if (font.latex() == LyXFont::ON)
+                       box = func_status::ToggleOn;
+               break;
 #endif
-               case LFUN_READ_ONLY_TOGGLE:
-                       if (buf->isReadonly())
-                               box = func_status::ToggleOn;
-                       break;
-               default:
-                       box = func_status::OK;
-                       break;
-               }
-               flag |= box;
+       case LFUN_READ_ONLY_TOGGLE:
+               if (buf->isReadonly())
+                       box = func_status::ToggleOn;
+               break;
+       default:
+               box = func_status::OK;
+               break;
        }
+       flag |= box;
 
        return flag;
 }
index 9cf1d7859f8d337bc8afdd2d68aa855c620f6997..95b61730c0d5cd04b90cf370e8fcfaf564825d51 100644 (file)
@@ -271,6 +271,8 @@ public:
        void getWord(LyXCursor & from, LyXCursor & to, word_location) const;
        /// just selects the word the cursor is in
        void selectWord(BufferView *);
+       /// returns the inset at cursor (if it exists), 0 otherwise
+       Inset * getInset() const;
 
        /** 'selects" the next word, where the cursor is not in 
         and returns this word as string. THe cursor will be moved 
@@ -377,7 +379,7 @@ public:
                           Row * row_ptr, int y, bool cleared=false);
 
        /// 
-       void openStuff(BufferView *);
+       void toggleInset(BufferView *);
        ///
        void cutSelection(BufferView *, bool = true);
        ///
index 6f6d0e848c614193553be7caf242502f61bfd3b4..5e70fda1ec300f62ad0ebcaee94a7e99486f5980 100644 (file)
@@ -430,7 +430,7 @@ void Paragraph::cutIntoMinibuffer(BufferParams const & bparams,
 bool Paragraph::insertFromMinibuffer(Paragraph::size_type pos)
 {
        if ((minibuffer_char == Paragraph::META_INSET) &&
-           !insertInsetAllowed(minibuffer_inset))
+           !insetAllowed(minibuffer_inset->lyxCode()))
                return false;
        if (minibuffer_char == Paragraph::META_INSET)
                insertInset(pos, minibuffer_inset, minibuffer_font);
@@ -489,12 +489,12 @@ void Paragraph::insertInset(Paragraph::size_type pos,
 }
 
 
-bool Paragraph::insertInsetAllowed(Inset * inset)
+bool Paragraph::insetAllowed(Inset::Code code)
 {
        //lyxerr << "Paragraph::InsertInsetAllowed" << endl;
        
        if (pimpl_->inset_owner)
-               return pimpl_->inset_owner->insertInsetAllowed(inset);
+               return pimpl_->inset_owner->insetAllowed(code);
        return true;
 }
 
index 9fc5b9b16fa7f3780b4d7bcade0e5d71cfa33ea0..042da4b717435202e40b4cd497e6012d84826698 100644 (file)
@@ -274,7 +274,7 @@ public:
        ///
        void insertInset(size_type pos, Inset * inset, LyXFont const &);
        ///
-       bool insertInsetAllowed(Inset * inset);
+       bool insetAllowed(Inset::Code code);
        ///
        Inset * getInset(size_type pos);
        ///
index 3c64a7ab7558c064036bf2edf922c44f112695a1..99497d055529a6e1f79872f7cefe5806f5f12223 100644 (file)
@@ -360,20 +360,29 @@ void LyXText::insertParagraph(BufferView * bview, Paragraph * par,
        }
 }
 
-void LyXText::openStuff(BufferView * bview)
+Inset * LyXText::getInset() const
 {
+       Inset * inset = 0;
        if (cursor.pos() == 0 && cursor.par()->bibkey){
-               cursor.par()->bibkey->edit(bview, 0, 0, 0);
+               inset = cursor.par()->bibkey;
        } else if (cursor.pos() < cursor.par()->size() 
                   && cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET) {
-               Inset * inset = cursor.par()->getInset(cursor.pos());
-               if (!inset->editable())
-                       return;
-               bview->owner()->message(inset->editMessage());
-               if (inset->editable() != Inset::HIGHLY_EDITABLE)
-                       setCursorParUndo(bview);
-               inset->edit(bview, 0, 0, 0);
+               inset = cursor.par()->getInset(cursor.pos());
        }
+       return inset;
+}
+
+void LyXText::toggleInset(BufferView * bview)
+{
+       Inset * inset = getInset();
+       if (!inset->editable())
+               return;
+       //bview->owner()->message(inset->editMessage());
+
+       // do we want to keep this?? (JMarc)
+       if (inset->editable() != Inset::HIGHLY_EDITABLE)
+               setCursorParUndo(bview);
+       inset->open(bview, !inset->isOpen());
 }
 
 
@@ -1534,7 +1543,7 @@ void LyXText::updateCounters(BufferView * bview, Row * row) const
 
 void LyXText::insertInset(BufferView * bview, Inset * inset)
 {
-       if (!cursor.par()->insertInsetAllowed(inset))
+       if (!cursor.par()->insetAllowed(inset->lyxCode()))
                return;
        setUndo(bview, Undo::INSERT,
                cursor.par(), cursor.par()->next());