INNER CODE UNIT · Python

renderPreview

pystardust/ytfzf · addons/interfaces/sixel-menu/menu.py:81

    def renderPreview(self, line):
        sys.stderr.write("\033[s")
        sys.stderr.write(f'\033[0;{TERMCOLUMNS // 2 + 1}H')
        if self.outputCache.get(self.selectedLine):
            sys.stderr.write(self.outputCache[self.selectedLine])
        else:
            cmd = list(map(lambda x: x.replace(
                "{}", line), self.renderCmd))
            o = subprocess.check_output(cmd).decode("utf-8")
            self.outputCache[self.selectedLine] = o
            sys.stderr.write(o + "\n")
        sys.stderr.write("\033[u")

    def render(self):
        start = max(0, self.selectedLine - TERMLINES // 2)
        end = min(len(self) + 1, self.selectedLine + TERMLINES // 2)
        i = start
        for line in self[start:end]:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…