source: popwin.c @ df0d93a

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