Exemplo n.º 1
0
static int findBestLineToScrollTo (StringArray lines, StringRef className)
{
    for (auto line : lines)
    {
        if (line.contains ("struct " + className) || line.contains ("class " + className))
        {
            auto index = lines.indexOf (line);

            if (isDivider (lines[index - 1]))
                return index - 1;

            if (isEndOfCommentBlock (lines[index - 1]))
            {
                auto blockStartIndex = getIndexOfCommentBlockStart (lines, index - 1);

                if (blockStartIndex > 0 && isDivider (lines [blockStartIndex - 1]))
                    return blockStartIndex - 1;

                return blockStartIndex;
            }

            return lines.indexOf (line);
        }
    }

    return 0;
}
Exemplo n.º 2
0
void matchStacks() {
    int i = 0; //stack_str index
    int j = 1; //stack index
    
    while ( j <= sp) {
        //skip AR dividers
        if( !isDivider(i) ) {
            char buf[50];
            
            // convert stack[j] to string and place in buffer
            sprintf(buf,"%d",stack[j]);
            
            //if the strings are different, copy buf to stack_str[i]
            if( strcmp(stack_str[i], buf) != 0) {
                strcpy(stack_str[i], buf);
            }
            
            //update indecies
            str_top = i;
            j++;
        }
        
        i++;
        
        //incase j is not incremented past sp
        if( i > MAX_STACK_HEIGHT) {
            printf("error@matchStacks(): i > MAX_STACK_HEIGHT");
            exit(1);
        }
        
    }
}
Exemplo n.º 3
0
void removeTopAR() {
    int i = str_top;
    
    //find index of AR divider closest to top of stack
    while ( !isDivider(i) ) {
        //clear element
        memset(&stack_str[i], 0, sizeof(stack_str[i]));
        i--;
    }
    //set the divier to 0
    memset(&stack_str[i], 0, sizeof(stack_str[i]));
    
    str_top = i - 1;
}