|
11 | 11 | """
|
12 | 12 |
|
13 | 13 | import os
|
14 |
| -from typing import List |
| 14 | +from typing import List, Iterable |
15 | 15 |
|
16 | 16 | from vimiv.qt.core import QDateTime
|
17 | 17 | from vimiv.qt.gui import QGuiApplication, QClipboard
|
@@ -68,30 +68,33 @@ def toggle(mode: str) -> None:
|
68 | 68 | api.modes.get_by_name(mode).toggle()
|
69 | 69 |
|
70 | 70 |
|
71 |
| -@api.keybindings.register("yA", "copy-name --abspath --primary") |
72 |
| -@api.keybindings.register("yY", "copy-name --primary") |
73 |
| -@api.keybindings.register("ya", "copy-name --abspath") |
74 |
| -@api.keybindings.register("yy", "copy-name") |
75 |
| -@api.keybindings.register("ymA", "copy-name --abspath --primary --mark") |
76 |
| -@api.keybindings.register("ymY", "copy-name --primary --mark") |
77 |
| -@api.keybindings.register("yma", "copy-name --abspath --mark") |
78 |
| -@api.keybindings.register("ymy", "copy-name --mark") |
| 71 | +@api.keybindings.register("yA", "copy-name % --abspath --primary") |
| 72 | +@api.keybindings.register("yY", "copy-name % --primary") |
| 73 | +@api.keybindings.register("ya", "copy-name % --abspath") |
| 74 | +@api.keybindings.register("yy", "copy-name %") |
| 75 | +@api.keybindings.register("ymA", "copy-name %m --abspath --primary") |
| 76 | +@api.keybindings.register("ymY", "copy-name %m --primary") |
| 77 | +@api.keybindings.register("yma", "copy-name %m --abspath") |
| 78 | +@api.keybindings.register("ymy", "copy-name %m") |
79 | 79 | @api.commands.register()
|
80 |
| -def copy_name(abspath: bool = False, primary: bool = False, mark: bool = False) -> None: |
81 |
| - """Copy name of current path or of marked images to system clipboard. |
| 80 | +def copy_name( |
| 81 | + paths: Iterable[str], abspath: bool = False, primary: bool = False |
| 82 | +) -> None: |
| 83 | + """Copy file name or full path of provided paths(s) to system clipboard. |
| 84 | +
|
| 85 | + **syntax:** ``:copy-name path [path ...] [--abspath] [--primary]`` |
82 | 86 |
|
83 |
| - **syntax:** ``:copy-name [--abspath] [--primary] [--mark]`` |
| 87 | + positional arguments: |
| 88 | + * ``paths``: The path(s) to copy. |
84 | 89 |
|
85 | 90 | optional arguments:
|
86 | 91 | * ``--abspath``: Copy absolute path instead of basename.
|
87 | 92 | * ``--primary``: Copy to primary selection.
|
88 |
| - * ``--mark``: Copy all marked images instead of current path. |
89 | 93 | """
|
90 | 94 | clipboard = QGuiApplication.clipboard()
|
91 | 95 | mode = QClipboard.Mode.Selection if primary else QClipboard.Mode.Clipboard
|
92 |
| - paths = api.mark.paths if mark else [api.current_path()] |
93 |
| - names = [path if abspath else os.path.basename(path) for path in paths] |
94 |
| - clipboard.setText(" ".join(names), mode=mode) |
| 96 | + text = " ".join(path if abspath else os.path.basename(path) for path in paths) |
| 97 | + clipboard.setText(text, mode=mode) |
95 | 98 |
|
96 | 99 |
|
97 | 100 | @api.keybindings.register("yi", "copy-image")
|
|
0 commit comments