Esempio n. 1
0
vi_rc Yank( range *r )
{
    vi_rc       rc;

    if( r->line_based ) {
        rc = YankLineRange( r->start.line, r->end.line );
    } else if( r->start.line == r->end.line ) {
        assert( CurrentPos.line == r->start.line );
        AddLineToSavebuf( CurrentLine->data, r->start.column, r->end.column );
#ifdef __WIN__
        if( LastSavebuf == 0 ) {
            Message1( "%d characters copied into the clipboard",
                      r->end.column - r->start.column + 1 );
        } else {
#endif
            Message1( "%d %s yanked into buffer %c",
                      r->end.column - r->start.column + 1,
                      MSG_CHARACTERS, LastSavebuf );
#ifdef __WIN__
        }
#endif
        rc = DO_NOT_CLEAR_MESSAGE_WINDOW;
    } else {
        rc = Cut( r->start.line, r->start.column, r->end.line, r->end.column, false );
    }
    if( rc != ERR_NO_ERR ) {
        rc = DO_NOT_CLEAR_MESSAGE_WINDOW;
    }
    return( rc );

} /* Yank */
Esempio n. 2
0
/*
 * SwitchSavebuf - switch current save buffer
 */
vi_rc SwitchSavebuf( void )
{
    int         buf, i;
    linenum     lcnt;
    savebuf     *tmp;
    char        *data;
    fcb         *cfcb;

    /*
     * validate savebuf
     */
    buf = -1;
    for( i = 0; i < MAX_SAVEBUFS; i++ ) {
        if( LastEvent == SavebufBound[i] ){
            buf = i;
            break;
        }
    }
    if( buf < 0 ) {
        return( ERR_NO_ERR );
    }
    CurrentSavebuf = buf;
    tmp = &Savebufs[buf];
    data = NULL;
    switch( tmp->type ) {
    case SAVEBUF_NOP:
        Message1( "Buffer %d now active. (empty buffer)", buf + 1 );
        return( DO_NOT_CLEAR_MESSAGE_WINDOW );
    case SAVEBUF_LINE:
        data = tmp->u.data;
        Message1( "Buffer %d active, %d characters:", buf + 1,
                  strlen( tmp->u.data ) );
        break;
    case SAVEBUF_FCBS:
        cfcb = tmp->u.fcbs.head;
        FetchFcb( cfcb );
        data = cfcb->lines.head->data;
        lcnt = 0;
        for( ; cfcb != NULL; cfcb = cfcb->next ) {
            lcnt += cfcb->end_line - cfcb->start_line + 1;
        }
        Message1( "Buffer %d active, %l lines:", buf + 1, lcnt );
        break;
    }
    Message2( "\"%s\"", data );

    return( DO_NOT_CLEAR_MESSAGE_WINDOW );

} /* SwitchSavebuf */
bool initDebugOutput()
{
	bool Validated(true);

	glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
	glDebugMessageCallbackARB(&glf::debugOutput, NULL);
	GLuint MessageId(4);
	glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_FALSE);
	glDebugMessageControlARB(GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_OTHER_ARB, GL_DONT_CARE, 0, NULL, GL_TRUE);
	glDebugMessageControlARB(GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_OTHER_ARB, GL_DONT_CARE, 1, &MessageId, GL_FALSE);
	std::string Message1("Message 1");
	glDebugMessageInsertARB(
		GL_DEBUG_SOURCE_APPLICATION_ARB, 
		GL_DEBUG_TYPE_OTHER_ARB, 1, 
		GL_DEBUG_SEVERITY_MEDIUM_ARB,
		GLsizei(Message1.size()), Message1.c_str());
	std::string Message2("Message 2");
	glDebugMessageInsertARB(
		GL_DEBUG_SOURCE_THIRD_PARTY_ARB, 
		GL_DEBUG_TYPE_OTHER_ARB, 2, 
		GL_DEBUG_SEVERITY_MEDIUM_ARB,
		GLsizei(Message2.size()), Message2.c_str());
	glDebugMessageInsertARB(
		GL_DEBUG_SOURCE_APPLICATION_ARB, 
		GL_DEBUG_TYPE_OTHER_ARB, 2, 
		GL_DEBUG_SEVERITY_MEDIUM_ARB,
		-1, "Message 3");
	glDebugMessageInsertARB(
		GL_DEBUG_SOURCE_APPLICATION_ARB, 
		GL_DEBUG_TYPE_OTHER_ARB, MessageId, 
		GL_DEBUG_SEVERITY_MEDIUM_ARB,
		-1, "Message 4");

	return Validated;
}
Esempio n. 4
0
/*
 * HideLineRange - hide/unhide a given line range
 */
vi_rc HideLineRange( linenum s, linenum e, bool unhide )
{
    vi_rc       rc;
    bool        hideval;
    fcb         *cfcb;
    line        *cline;
    char        *st;
    linenum     c;

    hideval = TRUE;
    if( unhide ) {
        hideval = FALSE;
    }

    for( c = s; c <= e; c++ ) {
        rc = CGimmeLinePtr( c, &cfcb, &cline );
        if( rc != ERR_NO_ERR ) {
            return( rc );
        }
        cline->u.ld.hidden = hideval;
    }

    DCDisplayAllLines();
    if( unhide ) {
        st = "revealed";
    } else {
        st = "hidden";
    }
    Message1( "%l lines %s", e - s + 1, st );
    EditFlags.Dotable = TRUE;
    return( DO_NOT_CLEAR_MESSAGE_WINDOW );

} /* HideLineRange */
Esempio n. 5
0
/*
 * DoVersion - display version info
 */
vi_rc DoVersion( void )
{
    Message1( "%s", BANNER1 );
    Message2( "%s", BANNER2 );
    return( DO_NOT_CLEAR_MESSAGE_WINDOW );

} /* DoVersion */
Esempio n. 6
0
/* TwoPartSubstitute - goes from current line to current line minus 1
 *                     doing substitute in 2 parts if it has to, that
 *                     appear as 1
 */
