Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add note about input prompt scaling, and add options to change the key to start and restart searches #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The script messages allow you to specify which page to open, valid values are `k

### Dynamic Keybinds

In addition the following keybinds are dynamically created when the search page is open, these cannot currently be changed:
In addition the following keybinds are dynamically created when the search page is open. `f12` and `Shift+f12` can be changed in [search_page.conf](search_page.conf). The others cannot currently be changed:

f12 opens search input
Shift+f12 opens advanced search input
Expand Down Expand Up @@ -111,6 +111,12 @@ By default the script will escape these special characters to make searches more

The full list of options, and their defaults are shown in [search_page.conf](search_page.conf).

The scale of the input prompt can be changed with this setting in the `mpv.conf`:

```txt
script-opts-append=user_input-scale=1
```

Comment on lines +114 to +119
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of recommending an entry in mpv.conf I would instead prefer to recommend an entry in ~~/script-opts/user_input.conf which would contain scale=1.

## Future Plans

Some ideas for future functionality:
Expand Down
14 changes: 9 additions & 5 deletions search-page.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ local o = {
--number of pixels to pan on each click
--this refers to the horizontal panning
pan_speed = 100,

--these change the default keybindings to open a search, as well as to restart a search, while a page is open
keybind_open_search = "f12",
keybind_open_flag_search = "Shift+f12",

--all colour options
ass_header = "{\\c&H00ccff&\\fs40\\b500\\q2\\fnMonospace}",
Expand Down Expand Up @@ -190,8 +194,8 @@ local function create_page(type, t)
{"Ctrl+LEFT", "page_left_search", function() temp:move_page(-1, true) end, {}},
{"Ctrl+RIGHT", "page_right_search", function() temp:move_page(1, true) end, {}},
{"Ctrl+ENTER", "run_latest", function() temp:run_search(LATEST_SEARCH.keyword, LATEST_SEARCH.flags) end, {}},
{"f12", "open_search", function() temp:get_input(false) end, {}},
{"Shift+f12", "open_flag_search", function() temp:get_input(true) end, {}}
{o.keybind_open_search, "open_search", function() temp:get_input(false) end, {}},
{o.keybind_open_flag_search, "open_flag_search", function() temp:get_input(true) end, {}}
Comment on lines +197 to +198
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this PR is actually unnecessary. If we remove these two lines:

Suggested change
{o.keybind_open_search, "open_search", function() temp:get_input(false) end, {}},
{o.keybind_open_flag_search, "open_flag_search", function() temp:get_input(true) end, {}}

And change the open_wrapper function to be:

function list_meta:open_wrapper(advanced)
    if self.keyword == nil then self.empty_text = "Press f12 to enter search query" end
    local hidden = self.hidden
    if hidden then self:open() end
    if self.keyword == nil or not hidden then self:get_input(advanced) end
end

Then the standard mpv keybind to open the page will be also be used when the page is open instead of being overridden. Then the keybinds can be changed by using standard input.conf changes.

}
return temp
end
Expand Down Expand Up @@ -502,7 +506,7 @@ function list_meta:run_search()
end

function list_meta:open_wrapper(advanced)
if self.keyword == nil then self.empty_text = "Press f12 to enter search query" end
if self.keyword == nil then self.empty_text = "Enter a new search query" end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this change.

self:open()
if self.keyword == nil then self:get_input(advanced) end
end
Expand Down Expand Up @@ -546,11 +550,11 @@ function list_meta:get_input(get_flags)
coroutine_resume_err(co)
end

mp.add_key_binding("f12", "open-search-page", function()
mp.add_key_binding(o.keybind_open_search, "open-search-page", function()
CURRENT_PAGE:open_wrapper()
end)

mp.add_key_binding("Shift+f12", "open-search-page/advanced", function()
mp.add_key_binding(o.keybind_open_flag_search, "open-search-page/advanced", function()
CURRENT_PAGE:open_wrapper(true)
end)

Expand Down
4 changes: 4 additions & 0 deletions search_page.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ max_list=26
#this refers to the horizontal panning
pan_speed=100

#these change the default keybindings to open a search, as well as to restart a search, while a page is open
keybind_open_search=f12
keybind_open_flag_search=Shift+f12


##############################################################
# The below options are very advanced, it is mostly to provide
Expand Down