void Buffer::onUpdateUi() {
    if (m_braceHighlight && selectionEmpty()) {
        sptr_t position = currentPos();
        sptr_t braceStart = -1;
        // Check previous character first.
        if (position != 0 && isBrace(charAt(position - 1))) {
            braceStart = position - 1;
        } else if (isBrace(charAt(position))) { // Check next character.
            braceStart = position;
        }
        if (braceStart != -1) {
            // Brace found
            sptr_t braceEnd = braceMatch(braceStart);
            if (braceEnd > 0) {
                braceHighlight(braceStart, braceEnd);
            } else {
                // Missing matching brace.
                braceBadLight(braceStart);
            }
        } else {
            // Not a brace, clear indicators.
            braceBadLight(-1);
        }
    }
}
Example #2
0
void Builder::parse( const char* content )
{
    NodeManager* mgr = NodeManager::getSingleton();
    const char* last = content;
    int width;
    while( *content ) {
        if( (width = isBlank(content)) > 0 ) {
            content += width;
        } else if( (width = isOp( content )) > 0 ) {
            mgr->createOperator(content, width);
            mgr->createOperand(content, content-last);
            last = content;
            content += width;
        } else if( (width = isBrace( content )) > 0 ) {
            mgr->createBrace(content, width);
            last = content;
            content += width;
        }
        content ++;
    }
}