@@ -90,7 +90,9 @@ local searching_history = false
9090local history_paths = {}
9191local histories_to_save = {}
9292
93+ local MAX_LOG_LINES = 1000
9394local log_buffers = {}
95+ local log_offset = 0
9496local key_bindings = {}
9597local dont_bind_up_down = false
9698local global_margins = { t = 0 , b = 0 }
@@ -747,7 +749,9 @@ local function render()
747749
748750 local log_ass = " "
749751 local log_buffer = log_buffers [id ] or {}
750- for i = # log_buffer - math.min (max_lines , # log_buffer ) + 1 , # log_buffer do
752+ log_offset = math.max (math.min (log_offset , # log_buffer - max_lines ), 0 )
753+ for i = # log_buffer - math.min (max_lines , # log_buffer ) - log_offset + 1 ,
754+ # log_buffer - log_offset do
751755 log_ass = log_ass .. style .. log_buffer [i ].style ..
752756 ass_escape (log_buffer [i ].text ) .. " \\ N"
753757 end
@@ -1314,6 +1318,15 @@ local function clear_log_buffer()
13141318 render ()
13151319end
13161320
1321+ local function scroll_log (amount )
1322+ if selectable_items then
1323+ return
1324+ end
1325+
1326+ log_offset = log_offset + amount
1327+ render ()
1328+ end
1329+
13171330-- Returns a string of UTF-8 text from the clipboard (or the primary selection)
13181331local function get_clipboard (clip )
13191332 if platform == " x11" then
@@ -1479,6 +1492,8 @@ local function get_bindings()
14791492 { " down" , function () move_history (1 ) end },
14801493 { " ctrl+n" , function () move_history (1 ) end },
14811494 { " wheel_down" , function () move_history (1 , true ) end },
1495+ { " shift+up" , function () scroll_log (1 ) end },
1496+ { " shift+down" , function () scroll_log (- 1 ) end },
14821497 { " wheel_left" , function () end },
14831498 { " wheel_right" , function () end },
14841499 { " ctrl+left" , prev_word },
@@ -1653,6 +1668,7 @@ mp.register_script_message("get-input", function (script_name, args)
16531668 selectable_items = nil
16541669 unbind_mouse ()
16551670 id = args .id or script_name .. prompt
1671+ log_offset = 0
16561672 completion_buffer = {}
16571673 autoselect_completion = args .autoselect_completion
16581674
@@ -1675,7 +1691,7 @@ mp.register_script_message("get-input", function (script_name, args)
16751691 mp .commandv (" script-message-to" , input_caller , " input-event" , " opened" )
16761692end )
16771693
1678- -- Add a line to the log buffer (which is limited to 100 lines)
1694+ -- Add a line to the log buffer
16791695mp .register_script_message (" log" , function (message )
16801696 local log_buffer = log_buffers [id ]
16811697 message = utils .parse_json (message )
@@ -1687,14 +1703,18 @@ mp.register_script_message("log", function (message)
16871703 message .terminal_style or " " ,
16881704 }
16891705
1690- if # log_buffer > 100 then
1706+ if # log_buffer > MAX_LOG_LINES then
16911707 table.remove (log_buffer , 1 )
16921708 end
16931709
16941710 if not open then
16951711 return
16961712 end
16971713
1714+ if log_offset > 0 then
1715+ log_offset = log_offset + 1
1716+ end
1717+
16981718 if not update_timer :is_enabled () then
16991719 render ()
17001720 update_timer :resume ()
0 commit comments