Example #1
0
	def move(self, **keywords):
		direction = Direction(keywords)
		if direction.horizontal():
			# Ensure that the pointer is moved utf-char-wise
			uc = uchars(self.line)
			upos = len(uchars(self.line[:self.pos]))
			newupos = direction.move(
					direction=direction.right(),
					minimum=0,
					maximum=len(uc) + 1,
					current=upos)
			self.pos = len(''.join(uc[:newupos]))
Example #2
0
	def delete(self, mod):
		self.tab_deque = None
		if mod == -1 and self.pos == 0:
			if not self.line:
				self.close()
			return
		# Delete utf-char-wise
		uc = uchars(self.line)
		upos = len(uchars(self.line[:self.pos])) + mod
		left_part = ''.join(uc[:upos])
		self.pos = len(left_part)
		self.line = left_part + ''.join(uc[upos+1:])
		self.on_line_change()
Example #3
0
 def move(self, **keywords):
     direction = Direction(keywords)
     if direction.horizontal():
         # Ensure that the pointer is moved utf-char-wise
         if self.fm.py3:
             self.pos = direction.move(direction=direction.right(),
                                       minimum=0,
                                       maximum=len(self.line) + 1,
                                       current=self.pos)
         else:
             uc = uchars(self.line)
             upos = len(uchars(self.line[:self.pos]))
             newupos = direction.move(direction=direction.right(),
                                      minimum=0,
                                      maximum=len(uc) + 1,
                                      current=upos)
             self.pos = len(''.join(uc[:newupos]))
Example #4
0
 def delete(self, mod):
     self.tab_deque = None
     if mod == -1 and self.pos == 0:
         if not self.line:
             self.close()
         return
     # Delete utf-char-wise
     if self.fm.py3:
         left_part = self.line[:self.pos + mod]
         self.pos = len(left_part)
         self.line = left_part + self.line[self.pos + 1:]
     else:
         uc = uchars(self.line)
         upos = len(uchars(self.line[:self.pos])) + mod
         left_part = ''.join(uc[:upos])
         self.pos = len(left_part)
         self.line = left_part + ''.join(uc[upos + 1:])
     self.on_line_change()
Example #5
0
 def delete(self, mod):
     self.tab_deque = None
     if mod == -1 and self.pos == 0:
         if not self.line:
             self.close()
         return
         # Delete utf-char-wise
     if self.fm.py3:
         left_part = self.line[: self.pos + mod]
         self.pos = len(left_part)
         self.line = left_part + self.line[self.pos + 1 :]
     else:
         uc = uchars(self.line)
         upos = len(uchars(self.line[: self.pos])) + mod
         left_part = "".join(uc[:upos])
         self.pos = len(left_part)
         self.line = left_part + "".join(uc[upos + 1 :])
     self.on_line_change()