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
670670 mp.input = {
671671 get: function(t) {
672672 mp.commandv("script-message-to", "console", "get-input", mp.script_name,
673− JSON.stringify({
674− prompt: t.prompt,
675− default_text: t.default_text,
676− cursor_position: t.cursor_position,
677− id: t.id,
678− }));
673+ JSON.stringify(t));
679674
680675 register_event_handler(t)
681676 },
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− },
692677 terminate: function () {
693678 mp.commandv("script-message-to", "console", "disable");
694679 },
@@ -708,6 +693,7 @@ mp.input = { · 13 unmodified lines
708693 JSON.stringify(log));
709694 }
710695 }
696+mp.input.select = mp.input.get
711697
712698 /**********************************************************************
713699 * 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