MCPcopy Create free account
hub / github.com/NetHack/NetHack / set_window_position

Function set_window_position

win/curses/cursinit.c:52–94  ·  view source on GitHub ↗

win* is size and placement of window to change, x/y/w/h is baseline which can decrease depending on alignment of win* in orientation. Negative minh/minw: as much as possible, but at least as much as specified. */

Source from the content-addressed store, hash-verified

50 Negative minh/minw: as much as possible, but at least as much as
51 specified. */
52static void
53set_window_position(int *winx, int *winy, int *winw, int *winh,
54 int orientation,
55 int *x, int *y, int *w, int *h, int border_space,
56 int minh, int minw)
57{
58 *winw = *w;
59 *winh = *h;
60
61 /* Set window height/width */
62 if (orientation == ALIGN_TOP || orientation == ALIGN_BOTTOM) {
63 if (minh < 0) {
64 *winh = (*h - ROWNO - border_space);
65 if (-minh > *winh)
66 *winh = -minh;
67 } else
68 *winh = minh;
69 *h -= (*winh + border_space);
70 } else {
71 if (minw < 0) {
72 *winw = (*w - COLNO - border_space);
73 if (-minw > *winw)
74 *winw = -minw;
75 } else
76 *winw = minw;
77 *w -= (*winw + border_space);
78 }
79
80 *winx = *w + border_space + *x;
81 *winy = *h + border_space + *y;
82
83 /* Set window position */
84 if (orientation != ALIGN_RIGHT) {
85 *winx = *x;
86 if (orientation == ALIGN_LEFT)
87 *x += *winw + border_space;
88 }
89 if (orientation != ALIGN_BOTTOM) {
90 *winy = *y;
91 if (orientation == ALIGN_TOP)
92 *y += *winh + border_space;
93 }
94}
95
96/* Create the "main" nonvolatile windows used by nethack */
97void

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected