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

Function curses_create_window

win/curses/curswins.c:60–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58/* Create a window with the specified size and orientation */
59
60WINDOW *
61curses_create_window(int wid, int width, int height, orient orientation)
62{
63 int mapx = 0, mapy = 0, maph = 0, mapw = 0;
64 int startx = 0;
65 int starty = 0;
66 WINDOW *win;
67 boolean map_border = FALSE;
68 int mapb_offset = 0;
69
70 if ((orientation == UP) || (orientation == DOWN) ||
71 (orientation == LEFT) || (orientation == RIGHT)) {
72 if (svm.moves > 0) {
73 map_border = curses_window_has_border(MAP_WIN);
74 curses_get_window_xy(MAP_WIN, &mapx, &mapy);
75 curses_get_window_size(MAP_WIN, &maph, &mapw);
76 } else {
77 map_border = TRUE;
78 mapx = 0;
79 mapy = 0;
80 maph = term_rows;
81 mapw = term_cols;
82 }
83 }
84
85 if (map_border) {
86 mapb_offset = 1;
87 }
88
89 width += 2; /* leave room for bounding box */
90 height += 2;
91
92 if ((width > term_cols) || (height > term_rows)) {
93 impossible(
94 "curses_create_window: Terminal too small for dialog window");
95 width = term_cols;
96 height = term_rows;
97 }
98 switch (orientation) {
99 default:
100 impossible("curses_create_window: Bad orientation");
101 FALLTHROUGH;
102 /*FALLTHRU*/
103 case CENTER:
104 startx = (term_cols / 2) - (width / 2);
105 starty = (term_rows / 2) - (height / 2);
106 break;
107 case UP:
108 if (svm.moves > 0) {
109 startx = (mapw / 2) - (width / 2) + mapx + mapb_offset;
110 } else {
111 startx = 0;
112 }
113
114 starty = mapy + mapb_offset;
115 break;
116 case DOWN:
117 if (svm.moves > 0) {

Callers 4

curses_line_input_dialogFunction · 0.85
curses_ext_cmdFunction · 0.85
curses_display_nhmenuFunction · 0.85

Calls 7

curses_window_has_borderFunction · 0.85
curses_get_window_xyFunction · 0.85
curses_get_window_sizeFunction · 0.85
curses_is_textFunction · 0.85
curses_is_menuFunction · 0.85
curses_toggle_color_attrFunction · 0.85
impossibleFunction · 0.50

Tested by

no test coverage detected