Changeset 11d55e5


Ignore:
Timestamp:
Sep 21, 2011, 4:20:30 PM (10 years ago)
Author:
Jason Gross <jgross@mit.edu>
Children:
8ad3964
Parents:
bbd0cf1
git-author:
Jason Gross <jgross@mit.edu> (06/25/11 21:19:32)
git-committer:
Jason Gross <jgross@mit.edu> (09/21/11 16:20:30)
Message:
Improved consistency between owl_function_start_* functions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r6646fdb r11d55e5  
    272272}
    273273
    274 void owl_function_start_edit_win(const char *line, void (*callback)(owl_editwin *), void *data, void (*cleanup)(void *))
     274owl_editwin *owl_function_start_edit_win(const char *line)
    275275{
    276276  owl_editwin *e;
     
    286286  g_free(s);
    287287
    288   owl_editwin_set_cbdata(e, data, cleanup);
    289   owl_editwin_set_callback(e, callback);
    290288  ctx = owl_editcontext_new(OWL_CTX_EDITMULTI, e, "editmulti",
    291289                            owl_global_deactivate_editcontext, &g);
    292290  owl_global_push_context_obj(&g, ctx);
    293 
     291  return e;
    294292}
    295293
     
    309307void owl_function_zwrite_setup(owl_zwrite *z)
    310308{
     309  owl_editwin *e;
    311310  /* send a ping if necessary */
    312311  if (owl_global_is_txping(&g)) {
     
    316315
    317316  owl_function_write_setup("zephyr");
    318   owl_function_start_edit_win(z->zwriteline,
    319                               &owl_callback_zwrite,
    320                               z, (void(*)(void*))owl_zwrite_delete);
     317  e = owl_function_start_edit_win(z->zwriteline);
     318  owl_editwin_set_cbdata(e, z, (void (*)(void *))owl_zwrite_delete);
     319  owl_editwin_set_callback(e, &owl_callback_zwrite);
    321320}
    322321
    323322void owl_function_aimwrite_setup(const char *to)
    324323{
     324  owl_editwin *e;
    325325  /* TODO: We probably actually want an owl_aimwrite object like
    326326   * owl_zwrite. */
    327327  char *line = g_strdup_printf("aimwrite %s", to);
    328328  owl_function_write_setup("message");
    329   owl_function_start_edit_win(line,
    330                               &owl_callback_aimwrite,
    331                               g_strdup(to),
    332                               g_free);
     329  e = owl_function_start_edit_win(line);
     330  owl_editwin_set_cbdata(e, g_strdup(to), g_free);
     331  owl_editwin_set_callback(e, &owl_callback_aimwrite);
    333332  g_free(line);
    334333}
     
    336335void owl_function_loopwrite_setup(void)
    337336{
     337  owl_editwin *e;
    338338  owl_function_write_setup("message");
    339   owl_function_start_edit_win("loopwrite",
    340                               &owl_callback_loopwrite,
    341                               NULL, NULL);
     339  e = owl_function_start_edit_win("loopwrite");
     340  owl_editwin_set_callback(e, &owl_callback_loopwrite);
    342341}
    343342
     
    19461945}
    19471946
    1948 void owl_function_start_command(const char *line)
     1947owl_editwin *owl_function_start_command(const char *line)
    19491948{
    19501949  owl_editwin *tw;
     
    19611960  owl_global_push_context_obj(&g, ctx);
    19621961  owl_editwin_set_callback(tw, owl_callback_command);
    1963 }
    1964 
    1965 CALLER_OWN owl_editwin *owl_function_start_question(const char *line)
     1962  return tw;
     1963}
     1964
     1965owl_editwin *owl_function_start_question(const char *line)
    19661966{
    19671967  owl_editwin *tw;
     
    19781978}
    19791979
    1980 CALLER_OWN owl_editwin *owl_function_start_password(const char *line)
     1980owl_editwin *owl_function_start_password(const char *line)
    19811981{
    19821982  owl_editwin *tw;
  • perlglue.xs

    rf271129 r11d55e5  
    209209        const char *line
    210210        SV *callback
     211        PREINIT:
     212                owl_editwin *e;
    211213        CODE:
    212214        {
     
    214216                        croak("Callback must be a subref");
    215217
    216                 owl_function_start_edit_win(line,
    217                                             owl_perlconfig_edit_callback,
    218                                             newSVsv(callback),
    219                                             owl_perlconfig_dec_refcnt);
     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);
    220223        }
    221224
Note: See TracChangeset for help on using the changeset viewer.