using cap::copySelection;
using cap::cutSelection;
+using cap::cutSelectionToTemp;
using cap::pasteFromStack;
+using cap::pasteFromTemp;
using cap::pasteClipboardText;
using cap::pasteClipboardGraphics;
using cap::replaceSelection;
using cap::grabAndEraseSelection;
using cap::selClearOrDel;
using cap::pasteSimpleText;
+using frontend::Clipboard;
// globals...
static Font freefont(ignore_font, ignore_language);
LASSERT(cur.inMathed(), return);
cur.pos() = 0;
cur.resetAnchor();
- cur.setSelection(true);
+ cur.selection(true);
cur.pos() = cur.lastpos();
if (cmd.action() != LFUN_MATH_MODE)
// LFUN_MATH_MODE has a different meaning in math mode
bool gotsel = false;
if (cur.selection()) {
- cutSelection(cur, false, pastesel);
+ cutSelectionToTemp(cur, false, pastesel);
cur.clearSelection();
gotsel = true;
}
if (!gotsel || !pastesel)
return true;
- pasteFromStack(cur, cur.buffer()->errorList("Paste"), 0);
+ pasteFromTemp(cur, cur.buffer()->errorList("Paste"));
cur.buffer()->errors("Paste");
cur.clearSelection(); // bug 393
cur.finishUndo();
if (cur.selection())
cutSelection(cur, true, false);
else
- deleteWordForward(cur);
+ deleteWordForward(cur, cmd.getArg(0) == "force");
finishChange(cur, false);
break;
if (cur.selection())
cutSelection(cur, true, false);
else
- deleteWordBackward(cur);
+ deleteWordBackward(cur, cmd.getArg(0) == "force");
finishChange(cur, false);
break;
case LFUN_CHAR_DELETE_FORWARD:
if (!cur.selection()) {
- bool was_separator = cur.paragraph().isEnvSeparator(cur.pos());
if (cur.pos() == cur.paragraph().size())
// Par boundary, force full-screen update
singleParUpdate = false;
- needsUpdate |= erase(cur);
- cur.resetAnchor();
- if (was_separator && cur.pos() == cur.paragraph().size()
- && (!cur.paragraph().layout().isEnvironment()
- || cur.paragraph().size() > 0)) {
- // Force full-screen update
- singleParUpdate = false;
- needsUpdate |= erase(cur);
+ else if (cmd.getArg(0) != "force" && cur.confirmDeletion()) {
cur.resetAnchor();
+ cur.selection(true);
+ cur.posForward();
+ cur.setSelection();
+ break;
}
- // It is possible to make it a lot faster still
- // just comment out the line below...
+ needsUpdate |= erase(cur);
+ cur.resetAnchor();
} else {
cutSelection(cur, true, false);
singleParUpdate = false;
// Par boundary, full-screen update
if (par_boundary)
singleParUpdate = false;
+ else if (cmd.getArg(0) != "force" && cur.confirmDeletion(true)) {
+ cur.resetAnchor();
+ cur.selection(true);
+ cur.posBackward();
+ cur.setSelection();
+ break;
+ }
needsUpdate |= backspace(cur);
cur.resetAnchor();
if (par_boundary && !first_par && cur.pos() > 0
Paragraph const & par = pars_[pit];
bool lastpar = (pit == pit_type(pars_.size() - 1));
Paragraph const & nextpar = lastpar ? par : pars_[pit + 1];
- pit_type prev = pit;
- if (pit > 0) {
- if (!pars_[pit - 1].layout().isEnvironment())
- prev = depthHook(pit, par.getDepth());
- else if (pars_[pit - 1].getDepth() >= par.getDepth())
- prev = pit - 1;
- }
+ pit_type prev = pit > 0 ? depthHook(pit, par.getDepth()) : pit;
if (prev < pit && cur.pos() == par.beginOfBody()
&& !par.size() && !par.isEnvSeparator(cur.pos())
&& !par.layout().isCommand()
docstring const layout = par.layout().name();
DocumentClass const & tc = bv->buffer().params().documentClass();
lyx::dispatch(FuncRequest(LFUN_LAYOUT, tc.plainLayout().name()));
- lyx::dispatch(FuncRequest(LFUN_SEPARATOR_INSERT, "parbreak"));
+ lyx::dispatch(FuncRequest(LFUN_SEPARATOR_INSERT, "plain"));
lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK, "inverse"));
lyx::dispatch(FuncRequest(LFUN_LAYOUT, layout));
} else {
- lyx::dispatch(FuncRequest(LFUN_SEPARATOR_INSERT, "parbreak"));
+ lyx::dispatch(FuncRequest(LFUN_SEPARATOR_INSERT, "plain"));
breakParagraph(cur);
}
Font const f(inherit_font, cur.current_font.language());
while (pos > 0 && par.isDeleted(pos - 1))
--pos;
- BufferParams const & bufparams = bv->buffer().params();
- bool const hebrew =
- par.getFontSettings(bufparams, pos).language()->lang() == "hebrew";
- bool const allow_inset_quote = !(par.isPassThru() || hebrew);
-
- string const arg = to_utf8(cmd.argument());
- if (allow_inset_quote) {
- char_type c = ' ';
- if (pos > 0 && (!cur.prevInset() || !cur.prevInset()->isSpace()))
+ bool const inner = (cmd.getArg(0) == "single" || cmd.getArg(0) == "inner");
+
+ // Guess quote side.
+ // A space triggers an opening quote. This is passed if the preceding
+ // char/inset is a space or at paragraph start.
+ char_type c = ' ';
+ if (pos > 0 && !par.isSpace(pos - 1)) {
+ if (cur.prevInset() && cur.prevInset()->lyxCode() == QUOTE_CODE) {
+ // If an opening double quotation mark precedes, and this
+ // is a single quote, make it opening as well
+ InsetQuotes & ins =
+ static_cast<InsetQuotes &>(*cur.prevInset());
+ string const type = ins.getType();
+ if (!suffixIs(type, "ld") || !inner)
+ c = par.getChar(pos - 1);
+ }
+ else if (!cur.prevInset()
+ || (cur.prevInset() && cur.prevInset()->isChar()))
+ // If a char precedes, pass that and let InsetQuote decide
c = par.getChar(pos - 1);
- InsetQuotes::QuoteTimes const quote_type = (arg == "single")
- ? InsetQuotes::SingleQuotes : InsetQuotes::DoubleQuotes;
- cur.insert(new InsetQuotes(cur.buffer(), c, quote_type));
- cur.posForward();
- } else {
- // The cursor might have been invalidated by the replaceSelection.
- cur.buffer()->changed(true);
- string const quote_string = (arg == "single") ? "'" : "\"";
- lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, quote_string));
+ else {
+ while (pos > 0) {
+ if (par.getInset(pos - 1)
+ && !par.getInset(pos - 1)->isPartOfTextSequence()) {
+ // skip "invisible" insets
+ --pos;
+ continue;
+ }
+ c = par.getChar(pos - 1);
+ break;
+ }
+ }
}
+ InsetQuotesParams::QuoteLevel const quote_level = inner
+ ? InsetQuotesParams::SecondaryQuotes : InsetQuotesParams::PrimaryQuotes;
+ cur.insert(new InsetQuotes(cur.buffer(), c, quote_level, cmd.getArg(1), cmd.getArg(2)));
+ cur.buffer()->updateBuffer();
+ cur.posForward();
break;
}
bvcur.setMark(false);
switch (cmd.button()) {
case mouse_button::button1:
- // Set the cursor
- if (!bv->mouseSetCursor(cur, cmd.argument() == "region-select"))
- cur.screenUpdateFlags(Update::FitCursor);
+ if (!bvcur.selection())
+ // Set the cursor
+ bvcur.resetAnchor();
+ if (!bv->mouseSetCursor(cur, cmd.modifier() == ShiftModifier))
+ cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
if (bvcur.wordSelection())
selectWord(bvcur, WHOLE_WORD);
break;
int const wh = bv->workHeight();
int const y = max(0, min(wh - 1, cmd.y()));
- tm->setCursorFromCoordinates(cur, cmd.x(), y);
+ tm->setCursorFromCoordinates(cur, cmd.x(), y, true);
cur.setTargetX(cmd.x());
+ // Don't allow selecting a separator inset
+ if (cur.pos() && cur.paragraph().isEnvSeparator(cur.pos() - 1))
+ cur.posBackward();
if (cmd.y() >= wh)
lyx::dispatch(FuncRequest(LFUN_DOWN_SELECT));
else if (cmd.y() < 0)
// We continue with our existing selection or start a new one, so don't
// reset the anchor.
bvcur.setCursor(cur);
- bvcur.setSelection(true);
+ bvcur.selection(true);
if (cur.top() == old) {
// We didn't move one iota, so no need to update the screen.
cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
}
case LFUN_HREF_INSERT: {
- // FIXME If we're actually given an argument, shouldn't
- // we use it, whether or not we have a selection?
docstring content = cmd.argument();
- if (cur.selection()) {
+ if (content.empty() && cur.selection())
content = cur.selectionAsString(false);
- cutSelection(cur, true, false);
- }
InsetCommandParams p(HYPERLINK_CODE);
if (!content.empty()){
cur.push(*inset);
cur.top().pos() = cur.top().lastpos();
cur.resetAnchor();
- cur.setSelection(true);
+ cur.selection(true);
cur.top().pos() = 0;
}
break;
case LFUN_ESCAPE:
if (cur.selection()) {
- cur.setSelection(false);
+ cur.selection(false);
} else {
cur.undispatched();
// This used to be LFUN_FINISHED_RIGHT, I think FORWARD is more
case LFUN_CAPTION_INSERT: {
code = CAPTION_CODE;
string arg = cmd.getArg(0);
- bool varia = arg != "LongTableNoNumber"
+ bool varia = arg != "Unnumbered"
&& cur.inset().allowsCaptionVariation(arg);
// not allowed in description items,
// and in specific insets
case LFUN_QUOTE_INSERT:
// always allow this, since we will inset a raw quote
// if an inset is not allowed.
+ allow_in_passthru = true;
break;
case LFUN_SPECIALCHAR_INSERT:
code = SPECIALCHAR_CODE;
docstring layout = cmd.argument();
if (layout.empty())
layout = tclass.defaultLayoutName();
- enable = !cur.inset().forcePlainLayout() && tclass.hasLayout(layout);
+ enable = !owner_->forcePlainLayout() && tclass.hasLayout(layout);
flag.setOnOff(layout == cur.paragraph().layout().name());
break;
case LFUN_PARAGRAPH_PARAMS:
case LFUN_PARAGRAPH_PARAMS_APPLY:
case LFUN_PARAGRAPH_UPDATE:
- enable = cur.inset().allowParagraphCustomization();
+ enable = owner_->allowParagraphCustomization();
break;
// FIXME: why are accent lfuns forbidden with pass_thru layouts?