bool
ArxDbgUiPrKeyWordDef::keyWordMatch()
{
    CString kword;
    CString keyWordList = keyWords();
    int defLen = m_default.GetLength();
    int kwordLen = keyWordList.GetLength();
    int i = 0;
    while (1) {
            // parse out an individual keyword
        kword.Empty();
        while ((i < kwordLen) && (keyWordList[i] != _T(' ')))
            kword += keyWordList[i++];

            // see if it matches the default
        if (!_tcsncmp(kword, m_default, defLen)) {
            m_keyWordPicked = kword;
            return true;
        }
        if (i >= kwordLen) {
            ASSERT(0);    // should never happen
            return false;
        }
        else {
            while (keyWordList[i] == _T(' ')) // chew any whitespace between words
                i++;
        }
    }
}
ArxDbgUiPrBase::Status
ArxDbgUiPrCorner::go()
{
    CString prompt;
    int result;
    ads_point adsPt;
    int initFlag = RSG_NONULL;

    if (m_noLimCheck == true)
        initFlag += RSG_NOLIM;
    if (m_useDashedLine == true)
        initFlag += RSG_DASH;

    prompt.Format(_T("\n%s: "), message());

    acedInitGet(initFlag, keyWords());
    result = acedGetCorner(asDblArray(m_basePt), prompt, adsPt);

    if (result == RTNORM) {
        m_value = asPnt3d(adsPt);
        return ArxDbgUiPrBase::kOk;
    }
    else if (result == RTKWORD) {
        const size_t kBufSize = 512;
        acedGetInput(m_keyWordPicked.GetBuffer(kBufSize), kBufSize);
        m_keyWordPicked.ReleaseBuffer();
        return ArxDbgUiPrBase::kKeyWord;
    }
    else
        return ArxDbgUiPrBase::kCancel;
}
示例#3
0
bool Highlighter::capitalize( const QTextBlock &block,QTextCursor cursor ){

    QString text=block.text();
    QColor color;

    int i=0,pos=cursor.position();

    cursor.beginEditBlock();

    for(;;){
        QString t=parseToke( text,color );
        if( t.isEmpty() ) break;

        QString kw=keyWords().value( t.toLower() );

        if( !kw.isEmpty() && t!=kw ){
            int i0=block.position()+i;
            int i1=i0+t.length();
            cursor.setPosition( i0 );
            cursor.setPosition( i1,QTextCursor::KeepAnchor );
            cursor.insertText( kw );
        }

        i+=t.length();
    }

    cursor.endEditBlock();

    cursor.setPosition( pos );

    return true;
}
ArxDbgUiPrBase::Status
ArxDbgUiPrAngleDef::go()
{
    CString prompt;
    char defStr[512];
    int initFlag;

        // set up prompt
    acdbAngToS(m_default, m_unit, m_precision, defStr);
    prompt.Format(_T("\n%s<%s>: "), message(), defStr);

        // set up init flag
    if (m_angType == kNoZero)
        initFlag = RSG_NOZERO;
    else
        initFlag = 0;

    int result;
    while (1) {
        acedInitGet(initFlag, keyWords());
        if (m_useBasePt)
            result = acedGetOrient(asDblArray(m_basePt), prompt, &m_value);
        else
            result = acedGetOrient(NULL, prompt, &m_value);

        if (result == RTNORM) {
            if (inRange())
                return ArxDbgUiPrBase::kOk;
        }
        else if(result == RTKWORD) {
            acedGetInput(m_keyWordPicked.GetBuffer(512));
            m_keyWordPicked.ReleaseBuffer();
            return ArxDbgUiPrBase::kKeyWord;
        }
        else if (result == RTNONE) {
            if (m_angType == ArxDbgUiPrAngle::kRange) {
                ASSERT(m_minVal != m_maxVal);    // make sure they set ranges!
                ASSERT((m_default >= m_minVal) && (m_default <= m_maxVal));
            }
            m_value = m_default;
            return ArxDbgUiPrBase::kOk;
        }
        else
            return ArxDbgUiPrBase::kCancel;
    }
}
示例#5
0
ArxDbgUiPrBase::Status
ArxDbgUiPrInt::go()
{
    CString prompt;
    int initFlag;

        // set up prompt
    prompt.Format(_T("\n%s: "), message());

        // set up init flag
    if (m_intType == kNoZero)
        initFlag = RSG_NONULL+RSG_NOZERO;
    else if (m_intType == kNoNeg)
        initFlag = RSG_NONULL+RSG_NONEG;
    else if (m_intType == kNoNegNoZero)
        initFlag = RSG_NONULL+RSG_NOZERO+RSG_NONEG;
    else if (m_intType == kNoNegNoZeroAllowNone)
		initFlag = RSG_NOZERO+ RSG_NONEG;
	else
        initFlag = RSG_NONULL;

    while (1) {
        acedInitGet(initFlag, keyWords());
        int result = acedGetInt(prompt, &m_value);

        if (result == RTNORM) {
            if (inRange())
                return ArxDbgUiPrBase::kOk;
        }
        else if (result == RTKWORD)
		{
            acedGetInput(m_keyWordPicked.GetBuffer(512));
            m_keyWordPicked.ReleaseBuffer();
            return ArxDbgUiPrBase::kKeyWord;
        }
		else if (result == RTNONE)
		{
			return ArxDbgUiPrBase::kNone;
		}
        else
            return ArxDbgUiPrBase::kCancel;
    }
}
示例#6
0
ArxDbgUiPrBase::Status
ArxDbgUiPrAngle::go()
{
    CString prompt;
    int initFlag = 0;

        // set up prompt
    prompt.Format(_T("\n%s: "), message());

        // set up init flag
    if (m_allowNone == false)
        initFlag += RSG_NONULL;

    if (m_angType == kNoZero)
        initFlag += RSG_NOZERO;

    int result;
    while (1) {
        acedInitGet(initFlag, keyWords());
        if (m_useBasePt)
            result = acedGetOrient(asDblArray(m_basePt), prompt, &m_value);
        else
            result = acedGetOrient(NULL, prompt, &m_value);

        if (result == RTNORM) {
            if (inRange())
                return ArxDbgUiPrBase::kOk;
        }
        else if (result == RTKWORD) {
            acedGetInput(m_keyWordPicked.GetBuffer(512));
            m_keyWordPicked.ReleaseBuffer();
            return ArxDbgUiPrBase::kKeyWord;
        }
		else if (result == RTNONE)
		{
			  if (inRange())
                return ArxDbgUiPrBase::kOk;
		}
        else
            return ArxDbgUiPrBase::kCancel;
    }
}
ArxDbgUiPrBase::Status
ArxDbgUiPrKeyWordDef::go()
{
    CString prompt;

    prompt.Format(_T("\n%s<%s>: "), message(), m_default);

    acedInitGet(0, keyWords());
    const size_t kBufSize = 512;
    int result = acedGetKword(prompt, m_keyWordPicked.GetBuffer(kBufSize), kBufSize);
    m_keyWordPicked.ReleaseBuffer();

    if (result == RTNORM) {
        return ArxDbgUiPrBase::kOk;
    }
    else if (result == RTNONE) {
        if (keyWordMatch() == Adesk::kTrue)
            return ArxDbgUiPrBase::kOk;
        else
            return ArxDbgUiPrBase::kCancel;
    }
    else
        return ArxDbgUiPrBase::kCancel;
}
示例#8
0
ArxDbgUiPrBase::Status
ArxDbgUiPrEntity::go()
{
    CString prompt;
    int result;
    int errNum;
    ads_point adsPt;
    ads_name ent;
    AcDbObjectId tmpId;
    AcDbEntity* tmpEnt;
    Acad::ErrorStatus es;

    prompt.Format(_T("\n%s: "), message());

    while (1) {
        acedInitGet(0, keyWords());
        result = acedEntSel(prompt, ent, adsPt);

        if (result == RTNORM) {
            ArxDbgUtils::enameToObjId(ent, tmpId);
            es = acdbOpenAcDbEntity(tmpEnt, tmpId, AcDb::kForRead);
            if (es == Acad::eOk) {
                    // if its correct class and we are not filtering locked layers its ok,
                    // or if we are filtering locked layers and this one isn't on a locked layer
                if (correctClass(tmpEnt)) {     // correctClass() will print error msg
                    if ((!m_filterLockedLayers) ||
                        (ArxDbgUtils::isOnLockedLayer(tmpEnt, true) == false)) {    // isOnLockedLayer() will print error msg
                        tmpEnt->close();
                        m_pickPt = asPnt3d(adsPt);
                        m_objId = tmpId;
                        return ArxDbgUiPrBase::kOk;
                    }
                }
                tmpEnt->close();    // close and loop again until they get it right!
            }
            else {
                ASSERT(0);
                ArxDbgUtils::rxErrorMsg(es);
                return ArxDbgUiPrBase::kCancel;
            }
        }
        else if (result == RTERROR) {
            getSysVar(AcadVar::adserr, errNum);
            if (errNum == OL_ENTSELPICK)            // picked but didn't get anything
                acutPrintf(_T("\nNothing selected."));
            else if (errNum == OL_ENTSELNULL) {     // hit RETURN or SPACE
                if (m_allowNone)
                    return ArxDbgUiPrBase::kNone;      // prompt specifically wants to know about None
                else
                    return ArxDbgUiPrBase::kCancel;    // prompt wants to bail on None
            }
            else
                acutPrintf(_T("\nNothing selected."));
        }
        else if (result == RTKWORD)
		{
            acedGetInput(m_keyWordPicked.GetBuffer(512));
            m_keyWordPicked.ReleaseBuffer();
            return ArxDbgUiPrBase::kKeyWord;
        }
		else if (result == RTNONE)
		{
			return ArxDbgUiPrBase::kNone;
		}
        else
            return ArxDbgUiPrBase::kCancel;
    }
}
示例#9
0
QString Highlighter::parseToke( QString &text,QColor &color ){
    if( !text.length() ) return "";

    int i=0,n=text.length();
    QChar c=text[i++];

    bool monkeyFile=_editor->isMonkey();

    if( c<=' ' ){
        while( i<n && text[i]<=' ' ) ++i;
    }else if( isAlpha(c) ){
        while( i<n && isIdent(text[i]) ) ++i;
        color=_identifiersColor;
        if( monkeyFile && keyWords().contains( text.left(i).toLower()  ) ) color=_keywordsColor;
    }else if( c=='0' && !monkeyFile ){
        if( i<n && text[i]=='x' ){
            for( ++i;i<n && isHexDigit( text[i] );++i ){}
        }else{
            for( ;i<n && isOctDigit( text[i] );++i ){}
        }
        color=_numbersColor;
    }else if( isDigit(c) || (c=='.' && i<n && isDigit(text[i])) ){
        bool flt=(c=='.');
        while( i<n && isDigit(text[i]) ) ++i;
        if( !flt && i<n && text[i]=='.' ){
            ++i;
            flt=true;
            while( i<n && isDigit(text[i]) ) ++i;
        }
        if( i<n && (text[i]=='e' || text[i]=='E') ){
            flt=true;
            if( i<n && (text[i]=='+' || text[i]=='-') ) ++i;
            while( i<n && isDigit(text[i]) ) ++i;
        }
        color=_numbersColor;
    }else if( c=='%' && monkeyFile && i<n && isBinDigit( text[i] ) ){
        for( ++i;i<n && isBinDigit( text[i] );++i ){}
        color=_numbersColor;
    }else if( c=='$' && monkeyFile && i<n && isHexDigit( text[i] ) ){
        for( ++i;i<n && isHexDigit( text[i] );++i ){}
        color=_numbersColor;
    }else if( c=='\"' ){
        if( monkeyFile ){
            for( ;i<n && text[i]!='\"';++i ){}
        }else{
            for( ;i<n && text[i]!='\"';++i ){
                if( text[i]=='\\' && i+1<n && text[i+1]=='\"' ) ++i;
            }
        }
        if( i<n ) ++i;
        color=_stringsColor;
    }else if( !monkeyFile && c=='/' && i<n && text[i]=='/' ){
        for( ++i;i<n && text[i]!='\n';++i ){}
        if( i<n ) ++i;
        color=_commentsColor;
    }else if( c=='\'' ){
        if( monkeyFile ){
            for( ;i<n && text[i]!='\n';++i ){}
            if( i<n ) ++i;
            color=_commentsColor;
        }else{
            for( ;i<n && text[i]!='\'';++i ){
                if( text[i]=='\\' && i+1<n && text[i+1]=='\'' ) ++i;
            }
            if( i<n ) ++i;
            color=_stringsColor;
        }
    }else{
        color=_defaultColor;
    }
    QString t=text.left(i);
    text=text.mid(i);
    return t;
}