本文整理汇总了Python中ranger.container.history.History.top方法的典型用法代码示例。如果您正苦于以下问题:Python History.top方法的具体用法?Python History.top怎么用?Python History.top使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ranger.container.history.History
的用法示例。
在下文中一共展示了History.top方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Console
# 需要导入模块: from ranger.container.history import History [as 别名]
# 或者: from ranger.container.history.History import top [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'))
示例2: Console
# 需要导入模块: from ranger.container.history import History [as 别名]
# 或者: from ranger.container.history.History import top [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'))
示例3: Console
# 需要导入模块: from ranger.container.history import History [as 别名]
# 或者: from ranger.container.history.History import top [as 别名]
#.........这里部分代码省略.........
return
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'))