Ejemplo n.º 1
0
/*
 * EnterExMode - start Ex emulation mode
 */
vi_rc EnterExMode( void )
{
    int         i;
    window_id   wid;
    char        *st;
    char        *prompt;
    vi_rc       rc;
    bool        ret;

    if( EditFlags.InputKeyMapMode ) {
        return( ERR_NO_ERR );
    }
    i = EditVars.WindMaxHeight - 1;
    exwInfo.area.y1 = exwInfo.area.y2 = i;
    exwInfo.area.x2 = EditVars.WindMaxWidth - 1;
    SetPosToMessageLine();
    EditFlags.ExMode = true;
    EditFlags.LineDisplay = true;
    EditFlags.ClockActive = false;
    MyPrintf( "\nEntering EX mode (type vi to return)\n" );
    rc = NewWindow2( &wid, &exwInfo );
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }
    st = MemAlloc( EditVars.MaxLine );

    for( ;; ) {
        if( EditFlags.Appending ) {
            prompt = "";
        } else {
            prompt = ":";
        }
        ret = ReadStringInWindow( wid, 1, prompt, st, EditVars.MaxLine, &EditVars.CLHist );
        MyPrintf( "\n" );
        if( !ret ) {
            continue;
        }
        ScreenPage( 1 );
        if( EditFlags.Appending ) {
            AppendAnother( st );
            ScreenPage( -1 );
            continue;
        }
        rc = RunCommandLine( st );
        if( !EditFlags.ExMode ) {
            break;
        }
        if( rc > ERR_NO_ERR ) {
            Error( GetErrorMsg( rc ) );
        }
        ScreenPage( -1 );
    }
    MemFree( st );
    return( ERR_NO_ERR );

} /* EnterExMode */
Ejemplo n.º 2
0
vi_rc UtilUpdateBoolean( bool old, bool val, char *name )
{
    char    cmd[MAX_SRC_LINE];

    if( old == val ) {
        return( ERR_NO_ERR );
    }
    sprintf( cmd, "set %s%s", GET_BOOL_PREFIX( val ), name );
    return( RunCommandLine( cmd ) );
}
Ejemplo n.º 3
0
vi_rc UtilUpdateStr( char *old, char *val, char *name )
{
    char    cmd[MAX_SRC_LINE];

    if( !strcmp( old, val ) ) {
        return( ERR_NO_ERR );
    }
    sprintf( cmd, "set %s %s", name, val );
    return( RunCommandLine( cmd ) );
}
Ejemplo n.º 4
0
vi_rc UtilUpdateChar( char old, char val, char *name )
{
    char    cmd[MAX_SRC_LINE];

    if( old == val ) {
        return( ERR_NO_ERR );
    }
    sprintf( cmd, "set %s %c", name, val );
    return( RunCommandLine( cmd ) );
}
Ejemplo n.º 5
0
  string_t cImageCacheManager::GetOrCreateThumbnailForImageFile(const string_t& sImageFilePath, IMAGE_SIZE imageSize)
  {
    LOG<<"cImageCacheManager::GetOrCreateThumbnailForImageFile \""<<sImageFilePath<<"\""<<std::endl;

    if (!IsConvertInstalled()) {
      LOG<<"cImageCacheManager::GetOrCreateThumbnailForImageFile convert is not installed, returning \"\""<<std::endl;
      return TEXT("");
    }

    spitfire::algorithm::cMD5 md5;
    md5.CalculateForFile(sImageFilePath);

    const string_t sCacheFolder = GetCacheFolderPath();

    string_t sFileJPG = TEXT("full.jpg");
    size_t width = 0;
    size_t height = 0;

    switch (imageSize) {
      case IMAGE_SIZE::THUMBNAIL: {
        sFileJPG = TEXT("thumbnail.jpg");
        width = 200;
        height = 200;
        break;
      }
    }

    const string_t sFilePathJPG = spitfire::filesystem::MakeFilePath(sCacheFolder, md5.GetResultFormatted() + TEXT("_") + sFileJPG);
    if (spitfire::filesystem::FileExists(sFilePathJPG)) return sFilePathJPG;

    const string_t sFolderJPG = spitfire::filesystem::GetFolder(sFilePathJPG);

    ostringstream_t o;
    o<<"\""<<GetConvertPath()<<"\" \""<<sImageFilePath<<"\"";
    if ((width != 0) && (height != 0)) o<<" -resize "<<width<<"x"<<height;
    o<<" -auto-orient \""<<sFilePathJPG<<"\"";
    const string_t sCommandLine = o.str();
    //LOG<<"cImageCacheManager::GetOrCreateThumbnailForImageFile Running command line \""<<sCommandLine<<"\""<<std::endl;
    #ifdef __WIN__
    RunCommandLine(sCommandLine);
    #else
    const int iResult = system(sCommandLine.c_str());
    if (iResult != 0) {
      LOG<<"cImageCacheManager::GetOrCreateThumbnailForImageFile convert returned "<<iResult<<" for \""<<sCommandLine<<"\", returning \"\""<<std::endl;
      return TEXT("");
    }
    #endif

    if (!spitfire::filesystem::FileExists(sFilePathJPG)) {
      LOG<<"cImageCacheManager::GetOrCreateThumbnailForImageFile Failed to create the thumbnail image \""<<sFilePathJPG<<"\", returning \"\""<<std::endl;
      return TEXT("");
    }

    return sFilePathJPG;
  }
