source: popwin.c @ 9854278

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 9854278 was ad96951, checked in by James M. Kretchmar <kretch@mit.edu>, 21 years ago
Use '+' for popwin corners when 'fancylines' is off
  • Property mode set to 100644
File size: 2.8 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  if (glines > 24) {
22    pw->lines=glines/2;
23    startline=glines/4;
24  } else {
25    pw->lines=(glines*3)/4;
26    startline=glines/8;
27  }
28
29  pw->cols=(gcols*15)/16;
30  startcol=gcols/32;
31  if (pw->cols > 100) {
32    pw->cols=100;
33    startcol=(gcols-100)/2;
34  }
35
36  pw->borderwin=newwin(pw->lines, pw->cols, startline, startcol);
37  pw->popwin=newwin(pw->lines-2, pw->cols-2, startline+1, startcol+1);
38  pw->needsfirstrefresh=1;
39 
40  meta(pw->popwin,TRUE);
41  nodelay(pw->popwin, 1);
42  keypad(pw->popwin, TRUE);
43
44  werase(pw->popwin);
45  werase(pw->borderwin);
46  if (owl_global_is_fancylines(&g)) {
47    box(pw->borderwin, 0, 0);
48  } else {
49    box(pw->borderwin, '|', '-');
50    wmove(pw->borderwin, 0, 0);
51    waddch(pw->borderwin, '+');
52    wmove(pw->borderwin, pw->lines-1, 0);
53    waddch(pw->borderwin, '+');
54    wmove(pw->borderwin, pw->lines-1, pw->cols-1);
55    waddch(pw->borderwin, '+');
56    wmove(pw->borderwin, 0, pw->cols-1);
57    waddch(pw->borderwin, '+');
58  }
59   
60  wnoutrefresh(pw->popwin);
61  wnoutrefresh(pw->borderwin);
62  owl_global_set_needrefresh(&g);
63  pw->active=1;
64  return(0);
65}
66
67int owl_popwin_display_text(owl_popwin *pw, char *text)
68{
69  waddstr(pw->popwin, text);
70  wnoutrefresh(pw->popwin);
71  touchwin(pw->borderwin);
72  wnoutrefresh(pw->borderwin);
73  owl_global_set_needrefresh(&g);
74  return(0);
75}             
76
77int owl_popwin_close(owl_popwin *pw)
78{
79  delwin(pw->popwin);
80  delwin(pw->borderwin);
81  pw->active=0;
82  owl_global_set_needrefresh(&g);
83  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
84  owl_function_full_redisplay(&g);
85  return(0);
86}
87
88int owl_popwin_is_active(owl_popwin *pw)
89{
90  if (pw->active==1) return(1);
91  return(0);
92}
93
94/* this will refresh the border as well as the text area */
95int owl_popwin_refresh(owl_popwin *pw)
96{
97  touchwin(pw->borderwin);
98  touchwin(pw->popwin);
99
100  wnoutrefresh(pw->borderwin);
101  wnoutrefresh(pw->popwin);
102  owl_global_set_needrefresh(&g);
103  return(0);
104}
105
106void owl_popwin_set_handler(owl_popwin *pw, void (*func)(int ch))
107{
108  pw->handler=func;
109}
110
111void owl_popwin_unset_handler(owl_popwin *pw)
112{
113  pw->handler=NULL;
114}
115
116WINDOW *owl_popwin_get_curswin(owl_popwin *pw)
117{
118  return(pw->popwin);
119}
120
121int owl_popwin_get_lines(owl_popwin *pw)
122{
123  return(pw->lines-2);
124}
125
126int owl_popwin_get_cols(owl_popwin *pw)
127{
128  return(pw->cols-2);
129}
130
131int owl_popwin_needs_first_refresh(owl_popwin *pw)
132{
133  if (pw->needsfirstrefresh) return(1);
134  return(0);
135}
136
137void owl_popwin_no_needs_first_refresh(owl_popwin *pw)
138{
139  pw->needsfirstrefresh=0;
140}
Note: See TracBrowser for help on using the repository browser.