コード例 #1
0
ファイル: misc.c プロジェクト: bhanug/open-watcom-v2
/*
 * ModificationTest - test a file as it is about to be modified
 */
vi_rc ModificationTest( void )
{
    vi_rc       rc;
    bool        olddm;
    int         olddotdigits;

    if( CurrentFile == NULL ) {
        return( ERR_NO_FILE );
    }

    if( CurrentFile->viewonly ) {
        return( ERR_FILE_VIEW_ONLY );
    }
    if( !CurrentFile->modified ) {
        olddm = EditFlags.DotMode;
        EditFlags.DotMode = false;
        EditFlags.NoAddToDotBuffer = true;
        olddotdigits = DotDigits;
        rc = SourceHook( SRC_HOOK_MODIFIED, ERR_NO_ERR );
        DotDigits = olddotdigits;
        EditFlags.NoAddToDotBuffer = false;
        EditFlags.DotMode = olddm;
        return( rc );
    }
    return( ERR_NO_ERR );

} /* ModificationTest */
コード例 #2
0
ファイル: cmdline.c プロジェクト: pavanvunnava/open-watcom-v2
/*
 * doProcessCommandLine - handle getting and processing a command line
 */
static vi_rc doProcessCommandLine( bool is_fancy )
{
    vi_rc       rc;
    char        *st;

    /*
     * open the window and get the string
     */
    st = MemAllocUnsafe( EditVars.MaxLine );
    if( st == NULL ) {
        return( ERR_NO_MEMORY );
    }
    is_fancy = is_fancy;
#ifdef __WIN__
    if( is_fancy ) {
        if( !GetCmdDialog( st, EditVars.MaxLine ) ) {
            MemFree( st );
            return( ERR_NO_ERR );
        }
    } else {
#endif
        rc = PromptForString( ":", st, EditVars.MaxLine, &EditVars.CLHist );
        if( rc != ERR_NO_ERR ) {
            MemFree( st );
            if( rc == NO_VALUE_ENTERED ) {
                return( ERR_NO_ERR );
            }
            return( rc );
        }
#ifdef __WIN__
    }
#endif
    CommandBuffer = st;
    rc = SourceHook( SRC_HOOK_COMMAND, ERR_NO_ERR );
    if( rc == ERR_NO_ERR ) {
        rc = RunCommandLine( st );
    }
    CommandBuffer = NULL;
    MemFree( st );
    return( rc );

} /* doProcessCommandLine */
コード例 #3
0
ファイル: filesave.c プロジェクト: jossk/open-watcom-v2
/*
 * SaveAndExit - save and exit a file
 */
vi_rc SaveAndExit( char *fname )
{
    vi_rc   rc;

    /*
     * save file and get next one
     */
    if( CurrentFile != NULL ) {
        if( CurrentFile->modified ) {
            rc = SourceHook( SRC_HOOK_WRITE, ERR_NO_ERR );
            if( rc != ERR_NO_ERR ) {
                return( rc );
            }
            rc = SaveFile( fname, -1, -1, FALSE );
            if( rc != ERR_NO_ERR ) {
                return( rc );
            }
            Modified( FALSE );
        }
    }
    return( NextFile() );

} /* SaveAndExit */
コード例 #4
0
ファイル: filenew.c プロジェクト: ABratovic/open-watcom-v2
/*
 * NewFile - load up a new file
 */
vi_rc NewFile( char *name, bool same_file )
{
    vi_rc       rc;
    bool        dup;
    status_type oldstatus;

    dup = EditFlags.DuplicateFile;
    EditFlags.DuplicateFile = false;
    oldstatus = UpdateCurrentStatus( CSTATUS_READING );

    ScreenPage( 1 );
#ifdef __WIN__
    EditFlags.ResizeableWindow = true;
#endif
    rc = createNewFile( name, same_file );
    if( rc != ERR_NO_ERR && rc != NEW_FILE ) {
        ScreenPage( -1 );
        if( !EditFlags.Starting ) {
            MoveWindowToFrontDammit( MessageWindow, true );
            MoveWindowToFrontDammit( CurrentWindow, true );
        }
        UpdateCurrentStatus( oldstatus );
        return( rc );
    }
    GoToLineNoRelCurs( 1 );
    GoToColumnOnCurrentLine( 1 );
    FileSPVAR();
    SaveCurrentInfo();
    if( !same_file ) {
        inReadHook++;
        rc = SourceHook( SRC_HOOK_READ, rc );
        inReadHook--;
    }

    /*
     * back from hook, so all loadings are done
     * (who should have priority - hook or fts commands?)
     */
#if 0
    rc = FTSRunCmds( CurrentFile->name );
    FTSRunCmds( CurrentFile->name );
#endif

    /*
     * reset the screen to the display page, display everything
     */
    ScreenPage( -1 );
    MoveWindowToFrontDammit( CurrentWindow, true );
    UpdateStatusWindow();
    SetWindowCursor();
    DCDisplayAllLines();
    EditFlags.DuplicateFile = dup;
    DisplayFileStatus();
    SaveCurrentInfo();
    ActiveWindow( CurrentWindow );
    VarAddRandC();
    SetModifiedVar( false );
    UpdateCurrentStatus( oldstatus );
    if( !same_file && !inReadHook ) {
        UpdateLastFileList( CurrentFile->name );
    }
#ifdef __WIN__
    DCUpdateAll();
    ResetEditWindowCursor( CurrentWindow );
    SetWindowCursorForReal();
    GotoFile( CurrentWindow );
#endif
    return( rc );

} /* NewFile */