source: popwin.c @ 2ee9e8d

release-1.10release-1.6release-1.7release-1.8release-1.9
Last change on this file since 2ee9e8d was dffb8b8, checked in by David Benjamin <davidben@mit.edu>, 14 years ago
Drop popwin and borderwin from owl_popwin Again, the WINDOWs are effectively owned by their PANELs, so we remove the extra reference to avoid possible inconsistency. Because del_panel fails to delwin, we need a little dance to delete both at once. A future abstraction layer should take care of that.
  • Property mode set to 100644
File size: 2.5 KB
Line 
1#include "owl.h"
2
3int owl_popwin_init(owl_popwin *pw)
4{
5  pw->active=0;
6  pw->needsfirstrefresh=0;
7  pw->lines=0;
8  pw->cols=0;
9  return(0);
10}
11
12int owl_popwin_up(owl_popwin *pw)
13{
14  int glines, gcols, startcol, startline;
15  WINDOW *popwin, *borderwin;
16
17  /* calculate the size of the popwin */
18  glines=owl_global_get_lines(&g);
19  gcols=owl_global_get_cols(&g);
20
21  pw->lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2;
22  startline = (glines-pw->lines)/2;
23
24  pw->cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2;
25  startcol = (gcols-pw->cols)/2;
26
27  borderwin = newwin(pw->lines, pw->cols, startline, startcol);
28  pw->borderpanel = new_panel(borderwin);
29  popwin = newwin(pw->lines-2, pw->cols-2, startline+1, startcol+1);
30  pw->poppanel = new_panel(popwin);
31  pw->needsfirstrefresh=1;
32 
33  meta(popwin,TRUE);
34  nodelay(popwin, 1);
35  keypad(popwin, TRUE);
36
37  werase(popwin);
38  werase(borderwin);
39  if (owl_global_is_fancylines(&g)) {
40    box(borderwin, 0, 0);
41  } else {
42    box(borderwin, '|', '-');
43    wmove(borderwin, 0, 0);
44    waddch(borderwin, '+');
45    wmove(borderwin, pw->lines-1, 0);
46    waddch(borderwin, '+');
47    wmove(borderwin, pw->lines-1, pw->cols-1);
48    waddch(borderwin, '+');
49    wmove(borderwin, 0, pw->cols-1);
50    waddch(borderwin, '+');
51  }
52   
53  update_panels();
54  owl_global_set_needrefresh(&g);
55  pw->active=1;
56  return(0);
57}
58
59int owl_popwin_close(owl_popwin *pw)
60{
61  WINDOW *popwin, *borderwin;
62
63  popwin = panel_window(pw->poppanel);
64  borderwin = panel_window(pw->borderpanel);
65
66  del_panel(pw->poppanel);
67  del_panel(pw->borderpanel);
68  delwin(popwin);
69  delwin(borderwin);
70
71  pw->active=0;
72  owl_global_set_needrefresh(&g);
73  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
74  owl_function_full_redisplay();
75  return(0);
76}
77
78int owl_popwin_is_active(const owl_popwin *pw)
79{
80  if (pw->active==1) return(1);
81  return(0);
82}
83
84/* this will refresh the border as well as the text area */
85int owl_popwin_refresh(const owl_popwin *pw)
86{
87  update_panels();
88  owl_global_set_needrefresh(&g);
89  return(0);
90}
91
92WINDOW *owl_popwin_get_curswin(const owl_popwin *pw)
93{
94  return panel_window(pw->poppanel);
95}
96
97int owl_popwin_get_lines(const owl_popwin *pw)
98{
99  return(pw->lines-2);
100}
101
102int owl_popwin_get_cols(const owl_popwin *pw)
103{
104  return(pw->cols-2);
105}
106
107int owl_popwin_needs_first_refresh(const owl_popwin *pw)
108{
109  if (pw->needsfirstrefresh) return(1);
110  return(0);
111}
112
113void owl_popwin_no_needs_first_refresh(owl_popwin *pw)
114{
115  pw->needsfirstrefresh=0;
116}
Note: See TracBrowser for help on using the repository browser.