Open .rtf and .txt in Scide

Hi list (forum),

When I open .rtf files with SC code, I get a warning that they will be
converted to, i guess, txt files. The subsequent document is displayed
in scide, but without syntax colorizing and can not be evaluated. No
error message is posted.
If I convert the .rtf to .txt using libreoffice-writer, the resulting
.txt file is handled alike, no evaluation possible. If I change its file
extension to .scd it is being colorized and is evaluatable.
I find, .rtf and .txt should load like .scd files. Is there a specific
reason for the current behavior?

thank you!

All files are just a bunch of binary. File extensions indicate how a file should be interpreted; they do not necessitate a file in be interpret in such a way, only suggest it. ‘.scd’ indicates that a file should be considered supercollider code, '.txt. raw text, and ‘.rtf’ as rich format text. These conventions only work if we all agree to interpret files in that way - in fact, most of computing is nothing but conventions we all follow because it is useful. That is why supercollider will not interpret other files as code, because it breaks the convention - its the equivalent of ‘good manners’ in software design.

However, there is nothing stopping you from changing the format yourself.

rtf used to be the file format for sc code when SuperCollider was open sourced. This old code is still around, so i can understand why such situations arise. the sidestep via convert to txt is necessary as it strips the riches from rtf files, changing *.rtf to *.scd directly probably does not give correct results.

Maybe it would be sufficient to code up a way to do this conversion in SuperCollider, so you could do this for a whole entire at a time? It should be easy as there is a readAllStringRTF method.

After opening the .rtf file, save it with the .scd extension and the syntax colorizing/evaluation will be activated. Maybe it’s not ideal but this is how it works currently; this could be improved.

Hm, there are few inaccuracies in the responses given to @Peter’s question.

Yes, all files are technically binary, BUT the convention is to call files can be properly interpreted as ASCII characters “text files”, to differentiate them from “binary files” which do not give reasonable result when rendered as text (an example of the latter would be an executable, a jpeg image, an audio file etc). RTF file is still a text file internally.

In addition to the text itself, RTF file contains extra symbols to indicate formatting. To see this, try opening such file in e.g. Visual Studio Code or some other editor which does not support rtf.

RTF was used in SuperCollider “Cocoa” editor on macOS, before we moved to the Qt-based IDE.

1 Like