Ejemplo n.º 6
0
vi_rc HandleToolCommand( int id )
{
    ss          *p;
    tool_item   *item;

    for( p = toolBarHead; p != NULL; p = p->next ) {
        item = (tool_item *)p;
        if( item->id == id ) {
            return( RunCommandLine( item->cmd ) );
        }
    }
    return( MENU_COMMAND_NOT_HANDLED );
}
Ejemplo n.º 7
0
  string_t cImageCacheManager::GetOrCreateDNGForRawFile(const string_t& sRawFilePath)
  {
    LOG<<"cImageCacheManager::GetOrCreateDNGForRawFile \""<<sRawFilePath<<"\""<<std::endl;

    ASSERT(spitfire::filesystem::FileExists(sRawFilePath));

    #ifndef __WIN__
    if (!IsWineInstalled()) {
      LOG<<"cImageCacheManager::GetOrCreateDNGForRawFile wine is not installed, returning \"\""<<std::endl;
      return TEXT("");
    }
    #endif

    #ifdef __WIN__
    // TODO: Use the actual dng sdk instead?
    #else
    // TODO: Use the actual dng sdk like this instead?
    // https://projects.kde.org/projects/extragear/graphics/kipi-plugins/repository/revisions/master/show/dngconverter
    #endif

    const string_t sFolder = spitfire::filesystem::GetFolder(sRawFilePath);
    const string_t sFile = spitfire::filesystem::GetFileNoExtension(sRawFilePath);
    const string_t sDNGFilePath = spitfire::filesystem::MakeFilePath(sFolder, sFile + TEXT(".dng"));

    ostringstream_t o;
    #ifndef __WIN__
    o<<"wine ";
    #endif
    const string_t sExecutablePath = GetAdobeDNGConverterPath();
    o<<"\""<<sExecutablePath<<"\" -c \""<<sRawFilePath<<"\"";
    #ifndef BUILD_DEBUG
    o<<" &> /dev/null";
    #endif
    const string_t sCommandLine = o.str();
    LOG<<"cImageCacheManager::GetOrCreateDNGForRawFile Running command line \""<<sCommandLine<<"\""<<std::endl;
    #ifdef __WIN__
    RunCommandLine(sCommandLine);
    if (!spitfire::filesystem::FileExists(sDNGFilePath)) {
      LOG<<"cImageCacheManager::GetOrCreateDNGForRawFile \""<<sCommandLine<<"\" FAILED, returning \"\""<<std::endl;
      return TEXT("");
    }
    #else
    const int iResult = system(sCommandLine.c_str());
    if (iResult != 0) {
      LOG<<"cImageCacheManager::GetOrCreateDNGForRawFile \""<<sCommandLine<<"\" returned "<<iResult<<", returning \"\""<<std::endl;
      return TEXT("");
    }
    #endif

    return sDNGFilePath;
  }
Ejemplo n.º 8
0
/*
 * handleMenuCommand - this routine takes a menu and an id and executes the
 *                     command associated with the menu item if there is an
 *                     item with that id.
 */
