pdcurses/overlay.c

Wed, 20 Jul 2016 13:25:54 +0300

author
Teemu Piippo <teemu@compsta2.com>
date
Wed, 20 Jul 2016 13:25:54 +0300
branch
protocol5
changeset 135
966c09c34ae1
parent 97
2d43f05b284c
permissions
-rw-r--r--

Removed the disconnection change in Interface::handle_input(), not sure where that even came from

97
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
1 /* Public Domain Curses */
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
2
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
3 #include <curspriv.h>
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
4
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
5 RCSID("$Id: overlay.c,v 1.36 2008/07/14 12:35:23 wmcbrine Exp $")
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
6
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
7 /*man-start**************************************************************
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
8
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
9 Name: overlay
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
10
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
11 Synopsis:
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
12 int overlay(const WINDOW *src_w, WINDOW *dst_w)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
13 int overwrite(const WINDOW *src_w, WINDOW *dst_w)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
14 int copywin(const WINDOW *src_w, WINDOW *dst_w, int src_tr,
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
15 int src_tc, int dst_tr, int dst_tc, int dst_br,
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
16 int dst_bc, bool overlay)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
17
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
18 Description:
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
19 overlay() and overwrite() copy all the text from src_w into
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
20 dst_w. The windows need not be the same size. Those characters
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
21 in the source window that intersect with the destination window
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
22 are copied, so that the characters appear in the same physical
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
23 position on the screen. The difference between the two functions
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
24 is that overlay() is non-destructive (blanks are not copied)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
25 while overwrite() is destructive (blanks are copied).
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
26
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
27 copywin() is similar, but doesn't require that the two windows
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
28 overlap. The arguments src_tc and src_tr specify the top left
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
29 corner of the region to be copied. dst_tc, dst_tr, dst_br, and
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
30 dst_bc specify the region within the destination window to copy
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
31 to. The argument "overlay", if TRUE, indicates that the copy is
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
32 done non-destructively (as in overlay()); blanks in the source
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
33 window are not copied to the destination window. When overlay is
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
34 FALSE, blanks are copied.
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
35
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
36 Return Value:
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
37 All functions return OK on success and ERR on error.
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
38
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
39 Portability X/Open BSD SYS V
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
40 overlay Y Y Y
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
41 overwrite Y Y Y
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
42 copywin Y - 3.0
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
43
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
44 **man-end****************************************************************/
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
45
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
46 /* Thanks to Andreas Otte <venn@@uni-paderborn.de> for the
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
47 corrected overlay()/overwrite() behavior. */
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
48
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
49 static int _copy_win(const WINDOW *src_w, WINDOW *dst_w, int src_tr,
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
50 int src_tc, int src_br, int src_bc, int dst_tr,
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
51 int dst_tc, bool overlay)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
52 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
53 int col, line, y1, fc, *minchng, *maxchng;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
54 chtype *w1ptr, *w2ptr;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
55
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
56 int lc = 0;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
57 int xdiff = src_bc - src_tc;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
58 int ydiff = src_br - src_tr;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
59
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
60 if (!src_w || !dst_w)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
61 return ERR;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
62
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
63 minchng = dst_w->_firstch;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
64 maxchng = dst_w->_lastch;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
65
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
66 for (y1 = 0; y1 < dst_tr; y1++)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
67 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
68 minchng++;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
69 maxchng++;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
70 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
71
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
72 for (line = 0; line < ydiff; line++)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
73 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
74 w1ptr = src_w->_y[line + src_tr] + src_tc;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
75 w2ptr = dst_w->_y[line + dst_tr] + dst_tc;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
76
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
77 fc = _NO_CHANGE;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
78
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
79 for (col = 0; col < xdiff; col++)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
80 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
81 if ((*w1ptr) != (*w2ptr) &&
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
82 !((*w1ptr & A_CHARTEXT) == ' ' && overlay))
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
83 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
84 *w2ptr = *w1ptr;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
85
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
86 if (fc == _NO_CHANGE)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
87 fc = col + dst_tc;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
88
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
89 lc = col + dst_tc;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
90 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
91
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
92 w1ptr++;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
93 w2ptr++;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
94 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
95
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
96 if (*minchng == _NO_CHANGE)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
97 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
98 *minchng = fc;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
99 *maxchng = lc;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
100 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
101 else if (fc != _NO_CHANGE)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
102 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
103 if (fc < *minchng)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
104 *minchng = fc;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
105 if (lc > *maxchng)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
106 *maxchng = lc;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
107 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
108
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
109 minchng++;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
110 maxchng++;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
111 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
112
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
113 return OK;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
114 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
115
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
116 int overlay(const WINDOW *src_w, WINDOW *dst_w)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
117 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
118 int first_line, first_col, last_line, last_col;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
119 int src_start_x, src_start_y, dst_start_x, dst_start_y;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
120 int xdiff, ydiff;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
121
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
122 PDC_LOG(("overlay() - called\n"));
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
123
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
124 if (!src_w || !dst_w)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
125 return ERR;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
126
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
127 first_col = max(dst_w->_begx, src_w->_begx);
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
128 first_line = max(dst_w->_begy, src_w->_begy);
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
129
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
130 last_col = min(src_w->_begx + src_w->_maxx, dst_w->_begx + dst_w->_maxx);
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
131 last_line = min(src_w->_begy + src_w->_maxy, dst_w->_begy + dst_w->_maxy);
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
132
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
133 /* determine the overlapping region of the two windows in real
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
134 coordinates */
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
135
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
136 /* if no overlapping region, do nothing */
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
137
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
138 if ((last_col < first_col) || (last_line < first_line))
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
139 return OK;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
140
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
141 /* size of overlapping region */
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
142
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
143 xdiff = last_col - first_col;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
144 ydiff = last_line - first_line;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
145
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
146 if (src_w->_begx <= dst_w->_begx)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
147 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
148 src_start_x = dst_w->_begx - src_w->_begx;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
149 dst_start_x = 0;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
150 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
151 else
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
152 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
153 dst_start_x = src_w->_begx - dst_w->_begx;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
154 src_start_x = 0;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
155 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
156
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
157 if (src_w->_begy <= dst_w->_begy)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
158 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
159 src_start_y = dst_w->_begy - src_w->_begy;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
160 dst_start_y = 0;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
161 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
162 else
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
163 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
164 dst_start_y = src_w->_begy - dst_w->_begy;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
165 src_start_y = 0;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
166 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
167
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
168 return _copy_win(src_w, dst_w, src_start_y, src_start_x,
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
169 src_start_y + ydiff, src_start_x + xdiff,
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
170 dst_start_y, dst_start_x, TRUE);
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
171 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
172
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
173 int overwrite(const WINDOW *src_w, WINDOW *dst_w)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
174 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
175 int first_line, first_col, last_line, last_col;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
176 int src_start_x, src_start_y, dst_start_x, dst_start_y;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
177 int xdiff, ydiff;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
178
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
179 PDC_LOG(("overwrite() - called\n"));
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
180
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
181 if (!src_w || !dst_w)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
182 return ERR;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
183
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
184 first_col = max(dst_w->_begx, src_w->_begx);
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
185 first_line = max(dst_w->_begy, src_w->_begy);
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
186
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
187 last_col = min(src_w->_begx + src_w->_maxx, dst_w->_begx + dst_w->_maxx);
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
188 last_line = min(src_w->_begy + src_w->_maxy, dst_w->_begy + dst_w->_maxy);
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
189
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
190 /* determine the overlapping region of the two windows in real
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
191 coordinates */
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
192
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
193 /* if no overlapping region, do nothing */
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
194
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
195 if ((last_col < first_col) || (last_line < first_line))
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
196 return OK;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
197
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
198 /* size of overlapping region */
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
199
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
200 xdiff = last_col - first_col;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
201 ydiff = last_line - first_line;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
202
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
203 if (src_w->_begx <= dst_w->_begx)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
204 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
205 src_start_x = dst_w->_begx - src_w->_begx;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
206 dst_start_x = 0;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
207 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
208 else
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
209 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
210 dst_start_x = src_w->_begx - dst_w->_begx;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
211 src_start_x = 0;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
212 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
213
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
214 if (src_w->_begy <= dst_w->_begy)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
215 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
216 src_start_y = dst_w->_begy - src_w->_begy;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
217 dst_start_y = 0;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
218 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
219 else
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
220 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
221 dst_start_y = src_w->_begy - dst_w->_begy;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
222 src_start_y = 0;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
223 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
224
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
225 return _copy_win(src_w, dst_w, src_start_y, src_start_x,
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
226 src_start_y + ydiff, src_start_x + xdiff,
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
227 dst_start_y, dst_start_x, FALSE);
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
228 }
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
229
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
230 int copywin(const WINDOW *src_w, WINDOW *dst_w, int src_tr, int src_tc,
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
231 int dst_tr, int dst_tc, int dst_br, int dst_bc, int overlay)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
232 {
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
233 int src_end_x, src_end_y;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
234 int src_rows, src_cols, dst_rows, dst_cols;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
235 int min_rows, min_cols;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
236
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
237 PDC_LOG(("copywin() - called\n"));
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
238
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
239 if (!src_w || !dst_w || dst_w == curscr || dst_br > dst_w->_maxy
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
240 || dst_bc > dst_w->_maxx || dst_tr < 0 || dst_tc < 0)
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
241 return ERR;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
242
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
243 src_rows = src_w->_maxy - src_tr;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
244 src_cols = src_w->_maxx - src_tc;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
245 dst_rows = dst_br - dst_tr + 1;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
246 dst_cols = dst_bc - dst_tc + 1;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
247
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
248 min_rows = min(src_rows, dst_rows);
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
249 min_cols = min(src_cols, dst_cols);
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
250
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
251 src_end_y = src_tr + min_rows;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
252 src_end_x = src_tc + min_cols;
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
253
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
254 return _copy_win(src_w, dst_w, src_tr, src_tc, src_end_y, src_end_x,
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
255 dst_tr, dst_tc, overlay);
2d43f05b284c Added pdcurses source files, if no curses library is provided, these source files will be fallen back to instead of raising an error. Should make compiling on windows slightly less painful.
Teemu Piippo <tsapii@utu.fi>
parents:
diff changeset
256 }

mercurial