[7d4fbcd] | 1 | #include "owl.h" |
---|
| 2 | |
---|
[b2b0773] | 3 | int owl_popwin_init(owl_popwin *pw) |
---|
| 4 | { |
---|
[7d4fbcd] | 5 | pw->active=0; |
---|
| 6 | pw->lines=0; |
---|
| 7 | pw->cols=0; |
---|
| 8 | return(0); |
---|
| 9 | } |
---|
| 10 | |
---|
[b2b0773] | 11 | int owl_popwin_up(owl_popwin *pw) |
---|
| 12 | { |
---|
[7d4fbcd] | 13 | int glines, gcols, startcol, startline; |
---|
[dffb8b8] | 14 | WINDOW *popwin, *borderwin; |
---|
[7d4fbcd] | 15 | |
---|
| 16 | /* calculate the size of the popwin */ |
---|
| 17 | glines=owl_global_get_lines(&g); |
---|
| 18 | gcols=owl_global_get_cols(&g); |
---|
| 19 | |
---|
[fe67f1f] | 20 | pw->lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2; |
---|
| 21 | startline = (glines-pw->lines)/2; |
---|
| 22 | |
---|
[818a073] | 23 | pw->cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2; |
---|
[fe67f1f] | 24 | startcol = (gcols-pw->cols)/2; |
---|
[7d4fbcd] | 25 | |
---|
[dffb8b8] | 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); |
---|
[7d4fbcd] | 30 | |
---|
[dffb8b8] | 31 | werase(popwin); |
---|
| 32 | werase(borderwin); |
---|
[c15bbfb] | 33 | if (owl_global_is_fancylines(&g)) { |
---|
[dffb8b8] | 34 | box(borderwin, 0, 0); |
---|
[c15bbfb] | 35 | } else { |
---|
[dffb8b8] | 36 | box(borderwin, '|', '-'); |
---|
| 37 | wmove(borderwin, 0, 0); |
---|
| 38 | waddch(borderwin, '+'); |
---|
| 39 | wmove(borderwin, pw->lines-1, 0); |
---|
| 40 | waddch(borderwin, '+'); |
---|
| 41 | wmove(borderwin, pw->lines-1, pw->cols-1); |
---|
| 42 | waddch(borderwin, '+'); |
---|
| 43 | wmove(borderwin, 0, pw->cols-1); |
---|
| 44 | waddch(borderwin, '+'); |
---|
[c15bbfb] | 45 | } |
---|
| 46 | |
---|
[7d4fbcd] | 47 | owl_global_set_needrefresh(&g); |
---|
| 48 | pw->active=1; |
---|
| 49 | return(0); |
---|
| 50 | } |
---|
| 51 | |
---|
[b2b0773] | 52 | int owl_popwin_close(owl_popwin *pw) |
---|
| 53 | { |
---|
[dffb8b8] | 54 | WINDOW *popwin, *borderwin; |
---|
| 55 | |
---|
| 56 | popwin = panel_window(pw->poppanel); |
---|
| 57 | borderwin = panel_window(pw->borderpanel); |
---|
| 58 | |
---|
[8ae2de9] | 59 | del_panel(pw->poppanel); |
---|
| 60 | del_panel(pw->borderpanel); |
---|
[dffb8b8] | 61 | delwin(popwin); |
---|
| 62 | delwin(borderwin); |
---|
| 63 | |
---|
[7d4fbcd] | 64 | pw->active=0; |
---|
| 65 | owl_global_set_needrefresh(&g); |
---|
| 66 | return(0); |
---|
| 67 | } |
---|
| 68 | |
---|
[9c01a5e] | 69 | int owl_popwin_is_active(const owl_popwin *pw) |
---|
[b2b0773] | 70 | { |
---|
[06cc8d9] | 71 | return pw->active; |
---|
[7d4fbcd] | 72 | } |
---|
| 73 | |
---|
[9c01a5e] | 74 | WINDOW *owl_popwin_get_curswin(const owl_popwin *pw) |
---|
[b2b0773] | 75 | { |
---|
[dffb8b8] | 76 | return panel_window(pw->poppanel); |
---|
[7d4fbcd] | 77 | } |
---|
| 78 | |
---|
[9c01a5e] | 79 | int owl_popwin_get_lines(const owl_popwin *pw) |
---|
[b2b0773] | 80 | { |
---|
[7d4fbcd] | 81 | return(pw->lines-2); |
---|
| 82 | } |
---|
| 83 | |
---|
[9c01a5e] | 84 | int owl_popwin_get_cols(const owl_popwin *pw) |
---|
[b2b0773] | 85 | { |
---|
[7d4fbcd] | 86 | return(pw->cols-2); |
---|
| 87 | } |
---|