vpemain2.cpp

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C++ 代码 · 共 595 行 · 第 1/2 页

CPP
595
字号
/****************************************************************************
*
*                            Open Watcom Project
*
*    Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
*  ========================================================================
*
*    This file contains Original Code and/or Modifications of Original
*    Code as defined in and that are subject to the Sybase Open Watcom
*    Public License version 1.0 (the 'License'). You may not use this file
*    except in compliance with the License. BY USING THIS FILE YOU AGREE TO
*    ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
*    provided with the Original Code and Modifications, and is also
*    available at www.sybase.com/developer/opensource.
*
*    The Original Code and all software distributed under the License are
*    distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
*    EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
*    ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
*    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
*    NON-INFRINGEMENT. Please see the License for the specific language
*    governing rights and limitations under the License.
*
*  ========================================================================
*
* Description:  WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
*               DESCRIBE IT HERE!
*
****************************************************************************/

#include <stdio.h>
#include <io.h>
#include <stdlib.h>

extern "C" {
    #include "rcdefs.h"
    #include "banner.h"
};

#include "vpemain.hpp"
#include "vmsglog.hpp"

#include "wwinmain.hpp"
#include "wmenu.hpp"
#include "wfiledlg.hpp"
#include "wmsgdlg.hpp"
#include "winpdlg.hpp"
#include "wpickdlg.hpp"
#include "wautodlg.hpp"
#include "weditdlg.hpp"
#include "wfilenam.hpp"
#include "wobjfile.hpp"
#include "wstrlist.hpp"
#include "wserver.hpp"
#include "wclient.hpp"
#include "wprocess.hpp"
#include "mconfig.hpp"

#include "vcompon.hpp"
#include "mcompon.hpp"
#include "maction.hpp"
#include "mtarget.hpp"
#include "mtoolitm.hpp"
#include "vcompdlg.hpp"

#include "wabout.hpp"
#include "mcommand.hpp"
#include "wmetrics.hpp"
#include "wsystem.hpp"

#include "wstatwin.hpp"
#include "wflashp.hpp"
#include "vhelpstk.hpp"
#include "veditdlg.hpp"
#include "ide.h"
#include "mitem.hpp"
#include "inifile.hpp"

#define MAX_CMD_LINE            256

extern char _viperTitle[];
extern char _viperError[];
extern char _viperRequest[];
extern char _viperInfo[];

void VpeMain::cForPBProject( WFileName &pj, bool nt ) {

    WString     mask( "wp6d" );

    if( nt ) {
        mask = "np2d";
    }
#ifdef __NT__
    mask.concat( 'n' );
#else
    mask.concat( 'w' );
#endif
    if( _project == NULL || _project->filename() != pj && okToClear() ) {
        clearProject();
        // eventually access should be provided by WCLASS
        if( !access( pj, F_OK ) ) {
            loadProject( pj );
        } else {
            _project = new MProject( pj );
            attachModel( _project );
            WFileName targname( pj );
            targname.setExt( ".dll" );
            MRule *rule = _config->findMatchingRule( targname, mask );
            MComponent* mcomp = new MComponent( _project, rule, mask, targname );
            _project->addComponent( mcomp );
            VComponent* vcomp = new VComponent( this, mcomp, vCompStyle() );
            _compViews.add( vcomp );
            mcomp->updateItemList();
        }
    }
    // update targets
    if( _project != NULL ) {
        unsigned        cnt;
        MComponent      *mcomp;

        cnt = _project->components().count();
        for( ; cnt > 0; cnt -- ) {
            mcomp = (MComponent *)(_project->components()[ cnt - 1 ] );
            mcomp->updateItemList();
        }
    }
}

