return true;
}
- case LFUN_INSET_DISSOLVE: {
- status.enabled(false);
- return true;
- }
-
- // because of the dissolve handling in insettext:
- case LFUN_CHAR_DELETE_FORWARD:
- if (!cur.selection() && cur.depth() > 1
- && cur.pit() == cur.lastpit()
- && cur.pos() == cur.lastpos()) {
- status.enabled(false);
- return true;
- }
- // Fall through
-
- case LFUN_CHAR_DELETE_BACKWARD:
- if (cur.depth() > 1 && cur.pit() == 0 && cur.pos() == 0) {
- status.enabled(false);
- return true;
- }
- // Fall through
-
case LFUN_INSET_MODIFY:
if (translate(cmd.getArg(0)) == TABULAR_CODE) {
status.enabled(true);
#include "dispatchresult.h"
#include "errorlist.h"
#include "funcrequest.h"
-#include "FuncStatus.h"
#include "gettext.h"
#include "intl.h"
#include "LColor.h"
<< " [ cmd.action = "
<< cmd.action << ']' << endl;
setViewCache(&cur.bv());
-
- switch (cmd.action) {
-
- case LFUN_CHAR_DELETE_FORWARD: {
- if (!cur.selection() && cur.depth() > 1
- && cur.pit() == cur.lastpit()
- && cur.pos() == cur.lastpos())
- // Merge inset with owner
- cmd = FuncRequest(LFUN_INSET_DISSOLVE);
- text_.dispatch(cur, cmd);
- break;
- }
-
- case LFUN_CHAR_DELETE_BACKWARD: {
- if (cur.depth() > 1 && cur.pit() == 0 && cur.pos() == 0)
- // Merge inset with owner
- cmd = FuncRequest(LFUN_INSET_DISSOLVE);
- text_.dispatch(cur, cmd);
- break;
- }
-
- default:
- text_.dispatch(cur, cmd);
- break;
- }
+ text_.dispatch(cur, cmd);
}
bool InsetText::getStatus(LCursor & cur, FuncRequest const & cmd,
FuncStatus & status) const
{
- switch (cmd.action) {
-
- case LFUN_CHAR_DELETE_FORWARD:
- case LFUN_CHAR_DELETE_BACKWARD:
- status.enabled(true);
- return true;
-
- default:
- return text_.getStatus(cur, cmd, status);
- }
+ return text_.getStatus(cur, cmd, status);
}
bool backspacePos0(LCursor & cur);
/// Delete character before cursor. Honour CT
bool backspace(LCursor & cur);
+ // Dissolve the inset under cursor
+ bool dissolveInset(LCursor & cur);
///
bool selectWordWhenUnderCursor(LCursor & cur, lyx::word_location);
///
using lyx::support::uppercase;
using lyx::cap::cutSelection;
+using lyx::cap::pasteParagraphList;
using std::auto_ptr;
using std::advance;
} else {
setCursorIntern(scur, scur.pit(), scur.pos(), false, scur.boundary());
}
- }
+ } else
+ needsUpdate = dissolveInset(cur);
+
return needsUpdate;
}
BOOST_ASSERT(this == cur.text());
bool needsUpdate = false;
if (cur.pos() == 0) {
+ if (cur.pit() == 0)
+ return dissolveInset(cur);
+
// The cursor is at the beginning of a paragraph, so
// the the backspace will collapse two paragraphs into
// one.
}
+bool LyXText::dissolveInset(LCursor & cur) {
+ BOOST_ASSERT(this == cur.text());
+
+ if (isMainText() || cur.inset().nargs() != 1)
+ return false;
+
+ recordUndoInset(cur);
+ cur.selHandle(false);
+ // save position
+ lyx::pos_type spos = cur.pos();
+ lyx::pit_type spit = cur.pit();
+ ParagraphList plist;
+ if (cur.lastpit() != 0 || cur.lastpos() != 0)
+ plist = paragraphs();
+ cur.popLeft();
+ // store cursor offset
+ if (spit == 0)
+ spos += cur.pos();
+ spit += cur.pit();
+ cur.paragraph().erase(cur.pos());
+ if (!plist.empty()) {
+ Buffer & b = cur.buffer();
+ pasteParagraphList(cur, plist, b.params().textclass,
+ b.errorList("Paste"));
+ // restore position
+ cur.pit() = std::min(cur.lastpit(), spit);
+ cur.pos() = std::min(cur.lastpos(), spos);
+ }
+ cur.clearSelection();
+ cur.resetAnchor();
+ return true;
+}
+
+
Row const & LyXText::firstRow() const
{
return *paragraphs().front().rows().begin();
using lyx::cap::copySelection;
using lyx::cap::cutSelection;
-using lyx::cap::pasteParagraphList;
using lyx::cap::pasteSelection;
using lyx::cap::replaceSelection;
break;
}
- case LFUN_INSET_DISSOLVE: {
- recordUndoInset(cur);
- cur.selHandle(false);
- // save position
- lyx::pos_type spos = cur.pos();
- lyx::pit_type spit = cur.pit();
- ParagraphList plist;
- if (cur.lastpit() != 0 || cur.lastpos() != 0)
- plist = paragraphs();
- cur.popLeft();
- // store cursor offset
- if (spit == 0)
- spos += cur.pos();
- spit += cur.pit();
- cur.paragraph().erase(cur.pos());
- if (!plist.empty()) {
- Buffer * b = bv->buffer();
- pasteParagraphList(cur, plist, b->params().textclass,
- b->errorList("Paste"));
- // restore position
- cur.pit() = std::min(cur.lastpit(), spit);
- cur.pos() = std::min(cur.lastpos(), spos);
- }
- cur.clearSelection();
- cur.resetAnchor();
- needsUpdate = true;
+ case LFUN_INSET_DISSOLVE:
+ needsUpdate = dissolveInset(cur);
break;
- }
case LFUN_INSET_SETTINGS:
cur.inset().showInsetDialog(bv);
enable = lyx::cap::numberOfSelections() > 0;
break;
- case LFUN_PARAGRAPH_MOVE_UP: {
+ case LFUN_PARAGRAPH_MOVE_UP:
enable = cur.pit() > 0 && !cur.selection();
break;
- }
- case LFUN_PARAGRAPH_MOVE_DOWN: {
+ case LFUN_PARAGRAPH_MOVE_DOWN:
enable = cur.pit() < cur.lastpit() && !cur.selection();
break;
- }
- case LFUN_INSET_DISSOLVE: {
- enable = !isMainText() && cur.inTexted();
+ case LFUN_INSET_DISSOLVE:
+ enable = !isMainText() && cur.inset().nargs() == 1;
break;
- }
case LFUN_WORD_DELETE_FORWARD:
case LFUN_WORD_DELETE_BACKWARD: