Skip to content

Commit e52e51a

Browse files
committed
ABC Assist: selected value is emphasized with an arrow
ABC Assist: selected value is emphasized with an arrow
1 parent b24a6fd commit e52e51a

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

tune_actions.py

+21-12
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def get_columns_for_value(self, context, value, show_value_column, fixed_font=Tr
307307
t = UrlTuple(self.get_action_url(params), desc)
308308
columns.append(t)
309309
else:
310-
columns.append(desc) # self.html_selected_item(context, value, desc)
310+
columns.append(self.html_selected_item(context, value, desc))
311311

312312
return columns
313313

@@ -340,10 +340,9 @@ def get_values_html(self, context):
340340
result = ''
341341
return result
342342

343-
@staticmethod
344-
def html_selected_item(context, value, description):
345-
# if self.is_current_value(context, value):
346-
# return html_enclose('b', description) # to make selected item bold
343+
def html_selected_item(self, context, value, description):
344+
if self.is_current_value(context, value):
345+
return description + ' \u25C4'
347346
return description
348347

349348

@@ -651,7 +650,7 @@ def length_to_fraction(length):
651650

652651
@staticmethod
653652
def is_power2(num):
654-
return ((num & (num - 1)) == 0) and num != 0
653+
return ((num & (num - 1)) == 0) and num > 0
655654

656655
def can_execute(self, context, params=None):
657656
value = params.get('value')
@@ -883,6 +882,9 @@ def abc_mode_to_number(mode, default=None):
883882
mode = mode[:3].lower()
884883
return KeyChangeAction._mode_to_num.get(mode, default)
885884

885+
def is_current_value(self, context, value):
886+
return True
887+
886888

887889
class KeySignatureChangeAction(KeyChangeAction):
888890
values = [
@@ -1029,8 +1031,7 @@ def can_execute(self, context, params=None):
10291031
value = params.get('value')
10301032
if value is None:
10311033
return True
1032-
match = self.get_match(context)
1033-
return match is None or value != match.group('clefname')
1034+
return not self.is_current_value(context, value)
10341035
return False
10351036

10361037
def execute(self, context, params=None):
@@ -1045,6 +1046,10 @@ def execute(self, context, params=None):
10451046
params['value'] = ' clef=' + value
10461047
super(ClefChangeAction, self).execute(context, params)
10471048

1049+
def is_current_value(self, context, value):
1050+
match = self.get_match(context)
1051+
return match and value == match.group('clefname')
1052+
10481053

10491054
class StaffTransposeChangeAction(ValueChangeAction):
10501055
values = [
@@ -1290,24 +1295,28 @@ def __init__(self, keyword):
12901295
url = 'http://moinejf.free.fr/abcm2ps-doc/{0}.xhtml'.format(urllib.parse.quote(keyword))
12911296
super(UrlAction, self).__init__('lookup_abcm2ps', url)
12921297

1293-
12941298
class Abc2MidiUrlAction(UrlAction):
12951299
def __init__(self, keyword):
1296-
url = 'http://ifdo.pugmarks.com/~seymour/runabc/abcguide/abc2midi_body.html#{0}'.format(urllib.parse.quote(keyword))
1300+
url = 'https://abcmidi.sourceforge.io/#{0}'.format(urllib.parse.quote(keyword))
12971301
super(UrlAction, self).__init__('lookup_abc2midi', url)
12981302

1303+
12991304
class AbcStandardUrlAction(UrlAction):
13001305
def __init__(self):
13011306
super(AbcStandardUrlAction, self).__init__('lookup_abc_standard')
13021307

13031308
def get_url(self, context):
1304-
version = context.get_matchgroup('version', '2.1')
1309+
version = self.get_version_from_context(context)
13051310
return 'http://abcnotation.com/wiki/abc:standard:v{0}'.format(version)
13061311

13071312
def can_execute(self, context, params=None):
1308-
version = context.get_matchgroup('version', '2.1')
1313+
version = self.get_version_from_context(context)
13091314
return version.startswith('2.')
13101315

1316+
@staticmethod
1317+
def get_version_from_context(context):
1318+
return context.get_matchgroup('version', '2.1')
1319+
13111320
def get_outer_text(self, context):
13121321
return None
13131322

0 commit comments

Comments
 (0)