Changeset e89ec48 for perl/lib


Ignore:
Timestamp:
Sep 30, 2011, 8:06:58 AM (13 years ago)
Author:
Jason Gross <jgross@mit.edu>
Branches:
master, release-1.10, release-1.9
Children:
7803326
Parents:
c737503
git-author:
Jason Gross <jgross@mit.edu> (07/10/11 17:58:20)
git-committer:
Jason Gross <jgross@mit.edu> (09/30/11 08:06:58)
Message:
Made BarnOwl::start_* wrappers around a new BarnOwl::start_edit

A new function, BarnOwl::start_edit, was created as the preferred
interface for starting the edit_win from perl.

The perl interface to the edit_win is backwards compatible.

This is mostly preparation for the next commit, which generalizes the
syntax of starting an edit_win to allow callbacks on cancel.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl.pm

    ra130fc5 re89ec48  
    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.
     152
     153=back
     154
    114155=head2 start_question PROMPT CALLBACK
    115156
    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 
    120157=head2 start_password PROMPT CALLBACK
    121158
    122 Like C<start_question>, but echoes the user's input as C<*>s when they
    123 input.
    124 
    125159=head2 start_edit_win PROMPT CALLBACK
    126160
    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.
     161Equivalent to C<start_edit> called with the appropriate parameters.
     162
     163=cut
     164
     165sub start_edit {
     166    my %args = (@_);
     167    BarnOwl::Internal::start_edit($args{type}, $args{prompt}, $args{callback});
     168}
     169
     170sub start_question {
     171    my ($prompt, $callback) = @_;
     172    BarnOwl::start_edit(type => 'question', prompt => $prompt, callback => $callback);
     173}
     174
     175sub start_password {
     176    my ($prompt, $callback) = @_;
     177    BarnOwl::start_edit(type => 'password', prompt => $prompt, callback => $callback);
     178}
     179
     180sub start_edit_win {
     181    my ($prompt, $callback) = @_;
     182    BarnOwl::start_edit(type => 'edit_win', prompt => $prompt, callback => $callback);
     183}
    130184
    131185=head2 get_data_dir
Note: See TracChangeset for help on using the changeset viewer.