vi_rc TwoPartSubstitute( char *find, char *replace, int prompt, int wrap )
{
    vi_rc   rc;
    long    changecnt, linecnt;
    linenum end_line;

    char *cmd = MemAlloc( MAX_INPUT_LINE );

    StartUndoGroup( UndoStack );

    // search from current position forward to end of doc
    sprintf( cmd, "/%s/%s/g%c", find, replace, ( prompt ) ? 'i' : '\0' );

    end_line = CurrentFile->fcbs.tail->end_line;
    rc = Substitute( CurrentPos.line, end_line, cmd );
    changecnt = LastChangeCount;
    linecnt = LastLineCount;
    if( wrap && !LastSubstituteCancelled && CurrentPos.line != 1 &&
        rc == ERR_NO_ERR ) {
        // search from beginning of do to here
        sprintf( cmd, "/%s/%s/g%c", find, replace, ( prompt ) ? 'i' : '\0' );
        rc = Substitute( 1, CurrentPos.line - 1, cmd );
        linecnt += LastLineCount;
        changecnt += LastChangeCount;
    }
    if( rc == ERR_NO_ERR ) {
        Message1( "%l changes on %l lines", changecnt, linecnt );
    }
    EndUndoGroup( UndoStack );

    MemFree( cmd );
    return( rc );

} /* TwoPartSubstitute */
Esempio n. 7
0
vi_rc ChangeCase( range *r )
{
    linenum     curr;
    vi_rc       rc;
    long        total;
    const char  *msg;

    UndoReplaceLines( r->start.line, r->end.line );
    if( r->start.line == r->end.line ) {
        rc = changeOneLine( r->start.line, r->start.column, r->end.column );
        msg = MSG_CHARACTERS;
        total = r->end.column - r->start.column + 1;
    } else {
        rc = changeToEndOfLine( r->start.line, r->start.column );
        if( rc != ERR_NO_ERR ) {
            return( rc );
        }
        for( curr = r->start.line + 1; curr < r->end.line; curr++ ) {
            rc = changeToEndOfLine( curr, 0 );
            if( rc != ERR_NO_ERR ) {
                return( rc );
            }
        }
        rc = changeOneLine( r->end.line, 0, r->end.column );
        msg = MSG_LINES;
        total = r->end.line - r->start.line + 1;
    }
    EditFlags.Dotable = true;
    DCDisplayAllLines();
    Message1( "case toggled for %l %s", total, msg );
    Modified( true );
    return( DO_NOT_CLEAR_MESSAGE_WINDOW );

} /* ChangeCase */
Esempio n. 8
0
/*
 * Error - print an error message in the message window
 */
void Error( char *str, ... )
{
    va_list     al;
    char        tmp[MAX_STR];

    if( MessageWindow != NO_WINDOW ) {
        WindowAuxUpdate( MessageWindow, WIND_INFO_TEXT_COLOR,
                            messagew_info.hilight.foreground );
        WindowAuxUpdate( MessageWindow, WIND_INFO_BACKGROUND_COLOR,
                            messagew_info.hilight.background );
        va_start( al, str );
        MyVSprintf( tmp, str, al );
        va_end( al );

        SourceError( tmp );
        Message1( "%s", tmp );

        WindowAuxUpdate( MessageWindow, WIND_INFO_TEXT_COLOR,
                            messagew_info.text.foreground );
        WindowAuxUpdate( MessageWindow, WIND_INFO_BACKGROUND_COLOR,
                            messagew_info.text.background );
        MyBeep();
    } else {
        va_start( al, str );
#ifndef __WIN__
        MyVPrintf( str, al );
        MyPrintf( "\n" );
#endif
        va_end( al );
    }

} /* Error */
Esempio n. 9
0
static change_resp ChangePrompt( void )
{
#ifdef __WIN__
    int     i;

    i = MyMessageBox( Root, "Change this occurence?", "Replace Text",
                      MB_ICONQUESTION | MB_YESNOCANCEL );
    if( i == IDNO ) {
        return( CHANGE_NO );
    } else if( i == IDCANCEL ) {
        return( CHANGE_CANCEL );
    } else {
        return( CHANGE_OK );
    }
#else
    vi_key      key = 0;

    Message1( "Change? (y)es/(n)o/(a)ll/(q)uit" );
    for( ;; ) {
        key = GetNextEvent( false );
        if( key == VI_KEY( y ) ) {
            return( CHANGE_OK );
        } else if( key == VI_KEY( n ) ) {
            return( CHANGE_NO );
        } else if( key == VI_KEY( a ) ) {
            return( CHANGE_ALL );
        } else if( key == VI_KEY( q ) ) {
            return( CHANGE_CANCEL );
        }
    }
#endif
}
Esempio n. 10
0
static void putMessage( void )
{
    if( needsRedisplay ) {
        ReDisplayScreen();
        needsRedisplay = FALSE;
    }
    Message1( msgString );
}
Esempio n. 11
0
/*
 * ProcessingMessage - display what line is being processed
 */
void ProcessingMessage( linenum cln )
{
    if( EditFlags.Verbose && EditFlags.EchoOn ) {
        // WPrintfLine( MessageWindow,1,"Processing line %l",cln );
        Message1( "Processing line %l", cln );
    }
    
} /* ProcessingMessage */
Esempio n. 12
0
/*
 * FindFcbWithLine - find the fcb with the specified line
 */
