Ask Leo! #714 – Why Do Things Disappear from the Clipboard When I Close a Program?

This Week

Featured: The magic that is the clipboard.

Also this week: your new computer, and that replacement power supply.

In case you haven't seen it, I shot a little behind the scenes video of a recent change to the way I record the video narration; a change that involves 100+ year old technology. (Smile)

Your support matters! Here are all the ways you can help. And while I'm at it, here are all the different ways to get Ask Leo!

Why Do Things Disappear from the Clipboard When I Close a Program?

(skip)

The clipboard is a pretty amazing concept. It's one of those things we use daily, take for granted, and rarely even think about …

… except when it doesn't do what we expect.

Let's review some of the magic behind the clipboard's curtain. It's more complex than you might realize.

Clipboard basics

I have to start with the usual caveat: this is not meant to be a detailed treatise on the inner workings of the clipboard. It almost certainly doesn't work exactly as I outline below. I'm grossly oversimplifying in order to make concepts and behavior clearer for non-programmers.

Conceptually, the clipboard is extremely simple: you copy something to it, where it remains until overwritten by another copy-to-clipboard. You can then paste it somewhere, which copies what's in the clipboard to the location you indicate.

It's a two-step process. First, you identify the item you want to copy — usually via a selection of some sort — and then copy it to the clipboard using a keystroke or mouse sequence.

Copy to Clipboard

Then, you identify a new location into which you want to place the copied item, and paste it there, once again using a keystroke or mouse sequence.

Paste From Clipboard

In the example above, I've copy/pasted some text from one document to another via the clipboard. When done, the text I've selected exists in three places:

  • The original location I copied from.
  • The clipboard.
  • The new location I pasted into.

The text will remain in the clipboard until the next time I copy something to it, because the clipboard can hold only one thing at a time.

Conceptually, that's how the clipboard works, and in some cases, it actually does work that way.

But in many cases, it doesn't.

Multiple formats

If you've ever copy/pasted from a word-processing program like Microsoft Word into a plain-text-editing program like Notepad, you may have noticed that all the formatting is lost. Notepad doesn't do formatting; it's text-only. Copy/pasting from Word to Notepad is, in fact, a convenient way to get only the text.

But as you might imagine, under the hood things are more complex. Word, for example, doesn't know where the data will be pasted, or what the capabilities of the receiving program might be. Ideally, it makes the highest fidelity of whatever has been copied available, but someone has to handle the conversion from one format (fancy and formatted) to the other (plain text).

There are two catches:

  • We can't assume that the clipboard understands what is being copied.
  • We can't assume that the destination application knows what to do with the way the information is stored. (Though it would be nice if it did.)

The result is that when you copy something to the clipboard, the application you're copying from provides a little more information than just the data to be copied; it includes the formats it can make that data available in.

Offering Formats on Copy

Depending on the sophistication of the program you're copying from, it may offer many different formats — as Word might — or it might offer only one. But that information, along with the data to be copied (in most cases; more on that in a moment), is given to the clipboard when you copy something.

Paste has a similar complication in that the program you're pasting into asks the clipboard for the data in a priority-ordered list of preferred formats.

Destination preferred formats

When you paste, the clipboard takes the highest-priority-requested format that was made available by the original copy, and provides that to application into which the data is to be pasted.

Pasting plain text

In our example, the “list” of preferred formats was only one item long, so the clipboard took the plain text of the copied data provided by Word and gave it to Notepad.

Format mismatches

The clipboard doesn't really care or even understand what's being copied or pasted; it just acts as an intermediary between the program from which data is copied and the program into which the data is pasted.

Those programs, on the other hand, care a lot. For example, we can use copy/paste to move files around in Windows File Explorer, but pasting a file into Notepad doesn't make sense.

Copy Paste type mismatch

You can't paste just anything anywhere — one of the formats offered by the source of whatever it is you want to copy must be a form that the destination understands. If that can't happen, you can't paste. In most cases, that manifests as a greyed-out “Paste” item in the destination application.

When things get big, really big

There's no conceptual limit as to how big something can be for copy/paste. There are practical limits, and they come from not-so-obvious places.

The clipboard itself can only hold so much, but that doesn't prevent it from brokering larger items. When a large item is copied to the clipboard, it can elect to keep only the available format information and not the data. Instead, the application in which the copy happened must hold on to the data until the someone requests it (or the clipboard is replaced or emptied). When a paste occurs, the information is transferred from application to application — the clipboard acts only as an intermediary to facilitate the exchange.

Direct transfer

  1. The application in which you hit “copy” tells the clipboard that the data is available, how large it is, and what formats are available.
  2. The application into which you “paste” tells the clipboard that it wants the data, and in which format.
  3. The clipboard essentially says, “You guys figure it out”, and the data is transferred directly from one application to the other.

This technique results in behavior that might confuse you. For example, what happens when you close the first application before you paste into the second?

Closing the copy source before the paste

