@@ -188,23 +188,28 @@ local style = {
188188}
189189
190190local state = {
191+ -- lvl 1 values
191192 list = {},
192- selected = 1 ,
193- hidden = true ,
194- flag_update = false ,
195- keybinds = nil ,
196-
197193 parser = nil ,
198194 directory = nil ,
199195 directory_label = nil ,
200196 prev_directory = " " ,
201197 co = nil ,
202198
199+ -- lvl 2 values
200+ selected = 1 ,
203201 multiselect_start = nil ,
204202 initial_selection = nil ,
205203 selection = {}
206204}
207205
206+ local overlay = {
207+ hidden = true ,
208+ flag_update = false
209+ }
210+
211+ local keybinds = nil
212+
208213-- the parser table actually contains 3 entries for each parser
209214-- a numeric entry which represents the priority of the parsers and has the parser object as the value
210215-- a string entry representing the id of each parser and with the parser object as the value
739744
740745-- refreshes the ass text using the contents of the list
741746local function update_ass ()
742- if state .hidden then state .flag_update = true ; return end
747+ if overlay .hidden then overlay .flag_update = true ; return end
743748
744749 ass .data = style .global
745750
@@ -1170,44 +1175,44 @@ end
11701175
11711176-- opens the browser
11721177local function open ()
1173- if not state .hidden then return end
1178+ if not overlay .hidden then return end
11741179
1175- for _ ,v in ipairs (state . keybinds ) do
1180+ for _ ,v in ipairs (keybinds ) do
11761181 mp .add_forced_key_binding (v [1 ], ' dynamic/' .. v [2 ], v [3 ], v [4 ])
11771182 end
11781183
11791184 utils .shared_script_property_set (" file_browser-open" , " yes" )
11801185 if o .toggle_idlescreen then mp .commandv (' script-message' , ' osc-idlescreen' , ' no' , ' no_osd' ) end
1181- state .hidden = false
1186+ overlay .hidden = false
11821187 if state .directory == nil then
11831188 local path = mp .get_property (' path' )
11841189 update_current_directory (nil , path )
11851190 if path or o .default_to_working_directory then goto_current_dir () else goto_root () end
11861191 return
11871192 end
11881193
1189- if state .flag_update then update_current_directory (nil , mp .get_property (' path' )) end
1190- if not state .flag_update then ass :update ()
1191- else state .flag_update = false ; update_ass () end
1194+ if overlay .flag_update then update_current_directory (nil , mp .get_property (' path' )) end
1195+ if not overlay .flag_update then ass :update ()
1196+ else overlay .flag_update = false ; update_ass () end
11921197end
11931198
11941199-- closes the list and sets the hidden flag
11951200local function close ()
1196- if state .hidden then return end
1201+ if overlay .hidden then return end
11971202
1198- for _ ,v in ipairs (state . keybinds ) do
1203+ for _ ,v in ipairs (keybinds ) do
11991204 mp .remove_key_binding (' dynamic/' .. v [2 ])
12001205 end
12011206
12021207 utils .shared_script_property_set (" file_browser-open" , " no" )
12031208 if o .toggle_idlescreen then mp .commandv (' script-message' , ' osc-idlescreen' , ' yes' , ' no_osd' ) end
1204- state .hidden = true
1209+ overlay .hidden = true
12051210 ass :remove ()
12061211end
12071212
12081213-- toggles the list
12091214local function toggle ()
1210- if state .hidden then open ()
1215+ if overlay .hidden then open ()
12111216 else close () end
12121217end
12131218
@@ -1487,7 +1492,7 @@ end
14871492---- --------------------------------------------------------------------------------------
14881493---- --------------------------------------------------------------------------------------
14891494
1490- state . keybinds = {
1495+ keybinds = {
14911496 {' ENTER' , ' play' , function () open_file (' replace' , false ) end },
14921497 {' Shift+ENTER' , ' play_append' , function () open_file (' append-play' , false ) end },
14931498 {' Alt+ENTER' , ' play_autoload' ,function () open_file (' replace' , true ) end },
@@ -1746,7 +1751,7 @@ local function insert_custom_keybind(keybind)
17461751 for code in string.gmatch (keybind .condition , KEYBIND_CODE_PATTERN ) do keybind .condition_codes [code ] = true end
17471752 end
17481753
1749- table.insert (state . keybinds , {keybind .key , keybind .name , function () run_keybind_coroutine (keybind ) end , keybind .flags or {}})
1754+ table.insert (keybinds , {keybind .key , keybind .name , function () run_keybind_coroutine (keybind ) end , keybind .flags or {}})
17501755 top_level_keys [keybind .key ] = keybind
17511756end
17521757
@@ -1756,7 +1761,7 @@ local function setup_keybinds()
17561761 if not o .custom_keybinds and not o .addons then return end
17571762
17581763 -- this is to make the default keybinds compatible with passthrough from custom keybinds
1759- for _ , keybind in ipairs (state . keybinds ) do
1764+ for _ , keybind in ipairs (keybinds ) do
17601765 top_level_keys [keybind [1 ]] = { key = keybind [1 ], name = keybind [2 ], command = keybind [3 ], flags = keybind [4 ] }
17611766 end
17621767
@@ -1885,7 +1890,7 @@ function API.get_current_parser() return state.parser:get_id() end
18851890function API .get_current_parser_keyname () return state .parser .keybind_name or state .parser .name end
18861891function API .get_selected_index () return state .selected end
18871892function API .get_selected_item () return API .copy_table (state .list [state .selected ]) end
1888- function API .get_open_status () return not state .hidden end
1893+ function API .get_open_status () return not overlay .hidden end
18891894function API .get_parse_state (co ) return parse_states [co or coroutine.running () or " " ] end
18901895
18911896function API .set_empty_text (str )
@@ -2259,10 +2264,10 @@ end)
22592264
22602265-- we don't want to add any overhead when the browser isn't open
22612266mp .observe_property (' path' , ' string' , function (_ ,path )
2262- if not state .hidden then
2267+ if not overlay .hidden then
22632268 update_current_directory (_ ,path )
22642269 update_ass ()
2265- else state .flag_update = true end
2270+ else overlay .flag_update = true end
22662271end )
22672272
22682273-- updates the dvd_device
0 commit comments