Skip to content

Commit

Permalink
replace readline with prompt_toolkit
Browse files Browse the repository at this point in the history
  • Loading branch information
toza-mimoza committed Aug 23, 2022
1 parent 8d7a514 commit 9b5a98a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions util/Util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
import os
from .exceptions import IllegalArgumentError
from mutagen import File
import readline

# prompt_toolkit pip package
from prompt_toolkit import prompt
from prompt_toolkit.completion import WordCompleter



class Util:
Expand Down Expand Up @@ -41,14 +45,10 @@ class Util:
]

@staticmethod
def input_with_prefill(prompt, prefill):
def hook():
readline.insert_text(prefill)
readline.redisplay()
readline.set_pre_input_hook(hook)
result = input(prompt)
readline.set_pre_input_hook()
return result
def input_with_prefill(prompt_question, suggestion):
title_completer = WordCompleter([suggestion])
return prompt(prompt_question, completer=title_completer)

@staticmethod
def replace_all(string):
result = string
Expand Down

0 comments on commit 9b5a98a

Please sign in to comment.