Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Clipboard Interfacing

24 views
Skip to first unread message

tomu...@gmail.com

unread,
Oct 27, 2018, 9:21:42 AM10/27/18
to
I am wondering if C++ would be the best language to write a program allowing:

1. Highlight some text
2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1
3. Highlight another string of text
4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2

THEN

5. Ctl+HOTKEY2 pastes COPIEDTEXT1
6. Ctl+HOTKEY2 pastes COPIEDTEXT2

Can someone point me in the right direction?

Thanks,

Musatov

Alf P. Steinbach

unread,
Oct 27, 2018, 9:33:11 AM10/27/18
to
You /can/ do it in C++.

Depending on the system you want to do this for, some other language
will probably be less work.

Right direction pointer: when Microsoft replaced the original Windows
clipboard viewer with one supporting multiple clips, like you sketch,
that marked the end of having a standard clipboard viewer in Windows.
The clipboard relies on simplicity for it to be useful. Adding
complexity and hidden modes is therefore not a good direction.


Cheers & hth.,

- Alf

Luuk

unread,
Oct 27, 2018, 9:38:46 AM10/27/18
to
In Windows 10 (from build 1809) you can view your copies with Windows+V.

CTRL+C copies (and adds to the list)
CTRL+V pastes
Windows+V (shows the list)

Now one has to wait till 1809 get released...

Sam

unread,
Oct 27, 2018, 10:02:52 AM10/27/18
to
The right direction for you would be some general books on computer
programming, where you will learn that in the several thousand of terse,
single-spaced pages that make up the current C++ standard, there is no
mention whatsoever about "highlighting" text, in some mysterious fashion, or
equally-mysterious "hotkeys", that do wondrous things.

This is purely a function of your operating system, and the exact task for
implementing these kinds of things depend entirely on the operating system
being used.

Since you don't even realize that this is an operating system-specific
question, and you didn't specify which OS you're using, I think it would be
rather difficult, if not impossible, for you to implement the task at hand
right now; but maybe several years down the road.

It just so happens that last week I finished implementing copy/cut/paste
support in my X toolkit library (shameless plug:
https://www.libcxx.org/w/copycutpastemenu.html). I don't remember exactly
when I started it, but I've been working on this library for the last eight
years, and coding C++ for …much longer than that. Just to give you a rough
idea how complicated C++-related things are, in the real world.

The only other thing I can tell you with some level of confidence is that,
whatever operating system you're using, it's unlikely that you will be able
to modify its default copy/cut/paste behavior in the manner you desire. All
traditional OSrd implement copy/cut/paste internally, behind the scenes, and
their exact mechanics are not exposed to applications. The mouse pointer
operations and/or the keyboard shortcuts for copy/cut/pasting text get
processed entirely by the operating system, or the GUI library being used on
your operating system. The application does not even realize that this is
happening. The OS/GUI library handles the mechanics of this process entirely
on its own. All that the application does is put up text input fields, where
text gets typed in when that text input field has keyboard focus, and the OS
or the GUI library handles copy/cut/paste operations on its own. All the
application cares about is text that mysterious appears in its
aforementioned text input fields, and how it got there, it doesn't really
care.

Some OSes might offer third-party add-on tools that enhance the existing
copy/cut/paste behavior. Those tools typically use highly OS-specific
internal functions to modify its copy/cut/paste behavior.

Manfred

unread,
Oct 27, 2018, 12:42:11 PM10/27/18
to
On 10/27/2018 4:02 PM, Sam wrote:
> tomu...@gmail.com writes:
>
>> I am wondering if C++ would be the best language to write a program
>> allowing:
>>
>> 1. Highlight some text
>> 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1
>> 3. Highlight another string of text
>> 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2
>>
>> THEN
>>
>> 5. Ctl+HOTKEY2 pastes COPIEDTEXT1
>> 6. Ctl+HOTKEY2 pastes COPIEDTEXT2
>>
>> Can someone point me in the right direction?
>
> The right direction for you would be some general books on computer
> programming, where you will learn that in the several thousand of terse,
> single-spaced pages that make up the current C++ standard, there is no
> mention whatsoever about "highlighting" text, in some mysterious
> fashion, or equally-mysterious "hotkeys", that do wondrous things.
>
> This is purely a function of your operating system, and the exact task
> for implementing these kinds of things depend entirely on the operating
> system being used.
>
> Since you don't even realize that this is an operating system-specific
> question, and you didn't specify which OS you're using, I think it would
> be rather difficult, if not impossible, for you to implement the task at
> hand right now; but maybe several years down the road.
The above sounds excessively hard on the poor OP.

>
> It just so happens that last week I finished implementing copy/cut/paste
> support in my X toolkit library (shameless plug:
> https://www.libcxx.org/w/copycutpastemenu.html). I don't remember
> exactly when I started it, but I've been working on this library for the
> last eight years, and coding C++ for …much longer than that. Just to
> give you a rough idea how complicated C++-related things are, in the
> real world.
It is true that C++ is a complex language, but in this case (copy/paste
of strings) the complexity is not about usage of the language, instead
it is mainly about how to interface with the OS - or better, how to
interface with whatever GUI manager is offered by the target platform.
Even this part, however, is not complex in the sense that it be rocket
science. Most of the work would be finding and digging through the
documentation of the system API, the patterns used throughout it, and
such API's are usually very large.

>
> The only other thing I can tell you with some level of confidence is
> that, whatever operating system you're using, it's unlikely that you
> will be able to modify its default copy/cut/paste behavior in the manner
> you desire. All traditional OSrd implement copy/cut/paste internally,
> behind the scenes, and their exact mechanics are not exposed to
> applications. The mouse pointer operations and/or the keyboard shortcuts
> for copy/cut/pasting text get processed entirely by the operating
> system, or the GUI library being used on your operating system. The
> application does not even realize that this is happening.
It is true that it would be impossible or next to impossible to modify
the system clipboard behavior.
It is instead possible to override the relevant commands and implement
your own clipboard scheme. Obviously this would only work within your
own applications.
Again, this is not a C++ problem, it is GUI software development instead.

tomu...@gmail.com

unread,
Oct 27, 2018, 2:54:34 PM10/27/18
to
Bout time. Amen!
0 new messages