You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Hope this is the last issue I'll open here, ahaha)
Basically, I need to do this:
If I type, for example, '[', it generates '[ ]' and puts caret between them
If I delete '[', it deletes ']' too
It works using '[' and ']', the problem is doing this with characters like quotes and double quotes, because they are equals.
So, when I type one of those characters, each replaceText calls a new richChanges and throws a StackOverflowError.
So, is there a way to call replaceText/insertText without calling richChanges?
The code below is written in Kotlin, but I think it's pretty readable.
(The onChange method is called inside the richChanges().filter(...).subscribe method.)
funonChange(change:RichTextChange<Collection<String>, StyledText<Collection<String>>, Collection<String>>, area:CodeArea) {
if(change.inserted.text == char1.toString()) {
area.insertText(change.position +1, c2.toString()) //If I type '[', it generates ']'
} elseif(change.removed.text == char1.toString() && area.text.toCharArray()[change.position] == c2) {
area.replaceText(change.position, change.position +1, "") //If I remove '[', it removes ']' too
}
}
The text was updated successfully, but these errors were encountered:
iamgio
changed the title
Question: replaceText without calling richChanges
Question: replaceText/insertText without calling richChanges
Feb 11, 2018
There's two ways you could potentially solve this.
The first is probably the easier of the two. You could override the area's InputMap for KeyTyped events to first check whether the inputted character is a " and change it to the actual opening quotes and ending quotes characters: “. Then you'll have to check for that character and add/delete the corresponding ” when you insert/delete one of those characters. The InputMap would continue from there with the default behavior.
The second is using your own custom UndoManager that handle identity changes differently. If you're not familiar with that FP concept, 0 is the identity change for any number, x, so that x + 0 = x. Your custom UM could ignore all identity changes except when the quotes change occurs.
(Hope this is the last issue I'll open here, ahaha)
Basically, I need to do this:
It works using '[' and ']', the problem is doing this with characters like quotes and double quotes, because they are equals.
So, when I type one of those characters, each replaceText calls a new richChanges and throws a StackOverflowError.
So, is there a way to call replaceText/insertText without calling richChanges?
The code below is written in Kotlin, but I think it's pretty readable.
(The onChange method is called inside the richChanges().filter(...).subscribe method.)
The text was updated successfully, but these errors were encountered: