Exemple #1
0
void VMsgLog::editRequest( WMenuItem* )
{
    int index = _batcher->selected();
    if( index >= 0 ) {
        const char* text = *(WString*)_data[index];
        char file[101]; int line, offset; char help[51];
        if( matchLine( index, file, line, offset, help ) ) {
            WSystemHelp *sh;
            const char *hf;
            if( findHelpFile( file, &sh, 0 ) == 0 ) {
                hf = "";
            } else {
                hf = sh->getHelpFile();
            }
            WString msg;
            int resId = atoi( help ) + 1;
            WFileName filename( file );
            if( filename.needQuotes() ) {
                msg.printf( "EditFileAtPos -f\"%s\" %d %d 0 %d",
                            file, line, offset, resId );
            } else {
                msg.printf( "EditFileAtPos -f%s %d %d 0 %d",
                            file, line, offset, resId );
            }
            msg.concat( " \"" );
            msg.concat( text ); // error message
            msg.concat( "\" " );
            msg.concat( hf ); // help file
            _parent->executeCommand( msg, EXECUTE_EDITOR, "LogEdit" );
        } else {
            WMessageDialog::info( this, "Can't find a filename in '%s'", text );
        }
    }
}
Exemple #2
0
bool VpeMain::execute( const WString& cmd )
{
    if( _config->debug() && !confirm( "Starting '%s'", cmd ) ) {
        return( false );
    }
    startWait();

    size_t icount = strlen( cmd );
    for( size_t i = 0; i < icount; ) {
        WString cbuff;
        while( isspace( cmd[i] ) ) i++;
        for( ; i < icount; ) {
            char ch = cmd[i];
            i++;
            if( ch == '\n' || ch == '\r' ) break;
            cbuff.concat( ch );
        }
        if( cbuff.size() > 0 ) {
            if( strnicmp( cbuff, "!Error ", 7 ) == 0 ) {
                WString msg;
                for( size_t i = 7; i < cbuff.size() && cbuff[i] != '$'; i++ ) {
                    msg.concat( cbuff[i] );
                }
                WMessageDialog::messagef( this, MsgError, MsgOk, _viperError, msg );
                return( false );
            } else {
                if( !executeOne( cbuff ) ) {
                    return( false );
                }
            }
        }
    }
    return( true );
}
Exemple #3
0
void MWorkFile::dump( WFile& fil )
{
    MRule* rule = _item->rule();
    WString& mask = _component->mask();

    fil.printf( "#%FP", this );
    fil.printf( ", %s:%s", (const char*)mask, (const char*)rule->tag() );
    fil.printf( ", %s", (const char*)*this );

    WString n;
    int icount = _states.count();
    if( icount > 0 ) {
        bool first = TRUE;
        for( int i=0; i<icount; i++ ) {
            MState* st = (MState*)_states[i];
            WString temp;
            st->sw()->getText( temp, st );
            if( temp.size() > 0 ) {
                if( first ) n.concat( " (" );
                if( !first ) n.concat( ' ' );
                n.concat( temp );
                first = FALSE;
            }
        }
        if( !first ) n.concat( ')' );
    }
    fil.printf( " %s\n", (const char*)n );
}
Exemple #4
0
void MConfig::expandMacroes( WString &str ) {
    WString     tok( str );
    WString     envvar;
    unsigned    i;

    str = "";
    for( i=0; tok[i] != '\0'; i++ ) {
        if( tok[i] == '$' && tok[i+1] == '(' && tok[i+2] == '%' ) {
            envvar = "";
            i += 3;
            for( ;; i++ ) {
                if( tok[i] == '\0' ) {
                    str.concat( "$%(" );
                    str.concat( envvar );
                    str.concat( tok[i] );
                    i--; // don't let the outside loop go past the NULLCHAR
                    break;
                } else if( tok[i] == ')' ) {
                    str.concat( getenv( envvar ) );
                    break;
                } else {
                    envvar.concat( tok[i] );
                }
            }
        } else {
            str.concat( tok[i] );
        }
    }
}
void MC2Switch::addone( WString& str, bool state )
{
    if( state && _on.size() > 0 ) {
        str.concat( _on );
    } else if( !state && _off.size() > 0 ) {
        str.concat( _off );
    }
}
Exemple #6
0
void MItem::name( WString& n )
{
    n = "";
    if( !isMask() ) {
        n.concat( *this );
    } else {
        n.concat( "( " );
        n.concat( this->ext() );
        n.concat( " )" );
    }
    addDecorators( n );
}
Exemple #7
0
void MConfig::kludgeMask( WString& str )
{
    if( _kludge ) {
        WString temp;
        for( size_t i=0; i<str.size(); i++ ) {
            temp.concat( str[i] );
            if( _kludge == 3 && i == 0 ) temp.concat( '?' );
            if( _version > 1 && _kludge == 3 && i == 2 ) temp.concat( '?' );
            if( _version > 1 && _kludge == 4 && i == 3 ) temp.concat( '?' );
        }
        str = temp;
    }
}
Exemple #8
0
void TreeNode::sibWidth()
//-----------------------
{
    WString     msg;
    TreeNode *  node;
    int         i;
    bool        sepInc = true;

    msg.concatf( "%s: _sibWidth = %ld; parents: ",
                        _nm ? _nm : "<>", _sibWidth );

    for( i = 0; i < getCount( ParentList ); i += 1 ) {
        node = getNode( ParentList, i );
        msg.concatf( "%s: sibContrib() = %ld; ",
                     node->_nm ? node->_nm : "<>",
                     node->getSibContrib( this, sepInc ) );
    }

    msg.concat( "children: " );
    for( i = 0; i < getCount( ChildList ); i += 1 ) {
        node = getNode( ChildList, i );
        msg.concatf( "%s: _sibWidth = %ld; ",
                     node->_nm ? node->_nm : "<>", node->_sibWidth );
    }

    WMessageDialog::message( _parent, MsgPlain, MsgOk, msg.gets(),
                            "Source Browser" );
}
Exemple #9
0
void MComponent::expand( WString& c, const MCommand& cmd )
{
    if( cmd.size() > 0 ) {
        cmd.expand( c, _target, _config->nilTool(), _mask, NULL, _mode );
        c.concat( "\n" );
        _project->insertBlanks( c );
    }
}
Exemple #10
0
void MAction::text( WString& t )
{
    int icount = _name.size();
    for( int i=0; i<icount; i++ ) {
        if( _name[i] != '&' ) {
            t.concat( _name[i] );
        }
    }
}
Exemple #11
0
void MProject::insertBlanks( WString& s )
{
    WString ss;
    bool lineStart = true;
    for( size_t i=0; i<s.size(); i++ ) {
        if( lineStart && s[i] != ' ' && s[i] != '!' ) {
            ss.concat( ' ' );
        }
        ss.concat( s[i] );

        if( s[i] == '\n' ) {
            lineStart = true;
        } else {
            lineStart = false;
        }
    }
    s = ss;
}
Exemple #12
0
void MComponent::typeDesc( WString& n )
{
    if( _config->debug() ) {
        n.concatf( "(%s)->", (const char*)_mask );
    }
    for( int i=0; i<_config->targets().count(); i++ ) {
        MTarget* tar = (MTarget*)_config->targets()[i];
        if( tar->mask() == _mask ) {
            if( _config->debug() ) {
                n.concatf( "(%s) ", (const char*)tar->mask() );
            }
            WString name;
            tar->name( name );
            n.concat( name );
            return;
        }
    }
    n.concat( "Obsolete form: Rename target type" );
}
Exemple #13
0
StrucView::StrucView( int x, int y, Symbol * info )
    :WBRWindow( WRect(x,y,StrucWidth,StrucHeight), "" )
    ,_listbox( new VerboseListBox( WRect( 5, 30, -5, -25 ), this ))
    ,_listobjs( new WVList )
    ,_type( new WText( this, WRect( 5, -20, -5, -2 ), NULL,
                       TextStyleLeftNoWrap | TextStyleAmpersands ))
    ,_treeRoot(NULL)
    ,_nodesSeen( new WVList )
    ,_lattice( new ClassLattice( info ) )
    ,_filter( activeProject->getFiltFlags( Filt_Members ))
