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->borderpanel = new_panel(pw->borderwin); |
---|
28 | pw->popwin=newwin(pw->lines-2, pw->cols-2, startline+1, startcol+1); |
---|
29 | pw->poppanel = new_panel(pw->popwin); |
---|
30 | pw->needsfirstrefresh=1; |
---|
31 | |
---|
32 | meta(pw->popwin,TRUE); |
---|
33 | nodelay(pw->popwin, 1); |
---|
34 | keypad(pw->popwin, TRUE); |
---|
35 | |
---|
36 | werase(pw->popwin); |
---|
37 | werase(pw->borderwin); |
---|
38 | if (owl_global_is_fancylines(&g)) { |
---|
39 | box(pw->borderwin, 0, 0); |
---|
40 | } else { |
---|
41 | box(pw->borderwin, '|', '-'); |
---|
42 | wmove(pw->borderwin, 0, 0); |
---|
43 | waddch(pw->borderwin, '+'); |
---|
44 | wmove(pw->borderwin, pw->lines-1, 0); |
---|
45 | waddch(pw->borderwin, '+'); |
---|
46 | wmove(pw->borderwin, pw->lines-1, pw->cols-1); |
---|
47 | waddch(pw->borderwin, '+'); |
---|
48 | wmove(pw->borderwin, 0, pw->cols-1); |
---|
49 | waddch(pw->borderwin, '+'); |
---|
50 | } |
---|
51 | |
---|
52 | update_panels(); |
---|
53 | owl_global_set_needrefresh(&g); |
---|
54 | pw->active=1; |
---|
55 | return(0); |
---|
56 | } |
---|
57 | |
---|
58 | int owl_popwin_close(owl_popwin *pw) |
---|
59 | { |
---|
60 | del_panel(pw->poppanel); |
---|
61 | del_panel(pw->borderpanel); |
---|
62 | delwin(pw->popwin); |
---|
63 | delwin(pw->borderwin); |
---|
64 | pw->active=0; |
---|
65 | owl_global_set_needrefresh(&g); |
---|
66 | owl_mainwin_redisplay(owl_global_get_mainwin(&g)); |
---|
67 | owl_function_full_redisplay(); |
---|
68 | return(0); |
---|
69 | } |
---|
70 | |
---|
71 | int owl_popwin_is_active(const owl_popwin *pw) |
---|
72 | { |
---|
73 | if (pw->active==1) return(1); |
---|
74 | return(0); |
---|
75 | } |
---|
76 | |
---|
77 | /* this will refresh the border as well as the text area */ |
---|
78 | int owl_popwin_refresh(const owl_popwin *pw) |
---|
79 | { |
---|
80 | update_panels(); |
---|
81 | owl_global_set_needrefresh(&g); |
---|
82 | return(0); |
---|
83 | } |
---|
84 | |
---|
85 | WINDOW *owl_popwin_get_curswin(const owl_popwin *pw) |
---|
86 | { |
---|
87 | return(pw->popwin); |
---|
88 | } |
---|
89 | |
---|
90 | int owl_popwin_get_lines(const owl_popwin *pw) |
---|
91 | { |
---|
92 | return(pw->lines-2); |
---|
93 | } |
---|
94 | |
---|
95 | int owl_popwin_get_cols(const owl_popwin *pw) |
---|
96 | { |
---|
97 | return(pw->cols-2); |
---|
98 | } |
---|
99 | |
---|
100 | int owl_popwin_needs_first_refresh(const owl_popwin *pw) |
---|
101 | { |
---|
102 | if (pw->needsfirstrefresh) return(1); |
---|
103 | return(0); |
---|
104 | } |
---|
105 | |
---|
106 | void owl_popwin_no_needs_first_refresh(owl_popwin *pw) |
---|
107 | { |
---|
108 | pw->needsfirstrefresh=0; |
---|
109 | } |
---|