vi_rc FindFcbWithLine( linenum lineno, file *cfile, fcb **fb )
{
    bool    lastflag = false;
    fcb     *tfcb, *ofcb;
    vi_rc   rc;

    /*
     * are we looking for the last line?
     */
    if( lineno < 0 ) {
        lastflag = true;
        lineno = MAX_LONG;
    }
    if( lineno < 1 ) {
        return( ERR_NO_SUCH_LINE );
    }
    if( cfile == NULL ) {
        return( ERR_NO_FILE );
    }

    /*
     * run through all possible fcb's
     */
    tfcb = cfile->fcbs.head;
    if( tfcb == NULL ) {
        return( ERR_NO_SUCH_LINE );
    }
    for( ;; ) {

        if( tfcb->end_line >= lineno ) {
            *fb = tfcb;
            FetchFcb( tfcb );
            return( ERR_NO_ERR );
        }
        ofcb = tfcb;
        tfcb = ofcb->next;
        if( tfcb == NULL ) {
            if( !cfile->bytes_pending ) {
                if( lastflag ) {
                    *fb = ofcb;
                    FetchFcb( ofcb );
                    return( ERR_NO_ERR );
                }
                return( ERR_NO_SUCH_LINE );
            }
            if( EditFlags.Verbose ) {
                Message1( "At line %l", ofcb->end_line );
            }
            rc = ReadFcbData( cfile, NULL );
            if( rc != ERR_NO_ERR && rc != END_OF_FILE ) {
                return( rc );
            }
            tfcb = cfile->fcbs.tail;
        }
    }

} /* FindFcbWithLine */
Esempio n. 13
0
/*
 * DeleteRangeOnCurrentLine - perform the deletion
 */
vi_rc DeleteRangeOnCurrentLine( int scol, int ecol, int savebuf_flag )
{
    int     i;
    vi_rc   rc;

    /*
     * verify range
     */
    if( scol > ecol ) {
        i = scol;
        scol = ecol;
        ecol = i;
    }

    /*
     * go delete block and set up undo
     */
    CurrentLineReplaceUndoStart();
    rc = DeleteBlockFromCurrentLine( scol, ecol, savebuf_flag );
    if( rc != ERR_NO_ERR ) {
        CurrentLineReplaceUndoCancel();
        return( rc );
    }
    DisplayWorkLine( TRUE );
    ReplaceCurrentLine();
    CurrentLineReplaceUndoEnd( TRUE );
    EditFlags.Dotable = TRUE;
    if( savebuf_flag ) {
#ifdef __WIN__
        if( LastSavebuf == 0 ) {
            Message1( "%d characters deleted into the clipboard", ecol - scol + 1 );
        } else {
#endif
            Message1( "%d %s%s%c", ecol - scol + 1, MSG_CHARACTERS,
                      MSG_DELETEDINTOBUFFER, LastSavebuf );
#ifdef __WIN__
        }
#endif
    }
    return( ERR_NO_ERR );

} /* DeleteRangeOnCurrentLine */
Esempio n. 14
0
/*
 * NextMenuId - returns the next available unique idea for a menu item
 */
unsigned NextMenuId( void )
{
    if( ++nextAvail == MAX_ID ) {
        /* run through all menu item lists and 'normalize' them */
        /* 0xefff menu id's should be enough so we will forget it
            for now */
        Message1( "YIKES! Menu id rollover! FIXME in file %s - line %d", __FILE__, __LINE__ );
    }
    return( nextAvail );

} /* NextMenuId */
Esempio n. 15
0
/*
 * PushFileStackAndMsg - push the file stack, and display a message
 */
vi_rc PushFileStackAndMsg( void )
{
    vi_rc   rc;

    rc = PushFileStack();
    if( rc == ERR_NO_ERR ) {
        Message1( "Current position saved; %d entries on file stack", fDepth );
    }
    return( rc );

} /* PushFileStackAndMsg */
Esempio n. 16
0
/*
 * 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 */
Esempio n. 17
0
WINEXPORT BOOL CALLBACK GrepListProc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam )
{
    static char         **fileList;
    static int          fileCount;
    HWND                list_box;
    char                tmp[MAX_STR];
    WORD                cmd;

    switch( msg ) {
    case WM_INITDIALOG:
        list_box = GetDlgItem( dlg, ID_FILE_LIST );
        SendMessage( list_box, WM_SETFONT, (WPARAM)FontHandle( dirw_info.text.font ), 0L );
        MySprintf( tmp, "Files Containing \"%s\"", sString );
        SetWindowText( dlg, tmp );
        fileList = (char **)MemAlloc( sizeof( char * ) * MAX_FILES );
        fileCount = initList( list_box, (char *)lparam, fileList );
        if( fileCount == 0 ) {
            /* tell him that there are no matches and close down? */
            Message1( "String \"%s\" not found", sString );
            EndDialog( dlg, DO_NOT_CLEAR_MESSAGE_WINDOW );
        } else {
            SendMessage( list_box, LB_SETCURSEL, 0, 0L );
            BringWindowToTop( dlg );
            SetFocus( dlg );
        }
        break;
    case WM_COMMAND:
        cmd = LOWORD( wparam );
        switch( cmd ) {
        case ID_FILE_LIST:
            if( GET_WM_COMMAND_CMD( wparam, lparam ) == LBN_DBLCLK ) {
                getOneFile( dlg, fileList, &fileCount, TRUE );
            }
            break;
        case ID_EDIT:
        case ID_GOTO:
            getOneFile( dlg, fileList, &fileCount, cmd == ID_GOTO );
            break;
        case ID_GETALL:
            getAllFiles( dlg, fileList, &fileCount );
            break;
        case IDCANCEL:
            EndDialog( dlg, ERR_NO_ERR );
            return( TRUE );
        }
        break;
    case WM_DESTROY:
        MemFreeList( fileCount, fileList );
        break;
    }
    return( FALSE );

} /* GrepListProc */
Esempio n. 18
0
vi_rc DoHelp( char *data )
{
    char        *hfile;
    char        *tstr;
    int         token;
    vi_rc       rc;
    char        path[FILENAME_MAX];
    char        tmp[MAX_STR];
    int         i;

    RemoveLeadingSpaces( data );
    token = Tokenize( helpCmds, data, false );
    if( token == TOK_INVALID ) {
        if( data[0] == 0 ) {
            strcpy( tmp, "Topics: " );
            for( i = 0; i < nHelpFiles; i++ ) {
                if( i != 0 ) {
                    strcat( tmp, ", " );
                }
                strcat( tmp, GetTokenString( helpCmds, i ) );
            }
            Message1( "%s", tmp );
        } else {
            Error( "No help on topic %s", data );
        }
        return( DO_NOT_CLEAR_MESSAGE_WINDOW );
    }
    hfile = helpFiles[token];
    GetFromEnv( hfile, path );
    if( path[0] == 0 ) {
        Error( "Help file %s not found", hfile );
        return( DO_NOT_CLEAR_MESSAGE_WINDOW );
    }
    EditFlags.ViewOnly = true;
    rc = EditFile( path, false );
    EditFlags.ViewOnly = false;
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }
    tstr = GetTokenString( helpCmds, token );
    strcpy( tmp, tstr );
    strlwr( tmp );
    strcat( tmp, " Help" );
    tmp[0] = toupper( tmp[0] );
    CurrentFile->read_only = false;
    AddString2( &(CurrentFile->name), tmp );
    SetFileWindowTitle( CurrentWindow, CurrentInfo, true );
    DisplayFileStatus();
    return( ERR_NO_ERR );

} /* DoHelp */
Esempio n. 19
0
/*
 * FilePromptForSaveChanges - give option to save file if modified
 */
