def _run(self, stdscr):
		c, self.c_stdscr = self.c, stdscr
		key_match = lambda key,*choices: key in map(self.c_key, choices)

		c.curs_set(0)
		c.use_default_colors()

		win = self.c_win_init()
		self.conf.adjust_step /= 100.0

		while True:
			try:
				# XXX: full refresh on every keypress is a bit excessive
				items, item_hl = self.menu.item_list, self.item_hl
				if item_hl is None: item_hl = self.item_hl = self.menu.item_default()
				if item_hl not in items: item_hl = self.menu.item_default()
				self.c_win_draw(win, items, item_hl)
			except PAMixerDBusError as err:
				if err.args[0] == 'org.freedesktop.DBus.Error.UnknownMethod': continue
				raise # XXX: check all the old pitfalls here

			watchdog_handle_ping()
			key = None
			while True:
				try: key = win.getch()
				except KeyboardInterrupt: key = self.c_key('q')
				except c.error: break
				try: key_name = c.keyname(key)
				except __HOLE__:
					key_name = 'unknown' # e.g. "-1"
					if watchdog_handle_ping():
						assert win.getch() == -1 # no idea why
						continue
				break
			if key is None: continue
			log.debug('Keypress event: %s (%r)', key, key_name)

			if item_hl:
				if key_match(key, 'up', 'k', 'p'): self.item_hl = item_hl.get_prev()
				elif key_match(key, 'down', 'j', 'n'): self.item_hl = item_hl.get_next()
				elif key_match(key, 'left', 'h', 'b'):
					item_hl.volume_change(-self.conf.adjust_step)
				elif key_match(key, 'right', 'l', 'f'): item_hl.volume_change(self.conf.adjust_step)
				elif key_match(key, ' ', 'm'): item_hl.muted_toggle()
				elif key_name.isdigit(): # 1-0 keyboard row
					item_hl.volume = (float(key_name) or 10.0) / 10 # 0 is 100%

			if key_match(key, 'resize', '\f'):
				if self.conf.overkill_redraw:
					c.endwin()
					stdscr.refresh()
					win = self.c_win_init()
				else:
					win.resize(*win.getmaxyx())
			elif key_match(key, 'q'): break
dataset/ETHPy150Open mk-fg/pulseaudio-mixer-cli/pa-mixer-mk2.py/PAMixerUI._run