AddConSnipHook()
Synopsis
void AddConSnipHook(
struct Hook * hook );
Function
Append a hook to the console selection notification list. The
console calls the hooks, in list order, when copying a nonempty
selection and successfully allocating a notification buffer.
Notes
The current implementation passes NULL as the hook object and a
pointer to a private ConClipData message with this layout:
struct ConClipData
{
ULONG flags;
ULONG size;
APTR buffer;
};
The flags field is zero, size is the selection length in bytes,
and buffer points to
a NUL-terminated copy with size bytes before the terminator.
The hook return value is ignored. The message and buffer are
borrowed and valid only during the callback. Do not retain or
free either pointer; copy data needed after the callback returns.
Callbacks run while the console holds its copy-buffer semaphore.
Do not modify the hook list from a callback or wait for another
task that needs this semaphore. SetConSnip() does not generate
these notifications. Empty selections and allocation failures do
not generate them either.
The caller retains ownership of the hook. Registration takes the
copy-buffer semaphore and may block.
GetConSnip()
Synopsis
APTR GetConSnip();
Function
Obtain a private, NUL-terminated copy of the console selection
buffer.
Result
A newly allocated copy, or NULL if there is no stored buffer or
memory could not be allocated. Release a non-NULL result with
FreeVec(), not FreeMem().
Notes
The returned memory belongs to the caller and remains valid across
later changes to the console selection. No length is returned.
This function takes the copy-buffer semaphore and may block.
RemConSnipHook()
Synopsis
void RemConSnipHook(
struct Hook * hook );
Function
Unlink a hook previously registered by AddConSnipHook(). Removal
is serialized with selection notification by the console's
copy-buffer semaphore.
Notes
The hook is unlinked, not freed. When this function returns to a
caller outside a notification callback, an ongoing notification
holding the semaphore has finished and the hook can be released.
Do not call this function from a selection notification callback:
the console is traversing the same list.
This function takes the copy-buffer semaphore and may block. The caller must coordinate
any concurrent registration or removal of the same hook.
SetConSnip()
Synopsis
LONG SetConSnip(
APTR data );
Function
Replace the console selection buffer with a copy of a
NUL-terminated string. The previous buffer is discarded before
storage for the replacement is allocated. A NULL pointer or an
empty string clears the selection buffer.
Result
1 if a nonempty string was successfully copied.
0 if data is NULL, the string is empty, or allocation failed.
In each of these cases the selection buffer is left empty; the
previous contents are not restored on failure.
Notes
SetConSnip() does not notify registered hooks. Only bytes before
the first NUL in data are copied.
This function takes the copy-buffer semaphore and may block.