Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/menu/text_input.py
blob: 05ca0f2226c9b1b44086aa9e073c6dc4b8dcf09b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import readline


class TextInput:
	def __init__(self, prompt: str, prefilled_text=''):
		self._prompt = prompt
		self._prefilled_text = prefilled_text

	def _hook(self):
		readline.insert_text(self._prefilled_text)
		readline.redisplay()

	def run(self) -> str:
		readline.set_pre_input_hook(self._hook)
		result = input(self._prompt)
		readline.set_pre_input_hook()
		return result