def print_prompt(): prompt_format = "{prompt_text} > " prompt = prompt_format.format(prompt_text=self.get_prompt_text()) printt(prompt, foreground=self.get_prompt_color(), bold=True, replace=True)
def print_meta(video: Video) -> None: def print_separator(text: Optional[str] = None, fat: bool = False) -> None: columns = shutil.get_terminal_size().columns sep = "━" if fat else "─" if not text: print(sep * columns) else: sep_len = (columns - len(text) - 2) padding = sep_len // 2 printt(sep * padding) printt(" ", text, " ", bold=fat) printtln(sep * (padding + (sep_len % 2))) print_separator("Playing now", fat=True) printt(_("Title: ")) printtln(video.title, bold=True) printt(_("Channel: ")) printtln(video.channel.displayname, bold=True) description = video.description if DESCRIPTION_ENABLED and description is not None: columns = shutil.get_terminal_size().columns lines = description.splitlines() print_separator(_("Video description")) for line in lines: print(wrap.fill(line, width=columns)) print_separator(fat=True) print()
def print_separator(text: Optional[str] = None, fat: bool = False) -> None: columns = shutil.get_terminal_size().columns sep = "━" if fat else "─" if not text: print(sep * columns) else: sep_len = (columns - len(text) - 2) padding = sep_len // 2 printt(sep * padding) printt(" ", text, " ", bold=fat) printtln(sep * (padding + (sep_len % 2)))
def command_line(self, tags: List[str], alphabet: Set[str]) -> Tuple[str, bool]: def print_prompt(): prompt_format = "{prompt_text} > " prompt = prompt_format.format(prompt_text=self.get_prompt_text()) printt(prompt, foreground=self.get_prompt_color(), bold=True, replace=True) print() print(_("Type a valid TAG. <F1> for help.")) print_prompt() tag = "" hook_triggered = False while tag not in tags: char = terminal.getkey() if char in self.hooks: hook_triggered = True if self.hooks[char](): break if char in {"\x04", "\x03"}: # Ctrl+d, Ctrl+d break if char in {"\r", ""}: tag = tags[0] break if char == "\x7f": # DEL tag = tag[:-1] elif char in alphabet: tag += char print_prompt() printt(tag) print() return tag, hook_triggered