本文整理匯總了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