Skip to content

max text editor file type setting? #58

@ramagottfried

Description

@ramagottfried

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"));
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions