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>, 15 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
RevLine 
[7d4fbcd]1#include "owl.h"
2
[b2b0773]3int owl_popwin_init(owl_popwin *pw)
4{
[7d4fbcd]5  pw->active=0;
6  pw->needsfirstrefresh=0;
7  pw->lines=0;
8  pw->cols=0;
9  return(0);
10}
11
[b2b0773]12int owl_popwin_up(owl_popwin *pw)
13{
[7d4fbcd]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
[fe67f1f]20  pw->lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2;
21  startline = (glines-pw->lines)/2;
22
[818a073]23  pw->cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2;
[fe67f1f]24  startcol = (gcols-pw->cols)/2;
[7d4fbcd]25
26  pw->borderwin=newwin(pw->lines, pw->cols, startline, startcol);
[8ae2de9]27  pw->borderpanel = new_panel(pw->borderwin);
[7d4fbcd]28  pw->popwin=newwin(pw->lines-2, pw->cols-2, startline+1, startcol+1);
[8ae2de9]29  pw->poppanel = new_panel(pw->popwin);
[7d4fbcd]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);
[c15bbfb]38  if (owl_global_is_fancylines(&g)) {
39    box(pw->borderwin, 0, 0);
40  } else {
41    box(pw->borderwin, '|', '-');
[ad96951]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, '+');
[c15bbfb]50  }
51   
[8ae2de9]52  update_panels();
[7d4fbcd]53  owl_global_set_needrefresh(&g);
54  pw->active=1;
55  return(0);
56}
57
[b2b0773]58int owl_popwin_close(owl_popwin *pw)
59{
[8ae2de9]60  del_panel(pw->poppanel);
61  del_panel(pw->borderpanel);
[7d4fbcd]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));
[8240bce]67  owl_function_full_redisplay();
[7d4fbcd]68  return(0);
69}
70
[9c01a5e]71int owl_popwin_is_active(const owl_popwin *pw)
[b2b0773]72{
[7d4fbcd]73  if (pw->active==1) return(1);
74  return(0);
75}
76
[b2b0773]77/* this will refresh the border as well as the text area */
[9c01a5e]78int owl_popwin_refresh(const owl_popwin *pw)
[b2b0773]79{
[8ae2de9]80  update_panels();
[7d4fbcd]81  owl_global_set_needrefresh(&g);
82  return(0);
83}
84
[9c01a5e]85WINDOW *owl_popwin_get_curswin(const owl_popwin *pw)
[b2b0773]86{
[7d4fbcd]87  return(pw->popwin);
88}
89
[9c01a5e]90int owl_popwin_get_lines(const owl_popwin *pw)
[b2b0773]91{
[7d4fbcd]92  return(pw->lines-2);
93}
94
[9c01a5e]95int owl_popwin_get_cols(const owl_popwin *pw)
[b2b0773]96{
[7d4fbcd]97  return(pw->cols-2);
98}
99
[9c01a5e]100int owl_popwin_needs_first_refresh(const owl_popwin *pw)
[b2b0773]101{
[7d4fbcd]102  if (pw->needsfirstrefresh) return(1);
103  return(0);
104}
105
[b2b0773]106void owl_popwin_no_needs_first_refresh(owl_popwin *pw)
107{
[7d4fbcd]108  pw->needsfirstrefresh=0;
109}
Note: See TracBrowser for help on using the repository browser.