This helps you avoid the monotonous re-typing of large sections of text. Because the clipboard is controlled by the operating system, you can copy and paste text between applications. Not only can you copy and paste text, but you can copy and paste images and even actual files.
Because one program may allow for different formatting of text than another, when you paste text may not be the same as what you copied. For example, you may copy a phrase from Microsoft Word that is in bold type, uses the Verdana font, and is size 16 pt. Connect and share knowledge within a single location that is structured and easy to search. I was wondering after using computer for a long times it feels like copy paste was fundamental feature but I know it is not.
So the question is how does this really work? I thought of all ideas how this could have been implemented but I get stuck every time I come up with the different file formats like gif, jpg, txt, png, mp3, mp4, JSON, YML etc. Like how it copies images that are in the search result in chrome whereas sometimes you can't copy something due to restriction also you can't select something then you can't copy it whereas sometimes even if you can't select in hierarchy the children are copied so how is it implemented.
But when someone asks me how does copy paste work generally I reply like: When something is copied then it puts the copied item to memory and when pasting it to somewhere the OS finds out the location to where it should be copied and replicates all the file to binary and copies it.
Which might not be true so can you explain how does it exactly work. Also it would be helpful to know how the code was written for copy paste. The first thing you need to realize is that "copy and paste" as well as "drag and drop" are a form of IPC Inter-process communication since the data is being transferred from one application to another. This mechanism is usually provided by the same subsystem or service which is responsible for managing the graphical user interface.
This subsystem provides a mechanism for "source" and "destination" applications to negotiate about the format of the data that should be transferred and if they "agree" on some common format then the data can be transferred.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow.
Learn more. How is copy paste possible? Ask Question. Asked 3 years ago. Create a free Team What is Teams? Learn more. How does the copy and paste mechanism work and is it a standard design pattern as in GoF? Ask Question.
Asked 5 years, 9 months ago. Active 5 years, 9 months ago. Viewed 1k times. Improve this question. I am actually interested in both. I have rephrased the question to make it more general — nonopolarity. Whether or not any specific design pattern as described in the book factors into it depends entirely on the implementation.
Design patters are just names given to common ways of solving certain problems; they're not something you snap together to build programs. The programmers of this functionality in each operating system may or may not have used a GoF design pattern when they were programming it. Show 1 more comment. Active Oldest Votes. Improve this answer. Ixrec Ixrec 27k 14 14 gold badges 74 74 silver badges 84 84 bronze badges.
0コメント