Improved help message display on small terminal windows

This commit is contained in:
Michael Lazar
2015-04-05 17:36:42 -07:00
parent 9ee21fe1ce
commit 0aa40f7f14
2 changed files with 8 additions and 10 deletions

View File

@@ -38,10 +38,10 @@ def show_notification(stdscr, message):
box_width = max(map(len, message)) + 2 box_width = max(map(len, message)) + 2
box_height = len(message) + 2 box_height = len(message) + 2
# Make sure the window is large enough to fit the message # Cut off the lines of the message that don't fit on the screen
if (box_width > n_cols) or (box_height > n_rows): box_width = min(box_width, n_cols)
curses.flash() box_height = min(box_height, n_rows)
return message = message[:box_height-2]
s_row = (n_rows - box_height) // 2 s_row = (n_rows - box_height) // 2
s_col = (n_cols - box_width) // 2 s_col = (n_cols - box_width) // 2
@@ -51,7 +51,7 @@ def show_notification(stdscr, message):
window.border() window.border()
for index, line in enumerate(message, start=1): for index, line in enumerate(message, start=1):
window.addstr(index, 1, line) window.addnstr(index, 1, line, box_width - 2)
window.refresh() window.refresh()
ch = stdscr.getch() ch = stdscr.getch()
@@ -67,10 +67,8 @@ def show_help(stdscr):
Overlay a message box with the help screen. Overlay a message box with the help screen.
""" """
curses.endwin() show_notification(stdscr, HELP.splitlines())
print(HELP)
raw_input('Press Enter to continue')
curses.doupdate()
class LoadScreen(object): class LoadScreen(object):

View File

@@ -176,7 +176,7 @@ class BasePage(object):
@BaseController.register('?') @BaseController.register('?')
def help(self): def help(self):
show_help(self.stdscr) show_help(self._content_window)
@BaseController.register(curses.KEY_UP, 'k') @BaseController.register(curses.KEY_UP, 'k')
def move_cursor_up(self): def move_cursor_up(self):