source: popwin.c @ ca9142e

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since ca9142e was 818a073, checked in by James M. Kretchmar <kretch@mit.edu>, 20 years ago
Tweaked the columns parameter for popup sizing
  • Property mode set to 100644
File size: 2.7 KB
Line 
1#include "owl.h"
2
3static const char fileIdent[] = "$Id$";
4
5int owl_popwin_init(owl_popwin *pw)
6{
7  pw->active=0;
8  pw->needsfirstrefresh=0;
9  pw->lines=0;
10  pw->cols=0;
11  return(0);
12}
13
14int owl_popwin_up(owl_popwin *pw)
15{
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
22  pw->lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2;
23  startline = (glines-pw->lines)/2;
24
25  pw->cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2;
26  startcol = (gcols-pw->cols)/2;
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);
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  wnoutrefresh(pw->popwin);
53  wnoutrefresh(pw->borderwin);
54  owl_global_set_needrefresh(&g);
55  pw->active=1;
56  return(0);
57}
58
59int owl_popwin_display_text(owl_popwin *pw, char *text)
60{
61  waddstr(pw->popwin, text);
62  wnoutrefresh(pw->popwin);
63  touchwin(pw->borderwin);
64  wnoutrefresh(pw->borderwin);
65  owl_global_set_needrefresh(&g);
66  return(0);
67}             
68
69int owl_popwin_close(owl_popwin *pw)
70{
71  delwin(pw->popwin);
72  delwin(pw->borderwin);
73  pw->active=0;
74  owl_global_set_needrefresh(&g);
75  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
76  owl_function_full_redisplay(&g);
77  return(0);
78}
79
80int owl_popwin_is_active(owl_popwin *pw)
81{
82  if (pw->active==1) return(1);
83  return(0);
84}
85
86/* this will refresh the border as well as the text area */
87int owl_popwin_refresh(owl_popwin *pw)
88{
89  touchwin(pw->borderwin);
90  touchwin(pw->popwin);
91
92  wnoutrefresh(pw->borderwin);
93  wnoutrefresh(pw->popwin);
94  owl_global_set_needrefresh(&g);
95  return(0);
96}
97
98void owl_popwin_set_handler(owl_popwin *pw, void (*func)(int ch))
99{
100  pw->handler=func;
101}
102
103void owl_popwin_unset_handler(owl_popwin *pw)
104{
105  pw->handler=NULL;
106}
107
108WINDOW *owl_popwin_get_curswin(owl_popwin *pw)
109{
110  return(pw->popwin);
111}
112
113int owl_popwin_get_lines(owl_popwin *pw)
114{
115  return(pw->lines-2);
116}
117
118int owl_popwin_get_cols(owl_popwin *pw)
119{
120  return(pw->cols-2);
121}
122
123int owl_popwin_needs_first_refresh(owl_popwin *pw)
124{
125  if (pw->needsfirstrefresh) return(1);
126  return(0);
127}
128
129void owl_popwin_no_needs_first_refresh(owl_popwin *pw)
130{
131  pw->needsfirstrefresh=0;
132}
Note: See TracBrowser for help on using the repository browser.