]> git.lyx.org Git - lyx.git/commitdiff
Get rid of all-insets-toggle and explain how to replace it with inset-forall.
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 8 Apr 2010 12:39:41 +0000 (12:39 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 8 Apr 2010 12:39:41 +0000 (12:39 +0000)
Change inset-forall so that screen is not repainted at each iteration, since this lead to very slow opeartion on large files. This is not a problem for current uses, but can potentially lead to crashes.

See ticket #6641 for more thoughts and possible solutions.

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

RELEASE-NOTES
lib/ui/stdcontext.inc
lib/ui/stdmenus.inc
src/BufferView.cpp
src/FuncCode.h
src/LyX.h
src/LyXAction.cpp
src/frontends/qt4/GuiDocument.cpp

index ab23e5077bedf67401a14ba595dec295109d4d4f..0d0cc31d91fffb8dc4dffaba4d1ffa7db0d49339 100644 (file)
@@ -98,6 +98,15 @@ The following LyX functions have been removed:
   with the more general function inset-forall
     inset-forall Note:<SOURCE> inset-modify note Note <TARGET>
 
+- LFUN_ALL_INSETS_TOGGLE ("all-insets-toggle"): replace
+    all-insets-toggle <ACTION> <TARGET>
+    all-insets-toggle <ACTION>
+  with the more generic function inset-forall
+    inset-forall <TARGET> inset-toggle <ACTION>
+    inset-forall * inset-toggle <ACTION>
+  There is a difference in the <TARGET> parameter, which is would be
+  like "note" in the first case and "Note" in the second.
+
 - LFUN_TABULAR_FEATURE ("tabular-feature"): use "inset-modify" instead.
 
 
index 79e242eb3ca12e50468667673b84159e1fce6e92..29f4026926e7a80fd838b28d19a083729cf39d3d 100644 (file)
@@ -179,8 +179,8 @@ Menuset
                OptItem "Open Inset|O" "inset-toggle open"
                OptItem "Close Inset|C" "inset-toggle close"
                Separator
-               Item "Open All Notes|A" "all-insets-toggle open note"
-               Item "Close All Notes|l" "all-insets-toggle close note"
+               Item "Open All Notes|A" "inset-forall Note inset-toggle open"
+               Item "Close All Notes|l" "inset-forall Note inset-toggle close"
                Separator
                Item "Dissolve Inset|D" "inset-dissolve"
        End
index 751242dc9d9e2f9f9ea3d8ea2a800197057c4b79..192b863e59f3ee8a7352c3efc99a03053ded6786 100644 (file)
@@ -306,8 +306,8 @@ Menuset
 #
 
        Menu "view"
-               Item "Open All Insets|O" "all-insets-toggle open"
-               Item "Close All Insets|C" "all-insets-toggle close"
+               Item "Open All Insets|O" "inset-forall * inset-toggle open"
+               Item "Close All Insets|C" "inset-forall * inset-toggle close"
                Separator
                Item "Unfold Math Macro|n" "math-macro-unfold"
                Item "Fold Math Macro|d" "math-macro-fold"
index 93c5b7f23c6472ba8e49e001c8ffd8f23aca3574..d5e4a016e40884907883ff5063c5d5f4d1f24d91 100644 (file)
@@ -1020,7 +1020,6 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
        case LFUN_SCREEN_SHOW_CURSOR:
        case LFUN_BIBTEX_DATABASE_ADD:
        case LFUN_BIBTEX_DATABASE_DEL:
-       case LFUN_ALL_INSETS_TOGGLE:
        case LFUN_STATISTICS:
        case LFUN_BRANCH_ADD_INSERT:
        case LFUN_KEYMAP_OFF:
@@ -1714,7 +1713,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        while (!insname.empty()) {
                                if (insname == name || name == from_utf8("*")) {
                                        cur.recordUndo();
-                                       lyx::dispatch(fr);
+                                       lyx::dispatch(fr, dr);
                                        ++iterations;
                                        break;
                                }
@@ -1739,29 +1738,6 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
        }
 
 
-       case LFUN_ALL_INSETS_TOGGLE: {
-               string action;
-               string const name = split(to_utf8(cmd.argument()), action, ' ');
-               InsetCode const inset_code = insetCode(name);
-
-               FuncRequest fr(LFUN_INSET_TOGGLE, action);
-
-               Inset & inset = cur.buffer()->inset();
-               InsetIterator it  = inset_iterator_begin(inset);
-               InsetIterator const end = inset_iterator_end(inset);
-               for (; it != end; ++it) {
-                       if (it->asInsetCollapsable()
-                           && (inset_code == NO_CODE
-                           || inset_code == it->lyxCode())) {
-                               Cursor tmpcur = cur;
-                               tmpcur.pushBackward(*it);
-                               it->dispatch(tmpcur, fr);
-                       }
-               }
-               dr.update(Update::Force | Update::FitCursor);
-               break;
-       }
-
        case LFUN_BRANCH_ADD_INSERT: {
                docstring branch_name = from_utf8(cmd.getArg(0));
                if (branch_name.empty())
index 8aa37890dd96b4c1830cc7205c823307d2ea3eae..20434e5ef4e99e1252a44cd3ddeee7ef98603d20 100644 (file)
@@ -322,7 +322,7 @@ enum FuncCode
        LFUN_WORD_REPLACE,
        LFUN_BUFFER_EXPORT_CUSTOM,
        LFUN_BUFFER_PRINT,
-       LFUN_ALL_INSETS_TOGGLE,
+       LFUN_BUFFER_CLOSE_ALL,          // vfr 20090806
        // 245
        LFUN_BUFFER_LANGUAGE,
        LFUN_TEXTCLASS_APPLY,
@@ -439,12 +439,11 @@ enum FuncCode
        LFUN_BRANCH_ADD_INSERT,
        // 340
        LFUN_BRANCHES_RENAME,           // spitz 20090709
-       LFUN_BUFFER_CLOSE_ALL,          // vfr 20090806
        LFUN_GRAPHICS_RELOAD,           // vfr 20090810
        LFUN_SCREEN_SHOW_CURSOR,        // vfr, 20090325
        LFUN_SPELLING_ADD,              // spitz 20100118
-       // 345
        LFUN_SPELLING_IGNORE,           // spitz 20100118
+       // 345
        LFUN_PREVIEW_INSERT,            // vfr, 20100328
 
        LFUN_LASTACTION                 // end of the table
index fdfe0c929aef4a45d38f1fc90365e590c275f9b0..238fe38de0c708f05ee4c8432ae6d1cc4fe2fa93 100644 (file)
--- a/src/LyX.h
+++ b/src/LyX.h
@@ -160,6 +160,9 @@ FuncStatus getStatus(FuncRequest const & action);
 ///
 void dispatch(FuncRequest const & action);
 
+///
+void dispatch(FuncRequest const & action, DispatchResult & dr);
+
 } // namespace lyx
 
 #endif // LYX_H
index af1f6041dea1bc9b0afe5c9c7dd491faca11c8bf..053680a66ed80d47193a5bd53183e24d00787153 100644 (file)
@@ -2388,17 +2388,6 @@ void LyXAction::init()
  * \endvar
  */
                { LFUN_INSET_TOGGLE, "inset-toggle", ReadOnly | AtPoint, Edit },
-/*!
- * \var lyx::FuncCode lyx::LFUN_ALL_INSETS_TOGGLE
- * \li Action: Toggles (open/closes) all collapsable insets (of a given type) in the document.
- * \li Notion: Used for box, branch, ert, float, listings, note, tabular, wrap insets.
- * \li Syntax: all-insets-toggle [<STATE>] [<INSET>]
- * \li Params: <STATE>: <toggle|open|close|assign> default: toggle \n
-               <INSET>: <box|branch|ert|float|listings|note|tabular|wrap> default: all insets
- * \li Origin: leeming, 30 Mar 2004
- * \endvar
- */
-               { LFUN_ALL_INSETS_TOGGLE, "all-insets-toggle", ReadOnly, Edit },
 /*!
  * \var lyx::FuncCode lyx::LFUN_INSET_FORALL
  * \li Action: Apply the given commands on insets of a given name.
@@ -2408,6 +2397,9 @@ void LyXAction::init()
                    inset-forall Note note-insert
                which starts an infinite loop. This is mitigated by the fact
                that the number of actions is arbitrarily limited to 10000.
+               Note also that inset-forall does not update metrics between 
+               iterations, which can lead to bugs. This has to be eventually
+               fixed.
  * \li Syntax: inset-forall <NAME> <LFUN-COMMAND> \n
                <NAME>: Type of Inset. If <NAME> is *, all insets are matched.
                The name is used like for InsetLayout in layout files: "Note"
index 77923128dadddacec3ad511a1d7b96f6bb77b664..427fe5d3a5f20fe9695716046873548602205acc 100644 (file)
@@ -3126,8 +3126,8 @@ void GuiDocument::dispatchParams()
                }
 
                // Open insets of selected branches, close deselected ones
-               dispatch(FuncRequest(LFUN_ALL_INSETS_TOGGLE,
-                       "assign branch"));
+               dispatch(FuncRequest(LFUN_INSET_FORALL,
+                       "Branch inset-toggle assign"));
        }
        // rename branches in the document
        executeBranchRenaming();