History

input.lua,defaults.js: don't hardcode mp.input arguments

Pass everything in the tables passed by mp.input callers to console.lua so new flags can be added without modifying these clients. In Lua, callbacks have to be excluded from the argument tables to not make utils.format_json() error, while with JSON.stringify they are automatically omitted.

Guido Cella committed 2 years ago

Commit b3f84641 parent dcd681e2 files · +16 −32Browse files

Showing the changes to player/javascript (1 of 2 files). Show all

Unified · Split

player/javascript/defaults.js+2−16
@@ -670,25 +670,10 @@ function register_event_handler(t) { · 669 unmodified lines
670mp.input = {670mp.input = {
671 get: function(t) {671 get: function(t) {
672 mp.commandv("script-message-to", "console", "get-input", mp.script_name,672 mp.commandv("script-message-to", "console", "get-input", mp.script_name,
673 JSON.stringify({673 JSON.stringify(t));
674 prompt: t.prompt,
675 default_text: t.default_text,
676 cursor_position: t.cursor_position,
677 id: t.id,
678 }));
679 674
680 register_event_handler(t)675 register_event_handler(t)
681 },676 },
682 select: function (t) {
683 mp.commandv("script-message-to", "console", "get-input", mp.script_name,
684 JSON.stringify({
685 prompt: t.prompt,
686 items: t.items,
687 default_item: t.default_item,
688 }));
689
690 register_event_handler(t);
691 },
692 terminate: function () {677 terminate: function () {
693 mp.commandv("script-message-to", "console", "disable");678 mp.commandv("script-message-to", "console", "disable");
694 },679 },
@@ -708,6 +693,7 @@ mp.input = { · 13 unmodified lines
708 JSON.stringify(log));693 JSON.stringify(log));
709 }694 }
710}695}
696mp.input.select = mp.input.get
711 697
712/**********************************************************************698/**********************************************************************
713 * various699 * various

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t