@@ -469,7 +469,7 @@ def __init__(self, pyradio_config,
469469 self .ws .PLAYLIST_RELOAD_ERROR_MODE : self ._print_playlist_reload_error ,
470470 self .ws .SAVE_PLAYLIST_ERROR_1_MODE : self ._print_save_playlist_error_1 ,
471471 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 ,
473473 self .ws .FOREIGN_PLAYLIST_ASK_MODE : self ._print_handle_foreign_playlist ,
474474 self .ws .FOREIGN_PLAYLIST_MESSAGE_MODE : self ._print_foreign_playlist_message ,
475475 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):
20742074 help_msg = True , suffix = self ._status_suffix , counter = ''
20752075 )
20762076
2077- def removeStation (self ):
2077+ def _ask_to_remove_station (self ):
20782078 if self ._cnf .confirm_station_deletion and not self ._cnf .is_register :
20792079 if self ._cnf .locked :
20802080 txt = '''
@@ -2103,7 +2103,7 @@ def removeStation(self):
21032103 prompt = '' , is_message = True )
21042104 else :
21052105 self .ws .operation_mode = self .ws .REMOVE_STATION_MODE
2106- curses . ungetch ( 'y' )
2106+ self . _remove_station ( )
21072107
21082108 def saveCurrentPlaylist (self , stationFile = '' ):
21092109 ret = self ._cnf .save_playlist_file (stationFile )
@@ -4078,6 +4078,7 @@ def _align_stations_and_refresh(self,
40784078 self .stopPlayer ()
40794079 self .playing , self .selection , self .stations , \
40804080 self .number_of_items = (- 1 , 0 , 0 , 0 )
4081+ self .refreshBody ()
40814082 return
40824083 else :
40834084 #if logger.isEnabledFor(logging.DEBUG):
@@ -4094,10 +4095,10 @@ def _align_stations_and_refresh(self,
40944095 self .playing -= 1
40954096 else :
40964097 self .playing = - 1
4097-
40984098 if self .selection > self .number_of_items - self .bodyMaxY :
40994099 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 :
41014102 self .selection -= 1
41024103 if self .startPos < 0 :
41034104 self .startPos = 0
@@ -4164,7 +4165,8 @@ def _align_stations_and_refresh(self,
41644165 self .selection = 0
41654166 self .startPos = 0
41664167 ''' 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 )
41684170
41694171 if logger .isEnabledFor (logging .DEBUG ):
41704172 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):
60876089 is_message = True
60886090 )
60896091
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+
60906117 def keypress (self , char ):
60916118 if char == curses .KEY_F2 :
60926119 self ._need_to_update_stations_csv = 2
@@ -7872,27 +7899,7 @@ def keypress(self, char):
78727899 self ._global_functions [char ]()
78737900 return
78747901 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 )
78967903 else :
78977904 if logger .isEnabledFor (logging .DEBUG ):
78987905 logger .debug ('Canceling: Remove station' )
@@ -8348,7 +8355,7 @@ def keypress(self, char):
83488355 callback_function = self .refreshBody )
83498356 pass
83508357 else :
8351- self .removeStation ()
8358+ self ._ask_to_remove_station ()
83528359 return
83538360
83548361 elif char in (ord ('s' ), ):
0 commit comments