source: popwin.c @ b928b3a

release-1.10release-1.6release-1.7release-1.8release-1.9
Last change on this file since b928b3a was 8ae2de9, checked in by David Benjamin <davidben@mit.edu>, 14 years ago
Attach PANELs to all of our WINDOWs We replace wnoutrefresh with update_panels (except in set cursor; there we have to guarantee that the window is empty.). The viewwin does not get a PANEL because it's weird and currently leeches onto someone else's WINDOW. Resizing is also rather fiddly because panel wants to know about window resizes. Not completely sure I got it right yet. The only library I know of that does something like with with ncurses (libgnt) and they endwin/refresh to resize the screen. Signed-off-by: David Benjamin <davidben@mit.edu>
  • Property mode set to 100644
File size: 2.4 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->borderpanel = new_panel(pw->borderwin);
28  pw->popwin=newwin(pw->lines-2, pw->cols-2, startline+1, startcol+1);
29  pw->poppanel = new_panel(pw->popwin);
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  update_panels();
53  owl_global_set_needrefresh(&g);
54  pw->active=1;
55  return(0);
56}
57
58int owl_popwin_close(owl_popwin *pw)
59{
60  del_panel(pw->poppanel);
61  del_panel(pw->borderpanel);
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();
68  return(0);
69}
70
71int owl_popwin_is_active(const owl_popwin *pw)
72{
73  if (pw->active==1) return(1);
74  return(0);
75}
76
77/* this will refresh the border as well as the text area */
78int owl_popwin_refresh(const owl_popwin *pw)
79{
80  update_panels();
81  owl_global_set_needrefresh(&g);
82  return(0);
83}
84
85WINDOW *owl_popwin_get_curswin(const owl_popwin *pw)
86{
87  return(pw->popwin);
88}
89
90int owl_popwin_get_lines(const owl_popwin *pw)
91{
92  return(pw->lines-2);
93}
94
95int owl_popwin_get_cols(const owl_popwin *pw)
96{
97  return(pw->cols-2);
98}
99
100int owl_popwin_needs_first_refresh(const owl_popwin *pw)
101{
102  if (pw->needsfirstrefresh) return(1);
103  return(0);
104}
105
106void owl_popwin_no_needs_first_refresh(owl_popwin *pw)
107{
108  pw->needsfirstrefresh=0;
109}
Note: See TracBrowser for help on using the repository browser.