draw the query search line
| 464 | |
| 465 | // draw the query search line |
| 466 | void Query::draw() |
| 467 | { |
| 468 | if (mode_ == Mode::QUERY) |
| 469 | { |
| 470 | start_ = 0; |
| 471 | |
| 472 | Screen::home(); |
| 473 | |
| 474 | if (row_ > 0) |
| 475 | { |
| 476 | char down[16]; |
| 477 | |
| 478 | snprintf(down, sizeof(down), "%3d ", row_); |
| 479 | |
| 480 | Screen::normal(); |
| 481 | Screen::put(down); |
| 482 | |
| 483 | start_ = static_cast<int>(strlen(down)); |
| 484 | } |
| 485 | |
| 486 | if (select_ == -1) |
| 487 | { |
| 488 | if (!dirs_.empty()) |
| 489 | { |
| 490 | int width = Screen::mbstring_width(dirs_.c_str()); |
| 491 | int offset = 0; |
| 492 | int middle = Screen::cols/2 - start_; |
| 493 | if (width + 2 > middle) |
| 494 | offset = width + 2 - middle; |
| 495 | |
| 496 | Screen::normal(); |
| 497 | if (offset > 0) |
| 498 | Screen::put(LARROW); |
| 499 | |
| 500 | const char *dir = Screen::mbstring_pos(dirs_.c_str(), offset); |
| 501 | Screen::put(dir); |
| 502 | Screen::put(' '); |
| 503 | |
| 504 | start_ += Screen::mbstring_width(dir) + 1 + (offset > 0); |
| 505 | } |
| 506 | |
| 507 | if (!Screen::mono) |
| 508 | { |
| 509 | Screen::normal(); |
| 510 | Screen::put(error_ == -1 ? color_qp : color_qe); |
| 511 | } |
| 512 | |
| 513 | Screen::put(prompt_.c_str()); |
| 514 | Screen::normal(); |
| 515 | |
| 516 | start_ += static_cast<int>(prompt_.size()); |
| 517 | |
| 518 | int pos; |
| 519 | if (len_ - col_ < shift_) |
| 520 | pos = Screen::cols - start_ - (len_ - col_) - 1; |
| 521 | else |
| 522 | pos = Screen::cols - start_ - shift_ - 1; |
| 523 |