Skip to content

Commit 6e8d8b1

Browse files
committed
- version 0.8.9.18 (0.9-beta15)
- implementing global functions for line editor - updating docs
1 parent 60b4121 commit 6e8d8b1

11 files changed

+365
-92
lines changed

Changelog

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1+
2022-05-18 s-n-g
2+
* version 0.8.9.18 (0.9-beta15)
3+
* changing shortcut w and ^W to e and ^E on the RadioBrowser
4+
Search Window
5+
* implementing global functions
6+
* fixing a couple of bugs and crashes
7+
* updating docs
8+
19
2022-04-29 s-n-g
2-
* version 0.8.9.17 (0.9-beta13)
10+
* version 0.8.9.17 (0.9-beta14)
311
* adding Title's Log
412
* changing versioning
5-
* fixing user isntallation in build_install_pyradio
13+
* fixing user installation in build_install_pyradio
614
* fixing python2 main.py crash (#153)
715
* updating docs
816

17+
2022-03-18 s-n-g (0.9-beta13)
18+
* version 0.8.9.16 (0.9-beta13)
19+
* fixing install.py script
20+
* installing Start Menu Shortcut on Windows
21+
922
2022-03-15 s-n-g
1023
* version 0.8.9.15 (0.9-beta12)
1124
* fixing "0" and "$" insertion on RadioBrowser search window

README.html

+57-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ <h2 id="table-of-contents">Table of Contents <span style="padding-left: 10px;"><
4848
<li><a href="#changelog">Changelog</a></li>
4949
<li><a href="#installation">Installation</a></li>
5050
<li><a href="#command-line-options">Command line options</a></li>
51-
<li><a href="#controls">Controls</a></li>
51+
<li><a href="#controls">Controls</a>
52+
<ul>
53+
<li><a href="#global-shortcuts">Global shortcuts</a></li>
54+
</ul></li>
5255
<li><a href="#html-help">HTML help</a></li>
5356
<li><a href="#pyradio-modes">PyRadio Modes</a>
5457
<ul>
@@ -150,14 +153,27 @@ <h2 id="requirements">Requirements <span style="padding-left: 10px;"><sup style=
150153
<h2 id="changelog">Changelog <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style></h2>
151154
<pre style="height: 200px;">
152155

156+
2022-05-18 s-n-g
157+
* version 0.8.9.18 (0.9-beta15)
158+
* changing shortcut w and ^W to e and ^E on the RadioBrowser
159+
Search Window
160+
* implementing global functions
161+
* fixing a couple of bugs and crashes
162+
* updating docs
163+
153164
2022-04-29 s-n-g
154-
* version 0.8.9.17 (0.9-beta13)
165+
* version 0.8.9.17 (0.9-beta14)
155166
* adding Title's Log
156167
* changing versioning
157-
* fixing user isntallation in build_install_pyradio
168+
* fixing user installation in build_install_pyradio
158169
* fixing python2 main.py crash (#153)
159170
* updating docs
160171

172+
2022-03-18 s-n-g (0.9-beta13)
173+
* version 0.8.9.16 (0.9-beta13)
174+
* fixing install.py script
175+
* installing Start Menu Shortcut on Windows
176+
161177
2022-03-15 s-n-g
162178
* version 0.8.9.15 (0.9-beta12)
163179
* fixing "0" and "$" insertion on RadioBrowser search window
@@ -803,9 +819,46 @@ <h2 id="controls">Controls <span style="padding-left: 10px;"><sup style="font-si
803819
Esc/q Quit - -
804820
Esc/q/Left/h - Cancel / close window Cancel / close window</pre>
805821
<p>The same logic applies to all <strong>PyRadio</strong> windows.</p>
806-
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> All windows - except the <em>Search window</em> - support changing the volume and muting / unmuting the player (provided that <strong>PyRadio</strong> is actually connected to a station).</p>
807822
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> When inserting numbers (either to jump to a station or to move a station), the number will be displayed at the right bottom corner of the window, suffixed by a “<em>G</em>”, i.e. pressing <em>35</em> will display <em>[35G]</em>.</p>
808823
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> When tagging a station position for a move action (by pressing “<strong>J</strong>”), the position will be displayed at the right bottom corner of the window, suffixed by a “<em>J</em>”, i.e. pressing “<em>J</em>” on position <em>35</em> will display <em>[35J]</em>.</p>
824+
<h3 id="global-shortcuts">Global shortcuts</h3>
825+
<p>Some of the functions provided by <strong>PyRadio</strong> will always be available to the user. These functions are:</p>
826+
<table>
827+
<thead>
828+
<tr class="header">
829+
<th>Shortcut</th>
830+
<th>Function</th>
831+
</tr>
832+
</thead>
833+
<tbody>
834+
<tr class="odd">
835+
<td><strong>+</strong>/<strong>-</strong> and <strong>,</strong>/<strong>.</strong></td>
836+
<td>adjust volume</td>
837+
</tr>
838+
<tr class="even">
839+
<td><strong>m</strong></td>
840+
<td>mute player</td>
841+
</tr>
842+
<tr class="odd">
843+
<td><strong>v</strong></td>
844+
<td>save volume</td>
845+
</tr>
846+
<tr class="even">
847+
<td><strong>T</strong></td>
848+
<td>toggle transparency</td>
849+
</tr>
850+
<tr class="odd">
851+
<td><strong>W</strong></td>
852+
<td>toggle titles logging</td>
853+
</tr>
854+
<tr class="even">
855+
<td><strong>w</strong></td>
856+
<td>like a station</td>
857+
</tr>
858+
</tbody>
859+
</table>
860+
<p>Every window in <strong>PyRadio</strong> will respect these shotrcuts, even the ones with a “<em>Press any key to…</em>” message.</p>
861+
<p>When focus is on a “<em>Line editor</em>”, all shortcuts will work when preceded by a “<strong>\</strong>”.</p>
809862
<h2 id="html-help">HTML help <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style></h2>
810863
<p>While in <strong>PyRadio</strong> main window, one can open the HTML (offline) help using “<strong>\h</strong>”.</p>
811864
<p>This is just a helper function for windows users who cannot use the man pages, but is still available for all platforms.</p>

README.md

+18-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Ben Dowling - [https://github.com/coderholic](https://github.com/coderholic)
1515
* [Installation](#installation)
1616
* [Command line options](#command-line-options)
1717
* [Controls](#controls)
18+
* [Global shortcuts](#global-shortcuts)
1819
* [HTML help](#html-help)
1920
* [PyRadio Modes](#pyradio-modes)
2021
* [Secondary Modes](#secondary-modes)
@@ -202,13 +203,28 @@ The following options can also be set in **PyRadio**'s [configuration file](#con
202203

203204
The same logic applies to all **PyRadio** windows.
204205

205-
**Note:** All windows - except the *Search window* - support changing the volume and muting / unmuting the player (provided that **PyRadio** is actually connected to a station).
206-
207206
**Note:** When inserting numbers (either to jump to a station or to move a station), the number will be displayed at the right bottom corner of the window, suffixed by a "*G*", i.e. pressing *35* will display *[35G]*.
208207

209208
**Note:** When tagging a station position for a move action (by pressing "**J**"), the position will be displayed at the right bottom corner of the window, suffixed by a "*J*", i.e. pressing "*J*" on position *35* will display *[35J]*.
210209

211210

211+
### Global shortcuts
212+
213+
Some of the functions provided by **PyRadio** will always be available to the user. These functions are:
214+
215+
| Shortcut | Function |
216+
|--------------------------------|-----------------------|
217+
| **\+**/**\-** and **,**/**\.** | adjust volume |
218+
| **m** | mute player |
219+
| **v** | save volume |
220+
| **T** | toggle transparency |
221+
| **W** | toggle titles logging |
222+
| **w** | like a station |
223+
224+
Every window in **PyRadio** will respect these shotrcuts, even the ones with a "*Press any key to...*" message.
225+
226+
When focus is on a "*Line editor*", all shortcuts will work when preceded by a "**\\**".
227+
212228
## HTML help
213229

214230
While in **PyRadio** main window, one can open the HTML (offline) help using "**\\h**".

pyradio.1

+26-3
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,38 @@ Quit
134134
.P
135135
The same logic applies to all \fBPyRadio\fR windows.
136136

137-
.IP \fBNote:
138-
All windows - except the \fISearch window\fR - support changing the volume and muting / unmuting the player (provided that \fBPyRadio\fR is actually connected to a station).
139-
140137
.IP \fBNote:
141138
When inserting numbers (either to jump to a station or to move a station), the number will be displayed at the right bottom corner of the window, suffixed by a "\fIG\fR", i.e. pressing \fI35\fR will display \fI[35G]\fR.
142139

143140
.IP \fBNote:
144141
When tagging a station position for a move action (by pressing "\fBJ\fR"), the position will be displayed at the right bottom corner of the window, suffixed by a "\fIJ\fR", i.e. pressing "\fIJ\fR" on position \fI35\fR will display \fI[35J]\fR.
145142

143+
.IP \fBGlobal\ shortcuts\fR
144+
145+
Some of the functions provided by \fBpyradio\fR will always be available to the user. These functions are:
146+
147+
148+
.RS 10
149+
150+
.IP \fB+\fR/\fB-\fR\ and\ \fB,\fR/\fB.\fR
151+
adjust volume
152+
.IP \fBm\fR
153+
mute player
154+
.IP \fBv\fR
155+
save volume
156+
.IP \fBT\fR
157+
toggle transparency
158+
.IP \fBW\fR
159+
toggle titles logging
160+
.IP \fBw\fR
161+
like a station
162+
163+
.RE
164+
.RS 7
165+
Every window in \fBpyradio\fR will respect these shotrcuts, even the ones with a “\fIPress any key to…\fR” message.
166+
167+
When focus is on a \fBLine editor\fR, all shortcuts will work when preceded by a "\fI\\\fR".
168+
146169
.SH Pyradio's Modes
147170

148171
\fBPyRadio\fR has the following primary modes:

pyradio/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" pyradio -- Console radio player. "
22

3-
version_info = (0, 8, 9, 17)
3+
version_info = (0, 8, 9, 18)
44

55
# Set it to True if new stations have been
66
# added to the package's stations.csv

pyradio/browser.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ def set_global_functions(self, global_functions):
401401
self._global_functions = dict(global_functions)
402402
if 't' in self._global_functions.keys():
403403
del self._global_functions['t']
404-
if 'T' in self._global_functions.keys():
405-
del self._global_functions['T']
404+
# if 'T' in self._global_functions.keys():
405+
# del self._global_functions['T']
406406

407407
def stations(self, playlist_format=1):
408408
''' Return stations' list (in PyRadio playlist format)
@@ -1401,7 +1401,8 @@ def do_search(self, parent=None, init=False):
14011401
parent=parent,
14021402
config=self.browser_config,
14031403
limit=self._default_max_number_of_results,
1404-
init=init
1404+
init=init,
1405+
global_functions=self._global_functions
14051406
)
14061407
self._search_win.set_search_history(
14071408
self._default_search_history_index,
@@ -2284,11 +2285,14 @@ class RadioBrowserSearchWindow(object):
22842285
_history_id = _selected_history_id = _default_history_id = 1
22852286
_history = []
22862287

2288+
_global_functions = {}
2289+
22872290
def __init__(self,
22882291
parent,
22892292
config,
22902293
limit=100,
2291-
init=False
2294+
init=False,
2295+
global_functions=None
22922296
):
22932297
self._parent = parent
22942298
self._cnf = config
@@ -2306,6 +2310,11 @@ def __init__(self,
23062310
self._half_width = 0
23072311
self._widgets = [ None ]
23082312

2313+
if global_functions is not None:
2314+
self._global_functions = dict(global_functions)
2315+
if 't' in self._global_functions.keys():
2316+
del self._global_functions['t']
2317+
23092318
def __del__(self):
23102319
for a_widget in self._widgets:
23112320
# logger.error('DE deleting: {}'.format(a_widget))
@@ -2689,6 +2698,7 @@ def show(self, parent=None):
26892698
key_down_function_handler=self._focus_down))
26902699
self._widgets[-1].bracket = False
26912700
self._widgets[-1].use_paste_mode = True
2701+
self._widgets[-1].set_global_functions(self._global_functions)
26922702
#self._widgets[-1].string = self.captions[n]
26932703

26942704
''' limit - index = -3 '''

pyradio/config_window.py

+41-13
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def set_global_functions(global_functions):
2727
ret = dict(global_functions)
2828
if 't' in ret.keys():
2929
del ret['t']
30-
del ret['T']
3130
return ret
3231

3332
class PyRadioConfigWindow(object):
@@ -669,12 +668,15 @@ def __init__(self,
669668
edit_color=curses.color_pair(9),
670669
cursor_color=curses.color_pair(8),
671670
unfocused_color=curses.color_pair(5),
672-
string_changed_handler=self._string_changed)
671+
string_changed_handler=self._string_changed
672+
)
673673
self._widgets[0].string = string
674674
self._widgets[0].bracket = False
675675
self._widgets[0]._use_paste_mode = True
676+
self._widgets[0]._mode_changed = self._show_alternative_modes
677+
self._widgets[0].set_global_functions(self._global_functions)
676678
''' enables direct insersion of ? and \ '''
677-
self._widgets[0]._paste_mode = True
679+
self._widgets[0]._paste_mode = False
678680
self._line_editor = self._widgets[0]
679681

680682
''' add horizontal push buttons '''
@@ -691,6 +693,27 @@ def __init__(self,
691693
if not self._orig_string:
692694
self._widgets[1].enabled = False
693695

696+
def _show_alternative_modes(self):
697+
if self._line_editor._paste_mode:
698+
""" print paste mode is on on editor """
699+
self._win.addstr(0, 18, '[', curses.color_pair(5))
700+
self._win.addstr('Paste mode', curses.color_pair(4))
701+
self._win.addstr('] ', curses.color_pair(5))
702+
else:
703+
if self._line_editor.backslash_pressed:
704+
""" print editor's flag """
705+
# fix for python 2
706+
#self._win.addstr(*lin[i], '[', curses.color_pair(5))
707+
self._win.addstr(0, 18, '[', curses.color_pair(5))
708+
self._win.addstr('Extra mode', curses.color_pair(4))
709+
self._win.addstr(']', curses.color_pair(5))
710+
else:
711+
""" print cleared editor's flag """
712+
# fix for python 2
713+
#self._win.addstr(*lin[i], 15 * ' ', curses.color_pair(5))
714+
self._win.addstr(0, 18, 15 * ' ', curses.color_pair(5))
715+
self._win.refresh()
716+
694717
def _string_changed(self):
695718
pass
696719

@@ -741,6 +764,7 @@ def show(self):
741764

742765
self._win.addstr(10 + step, 5, '?', curses.color_pair(4))
743766
self._win.addstr(10 + step, 23, 'Line editor help (in Line Editor).', curses.color_pair(5))
767+
self._show_alternative_modes()
744768
self._win.refresh()
745769
self.refresh_win()
746770

@@ -790,10 +814,7 @@ def keypress(self, char):
790814
2: Display line editor help
791815
'''
792816
ret = 1
793-
if chr(char) in self._global_functions.keys():
794-
self._global_functions[chr(char)]()
795-
return 1
796-
elif char == ord('?') and self._focus > 0:
817+
if char == ord('?') and self._focus > 0:
797818
return 2
798819
elif char in (curses.KEY_EXIT, 27, ord('q')) and \
799820
self._focus > 0:
@@ -846,6 +867,9 @@ def keypress(self, char):
846867
''' cancel '''
847868
self.edit_string = ''
848869
ret = 0
870+
elif chr(char) in self._global_functions.keys():
871+
self._global_functions[chr(char)]()
872+
return 1
849873

850874
if ret == 1:
851875
self._update_focus()
@@ -1461,11 +1485,11 @@ def keypress(self, char):
14611485
3 - Editor is visible
14621486
4 - Editor exited
14631487
'''
1464-
if chr(char) in self._global_functions.keys():
1465-
self._global_functions[chr(char)]()
1466-
elif self.editing == 0:
1488+
if self.editing == 0:
14671489
''' focus on players '''
1468-
if char in (9, ):
1490+
if chr(char) in self._global_functions.keys():
1491+
self._global_functions[chr(char)]()
1492+
elif char in (9, ):
14691493
if self._players[self.selection][1]:
14701494
self._switch_column()
14711495
self.refresh_selection()
@@ -1558,14 +1582,18 @@ def keypress(self, char):
15581582
self._parameter_editor = ExtraParametersEditor(
15591583
self._win,
15601584
self._cnf,
1561-
string=self._extra._items[self._extra.selection])
1585+
string=self._extra._items[self._extra.selection],
1586+
global_functions=self._global_functions
1587+
)
15621588
self.refresh_win()
15631589
return 3
15641590
elif ret == 5:
15651591
''' add parameter '''
15661592
self._parameter_editor = ExtraParametersEditor(
15671593
self._win,
1568-
self._cnf)
1594+
self._cnf,
1595+
global_functions=self._global_functions
1596+
)
15691597
self.editing = 1
15701598
self.refresh_win()
15711599
return 3

pyradio/edit.py

+2
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ def _add_editors(self):
302302
self._line_editor[ed].bracket = False
303303
self._line_editor[ed]._mode_changed = self._show_alternative_modes
304304
self._line_editor[ed].use_paste_mode = True
305+
self._line_editor[ed].set_global_functions(self._global_functions)
305306

306307
def show(self, item=None):
307308
self._win = None
@@ -808,6 +809,7 @@ def show(self):
808809
unfocused_color=curses.color_pair(5),
809810
string_changed_handler=self._string_changed)
810811
self._widgets[0].bracket = False
812+
self._widgets[0].set_global_functions(self._global_functions)
811813
self._line_editor = self._widgets[0]
812814
# add copy checkbox
813815
if self._widgets[1] is None:

0 commit comments

Comments
 (0)