Exemplo n.º 1
0
GmodelVar GmodelVar::deepCopy()
{
	GmodelVar gVar = GmodelVar(m_mode, m_type, m_name, m_name->getFileName(), getEndLine(), getBlockName(), getBlockPath());
	if(m_isPrim) gVar.setAsPrim();

	return gVar;
}
Exemplo n.º 2
0
/**
 * Style needed
 */
void FbEditor::onStyleNeeded(wxStyledTextEvent & event)
{
    // startint position
    auto startPos  = GetEndStyled();
    auto startLine = LineFromPosition(startPos);
    startPos       = PositionFromLine(startLine);
    // end position
    int lastPos    = event.GetPosition();
    int lastLine   = std::max(LineFromPosition(lastPos), std::min(GetLineCount(), GetFirstVisibleLine() + LinesOnScreen()));
    lastPos        = GetLineEndPosition(lastLine);
        
    // get token
    auto token = m_srcCtx->getLine(startLine, lastLine);
    
    // set stylling position
    StartStyling(startPos, INT_MAX);
    
    // clear indicatirs
    SetIndicatorCurrent(ErrorIndicator);
    IndicatorClearRange(startPos, lastPos - startPos);
    
    // no token? just colour to default
    if (!token) {
        style(lastPos - startPos, TokenStyle::Default);
        return;
    }
    
    
    // style the tokens
    int line = startLine;
    int col  = 0;
    while (token && line <= lastLine) {
        // end of the line?
        if (token->getKind() == TokenKind::EndOfLine) {
            token = token->getNext();
            continue;
        }
        
        // token line
        int tline = token->getLine();
        
        // token started before current line
        if (line > tline) {
            int start = PositionFromLine(line);
            int end   = PositionFromLine(token->getEndLine()) + token->getEndCol();
            style(end - start, token);
            
            // end on line and column
            col  = token->getEndCol();
            line = token->getEndLine();
            
            // get next token and continue
            token = token->getNext();
            continue;
        }
        
        // empty lines before next token?
        if (line < tline) {
            int start = PositionFromLine(line) + col;
            int end   = PositionFromLine(tline) + token->getCol();
            style(end - start, TokenStyle::Default);
            
            // end on line and column
            line = token->getLine();
            col = token->getCol();
            continue;
        }
        
        // started on the current line
        if (line == tline) {
            // empty space ?
            if (token->getCol() > col) {
                style(token->getCol() - col, TokenStyle::Default);
            }
            
            // style the token
            style(token->getLength(), token);
            col = token->getEndCol();
            line = token->getEndLine();
            
            // advance to the next one
            token = token->getNext();
            continue;
        }
        
        // some empty space till end of the line
        int length = GetLineLength(line);
        if (col < length) {
            style(length - col, TokenStyle::Default);
        }
        
        // incement line
        line++;
        col = 0;
    }
}
Exemplo n.º 3
0
void Gtoken::print()
{
	printf("{%s, %s, %d, %d}\n", m_data.c_str(), getBlockPath().c_str(), getEndLine(), m_type);
}
Exemplo n.º 4
0
bool TextImportConfig::parserToOneColumn()
{
    if(!m_parser->isValid())
    {
        return false;
    }
    m_data.clear();
    m_parser->seek(0);
    QString line;
    int lineCount = 0;
    int startLine = getStartLine();
    int endLine = getEndLine();
    saDebug(QString("[start parser] startLine:%1 ,endLine:%2 ").arg(startLine).arg(endLine));
    double d = 0;
    bool isOK = false;
    auto pd = SAValueManager::makeData<SAVectorDouble>();
    m_data.append(std::static_pointer_cast<SAAbstractDatas>(pd));
    do{

        line = m_parser->readLine();
        ++lineCount;
        if(startLine > 0)
        {//需要忽略头n行
            if(lineCount<startLine)
                continue;
        }
        if(endLine > 0)
        {//有指定结束范围
            if(lineCount>endLine)
            {
                break;
            }
        }

        QStringList strlist;
        if(Txt == m_textType)
        {
            QString seperator = getSpliter();
            if(seperator.isEmpty ())
            {//没有指定分割
                strlist << line;
            }
            else
            {//指定了分割,先进行分割
                 strlist = line.split (seperator);
            }
        }
        else if(Csv == m_textType)
        {

            strlist =  SACsvParser::fromCsvLine(line);
        }


        int sps = strlist.size ();
        for(int i=0;i<sps;++i)
        {
            d = strlist[i].toDouble(&isOK);
            if(isOK)
            {
                pd->append(d);
            }
        }
    }while(!line.isNull ());
    emit dataChanged();
    return true;
}
Exemplo n.º 5
0
void Gtoken::print(unsigned int indent)
{
	for (unsigned int i=0; i<indent; i++) 
		printf("|  ");
	printf("|- {%s, %s, %d, %d}\n", m_data.c_str(), getBlockPath().c_str(), getEndLine(), m_type);
}