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

Function onMSNHCommand

win/win32/mhmsgwnd.c:242–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240}
241
242void
243onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
244{
245 PNHMessageWindow data;
246
247 data = (PNHMessageWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
248 switch (wParam) {
249 case MSNH_MSG_PUTSTR: {
250 /* Add the passed in message to the existing text. Support the
251 * adding of text that ends in newline. A newline in text
252 * will force any subsequent text that is added to be added on
253 * a new output line.
254 *
255 * TODO: Text can be added with newlines occurring within the text not
256 * just at the end. As currently implemented, this can cause
257 * the text to be rendered such that the text following the
258 * newline is rendered on a new line. This can cause a poor
259 * user experience when the user has set only a single text line
260 * for the message window. In this case, the user will not see
261 * any line other then the last line of text and the --MORE--
262 * message thus missing any text that appears before the last
263 * embedded newline. This does not meet the requirements of the
264 * message window.
265 * This code should be changed to do the right thing and split
266 * the text so that only lines that end in newlines are added to
267 * the stored window text.
268 */
269 PMSNHMsgPutstr msg_data = (PMSNHMsgPutstr) lParam;
270 SCROLLINFO si;
271 char *p;
272
273 if (msg_data->append == 1) {
274 /* Forcibly append to line, even if we pass the edge */
275 strncat(data->window_text[MSG_LINES - 1].text, msg_data->text,
276 MAXWINDOWTEXT
277 - strlen(data->window_text[MSG_LINES - 1].text));
278 } else if (msg_data->append < 0) {
279 /* remove that many chars */
280 int len = strlen(data->window_text[MSG_LINES - 1].text);
281 int newend = max(len + msg_data->append, 0);
282 data->window_text[MSG_LINES - 1].text[newend] = '\0';
283 } else {
284 if (can_append_text(hWnd, msg_data->attr, msg_data->text)) {
285 strncat(data->window_text[MSG_LINES - 1].text, " ",
286 MAXWINDOWTEXT
287 - strlen(data->window_text[MSG_LINES - 1].text));
288 strncat(data->window_text[MSG_LINES - 1].text, msg_data->text,
289 MAXWINDOWTEXT
290 - strlen(data->window_text[MSG_LINES - 1].text));
291 } else {
292 /* check for "--more--" */
293 if (!data->nevermore && more_prompt_check(hWnd)) {
294 int okkey = 0;
295 char tmptext[MAXWINDOWTEXT + 1];
296
297 // @@@ Ok responses
298
299 /* save original text */

Callers 1

NHMessageWndProcFunction · 0.70

Calls 7

can_append_textFunction · 0.85
more_prompt_checkFunction · 0.85
strip_newlineFunction · 0.85
isspaceFunction · 0.85
play_sound_for_messageFunction · 0.85
mswin_nhgetchFunction · 0.70
GetNHAppFunction · 0.70

Tested by

no test coverage detected