\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"
case LFUN_SCROLL:
case LFUN_SCREEN_UP_SELECT:
case LFUN_SCREEN_DOWN_SELECT:
+ case LFUN_INSET_FORALL:
flag.setEnabled(true);
break;
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, ' ');
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
};
{ 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
};