bool FilePromptForSaveChanges( file *f )
{
    char    buffer[MAX_STR];
    vi_rc   rc;

#ifdef __WIN__
    MySprintf( buffer, "\"%s\" has been modified - save changes?",
               f->name );
    BringWindowToTop( Root );
    SetWindowPos( Root, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
    if( MessageBox( Root, buffer, EditorName, MB_YESNO | MB_TASKMODAL ) == IDYES ) {
        rc = SaveFile( NULL, -1, -1, FALSE );
        if( rc != ERR_NO_ERR ) {
            MySprintf( buffer, "Error saving \"%s\"", f->name );
            MessageBox( Root, buffer, EditorName, MB_OK | MB_TASKMODAL );
        } else {
            Modified( FALSE );
        }
    }
    SetWindowPos( Root, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
    SetWindowPos( Root, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
#else
    char    response[MAX_SRC_LINE];

//  MySprintf( buffer, "\"%s\" has been modified - save changes (yes|no|cancel)?",
    MySprintf( buffer, "\"%s\" has been modified - save changes (yes|no)?",
               f->name );
    if( GetResponse( buffer, response ) == GOT_RESPONSE ) {
        switch( response[0] ) {
        case 0:
        // if the user hit ENTER then the buffer will be
        // a string of 0 chars so act as if y had been hit
        case 'y':
        case 'Y':
            rc = SaveFile( NULL, -1, -1, FALSE );
            if( rc != ERR_NO_ERR ) {
                MySprintf( buffer, "Error saving \"%s\"", f->name );
                Message1( buffer );
            } else {
                Modified( FALSE );
            }
            break;
        }
    }
#endif
    /* would return TRUE if we supported a CANCEL option
     * the same as the FileExitOptionSaveChanges function below */
    return( FALSE );

} /* FilePromptForSaveChanges */
Esempio n. 20
0
/*
 * removeGenericAlias
 */
static vi_rc removeGenericAlias( const char *which, alias_list **head, alias_list **tail )
{
    alias_list  *curr;

    which = SkipLeadingSpaces( which );
    curr = checkGenericAlias( which, 0, *head );
    if( curr == NULL ) {
        return( ERR_NO_SUCH_ALIAS );
    }
    DeleteLLItem( (ss **)head, (ss **)tail, (ss *)curr );
    Message1( "%s removed", which );
    return( ERR_NO_ERR );

} /* removeGenericAlias */
Esempio n. 21
0
/*
 * PrintHexValue - print hex value of char under cursor
 */
vi_rc PrintHexValue( void )
{
    int i;

    if( CurrentFile != NULL ) {
        i = CurrentLine->data[CurrentPos.column - 1];
        if( i == '\0' ) {
            // of not on data, pretend are 'on' newline
            i = '\n';
        }
        Message1( "Char '%c': 0x%Z (%d)", (char) i, i, i );
    }

    return( DO_NOT_CLEAR_MESSAGE_WINDOW );

} /* PrintHexValue */
Esempio n. 22
0
/*
 * SwapAllWindows - swap any window data we can
 */
void SwapAllWindows( void )
{
    info        *cinfo;
    wind        *w;

    windowSwapFileOpen();
    if( swapHandle < 0 ) {
        return;
    }
    if( EditFlags.Verbose ) {
        Message1( "Swapping window data" );
    }
    for( cinfo = InfoHead; cinfo != NULL; cinfo = cinfo->next ) {
        w = Windows[cinfo->CurrentWindow];
        if( !TestVisible( w ) && !w->isswapped && w->accessed == 0 ) {
            windowSwap( w );
        }
    }

} /* SwapAllWindows */
Esempio n. 23
0
/*
 * setGenericAlias - define an alias/abbreviation
 */
static vi_rc setGenericAlias( const char *what, alias_list **head, alias_list **tail )
{
    alias_list  *curr;
    char        str[MAX_STR];

    what = GetNextWord1( what, str );
    if( *str == '\0' ) {
        return( ERR_INVALID_ALIAS );
    }
    what = SkipLeadingSpaces( what );

    /*
     * see if alias is already in list: if so, and there is expansion data,
     * then replace the data, else delete the item
     */
    for( curr = *head; curr != NULL; curr = curr->next ) {
        if( strcmp( str, curr->alias ) == 0 ) {
            MemFree( curr->expand );
            if( *what == '\0' ) {
                MemFree( curr->alias );
                MemFree( DeleteLLItem( (ss **)head, (ss **)tail, (ss *)curr ) );
            } else {
                curr->expand = DupString( what );
            }
        }
    }

    /*
     * add the new item
     */
    curr = MemAlloc( sizeof( alias_list ) );
    curr->alias = DupString( str );
    curr->expand = DupString( what );

    AddLLItemAtEnd( (ss **)head, (ss **)tail, (ss *)curr );
    Message1( "%s set to \"%s\"", str, what );
    return( DO_NOT_CLEAR_MESSAGE_WINDOW );

} /* setGenericAlias */
Esempio n. 24
0
/*
 * AutoSaveInit - initialize for auto-save
 */
void AutoSaveInit( void )
{
    char        path[FILENAME_MAX];
    char        path2[FILENAME_MAX];
    char        as_path[FILENAME_MAX];
    char        asl_path[FILENAME_MAX];
    int         len;
    int         cnt;
    FILE        *f;
    int         pid;
    int         ch;
    int         handle;
    int         off;
//    int         old_len;
    int         i;

    /*
     * initialize tmpname
     */
#ifdef __UNIX__
    strcpy( currTmpName,"aaaaaaaaaaaa.tmp" );
#else
    strcpy( currTmpName,"aaaaaaaa.tmp" );
#endif
    pid = getpid();
    itoa( pid, path, 36 );
    len = strlen( path );
    memcpy( &currTmpName[TMP_FNAME_LEN - len], path, len );
#ifdef __QNX__
    {
        int     len2, len3;
        int     nid, uid;

        nid = getnid();
        itoa( nid, path, 36 );
        len2 = strlen( path );
        memcpy( &currTmpName[TMP_FNAME_LEN - len - len2], path, len2 );

        uid = getuid();
        itoa( uid, path, 36 );
        len3 = strlen( path );
        memcpy( &currTmpName[TMP_FNAME_LEN - len - len2 - len3], path, len3 );
        memcpy( &checkFileName[EXTRA_EXT_OFF], path, len3 );
        memcpy( &checkFileTmpName[EXTRA_EXT_OFF], path, len3 );
        memcpy( &lockFileName[EXTRA_EXT_OFF], path, len3 );
    }
#endif

    /*
     * check if we need to recover lost files
     */
    if( EditFlags.RecoverLostFiles ) {
        cnt = 0;
        MakeTmpPath( as_path, checkFileName );
        MakeTmpPath( asl_path, lockFileName );
        off = strlen( as_path ) - 5;
        for( ch = START_CHAR; ch <= END_CHAR; ch++ ) {
            as_path[off] = ch;
            asl_path[off] = ch;
            handle = sopen3( as_path, O_RDONLY | O_TEXT, SH_DENYRW );
            if( handle < 0 ) {
                continue;
            }
            f = fdopen( handle, "r" );
            if( f != NULL ) {
                while( fgets( path2, FILENAME_MAX, f ) != NULL ) {
                    for( i = strlen( path2 ); i && isWSorCtrlZ( path2[i - 1] ); --i ) {
                        path2[i - 1] = '\0';
                    }
                    NextWord1( path2, path );
                    RemoveLeadingSpaces( path2 );
                    NewFile( path, FALSE );
                    AddString2( &(CurrentFile->name), path2 );
                    SetFileWindowTitle( CurrentWindow, CurrentInfo, TRUE );
                    FileSPVAR();
                    CurrentFile->modified = TRUE;
                    CurrentFile->check_readonly = TRUE;
                    FTSRunCmds( path2 );
                    cnt++;
                }
                fclose( f );
                remove( as_path );
            } else {
                close( handle );
            }
            remove( asl_path );
        }
        if( cnt == 0 ) {
            MyPrintf( "No files recovered!\n" );
            ExitEditor( -1 );
        }
        Message1( "%d files recovered", cnt );

    }
    if( EditVars.AutoSaveInterval == 0 ) {
        return;
    }

//    old_len = strlen( lockFileName );
    MakeTmpPath( path, lockFileName );
    len = strlen( path ) - strlen( lockFileName );
    off = len + CHAR_OFF;
    for( ch = START_CHAR; ch <= END_CHAR; ch++ ) {
        path[off] = ch;
        lockFileHandle = sopen4( path, O_CREAT | O_TRUNC | O_RDWR | O_TEXT, SH_DENYRW, PMODE_RW );
        if( lockFileHandle > 0 ) {
            break;
        }
    }
    if( lockFileHandle < 0 ) {
        // MyPrintf( "Too many editors running!\n" );
        MyPrintf( "Error opening temp file - '%s'\n", strerror( errno ) );
        ExitEditor( -1 );
    }
    lockFileName[CHAR_OFF] = ch;
    checkFileName[CHAR_OFF] = ch;
    checkFileTmpName[CHAR_OFF] = ch;

} /* AutoSaveInit */
void Message2(char *Msg1, char *Msg2)
{
   char Ss[4096];
   wsprintf(Ss, "%s\n%s", Msg1, Msg2);
   Message1(Ss);
}
Esempio n. 26
0
/*
 * Shift - shove a tab in/out over a line range
 */
vi_rc Shift( linenum s, linenum e, char dir, bool msgflag )
{
    int         shv;
    linenum     fullcnt = 0;
    vi_rc       rc;

    /*
     * set up undo
     */
    if( rc = ModificationTest() ) {
        return( rc );
    }
    rc = UndoReplaceLines( s, e );
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }

    /*
     * now, point to start line
     */
    rc = SaveAndResetFilePos( s );
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }

    /*
     * process all lines
     */
    for( CurrentPos.line = s; CurrentPos.line <= e; CurrentPos.line++ ) {

        /*
         * Add/Subtract leading tab space
         */
        GetCurrentLine();
        shv = ShiftWidth;
        if( dir != '>' ) {
            shv *= -1;
        }
        if( AddLeadingTabSpace( &WorkLine->len, WorkLine->data, shv ) ) {
            ++fullcnt;
        }
        ReplaceCurrentLine();

        if( CurrentPos.line != e ) {
            rc = CGimmeNextLinePtr( &CurrentFcb, &CurrentLine );
            if( rc != ERR_NO_ERR ) {
                RestoreCurrentFilePos();
                return( rc );
            }
        }

    }

    /*
     * done, say so and go back
     */
    RestoreCurrentFilePos();
    if( msgflag ) {
        Message1( "%l lines %c'ed", e - s + 1, dir );
        if( fullcnt > 0 ) {
            Message2( "%l full lines not processed", fullcnt );
        }
    }
    if( CurrentPos.line >= s && CurrentPos.line <= e ) {
        CheckCurrentColumn();
    }
    DCDisplayAllLines();
    SetWindowCursor();
    Modified( TRUE );
    return( DO_NOT_CLEAR_MESSAGE_WINDOW );

} /* Shift */
Esempio n. 27
0
/*
 * GenerateConfiguration - write out a config file
 */
vi_rc GenerateConfiguration( const char *fname, bool is_cmdline )
{
    FILE        *fp;
    int         i;
    char        token[128];
    const char  *str;
    char        *buff;
    int         num;
    rgb         c;
    const char  *res;
    char        tmpstr[MAX_STR];

    if( fname == NULL ) {
        fname = CFG_NAME;
    }
    fp = fopen( fname, "w" );
    if( fp == NULL ) {
        return( ERR_FILE_OPEN );
    }
    isCmdLine = is_cmdline;
    buff = MemAllocUnsafe( VBUF_SIZE );
    if( buff != NULL ) {
        setvbuf( fp, buff, _IOFBF, VBUF_SIZE );
    }
    MyFprintf( fp, "#\n# %s configuration file\n# %s\n#\n",
#if defined( __WIN__ )
    banner1w1( "Text Editor for Windows" ), banner1w2( _VI_VERSION_ ) );
#else
    banner1w1( "Vi Text Editor" ), banner1w2( _VI_VERSION_ ) );
#endif
    if( is_cmdline ) {
        GetDateTimeString( token );
        MyFprintf( fp, "# File generated on %s\n#\n", token );
    }

    writeTitle( fp, "Hook script assignments" );
    doHookAssign( fp, SRC_HOOK_WRITE );
    doHookAssign( fp, SRC_HOOK_READ );
    doHookAssign( fp, SRC_HOOK_BUFFIN );
    doHookAssign( fp, SRC_HOOK_BUFFOUT );
    doHookAssign( fp, SRC_HOOK_COMMAND );
    doHookAssign( fp, SRC_HOOK_MODIFIED );
    doHookAssign( fp, SRC_HOOK_MENU );
    doHookAssign( fp, SRC_HOOK_MOUSE_LINESEL );
    doHookAssign( fp, SRC_HOOK_MOUSE_CHARSEL );

    writeTitle( fp, "General Settings" );
    num = GetNumberOfTokens( SetVarTokens );
    for( i = 0; i < num; i++ ) {
        if( i == SETVAR_T_TILECOLOR || i == SETVAR_T_FIGNORE || i == SETVAR_T_FILENAME ) {
            continue;
        }
        res = GetASetVal( GetTokenStringCVT( SetVarTokens, i, token, true ), tmpstr );
        switch( i ) {
        case SETVAR_T_STATUSSTRING:
        case SETVAR_T_FILEENDSTRING:
        case SETVAR_T_HISTORYFILE:
        case SETVAR_T_TMPDIR:
            /* strings with possible spaces */
            MyFprintf( fp, "set %s = \"%s\"\n", token, res );
            break;
        case SETVAR_T_GADGETSTRING:
            if( !IsGadgetStringChanged( res ) )
                break;
            // fall through
        default:
            MyFprintf( fp, "set %s = %s\n", token, res );
            break;
        }
    }

    writeTitle( fp, "Boolean Settings" );
    num = GetNumberOfTokens( SetFlagTokens );
    for( i = 0; i < num; i++ ) {
        str = GetASetVal( GetTokenStringCVT( SetFlagTokens, i, token, true ), tmpstr );
        MyFprintf( fp, "set %s%s\n", (*str == '0') ? "no" : "", token );
    }
    writeTitle( fp, "Match pairs" );
    for( i = INITIAL_MATCH_COUNT; i < MatchCount; i += 2 ) {
        MyFprintf( fp, "match /" );
        outputMatchData( fp, MatchData[i] );
        outputMatchData( fp, MatchData[i + 1] );
        MyFprintf( fp, "\n" );
    }

    writeTitle( fp, "Command Mode Mappings" );
    doMaps( fp, KeyMaps, "" );
    writeTitle( fp, "Insert Mode Mappings" );
    doMaps( fp, InputKeyMaps, "!" );

    writeTitle( fp, "Color Settings" );
    for( i = 0; i < GetNumColors(); i++ ) {
        if( GetColorSetting( i, &c ) ) {
            MyFprintf( fp, "setcolor %d %d %d %d\n", i, c.red, c.green, c.blue );
        }
    }

#ifdef __WIN__
    writeTitle( fp, "Font Settings" );
    BarfFontData( fp );
#endif

    writeTitle( fp, "Window Configuration" );
    doWindow( fp, PCL_T_COMMANDWINDOW, &cmdlinew_info, false );
    doWindow( fp, PCL_T_STATUSWINDOW, &statusw_info, false );
    doWindow( fp, PCL_T_COUNTWINDOW, &repcntw_info, false );
    doWindow( fp, PCL_T_EDITWINDOW, &editw_info, false );
    doWindow( fp, PCL_T_FILECWINDOW, &filecw_info, false );
    doWindow( fp, PCL_T_DIRWINDOW, &dirw_info, false );
    doWindow( fp, PCL_T_FILEWINDOW, &filelistw_info, false );
    doWindow( fp, PCL_T_MESSAGEWINDOW, &messagew_info, false );
#ifndef __WIN__
    doWindow( fp, PCL_T_SETWINDOW, &setw_info, false );
    doWindow( fp, PCL_T_LINENUMBERWINDOW, &linenumw_info, false );
    doWindow( fp, PCL_T_EXTRAINFOWINDOW, &extraw_info, false );
    doWindow( fp, PCL_T_SETVALWINDOW, &setvalw_info, false );
    doWindow( fp, PCL_T_MENUWINDOW, &menuw_info, false );
    doWindow( fp, PCL_T_MENUBARWINDOW, &menubarw_info, true );
    doWindow( fp, PCL_T_ACTIVEMENUWINDOW, &activemenu_info, true );
    doWindow( fp, PCL_T_GREYEDMENUWINDOW, &greyedmenu_info, true );
    doWindow( fp, PCL_T_ACTIVEGREYEDMENUWINDOW, &activegreyedmenu_info, true );
#endif

    writeTitle( fp, "Menu Configuration" );
    BarfMenuData( fp );

#ifdef __WIN__
    writeTitle( fp, "ToolBar Configuration" );
    BarfToolBarData( fp );
#endif

    writeTitle( fp, "File Type Source" );
    FTSBarfData( fp );

    fclose( fp );
    if( is_cmdline ) {
        Message1( "Configuration file \"%s\" generated", fname );
    }

    MemFree( buff );
    return( DO_NOT_CLEAR_MESSAGE_WINDOW );

} /* GenerateConfiguration */
Esempio n. 28
0
/*
 * doCompressExpand - convert tabs to spaces, and spaces to tabs
 */
