Changeset 7803326
- Timestamp:
- Sep 30, 2011, 8:07:53 AM (13 years ago)
- Branches:
- master, release-1.10, release-1.9
- Children:
- 0c71c58, 5f784ec, 923c3f6, a962f5c, d953ede
- Parents:
- e89ec48
- git-author:
- Jason Gross <jgross@mit.edu> (06/23/11 23:58:21)
- git-committer:
- Jason Gross <jgross@mit.edu> (09/30/11 08:07:53)
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
rf271129 r7803326 2796 2796 owl_history_store(hist, owl_editwin_get_text(e), false); 2797 2797 2798 /* Take a reference to the editwin, so that it survives the pop 2799 * context. TODO: We should perhaps refcount or otherwise protect 2800 * the context so that, even if a command pops a context, the 2801 * context itself will last until the command returns. */ 2802 owl_editwin_ref(e); 2798 2803 owl_global_pop_context(&g); 2804 2805 owl_editwin_do_callback(e, false); 2806 owl_editwin_unref(e); 2799 2807 } 2800 2808 … … 2856 2864 owl_global_pop_context(&g); 2857 2865 2858 owl_editwin_do_callback(e );2866 owl_editwin_do_callback(e, true); 2859 2867 owl_editwin_unref(e); 2860 2868 } -
editwin.c
rf271129 r7803326 33 33 oe_excursion *excursions; 34 34 35 void (*callback)(struct _owl_editwin *);35 void (*callback)(struct _owl_editwin *e, bool success); 36 36 void (*destroy_cbdata)(void *); 37 37 void *cbdata; … … 220 220 } 221 221 222 void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin *))222 void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin *, bool)) 223 223 { 224 224 e->callback = cb; 225 225 } 226 226 227 void (*owl_editwin_get_callback(owl_editwin *e))(owl_editwin *)227 void (*owl_editwin_get_callback(owl_editwin *e))(owl_editwin *, bool) 228 228 { 229 229 return e->callback; … … 248 248 } 249 249 250 void owl_editwin_do_callback(owl_editwin *e) { 251 void (*cb)(owl_editwin*); 252 cb=owl_editwin_get_callback(e); 253 if(!cb) { 250 void owl_editwin_do_callback(owl_editwin *e, bool success) 251 { 252 void (*cb)(owl_editwin *, bool); 253 cb = owl_editwin_get_callback(e); 254 if (!cb) { 254 255 owl_function_error("Internal error: No editwin callback!"); 255 256 } else { 256 /* owl_function_error("text: |%s|", owl_editwin_get_text(e)); */ 257 cb(e); 257 cb(e, success); 258 258 } 259 259 } -
functions.c
rc737503 r7803326 341 341 } 342 342 343 void owl_callback_zwrite(owl_editwin *e) { 343 void owl_callback_zwrite(owl_editwin *e, bool success) 344 { 345 if (!success) return; 344 346 owl_zwrite *z = owl_editwin_get_cbdata(e); 345 347 owl_function_zwrite(z, owl_editwin_get_text(e)); … … 436 438 } 437 439 438 void owl_callback_aimwrite(owl_editwin *e) { 440 void owl_callback_aimwrite(owl_editwin *e, bool success) 441 { 442 if (!success) return; 439 443 char *to = owl_editwin_get_cbdata(e); 440 444 owl_function_aimwrite(to, owl_editwin_get_text(e), true); … … 500 504 } 501 505 502 void owl_callback_loopwrite(owl_editwin *e) { 506 void owl_callback_loopwrite(owl_editwin *e, bool success) 507 { 508 if (!success) return; 503 509 owl_function_loopwrite(owl_editwin_get_text(e)); 504 510 } … … 911 917 } 912 918 913 void owl_callback_aimlogin(owl_editwin *e) { 919 void owl_callback_aimlogin(owl_editwin *e, bool success) 920 { 921 if (!success) return; 914 922 char *user = owl_editwin_get_cbdata(e); 915 923 owl_function_aimlogin(user, … … 1933 1941 } 1934 1942 1935 void owl_callback_command(owl_editwin *e) 1936 { 1943 void owl_callback_command(owl_editwin *e, bool success) 1944 { 1945 if (!success) return; 1937 1946 char *rv; 1938 1947 const char *line = owl_editwin_get_text(e); -
perl/lib/BarnOwl.pm
re89ec48 r7803326 150 150 151 151 A Perl subroutine that is called when the user closes the edit_win. 152 C<CALLBACK> gets called with two parameters: the text the user entered, 153 and a C<SUCCESS> boolean parameter which is false if the user canceled 154 the edit_win and true otherwise. 152 155 153 156 =back … … 159 162 =head2 start_edit_win PROMPT CALLBACK 160 163 161 Equivalent to C<start_edit> called with the appropriate parameters. 164 Roughly equivalent to C<start_edit> called with the appropriate parameters. 165 C<CALLBACK> is only called on success, for compatibility. 166 167 These are deprecated wrappers around L<BarnOwl::start_edit>, and should not 168 be uesd in new code. 162 169 163 170 =cut … … 170 177 sub start_question { 171 178 my ($prompt, $callback) = @_; 172 BarnOwl::start_edit(type => 'question', prompt => $prompt, callback => $callback); 179 BarnOwl::start_edit(type => 'question', prompt => $prompt, callback => sub { 180 my ($text, $success) = @_; 181 $callback->($text) if $success; 182 }); 173 183 } 174 184 175 185 sub start_password { 176 186 my ($prompt, $callback) = @_; 177 BarnOwl::start_edit(type => 'password', prompt => $prompt, callback => $callback); 187 BarnOwl::start_edit(type => 'password', prompt => $prompt, callback => sub { 188 my ($text, $success) = @_; 189 $callback->($text) if $success; 190 }); 178 191 } 179 192 180 193 sub start_edit_win { 181 194 my ($prompt, $callback) = @_; 182 BarnOwl::start_edit(type => 'edit_win', prompt => $prompt, callback => $callback); 195 BarnOwl::start_edit(type => 'edit_win', prompt => $prompt, callback => sub { 196 my ($text, $success) = @_; 197 $callback->($text) if $success; 198 }); 183 199 } 184 200 -
perlconfig.c
rb9517cf r7803326 520 520 } 521 521 522 void owl_perlconfig_edit_callback(owl_editwin *e )522 void owl_perlconfig_edit_callback(owl_editwin *e, bool success) 523 523 { 524 524 SV *cb = owl_editwin_get_cbdata(e); … … 537 537 PUSHMARK(SP); 538 538 XPUSHs(sv_2mortal(text)); 539 XPUSHs(sv_2mortal(newSViv(success))); 539 540 PUTBACK; 540 541 -
viewwin.c
rf271129 r7803326 158 158 } owl_viewwin_search_data; 159 159 160 static void owl_viewwin_callback_search(owl_editwin *e) 161 { 160 static void owl_viewwin_callback_search(owl_editwin *e, bool success) 161 { 162 if (!success) return; 162 163 int consider_current = false; 163 164 const char *line = owl_editwin_get_text(e);
Note: See TracChangeset
for help on using the changeset viewer.