Skip to content

Commit 0d9dd4d

Browse files
committed
now highlights on space
1 parent f9f7f27 commit 0d9dd4d

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

clid/editmeta.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class EditMeta(npy.ActionFormV2):
2525

2626
def __init__(self, *args, **kwags):
2727
super().__init__(*args, **kwags)
28+
self.handlers.update({
29+
'^S': self.h_ok,
30+
'^Q': self.h_cancel
31+
})
32+
2833
self.in_insert_mode = False
2934

3035
def create(self):
@@ -67,11 +72,7 @@ def create(self):
6772
self.nextrely += 2
6873
self.com = self.add(self.TEXTBOX, name='Comment', value=self.meta.comment)
6974

70-
def set_up_handlers(self):
71-
super().set_up_handlers()
72-
self.handlers['^S'] = self.h_ok
73-
self.handlers['^Q'] = self.h_cancel
74-
75+
7576
def resolve_genre(self, num_gen):
7677
"""Convert numerical genre values to readable values. Genre may be
7778
saved as a str of the format '(int)' by applications like EasyTag.

clid/main.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,29 @@ class ClidMultiline(npy.MultiLine):
5656
the screen back to the normal view after a searh has been performed
5757
(the search results will be shown; blank if no matches are found)
5858
59+
Attributes:
60+
space_selected_values(list):
61+
Stores list of files which was selected for batch tagging using <Space>
62+
5963
Note:
6064
self.parent refers to ClidInterface -> class
6165
self.parent.value refers to database.Mp3DataBase -> class
6266
"""
6367

6468
def __init__(self, *args, **kwargs):
6569
super().__init__(*args, **kwargs)
70+
self.handlers.update({
71+
'u': self.h_reload_files,
72+
'2': self.h_switch_to_settings,
73+
curses.ascii.SP: self.h_multi_select,
74+
curses.ascii.ESC: self.h_revert_escape,
75+
})
76+
77+
self.allow_filtering = False # does NOT refer to search invoked with '/'
78+
self.space_selected_values = []
79+
6680
smooth = self.parent.parentApp.settings['smooth_scroll'] # is smooth scroll enabled ?
6781
self.slow_scroll = True if smooth == 'true' else False
68-
self.space_selected_values = [] # stores list of files which was selected for batch tagging using <Space>
6982

7083
def set_status(self, filename):
7184
"""Set the the value of self.parent.wStatus2 with metadata of file under cursor."""
@@ -76,16 +89,6 @@ def get_selected(self):
7689
"""Return the name of file under the cursor line"""
7790
return self.values[self.cursor_line]
7891

79-
def set_up_handlers(self):
80-
super().set_up_handlers()
81-
self.handlers.update({
82-
'u': self.h_reload_files,
83-
'2': self.h_switch_to_settings,
84-
curses.ascii.SP: self.h_multi_select,
85-
curses.ascii.ESC: self.h_revert_escape,
86-
})
87-
88-
8992
def h_reload_files(self, char):
9093
"""Reload files in `music_dir`"""
9194
self.parent.value.load_files_and_set_values()
@@ -150,7 +153,20 @@ def h_select(self, char):
150153
self.parent.parentApp.switchForm("EDIT")
151154

152155
def h_multi_select(self, char):
153-
pass
156+
if self.cursor_line in self.space_selected_values:
157+
self.space_selected_values.remove(self.cursor_line)
158+
else:
159+
self.space_selected_values.append(self.cursor_line)
160+
161+
def _set_line_highlighting(self, line, value_indexer):
162+
if value_indexer in self.space_selected_values:
163+
self.set_is_line_important(line, True) # mark as important
164+
else:
165+
self.set_is_line_important(line, False)
166+
167+
# without this line every file will get highlighted as we go down
168+
self.set_is_line_cursor(line, False)
169+
154170

155171
class ClidInterface(npy.FormMuttActiveTraditional):
156172
"""The main app with the ui.

0 commit comments

Comments
 (0)