| 176 | } |
| 177 | |
| 178 | LRESULT CALLBACK |
| 179 | StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
| 180 | { |
| 181 | PNHStatusWindow data; |
| 182 | |
| 183 | data = (PNHStatusWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA); |
| 184 | switch (message) { |
| 185 | case WM_MSNH_COMMAND: { |
| 186 | switch (wParam) { |
| 187 | case MSNH_MSG_PUTSTR: { |
| 188 | PMSNHMsgPutstr msg_data = (PMSNHMsgPutstr) lParam; |
| 189 | strncpy(data->window_text[data->index], msg_data->text, |
| 190 | MAXWINDOWTEXT); |
| 191 | data->index = (data->index + 1) % NHSW_LINES; |
| 192 | InvalidateRect(hWnd, NULL, TRUE); |
| 193 | } break; |
| 194 | |
| 195 | case MSNH_MSG_CLEAR_WINDOW: { |
| 196 | data->index = 0; |
| 197 | ZeroMemory(data->window_text, sizeof(data->window_text)); |
| 198 | InvalidateRect(hWnd, NULL, TRUE); |
| 199 | } break; |
| 200 | |
| 201 | case MSNH_MSG_GETTEXT: { |
| 202 | PMSNHMsgGetText msg_data = (PMSNHMsgGetText) lParam; |
| 203 | msg_data->buffer[0] = '\0'; |
| 204 | size_t space_remaining = msg_data->max_size; |
| 205 | |
| 206 | for (int line = 0; line < NHSW_LINES; line++) { |
| 207 | mswin_status_line *status_line = &data->status_lines->lines[line]; |
| 208 | for (int i = 0; i < status_line->status_strings.count; i++) { |
| 209 | mswin_status_string * status_string = status_line->status_strings.status_strings[i]; |
| 210 | if (status_string->str != NULL) { |
| 211 | if (status_string->space_in_front) { |
| 212 | strncat(msg_data->buffer, " ", space_remaining); |
| 213 | space_remaining = msg_data->max_size - strlen(msg_data->buffer); |
| 214 | } |
| 215 | strncat(msg_data->buffer, status_string->str, space_remaining); |
| 216 | space_remaining = msg_data->max_size - strlen(msg_data->buffer); |
| 217 | } |
| 218 | } |
| 219 | strncat(msg_data->buffer, "\r\n", space_remaining); |
| 220 | space_remaining = msg_data->max_size - strlen(msg_data->buffer); |
| 221 | } |
| 222 | } break; |
| 223 | |
| 224 | case MSNH_MSG_UPDATE_STATUS: { |
| 225 | PMSNHMsgUpdateStatus msg_data = (PMSNHMsgUpdateStatus) lParam; |
| 226 | data->status_lines = msg_data->status_lines; |
| 227 | InvalidateRect(hWnd, NULL, TRUE); |
| 228 | } break; |
| 229 | |
| 230 | case MSNH_MSG_RANDOM_INPUT: |
| 231 | nhassert(0); // unexpected |
| 232 | break; |
| 233 | |
| 234 | } /* end switch( wParam ) { */ |
| 235 | } break; |
nothing calls this directly
no test coverage detected