source: popwin.c @ fa4562c

release-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since fa4562c was d43edd2, checked in by Anders Kaseorg <andersk@mit.edu>, 15 years ago
Death to RCS keywords. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
  • Property mode set to 100644
File size: 2.3 KB
Line 
1#include "owl.h"
2
3int 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
12int 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->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);
36  if (owl_global_is_fancylines(&g)) {
37    box(pw->borderwin, 0, 0);
38  } else {
39    box(pw->borderwin, '|', '-');
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, '+');
48  }
49   
50  wnoutrefresh(pw->popwin);
51  wnoutrefresh(pw->borderwin);
52  owl_global_set_needrefresh(&g);
53  pw->active=1;
54  return(0);
55}
56
57int owl_popwin_close(owl_popwin *pw)
58{
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
68int owl_popwin_is_active(owl_popwin *pw)
69{
70  if (pw->active==1) return(1);
71  return(0);
72}
73
74/* this will refresh the border as well as the text area */
75int owl_popwin_refresh(owl_popwin *pw)
76{
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
86WINDOW *owl_popwin_get_curswin(owl_popwin *pw)
87{
88  return(pw->popwin);
89}
90
91int owl_popwin_get_lines(owl_popwin *pw)
92{
93  return(pw->lines-2);
94}
95
96int owl_popwin_get_cols(owl_popwin *pw)
97{
98  return(pw->cols-2);
99}
100
101int owl_popwin_needs_first_refresh(owl_popwin *pw)
102{
103  if (pw->needsfirstrefresh) return(1);
104  return(0);
105}
106
107void owl_popwin_no_needs_first_refresh(owl_popwin *pw)
108{
109  pw->needsfirstrefresh=0;
110}
Note: See TracBrowser for help on using the repository browser.