top logo menu kitty mascot
AROS.ORG Developers Localization Bounties

console

Index


AddConSnipHook() CDInputHandler() GetConSnip() RawKeyConvert()
RemConSnipHook() SetConSnip()    

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.

Inputs

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().

Result

None.

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.

CDInputHandler()

Synopsis

struct InputEvent * CDInputHandler(
         struct InputEvent * events,
         APTR consoleDevice );

GetConSnip()

Synopsis

APTR GetConSnip();

Function

Obtain a private, NUL-terminated copy of the console selection
buffer.

Inputs

None.

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.

RawKeyConvert()

Synopsis

LONG RawKeyConvert(
         struct InputEvent * events,
         STRPTR buffer,
         struct KeyMap * keyMap );

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.

Inputs

hook - Non-NULL pointer to a hook currently registered with
       AddConSnipHook(). Do not remove a hook twice or pass an
       unregistered hook.

Result

None.

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.

See also

AddConSnipHook()


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.

Inputs

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.

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.