[7d4fbcd] | 1 | #include "owl.h" |
---|
| 2 | |
---|
[b2b0773] | 3 | int owl_popwin_init(owl_popwin *pw) |
---|
| 4 | { |
---|
[7d4fbcd] | 5 | pw->active=0; |
---|
| 6 | pw->needsfirstrefresh=0; |
---|
| 7 | pw->lines=0; |
---|
| 8 | pw->cols=0; |
---|
| 9 | return(0); |
---|
| 10 | } |
---|
| 11 | |
---|
[b2b0773] | 12 | int owl_popwin_up(owl_popwin *pw) |
---|
| 13 | { |
---|
[7d4fbcd] | 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 | |
---|
[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 | |
---|
| 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); |
---|
[c15bbfb] | 36 | if (owl_global_is_fancylines(&g)) { |
---|
| 37 | box(pw->borderwin, 0, 0); |
---|
| 38 | } else { |
---|
| 39 | box(pw->borderwin, '|', '-'); |
---|
[ad96951] | 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, '+'); |
---|
[c15bbfb] | 48 | } |
---|
| 49 | |
---|
[7d4fbcd] | 50 | wnoutrefresh(pw->popwin); |
---|
| 51 | wnoutrefresh(pw->borderwin); |
---|
| 52 | owl_global_set_needrefresh(&g); |
---|
| 53 | pw->active=1; |
---|
| 54 | return(0); |
---|
| 55 | } |
---|
| 56 | |
---|
[b2b0773] | 57 | int owl_popwin_close(owl_popwin *pw) |
---|
| 58 | { |
---|
[7d4fbcd] | 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 | |
---|
[b2b0773] | 68 | int owl_popwin_is_active(owl_popwin *pw) |
---|
| 69 | { |
---|
[7d4fbcd] | 70 | if (pw->active==1) return(1); |
---|
| 71 | return(0); |
---|
| 72 | } |
---|
| 73 | |
---|
[b2b0773] | 74 | /* this will refresh the border as well as the text area */ |
---|
| 75 | int owl_popwin_refresh(owl_popwin *pw) |
---|
| 76 | { |
---|
[7d4fbcd] | 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 | |
---|
[b2b0773] | 86 | WINDOW *owl_popwin_get_curswin(owl_popwin *pw) |
---|
| 87 | { |
---|
[7d4fbcd] | 88 | return(pw->popwin); |
---|
| 89 | } |
---|
| 90 | |
---|
[b2b0773] | 91 | int owl_popwin_get_lines(owl_popwin *pw) |
---|
| 92 | { |
---|
[7d4fbcd] | 93 | return(pw->lines-2); |
---|
| 94 | } |
---|
| 95 | |
---|
[b2b0773] | 96 | int owl_popwin_get_cols(owl_popwin *pw) |
---|
| 97 | { |
---|
[7d4fbcd] | 98 | return(pw->cols-2); |
---|
| 99 | } |
---|
| 100 | |
---|
[b2b0773] | 101 | int owl_popwin_needs_first_refresh(owl_popwin *pw) |
---|
| 102 | { |
---|
[7d4fbcd] | 103 | if (pw->needsfirstrefresh) return(1); |
---|
| 104 | return(0); |
---|
| 105 | } |
---|
| 106 | |
---|
[b2b0773] | 107 | void owl_popwin_no_needs_first_refresh(owl_popwin *pw) |
---|
| 108 | { |
---|
[7d4fbcd] | 109 | pw->needsfirstrefresh=0; |
---|
| 110 | } |
---|