| 1 | package SDL2::clipboard 0.01 { | ||
| 2 | use SDL2::Utils; | ||
| 3 | attach clipboard => { | ||
| 4 | SDL_SetClipboardText => [ ['string'], 'int' ], | ||
| 5 | SDL_GetClipboardText => [ [], 'string' ], | ||
| 6 | SDL_HasClipboardText => [ [], 'SDL_bool' ] | ||
| 7 | }; | ||
| 8 | |||
| 9 | =encoding utf-8 | ||
| 10 | |||
| 11 | =head1 NAME | ||
| 12 | |||
| 13 | SDL2::clipboard - UTF-8 Friendly Clipboard Functions | ||
| 14 | |||
| 15 | =head1 SYNOPSIS | ||
| 16 | |||
| 17 | use SDL2 qw[:clipboard]; | ||
| 18 | |||
| 19 | =head1 DESCRIPTION | ||
| 20 | |||
| 21 | Basic clipboard handling. | ||
| 22 | |||
| 23 | =head1 Functions | ||
| 24 | |||
| 25 | These functions expose the clipboard. SDL's video subsystem must be initialized | ||
| 26 | to get or modify clipboard text. | ||
| 27 | |||
| 28 | =head2 C<SDL_SetClipboardText( ... )> | ||
| 29 | |||
| 30 | Put UTF-8 text into the clipboard. | ||
| 31 | |||
| 32 | SDL_SetClipboardText( 'Hello, world!' ); | ||
| 33 | |||
| 34 | Expected parameters include: | ||
| 35 | |||
| 36 | =over | ||
| 37 | |||
| 38 | =item C<text> - the text to store in the clipboard | ||
| 39 | |||
| 40 | =back | ||
| 41 | |||
| 42 | Returns C<0> on success or a negative error code on failure; call | ||
| 43 | C<SDL_GetError( )> for more information. | ||
| 44 | |||
| 45 | =head2 C<SDL_GetClipboardText( )> | ||
| 46 | |||
| 47 | Get UTF-8 text from the clipboard, which must be freed with C<SDL_free( )>. | ||
| 48 | |||
| 49 | my $clipboard = SDL_GetClipboardText( ); | ||
| 50 | |||
| 51 | This functions returns NULL if there was not enough memory left for a copy of | ||
| 52 | the clipboard's content. | ||
| 53 | |||
| 54 | Returns the clipboard text on success or NULL on failure; call C<SDL_GetError( | ||
| 55 | )> for more information. Caller must call C<SDL_free( )> on the returned | ||
| 56 | pointer when done with it. | ||
| 57 | |||
| 58 | =head2 C<SDL_HasClipboardText( )> | ||
| 59 | |||
| 60 | Query whether the clipboard exists and contains a non-empty text string. | ||
| 61 | |||
| 62 | if ( SDL_HasClipboardText( ) ) { | ||
| 63 | ... | ||
| 64 | } | ||
| 65 | |||
| 66 | Returns C<SDL_TRUE> if the clipboard has text, or C<SDL_FALSE> if it does not. | ||
| 67 | |||
| 68 | =head1 LICENSE | ||
| 69 | |||
| 70 | Copyright (C) Sanko Robinson. | ||
| 71 | |||
| 72 | This library is free software; you can redistribute it and/or modify it under | ||
| 73 | the terms found in the Artistic License 2. Other copyrights, terms, and | ||
| 74 | conditions may apply to data transmitted through this module. | ||
| 75 | |||
| 76 | =head1 AUTHOR | ||
| 77 | |||
| 78 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||
| 79 | |||
| 80 | =begin stopwords | ||
| 81 | |||
| 82 | =end stopwords | ||
| 83 | |||
| 84 | =cut | ||
| 85 | |||
| 86 | }; | ||
| 87 | 1; |