From e8529a2ecf233b8c3ccadbad4da14941fa02fd07 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 8 Apr 2010 12:39:41 +0000 Subject: [PATCH] Get rid of all-insets-toggle and explain how to replace it with inset-forall. 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 | 9 +++++++++ lib/ui/stdcontext.inc | 4 ++-- lib/ui/stdmenus.inc | 4 ++-- src/BufferView.cpp | 26 +------------------------- src/FuncCode.h | 5 ++--- src/LyX.h | 3 +++ src/LyXAction.cpp | 14 +++----------- src/frontends/qt4/GuiDocument.cpp | 4 ++-- 8 files changed, 24 insertions(+), 45 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ab23e5077b..0d0cc31d91 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -98,6 +98,15 @@ The following LyX functions have been removed: with the more general function inset-forall inset-forall Note: inset-modify note Note +- LFUN_ALL_INSETS_TOGGLE ("all-insets-toggle"): replace + all-insets-toggle + all-insets-toggle + with the more generic function inset-forall + inset-forall inset-toggle + inset-forall * inset-toggle + There is a difference in the 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. diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc index 79e242eb3c..29f4026926 100644 --- a/lib/ui/stdcontext.inc +++ b/lib/ui/stdcontext.inc @@ -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 diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc index 751242dc9d..192b863e59 100644 --- a/lib/ui/stdmenus.inc +++ b/lib/ui/stdmenus.inc @@ -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" diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 93c5b7f23c..d5e4a016e4 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -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()) diff --git a/src/FuncCode.h b/src/FuncCode.h index 8aa37890dd..20434e5ef4 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -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 diff --git a/src/LyX.h b/src/LyX.h index fdfe0c929a..238fe38de0 100644 --- 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 diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index af1f6041de..053680a66e 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -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 [] [] - * \li Params: : default: toggle \n - : 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 \n : Type of Inset. If is *, all insets are matched. The name is used like for InsetLayout in layout files: "Note" diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 77923128da..427fe5d3a5 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -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();