static vi_rc handleMenuCommand( menu *m, int menuid )
{
    item        *citem;
    vi_rc       rc;

    for( citem = m->item_head; citem != NULL; citem = citem->next ) {
        if( citem->menuid == menuid ) {
            /* run this command */
            IMEsc();
            rc = RunCommandLine( citem->cmd );
#ifdef __WIN__
            SetWindowCursorForReal();
#endif
            return( rc );
        }
    }
    return( MENU_COMMAND_NOT_HANDLED );

} /* handleMenuCommand */
Ejemplo n.º 9
0
/*
 * 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 */
Ejemplo n.º 10
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 */
Ejemplo n.º 11
0
/*
 * handleMenuCommand - this routine takes a menu and an id and executes the
 *                     command associated with the menu item if there is an
 *                     item with that id.
 */
static vi_rc handleMenuCommand( menu *m, UINT id )
{
    item        *citem;
    char        *str;
    int         len;
    vi_rc       rc;

    for( citem = m->item_head; citem != NULL; citem = citem->next ) {
        if( citem->id == id ) {
            /* run this command */
            len = strlen( citem->cmd ) + 1;
            str = alloca( len );
            memcpy( str, citem->cmd, len );
            IMEsc();
            rc = RunCommandLine( str );
#ifdef __WIN__
            SetWindowCursorForReal();
#endif
            return( rc );
        }
    }
    return( MENU_COMMAND_NOT_HANDLED );

} /* handleMenuCommand */
Ejemplo n.º 12
0
/*
 * Global - perform global command
 */
