Changeset 9eb38bb


Ignore:
Timestamp:
Sep 18, 2010, 5:07:39 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
d574d61
Parents:
8ee712e0
git-author:
David Benjamin <davidben@mit.edu> (08/01/10 14:09:34)
git-committer:
David Benjamin <davidben@mit.edu> (09/18/10 17:07:39)
Message:
Likewise, don't reuse a global owl_viewwin

This means we don't have to support plugging and unplugging that thing
over and over. We also can almost entirely drop the global owl_viewwin.
Most of the code gets it from the context anyway.
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r8ee712e0 r9eb38bb  
    27722772  pw = owl_global_get_popwin(&g);
    27732773  owl_global_set_popwin(&g, NULL);
    2774   owl_viewwin_cleanup(vw);
     2774  /* Kind of a hack, but you can only have one active viewwin right
     2775   * now anyway. */
     2776  if (vw == owl_global_get_viewwin(&g))
     2777    owl_global_set_viewwin(&g, NULL);
     2778  owl_viewwin_delete(vw);
    27752779  owl_popwin_delete(pw);
    27762780  owl_global_pop_context(&g);
  • functions.c

    r03ca005 r9eb38bb  
    12371237  owl_viewwin *v;
    12381238
    1239   v=owl_global_get_viewwin(&g);
    1240 
    1241   if (owl_global_get_popwin(&g)) {
     1239  if (owl_global_get_popwin(&g) || owl_global_get_viewwin(&g)) {
    12421240    owl_function_error("Popwin already in use.");
    12431241    return;
     
    12461244  owl_global_set_popwin(&g, pw);
    12471245  owl_popwin_up(pw);
     1246
     1247  v = owl_viewwin_new_text(owl_popwin_get_content(pw), text);
     1248  owl_global_set_viewwin(&g, v);
     1249
    12481250  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL);
    1249   owl_viewwin_init_text(v, owl_popwin_get_content(pw), text);
    12501251}
    12511252
     
    12551256  owl_viewwin *v;
    12561257
    1257   v=owl_global_get_viewwin(&g);
    1258 
    1259   if (owl_global_get_popwin(&g)) {
     1258  if (owl_global_get_popwin(&g) || owl_global_get_viewwin(&g)) {
    12601259    owl_function_error("Popwin already in use.");
    12611260    return;
     
    12641263  owl_global_set_popwin(&g, pw);
    12651264  owl_popwin_up(pw);
     1265
     1266  v = owl_viewwin_new_fmtext(owl_popwin_get_content(pw), fm);
     1267  owl_global_set_viewwin(&g, v);
     1268
    12661269  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL);
    1267   owl_viewwin_init_fmtext(v, owl_popwin_get_content(pw), fm);
    12681270}
    12691271
  • global.c

    r03ca005 r9eb38bb  
    4949
    5050  g->pw = NULL;
     51  g->vw = NULL;
    5152  g->tw = NULL;
    5253
     
    492493
    493494owl_viewwin *owl_global_get_viewwin(owl_global *g) {
    494   return(&(g->vw));
     495  return g->vw;
     496}
     497
     498void owl_global_set_viewwin(owl_global *g, owl_viewwin *vw) {
     499  g->vw = vw;
    495500}
    496501
  • owl.h

    r03ca005 r9eb38bb  
    596596  void *buffercbdata;
    597597  owl_editwin *tw;
    598   owl_viewwin vw;
     598  owl_viewwin *vw;
    599599  void *perl;
    600600  int debug;
  • popexec.c

    r03ca005 r9eb38bb  
    1717  pid_t pid;
    1818
    19   if (owl_global_get_popwin(&g)) {
     19  if (owl_global_get_popwin(&g) || owl_global_get_viewwin(&g)) {
    2020    owl_function_error("Popwin already in use.");
    2121    return NULL;
     
    2828  pe->refcount=0;
    2929
    30   pe->vwin=v=owl_global_get_viewwin(&g);
    3130  pw = owl_popwin_new();
    3231  owl_global_set_popwin(&g, pw);
    3332  owl_popwin_up(pw);
     33  pe->vwin = v = owl_viewwin_new_text(owl_popwin_get_content(pw), "");
     34  owl_global_set_viewwin(&g, v);
     35  owl_viewwin_set_onclose_hook(v, owl_popexec_viewwin_onclose, pe);
    3436
    3537  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL);
    36   owl_viewwin_init_text(v, owl_popwin_get_content(pw), "");
    37   owl_viewwin_set_onclose_hook(v, owl_popexec_viewwin_onclose, pe);
    3838  pe->refcount++;
    3939
  • viewwin.c

    r61c1f19 r9eb38bb  
    77static void owl_viewwin_set_window(owl_viewwin *v, owl_window *w);
    88
    9 /* initialize the viewwin e.  'win' is an already initialzed curses
    10  * window that will be used by viewwin
     9/* Create a viewwin.  'win' is an already initialized owl_window that
     10 * will be used by the viewwin
    1111 */
    12 void owl_viewwin_init_text(owl_viewwin *v, owl_window *win, const char *text)
     12owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text)
    1313{
     14  owl_viewwin *v = owl_malloc(sizeof(owl_viewwin));
     15  memset(v, 0, sizeof(*v));
    1416  owl_fmtext_init_null(&(v->fmtext));
    1517  if (text) {
     
    2527
    2628  owl_viewwin_set_window(v, win);
     29  return v;
    2730}
    2831
     
    4245}
    4346
    44 /* initialize the viewwin e.  'win' is an already initialzed curses
    45  * window that will be used by viewwin
     47/* Create a viewwin.  'win' is an already initialized owl_window that
     48 * will be used by the viewwin
    4649 */
    47 void owl_viewwin_init_fmtext(owl_viewwin *v, owl_window *win, const owl_fmtext *fmtext)
     50owl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext)
    4851{
    4952  char *text;
     53  owl_viewwin *v = owl_malloc(sizeof(owl_viewwin));
     54  memset(v, 0, sizeof(*v));
    5055
    5156  owl_fmtext_copy(&(v->fmtext), fmtext);
     
    6065
    6166  owl_viewwin_set_window(v, win);
     67  return v;
    6268}
    6369
    6470static void owl_viewwin_set_window(owl_viewwin *v, owl_window *w)
    6571{
    66   if (v->window) {
    67     g_signal_handler_disconnect(v->window, v->sig_redraw_id);
    68     g_object_unref(v->window);
    69   }
    7072  v->window = w;
    7173  if (w) {
     
    181183}
    182184
    183 void owl_viewwin_cleanup(owl_viewwin *v)
     185void owl_viewwin_delete(owl_viewwin *v)
    184186{
    185   owl_viewwin_set_window(v, NULL);
    186187  if (v->onclose_hook) {
    187188    v->onclose_hook(v, v->onclose_hook_data);
     
    189190    v->onclose_hook_data = NULL;
    190191  }
     192  if (v->window) {
     193    g_signal_handler_disconnect(v->window, v->sig_redraw_id);
     194    g_object_unref(v->window);
     195    v->window = NULL;
     196  }
    191197  owl_fmtext_cleanup(&(v->fmtext));
     198  owl_free(v);
    192199}
Note: See TracChangeset for help on using the changeset viewer.