source: popwin.c @ a038c2a3

release-1.10release-1.6release-1.7release-1.8release-1.9
Last change on this file since a038c2a3 was dffb8b8, checked in by David Benjamin <davidben@mit.edu>, 14 years ago
Drop popwin and borderwin from owl_popwin Again, the WINDOWs are effectively owned by their PANELs, so we remove the extra reference to avoid possible inconsistency. Because del_panel fails to delwin, we need a little dance to delete both at once. A future abstraction layer should take care of that.
  • Property mode set to 100644
File size: 2.5 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;
[dffb8b8]15  WINDOW *popwin, *borderwin;
[7d4fbcd]16
17  /* calculate the size of the popwin */
18  glines=owl_global_get_lines(&g);
19  gcols=owl_global_get_cols(&g);
20
[fe67f1f]21  pw->lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2;
22  startline = (glines-pw->lines)/2;
23
[818a073]24  pw->cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2;
[fe67f1f]25  startcol = (gcols-pw->cols)/2;
[7d4fbcd]26
[dffb8b8]27  borderwin = newwin(pw->lines, pw->cols, startline, startcol);
28  pw->borderpanel = new_panel(borderwin);
29  popwin = newwin(pw->lines-2, pw->cols-2, startline+1, startcol+1);
30  pw->poppanel = new_panel(popwin);
[7d4fbcd]31  pw->needsfirstrefresh=1;
32 
[dffb8b8]33  meta(popwin,TRUE);
34  nodelay(popwin, 1);
35  keypad(popwin, TRUE);
[7d4fbcd]36
[dffb8b8]37  werase(popwin);
38  werase(borderwin);
[c15bbfb]39  if (owl_global_is_fancylines(&g)) {
[dffb8b8]40    box(borderwin, 0, 0);
[c15bbfb]41  } else {
[dffb8b8]42    box(borderwin, '|', '-');
43    wmove(borderwin, 0, 0);
44    waddch(borderwin, '+');
45    wmove(borderwin, pw->lines-1, 0);
46    waddch(borderwin, '+');
47    wmove(borderwin, pw->lines-1, pw->cols-1);
48    waddch(borderwin, '+');
49    wmove(borderwin, 0, pw->cols-1);
50    waddch(borderwin, '+');
[c15bbfb]51  }
52   
[8ae2de9]53  update_panels();
[7d4fbcd]54  owl_global_set_needrefresh(&g);
55  pw->active=1;
56  return(0);
57}
58
[b2b0773]59int owl_popwin_close(owl_popwin *pw)
60{
[dffb8b8]61  WINDOW *popwin, *borderwin;
62
63  popwin = panel_window(pw->poppanel);
64  borderwin = panel_window(pw->borderpanel);
65
[8ae2de9]66  del_panel(pw->poppanel);
67  del_panel(pw->borderpanel);
[dffb8b8]68  delwin(popwin);
69  delwin(borderwin);
70
[7d4fbcd]71  pw->active=0;
72  owl_global_set_needrefresh(&g);
73  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
[8240bce]74  owl_function_full_redisplay();
[7d4fbcd]75  return(0);
76}
77
[9c01a5e]78int owl_popwin_is_active(const owl_popwin *pw)
[b2b0773]79{
[7d4fbcd]80  if (pw->active==1) return(1);
81  return(0);
82}
83
[b2b0773]84/* this will refresh the border as well as the text area */
[9c01a5e]85int owl_popwin_refresh(const owl_popwin *pw)
[b2b0773]86{
[8ae2de9]87  update_panels();
[7d4fbcd]88  owl_global_set_needrefresh(&g);
89  return(0);
90}
91
[9c01a5e]92WINDOW *owl_popwin_get_curswin(const owl_popwin *pw)
[b2b0773]93{
[dffb8b8]94  return panel_window(pw->poppanel);
[7d4fbcd]95}
96
[9c01a5e]97int owl_popwin_get_lines(const owl_popwin *pw)
[b2b0773]98{
[7d4fbcd]99  return(pw->lines-2);
100}
101
[9c01a5e]102int owl_popwin_get_cols(const owl_popwin *pw)
[b2b0773]103{
[7d4fbcd]104  return(pw->cols-2);
105}
106
[9c01a5e]107int owl_popwin_needs_first_refresh(const owl_popwin *pw)
[b2b0773]108{
[7d4fbcd]109  if (pw->needsfirstrefresh) return(1);
110  return(0);
111}
112
[b2b0773]113void owl_popwin_no_needs_first_refresh(owl_popwin *pw)
114{
[7d4fbcd]115  pw->needsfirstrefresh=0;
116}
Note: See TracBrowser for help on using the repository browser.