--- Cannot embed stylesheet: [Errno 2] No such file or directory: '../../../aros.css' --->
| AddConSnipHook() | CDInputHandler() | GetConSnip() | RawKeyConvert() |
| RemConSnipHook() | SetConSnip() |
void AddConSnipHook(
struct Hook * hook );
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.
hook - Non-NULL pointer to an initialized struct Hook with a valid
entry point. Its list node must not already belong to any
list. The hook and its associated code and data must remain
valid until it has been removed with RemConSnipHook().
None.
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.
struct InputEvent * CDInputHandler(
struct InputEvent * events,
APTR consoleDevice );
APTR GetConSnip();
Obtain a private, NUL-terminated copy of the console selection buffer.
None.
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().
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.
LONG RawKeyConvert(
struct InputEvent * events,
STRPTR buffer,
struct KeyMap * keyMap );
void RemConSnipHook(
struct Hook * hook );
Unlink a hook previously registered by AddConSnipHook(). Removal is serialized with selection notification by the console's copy-buffer semaphore.
hook - Non-NULL pointer to a hook currently registered with
AddConSnipHook(). Do not remove a hook twice or pass an
unregistered hook.
None.
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.
LONG SetConSnip(
APTR data );
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.
data - Pointer to a readable NUL-terminated string, or NULL to
clear the buffer. The input remains owned by the caller
and need only remain valid until this call returns.
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.
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.