(self, c)
Given a curses wide character, insert that character in the current
        line. Stop when the maximum line length is reached.
Given a curses wide character, insert that character in the current
        line. Stop when the maximum line length is reached.
Given a curses wide character insert that character in the current line . Stop when the maximum line length is reached .
def insert_char(self, c):
        """Given a curses wide character, insert that character in the current
        line. Stop when the maximum line length is reached.

        """
        # Skip non-handled special characters (get_wch returns int value for
        # certain special characters)
        if isinstance(c, int):
            return
        line = list(self.text[self.buffer_idx_y])
        line.insert(self.buffer_idx_x, c)
        if len(line) < self.win_size_x:
            if self.filebrowser is True:
                self.show = 0
                self.rem = []
                self.cur_dir = ""
                if c == "~":
                    line = line[:-1]
                    line.insert(self.buffer_idx_x, expanduser("~/"))
                    self.text[self.buffer_idx_y] = "".join(line)
                    self.cur_pos_x += len(expanduser("~/"))
                    self.x_offset = max(0, (len(self.text[self.buffer_idx_y])
                                            - self.win_size_x) + 1)
                else:
                    self.text[self.buffer_idx_y] = "".join(line)
                    self.cur_pos_x += 1
            else:
                self.text[self.buffer_idx_y] = "".join(line)
                self.cur_pos_x += 1
        elif self.max_text_size == 1:
            if self.filebrowser is True:
                self.show = 0
                self.rem = []
                self.cur_dir = ""
                if c == "~":
                    line = line[:-1]
                    line.insert(self.buffer_idx_x, expanduser("~/"))
                    self.text[self.buffer_idx_y] = "".join(line)
                    self.cur_pos_x += len(expanduser("~/"))
                    self.x_offset += len(expanduser("~/"))
                else:
                    self.text[self.buffer_idx_y] = "".join(line)
                    self.cur_pos_x += 1
                    self.x_offset += 1            
            else:
                self.text[self.buffer_idx_y] = "".join(line)
                self.cur_pos_x += 1
                self.x_offset += 1            
        else:
            if self.cur_pos_y < len(self.text) - 1:
                nline = self.text[self.cur_pos_y + 1]
            if len(self.text) != self.max_text_size:
                if self.cur_pos_y < len(self.text) - 1:
                    self.text[self.cur_pos_y] = "".join(line[:-1])
                    self.text[self.cur_pos_y + 1] = ("".join(line[-1:])) + nline
                    self.text_init("".join(self.text))
                else:
                    self.text[self.cur_pos_y] = "".join(line[:-1])
                    self.text.insert(self.cur_pos_y + 1, "".join(line[-1:]))
                if self.cur_pos_x < self.win_size_x - 2:
                    self.cur_pos_x += 1
                else:
                    self.down()
                    self.cur_pos_x = 1
                self.buffer_rows = max(self.win_size_y, len(self.text))
def insert_char ( self , c ) : # Skip non-handled special characters (get_wch returns int value for # certain special characters) if isinstance ( c , int ) : return line = list ( self . text [ self . buffer_idx_y ] ) line . insert ( self . buffer_idx_x , c ) if len ( line ) < self . win_size_x : if self . filebrowser is True : self . show = 0 self . rem = [ ] self . cur_dir = "" if c == "~" : line = line [ : - 1 ] line . insert ( self . buffer_idx_x , expanduser ( "~/" ) ) self . text [ self . buffer_idx_y ] = "" . join ( line ) self . cur_pos_x += len ( expanduser ( "~/" ) ) self . x_offset = max ( 0 , ( len ( self . text [ self . buffer_idx_y ] ) - self . win_size_x ) + 1 ) else : self . text [ self . buffer_idx_y ] = "" . join ( line ) self . cur_pos_x += 1 else : self . text [ self . buffer_idx_y ] = "" . join ( line ) self . cur_pos_x += 1 elif self . max_text_size == 1 : if self . filebrowser is True : self . show = 0 self . rem = [ ] self . cur_dir = "" if c == "~" : line = line [ : - 1 ] line . insert ( self . buffer_idx_x , expanduser ( "~/" ) ) self . text [ self . buffer_idx_y ] = "" . join ( line ) self . cur_pos_x += len ( expanduser ( "~/" ) ) self . x_offset += len ( expanduser ( "~/" ) ) else : self . text [ self . buffer_idx_y ] = "" . join ( line ) self . cur_pos_x += 1 self . x_offset += 1 else : self . text [ self . buffer_idx_y ] = "" . join ( line ) self . cur_pos_x += 1 self . x_offset += 1 else : if self . cur_pos_y < len ( self . text ) - 1 : nline = self . text [ self . cur_pos_y + 1 ] if len ( self . text ) != self . max_text_size : if self . cur_pos_y < len ( self . text ) - 1 : self . text [ self . cur_pos_y ] = "" . join ( line [ : - 1 ] ) self . text [ self . cur_pos_y + 1 ] = ( "" . join ( line [ - 1 : ] ) ) + nline self . text_init ( "" . join ( self . text ) ) else : self . text [ self . cur_pos_y ] = "" . join ( line [ : - 1 ] ) self . text . insert ( self . cur_pos_y + 1 , "" . join ( line [ - 1 : ] ) ) if self . cur_pos_x < self . win_size_x - 2 : self . cur_pos_x += 1 else : self . down ( ) self . cur_pos_x = 1 self . buffer_rows = max ( self . win_size_y , len ( self . text ) )