本文整理匯總了Python中prompt_toolkit.token.Token.LineNumber方法的典型用法代碼示例。如果您正苦於以下問題:Python Token.LineNumber方法的具體用法?Python Token.LineNumber怎麽用?Python Token.LineNumber使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類prompt_toolkit.token.Token
的用法示例。
在下文中一共展示了Token.LineNumber方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_margin
# 需要導入模塊: from prompt_toolkit.token import Token [as 別名]
# 或者: from prompt_toolkit.token.Token import LineNumber [as 別名]
def create_margin(self, cli, window_render_info, width, height):
# First line.
tokens = self.get_prompt_tokens(cli)[:]
# Next lines. (Show line numbering when numbering is enabled.)
if self.get_continuation_tokens:
tokens2 = self.get_continuation_tokens(cli, width)
else:
tokens2 = []
show_numbers = self.show_numbers(cli)
last_y = None
for y in window_render_info.displayed_lines[1:]:
tokens.append((Token, '\n'))
if show_numbers:
if y != last_y:
tokens.append((Token.LineNumber, ('%i ' % (y + 1)).rjust(width)))
else:
tokens.extend(tokens2)
last_y = y
return tokens
示例2: create_margin
# 需要導入模塊: from prompt_toolkit.token import Token [as 別名]
# 或者: from prompt_toolkit.token.Token import LineNumber [as 別名]
def create_margin(self, cli, window_render_info, width, height):
# First line.
tokens = self.get_prompt_tokens(cli)[:]
# Next lines. (Show line numbering when numbering is enabled.)
if self.get_continuation_tokens:
# Note: we turn this into a list, to make sure that we fail early
# in case `get_continuation_tokens` returns something else,
# like `None`.
tokens2 = list(self.get_continuation_tokens(cli, width))
else:
tokens2 = []
show_numbers = self.show_numbers(cli)
last_y = None
for y in window_render_info.displayed_lines[1:]:
tokens.append((Token, '\n'))
if show_numbers:
if y != last_y:
tokens.append((Token.LineNumber, ('%i ' % (y + 1)).rjust(width)))
else:
tokens.extend(tokens2)
last_y = y
return tokens