* \li Origin: JSpitz, 7 Aug 2006
* \endvar
*/
- { LFUN_INSET_DISSOLVE, "inset-dissolve", Noop, Edit },
+ { LFUN_INSET_DISSOLVE, "inset-dissolve", AtPoint, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_INSET_INSERT
* \li Action: Insert new inset (type given by the parameters).
}
case LFUN_INSET_DISSOLVE: {
- // first, try if there's an inset at cursor
- // FIXME: this first part should be moved to
- // a LFUN_NEXT_INSET_DISSOLVE, or be called via
- // some generic "next-inset inset-dissolve"
- Inset * inset = cur.nextInset();
- if (inset && inset->isActive()) {
- Cursor tmpcur = cur;
- tmpcur.pushBackward(*inset);
- inset->dispatch(tmpcur, cmd);
- if (tmpcur.result().dispatched()) {
- cur.dispatched();
- break;
- }
- }
- // if it did not work, try the underlying inset
- if (dissolveInset(cur)) {
+ if (dissolveInset(cur))
needsUpdate = true;
- break;
- }
- // if it did not work, do nothing.
break;
}
enable = cur.pit() < cur.lastpit() && !cur.selection();
break;
- case LFUN_INSET_DISSOLVE:
- if (!cmd.argument().empty()) {
- InsetLayout const & il = cur.inset().getLayout();
- InsetLayout::InsetLyXType const type =
- translateLyXType(to_utf8(cmd.argument()));
- enable = cur.inset().lyxCode() == FLEX_CODE
- && il.lyxtype() == type;
- } else {
- enable = ((!isMainText()
- && cur.inset().nargs() == 1)
- || (cur.nextInset()
- && cur.nextInset()->nargs() == 1));
- }
- break;
-
case LFUN_CHANGE_ACCEPT:
case LFUN_CHANGE_REJECT:
// In principle, these LFUNs should only be enabled if there
#include "Buffer.h"
#include "BufferParams.h"
+#include "Cursor.h"
+#include "FuncRequest.h"
+#include "FuncStatus.h"
#include "Lexer.h"
#include "support/gettext.h"
}
+bool InsetFlex::getStatus(Cursor & cur, FuncRequest const & cmd,
+ FuncStatus & flag) const
+{
+ switch (cmd.action) {
+ case LFUN_INSET_DISSOLVE:
+ if (!cmd.argument().empty()) {
+ InsetLayout const & il = getLayout();
+ InsetLayout::InsetLyXType const type =
+ translateLyXType(to_utf8(cmd.argument()));
+ if (il.lyxtype() == type) {
+ FuncRequest temp_cmd(LFUN_INSET_DISSOLVE);
+ return InsetCollapsable::getStatus(cur, temp_cmd, flag);
+ } else
+ return false;
+ }
+ // fall-through
+ default:
+ return InsetCollapsable::getStatus(cur, cmd, flag);
+ }
+}
+
+
+void InsetFlex::doDispatch(Cursor & cur, FuncRequest & cmd)
+{
+ switch (cmd.action) {
+ case LFUN_INSET_DISSOLVE:
+ if (!cmd.argument().empty()) {
+ InsetLayout const & il = getLayout();
+ InsetLayout::InsetLyXType const type =
+ translateLyXType(to_utf8(cmd.argument()));
+
+ if (il.lyxtype() == type) {
+ FuncRequest temp_cmd(LFUN_INSET_DISSOLVE);
+ InsetCollapsable::doDispatch(cur, temp_cmd);
+ } else
+ cur.undispatched();
+ break;
+ }
+ // fall-through
+ default:
+ InsetCollapsable::doDispatch(cur, cmd);
+ break;
+ }
+}
+
+
} // namespace lyx
bool neverIndent() const { return true; }
///
bool hasSettings() const { return false; }
+ ///
+ bool getStatus(Cursor & cur, FuncRequest const & cmd,
+ FuncStatus &) const;
+ ///
+ void doDispatch(Cursor & cur, FuncRequest & cmd);
protected:
+ ///
InsetFlex(InsetFlex const &);
private:
+ ///
Inset * clone() const { return new InsetFlex(*this); }
///
std::string name_;
// FIXME: Change only the pasted paragraphs
fixParagraphsFont();
break;
+
+ case LFUN_INSET_DISSOLVE: {
+ bool const main_inset = &buffer().inset() == this;
+ bool const target_inset = cmd.argument().empty()
+ || cmd.getArg(0) == insetName(lyxCode());
+ bool const one_cell = cur.inset().nargs() == 1;
+
+ if (!main_inset && target_inset && one_cell) {
+ // Text::dissolveInset assumes that the cursor
+ // is inside the Inset.
+ if (&cur.inset() != this)
+ cur.pushBackward(*this);
+ cur.beginUndoGroup();
+ text_.dispatch(cur, cmd);
+ cur.endUndoGroup();
+ } else
+ cur.undispatched();
+ break;
+ }
+
default:
text_.dispatch(cur, cmd);
}
case LFUN_PARAGRAPH_UPDATE:
status.setEnabled(allowParagraphCustomization());
return true;
+
+ case LFUN_INSET_DISSOLVE: {
+ bool const main_inset = &buffer().inset() == this;
+ bool const target_inset = cmd.argument().empty()
+ || cmd.getArg(0) == insetName(lyxCode());
+ bool const one_cell = cur.inset().nargs() == 1;
+
+ return !main_inset && target_inset && one_cell;
+ }
+
default:
// Dispatch only to text_ if the cursor is inside
// the text_. It is not for context menus (bug 5797).