Changeset 68f63a2 for popwin.c


Ignore:
Timestamp:
May 29, 2010, 1:14:57 PM (14 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.7, release-1.8, release-1.9
Children:
1383b58
Parents:
7c8811c
git-author:
David Benjamin <davidben@mit.edu> (05/27/10 02:49:57)
git-committer:
David Benjamin <davidben@mit.edu> (05/29/10 13:14:57)
Message:
Port owl_viewwin to owl_window

A number of hacks. This is just a test run of the API.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • popwin.c

    r0881cdd r68f63a2  
    1111int owl_popwin_up(owl_popwin *pw)
    1212{
    13   int glines, gcols, startcol, startline;
    14   WINDOW *popwin, *borderwin;
     13  /* make them zero-size for now */
     14  pw->border = owl_window_new(0, 0, 0, 0, 0);
     15  pw->content = owl_window_new(pw->border, 0, 0, 0, 0);
    1516
    16   /* calculate the size of the popwin */
    17   glines=owl_global_get_lines(&g);
    18   gcols=owl_global_get_cols(&g);
     17  owl_window_set_redraw_cb(pw->border, owl_popwin_draw_border, pw, 0);
     18  owl_window_set_resize_cb(pw->border, owl_popwin_resize_content, pw, 0);
     19  /* HACK */
     20  owl_window_set_resize_cb(owl_window_get_screen(), owl_popwin_reposition, pw, 0);
    1921
    20   pw->lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2;
    21   startline = (glines-pw->lines)/2;
     22  /* calculate position, THEN map the windows maybe setting a resize hook
     23   * should just cause it to get called? */
     24  owl_popwin_reposition(owl_window_get_screen(), pw);
     25  owl_window_map(pw->border, 1);
    2226
    23   pw->cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2;
    24   startcol = (gcols-pw->cols)/2;
     27  pw->active=1;
     28  return(0);
     29}
    2530
    26   borderwin = newwin(pw->lines, pw->cols, startline, startcol);
    27   pw->borderpanel = new_panel(borderwin);
    28   popwin = newwin(pw->lines-2, pw->cols-2, startline+1, startcol+1);
    29   pw->poppanel = new_panel(popwin);
     31void owl_popwin_reposition(owl_window *screen, void *user_data)
     32{
     33  owl_popwin *pw = user_data;
     34  int lines, cols, startline, startcol;
     35  int glines, gcols;
    3036
    31   werase(popwin);
    32   werase(borderwin);
     37  owl_window_get_position(screen, &glines, &gcols, 0, 0);
     38
     39  lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2;
     40  startline = (glines-lines)/2;
     41  cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2;
     42  startcol = (gcols-cols)/2;
     43
     44  owl_window_set_position(pw->border, lines, cols, startline, startcol);
     45}
     46
     47void owl_popwin_resize_content(owl_window *w, void *user_data)
     48{
     49  owl_popwin *pw = user_data;
     50  owl_window_get_position(w, &pw->lines, &pw->cols, 0, 0);
     51  owl_window_set_position(pw->content, pw->lines-2, pw->cols-2, 1, 1);
     52}
     53
     54void owl_popwin_draw_border(owl_window *w, WINDOW *borderwin, void *user_data)
     55{
     56  owl_popwin *pw = user_data;
    3357  if (owl_global_is_fancylines(&g)) {
    3458    box(borderwin, 0, 0);
     
    4468    waddch(borderwin, '+');
    4569  }
    46    
    47   owl_global_set_needrefresh(&g);
    48   pw->active=1;
    49   return(0);
    5070}
    5171
    5272int owl_popwin_close(owl_popwin *pw)
    5373{
    54   WINDOW *popwin, *borderwin;
    55 
    56   popwin = panel_window(pw->poppanel);
    57   borderwin = panel_window(pw->borderpanel);
    58 
    59   del_panel(pw->poppanel);
    60   del_panel(pw->borderpanel);
    61   delwin(popwin);
    62   delwin(borderwin);
    63 
     74  owl_window_delete(pw->border);
     75  pw->border = 0;
     76  pw->content = 0;
    6477  pw->active=0;
    65   owl_global_set_needrefresh(&g);
     78  owl_window_set_resize_cb(owl_window_get_screen(), 0, 0, 0);
    6679  return(0);
    6780}
     
    7285}
    7386
    74 WINDOW *owl_popwin_get_curswin(const owl_popwin *pw)
     87owl_window *owl_popwin_get_content(const owl_popwin *pw)
    7588{
    76   return panel_window(pw->poppanel);
     89  return pw->content;
    7790}
    7891
Note: See TracChangeset for help on using the changeset viewer.