Esempio n. 1
0
 public int getAbsoluteY(TextLocation location) {
   int height = 0;
   for (int i = 0; i < location.line; i++) {
     TypedLayout layout = getLines().get(i);
     height += layout.getHeightWithLeading();
   }
   return height;
 }
Esempio n. 2
0
  public void moveCaretToNewLine(int lineDelta) {
    ArrayList<TypedLayout> lines = getLines();
    int newLineNumber = caretLocation.line + lineDelta;
    if (newLineNumber >= 0 && newLineNumber < lines.size()) {
      TextLocation origin = verticalOrigin != null ? verticalOrigin : caretLocation;
      int desiredX = lines.get(origin.line).getX(origin.index);

      TypedLayout newLine = lines.get(newLineNumber);
      int newIndex = newLine.getIndexAt(desiredX);

      TextLocation newLocation = TextLocation.at(newLineNumber, newIndex);
      setCaretLocation(newLocation);

      verticalOrigin = origin;
    }
  }
Esempio n. 3
0
 public int getXOffset(TypedLayout line) {
   HorizontalAlignmentValue horizontalAlignment =
       getContainer().getStyle().getCompiledHorizontalAlignment();
   return horizontalAlignment.getX(line.getWidth(), getContainer().getBounds());
 }
Esempio n. 4
0
 public void sendCaretToEndOfLine() {
   final TextLocation caret = getCaretLocation();
   TypedLayout caretLine = getLines().get(caret.line);
   setCaretLocation(TextLocation.at(caret.line, caretLine.visibleLength()));
 }