Changelog the last few changes.
[screen-lua.git] / src / viewport.c
blobf1607d541600ebb803f08f777331e64c89e3ffb9
1 /* Copyright (c) 2008, 2009
2 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
3 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
4 * Micah Cowan (micah@cowan.name)
5 * Sadrul Habib Chowdhury (sadrul@users.sourceforge.net)
6 * Copyright (c) 1993-2002, 2003, 2005, 2006, 2007
7 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
8 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
9 * Copyright (c) 1987 Oliver Laumann
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3, or (at your option)
14 * any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program (see the file COPYING); if not, see
23 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 ****************************************************************
29 #include "config.h"
30 #include "screen.h"
31 #include "extern.h"
32 #include "viewport.h"
34 extern struct display *display;
36 int
37 RethinkDisplayViewports()
39 struct canvas *cv;
40 struct viewport *vp, *vpn;
42 /* free old viewports */
43 for (cv = display->d_cvlist; cv; cv = cv->c_next)
45 for (vp = cv->c_vplist; vp; vp = vpn)
47 vp->v_canvas = 0;
48 vpn = vp->v_next;
49 bzero((char *)vp, sizeof(*vp));
50 free(vp);
52 cv->c_vplist = 0;
54 display->d_vpxmin = -1;
55 display->d_vpxmax = -1;
57 for (cv = display->d_cvlist; cv; cv = cv->c_next)
59 if ((vp = (struct viewport *)malloc(sizeof *vp)) == 0)
60 return -1;
61 #ifdef HOLE
62 vp->v_canvas = cv;
63 vp->v_xs = cv->c_xs;
64 vp->v_ys = (cv->c_ys + cv->c_ye) / 2;
65 vp->v_xe = cv->c_xe;
66 vp->v_ye = cv->c_ye;
67 vp->v_xoff = cv->c_xoff;
68 vp->v_yoff = cv->c_yoff;
69 vp->v_next = cv->c_vplist;
70 cv->c_vplist = vp;
72 if ((vp = (struct viewport *)malloc(sizeof *vp)) == 0)
73 return -1;
74 vp->v_canvas = cv;
75 vp->v_xs = (cv->c_xs + cv->c_xe) / 2;
76 vp->v_ys = (3 * cv->c_ys + cv->c_ye) / 4;
77 vp->v_xe = cv->c_xe;
78 vp->v_ye = (cv->c_ys + cv->c_ye) / 2 - 1;
79 vp->v_xoff = cv->c_xoff;
80 vp->v_yoff = cv->c_yoff;
81 vp->v_next = cv->c_vplist;
82 cv->c_vplist = vp;
84 if ((vp = (struct viewport *)malloc(sizeof *vp)) == 0)
85 return -1;
86 vp->v_canvas = cv;
87 vp->v_xs = cv->c_xs;
88 vp->v_ys = (3 * cv->c_ys + cv->c_ye) / 4;
89 vp->v_xe = (3 * cv->c_xs + cv->c_xe) / 4 - 1;
90 vp->v_ye = (cv->c_ys + cv->c_ye) / 2 - 1;
91 vp->v_xoff = cv->c_xoff;
92 vp->v_yoff = cv->c_yoff;
93 vp->v_next = cv->c_vplist;
94 cv->c_vplist = vp;
96 if ((vp = (struct viewport *)malloc(sizeof *vp)) == 0)
97 return -1;
98 vp->v_canvas = cv;
99 vp->v_xs = cv->c_xs;
100 vp->v_ys = cv->c_ys;
101 vp->v_xe = cv->c_xe;
102 vp->v_ye = (3 * cv->c_ys + cv->c_ye) / 4 - 1;
103 vp->v_xoff = cv->c_xoff;
104 vp->v_yoff = cv->c_yoff;
105 vp->v_next = cv->c_vplist;
106 cv->c_vplist = vp;
107 #else
108 vp->v_canvas = cv;
109 vp->v_xs = cv->c_xs;
110 vp->v_ys = cv->c_ys;
111 vp->v_xe = cv->c_xe;
112 vp->v_ye = cv->c_ye;
113 vp->v_xoff = cv->c_xoff;
114 vp->v_yoff = cv->c_yoff;
115 vp->v_next = cv->c_vplist;
116 cv->c_vplist = vp;
117 #endif
119 if (cv->c_xs < display->d_vpxmin || display->d_vpxmin == -1)
120 display->d_vpxmin = cv->c_xs;
121 if (cv->c_xe > display->d_vpxmax || display->d_vpxmax == -1)
122 display->d_vpxmax = cv->c_xe;
124 return 0;
127 void
128 RethinkViewportOffsets(cv)
129 struct canvas *cv;
131 struct viewport *vp;
133 for (vp = cv->c_vplist; vp; vp = vp->v_next)
135 vp->v_xoff = cv->c_xoff;
136 vp->v_yoff = cv->c_yoff;