]> git.lyx.org Git - features.git/commitdiff
another bad binding related to ticket #6416 (see r32619)
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 23 Dec 2009 14:27:43 +0000 (14:27 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 23 Dec 2009 14:27:43 +0000 (14:27 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32620 a592a061-630c-0410-9148-cb99ea01b6c8

lib/bind/aqua.bind
src/BufferView.cpp
src/FuncCode.h
src/LyXAction.cpp

index bf138716ab925217b7e645cab0c1765323993d20..319dc829b8aee69fc57cbdb4008c681cd480f9d3 100644 (file)
@@ -32,7 +32,7 @@
 \bind "M-~S-i s l"             "newline-insert newline"
 \bind "M-~S-i s r"             "newline-insert linebreak"
 \bind "M-~S-i s i"             "specialchar-insert dots"
-\bind "M-~S-i s e"             "specialchar-insert end-of-sentence-period"
+\bind "M-~S-i s e"             "specialchar-insert end-of-sentence"
 \bind "M-~S-i s q"             "self-insert \""
 # FIXME: find a binding for single quotes
 # \bind "M-~S-i s q"           "quote-insert single"
index cb06810f7aaafa248eab7cd0b858a32f0feb336e..a207abd936603557052e6b8e3ed6526af19e24b6 100644 (file)
@@ -1090,6 +1090,7 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
        case LFUN_SCROLL:
        case LFUN_SCREEN_UP_SELECT:
        case LFUN_SCREEN_DOWN_SELECT:
+       case LFUN_INSET_FORALL:
                flag.setEnabled(true);
                break;
 
@@ -1729,6 +1730,53 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                break;
        }
 
+
+       // This would be in Buffer class if only Cursor did not
+       // require a bufferview
+       case LFUN_INSET_FORALL: {
+               docstring const name = from_utf8(cmd.getArg(0));
+               string const commandstr = cmd.getLongArg(1);
+               FuncRequest const fr = lyxaction.lookupFunc(commandstr);
+
+               // an arbitrary number to limit number of iterations
+               const int max_iter = 1000;
+               int iterations = 0;
+               Cursor & cur = d->cursor_;
+               cur.reset();
+               if (!cur.nextInset())
+                       cur.forwardInset();
+               cur.beginUndoGroup();
+               while(cur && iterations < max_iter) {
+                       Inset * ins = cur.nextInset();
+                       if (!ins)
+                               break;
+                       docstring insname = ins->name();
+                       while (!insname.empty()) {
+                               if (insname == name || name == from_utf8("*")) {
+                                       cur.recordUndo();
+                                       lyx::dispatch(fr);
+                                       ++iterations;
+                                       break;
+                               }
+                               size_t const i = insname.rfind(':');
+                               if (i == string::npos)
+                                       break;
+                               insname = insname.substr(0, i);
+                       }
+                       cur.forwardInset();
+               }
+               cur.endUndoGroup();
+               cur.reset();
+               processUpdateFlags(Update::Force);
+
+               if (iterations >= max_iter)
+                       cur.errorMessage(bformat(_("inset-forall interrupted because number of actions is larger than %1$s"), max_iter));
+               else
+                       cur.message(bformat(_("Applied \"%1$s\" to %2$d insets"), from_utf8(commandstr), iterations));
+               break;
+       }
+
+
        case LFUN_ALL_INSETS_TOGGLE: {
                string action;
                string const name = split(to_utf8(cmd.argument()), action, ' ');
index 65f602c3fba6cbf6d4d86cea363a828ca4af2afd..7324c2bf5c0ed625fa0f8695e8db648f31971e04 100644 (file)
@@ -443,6 +443,7 @@ enum FuncCode
        LFUN_GRAPHICS_RELOAD,           // vfr 20090810
        LFUN_SCREEN_SHOW_CURSOR,        // vfr, 20090325
        LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE, // ARRae 971202
+       LFUN_INSET_FORALL,              // lasgouttes, 20091127
 
        LFUN_LASTACTION                 // end of the table
 };
index d2d9d757001652f4133b53604808edb6fee431c6..d975eb5c5baf9b0a1201d8a0daf69f788aeaf69b 100644 (file)
@@ -3434,6 +3434,27 @@ void LyXAction::init()
                { LFUN_GRAPHICS_RELOAD, "graphics-reload", ReadOnly | AtPoint, Edit },
 
 
+/*!
+ * \var lyx::FuncCode lyx::LFUN_INSET_FORALL
+
+ * \li Action: Apply the given commands on insets of a given name. WARNING: use
+               at your own risks; this function gives you too many ways of
+              shooting yourself in the foot. A typical example is
+                   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 1000.
+ * \li Syntax: inset-forall <NAME> <LFUN-COMMAND>
+               If <NAME> is *, all insets are matched.
+ * \li Sample: The name is used like for InsetLayout in layout files: "Note" 
+               matches all note insets, while "Note:Note" only matches LyX 
+              yellow note insets. The following command closes all note insets
+                   inset-forall Note inset-toggle close
+ * \li Origin: lasgouttes, 27 Nov 2009
+ * \endvar
+ */
+               { LFUN_INSET_FORALL, "inset-forall", ReadOnly, Edit },
+
+
                { LFUN_NOACTION, "", Noop, Hidden }
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
        };