예제 #1
0
파일: library.py 프로젝트: jkrass1/vimiv-qt
    def elided(self, text, font_metrics, width):
        """Return an elided text preserving html tags.

        If the text is wider than width, it is elided by replacing characters from the
        middle by …. Surrounding html tags are not included in the calculation and left
        untouched.

        Args:
            text: The text to elide.
            font_metrics: QFontMetrics to create elided text based on width.
            width: Width in pixels that the text may take.
        Returns:
            Elided version of the text.
        """
        html_stripped = strip_html(text)
        # Html only surrounds the leading mark indicator as directories are never marked
        if text.startswith(self.mark_str):
            mark_stripped = strip_html(self.mark_str)
            elided = font_metrics.elidedText(html_stripped, Qt.ElideMiddle,
                                             width)
            return elided.replace(mark_stripped, self.mark_str)
        # Html surrounds the full text as the file may be a directory which is displayed
        # in bold
        elided = font_metrics.elidedText(html_stripped, Qt.ElideMiddle, width)
        return text.replace(html_stripped, elided)
예제 #2
0
파일: library.py 프로젝트: kaldown/vimiv-qt
    def elided(self, text, width):
        """Return an elided text preserving html tags.

        If the text is wider than width, it is elided by replacing characters from the
        middle by …. Surrounding html tags are not included in the calculation and left
        untouched.

        Args:
            text: The text to elide.
            width: Width in pixels that the text may take.
        Returns:
            Elided version of the text.
        """
        mark_str = api.settings.statusbar.mark_indicator.value
        marked = text.startswith(mark_str)
        html_stripped = strip_html(text)
        elided = self.font_metrics.elidedText(html_stripped, Qt.ElideMiddle,
                                              width)
        # This becomes more complicated as the html is no longer simply surrounding
        # We must bring back the html from the mark indicator before replacing
        if marked:
            mark_stripped = strip_html(mark_str)
            html_stripped = html_stripped.replace(mark_stripped, mark_str)
            elided = elided.replace(mark_stripped, mark_str)
        return text.replace(html_stripped, elided)
예제 #3
0
def test_strip_html():
    assert utils.strip_html("<b>hello</b>") == "hello"
예제 #4
0
def check_keybindings_popup_highlighting(keybindings_popup, search, command):
    highlight = keybindings_popup.highlighted_search_str(search)
    # Ensure the search_str is the actual highlighted string
    assert utils.strip_html(highlight) == search
    # Ensure the highlighted command is in the pop up text
    assert command.replace(search, highlight) in keybindings_popup.text
예제 #5
0
파일: library.py 프로젝트: jkrass1/vimiv-qt
def strip(path: str) -> str:
    """Strip html tags and mark indicator from a library path."""
    return strip_html(api.mark.highlight(path, marked=False))