← Back
Editing: application.cpython-311.pyc
� �Ïc6� � �� � d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dl mZmZm Z m Z mZmZm Z d dlmZmZ d dlmZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) d dl*m+Z+ d dl,m-Z- d d l.m/Z/m0Z0 d d l1m2Z2m3Z3 d dl4m5Z5 d dl6m7Z7 d d l8m9Z9m:Z: d dl;m<Z<m=Z= d dl>m?Z?m@Z@mAZAmBZB d dlCmDZD d dlEmFZF d dlGmHZHmIZI d dlJmKZK d dlLmMZM d dlNmOZO d dlPmQZQmRZRmSZSmTZTmUZUmVZVmWZW d dlXmYZYmZZZ d dl[m\Z\ d dl]m^Z^ d dl_m`Z`maZa d dlbmcZcmdZd d dlemfZf d dlgmhZhmiZi d dljmkZkmlZl d dlmmnZnmoZo d d lpmqZq d d!lrmsZsmtZtmuZumvZvmwZwmxZxmyZymzZz d d"l{m|Z|m}Z} d#d$l~mZm�Z� d#d%l�m�Z�m�Z� d dl�Z�n# e�$ r d dl�m�c m�Z� Y nw xY wd&gZ�eYZ� e&d'� � Z�ed(gdf Z� e�ed)d� � Z� e�ed*d� � Z� G d+� d&ee� � � Z� G d,� d-eU� � Z�d.eDd/dfd0�Z�ed1eg df d/ed2 fd3�� � Z�dS )4� N)�AbstractEventLoop�Future�Task� ensure_future�new_event_loop�set_event_loop�sleep)� ExitStack�contextmanager)�Popen)� format_tb)�Any� Awaitable�Callable� Coroutine�Dict� FrozenSet� Generator�Generic�Hashable�Iterable�Iterator�List�Optional�Set�Tuple�Type�TypeVar�Union�cast�overload)�Buffer)�SimpleCache)� Clipboard�InMemoryClipboard)�AnyCursorShapeConfig�to_cursor_shape_config)�Size)�EditingMode)�get_traceback_from_context�run_in_executor_with_context)�call_soon_threadsafe�get_event_loop)� Condition�Filter�FilterOrBool� to_filter)�AnyFormattedText)�Input)� get_typeahead�store_typeahead)�load_page_navigation_bindings)�load_key_bindings)� EmacsState)�Binding�ConditionalKeyBindings�GlobalOnlyKeyBindings�KeyBindings�KeyBindingsBase� KeysTuple�merge_key_bindings)� KeyPressEvent�KeyProcessor)�ViState)�Keys)� Container�Window)� BufferControl� UIControl)�create_dummy_layout)�Layout�walk)� ColorDepth�Output)�Renderer�print_formatted_text)�SearchState)� BaseStyle� DummyStyle�DummyStyleTransformation�DynamicStyle�StyleTransformation�default_pygments_style�default_ui_style�merge_styles)�Event�in_main_thread� )�get_app_session�set_app)�in_terminal�run_in_terminal�Application� _AppResultzApplication[_AppResult]�SIGWINCH�SIGTSTPc 5 �j � e Zd ZdZdddddddddddej dddddddddddddfdee dee d e d ee dee dee d e deeeg eedf f df de dee de dede de deeedf deeedf dee dee deded ded ded ded dee d ee d!df4d"�Zd ed!efd#�Zed!efd$�� � Zed!efd%�� � Zed!efd&�� � Zd_d'�Zd_d(�Z ed!e fd)�� � Z!d`d*e d!dfd+�Z"d_d,�Z#d_d-�Z$d.e%d!dfd/�Z&d_d0�Z'dad1eeg df d!dfd2�Z( dbd1eeg df d3e d4e d5ed!e)f d6�Z* dcd1eeg df d3e d4e d7e d!e)f d8�Z+d9e,d:e-e.e/f d!dfd;�Z0e1d!e2d< fd=�� � Z3d>e%d?e%d!dfd@�Z4dAe5e/e/df d!dBfdC�Z6dddE�Z7d_dF�Z8d_dG�Z9d_dH�Z:e;d_dI�� � Z<e;dJdK�dLe)de.d!dfdM�� � Z<e;dJdK�dNee=e>e= f de.d!dfdO�� � Z< dedLee) dNeee=e>e= f de.d!dfdP�Z<d_dQ�Z? dfdSe.dTe dUe@dVe.d!df dW�ZAdgdXe d!dfdY�ZB dadZe@dee d!dfd[�ZCed!e fd\�� � ZDed!e fd]�� � ZEd!eFe. fd^�ZGdS )hr_ a' The main Application class! This glues everything together. :param layout: A :class:`~prompt_toolkit.layout.Layout` instance. :param key_bindings: :class:`~prompt_toolkit.key_binding.KeyBindingsBase` instance for the key bindings. :param clipboard: :class:`~prompt_toolkit.clipboard.Clipboard` to use. :param full_screen: When True, run the application on the alternate screen buffer. :param color_depth: Any :class:`~.ColorDepth` value, a callable that returns a :class:`~.ColorDepth` or `None` for default. :param erase_when_done: (bool) Clear the application output when it finishes. :param reverse_vi_search_direction: Normally, in Vi mode, a '/' searches forward and a '?' searches backward. In Readline mode, this is usually reversed. :param min_redraw_interval: Number of seconds to wait between redraws. Use this for applications where `invalidate` is called a lot. This could cause a lot of terminal output, which some terminals are not able to process. `None` means that every `invalidate` will be scheduled right away (which is usually fine). When one `invalidate` is called, but a scheduled redraw of a previous `invalidate` call has not been executed yet, nothing will happen in any case. :param max_render_postpone_time: When there is high CPU (a lot of other scheduled calls), postpone the rendering max x seconds. '0' means: don't postpone. '.5' means: try to draw at least twice a second. :param refresh_interval: Automatically invalidate the UI every so many seconds. When `None` (the default), only invalidate when `invalidate` has been called. :param terminal_size_polling_interval: Poll the terminal size every so many seconds. Useful if the applications runs in a thread other then then main thread where SIGWINCH can't be handled, or on Windows. Filters: :param mouse_support: (:class:`~prompt_toolkit.filters.Filter` or boolean). When True, enable mouse support. :param paste_mode: :class:`~prompt_toolkit.filters.Filter` or boolean. :param editing_mode: :class:`~prompt_toolkit.enums.EditingMode`. :param enable_page_navigation_bindings: When `True`, enable the page navigation key bindings. These include both Emacs and Vi bindings like page-up, page-down and so on to scroll through pages. Mostly useful for creating an editor or other full screen applications. Probably, you don't want this for the implementation of a REPL. By default, this is enabled if `full_screen` is set. Callbacks (all of these should accept an :class:`~prompt_toolkit.application.Application` object as input.) :param on_reset: Called during reset. :param on_invalidate: Called when the UI has been invalidated. :param before_render: Called right before rendering. :param after_render: Called right after rendering. I/O: (Note that the preferred way to change the input/output is by creating an `AppSession` with the required input/output objects. If you need multiple applications running at the same time, you have to create a separate `AppSession` using a `with create_app_session():` block. :param input: :class:`~prompt_toolkit.input.Input` instance. :param output: :class:`~prompt_toolkit.output.Output` instance. (Probably Vt100_Output or Win32Output.) Usage: app = Application(...) app.run() # Or await app.run_async() NTFg{�G�z�?� �?�layout�style�include_default_pygments_style�style_transformation�key_bindings� clipboard�full_screen�color_depth� mouse_support�enable_page_navigation_bindings� paste_mode�editing_mode�erase_when_done�reverse_vi_search_direction�min_redraw_interval�max_render_postpone_time�refresh_interval�terminal_size_polling_interval�cursor�on_resetz#ApplicationEventHandler[_AppResult]� on_invalidate� before_render�after_render�input�output�returnc �~ � � | �t � fd�� � } t |� � }t | � � } t |� � }t | � � } t |� � }|�t � � }|�t � � }|� _ |� _ |� _ t � � � _ t � � � _ |� _ |p t � � � _ |� _ |� _ | � _ |� _ |� _ | � _ |� _ | � _ |� _ |� _ |� _ |� _ t5 |� � � _ t9 � |� � � _ t9 � |� � � _ t9 � |� � � _ t9 � |� � � _ tC � � }|p|j"