Moves the current line or the selected lines up or down. @param down down/up flag
(final boolean down)
| 590 | * @param down down/up flag |
| 591 | */ |
| 592 | void move(final boolean down) { |
| 593 | if(!extend()) return; |
| 594 | |
| 595 | final int s = start, e = end, ts = size(); |
| 596 | final byte[] tmp = Arrays.copyOf(text, ts); |
| 597 | if(down) { |
| 598 | if(e == ts) return; |
| 599 | pos = e; |
| 600 | lineEnd(true); |
| 601 | int c = s; |
| 602 | for(int i = e; i < pos; i++) tmp[c++] = text[i]; |
| 603 | tmp[c++] = '\n'; |
| 604 | for(int i = s; i < e - 1; i++) tmp[c++] = text[i]; |
| 605 | text(tmp); |
| 606 | select(s + pos - e + 1, Math.min(ts, pos + 1)); |
| 607 | } else { |
| 608 | if(s == 0) return; |
| 609 | pos = s - 1; |
| 610 | bol(true); |
| 611 | int c = pos; |
| 612 | for(int i = s; i < e; i++) tmp[c++] = text[i]; |
| 613 | if(tmp[c - 1] != '\n') tmp[c++] = '\n'; |
| 614 | for(int i = pos; i < s && c < ts; i++) tmp[c++] = text[i]; |
| 615 | text(tmp); |
| 616 | select(pos, pos + e - s); |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | /** |
| 621 | * Inserts the specified value and updates the cursor position. |