| [7d4fbcd] | 1 | #include "owl.h" |
|---|
| 2 | |
|---|
| [1aee7d9] | 3 | static const char fileIdent[] = "$Id$"; |
|---|
| 4 | |
|---|
| [b2b0773] | 5 | int owl_popwin_init(owl_popwin *pw) |
|---|
| 6 | { |
|---|
| [7d4fbcd] | 7 | pw->active=0; |
|---|
| 8 | pw->needsfirstrefresh=0; |
|---|
| 9 | pw->lines=0; |
|---|
| 10 | pw->cols=0; |
|---|
| 11 | return(0); |
|---|
| 12 | } |
|---|
| 13 | |
|---|
| [b2b0773] | 14 | int owl_popwin_up(owl_popwin *pw) |
|---|
| 15 | { |
|---|
| [7d4fbcd] | 16 | int glines, gcols, startcol, startline; |
|---|
| 17 | |
|---|
| 18 | /* calculate the size of the popwin */ |
|---|
| 19 | glines=owl_global_get_lines(&g); |
|---|
| 20 | gcols=owl_global_get_cols(&g); |
|---|
| 21 | |
|---|
| [fe67f1f] | 22 | pw->lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2; |
|---|
| 23 | startline = (glines-pw->lines)/2; |
|---|
| 24 | |
|---|
| [818a073] | 25 | pw->cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2; |
|---|
| [fe67f1f] | 26 | startcol = (gcols-pw->cols)/2; |
|---|
| [7d4fbcd] | 27 | |
|---|
| 28 | pw->borderwin=newwin(pw->lines, pw->cols, startline, startcol); |
|---|
| 29 | pw->popwin=newwin(pw->lines-2, pw->cols-2, startline+1, startcol+1); |
|---|
| 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); |
|---|
| [c15bbfb] | 38 | if (owl_global_is_fancylines(&g)) { |
|---|
| 39 | box(pw->borderwin, 0, 0); |
|---|
| 40 | } else { |
|---|
| 41 | box(pw->borderwin, '|', '-'); |
|---|
| [ad96951] | 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, '+'); |
|---|
| [c15bbfb] | 50 | } |
|---|
| 51 | |
|---|
| [7d4fbcd] | 52 | wnoutrefresh(pw->popwin); |
|---|
| 53 | wnoutrefresh(pw->borderwin); |
|---|
| 54 | owl_global_set_needrefresh(&g); |
|---|
| 55 | pw->active=1; |
|---|
| 56 | return(0); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| [b2b0773] | 59 | int owl_popwin_close(owl_popwin *pw) |
|---|
| 60 | { |
|---|
| [7d4fbcd] | 61 | delwin(pw->popwin); |
|---|
| 62 | delwin(pw->borderwin); |
|---|
| 63 | pw->active=0; |
|---|
| 64 | owl_global_set_needrefresh(&g); |
|---|
| 65 | owl_mainwin_redisplay(owl_global_get_mainwin(&g)); |
|---|
| 66 | owl_function_full_redisplay(&g); |
|---|
| 67 | return(0); |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| [b2b0773] | 70 | int owl_popwin_is_active(owl_popwin *pw) |
|---|
| 71 | { |
|---|
| [7d4fbcd] | 72 | if (pw->active==1) return(1); |
|---|
| 73 | return(0); |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| [b2b0773] | 76 | /* this will refresh the border as well as the text area */ |
|---|
| 77 | int owl_popwin_refresh(owl_popwin *pw) |
|---|
| 78 | { |
|---|
| [7d4fbcd] | 79 | touchwin(pw->borderwin); |
|---|
| 80 | touchwin(pw->popwin); |
|---|
| 81 | |
|---|
| 82 | wnoutrefresh(pw->borderwin); |
|---|
| 83 | wnoutrefresh(pw->popwin); |
|---|
| 84 | owl_global_set_needrefresh(&g); |
|---|
| 85 | return(0); |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| [b2b0773] | 88 | WINDOW *owl_popwin_get_curswin(owl_popwin *pw) |
|---|
| 89 | { |
|---|
| [7d4fbcd] | 90 | return(pw->popwin); |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| [b2b0773] | 93 | int owl_popwin_get_lines(owl_popwin *pw) |
|---|
| 94 | { |
|---|
| [7d4fbcd] | 95 | return(pw->lines-2); |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| [b2b0773] | 98 | int owl_popwin_get_cols(owl_popwin *pw) |
|---|
| 99 | { |
|---|
| [7d4fbcd] | 100 | return(pw->cols-2); |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| [b2b0773] | 103 | int owl_popwin_needs_first_refresh(owl_popwin *pw) |
|---|
| 104 | { |
|---|
| [7d4fbcd] | 105 | if (pw->needsfirstrefresh) return(1); |
|---|
| 106 | return(0); |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| [b2b0773] | 109 | void owl_popwin_no_needs_first_refresh(owl_popwin *pw) |
|---|
| 110 | { |
|---|
| [7d4fbcd] | 111 | pw->needsfirstrefresh=0; |
|---|
| 112 | } |
|---|