def win_init(self):
"""Set initial editor window size parameters, and reset them if window
is resized.
"""
# self.cur_pos is the current y,x position of the cursor relative to
# the visible area of the box
self.cur_pos_y = 0
self.cur_pos_x = 0
# y_offset controls the up-down scrolling feature
self.y_offset = 0
# Position of the cursor relative to the upper left corner of the data
# (self.flattend_text)
self.buffer_idx_y = 0
self.buffer_idx_x = 0
# Make sure requested window size is < available window size
self.max_win_size_y, self.max_win_size_x = self.scr.getmaxyx()
# Keep the input box inside the physical window
self.win_size_y = min(self.win_size_orig_y, self.max_win_size_y)
self.win_size_x = min(self.win_size_orig_x, self.max_win_size_x)
# Validate win_location settings
self.win_location_x = min(max(0, self.max_win_size_x -
self.win_size_x),
self.win_location_orig_x)
self.win_location_y = min(max(0, self.max_win_size_y -
self.win_size_y),
self.win_location_orig_y)
# Adjust max_win_size for different possible offsets
# (e.g. if there is a title and/or a box) and initiate the curses
# screen(s)
self._win_scr_init()
self.title, self.title_help = self._title_init()
self.stdscr.keypad(1)
try:
curses.use_default_colors()
except _curses.error:
pass
if self.pw_mode is True:
try:
curses.curs_set(0)
except _curses.error:
pass
评论列表
文章目录