Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 31 additions & 22 deletions search-page.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ local o = {
--there seems to be a significant performance hit from having lots of text off the screen
max_list = 20,

wrap = false,

--number of pixels to pan on each click
--this refers to the horizontal panning
pan_speed = 100,
Expand Down Expand Up @@ -108,6 +110,7 @@ list_meta.wrapper_style = o.ass_footer
list_meta.indent = [[\h\h\h]]
list_meta.num_entries = o.max_list
list_meta.empty_text = "no results"
list_meta.wrap = o.wrap

local CURRENT_PAGE = nil
local LATEST_SEARCH = {
Expand Down Expand Up @@ -363,26 +366,27 @@ function COMMANDS:search(keyword, flags)
local commands = mp.get_property_native('command-list')

for _,command in ipairs(commands) do
local cmd = command.name
local result_no_ass = cmd

local arg_string = ""

for _,arg in ipairs(command.args) do
if arg.optional then
arg_string = arg_string .. o.ass_optargs
result_no_ass = result_no_ass .. " "
else
result_no_ass = result_no_ass .. " !"
arg_string = arg_string .. o.ass_args
end
result_no_ass = result_no_ass .. arg.name .. "("..arg.type..") "
arg_string = arg_string .. " " .. arg.name .. o.ass_argtype.." ("..arg.type..") "
end

if
compare(command.name, keyword, flags)
or compare(result_no_ass, keyword, flags)
then
local cmd = command.name
local result_no_ass = cmd

local arg_string = ""

for _,arg in ipairs(command.args) do
if arg.optional then
arg_string = arg_string .. o.ass_optargs
result_no_ass = result_no_ass .. " "
else
result_no_ass = result_no_ass .. " !"
arg_string = arg_string .. o.ass_args
end
result_no_ass = result_no_ass .. arg.name .. "("..arg.type..") "
arg_string = arg_string .. " " .. arg.name .. o.ass_argtype.." ("..arg.type..") "
end

self:insert({
type = "command",
ass = o.ass_cmd..self.ass_escape(cmd)..return_spaces(cmd:len(), 20)..arg_string,
Expand Down Expand Up @@ -424,14 +428,14 @@ function OPTIONS:search(keyword, flags)

local options_spec = ""

if type == "Choice" then
options_spec = " [ " .. choices .. ' ]'
elseif type == "Integer"
if type == "Integer"
or type == "ByteSize"
or type == "Float"
or type == "Aspect"
or type == "Double" then
options_spec = " [ "..mp.get_property_number('option-info/'..option..'/min', "").." - ".. mp.get_property_number("option-info/"..option..'/max', "").." ]"
elseif choices ~= "" then
options_spec = " [ " .. choices .. ' ]'
end

local result = o.ass_options..self.ass_escape(option).." "..o.ass_optionstype..type..first_space..o.ass_optvalue..self.ass_escape(opt_value)
Expand All @@ -452,10 +456,15 @@ function PROPERTIES:search(keyword, flags)
local properties = mp.get_property_native('property-list', {})

for _,property in ipairs(properties) do
if compare(property, keyword, flags) then
local values = mp.get_property(property, "")

if
compare(property, keyword, flags)
or compare(values, keyword, flags)
then
self:insert({
type = "property",
ass = o.ass_properties..self.ass_escape(property)..return_spaces(property:len(), 40)..o.ass_propertycurrent..self.ass_escape(mp.get_property(property, "")),
ass = o.ass_properties..self.ass_escape(property)..return_spaces(property:len(), 40)..o.ass_propertycurrent..self.ass_escape(values),
funct = function()
mp.commandv('script-message-to', 'console', 'type', 'print-text ${'.. property .. "} ")
self:close()
Expand Down