Changeset 8ad3964
- Timestamp:
- Sep 21, 2011, 4:21:50 PM (13 years ago)
- Children:
- c8ef50b
- Parents:
- 11d55e5
- git-author:
- Jason Gross <jgross@mit.edu> (07/10/11 17:58:20)
- git-committer:
- Jason Gross <jgross@mit.edu> (09/21/11 16:21:50)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/lib/BarnOwl.pm
ra130fc5 r8ad3964 9 9 zephyr_stylestrip zephyr_smartstrip_user zephyr_getsubs 10 10 queue_message admin_message 11 start_edit 11 12 start_question start_password start_edit_win 12 13 get_data_dir get_config_dir popless_text popless_ztext … … 105 106 Enqueue a message in the BarnOwl message list, logging it and 106 107 processing 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. 108 BarnOwl::Message or a subclass. 109 109 110 110 =head2 admin_message HEADER BODY … … 112 112 Display a BarnOwl B<Admin> message, with the given header and body. 113 113 114 =head2 start_edit %ARGS 115 116 Displays a prompt on the screen and lets the user enter text, 117 and calls a callback when the editwin is closed. 118 119 C<%ARGS> must contain the following keys: 120 121 =over 4 122 123 =item prompt 124 125 The line to display on the screen 126 127 =item type 128 129 One of: 130 131 =over 4 132 133 =item edit_win 134 135 Displays the prompt on a line of its own and opens the edit_win. 136 137 =item question 138 139 Displays prompt on the screen and lets the user enter a line of 140 text. 141 142 =item password 143 144 Like question, but echoes the user's input as C<*>s when they 145 input. 146 147 =back 148 149 =item callback 150 151 A Perl subroutine that is called when the user closes the edit_win. 152 153 =back 154 114 155 =head2 start_question PROMPT CALLBACK 115 156 116 Displays C<PROMPT> on the screen and lets the user enter a line of117 text, and calls C<CALLBACK>, which must be a perl subroutine118 reference, with the text the user entered119 120 157 =head2 start_password PROMPT CALLBACK 121 158 122 Like C<start_question>, but echoes the user's input as C<*>s when they123 input.124 125 159 =head2 start_edit_win PROMPT CALLBACK 126 160 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. 161 Equivalent to C<start_edit> called with the appropriate parameters. 162 163 =cut 164 165 sub start_edit { 166 my %args = (@_); 167 BarnOwl::Internal::start_edit($args{type}, $args{prompt}, $args{callback}); 168 } 169 170 sub start_question { 171 my ($prompt, $callback) = @_; 172 BarnOwl::start_edit(type => 'question', prompt => $prompt, callback => $callback); 173 } 174 175 sub start_password { 176 my ($prompt, $callback) = @_; 177 BarnOwl::start_edit(type => 'password', prompt => $prompt, callback => $callback); 178 } 179 180 sub start_edit_win { 181 my ($prompt, $callback) = @_; 182 BarnOwl::start_edit(type => 'edit_win', prompt => $prompt, callback => $callback); 183 } 130 184 131 185 =head2 get_data_dir -
perlglue.xs
r11d55e5 r8ad3964 167 167 } 168 168 169 void170 start_question(line, callback)171 const char *line172 SV *callback173 PREINIT:174 owl_editwin *e;175 CODE:176 {177 if(!SV_IS_CODEREF(callback))178 croak("Callback must be a subref");179 180 e = owl_function_start_question(line);181 182 owl_editwin_set_cbdata(e,183 newSVsv(callback),184 owl_perlconfig_dec_refcnt);185 owl_editwin_set_callback(e, owl_perlconfig_edit_callback);186 }187 188 void189 start_password(line, callback)190 const char *line191 SV *callback192 PREINIT:193 owl_editwin *e;194 CODE:195 {196 if(!SV_IS_CODEREF(callback))197 croak("Callback must be a subref");198 199 e = owl_function_start_password(line);200 201 owl_editwin_set_cbdata(e,202 newSVsv(callback),203 owl_perlconfig_dec_refcnt);204 owl_editwin_set_callback(e, owl_perlconfig_edit_callback);205 }206 207 void208 start_edit_win(line, callback)209 const char *line210 SV *callback211 PREINIT:212 owl_editwin *e;213 CODE:214 {215 if(!SV_IS_CODEREF(callback))216 croak("Callback must be a subref");217 218 e = owl_function_start_edit_win(line);219 owl_editwin_set_cbdata(e,220 newSVsv(callback),221 owl_perlconfig_dec_refcnt);222 owl_editwin_set_callback(e, &owl_perlconfig_edit_callback);223 }224 225 169 226 170 const char * … … 499 443 ival); 500 444 445 void 446 start_edit(edit_type, line, callback) 447 const char *edit_type 448 const char *line 449 SV *callback 450 PREINIT: 451 owl_editwin *e; 452 CODE: 453 { 454 if (!SV_IS_CODEREF(callback)) 455 croak("Callback must be a subref"); 456 457 if (!strcmp(edit_type, "question")) 458 e = owl_function_start_question(line); 459 else if (!strcmp(edit_type, "password")) 460 e = owl_function_start_password(line); 461 else if (!strcmp(edit_type, "edit_win")) 462 e = owl_function_start_edit_win(line); 463 else 464 croak("edit_type must be one of 'password', 'question', 'edit_win', not '%s'", edit_type); 465 466 owl_editwin_set_cbdata(e, newSVsv(callback), owl_perlconfig_dec_refcnt); 467 owl_editwin_set_callback(e, owl_perlconfig_edit_callback); 468 } 469 501 470 MODULE = BarnOwl PACKAGE = BarnOwl::Editwin 502 471
Note: See TracChangeset
for help on using the changeset viewer.