Changeset c162fd6 for perl


Ignore:
Timestamp:
Sep 27, 2011, 5:24:40 PM (13 years ago)
Author:
GitHub Merge Button <merge-button@github.com>
Parents:
eba02ec (diff), c8ef50b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge c8ef50b948941e905b8fd8356002fc8014f22c8d into eba02ec95bdc692803bcaf7dc90abc666c7097f7
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl.pm

    ra130fc5 rc8ef50b  
    99                    zephyr_stylestrip zephyr_smartstrip_user zephyr_getsubs
    1010                    queue_message admin_message
     11                    start_edit
    1112                    start_question start_password start_edit_win
    1213                    get_data_dir get_config_dir popless_text popless_ztext
     
    105106Enqueue a message in the BarnOwl message list, logging it and
    106107processing it appropriately. C<MESSAGE> should be an instance of
    107 BarnOwl::Message or a subclass.  Returns the queued message.  This
    108 is useful for, e.g., deleting a message from the message list.
     108BarnOwl::Message or a subclass.
    109109
    110110=head2 admin_message HEADER BODY
     
    112112Display a BarnOwl B<Admin> message, with the given header and body.
    113113
     114=head2 start_edit %ARGS
     115
     116Displays a prompt on the screen and lets the user enter text,
     117and calls a callback when the editwin is closed.
     118
     119C<%ARGS> must contain the following keys:
     120
     121=over 4
     122
     123=item prompt
     124
     125The line to display on the screen
     126
     127=item type
     128
     129One of:
     130
     131=over 4
     132
     133=item edit_win
     134
     135Displays the prompt on a line of its own and opens the edit_win.
     136
     137=item question
     138
     139Displays prompt on the screen and lets the user enter a line of
     140text.
     141
     142=item password
     143
     144Like question, but echoes the user's input as C<*>s when they
     145input.
     146
     147=back
     148
     149=item callback
     150
     151A Perl subroutine that is called when the user closes the edit_win.
     152C<CALLBACK> gets called with two parameters: the text the user entered,
     153and a C<SUCCESS> boolean parameter which is false if the user canceled
     154the edit_win and true otherwise.
     155
     156=back
     157
    114158=head2 start_question PROMPT CALLBACK
    115159
    116 Displays C<PROMPT> on the screen and lets the user enter a line of
    117 text, and calls C<CALLBACK>, which must be a perl subroutine
    118 reference, with the text the user entered
    119 
    120160=head2 start_password PROMPT CALLBACK
    121161
    122 Like C<start_question>, but echoes the user's input as C<*>s when they
    123 input.
    124 
    125162=head2 start_edit_win PROMPT CALLBACK
    126163
    127 Like C<start_question>, but displays C<PROMPT> on a line of its own
    128 and opens the editwin. If the user cancels the edit win, C<CALLBACK>
    129 is not invoked.
     164Roughly equivalent to C<start_edit> called with the appropriate parameters.
     165C<CALLBACK> is only called on success.
     166
     167These are deprecated wrappers around L<BarnOwl::start_edit>, and should not
     168be uesd in new code.
     169
     170=cut
     171
     172sub start_edit {
     173    my %args = (@_);
     174    BarnOwl::Internal::start_edit($args{type}, $args{prompt}, $args{callback});
     175}
     176
     177sub start_question {
     178    my ($prompt, $callback) = @_;
     179    BarnOwl::start_edit(type => 'question', prompt => $prompt, callback => sub {
     180            my ($text, $success) = @_;
     181            $callback->($text) if $success;
     182        });
     183}
     184
     185sub start_password {
     186    my ($prompt, $callback) = @_;
     187    BarnOwl::start_edit(type => 'password', prompt => $prompt, callback => sub {
     188            my ($text, $success) = @_;
     189            $callback->($text) if $success;
     190        });
     191}
     192
     193sub start_edit_win {
     194    my ($prompt, $callback) = @_;
     195    BarnOwl::start_edit(type => 'edit_win', prompt => $prompt, callback => sub {
     196            my ($text, $success) = @_;
     197            $callback->($text) if $success;
     198        });
     199}
    130200
    131201=head2 get_data_dir
Note: See TracChangeset for help on using the changeset viewer.