Skip to content

Commit cfe8415

Browse files
committed
radio-browser: stations' cursor devided between columns
1 parent 93c714a commit cfe8415

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

pyradio/browser.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@ def __init__(self, search=None):
4242
self._url_timeout = 3
4343
self._search_timeout = 3
4444

45+
# Normally outer boddy (holding box, header, internal header) is
46+
# 2 chars wider that the internal body (holding the stations)
47+
# This property value is half the difference (normally 2 / 2 = 1)
48+
# Used to chgat the columns' separators in internal body
49+
# Check if the cursor is divided as required and adjust
50+
self._outer_internal_body_diff = 1
51+
52+
@property
53+
def outer_internal_body_diff(self):
54+
return self._outer_internal_body_diff
55+
56+
@outer_internal_body_diff.setter
57+
def outer_internal_body_diff(self, value):
58+
raise ValueError('property is read only')
59+
4560
@property
4661
def internal_header_height(self):
4762
return self._internal_header_height
@@ -137,10 +152,12 @@ class PyRadioBrowserInfoBrowser(PyRadioStationsBrowser):
137152
_have_to_retrieve_url = True
138153
_internal_header_height = 1
139154

140-
_url_timeout = 3
141-
_search_timeout = 3
142155

143156
def __init__(self, search=None):
157+
if PY3:
158+
super().__init__()
159+
else:
160+
super(PyRadioBrowserInfoBrowser, self).__init__()
144161
self._raw_stations = []
145162
if search:
146163
self.search(search)

pyradio/radio.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def setup(self, stdscr):
272272
self.setup_return_status = False
273273
return
274274
if logger.isEnabledFor(logging.INFO):
275-
logger.info("GUI initialization on python v. {0} on {1}".format(python_version.replace('\n', ' ').replace('\r', ' '), system()))
275+
logger.info("TUI initialization on python v. {0} on {1}".format(python_version.replace('\n', ' ').replace('\r', ' '), system()))
276276
logger.info('Terminal supports {} colors'.format(curses.COLORS))
277277
self.stdscr = stdscr
278278
from pyradio import version
@@ -553,10 +553,13 @@ def __displayBodyLine(self, lineNum, pad, station):
553553
if lineNum + self.startPos == self.selection and \
554554
self.selection == self.playing:
555555
col = curses.color_pair(9)
556-
# sep_col = curses.color_pair(5)
556+
# initialize col_sep here to have separated cursor
557+
sep_col = curses.color_pair(5)
557558
self.bodyWin.hline(lineNum, 0, ' ', self.bodyMaxX, col)
558559
elif lineNum + self.startPos == self.selection:
559560
col = curses.color_pair(6)
561+
# initialize col_sep here to have separated cursor
562+
sep_col = curses.color_pair(5)
560563
self.bodyWin.hline(lineNum, 0, ' ', self.bodyMaxX, col)
561564
elif lineNum + self.startPos == self.playing:
562565
col = curses.color_pair(4)
@@ -582,8 +585,9 @@ def __displayBodyLine(self, lineNum, pad, station):
582585

583586
if self._cnf.browsing_station_service and sep_col:
584587
ticks = self._cnf.online_browser.get_columns_separators(self.bodyMaxX)
585-
for n in ticks:
586-
self.bodyWin.chgat(lineNum + 1, n, 1, sep_col)
588+
if ticks:
589+
for n in ticks:
590+
self.bodyWin.chgat(lineNum, n - self._cnf.online_browser.outer_internal_body_diff , 1, sep_col)
587591

588592
def run(self):
589593
if self.ws.operation_mode == self.ws.NO_PLAYER_ERROR_MODE:
@@ -2519,7 +2523,7 @@ def keypress(self, char):
25192523
self.stations.append(self._station_editor.new_station)
25202524
self.number_of_items = len(self.stations)
25212525
self.selection = self.number_of_items - 1
2522-
self.startPos = self.number_of_items - self.bodyMaxY2
2526+
self.startPos = self.number_of_items - self.bodyMaxY
25232527
else:
25242528
ret, self.number_of_items = self._cnf.insert_station(self._station_editor.new_station, self.selection + 1)
25252529
self.stations = self._cnf.stations

0 commit comments

Comments
 (0)