Getting full paste (Text+Code)

RanC

New member
Local time
4:54 PM
Messages
3
In windows, you can paste regular text (like from notepad to Word), and styled text (like copying colored text from one Word to another, or even text with bullets from here (chrome) to a Word document).
I believe that when you "copy", you copy the text, along with meta-chars that are the style.
How can I see these meta-chars? Is there A C# code that can do this?
 
Last edited:

My Computer

Computer type
PC/Desktop
OS
Windows 7
Are you referring to the source code of a web page? Right click the web page and select "View Page Source "
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built By Me.
OS
Windows 10 Pro 64 bit
CPU
AMD FX 9590 8 Core Black Edition
Motherboard
MSI 990FXA GAMING (MS-7893)
Memory
Corsair Vengeance 16GB DDR3
Graphics Card(s)
AMD Radeon (TM) R9 380 Gaming Series
Sound Card
AMD High Definition
Monitor(s) Displays
Samsung 32" 60Hz 4ms Curved PLS LED
Screen Resolution
1920 X 1080
Hard Drives
C: 223 GB SSD = E: 465 GB HDD = F: 931 GB HDD = G: 149 GB HDD = H: 931 GB HDD
PSU
EVGA Supernova NEX750B 750W ATX EPS12V 80PLUS Bronze
Case
Cool Master
Cooling
Noctua NH-D15 Premium Cooler with 2x NF-A15 PWM 140mm Fan
Internet Speed
Fiber Optic: Download 332.7 Mbps / Upload 331.5 Mbps
Antivirus
Windows Defender
Browser
Slimjet (64bit)
Not only source code. Say I copied styled text from Word. How can I know the style?
 

My Computer

Computer type
PC/Desktop
OS
Windows 7
If you copy styled text from one Word doc to another. Highlight the styled text in question and click the Home tab. Look under styles and that style should be highlighted. I hope this is this is what you are referring too.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built By Me.
OS
Windows 10 Pro 64 bit
CPU
AMD FX 9590 8 Core Black Edition
Motherboard
MSI 990FXA GAMING (MS-7893)
Memory
Corsair Vengeance 16GB DDR3
Graphics Card(s)
AMD Radeon (TM) R9 380 Gaming Series
Sound Card
AMD High Definition
Monitor(s) Displays
Samsung 32" 60Hz 4ms Curved PLS LED
Screen Resolution
1920 X 1080
Hard Drives
C: 223 GB SSD = E: 465 GB HDD = F: 931 GB HDD = G: 149 GB HDD = H: 931 GB HDD
PSU
EVGA Supernova NEX750B 750W ATX EPS12V 80PLUS Bronze
Case
Cool Master
Cooling
Noctua NH-D15 Premium Cooler with 2x NF-A15 PWM 140mm Fan
Internet Speed
Fiber Optic: Download 332.7 Mbps / Upload 331.5 Mbps
Antivirus
Windows Defender
Browser
Slimjet (64bit)
If you copy styled text from one Word doc to another. Highlight the styled text in question and click the Home tab. Look under styles and that style should be highlighted. I hope this is this is what you are referring too.

No. What I mean is not only in Word. If I copied a text with bullets to Word (or any other program that supports text with bullets) - text with bullets would appear. If we have a program that supports colorful text, colorful text would appear. How do I know the style? If I copied blue text from Word, how would I know *programmatically* that its blue? How do I know what meta-singes are attached (I know how to programmatically invoke adding plain text to the clipboard via C#/Java - how do I invoke copying blue text?)?
 

My Computer

Computer type
PC/Desktop
OS
Windows 7
So this is entirely a programming question?
If so, the first thing to understand is how the clipboard really works.

The clipboard works by holding data and its associated format. Each program specifies what format it's sending data in, so the pasting software knows how to deal with it. The trick that makes the clipboard so flexible is that it allows programs to set multiple copies of the very same data, in different formats, at the same time.
When you copy a chunk of text from Word, what actually happens is that Word places the text multiple times, one in plain text, other in rich text format, some other proprietary format and so on. What this allows is to provide a wide range of options for programs to paste from. Notepad may pick the plain text, Word would pick the most complete format, another editor maybe would pick RTF, and so on.

Back to the original question, when you read data from the clipboard, you can query what data formats are available, then if the formated text is there, you can read it by specifying the appropriate format. It would contain, for example, the RTF simbols or the HTML markup, which is then up to you to interpret.

As an example, a few threads on StackOverflow deal with this. Two specially relevant are those:
winforms - C# How can I paste formatted text from clipboard to the RichTextBox - Stack Overflow
.net - Copying text along with its formatting from a RichTextBox - Stack Overflow

While both talk about a RichTextBox control, the clipboard part is independent of it and you can use it in any situation you need. Also, be sure to read something from Wikipedia:
Clipboard (computing - Wikipedia)

And finally, the official .NET Framework reference on the topic, applicable to C#, as well as all .NET languages:
Clipboard Class (System.Windows.Forms)

I have no real experience with Java, but the fundamental concepts are the same. Its documentation will help fill the gaps and understand the differences in the APIs.
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Sattelite A665-S6092
OS
Windows 7 Ultimate x64
CPU
Intel Core i7-740QM
Memory
8 GB DDR3
Graphics Card(s)
NVIDIA GeForce 330GT
Screen Resolution
1366x768
Hard Drives
Samsung 840 SSD 500GB
1TB USB3 external HD
Cooling
Coolermaster Notepal U3 notebook cooling pad
Internet Speed
3mbps ASDL
Antivirus
ClamWin 0.98.7
Browser
Opera 12.17 x86 (main), Firefox 38 (sec), IE11 (last resort)
Back
Top