Statusline for Hexfiles verbessert
git-svn-id: https://vimsuite.svn.sourceforge.net/svnroot/vimsuite/trunk@184 eb2d0018-73a3-4aeb-bfe9-1def61c9ec69
This commit is contained in:
parent
bd755f44a3
commit
fe6af919eb
@ -35,9 +35,8 @@ endfunction
|
|||||||
|
|
||||||
" Get Address of current cursor position
|
" Get Address of current cursor position
|
||||||
function! s:HexGetAddress()
|
function! s:HexGetAddress()
|
||||||
let AddressLineNumber = search('^:02*', 'bcnW')
|
let AddressLineNumber = search('^:......04*', 'bcnW')
|
||||||
let AddressLine = getline(AddressLineNumber)
|
let AddressLine = getline(AddressLineNumber)
|
||||||
|
|
||||||
let LineDict = s:HexParseLine(AddressLine)
|
let LineDict = s:HexParseLine(AddressLine)
|
||||||
let ExtLinAddress = LineDict['Data']
|
let ExtLinAddress = LineDict['Data']
|
||||||
|
|
||||||
@ -80,29 +79,25 @@ function! HexGetVal(Bytes)
|
|||||||
let LineDict = s:HexParseLine(getline(line('.')))
|
let LineDict = s:HexParseLine(getline(line('.')))
|
||||||
let Data = LineDict['Data']
|
let Data = LineDict['Data']
|
||||||
let DataList = HexSplitData(Data)
|
let DataList = HexSplitData(Data)
|
||||||
|
if (StartByte + a:Bytes) <= len(DataList)
|
||||||
let ByteNum = 0
|
let ByteNum = 0
|
||||||
while ByteNum < a:Bytes
|
while ByteNum < a:Bytes
|
||||||
try
|
|
||||||
let HexString .= DataList[StartByte + ByteNum]
|
let HexString .= DataList[StartByte + ByteNum]
|
||||||
catch /^Vim\%((\a\+)\)\=:E684/
|
|
||||||
throw 'oops'
|
|
||||||
finally
|
|
||||||
let ByteNum += 1
|
let ByteNum += 1
|
||||||
endtry
|
|
||||||
endwhile
|
endwhile
|
||||||
return eval('0x'.HexString)
|
return eval('0x'.HexString)
|
||||||
|
else
|
||||||
|
return -1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Get actual values for 1, 2, 4 Bytes in hex and dez
|
" Get actual values for 1, 2, 4 Bytes in hex and dez
|
||||||
function! s:HexGetDezValuesString()
|
function! s:HexGetDezValuesString()
|
||||||
let String = ''
|
let String = ''
|
||||||
for i in [1, 2, 4]
|
for i in [1, 2, 4]
|
||||||
try
|
|
||||||
let Byte = HexGetVal(i)
|
let Byte = HexGetVal(i)
|
||||||
catch /oops/
|
if Byte != -1
|
||||||
break
|
|
||||||
endtry
|
|
||||||
let String .= ' ' . printf('0x%x (%d)', Byte, Byte)
|
let String .= ' ' . printf('0x%x (%d)', Byte, Byte)
|
||||||
|
endif
|
||||||
endfor
|
endfor
|
||||||
return String
|
return String
|
||||||
endfunction
|
endfunction
|
||||||
@ -112,10 +107,10 @@ function! HexStatusLine()
|
|||||||
let StatusLine =
|
let StatusLine =
|
||||||
\ ' Address: '
|
\ ' Address: '
|
||||||
\ . s:HexGetAddress()
|
\ . s:HexGetAddress()
|
||||||
\ . ' Data: '
|
|
||||||
\ . s:HexGetAsciiLine()
|
|
||||||
\ . ' Values: '
|
\ . ' Values: '
|
||||||
\ . s:HexGetDezValuesString()
|
\ . s:HexGetDezValuesString()
|
||||||
|
" \ . ' Data: '
|
||||||
|
" \ . s:HexGetAsciiLine()
|
||||||
return StatusLine
|
return StatusLine
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -124,7 +119,8 @@ endfunction
|
|||||||
" echo HexStatusLine()
|
" echo HexStatusLine()
|
||||||
"endfunction
|
"endfunction
|
||||||
|
|
||||||
command HexStatusLine set statusline=%!HexStatusLine()
|
command! HexStatusLine set statusline=%!HexStatusLine()
|
||||||
|
command! HexStatusLineOff set statusline=
|
||||||
" Update statusline with HEX info
|
" Update statusline with HEX info
|
||||||
set statusline=%!HexStatusLine()
|
set statusline=%!HexStatusLine()
|
||||||
" Always show statusline
|
" Always show statusline
|
||||||
|
Loading…
x
Reference in New Issue
Block a user