diff --git a/README.md b/README.md index 77ac3a30..b013e820 100644 --- a/README.md +++ b/README.md @@ -329,6 +329,8 @@ Note: there are alternative ways to open stuff from clipboard without the need t Copy currently open path or URL to clipboard. +Additionally, you can also press `ctrl+c` to copy path of a selected item in `playlist` or all directory listing menus. + #### `open-config-directory` Open directory with `mpv.conf` in file explorer. diff --git a/src/uosc/elements/Menu.lua b/src/uosc/elements/Menu.lua index 6d514950..f1701f06 100644 --- a/src/uosc/elements/Menu.lua +++ b/src/uosc/elements/Menu.lua @@ -323,7 +323,8 @@ function Menu:update_dimensions() -- and dumb titles with no search inputs. It could use a refactor. local margin = round(self.item_height / 2) local external_buttons_reserve = display.width / self.item_height > 14 and self.scroll_step * 6 - margin * 2 or 0 - local width_available, height_available = display.width - margin * 2 - external_buttons_reserve, display.height - margin * 2 + local width_available = display.width - margin * 2 - external_buttons_reserve + local height_available = display.height - margin * 2 local min_width = math.min(self.min_width, width_available) for _, menu in ipairs(self.all) do @@ -1031,7 +1032,9 @@ end function Menu:enable_key_bindings() -- `+` at the end enables `repeatable` flag - local standalone_keys = {'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12', {'v', 'ctrl'}} + local standalone_keys = { + 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12', {'v', 'ctrl'}, {'c', 'ctrl'}, + } local modifiable_keys = {'up+', 'down+', 'left', 'right', 'enter', 'kp_enter', 'bs', 'tab', 'esc', 'pgup+', 'pgdwn+', 'home', 'end', 'del'} local modifiers = {nil, 'alt', 'alt+ctrl', 'alt+shift', 'alt+ctrl+shift', 'ctrl', 'ctrl+shift', 'shift'} diff --git a/src/uosc/lib/menus.lua b/src/uosc/lib/menus.lua index 876e80c3..6c4a2704 100644 --- a/src/uosc/lib/menus.lua +++ b/src/uosc/lib/menus.lua @@ -536,6 +536,11 @@ function open_file_navigation_menu(directory_path, handle_activate, opts) if back_path then open_directory(back_path) end elseif event.type == 'paste' then handle_activate({type = 'activate', value = event.value}) + elseif event.type == 'key' then + if event.id == 'ctrl+c' and event.selected_item then + set_clipboard(event.selected_item.value) + mp.commandv('show-text', t('Copied to clipboard') .. ': ' .. event.selected_item.value, 3000) + end elseif event.type == 'close' then close() end diff --git a/src/uosc/main.lua b/src/uosc/main.lua index e5a55526..77655724 100644 --- a/src/uosc/main.lua +++ b/src/uosc/main.lua @@ -947,6 +947,13 @@ bind_command('playlist', create_self_updating_menu_opener({ end, on_activate = function(event) mp.commandv('set', 'playlist-pos-1', tostring(event.value)) end, on_paste = function(event) mp.commandv('loadfile', tostring(event.value), 'append') end, + on_key = function(event) + if event.id == 'ctrl+c' and event.selected_item then + local payload = mp.get_property_native('playlist/' .. (event.selected_item.value - 1) .. '/filename') + set_clipboard(payload) + mp.commandv('show-text', t('Copied to clipboard') .. ': ' .. payload, 3000) + end + end, on_move = function(event) local from, to = event.from_index, event.to_index mp.commandv('playlist-move', tostring(from - 1), tostring(to - (to > from and 0 or 1)))