def make_display_lines(self): """通过歌词生成屏幕需要显示的内容""" self.screen_height, self.screen_width = self.linesnum() # 屏幕显示行数 display_lines = ['\n'] display_lines.append(self._title + '\r') display_lines.append('\n') for linenum in range(self.screen_height - 2): if self.screen_height/2 - linenum > self.markline - self.topline or \ linenum - self.screen_height/2 >= len(self._lines) - self.markline: display_lines.append('\r') else: line = self._lines[self.markline - (self.screen_height/2 - linenum)] line = line.strip('\n') l = self.center_num(line) flag_num = (self.screen_width - l) / 2 if linenum == self.screen_height/2: i = color_func(self.c['LRC']['highlight'])(line) display_lines.append(' ' * flag_num + i + '\r') else: line = color_func(self.c['LRC']['line'])(line) display_lines.append(' ' * flag_num + line + '\r') display_lines.append(self.center_suffix_selected()) # 歌词页面标题 self.display_lines = display_lines
def make_display_lines(self): """ 生成输出行 注意: 多线程终端同时输出会有bug, 导致起始位置偏移 """ self.screen_height, self.screen_width = self.linesnum() # 屏幕显示行数 display_lines = ['\n\r'] display_lines.append(self._title + '\r') top = self.topline bottom = self.topline + self.screen_height + 1 for index, i in enumerate(self._lines[top:bottom]): # 箭头指向 if index == self.markline: prefix = self._prefix_selected i = color_func(self.c['LINE']['highlight'])(i) else: prefix = self._prefix_deselected # 选择频道 if index + self.topline == self.displayline: suffix = self._suffix_selected else: suffix = self._suffix_deselected line = '%s %s %s' % (prefix, i, suffix) line = color_func(self.c['LINE']['line'])(line) display_lines.append(line + '\r') # 为什么加\r,我不知道,如果不加会出bug self.display_lines = display_lines
def make_display_lines(self): """ 生成输出行 注意: 多线程终端同时输出会有bug, 导致起始位置偏移, 需要在每行加\r """ self.screen_height, self.screen_width = self.linesnum() # 屏幕显示行数 display_lines = ["\n\r"] display_lines.append(self._title + "\r") top = self.topline bottom = self.topline + self.screen_height + 1 for index, i in enumerate(self._lines[top:bottom]): # 箭头指向 if index == self.markline: prefix = self._prefix_selected i = color_func(self.c["LINE"]["highlight"])(i) else: prefix = self._prefix_deselected # 选择频道 if index + self.topline == self.displayline: suffix = self._suffix_selected else: suffix = self._suffix_deselected line = "%s %s %s" % (prefix, i, suffix) line = color_func(self.c["LINE"]["line"])(line) display_lines.append(line + "\r") self.display_lines = display_lines
def make_display_lines(self): """ 生成输出行 注意: 多线程终端同时输出会有bug, 导致起始位置偏移, 需要在每行加\r """ self.screen_height, self.screen_width = self.linesnum() # 屏幕显示行数 display_lines = ['\r'] display_lines.append(self._title + '\r') top = self.topline bottom = self.topline + self.screen_height - 3 for index, i in enumerate(self._lines[top:bottom]): # 箭头指向 if index == self.markline: prefix = self._prefix_selected i = color_func(self.c['LINE']['highlight'])(i) else: prefix = self._prefix_deselected # 选择频道 if index + self.topline == self.displayline: suffix = self._suffix_selected else: suffix = self._suffix_deselected line = '%s %s %s' % (prefix, i, suffix) line = color_func(self.c['LINE']['line'])(line) display_lines.append(line + '\r') return_num = self.screen_height - 3 - len(self._lines) for _ in range(return_num): display_lines.append('\r') self.display_lines = display_lines
def make_display_lines(self): """通过歌词生成屏幕需要显示的内容""" self.screen_height, self.screen_width = self.linesnum() # 屏幕显示行数 display_lines = [""] display_lines.append(self._title + "\r") display_lines.append("") scroll_line_num = self.screen_height - 6 for linenum in range(scroll_line_num): if ( scroll_line_num / 2 - linenum > self.markline - self.topline or linenum - scroll_line_num / 2 >= len(self._lines) - self.markline ): display_lines.append("\r") else: line = self._lines[self.markline - (scroll_line_num / 2 - linenum)] line = line.strip("\n") l = self.center_num(line) flag_num = (self.screen_width - l) / 2 if linenum == scroll_line_num / 2: i = color_func(self.c["LRC"]["highlight"])(line) display_lines.append(" " * flag_num + i + "\r") else: line = color_func(self.c["LRC"]["line"])(line) display_lines.append(" " * flag_num + line + "\r") display_lines.append("") # 空行 display_lines.append(self.center_suffix_selected() + "\r") # 歌词页面标题 self.display_lines = display_lines
def make_display_lines(self): """通过歌词生成屏幕需要显示的内容""" self.screen_height, self.screen_width = self.linesnum() # 屏幕显示行数 display_lines = [''] display_lines.append(self._title + '\r') display_lines.append('') scroll_line_num = self.screen_height - 6 for linenum in range(scroll_line_num): if scroll_line_num/2 - linenum > self.markline - self.topline or \ linenum - scroll_line_num/2 >= len(self._lines) - self.markline: display_lines.append('\r') else: line = self._lines[self.markline - (scroll_line_num/2 - linenum)] line = line.strip('\n') l = self.center_num(line) flag_num = (self.screen_width - l) / 2 if linenum == scroll_line_num/2: i = color_func(self.c['LRC']['highlight'])(line) display_lines.append(' ' * flag_num + i + '\r') else: line = color_func(self.c['LRC']['line'])(line) display_lines.append(' ' * flag_num + line + '\r') display_lines.append('') # 空行 display_lines.append(self.center_suffix_selected() + '\r') # 歌词页面标题 self.display_lines = display_lines
def suffix_selected(self): love = self.love title = color_func(self.c['PLAYINGSONG']['title']) \ (self.song_title) albumtitle = color_func(self.c['PLAYINGSONG']['albumtitle']) \ (self.song_albumtitle) artist = color_func(self.c['PLAYINGSONG']['artist']) \ (self.song_artist) # public_time = color_func(self.c['PLAYINGSONG']['publictime']) \ # (self.song_public_time) or '' return (love + title + ' • ' + albumtitle + ' • ' + artist + ' ' # public_time ).replace('\\', '')
def title(self): time = self.set_time(self.time) volume = str(self.volume) + '%' if self.volume != 0 else \ color_func(self.c['TITLE']['state'])('✖') if self.pause: loop = 'P' elif self.loop: loop = '⟲' else: loop = '→' source = '网易' if self.netease else '' title = [ PREFIX_DESELECTED, color_func(self.c['TITLE']['doubanfm'])('DoubanFM'), '\\', color_func(self.c['TITLE']['username'])(self.user_name), '>>', # color_func(self.c['TITLE']['pro'])(self.song_pro), color_func(self.c['PLAYINGSONG']['like'])(source), color_func(self.c['TITLE']['kbps'])(self.song_kbps), color_func(self.c['TITLE']['time'])(time), # color_func(self.c['TITLE']['rate'])(self.song_rate), color_func(self.c['TITLE']['vol'])(volume), color_func(self.c['TITLE']['state'])(loop)] return ' '.join(title)
def title(self): time = self.set_time(self.time) volume = str(self.volume) + "%" if self.volume != 0 else color_func(self.c["TITLE"]["state"])("✖") if self.pause: loop = "P" elif self.loop: loop = "⟲" else: loop = "→" source = "网易" if self.netease else "" title = [ PREFIX_DESELECTED, color_func(self.c["TITLE"]["doubanfm"])("DoubanFM"), "\\", color_func(self.c["TITLE"]["username"])(self.user_name), ">>", # color_func(self.c['TITLE']['pro'])(self.song_pro), color_func(self.c["PLAYINGSONG"]["like"])(source), color_func(self.c["TITLE"]["kbps"])(self.song_kbps), color_func(self.c["TITLE"]["time"])(time), # color_func(self.c['TITLE']['rate'])(self.song_rate), color_func(self.c["TITLE"]["vol"])(volume), color_func(self.c["TITLE"]["state"])(loop), ] return " ".join(title)
def title(self): time = self.set_time(self.time) volume = str(self.volume) + '%' if self.volume != 0 else \ color_func(self.c['TITLE']['state'])('✖') if self.pause: loop = 'P' elif self.loop: loop = '⟲' else: loop = '→' source = '网易' if self.netease else '' title = [ PREFIX_DESELECTED, color_func(self.c['TITLE']['doubanfm'])('DoubanFM'), '\\', color_func(self.c['TITLE']['username'])(self.user_name), '>>', # color_func(self.c['TITLE']['pro'])(self.song_pro), color_func(self.c['PLAYINGSONG']['like'])(source), color_func(self.c['TITLE']['kbps'])(self.song_kbps), color_func(self.c['TITLE']['time'])(time), # color_func(self.c['TITLE']['rate'])(self.song_rate), color_func(self.c['TITLE']['vol'])(volume), color_func(self.c['TITLE']['state'])(loop) ] return ' '.join(title)
def suffix_selected(self): love = self.love title = color_func(self.c["PLAYINGSONG"]["title"])(self.song_title) albumtitle = color_func(self.c["PLAYINGSONG"]["albumtitle"])(self.song_albumtitle) artist = color_func(self.c["PLAYINGSONG"]["artist"])(self.song_artist) # public_time = color_func(self.c['PLAYINGSONG']['publictime']) \ # (self.song_public_time) or '' return ( love + title + " • " + albumtitle + " • " + artist + " " # public_time ).replace("\\", "")
def suffix_selected(self): love = self.love title = color_func(self.c['PLAYINGSONG']['title']) \ (self.song_title) albumtitle = color_func(self.c['PLAYINGSONG']['albumtitle']) \ (self.song_albumtitle) artist = color_func(self.c['PLAYINGSONG']['artist']) \ (self.song_artist) # public_time = color_func(self.c['PLAYINGSONG']['publictime']) \ # (self.song_public_time) or '' return ( love + title + ' • ' + albumtitle + ' • ' + artist + ' ' # public_time ).replace('\\', '')
def lines(self): keys = self.keys lines = [] lines.append(' '*5 + color_func(self.c['PLAYINGSONG']['title'])('移动') + ' '*17 + color_func(self.c['PLAYINGSONG']['title'])('音乐') + '\r') lines.append(' '*5 + '[%(DOWN)s] ---> 下 [space] ---> 播放' % keys + '\r') lines.append(' '*5 + '[%(UP)s] ---> 上 [%(OPENURL)s] ---> 打开歌曲主页' % keys + '\r') lines.append(' '*5 + '[%(TOP)s] ---> 移到最顶 [%(NEXT)s] ---> 下一首' % keys + '\r') lines.append(' '*5 + '[%(BOTTOM)s] ---> 移到最底 [%(RATE)s] ---> 喜欢/取消喜欢' % keys + '\r') lines.append(' '*26 + '[%(BYE)s] ---> 不再播放' % keys + '\r') lines.append(' '*5 + color_func(self.c['PLAYINGSONG']['title'])('音量') + ' '*17 + '[%(PAUSE)s] ---> 暂停' % keys + '\r') lines.append(' '*5 + '[=] ---> 增 [%(QUIT)s] ---> 退出' % keys + '\r') lines.append(' '*5 + '[-] ---> 减 [%(LOOP)s] ---> 单曲循环' % keys + '\r') lines.append(' '*5 + '[%(MUTE)s] ---> 静音 [i] ---> 网易320k音乐' % keys + '\r') lines.append('') lines.append(' '*5 + color_func(self.c['PLAYINGSONG']['title'])('歌词') + '\r') lines.append(' '*5 + '[%(LRC)s] ---> 歌词' % keys + '\r') return lines
def title(self): time = self.set_time(self.time) volume = str(self.volume) + '%' if self.volume != 0 else \ color_func(self.c['TITLE']['state'])('✖') loop = '↺' if self.loop else '→' title = [ PREFIX_DESELECTED, color_func(self.c['TITLE']['doubanfm'])('DoubanFM'), '\\', color_func(self.c['TITLE']['username'])(self.user_name), '>>', color_func(self.c['TITLE']['pro'])(self.song_pro), color_func(self.c['TITLE']['kbps'])(self.song_kbps), color_func(self.c['TITLE']['time'])(time), # color_func(self.c['TITLE']['rate'])(self.song_rate), color_func(self.c['TITLE']['vol'])(volume), color_func(self.c['TITLE']['state'])(loop)] return ' '.join(title)
def love(self): if self.song_like == 1: return color_func(self.c['PLAYINGSONG']['like'])(LOVE) else: return ''
def love(self): if self.song_like: return color_func(self.c["PLAYINGSONG"]["like"])(LOVE) else: return ""
def prefix_selected(self): return color_func(self.c['LINE']['arrow'])(PREFIX_SELECTED)
def prefix_selected(self): return color_func(self.c["LINE"]["arrow"])(PREFIX_SELECTED)