@@ -469,7 +469,7 @@ def __init__(self, pyradio_config,
469
469
self .ws .PLAYLIST_RELOAD_ERROR_MODE : self ._print_playlist_reload_error ,
470
470
self .ws .SAVE_PLAYLIST_ERROR_1_MODE : self ._print_save_playlist_error_1 ,
471
471
self .ws .SAVE_PLAYLIST_ERROR_2_MODE : self ._print_save_playlist_error_2 ,
472
- self .ws .REMOVE_STATION_MODE : self .removeStation ,
472
+ self .ws .REMOVE_STATION_MODE : self ._ask_to_remove_station ,
473
473
self .ws .FOREIGN_PLAYLIST_ASK_MODE : self ._print_handle_foreign_playlist ,
474
474
self .ws .FOREIGN_PLAYLIST_MESSAGE_MODE : self ._print_foreign_playlist_message ,
475
475
self .ws .FOREIGN_PLAYLIST_COPY_ERROR_MODE : self ._print_foreign_playlist_copy_error ,
@@ -2074,7 +2074,7 @@ def _show_player_is_stopped(self, from_update_thread=False):
2074
2074
help_msg = True , suffix = self ._status_suffix , counter = ''
2075
2075
)
2076
2076
2077
- def removeStation (self ):
2077
+ def _ask_to_remove_station (self ):
2078
2078
if self ._cnf .confirm_station_deletion and not self ._cnf .is_register :
2079
2079
if self ._cnf .locked :
2080
2080
txt = '''
@@ -2103,7 +2103,7 @@ def removeStation(self):
2103
2103
prompt = '' , is_message = True )
2104
2104
else :
2105
2105
self .ws .operation_mode = self .ws .REMOVE_STATION_MODE
2106
- curses . ungetch ( 'y' )
2106
+ self . _remove_station ( )
2107
2107
2108
2108
def saveCurrentPlaylist (self , stationFile = '' ):
2109
2109
ret = self ._cnf .save_playlist_file (stationFile )
@@ -4078,6 +4078,7 @@ def _align_stations_and_refresh(self,
4078
4078
self .stopPlayer ()
4079
4079
self .playing , self .selection , self .stations , \
4080
4080
self .number_of_items = (- 1 , 0 , 0 , 0 )
4081
+ self .refreshBody ()
4081
4082
return
4082
4083
else :
4083
4084
#if logger.isEnabledFor(logging.DEBUG):
@@ -4094,10 +4095,10 @@ def _align_stations_and_refresh(self,
4094
4095
self .playing -= 1
4095
4096
else :
4096
4097
self .playing = - 1
4097
-
4098
4098
if self .selection > self .number_of_items - self .bodyMaxY :
4099
4099
self .startPos -= 1
4100
- if self .selection >= self .number_of_items :
4100
+ if self .selection >= self .number_of_items or \
4101
+ self .selection >= self .startPos + self .maxY - 4 :
4101
4102
self .selection -= 1
4102
4103
if self .startPos < 0 :
4103
4104
self .startPos = 0
@@ -4164,7 +4165,8 @@ def _align_stations_and_refresh(self,
4164
4165
self .selection = 0
4165
4166
self .startPos = 0
4166
4167
''' make sure playing station is visible '''
4167
- self ._goto_playing_station (changing_playlist = True )
4168
+ if cur_mode != self .ws .REMOVE_STATION_MODE :
4169
+ self ._goto_playing_station (changing_playlist = True )
4168
4170
4169
4171
if logger .isEnabledFor (logging .DEBUG ):
4170
4172
logger .debug ('self.selection = {0}, self.playing = {1}, self.startPos = {2}' .format (self .selection , self .playing , self .startPos ))
@@ -6087,6 +6089,31 @@ def _show_remote_control_server_active(self):
6087
6089
is_message = True
6088
6090
)
6089
6091
6092
+ def _remove_station (self , char = 121 ):
6093
+ ''' removes a station
6094
+ char=121 is ord('y')
6095
+ '''
6096
+ self ._set_active_stations ()
6097
+ deleted_station , self .number_of_items = self ._cnf .remove_station (self .selection )
6098
+ if logger .isEnabledFor (logging .DEBUG ):
6099
+ logger .debug ('Deleted station: "{}"' .format (deleted_station [0 ]))
6100
+ self .ws .close_window ()
6101
+ self ._align_stations_and_refresh (self .ws .REMOVE_STATION_MODE )
6102
+ if not self ._cnf .locked and char == ord ('Y' ):
6103
+ self ._cnf .confirm_station_deletion = False
6104
+ self ._cnf .stations_history .remove_station (deleted_station [0 ])
6105
+
6106
+ ''' auto save register file '''
6107
+ if self ._cnf .is_register :
6108
+ self .saveCurrentPlaylist ()
6109
+ if self .number_of_items == 0 :
6110
+ try :
6111
+ remove (self ._cnf .station_path )
6112
+ except :
6113
+ pass
6114
+ self ._unnamed_register = deleted_station
6115
+ self .selections [0 ][3 ] = self .stations
6116
+
6090
6117
def keypress (self , char ):
6091
6118
if char == curses .KEY_F2 :
6092
6119
self ._need_to_update_stations_csv = 2
@@ -7872,27 +7899,7 @@ def keypress(self, char):
7872
7899
self ._global_functions [char ]()
7873
7900
return
7874
7901
if char in (ord ('y' ), ord ('Y' )):
7875
- self ._set_active_stations ()
7876
- deleted_station , self .number_of_items = self ._cnf .remove_station (self .selection )
7877
- if logger .isEnabledFor (logging .DEBUG ):
7878
- logger .debug ('Deleted station: "{}"' .format (deleted_station [0 ]))
7879
- self .ws .close_window ()
7880
- self ._align_stations_and_refresh (self .ws .REMOVE_STATION_MODE )
7881
- if not self ._cnf .locked and char == ord ('Y' ):
7882
- self ._cnf .confirm_station_deletion = False
7883
- self ._cnf .stations_history .remove_station (deleted_station [0 ])
7884
-
7885
- ''' auto save register file '''
7886
- if self ._cnf .is_register :
7887
- self .saveCurrentPlaylist ()
7888
- if self .number_of_items == 0 :
7889
- try :
7890
- remove (self ._cnf .station_path )
7891
- except :
7892
- pass
7893
- self ._unnamed_register = deleted_station
7894
- self .selections [0 ][3 ] = self .stations
7895
-
7902
+ self ._remove_station (char )
7896
7903
else :
7897
7904
if logger .isEnabledFor (logging .DEBUG ):
7898
7905
logger .debug ('Canceling: Remove station' )
@@ -8348,7 +8355,7 @@ def keypress(self, char):
8348
8355
callback_function = self .refreshBody )
8349
8356
pass
8350
8357
else :
8351
- self .removeStation ()
8358
+ self ._ask_to_remove_station ()
8352
8359
return
8353
8360
8354
8361
elif char in (ord ('s' ), ):
0 commit comments