vi_rc Global( linenum n1, linenum n2, const char *data, int dmt )
{
    char        *sstr, *linedata;
    bool        match;
    vi_rc       rc;
    vi_rc       rc1;
    long        changecnt = 0;
    linenum     ll;
    fcb         *cfcb;
    line        *cline;
    regexp      crx;
    i_mark      pos;

    /*
     * get search string and command
     */
    rc = ModificationTest();
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }
    sstr = alloca( MAX_INPUT_LINE );
    if( sstr == NULL ) {
        return( ERR_NO_STACK );
    }
    data = SkipLeadingSpaces( data );
    data = GetNextWord( data, sstr, SingleSlash );
    if( *sstr == '\0' ) {
        return( ERR_INVALID_GLOBAL_CMD );
    }
    if( *data == '/' )
    	++data;     // skip one slash character
    data = SkipLeadingSpaces( data );

    /*
     * verify last line
     */
    if( n2 > CurrentFile->fcbs.tail->end_line ) {
        rc = CFindLastLine( &ll );
        if( rc != ERR_NO_ERR ) {
            return( rc );
        }
        if( n2 > ll ) {
            return( ERR_INVALID_LINE_RANGE );
        }
    }

    /*
     * set for start of search
     */
    if( EditFlags.Verbose && EditFlags.EchoOn ) {
        ClearWindow( MessageWindow );
    }
    rc = CurrentRegComp( sstr );
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }
    SaveCurrentFilePos();
    StartUndoGroup( UndoStack );
    EditFlags.DisplayHold = true;

    /*
     * pass one - find all matches
     */
    for( pos.line = n1; pos.line <= n2; pos.line++ ) {

        /*
         * go thorugh file, marking global lines
         */
        pos.column = 0;
        rc = FindRegularExpression( NULL, &pos, &linedata, n2, 0 );
        if( rc != ERR_NO_ERR ) {
            if( rc == ERR_FIND_PAST_TERM_LINE || rc == ERR_FIND_NOT_FOUND ||
                rc == ERR_FIND_END_OF_FILE ) {
                break;
            }
            RestoreCurrentFilePos();
            EditFlags.DisplayHold = false;
            return( rc );
        }
        if( pos.line > n2 ) {
            break;
        }

        /*
         * go to appropriate spot in file
         */
        rc = GoToLineNoRelCurs( pos.line );
        if( rc != ERR_NO_ERR ) {
            RestoreCurrentFilePos();
            EditFlags.DisplayHold = false;
            return( rc );
        }

        /*
         * mark fcb and line for a match
         */
        CurrentFcb->globalmatch = true;
        CurrentLine->u.ld.globmatch = true;
        if( EditFlags.Verbose && EditFlags.EchoOn ) {
            // WPrintfLine( MessageWindow,1,"Match on line %l",clineno );
            Message1( "Match on line %l", pos.line );
        }
    }


    /*
     * negate range, if needed
     */
    if( dmt ) {
        /*
         * run through each line, flipping globmatch flag on lines
         */
        CGimmeLinePtr( n1, &CurrentFcb, &CurrentLine );
        match = false;
        for( CurrentPos.line = n1; CurrentPos.line <= n2; CurrentPos.line++ ) {
            if( CurrentLine->u.ld.globmatch ) {
                CurrentLine->u.ld.globmatch = false;
            } else {
                match = true;
                CurrentLine->u.ld.globmatch = true;
            }
            CurrentLine = CurrentLine->next;
            if( CurrentLine == NULL ) {
                CurrentFcb->globalmatch = match;
                CurrentFcb = CurrentFcb->next;
                FetchFcb( CurrentFcb );
                CurrentLine = CurrentFcb->lines.head;
                match = false;
            }
        }
    }

    /*
     * Pass 2: do all changes
     */
    rc = ERR_NO_ERR;
    EditFlags.GlobalInProgress = true;
    memcpy( &crx, CurrentRegularExpression, sizeof( crx ) );

    for( CurrentFcb = CurrentFile->fcbs.head; CurrentFcb != NULL; CurrentFcb = CurrentFcb->next ) {
        if( !CurrentFcb->globalmatch )
            continue;
        FetchFcb( CurrentFcb );
        CurrentPos.line = CurrentFcb->start_line;
        for( CurrentLine = CurrentFcb->lines.head; CurrentLine != NULL; CurrentLine = CurrentLine->next, CurrentPos.line++ ) {
            if( !CurrentLine->u.ld.globmatch )
                continue;
            CurrentLine->u.ld.globmatch = false;
            changecnt++;

            CurrentPos.column = 1;
            ProcessingMessage( CurrentPos.line );
            /*
            * build command line
            */
            rc = RunCommandLine( data );
            if( rc > ERR_NO_ERR ) {
                break;
            }
        }
        if( rc > ERR_NO_ERR ) {
            break;
        }
        CurrentFcb->globalmatch = false;
    }

    /*
     * we have an error, so fix up fcbs
     */
    if( rc > ERR_NO_ERR ) {
        for( cfcb = CurrentFile->fcbs.head; cfcb != NULL; cfcb = cfcb->next ) {
            if( cfcb->globalmatch ) {
                cfcb->globalmatch = false;
                cfcb->non_swappable = false;
                for( cline = cfcb->lines.head; cline != NULL; cline = cline->next ) {
                    cline->u.ld.globmatch = false;
                }
            }
        }
    }

    /*
     * display results
     */
    EditFlags.GlobalInProgress = false;
    EditFlags.DisplayHold = false;
    EndUndoGroup( UndoStack );
    RestoreCurrentFilePos();
    rc1 = SetCurrentLine( CurrentPos.line );
    if( rc1 != ERR_NO_ERR ) {
        if( rc1 == ERR_NO_SUCH_LINE ) {
            SetCurrentLine( 1 );
        } else {
            return( rc1 );
        }
    }
    Message1( "%l matches found",changecnt );
    DCDisplayAllLines();
    return( rc );

} /* Global */
Ejemplo n.º 13
0
  string_t cImageCacheManager::GetOrCreateThumbnailForDNGFile(const string_t& sDNGFilePath, IMAGE_SIZE imageSize)
  {
    LOG<<"cImageCacheManager::GetOrCreateThumbnailForDNGFile \""<<sDNGFilePath<<"\""<<std::endl;

    ASSERT(spitfire::filesystem::FileExists(sDNGFilePath));

    if (!IsUFRawBatchInstalled()) {
      LOG<<"cImageCacheManager::GetOrCreateThumbnailForDNGFile ufraw-batch is not installed, returning \"\""<<std::endl;
      return TEXT("");
    }

    spitfire::algorithm::cMD5 md5;
    md5.CalculateForFile(sDNGFilePath);

    const string_t sCacheFolder = GetCacheFolderPath();

    string_t sFileJPG = TEXT("full.jpg");
    size_t size = 0;

    switch (imageSize) {
      case IMAGE_SIZE::THUMBNAIL: {
        sFileJPG = TEXT("thumbnail.jpg");
        size = 200;
        break;
      }
    }

    const string_t sFilePathJPG = spitfire::filesystem::MakeFilePath(sCacheFolder, md5.GetResultFormatted() + TEXT("_") + sFileJPG);
    if (spitfire::filesystem::FileExists(sFilePathJPG)) return sFilePathJPG;

    const string_t sFolderJPG = spitfire::filesystem::GetFolder(sFilePathJPG);

    const string_t sFileUFRawEmbeddedJPG = spitfire::filesystem::GetFileNoExtension(sDNGFilePath) + TEXT(".embedded.jpg");
    const string_t sFilePathUFRawEmbeddedJPG = spitfire::filesystem::MakeFilePath(sFolderJPG, sFileUFRawEmbeddedJPG);
    const string_t sFileUFRawJPG = spitfire::filesystem::GetFileNoExtension(sDNGFilePath) + TEXT(".jpg");
    const string_t sFilePathUFRawJPG = spitfire::filesystem::MakeFilePath(sFolderJPG, sFileUFRawJPG);

    ostringstream_t o;
    #ifdef __WIN__
    o<<"\""<<GetUFRawBatchPath()<<"\"";
    #else
    o<<"ufraw-batch";
    #endif
    o<<" --out-type=jpg";
    if (size != 0) o<<" --embedded-image --size="<<size;
    o<<" \""<<sDNGFilePath<<"\" --overwrite --out-path=\""<<spitfire::string::StripTrailing(sFolderJPG, sFolderSeparator)<<"\"";
    #ifndef BUILD_DEBUG
    o<<" --silent";
    #endif
    const string_t sCommandLine = o.str();
    LOG<<"cImageCacheManager::GetOrCreateThumbnailForDNGFile Running command line \""<<sCommandLine<<"\""<<std::endl;
    #ifdef __WIN__
    RunCommandLine(sCommandLine);
    #else
    const int iResult = system(sCommandLine.c_str());
    if (iResult != 0) {
      LOG<<"cImageCacheManager::GetOrCreateThumbnailForDNGFile ufraw-batch returned "<<iResult<<" for \""<<sCommandLine<<"\", returning \"\""<<std::endl;
      return TEXT("");
    }
    #endif

    if (!spitfire::filesystem::FileExists(sFilePathUFRawEmbeddedJPG) && !spitfire::filesystem::FileExists(sFilePathUFRawJPG)) {
      LOG<<"cImageCacheManager::GetOrCreateThumbnailForDNGFile ufraw-batch FAILED for \""<<sCommandLine<<"\", embedded file \""<<sFilePathUFRawEmbeddedJPG<<"\" and file \""<<sFilePathUFRawJPG<<"\" were not found, returning \"\""<<std::endl;
      return TEXT("");
    }

    // ufraw-batch doesn't respect the output folder if we provide our own output filename, so we have to rename the file after it is converted
    const string_t sNameJPG = spitfire::filesystem::GetFileNoExtension(sFilePathJPG);

    // Try to rename from file.embedded.jpg to abcdefghi_file.jpg
    LOG<<"cImageCacheManager::GetOrCreateThumbnailForDNGFile Looking for \""<<sFilePathUFRawEmbeddedJPG<<"\""<<std::endl;
    if (spitfire::filesystem::FileExists(sFilePathUFRawEmbeddedJPG)) {
      if (!spitfire::filesystem::MoveFile(sFilePathUFRawEmbeddedJPG, sFilePathJPG)) {
        LOG<<"cImageCacheManager::GetOrCreateThumbnailForDNGFile Failed to move the file from \""<<sFilePathUFRawEmbeddedJPG<<"\" to \""<<sFilePathJPG<<"\""<<std::endl;
      }
    }

    // Try to rename from file.jpg to abcdefghi_file.jpg
    LOG<<"cImageCacheManager::GetOrCreateThumbnailForDNGFile Looking for \""<<sFilePathUFRawJPG<<"\""<<std::endl;
    if (spitfire::filesystem::FileExists(sFilePathUFRawJPG)) {
      if (!spitfire::filesystem::MoveFile(sFilePathUFRawJPG, sFilePathJPG)) {
        LOG<<"cImageCacheManager::GetOrCreateThumbnailForDNGFile Failed to move the file from \""<<sFilePathUFRawJPG<<"\" to \""<<sFilePathJPG<<"\""<<std::endl;
      }
    }

    if (!spitfire::filesystem::FileExists(sFilePathJPG)) {
      LOG<<"cImageCacheManager::GetOrCreateThumbnailForDNGFile Failed to create the thumbnail image \""<<sFilePathJPG<<"\", returning \"\""<<std::endl;
      return TEXT("");
    }

    return sFilePathJPG;
  }
