# HG changeset patch # User Dan Drogichen # Date 1405449621 25200 # Tue Jul 15 11:40:21 2014 -0700 # Node ID 35add4ba02ebdd4e9b77a8394d8f807ec8c3f2e9 # Parent 8fb3d3a31a27187ab5385372f0d1f687ee83179a [developer] Control address format for full-file dump/diff - #1767 Add a [developer] section directive "hexdump_addrfmt" which takes values of "decimal", "hex", or "both", allowing developers to see the address printed in the full-file hex dump/diff display as they prefer. The default remains "decimal". If the value supplied is not recognized, a log message is printed and the default is used. The decimal format, where printed, now prints a minimum of 4 digits instead of 3, to eliminate the column alignment break at address 1000. README.developers is modified to document hexdump_addrfmt, and also to put the directive descriptions in alphabetical order, and other small corrections. #1767 diff -r 8fb3d3a31a27 -r 35add4ba02eb README.developers --- a/README.developers Sat Jul 12 20:05:28 2014 -0700 +++ b/README.developers Tue Jul 15 11:40:21 2014 -0700 @@ -19,19 +19,10 @@ [developer] diff_fontsize = 16 browser_fontsize = 13 +hexdump_addrfmt = both =================================== -diff_fontize = -This specifies the fontsize used in the hex dump/diff display which is -invoked by selecting View -> Developer -> Diff tabs, and then in the -"Diff Radios" popup, selecting < 0 for either or both memory locations. - -The default size is 11. Values less than 4, greater than 144, or not -recognized as an integer will result in a log message and the default -size will be used. - -======== browser_fontsize = This specifies the fontsize used in the file browser, invoked by selecting the "Browser" tab in the left sidebar, which is visible when the Developer @@ -40,3 +31,22 @@ The default size is 10. Values less than 4, greater than 144, or not recognized as an integer will result in a log message and the default size will be used. +======== + +diff_fontize = +This specifies the fontsize used in the hex dump/diff display which is +invoked by selecting View -> Developer -> Diff tabs. + +The default size is 11. Values less than 4, greater than 144, or not +recognized as an integer will result in a log message and the default +size will be used. +======== + +hexdump_addrfmt = decimal | hex | both +This specifies the format of the address used in the full-file hex dump/diff +display which is invoked by selecting View -> Developer -> Diff tabs, +and then in the "Diff Radios" popup, selecting < 0 for either or both +memory locations. + +The default is decimal. Values not recognized as one of the three values +shown will result in a log message and the default format will be used. diff -r 8fb3d3a31a27 -r 35add4ba02eb chirp/util.py --- a/chirp/util.py Sat Jul 12 20:05:28 2014 -0700 +++ b/chirp/util.py Tue Jul 15 11:40:21 2014 -0700 @@ -15,6 +15,10 @@ import struct +from chirpui import config + +CONF = config.get() + def hexprint(data): """Return a hexdump-like encoding of @data""" line_sz = 8 @@ -26,9 +30,24 @@ data += "\x00" * ((lines * line_sz) - len(data)) out = "" + + try: + addrfmt = CONF.get("hexdump_addrfmt", "developer") + except Exception: + addrfmt = "decimal" + if addrfmt == None: + addrfmt = "decimal" + elif (addrfmt != "decimal" and addrfmt != "hex" and addrfmt != "both"): + print "Invalid hexdump_addrfmt value %s. Using decimal." % addrfmt + addrfmt = "decimal" for i in range(0, (len(data)/line_sz)): - out += "%03i: " % (i * line_sz) + if addrfmt == "hex": + out += "x%04X: " % (i * line_sz) + elif addrfmt == "both": + out += "%04i x%04X: " % ((i * line_sz), (i * line_sz)) + else: + out += "%04i: " % (i * line_sz) left = len(data) - (i * line_sz) if left < line_sz: