Skip to content

Commit

Permalink
脚本更新
Browse files Browse the repository at this point in the history
  • Loading branch information
dyphire committed Aug 16, 2024
1 parent 2b6c045 commit 846ef32
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
7 changes: 6 additions & 1 deletion script-modules/extended-menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ local em = {
-- styles (earlyer it was a table, but required many more steps to pass def-s
-- here from .conf file)
font_size = 21,
--font size scales by window
scale_by_window = false,
-- cursor 'width', useful to change if you have hidpi monitor
cursor_x_border = 0.3,
line_bottom_margin = 1, -- basically space between lines
Expand Down Expand Up @@ -174,7 +176,10 @@ function em:update(err_code)
end

local line_height = self.font_size + self.line_bottom_margin
local ww, wh = mp.get_osd_size() -- window width & height
local _, h, aspect = mp.get_osd_size()
local wh = self.scale_by_window and 720 or h
local ww = wh * aspect

-- '+ 1' below is a search string
local menu_y_pos =
wh - (line_height * (self.lines_to_show + 1) + self.menu_y_padding * 2)
Expand Down
4 changes: 4 additions & 0 deletions script-opts/command_palette.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#指定命令面板的字体大小,默认值:16
font_size=26
#指定字体大小是否随窗口大小缩放,默认值:no
scale_by_window=yes
#指定命令面板的菜单项的显示数量,默认值:12
lines_to_show=12
#指定是否在打开命令面板时暂停播放,默认值:no
Expand Down
12 changes: 2 additions & 10 deletions scripts/command_palette.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
----- options

local o = {
font_size = 16,
scale_by_window = false,
lines_to_show = 12,
pause_on_open = false, -- does not work on my system when enabled, menu won't show
resume_on_exit = "only-if-was-paused",
Expand Down Expand Up @@ -435,16 +437,6 @@ mp.register_script_message("show-command-palette", function (name)
menu.filter_by_fields = { "content" }
em.get_line = original_get_line_func

local font_size = 40
local width = mp.get_property_native("osd-width")
local height = mp.get_property_native("osd-height")
if width > height then
font_size = math.floor(font_size * width / 1920)
else
font_size = math.floor(font_size * height / 1920)
end
o.font_size = font_size

if name == "Command Palette" then
local menu_items = {}
local bindings = utils.parse_json(mp.get_property("input-bindings"))
Expand Down

0 comments on commit 846ef32

Please sign in to comment.