Ejemplo n.º 14
0
/*
 * Source - main driver
 */
vi_rc Source( char *fn, char *data, int *ln )
{
    undo_stack  *atomic = NULL;
    labels      *lab, lb;
    vlist       vl;
    files       fi;
    sfile       *sf, *curr;
    char        tmp[MAX_SRC_LINE];
    char        sname[FILENAME_MAX];
    vi_rc       rc;
    bool        sicmp, wfb, ssa, exm;
    resident    *res;
    int         cTokenID;

    /*
     * startup
     */
    LastRC = LastRetCode;
    memset( &fi, 0, sizeof( fi ) );
    vl.head = vl.tail = NULL;
    res = residentScript( fn );
    if( res != NULL && EditFlags.LoadResidentScript ) {
        return( ERR_SCRIPT_ALREADY_RESIDENT );
    }
    if( EditFlags.CompileScript || res == NULL ) {
        lab = &lb;
        memset( lab, 0, sizeof( labels ) );
        sf = NULL;
    } else {
        lab = &res->lab;
        sf = res->sf;
    }
    if( EditFlags.CompileScript ) {
        sname[0] = 0;
        NextWord1( data, sname );
    }

    /*
     * initialize variables
     */
    memset( &fi, 0, sizeof( fi ) );
    rc = initSource( &vl, data );
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }

    /*
     * pre-process
     */
    sicmp = EditFlags.ScriptIsCompiled;
    SourceErrCount = 0;
    if( EditFlags.CompileScript || res == NULL ) {
        EditFlags.ScriptIsCompiled = FALSE;
        rc = PreProcess( fn, &sf, lab );
        finiSourceErrFile( fn );
        if( rc != ERR_NO_ERR || SourceErrCount > 0 ) {
            EditFlags.ScriptIsCompiled = sicmp;
            return( rc );
        }
    } else {
        EditFlags.ScriptIsCompiled = res->scriptcomp;
    }

    /*
     * if we were loading a resident script, then add it
     */
    if( EditFlags.LoadResidentScript ) {
        finiSource( NULL, &vl, NULL, NULL );
        if( SourceErrCount == 0 ) {
            addResidentScript( fn, sf, lab );
        }
        EditFlags.ScriptIsCompiled = sicmp;
        return( ERR_NO_ERR );
    }

    /*
     * if we were compiling, dump results and go back
     */
    if( EditFlags.CompileScript ) {
        rc = barfScript( fn, sf, &vl, ln, sname );
        finiSource( lab, &vl, sf, NULL );
        return( rc );
    }

    /*
     * process each source line
     */
    exm = EditFlags.ExMode;
    wfb = EditFlags.WatchForBreak;
    ssa = EditFlags.SourceScriptActive;
    EditFlags.SourceScriptActive = TRUE;
    EditFlags.WatchForBreak = TRUE;
    EditFlags.ExMode = TRUE;
    curr = sf->next;
    while( curr != NULL ) {

        cTokenID = curr->token - SRC_T_NULL - 1;

        if( !EditFlags.Starting ) {
            if( EditFlags.BreakPressed ) {
                ClearBreak();
                break;
            }
        }
        rc = LastError = ERR_NO_ERR;
        if( curr->data != NULL ) {
            strcpy( tmp, curr->data );
        } else {
            tmp[0] = 0;
        }

        if( EditFlags.Appending ) {
            if( curr->hasvar) {
                Expand( tmp, &vl );
            }
            rc = AppendAnother( tmp );
            goto evil_continue;
        }

        if( cTokenID == PCL_T_ENDFILETYPESOURCE ) {
            rc = FTSEnd();
            goto evil_continue;
        }

        if( EditFlags.FileTypeSource ) {
            rc = FTSAddCmd( tmp, curr->token );
            goto evil_continue;
        }

        if( curr->token > SRC_T_NULL ) {

            if( curr->hasvar) {
                Expand( tmp, &vl );
            }
            rc = TryCompileableToken( cTokenID, tmp, FALSE, 0 );
            if( rc == NOT_COMPILEABLE_TOKEN ) {
                rc = ProcessWindow( cTokenID, tmp );
            }
            if( rc < ERR_NO_ERR ) {
                rc = ERR_NO_ERR;
            }

        } else switch( curr->token ) {
        case SRC_T_ATOMIC:
            if( atomic == NULL ) {
                atomic = UndoStack;
                StartUndoGroup( atomic );
            }
            break;

        case SRC_T_IF:
            rc = SrcIf( &curr, &vl );
            break;

        case SRC_T_GOTO:
            rc = SrcGoTo( &curr, tmp, lab );
            break;

        case SRC_T_LABEL:
            break;

        case SRC_T_RETURN:
            if( curr->data != NULL ) {
                int     ret;
                GetErrorTokenValue( &ret, curr->data );
                rc = ret;
            } else {
                rc = ERR_NO_ERR;
            }
            goto evil_exit;

        case SRC_T_GET:
            SrcGet( tmp, &vl );
            rc = ERR_NO_ERR;
            break;

        case SRC_T_INPUT:
            LastRC = SrcInput( tmp, &vl );
            if( LastRC != NO_VALUE_ENTERED && LastRC != ERR_NO_ERR ) {
                rc = LastRC;
            }
            break;

        case SRC_T_NEXTWORD:
            rc = SrcNextWord( tmp, &vl );
            break;

        case SRC_T_ASSIGN:
            rc = SrcAssign( tmp, &vl );
            break;

        case SRC_T_EXPR:
            rc = SrcExpr( curr, &vl );
            break;

        case SRC_T_OPEN:
            LastRC = SrcOpen( curr, &vl, &fi, tmp );
            if( LastRC != ERR_FILE_NOT_FOUND && LastRC != ERR_NO_ERR ) {
                rc = LastRC;
            }
            break;

        case SRC_T_READ:
            LastRC = SrcRead( curr, &fi, tmp, &vl );
            if( LastRC != END_OF_FILE && LastRC != ERR_NO_ERR ) {
                rc = LastRC;
            }
            break;

        case SRC_T_WRITE:
            rc = SrcWrite( curr, &fi, tmp, &vl );
            break;

        case SRC_T_CLOSE:
            rc = SrcClose( curr, &vl, &fi, tmp );
            break;

        default:
#ifdef __WIN__
            {
                if( RunWindowsCommand( tmp, &LastRC, &vl ) ) {
                    rc = LastRC;
                    break;
                }
            }
#endif
            if( curr->hasvar ) {
                Expand( tmp, &vl );
            }
            LastRC = RunCommandLine( tmp );
            if( LastRC == DO_NOT_CLEAR_MESSAGE_WINDOW ) {
                LastRC = LastError;
            }
            break;
        }

evil_continue:
        if( rc != ERR_NO_ERR ) {
            break;
        }
        curr = curr->next;

    }

