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

Function onMSNHCommand

outdated/sys/wince/mhmsgwnd.c:197–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195}
196
197void
198onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
199{
200 PNHMessageWindow data;
201
202 data = (PNHMessageWindow) GetWindowLong(hWnd, GWL_USERDATA);
203 switch (wParam) {
204 case MSNH_MSG_PUTSTR: {
205 PMSNHMsgPutstr msg_data = (PMSNHMsgPutstr) lParam;
206 SCROLLINFO si;
207 char *p;
208
209 if (msg_data->append) {
210 strncat(data->window_text[MSG_LINES - 1].text, msg_data->text,
211 MAXWINDOWTEXT
212 - strlen(data->window_text[MSG_LINES - 1].text));
213 } else {
214 /* check if the string is empty */
215 for (p = data->window_text[MSG_LINES - 1].text; *p && isspace(*p);
216 p++)
217 ;
218
219 if (*p) {
220 /* last string is not empty - scroll up */
221 memmove(&data->window_text[0], &data->window_text[1],
222 (MSG_LINES - 1) * sizeof(data->window_text[0]));
223 }
224
225 /* append new text to the end of the array */
226 data->window_text[MSG_LINES - 1].attr = msg_data->attr;
227 strncpy(data->window_text[MSG_LINES - 1].text, msg_data->text,
228 MAXWINDOWTEXT);
229 }
230
231 /* reset V-scroll position to display new text */
232 data->yPos = data->yMax;
233
234 ZeroMemory(&si, sizeof(si));
235 si.cbSize = sizeof(si);
236 si.fMask = SIF_POS;
237 si.nPos = data->yPos;
238 SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
239
240 /* deal with overflows */
241 data->lines_last_turn++;
242 if (!data->dont_care && data->lines_last_turn >= MSG_LINES - 2) {
243 char c;
244 BOOL done;
245
246 /* append "--More--" to the message window text (cannot call
247 putstr
248 here - infinite recursion) */
249 memmove(&data->window_text[0], &data->window_text[1],
250 (MSG_LINES - 1) * sizeof(data->window_text[0]));
251 data->window_text[MSG_LINES - 1].attr = ATR_NONE;
252 strncpy(data->window_text[MSG_LINES - 1].text, "--More--",
253 MAXWINDOWTEXT);
254

Callers 1

NHMessageWndProcFunction · 0.70

Calls 5

isspaceFunction · 0.85
NHSPhoneSetKeypadDefaultFunction · 0.85
play_sound_for_messageFunction · 0.85
mswin_nh_poskeyFunction · 0.70

Tested by

no test coverage detected