Possible improvement to error message — what do you think?

I couldn’t get those to work in supecollider though, even when running in the terminal

I tried in C++ and it worked… Maybe sclang changes the string??? what happens with two slashes \\ ?

#include <iostream>

const std::string RED = "\033[31m";      
const std::string GREEN = "\033[32m";   
const std::string YELLOW = "\033[33m";
int main() {
    std::cout << RED << "This is red text."  << std::endl;
    std::cout << GREEN << "This is green text."  << std::endl;
    std::cout << YELLOW << "This is yellow text."  << std::endl;
    return 0;
}

EDIT: I’m kind of surprised that sclang never implemented colors in the post window

In terminals, "asdf".error does not produce coloured text. I imagine the colouring is QT looking through the post window for strings beginning “ERROR:”, “->” and “WARNING” and colouring the line.

Do you know what it would take to make colour codes work?

int prPostString(struct VMGlobals* g, int numArgsPushed) {
    PyrSlot* a;

    a = g->sp;
    // if (NotObj(a)) return errWrongType;
    // assume it is a string!
    postText(slotRawString(a)->s, slotRawString(a)->size);
    return errNone;
}

int prPostLine(struct VMGlobals* g, int numArgsPushed) {
    PyrSlot* a;

    a = g->sp;
    // if (NotObj(a)) return errWrongType;
    // assume it is a string!
    postText(slotRawString(a)->s, slotRawString(a)->size);
    postChar('\n');
    return errNone;
}

I think not possible without changing something in the interpreter, the language can’ t do this I think.

yep:

So you can see why formatting only applies to a single line…

Adding one or two more string hooks for the sake of error formatting could be reasonable (those strings could even be scrubbed from the actual output).

1 Like

The Post Window would not work with ANSI codes, but that would work in other environments. In any case, a solution inside the IDE would be easier to improve than what QtCollider already does. (But I believe a programming language should be used in different contexts, and editors should not ignore ANSI code sequences.)