Skip to content

Commit 446ec69

Browse files
committed
Version 0.8.0: Adding station editor
1 parent cc40c71 commit 446ec69

File tree

8 files changed

+171
-127
lines changed

8 files changed

+171
-127
lines changed

Changelog

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
2019-00-01 s-n-g
1+
2019-09-08 s-n-g
22
* Adding station editor ("a" and "A" to add a station, "e" to edit)
3+
* Line editor supports unlimited string length
34
* Main help window separated to two pages (navigation with "n" / "p")
45
* Changing "e" to "E" to change a station's encoding
56
* Changing "p" to "P" to jump to playing station / loaded playlist
67
* Adding H, L to jump to top / bottom of screen
7-
* Canging M to jump to middle of screen
8+
* Changing M to jump to middle of screen
89
* Changing volume, saving volume and muting is now available on most
910
windows (pop up and questions)
1011
* Manipulating volume (keys m,v) on a help window, will close it
11-
if player not playing.
12+
if player not playing
1213
* Adding ^U, ^D to move station up, down
1314
* Search string will not be lost after displaying help
1415
* PyRadio runs on Windows (finally). Added an installation BAT file,

README.html

+7-7
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ <h2 id="table-of-contents">Table of contents <span style="padding-left: 10px;"><
3636
<li><a href="#controls">Controls</a></li>
3737
<li><a href="#config-file">Config file</a></li>
3838
<li><a href="#about-playlist-files">About Playlist files</a></li>
39+
<li><a href="#search-function">Search function</a></li>
3940
<li><a href="#moving-stations-around">Moving stations around</a></li>
4041
<li><a href="#specifying-stations-encoding">Specifying stations’ encoding</a></li>
4142
<li><a href="#player-detection-selection">Player detection / selection</a></li>
4243
<li><a href="#player-default-volume-level">Player default volume level</a></li>
43-
<li><a href="#search-function">Search function</a></li>
4444
<li><a href="#pyradio-themes">PyRadio Themes</a></li>
4545
<li><a href="#session-locking">Session Locking</a></li>
4646
<li><a href="#update-notification">Update notification</a></li>
@@ -177,6 +177,12 @@ <h3 id="managing-foreign-playlists">Managing “foreign” playlists</h3>
177177
<p>A playlist that does not reside within the program’s configuration directory is considered a “<strong><em>foreign</em></strong>” playlist. This playlist can only be opened by the <strong>-s</strong> command line option.</p>
178178
<p>When this happens, <strong>PyRadio</strong> will offer you the choice to copy the playlist in its configuration directory, thus making it available for manipulation within the program.</p>
179179
<p>If a playlist of the same name already exists in the configuration directory, the “<strong><em>foreign</em></strong>” playlist will be time-stamped. For example, if a “<strong><em>foreign</em></strong>” playlist is named “<em>stations.csv</em>”, it will be named “<em>2019-01-11_13-35-47_stations.csv</em>” (provided that the action was taken on January 11, 2019 at 13:35:47).</p>
180+
<h2 id="search-function">Search function <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style></h2>
181+
<p>On any window presenting a list of items (stations, playlists, themes) a <strong>search function</strong> is available by pressing “<strong>/</strong>”.</p>
182+
<p>The <em>Search Window</em> supports normal and extend editing and in session history.</p>
183+
<p>One can always get help by pressing the “<strong>?</strong>” key.</p>
184+
<p>After a search term has been successfully found (search is case insensitive), next occurrence can be obtained using the “<strong>n</strong>” key and previous occurrence can be obtained using the “<strong>N</strong>” key.</p>
185+
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> <strong>Python 2</strong> users are confined in typing ASCII characters only.</p>
180186
<h2 id="moving-stations-around">Moving stations around <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style></h2>
181187
<p>Rearranging the order of the stations in the playlist is another feature <strong>PyRadio</strong> offers.</p>
182188
<p>All you have to do is specify the <em>source</em> station (the station to be moved) and the position it will be moved to (<em>target</em>).</p>
@@ -247,12 +253,6 @@ <h3 id="mplayer">MPlayer</h3>
247253
[pyradio]
248254
volstep=1
249255
volume=28</pre>
250-
<h2 id="search-function">Search function <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style></h2>
251-
<p>On any window presenting a list of items (stations, playlists, themes) a <strong>search function</strong> is available by pressing “<strong>/</strong>”.</p>
252-
<p>The <em>Search Window</em> supports normal and extend editing and in session history.</p>
253-
<p>One can always get help by pressing the “<strong>?</strong>” key.</p>
254-
<p>After a search term has been successfully found (search is case insensitive), next occurrence can be obtained using the “<strong>n</strong>” key and previous occurrence can be obtained using the “<strong>N</strong>” key.</p>
255-
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> <strong>Python 2</strong> users are confined in typing ASCII characters only.</p>
256256
<h2 id="pyradio-themes">PyRadio Themes <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style></h2>
257257
<p><strong>PyRadio</strong> comes with 6 preconfigured (hard coded) themes:</p>
258258
<ol type="1">

