本文整理汇总了Python中prompt_toolkit.layout.screen.Point方法的典型用法代码示例。如果您正苦于以下问题:Python screen.Point方法的具体用法?Python screen.Point怎么用?Python screen.Point使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prompt_toolkit.layout.screen
的用法示例。
在下文中一共展示了screen.Point方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reset
# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Point [as 别名]
def reset(self, _scroll=False, leave_alternate_screen=True):
# Reset position
self._cursor_pos = Point(x=0, y=0)
# Remember the last screen instance between renderers. This way,
# we can create a `diff` between two screens and only output the
# difference. It's also to remember the last height. (To show for
# instance a toolbar at the bottom position.)
self._last_screen = None
self._last_size = None
self._last_style = None
# Default MouseHandlers. (Just empty.)
self.mouse_handlers = MouseHandlers()
#: Space from the top of the layout, until the bottom of the terminal.
#: We don't know this until a `report_absolute_cursor_row` call.
self._min_available_height = 0
# In case of Windown, also make sure to scroll to the current cursor
# position. (Only when rendering the first time.)
if is_windows() and _scroll:
self.output.scroll_buffer_to_prompt()
# Quit alternate screen.
if self._in_alternate_screen and leave_alternate_screen:
self.output.quit_alternate_screen()
self._in_alternate_screen = False
# Disable mouse support.
if self._mouse_support_enabled:
self.output.disable_mouse_support()
self._mouse_support_enabled = False
# Disable bracketed paste.
if self._bracketed_paste_enabled:
self.output.disable_bracketed_paste()
self._bracketed_paste_enabled = False
# Flush output. `disable_mouse_support` needs to write to stdout.
self.output.flush()
示例2: reset
# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Point [as 别名]
def reset(self, _scroll=False, leave_alternate_screen=True):
# Reset position
self._cursor_pos = Point(x=0, y=0)
# Remember the last screen instance between renderers. This way,
# we can create a `diff` between two screens and only output the
# difference. It's also to remember the last height. (To show for
# instance a toolbar at the bottom position.)
self._last_screen = None
self._last_size = None
self._last_token = None
# When the style hash changes, we have to do a full redraw as well as
# clear the `_attrs_for_token` dictionary.
self._last_style_hash = None
self._attrs_for_token = None
# Default MouseHandlers. (Just empty.)
self.mouse_handlers = MouseHandlers()
# Remember the last title. Only set the title when it changes.
self._last_title = None
#: Space from the top of the layout, until the bottom of the terminal.
#: We don't know this until a `report_absolute_cursor_row` call.
self._min_available_height = 0
# In case of Windown, also make sure to scroll to the current cursor
# position. (Only when rendering the first time.)
if is_windows() and _scroll:
self.output.scroll_buffer_to_prompt()
# Quit alternate screen.
if self._in_alternate_screen and leave_alternate_screen:
self.output.quit_alternate_screen()
self._in_alternate_screen = False
# Disable mouse support.
if self._mouse_support_enabled:
self.output.disable_mouse_support()
self._mouse_support_enabled = False
# Disable bracketed paste.
if self._bracketed_paste_enabled:
self.output.disable_bracketed_paste()
self._bracketed_paste_enabled = False
# Flush output. `disable_mouse_support` needs to write to stdout.
self.output.flush()
示例3: reset
# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Point [as 别名]
def reset(self, _scroll=False, leave_alternate_screen=True):
# Reset position
self._cursor_pos = Point(x=0, y=0)
# Remember the last screen instance between renderers. This way,
# we can create a `diff` between two screens and only output the
# difference. It's also to remember the last height. (To show for
# instance a toolbar at the bottom position.)
self._last_screen = None
self._last_size = None
self._last_char = None
# When the style hash changes, we have to do a full redraw as well as
# clear the `_attrs_for_token` dictionary.
self._last_style_hash = None
self._attrs_for_token = None
# Default MouseHandlers. (Just empty.)
self.mouse_handlers = MouseHandlers()
# Remember the last title. Only set the title when it changes.
self._last_title = None
#: Space from the top of the layout, until the bottom of the terminal.
#: We don't know this until a `report_absolute_cursor_row` call.
self._min_available_height = 0
# In case of Windown, also make sure to scroll to the current cursor
# position. (Only when rendering the first time.)
if is_windows() and _scroll:
self.output.scroll_buffer_to_prompt()
# Quit alternate screen.
if self._in_alternate_screen and leave_alternate_screen:
self.output.quit_alternate_screen()
self._in_alternate_screen = False
# Disable mouse support.
if self._mouse_support_enabled:
self.output.disable_mouse_support()
self._mouse_support_enabled = False
# Disable bracketed paste.
if self._bracketed_paste_enabled:
self.output.disable_bracketed_paste()
self._bracketed_paste_enabled = False
# Flush output. `disable_mouse_support` needs to write to stdout.
self.output.flush()
示例4: create_content
# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Point [as 别名]
def create_content(self, width, height):
# Report dimensions to the process.
self.process.set_size(width, height)
# The first time that this user control is rendered. Keep track of the
# 'app' object and start the process.
if not self._running:
self.process.start()
self._running = True
if not self.process.screen:
return UIContent()
pt_screen = self.process.screen.pt_screen
data_buffer = pt_screen.data_buffer
cursor_y = pt_screen.cursor_position.y
cursor_x = pt_screen.cursor_position.x
def get_line(number):
row = data_buffer[number]
empty = True
if row:
max_column = max(row)
empty = False
else:
max_column = 0
if number == cursor_y:
max_column = max(max_column, cursor_x)
empty = False
if empty:
return [('', ' ')]
else:
cells = [row[i] for i in range(max_column + 1)]
return [(cell.style, cell.char) for cell in cells]
if data_buffer:
line_count = max(data_buffer) + 1 # TODO: substract all empty lines from the beginning. (If we need to. Not sure.)
else:
line_count = 1
return UIContent(
get_line, line_count=line_count,
cursor_position=Point(
x=pt_screen.cursor_position.x,
y=pt_screen.cursor_position.y))