def help(self):
"""Display help text popup window.
"""
help_txt = (" Save and exit : F2 or Ctrl-x\n"
" (Enter if in single-line entry mode)\n"
" Exit (no save) : F3, Ctrl-c or ESC\n"
" Cursor movement : Arrow keys/Ctrl-f/b/n/p\n"
" Beginning of line : Home/Ctrl-a\n"
" End of line : End/Ctrl-e\n"
" Page Up/Page Down : PgUp/PgDn\n"
" Backspace/Delete : Backspace/Ctrl-h\n"
" Delete current char : Del/Ctrl-d\n"
" Insert line at cursor : Enter\n"
" Paste block of text : Ctrl-v\n"
" Delete to end of line : Ctrl-k\n"
" Delete to BOL : Ctrl-u\n")
help_txt_no = (" Save and exit : F2,F3,ESC,Ctrl-c or Ctrl-x\n"
" Cursor movement : Arrow keys/j-k/Ctrl-n/p\n"
" Page Up/Page Down : J/K/PgUp/PgDn/Ctrl-b/n\n")
if self.edit is False:
help_txt = help_txt_no
txt = help_txt.splitlines()
try:
curses.curs_set(0)
except _curses.error:
pass
lines = len(txt) + 2
cols = max([len(i) for i in txt]) + 2
# Only print help text if the window is big enough
try:
popup = curses.newwin(lines, cols, self.win_location_y,
self.win_location_x)
addstr(popup, 1, 0, "\n".join(txt))
popup.box()
except _curses.error:
pass
else:
while not popup.getch():
pass
finally:
# Turn back on the cursor
if self.pw_mode is False and self.edit is True:
curses.curs_set(1)
# flushinp Needed to prevent spurious F1 characters being written
# to line
curses.flushinp()
self.box_init()
评论列表
文章目录