When the data is copied to the clipboard, as in our earlier example of a small copy/paste, it doesn't matter if the source application is closed before you paste. Everything necessary was placed into the clipboard and remains available for a paste operation.

In the example of a large copy, though, where the clipboard doesn't hold the actual data, there are two options when the source application goes away:

  • The clipboard can be emptied. The source application isn't available to provide the copied data, so there's nothing to paste.
  • The data can be written to disk for the clipboard to access later when a paste is requested.

Would you like to keep that clipboard?

I've seen both; it varies from application to application. When you close an application that has made something large available to the clipboard, it may:

  • Write it to disk without asking
  • Offer to write to disk (as Word is doing in the example above)
  • Offer to abort the exit so the program keeps running to provide the information via the clipboard
  • Empty the clipboard without asking

The clipboard's about more than the clipboard

Needless to say, I've only scratched the surface of the clipboard's capabilities.

Perhaps most important is to realize that the clipboard's functionality — beyond its role as intermediary — is provided by the applications from which you can copy and into which you can paste. They control what can be copied, where it can be pasted, and what results or transformations — like fancy text to plain text — are available.

Related Links & Comments: Why Do Things Disappear from the Clipboard When I Close a Program?
https://askleo.com/59842

Ad-Free Ask Leo!

Support Ask Leo! and enjoy an ad-free experience whenever you visit askleo.com.

Become a patron for as little as $2/month (or $24/year) for Ad Free Ask Leo!.

Thanks!

Leo

No Ads

The First Eight Things to Do with Your New Computer

Congratulations! You got a new computer!

Of course you want to jump right in and start using it right now, but if you can hold on a bit, there are a few tasks you might want to do first. When all heck breaks loose later and the machine dies, the software crashes, or you get a massive malware infection, the steps you take now can save you lots of time and grief later.

Every day, people lose data, precious memories, and valuable time because they didn't take a few simple steps to prepare.

And by far the best time to prepare is at the very beginning.

Continue Reading: The First Eight Things to Do with Your New Computer
https://askleo.com/4689

Is it Safe to Install a Higher Wattage Power Supply in My Computer?

I want to upgrade my current case that has a 300W PSU to a nicer looking case, but it has a 520W PSU. Is it ok and how does the “W” difference influence PC operation?

It's quite all right, and if things were working well before, you probably won't notice a difference.

Let's look at why, and just what that “W” means. I get questions on this topic frequently.

Continue Reading: Is it Safe to Install a Higher Wattage Power Supply in My Computer?
https://askleo.com/2873

The Ask Leo! Tip of the Day

A feature exclusively available to Ask Leo! Patrons Bronze level & above.

More Ask Leo!

Tech Enthusiast Hour: I'm one of the regular hosts of the weekly Tech Enthusiast Hour podcast! Join us as we discuss the latest news & tech goings on. More information at tehpodcast.com!

Become a Patron
Ask Leo! Books
Facebook - YouTube - More..

Leo's Other Projects....

HeroicStories Since 1999, HeroicStories brings diverse, international voices to the world ' reminding us that people are good, that individuals and individual action matter. Stories - new and old - are published twice a week.

Not All News Is Bad - Each day I look for one story in the current news of the day with a positive bent. Just one. And I share it.

leo.notenboom.org - My personal blog. Part writing exercise, part ranting platform, it's where I write about anything and everything and nothing at all.

Help Ask Leo! Just forward this message, in its entirety (but without your unsubscribe link below) to your friends. Or, just point them at https://newsletter.askleo.com for their own FREE subscription!

Newsletter contents Copyright © 2018,
Leo A. Notenboom & Puget Sound Software, LLC.
Ask Leo! is a registered trademark ® of Puget Sound Software, LLC

Posted: July 24, 2018 in: 2018
Shortlink: https://newsletter.askleo.com/7924
« Previous post:
Next post: »

New Here?

Let me suggest my collection of best and most important articles to get you started.

Of course I strongly recommend you search the site -- there's a ton of information just waiting for you.

Finally, if you just can't find what you're looking for, ask me!

Confident Computing

Confident Computing is the weekly newsletter from Ask Leo!. Each week I give you tools, tips, tricks, answers, and solutions to help you navigate today’s complex world of technology and do so in a way that protects your privacy, your time, and your money, and even help you better connect with the people around you.

The Ask Leo! Guide to Staying Safe on the Internet – FREE Edition

Subscribe for FREE today and claim your copy of The Ask Leo! Guide to Staying Safe on the Internet – FREE Edition. Culled from the articles published on Ask Leo! this FREE downloadable PDF will help you identify the most important steps you can take to keep your computer, and yourself, safe as you navigate today’s digital landscape.



My Privacy Pledge

Leo Who?

I'm Leo Notenboom and I've been playing with computers since I took a required programming class in 1976. I spent over 18 years as a software engineer at Microsoft, and after "retiring" in 2001 I started Ask Leo! in 2003 as a place to help you find answers and become more confident using this amazing technology at our fingertips. More about Leo.