I want to write a package which changes the text selected by a multiple selection. I hereby mean if you eg select all occurrences of a phrase, I then want to change these multiple selected phrases.
I’ve searched the API for some time now, especially in TextEditor and TextBuffer docs but I’m still not sure what’s the appropriate way to do this.
The easiest way I could think of would be to call getSelectedText() on the TextEditor but this seems to only return the latest addition of a multiple selection. I couldn’t find a command to return like an array of strings, like the selected texts line wise.
I’m thankful for any hint. Thanks a lot!
Writing a question like this seems to clear the mind. I think I’ve probably found a way to do this. Please correct me if it’s wrong.
I could call getSelectedScreenRanges() on the TextEditor and then getTextInRange() on the ScreenBuffer to get the actual text. After changing the strings I could the use TextBuffer’s setTextInRamge() to overwrite the old texts.
Is this a good way to do it? Thanks again.