@@ -39,8 +39,8 @@ local script_opts = {
3939 menu_outline_size = 0 ,
4040 menu_outline_color = " #FFFFFF" ,
4141 corner_radius = 8 ,
42- margin_x = - 1 ,
43- margin_y = - 1 ,
42+ margin_x = mp . get_property_native ( " osd-margin-x " ) ,
43+ margin_y = mp . get_property_native ( " osd-margin-y " ) ,
4444 scale_with_window = " auto" ,
4545 focused_color = " #222222" ,
4646 focused_back_color = " #FFFFFF" ,
@@ -159,15 +159,6 @@ local function get_font()
159159 return " monospace"
160160end
161161
162- local function get_margin_x ()
163- return opts .margin_x > - 1 and opts .margin_x or mp .get_property_native (" osd-margin-x" )
164- end
165-
166- local function get_margin_y ()
167- return opts .margin_y > - 1 and opts .margin_y or mp .get_property_native (" osd-margin-y" )
168- end
169-
170-
171162-- Naive helper function to find the next UTF-8 character in "str" after "pos"
172163-- by skipping continuation bytes. Assumes "str" contains valid UTF-8.
173164local function next_utf8 (str , pos )
@@ -335,7 +326,7 @@ local function calculate_max_lines()
335326
336327 return math.floor ((select (2 , get_scaled_osd_dimensions ())
337328 * (1 - global_margins .t - global_margins .b )
338- - get_margin_y () - (selectable_items and opts .padding * 2 or 0 ))
329+ - opts . margin_y - (selectable_items and opts .padding * 2 or 0 ))
339330 / get_line_height ()
340331 -- Subtract 1 for the input line and 0.5 for the empty
341332 -- line between the log and the input line.
@@ -364,7 +355,7 @@ local function calculate_max_item_width()
364355 local result = width_overlay :update ()
365356 if result .x0 then
366357 max_item_width = math.min (result .x1 - result .x0 ,
367- osd_w - get_margin_x () * 2 - opts .padding * 2 )
358+ osd_w - opts . margin_x * 2 - opts .padding * 2 )
368359 end
369360end
370361
@@ -741,8 +732,8 @@ render = function()
741732 alignment = 7
742733 clipping_coordinates = x .. " ,0," .. x + max_item_width .. " ," .. osd_h
743734 else
744- x = get_margin_x ()
745- y = osd_h * (1 - global_margins .b ) - get_margin_y ()
735+ x = opts . margin_x
736+ y = osd_h * (1 - global_margins .b ) - opts . margin_y
746737 alignment = 1
747738 -- Avoid drawing below topbar OSC when there are wrapped lines.
748739 local coordinate_top = math.floor (global_margins .t * osd_h + 0.5 )
@@ -1123,7 +1114,7 @@ local function determine_hovered_item()
11231114 local mouse_pos = mp .get_property_native (" mouse-pos" )
11241115 local mouse_x = mouse_pos .x / scale
11251116 local mouse_y = mouse_pos .y / scale
1126- local item_x0 = (searching_history and get_margin_x () or (osd_w - max_item_width ) / 2 )
1117+ local item_x0 = (searching_history and opts . margin_x or (osd_w - max_item_width ) / 2 )
11271118 - opts .padding
11281119
11291120 if mouse_x < item_x0 or mouse_x > item_x0 + max_item_width + opts .padding * 2 then
0 commit comments