Skip to content

Commit 7b09038

Browse files
committed
- Adding H, L and changing M behavior
- Main help window now has captions
1 parent 81e071f commit 7b09038

File tree

1 file changed

+67
-20
lines changed

1 file changed

+67
-20
lines changed

pyradio/radio.py

Lines changed: 67 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,18 @@ def _show_help(self, txt,
975975
self.helpWin.addstr('┤'.encode('utf-8'), curses.color_pair(3))
976976
self.helpWin.addstr(i + 1, inner_width-len(a_line[1:]) - 1, a_line[1:].replace('_', ' '), caption_col)
977977
#self.helpWin.addstr(i + 1, int((inner_width-len(a_line[1:]))/2), a_line[1:].replace('_', ' '), caption_col)
978+
elif a_line.startswith('!'):
979+
self.helpWin.move(i + 1, 2)
980+
lin = ' ' + a_line[1:] + ' '
981+
llin = len(lin)
982+
983+
wsp = inner_width - 4
984+
try:
985+
self.helpWin.addstr('─' * wsp , curses.color_pair(3))
986+
except:
987+
self.helpWin.addstr('─'.encode('utf-8') * wsp, curses.color_pair(3))
988+
self.helpWin.addstr(i + 1, 5, lin, caption_col)
989+
978990
else:
979991
splited = a_line.split('|')
980992
self.helpWin.move(i + 1, 2)
@@ -1083,28 +1095,33 @@ def _show_main_help(self):
10831095
txt = """Up|,|j|,|PgUp|,
10841096
Down|,|k|,|PgDown |Change station selection.
10851097
g| / |<n>G |Jump to first or n-th / last station.
1086-
M| / |P |Jump to |M|iddle / |P|laying station.
1098+
H M L |Go to top / middle / bottom of screen.
1099+
P |Go to |P|laying station.
10871100
Enter|,|Right|,|l |Play selected station.
10881101
r |Select and play a random station.
10891102
Space|,|Left|,|h |Stop / start playing selected station.
1103+
Esc|,|q |Quit.
1104+
!Volume management
10901105
-|/|+| or |,|/|. |Change volume.
10911106
m| / |v ||M|ute player / Save |v|olume (not in vlc).
1107+
!Misc
10921108
o| / |s| / |R ||O|pen / |S|ave / |R|eload playlist.
10931109
t| / |T |Load |t|heme / |T|oggle transparency.
1094-
c |Open Configuration window.
1095-
/| / |n| / |N |Search, go to next / previous result.
1096-
Esc|,|q |Quit. """
1110+
c |Open Configuration window."""
10971111
self._show_help(txt, mode_to_set=self.ws.MAIN_HELP_MODE)
10981112

10991113
def _show_main_help_page_2(self):
1100-
txt = """a| / |A |Add / append new station.
1101-
e |Edit station.
1114+
txt = """!Playlist editing
1115+
a| / |A |Add / append new station.
1116+
e |Edit current station.
11021117
E |Change station's encoding.
11031118
DEL|,|x |Delete selected station.
1104-
J |Create a |J|ump tag
1119+
!Moving stations
1120+
J |Create a |J|ump tag.
11051121
<n>^U|,|<n>^D |Move station |U|p / |D|own.
1106-
||_________________|If a |jump tag| exists,
1107-
||_________________|move the station there."""
1122+
||_________________|If a |jump tag| exists, move it there.
1123+
!Searching
1124+
/| / |n| / |N |Search, go to next / previous result."""
11081125
self._show_help(txt, mode_to_set=self.ws.MAIN_HELP_MODE_PAGE_2)
11091126

11101127
def _show_playlist_help(self):
@@ -1482,9 +1499,11 @@ def _print_save_playlist_error_2(self):
14821499
is_message=True)
14831500

14841501
def _print_editor_name_error(self):
1485-
txt = '''Station Name is empty!
1502+
txt = '''
1503+
___Incomplete Station Data provided!___
1504+
1505+
___Please provide a Station Name.___
14861506
1487-
Please provide a Station Name.
14881507
'''
14891508
self._show_help(txt,
14901509
mode_to_set = self.ws.EDIT_STATION_NAME_ERROR,
@@ -1493,10 +1512,22 @@ def _print_editor_name_error(self):
14931512
is_message=True)
14941513

14951514
def _print_editor_url_error(self):
1496-
txt = '''Station URL is invalid!
1515+
if self._station_editor._line_editor[1].string.strip():
1516+
txt = '''
1517+
___Errorenous Station Data provided!___
14971518
1498-
Please provide a valid Station URL.
1499-
'''
1519+
___Station URL is invalid!___
1520+
___Please provide a valid Station URL.___
1521+
1522+
'''
1523+
else:
1524+
txt = '''
1525+
___Errorenous Station Data provided!___
1526+
1527+
___Station URL is empty!___
1528+
___Please provide a valid Station URL.___
1529+
1530+
'''
15001531
self._show_help(txt,
15011532
mode_to_set = self.ws.EDIT_STATION_URL_ERROR,
15021533
caption = ' Error ',
@@ -2015,15 +2046,31 @@ def keypress(self, char):
20152046
""" if no player, don't serve keyboard """
20162047
return
20172048

2049+
elif char == ord('H'):
2050+
if self.ws.operation_mode in \
2051+
(self.ws.NORMAL_MODE, self.ws.PLAYLIST_MODE):
2052+
self.jumpnr = ''
2053+
self._random_requested = False
2054+
self.selection = self.startPos
2055+
self.refreshBody()
2056+
return
2057+
20182058
elif char == ord('M'):
2019-
if (self.ws.operation_mode == self.ws.NORMAL_MODE or \
2020-
self.ws.operation_mode == self.ws.PLAYLIST_MODE):
2059+
if self.ws.operation_mode in \
2060+
(self.ws.NORMAL_MODE, self.ws.PLAYLIST_MODE):
20212061
self.jumpnr = ''
20222062
self._random_requested = False
2023-
if self.number_of_items > 0:
2024-
self.setStation(int(self.number_of_items / 2) - 1)
2025-
self._put_selection_in_the_middle(force=True)
2026-
self.refreshBody()
2063+
self.selection = self.startPos + int((self.bodyMaxY - 3) / 2)
2064+
self.refreshBody()
2065+
return
2066+
2067+
elif char == ord('L'):
2068+
if self.ws.operation_mode in \
2069+
(self.ws.NORMAL_MODE, self.ws.PLAYLIST_MODE):
2070+
self.jumpnr = ''
2071+
self._random_requested = False
2072+
self.selection = self.startPos + self.bodyMaxY - 3
2073+
self.refreshBody()
20272074
return
20282075

20292076
elif char in (ord('t'), ) and \

0 commit comments

Comments
 (0)