source: popwin.c @ 8830df47

release-1.6release-1.7release-1.8release-1.9
Last change on this file since 8830df47 was 8830df47, checked in by David Benjamin <davidben@mit.edu>, 11 years ago
libpanel makes owl_popwin_refresh unnecessary
  • Property mode set to 100644
File size: 2.3 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
84WINDOW *owl_popwin_get_curswin(const owl_popwin *pw)
85{
86  return panel_window(pw->poppanel);
87}
88
89int owl_popwin_get_lines(const owl_popwin *pw)
90{
91  return(pw->lines-2);
92}
93
94int owl_popwin_get_cols(const owl_popwin *pw)
95{
96  return(pw->cols-2);
97}
98
99int owl_popwin_needs_first_refresh(const owl_popwin *pw)
100{
101  if (pw->needsfirstrefresh) return(1);
102  return(0);
103}
104
105void owl_popwin_no_needs_first_refresh(owl_popwin *pw)
106{
107  pw->needsfirstrefresh=0;
108}
Note: See TracBrowser for help on using the repository browser.