- commit
- 39166f4f5aecef36c2d307b0f119d84daff41b9e
- parent
- afdcc5e3c4ab439bd19e26f7924187f9dcec88bb
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2021-07-17 17:49
use on_submit for playlist set_path
Diffstat
| M | cplay.py | 19 | +++++++++++++------ |
1 files changed, 13 insertions, 6 deletions
diff --git a/cplay.py b/cplay.py
@@ -248,12 +248,14 @@ class Input: 248 248 self.active = False 249 249 self.str = '' 250 250251 -1 def start(self, prompt, on_input, initial=''):-1 251 def start(self, prompt, on_input=None, on_submit=None, initial=''): 252 252 self.str = initial 253 253 self.prompt = prompt 254 254 self.on_input = on_input -1 255 self.on_submit = on_submit 255 256 self.active = True256 -1 self.on_input(self.str)-1 257 if self.on_input: -1 258 self.on_input(self.str) 257 259 258 260 def process_key(self, key): 259 261 if not self.active: @@ -263,6 +265,8 @@ class Input: 263 265 self.active = False 264 266 elif key == '\n': 265 267 self.active = False -1 268 if self.on_submit: -1 269 self.on_submit(self.str) 266 270 elif key == curses.KEY_BACKSPACE: 267 271 self.str = self.str[:-1] 268 272 elif isinstance(key, str): @@ -270,7 +274,8 @@ class Input: 270 274 else: 271 275 self.active = False 272 276 return False273 -1 self.on_input(self.str)-1 277 if self.on_input: -1 278 self.on_input(self.str) 274 279 return True 275 280 276 281 @@ -338,7 +343,7 @@ class List: 338 343 elif key in [curses.KEY_HOME, 'g']: 339 344 self.set_cursor(0) 340 345 elif key == '/':341 -1 app.input.start('/', self.search)-1 346 app.input.start('/', on_input=self.search) 342 347 elif key == chr(19): 343 348 if self.search_str: 344 349 self.search(self.search_str, 1, 1) @@ -452,7 +457,7 @@ class Filelist(List): 452 457 playlist.write() 453 458 self.move_cursor(1) 454 459 elif key == 's':455 -1 app.input.start('search: ', self.filter)-1 460 app.input.start('search: ', on_input=self.filter) 456 461 self.filter(self.rsearch_str) 457 462 elif key == '\n': 458 463 if not self.items: @@ -646,7 +651,9 @@ class Playlist(List): 646 651 self.random = not self.random 647 652 elif key == 'w': 648 653 app.input.start(649 -1 'playlist path: ', self.set_path, self.path or filelist.path-1 654 'playlist path: ', -1 655 on_submit=self.set_path, -1 656 initial=self.path or filelist.path, 650 657 ) 651 658 else: 652 659 return super().process_key(key)