static vi_rc doCompressExpand( bool compress )
{
    int         k;
    long        bytes_saved = 0;
    long        bytes_added = 0;
    long        otabcnt;
    linenum     linecnt = 0;
    char        *tmp;
    vi_rc       rc;

    /*
     * init
     */
    rc = ModificationTest();
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }
    rc = SaveAndResetFilePos( 1 );
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }
    tmp = StaticAlloc();

    /*
     * process all lines
     */
    TabCnt = 0;
    for( ;; ) {

        if( compress ) {
            otabcnt = TabCnt;
            ExpandTabsInABuffer( CurrentLine->data, CurrentLine->len, tmp, EditVars.MaxLine );
            TabCnt = otabcnt;
            k = strlen( tmp );
            ConvertSpacesToTabsUpToColumn( k, tmp, k, WorkLine->data, EditVars.MaxLine );
            WorkLine->len = strlen( WorkLine->data );
            bytes_saved += CurrentLine->len - WorkLine->len;
        } else {
            ExpandTabsInABuffer( CurrentLine->data, CurrentLine->len, WorkLine->data, EditVars.MaxLine );
            WorkLine->len = strlen( WorkLine->data );
            bytes_added += WorkLine->len - CurrentLine->len;
        }
        ReplaceCurrentLine();

        /*
         * get next line
         */
        linecnt++;
        rc = CGimmeNextLinePtr( &CurrentFcb, &CurrentLine );
        if( rc != ERR_NO_ERR ) {
            if( rc == ERR_NO_MORE_LINES ) {
                break;
            }
            RestoreCurrentFilePos();
            StaticFree( tmp );
            return( rc );
        }

    }

    StaticFree( tmp );
    RestoreCurrentFilePos();

    Modified( TRUE );
    DCDisplayAllLines();
    Message1( "%l lines processed in \"%s\"", linecnt, CurrentFile->name );
    if( compress ) {
        Message2( " %l tabs added (%l bytes saved)", TabCnt, bytes_saved );
    } else {
        Message2( " %l tabs removed (%l bytes added)", TabCnt, bytes_added );
    }
    return( DO_NOT_CLEAR_MESSAGE_WINDOW );

} /* doCompressExpand */
Esempio n. 29
0
/*
 * DoGenericFilter - filter some crap
 */
