Allow frontends/GUIs and C plugins to use select.lua
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 37k
- Forks
- 3.5k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 22
Description
Expected behavior of the wanted feature
With uosc.lua and commnd_palette.lua this is possible. Both use the same API, commnd_palette.lua implements it only partly.
From https://github.com/natural-harmonia-gropius/recent-menu/blob/master/recentmenu.lua#L279
function open_menu_uosc()
local json = utils.format_json(menu)
mp.commandv("script-message-to", "uosc", "open-menu", json)
end
function open_menu_command_palette()
local json = utils.format_json(menu)
mp.commandv("script-message-to",
"command_palette",
"show-command-palette-json", json)
end
From commnd_palette.lua:
mp.register_script_message("show-command-palette-json", function (json)
if dpiScale == 0 then
dpiScale = mp.get_property_native("display-hidpi-scale", 1)
end
o.font_size = originalFontSize * dpiScale
local menu_data = utils.parse_json(json)
menu_content.list = {}
menu_content.current_i = 1
menu.search_heading = menu_data.title
menu.filter_by_fields = { "content", "hint", "value_hint" }
em.get_line = original_get_line_func
for k, v in ipairs(menu_data.items) do
local values = v.value
if type(values) == "string" then
values = { values }
end
table.insert(menu_content.list, {
index = k,
content = v.title,
hint = v.hint,
values = values,
value_hint = table.concat(values, " "),
})
if menu_data.selected_index then
menu_content.current_i = menu_data.selected_index
end
end
function menu:submit(tbl)
mp.command_native(tbl.values)
end
hide_osc()
menu:init(menu_content)
end)
From mpv.net
void ShowRecentFilesInCommandPalette()
{
Obj o = new();
o.title = "Recent Files";
o.selected_index = 0;
var items = new List<Item>();
foreach (string file in App.Settings.RecentFiles)
{
items.Add(new Item() { title = Path.GetFileName(file),
value = ["loadfile", file],
hint = file});
}
o.items = [.. items];
string json = JsonSerializer.Serialize(o);
Player.CommandV("script-message", "show-command-palette-json", json);
}
@natural-harmonia-gropius
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading select.lua and comparing the uosc.lua, commnd_palette.lua, recentmenu.lua, and mpv.net examples cited in the issue. Determine the API needed for frontends/GUIs and C plugins to use select.lua, then verify that the demonstrated menu data and command submission flows work through that API.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, lua
- Domain
- api, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100