1 | #include "owl.h" |
---|
2 | |
---|
3 | int 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 | |
---|
12 | int owl_popwin_up(owl_popwin *pw) |
---|
13 | { |
---|
14 | int glines, gcols, startcol, startline; |
---|
15 | |
---|
16 | /* calculate the size of the popwin */ |
---|
17 | glines=owl_global_get_lines(&g); |
---|
18 | gcols=owl_global_get_cols(&g); |
---|
19 | |
---|
20 | pw->lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2; |
---|
21 | startline = (glines-pw->lines)/2; |
---|
22 | |
---|
23 | pw->cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2; |
---|
24 | startcol = (gcols-pw->cols)/2; |
---|
25 | |
---|
26 | pw->borderwin=newwin(pw->lines, pw->cols, startline, startcol); |
---|
27 | pw->popwin=newwin(pw->lines-2, pw->cols-2, startline+1, startcol+1); |
---|
28 | pw->needsfirstrefresh=1; |
---|
29 | |
---|
30 | meta(pw->popwin,TRUE); |
---|
31 | nodelay(pw->popwin, 1); |
---|
32 | keypad(pw->popwin, TRUE); |
---|
33 | |
---|
34 | werase(pw->popwin); |
---|
35 | werase(pw->borderwin); |
---|
36 | if (owl_global_is_fancylines(&g)) { |
---|
37 | box(pw->borderwin, 0, 0); |
---|
38 | } else { |
---|
39 | box(pw->borderwin, '|', '-'); |
---|
40 | wmove(pw->borderwin, 0, 0); |
---|
41 | waddch(pw->borderwin, '+'); |
---|
42 | wmove(pw->borderwin, pw->lines-1, 0); |
---|
43 | waddch(pw->borderwin, '+'); |
---|
44 | wmove(pw->borderwin, pw->lines-1, pw->cols-1); |
---|
45 | waddch(pw->borderwin, '+'); |
---|
46 | wmove(pw->borderwin, 0, pw->cols-1); |
---|
47 | waddch(pw->borderwin, '+'); |
---|
48 | } |
---|
49 | |
---|
50 | wnoutrefresh(pw->popwin); |
---|
51 | wnoutrefresh(pw->borderwin); |
---|
52 | owl_global_set_needrefresh(&g); |
---|
53 | pw->active=1; |
---|
54 | return(0); |
---|
55 | } |
---|
56 | |
---|
57 | int owl_popwin_close(owl_popwin *pw) |
---|
58 | { |
---|
59 | delwin(pw->popwin); |
---|
60 | delwin(pw->borderwin); |
---|
61 | pw->active=0; |
---|
62 | owl_global_set_needrefresh(&g); |
---|
63 | owl_mainwin_redisplay(owl_global_get_mainwin(&g)); |
---|
64 | owl_function_full_redisplay(&g); |
---|
65 | return(0); |
---|
66 | } |
---|
67 | |
---|
68 | int owl_popwin_is_active(const owl_popwin *pw) |
---|
69 | { |
---|
70 | if (pw->active==1) return(1); |
---|
71 | return(0); |
---|
72 | } |
---|
73 | |
---|
74 | /* this will refresh the border as well as the text area */ |
---|
75 | int owl_popwin_refresh(const owl_popwin *pw) |
---|
76 | { |
---|
77 | touchwin(pw->borderwin); |
---|
78 | touchwin(pw->popwin); |
---|
79 | |
---|
80 | wnoutrefresh(pw->borderwin); |
---|
81 | wnoutrefresh(pw->popwin); |
---|
82 | owl_global_set_needrefresh(&g); |
---|
83 | return(0); |
---|
84 | } |
---|
85 | |
---|
86 | WINDOW *owl_popwin_get_curswin(const owl_popwin *pw) |
---|
87 | { |
---|
88 | return(pw->popwin); |
---|
89 | } |
---|
90 | |
---|
91 | int owl_popwin_get_lines(const owl_popwin *pw) |
---|
92 | { |
---|
93 | return(pw->lines-2); |
---|
94 | } |
---|
95 | |
---|
96 | int owl_popwin_get_cols(const owl_popwin *pw) |
---|
97 | { |
---|
98 | return(pw->cols-2); |
---|
99 | } |
---|
100 | |
---|
101 | int owl_popwin_needs_first_refresh(const owl_popwin *pw) |
---|
102 | { |
---|
103 | if (pw->needsfirstrefresh) return(1); |
---|
104 | return(0); |
---|
105 | } |
---|
106 | |
---|
107 | void owl_popwin_no_needs_first_refresh(owl_popwin *pw) |
---|
108 | { |
---|
109 | pw->needsfirstrefresh=0; |
---|
110 | } |
---|