From 6fae44aafc24acab3e33cf6b2918709a2c4548cb Mon Sep 17 00:00:00 2001 From: Spiros Georgaras Date: Tue, 11 May 2021 20:04:53 +0300 Subject: [PATCH] Version 0.8.9.2 Using subwin to eliminate flickering --- Changelog | 7 ++- devel/build_install_pyradio | 3 +- pyradio/__init__.py | 2 +- pyradio/browser.py | 12 +--- pyradio/common.py | 11 ++++ pyradio/radio.py | 115 +++++++++++++++++++++++++++--------- 6 files changed, 107 insertions(+), 43 deletions(-) diff --git a/Changelog b/Changelog index 929c2aa1..e66ab46e 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,9 @@ -2021-04-20 s-n-g +2021-05-11 s-n-g + * Screen flickering when moving within the stations' list eliminated + * VLC player is available again (disabled by unreported bug) + * Advancing Radio Browser support * Fixing python 2 return from Radio Browser TUI breakage - * Adding dnspython module existence check + * Adding dnspython module availability check 2021-04-14 s-n-g * Version 0.8.9.1 diff --git a/devel/build_install_pyradio b/devel/build_install_pyradio index e922c938..e842960b 100755 --- a/devel/build_install_pyradio +++ b/devel/build_install_pyradio @@ -219,7 +219,8 @@ set -- "${POSITIONAL[@]}" # restore positional parameters #done # check dependencies :) -for prog in git sed ;do +# for prog in git sed ;do +for prog in sed ;do ${prog} --version 2>/dev/null 1>&2 || { if [ "${prog}" = "sed" ];then sed 's/a/b/' LICENCE > /dev/null ||{ diff --git a/pyradio/__init__.py b/pyradio/__init__.py index 8e3fe19e..5bf84539 100644 --- a/pyradio/__init__.py +++ b/pyradio/__init__.py @@ -1,6 +1,6 @@ " pyradio -- Console radio player. " -version_info = (0, 8, 9, 1) +version_info = (0, 8, 9, 2) # Application state: # New stable version: '' diff --git a/pyradio/browser.py b/pyradio/browser.py index 1978ae3c..73dcfaa2 100644 --- a/pyradio/browser.py +++ b/pyradio/browser.py @@ -288,7 +288,7 @@ def initialize(self): 'term': '', 'post_data': {'name': 'jaz'}, }) - self._search_history_index = 1 + self._search_history_index = 0 return True return False @@ -1238,7 +1238,7 @@ def show(self): self.TITLE, curses.color_pair(4)) self._win.refresh() - self._erase_win(self.maxY, self.maxX, self.Y, self.X) + # self._erase_win(self.maxY, self.maxX, self.Y, self.X) ''' start displaying things ''' self._win.addstr(1, 2, 'Search for', curses.color_pair(5)) @@ -1369,14 +1369,6 @@ def _update_focus(self): else: x._focused = False - def _erase_win(self, pY, pX, Y, X): - empty_win = curses.newwin( - pY - 2, pX - 2, - Y + 1, X + 1 - ) - empty_win.bkgdset(' ', curses.color_pair(5)) - empty_win.erase() - empty_win.refresh() def keypress(self, char): ''' RadioBrowserInfoSearchWindow keypress diff --git a/pyradio/common.py b/pyradio/common.py index 79051124..c0f61e8a 100644 --- a/pyradio/common.py +++ b/pyradio/common.py @@ -33,3 +33,14 @@ def BACKGROUND(): return 1 ': Playback stopped', ': Player terminated abnormally!') +def erase_curses_win(self, Y, X, beginY, beginX, char=' ', color=5): + ''' empty a part of the screen + ''' + empty_win = curses.newwin( + Y - 2, X - 2, + beginY + 1, beginX + 1 + ) + empty_win.bkgdset(char, curses.color_pair(color)) + empty_win.erase() + empty_win.refresh() + diff --git a/pyradio/radio.py b/pyradio/radio.py index 1e098266..7939b7a8 100644 --- a/pyradio/radio.py +++ b/pyradio/radio.py @@ -456,6 +456,7 @@ def __del__(self): self.transientWin = None def setup(self, stdscr): + # curses.savetty() self.setup_return_status = True if not curses.has_colors(): self.setup_return_status = False @@ -499,7 +500,6 @@ def setup(self, stdscr): self.playbackTimeoutCounter, self.connectionFailed, self._show_station_info_from_thread) - logger.error('DE \n\nNEW_PROFILE_STRING = {}\n\n'.format(self.player.NEW_PROFILE_STRING)) except: ''' no player ''' self.ws.operation_mode = self.ws.NO_PLAYER_ERROR_MODE @@ -593,7 +593,7 @@ def setupAndDrawScreen(self, init_from_setup=False): self.bodyWinEndY = self.maxY - 1 if logger.isEnabledFor(logging.DEBUG): logger.debug('body starts at line {0}, ends at line {1}'.format(self.bodyWinStartY, self.bodyWinEndY)) - self.bodyWin = curses.newwin( + self.bodyWin = self.outerBodyWin.subwin( self.maxY - 4 - self._cnf.internal_header_height, self.maxX - 2, self.bodyWinStartY, @@ -615,6 +615,7 @@ def setupAndDrawScreen(self, init_from_setup=False): ''' for light color scheme ''' # TODO self.outerBodyWin.bkgdset(' ', curses.color_pair(5)) + self.outerBodyWin.erase() self.bodyWin.bkgdset(' ', curses.color_pair(5)) self.initBody() @@ -880,11 +881,11 @@ def __displayBodyLine(self, lineNum, pad, station, return_line=False): except: pass - if station and self._cnf.browsing_station_service and sep_col: - ticks = self._cnf.online_browser.get_columns_separators(self.bodyMaxX, adjust_for_body=True) - if ticks: - for n in ticks: - self.bodyWin.chgat(lineNum, n, 1, sep_col) + if station and self._cnf.browsing_station_service and sep_col: + ticks = self._cnf.online_browser.get_columns_separators(self.bodyMaxX, adjust_for_body=True) + if ticks: + for n in ticks: + self.bodyWin.chgat(lineNum, n, 1, sep_col) def run(self): self._register_signals_handlers() @@ -5883,6 +5884,8 @@ def keypress(self, char): self._cnf.jump_tag = -1 self._update_status_bar_right(status_suffix='') if self._cnf.browsing_station_service: + self._print_not_implemented_yet() + return self.ws.operation_mode = self.ws.BROWSER_SEARCH_MODE self._browser_init_search(parent=self.outerBodyWin) else: @@ -6476,51 +6479,103 @@ def _find_renamed_selection(self, mode, search_path, search_file): def _redisplay_stations_and_playlists(self): if self._limited_height_mode: return - self.outerBodyWin.erase() if self._redisplay_list[-1][0] ==self.ws.BROWSER_SEARCH_MODE and \ self._redisplay_list[-2][0] == self.ws.NORMAL_MODE: if logger.isEnabledFor(logging.DEBUG): logger.debug('---=== Not displaying stations (Radio Browser window follows) ===---') self.outerBodyWin.refresh() return - self.bodyWin.erase() + + # self.bodyWin.erase() if self.maxY > 2: self.outerBodyWin.box() try: self.bodyWin.move(1, 1) self.bodyWin.move(0, 0) except: + if logger.isEnabledFor(logging.DEBUG): + logger.debug('====---- cursrm move failed ----====') pass self._print_body_header() pad = len(str(self.startPos + self.bodyMaxY)) - ''' display the content ''' - if self.number_of_items > 0: - for lineNum in range(self.bodyMaxY): - i = lineNum + self.startPos - if i < len(self.stations): - self.__displayBodyLine(lineNum, pad, self.stations[i]) - else: - ''' display browser empty lines (station=None) ''' - line = self.__displayBodyLine(0, pad, None, return_line = True) - if self._cnf.browsing_station_service: - for n in range(i+1, self.bodyMaxY + 1): - try: - self.bodyWin.addstr(lineNum, 0, line, curses.color_pair(5)) - except: - pass - lineNum += 1 - break - else: - ''' we have no stations to display ''' + if self.number_of_items == 0: if self._cnf.browsing_station_service: - ''' we have to display emplty lines ''' + ''' we have to fill the screen with emplty lines ''' line = self.__displayBodyLine(0, pad, None, return_line = True) for n in range(0, self.bodyMaxY + 1): try: self.bodyWin.addstr(n, 0, line, curses.color_pair(5)) except: pass + pass + else: + self.bodyWin.erase() + else: + for lineNum in range(self.bodyMaxY): + i = lineNum + self.startPos + if i < len(self.stations): + if not self._cnf.browsing_station_service and \ + self.ws.operation_mode == self.ws.NORMAL_MODE: + try: + self.bodyWin.move(lineNum, 0) + self.bodyWin.clrtoeol() + except: + if logger.isEnabledFor(logging.DEBUG): + logger.debug('====---- clear line move failed----====') + self.__displayBodyLine(lineNum, pad, self.stations[i]) + else: + if self._cnf.browsing_station_service: + ''' display browser empty lines (station=None) ''' + line = self.__displayBodyLine(0, pad, None, return_line = True) + if self._cnf.browsing_station_service: + for n in range(i+1, self.bodyMaxY + 1): + try: + self.bodyWin.addstr(lineNum, 0, line, curses.color_pair(5)) + except: + pass + lineNum += 1 + break + else: + logger.error('clearing window from line {} to end.'.format(i)) + try: + self.bodyWin.move(i, 0) + self.bodyWin.clrtobot() + except: + if logger.isEnabledFor(logging.DEBUG): + logger.debug('====---- clear to end of window failed----====') + break + + + + + #''' display the content ''' + #if self.number_of_items > 0: + # for lineNum in range(self.bodyMaxY): + # i = lineNum + self.startPos + # if i < len(self.stations): + # self.__displayBodyLine(lineNum, pad, self.stations[i]) + # else: + # ''' display browser empty lines (station=None) ''' + # line = self.__displayBodyLine(0, pad, None, return_line = True) + # if self._cnf.browsing_station_service: + # for n in range(i+1, self.bodyMaxY + 1): + # try: + # self.bodyWin.addstr(lineNum, 0, line, curses.color_pair(5)) + # except: + # pass + # lineNum += 1 + # break + #else: + # ''' we have no stations to display ''' + # if self._cnf.browsing_station_service: + # ''' we have to display emplty lines ''' + # line = self.__displayBodyLine(0, pad, None, return_line = True) + # for n in range(0, self.bodyMaxY + 1): + # try: + # self.bodyWin.addstr(n, 0, line, curses.color_pair(5)) + # except: + # pass if self._cnf.browsing_station_service: if self._cnf.internal_header_height > 0: @@ -6551,7 +6606,9 @@ def _redisplay_stations_and_playlists(self): self.outerBodyWin.addstr(column_name[j], curses.color_pair(2)) except: pass + self.outerBodyWin.touchwin() self.outerBodyWin.refresh() + self.bodyWin.touchwin() self.bodyWin.refresh() def _redisplay_config(self):