/* * SelectFileOpen - use common dialog file open to pick a file to edit */ vi_rc SelectFileOpen( const char *dir, char **result, const char *mask, bool want_all_dirs ) { OPENFILENAME of; bool rc; static long filemask = 1; bool is_chicago = false; #if defined( __NT__ ) && !defined( _WIN64 ) /* added to get around chicago crashing in the fileopen dlg */ /* -------------------------------------------------------- */ if( LOBYTE( LOWORD( GetVersion() ) ) >= 4 ) { is_chicago = true; } /* -------------------------------------------------------- */ #endif mask = mask; want_all_dirs = want_all_dirs; *result[0] = '\0'; memset( &of, 0, sizeof( OPENFILENAME ) ); of.lStructSize = sizeof( OPENFILENAME ); of.hwndOwner = root_window_id; of.lpstrFilter = (LPSTR)filterList; of.lpstrDefExt = NULL; of.nFilterIndex = filemask; of.lpstrFile = *result; of.nMaxFile = FILENAME_MAX; of.lpstrTitle = NULL; of.lpstrInitialDir = dir; if( is_chicago ) { of.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_EXPLORER; } else { of.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_ENABLEHOOK; of.lpfnHook = (LPOFNHOOKPROC)MakeOpenFileHookProcInstance( OpenHook, InstanceHandle ); } rc = GetOpenFileName( &of ) != 0; filemask = of.nFilterIndex; if( !is_chicago ) { (void)FreeProcInstance( (FARPROC)of.lpfnHook ); } if( !rc && CommDlgExtendedError() == FNERR_BUFFERTOOSMALL ) { if( !is_chicago ) { MemFree( (char*)(of.lpstrFile) ); *result = FileNameList; } #if 0 MyBeep(); Message1( "Please open files in smaller groups" ); #endif } UpdateCurrentDirectory(); return( ERR_NO_ERR ); } /* SelectFileOpen */
/* * SelectFileSave - use common dialog file open to pickname to save under */ vi_rc SelectFileSave( char *result ) { OPENFILENAME of; int doit; bool is_chicago = false; assert( CurrentFile != NULL ); strcpy( result, CurrentFile->name ); memset( &of, 0, sizeof( OPENFILENAME ) ); of.lStructSize = sizeof( OPENFILENAME ); of.hwndOwner = root_window_id; of.lpstrFilter = (LPSTR) filterList; of.lpstrDefExt = NULL; of.nFilterIndex = 1L; of.lpstrFile = result; of.nMaxFile = FILENAME_MAX; of.lpstrTitle = NULL; of.lpstrInitialDir = CurrentFile->home; #if defined( __NT__ ) && !defined( _WIN64 ) if( LOBYTE( LOWORD( GetVersion() ) ) >= 4 ) is_chicago = true; #endif if( is_chicago ) { of.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOREADONLYRETURN | OFN_EXPLORER; } else { of.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOREADONLYRETURN | OFN_ENABLEHOOK; of.lpfnHook = (LPOFNHOOKPROC)MakeOpenFileHookProcInstance( OpenHook, InstanceHandle ); } doit = GetSaveFileName( &of ); if( !is_chicago ) { (void)FreeProcInstance( (FARPROC)of.lpfnHook ); } if( doit != 0 ) { UpdateCurrentDirectory(); return( ERR_NO_ERR ); } else { return( ERR_SAVE_CANCELED ); } } /* SelectFileSave */
static void postSpawn( long rc ) { restorePrompt(); VarAddGlobalLong( "Sysrc", rc ); UpdateCurrentDirectory(); #ifndef __WIN__ ResetColors(); // if( (EditFlags.PauseOnSpawnErr && rc != 0 ) || // !EditFlags.SourceScriptActive ) { if( EditFlags.PauseOnSpawnErr && rc != 0 ) { MyPrintf( "[%s]\n", MSG_PRESSANYKEY ); GetNextEvent( false ); } ResetSpawnScreen(); if( !EditFlags.LineDisplay ) { ReDisplayScreen(); } #endif EditFlags.ClockActive = clockActive; }