| 448 | } |
| 449 | |
| 450 | void renderdoc(int x, int y, int doch) |
| 451 | { |
| 452 | if(!docvisible) return; |
| 453 | doch -= 3*FONTH + FONTH/2; |
| 454 | |
| 455 | int cmdpos; |
| 456 | const char *exp = getcurcommand(&cmdpos); // get command buffer and cursor position |
| 457 | if(!exp || *exp != '/') return; |
| 458 | |
| 459 | const char *pos = exp + (cmdpos < 0 ? strlen(exp) : cmdpos), *w[MAXWORDS]; |
| 460 | int wl[MAXWORDS], carg, unmatched = 0; |
| 461 | docident *curident = NULL; |
| 462 | string buf; |
| 463 | loopi(2) // two scan passes, first one retries on unmatched braces |
| 464 | { |
| 465 | carg = docs_parsecmd(exp + 1, pos, w, wl, i != 0, &unmatched); // break into words |
| 466 | if(!w[0]) return; |
| 467 | copystring(buf, w[0], wl[0] + 1); |
| 468 | curident = docidents.access(buf); // get doc entry |
| 469 | if(curident) break; |
| 470 | } |
| 471 | if(unmatched) draw_textf("\f3missing '%c'", x + 1111, y + doch + 2*FONTH, unmatched); |
| 472 | |
| 473 | ident *csident = idents->access(buf); // check for cs ident |
| 474 | |
| 475 | if(!curident && !csident && docidentverbose < 3) { docskip = 0; return; } |
| 476 | |
| 477 | vector<const char *> doclines; |
| 478 | vector<char *> heaplines; |
| 479 | |
| 480 | if(curident) |
| 481 | { |
| 482 | if(!curident->label) |
| 483 | { |
| 484 | formatstring(buf)("~%s", curident->name); // label |
| 485 | loopvj(curident->arguments) concatformatstring(buf, " %s", curident->arguments[j].token); |
| 486 | curident->label = newstring(buf); |
| 487 | } |
| 488 | doclines.add(curident->label); |
| 489 | |
| 490 | doclines.add(NULL); |
| 491 | doclines.add(curident->desc); |
| 492 | doclines.add(NULL); |
| 493 | |
| 494 | if(curident->arguments.length()) // args |
| 495 | { |
| 496 | if(carg >= curident->arguments.length() && curident->arguments.last().vararg) carg = curident->arguments.length() - 1; // vararg spans the line |
| 497 | |
| 498 | loopvj(curident->arguments) |
| 499 | { |
| 500 | docargument *a = &curident->arguments[j]; |
| 501 | formatstring(doclines.add(heaplines.add(newstringbuf())))("\f%c%-8s%s", j == carg ? '4' : '5', a->token, a->desc); |
| 502 | if(a->values) concatformatstring(heaplines.last(), " (%s)", a->values); |
| 503 | } |
| 504 | doclines.add(NULL); |
| 505 | } |
| 506 | |
| 507 | if(curident->remarks.length()) // remarks |
no test coverage detected