(This posting, while it is very lonnng...it is actually not quite as very
lonnng as it might first appear to be. What I mean, the second half of it
is just footnote text quoted from external source.)
(e-mail address removed) (Steven):
I will look into adding this feature into all of the text editors I've
built. (I can't stand it when a feature is available only in a
non-freeware application).
I wonder if it will be something of a project to find the method to do it?
I ended up reading the documents that came up through web search. However,
as a non-programmer, I wasn't able to gain any sense about the difficulty,
the howto of the implementation. Just that I develop the notion that there
is a general paucity of information on this, compared to some more common
programmer quests. So I will be very interested in whether you can pull off
a success.
The part of the reading that was useful for me, as an end user, was the
general subject of clipboard formats. I'd previously had a pretty
unsatisfactory understanding about that. Even very recently, when someone
here quoted Acrobat's help file doc about its copy picture operation sending
out in WMF, my first internal thought was "huh, why wasn't it BMP." But
next foggily recalled how paste graphics in word processors can sometimes
offer two or three choices.... I realized a lacked a decent grasp/
visualization about the underlying events during send-to and receive-from
clipboard. [1]
After my recent reading, I now feel an improved sense of the clipboard,
especially wrt how an app can be sending out a combo of available formats,
and a receiving app can select what it handles. I benefited most from
reading the whole msdn chapter (the semi-English parts that is; I can't
read the win api calls snippets stuff), found here:
http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/dataexchange/clipboard.asp
A primary question going on in my mind pertained to my big wish about
an app that not only has a "paste as html" feature -- but also about
extending the usefulness of that. Via making raw html paste the output
format automatically, instead of a manual multi-step affair for the user
(who must seek out a "paste special" type menu, and cannot get this format
from ctrl-V etc).
As I think about it now, I should have been able to get the first couple
of steps into the question about changing what's default and not paste
special, not by reading at msdn, but by just reviewing my experience as
a user of various software. Mainly, a question like this. Of the programs
that have a monitor clipboard feature, have any of them let me set it up
to receive in one format or another (usually txt vs rtf in the cases I'm
thinking)?
My ~memory tells me the answer to that is no. The workaround, during those
cases where any workaround is available, is having the app told it is making
strictly a whole text document, or rtf. It's all very clumsy. Ok, likely
a few of the specialized clipboard-collector programs have a choice to
auto-capture in eg txt vs rtf. But with those, that gets things even more
clumsy, since that's leaving the editor entirely, and would defeat the hope
of the best uses for the extended functionality.
And then there is this. That user choice of automatic receive in richtext
vs text, that might perhaps have occasional precedent (however clumsy)...
However still I believe there is no precedent at all for automatic receive
of CF_HTML (even latest M$ Office, whatever it might have along these lines,
I'd suspect it might mark it up a bit, and also, that to make it display it
raw would take 25 convoluted steps).
I read the general situation of multiple clipboard format [2], then looked
through that msdn chapter for my question. About the receiving window's
selection of what format to receive when there are a variety available in
the clipboard. One part of the chapter explained to me how that default
receive behavior happens. That the most descriptive (complex) format
from the sending window goes to the top of clipboard; and that the receiving
app takes from the top (or moves down to the less descriptive, simpler
formats if it can't handle the more complex).
Then I saw there was indeed some talk about methods for a receiving window
to _choose_ what format to take from the clipboard.
Where msdn says....
"Alternatively, a window can use the GetPriorityClipboardFormat
function. This function identifies the best available clipboard
format according to a specified priority."
I have absolutely not the least idea what "priority" means. And it is
not my area to further know what it entails, etc. I am just after my
quest: I am just hoping that "priority" in this case might represent
the programming approach towards the possibility (?) of what I wish to
see come into being...
A text editor who will not only handle "CF_HTML" but would have a way to
make it an optional default for what it takes from the clipboard. Is it
possible??
I am really hoping you might be able to achieve something here!
I want to repeat my desire. Main essence of it is: Freeware program that
has a "Paste as HTML" function. It seems to be a very rare feature.
There might be a couple of big commercial products that have it, but
even with them, I'm not sure if they are even any good about it -- that
is, good to automatically present it as _raw html_ to the user. Even
if so, it's not just that these would be programs costing hundreds of
dollars; but that they are much too fat and heavy, and overkill for this
function.
Code Genie has the feature, and it's a great program, but it is shareware.
And furthermore it is muti-step for the user to do that command. AceHTML
has the feature, but it's not the most wonderful choice. First, it is
registerware (who also demands one's info all over again on each upgrade).
It's also kind of big; a good, sleek editor would be much more desirable.
Finally, the shortcoming that stands throughout. With AceHTML, as with
every program existing within my knowledge, there is no way to set up
a clipboard capture feature, or paste operations, to be in the CF_HTML
format _automatically_.
If that second part of my wish could also be achieved within a text editor,
the use would be great. The capture as CF_HTML as default, I'm especially
daydreaming on a main area to then take that. A "save selected html" on the
browser context menu. Implemented in similar fashion to the IE Text Archiver
..vbs script. User selects text from the browser, and that selection becomes
a file to save.... Only what would be much better is the raw html selected
to be saved, not plain text, thus preserving the formatting.
--
Karen S.
Footnoted Refs follow.
<MSDN, quoted>
__________________________________________________________________________
[1]
Clipboard Formats
A window should use the clipboard when cutting, copying, or pasting data.
[...]
A window can place more than one object on the clipboard, each
representing the same information in a different clipboard format.
[...]
A memory object on the clipboard can be in any data format, called a
clipboard format.
[...]
CF_TIFF Tagged-image file format.
CF_WAVE Represents audio data in one of the standard wave formats,
such as 11 kHz or 22 kHz Pulse Code Modulation (PCM).
CF_TEXT Text format. Each line ends with a carriage return/linefeed
(CR-LF) combination. A null character signals the end of the
data. Use this format for ANSI text.
CF_UNICODETEXT Windows NT/2000/XP:Unicode text format.
[...]
CF_HTML is entirely text format (to be, among other things, in the HTML
spirit, and uses UTF-8) and includes a description, an optional context,
and, within the context, the fragment.
[...]
Many applications work with data that cannot be translated into a standard
clipboard format without loss of information. These applications can create
their own clipboard formats. [...] For example, if a word-processing
application copied formatted text to the clipboard using a standard text
format, the formatting information would be lost. The solution would be to
register a new clipboard format, such as RTF.
[...]
__________________________________________________________________________
[2]
Multiple Clipboard Formats
A window can place more than one clipboard object on the clipboard, each
representing the same information in a different clipboard format. When
placing information on the clipboard, the window should provide data in as
many formats as possible. To find out how many formats are currently used on
the clipboard, call the CountClipboardFormats function.
Clipboard formats that contain the most information should be placed on the
clipboard first, followed by less descriptive formats.
A window pasting information from the clipboard typically retrieves a
clipboard object in the first format it recognizes.
Because clipboard formats are enumerated in the order they are placed on the
clipboard, the first recognized format is also the most descriptive.
For example, suppose a user copies styled text from a word-processing
document. The window containing the document might first place data on the
clipboard in a registered format, such as RTF. Subsequently, the window
would place data on the clipboard in a less descriptive format, such as text
(CF_TEXT).
When the content of the clipboard is pasted into another window, the window
retrieves data in the most descriptive format it recognizes. If the window
recognizes RTF, the corresponding data is pasted into the document.
Otherwise, the text data is pasted into the document and the formatting
information is lost.
[...]
Paste Operations
To retrieve paste information from the clipboard, a window first determines
the clipboard format to retrieve. Typically, a window enumerates the
available clipboard formats by using the EnumClipboardFormats function and
uses the first format it recognizes. This method selects the best available
format according to the priority set when the data was placed on the
clipboard.
__________________________________________________________________________
[3]
Clipboard Operations
To retrieve paste information from the clipboard, a window first determines
the clipboard format to retrieve. Typically, a window enumerates the
available clipboard formats by using the EnumClipboardFormats function and
uses the first format it recognizes. This method selects the best available
format according to the priority set when the data was placed on the
clipboard.
Alternatively, a window can use the GetPriorityClipboardFormat function.
This function identifies the best available clipboard format according to a
specified priority.
A window that recognizes only one clipboard format can simply determine
whether that format is available by using the IsClipboardFormatAvailable
function.
After determining the clipboard format to use, a window calls the
GetClipboardData function. This function returns the handle to a global
memory object containing data in the specified format.
__________________________________________________________________________
</MSDN, quoted>
Footnote to the footnotes. Amount of material needed to quote was quite
large mainly because I was not qualified to summarize more. Also in
including a fair body of the stuff, was because I had in mind that it
could be useful for a reader or two out there who is at the same juncture
I am wrt understanding/visualizing the comm between apps when the clipboard
is in play.
-Karen