Changeset 1b1cd2c for editwin.c


Ignore:
Timestamp:
Mar 23, 2010, 5:23:43 PM (11 years ago)
Author:
Nelson Elhage <nelhage@ksplice.com>
Branches:
master, release-1.6, release-1.7, release-1.8, release-1.9
Children:
8dfb59c
Parents:
6b78afb
git-author:
Nelson Elhage <nelhage@mit.edu> (03/13/10 21:18:03)
git-committer:
Nelson Elhage <nelhage@ksplice.com> (03/23/10 17:23:43)
Message:
Editwin: Add a callback to destroy cbdata
File:
1 edited

Legend:

Unmodified
Added
Removed
  • editwin.c

    rf449096 r1b1cd2c  
    3737  char *command;
    3838  void (*callback)(struct _owl_editwin*);
     39  void (*destroy_cbdata)(void *);
    3940  void *cbdata;
    4041};
     
    5859static int oe_copy_region(owl_editwin *e);
    5960static char *oe_chunk(owl_editwin *e, int start, int end);
     61static void oe_destroy_cbdata(owl_editwin *e);
    6062
    6163#define INCR 4096
     
    145147  e->echochar='\0';
    146148
    147   /* We get initialized multiple times, but we need to hold on to
    148      the callbacks, so we can't NULL them here. */
    149   /*
    150     e->command = NULL;
    151     e->callback = NULL;
    152     e->cbdata = NULL;
    153   */
    154149  if (win) werase(win);
    155150}
     
    210205}
    211206
    212 void owl_editwin_set_cbdata(owl_editwin *e, void *data)
    213 {
     207static void oe_destroy_cbdata(owl_editwin *e) {
     208  if (e->destroy_cbdata)
     209    e->destroy_cbdata(e->cbdata);
     210  e->cbdata = NULL;
     211  e->destroy_cbdata = NULL;
     212}
     213
     214void owl_editwin_set_cbdata(owl_editwin *e, void *data, void (*destroy)(void *))
     215{
     216  oe_destroy_cbdata(e);
    214217  e->cbdata = data;
     218  e->destroy_cbdata = destroy;
    215219}
    216220
     
    282286  owl_free(e->buff);
    283287  owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist);
     288  e->callback = NULL;
     289  oe_destroy_cbdata(e);
    284290}
    285291
Note: See TracChangeset for help on using the changeset viewer.