本文整理汇总了Python中prompt_toolkit.layout.screen.Size方法的典型用法代码示例。如果您正苦于以下问题:Python screen.Size方法的具体用法?Python screen.Size怎么用?Python screen.Size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prompt_toolkit.layout.screen
的用法示例。
在下文中一共展示了screen.Size方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_size
# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Size [as 别名]
def get_size(self):
from prompt_toolkit.layout.screen import Size
info = self.get_win32_screen_buffer_info()
# We take the width of the *visible* region as the size. Not the width
# of the complete screen buffer. (Unless use_complete_width has been
# set.)
if self.use_complete_width:
width = info.dwSize.X
else:
width = info.srWindow.Right - info.srWindow.Left
height = info.srWindow.Bottom - info.srWindow.Top + 1
# We avoid the right margin, windows will wrap otherwise.
maxwidth = info.dwSize.X - 1
width = min(maxwidth, width)
# Create `Size` object.
return Size(rows=height, columns=width)
示例2: __init__
# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Size [as 别名]
def __init__(self, conn, addr, application, server, encoding):
assert isinstance(addr, tuple) # (addr, port) tuple
assert isinstance(application, TelnetApplication)
assert isinstance(server, TelnetServer)
assert isinstance(encoding, text_type) # e.g. 'utf-8'
self.conn = conn
self.addr = addr
self.application = application
self.closed = False
self.handling_command = True
self.server = server
self.encoding = encoding
self.callback = None # Function that handles the CLI result.
# Create "Output" object.
self.size = Size(rows=40, columns=79)
# Initialize.
_initialize_telnet(conn)
# Create output.
def get_size():
return self.size
self.stdout = _ConnectionStdout(conn, encoding=encoding)
self.vt100_output = Vt100_Output(self.stdout, get_size, write_binary=False)
# Create an eventloop (adaptor) for the CommandLineInterface.
self.eventloop = _TelnetEventLoopInterface(server)
# Set default CommandLineInterface.
self.set_application(create_prompt_application())
# Call client_connected
application.client_connected(self)
# Draw for the first time.
self.handling_command = False
self.cli._redraw()
示例3: get_size
# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Size [as 别名]
def get_size(self):
return Size(rows=40, columns=80)
示例4: from_pty
# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Size [as 别名]
def from_pty(cls, stdout, true_color=False, ansi_colors_only=None, term=None):
"""
Create an Output class from a pseudo terminal.
(This will take the dimensions by reading the pseudo
terminal attributes.)
"""
assert stdout.isatty()
def get_size():
rows, columns = _get_size(stdout.fileno())
# If terminal (incorrectly) reports its size as 0, pick a reasonable default.
# See https://github.com/ipython/ipython/issues/10071
return Size(rows=(rows or 24), columns=(columns or 80))
return cls(stdout, get_size, true_color=true_color,
ansi_colors_only=ansi_colors_only, term=term)
示例5: from_pty
# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Size [as 别名]
def from_pty(cls, stdout, true_color=False, ansi_colors_only=None, term=None):
"""
Create an Output class from a pseudo terminal.
(This will take the dimensions by reading the pseudo
terminal attributes.)
"""
assert stdout.isatty()
def get_size():
rows, columns = _get_size(stdout.fileno())
return Size(rows=rows, columns=columns)
return cls(stdout, get_size, true_color=true_color,
ansi_colors_only=ansi_colors_only, term=term)
示例6: from_pty
# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Size [as 别名]
def from_pty(cls, stdout, true_color=False, ansi_colors_only=None, term=None):
"""
Create an Output class from a pseudo terminal.
(This will take the dimensions by reading the pseudo
terminal attributes.)
"""
assert stdout.isatty()
def get_size():
rows, columns = _get_size(stdout.fileno())
return Size(rows=rows, columns=columns)
return cls(stdout, get_size, true_color=true_color,
ansi_colors_only=ansi_colors_only, term=term)
示例7: set_application
# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Size [as 别名]
def set_application(self, app, callback=None):
"""
Set ``CommandLineInterface`` instance for this connection.
(This can be replaced any time.)
:param cli: CommandLineInterface instance.
:param callback: Callable that takes the result of the CLI.
"""
assert isinstance(app, Application)
assert callback is None or callable(callback)
self.cli = CommandLineInterface(
application=app,
eventloop=self.eventloop,
output=self.vt100_output)
self.callback = callback
# Create a parser, and parser callbacks.
cb = self.cli.create_eventloop_callbacks()
inputstream = InputStream(cb.feed_key)
# Input decoder for stdin. (Required when working with multibyte
# characters, like chinese input.)
stdin_decoder_cls = getincrementaldecoder(self.encoding)
stdin_decoder = [stdin_decoder_cls()] # nonlocal
# Tell the CLI that it's running. We don't start it through the run()
# call, but will still want _redraw() to work.
self.cli._is_running = True
def data_received(data):
""" TelnetProtocolParser 'data_received' callback """
assert isinstance(data, binary_type)
try:
result = stdin_decoder[0].decode(data)
inputstream.feed(result)
except UnicodeDecodeError:
stdin_decoder[0] = stdin_decoder_cls()
return ''
def size_received(rows, columns):
""" TelnetProtocolParser 'size_received' callback """
self.size = Size(rows=rows, columns=columns)
cb.terminal_size_changed()
self.parser = TelnetProtocolParser(data_received, size_received)
示例8: __init__
# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Size [as 别名]
def __init__(self, conn, addr, interact, server, encoding, style):
assert isinstance(addr, tuple) # (addr, port) tuple
assert callable(interact)
assert isinstance(server, TelnetServer)
assert isinstance(encoding, text_type) # e.g. 'utf-8'
assert isinstance(style, BaseStyle)
self.conn = conn
self.addr = addr
self.interact = interact
self.server = server
self.encoding = encoding
self.style = style
self._closed = False
# Execution context.
self._context_id = None
# Create "Output" object.
self.size = Size(rows=40, columns=79)
# Initialize.
_initialize_telnet(conn)
# Create input.
self.vt100_input = PipeInput()
# Create output.
def get_size():
return self.size
self.stdout = _ConnectionStdout(conn, encoding=encoding)
self.vt100_output = Vt100_Output(
self.stdout, get_size, write_binary=False)
def data_received(data):
""" TelnetProtocolParser 'data_received' callback """
assert isinstance(data, binary_type)
self.vt100_input.send_bytes(data)
def size_received(rows, columns):
""" TelnetProtocolParser 'size_received' callback """
self.size = Size(rows=rows, columns=columns)
get_app()._on_resize()
self.parser = TelnetProtocolParser(data_received, size_received)