@@ -116,7 +116,7 @@ class Dictionary(tk.Tk):
116116        self .local_var  =  tk .StringVar (value = self .current_local )
117117        selected_g2p  =  config .get ('Settings' , 'G2P' , fallback = 'Arpabet-Plus G2p' )
118118        self .g2p_var  =  tk .StringVar (value = selected_g2p )
119-         self .current_version  =  "v0.9.0 " 
119+         self .current_version  =  "v0.9.7 " 
120120
121121        # Set window title 
122122        self .base_title  =  "OpenUTAU Dictionary Editor" 
@@ -1155,12 +1155,13 @@ class Dictionary(tk.Tk):
11551155            self .entries_window  =  tk .Toplevel (self )
11561156            self .entries_window .title ("Entries Viewer" )
11571157            self .entries_window .protocol ("WM_DELETE_WINDOW" , self .close )
1158-             self .save_state_before_change ()
1158+             #self.save_state_before_change() 
1159+             self .icon (self .entries_window )
11591160
11601161            # Create a Frame for the search bar 
11611162            search_frame  =  ttk .Frame (self .entries_window , style = 'Card.TFrame' )
11621163            search_frame .pack (fill = tk .X , padx = 15 , pady = 10 )
1163-             search_label  =  ttk .Button (search_frame , text = "Search:" , style = 'Accent.TButton' , command = self .filter_treeview )
1164+             search_label  =  ttk .Button (search_frame , text = "Search:" , style = 'Accent.TButton' , command = self .iterate_search )
11641165            search_label .pack (side = tk .LEFT , padx = (10 ,5 ), pady = 5 )
11651166            self .localizable_widgets ['search' ] =  search_label 
11661167            self .search_var  =  tk .StringVar ()
@@ -1194,8 +1195,6 @@ class Dictionary(tk.Tk):
11941195            self .viewer_tree .bind ("<Button-3>" , self .deselect_entry )
11951196            # select 
11961197            self .viewer_tree .bind ("<<TreeviewSelect>>" , self .on_tree_selection )
1197-             self .entries_window .bind ("<Control-a>" , lambda  event : self .select_all_entries ())
1198-             self .entries_window .bind ("<Command-a>" , lambda  event : self .select_all_entries ())
11991198            # mouse drag 
12001199            self .viewer_tree .bind ("<ButtonPress-1>" , self .start_drag )
12011200            self .viewer_tree .bind ("<B1-Motion>" , self .on_drag )
@@ -1206,13 +1205,15 @@ class Dictionary(tk.Tk):
12061205            os_name  =  platform .system ()
12071206            if  os_name  ==  "Windows" :
12081207                # Windows key bindings 
1208+                 self .entries_window .bind ("<Control-a>" , lambda  event : self .select_all_entries ())
12091209                self .entries_window .bind ('<Control-z>' , lambda  event : self .undo ())
12101210                self .entries_window .bind ('<Control-y>' , lambda  event : self .redo ())
12111211                self .entries_window .bind ("<Control-c>" , lambda  event : self .copy_entry ())
12121212                self .entries_window .bind ("<Control-x>" , lambda  event : self .cut_entry ())
12131213                self .entries_window .bind ("<Control-v>" , lambda  event : self .paste_entry ())
12141214            elif  os_name  ==  "Darwin" :
12151215                # macOS key bindings (uses Command key) 
1216+                 self .entries_window .bind ("<Command-a>" , lambda  event : self .select_all_entries ())
12161217                self .entries_window .bind ('<Command-z>' , lambda  event : self .undo ())
12171218                self .entries_window .bind ('<Command-y>' , lambda  event : self .redo ())
12181219                self .entries_window .bind ("<Command-c>" , lambda  event : self .copy_entry ())
@@ -1250,12 +1251,11 @@ class Dictionary(tk.Tk):
12501251                        self .viewer_tree .update ()
12511252
12521253            # Refresh the Treeview 
1253-             self .icon (self .entries_window )
12541254            self .viewer_tree .pack (side = tk .LEFT , fill = tk .BOTH , expand = True , padx = (15 ,0 ))
12551255        if  self .entries_window .winfo_exists ():
12561256            self .apply_localization ()
12571257        self .refresh_treeview ()
1258- 
1258+      
12591259    def  start_drag (self , event ):
12601260        self .drag_start_x  =  event .x 
12611261        self .drag_start_y  =  event .y 
@@ -1806,17 +1806,76 @@ class Dictionary(tk.Tk):
18061806            self .viewer_tree .selection_set (new_item_ids ) 
18071807        self .refresh_treeview ()
18081808
1809-     def  filter_treeview (self ):
1810-         search_text  =  self .search_var .get ().replace ("," , "" )  # Remove commas from search text 
1811-         self .refresh_treeview ()
1809+     def  filter_treeview (self , exact_search = False ):
1810+         search_text  =  self .search_var .get ().strip ().lower ()  # Get and normalize search text 
1811+         # Clear previous selections 
1812+         self .viewer_tree .selection_remove (self .viewer_tree .selection ())
1813+         if  search_text :
1814+             closest_item  =  None 
1815+             closest_distance  =  float ('inf' )  # Start with a large distance 
1816+ 
1817+             for  item  in  self .viewer_tree .get_children ():
1818+                 item_values  =  self .viewer_tree .item (item , "values" )
1819+                 matched  =  False 
1820+                 for  value  in  item_values :
1821+                     value_lower  =  value .lower ().strip ().replace ("," , "" )
1822+                     if  exact_search :
1823+                         # Perform exact match search 
1824+                         if  search_text  ==  value_lower :
1825+                             closest_item  =  item 
1826+                             matched  =  True 
1827+                             break 
1828+                     else :
1829+                         # Perform closest match search (similar to your previous logic) 
1830+                         if  search_text  in  value_lower :
1831+                             # Calculate distance (you can define your own metric here) 
1832+                             distance  =  abs (len (value_lower ) -  len (search_text ))
1833+                             if  distance  <  closest_distance :
1834+                                 closest_item  =  item 
1835+                                 closest_distance  =  distance 
1836+                             matched  =  True 
1837+ 
1838+                 if  exact_search  and  matched :
1839+                     # If exact match found and exact_search is True, stop iterating 
1840+                     break 
1841+             # Select the closest matching item 
1842+             if  closest_item :
1843+                 self .viewer_tree .selection_set (closest_item )
1844+                 self .viewer_tree .see (closest_item )
1845+             # Optionally iterate through all items if used by a button 
1846+             elif  not  exact_search :
1847+                 items_to_select  =  []
1848+                 for  item  in  self .viewer_tree .get_children ():
1849+                     item_values  =  self .viewer_tree .item (item , "values" )
1850+                     for  value  in  item_values :
1851+                         value_lower  =  value .lower ().strip ().replace ("," , "" )
1852+                         if  search_text  in  value_lower :
1853+                             items_to_select .append (item )
1854+                             break 
1855+ 
1856+                 # Set the selection to items found in the iteration 
1857+                 if  items_to_select :
1858+                     self .viewer_tree .selection_set (items_to_select )
1859+                     self .viewer_tree .see (items_to_select [0 ])
1860+     
1861+     def  iterate_search (self ):
1862+         search_text  =  self .search_var .get ().strip ().lower ()  # Get and normalize search text 
1863+         # Clear previous selections 
1864+         self .viewer_tree .selection_remove (self .viewer_tree .selection ())
18121865        if  search_text :
1866+             items_to_select  =  []
18131867            for  item  in  self .viewer_tree .get_children ():
18141868                item_values  =  self .viewer_tree .item (item , "values" )
1815-                 if  not  (search_text  in  item_values [0 ].lower ().replace ("," , "" ) or 
1816-                         search_text  in  item_values [1 ].lower ().replace ("," , "" ) or 
1817-                         search_text  in  item_values [2 ].replace ("," , "" )):
1818-                     # Detach items that don't match the search criteria 
1819-                     self .viewer_tree .detach (item )
1869+                 for  value  in  item_values :
1870+                     value_lower  =  value .lower ().strip ().replace ("," , "" )
1871+                     if  search_text  in  value_lower :
1872+                         items_to_select .append (item )
1873+                         break   # Stop iterating further for this item if a match is found 
1874+ 
1875+             # Select all matching items found during iteration 
1876+             for  item  in  items_to_select :
1877+                 self .viewer_tree .selection_add (item )
1878+                 self .viewer_tree .see (item )
18201879
18211880    def  save_window (self ):
18221881        # Create a toplevel window to inform the user that the file is being saved 
0 commit comments