I am trying to set the text style (using GenericStyledArea) such that text that follows will inherit/use that style.
To set some text as bold I'm doing:
private void toggle(Consumer<TextStyle> mixin)
{
IndexRange r = this.getSelection();
this.setStyleSpans(r.getStart(), this.getStyleSpans(r).mapStyles(ss ->
{
TextStyle _s = new TextStyle(ss);
mixin.accept(_s);
return _s;
}));
}
public void toggleBold()
{
IndexRange r = this.getSelection();
TextStyle s = this.getStyleAtPosition(r.getStart());
boolean t = !s.isBold();
this.toggle (_s -> _s.setBold(t));
}
This code will let me bold a piece of selected text but not set the style to be used for the text that follows the style change, except when I apply the bold at the start of an empty paragraph.
The question is, how do I set the style so that text that follows it will use the style?
The image below hopefully highlights what I mean.

I am trying to set the text style (using GenericStyledArea) such that text that follows will inherit/use that style.
To set some text as bold I'm doing:
This code will let me bold a piece of selected text but not set the style to be used for the text that follows the style change, except when I apply the bold at the start of an empty paragraph.
The question is, how do I set the style so that text that follows it will use the style?
The image below hopefully highlights what I mean.