vi_rc DoGenericFilter( linenum s, linenum e, const char *cmd )
{
    fcb         *cfcb, *tfcb;
    line        *cline;
    vi_rc       rc;
    char        filtin[_MAX_PATH], filtout[_MAX_PATH];
    fcb_list    fcblist;
    int         fh;

    rc = ModificationTest();
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }

    /*
     * filter on a line
     */
    rc = GetCopyOfLineRange( s, e, &fcblist );
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }

    /*
     * get file
     */
    MakeTmpPath( filtin, FILTER_FILE_NAME );
    fh = mkstemp( filtin );
    if( fh == -1 )
        return( ERR_FILE_OPEN );

    /*
     * now, dump this crap to a tmp file
     */
    for( cfcb = fcblist.head; cfcb != NULL; cfcb = tfcb ) {
        FetchFcb( cfcb );
        for( cline = cfcb->lines.head; cline != NULL; cline = cline->next ) {
            write( fh, cline->data, strlen( cline->data ) );
#if defined( __UNIX__ )
            write( fh, "\n", 1 );
#else
            write( fh, "\r\n", 2 );
#endif
        }
        tfcb = cfcb->next;
        FcbFree( cfcb );
    }
    close( fh );

    MakeTmpPath( filtout, FILTER_FILE_NAME );
    fh = mkstemp( filtout );
    if( fh == -1 ) {
        remove( filtin );
        return( ERR_FILE_OPEN );
    }
    close( fh );
    /*
     * shell out to the given command
     */
    ExecCmd( filtin, filtout, cmd );
    StartUndoGroup( UndoStack );
    rc = DeleteLineRange( s, e, 0 );
    if( rc == ERR_NO_ERR ) {
        ReadAFile( s - 1, filtout );
        Message1( "%l lines filtered through %s", e - s + 1, cmd );
    }
    EndUndoGroup( UndoStack );

    /*
     * cleanup
     */
    if( rc == ERR_NO_ERR ) {
        rc = DO_NOT_CLEAR_MESSAGE_WINDOW;
    }
    remove( filtin );
    remove( filtout );
    return( rc );

} /* DoGenericFilter */
Esempio n. 30
0
/*
 * Substitute - perform substitution
 */
