in src/pathpicker/screen_control.py [0:0]
def show_and_get_command(self) -> str:
path_objs = self.get_paths_to_use()
paths = [path_obj.get_path() for path_obj in path_objs]
max_y, max_x = self.get_screen_dimensions()
# Alright this is a bit tricky -- for tall screens, we try to aim
# the command prompt right at the middle of the screen so you don't
# have to shift your eyes down or up a bunch
begin_height = int(round(max_y / 2) - len(paths) / 2.0)
# but if you have a TON of paths, we are going to start printing
# way off screen. in this case lets just slap the prompt
# at the bottom so we can fit as much as possible.
#
# There could better option here to slowly increase the prompt
# height to the bottom, but this is good enough for now...
if begin_height <= 1:
begin_height = max_y - 6
border_line = "=" * len(SHORT_COMMAND_PROMPT)
prompt_line = "." * len(SHORT_COMMAND_PROMPT)
# from helper chrome code
max_path_length = max_x - 5
if self.helper_chrome.get_is_sidebar_mode():
# need to be shorter to not go into side bar
max_path_length = len(SHORT_COMMAND_PROMPT) + 18
# first lets print all the paths
start_height = begin_height - 1 - len(paths)
try:
self.color_printer.addstr(start_height - 3, 0, border_line)
self.color_printer.addstr(start_height - 2, 0, SHORT_PATHS_HEADER)
self.color_printer.addstr(start_height - 1, 0, border_line)
except curses.error:
pass
for index, path in enumerate(paths):
try:
self.color_printer.addstr(
start_height + index, 0, path[0:max_path_length]
)
except curses.error:
pass
# first print prompt
try:
self.color_printer.addstr(begin_height, 0, SHORT_COMMAND_PROMPT)
self.color_printer.addstr(begin_height + 1, 0, SHORT_COMMAND_PROMPT2)
except curses.error:
pass
# then line to distinguish and prompt line
try:
self.color_printer.addstr(begin_height - 1, 0, border_line)
self.color_printer.addstr(begin_height + 2, 0, border_line)
self.color_printer.addstr(begin_height + 3, 0, prompt_line)
except curses.error:
pass
self.stdscr.refresh()
self.curses_api.echo()
max_x = int(round(max_x - 1))
return self.stdscr.getstr(begin_height + 3, 0, max_x)