Skip to content

Commit

Permalink
Version 0.8.0: Adding station editor
Browse files Browse the repository at this point in the history
  • Loading branch information
s-n-g committed Sep 8, 2019
1 parent cc40c71 commit 446ec69
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 127 deletions.
7 changes: 4 additions & 3 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
2019-00-01 s-n-g
2019-09-08 s-n-g
* Adding station editor ("a" and "A" to add a station, "e" to edit)
* Line editor supports unlimited string length
* Main help window separated to two pages (navigation with "n" / "p")
* Changing "e" to "E" to change a station's encoding
* Changing "p" to "P" to jump to playing station / loaded playlist
* Adding H, L to jump to top / bottom of screen
* Canging M to jump to middle of screen
* Changing M to jump to middle of screen
* Changing volume, saving volume and muting is now available on most
windows (pop up and questions)
* Manipulating volume (keys m,v) on a help window, will close it
if player not playing.
if player not playing
* Adding ^U, ^D to move station up, down
* Search string will not be lost after displaying help
* PyRadio runs on Windows (finally). Added an installation BAT file,
Expand Down
14 changes: 7 additions & 7 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ <h2 id="table-of-contents">Table of contents <span style="padding-left: 10px;"><
<li><a href="#controls">Controls</a></li>
<li><a href="#config-file">Config file</a></li>
<li><a href="#about-playlist-files">About Playlist files</a></li>
<li><a href="#search-function">Search function</a></li>
<li><a href="#moving-stations-around">Moving stations around</a></li>
<li><a href="#specifying-stations-encoding">Specifying stations’ encoding</a></li>
<li><a href="#player-detection-selection">Player detection / selection</a></li>
<li><a href="#player-default-volume-level">Player default volume level</a></li>
<li><a href="#search-function">Search function</a></li>
<li><a href="#pyradio-themes">PyRadio Themes</a></li>
<li><a href="#session-locking">Session Locking</a></li>
<li><a href="#update-notification">Update notification</a></li>
Expand Down Expand Up @@ -177,6 +177,12 @@ <h3 id="managing-foreign-playlists">Managing “foreign” playlists</h3>
<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>
<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>
<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>
<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>
<p>On any window presenting a list of items (stations, playlists, themes) a <strong>search function</strong> is available by pressing “<strong>/</strong>”.</p>
<p>The <em>Search Window</em> supports normal and extend editing and in session history.</p>
<p>One can always get help by pressing the “<strong>?</strong>” key.</p>
<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>
<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>
<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>
<p>Rearranging the order of the stations in the playlist is another feature <strong>PyRadio</strong> offers.</p>
<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>
Expand Down Expand Up @@ -247,12 +253,6 @@ <h3 id="mplayer">MPlayer</h3>
[pyradio]
volstep=1
volume=28</pre>
<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>
<p>On any window presenting a list of items (stations, playlists, themes) a <strong>search function</strong> is available by pressing “<strong>/</strong>”.</p>
<p>The <em>Search Window</em> supports normal and extend editing and in session history.</p>
<p>One can always get help by pressing the “<strong>?</strong>” key.</p>
<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>
<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>
<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>
<p><strong>PyRadio</strong> comes with 6 preconfigured (hard coded) themes:</p>
<ol type="1">
Expand Down
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Ben Dowling - [https://github.com/coderholic](https://github.com/coderholic)
* [Controls](#controls)
* [Config file](#config-file)
* [About Playlist files](#about-playlist-files)
* [Search function](#search-function)
* [Moving stations around](#moving-stations-around)
* [Specifying stations' encoding](#specifying-stations-encoding)
* [Player detection / selection](#player-detection-selection)
* [Player default volume level](#player-default-volume-level)
* [Search function](#search-function)
* [PyRadio Themes](#pyradio-themes)
* [Session Locking](#session-locking)
* [Update notification](#update-notification)
Expand Down Expand Up @@ -209,6 +209,19 @@ When this happens, **PyRadio** will offer you the choice to copy the playlist in

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).


## Search function

On any window presenting a list of items (stations, playlists, themes) a **search function** is available by pressing "**/**".

The *Search Window* supports normal and extend editing and in session history.

One can always get help by pressing the "**?**" key.

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.

**Note:** **Python 2** users are confined in typing ASCII characters only.

## Moving stations around

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

## Search function

On any window presenting a list of items (stations, playlists, themes) a **search function** is available by pressing "**/**".

The *Search Window* supports normal and extend editing and in session history.

One can always get help by pressing the "**?**" key.

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.

**Note:** **Python 2** users are confined in typing ASCII characters only.

## PyRadio Themes

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

**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.

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.
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.

### Session unlocking

Expand Down
52 changes: 39 additions & 13 deletions pyradio.1
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,45 @@ When this happens, \fBpyradio\fR will offer you the choise to copy the playlist

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).


.SH SEARCH FUNCTION

On any window presenting a list of items (stations, playlists, themes) a \fBsearch function\fR is available by pressing "\fI/\fR".

The \fISearch Window\fR supports normal and extend editing and in session history.

One can always get help by pressing the "\fI?\fR" key.

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.

.IP \fBNote\fR
\fBPython 2\fR users are confined in typing ASCII characters only.





.SH MOVING STATIONS AROUND

Rearranging the order of the stations in the playlist is another feature PyRadio offers.

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).

There are three way to do that:

.RS 5

.IP 1.
Press \fICtrl-U\fR or \fICtrl-D\fR to move the current station up or down.
.IP 2.
Type a station number and press \fICtrl-U\fR or \fICtrl-D\fR to move the current station there.
.IP 3.
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.





.SH SPECIFYING STATIONS' ENCODING

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.
Expand Down Expand Up @@ -372,19 +411,6 @@ volstep=1
.br
volume=28

.SH SEARCH FUNCTION

On any window presenting a list of items (stations, playlists, themes) a \fBsearch function\fR is available by pressing "\fI/\fR".

The \fISearch Window\fR supports normal and extend editing and in session history.

One can always get help by pressing the "\fI?\fR" key.

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.

.IP \fBNote\fR
\fBPython 2\fR users are confined in typing ASCII characters only.

.SH PYRADIO THEMES
.PP

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

__version__ = version = '.'.join(map(str, version_info))
__project__ = __name__
Expand Down
15 changes: 7 additions & 8 deletions pyradio/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ def show(self, item=None):

self._show_title()

logger.error('DE maxY = {}'.format(self.maxY))
if self.maxY < 22 or self.maxX < 72:
txt = ' Window too small to display content '
error_win = curses.newwin(3, len(txt) + 2, int(self.maxY / 2) - 1, int((self.maxX - len(txt)) / 2))
Expand Down Expand Up @@ -448,7 +447,11 @@ def keypress(self, char):
self.new_station = None
ret = -1
else:
if char in ( ord('\t'), 9, curses.KEY_DOWN):
if char in (curses.KEY_EXIT, 27, ord('q')) and \
self.focus > 1:
self.new_station = None
ret = -1
elif char in ( ord('\t'), 9, curses.KEY_DOWN):
self.focus +=1
elif char == curses.KEY_UP:
self.focus -=1
Expand All @@ -470,15 +473,9 @@ def keypress(self, char):
# cancel
self.new_station = None
ret = -1
elif char in (curses.KEY_EXIT, 27):
self.new_station = None
ret = -1
elif char == ord('s') and self._focus > 1:
ret = self._return_station()
self.focus = abs(ret + 2)
elif char == ord('q') and self._focus > 1:
self.new_station = None
ret = -1
elif char == ord('?') and self.focus <= 1:
ret = 2
elif (char in (curses.ascii.DC2, 18) and not self._adding) or \
Expand All @@ -490,6 +487,8 @@ def keypress(self, char):
else:
self._encoding = 'utf-8'
self._orig_encoding = self._encoding
for i in range(0,2):
self._line_editor[i]._reset_position = True
elif self._focus <= 1:
"""
Returns:
Expand Down
8 changes: 2 additions & 6 deletions pyradio/radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class PyRadio(object):

""" editor class """
_station_editor = None

_force_exit = False

_help_metrics = {}
Expand Down Expand Up @@ -443,10 +443,6 @@ def _get_redisplay_index():

def refreshBody(self, start=0):
self._update_redisplay_list()
#if logger.isEnabledFor(logging.ERROR):
# logger.error('DE {}'.format(self.ws._dq))
if logger.isEnabledFor(logging.DEBUG):
logger.debug('refreshBody: redisplay windows: {}'.format(self._redisplay_list))
end = len(self._redisplay_list)
if end == 0: end = 1
for n in range(start, end):
Expand Down Expand Up @@ -2306,6 +2302,7 @@ def keypress(self, char):
self.startPos += 1

self.ws.close_window()
self._station_editor = None
self.refreshBody()
elif ret == 2:
# display line editor help
Expand Down Expand Up @@ -2906,7 +2903,6 @@ def keypress(self, char):
return

if self.ws.operation_mode == self.ws.NORMAL_MODE:
logger.error('DE here')
if char in ( ord('a'), ord('A') ):
self._station_editor = PyRadioEditor(self.stations, self.selection, self.bodyWin)
if char == ord('A'):
Expand Down
Loading

0 comments on commit 446ec69

Please sign in to comment.