コード例 #1
0
 def insert_char(self, key):
     ch = key.encode('utf-8')
     self.display.print_in_statusline(40, '[{}]'.format(ch), 10)
     index = self.cursor.x
     insert_element(self.lines[self.cursor.y], index,
                    Char(key, curses.A_NORMAL))
     self.cursor_right('@')
     self.rescan()
     self.cursor_and_viewport_adjustement()
コード例 #2
0
 def shift(self, right=True):
     ''' Shift right/left n spaces (tab size) or a tab character '''
     # ch = ' '.encode('utf-8')
     x = 0
     if self.visual_cursor is not None:
         first_line, last_line = self.get_visual_range()
         r = range(first_line, last_line + 1)
         # Reset visual selection
         self.set_visual()
     else:
         r = [self.cursor.y]
     if right:
         for y in r:
             line = self.lines[y]
             if len(line) == 0:
                 continue        # Do not shift empty lines
             for times in range(4):
                 insert_element(self.lines[y], x,
                                Char(u' ', curses.A_NORMAL))
             # TODO: Use tabs when specified
     else:
         for y in r:
             line = self.lines[y]
             if len(line) == 0:
                 continue
             if line[0].ch == u'\t':
                 # There is a tab to delete, stop here
                 self.cursor.x = 0
                 self.cursor.y = y
                 self.delete_char_at_cursor('@')
                 self.move_to_first_non_blank('^')
                 continue
             mx = 0
             for n in range(len(line)):
                 char = line[n]
                 if char.ch != u' ':
                     mx = n
                     break
             if mx >= 4:                 # TODO: use tab size instead of 4
                 self.cursor.x = 0
                 self.cursor.y = y
                 self.delete_char_at_cursor('@')  # This deletes 4
                 self.move_to_first_non_blank('^')
コード例 #3
0
 def status_insert(self, key):
     if key == -1:
         return
     insert_element(self.display.status, self.sx,
                    Char(key, curses.A_NORMAL))
     self.status_right('@')