Search in sources :

Example 6 with TextLocation

use of limelight.ui.text.TextLocation in project limelight by slagyr.

the class TextModel method moveCaretToNewLine.

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;
    }
}
Also used : TypedLayout(limelight.ui.text.TypedLayout) TextLocation(limelight.ui.text.TextLocation)

Example 7 with TextLocation

use of limelight.ui.text.TextLocation in project limelight by slagyr.

the class TextModel method sendCaretToEndOfLine.

public void sendCaretToEndOfLine() {
    final TextLocation caret = getCaretLocation();
    TypedLayout caretLine = getLines().get(caret.line);
    setCaretLocation(TextLocation.at(caret.line, caretLine.visibleLength()));
}
Also used : TypedLayout(limelight.ui.text.TypedLayout) TextLocation(limelight.ui.text.TextLocation)

Example 8 with TextLocation

use of limelight.ui.text.TextLocation in project limelight by slagyr.

the class TextInputKeyProcessor method canMoveRight.

private boolean canMoveRight(TextModel model) {
    final TextLocation caret = model.getCaretLocation();
    final TypedLayout line = model.getLines().get(caret.line);
    return caret.index < line.length() || canMoveDown(model);
}
Also used : TypedLayout(limelight.ui.text.TypedLayout) TextLocation(limelight.ui.text.TextLocation)

Aggregations

TextLocation (limelight.ui.text.TextLocation)8 TypedLayout (limelight.ui.text.TypedLayout)7 Box (limelight.util.Box)3 ArrayList (java.util.ArrayList)1 Panel (limelight.ui.Panel)1