Skip to content

Commit 2bad70a

Browse files
committed
- version 0.9.3.11.9 - 0.9.3.12-beta9
- adding search support for the Keyboard Config Window
1 parent 9e3f14d commit 2bad70a

10 files changed

+137
-29
lines changed

Changelog

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2025-03-21 s-n-g
2+
* version 0.9.3.11.9 - 0.9.3.12-beta9
3+
* fixing default station selection in the config window
4+
* adding search support for both the config window and the shortcuts window
5+
16
2025-03-19 s-n-g
27
* version 0.9.3.11.8 - 0.9.3.12-beta8
38
* fixing #281 - Favourite list becomes corrupted after adding station

docs/index.html

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

189+
2025-03-21 s-n-g
190+
* version 0.9.3.11.9 - 0.9.3.12-beta9
191+
* fixing default station selection in the config window
192+
* adding search support for both the config window and the shortcuts window
193+
189194
2025-03-19 s-n-g
190195
* version 0.9.3.11.8 - 0.9.3.12-beta8
191196
* fixing #281 - Favourite list becomes corrupted after adding station

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "pyradio"
3-
version = "0.9.3.11.8"
3+
version = "0.9.3.11.9"
44
authors = [
55
{ name="Ben Dowling", email="[email protected]" },
66
{ name="Spiros Georgaras", email="[email protected]" },

pyradio/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
" pyradio -- Console radio player. "
33

4-
version_info = (0, 9, 3, 11, 8)
4+
version_info = (0, 9, 3, 11, 9)
55

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

pyradio/config.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,12 @@ class PyRadioConfig(PyRadioStations):
13661366
''' True if lock file exists '''
13671367
locked = False
13681368

1369+
''' this is used to inhibit opening the search window
1370+
currently used by:
1371+
- PyRadioKeyboardConfig when editing
1372+
'''
1373+
inhibit_search = False
1374+
13691375
_distro = 'None'
13701376
opts = collections.OrderedDict()
13711377
opts['general_title'] = ['General Options', '']
@@ -1385,11 +1391,11 @@ class PyRadioConfig(PyRadioStations):
13851391
opts['connection_timeout'] = ['Connection timeout: ', '10']
13861392
opts['force_http'] = ['Force http connections: ', False]
13871393
opts['buffering'] = ['Buffering (seconds): ', '20']
1388-
opts['mplayer_save_br'] = [' MPlayer auto save br: ', False]
1394+
opts['mplayer_save_br'] = ['MPlayer auto save br: ', False]
13891395
opts['notification'] = ['Notifications', '']
13901396
opts['enable_notifications'] = ['Enable notifications: ', '-1']
1391-
opts['use_station_icon'] = [' Use station icon: ', True]
1392-
opts['remove_station_icons'] = [' Remove cached icons: ', True]
1397+
opts['use_station_icon'] = [' Use station icon: ', True]
1398+
opts['remove_station_icons'] = [' Remove cached icons: ', True]
13931399
opts['clock_title'] = ['Clock', '']
13941400
opts['enable_clock'] = ['Display on startup: ', False]
13951401
opts['time_format'] = ['Time format: ', '1']
@@ -1401,7 +1407,7 @@ class PyRadioConfig(PyRadioStations):
14011407
opts['console_theme'] = ['Console theme: ', 'dark']
14021408
opts['mouse_options'] = ['Mouse Support', '']
14031409
opts['enable_mouse'] = ['Enable mouse support: ', False]
1404-
opts['wheel_adjusts_volume'] = [' Reverse wheel: ', False]
1410+
opts['wheel_adjusts_volume'] = [' Reverse wheel: ', False]
14051411
opts['remote'] = ['Remote Control Server', '']
14061412
opts['remote_control_server_ip'] = ['Server IP: ', 'localhost']
14071413
opts['remote_control_server_port'] = ['Server Port: ', '9998']

pyradio/config_window.py

+58-9
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,13 @@ def selection(self, val):
316316
self.__selection = val
317317
#self.refresh_config_win()
318318

319+
def get_previous_search(self, string):
320+
sel = self.__selection - 1
321+
if sel in self._headers and \
322+
string in list(self._config_options.values())[sel][0].lower():
323+
sel -= 1
324+
return sel
325+
319326
def set_selection(self, sel):
320327
self.selection = sel
321328
self._put_cursor(0)
@@ -3555,6 +3562,9 @@ class PyRadioKeyboardConfig():
35553562
_start = 0
35563563
_selection = 1
35573564

3565+
# titles for search function
3566+
_titles = None
3567+
35583568
message = None
35593569

35603570
def __init__(
@@ -3609,7 +3619,7 @@ def __init__(
36093619
self._list[i][-2] = header_index
36103620
if logger.isEnabledFor(logging.DEBUG):
36113621
for n in self._list:
3612-
logger.debug(f'{n}')
3622+
logger.debug(f'list : {n}')
36133623
'''
36143624
36153625
# do not read keys.json to self._keys_to_classes
@@ -3630,7 +3640,33 @@ def __init__(
36303640
self._keys_to_classes = self._precompute_context_map(self._classes)
36313641
# logger.error(f'{self._keys_to_classes = }')
36323642
self._needs_update = False
3643+
# logger.error('\n\ntitles\n{}\n\n'.format(self.titles()))
3644+
3645+
@property
3646+
def editing(self):
3647+
return self._editing
36333648

3649+
@property
3650+
def selection(self):
3651+
return self._selection
3652+
3653+
@selection.setter
3654+
def selection(self, value):
3655+
self._selection = value
3656+
if self._selection in self._headers:
3657+
self._selection += 1
3658+
3659+
def get_previous_search(self, string):
3660+
sel = self._selection - 1
3661+
if string.lower() in self._list[sel][-1].lower() and \
3662+
sel in self._headers:
3663+
sel -= 1
3664+
return sel
3665+
3666+
def titles(self):
3667+
if self._titles is None:
3668+
self._titles = [x[-1] for x in self._list]
3669+
return self._titles
36343670

36353671
def _precompute_context_map(self, results):
36363672
"""
@@ -3681,17 +3717,18 @@ def _rename_keyboard_json_file(self, file_path):
36813717
return new_file_name
36823718

36833719
def _start_editing(self):
3684-
self.existing_conflict = None
36853720
self._win.addstr(self._selection - self._start + 2, self.maxX-8, '[edit]', curses.color_pair(6))
36863721
self._win.refresh()
36873722
self._editing = True
3723+
self._cnf.inhibit_search = True
36883724
if logger.isEnabledFor(logging.DEBUG):
36893725
logger.debug('editing "{}"'.format(self._list[self._selection]))
36903726

36913727
def _stop_editing(self):
36923728
self._win.addstr(self._selection - self._start + 2, self.maxX-8, ' ', curses.color_pair(6))
36933729
self._win.refresh()
36943730
self._editing = False
3731+
self._cnf.inhibit_search = False
36953732
if logger.isEnabledFor(logging.DEBUG):
36963733
logger.debug('edited "{}"'.format(self._list[self._selection]))
36973734

@@ -3891,6 +3928,10 @@ def _make_selection_visible(self):
38913928
elif chk > self._number_of_lines:
38923929
self._start = max(0, int((self._selection - self._number_of_lines) / 2))
38933930

3931+
def set_selection(self, sel):
3932+
self.selection = sel
3933+
self._go_to_line(self._selection)
3934+
38943935
def _go_to_line(self, a_line):
38953936
self._selection = a_line
38963937
self._make_selection_visible()
@@ -4018,6 +4059,7 @@ def _detect_conflict(self, modified_item):
40184059
"""
40194060
# reset self.existing_conflict ; None means no conflict
40204061
self.existing_conflict = None
4062+
logger.error(f'2 {self.existing_conflict = }')
40214063

40224064
# Extract key and the new shortcut code from the modified item
40234065
key = modified_item[0] # Identifier for the shortcut (e.g., "reload", "mute")
@@ -4059,13 +4101,18 @@ def _detect_conflict(self, modified_item):
40594101
if key_in_context == key:
40604102
continue
40614103

4062-
idx, chk = [(i, x) for i, x in enumerate(self._list) if x[0] == key_in_context][0]
4063-
if logger.isEnabledFor(logging.DEBUG):
4064-
logger.debug('\n\nitem with key - {0}: {1}\n\n'.format(idx, chk))
4065-
# Check if the new shortcut code matches the existing shortcut code for any other key
4066-
if chk[3] == new_shortcut_code:
4067-
self.existing_conflict = (modified_item[-3], idx) # Return the first conflicting key and index
4068-
return
4104+
try:
4105+
idx, chk = [(i, x) for i, x in enumerate(self._list) if x[0] == key_in_context][0]
4106+
if logger.isEnabledFor(logging.DEBUG):
4107+
logger.debug('\n\nitem with key - {}: {}, new_shortcut_code = {}\n\n'.format(idx, chk, new_shortcut_code))
4108+
4109+
# Check if the new shortcut code matches the existing shortcut code for any other key
4110+
if chk[3] == new_shortcut_code:
4111+
self.existing_conflict = (modified_item[-3], idx) # Return the first conflicting key and index
4112+
logger.debug(f'{self.existing_conflict = }')
4113+
return
4114+
except IndexError:
4115+
pass
40694116

40704117
if logger.isEnabledFor(logging.DEBUG):
40714118
logger.debug('\n-*-*-*-*-*-*-*-*- None 2\n\n')
@@ -4143,8 +4190,10 @@ def keypress(self, char):
41434190
l_char = None
41444191
self._needs_update = False
41454192
if char == ord('0'):
4193+
logger.error(f'{self.existing_conflict = }')
41464194
if self.existing_conflict:
41474195
self._editing = False
4196+
self._cnf.inhibit_search = False
41484197
if self._selection == self.existing_conflict[0]:
41494198
self._go_to_line(self.existing_conflict[1])
41504199
else:

pyradio/install.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
''' This is PyRadio version this
1818
install.py was released for
1919
'''
20-
PyRadioInstallPyReleaseVersion = '0.9.3.11.8'
20+
PyRadioInstallPyReleaseVersion = '0.9.3.11.9'
2121

2222
locale.setlocale(locale.LC_ALL, "")
2323

pyradio/messages_system.py

+2
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,7 @@ def set_text(self, parent, *args):
854854
{g}|, |Home| / |{G}|, |End |*| Jump to first / last option.
855855
Enter|, |{pause}|, |Right|, |{l} |*| Change option value.
856856
{revert_saved} |*| Revert to saved values.
857+
{search} |/ |{search_next}| / |{search_prev} |*| Search, go to next / previous result.
857858
{revert_def} |*| Load default values.
858859
{s} |*| Save config.
859860
Esc|, |{q}|, |Left|, |{h} |*| Cancel.
@@ -1480,6 +1481,7 @@ def set_text(self, parent, *args):
14801481
__|Tab|, |{tab}| / |Sh-Tab|, |{stab}| |*| Move to next / previous field.
14811482
__|{g}| / |{G}| |*| Go to top / bottom of the list.
14821483
__|[| / |]| |*| Move between sections.
1484+
__{search} |/ |{search_next}| / |{search_prev} |*| Search, go to next / previous result.
14831485
__|{revert_def}| / |{revert_saved}| |*| Revert to default / saved shortcuts.
14841486
__|x| |*| Revert current item to saved value.
14851487
__|f| |*| Show |free| keys.

0 commit comments

Comments
 (0)