Discussion:
MultiPaste in wxSTC
Paul K
2014-04-30 01:41:31 UTC
Permalink
Neil,

I ran across a problem with MultiPaste in wxSTC control. I suspect the
issue is in wxwidgets, but I'd like to confirm that and a proper patch for
it before I propose a fix.

I have this simple (Lua) script to test MultiPaste:

e:SetText("12 34 56 Multi-selection paste")
e:SetMultipleSelection(1)
e:SetAdditionalCaretsBlink(1)
e:SetAdditionalSelectionTyping(1)
e:SetMultiPaste(1)
e:SetSelection(0, 2)
e:AddSelection(3, 5)
e:AddSelection(6, 8)
e:Paste()

I expect it to replace 12, 34, and 56 with the content of the clipboard,
but it only replaces the main selection.

I think this is because the implementation of Paste in wxwidgets only does
one InsertString (src/stc/ScintillaWX.cpp):

int caretMain = sel.MainCaret();
pdoc->InsertString(caretMain, buf, len);
SetEmptySelection(caretMain + len);
Should this be replaced with InsertPaste?

int caretMain = sel.MainCaret();
InsertPaste(sel, buf, len);
SetEmptySelection(caretMain + len);
I couldn't find any other method that is referencing SC_MULTIPASTE_EACH.
Thank you.

Paul.
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
Neil Hodgson
2014-04-30 03:52:39 UTC
Permalink
Post by Paul K
int caretMain = sel.MainCaret();
pdoc->InsertString(caretMain, buf, len);
SetEmptySelection(caretMain + len);
Should this be replaced with InsertPaste?
You could use InsertPaste or write similar code yourself.

I'm not completely happy with InsertPaste: it takes a position argument which is only used for the SC_MULTIPASTE_ONCE mode but uses the global sel object for SC_MULTIPASTE_EACH. It should probably use sel for SC_MULTIPASTE_ONCE as well and drop the position argument. That's a fix I haven't got around to and will break any platforms that have used the current signature.
Post by Paul K
int caretMain = sel.MainCaret();
InsertPaste(sel, buf, len);
SetEmptySelection(caretMain + len);
On the bundled platforms, there is no call to SetEmptySelection as InsertPaste should be fixing the selection.

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
Paul K
2014-04-30 04:09:50 UTC
Permalink
I’m not completely happy with InsertPaste: it takes a position argument
which is only used for the SC_MULTIPASTE_ONCE mode but uses the global sel
object for SC_MULTIPASTE_EACH. It should probably use sel for
SC_MULTIPASTE_ONCE as well and drop the position argument. That’s a fix I
haven’t got around to and will break any platforms that have used the
current signature.

It's a small risk as wxwidgets bundles Scintilla source, so when the
signature changes and the upgraded version is included, the call will need
to by updated (the source will fail to compile, so it will be easily
detectable).
On the bundled platforms, there is no call to SetEmptySelection as
InsertPaste should be fixing the selection.

That's good; does this mean I only need: "InsertPaste(sel, buf, len);" and
nothing else in this case?

Paul.
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
Loading...