Recent

Author Topic: [SOLVED] copy on selection  (Read 3319 times)

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
[SOLVED] copy on selection
« on: May 27, 2018, 01:32:02 am »
All (?) X11 systems inc Linux have had an additional copy and paste method (other than the ctrl X,C,V made popular by Wordstar on DOS).

When you select some text with the mouse, the selection is auto copied into some buffer and clicking with the middle button (or three fingers on touch pad) will paste that content wherever you are. This model goes way back and is far more convenient for many uses.

The behaviour is system wide, so supported by the OS, must be an (GTK2 ?) api somewhere ?

The Lazarus IDE does do it on Linux across the system and, to my surprise on windows but, obviously only internally. I've been poking through the lazarus source in the hope of finding how it works but cannot even find a mention of mbMiddle.

Can anyone point me in the right direction ? Is there an API ?

Davo

« Last Edit: June 02, 2018, 03:51:41 am by dbannon »
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: copy on selection
« Reply #1 on: May 27, 2018, 01:58:44 am »
The Lazarus IDE does do it on Linux across the system and, to my surprise on windows

I don't see that behavior in Lazarus on Ubuntu (gtk2) or Windows (win32) or Mac (carbon). (All run from Mac, so using trackpad.)

You're saying that just selecting text, say in the code editor, copies it to somewhere that can be pasted via a 3-fingered salute (not Microsoft's Ctrl+Alt+Del)?

I do note that the Paste command in the Laz Edit menu always seems to be enabled, even if there's nothing on the clipboard. I don't see that oddity anywhere else (Word, Pages, BBEdit).

Note that Ctrl+X, Ctrl+C, Ctrl+V and the others were popularized by Windows. These are the Windows equivalents of the Mac's Cmd commands, which MS copied (and good that they did so that these keystrokes became a standard). I've always thought that Apple's thinking was pretty clever: X like a scissors, V like an insertion point, and C, well, because copy started with C. Cmd+Z being right next to X, C, V then became undo. So simple, so intuitive.

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: copy on selection
« Reply #2 on: May 27, 2018, 04:32:28 am »
Hi Phil, I have not see that model on the Mac at any time. Its really about using the middle mouse button, the three finger tap is intercepted somewhere in the Linux OS and converted to a middle button event.

I don't have a windows system with a touchpad but don't believe the three finger touch would work in the Lazarus IDE under windows, only a real middle button click. A three button mouse or a click of the scroll wheel is all it takes.

Under Linux, where the behavior is across applications, its very, very useful. I bitterly miss it on the Mac !  Most regular Linux users expect it to be there on any app.

It does not connect in any way to the 'regular' clipboard. It has its own, separate buffer space so middle button click should not paste from same place as Ctrl-V.

And looks like I'm wrong about Wordstar inventing Ctrl-X,C and V, they used the Ins and Del keys. Amazing how things slip your mind in just a few short decades ....

Davo


 
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: copy on selection
« Reply #3 on: May 28, 2018, 10:05:32 am »
look for "PrimarySelection"

you can find it in SynEdit.pp (synedit does extra work, as it also copies info about folding)

You need to acquire it, when a selection is made. (Not sure, maybe there also is an "AsText"...)

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: copy on selection
« Reply #4 on: May 28, 2018, 10:15:45 am »
Martin, I thank you for that. I'm tied up at present but will look into it when I can.
Thanks !
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: copy on selection
« Reply #5 on: June 02, 2018, 03:51:00 am »
Thanks Martin_fr, I did indeed find what I needed.

I have documented how to graft this capability into KMemo here http://wiki.freepascal.org/KControls/KmemoNotes#Copy_on_Selection_and_Middle_Button_Paste

It would be useful to anyone wanting to do this with other components that do not already support this model.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018