Requested in https://github.com/mpv-player/mpv/pull/14087#issuecomment-2110889436 and https://github.com/mpv-player/mpv/pull/15031#issuecomment-2401328081 This is mainly useful to keep highlighting the current playlist entry after moving the mouse.
Showing the changes to player/lua/console.lua (1 of 1 file). Show all
Unified · Split
| @@ -64,6 +64,7 @@ local styles = { · 63 unmodified lines | |||
| 64 | fatal = '{\\1c&H5791f9&}', | 64 | fatal = '{\\1c&H5791f9&}', |
| 65 | suggestion = '{\\1c&Hcc99cc&}', | 65 | suggestion = '{\\1c&Hcc99cc&}', |
| 66 | selected_suggestion = '{\\1c&H2fbdfa&\\b1}', | 66 | selected_suggestion = '{\\1c&H2fbdfa&\\b1}', |
| 67 | default_item = '{\\1c&H2fbdfa&}', | ||
| 67 | disabled = '{\\1c&Hcccccc&}', | 68 | disabled = '{\\1c&Hcccccc&}', |
| 68 | } | 69 | } |
| 69 | 70 | ||
| @@ -74,6 +75,7 @@ local terminal_styles = { · 4 unmodified lines | |||
| 74 | error = '\027[31m', | 75 | error = '\027[31m', |
| 75 | fatal = '\027[91m', | 76 | fatal = '\027[91m', |
| 76 | selected_suggestion = '\027[7m', | 77 | selected_suggestion = '\027[7m', |
| 78 | default_item = '\027[1m', | ||
| 77 | disabled = '\027[38;5;8m', | 79 | disabled = '\027[38;5;8m', |
| 78 | } | 80 | } |
| 79 | 81 | ||
| @@ -109,6 +111,7 @@ local selectable_items · 29 unmodified lines | |||
| 109 | local matches = {} | 111 | local matches = {} |
| 110 | local selected_match = 1 | 112 | local selected_match = 1 |
| 111 | local first_match_to_print = 1 | 113 | local first_match_to_print = 1 |
| 114 | local default_item | ||
| 112 | 115 | ||
| 113 | local set_active | 116 | local set_active |
| 114 | 117 | ||
| @@ -417,10 +420,22 @@ local function populate_log_with_matches() · 302 unmodified lines | |||
| 417 | end | 420 | end |
| 418 | 421 | ||
| 419 | for i = first_match_to_print, last_match_to_print do | 422 | for i = first_match_to_print, last_match_to_print do |
| 423 | local style = '' | ||
| 424 | local terminal_style = '' | ||
| 425 | |||
| 426 | if i == selected_match then | ||
| 427 | style = styles.selected_suggestion | ||
| 428 | terminal_style = terminal_styles.selected_suggestion | ||
| 429 | end | ||
| 430 | if matches[i].index == default_item then | ||
| 431 | style = style .. styles.default_item | ||
| 432 | terminal_style = terminal_style .. terminal_styles.default_item | ||
| 433 | end | ||
| 434 | |||
| 420 | log[#log + 1] = { | 435 | log[#log + 1] = { |
| 421 | text = matches[i].text, | 436 | text = matches[i].text, |
| 422 | style = i == selected_match and styles.selected_suggestion or '', | 437 | style = style, |
| 423 | terminal_style = i == selected_match and terminal_styles.selected_suggestion or '', | 438 | terminal_style = terminal_style, |
| 424 | } | 439 | } |
| 425 | end | 440 | end |
| 426 | 441 | ||
| @@ -1697,6 +1712,7 @@ set_active = function (active) · 1270 unmodified lines | |||
| 1697 | line = '' | 1712 | line = '' |
| 1698 | cursor = 1 | 1713 | cursor = 1 |
| 1699 | selectable_items = nil | 1714 | selectable_items = nil |
| 1715 | default_item = nil | ||
| 1700 | dont_bind_up_down = false | 1716 | dont_bind_up_down = false |
| 1701 | unbind_mouse() | 1717 | unbind_mouse() |
| 1702 | end | 1718 | end |
| @@ -1770,6 +1786,7 @@ mp.register_script_message('get-input', function (script_name, args) · 67 unmodified lines | |||
| 1770 | if selectable_items then | 1786 | if selectable_items then |
| 1771 | matches = {} | 1787 | matches = {} |
| 1772 | selected_match = args.default_item or 1 | 1788 | selected_match = args.default_item or 1 |
| 1789 | default_item = args.default_item | ||
| 1773 | first_match_to_print = 1 | 1790 | first_match_to_print = 1 |
| 1774 | for i, item in ipairs(selectable_items) do | 1791 | for i, item in ipairs(selectable_items) do |
| 1775 | matches[i] = { index = i, text = item } | 1792 | matches[i] = { index = i, text = item } |