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