cur.buffer()->errors("Paste");
cur.clearSelection(); // bug 393
cur.finishUndo();
- InsetText * insetText = dynamic_cast<InsetText *>(inset);
- if (insetText) {
- insetText->fixParagraphsFont();
- if (!insetText->allowMultiPar() || cur.lastpit() == 0) {
+ InsetText * inset_text = inset->asInsetText();
+ if (inset_text) {
+ inset_text->fixParagraphsFont();
+ if (!inset_text->allowMultiPar() || cur.lastpit() == 0) {
// reset first par to default
cur.text()->paragraphs().begin()
->setPlainOrDefaultLayout(bparams.documentClass());
case LFUN_WORD_FORWARD_SELECT:
needsUpdate |= cur.selHandle(cmd.action() == LFUN_WORD_FORWARD_SELECT);
needsUpdate |= cursorForwardOneWord(cur);
+
+ if (!needsUpdate && oldTopSlice == cur.top()
+ && cur.boundary() == oldBoundary) {
+ cur.undispatched();
+ cmd = FuncRequest(LFUN_FINISHED_FORWARD);
+
+ // we will probably be moving out the inset, so we should execute
+ // the depm-mechanism, but only when the cursor has a place to
+ // go outside this inset, i.e. in a slice above.
+ if (cur.depth() > 1 && cur.pos() == cur.lastpos()
+ && cur.pit() == cur.lastpit()) {
+ // The cursor hasn't changed yet. To give the
+ // DEPM the possibility of doing something we must
+ // provide it with two different cursors.
+ Cursor dummy = cur;
+ dummy.pos() = dummy.pit() = 0;
+ if (cur.bv().checkDepm(dummy, cur))
+ cur.forceBufferUpdate();;
+ }
+ }
break;
case LFUN_WORD_LEFT:
case LFUN_WORD_BACKWARD_SELECT:
needsUpdate |= cur.selHandle(cmd.action() == LFUN_WORD_BACKWARD_SELECT);
needsUpdate |= cursorBackwardOneWord(cur);
+
+ if (!needsUpdate && oldTopSlice == cur.top()
+ && cur.boundary() == oldBoundary) {
+ cur.undispatched();
+ cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
+
+ // we will probably be moving out the inset, so we should execute
+ // the depm-mechanism, but only when the cursor has a place to
+ // go outside this inset, i.e. in a slice above.
+ if (cur.depth() > 1 && cur.pos() == 0
+ && cur.pit() == 0) {
+ // The cursor hasn't changed yet. To give the
+ // DEPM the possibility of doing something we must
+ // provide it with two different cursors.
+ Cursor dummy = cur;
+ dummy.pos() = cur.lastpos();
+ dummy.pit() = cur.lastpit();
+ if (cur.bv().checkDepm(dummy, cur))
+ cur.forceBufferUpdate();
+ }
+ }
break;
case LFUN_WORD_SELECT: {
pit_type const pit_end = cur.selEnd().pit();
for (pit_type pit = cur.selBegin().pit(); pit <= pit_end; pit++) {
Paragraph & par = paragraphs()[pit];
- if (par.getChar(0) == '\t') {
- if (cur.pit() == pit)
- cur.posBackward();
- if (cur.realAnchor().pit() == pit && cur.realAnchor().pos() > 0 )
- cur.realAnchor().backwardPos();
-
- par.eraseChar(0, tc);
- } else
- // If no tab was present, try to remove up to four spaces.
- for (int n_spaces = 0;
- par.getChar(0) == ' ' && n_spaces < 4; ++n_spaces) {
+ if (par.empty())
+ continue;
+ char_type const c = par.getChar(0);
+ if (c == '\t' || c == ' ') {
+ // remove either 1 tab or 4 spaces.
+ int const n = (c == ' ' ? 4 : 1);
+ for (int i = 0; i < n
+ && !par.empty() && par.getChar(0) == c; ++i) {
if (cur.pit() == pit)
cur.posBackward();
- if (cur.realAnchor().pit() == pit && cur.realAnchor().pos() > 0 )
+ if (cur.realAnchor().pit() == pit
+ && cur.realAnchor().pos() > 0 )
cur.realAnchor().backwardPos();
-
par.eraseChar(0, tc);
}
+ }
}
cur.finishUndo();
} else {
}
p["target"] = (cmd.argument().empty()) ?
content : cmd.argument();
- string const data = InsetCommand::params2string("href", p);
+ string const data = InsetCommand::params2string(p);
if (p["target"].empty()) {
bv->showDialog("href", data);
} else {
p["name"] = (cmd.argument().empty()) ?
cur.getPossibleLabel() :
cmd.argument();
- string const data = InsetCommand::params2string("label", p);
+ string const data = InsetCommand::params2string(p);
if (cmd.argument().empty()) {
bv->showDialog("label", data);
break;
}
- case LFUN_LINE_INSERT: {
- InsetCommandParams p(LINE_CODE);
- p["offset"] = from_ascii(".5ex");
- p["width"] = from_ascii("100col%");
- p["height"] = from_ascii("1pt");
- string const data = InsetCommand::params2string("line", p);
-
- if (cmd.argument().empty()) {
- bv->showDialog("line", data);
- } else {
- FuncRequest fr(LFUN_INSET_INSERT, data);
- dispatch(cur, fr);
- }
- break;
- }
-
case LFUN_INFO_INSERT: {
Inset * inset;
if (cmd.argument().empty() && cur.selection()) {
p["symbol"] = bv->cursor().innerText()->getStringToIndex(bv->cursor());
else
p["symbol"] = cmd.argument();
- string const data = InsetCommand::params2string("nomenclature", p);
+ string const data = InsetCommand::params2string(p);
bv->showDialog("nomenclature", data);
break;
}
p["type"] = from_ascii("idx");
else
p["type"] = cmd.argument();
- string const data = InsetCommand::params2string("index_print", p);
+ string const data = InsetCommand::params2string(p);
FuncRequest fr(LFUN_INSET_INSERT, data);
dispatch(cur, fr);
break;
}
case LFUN_NOMENCL_PRINT:
- case LFUN_TOC_INSERT:
case LFUN_NEWPAGE_INSERT:
// do nothing fancy
doInsertInset(cur, this, cmd, false, false);
if (!cmd.argument().empty())
// FIXME: Are all these characters encoded in one byte in utf8?
bv->translateAndInsert(cmd.argument()[0], this, cur);
+ cur.screenUpdateFlags(Update::FitCursor);
break;
case LFUN_FLOAT_LIST_INSERT: {
// for now only Text::erase() and Text::backspace() do that.
// The plan is to verify all the LFUNs and then to remove this
// singleParUpdate boolean altogether.
- if (cur.result().update() & Update::Force) {
+ if (cur.result().screenUpdate() & Update::Force) {
singleParUpdate = false;
needsUpdate = true;
}
case LFUN_LABEL_INSERT:
code = LABEL_CODE;
break;
- case LFUN_LINE_INSERT:
- code = LINE_CODE;
- break;
case LFUN_INFO_INSERT:
code = INFO_CODE;
break;
// not allowed in description items
enable = !inDescriptionItem(cur);
break;
- case LFUN_TOC_INSERT:
- code = TOC_CODE;
- // not allowed in description items
- enable = !inDescriptionItem(cur);
- break;
case LFUN_HYPERLINK_INSERT:
if (cur.selIsMultiCell() || cur.selIsMultiLine()) {
enable = false;
case LFUN_LINE_END:
case LFUN_CHAR_DELETE_FORWARD:
case LFUN_CHAR_DELETE_BACKWARD:
- case LFUN_INSET_INSERT:
case LFUN_WORD_UPCASE:
case LFUN_WORD_LOWCASE:
case LFUN_WORD_CAPITALIZE:
enable = true;
break;
+ case LFUN_INSET_INSERT: {
+ string const type = cmd.getArg(0);
+ if (type == "toc") {
+ code = TOC_CODE;
+ // not allowed in description items
+ //FIXME: couldn't this be merged in Inset::insetAllowed()?
+ enable = !inDescriptionItem(cur);
+ } else {
+ enable = true;
+ }
+ break;
+ }
+
default:
return false;
}