Access current editor in IDE programmatically?

Is there a way to access the IDE editor programmatically, like:

~x = Something
~x.insert(“new line of stuff”, 1,1)

Specifically I am interested in having midi events call such a thing, but that’s a longer story.

I couldn’t find this in the documentation, a pointer in the general direction would be great.

Tx

check out the Document class!

https://doc.sccode.org/Classes/Document.html

As @semiquaver mentioned above, Document has such a method.

x = { |string, index| Document.current.insertText(string, index) }



x.("string\nstring\t\string\n", 68)

However, the second argument of the method .insertText is the nth character, and there is no way to define a line number for text insertion.

I think, however, TextView could be also appropriate if you need it to show the information:
https://doc.sccode.org/Classes/TextView.html

If you would like to save the midi input please refer to the following posts:

also once you get the current path (from Document.path IIRC) you can use external tools using String:unixCmd or Pipe…