//-------------------------------------------------------------------
{
    WString title = info->name();
    Symbol * sym;

    title.concat( " Structure" );
    setText( title );

    _listbox->setCallbacks( this, (cbw)&StrucView::itemSelected,
                        (bcbwi)&StrucView::keyPressed,
                        (cbw)&StrucView::itemDblClicked );
//  _listbox->setFont(stdFont);
    _listbox->select( 0 );
    _listbox->show();
//  _type->setFont(stdFont);
    _type->show();

    WPushButton * bttn;
    bttn = new WPushButton( this, WRect( 5, 2, 25, 25 ), "+" );
    bttn->onClick( this, (cbw) plusSelected );
    bttn->show();

    bttn = new WPushButton( this, WRect( 40, 2, 25, 25 ), "-" );
    bttn->onClick( this, (cbw) minusSelected );
    bttn->show();

    bttn = new WPushButton( this, WRect( 75, 2, 25, 25 ), "*" );
    bttn->onClick( this, (cbw) starSelected );
    bttn->show();

    bttn = new WPushButton( this, WRect( -70, 2, 65, 25 ), "&Filters..." );
    bttn->onClick( this, (cbw) filterSelected );
    bttn->show();

    sym = Symbol::defineSymbol( info );
    _treeRoot = new StrucViewItem( this, sym );
    reset();

    _listbox->setFocus();
    show();
}
Exemple #14
0
void VMsgLog::doRun()
{
    _running = TRUE;
    if( isIconic() ) {
        show( WWinStateShowNormal );
    } else {
        show();
    }
    setFocus();
    _batcher->setFocus();
    if( _cwd.size() > 0 ) {
        WString c( "cd " );
        c.concat( _cwd );
        lastCD = "";
        if( !_batserv ) {
            runCmd( c );
        } else {
            addLine( c );
            BatchChdir( _cwd );
        }
    }

    int icount = _command.size();
    for( int i=0; i<icount; ) {
        WString cbuff;
        for( ;i<icount; ) {
            char ch = _command[i++];
            if( ch == '\n' ) break;
            cbuff.concat( ch );
        }
        if( cbuff.size() > 0 ) {
            runCmd( cbuff );
        }
    }
    addLine( "Execution complete" );
    _running = FALSE;
    _parent->quickRefresh();
}
Exemple #15
0
void MItem::addDecorators( WString& n )
{
    if( _config->debug() ) {
        n.concat( " '" );
        n.concat( _ruleTag );
        n.concat( "'" );
    }
    if( _states.count() > 0 ) {
        n.concat( " [sw]" );
    }
    if( !isMask() ) {
        if( _exists ) {
#ifndef __UNIX__
            if( (_attribs & _A_RDONLY) ) {
                n.concat( " [r/o]" );
            }
#endif
        } else {
            n.concat( " [n/a]" );
        }
    }
}
Exemple #16
0
bool VpeMain::executeCommand( const char *cmdl, int location, const char* title )
{
    int i;

    if( cmdl != NULL && strlen( cmdl ) > 0 ) {
        WString* cur = NULL;
        WStringList opts;
        for( i=0; cmdl[i]!= '\0'; i++ ) {
            if( cur ) {
                if( cmdl[i] == '"' ) {
                    opts.add( cur );
                    cur = NULL;
                } else {
                    cur->concat( cmdl[i] );
                }
            } else if( cmdl[i] == '$' && cmdl[i+1] == '"' ) {
                i++;
                cur = new WString();
            }
        }
        delete cur;
        cur = NULL;
        WStringList reps;
        if( opts.count() > 0 ) {
            WString dTitle( title );
            if( dTitle.size() == 0 )
                dTitle = "AutoDialog";
            WAutoDialog prompts( this, dTitle, opts );
            if( !prompts.getInput( reps ) ) {
                setStatus( NULL );
                return( false );
            }
        }
        WString cmd;
        int j = 0;
        for( i=0; cmdl[i]!= '\0'; i++ ) {
            if( !cur ) {
                if( cmdl[i] == '$' && cmdl[i+1] == '"' ) {
                    i++;
                    cur = &reps.stringAt( j );
                    j++;
                } else {
                    cmd.concat( cmdl[i] );
                }
            } else if( cmdl[i] == '"' ) {
                cmd.concat( *cur );
                cur = NULL;
            }
        }
        startWait();
        switch( location ) {
            case EXECUTE_NORMAL: {
                setStatus( "Executing..." );
                execute( cmd );
                break;
            }
            case EXECUTE_BATCH: {
                runBatch( cmd );
                break;
            }
            case EXECUTE_MAKE: {
                if( makeMake() ) {
                    runBatch( cmd );
                }
                break;
            }
            case EXECUTE_BROWSE: {
                executeBrowse( cmd );
                break;
            }
            case EXECUTE_EDITOR: {
                executeEditor( cmd );
                break;
            }
            case EXECUTE_TOUCH_ALL: {
                MsgRetType      rc;
                unsigned        i;
                VComponent      *comp;
                rc = WMessageDialog::messagef( this, MsgQuestion, MsgYesNo,
                        _viperRequest,
                        "Do you really want to remake all targets and their components?" );
                if( rc == MsgRetYes ) {
                    i = _compViews.count();
                    while( i > 0 ) {
                        comp = (VComponent *)_compViews[i-1];
                        comp->touchComponent( true );
                        i--;
                    }
                }
                break;
            }
            case EXECUTE_HELP: {
                if( _otherhelp == NULL ) {
                    delete _otherhelp;
                }
                _otherhelp = new WSystemHelp( this, "", cmd );
                _otherhelp->sysHelpContent();
                break;
            }
        }
        stopWait();
        setStatus( NULL );
        if( _quitAnyways ) {
            exit( NULL );
        }
    }
    return( true );
}
Exemple #17
0
DescriptionPaint::DescriptionPaint( WBRWindow * prnt, const WRect & r,
                                    Symbol * sym )
                    : _parent( prnt )
                    , _rect( r )
                    , _current( -1 )