void VpeMain::readIdeInit()
{
    char buff[FILENAME_MAX];
    int width, height, x, y;

    _ini.read( IDE_INI_IDENTIFIER, IDE_INI_TOOLBAR, "1", buff, sizeof( buff ) );
    if( buff[0] == '0' ) {
        delete clearToolBar();
        _toolBarActive = FALSE;
    }

    _ini.read( IDE_INI_IDENTIFIER, IDE_INI_STATWND, "1", buff, sizeof( buff ) );
    if( buff[0] == '0' ) {
        deleteStatusBar();
    }

    _ini.read( IDE_INI_IDENTIFIER,IDE_INI_AUTOREFRESH, "1", buff, sizeof( buff ) );
    if( buff[0] == '0' ) {
        _autoRefresh = FALSE;
    } else {
        _autoRefresh = TRUE;
    }
    _ini.read( IDE_INI_IDENTIFIER, IDE_INI_EDITOR, (const char*)_config->editor(),
               buff, sizeof( buff ) );
    _editor = buff;

    _ini.read( IDE_INI_IDENTIFIER, IDE_INI_EDITOR_ISDLL,
               _config->editorIsDLL() ? "1" : "0", buff, sizeof( buff ) );
    if( buff[0] == '0' ) {
        _editorIsDll = FALSE;
    } else {
        _editorIsDll = TRUE;
    }

    _ini.read( IDE_INI_IDENTIFIER, IDE_INI_EDITOR_PARMS, "%f", buff, sizeof( buff ) );
    _editorParms = buff;

    for( int i=0; i < MAXOLDPROJECTS; i++ ) {
        itoa( i+1, buff, 10 );
        _ini.read( IDE_INI_IDENTIFIER, buff, "*", buff, sizeof( buff ) ); // if we get "*", doesn't exist
        if( buff[0] != '*' ) {
            _oldProjects.add( new WFileName( buff ) );
        }
    }
    _ini.read( IDE_INI_IDENTIFIER, IDE_INI_HEIGHT, "0", buff, sizeof( buff ) );
    height = atoi( buff );

    _ini.read( IDE_INI_IDENTIFIER, IDE_INI_WIDTH, "0", buff, sizeof( buff ) );
    width = atoi( buff );

    _ini.read( IDE_INI_IDENTIFIER, IDE_INI_X, "0", buff, sizeof( buff ) );
    x = atoi( buff );

    _ini.read( IDE_INI_IDENTIFIER, IDE_INI_Y, "0", buff, sizeof( buff ) );
    y = atoi( buff );

    WRect sc;
    WSystemMetrics::screenCoordinates( sc );
    if( width == 0 ) width = sc.w() * 3/4;
    if( height == 0 ) height = sc.h() * 9/10;

    sc.w( width );
    sc.h( height );
    sc.x( x );
    sc.y( y );
    move( sc );
}

void writeEditor( WFile &ifile, char *edtext, char *isdlltext,
                        WFileName &editor, bool isdll, bool thisos ) {
    // the WFileName class has no != operator
    if( ( !thisos && !( editor == "" ) )
        || ( thisos && !( editor == _config->editor() ) )
        || ( thisos && isdll != _config->editorIsDLL() ) ) {
        ifile.printf( "%s=%s\n", edtext, editor.gets() );
        ifile.printf( "%s=%d\n", isdlltext, isdll == TRUE );
    }
}

bool VpeMain::reallyClose()
{
    WRect rect;
    show( WWinStateShowNormal );
    if( _quitAnyways || okToQuit() ) {
        startWait();
        clearProject();
        stopWait();
        // write out .INI file stuff
        char buff[_MAX_PATH];
        _ini.write( IDE_INI_IDENTIFIER, IDE_INI_EDITOR, (char*)_editor.gets() );
        _ini.write( IDE_INI_IDENTIFIER, IDE_INI_EDITOR_ISDLL, _editorIsDll ? "1" : "0" );
        _ini.write( IDE_INI_IDENTIFIER, IDE_INI_EDITOR_PARMS, _editorParms.gets() );
        for( int i=0; i<_oldProjects.count(); i++ ) {
            itoa( i+1, buff, 10 );
            _ini.write( IDE_INI_IDENTIFIER, buff, (const char*)*((WFileName*)_oldProjects[i]) );
        }
        _ini.write( IDE_INI_IDENTIFIER, IDE_INI_TOOLBAR, _toolBarActive ? "1" : "0" );
        _ini.write( IDE_INI_IDENTIFIER, IDE_INI_STATWND, (_statusBar != NULL) ? "1" : "0" );
        _ini.write( IDE_INI_IDENTIFIER, IDE_INI_AUTOREFRESH, _autoRefresh ? "1" : "0" );
        getRectangle( rect );
        itoa( rect.w(), buff, 10 );
        _ini.write( IDE_INI_IDENTIFIER, IDE_INI_WIDTH, buff );
        itoa( rect.h(), buff, 10 );
        _ini.write( IDE_INI_IDENTIFIER, IDE_INI_HEIGHT, buff );
        itoa( rect.x(), buff, 10 );
        _ini.write( IDE_INI_IDENTIFIER, IDE_INI_X, buff );
        itoa( rect.y(), buff, 10 );
        _ini.write( IDE_INI_IDENTIFIER, IDE_INI_Y, buff );
        if( _otherhelp != NULL ) {
            delete _otherhelp;
            _otherhelp = NULL;
        }
        delete _help;
        _help = NULL;
        return( TRUE );
    }
    return( FALSE );
}

bool VpeMain::executeCommand( const char* c, int location, const char* title )
{
    int i;

    if( c && strlen( c ) > 0 ) {
        WString* cur = NULL;
        WStringList opts;
        for( i=0; c[i]!= '\0'; i++ ) {
            if( cur ) {
                if( c[i] == '"' ) {
                    opts.add( cur );
                    cur = NULL;
                } else {
                    cur->concat( c[i] );
                }
            } else if( c[i] == '$' && c[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; c[i]!= '\0'; i++ ) {
            if( !cur ) {
                if( c[i] == '$' && c[i+1] == '"' ) {
                    i++;
                    cur = &reps.stringAt( j );
                    j++;
                } else {
                    cmd.concat( c[i] );
                }
            } else if( c[i] == '"' ) {
                cmd.concat( *cur );
                cur = NULL;
            }
        }
        startWait();
        switch( location ) {

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?