| 263 | */ |
| 264 | |
| 265 | void grViewport::draw_text_line_clip(int x, int y, char *str) { |
| 266 | int ch_y, ch_x, ch_w, ch_h; // what part of the character to draw |
| 267 | int i, cur_x, draw_x, draw_y; // where to draw character section |
| 268 | int h; |
| 269 | |
| 270 | /* by clipping, we should first determine what our vertical clipping is. then |
| 271 | go through each character in the line and determine what is totally clipped, |
| 272 | partially clipped and by how much, and not clipped at all and draw accordingly |
| 273 | */ |
| 274 | h = text_Font.height(); |
| 275 | ch_y = 0; |
| 276 | ch_h = h; |
| 277 | draw_y = y; |
| 278 | // determine each character bitmap y and height to blt. |
| 279 | if (CLIP_TOP >= y) { |
| 280 | ch_y = CLIP_TOP - y; |
| 281 | draw_y = CLIP_TOP; |
| 282 | } |
| 283 | if (CLIP_BOTTOM < (y + text_Font.height())) { |
| 284 | ch_h = CLIP_BOTTOM - y; |
| 285 | } |
| 286 | ch_h = ch_h - ch_y; // do this to clip both top and bottom |
| 287 | |
| 288 | cur_x = x; |
| 289 | for (i = 0; i < (int)strlen(str); i++) { |
| 290 | uint8_t ch; |
| 291 | int w; |
| 292 | ch = (uint8_t)str[i]; |
| 293 | text_Font.get_char_info((int)ch, &w); |
| 294 | |
| 295 | if (ch == GR_COLOR_CHAR) { |
| 296 | if ((i + 3) >= (int)strlen(str)) |
| 297 | Int3(); // This shouldn't happen! bad string! |
| 298 | set_text_color(GR_RGB(str[i + 1], str[i + 2], str[i + 3])); |
| 299 | i += 4; |
| 300 | if (i >= (int)strlen(str)) |
| 301 | Int3(); // This shouldn't happen too. |
| 302 | ch = (uint8_t)str[i]; |
| 303 | } else if (ch == '\t') { // tab char |
| 304 | int space_width; |
| 305 | text_Font.get_char_info(' ', &space_width); |
| 306 | space_width += text_Spacing; |
| 307 | cur_x = (cur_x + space_width - 1) / space_width * space_width; |
| 308 | } |
| 309 | |
| 310 | // do horizontal clipping |
| 311 | if (((cur_x + w) < CLIP_LEFT) || (cur_x > CLIP_RIGHT)) { |
| 312 | cur_x += (text_Spacing + w); |
| 313 | } else { |
| 314 | ch_x = 0; |
| 315 | ch_w = w; |
| 316 | draw_x = cur_x; |
| 317 | if (CLIP_LEFT > cur_x) { |
| 318 | ch_x = CLIP_LEFT - cur_x; |
| 319 | draw_x = CLIP_LEFT; |
| 320 | } |
| 321 | if (CLIP_RIGHT < (cur_x + w)) { |
| 322 | ch_w = CLIP_RIGHT - cur_x; |
nothing calls this directly
no test coverage detected