vi_rc Substitute( linenum n1, linenum n2, char *data )
{
    char        *sstr, *rstr, *newr;
    char        flag[20], *linedata;
    bool        iflag = false;
    bool        gflag = false;
    bool        undoflag = false;
    bool        restline = false;
    bool        splitpending = false;
    bool        undoline = false;
    int         i, rlen, slen;
    bool        splitme;
    long        changecnt = 0, linecnt = 0;
    linenum     llineno, ll, lastline = 0, extra;
    i_mark      pos;
    vi_rc       rc;

    LastSubstituteCancelled = 0;
    LastChangeCount = 0;
    LastLineCount = 0;

    sstr = alloca( MAX_INPUT_LINE );
    if( sstr == NULL ) {
        return( ERR_NO_STACK );
    }
    strcpy( sstr, data );
    rc = ModificationTest();
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }
    strcpy( data, sstr );
    rstr = alloca( MAX_INPUT_LINE  );
    if( rstr == NULL ) {
        return( ERR_NO_STACK );
    }
    if( NextWordSlash( data, sstr ) < 0 ) {
        return( ERR_INVALID_SUBS_CMD );
    }
    if( NextWordSlash( data, rstr ) < 0 ) {
        return( ERR_INVALID_SUBS_CMD );
    }
    slen = NextWord1( data, flag );
    for( i = 0; i < slen; i++ ) {
        switch( flag[i] ) {
        case 'g':
            gflag = true;
            break;
        case 'i':
        case 'c':
            iflag = true;
            break;
        }
    }
    rc = CurrentRegComp( sstr );
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }

    /*
     * 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 );
    }
    SaveCurrentFilePos();
    llineno = n1 - 1;

    EditFlags.AllowRegSubNewline = true;
    newr = StaticAlloc();
    for( pos.column = 0, pos.line = n1;
        pos.line <= n2;
        nextSearchStartPos( &pos, gflag, rlen ) ) {

        /*
         * get regular expression, and build replacement string
         */
        rc = FindRegularExpression( NULL, &pos, &linedata, n2, 0 );
        if( rc != ERR_NO_ERR || pos.line > n2 ) {
            break;
        }

        slen = GetCurrRegExpLength();
        splitme = RegSub( CurrentRegularExpression, rstr, newr, pos.line );
        rlen = strlen( newr );

        ProcessingMessage( pos.line );

        /*
         * if in global mode, see if we already have an undo for
         * this line
         */
        if( gflag ) {
            if( lastline != pos.line ) {
                undoline = false;
            }
        }

        /*
         * interactive mode? yes, then display text and ask to change
         */
        if( iflag ) {
            change_resp rsp;

            if( !restline ) {
                ClearWindow( MessageWindow );
            }
            restline = true;
            GoToLineNoRelCurs( pos.line );
            if( EditFlags.GlobalInProgress ) {
                EditFlags.DisplayHold = false;
                DCDisplayAllLines();
                EditFlags.DisplayHold = true;
            }
            HilightSearchString( &pos, slen );
            rsp = ChangePrompt();
            if( rsp == CHANGE_NO ) {
                ResetDisplayLine();
                rlen = 1;
                continue;
            } else if( rsp == CHANGE_CANCEL ) {
                ResetDisplayLine();
                LastSubstituteCancelled = 1;
                break;
            } else if( rsp == CHANGE_ALL ) {
                ResetDisplayLine();
                iflag = false;
            }
        }

        /*
         * set up for global undo if we haven't already
         */
        if( !undoflag ) {
            StartUndoGroup( UndoStack );
            undoflag = true;
        }

        /*
         * bump change counts
         */
        changecnt++;
        if( llineno != pos.line ) {
            if( splitpending ) {
                splitpending = false;
                extra = SplitUpLine( llineno );
                n2 += extra;
                pos.line += extra;
            }
            linecnt++;
            llineno = pos.line;
        }

        /*
         * get copy of line, and verify that new stuff fits
         */
        CurrentPos.line = pos.line;
        rc = CGimmeLinePtr( pos.line, &CurrentFcb, &CurrentLine );
        if( rc != ERR_NO_ERR ) {
            break;
        }
        if( CurrentLine->len + rlen - slen >= EditVars.MaxLine ) {
            rc = ERR_LINE_FULL;
            break;
        }

        /*
         * now build the individual undo
         */
        CurrentFcb->non_swappable = true;
        if( !undoline ) {
            CurrentLineReplaceUndoStart();
            CurrentLineReplaceUndoEnd( true );
            if( gflag ) {
                undoline = true;
                lastline = pos.line;
            }
        }

        /*
         * remove the old string
         */
        GetCurrentLine();
        WorkLine->len = ReplaceSubString( WorkLine->data, WorkLine->len,
                                          pos.column, pos.column + slen - 1, newr, rlen );
        if( iflag ) {
            DisplayWorkLine( true );
        }
        ReplaceCurrentLine();

        /*
         * if not global, only do this change on this line
         */
        if( splitme ) {
            splitpending = true;
        }
        CurrentFcb->non_swappable = false;
    }
    StaticFree( newr );
    EditFlags.AllowRegSubNewline = false;
    /*
    * is there still a split line pending?
    */
    if( splitpending ) {
        SplitUpLine( llineno );
    }
    RestoreCurrentFilePos();
    if( restline ) {
        SetCurrentLine( CurrentPos.line );
        GoToColumnOK( CurrentPos.column );
    }
    if( undoflag ) {
        EndUndoGroup( UndoStack );
    }
    switch( rc ) {
    case ERR_NO_ERR:
    case ERR_LINE_FULL:
    case ERR_FIND_PAST_TERM_LINE:
    case ERR_FIND_NOT_FOUND:
    case ERR_FIND_END_OF_FILE:
        /*
        * display results
        */
        if( rc == ERR_LINE_FULL ) {
            Message1( "Stopped at line %l - line full", pos.line );
        } else {
            Message1( "%l changes on %l lines", changecnt, linecnt );
            LastLineCount = linecnt;
            LastChangeCount = changecnt;
        }
        DCDisplayAllLines();
        rc = ERR_NO_ERR;
        break;
    default:
        break;
    }
    return( rc );

} /* Substitute */