@@ -131,6 +131,9 @@ function cursor.toggle_select_mode()
131131 end
132132end
133133
134+ --- @param str string
135+ --- @param substring string
136+ --- @return number
134137local function count_substrings (str , substring )
135138 local count = 0
136139 for match in string.gmatch (str , substring ) do
@@ -147,7 +150,9 @@ local num_header_lines = count_substrings(o.format_string_header, '\\N') + 1
147150local num_twrapper_lines = count_substrings (o .format_string_topwrapper , ' \\ N' ) + 1
148151local num_bwrapper_lines = count_substrings (o .format_string_bottomwrapper , ' \\ N' ) + 1
149152
150- -- update the selected item based on the mouse position
153+ --- update the selected item based on the mouse position
154+ --- @param _ ? string
155+ --- @param mouse_pos ? MPVMousePos
151156function cursor .update_mouse_pos (_ , mouse_pos )
152157 if not o .mouse_mode or g .state .hidden or # g .state .list == 0 then return end
153158
@@ -158,10 +163,10 @@ function cursor.update_mouse_pos(_, mouse_pos)
158163 local scale = mp .get_property_number (" osd-height" , 0 ) / g .ass .res_y
159164 local osd_offset = scale * mp .get_property (" osd-margin-y" , 22 )
160165
161- msg .trace (' calculating mouse pos for' , g .state . osd_alignment , ' alignment' )
166+ msg .trace (' calculating mouse pos for' , g .osd_alignment , ' alignment' )
162167
163168 -- calculate position when browser is aligned to the top of the screen
164- if g .state . osd_alignment == " top" then
169+ if g .osd_alignment == " top" then
165170 local header_offset = osd_offset + (num_header_lines * scale * font_size_header )
166171 if g .state .scroll_offset > 0 then header_offset = header_offset + (num_twrapper_lines * scale * font_size_wrappers ) end
167172 msg .trace (' calculated header offset' , header_offset )
@@ -171,7 +176,7 @@ function cursor.update_mouse_pos(_, mouse_pos)
171176 -- calculate position when browser is aligned to the bottom of the screen
172177 -- this calculation is slightly off when a bottom wrapper exists,
173178 -- I do not know what causes this.
174- elseif g .state . osd_alignment == " bottom" then
179+ elseif g .osd_alignment == " bottom" then
175180 mouse_pos .y = (mp .get_property_number (" osd-height" , 0 )) - mouse_pos .y
176181
177182 local bottom = math.min (# g .state .list , g .state .scroll_offset + o .num_entries )
@@ -184,7 +189,8 @@ function cursor.update_mouse_pos(_, mouse_pos)
184189 ass .update_ass ()
185190end
186191
187- -- scrolls the view window when using mouse mode
192+ --- scrolls the view window when using mouse mode
193+ --- @param direction number
188194function cursor .wheel (direction )
189195 g .state .scroll_offset = g .state .scroll_offset + direction
190196 if (g .state .scroll_offset + o .num_entries ) > # g .state .list then
0 commit comments