extern void AsmMoveDot( a_window *wnd, address addr ) { int row; asm_window *asw; DIPHDL( cue, ch1 ); DIPHDL( cue, ch2 ); if( wnd == NULL ) return; asw = WndAsm( wnd ); if( DeAliasAddrCue( asw->mod, addr, ch1 ) != SR_NONE && DeAliasAddrCue( asw->mod, asw->dotaddr, ch2 ) != SR_NONE ) { if( CueMod( ch1 ) == CueMod( ch2 ) && CueFileId( ch1 ) == CueFileId( ch2 ) && CueLine( ch1 ) == CueLine( ch2 ) ) { return; } } WndNoSelect( wnd ); row = AsmAddrRow( wnd, addr ); if( row == WndRows( wnd ) ) { AsmSetFirst( wnd, addr, TRUE ); row = AsmAddrRow( wnd, addr ); WndDirtyCurr( wnd ); WndNewCurrent( wnd, row, PIECE_CURRENT ); WndRepaint( wnd ); row = 0; } else { WndDirtyCurr( wnd ); WndNewCurrent( wnd, row, PIECE_CURRENT ); } AsmSetDotAddr( wnd, addr ); }
extern bool SrcMoveDot( a_window *wnd, address addr ) { unsigned line; mod_handle mod; file_window *file; DIPHDL( cue, ch ); if( wnd == NULL ) return( FALSE ); file = WndFile( wnd ); if( file->mod == NO_MOD && !file->track ) return( FALSE ); if( IS_NIL_ADDR( addr ) ) { WndScrollAbs( wnd, 0 ); return( FALSE ); } DeAliasAddrMod( addr, &mod ); if( DeAliasAddrCue( mod, addr, ch ) == SR_NONE ) { if( LineCue( mod, 0, 0, 0, ch ) == SR_NONE ) return( FALSE ); } line = CueLine( ch ); if( mod != file->mod || CueFileId( ch ) != file->file_id ) { if( !file->track ) return( FALSE ); FileTrack( wnd, ch ); } --line; WndScrollAbs( wnd, line ); // WndMoveCurrent( wnd, line, PIECE_SOURCE ); FileSetDotAddr( wnd, addr ); FileSetTitle( wnd, CueMod( ch ) ); return( TRUE ); }
void *OpenSrcFile( cue_handle *ch ) { void *hndl; char_ring *path; char *p; char *d; char *rem_name; bool used_star; unsigned len; char *buff; len = CueFile( ch, NULL, 0 ) + 1; _AllocA( buff, len ); CueFile( ch, buff, len ); hndl = FOpenSource( buff, CueMod( ch ), CueFileId( ch ) ); if( hndl != NULL ) return( hndl ); for( path = SrcSpec; path != NULL; path = path->next ) { used_star = FALSE; d = TxtBuff; for( p = path->name; *p != '\0'; ++p ) { if( *p == '*' ) { used_star = TRUE; d += ModName( CueMod( ch ), d, TXT_LEN ); } else { *d++ = *p; } } *d = NULLCHAR; if( !used_star ) { #if 0 /* John can't remember why he put this code in, and it screws up when the user sets a source path of ".". If we find some case where it's required, we'll have to think harder about things. */ if( *ExtPointer( TxtBuff, 0 ) != '\0' ) { *SkipPathInfo( TxtBuff, 0 ) = '\0'; } #endif d = AppendPathDelim( TxtBuff, 0 ); if( !IsAbsolutePath( buff ) ) { StrCopy( buff, d ); hndl = FOpenSource( TxtBuff, CueMod( ch ), CueFileId( ch ) ); if( hndl != NULL ) return( hndl ); } /* We have a small problem here. We want to strip off the path information for the source file name, but we don't know if the file was compiled on the local system or the remote one. We'll kludge things by doing a local skip and then a remote one and seeing who takes off the most stuff. Don't even think about the case where the file has been compiled on a third, different type of file system. */ p = SkipPathInfo( buff, OP_LOCAL ); rem_name = SkipPathInfo( buff, OP_REMOTE ); if( rem_name > p ) p = rem_name; d = StrCopy( p, d ); *d = NULLCHAR; } hndl = FOpenSource( TxtBuff, CueMod( ch ), CueFileId( ch ) ); if( hndl != NULL ) return( hndl ); } return( NULL ); }
/** * WalkFileList callback, the module pass. * * @returns WR_CONTINUE * @param cue The file. * @param ignored Unused user argument. */ static walk_result File2Callback( cue_handle *cue, void *ignored ) { address prev_addr = {0}; long prev_line = -1; cue_handle *next_cue = alloca( DIPHandleSize( HK_CUE, false ) ); cue_handle *prev_cue = NULL; cue_handle *cue2 = alloca( DIPHandleSize( HK_CUE, false ) ); mod_handle mod = CueMod( cue ); cue_fileid file_id = CueFileId( cue ); search_result search_rc; char buff[1024]; size_t len; dip_status rc; /* filename */ buff[0] = '\0'; len = CueFile( cue, buff, sizeof( buff ) ); if( len > 0 ) { printf( " %lx %s\n", file_id, buff ); } else { printf( " %lx (len=%u)\n", file_id, len ); } /* check the LineCue function */ if( Opts.do_cue_tests ) { search_rc = LineCue( mod, file_id, 0, 0, cue2 ); CompareCues( cue, cue2, SR_EXACT, search_rc, true, false, true, false, "LineCue(,,0,)" ); } /* lines */ do { long line = CueLine( cue ); unsigned column = CueColumn( cue ); address addr = CueAddr( cue ); printf( " Line %5ld ", line ); if( column ) { printf( "Col %2d ", column ); } printf( "at %04x:%08lx%s\n", addr.mach.segment, (long)addr.mach.offset, prev_line >= 0 && addr.mach.offset < prev_addr.mach.offset ? "^" : prev_line >= 0 && line < prev_line ? "!" : "" ); /* do tests */ if( Opts.do_cue_tests ) { if( CueFileId( cue ) != file_id ) { printf( "ERROR: file id changed! new:%#lx old:%#lx\n", (long)CueFileId( cue ), (long)file_id ); } if( CueMod( cue ) != mod ) { printf( "ERROR: module changed! new:%#lx old:%#lx\n", (long)CueMod( cue ), (long)file_id ); } /* line searches */ search_rc = LineCue( mod, file_id, line, 0, cue2 ); CompareCues( cue, cue2, SR_EXACT, search_rc, true, false, false, false, "LineCue(,,n,)" ); if( line > prev_line + 1 && prev_line >= 0 ) { search_rc = LineCue( mod, file_id, line - 1, 0, cue2 ); CompareCues( prev_cue, cue2, prev_line == line - 1 ? SR_EXACT : SR_CLOSEST, search_rc, true, false, false, false, "LineCue(,,n-1,)" ); } /* address searches */ search_rc = AddrCue( mod, addr, cue2 ); CompareCues( cue, cue2, SR_EXACT, search_rc, false, false, true, false, "AddrCue(,,n,)" ); } /* next */ rc = CueAdjust( cue, 1, next_cue ); prev_cue = cue; cue = next_cue; next_cue = prev_cue; prev_addr = addr; prev_line = line; } while( rc == DS_OK ); return( WR_CONTINUE ); }
static void FileTrack( a_window *wnd, cue_handle *ch ) { unsigned active, old_active; unsigned end_line; int slack; file_window *file = WndFile( wnd ); mod_handle mod; cue_fileid id; wnd_row curr_row; int curr_piece; if( ch == NULL ) { mod = NO_MOD; id = 0; } else { mod = CueMod( ch ); id = CueFileId( ch ); } if( file->viewhndl == NULL || file->mod != mod || file->file_id != id ) { if( file->viewhndl != NULL ) { FDoneSource( file->viewhndl ); } file->mod = mod; file->file_id = id; FileSetDotAddr( wnd, GetCodeDot() ); if( file->mod == NO_MOD ) { file->viewhndl = NULL; } else { file->viewhndl = OpenSrcFile( ch ); } FileSetTitle( wnd, mod ); SeekToTheEnd( file ); file->eof = UINT_MAX; WndZapped( wnd ); FilePosInit( wnd ); file->active = NOT_ACTIVE; FilePos( wnd, 0 ); DbgUpdate( UP_OPEN_CHANGE ); } active = ActiveLine(); if( active != file->active ) { FileSetDotAddr( wnd, GetCodeDot() ); WndGetCurrent( wnd, &curr_row, &curr_piece ); WndNoCurrent( wnd ); if( curr_row != WND_NO_ROW ) { WndRowDirty( wnd, curr_row ); } } old_active = file->active; file->active = NOT_ACTIVE; slack = WndRows( wnd ) / 4; if( slack > 2 ) slack = 2; end_line = WndTop( wnd ) + WndRows( wnd ) - 1; if( old_active == NOT_ACTIVE || active > end_line ) { WndZapped( wnd ); WndScroll( wnd, active - slack - WndTop( wnd ) ); } else if( active > end_line - slack ) { WndRowDirtyImmed( wnd, old_active ); WndScroll( wnd, WndRows( wnd ) - 2 * slack ); } else if( active < WndTop( wnd ) ) { WndRowDirtyImmed( wnd, old_active ); WndScroll( wnd, active - WndTop( wnd ) - slack ); } else { WndRowDirty( wnd, old_active ); } WndNewCurrent( wnd, active, PIECE_SOURCE ); WndRowDirty( wnd, active ); file->active = active; }