insert text to line at cursor
| 776 | |
| 777 | // insert text to line at cursor |
| 778 | void Query::insert(const char *text, size_t size) |
| 779 | { |
| 780 | char *end = line_end(); |
| 781 | if (end + size >= line_ + sizeof(Line)) |
| 782 | { |
| 783 | size = line_ + sizeof(Line) - end - 1; |
| 784 | Screen::alert(); |
| 785 | } |
| 786 | if (size > 0) |
| 787 | { |
| 788 | char *ptr = line_ptr(col_); |
| 789 | memmove(ptr + size, ptr, end - ptr + 1); |
| 790 | memcpy(ptr, text, size); |
| 791 | int oldlen = len_; |
| 792 | len_ = line_len(); |
| 793 | int forward = len_ - oldlen; |
| 794 | if (forward > 0) |
| 795 | { |
| 796 | updated_ = true; |
| 797 | error_ = -1; |
| 798 | col_ += forward; |
| 799 | draw(); |
| 800 | } |
| 801 | } |
| 802 | } |
| 803 | |
| 804 | // insert one character (or a byte of a multi-byte sequence) in the line at the cursor |
| 805 | void Query::insert(int ch) |
no outgoing calls
no test coverage detected