Exemplo n.º 1
0
static void FilePos( a_window *wnd, int pos )
{
    unsigned long       range;
    file_window *file = WndFile( wnd );

    if( pos < 0 )
        pos = 0;
    if( file->viewhndl == NULL ) {
        if( pos+WndRows(wnd) > file->eof )
            return;
        WndSetTop( wnd, pos );
        return;
    }
    if( FReadLine( file->viewhndl, pos+WndRows(wnd), 0, TxtBuff, TXT_LEN ) < 0 ) {
        pos = FCurrLine( file->viewhndl ) - WndRows(wnd) - 1;
        if( pos < 0 ) {
            pos = 0;
        }
    }
    WndSetTop( wnd, pos );
    if( pos >= file->rows ) {
        file->rows = pos+1;
        file->rows_offset = FLastOffset( file->viewhndl );
    }
    if( file->rows == 0 )
        file->rows = 1;
    if( file->rows_offset == 0 ) {
        range = file->size;
    } else {
        range = file->size * file->rows / file->rows_offset;
    }
    WndSetVScrollRange( wnd, range );
    WndSetThumbPos( wnd, pos );
}
Exemplo n.º 2
0
extern char * WPSourceGetLine( a_window * wnd, int line )
/*******************************************************/
{
    sio_data *      curr_sio;
    wp_srcfile *    wp_src;
    int             buff_len;

    curr_sio = WndExtra( wnd );
    wp_src = curr_sio->src_file;
    if( wp_src->src_buff_len == 0 ) {
        wp_src->src_buff = ProfAlloc( 100 );
        wp_src->src_buff_len = 100;
    }
    for( ;; ) {
        buff_len = FReadLine( wp_src->src_file, line, 0, wp_src->src_buff,
                              wp_src->src_buff_len );
        if( buff_len != wp_src->src_buff_len ) break;
        wp_src->src_buff_len += 120;
        wp_src->src_buff = ProfRealloc( wp_src->src_buff,
                                        wp_src->src_buff_len );
    }
    if( buff_len < 0 ) {
        wp_src->src_eof = P_TRUE;
        return( NULL );
    }
    wp_src->src_eof = P_FALSE;
    wp_src->src_buff[buff_len] = NULLCHAR;
    return( wp_src->src_buff );
}
Exemplo n.º 3
0
bool DUIGetSourceLine( cue_handle *ch, char *buff, unsigned len )
{
    void        *viewhndl;

    viewhndl = OpenSrcFile( ch );
    if( viewhndl == NULL ) return( FALSE );
    buff[ FReadLine( viewhndl, CueLine( ch ), 0, buff, len )] = '\0';
    FDoneSource( viewhndl );
    return( TRUE );
}
Exemplo n.º 4
0
bool DUIGetSourceLine( cue_handle *ch, char *buff, unsigned len )
{
    void        *viewhndl;

    viewhndl = OpenSrcFile( ch );
    if( viewhndl == NULL ) return( false );
    buff[FReadLine( viewhndl, CueLine( ch ), 0, buff, len )] = NULLCHAR;
    FDoneSource( viewhndl );
    return( true );
}
Exemplo n.º 5
0
int main( void )
{
    char        buff[256];
    struct browser *fp;
    int         len;
    int         i;
    int         got;

    fp = FOpenSource( "testsrcm.c", 0, 0 );
    if( fp != NULL ) {
        for( i = 1; FReadLine( fp, i, 0, buff, 256 ) != FREADLINE_ERROR; ++i ) {
        }
        for( --i; i >= 1; --i ) {
            buff[FReadLine( fp, i, 0, buff, 256 )] = '\0';
            printf( "%s\n", buff );
        }
        FDoneSource( fp );
    }
}
Exemplo n.º 6
0
static void SeekToTheEnd( file_window *file )
{
    if( file->viewhndl != NULL && !FileIsRemote( file->viewhndl ) ) {
        FReadLine( file->viewhndl, INT_MAX, 0, TxtBuff, TXT_LEN );
        file->rows = FCurrLine( file->viewhndl ) - 1;
        file->rows_offset = FLastOffset( file->viewhndl );
    } else {
        file->rows = 0;
        file->rows_offset = 0;
    }
}
Exemplo n.º 7
0
char * WPAsmGetLine( a_window * wnd, int line )
/*********************************************/
{
    sio_data *      curr_sio;
    wp_asmfile *    wpasm_file;
    src_info *      src;
    wp_asmline *    asm_line;
    int             asm_group;
    int             asm_row;
    int             buff_len;

    curr_sio = WndExtra( wnd );
    wpasm_file = curr_sio->asm_file;
    if( line >= wpasm_file->asm_rows ) {
        return( NULL );
    }
    asm_line = WPGetAsmLoc( wpasm_file, line, &asm_group, &asm_row );
    if( asm_line->source_line ) {
        src = &asm_line->u.src;
        if( src->src_file == NULL ) {
            strcpy( wpasm_file->asm_buff, LIT( Unable_To_Open_Src ) );
        } else {
            for( ;; ) {
                buff_len = FReadLine( src->src_file, src->line, 0,
                                      wpasm_file->asm_buff,
                                      wpasm_file->asm_buff_len );
                if( buff_len != wpasm_file->asm_buff_len ) break;
                wpasm_file->asm_buff_len += 120;
                wpasm_file->asm_buff = ProfRealloc( wpasm_file->asm_buff,
                                                    wpasm_file->asm_buff_len );
            }
            if( buff_len < 0 ) {
                buff_len = 0;
            }
            wpasm_file->asm_buff[buff_len] = NULLCHAR;
        }
    } else {
        SetNumBytes( 0 );
        SetExeFile( wpasm_file->fh, false );
        SetExeImage( curr_sio->curr_image );
        GetFullInstruct( asm_line->u.asm_line.addr, wpasm_file->asm_buff, wpasm_file->asm_buff_len-1 );
    }
    return( wpasm_file->asm_buff );
}
Exemplo n.º 8
0
static  bool    FileGetLine( a_window *wnd, int row, int piece,
                             wnd_line_piece *line )
{
    int         len;
    file_window *file = WndFile( wnd );
    address     addr;
    brkp        *bp;
    bool        curr;
    DIPHDL( cue, ch );

    line->text = LIT_ENG( Empty );
    if( file->viewhndl == NULL && ModHasInfo( file->mod, HK_CUE ) != DS_OK ) {
        return( false );
    }
    curr = ( row == file->active && ContextMod == file->mod );
    switch( piece ) {
    case PIECE_BREAK:
        line->tabstop = false;
        if( row >= file->eof )
            return( false );
        if( file->mod == NO_MOD )
            return( true );
        addr = NilAddr;
        if( !WndDoingSearch ) { // too expensive
            addr = GetRowAddr( file, row, true );
        }
        if( !IS_NIL_ADDR( addr ) ) {
            bp = FindBreakByLine( file->mod, file->file_id, row+1 );
            FileBreakGadget( wnd, line, curr, bp );
        }
        return( true );
    case PIECE_SOURCE:
        line->text = TxtBuff;
        line->extent = WND_MAX_EXTEND;
        if( curr )
            line->attr = WND_STANDOUT;
        if( file->mod != NO_MOD ) {
            line->indent = MaxGadgetLength;
        }
        if( file->viewhndl == NULL ) {
            Format( TxtBuff, LIT_DUI( No_Source_Line ), row+1 );
            if( LineCue( file->mod, file->file_id, 0, 0, ch ) != SR_NONE ) {
                if( (CueAdjust( ch, -1, ch ) & DS_ERR) ) {
                    file->eof = CueLine( ch );
                }
            }
            return( true );
        }
        len = FReadLine( file->viewhndl, row+1, 0, TxtBuff, MAX_LINE_LEN );
        if( len < 0 ) {
            file->eof = row;
            return( false );
        }
        if( len == MAX_LINE_LEN ) {
            StrCopy( " ...", TxtBuff + MAX_LINE_LEN );
        } else {
            TxtBuff[len] = NULLCHAR;
        }
        if( row >= file->rows ) {
            file->rows = row + 1;
            file->rows_offset = FLastOffset( file->viewhndl );
        }
        return( true );
    default:
        return( false );
    }
}