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