コード例 #1
0
ファイル: search.py プロジェクト: kaldown/vimiv-qt
 def _run(self, text, mode, count, reverse, incremental):
     """Implementation of running search."""
     paths = pathreceiver.pathlist(mode)
     current_index = paths.index(pathreceiver.current(mode))
     basenames = [os.path.basename(path) for path in paths]
     sorted_paths = _sort_for_search(basenames, current_index, reverse)
     next_match, matches = _get_next_match(text, count, sorted_paths)
     index = basenames.index(next_match)
     self.new_search.emit(index, matches, mode, incremental)
     api.status.update()
コード例 #2
0
ファイル: runners.py プロジェクト: kaldown/vimiv-qt
def expand_percent(text, mode):
    """Expand % to the corresponding path and %m to all marked paths.

    Args:
        text: The command in which the wildcards are expanded.
        mode: Mode the command is run in to get correct path(-list).
    """
    # Check first as the re substitutions are rather expensive
    if "%m" in text:
        text = re.sub(r"(?<!\\)%m", " ".join(api.mark.paths), text)
    if "%" in text:
        current = shlex.quote(pathreceiver.current(mode))
        text = re.sub(r"(?<!\\)%", current, text)
    return text
コード例 #3
0
def copy_name(abspath: bool = False, primary: bool = False) -> None:
    """Copy name of current path to system clipboard.

    **syntax:** ``:copy-name [--abspath] [--primary]``

    optional arguments:
        * ``--abspath``: Copy absolute path instead of basename.
        * ``--primary``: Copy to primary selection.
    """
    clipboard = QGuiApplication.clipboard()
    mode = QClipboard.Selection if primary else QClipboard.Clipboard
    path = pathreceiver.current()
    name = path if abspath else os.path.basename(path)
    clipboard.setText(name, mode=mode)
コード例 #4
0
 def mark_indicator(self) -> str:
     """Indicator if the current image is marked."""
     if pathreceiver.current() in self._marked:
         return Mark.indicator()
     return ""
コード例 #5
0
ファイル: files.py プロジェクト: kaldown/vimiv-qt
def modified() -> str:
    """Modification date of the current image."""
    mtime = os.path.getmtime(pathreceiver.current())
    d = datetime.datetime.fromtimestamp(mtime)
    return d.strftime("%y-%m-%d %H:%M")
コード例 #6
0
ファイル: files.py プロジェクト: kaldown/vimiv-qt
def filesize() -> str:
    """Size of the current image in bytes."""
    return get_size(pathreceiver.current())