40
40
import org .fxmisc .easybind .monadic .MonadicObservableValue ;
41
41
import org .fxmisc .flowless .Cell ;
42
42
import org .fxmisc .flowless .VirtualFlow ;
43
+ import org .fxmisc .flowless .VirtualFlowHit ;
43
44
import org .fxmisc .richtext .MouseOverTextEvent ;
44
45
import org .fxmisc .richtext .Paragraph ;
45
46
import org .fxmisc .richtext .PopupAlignment ;
@@ -139,11 +140,11 @@ public StyledTextAreaVisual(
139
140
// Initialize content
140
141
virtualFlow = VirtualFlow .createVertical (
141
142
area .getParagraphs (),
142
- ( index , par ) -> {
143
- Cell <Paragraph <S >, ParagraphBox <S >> cell = createCell (index , par , applyStyle );
143
+ par -> {
144
+ Cell <Paragraph <S >, ParagraphBox <S >> cell = createCell (par , applyStyle );
144
145
nonEmptyCells .add (cell .getNode ());
145
146
return cell .beforeReset (() -> nonEmptyCells .remove (cell .getNode ()))
146
- .afterUpdateItem (( i , p ) -> nonEmptyCells .add (cell .getNode ()));
147
+ .afterUpdateItem (p -> nonEmptyCells .add (cell .getNode ()));
147
148
});
148
149
149
150
// initialize navigator
@@ -202,8 +203,8 @@ public StyledTextAreaVisual(
202
203
EventStreams .valuesOf (area .popupAlignmentProperty ()),
203
204
EventStreams .valuesOf (popupAnchorAdjustment ))
204
205
.repeatOn (positionPopupImpulse )
205
- .filter (( w , al , adj ) -> w != null )
206
- .subscribe (( w , al , adj ) -> positionPopup (w , al , adj )));
206
+ .filter (t3 -> t3 . map (( w , al , adj ) -> w != null ) )
207
+ .subscribe (t3 -> t3 . exec (( w , al , adj ) -> positionPopup (w , al , adj ) )));
207
208
208
209
// dispatch MouseOverTextEvents when mouseOverTextDelay is not null
209
210
EventStreams .valuesOf (area .mouseOverTextDelayProperty ())
@@ -266,7 +267,7 @@ void followCaret() {
266
267
int parIdx = area .getCurrentParagraph ();
267
268
Cell <Paragraph <S >, ParagraphBox <S >> cell = virtualFlow .getCell (parIdx );
268
269
Bounds caretBounds = cell .getNode ().getCaretBounds ();
269
- double graphicWidth = cell .getNode ().getGraphicWidth ();
270
+ double graphicWidth = cell .getNode ().getGraphicPrefWidth ();
270
271
Bounds region = extendLeft (caretBounds , graphicWidth );
271
272
virtualFlow .show (cell , region );
272
273
}
@@ -311,7 +312,7 @@ int getInsertionIndex(double textX, Position targetLine) {
311
312
}
312
313
313
314
int getInsertionIndex (double textX , double y ) {
314
- VirtualFlow . HitInfo <Cell <Paragraph <S >, ParagraphBox <S >>> hit = virtualFlow .hit (y );
315
+ VirtualFlowHit <Cell <Paragraph <S >, ParagraphBox <S >>> hit = virtualFlow .hit (y );
315
316
if (hit .isBeforeCells ()) {
316
317
return 0 ;
317
318
} else if (hit .isAfterCells ()) {
@@ -352,16 +353,16 @@ Position position(int par, int line) {
352
353
* ********************************************************************** */
353
354
354
355
private Cell <Paragraph <S >, ParagraphBox <S >> createCell (
355
- int index ,
356
356
Paragraph <S > paragraph ,
357
357
BiConsumer <Text , S > applyStyle ) {
358
358
359
- ParagraphBox <S > box = new ParagraphBox <>(index , paragraph , applyStyle );
359
+ ParagraphBox <S > box = new ParagraphBox <>(paragraph , applyStyle );
360
360
361
361
box .highlightFillProperty ().bind (highlightFill );
362
362
box .highlightTextFillProperty ().bind (highlightTextFill );
363
363
box .wrapTextProperty ().bind (area .wrapTextProperty ());
364
364
box .graphicFactoryProperty ().bind (area .paragraphGraphicFactoryProperty ());
365
+ box .graphicOffset .bind (virtualFlow .breadthOffsetProperty ());
365
366
366
367
BooleanBinding hasCaret = Bindings .equal (
367
368
box .indexProperty (),
@@ -404,6 +405,7 @@ public void dispose() {
404
405
box .highlightTextFillProperty ().unbind ();
405
406
box .wrapTextProperty ().unbind ();
406
407
box .graphicFactoryProperty ().unbind ();
408
+ box .graphicOffset .unbind ();
407
409
408
410
box .caretVisibleProperty ().unbind ();
409
411
cellCaretVisible .dispose ();
@@ -417,7 +419,7 @@ public void dispose() {
417
419
}
418
420
419
421
private ParagraphBox <S > getCell (int index ) {
420
- return virtualFlow .getCellIfVisible (index ). get ( ).getNode ();
422
+ return virtualFlow .getCell (index ).getNode ();
421
423
}
422
424
423
425
private int getCellInsertionIndex (ParagraphBox <S > cell , double x , int line ) {
@@ -477,7 +479,7 @@ private Optional<Bounds> getSelectionBoundsOnScreen() {
477
479
return getCaretBoundsOnScreen ();
478
480
}
479
481
480
- Bounds [] bounds = virtualFlow .visibleCells ()
482
+ Bounds [] bounds = virtualFlow .visibleCells (). stream ()
481
483
.map (c -> c .getNode ().getSelectionBoundsOnScreen ())
482
484
.filter (opt -> opt .isPresent ())
483
485
.map (opt -> opt .get ())
0 commit comments