(self)
Set initial editor window size parameters, and reset them if window
        is resized.
Set initial editor window size parameters, and reset them if window
        is resized.
Set initial editor window size parameters and reset them if window is resized .
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
        self.cur_pos_y = 0
        self.cur_pos_x = 0
        # y_offset controls the up-down scrolling feature
        self.x_offset = 0
        self.y_offset = 0
        self.buffer_idx_y = 0
        self.buffer_idx_x = 0
        # Adjust win_size if resizing
        if self.resize_flag is True:
            self.win_size_x += 1
            self.win_size_y += 1
            self.resize_flag = False
        # Make sure requested window size is < available window size
        self.max_win_size_y, self.max_win_size_x = self.scr.getmaxyx()
        # Adjust max_win_size for maximum possible offsets
        # (e.g. if there is a title and a box)
        self.max_win_size_y = max(0, self.max_win_size_y - 4)
        self.max_win_size_x = max(0, self.max_win_size_x - 3)
        # Keep the input box inside the physical window
        if (self.win_size_y > self.max_win_size_y or
                self.win_size_y < self.win_size_orig_y):
            self.win_size_y = self.max_win_size_y
        if (self.win_size_x > self.max_win_size_x or
                self.win_size_x < self.win_size_orig_x):
            self.win_size_x = self.max_win_size_x
        # Reduce win_size by 1 to account for position starting at 0 instead of
        # 1. E.g. if size=80, then the max size should be 79 (0-79).
        self.win_size_y -= 1
        self.win_size_x -= 1
        # Validate win_location settings
        if self.win_size_x + self.win_location_x >= self.max_win_size_x:
            self.win_location_x = max(0, self.max_win_size_x -
                                      self.win_size_x)
        if self.win_size_y + self.win_location_y >= self.max_win_size_y:
            self.win_location_y = max(0, self.max_win_size_y -
                                      self.win_size_y)
        # Create an extra window for the box outline and/or title, if required
        x_off = y_off = loc_off_y = loc_off_x = 0
        if self.box:
            y_off += 3
            x_off += 2
            loc_off_y += 1
            loc_off_x += 1
        if self.title:
            y_off += 1
            loc_off_y += 1
        if self.box is True or self.title:
            # Make box/title screen bigger than actual text area (stdscr)
            self.boxscr = self.scr.subwin(self.win_size_y + y_off,
                                          self.win_size_x + x_off,
                                          self.win_location_y,
                                          self.win_location_x)
            self.stdscr = self.boxscr.subwin(self.win_size_y,
                                             self.win_size_x,
                                             self.win_location_y + loc_off_y,
                                             self.win_location_x + loc_off_x)
        else:
            self.stdscr = self.scr.subwin(self.win_size_y,
                                          self.win_size_x,
                                          self.win_location_y,
                                          self.win_location_x)
        self.stdscr.keypad(1)
def win_init ( self ) : # self.cur_pos is the current y,x position of the cursor self . cur_pos_y = 0 self . cur_pos_x = 0 # y_offset controls the up-down scrolling feature self . x_offset = 0 self . y_offset = 0 self . buffer_idx_y = 0 self . buffer_idx_x = 0 # Adjust win_size if resizing if self . resize_flag is True : self . win_size_x += 1 self . win_size_y += 1 self . resize_flag = False # Make sure requested window size is < available window size self . max_win_size_y , self . max_win_size_x = self . scr . getmaxyx ( ) # Adjust max_win_size for maximum possible offsets # (e.g. if there is a title and a box) self . max_win_size_y = max ( 0 , self . max_win_size_y - 4 ) self . max_win_size_x = max ( 0 , self . max_win_size_x - 3 ) # Keep the input box inside the physical window if ( self . win_size_y > self . max_win_size_y or self . win_size_y < self . win_size_orig_y ) : self . win_size_y = self . max_win_size_y if ( self . win_size_x > self . max_win_size_x or self . win_size_x < self . win_size_orig_x ) : self . win_size_x = self . max_win_size_x # Reduce win_size by 1 to account for position starting at 0 instead of # 1. E.g. if size=80, then the max size should be 79 (0-79). self . win_size_y -= 1 self . win_size_x -= 1 # Validate win_location settings if self . win_size_x + self . win_location_x >= self . max_win_size_x : self . win_location_x = max ( 0 , self . max_win_size_x - self . win_size_x ) if self . win_size_y + self . win_location_y >= self . max_win_size_y : self . win_location_y = max ( 0 , self . max_win_size_y - self . win_size_y ) # Create an extra window for the box outline and/or title, if required x_off = y_off = loc_off_y = loc_off_x = 0 if self . box : y_off += 3 x_off += 2 loc_off_y += 1 loc_off_x += 1 if self . title : y_off += 1 loc_off_y += 1 if self . box is True or self . title : # Make box/title screen bigger than actual text area (stdscr) self . boxscr = self . scr . subwin ( self . win_size_y + y_off , self . win_size_x + x_off , self . win_location_y , self . win_location_x ) self . stdscr = self . boxscr . subwin ( self . win_size_y , self . win_size_x , self . win_location_y + loc_off_y , self . win_location_x + loc_off_x ) else : self . stdscr = self . scr . subwin ( self . win_size_y , self . win_size_x , self . win_location_y , self . win_location_x ) self . stdscr . keypad ( 1 )