evil_exit:
    if( EditFlags.Appending ) {
        AppendAnother( "." );
    }
    if( curr != NULL ) {
        *ln = curr->line;
    } else {
        *ln = CurrentSrcLine;
        rc = ERR_NO_ERR;
    }
    EditFlags.WatchForBreak = wfb;
    EditFlags.SourceScriptActive = ssa;
    EditFlags.ScriptIsCompiled = sicmp;
    EditFlags.ExMode = exm;
    if( res != NULL && !EditFlags.CompileScript ) {
        sf = NULL;
        lab = NULL;
    }
    finiSource( lab, &vl, sf, atomic );
    return( rc );

} /* Source */
Ejemplo n.º 15
0
vi_rc ToggleFontbar( void )
{
    char    cmd[14];
    sprintf( cmd, "set%sfontbar", EditFlags.Fontbar ? " no" : " " );
    return( RunCommandLine( cmd ) );
}
Ejemplo n.º 16
0
vi_rc ToggleSSbar( void )
{
    char    cmd[15];
    sprintf( cmd, "set%sssbar", EditFlags.SSbar ? " no" : " " );
    return( RunCommandLine( cmd ) );
}
Ejemplo n.º 17
0
vi_rc ToggleStatusbar( void )
{
    char    cmd[17];
    sprintf( cmd, "set%sstatusinfo", EditFlags.StatusInfo ? " no" : " " );
    return( RunCommandLine( cmd ) );
}