use of org.fxmisc.richtext.CaretNode in project RichTextFX by FXMisc.
the class MultipleCaretSelectionTests method adding_caret_works.
@Test
public void adding_caret_works() {
CaretNode caret = new CaretNode("test caret", area, 0);
interact(() -> assertTrue(area.addCaret(caret)));
assertTrue(caret.getCaretBounds().isPresent());
assertEquals(0, caret.getPosition());
}
use of org.fxmisc.richtext.CaretNode in project RichTextFX by FXMisc.
the class MultipleCaretSelectionTests method attempting_to_add_caret_associated_with_different_area_fails.
@Test
public void attempting_to_add_caret_associated_with_different_area_fails() {
InlineCssTextArea area2 = new InlineCssTextArea();
CaretNode caret = new CaretNode("test caret", area2);
interact(() -> {
try {
area.addCaret(caret);
fail();
} catch (IllegalArgumentException e) {
// cannot add a caret associated with a different area
}
});
}
use of org.fxmisc.richtext.CaretNode in project RichTextFX by FXMisc.
the class MultipleCaretSelectionTests method removing_caret_works.
@Test
public void removing_caret_works() {
CaretNode caret = new CaretNode("test caret", area, 0);
interact(() -> {
assertTrue(area.addCaret(caret));
assertTrue(area.removeCaret(caret));
});
}
use of org.fxmisc.richtext.CaretNode in project RichTextFX by FXMisc.
the class MultiCaretAndSelectionDemo method addExtraCaret.
private void addExtraCaret() {
CaretNode extraCaret = new CaretNode("another caret", area);
if (!area.addCaret(extraCaret)) {
throw new IllegalStateException("caret was not added to area");
}
extraCaret.moveTo(3, 8);
// since the CSS properties are re-set when it applies the CSS from files
// remove the style class so that properties set below are not overridden by CSS
extraCaret.getStyleClass().remove("caret");
extraCaret.setStrokeWidth(10.0);
extraCaret.setStroke(Color.BROWN);
extraCaret.setBlinkRate(Duration.millis(200));
}
use of org.fxmisc.richtext.CaretNode in project RichTextFX by FXMisc.
the class MultipleCaretSelectionTests method modifying_caret_before_adding_to_area_does_not_throw_exception.
@Test
public void modifying_caret_before_adding_to_area_does_not_throw_exception() {
CaretNode caret = new CaretNode("test caret", area);
interact(() -> {
caret.moveToAreaEnd();
area.addCaret(caret);
caret.moveToParEnd();
area.removeCaret(caret);
caret.moveToParStart();
area.addCaret(caret);
area.removeCaret(caret);
});
}
Aggregations