equal
deleted
inserted
replaced
2910 contentsOfBytesAsDump:dataOrFileStream base:numberBase numberOfAddressDigits:addrDigits |
2910 contentsOfBytesAsDump:dataOrFileStream base:numberBase numberOfAddressDigits:addrDigits |
2911 addressStart:virtualStart characterEncoding:characterEncodingSymbol |
2911 addressStart:virtualStart characterEncoding:characterEncodingSymbol |
2912 highlightRangeHolder:nil |
2912 highlightRangeHolder:nil |
2913 ! |
2913 ! |
2914 |
2914 |
2915 contentsOfBytesAsDump:dataOrFileStream base:numberBase numberOfAddressDigits:addrDigits |
2915 contentsOfBytesAsDump:dataOrFileStream base:numberBaseArg numberOfAddressDigits:addrDigits |
2916 addressStart:virtualStart characterEncoding:characterEncodingSymbol |
2916 addressStart:virtualStart characterEncoding:characterEncodingSymbol |
2917 highlightRangeHolder:highlightRangeHolderOrNil |
2917 highlightRangeHolder:highlightRangeHolderOrNil |
2918 |
2918 |
2919 "utility helper: generate a hex (or octal) dump with addresses; |
2919 "utility helper: generate a hex (or octal) dump with addresses; |
2920 characterEncodingSymbol determines how characters are to be shown in the right (character) columns. |
2920 characterEncodingSymbol determines how characters are to be shown in the right (character) columns. |
2937 |
2937 |
2938 "/ used to be: |
2938 "/ used to be: |
2939 "/ replacementForUnprintable := $. |
2939 "/ replacementForUnprintable := $. |
2940 replacementForUnprintable := Character value:16rB7. "/ a centered dot. |
2940 replacementForUnprintable := Character value:16rB7. "/ a centered dot. |
2941 |
2941 |
2942 "/ cols needed per byte in the hex dump |
|
2943 colsPerByte := ((255 printStringRadix:numberBase) size). |
|
2944 spaces := String new:colsPerByte. |
|
2945 |
|
2946 dataSize := dataOrFileStream isStream |
2942 dataSize := dataOrFileStream isStream |
2947 ifTrue:[ dataOrFileStream fileSize ] |
2943 ifTrue:[ dataOrFileStream fileSize ] |
2948 ifFalse:[ dataOrFileStream size ]. |
2944 ifFalse:[ dataOrFileStream size ]. |
2949 nHexLines := (dataSize + 15) // 16. |
2945 nHexLines := (dataSize + 15) // 16. |
2950 |
2946 |
2952 lines := VirtualArray new. |
2948 lines := VirtualArray new. |
2953 lines setSize:nHexLines + (nHexLines // 16). |
2949 lines setSize:nHexLines + (nHexLines // 16). |
2954 lines |
2950 lines |
2955 generator:[:lineNr | |
2951 generator:[:lineNr | |
2956 |blockNr lineNrInBlock startOffset lineStream asciiLineStream byte line |
2952 |blockNr lineNrInBlock startOffset lineStream asciiLineStream byte line |
2957 decodedChar charPrinted| |
2953 decodedChar charPrinted numberBase padChar| |
|
2954 |
|
2955 numberBase := numberBaseArg value. |
|
2956 padChar := numberBase == 10 ifTrue:[Character space] ifFalse:[$0]. |
|
2957 |
|
2958 "/ cols needed per byte in the hex dump |
|
2959 colsPerByte := ((255 printStringRadix:numberBase) size). |
|
2960 spaces := String new:colsPerByte. |
2958 |
2961 |
2959 blockNr := (lineNr - 1) // 17. |
2962 blockNr := (lineNr - 1) // 17. |
2960 lineNrInBlock := (lineNr - 1) \\ 17. |
2963 lineNrInBlock := (lineNr - 1) \\ 17. |
2961 |
2964 |
2962 lineNrInBlock == 16 ifTrue:[ |
2965 lineNrInBlock == 16 ifTrue:[ |
2984 dataOrFileStream position:(startOffset + i - 1). |
2987 dataOrFileStream position:(startOffset + i - 1). |
2985 byte := dataOrFileStream nextByte. |
2988 byte := dataOrFileStream nextByte. |
2986 ] ifFalse:[ |
2989 ] ifFalse:[ |
2987 byte := dataOrFileStream at:startOffset + i. |
2990 byte := dataOrFileStream at:startOffset + i. |
2988 ]. |
2991 ]. |
2989 byteString := (byte printStringRadix:numberBase size:colsPerByte fill:$0). |
2992 byteString := (byte printStringRadix:numberBase size:colsPerByte fill:padChar). |
2990 |
2993 |
2991 decodedChar := byte. |
2994 decodedChar := byte. |
2992 characterDecoder notNil ifTrue:[ |
2995 characterDecoder notNil ifTrue:[ |
2993 decodedChar := characterDecoder encode:byte. |
2996 decodedChar := characterDecoder encode:byte. |
2994 ]. |
2997 ]. |
2995 |
|
2996 charPrinted := replacementForUnprintable. |
2998 charPrinted := replacementForUnprintable. |
2997 decodedChar notNil ifTrue:[ |
2999 decodedChar notNil ifTrue:[ |
2998 ((decodedChar between:32 and:127) or:[(decodedChar between:(128+32) and:(128+127))]) ifTrue:[ |
3000 ((decodedChar between:32 and:127) or:[(decodedChar between:(128+32) and:(128+127))]) ifTrue:[ |
2999 charPrinted := Character value:decodedChar. |
3001 charPrinted := Character value:decodedChar. |
3000 ] ifFalse:[ |
3002 ] ifFalse:[ |