(self)
Delete character under cursor and move one space left.
Delete character under cursor and move one space left.
Delete character under cursor and move one space left .
def backspace(self):
        """Delete character under cursor and move one space left.

        """
        line = list(self.text[self.buffer_idx_y])
        if self.cur_pos_x > 0:
            if self.cur_pos_x <= len(line):
                # Just backspace if beyond the end of the actual string
                del line[self.buffer_idx_x - 1]
            self.text[self.buffer_idx_y] = "".join(line)
            self.cur_pos_x -= 1
        elif self.cur_pos_x == 0:
            # If at BOL, move cursor to end of previous line
            # (unless already at top of file)
            # If current or previous line is empty, delete it
            if self.y_offset > 0 or self.cur_pos_y > 0:
                self.cur_pos_x = len(self.text[self.buffer_idx_y - 1])
            if not self.text[self.buffer_idx_y]:
                if len(self.text) > 1:
                    del self.text[self.buffer_idx_y]
            elif not self.text[self.buffer_idx_y - 1]:
                del self.text[self.buffer_idx_y - 1]
            self.up()
        self.buffer_rows = max(self.win_size_y, len(self.text))
        # Makes sure leftover rows are visually cleared if deleting rows from
        # the bottom of the text.
        self.stdscr.clear()

        if self.filebrowser is True:
            self.show = 0
            self.rem = []
            self.cur_dir = ""
def backspace ( self ) : line = list ( self . text [ self . buffer_idx_y ] ) if self . cur_pos_x > 0 : if self . cur_pos_x <= len ( line ) : # Just backspace if beyond the end of the actual string del line [ self . buffer_idx_x - 1 ] self . text [ self . buffer_idx_y ] = "" . join ( line ) self . cur_pos_x -= 1 elif self . cur_pos_x == 0 : # If at BOL, move cursor to end of previous line # (unless already at top of file) # If current or previous line is empty, delete it if self . y_offset > 0 or self . cur_pos_y > 0 : self . cur_pos_x = len ( self . text [ self . buffer_idx_y - 1 ] ) if not self . text [ self . buffer_idx_y ] : if len ( self . text ) > 1 : del self . text [ self . buffer_idx_y ] elif not self . text [ self . buffer_idx_y - 1 ] : del self . text [ self . buffer_idx_y - 1 ] self . up ( ) self . buffer_rows = max ( self . win_size_y , len ( self . text ) ) # Makes sure leftover rows are visually cleared if deleting rows from # the bottom of the text. self . stdscr . clear ( ) if self . filebrowser is True : self . show = 0 self . rem = [ ] self . cur_dir = ""