Skip to content

Commit d432d76

Browse files
committed
- version 0.8.9.25 (0.9-beta22)
- fixing global shorcuts inside RadioBrowser search window (as per #164)
1 parent 30f8581 commit d432d76

File tree

5 files changed

+70
-12
lines changed

5 files changed

+70
-12
lines changed

Changelog

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2022-08-14 s-n-g
2+
* version 0.8.9.25 (0.9-beta22)
3+
* fixing global shorcuts inside RadioBrowser search window
4+
(as per #164)
5+
16
2022-08-12 s-n-g
27
* version 0.8.9.24 (0.9-beta21)
38
* fixing several theme issues (exchanging cursors background color

README.html

+5
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ <h2 id="requirements">Requirements <span style="padding-left: 10px;"><sup style=
174174
<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>
175175
<pre style="height: 200px;">
176176

177+
2022-08-14 s-n-g
178+
* version 0.8.9.25 (0.9-beta22)
179+
* fixing global shorcuts inside RadioBrowser search window
180+
(as per #164)
181+
177182
2022-08-12 s-n-g
178183
* version 0.8.9.24 (0.9-beta21)
179184
* fixing several theme issues (exchanging cursors background color

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

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

pyradio/browser.py

+53-7
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,9 @@ def read_config(self):
15291529
except:
15301530
if logger.isEnabledFor(logging.ERROR):
15311531
logger.error('RadioBrowser: error inserting serch item id {}'.format(n))
1532+
if 'limit' in self.terms[-1]['post_data'].keys():
1533+
if self.terms[-1]['post_data']['limit'] == str(self.limit):
1534+
self.terms[-1]['post_data'].pop('limit')
15321535
else:
15331536
if logger.isEnabledFor(logging.DEBUG):
15341537
logger.debug('RadioBrowser: no search terms found, reverting to defaults')
@@ -2289,6 +2292,8 @@ class RadioBrowserSearchWindow(object):
22892292

22902293
_global_functions = {}
22912294

2295+
_backslash_pressed = False
2296+
22922297
def __init__(self,
22932298
parent,
22942299
config,
@@ -2502,6 +2507,8 @@ def _widgets_to_search_term(self):
25022507
''' get limit (term)'''
25032508
if self._widgets[-self.NUMBER_OF_WIDGETS_AFTER_SEARCH_SECTION].value != self._default_limit:
25042509
ret['post_data']['limit'] = str(self._widgets[-self.NUMBER_OF_WIDGETS_AFTER_SEARCH_SECTION].value)
2510+
# else:
2511+
# ret['post_data']['limit'] = str(self._default_limit)
25052512

25062513
''' get order '''
25072514
self._order_to_term(ret)
@@ -2917,28 +2924,28 @@ def _get_search_term_index(self, new_search_term):
29172924
''' search for a search term in history
29182925
29192926
if found return True, index
2920-
if not found return False, len(self._history) - 1
2921-
and append the search term in the history
2927+
if not found return False, len(self._history) - 1
2928+
and append the search term in the history
29222929
'''
29232930
found = False
29242931
for a_search_term_index, a_search_term in enumerate(self._history):
29252932
if new_search_term == a_search_term:
29262933
# self._history_id = self._selected_history_id
2927-
index = a_search_term_index
2934+
ret_index = a_search_term_index
29282935
found = True
29292936
if logger.isEnabledFor(logging.DEBUG):
2930-
logger.debug('New search term already in history, id = {}'.format(self._selected_history_id))
2937+
logger.debug('New search term already in history, id = {}'.format(ret_index))
29312938
break
29322939

29332940
if not found:
29342941
if logger.isEnabledFor(logging.DEBUG):
29352942
logger.debug('Adding new search term to history, id = {}'.format(len(self._history)))
29362943
self._history.append(new_search_term)
29372944
# self._history_id = self._selected_history_id = len(self._history) - 1
2938-
index = len(self._history) - 1
2945+
ret_index = len(self._history) - 1
29392946
self._cnf.dirty = True
29402947

2941-
return found, index
2948+
return found, ret_index
29422949

29432950
def _goto_first_history_item(self):
29442951
self._handle_new_or_existing_search_term()
@@ -2971,6 +2978,7 @@ def _jump_history_down(self):
29712978
def _ctrl_n(self):
29722979
''' ^N - Next history item '''
29732980
cur_history_id = self._selected_history_id
2981+
logger.error('cur_history_id = {}'.format(cur_history_id))
29742982
self._handle_new_or_existing_search_term()
29752983
if abs(self._selected_history_id - cur_history_id) > 1:
29762984
self._selected_history_id = cur_history_id
@@ -3055,29 +3063,36 @@ def keypress(self, char):
30553063
return -1
30563064

30573065
if self._too_small:
3066+
self._backslash_pressed = False
30583067
return 1
30593068

30603069
class_name = type(self._widgets[self._focus]).__name__
30613070

30623071
if char == ord('0') and \
30633072
type(self._widgets[self._focus]).__name__ != 'SimpleCursesLineEdit':
30643073
self._goto_first_history_item()
3074+
self._backslash_pressed = False
30653075

30663076
elif char == ord('$') and \
30673077
type(self._widgets[self._focus]).__name__ != 'SimpleCursesLineEdit':
30683078
self._goto_last_history_item()
3079+
self._backslash_pressed = False
30693080

30703081
elif char in (curses.KEY_PPAGE, ) and self._focus != len(self._widgets) -3:
30713082
self._jump_history_up()
3083+
self._backslash_pressed = False
30723084

30733085
elif char in (curses.KEY_NPAGE, ) and self._focus != len(self._widgets) -3:
30743086
self._jump_history_down()
3087+
self._backslash_pressed = False
30753088

30763089
elif char in (ord('\t'), 9):
30773090
self._focus_next()
3091+
self._backslash_pressed = False
30783092

30793093
elif char in (curses.KEY_BTAB, ):
30803094
self._focus_previous()
3095+
self._backslash_pressed = False
30813096

30823097
elif char in (ord(' '), curses.KEY_ENTER, ord('\n'),
30833098
ord('\r')) and self._focus == len(self._widgets) - 1:
@@ -3087,39 +3102,47 @@ def keypress(self, char):
30873102
elif char in (ord(' '), curses.KEY_ENTER, ord('\n'),
30883103
ord('\r')) and self._focus == len(self._widgets) - 2:
30893104
''' enter on ok button '''
3105+
self._backslash_pressed = False
30903106
ret = self._handle_new_or_existing_search_term()
30913107
return 0 if ret == 1 else ret
30923108

30933109
elif char in (curses.ascii.SO, ):
30943110
''' ^N - Next history item '''
30953111
self._ctrl_n()
3112+
self._backslash_pressed = False
30963113

30973114
elif char in (curses.ascii.DLE, ):
30983115
''' ^P - Previous history item '''
30993116
self._ctrl_p()
3117+
self._backslash_pressed = False
31003118

31013119
# elif char in (curses.ascii.ETB, ):
31023120
elif char in (curses.ascii.ENQ, ):
31033121
''' ^E - Save search history '''
3122+
self._backslash_pressed = False
31043123
self._handle_new_or_existing_search_term()
31053124
''' Save search history '''
31063125
return 5
31073126

31083127
elif char in (curses.ascii.EM, ):
31093128
''' ^Y - Add history item '''
31103129
self._handle_new_or_existing_search_term()
3130+
self._backslash_pressed = False
31113131

31123132
elif char in (curses.ascii.CAN, ):
31133133
''' ^X - Delete history item '''
31143134
self._ctrl_x()
3135+
self._backslash_pressed = False
31153136

31163137
elif char in (curses.ascii.STX, ):
31173138
''' ^B - Set default item '''
31183139
self._ctrl_b()
3140+
self._backslash_pressed = False
31193141

31203142
elif char in (curses.ascii.ACK, ):
31213143
''' ^F - Go to template (item 0) '''
31223144
self._ctrl_f()
3145+
self._backslash_pressed = False
31233146

31243147
else:
31253148
if class_name == 'SimpleCursesWidgetColumns':
@@ -3130,8 +3153,10 @@ def keypress(self, char):
31303153
elif ret == 2:
31313154
# cursor moved
31323155
self._win.refresh()
3156+
self._backslash_pressed = False
31333157

31343158
elif self._focus in self._checkbox_to_enable_widgets:
3159+
self._backslash_pressed = False
31353160
ret = self._widgets[self._focus].keypress(char)
31363161
if not ret:
31373162
tp = list(self._checkbox_to_enable_widgets)
@@ -3143,17 +3168,37 @@ def keypress(self, char):
31433168
return 1
31443169

31453170
elif class_name == 'SimpleCursesCheckBox':
3171+
self._backslash_pressed = False
31463172
ret = self._widgets[self._focus].keypress(char)
31473173
if not ret:
31483174
return 1
31493175

31503176
elif class_name == 'SimpleCursesCounter':
3177+
self._backslash_pressed = False
31513178
ret = self._widgets[self._focus].keypress(char)
31523179
if ret == 0:
31533180
self._win.refresh()
31543181
return 1
31553182

31563183
elif class_name == 'SimpleCursesLineEdit':
3184+
if char == ord('\\'):
3185+
self._backslash_pressed = True
3186+
# return 1
3187+
3188+
if self._backslash_pressed:
3189+
if char in self._global_functions.keys():
3190+
self._backslash_pressed = False
3191+
self._global_functions[char]()
3192+
return 1
3193+
elif char == ord('0'):
3194+
self._backslash_pressed = False
3195+
self._goto_first_history_item()
3196+
return 1
3197+
elif char == ord('$'):
3198+
self._backslash_pressed = False
3199+
self._goto_last_history_item()
3200+
return 1
3201+
31573202
ret = self._widgets[self._focus].keypress(self._win, char)
31583203
if ret == -1:
31593204
# Cancel
@@ -3164,6 +3209,7 @@ def keypress(self, char):
31643209
elif ret < 2:
31653210
return 1
31663211

3212+
self._backslash_pressed = False
31673213
if char in (ord('s'), ):
31683214
''' prerform search '''
31693215
ret = self._handle_new_or_existing_search_term()
@@ -3243,7 +3289,7 @@ def keypress(self, char):
32433289
return 1
32443290

32453291
def _handle_new_or_existing_search_term(self):
3246-
''' read alla widgets and create a search term
3292+
''' read all widgets and create a search term
32473293
if it does not exist add it to history
32483294
'''
32493295
test_search_term = self._widgets_to_search_term()

pyradio/radio.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -6067,11 +6067,13 @@ def keypress(self, char):
60676067
''' browser config save canceled '''
60686068
self._exit_browser_config()
60696069

6070-
elif self.ws.operation_mode == self.ws.BROWSER_SEARCH_MODE and \
6071-
(char not in self._chars_to_bypass_on_editor or \
6072-
self._cnf._online_browser.line_editor_has_focus()):
6070+
# elif self.ws.operation_mode == self.ws.BROWSER_SEARCH_MODE and \
6071+
# (char not in self._chars_to_bypass_on_editor or \
6072+
# self._cnf._online_browser.line_editor_has_focus()):
6073+
elif self.ws.operation_mode == self.ws.BROWSER_SEARCH_MODE:
60736074

6074-
if char in self._global_functions.keys():
6075+
if char in self._global_functions.keys() and \
6076+
not self._cnf._online_browser.line_editor_has_focus():
60756077
self._global_functions[char]()
60766078
return
60776079

0 commit comments

Comments
 (0)