@@ -114,6 +114,7 @@ local first_match_to_print = 1
114114local default_item
115115local item_positions = {}
116116local max_item_width = 0
117+ local horizontal_offset = 0
117118
118119local complete
119120local cycle_through_completions
@@ -709,7 +710,7 @@ local function render()
709710 (global_margins .t + (1 - global_margins .t - global_margins .b ) / 2 ) -
710711 (math.min (# selectable_items , max_lines ) + 1.5 ) * line_height / 2
711712 alignment = 7
712- clipping_coordinates = " 0 ,0," .. x + max_item_width .. " ," .. osd_h
713+ clipping_coordinates = x .. " ,0," .. x + max_item_width .. " ," .. osd_h
713714 else
714715 x = get_margin_x ()
715716 y = osd_h * (1 - global_margins .b ) - get_margin_y ()
@@ -828,7 +829,7 @@ local function render()
828829
829830 ass :new_event ()
830831 ass :an (4 )
831- ass :pos (x , item_y )
832+ ass :pos (x - horizontal_offset , item_y )
832833 ass :append (style .. item )
833834
834835 item_positions [# item_positions + 1 ] =
@@ -1202,6 +1203,11 @@ local function move_history(amount, is_wheel)
12021203 render ()
12031204end
12041205
1206+ local function horizontal_scroll (amount )
1207+ horizontal_offset = math.max (horizontal_offset + amount , 0 )
1208+ render ()
1209+ end
1210+
12051211-- Go to the first command in the command history (PgUp)
12061212local function handle_pgup ()
12071213 if selectable_items then
@@ -1231,6 +1237,7 @@ local function search_history()
12311237
12321238 searching_history = true
12331239 selectable_items = {}
1240+ horizontal_offset = 0
12341241
12351242 for i = 1 , # history do
12361243 selectable_items [i ] = history [# history + 1 - i ]
@@ -1497,6 +1504,12 @@ local function get_bindings()
14971504 { " wheel_down" , function () move_history (1 , true ) end },
14981505 { " wheel_left" , function () end },
14991506 { " wheel_right" , function () end },
1507+ { " shift+left" , function () horizontal_scroll (- 25 ) end },
1508+ { " shift+right" , function () horizontal_scroll (25 ) end },
1509+ { " wheel_left" , function () horizontal_scroll (- 25 ) end },
1510+ { " wheel_right" , function () horizontal_scroll (25 ) end },
1511+ { " shift+wheel_up" , function () horizontal_scroll (- 25 ) end },
1512+ { " shift+wheel_down" , function () horizontal_scroll (25 ) end },
15001513 { " ctrl+left" , prev_word },
15011514 { " alt+b" , prev_word },
15021515 { " ctrl+right" , next_word },
@@ -1653,6 +1666,7 @@ mp.register_script_message("get-input", function (script_name, args)
16531666
16541667 if args .items then
16551668 selectable_items = {}
1669+ horizontal_offset = 0
16561670
16571671 -- Limit the number of characters to prevent libass from freezing mpv.
16581672 -- Not important for terminal output.
0 commit comments