MacroInspect which comments macros
-
I see you didn’t break down the search “boolean” values in your latest script, so, I took the liberty of pulling that code from my now defunct macro disassembler and inserting it into your script:
elif message == 'IDC_FRCOMMAND_BOOLEANS': numeric_data = int(v) bit_weights_numeric_value_to_str_dict = { 1 : 'MATCH_WHOLE_WORD_ONLY', 2 : 'MATCH_CASE', 4 : 'PURGE_MARKS_BEFORE_NEW_SEARCH', 16 : 'BOOKMARK_LINE', 32 : 'IN_SUBFOLDERS', 64 : 'IN_HIDDEN_FOLDERS', 128 : 'IN_SELECTION__OR__PROJECT1', 256 : 'WRAP_AROUND__OR__PROJECT2', 512 : 'FORWARD_DIRECTION__OR__PROJECT3', 1024 : 'DOT_MATCHES_NEWLINE_FOR_REGEX', } running_single_bitweight = 1 search_options_str_list = [] while numeric_data != 0: if running_single_bitweight in bit_weights_numeric_value_to_str_dict: if (numeric_data & running_single_bitweight) != 0: search_options_str_list.append(bit_weights_numeric_value_to_str_dict[running_single_bitweight]) numeric_data &= ~running_single_bitweight running_single_bitweight <<= 1 value_str = 'NONE' if len(search_options_str_list) == 0 else ' / '.join(search_options_str_list) comment += ' [ ' + value_str + ' ]'
-
I have already tested
IDC_FRCOMMAND_BOOLEANS
and ran into issues. If you look at the json data file, you may see lines like:"128": "IDF_IN_SELECTION_CHECK IDF_FINDINFILES_PROJECT1_CHECK", "256": "IDF_WRAP IDF_FINDINFILES_PROJECT2_CHECK", "512": "IDF_WHICH_DIRECTION IDF_FINDINFILES_PROJECT3_CHECK",
which has space delimited pairs of constant names.
as I use this code to fill the dictionary with the constant pairs:
if k in dic: dic[k] += ' ' + v else: dic[k] = v
which are pairs that share the same boolean value in which only 1 can be correct. Though in testing depending on the FindReplaceDLG tab recorded, sometimes none are correct IMO. I am unsure if I can fix the code I have to make it reliable as some incorrect comments may make the user puzzled. I suspect that perhaps some bit flags should not be in the
lParams
value and perhaps the playback ignores them, though that does not help with making the xml comments.
Edit:
There is also a possibility that Notepad++ is getting the checkbox booleans incorrect. Unchecked/checked is ok until disabling the checkbox, which leads to a 3rd state with a enabled/disabled needing to be validated. IDK yet and so may need investigation. This may explain why I get
IDF_FINDINFILES_PROJECT2_CHECK
andIDF_FINDINFILES_PROJECT3_CHECK
in the comments even though they are unchecked and disabled so cannot be valid in the xml comments. -
@mpheath said in MacroInspect which comments macros:
I have already tested IDC_FRCOMMAND_BOOLEANS and ran into issues.
I don’t know…but I’m fairly certain the code I posted works correctly.
which are pairs that share the same boolean value in which only 1 can be correct.
Yep, the “genius” that implemented the project options decided repurposing some bit weighting for that was a great idea.
I suspect that perhaps some bit flags should not be in the lParams value and perhaps the playback ignores them
Yes, there can be items that are not applicable in there.
If one knew in advance what the 1701 value was going to be, one could filter out the n/a items, but alas the 1702 message comes before the 1701.