//--------------------------------------------------------------------
{
    int             i;
    WVList          desc;
    Description *   entry;
    WString         buf;
    const char *    uDefSymName;
    int             x = r.x();
    int             w;
    int             h;

    _parts = new WCPtrOrderedVector<DescriptionPart>;

    sym->description( desc );

    for( i = 0; i < desc.count(); i += 1 ) {
        entry = (Description *) desc[i];
        if( entry->symbol() ) {
            if( sym->isEqual( entry->symbol() ) ) {

                // don't hilight the symbol we're describing
                buf.concat( entry->name() );
                delete entry->symbol();

            } else {

                if( buf != "" ) { // flush buf
                    w = prnt->getTextExtentX( buf );
                    h = prnt->getTextExtentY( buf );
                    _parts->append( new DescriptionPart( buf.gets(), NULL,
                                        WRect(x,r.y(),w, h ) ) );

                    buf="";
                    x+=w;
                }

                uDefSymName = entry->name();
                w = prnt->getTextExtentX( uDefSymName );
                h = prnt->getTextExtentY( uDefSymName );
                _parts->append( new DescriptionPart( uDefSymName,
                                                     entry->symbol(),
                                                     WRect(x,r.y(),w, h ) ) );
                x+=w;
            }
        } else {
            buf.concat( entry->name() );
        }
    }

    desc.deleteContents();


    if( buf != "" ) { // flush buf
        w = prnt->getTextExtentX( buf );
        h = prnt->getTextExtentY( buf );
        _parts->append( new DescriptionPart( buf, NULL,
                                WRect(x,r.y(),w, h ) ) );

        buf="";
        x+=w;
    }

    _rect.w( x - abs( _rect.x() ) );
}