README.md

+15-14
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ Ben Dowling - [https://github.com/coderholic](https://github.com/coderholic)
1212
* [Controls](#controls)
1313
* [Config file](#config-file)
1414
* [About Playlist files](#about-playlist-files)
15+
* [Search function](#search-function)
1516
* [Moving stations around](#moving-stations-around)
1617
* [Specifying stations' encoding](#specifying-stations-encoding)
1718
* [Player detection / selection](#player-detection-selection)
1819
* [Player default volume level](#player-default-volume-level)
19-
* [Search function](#search-function)
2020
* [PyRadio Themes](#pyradio-themes)
2121
* [Session Locking](#session-locking)
2222
* [Update notification](#update-notification)
@@ -209,6 +209,19 @@ When this happens, **PyRadio** will offer you the choice to copy the playlist in
209209

210210
If a playlist of the same name already exists in the configuration directory, the "***foreign***" playlist will be time-stamped. For example, if a "***foreign***" playlist is named "*stations.csv*", it will be named "*2019-01-11_13-35-47_stations.csv*" (provided that the action was taken on January 11, 2019 at 13:35:47).
211211

212+
213+
## Search function
214+
215+
On any window presenting a list of items (stations, playlists, themes) a **search function** is available by pressing "**/**".
216+
217+
The *Search Window* supports normal and extend editing and in session history.
218+
219+
One can always get help by pressing the "**?**" key.
220+
221+
After a search term has been successfully found (search is case insensitive), next occurrence can be obtained using the "**n**" key and previous occurrence can be obtained using the "**N**" key.
222+
223+
**Note:** **Python 2** users are confined in typing ASCII characters only.
224+
212225
## Moving stations around
213226

214227
Rearranging the order of the stations in the playlist is another feature **PyRadio** offers.
@@ -349,18 +362,6 @@ Example:
349362
volstep=1
350363
volume=28
351364

352-
## Search function
353-
354-
On any window presenting a list of items (stations, playlists, themes) a **search function** is available by pressing "**/**".
355-
356-
The *Search Window* supports normal and extend editing and in session history.
357-
358-
One can always get help by pressing the "**?**" key.
359-
360-
After a search term has been successfully found (search is case insensitive), next occurrence can be obtained using the "**n**" key and previous occurrence can be obtained using the "**N**" key.
361-
362-
**Note:** **Python 2** users are confined in typing ASCII characters only.
363-
364365
## PyRadio Themes
365366

366367
**PyRadio** comes with 6 preconfigured (hard coded) themes:
@@ -402,7 +403,7 @@ When the *Theme selection window* is visible, a "**[T]**" string displayed at
402403

403404
**PyRadio** uses session locking, which actually means that only the first instance executed within a given session will be able to write to the configuration file.
404405

405-
Subsequent instances will be "*locked*". This means that the user can still play stations, load and edit playlists, load and test themes, but any changes will **not** be recorded in the configuration file.
406+
Subsequent instances will be "*locked*". This means that the user can still play stations, load and edit playlists, load and test themes, but any changes will **not** be recorded in the configuration file.
406407

407408
### Session unlocking
408409

pyradio.1

+39-13
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,45 @@ When this happens, \fBpyradio\fR will offer you the choise to copy the playlist
228228

229229
If a playlist of the same name already exists in the configuration directory, the "\fIforeign\fR" playlist will be time-stamped. For example, if a "\fIforeign\fR" playlist is named "\fIstations.csv\fR", it will be named "\fI2019-01-11_13-35-47_stations.csv\fR" (provided that the action was taked on January 11, 2019 at 13:35:47).
230230

231+
232+
.SH SEARCH FUNCTION
233+
234+
On any window presenting a list of items (stations, playlists, themes) a \fBsearch function\fR is available by pressing "\fI/\fR".
235+
236+
The \fISearch Window\fR supports normal and extend editing and in session history.
237+
238+
One can always get help by pressing the "\fI?\fR" key.
239+
240+
After a search term has been successfully found (search is case insensitive), next occurrence can be obtained using the "\fIn\fR" key and previous occurrence can be obtained using the "\fIN\fR" key.
241+
242+
.IP \fBNote\fR
243+
\fBPython 2\fR users are confined in typing ASCII characters only.
244+
245+
246+
247+
248+
249+
.SH MOVING STATIONS AROUND
250+
251+
Rearranging the order of the stations in the playlist is another feature PyRadio offers.
252+
253+
All you have to do is specify the \fIsource\fR station (the station to be moved) and the position it will be moved to (\fItarget\fR).
254+
255+
There are three way to do that:
256+
257+
.RS 5
258+
259+
.IP 1.
260+
Press \fICtrl-U\fR or \fICtrl-D\fR to move the current station up or down.
261+
.IP 2.
262+
Type a station number and press \fICtrl-U\fR or \fICtrl-D\fR to move the current station there.
263+
.IP 3.
264+
Go to the position you want to move a station to, and press "\fIJ\fR". This will tag this position (making it the target of the move). Then go to the station you want to move and press \fICtrl-U\fR or \fICtrl-D\fR to move it there.
265+
266+
267+
268+
269+
231270
.SH SPECIFYING STATIONS' ENCODING
232271

233272
Normally, stations provide information about their status (including the title of the song playing, which \fBpyradio\fR displays) in Unicode (\fIutf-8\fR encoded). Therefore, \fBpyradio\fR will use \fIutf-8\fR to decode such data, by default.
@@ -372,19 +411,6 @@ volstep=1
372411
.br
373412
volume=28
374413

375-
.SH SEARCH FUNCTION
376-
377-
On any window presenting a list of items (stations, playlists, themes) a \fBsearch function\fR is available by pressing "\fI/\fR".
378-
379-
The \fISearch Window\fR supports normal and extend editing and in session history.
380-
381-
One can always get help by pressing the "\fI?\fR" key.
382-
383-
After a search term has been successfully found (search is case insensitive), next occurrence can be obtained using the "\fIn\fR" key and previous occurrence can be obtained using the "\fIN\fR" key.
384-
385-
.IP \fBNote\fR
386-
\fBPython 2\fR users are confined in typing ASCII characters only.
387-
388414
.SH PYRADIO THEMES
389415
.PP
390416

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, 7, 9)
3+
version_info = (0, 8, 0)
44

55
__version__ = version = '.'.join(map(str, version_info))
66
__project__ = __name__

pyradio/edit.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ def show(self, item=None):
251251

252252
self._show_title()
253253

254-
logger.error('DE maxY = {}'.format(self.maxY))
255254
if self.maxY < 22 or self.maxX < 72:
256255
txt = ' Window too small to display content '
257256
error_win = curses.newwin(3, len(txt) + 2, int(self.maxY / 2) - 1, int((self.maxX - len(txt)) / 2))
@@ -448,7 +447,11 @@ def keypress(self, char):
448447
self.new_station = None
449448
ret = -1
450449
else:
451-
if char in ( ord('\t'), 9, curses.KEY_DOWN):
450+
if char in (curses.KEY_EXIT, 27, ord('q')) and \
451+
self.focus > 1:
452+
self.new_station = None
453+
ret = -1
454+
elif char in ( ord('\t'), 9, curses.KEY_DOWN):
452455
self.focus +=1
453456
elif char == curses.KEY_UP:
454457
self.focus -=1
@@ -470,15 +473,9 @@ def keypress(self, char):
470473
# cancel
471474
self.new_station = None
472475
ret = -1
473-
elif char in (curses.KEY_EXIT, 27):
474-
self.new_station = None
475-
ret = -1
476476
elif char == ord('s') and self._focus > 1:
477477
ret = self._return_station()
478478
self.focus = abs(ret + 2)
479-
elif char == ord('q') and self._focus > 1:
480-
self.new_station = None
481-
ret = -1
482479
elif char == ord('?') and self.focus <= 1:
483480
ret = 2
484481
elif (char in (curses.ascii.DC2, 18) and not self._adding) or \
@@ -490,6 +487,8 @@ def keypress(self, char):
490487
else:
491488
self._encoding = 'utf-8'
492489
self._orig_encoding = self._encoding
490+
for i in range(0,2):
491+
self._line_editor[i]._reset_position = True
493492
elif self._focus <= 1:
494493
"""
495494
Returns:

pyradio/radio.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class PyRadio(object):
122122

123123
""" editor class """
124124
_station_editor = None
125-
125+
126126
_force_exit = False
127127

128128
_help_metrics = {}
@@ -443,10 +443,6 @@ def _get_redisplay_index():
443443

444444
def refreshBody(self, start=0):
445445
self._update_redisplay_list()
446-
#if logger.isEnabledFor(logging.ERROR):
447-
# logger.error('DE {}'.format(self.ws._dq))
448-
if logger.isEnabledFor(logging.DEBUG):
449-
logger.debug('refreshBody: redisplay windows: {}'.format(self._redisplay_list))
450446
end = len(self._redisplay_list)
451447
if end == 0: end = 1
452448
for n in range(start, end):
@@ -2306,6 +2302,7 @@ def keypress(self, char):
23062302
self.startPos += 1
23072303

23082304
self.ws.close_window()
2305+
self._station_editor = None
23092306
self.refreshBody()
23102307
elif ret == 2:
23112308
# display line editor help
@@ -2906,7 +2903,6 @@ def keypress(self, char):
29062903
return
29072904

29082905
if self.ws.operation_mode == self.ws.NORMAL_MODE:
2909-
logger.error('DE here')
29102906
if char in ( ord('a'), ord('A') ):
29112907
self._station_editor = PyRadioEditor(self.stations, self.selection, self.bodyWin)
29122908
if char == ord('A'):

0 commit comments

Comments
 (0)