source: popwin.c @ 7d4fbcd

barnowl_perlaimdebianowlrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 7d4fbcd was 7d4fbcd, checked in by James M. Kretchmar <kretch@mit.edu>, 18 years ago
Initial check in
  • Property mode set to 100644
File size: 2.4 KB
Line 
1#include "owl.h"
2
3int owl_popwin_init(owl_popwin *pw) {
4  pw->active=0;
5  pw->needsfirstrefresh=0;
6  pw->lines=0;
7  pw->cols=0;
8  return(0);
9}
10
11int owl_popwin_up(owl_popwin *pw) {
12  int glines, gcols, startcol, startline;
13
14  /* calculate the size of the popwin */
15  glines=owl_global_get_lines(&g);
16  gcols=owl_global_get_cols(&g);
17  if (glines > 24) {
18    pw->lines=glines/2;
19    startline=glines/4;
20  } else {
21    pw->lines=(glines*3)/4;
22    startline=glines/8;
23  }
24
25  pw->cols=(gcols*15)/16;
26  startcol=gcols/32;
27  if (pw->cols > 100) {
28    pw->cols=100;
29    startcol=(gcols-100)/2;
30  }
31
32  pw->borderwin=newwin(pw->lines, pw->cols, startline, startcol);
33  pw->popwin=newwin(pw->lines-2, pw->cols-2, startline+1, startcol+1);
34  pw->needsfirstrefresh=1;
35 
36  meta(pw->popwin,TRUE);
37  nodelay(pw->popwin, 1);
38  keypad(pw->popwin, TRUE);
39
40  werase(pw->popwin);
41  werase(pw->borderwin);
42  box(pw->borderwin, 0, 0);
43  wnoutrefresh(pw->popwin);
44  wnoutrefresh(pw->borderwin);
45  owl_global_set_needrefresh(&g);
46  pw->active=1;
47  return(0);
48}
49
50int owl_popwin_display_text(owl_popwin *pw, char *text) {
51  waddstr(pw->popwin, text);
52  wnoutrefresh(pw->popwin);
53  touchwin(pw->borderwin);
54  wnoutrefresh(pw->borderwin);
55  owl_global_set_needrefresh(&g);
56  return(0);
57}             
58
59int owl_popwin_close(owl_popwin *pw) {
60  delwin(pw->popwin);
61  delwin(pw->borderwin);
62  pw->active=0;
63  owl_global_set_needrefresh(&g);
64  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
65  owl_function_full_redisplay(&g);
66  return(0);
67}
68
69int owl_popwin_is_active(owl_popwin *pw) {
70  if (pw->active==1) return(1);
71  return(0);
72}
73
74int owl_popwin_refresh(owl_popwin *pw) {
75  /* this will refresh the border as well as the text area */
76  touchwin(pw->borderwin);
77  touchwin(pw->popwin);
78
79  wnoutrefresh(pw->borderwin);
80  wnoutrefresh(pw->popwin);
81  owl_global_set_needrefresh(&g);
82  return(0);
83}
84
85void owl_popwin_set_handler(owl_popwin *pw, void (*func)(int ch)) {
86  pw->handler=func;
87}
88
89void owl_popwin_unset_handler(owl_popwin *pw) {
90  pw->handler=NULL;
91}
92
93WINDOW *owl_popwin_get_curswin(owl_popwin *pw) {
94  return(pw->popwin);
95}
96
97int owl_popwin_get_lines(owl_popwin *pw) {
98  return(pw->lines-2);
99}
100
101int owl_popwin_get_cols(owl_popwin *pw) {
102  return(pw->cols-2);
103}
104
105int owl_popwin_needs_first_refresh(owl_popwin *pw) {
106  if (pw->needsfirstrefresh) return(1);
107  return(0);
108}
109
110void owl_popwin_no_needs_first_refresh(owl_popwin *pw) {
111  pw->needsfirstrefresh=0;
112}
Note: See TracBrowser for help on using the repository browser.