mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 15:44:04 +02:00
IntelFsp2Pkg: Add search function for Config Editor
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. It also includes a README for this function. Cc: Maurice Ma <maurice.ma@intel.com> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Chasel Chiu <chasel.chiu@intel.com> Signed-off-by: Loo Tung Lun <tung.lun.loo@intel.com> Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
This commit is contained in:
parent
be282b1493
commit
cac83b6f3b
@ -811,6 +811,8 @@ class application(tkinter.Frame):
|
|||||||
self.org_cfg_data_bin = None
|
self.org_cfg_data_bin = None
|
||||||
self.in_left = state()
|
self.in_left = state()
|
||||||
self.in_right = state()
|
self.in_right = state()
|
||||||
|
self.search_text = ''
|
||||||
|
self.binseg_dict = {}
|
||||||
|
|
||||||
# Check if current directory contains a file with a .yaml extension
|
# Check if current directory contains a file with a .yaml extension
|
||||||
# if not default self.last_dir to a Platform directory where it is
|
# if not default self.last_dir to a Platform directory where it is
|
||||||
@ -835,6 +837,23 @@ class application(tkinter.Frame):
|
|||||||
|
|
||||||
root.geometry("1200x800")
|
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 = ttk.Panedwindow(root, orient=tkinter.HORIZONTAL)
|
||||||
paned.pack(fill=tkinter.BOTH, expand=True, padx=(4, 4))
|
paned.pack(fill=tkinter.BOTH, expand=True, padx=(4, 4))
|
||||||
|
|
||||||
@ -943,6 +962,12 @@ class application(tkinter.Frame):
|
|||||||
"Unsupported file '%s' !" % path)
|
"Unsupported file '%s' !" % path)
|
||||||
return
|
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):
|
def set_object_name(self, widget, name):
|
||||||
self.conf_list[id(widget)] = name
|
self.conf_list[id(widget)] = name
|
||||||
|
|
||||||
@ -976,14 +1001,18 @@ class application(tkinter.Frame):
|
|||||||
'units')
|
'units')
|
||||||
|
|
||||||
def update_visibility_for_widget(self, widget, args):
|
def update_visibility_for_widget(self, widget, args):
|
||||||
|
|
||||||
visible = True
|
visible = True
|
||||||
item = self.get_config_data_item_from_widget(widget, True)
|
item = self.get_config_data_item_from_widget(widget, True)
|
||||||
if item is None:
|
if item is None:
|
||||||
return visible
|
return visible
|
||||||
elif not item:
|
elif not item:
|
||||||
return visible
|
return visible
|
||||||
|
if self.cfg_data_obj.binseg_dict:
|
||||||
|
str_split = item['path'].split('.')
|
||||||
|
if self.cfg_data_obj.binseg_dict[str_split[-2]] == -1:
|
||||||
|
visible = False
|
||||||
|
widget.grid_remove()
|
||||||
|
return visible
|
||||||
result = 1
|
result = 1
|
||||||
if item['condition']:
|
if item['condition']:
|
||||||
result = self.evaluate_condition(item)
|
result = self.evaluate_condition(item)
|
||||||
@ -999,6 +1028,12 @@ class application(tkinter.Frame):
|
|||||||
widget.grid()
|
widget.grid()
|
||||||
widget.configure(state='normal')
|
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
|
return visible
|
||||||
|
|
||||||
def update_widgets_visibility_on_page(self):
|
def update_widgets_visibility_on_page(self):
|
||||||
@ -1134,6 +1169,7 @@ class application(tkinter.Frame):
|
|||||||
self.fsp_version = '2.X'
|
self.fsp_version = '2.X'
|
||||||
else:
|
else:
|
||||||
self.fsp_version = '1.X'
|
self.fsp_version = '1.X'
|
||||||
|
|
||||||
return gen_cfg_data
|
return gen_cfg_data
|
||||||
|
|
||||||
def about(self):
|
def about(self):
|
||||||
@ -1377,6 +1413,7 @@ class application(tkinter.Frame):
|
|||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
path = name
|
path = name
|
||||||
|
|
||||||
item = self.cfg_data_obj.get_item_by_path(path)
|
item = self.cfg_data_obj.get_item_by_path(path)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
@ -583,6 +583,8 @@ class CGenYamlCfg:
|
|||||||
self._mode = ''
|
self._mode = ''
|
||||||
self._debug = False
|
self._debug = False
|
||||||
self._macro_dict = {}
|
self._macro_dict = {}
|
||||||
|
self.bin_offset = []
|
||||||
|
self.binseg_dict = {}
|
||||||
self.initialize()
|
self.initialize()
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
@ -1301,10 +1303,15 @@ option format '%s' !" % option)
|
|||||||
if 'indx' not in cfgs:
|
if 'indx' not in cfgs:
|
||||||
return
|
return
|
||||||
act_cfg = self.get_item_by_index(cfgs['indx'])
|
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,
|
value = get_bits_from_bytes(full_bytes,
|
||||||
act_cfg['offset'] -
|
actual_offset,
|
||||||
struct_info['offset'],
|
|
||||||
act_cfg['length'])
|
act_cfg['length'])
|
||||||
act_val = act_cfg['value']
|
act_val = act_cfg['value']
|
||||||
if act_val == '':
|
if act_val == '':
|
||||||
@ -1423,9 +1430,11 @@ for '%s' !" % (act_cfg['value'], act_cfg['path']))
|
|||||||
"in binary, the 1st instance will be used !"
|
"in binary, the 1st instance will be used !"
|
||||||
% seg[0])
|
% seg[0])
|
||||||
bin_segs.append([seg[0], pos, seg[2]])
|
bin_segs.append([seg[0], pos, seg[2]])
|
||||||
|
self.binseg_dict[seg[0]] = pos
|
||||||
else:
|
else:
|
||||||
raise Exception("Could not find '%s' in binary !"
|
bin_segs.append([seg[0], -1, seg[2]])
|
||||||
% seg[0])
|
self.binseg_dict[seg[0]] = -1
|
||||||
|
continue
|
||||||
|
|
||||||
return bin_segs
|
return bin_segs
|
||||||
|
|
||||||
@ -1433,8 +1442,17 @@ for '%s' !" % (act_cfg['value'], act_cfg['path']))
|
|||||||
# get cfg bin length
|
# get cfg bin length
|
||||||
cfg_bins = bytearray()
|
cfg_bins = bytearray()
|
||||||
bin_segs = self.get_bin_segment(bin_data)
|
bin_segs = self.get_bin_segment(bin_data)
|
||||||
|
Dummy_offset = 0
|
||||||
for each in bin_segs:
|
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:
|
||||||
|
string = each[0] + ' is not availabe.'
|
||||||
|
messagebox.showinfo('', string)
|
||||||
|
self.bin_offset.append([Dummy_offset, each[1], each[2]])
|
||||||
|
cfg_bins.extend(bytearray(each[2]))
|
||||||
|
Dummy_offset += each[2]
|
||||||
return cfg_bins
|
return cfg_bins
|
||||||
|
|
||||||
def save_current_to_bin(self):
|
def save_current_to_bin(self):
|
||||||
@ -1447,12 +1465,15 @@ for '%s' !" % (act_cfg['value'], act_cfg['path']))
|
|||||||
cfg_off = 0
|
cfg_off = 0
|
||||||
for each in bin_segs:
|
for each in bin_segs:
|
||||||
length = each[2]
|
length = each[2]
|
||||||
bin_data[each[1]:each[1] + length] = cfg_bins[cfg_off:
|
if each[1] != -1:
|
||||||
cfg_off
|
bin_data[each[1]:each[1] + length] = cfg_bins[cfg_off:
|
||||||
+ length]
|
cfg_off
|
||||||
cfg_off += length
|
+ length]
|
||||||
print('Patched the loaded binary successfully !')
|
cfg_off += length
|
||||||
|
else:
|
||||||
|
cfg_off += length
|
||||||
|
|
||||||
|
print('Patched the loaded binary successfully !')
|
||||||
return bin_data
|
return bin_data
|
||||||
|
|
||||||
def load_default_from_bin(self, bin_data):
|
def load_default_from_bin(self, bin_data):
|
||||||
@ -1469,6 +1490,7 @@ for '%s' !" % (act_cfg['value'], act_cfg['path']))
|
|||||||
if not top:
|
if not top:
|
||||||
raise Exception("Invalid configuration path '%s' !"
|
raise Exception("Invalid configuration path '%s' !"
|
||||||
% path)
|
% path)
|
||||||
|
|
||||||
return self.get_field_value(top)
|
return self.get_field_value(top)
|
||||||
|
|
||||||
def generate_binary(self, bin_file_name, path=''):
|
def generate_binary(self, bin_file_name, path=''):
|
||||||
|
@ -40,6 +40,10 @@ This option generates a new configuration delta file for the newly changed value
|
|||||||
## 8. Save Full Config Data to Delta File
|
## 8. Save Full Config Data to Delta File
|
||||||
This option saves all the changed configuration values into a Delta file.
|
This option saves all the changed configuration values into a Delta file.
|
||||||
|
|
||||||
|
## 9. Search feature
|
||||||
|
This feature helps the user to easily find any configuration item they are looking for in ConfigEditor.
|
||||||
|
A text search box is available on the Top Right Corner of ConfigEditor. To use this feature the user should type the name or a key word of the item they want to search in the text box and then click on the "Search" button. This will display all the items which contains that particular word searched by the user.
|
||||||
|
|
||||||
## Running Configuration Editor:
|
## Running Configuration Editor:
|
||||||
|
|
||||||
**python ConfigEditor.py**
|
**python ConfigEditor.py**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user