Exemple #1
0
/*
 * FancyFileSave
 */
vi_rc FancyFileSave( void )
{
    vi_rc       rc;

    if( CurrentFile == NULL ) {
        return( ERR_NO_FILE );
    }
    rc = SaveFile( CurrentFile->name, -1, -1, TRUE );
    if( rc == ERR_NO_ERR ) {
        CurrentFile->modified = FALSE;
        UpdateLastFileList( CurrentFile->name );
    }
    return( rc );

} /* FancyFileSave */
Exemple #2
0
/*
 * SaveFileAs - save data from current file
 */
vi_rc SaveFileAs( void )
{
    char    fn[FILENAME_MAX];
    char    cmd[14 + FILENAME_MAX];
    vi_rc   rc;

    rc = SelectFileSave( fn );
    if( rc != ERR_NO_ERR || fn[0] == '\0' ) {
        return( rc );
    }
    // rename current file
#ifndef __NT__   // this is stupid for all case-preserving systems like NT
    FileLower( fn );
#endif
    sprintf( cmd, "set filename \"%s\"", fn );
    RunCommandLine( cmd );
    UpdateLastFileList( fn );

    // flag dammit as user must have already said overwrite ok
    return( SaveFile( fn, -1L, -1L, TRUE ) );

} /* SaveFileAs */
Exemple #3
0
/*
 * 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 */