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

Function display_text_window

win/X11/wintext.c:144–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144void
145display_text_window(struct xwindow *wp, boolean blocking)
146{
147 struct text_info_t *text_info;
148 Arg args[8];
149 Cardinal num_args;
150 Dimension width, height, font_height;
151 int nlines;
152
153 text_info = wp->text_information;
154 width = text_info->max_width + text_info->extra_width;
155 text_info->blocked = blocking;
156 text_info->destroy_on_ack = FALSE;
157 font_height = nhFontHeight(wp->w);
158
159 /*
160 * Calculate the number of lines to use. First, find the number of
161 * lines that would fit on the screen. Next, remove four of these
162 * lines to give room for a possible window manager titlebar (some
163 * wm's put a titlebar on transient windows). Make sure we have
164 * _some_ lines. Finally, use the number of lines in the text if
165 * there are fewer than the max.
166 */
167 nlines = (XtScreen(wp->w)->height - text_info->extra_height) / font_height;
168 nlines -= 4;
169
170 if (nlines > text_info->text.num_lines)
171 nlines = text_info->text.num_lines;
172 if (nlines <= 0)
173 nlines = 1;
174
175 height = nlines * font_height + text_info->extra_height;
176
177 num_args = 0;
178
179 if (nlines < text_info->text.num_lines) {
180 /* add on width of scrollbar. Really should look this up,
181 * but can't until the window is realized. Chicken-and-egg problem.
182 */
183 width += 20;
184 }
185
186#ifdef GRAPHIC_TOMBSTONE
187 if (text_info->is_rip) {
188 Widget rip = create_ripout_widget(XtParent(wp->w));
189
190 if (rip) {
191 XtSetArg(args[num_args], nhStr(XtNfromVert), rip);
192 num_args++;
193 } else
194 text_info->is_rip = FALSE;
195 }
196#endif
197
198 if (width > (Dimension) XtScreen(wp->w)->width) { /* too wide for screen */
199 /* Back off some amount - we really need to back off the scrollbar */
200 /* width plus some extra. */
201 width = XtScreen(wp->w)->width - 20;

Callers 1

X11_display_nhwindowFunction · 0.85

Calls 6

nhFontHeightFunction · 0.85
create_ripout_widgetFunction · 0.85
positionpopupFunction · 0.85
nh_XtPopupFunction · 0.85
x_eventFunction · 0.85
nh_XtPopdownFunction · 0.85

Tested by

no test coverage detected