BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3482
This patch adds a search function in the Config Editor GUI at the top right corner. Once users key in the words to search, it will look for the option containing the string in the same page and display it. Cc: Maurice Ma <maurice...@intel.com> Cc: Nate DeSimone <nathaniel.l.desim...@intel.com> Cc: Star Zeng <star.z...@intel.com> Cc: Chasel Chiu <chasel.c...@intel.com> Signed-off-by: Loo Tung Lun <tung.lun....@intel.com> --- IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py | 31 +++++++++++++++++++++++++++++++ IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py | 25 +++++++++++++++++++------ 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py b/IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py index a7f79bbc96..d58df385b1 100644 --- a/IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py +++ b/IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py @@ -811,6 +811,7 @@ class application(tkinter.Frame): self.org_cfg_data_bin = None self.in_left = state() self.in_right = state() + self.search_text = '' # Check if current directory contains a file with a .yaml extension # if not default self.last_dir to a Platform directory where it is @@ -835,6 +836,23 @@ class application(tkinter.Frame): root.geometry("1200x800") + # Search string + fram = tkinter.Frame(root) + # adding label to search box + tkinter.Label(fram, text='Text to find:').pack(side=tkinter.LEFT) + # adding of single line text box + self.edit = tkinter.Entry(fram, width=30) + # positioning of text box + self.edit.pack( + side=tkinter.LEFT, fill=tkinter.BOTH, expand=1, padx=(4, 4)) + # setting focus + self.edit.focus_set() + # adding of search button + butt = tkinter.Button(fram, text='Search', relief=tkinter.GROOVE, + command=self.search_bar) + butt.pack(side=tkinter.RIGHT, padx=(4, 4)) + fram.pack(side=tkinter.TOP, anchor=tkinter.SE) + paned = ttk.Panedwindow(root, orient=tkinter.HORIZONTAL) paned.pack(fill=tkinter.BOTH, expand=True, padx=(4, 4)) @@ -943,6 +961,12 @@ class application(tkinter.Frame): "Unsupported file '%s' !" % path) return + def search_bar(self): + # get data from text box + self.search_text = self.edit.get() + # Clear the page and update it according to search value + self.refresh_config_data_page() + def set_object_name(self, widget, name): self.conf_list[id(widget)] = name @@ -999,6 +1023,12 @@ class application(tkinter.Frame): widget.grid() widget.configure(state='normal') + if visible and self.search_text != '': + name = item['name'] + if name.lower().find(self.search_text.lower()) == -1: + visible = False + widget.grid_remove() + return visible def update_widgets_visibility_on_page(self): @@ -1377,6 +1407,7 @@ class application(tkinter.Frame): return None else: path = name + item = self.cfg_data_obj.get_item_by_path(path) return item diff --git a/IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py b/IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py index 25fd9c547e..0d9505b97f 100644 --- a/IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py +++ b/IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py @@ -583,6 +583,7 @@ class CGenYamlCfg: self._mode = '' self._debug = False self._macro_dict = {} + self.bin_offset = [] self.initialize() def initialize(self): @@ -1301,10 +1302,15 @@ option format '%s' !" % option) if 'indx' not in cfgs: return act_cfg = self.get_item_by_index(cfgs['indx']) - if force or act_cfg['value'] == '': + actual_offset = act_cfg['offset'] - struct_info['offset'] + set_value = True + for each in self.bin_offset: + if actual_offset in range(each[0], (each[0] + each[2]) * 8): + if each[1] < 0: + set_value = False + if set_value and force or act_cfg['value'] == '': value = get_bits_from_bytes(full_bytes, - act_cfg['offset'] - - struct_info['offset'], + actual_offset, act_cfg['length']) act_val = act_cfg['value'] if act_val == '': @@ -1424,8 +1430,8 @@ for '%s' !" % (act_cfg['value'], act_cfg['path'])) % seg[0]) bin_segs.append([seg[0], pos, seg[2]]) else: - raise Exception("Could not find '%s' in binary !" - % seg[0]) + bin_segs.append([seg[0], -1, seg[2]]) + continue return bin_segs @@ -1433,8 +1439,15 @@ for '%s' !" % (act_cfg['value'], act_cfg['path'])) # get cfg bin length cfg_bins = bytearray() bin_segs = self.get_bin_segment(bin_data) + Dummy_offset = 0 for each in bin_segs: - cfg_bins.extend(bin_data[each[1]:each[1] + each[2]]) + if each[1] != -1: + self.bin_offset.append([Dummy_offset, each[1], each[2]]) + cfg_bins.extend(bin_data[each[1]:each[1] + each[2]]) + else: + self.bin_offset.append([Dummy_offset, each[1], each[2]]) + cfg_bins.extend(bytearray(each[2])) + Dummy_offset += each[2] return cfg_bins def save_current_to_bin(self): -- 2.28.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#77550): https://edk2.groups.io/g/devel/message/77550 Mute This Topic: https://groups.io/mt/84040828/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-