当前位置: 首页>>代码示例>>Python>>正文


Python History.modify方法代码示例

本文整理汇总了Python中ranger.container.history.History.modify方法的典型用法代码示例。如果您正苦于以下问题:Python History.modify方法的具体用法?Python History.modify怎么用?Python History.modify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ranger.container.history.History的用法示例。


在下文中一共展示了History.modify方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Console

# 需要导入模块: from ranger.container.history import History [as 别名]
# 或者: from ranger.container.history.History import modify [as 别名]

#.........这里部分代码省略.........
        if self.fm.py3:
            if len(unicode_buffer) >= 4:
                unicode_buffer = ""
            if ord(key) in range(0, 256):
                unicode_buffer += key
                try:
                    decoded = unicode_buffer.encode("latin-1").decode("utf-8")
                except UnicodeDecodeError:
                    return unicode_buffer, line, pos
                except UnicodeEncodeError:
                    return unicode_buffer, line, pos
                else:
                    unicode_buffer = ""
                    if pos == len(line):
                        line += decoded
                    else:
                        line = line[:pos] + decoded + line[pos:]
                    pos += len(decoded)
        else:
            if pos == len(line):
                line += key
            else:
                line = line[:pos] + key + line[pos:]
            pos += len(key)
        return unicode_buffer, line, pos

    def history_move(self, n):
        try:
            current = self.history.current()
        except HistoryEmptyException:
            pass
        else:
            if self.line != current and self.line != self.history.top():
                self.history.modify(self.line)
            if self.history_search_pattern:
                self.history.search(self.history_search_pattern, n)
            else:
                self.history.move(n)
            current = self.history.current()
            if self.line != current:
                self.line = self.history.current()
                self.pos = len(self.line)

    def add_to_history(self):
        self.history_backup.fast_forward()
        self.history_backup.add(self.line)
        self.history = History(self.history_backup)

    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:
                if self.fm.py3:
                    uc = list(self.line)
                    upos = len(self.line[:self.pos])
                else:
                    uc = list(self.line.decode('utf-8', 'ignore'))
                    upos = len(self.line[:self.pos].decode('utf-8', 'ignore'))
                newupos = direction.move(
开发者ID:Klinkenstecker,项目名称:ranger,代码行数:70,代码来源:console.py

示例2: Console

# 需要导入模块: from ranger.container.history import History [as 别名]
# 或者: from ranger.container.history.History import modify [as 别名]

#.........这里部分代码省略.........
        if self.fm.py3:
            if len(unicode_buffer) >= 4:
                unicode_buffer = ""
            if ord(key) in range(0, 256):
                unicode_buffer += key
                try:
                    decoded = unicode_buffer.encode("latin-1").decode("utf-8")
                except UnicodeDecodeError:
                    return unicode_buffer, line, pos
                except UnicodeEncodeError:
                    return unicode_buffer, line, pos
                else:
                    unicode_buffer = ""
                    if pos == len(line):
                        line += decoded
                    else:
                        line = line[:pos] + decoded + line[pos:]
                    pos += len(decoded)
        else:
            if pos == len(line):
                line += key
            else:
                line = line[:pos] + key + line[pos:]
            pos += len(key)
        return unicode_buffer, line, pos

    def history_move(self, n):
        try:
            current = self.history.current()
        except HistoryEmptyException:
            pass
        else:
            if self.line != current and self.line != self.history.top():
                self.history.modify(self.line)
            if self.history_search_pattern:
                self.history.search(self.history_search_pattern, n)
            else:
                self.history.move(n)
            current = self.history.current()
            if self.line != current:
                self.line = self.history.current()
                self.pos = len(self.line)

    def add_to_history(self):
        self.history_backup.fast_forward()
        self.history_backup.add(self.line)
        self.history = History(self.history_backup)

    def move(self, **keywords):
        direction = Direction(keywords)
        if direction.horizontal():
            # Ensure that the pointer is moved utf-char-wise
            if self.fm.py3:
                if self.question_queue:
                    umax = len(self.question_queue[0][0]) + 1 - self.wid
                else:
                    umax = len(self.line) + 1
                self.pos = direction.move(
                    direction=direction.right(),
                    minimum=0,
                    maximum=umax,
                    current=self.pos)
            else:
                if self.question_queue:
                    uchar = list(self.question_queue[0][0].decode('utf-8', 'ignore'))
                    upos = len(self.question_queue[0][0][:self.pos].decode('utf-8', 'ignore'))
开发者ID:ajtluser,项目名称:ranger,代码行数:70,代码来源:console.py

示例3: Console

# 需要导入模块: from ranger.container.history import History [as 别名]
# 或者: from ranger.container.history.History import modify [as 别名]

#.........这里部分代码省略.........

		if self.fm.py3:
			self.unicode_buffer += key
			try:
				decoded = self.unicode_buffer.encode("latin-1").decode("utf-8")
			except UnicodeDecodeError:
				return
			except UnicodeEncodeError:
				return
			else:
				self.unicode_buffer = ""
				if self.pos == len(self.line):
					self.line += decoded
				else:
					pos = self.pos
					self.line = self.line[:pos] + decoded + self.line[pos:]
				self.pos += len(decoded)
		else:
			if self.pos == len(self.line):
				self.line += key
			else:
				self.line = self.line[:self.pos] + key + self.line[self.pos:]
			self.pos += len(key)

		self.on_line_change()

	def history_move(self, n):
		try:
			current = self.history.current()
		except HistoryEmptyException:
			pass
		else:
			if self.line != current and self.line != self.history.top():
				self.history.modify(self.line)
			if self.history_search_pattern:
				self.history.search(self.history_search_pattern, n)
			else:
				self.history.move(n)
			current = self.history.current()
			if self.line != current:
				self.line = self.history.current()
				self.pos = len(self.line)

	def add_to_history(self):
		self.history_backup.fast_forward()
		self.history_backup.add(self.line)
		self.history = History(self.history_backup)

	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:
				if self.fm.py3:
					uc = list(self.line)
					upos = len(self.line[:self.pos])
				else:
					uc = list(self.line.decode('utf-8', 'ignore'))
					upos = len(self.line[:self.pos].decode('utf-8', 'ignore'))
				newupos = direction.move(
开发者ID:sharklasers,项目名称:livarp_0.3.9,代码行数:70,代码来源:console.py


注:本文中的ranger.container.history.History.modify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。