本文整理汇总了Python中prompt_toolkit.token.Token.Tilde方法的典型用法代码示例。如果您正苦于以下问题:Python Token.Tilde方法的具体用法?Python Token.Tilde怎么用?Python Token.Tilde使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prompt_toolkit.token.Token
的用法示例。
在下文中一共展示了Token.Tilde方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_margin
# 需要导入模块: from prompt_toolkit.token import Token [as 别名]
# 或者: from prompt_toolkit.token.Token import Tilde [as 别名]
def create_margin(self, cli, window_render_info, width, height):
relative = self.relative(cli)
token = Token.LineNumber
token_current = Token.LineNumber.Current
# Get current line number.
current_lineno = window_render_info.ui_content.cursor_position.y
# Construct margin.
result = []
last_lineno = None
for y, lineno in enumerate(window_render_info.displayed_lines):
# Only display line number if this line is not a continuation of the previous line.
if lineno != last_lineno:
if lineno is None:
pass
elif lineno == current_lineno:
# Current line.
if relative:
# Left align current number in relative mode.
result.append((token_current, '%i' % (lineno + 1)))
else:
result.append((token_current, ('%i ' % (lineno + 1)).rjust(width)))
else:
# Other lines.
if relative:
lineno = abs(lineno - current_lineno) - 1
result.append((token, ('%i ' % (lineno + 1)).rjust(width)))
last_lineno = lineno
result.append((Token, '\n'))
# Fill with tildes.
if self.display_tildes(cli):
while y < window_render_info.window_height:
result.append((Token.Tilde, '~\n'))
y += 1
return result