MCPcopy Create free account
hub / github.com/BaseXdb/basex / move

Method move

basex-core/src/main/java/org/basex/gui/text/TextEditor.java:592–618  ·  view source on GitHub ↗

Moves the current line or the selected lines up or down. @param down down/up flag

(final boolean down)

Source from the content-addressed store, hash-verified

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.

Callers 1

keyPressedMethod · 0.45

Calls 8

extendMethod · 0.95
sizeMethod · 0.95
lineEndMethod · 0.95
textMethod · 0.95
selectMethod · 0.95
bolMethod · 0.95
copyOfMethod · 0.80
minMethod · 0.45

Tested by

no test coverage detected