Neil
I am one of the developers for Code Roar (http://coderoar.com). Roar
is build around Scintilla and we have implemented selectionless
cut/copy (without changing Scintilla). You can down load it and try
this feature out to see if you like it before putting it in Scite.
The way we have done it is as follows:
We register a new clipboard format the same as MSDEVColumnSelect is:
cfSingleLine=RegisterClipboardFormat("RoarSingleLine");
When CTRL+C is pressed we check to see if there is a selection, if not
we get the caret line. We then get that line into a buffer.
We then copy into the clip board setting "RoarSingleLine" (as this is
a line copy).
SetClipboardData(cfSingleLine,0);
Now when CTRL+V is pressed we first check to see if the "RoarSingleLine" is set:
if(Clipboard()->HasFormat(cfSingleLine))
SingleLine=true;
If it is then we remove the old selection, move the caret to the start
of the line:
if(SingleLine)
{
/* We need to move the caret to the start of the line before the
paste (kill off the selection before we do this) */
UIReplaceSelectionText(UIControl,"");
DoRAWSciCMD(SCI_HOME,0,0);
DoRAWSciCMD(SCI_REPLACESEL,0,(long)ReplaceText);
}
This seems to work well. I can post the full code that we use for
this as a reference on how to put it in Scite (I skipped some the
little details like rect selections above).
Paul Hutchinson
Lead Developer,
http://CodeRoar.com
> The way we have done it is as follows:
> We register a new clipboard format the same as MSDEVColumnSelect is:
> cfSingleLine=RegisterClipboardFormat("RoarSingleLine");
The patch uses the format name MSDEVLineSelect but I can't find any
mention of MSDEVLineSelect on the 'net. Compatibility of whatever
technique is used by Visual Studio would be better than something that
just works with Scintilla.
It was much more difficult to place multiple formats on the
clipboard with GTK+ (and other platforms over X) so there is a low
quality hack for differentiating rectangular and stream selection
there. Possibly this has improved with newer GTK+ clipboard APIs but I
don't have much time for exploration. Having line copy only work on
Windows isn't great and its one reason for making this a separate
command CopyWithLine (or VCCopy) that is then marked as Windows-only.
Neil
We implemented it this way the first time round but it doesn't really
work. Basically you have a problem where if you select a line for
coping (highlight and CTRL+C) you expect the line to be pasted out
starting at the caret. If you use line copy (no selection) then when
you paste it in you expect it to insert the line at column 1 no matter
where the caret is.
As for using MSDEVLineSelect I would say that using an existing
standard is better than making up your own. I don't know if
MSDEVLineSelect is a standard or not (I don't see any other references
to it with Google). If we find a standard I will be changing Roar to
match it.
Earlier on we did the selectionless line copy with using multi-clip
formats by keeping a hash of what we placed on the clip board and
storing the line copy status (and rect status) our selfs. When the
user pressed paste we grabed the contents of the system clip board and
did the hash. If they where the same we used our stored status, if
not we assumed that someone else had changed the contents. Of course
there are down sides to doing this (mainly speed) and we changed it in
favor of the multi-clip format.
This uses a separate API CopyAllowLine instead of including the
feature in the standard Copy. On GTK+, CopyAllowLine works as on
Windows except there is no extra format added to the clipboard so the
receiver does not know when to perform a line paste so performs a
standard paste. There is some difference between the original patch
(or the update) and Visual Studio when a paste is performed with
MSDEVLineSelect present with Visual Studio first deleting the
selection then performing a line paste. The download includes some
temporary assignment to keys and keyboard commands - SciTE should
probably add an option to choose between CopyAllowLine and Copy.
This is all still a little too messy for me to be completely
content yet. Inconsistency between platforms is a support and
documentation sink.
Neil
<p><code>SCI_COPYALLOWLINE</code> works the same as SCI_COPY
except that if the
selection is empty then the current line is copied. On Windows, an
extra "MSDEVLineSelect" marker
is added to the clipboard which is then used in
<code>SCI_PASTE</code> to paste
the whole line before the current line.</p>
Neil