Unified · Split
| @@ -112,6 +112,7 @@ local completion_append · 111 unmodified lines | ||
| 112 | 112 | local path_separator = platform == 'windows' and '\\' or '/' |
| 113 | 113 | local completion_old_line |
| 114 | 114 | local completion_old_cursor |
| 115 | +local commands | |
| 115 | 116 | |
| 116 | 117 | local selectable_items |
| 117 | 118 | local matches = {} |
| @@ -151,11 +152,18 @@ local function get_margin_x() · 33 unmodified lines | ||
| 151 | 152 | return opts.margin_x > -1 and opts.margin_x or mp.get_property_native('osd-margin-x') |
| 152 | 153 | end |
| 153 | 154 | |
| 154 | − | |
| 155 | 155 | local function get_margin_y() |
| 156 | 156 | return opts.margin_y > -1 and opts.margin_y or mp.get_property_native('osd-margin-y') |
| 157 | 157 | end |
| 158 | 158 | |
| 159 | +local function get_commands() | |
| 160 | + if not commands then | |
| 161 | + commands = mp.get_property_native('command-list') | |
| 162 | + end | |
| 163 | + | |
| 164 | + return commands | |
| 165 | +end | |
| 166 | + | |
| 159 | 167 | |
| 160 | 168 | -- Naive helper function to find the next UTF-8 character in 'str' after 'pos' |
| 161 | 169 | -- by skipping continuation bytes. Assumes 'str' contains valid UTF-8. |
| @@ -1017,14 +1025,13 @@ local function maybe_exit() · 855 unmodified lines | ||
| 1017 | 1025 | end |
| 1018 | 1026 | |
| 1019 | 1027 | local function help_command(param) |
| 1020 | − local cmdlist = mp.get_property_native('command-list') | |
| 1021 | − table.sort(cmdlist, function(c1, c2) | |
| 1028 | + table.sort(get_commands(), function(c1, c2) | |
| 1022 | 1029 | return c1.name < c2.name |
| 1023 | 1030 | end) |
| 1024 | 1031 | local output = '' |
| 1025 | 1032 | if param == '' then |
| 1026 | 1033 | output = 'Available commands:\n' |
| 1027 | − for _, cmd in ipairs(cmdlist) do | |
| 1034 | + for _, cmd in ipairs(get_commands()) do | |
| 1028 | 1035 | output = output .. ' ' .. cmd.name |
| 1029 | 1036 | end |
| 1030 | 1037 | output = output .. '\n' |
| @@ -1032,7 +1039,7 @@ local function help_command(param) · 1 unmodified line | ||
| 1032 | 1039 | output = output .. "ESC or Ctrl+d exits the console.\n" |
| 1033 | 1040 | else |
| 1034 | 1041 | local cmd = nil |
| 1035 | − for _, curcmd in ipairs(cmdlist) do | |
| 1042 | + for _, curcmd in ipairs(get_commands()) do | |
| 1036 | 1043 | if curcmd.name:find(param, 1, true) then |
| 1037 | 1044 | cmd = curcmd |
| 1038 | 1045 | if curcmd.name == param then |
| @@ -1410,12 +1417,12 @@ local function text_input(info) · 371 unmodified lines | ||
| 1410 | 1417 | end |
| 1411 | 1418 | |
| 1412 | 1419 | local function command_list() |
| 1413 | − local commands = {} | |
| 1414 | − for i, command in ipairs(mp.get_property_native('command-list')) do | |
| 1415 | − commands[i] = command.name | |
| 1420 | + local cmds = {} | |
| 1421 | + for i, command in ipairs(get_commands()) do | |
| 1422 | + cmds[i] = command.name | |
| 1416 | 1423 | end |
| 1417 | 1424 | |
| 1418 | − return commands | |
| 1425 | + return cmds | |
| 1419 | 1426 | end |
| 1420 | 1427 | |
| 1421 | 1428 | local function property_list() |
| @@ -1493,7 +1500,7 @@ local function list_option_value_list(option) · 71 unmodified lines | ||
| 1493 | 1500 | end |
| 1494 | 1501 | |
| 1495 | 1502 | local function has_file_argument(candidate_command) |
| 1496 | − for _, command in pairs(mp.get_property_native('command-list')) do | |
| 1503 | + for _, command in pairs(get_commands()) do | |
| 1497 | 1504 | if command.name == candidate_command then |
| 1498 | 1505 | return command.args[1] and |
| 1499 | 1506 | (command.args[1].name == 'filename' or command.args[1].name == 'url') |
| @@ -1587,7 +1594,7 @@ local function command_flags_at_2nd_argument_list(command) · 87 unmodified lines | ||
| 1587 | 1594 | end |
| 1588 | 1595 | |
| 1589 | 1596 | local function handle_flags(command, arg_index, flags) |
| 1590 | − for _, cmd in pairs(mp.get_property_native('command-list')) do | |
| 1597 | + for _, cmd in pairs(get_commands()) do | |
| 1591 | 1598 | if cmd.name == command then |
| 1592 | 1599 | if cmd.args[arg_index] and cmd.args[arg_index].type == 'Flags' then |
| 1593 | 1600 | break |