Cycling74 / max-sdk

Software Development Kit for Max by Cycling '74
Other
262 stars 57 forks source link

max text editor file type setting? #58

Open ramagottfried opened 1 year ago

ramagottfried commented 1 year ago

I have an object I am working on that works with lua files, and I notice that when I open the file in the text editor, the filename and title are set with the .lua extension, but text is all grey --

but then if I save the file, the syntax highlighting is automatically enabled, which is really useful.

Is there a filetype attribute or object_method I can call so that the "jed" object knows to use syntax highlighting when the file is first opened?

Here is my dbclick function:

void oluajit_dblclick(t_oluajit *x)
{
    if (x->t_editor)
        object_attr_setchar(x->t_editor, gensym("visible"), 1);
    else
    {
        x->t_editor = (t_object *)object_new(CLASS_NOBOX, gensym("jed"), x, 0);

        if( x->filename != "" ){
            object_method(x->t_editor, gensym("settext"), *(x->t_text), gensym("utf-8"));
            object_method(x->t_editor, gensym("filename"), x->filename.c_str(), x->pathID );
            object_attr_setsym(x->t_editor, gensym("title"), gensym(x->filename.c_str()) );
            object_attr_setchar(x->t_editor, gensym("scratch"), 0);
        }
        else
        {
            object_attr_setsym(x->t_editor, gensym("title"), gensym("untitled.lua"));
            object_attr_setchar(x->t_editor, gensym("scratch"), 1);
        }

        object_method(x->t_editor, gensym("openwindow"));
    }
}
ramagottfried commented 1 year ago

also, if I close the text editor, and then reopen it again, the highlighting disappears until I hit cmd-s again.

shakfu commented 11 months ago

I would also be interested in custom syntax highlighting for the textedit and code editor widgets. I have a python external which would greatly benefit from this.