Skip to content

Commit

Permalink
Version 0.8.9.2
Browse files Browse the repository at this point in the history
Using subwin to eliminate flickering
  • Loading branch information
s-n-g committed May 11, 2021
1 parent c8e47a7 commit 6fae44a
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 43 deletions.
7 changes: 5 additions & 2 deletions Changelog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion devel/build_install_pyradio
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||{
Expand Down
2 changes: 1 addition & 1 deletion pyradio/__init__.py
Original file line number Diff line number Diff line change
@@ -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: ''
Expand Down
12 changes: 2 additions & 10 deletions pyradio/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions pyradio/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

115 changes: 86 additions & 29 deletions pyradio/radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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()

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 6fae44a

Please sign in to comment.